]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
hvm: Register fields CS,DS,ES,FS,GS,SS,etc. are all undefined during
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 27 Dec 2007 21:55:38 +0000 (21:55 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 27 Dec 2007 21:55:38 +0000 (21:55 +0000)
HVM execution as they are not saved/restore on vmexit/vmentry. To
prevent accidental usage of these fields, poison them with 16-bit
value 0xbeef (debug builds only).
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen-unstable changeset:   16660:2324110ef2c6
xen-unstable date:        Thu Dec 27 10:39:04 2007 +0000

xen/arch/x86/hvm/svm/x86_32/exits.S
xen/arch/x86/hvm/svm/x86_64/exits.S
xen/arch/x86/hvm/vmx/x86_32/exits.S
xen/arch/x86/hvm/vmx/x86_64/exits.S
xen/arch/x86/x86_32/asm-offsets.c
xen/arch/x86/x86_64/asm-offsets.c

index ba5c064b68c634b866ac491fbe4171e088c09c6d..7bef7b48a0c47a48f92be181b8525d821d5460ac 100644 (file)
@@ -82,6 +82,22 @@ svm_trace_done:
         movl VMCB_rax(%ecx),%eax
         movl %eax,UREGS_eax(%esp)
 
+#ifndef NDEBUG
+        movl $0xdeadbeef,%eax
+        movw %ax,UREGS_error_code(%esp)
+        movw %ax,UREGS_entry_vector(%esp)
+        movw %ax,UREGS_saved_upcall_mask(%esp)
+        movw %ax,UREGS_cs(%esp)
+        movw %ax,UREGS_ds(%esp)
+        movw %ax,UREGS_es(%esp)
+        movw %ax,UREGS_fs(%esp)
+        movw %ax,UREGS_gs(%esp)
+        movw %ax,UREGS_ss(%esp)
+        movl %eax,UREGS_eflags(%esp)
+        movl %eax,UREGS_eip(%esp)
+        movl %eax,UREGS_esp(%esp)
+#endif
+
         STGI
 .globl svm_stgi_label;
 svm_stgi_label:
index e991bb4cd4f1bc83d2a2d77a8d0bae31fd713b62..93d23483e25be5c05069262cf4099d36406d2135 100644 (file)
@@ -101,6 +101,22 @@ svm_trace_done:
         movq VMCB_rax(%rcx),%rax
         movq %rax,UREGS_rax(%rsp)
 
+#ifndef NDEBUG
+        movl $0xdeadbeef,%eax
+        movw %ax,UREGS_error_code(%rsp)
+        movw %ax,UREGS_entry_vector(%rsp)
+        movw %ax,UREGS_saved_upcall_mask(%rsp)
+        movw %ax,UREGS_cs(%rsp)
+        movw %ax,UREGS_ds(%rsp)
+        movw %ax,UREGS_es(%rsp)
+        movw %ax,UREGS_fs(%rsp)
+        movw %ax,UREGS_gs(%rsp)
+        movw %ax,UREGS_ss(%rsp)
+        movq %rax,UREGS_eflags(%rsp)
+        movq %rax,UREGS_rip(%rsp)
+        movq %rax,UREGS_rsp(%rsp)
+#endif
+
         STGI
 .globl svm_stgi_label;
 svm_stgi_label:
index ef24dce0eab163e113ae679b292cacab71f0605b..c210590610616ce41d6a40c160163ba9bf2e60af 100644 (file)
@@ -30,7 +30,6 @@
         movl (reg),reg;
 
 #define HVM_SAVE_ALL_NOSEGREGS                                              \
-        movl $0, 0xc(%esp);  /* XXX why do we need to force eflags==0 ?? */ \
         pushl %eax;                                                         \
         pushl %ebp;                                                         \
         pushl %edi;                                                         \
         ALIGN
 ENTRY(vmx_asm_vmexit_handler)
         HVM_SAVE_ALL_NOSEGREGS
+
+#ifndef NDEBUG
+        movl $0xdeadbeef,%eax
+        movw %ax,UREGS_error_code(%esp)
+        movw %ax,UREGS_entry_vector(%esp)
+        movw %ax,UREGS_saved_upcall_mask(%esp)
+        movw %ax,UREGS_cs(%esp)
+        movw %ax,UREGS_ds(%esp)
+        movw %ax,UREGS_es(%esp)
+        movw %ax,UREGS_fs(%esp)
+        movw %ax,UREGS_gs(%esp)
+        movw %ax,UREGS_ss(%esp)
+        movl %eax,UREGS_eflags(%esp)
+        movl %eax,UREGS_eip(%esp)
+        movl %eax,UREGS_esp(%esp)
+#endif
+
         movl %esp,%eax
         push %eax
         call vmx_vmexit_handler
index 0bebeb6ec3df0b0574c8a1693376cdd426c57c5c..e2a2c2d3d0d0a3538027a25de022d9c10112284a 100644 (file)
         ALIGN
 ENTRY(vmx_asm_vmexit_handler)
         HVM_SAVE_ALL_NOSEGREGS
+
+#ifndef NDEBUG
+        movl $0xdeadbeef,%eax
+        movw %ax,UREGS_error_code(%rsp)
+        movw %ax,UREGS_entry_vector(%rsp)
+        movw %ax,UREGS_saved_upcall_mask(%rsp)
+        movw %ax,UREGS_cs(%rsp)
+        movw %ax,UREGS_ds(%rsp)
+        movw %ax,UREGS_es(%rsp)
+        movw %ax,UREGS_fs(%rsp)
+        movw %ax,UREGS_gs(%rsp)
+        movw %ax,UREGS_ss(%rsp)
+        movq %rax,UREGS_eflags(%rsp)
+        movq %rax,UREGS_rip(%rsp)
+        movq %rax,UREGS_rsp(%rsp)
+#endif
+
         movq %rsp,%rdi
         call vmx_vmexit_handler
         jmp vmx_asm_do_vmentry
index 2d6b47de2c42086eeca90cff6aa2c8f8c36ec86e..83b50434e1e218270d04bad207eed0ae13525c99 100644 (file)
@@ -44,6 +44,7 @@ void __dummy__(void)
     OFFSET(UREGS_eflags, struct cpu_user_regs, eflags);
     OFFSET(UREGS_error_code, struct cpu_user_regs, error_code);
     OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector);
+    OFFSET(UREGS_saved_upcall_mask, struct cpu_user_regs, saved_upcall_mask);
     OFFSET(UREGS_kernel_sizeof, struct cpu_user_regs, esp);
     DEFINE(UREGS_user_sizeof, sizeof(struct cpu_user_regs));
     BLANK();
index 836ce6a05472bee7005dcd6876fcb13e86b6453a..a09dc444a040d88677b01ef31284a22b2d9c4ae4 100644 (file)
@@ -46,11 +46,16 @@ void __dummy__(void)
     OFFSET(UREGS_rdi, struct cpu_user_regs, rdi);
     OFFSET(UREGS_error_code, struct cpu_user_regs, error_code);
     OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector);
+    OFFSET(UREGS_saved_upcall_mask, struct cpu_user_regs, saved_upcall_mask);
     OFFSET(UREGS_rip, struct cpu_user_regs, rip);
     OFFSET(UREGS_cs, struct cpu_user_regs, cs);
     OFFSET(UREGS_eflags, struct cpu_user_regs, eflags);
     OFFSET(UREGS_rsp, struct cpu_user_regs, rsp);
     OFFSET(UREGS_ss, struct cpu_user_regs, ss);
+    OFFSET(UREGS_ds, struct cpu_user_regs, ds);
+    OFFSET(UREGS_es, struct cpu_user_regs, es);
+    OFFSET(UREGS_fs, struct cpu_user_regs, fs);
+    OFFSET(UREGS_gs, struct cpu_user_regs, gs);
     OFFSET(UREGS_kernel_sizeof, struct cpu_user_regs, es);
     DEFINE(UREGS_user_sizeof, sizeof(struct cpu_user_regs));
     BLANK();