[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 1/3] x86/pv: Avoid locked bit manipulation in register_guest_callback()



Changes to arch.vgc_flags are made to current in syncrhonous context only, and
don't need to be locked.  (The only other changes are via
arch_set_info_guest(), which operates on descheduled vcpus only).

Replace the {set,clear}_bit() calls with compiler-visible bitwise operations.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/pv/callback.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/pv/callback.c b/xen/arch/x86/pv/callback.c
index 29ae692..e6a17c5 100644
--- a/xen/arch/x86/pv/callback.c
+++ b/xen/arch/x86/pv/callback.c
@@ -88,21 +88,17 @@ static long register_guest_callback(struct 
callback_register *reg)
     case CALLBACKTYPE_failsafe:
         curr->arch.pv_vcpu.failsafe_callback_eip = reg->address;
         if ( reg->flags & CALLBACKF_mask_events )
-            set_bit(_VGCF_failsafe_disables_events,
-                    &curr->arch.vgc_flags);
+            curr->arch.vgc_flags |= VGCF_failsafe_disables_events;
         else
-            clear_bit(_VGCF_failsafe_disables_events,
-                      &curr->arch.vgc_flags);
+            curr->arch.vgc_flags &= ~VGCF_failsafe_disables_events;
         break;
 
     case CALLBACKTYPE_syscall:
         curr->arch.pv_vcpu.syscall_callback_eip  = reg->address;
         if ( reg->flags & CALLBACKF_mask_events )
-            set_bit(_VGCF_syscall_disables_events,
-                    &curr->arch.vgc_flags);
+            curr->arch.vgc_flags |= VGCF_syscall_disables_events;
         else
-            clear_bit(_VGCF_syscall_disables_events,
-                      &curr->arch.vgc_flags);
+            curr->arch.vgc_flags &= ~VGCF_syscall_disables_events;
         break;
 
     case CALLBACKTYPE_syscall32:
@@ -236,11 +232,9 @@ static long compat_register_guest_callback(struct 
compat_callback_register *reg)
         curr->arch.pv_vcpu.failsafe_callback_cs  = reg->address.cs;
         curr->arch.pv_vcpu.failsafe_callback_eip = reg->address.eip;
         if ( reg->flags & CALLBACKF_mask_events )
-            set_bit(_VGCF_failsafe_disables_events,
-                    &curr->arch.vgc_flags);
+            curr->arch.vgc_flags |= VGCF_failsafe_disables_events;
         else
-            clear_bit(_VGCF_failsafe_disables_events,
-                      &curr->arch.vgc_flags);
+            curr->arch.vgc_flags &= ~VGCF_failsafe_disables_events;
         break;
 
     case CALLBACKTYPE_syscall32:
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.