3 messages in com.xensource.lists.xen-develRe: [Xen-devel] [PATCH] libxc-x86-64-...
FromSent OnAttachments
Arun Sharma29 Mar 2005 15:32 
Anthony Liguori29 Mar 2005 19:40 
Arun Sharma29 Mar 2005 22:25 
Subject:Re: [Xen-devel] [PATCH] libxc-x86-64-fixes.patch
From:Anthony Liguori (alig@us.ibm.com)
Date:03/29/2005 07:40:08 PM
List:com.xensource.lists.xen-devel

Arun Sharma wrote:

+#ifdef __i386__ __asm__ __volatile__ ("pushl %%ebx; cpuid; popl %%ebx" : "=a" (eax), "=c" (ecx) : "0" (1) : "dx"); +#elif defined __x86_64__ + __asm__ __volatile__ ("pushq %%rbx; cpuid; popq %%rbx" + : "=a" (eax), "=c" (ecx) + : "0" (1) + : "dx"); +#endif +

Does this mean the ebx-clobbering bug in gcc 3.4 also exists on x86-64 (except it clobbers rbx instead)?

I really hate to see this end up a permanent part of the tree... perhaps we should add a Linux style cpuid() function:

static inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx) { int ax, bx, cx, dx;

#if defined __i386__ || defined __x86_64__ __asm__("cpuid" : "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "0" (op)); #else #error cpuid not defined on current architecture #endif

if (eax) *eax = ax; if (ebx) *ebx = bx; if (ecx) *ecx = cx if (edx) *edx = dx; }

This should take care of the ebx clobbering bug while also resulting in more shared code.

Just a thought.