ia64/xen-unstable

changeset 16660:2324110ef2c6

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>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Dec 27 10:39:04 2007 +0000 (2007-12-27)
parents 717f0dce76e7
children 1e3e30670ce4
files 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
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/x86_32/exits.S	Sat Dec 22 10:27:26 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/svm/x86_32/exits.S	Thu Dec 27 10:39:04 2007 +0000
     1.3 @@ -94,6 +94,19 @@ svm_trace_done:
     1.4          movl VMCB_rflags(%ecx),%eax
     1.5          movl %eax,UREGS_eflags(%esp)
     1.6  
     1.7 +#ifndef NDEBUG
     1.8 +        movw $0xbeef,%ax
     1.9 +        movw %ax,UREGS_error_code(%esp)
    1.10 +        movw %ax,UREGS_entry_vector(%esp)
    1.11 +        movw %ax,UREGS_saved_upcall_mask(%esp)
    1.12 +        movw %ax,UREGS_cs(%esp)
    1.13 +        movw %ax,UREGS_ds(%esp)
    1.14 +        movw %ax,UREGS_es(%esp)
    1.15 +        movw %ax,UREGS_fs(%esp)
    1.16 +        movw %ax,UREGS_gs(%esp)
    1.17 +        movw %ax,UREGS_ss(%esp)
    1.18 +#endif
    1.19 +
    1.20          STGI
    1.21  .globl svm_stgi_label;
    1.22  svm_stgi_label:
     2.1 --- a/xen/arch/x86/hvm/svm/x86_64/exits.S	Sat Dec 22 10:27:26 2007 +0000
     2.2 +++ b/xen/arch/x86/hvm/svm/x86_64/exits.S	Thu Dec 27 10:39:04 2007 +0000
     2.3 @@ -113,6 +113,19 @@ svm_trace_done:
     2.4          movq VMCB_rflags(%rcx),%rax
     2.5          movq %rax,UREGS_eflags(%rsp)
     2.6  
     2.7 +#ifndef NDEBUG
     2.8 +        movw $0xbeef,%ax
     2.9 +        movw %ax,UREGS_error_code(%rsp)
    2.10 +        movw %ax,UREGS_entry_vector(%rsp)
    2.11 +        movw %ax,UREGS_saved_upcall_mask(%rsp)
    2.12 +        movw %ax,UREGS_cs(%rsp)
    2.13 +        movw %ax,UREGS_ds(%rsp)
    2.14 +        movw %ax,UREGS_es(%rsp)
    2.15 +        movw %ax,UREGS_fs(%rsp)
    2.16 +        movw %ax,UREGS_gs(%rsp)
    2.17 +        movw %ax,UREGS_ss(%rsp)
    2.18 +#endif
    2.19 +
    2.20          STGI
    2.21  .globl svm_stgi_label;
    2.22  svm_stgi_label:
     3.1 --- a/xen/arch/x86/hvm/vmx/x86_32/exits.S	Sat Dec 22 10:27:26 2007 +0000
     3.2 +++ b/xen/arch/x86/hvm/vmx/x86_32/exits.S	Thu Dec 27 10:39:04 2007 +0000
     3.3 @@ -40,7 +40,6 @@
     3.4          movl (reg),reg;
     3.5  
     3.6  #define HVM_SAVE_ALL_NOSEGREGS                                              \
     3.7 -        movl $0, 0xc(%esp);  /* XXX why do we need to force eflags==0 ?? */ \
     3.8          pushl %eax;                                                         \
     3.9          pushl %ebp;                                                         \
    3.10          pushl %edi;                                                         \
    3.11 @@ -69,6 +68,19 @@ ENTRY(vmx_asm_vmexit_handler)
    3.12          movl $GUEST_RFLAGS,%eax
    3.13          VMREAD(UREGS_eflags)
    3.14  
    3.15 +#ifndef NDEBUG
    3.16 +        movw $0xbeef,%ax
    3.17 +        movw %ax,UREGS_error_code(%esp)
    3.18 +        movw %ax,UREGS_entry_vector(%esp)
    3.19 +        movw %ax,UREGS_saved_upcall_mask(%esp)
    3.20 +        movw %ax,UREGS_cs(%esp)
    3.21 +        movw %ax,UREGS_ds(%esp)
    3.22 +        movw %ax,UREGS_es(%esp)
    3.23 +        movw %ax,UREGS_fs(%esp)
    3.24 +        movw %ax,UREGS_gs(%esp)
    3.25 +        movw %ax,UREGS_ss(%esp)
    3.26 +#endif
    3.27 +
    3.28          movl %esp,%eax
    3.29          push %eax
    3.30          call vmx_vmexit_handler
     4.1 --- a/xen/arch/x86/hvm/vmx/x86_64/exits.S	Sat Dec 22 10:27:26 2007 +0000
     4.2 +++ b/xen/arch/x86/hvm/vmx/x86_64/exits.S	Thu Dec 27 10:39:04 2007 +0000
     4.3 @@ -86,6 +86,19 @@ ENTRY(vmx_asm_vmexit_handler)
     4.4          movl $GUEST_RFLAGS,%eax
     4.5          VMREAD(UREGS_eflags)
     4.6  
     4.7 +#ifndef NDEBUG
     4.8 +        movw $0xbeef,%ax
     4.9 +        movw %ax,UREGS_error_code(%rsp)
    4.10 +        movw %ax,UREGS_entry_vector(%rsp)
    4.11 +        movw %ax,UREGS_saved_upcall_mask(%rsp)
    4.12 +        movw %ax,UREGS_cs(%rsp)
    4.13 +        movw %ax,UREGS_ds(%rsp)
    4.14 +        movw %ax,UREGS_es(%rsp)
    4.15 +        movw %ax,UREGS_fs(%rsp)
    4.16 +        movw %ax,UREGS_gs(%rsp)
    4.17 +        movw %ax,UREGS_ss(%rsp)
    4.18 +#endif
    4.19 +
    4.20          movq %rsp,%rdi
    4.21          call vmx_vmexit_handler
    4.22          jmp vmx_asm_do_vmentry
     5.1 --- a/xen/arch/x86/x86_32/asm-offsets.c	Sat Dec 22 10:27:26 2007 +0000
     5.2 +++ b/xen/arch/x86/x86_32/asm-offsets.c	Thu Dec 27 10:39:04 2007 +0000
     5.3 @@ -44,6 +44,7 @@ void __dummy__(void)
     5.4      OFFSET(UREGS_eflags, struct cpu_user_regs, eflags);
     5.5      OFFSET(UREGS_error_code, struct cpu_user_regs, error_code);
     5.6      OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector);
     5.7 +    OFFSET(UREGS_saved_upcall_mask, struct cpu_user_regs, saved_upcall_mask);
     5.8      OFFSET(UREGS_kernel_sizeof, struct cpu_user_regs, esp);
     5.9      DEFINE(UREGS_user_sizeof, sizeof(struct cpu_user_regs));
    5.10      BLANK();
     6.1 --- a/xen/arch/x86/x86_64/asm-offsets.c	Sat Dec 22 10:27:26 2007 +0000
     6.2 +++ b/xen/arch/x86/x86_64/asm-offsets.c	Thu Dec 27 10:39:04 2007 +0000
     6.3 @@ -46,11 +46,16 @@ void __dummy__(void)
     6.4      OFFSET(UREGS_rdi, struct cpu_user_regs, rdi);
     6.5      OFFSET(UREGS_error_code, struct cpu_user_regs, error_code);
     6.6      OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector);
     6.7 +    OFFSET(UREGS_saved_upcall_mask, struct cpu_user_regs, saved_upcall_mask);
     6.8      OFFSET(UREGS_rip, struct cpu_user_regs, rip);
     6.9      OFFSET(UREGS_cs, struct cpu_user_regs, cs);
    6.10      OFFSET(UREGS_eflags, struct cpu_user_regs, eflags);
    6.11      OFFSET(UREGS_rsp, struct cpu_user_regs, rsp);
    6.12      OFFSET(UREGS_ss, struct cpu_user_regs, ss);
    6.13 +    OFFSET(UREGS_ds, struct cpu_user_regs, ds);
    6.14 +    OFFSET(UREGS_es, struct cpu_user_regs, es);
    6.15 +    OFFSET(UREGS_fs, struct cpu_user_regs, fs);
    6.16 +    OFFSET(UREGS_gs, struct cpu_user_regs, gs);
    6.17      OFFSET(UREGS_kernel_sizeof, struct cpu_user_regs, es);
    6.18      DEFINE(UREGS_user_sizeof, sizeof(struct cpu_user_regs));
    6.19      BLANK();