]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86emul: assert no duplicate mappings of stub space
authorJan Beulich <jbeulich@suse.com>
Fri, 3 Mar 2017 11:00:05 +0000 (12:00 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 3 Mar 2017 11:00:05 +0000 (12:00 +0100)
Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/tests/x86_emulator/x86_emulate.c
xen/arch/x86/x86_emulate.c

index cda0fd8ee14a6e5f66f1b84819e3c3b1e2389925..bbfd03f9b3de5758a9db8941a17622ed9f9f5c7f 100644 (file)
 # define __OP          "r"  /* Operand Prefix */
 #endif
 
-#define get_stub(stb) ((void *)((stb).addr = (uintptr_t)(stb).buf))
-#define put_stub(stb)
+#define get_stub(stb) ({                         \
+    assert(!(stb).addr);                         \
+    (void *)((stb).addr = (uintptr_t)(stb).buf); \
+})
+#define put_stub(stb) ((stb).addr = 0)
 
 bool emul_test_make_stack_executable(void)
 {
index 653b5f8b31988612788ee0676f64adcaff5f5caa..51df3408a06b3eeb7424e0020b63419c592ddcc0 100644 (file)
@@ -28,6 +28,7 @@
 
 #define get_stub(stb) ({                                        \
     BUILD_BUG_ON(STUB_BUF_SIZE / 2 < MAX_INST_LEN + 1);         \
+    ASSERT(!(stb).ptr);                                         \
     (stb).addr = this_cpu(stubs.addr) + STUB_BUF_SIZE / 2;      \
     ((stb).ptr = map_domain_page(_mfn(this_cpu(stubs.mfn)))) +  \
         ((stb).addr & ~PAGE_MASK);                              \