xen: Filter out MSR write events
PATCH 1/1 xen: Filter out MSR write events
This patch only allows introspection-related MSR write events to be sent out, improving performance. Should additional events be required, they can then simply be added to the list of vmx_introspection_force_enabled_msrs[].
--- xen/arch/x86/hvm/hvm.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +13 -1
@@ -3688,6 +3688,17 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) goto out; } +static bool_t is_introspection_msr (unsigned int msr) +{ +unsigned int i; + +for ( i =0 ; i < vmx_introspection_force_enabled_msrs_size; i++ ) +if ( msr == vmx_introspection_force_enabled_msrs[i] ) +return 1 ; + +return 0 ; +} +int hvm_msr_write_intercept (unsigned int msr,uint64_t msr_content,bool_t may_defer) {
@@ -3703,7 +3714,8 @@ 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 (currad->monitor.mov_to_msr_enabled) && +is_introspection_msr (msr) ) {ASSERT (v->arch.vm_event);
Signature · 7 lines
2.8.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 6 lines · Razvan Cojocaru
This patch only allows introspection-related MSR write events to be sent out, improving performance. Should additional events be required, they can then simply be added to the list of vmx_introspection_force_enabled_msrs[].
Signed-off-by Razvan Cojocaru <[email protected]>
Thought should there be some .. dynamic mechanism to update the MSR list? Or remove entries (or temporarily blacklist the built-one ins), etc?
Quoted 44 lines
--- xen/arch/x86/hvm/hvm.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)xen/arch/x86/hvm/hvm.c +13
-1@@ -3688,6 +3688,17 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) goto out; } +static bool_t is_introspection_msr (unsigned int msr) +{ +unsigned int i; + +for ( i =0 ; i < vmx_introspection_force_enabled_msrs_size; i++ ) +if ( msr == vmx_introspection_force_enabled_msrs[i] ) +return 1 ; + +return 0 ; +} +int hvm_msr_write_intercept (unsigned int msr,uint64_t msr_content,bool_t may_defer) {@@ -3703,7 +3714,8 @@ 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 (currad->monitor.mov_to_msr_enabled) && +is_introspection_msr (msr) ) {ASSERT (v->arch.vm_event);Signature · 7 lines
2.8.0 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Razvan Cojocaru
This patch only allows introspection-related MSR write events to be sent out, improving performance. Should additional events be required, they can then simply be added to the list of vmx_introspection_force_enabled_msrs[].
Quoted 7 lines
Quoted 1 line
Signed-off-by Razvan Cojocaru <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>Thought should there be some .. dynamic mechanism to update the MSR list? Or remove entries (or temporarily blacklist the built-one ins), etc?
While this should be enough for now (the introspection MSR list is very small, and we're probably the only consumers), that's indeed the way for the future, I think. We should have a set-like container of unique elements that can grow and shrink and can be searched quickly, and add / remove MSRs we're interested in there.
The CR write events bitmap approach clearly doesn't work, as there are too many MSRs to be able to select them all with a bitmap in the future.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 13 lines · Razvan Cojocaru
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Razvan Cojocaru
This patch only allows introspection-related MSR write events to be sent out, improving performance. Should additional events be required, they can then simply be added to the list of vmx_introspection_force_enabled_msrs[].
Quoted 6 lines
Quoted 1 line
Signed-off-by Razvan Cojocaru <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>Thought should there be some .. dynamic mechanism to update the MSR list? Or remove entries (or temporarily blacklist the built-one ins), etc?
Quoted 8 lines
While this should be enough for now (the introspection MSR list is very small, and we're probably the only consumers), that's indeed the way for the future, I think. We should have a set-like container of unique elements that can grow and shrink and can be searched quickly, and add / remove MSRs we're interested in there.
The CR write events bitmap approach clearly doesn't work, as there are too many MSRs to be able to select them all with a bitmap in the future.
The current intercept bitmaps have 4x1K bitmaps, a read and a write bit for the low and high MSR indices.
For introspection purposes, you will also want a bitmap covering the hypervisor range. For now, 3x1K bitmaps should be plenty to cover all potentially interesting MSRs.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 23 lines · Andrew Cooper
Quoted 13 lines · Razvan Cojocaru
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Razvan Cojocaru
This patch only allows introspection-related MSR write events to be sent out, improving performance. Should additional events be required, they can then simply be added to the list of vmx_introspection_force_enabled_msrs[].
Quoted 6 lines
Quoted 1 line
Signed-off-by Razvan Cojocaru <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>Thought should there be some .. dynamic mechanism to update the MSR list? Or remove entries (or temporarily blacklist the built-one ins), etc?
Quoted 8 lines
While this should be enough for now (the introspection MSR list is very small, and we're probably the only consumers), that's indeed the way for the future, I think. We should have a set-like container of unique elements that can grow and shrink and can be searched quickly, and add / remove MSRs we're interested in there.
The CR write events bitmap approach clearly doesn't work, as there are too many MSRs to be able to select them all with a bitmap in the future.
Quoted 6 lines
The current intercept bitmaps have 4x1K bitmaps, a read and a write bit for the low and high MSR indices.
For introspection purposes, you will also want a bitmap covering the hypervisor range. For now, 3x1K bitmaps should be plenty to cover all potentially interesting MSRs.
I see, so for future reference, add a pointer member allocated with alloc_xenheap_page() and memset() to 0 to struct arch_domain, maybe named monitor_msrs_bitmap (while removing mov_to_msr_enabled and mov_to_msr_extended from struct monitor)? This could get allocated on vm_event_init_domain() and de-allocated on vm_event_cleanup_domain().
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 26 lines · Razvan Cojocaru
Quoted 25 lines · Andrew Cooper
Quoted 13 lines · Razvan Cojocaru
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Razvan Cojocaru
This patch only allows introspection-related MSR write events to be sent out, improving performance. Should additional events be required, they can then simply be added to the list of vmx_introspection_force_enabled_msrs[].
Quoted 6 lines
Quoted 1 line
Signed-off-by Razvan Cojocaru <[email protected]>Reviewed-by Konrad Rzeszutek Wilk <[email protected]>Thought should there be some .. dynamic mechanism to update the MSR list? Or remove entries (or temporarily blacklist the built-one ins), etc?
Quoted 8 lines
While this should be enough for now (the introspection MSR list is very small, and we're probably the only consumers), that's indeed the way for the future, I think. We should have a set-like container of unique elements that can grow and shrink and can be searched quickly, and add / remove MSRs we're interested in there.
The CR write events bitmap approach clearly doesn't work, as there are too many MSRs to be able to select them all with a bitmap in the future.
The current intercept bitmaps have 4x1K bitmaps, a read and a write bit for the low and high MSR indices.
Quoted 8 lines
Quoted 3 lines
For introspection purposes, you will also want a bitmap covering the hypervisor range. For now, 3x1K bitmaps should be plenty to cover all potentially interesting MSRs.
I see, so for future reference, add a pointer member allocated with
alloc_xenheap_page()andmemset()to 0 to structarch_domain, maybe namedmonitor_msrs_bitmap(while removingmov_to_msr_enabledandmov_to_msr_extendedfrom struct monitor)? This could get allocated onvm_event_init_domain()and de-allocated onvm_event_cleanup_domain().
Looks suitable.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel