From: Hollis Blanchard Subject: [rfc] [patch] 32/64-bit hypercall interface revisited Date: Fri, 14 Apr 2006 16:15:25 -0500 Message-ID: <1145049326.8498.39.camel@basalt.austin.ibm.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: xen-ppc-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Last year we had a discussion[1] about how the hypercall ABI unfortunately contains fields that change width between 32- and 64-bit builds. This is a huge problem as we come up on the python management stack for ppc64, since the distributions ship 32-bit python. A 32-bit python/libxc cannot currently manage a 64-bit hypervisor. I had a patch but was unable to test it, and some other things were more important at the time so I dropped the issue. Ultimately, there were three main issues: First, "unsigned longs" in the dom0 interface (but not the guest interface) should be converted[2] to a new type[3]: typedef unsigned long long __attribute__((aligned(8))) foo_t; Second, hypercalls that deal with frame numbers, e.g. DOM0_GETMEMLIST, also use "unsigned long". I've sent a separate mail about this, but I think it makes sense to define a DOM0_GETMEMLIST2 hypercall for this issue. I haven't investigated this fully. Third, the tools need to treat GUEST_HANDLEs specially.[4] The attached patch does this; I have a ppc32 app successfully making DOM0_GETVCPUCONTEXT hcalls to a ppc64 Xen. The patch has only been compile-tested on x86-32, so I would appreciate it if people could try it out on x86. For reference, the PPC changes look something like this: - typedef struct { type *p; } __guest_handle_ ## name + typedef union { uint64_t u; type *p; } __guest_handle_ ## name +#define SET_HANDLE(hnd, val) do { \ + (void)((hnd).p == (val)); \ + (hnd).u = (uint64_t)(unsigned long)(void *)(val); \ + } while (0) + +#define GET_HANDLE(val, hnd) do { \ + (val) = (hnd).p; \ + } while (0) This patch could be applied in advance of solving problems #1 and #2 above. However, it will likely require hand-merging with the libxc whitespace patch I sent recently. [1] In the archive, the thread spilled from Sep to Oct: http://lists.xensource.com/archives/html/xen-devel/2005-09/threads.html#01106 http://lists.xensource.com/archives/html/xen-devel/2005-10/threads.html#00205 [2] http://lists.xensource.com/archives/html/xen-devel/2005-10/msg00078.html [3] the alignment of long long on 32-bit x86 is 4 bytes, not 8 http://lists.xensource.com/archives/html/xen-devel/2005-10/msg00117.html [4] the original incarnation of GUEST_HANDLE http://lists.xensource.com/archives/html/xen-devel/2005-10/msg00205.html -- Hollis Blanchard IBM Linux Technology Center