]> xenbits.xensource.com Git - xen.git/commitdiff
x86/hypercall: Make the HVM hcall_64bit boolean common
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 14 Feb 2017 18:21:22 +0000 (18:21 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Feb 2017 14:15:25 +0000 (14:15 +0000)
HVM guests currently make use of arch.hvm_vcpu.hcall_64bit to track the ABI of
the hypercall in use.

The rest of Xen deals in terms of the comat ABI or not, so rename the boolean
and make it common, guared by CONFIG_COMPAT to avoid bloat if a compat ABI is
not wanted/needed.

Set hcall_compat uniformly for PV guests as well as HVM guests.  This removes
the remaining piece of guest-type-specific knowledge from
hypercall_create_continuation(), allowing it to operate only in terms of the
hypercall ABI in use.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domain.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/hypercall.c
xen/arch/x86/hypercall.c
xen/include/asm-x86/hvm/vcpu.h
xen/include/xen/sched.h

index 4ffd94b3172c6eeaf8f11b2497dbb9c9fd14466c..694d2dc71aa03d7510a22a5a8b85a279ed6295bd 100644 (file)
@@ -2225,9 +2225,7 @@ unsigned long hypercall_create_continuation(
 
         regs->rax = op;
 
-        if ( is_pv_vcpu(curr) ?
-             !is_pv_32bit_vcpu(curr) :
-             curr->arch.hvm_vcpu.hcall_64bit )
+        if ( !curr->hcall_compat )
         {
             for ( i = 0; *p != '\0'; i++ )
             {
index 3f5c4bfdd697b73996159693ed01b9f47fcc8859..6621d629a5ed01f3fc4bdc80f26120dce7e6ee6e 100644 (file)
@@ -3253,8 +3253,7 @@ unsigned long copy_to_user_hvm(void *to, const void *from, unsigned int len)
 {
     int rc;
 
-    if ( !current->arch.hvm_vcpu.hcall_64bit &&
-         is_compat_arg_xlat_range(to, len) )
+    if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) )
     {
         memcpy(to, from, len);
         return 0;
@@ -3268,8 +3267,7 @@ unsigned long clear_user_hvm(void *to, unsigned int len)
 {
     int rc;
 
-    if ( !current->arch.hvm_vcpu.hcall_64bit &&
-         is_compat_arg_xlat_range(to, len) )
+    if ( current->hcall_compat && is_compat_arg_xlat_range(to, len) )
     {
         memset(to, 0x00, len);
         return 0;
@@ -3283,8 +3281,7 @@ unsigned long copy_from_user_hvm(void *to, const void *from, unsigned len)
 {
     int rc;
 
-    if ( !current->arch.hvm_vcpu.hcall_64bit &&
-         is_compat_arg_xlat_range(from, len) )
+    if ( current->hcall_compat && is_compat_arg_xlat_range(from, len) )
     {
         memcpy(to, from, len);
         return 0;
index fe7802b1074a6a77f3aa2ccf74a39e7d0b67cfe2..0f7c310d28bb4631166353463f7715fdec469d44 100644 (file)
@@ -35,7 +35,7 @@ static long hvm_memory_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         return -ENOSYS;
     }
 
-    if ( curr->arch.hvm_vcpu.hcall_64bit )
+    if ( !curr->hcall_compat )
         rc = do_memory_op(cmd, arg);
     else
         rc = compat_memory_op(cmd, arg);
@@ -65,7 +65,7 @@ static long hvm_grant_table_op(
         return -ENOSYS;
     }
 
-    if ( current->arch.hvm_vcpu.hcall_64bit )
+    if ( !current->hcall_compat )
         return do_grant_table_op(cmd, uop, count);
     else
         return compat_grant_table_op(cmd, uop, count);
@@ -89,7 +89,7 @@ static long hvm_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
     }
 
-    if ( curr->arch.hvm_vcpu.hcall_64bit )
+    if ( !curr->hcall_compat )
         return do_physdev_op(cmd, arg);
     else
         return compat_physdev_op(cmd, arg);
@@ -203,12 +203,9 @@ int hvm_hypercall(struct cpu_user_regs *regs)
         }
 #endif
 
-        curr->arch.hvm_vcpu.hcall_64bit = 1;
         regs->rax = hvm_hypercall_table[eax].native(rdi, rsi, rdx, r10, r8,
                                                     r9);
 
-        curr->arch.hvm_vcpu.hcall_64bit = 0;
-
 #ifndef NDEBUG
         if ( !curr->hcall_preempted )
         {
@@ -250,8 +247,10 @@ int hvm_hypercall(struct cpu_user_regs *regs)
         }
 #endif
 
+        curr->hcall_compat = true;
         regs->rax = hvm_hypercall_table[eax].compat(ebx, ecx, edx, esi, edi,
                                                     ebp);
+        curr->hcall_compat = false;
 
 #ifndef NDEBUG
         if ( !curr->hcall_preempted )
index 945afa0e0142a53e893ec1f18551b91352fcf386..c0718f8b5f1b63578599eb951c5b7bdf915e018e 100644 (file)
@@ -234,7 +234,9 @@ void pv_hypercall(struct cpu_user_regs *regs)
             __trace_hypercall(TRC_PV_HYPERCALL_V2, eax, args);
         }
 
+        curr->hcall_compat = true;
         regs->_eax = pv_hypercall_table[eax].compat(ebx, ecx, edx, esi, edi, ebp);
+        curr->hcall_compat = false;
 
 #ifndef NDEBUG
         if ( !curr->hcall_preempted )
index 6d5553d4dbb3c4e7cceef683ebc97f83255fd638..6c54773f1c02316cb275916bd80ee4061c76cda9 100644 (file)
@@ -166,8 +166,6 @@ struct hvm_vcpu {
     bool                debug_state_latch;
     bool                single_step;
 
-    bool                hcall_64bit;
-
     struct hvm_vcpu_asid n1asid;
 
     u32                 msr_tsc_aux;
index 1b1c26abeb63d1157f5312f1c9d8c9f11b8c6c5e..0929c0b910ca1405f93e921b853d3c69a0354f9a 100644 (file)
@@ -205,6 +205,10 @@ struct vcpu
 
     /* A hypercall has been preempted. */
     bool             hcall_preempted;
+#ifdef CONFIG_COMPAT
+    /* A hypercall is using the compat ABI? */
+    bool             hcall_compat;
+#endif
 
 
     /*