[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] x86emul: assert no duplicate mappings of stub space



commit ca82be5f5cffc3b64e4c8d6d944b8a77bfce1a0e
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Mar 3 12:00:05 2017 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Mar 3 12:00:05 2017 +0100

    x86emul: assert no duplicate mappings of stub space
    
    Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 tools/tests/x86_emulator/x86_emulate.c | 7 +++++--
 xen/arch/x86/x86_emulate.c             | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/tests/x86_emulator/x86_emulate.c 
b/tools/tests/x86_emulator/x86_emulate.c
index cda0fd8..bbfd03f 100644
--- a/tools/tests/x86_emulator/x86_emulate.c
+++ b/tools/tests/x86_emulator/x86_emulate.c
@@ -19,8 +19,11 @@
 # 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)
 {
diff --git a/xen/arch/x86/x86_emulate.c b/xen/arch/x86/x86_emulate.c
index 653b5f8..51df340 100644
--- a/xen/arch/x86/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate.c
@@ -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);                              \
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.