From: Andrew Cooper Date: Wed, 13 Jan 2016 10:49:46 +0000 (+0000) Subject: Provide a Forced Emulation identifier rather than hand-rolling assembly X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=86ef387b16b42dccd6be681590474ff10572c8b8;p=people%2Froyger%2Fxen-test-framework.git Provide a Forced Emulation identifier rather than hand-rolling assembly Signed-off-by: Andrew Cooper --- diff --git a/arch/x86/setup.c b/arch/x86/setup.c index 914fd38..a039aa1 100644 --- a/arch/x86/setup.c +++ b/arch/x86/setup.c @@ -149,7 +149,7 @@ void test_setup(void) * for the #UD exception if FEP is not available. */ asm volatile ("xor %0, %0;" - "1: ud2a; .ascii \"xen\";" + "1:" _ASM_XEN_FEP "mov $1, %0;" "2:" _ASM_EXTABLE(1b, 2b) diff --git a/include/xen/arch-x86/xen.h b/include/xen/arch-x86/xen.h index 8642eae..19a1c0f 100644 --- a/include/xen/arch-x86/xen.h +++ b/include/xen/arch-x86/xen.h @@ -38,6 +38,22 @@ struct xen_trap_info { #endif +/** + * Xen Forced Emulation Prefix. + * + * For PV guests, may prefix a `cpuid` instruction to allow Xen to fill in + * information, rather than reading the hardware values. + * + * For HVM guests (and with the Xen 'hvm_fep' command line option enabled), + * may be used for cause any arbitrary instruction to be emulated in the + * hypervisor's x86 emulator. + */ +#ifdef __ASSEMBLY__ +#define _ASM_XEN_FEP ud2a; .ascii "xen"; +#else +#define _ASM_XEN_FEP "ud2a; .ascii \"xen\";" +#endif + #endif /* XEN_PUBLIC_ARCH_X86_XEN_H */ /*