WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: Anthony Liguori <aliguori@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] libxc-x86-64-fixes.patch
From: Arun Sharma <arun.sharma@xxxxxxxxx>
Date: Tue, 29 Mar 2005 22:26:11 -0800
Cc: Ian Pratt <Ian.Pratt@xxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 30 Mar 2005 06:26:21 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <424A1FAE.6000106@xxxxxxxxxx>
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>
References: <20050329233303.GA409@xxxxxxxxx> <424A1FAE.6000106@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)
Anthony Liguori wrote:
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)?


There was no bug in pre gcc-3.4 generated code in the original version of vmx_identify(). The problem was with some other test case where the compiler generated code used %ebx within the inline assembly (which would be broken because cpuid clobbers %ebx and compiler didn't realize that).

gcc developers instead of making only those cases illegal, made even cases such as ours which look perfectly legal to me, illegal (because it's too much work for them to figure out what's legal and what's not).

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));

As I pointed out in the earlier thread, the linux code in <asm/processor.h> is also broken when used in userland with -fPIC.

I used this particular case (<asm/processor.h>) as an argument with gcc developers on why they shouldn't be making code that was legal with an earlier version of gcc suddenly illegal. But I couldn't provide enough use cases to make a strong argument and since an easy (although ugly) workaround was available, I settled for it.

        -Arun

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

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