All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xencomm, xenmem and hypercall continuation
@ 2006-11-10  5:49 Isaku Yamahata
  2006-11-10  8:03 ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Isaku Yamahata @ 2006-11-10  5:49 UTC (permalink / raw)
  To: xen-devel; +Cc: xen-ppc-devel, xen-ia64-devel

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

fix xenmem hypercall for non-trivial xencomm arch(i.e. ia64, and powerpc)
On ia64 and powerpc, guest_handle_add_offset() effect persists over
hypercall continuation because its consumed offset is recorced in
guest domains memory space.
On the other hand, x86 guest_handle_add_offset() effect is volatile
over hypercall continuation.
So xenmem hypercall(more specifically increase_reservation,
decrease_reservaton, populate_memory and exchange) is broken on
ia64 and powerpc.
#ifdef/ifndef CONFIG_X86 is used to solve this issue without breaking
the existing ABI. #ifdef is ugly, but it would be difficult to solve
this issue without #ifdef and to preserve the existing ABI simaltaneously.

I checked other users of both guest_handle_add_offset() and hypercall
continuation. Fortunately other users records restart points
by hypercall argument so that this isn't an issue.


-- 
yamahata

[-- Attachment #2: 12315_f3e97d467b6f_xencomm_and_xenmem_hypercall.patch --]
[-- Type: text/plain, Size: 3754 bytes --]

# HG changeset patch
# User yamahata@valinux.co.jp
# Date 1163136126 -32400
# Node ID f3e97d467b6f7e36c95d4deb3ed3bc955710f8e7
# Parent  5470cadfeb22e33e7abb86193224984140732361
fix xenmem hypercall for non-trivial xencomm arch(i.e. ia64, and powerpc)
On ia64 and powerpc, guest_handle_add_offset() effect persists over
hypercall continuation because its consumed offset is recorced in
guest domains memory space.
On the other hand, x86 guest_handle_add_offset() effect is volatile
over hypercall continuation.
So xenmem hypercall(more specifically increase_reservation,
decrease_reservaton, populate_memory and exchange) is broken on
ia64 and powerpc.
#ifdef/ifndef CONFIG_X86 is used to solve this issue without breaking
the existing ABI. #ifdef is ugly, but it would be difficult to solve
this issue without #ifdef and to preserve the existing ABI simaltaneously.

I checked other users of both guest_handle_add_offset() and hypercall
continuation. Fortunately other users records restart points
by hypercall argument so that this isn't an issue.
PATCHNAME: xencomm_and_xenmem_hypercall

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>

diff -r 5470cadfeb22 -r f3e97d467b6f xen/common/memory.c
--- a/xen/common/memory.c	Fri Nov 10 14:22:05 2006 +0900
+++ b/xen/common/memory.c	Fri Nov 10 14:22:06 2006 +0900
@@ -341,23 +341,29 @@ memory_exchange(XEN_GUEST_HANDLE(xen_mem
         memflags = MEMF_dma;
     }
 
+#ifdef CONFIG_X86
     guest_handle_add_offset(exch.in.extent_start, exch.nr_exchanged);
+#endif
     exch.in.nr_extents -= exch.nr_exchanged;
 
     if ( exch.in.extent_order <= exch.out.extent_order )
     {
         in_chunk_order  = exch.out.extent_order - exch.in.extent_order;
         out_chunk_order = 0;
+#ifdef CONFIG_X86
         guest_handle_add_offset(
             exch.out.extent_start, exch.nr_exchanged >> in_chunk_order);
+#endif
         exch.out.nr_extents -= exch.nr_exchanged >> in_chunk_order;
     }
     else
     {
         in_chunk_order  = 0;
         out_chunk_order = exch.in.extent_order - exch.out.extent_order;
+#ifdef CONFIG_X86
         guest_handle_add_offset(
             exch.out.extent_start, exch.nr_exchanged << out_chunk_order);
+#endif
         exch.out.nr_extents -= exch.nr_exchanged << out_chunk_order;
     }
 
@@ -379,6 +385,15 @@ memory_exchange(XEN_GUEST_HANDLE(xen_mem
     {
         if ( hypercall_preempt_check() )
         {
+#ifndef CONFIG_X86
+            guest_handle_add_offset(exch.in.extent_start, i);
+            if ( exch.in.extent_order <= exch.out.extent_order )
+                guest_handle_add_offset(
+                    exch.out.extent_start, i >> in_chunk_order);
+            else
+                guest_handle_add_offset(
+                    exch.out.extent_start, i << out_chunk_order);
+#endif
             exch.nr_exchanged += i << in_chunk_order;
             if ( copy_field_to_guest(arg, &exch, nr_exchanged) )
                 return -EFAULT;
@@ -543,8 +558,10 @@ long do_memory_op(unsigned long cmd, XEN
         if ( unlikely(start_extent > reservation.nr_extents) )
             return start_extent;
 
+#ifdef CONFIG_X86
         if ( !guest_handle_is_null(reservation.extent_start) )
             guest_handle_add_offset(reservation.extent_start, start_extent);
+#endif
         reservation.nr_extents -= start_extent;
 
         if ( (reservation.address_bits != 0) &&
@@ -596,6 +613,10 @@ long do_memory_op(unsigned long cmd, XEN
         if ( unlikely(reservation.domid != DOMID_SELF) )
             put_domain(d);
 
+#ifndef CONFIG_X86
+        if (rc > 0 && !guest_handle_is_null(reservation.extent_start))
+            guest_handle_add_offset(reservation.extent_start, rc);
+#endif
         rc += start_extent;
 
         if ( preempted )

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-11-10 10:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-10  5:49 [PATCH] xencomm, xenmem and hypercall continuation Isaku Yamahata
2006-11-10  8:03 ` Keir Fraser
2006-11-10  8:45   ` Isaku Yamahata
2006-11-10  9:57     ` [Xen-devel] " Keir Fraser
2006-11-10 10:42       ` Isaku Yamahata
2006-11-10 10:55         ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.