From: Guillaume Rousse <Guillaume.Rousse@inria.fr>
To: Keir Fraser <keir.fraser@eu.citrix.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: porting xen-detect ASM code into a shared library
Date: Thu, 10 Jul 2008 12:54:33 +0200 [thread overview]
Message-ID: <4875EA69.5040109@inria.fr> (raw)
In-Reply-To: <C49B94E2.23DA5%keir.fraser@eu.citrix.com>
Keir Fraser a écrit :
>
>
> On 10/7/08 10:21, "Guillaume Rousse" <Guillaume.Rousse@inria.fr> 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
next prev parent reply other threads:[~2008-07-10 10:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-10 9:21 porting xen-detect ASM code into a shared library Guillaume Rousse
2008-07-10 9:28 ` Keir Fraser
2008-07-10 10:54 ` Guillaume Rousse [this message]
2008-07-10 10:57 ` Keir Fraser
2008-07-10 11:42 ` Guillaume Rousse
2008-07-10 12:18 ` Keir Fraser
2008-07-10 12:30 ` Guillaume Rousse
2008-07-10 12:31 ` Keir Fraser
2008-07-10 12:43 ` Guillaume Rousse
2008-07-10 12:44 ` Keir Fraser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4875EA69.5040109@inria.fr \
--to=guillaume.rousse@inria.fr \
--cc=keir.fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.