xen/multicall: Use the common hcall_preempted boolean
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 14 Feb 2017 18:06:59 +0000 (18:06 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Feb 2017 14:15:25 +0000 (14:15 +0000)
The now-common hcall_preempted boolean is perfectly usable for multicalls.
Remove the multicall-specific preemption mechanism.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/domain.c
xen/arch/x86/domain.c
xen/common/multicall.c
xen/include/xen/multicall.h

index ee803346a87a070059383046544156fa224b8970..bb327dadfa11b8bd892440e9cf7b8a1a2d88ced6 100644 (file)
@@ -348,12 +348,7 @@ void sync_vcpu_execstate(struct vcpu *v)
 
 void hypercall_cancel_continuation(void)
 {
-    struct mc_state *mcs = &current->mc_state;
-
-    if ( mcs->flags & MCSF_in_multicall )
-        __clear_bit(_MCSF_call_preempted, &mcs->flags);
-    else
-        current->hcall_preempted = false;
+    current->hcall_preempted = false;
 }
 
 unsigned long hypercall_create_continuation(
@@ -369,12 +364,12 @@ unsigned long hypercall_create_continuation(
     /* All hypercalls take at least one argument */
     BUG_ON( !p || *p == '\0' );
 
+    current->hcall_preempted = true;
+
     va_start(args, format);
 
     if ( mcs->flags & MCSF_in_multicall )
     {
-        __set_bit(_MCSF_call_preempted, &mcs->flags);
-
         for ( i = 0; *p != '\0'; i++ )
             mcs->call.args[i] = next_arg(p, args);
 
@@ -385,8 +380,6 @@ unsigned long hypercall_create_continuation(
     {
         regs = guest_cpu_user_regs();
 
-        current->hcall_preempted = true;
-
 #ifdef CONFIG_ARM_64
         if ( !is_32bit_domain(current->domain) )
         {
index 3fb1bdcec8658172122795c2f17a2fd296118623..4ffd94b3172c6eeaf8f11b2497dbb9c9fd14466c 100644 (file)
@@ -2197,41 +2197,34 @@ void sync_vcpu_execstate(struct vcpu *v)
 
 void hypercall_cancel_continuation(void)
 {
-    struct mc_state *mcs = &current->mc_state;
-
-    if ( mcs->flags & MCSF_in_multicall )
-        __clear_bit(_MCSF_call_preempted, &mcs->flags);
-    else
-        current->hcall_preempted = false;
+    current->hcall_preempted = false;
 }
 
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...)
 {
-    struct mc_state *mcs = &current->mc_state;
+    struct vcpu *curr = current;
+    struct mc_state *mcs = &curr->mc_state;
     const char *p = format;
     unsigned long arg;
     unsigned int i;
     va_list args;
 
+    curr->hcall_preempted = true;
+
     va_start(args, format);
 
     if ( mcs->flags & MCSF_in_multicall )
     {
-        __set_bit(_MCSF_call_preempted, &mcs->flags);
-
         for ( i = 0; *p != '\0'; i++ )
             mcs->call.args[i] = next_arg(p, args);
     }
     else
     {
         struct cpu_user_regs *regs = guest_cpu_user_regs();
-        struct vcpu *curr = current;
 
         regs->rax = op;
 
-        curr->hcall_preempted = true;
-
         if ( is_pv_vcpu(curr) ?
              !is_pv_32bit_vcpu(curr) :
              curr->arch.hvm_vcpu.hcall_64bit )
@@ -2292,7 +2285,7 @@ int hypercall_xlat_continuation(unsigned int *id, unsigned int nr,
 
     if ( mcs->flags & MCSF_in_multicall )
     {
-        if ( !(mcs->flags & MCSF_call_preempted) )
+        if ( !current->hcall_preempted )
         {
             va_end(args);
             return 0;
index f7880a85817a9ad5b5003adb315db59162b1d127..cc8daf919f356a9b47076b8034caff7f86c0af55 100644 (file)
@@ -78,7 +78,7 @@ do_multicall(
 
         if ( unlikely(__copy_field_to_guest(call_list, &mcs->call, result)) )
             rc = -EFAULT;
-        else if ( mcs->flags & MCSF_call_preempted )
+        else if ( current->hcall_preempted )
         {
             /* Translate sub-call continuation to guest layout */
             xlat_multicall_entry(mcs);
@@ -86,6 +86,8 @@ do_multicall(
             /* Copy the sub-call continuation. */
             if ( likely(!__copy_to_guest(call_list, &mcs->call, 1)) )
                 goto preempted;
+            else
+                hypercall_cancel_continuation();
             rc = -EFAULT;
         }
         else
index fff15ebf2c015a814376b34c8e4e29315b13688e..e8d7905a0f9571868061632dc563f0ec1aabfd6b 100644 (file)
@@ -11,9 +11,7 @@
 #endif
 
 #define _MCSF_in_multicall   0
-#define _MCSF_call_preempted 1
 #define MCSF_in_multicall    (1<<_MCSF_in_multicall)
-#define MCSF_call_preempted  (1<<_MCSF_call_preempted)
 struct mc_state {
     unsigned long flags;
     union {