diff mbox

[13/16] x86/monitor: introduce writes_pending field in monitor_write_data

Message ID 1468038098-7027-1-git-send-email-czuzu@bitdefender.com (mailing list archive)
State New, archived
Headers show

Commit Message

Corneliu ZUZU July 9, 2016, 4:21 a.m. UTC
Introduce writes_pending field in monitor_write_data structure to slightly
optimize code @ monitor_write_data(): avoid having to check each bit when -all-
bits are zero (which is likely).

Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com>
---
 xen/arch/x86/monitor.c       |  3 +++
 xen/include/asm-x86/domain.h | 17 +++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
index c558f46..0763ed7 100644
--- a/xen/arch/x86/monitor.c
+++ b/xen/arch/x86/monitor.c
@@ -127,6 +127,9 @@  void monitor_ctrlreg_write_data(struct vcpu *v)
 {
     struct monitor_write_data *w = &v->arch.vm_event->write_data;
 
+    if ( likely(!w->writes_pending) )
+        return;
+
     if ( w->do_write.msr )
     {
         hvm_msr_write_intercept(w->msr, w->value, 0);
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index 8f64ae9..ae1dcb4 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -260,12 +260,17 @@  struct pv_domain
 };
 
 struct monitor_write_data {
-    struct {
-        unsigned int msr : 1;
-        unsigned int cr0 : 1;
-        unsigned int cr3 : 1;
-        unsigned int cr4 : 1;
-    } do_write;
+    union {
+        struct {
+            unsigned int msr : 1;
+            unsigned int cr0 : 1;
+            unsigned int cr3 : 1;
+            unsigned int cr4 : 1;
+        } do_write;
+
+        /* Non-zero when at least one of do_write fields is 1. */
+        unsigned int writes_pending;
+    };
 
     uint32_t msr;
     uint64_t value;