|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V3 1/2] xen, libxc: Fine grained control of REP emulation optimizations
Previously, if vm_event emulation support was enabled, then REP
optimizations were disabled when emulating REP-compatible
instructions. This patch allows fine-tuning of this behaviour by
providing a dedicated libxc helper function.
Signed-off-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
Changes since V2:
- Now only checking ->arch.mem_access_emulate_each_rep in
hvmemul_virtual_to_linear() (previously was also checking
->arch.mem_access_emulate_enabled.
- Disabling ->arch.mem_access_emulate_enabled when monitoring
is disabled.
- Changed the if()s in vm_event_resume() to a switch().
- Added Ian Campbell's ack.
---
tools/libxc/include/xenctrl.h | 12 ++++++++++++
tools/libxc/xc_monitor.c | 13 +++++++++++++
xen/arch/x86/hvm/emulate.c | 2 +-
xen/arch/x86/monitor.c | 7 ++++++-
xen/arch/x86/vm_event.c | 2 ++
xen/include/asm-x86/domain.h | 1 +
xen/include/public/domctl.h | 1 +
7 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 3482544..3bfa00b 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2428,6 +2428,18 @@ int xc_monitor_software_breakpoint(xc_interface *xch,
domid_t domain_id,
int xc_monitor_guest_request(xc_interface *xch, domid_t domain_id,
bool enable, bool sync);
+/**
+ * This function enables / disables emulation for each REP for a
+ * REP-compatible instruction.
+ *
+ * @parm xch a handle to an open hypervisor interface.
+ * @parm domain_id the domain id one wants to get the node affinity of.
+ * @parm enable if 0 optimize when possible, else emulate each REP.
+ * @return 0 on success, -1 on failure.
+ */
+int xc_monitor_emulate_each_rep(xc_interface *xch, domid_t domain_id,
+ bool enable);
+
/***
* Memory sharing operations.
*
diff --git a/tools/libxc/xc_monitor.c b/tools/libxc/xc_monitor.c
index 065669c..b1705dd 100644
--- a/tools/libxc/xc_monitor.c
+++ b/tools/libxc/xc_monitor.c
@@ -143,3 +143,16 @@ int xc_monitor_guest_request(xc_interface *xch, domid_t
domain_id, bool enable,
return do_domctl(xch, &domctl);
}
+
+int xc_monitor_emulate_each_rep(xc_interface *xch, domid_t domain_id,
+ bool enable)
+{
+ DECLARE_DOMCTL;
+
+ domctl.cmd = XEN_DOMCTL_monitor_op;
+ domctl.domain = domain_id;
+ domctl.u.monitor_op.op = XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP;
+ domctl.u.monitor_op.event = enable;
+
+ return do_domctl(xch, &domctl);
+}
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 5934c72..39774b7 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -514,7 +514,7 @@ static int hvmemul_virtual_to_linear(
* being triggered for repeated writes to a whole page.
*/
*reps = min_t(unsigned long, *reps,
- unlikely(current->domain->arch.mem_access_emulate_enabled)
+ unlikely(current->domain->arch.mem_access_emulate_each_rep)
? 1 : 4096);
reg = hvmemul_get_seg_reg(seg, hvmemul_ctxt);
diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
index 3d52135..7611f7b 100644
--- a/xen/arch/x86/monitor.c
+++ b/xen/arch/x86/monitor.c
@@ -73,10 +73,15 @@ int monitor_domctl(struct domain *d, struct
xen_domctl_monitor_op *mop)
if ( rc )
return rc;
- if ( mop->op == XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES )
+ switch ( mop->op )
{
+ case XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES:
mop->event = capabilities;
return 0;
+
+ case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP:
+ d->arch.mem_access_emulate_each_rep = !!mop->event;
+ return 0;
}
/*
diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c
index e4e0aa4..c38d37b 100644
--- a/xen/arch/x86/vm_event.c
+++ b/xen/arch/x86/vm_event.c
@@ -54,6 +54,8 @@ void vm_event_cleanup_domain(struct domain *d)
xfree(v->arch.vm_event);
v->arch.vm_event = NULL;
}
+
+ d->arch.mem_access_emulate_each_rep = 0;
}
void vm_event_toggle_singlestep(struct domain *d, struct vcpu *v)
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index f0aeade..f1d7ed6 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -386,6 +386,7 @@ struct arch_domain
/* Mem_access emulation control */
bool_t mem_access_emulate_enabled;
+ bool_t mem_access_emulate_each_rep;
} __cacheline_aligned;
#define has_arch_pdevs(d) (!list_empty(&(d)->arch.pdev_list))
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 794d4d5..ae241f2 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -1007,6 +1007,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cmt_op_t);
#define XEN_DOMCTL_MONITOR_OP_ENABLE 0
#define XEN_DOMCTL_MONITOR_OP_DISABLE 1
#define XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES 2
+#define XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP 3
#define XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG 0
#define XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR 1
--
1.7.9.5
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |