Xen 
 
Home About Xen.org Xen Xen Summit Wiki Mailing List Bug Tracker Xen Downloads
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] libxc-x86-64-fixes.patch

To: Arun Sharma <arun.sharma@xxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] libxc-x86-64-fixes.patch
From: Anthony Liguori <aliguori@xxxxxxxxxx>
Date: Tue, 29 Mar 2005 21:40:30 -0600
Cc: Ian Pratt <Ian.Pratt@xxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 30 Mar 2005 03:42:41 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20050329233303.GA409@xxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: IBM
References: <20050329233303.GA409@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)
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.

Regards,
Anthony Liguori

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

<Prev in Thread] Current Thread [Next in Thread>