[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] multicall: don't ignore failure from __copy_to_guest() upon preemption



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1321018061 -3600
# Node ID b44278816b72557c9de29681f58daf107806a18d
# Parent  69f8b6f4c29cb2fb2d11e27c391090f543e6b393
multicall: don't ignore failure from __copy_to_guest() upon preemption

At once adjust perf counter updates to also count calls from here even
if a guest memory access failed.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Acked-by: Keir Fraser <keir@xxxxxxx>
---


diff -r 69f8b6f4c29c -r b44278816b72 xen/common/multicall.c
--- a/xen/common/multicall.c    Fri Nov 11 14:26:48 2011 +0100
+++ b/xen/common/multicall.c    Fri Nov 11 14:27:41 2011 +0100
@@ -25,6 +25,7 @@
 {
     struct mc_state *mcs = &current->mc_state;
     unsigned int     i;
+    int              rc = 0;
 
     if ( unlikely(__test_and_set_bit(_MCSF_in_multicall, &mcs->flags)) )
     {
@@ -33,15 +34,18 @@
     }
 
     if ( unlikely(!guest_handle_okay(call_list, nr_calls)) )
-        goto fault;
+        rc = -EFAULT;
 
-    for ( i = 0; i < nr_calls; i++ )
+    for ( i = 0; !rc && i < nr_calls; i++ )
     {
         if ( hypercall_preempt_check() )
             goto preempted;
 
         if ( unlikely(__copy_from_guest(&mcs->call, call_list, 1)) )
-            goto fault;
+        {
+            rc = -EFAULT;
+            break;
+        }
 
         do_multicall_call(&mcs->call);
 
@@ -58,30 +62,25 @@
 #endif
 
         if ( unlikely(__copy_field_to_guest(call_list, &mcs->call, result)) )
-            goto fault;
-
-        if ( test_bit(_MCSF_call_preempted, &mcs->flags) )
+            rc = -EFAULT;
+        else if ( test_bit(_MCSF_call_preempted, &mcs->flags) )
         {
             /* Translate sub-call continuation to guest layout */
             xlat_multicall_entry(mcs);
 
             /* Copy the sub-call continuation. */
-            (void)__copy_to_guest(call_list, &mcs->call, 1);
-            goto preempted;
+            if ( likely(!__copy_to_guest(call_list, &mcs->call, 1)) )
+                goto preempted;
+            rc = -EFAULT;
         }
-
-        guest_handle_add_offset(call_list, 1);
+        else
+            guest_handle_add_offset(call_list, 1);
     }
 
     perfc_incr(calls_to_multicall);
-    perfc_add(calls_from_multicall, nr_calls);
+    perfc_add(calls_from_multicall, i);
     mcs->flags = 0;
-    return 0;
-
- fault:
-    perfc_incr(calls_to_multicall);
-    mcs->flags = 0;
-    return -EFAULT;
+    return rc;
 
  preempted:
     perfc_add(calls_from_multicall, i);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.