1 /******************************************************************************
2  * x86_emulate.c
3  *
4  * Wrapper for generic x86 instruction decoder and emulator.
5  *
6  * Copyright (c) 2008, Citrix Systems, Inc.
7  *
8  * Authors:
9  *    Keir Fraser <keir@xen.org>
10  */
11 
12 #include <xen/domain_page.h>
13 #include <asm/x86_emulate.h>
14 #include <asm/asm_defns.h> /* mark_regs_dirty() */
15 #include <asm/processor.h> /* current_cpu_info */
16 #include <asm/xstate.h>
17 #include <asm/amd.h> /* cpu_has_amd_erratum() */
18 
19 /* Avoid namespace pollution. */
20 #undef cmpxchg
21 #undef cpuid
22 #undef wbinvd
23 
24 #define r(name) r ## name
25 
26 #define cpu_has_amd_erratum(nr) \
27         cpu_has_amd_erratum(&current_cpu_data, AMD_ERRATUM_##nr)
28 
29 #define get_stub(stb) ({                                        \
30     BUILD_BUG_ON(STUB_BUF_SIZE / 2 < MAX_INST_LEN + 1);         \
31     ASSERT(!(stb).ptr);                                         \
32     (stb).addr = this_cpu(stubs.addr) + STUB_BUF_SIZE / 2;      \
33     memset(((stb).ptr = map_domain_page(_mfn(this_cpu(stubs.mfn)))) +  \
34            ((stb).addr & ~PAGE_MASK), 0xcc, STUB_BUF_SIZE / 2);        \
35 })
36 #define put_stub(stb) ({                                   \
37     if ( (stb).ptr )                                       \
38     {                                                      \
39         unmap_domain_page((stb).ptr);                      \
40         (stb).ptr = NULL;                                  \
41     }                                                      \
42 })
43 
44 #include "x86_emulate/x86_emulate.c"
45