vm_event: Allow subscribing to write events for specific MSR-s
PATCH v3 1/1 vm_event: Allow subscribing to write events for specific MSR-s
Previously, subscribing to MSR write events was an all-or-none approach, with special cases for introspection MSR-s. This patch allows the vm_event consumer to specify exactly what MSR-s it is interested in, and as a side-effect gets rid of the vmx_introspection_force_enabled_msrs[] special case. This replaces the previously posted "xen: Filter out MSR write events" patch.
---
Changes since V2:
- Bumped XEN_DOMCTL_INTERFACE_VERSION.
- Introduced struct monitor_msr_bitmap as recommended by Andrew Cooper, which allowed removing some pointer arithmetic magic.
- Removed arch_ prefix from monitor functions, as recommended by Tamas Lengyel.
- Replaced the page allocation code with xzalloc() / xfree() for struct monitor_msr_bitmap.
- Now returning -ENXIO instead of -EINVAL from the monitor functions, as recommended by Konrad Rzeszutek Wilk.
--- tools/libxc/include/xenctrl.h | 4 +- tools/libxc/xc_monitor.c | 6 +-- xen/arch/x86/hvm/event.c | 3 +- xen/arch/x86/hvm/hvm.c | 3 +- xen/arch/x86/hvm/vmx/vmcs.c | 26 ++--------- xen/arch/x86/hvm/vmx/vmx.c | 10 ++-- xen/arch/x86/monitor.c | 95 +++++++++++++++++++++++++++++++++----- xen/arch/x86/vm_event.c | 9 ++++ xen/include/asm-x86/domain.h | 4 +- xen/include/asm-x86/hvm/hvm.h | 8 ++-- xen/include/asm-x86/hvm/vmx/vmcs.h | 7 --- xen/include/asm-x86/monitor.h | 8 ++++ xen/include/public/domctl.h | 5 +- 13 files changed, 121 insertions(+), 67 deletions(-)
tools/libxc/include/xenctrl.h +2 -2
@@ -2183,8 +2183,8 @@ int xc_monitor_get_capabilities(xc_interface *xch, domid_t domain_id,int xc_monitor_write_ctrlreg (xc_interface *xch,domid_t domain_id,uint16_t index,bool enable,bool sync,bool onchangeonly); -int xc_monitor_mov_to_msr (xc_interface *xch,domid_t domain_id,bool enable, -bool extended_capture); +int xc_monitor_mov_to_msr (xc_interface *xch,domid_t domain_id,uint32_t msr, +bool enable);int xc_monitor_singlestep (xc_interface *xch,domid_t domain_id,bool enable);int xc_monitor_software_breakpoint (xc_interface *xch,domid_t domain_id,bool enable);
tools/libxc/xc_monitor.c +3 -3
@@ -86,8 +86,8 @@ int xc_monitor_write_ctrlreg(xc_interface *xch, domid_t domain_id,return do_domctl (xch, &domctl); } -int xc_monitor_mov_to_msr (xc_interface *xch,domid_t domain_id,bool enable, -bool extended_capture) +int xc_monitor_mov_to_msr (xc_interface *xch,domid_t domain_id,uint32_t msr, +bool enable) {DECLARE_DOMCTL ;
@@ -96,7 +96,7 @@ int xc_monitor_mov_to_msr(xc_interface *xch, domid_t domain_id, bool enable, domctl.u.monitor_op.op = enable ?XEN_DOMCTL_MONITOR_OP_ENABLE :XEN_DOMCTL_MONITOR_OP_DISABLE ; domctl.u.monitor_op.event =XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR ; - domctl.u.monitor_op.u.mov_to_msr.extended_capture = extended_capture; + domctl.u.monitor_op.u.mov_to_msr.msr = msr;return do_domctl (xch, &domctl); }
xen/arch/x86/hvm/event.c +1 -2
@@ -57,9 +57,8 @@ bool_t hvm_event_cr(unsigned int index, unsigned long value, unsigned long old)void hvm_event_msr (unsigned int msr,uint64_t value) {struct vcpu *curr = current; -struct arch_domain *ad = &curr->domain->arch; -if ( ad->monitor.mov_to_msr_enabled ) +if (monitor_is_msr_enabled (curr->domain, msr) ) {vm_event_request_t req = { .reason = VM_EVENT_REASON_MOV_TO_MSR,
xen/arch/x86/hvm/hvm.c +1 -2
@@ -3695,7 +3695,6 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content,bool_t mtrr;unsigned int edx, index;int ret =X86EMUL_OKAY ; -struct arch_domain *currad = ¤t->domain->arch;HVMTRACE_3D (MSR_WRITE , msr, (uint32_t )msr_content, (uint32_t )(msr_content >>32 ));
@@ -3703,7 +3702,7 @@ int hvm_msr_write_intercept(unsigned int msr, uint64_t msr_content,hvm_cpuid (1 ,NULL ,NULL ,NULL , &edx); mtrr = !!(edx &cpufeat_mask (X86_FEATURE_MTRR )); -if ( may_defer &&unlikely (currad->monitor.mov_to_msr_enabled) ) +if ( may_defer &&unlikely (monitor_is_msr_enabled (v->domain, msr)) ) {ASSERT (v->arch.vm_event);
xen/arch/x86/hvm/vmx/vmcs.c +3 -23
@@ -37,6 +37,7 @@#include <asm/hvm/vmx/vvmx.h> #include <asm/hvm/vmx/vmcs.h> #include <asm/flushtlb.h> +#include <asm/monitor.h> #include <asm/shadow.h> #include <asm/tboot.h> #include <asm/apic.h>
@@ -108,18 +109,6 @@ u64 vmx_ept_vpid_cap __read_mostly;u64 vmx_vmfunc__read_mostly ;bool_t vmx_virt_exception__read_mostly ; -const u32 vmx_introspection_force_enabled_msrs[] = { -MSR_IA32_SYSENTER_EIP , -MSR_IA32_SYSENTER_ESP , -MSR_IA32_SYSENTER_CS , -MSR_IA32_MC0_CTL , -MSR_STAR , -MSR_LSTAR -}; - -const unsigned int vmx_introspection_force_enabled_msrs_size = -ARRAY_SIZE (vmx_introspection_force_enabled_msrs); - static DEFINE_PER_CPU_READ_MOSTLY(paddr_t, vmxon_region); static DEFINE_PER_CPU(paddr_t, current_vmcs); static DEFINE_PER_CPU(struct list_head, active_vmcs_list);
@@ -810,17 +799,8 @@ void vmx_disable_intercept_for_msr(struct vcpu *v, u32 msr, int type)if ( msr_bitmap ==NULL )return ; -if (unlikely (d->arch.monitor.mov_to_msr_enabled && - d->arch.monitor.mov_to_msr_extended) && -vm_event_check_ring (&d->vm_event->monitor) ) - { -unsigned int i; - -/* Filter out MSR-s needed for memory introspection */ -for ( i =0 ; i < vmx_introspection_force_enabled_msrs_size; i++ ) -if ( msr == vmx_introspection_force_enabled_msrs[i] ) -return ; - } +if (unlikely (monitor_is_msr_enabled (d, msr)) ) +return ;/* * See Intel PRM Vol. 3, 20.6.9 (MSR-Bitmap Address). Early manuals
xen/arch/x86/hvm/vmx/vmx.c +3 -7
@@ -1958,16 +1958,12 @@ void vmx_hypervisor_cpuid_leaf(uint32_t sub_idx, *eax |=XEN_HVM_CPUID_X2APIC_VIRT ; } -static void vmx_enable_msr_exit_interception (struct domain *d) +static void vmx_enable_msr_interception (struct domain *d,uint32_t msr) {struct vcpu *v; -unsigned int i; -/* Enable interception for MSRs needed for memory introspection. */ for_each_vcpu ( d, v ) -for ( i =0 ; i < vmx_introspection_force_enabled_msrs_size; i++ ) -vmx_enable_intercept_for_msr (v, vmx_introspection_force_enabled_msrs[i], -MSR_TYPE_W ); +vmx_enable_intercept_for_msr (v, msr,MSR_TYPE_W ); }static bool_t vmx_is_singlestep_supported (void )
@@ -2166,7 +2162,7 @@ static struct hvm_function_table __initdata vmx_function_table = { .handle_eoi = vmx_handle_eoi, .nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m, .hypervisor_cpuid_leaf = vmx_hypervisor_cpuid_leaf, - .enable_msr_exit_interception = vmx_enable_msr_exit_interception, + .enable_msr_interception = vmx_enable_msr_interception, .is_singlestep_supported = vmx_is_singlestep_supported, .set_mode = vmx_set_mode, .altp2m_vcpu_update_p2m = vmx_vcpu_update_eptp,
xen/arch/x86/monitor.c +83 -12
114 lines not on this page · raw message
xen/arch/x86/vm_event.c +9 -0
@@ -20,6 +20,7 @@#include <xen/sched.h> #include <asm/hvm/hvm.h> +#include <asm/monitor.h> #include <asm/vm_event.h> /* Implicitly serialized by the domctl lock. */
@@ -27,6 +28,11 @@ int vm_event_init_domain(struct domain *d) {struct vcpu *v; + d->arch.monitor_msr_bitmap = xzalloc(struct monitor_msr_bitmap); + +if ( !d->arch.monitor_msr_bitmap ) +return -ENOMEM ; + for_each_vcpu ( d, v ) {if ( v->arch.vm_event )
@@ -55,6 +61,9 @@ void vm_event_cleanup_domain(struct domain *d) v->arch.vm_event =NULL ; } +xfree (d->arch.monitor_msr_bitmap); + d->arch.monitor_msr_bitmap =NULL ; + d->arch.mem_access_emulate_each_rep =0 ;memset (&d->arch.monitor,0 ,sizeof (d->arch.monitor));memset (&d->monitor,0 ,sizeof (d->monitor));
xen/include/asm-x86/domain.h +2 -2
@@ -398,12 +398,12 @@ struct arch_domain unsigned int write_ctrlreg_enabled : 4; unsigned int write_ctrlreg_sync : 4; unsigned int write_ctrlreg_onchangeonly : 4; - unsigned int mov_to_msr_enabled : 1; - unsigned int mov_to_msr_extended : 1; unsigned int singlestep_enabled : 1; unsigned int software_breakpoint_enabled : 1; } monitor; +struct monitor_msr_bitmap *monitor_msr_bitmap; +/* Mem_access emulation control */ bool_t mem_access_emulate_each_rep;
xen/include/asm-x86/hvm/hvm.h +4 -4
@@ -211,7 +211,7 @@ struct hvm_function_table { uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); -void (*enable_msr_exit_interception)(struct domain *d); +void (*enable_msr_interception)(struct domain *d,uint32_t msr);bool_t (*is_singlestep_supported)(void);int (*set_mode)(struct vcpu *v,int mode);
@@ -565,11 +565,11 @@ static inline enum hvm_intblk nhvm_interrupt_blocked(struct vcpu *v)return hvm_funcs.nhvm_intr_blocked (v); } -static inline bool_t hvm_enable_msr_exit_interception (struct domain *d) +static inline bool_t hvm_enable_msr_interception (struct domain *d,uint32_t msr) { -if ( hvm_funcs.enable_msr_exit_interception ) +if ( hvm_funcs.enable_msr_interception ) { - hvm_funcs.enable_msr_exit_interception (d); + hvm_funcs.enable_msr_interception (d, msr);return 1 ; }
xen/include/asm-x86/hvm/vmx/vmcs.h +0 -7
@@ -562,13 +562,6 @@ enum vmcs_field { HOST_RIP = 0x00006c16, }; -/* -* A set of MSR-s that need to be enabled for memory introspection -* to work. -*/ -extern const u32 vmx_introspection_force_enabled_msrs[]; -extern const unsigned int vmx_introspection_force_enabled_msrs_size; -#define VMCS_VPID_WIDTH 16#define MSR_TYPE_R 1
xen/include/asm-x86/monitor.h +8 -0
@@ -29,6 +29,12 @@#define monitor_ctrlreg_bitmask (ctrlreg_index) (1U << (ctrlreg_index)) +struct monitor_msr_bitmap { +uint8_t low[1024 ]; +uint8_t hypervisor[1024 ]; +uint8_t high[1024 ]; +}; +static inline int arch_monitor_domctl_op (struct domain *d,struct xen_domctl_monitor_op *mop) {
@@ -50,4 +56,6 @@ int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)int arch_monitor_domctl_event (struct domain *d,struct xen_domctl_monitor_op *mop); +bool_t monitor_is_msr_enabled (const struct domain *d,u32 msr); +#endif /* __ASM_X86_MONITOR_H__ */
xen/include/public/domctl.h +2 -3
@@ -37,7 +37,7 @@#include "hvm/save.h" #include "memory.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000b +#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000c/* * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
@@ -1107,8 +1107,7 @@ struct xen_domctl_monitor_op { } mov_to_cr;struct { -/* Enable the capture of an extended set of MSRs */ -uint8_t extended_capture; +uint32_t msr; } mov_to_msr;struct {
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 21 lines · Razvan Cojocaru
Previously, subscribing to MSR write events was an all-or-none approach, with special cases for introspection MSR-s. This patch allows the
vm_eventconsumer to specify exactly what MSR-s it is interested in, and as a side-effect gets rid of the vmx_introspection_force_enabled_msrs[] special case. This replaces the previously posted "xen: Filter out MSR write events" patch.Signed-off-by Razvan Cojocaru <[email protected]>---
Changes since V2:
- BumpedXEN_DOMCTL_INTERFACE_VERSION.
- Introduced structmonitor_msr_bitmapas recommended by Andrew Cooper, which allowed removing some pointer arithmetic magic.
- Removedarch_prefix from monitor functions, as recommended by Tamas Lengyel.
- Replaced the page allocation code withxzalloc()/xfree()for structmonitor_msr_bitmap.
- Now returning-ENXIOinstead of-EINVALfrom the monitor functions, as recommended by Konrad Rzeszutek Wilk.
Quoted 3 lines
--- tools/libxc/include/xenctrl.h | 4 +- tools/libxc/xc_monitor.c | 6 +--
Subject to an ack from hypervisor maintainer:
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
xen/arch/x86/monitor.c line 41
Quoted 5 lines · Razvan Cojocaru
xen/arch/x86/monitor.c +5
-0+else if ( (msr >=0x80000000 ) && (msr <=0x80001fff ) ) + { + msr &=0x1fff ; +__set_bit (msr, &d->arch.monitor_msr_bitmap->high); + }
This of course should be 0xc0000000 and 0xc0001fff. Sorry for the typo. Will fix it in V4 (but waiting for other comments in the meantime).
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 44 lines · Razvan Cojocaru
Previously, subscribing to MSR write events was an all-or-none approach, with special cases for introspection MSR-s. This patch allows the
vm_eventconsumer to specify exactly what MSR-s it is interested in, and as a side-effect gets rid of the vmx_introspection_force_enabled_msrs[] special case. This replaces the previously posted "xen: Filter out MSR write events" patch.Signed-off-by Razvan Cojocaru <[email protected]>---
Changes since V2:
- BumpedXEN_DOMCTL_INTERFACE_VERSION.
- Introduced structmonitor_msr_bitmapas recommended by Andrew Cooper, which allowed removing some pointer arithmetic magic.
- Removedarch_prefix from monitor functions, as recommended by Tamas Lengyel.
- Replaced the page allocation code withxzalloc()/xfree()for structmonitor_msr_bitmap.
- Now returning-ENXIOinstead of-EINVALfrom the monitor functions, as recommended by Konrad Rzeszutek Wilk.--- tools/libxc/include/xenctrl.h | 4 +- tools/libxc/xc_monitor.c | 6 +-- xen/arch/x86/hvm/event.c | 3 +- xen/arch/x86/hvm/hvm.c | 3 +- xen/arch/x86/hvm/vmx/vmcs.c | 26 ++--------- xen/arch/x86/hvm/vmx/vmx.c | 10 ++-- xen/arch/x86/monitor.c | 95 +++++++++++++++++++++++++++++++++----- xen/arch/x86/vm_event.c | 9 ++++ xen/include/asm-x86/domain.h | 4 +- xen/include/asm-x86/hvm/hvm.h | 8 ++-- xen/include/asm-x86/hvm/vmx/vmcs.h | 7 --- xen/include/asm-x86/monitor.h | 8 ++++ xen/include/public/domctl.h | 5 +- 13 files changed, 121 insertions(+), 67 deletions(-)tools/libxc/include/xenctrl.h +0
-0
tools/libxc/include/xenctrl.h int xc_monitor_get_capabilities(xc_interface *xch, · line 2190
Quoted 10 lines
tools/libxc/include/xenctrl.h +2
-2@@ -2183,8 +2183,8 @@ int xc_monitor_get_capabilities(xc_interface *xch,domid_t domain_id, int xc_monitor_write_ctrlreg(xc_interface *xch, domid_t domain_id,uint16_t index,bool enable,bool sync,bool onchangeonly); -int xc_monitor_mov_to_msr (xc_interface *xch,domid_t domain_id,bool enable, -bool extended_capture); +int xc_monitor_mov_to_msr (xc_interface *xch,domid_t domain_id,uint32_t msr, +bool enable);
So my only concern with this approach here is that the MSR index definitions that are supposed to be passed are never exported via a public header, are only defined in asm-x86/msr-index.h. Should that also be moved to be a public header as part of this patch?
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 62 lines · Tamas K Lengyel
On Fri, Apr 15, 2016 at 3:02 AM, Razvan Cojocaru <[email protected] <mailto:[email protected]>> wrote:
Previously, subscribing to MSR write events was an all-or-none approach, with special cases for introspection MSR-s. This patch allows the
vm_eventconsumer to specify exactly what MSR-s it is interested in, and as a side-effect gets rid of the vmx_introspection_force_enabled_msrs[] special case. This replaces the previously posted "xen: Filter out MSR write events" patch.Signed-off-by Razvan Cojocaru <[email protected]<mailto:[email protected]>>
---
Changes since V2:
- BumpedXEN_DOMCTL_INTERFACE_VERSION.
- Introduced structmonitor_msr_bitmapas recommended by Andrew Cooper, which allowed removing some pointer arithmetic magic.
- Removedarch_prefix from monitor functions, as recommended by Tamas Lengyel.
- Replaced the page allocation code withxzalloc()/xfree()for structmonitor_msr_bitmap.
- Now returning-ENXIOinstead of-EINVALfrom the monitor functions, as recommended by Konrad Rzeszutek Wilk.
---
tools/libxc/include/xenctrl.h| 4 +-
tools/libxc/xc_monitor.c| 6 +--
xen/arch/x86/hvm/event.c| 3 +-
xen/arch/x86/hvm/hvm.c| 3 +-
xen/arch/x86/hvm/vmx/vmcs.c| 26 ++---------
xen/arch/x86/hvm/vmx/vmx.c| 10 ++--
xen/arch/x86/monitor.c| 95
+++++++++++++++++++++++++++++++++-----
xen/arch/x86/vm_event.c| 9 ++++
xen/include/asm-x86/domain.h| 4 +-
xen/include/asm-x86/hvm/hvm.h| 8 ++--
xen/include/asm-x86/hvm/vmx/vmcs.h| 7 ---
xen/include/asm-x86/monitor.h| 8 ++++
xen/include/public/domctl.h| 5 +-
13 files changed, 121 insertions(+), 67 deletions(-)diff --git
a/tools/libxc/include/xenctrl.hb/tools/libxc/include/xenctrl.h
index f5a034a..9698d46 100644
---a/tools/libxc/include/xenctrl.h
+++b/tools/libxc/include/xenctrl.h
@@ -2183,8 +2183,8 @@ int xc_monitor_get_capabilities(xc_interface *xch,domid_tdomain_id,
int xc_monitor_write_ctrlreg(xc_interface *xch,domid_tdomain_id,
uint16_tindex, bool enable, bool sync, bool onchangeonly);
-int xc_monitor_mov_to_msr(xc_interface *xch,domid_tdomain_id, bool enable,
- boolextended_capture);
+int xc_monitor_mov_to_msr(xc_interface *xch,domid_tdomain_id,uint32_tmsr,
+ bool enable);
Quoted 4 lines
So my only concern with this approach here is that the MSR index definitions that are supposed to be passed are never exported via a public header, are only defined in
asm-x86/msr-index.h. Should that also be moved to be a public header as part of this patch?
The MSRs are specified by the Intel/AMD manuals. Furthermore, for the non-architectural ones, it is quite possible that the same index maps to different MSRs on different hardware. It is definitely the case that different hadware has the same MSR at different indices. (The Intel cpuid masking MSRs have this propery across different CPU generations).
I expect the monitoring application to know the current hardware, and which MSRs are applicable.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 75 lines · Andrew Cooper
On 15/04/16 18:12, Tamas K Lengyel wrote:
Quoted 45 lines · On Fri, Apr 15, 2016 at 3:02 AM, Razvan Cojocaru <…
Previously, subscribing to MSR write events was an all-or-none approach, with special cases for introspection MSR-s. This patch allows the
vm_eventconsumer to specify exactly what MSR-s it is interested in, and as a side-effect gets rid of the vmx_introspection_force_enabled_msrs[] special case. This replaces the previously posted "xen: Filter out MSR write events" patch.Signed-off-by Razvan Cojocaru < <[email protected]>---
Changes since V2:
- BumpedXEN_DOMCTL_INTERFACE_VERSION.
- Introduced structmonitor_msr_bitmapas recommended by Andrew Cooper, which allowed removing some pointer arithmetic magic.
- Removedarch_prefix from monitor functions, as recommended by Tamas Lengyel.
- Replaced the page allocation code withxzalloc()/xfree()for structmonitor_msr_bitmap.
- Now returning-ENXIOinstead of-EINVALfrom the monitor functions, as recommended by Konrad Rzeszutek Wilk.--- tools/libxc/include/xenctrl.h | 4 +- tools/libxc/xc_monitor.c | 6 +-- xen/arch/x86/hvm/event.c | 3 +- xen/arch/x86/hvm/hvm.c | 3 +- xen/arch/x86/hvm/vmx/vmcs.c | 26 ++--------- xen/arch/x86/hvm/vmx/vmx.c | 10 ++-- xen/arch/x86/monitor.c | 95 +++++++++++++++++++++++++++++++++----- xen/arch/x86/vm_event.c | 9 ++++ xen/include/asm-x86/domain.h | 4 +- xen/include/asm-x86/hvm/hvm.h | 8 ++-- xen/include/asm-x86/hvm/vmx/vmcs.h | 7 --- xen/include/asm-x86/monitor.h | 8 ++++ xen/include/public/domctl.h | 5 +- 13 files changed, 121 insertions(+), 67 deletions(-)tools/libxc/include/xenctrl.h +0
-0tools/libxc/include/xenctrl.h int xc_monitor_get_capabilities(xc_interface *xch, · line 2190
Quoted 10 lines
tools/libxc/include/xenctrl.h +2
-2@@ -2183,8 +2183,8 @@ int xc_monitor_get_capabilities(xc_interface *xch,domid_t domain_id, int xc_monitor_write_ctrlreg(xc_interface *xch, domid_t domain_id,uint16_t index,bool enable,bool sync,bool onchangeonly); -int xc_monitor_mov_to_msr (xc_interface *xch,domid_t domain_id,bool enable, -bool extended_capture); +int xc_monitor_mov_to_msr (xc_interface *xch,domid_t domain_id,uint32_t msr, +bool enable);So my only concern with this approach here is that the MSR index definitions that are supposed to be passed are never exported via a public header, are only defined in
asm-x86/msr-index.h. Should that also be moved to be a public header as part of this patch?The MSRs are specified by the Intel/AMD manuals. Furthermore, for the non-architectural ones, it is quite possible that the same index maps to different MSRs on different hardware. It is definitely the case that different hadware has the same MSR at different indices. (The Intel cpuid masking MSRs have this propery across different CPU generations).
Quoted 5 lines
I expect the monitoring application to know the current hardware, and which MSRs are applicable.
~Andrew
Fair enough.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 62 lines · Tamas K Lengyel
On Fri, Apr 15, 2016 at 3:02 AM, Razvan Cojocaru <[email protected] <mailto:[email protected]>> wrote:
Previously, subscribing to MSR write events was an all-or-none approach, with special cases for introspection MSR-s. This patch allows the
vm_eventconsumer to specify exactly what MSR-s it is interested in, and as a side-effect gets rid of the vmx_introspection_force_enabled_msrs[] special case. This replaces the previously posted "xen: Filter out MSR write events" patch.Signed-off-by Razvan Cojocaru <[email protected]<mailto:[email protected]>>
---
Changes since V2:
- BumpedXEN_DOMCTL_INTERFACE_VERSION.
- Introduced structmonitor_msr_bitmapas recommended by Andrew Cooper, which allowed removing some pointer arithmetic magic.
- Removedarch_prefix from monitor functions, as recommended by Tamas Lengyel.
- Replaced the page allocation code withxzalloc()/xfree()for structmonitor_msr_bitmap.
- Now returning-ENXIOinstead of-EINVALfrom the monitor functions, as recommended by Konrad Rzeszutek Wilk.
---
tools/libxc/include/xenctrl.h| 4 +-
tools/libxc/xc_monitor.c| 6 +--
xen/arch/x86/hvm/event.c| 3 +-
xen/arch/x86/hvm/hvm.c| 3 +-
xen/arch/x86/hvm/vmx/vmcs.c| 26 ++---------
xen/arch/x86/hvm/vmx/vmx.c| 10 ++--
xen/arch/x86/monitor.c| 95
+++++++++++++++++++++++++++++++++-----
xen/arch/x86/vm_event.c| 9 ++++
xen/include/asm-x86/domain.h| 4 +-
xen/include/asm-x86/hvm/hvm.h| 8 ++--
xen/include/asm-x86/hvm/vmx/vmcs.h| 7 ---
xen/include/asm-x86/monitor.h| 8 ++++
xen/include/public/domctl.h| 5 +-
13 files changed, 121 insertions(+), 67 deletions(-)diff --git
a/tools/libxc/include/xenctrl.hb/tools/libxc/include/xenctrl.h
index f5a034a..9698d46 100644
---a/tools/libxc/include/xenctrl.h
+++b/tools/libxc/include/xenctrl.h
@@ -2183,8 +2183,8 @@ int xc_monitor_get_capabilities(xc_interface *xch,domid_tdomain_id,
int xc_monitor_write_ctrlreg(xc_interface *xch,domid_tdomain_id,
uint16_tindex, bool enable, bool sync, bool onchangeonly);
-int xc_monitor_mov_to_msr(xc_interface *xch,domid_tdomain_id, bool enable,
- boolextended_capture);
+int xc_monitor_mov_to_msr(xc_interface *xch,domid_tdomain_id,uint32_tmsr,
+ bool enable);
Quoted 4 lines
So my only concern with this approach here is that the MSR index definitions that are supposed to be passed are never exported via a public header, are only defined in
asm-x86/msr-index.h. Should that also be moved to be a public header as part of this patch?
There's usually an OS header defining those constants, at least with Linux. I've just checked on my Arch Linux now and I have /usr/include/asm/msr-index.h, so I would say that's not necessary.
Having said that, if you'd prefer that the Xen header file be made public I'm happy to do that.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
On Fri, Apr 15, 2016 at 11:19 AM, Razvan Cojocaru <[email protected]
Quoted 70 lines
wrote:
Quoted 62 lines · Tamas K Lengyel
On Fri, Apr 15, 2016 at 3:02 AM, Razvan Cojocaru <[email protected] <mailto:[email protected]>> wrote:
Previously, subscribing to MSR write events was an all-or-none approach, with special cases for introspection MSR-s. This patch allows the
vm_eventconsumer to specify exactly what MSR-s it is interested in, and as a side-effect gets rid of the vmx_introspection_force_enabled_msrs[] special case. This replaces the previously posted "xen: Filter out MSR write events" patch.Signed-off-by Razvan Cojocaru <[email protected]<mailto:[email protected]>>
---
Changes since V2:
- BumpedXEN_DOMCTL_INTERFACE_VERSION.
- Introduced structmonitor_msr_bitmapas recommended by Andrew Cooper, which allowed removing some pointer arithmetic magic.
- Removedarch_prefix from monitor functions, as recommended by Tamas Lengyel.
- Replaced the page allocation code withxzalloc()/xfree()for structmonitor_msr_bitmap.
- Now returning-ENXIOinstead of-EINVALfrom the monitor functions, as recommended by Konrad Rzeszutek Wilk.
---
tools/libxc/include/xenctrl.h| 4 +-
tools/libxc/xc_monitor.c| 6 +--
xen/arch/x86/hvm/event.c| 3 +-
xen/arch/x86/hvm/hvm.c| 3 +-
xen/arch/x86/hvm/vmx/vmcs.c| 26 ++---------
xen/arch/x86/hvm/vmx/vmx.c| 10 ++--
xen/arch/x86/monitor.c| 95
+++++++++++++++++++++++++++++++++-----
xen/arch/x86/vm_event.c| 9 ++++
xen/include/asm-x86/domain.h| 4 +-
xen/include/asm-x86/hvm/hvm.h| 8 ++--
xen/include/asm-x86/hvm/vmx/vmcs.h| 7 ---
xen/include/asm-x86/monitor.h| 8 ++++
xen/include/public/domctl.h| 5 +-
13 files changed, 121 insertions(+), 67 deletions(-)diff --git
a/tools/libxc/include/xenctrl.hb/tools/libxc/include/xenctrl.h
index f5a034a..9698d46 100644
---a/tools/libxc/include/xenctrl.h
+++b/tools/libxc/include/xenctrl.h
@@ -2183,8 +2183,8 @@ int xc_monitor_get_capabilities(xc_interface *xch,domid_tdomain_id,
int xc_monitor_write_ctrlreg(xc_interface *xch,domid_tdomain_id,
uint16_tindex, bool enable, bool sync, bool onchangeonly);
-int xc_monitor_mov_to_msr(xc_interface *xch,domid_tdomain_id, bool enable,
- boolextended_capture);
+int xc_monitor_mov_to_msr(xc_interface *xch,domid_tdomain_id,uint32_tmsr,
+ bool enable);Quoted 4 lines
So my only concern with this approach here is that the MSR index definitions that are supposed to be passed are never exported via a public header, are only defined in
asm-x86/msr-index.h. Should that also be moved to be a public header as part of this patch?
Quoted 7 lines
There's usually an OS header defining those constants, at least with Linux. I've just checked on my Arch Linux now and I have
/usr/include/asm/msr-index.h, so I would say that's not necessary.Having said that, if you'd prefer that the Xen header file be made public I'm happy to do that.
I just checked on Debian and got the same header so I'm OK with that. Adding a comment might then be enough specifying that the most common MSR indices can usually be found there (with a note saying non-architectural MSRs should be gathered from the manuals).
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 83 lines · Tamas K Lengyel
On Fri, Apr 15, 2016 at 11:19 AM, Razvan Cojocaru <[email protected] <mailto:[email protected]>> wrote:
On 04/15/16 20:12, Tamas K Lengyel wrote:
>
>
> On Fri, Apr 15, 2016 at 3:02 AM, Razvan Cojocaru
> <[email protected] <mailto:[email protected]> <mailto:[email protected] <mailto:[email protected]>>> wrote:
>
> Previously, subscribing to MSR write events was an all-or-none
> approach, with special cases for introspection MSR-s. This patch
> allows thevm_eventconsumer to specify exactly what MSR-s it is
> interested in, and as a side-effect gets rid of the
> vmx_introspection_force_enabled_msrs[] special case.
> This replaces the previously posted "xen: Filter out MSR write
> events" patch.
>
> Signed-off-by: Razvan Cojocaru <[email protected] <mailto:[email protected]>
> <mailto:[email protected]
<mailto:[email protected]>>>
>
> ---
> Changes since V2:
> - BumpedXEN_DOMCTL_INTERFACE_VERSION.
> - Introduced structmonitor_msr_bitmapas recommended by Andrew
> Cooper, which allowed removing some pointer arithmetic magic.
> - Removedarch_prefix from monitor functions, as recommended
> by Tamas Lengyel.
> - Replaced the page allocation code withxzalloc()/xfree()for
> structmonitor_msr_bitmap.
> - Now returning-ENXIOinstead of-EINVALfrom the monitor
> functions, as recommended by Konrad Rzeszutek Wilk.
> ---
>tools/libxc/include/xenctrl.h| 4 +-
>tools/libxc/xc_monitor.c| 6 +--
>xen/arch/x86/hvm/event.c| 3 +-
>xen/arch/x86/hvm/hvm.c| 3 +-
>xen/arch/x86/hvm/vmx/vmcs.c| 26 ++---------
>xen/arch/x86/hvm/vmx/vmx.c| 10 ++--
>xen/arch/x86/monitor.c| 95
> +++++++++++++++++++++++++++++++++-----
>xen/arch/x86/vm_event.c| 9 ++++
>xen/include/asm-x86/domain.h| 4 +-
>xen/include/asm-x86/hvm/hvm.h| 8 ++--
>xen/include/asm-x86/hvm/vmx/vmcs.h| 7 ---
>xen/include/asm-x86/monitor.h| 8 ++++
>xen/include/public/domctl.h| 5 +-
> 13 files changed, 121 insertions(+), 67 deletions(-)
>
> diff --gita/tools/libxc/include/xenctrl.h
>b/tools/libxc/include/xenctrl.h
> index f5a034a..9698d46 100644
> ---a/tools/libxc/include/xenctrl.h
> +++b/tools/libxc/include/xenctrl.h
> @@ -2183,8 +2183,8 @@ int xc_monitor_get_capabilities(xc_interface
> *xch,domid_tdomain_id,
> int xc_monitor_write_ctrlreg(xc_interface *xch,domid_t
domain_id,
>uint16_tindex, bool enable,
bool sync,
> bool onchangeonly);
> -int xc_monitor_mov_to_msr(xc_interface *xch,domid_tdomain_id,
> bool enable,
> - boolextended_capture);
> +int xc_monitor_mov_to_msr(xc_interface *xch,domid_tdomain_id,
>uint32_tmsr,
> + bool enable);
>
>
> So my only concern with this approach here is that the MSR index > definitions that are supposed to be passed are never exported via a > public header, are only defined inasm-x86/msr-index.h. Should that also
> be moved to be a public header as part of this patch?There's usually an OS header defining those constants, at least with Linux. I've just checked on my Arch Linux now and I have
/usr/include/asm/msr-index.h, so I would say that's not necessary.
Quoted 8 lines
Having said that, if you'd prefer that the Xen header file be made public I'm happy to do that.
I just checked on Debian and got the same header so I'm OK with that. Adding a comment might then be enough specifying that the most common MSR indices can usually be found there (with a note saying non-architectural MSRs should be gathered from the manuals).
That sounds fair, I'll add the comment.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel