diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2007-12-27 10:39:04 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2007-12-27 10:39:04 +0000 |
commit | d22f3583407347c84e88fd81351e74f04e9c1743 (patch) | |
tree | 06945bea9ae49441bcc64e1bfabb8758a465a339 | |
parent | bcaa6b863d31951f59e6b83f6f174c9b8cfbab8f (diff) | |
download | xen-d22f3583407347c84e88fd81351e74f04e9c1743.tar.gz xen-d22f3583407347c84e88fd81351e74f04e9c1743.tar.bz2 xen-d22f3583407347c84e88fd81351e74f04e9c1743.zip |
hvm: Register fields CS,DS,ES,FS,GS,SS,etc. are all undefined during
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>
-rw-r--r-- | xen/arch/x86/hvm/svm/x86_32/exits.S | 13 | ||||
-rw-r--r-- | xen/arch/x86/hvm/svm/x86_64/exits.S | 13 | ||||
-rw-r--r-- | xen/arch/x86/hvm/vmx/x86_32/exits.S | 14 | ||||
-rw-r--r-- | xen/arch/x86/hvm/vmx/x86_64/exits.S | 13 | ||||
-rw-r--r-- | xen/arch/x86/x86_32/asm-offsets.c | 1 | ||||
-rw-r--r-- | xen/arch/x86/x86_64/asm-offsets.c | 5 |
6 files changed, 58 insertions, 1 deletions
diff --git a/xen/arch/x86/hvm/svm/x86_32/exits.S b/xen/arch/x86/hvm/svm/x86_32/exits.S index f9c29a6d95..83d893a90d 100644 --- a/xen/arch/x86/hvm/svm/x86_32/exits.S +++ b/xen/arch/x86/hvm/svm/x86_32/exits.S @@ -94,6 +94,19 @@ svm_trace_done: movl VMCB_rflags(%ecx),%eax movl %eax,UREGS_eflags(%esp) +#ifndef NDEBUG + movw $0xbeef,%ax + 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) +#endif + STGI .globl svm_stgi_label; svm_stgi_label: diff --git a/xen/arch/x86/hvm/svm/x86_64/exits.S b/xen/arch/x86/hvm/svm/x86_64/exits.S index 99ffea4a8f..8c2f70a6bd 100644 --- a/xen/arch/x86/hvm/svm/x86_64/exits.S +++ b/xen/arch/x86/hvm/svm/x86_64/exits.S @@ -113,6 +113,19 @@ svm_trace_done: movq VMCB_rflags(%rcx),%rax movq %rax,UREGS_eflags(%rsp) +#ifndef NDEBUG + movw $0xbeef,%ax + 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) +#endif + STGI .globl svm_stgi_label; svm_stgi_label: diff --git a/xen/arch/x86/hvm/vmx/x86_32/exits.S b/xen/arch/x86/hvm/vmx/x86_32/exits.S index ff0cd6f43c..09202eaed3 100644 --- a/xen/arch/x86/hvm/vmx/x86_32/exits.S +++ b/xen/arch/x86/hvm/vmx/x86_32/exits.S @@ -40,7 +40,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; \ @@ -69,6 +68,19 @@ ENTRY(vmx_asm_vmexit_handler) movl $GUEST_RFLAGS,%eax VMREAD(UREGS_eflags) +#ifndef NDEBUG + movw $0xbeef,%ax + 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) +#endif + movl %esp,%eax push %eax call vmx_vmexit_handler diff --git a/xen/arch/x86/hvm/vmx/x86_64/exits.S b/xen/arch/x86/hvm/vmx/x86_64/exits.S index a54d7ef79c..0adb337681 100644 --- a/xen/arch/x86/hvm/vmx/x86_64/exits.S +++ b/xen/arch/x86/hvm/vmx/x86_64/exits.S @@ -86,6 +86,19 @@ ENTRY(vmx_asm_vmexit_handler) movl $GUEST_RFLAGS,%eax VMREAD(UREGS_eflags) +#ifndef NDEBUG + movw $0xbeef,%ax + 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) +#endif + movq %rsp,%rdi call vmx_vmexit_handler jmp vmx_asm_do_vmentry diff --git a/xen/arch/x86/x86_32/asm-offsets.c b/xen/arch/x86/x86_32/asm-offsets.c index 17beecc759..2e08ccf2fd 100644 --- a/xen/arch/x86/x86_32/asm-offsets.c +++ b/xen/arch/x86/x86_32/asm-offsets.c @@ -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(); diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c index ce92b848c9..8a7c55f951 100644 --- a/xen/arch/x86/x86_64/asm-offsets.c +++ b/xen/arch/x86/x86_64/asm-offsets.c @@ -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(); |