xen: lift hypercall_cancel_continuation to sched.h
authorWei Liu <wei.liu2@citrix.com>
Mon, 14 Aug 2017 15:46:28 +0000 (16:46 +0100)
committerWei Liu <wei.liu2@citrix.com>
Tue, 15 Aug 2017 14:49:26 +0000 (15:49 +0100)
The function is the same on both x86 and arm. Lift it to sched.h to
save a function call, make it take a pointer to vcpu to avoid
resolving current every time it gets called.

Take the chance to change one of its callers to only use one current
in code.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/arm/domain.c
xen/arch/x86/hypercall.c
xen/arch/x86/x86_64/compat/mm.c
xen/common/multicall.c
xen/include/xen/sched.h

index 2dc8b0ab5aa0071082692836bceb372e80b9dc9d..eeebbdb39a3f2454080587d2db5e1310116f3f13 100644 (file)
@@ -365,11 +365,6 @@ void sync_vcpu_execstate(struct vcpu *v)
     __arg;                                                                  \
 })
 
-void hypercall_cancel_continuation(void)
-{
-    current->hcall_preempted = false;
-}
-
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...)
 {
index e30181817a15c4977428756f5814f752f3425867..90e88c1d2c976aaa8d590ab2728058552063119b 100644 (file)
@@ -86,11 +86,6 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] =
     __arg;                                                                  \
 })
 
-void hypercall_cancel_continuation(void)
-{
-    current->hcall_preempted = false;
-}
-
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...)
 {
index b737af1888f3b18f7de03b18ca0fa7a27922aa34..ef0ff86519ef4043efddddcdc6c4f6ea251a5dba 100644 (file)
@@ -124,7 +124,7 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( __copy_to_guest(arg, &cmp, 1) )
         {
             if ( rc == __HYPERVISOR_memory_op )
-                hypercall_cancel_continuation();
+                hypercall_cancel_continuation(current);
             rc = -EFAULT;
         }
 
index 7cbf8570480e41a2a0db14aa949a3bebedeafcb0..c7af4e01566c8430800c1e09332710ccc1b5f3bf 100644 (file)
@@ -36,7 +36,8 @@ ret_t
 do_multicall(
     XEN_GUEST_HANDLE_PARAM(multicall_entry_t) call_list, uint32_t nr_calls)
 {
-    struct mc_state *mcs = &current->mc_state;
+    struct vcpu *curr = current;
+    struct mc_state *mcs = &curr->mc_state;
     uint32_t         i;
     int              rc = 0;
     enum mc_disposition disp = mc_continue;
@@ -86,7 +87,7 @@ do_multicall(
         else if ( unlikely(__copy_field_to_guest(call_list, &mcs->call,
                                                  result)) )
             rc = -EFAULT;
-        else if ( current->hcall_preempted )
+        else if ( curr->hcall_preempted )
         {
             /* Translate sub-call continuation to guest layout */
             xlat_multicall_entry(mcs);
@@ -95,7 +96,7 @@ do_multicall(
             if ( likely(!__copy_to_guest(call_list, &mcs->call, 1)) )
                 goto preempted;
             else
-                hypercall_cancel_continuation();
+                hypercall_cancel_continuation(curr);
             rc = -EFAULT;
         }
         else
index 8690f29ac3021aba3db937b2a05e23811a7d699c..5828a0123c9c278b777a20cf4d5e1df7521373e7 100644 (file)
@@ -706,7 +706,11 @@ extern void (*dead_idle) (void);
  */
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...);
-void hypercall_cancel_continuation(void);
+
+static inline void hypercall_cancel_continuation(struct vcpu *v)
+{
+    v->hcall_preempted = false;
+}
 
 /*
  * For long-running operations that must be in hypercall context, check