]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Hypercall continuation cancelation in compat mode for XENMEM_get/set_pod_target
authorJean Guyader <jean.guyader@eu.citrix.com>
Thu, 17 Nov 2011 09:13:25 +0000 (09:13 +0000)
committerJean Guyader <jean.guyader@eu.citrix.com>
Thu, 17 Nov 2011 09:13:25 +0000 (09:13 +0000)
If copy_to_guest failed in the compat code after a continuation as
been done in the native code we need to cancel it so we won't
reexecute the hypercall but return from the hypercall with the
appropriate error.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset:   24116:a095cf28f2b6
xen-unstable date:        Fri Nov 11 10:14:22 2011 +0100
Committed-by: Keir Fraser <keir@xen.org>
xen/arch/x86/domain.c
xen/arch/x86/x86_64/compat/mm.c
xen/include/xen/sched.h

index aa8baba855700ceb2070bbb2d402f3f511263206..626e305ee91b545bf1f80780bbf0c11cfd2f18d3 100644 (file)
@@ -1585,6 +1585,24 @@ void sync_vcpu_execstate(struct vcpu *v)
     __arg;                                                                  \
 })
 
+void hypercall_cancel_continuation(void)
+{
+    struct cpu_user_regs *regs = guest_cpu_user_regs();
+    struct mc_state *mcs = &current->mc_state;
+
+    if ( test_bit(_MCSF_in_multicall, &mcs->flags) )
+    {
+        __clear_bit(_MCSF_call_preempted, &mcs->flags);
+    }
+    else
+    {
+        if ( !is_hvm_vcpu(current) )
+            regs->eip += 2; /* skip re-execute 'syscall' / 'int $xx' */
+        else
+            current->arch.hvm_vcpu.hcall_preempted = 0;
+    }
+}
+
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...)
 {
index 2c050997b687f5fa4c9306986d4fddf5c425264e..3ef08a53cd1104393768b805c64fecd8bb414695 100644 (file)
@@ -133,7 +133,11 @@ int compat_arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
         XLAT_pod_target(&cmp, nat);
 
         if ( copy_to_guest(arg, &cmp, 1) )
+        {
+            if ( rc == __HYPERVISOR_memory_op )
+                hypercall_cancel_continuation();
             rc = -EFAULT;
+        }
 
         break;
     }
index 652a39c5b07d3d30c29d4ca52dfa91ae7fc1601d..35c3a7f13c7a786a04e810aaec140d0de737f8c5 100644 (file)
@@ -554,6 +554,7 @@ void startup_cpu_idle_loop(void);
  */
 unsigned long hypercall_create_continuation(
     unsigned int op, const char *format, ...);
+void hypercall_cancel_continuation(void);
 
 #define hypercall_preempt_check() (unlikely(    \
         softirq_pending(smp_processor_id()) |   \