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] porting xen-detect ASM code into a shared library

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] porting xen-detect ASM code into a shared library
From: Guillaume Rousse <Guillaume.Rousse@xxxxxxxx>
Date: Thu, 10 Jul 2008 13:42:18 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 10 Jul 2008 04:42:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C49BA9C5.23DBD%keir.fraser@xxxxxxxxxxxxx>
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <C49BA9C5.23DBD%keir.fraser@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (X11/20080504)
Keir Fraser a écrit :
On 10/7/08 11:54, "Guillaume Rousse" <Guillaume.Rousse@xxxxxxxx> wrote:

I turned it into the current way because I don't need the check in pv
context, but I guess it might be simplified.

Actually then you can take the xc_cpuid_x86 function pretty much unmodified
(of course regs[0-3] become eax-edx, and input[1] is not needed).

The other stuff in the asm code is to ensure that cpuid traps into the
hypervisor when run in a pv guest. If you don't need to run in a pv guest
then you don't need that extra code.
OK, I tried this:

void Xen_cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)

{
     asm (
/* %ebx register need to be saved before usage and restored thereafter
         * for PIC-compliant code on i386 */
#ifdef __i386__
        "push %%ebx; cpuid; mov %%ebx,%1; pop %%ebx"
#else
        "push %%rbx; cpuid; mov %%ebx,%1; pop %%rbx"
#endif
        : "=a" (*eax), "=r" (*ebx), "=c" (*ecx), "=d" (*edx)
        : "" (idx), "2" (0) );

But it doesn't build:
misc.c: In function 'Xen_cpuid':
misc.c:1377: warning: asm operand 4 probably doesn't match constraints
misc.c:1377: error: impossible constraint in 'asm'

According to what I understood from GCC-Inline-Assembly-HOWTO, the 4th operand is probably "=d" (*edx), but I don't see the exact issue.
--
Guillaume Rousse
Moyens Informatiques - INRIA Futurs
Tel: 01 69 35 69 62

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