x86/pv: Avoid locked bit manipulation in register_guest_callback()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 14 Mar 2018 15:20:05 +0000 (15:20 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 17 Jul 2018 09:12:40 +0000 (10:12 +0100)
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@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/pv/callback.c

index 2550a726d259473bcb065ab438a7d70b78007ff8..394726a1979b6b051a5f6e5efb0e600b5b1c09f7 100644 (file)
@@ -82,21 +82,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:
@@ -230,11 +226,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: