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 12:54:33 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 10 Jul 2008 03:54:55 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <C49B94E2.23DA5%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: <C49B94E2.23DA5%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 10:21, "Guillaume Rousse" <Guillaume.Rousse@xxxxxxxx> wrote:

I'm trying to port xen-detect.c ASM code into cfengine, which is
currently build as a shared library. However, I'm facing a compilation
error:
misc.c: In function 'Xen_cpuid':
misc.c:1376: error: can't find a register in class 'BREG' while
reloading 'asm'
misc.c:1376: error: 'asm' operand has impossible constraints

From

See tools/libxc/xc_cpuid_x86.c for an example of how to work around this.
Essentially you turn the "=b" constraint into "=r". You then push/pop ebx
(to save/restore it) and you 'mov %%ebx,%1' to save away ebx's value before
restoring its original value.
Thanks, I see the idea, but I feel like a typing monkey here because of the unknown syntax. Is this supposed to be OK ?

void Xen_cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx,
                  uint32_t *edx)
{
    asm volatile (
        "test %1,%1 ; jz 1f ; ud2a ; .ascii \"xen\" ;"

#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)
        : "0" (idx), "1" (0) );
}

Also, the final line was originally:
: "0" (idx), "1" (pv_context) );

I turned it into the current way because I don't need the check in pv context, but I guess it might be simplified.
--
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