From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guillaume Rousse Subject: Re: porting xen-detect ASM code into a shared library Date: Thu, 10 Jul 2008 13:42:18 +0200 Message-ID: <4875F59A.3060107@inria.fr> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Keir Fraser a =E9crit : > On 10/7/08 11:54, "Guillaume Rousse" wrote: >=20 >> I turned it into the current way because I don't need the check in pv >> context, but I guess it might be simplified. >=20 > Actually then you can take the xc_cpuid_x86 function pretty much unmodi= fied > (of course regs[0-3] become eax-edx, and input[1] is not needed). >=20 > 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 gue= st > 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=20 *ecx, uint32_t *edx) { asm ( /* %ebx register need to be saved before usage and restored=20 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 : "=3Da" (*eax), "=3Dr" (*ebx), "=3Dc" (*ecx), "=3Dd" (*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=20 operand is probably "=3Dd" (*edx), but I don't see the exact issue. --=20 Guillaume Rousse Moyens Informatiques - INRIA Futurs Tel: 01 69 35 69 62