From 2e3eba1a3d5cead2f25fde11874a9ef5e9c7b4be Mon Sep 17 00:00:00 2001 From: Mukesh Rathor Date: Wed, 13 Nov 2013 09:52:18 +0100 Subject: [PATCH] PVH dom0: set eflags resvd bit #1 In this patch the eflags resv bit #1 is set in vmx_vmenter_helper. If the bit is not set, the vmlaunch/resume will fail with guest state invalid. Signed-off-by: Mukesh Rathor For consistency (i.e. even if perhaps not strictly needed) also do the same on SVM. Signed-off-by: Jan Beulich --- xen/arch/x86/domain.c | 2 -- xen/arch/x86/hvm/hvm.c | 6 ++---- xen/arch/x86/hvm/svm/entry.S | 1 + xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/include/asm-x86/processor.h | 1 + 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 45e5afead7..a3868f9265 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -743,8 +743,6 @@ int arch_set_info_guest( for ( i = 0; i < ARRAY_SIZE(v->arch.debugreg); ++i ) v->arch.debugreg[i] = c(debugreg[i]); - v->arch.user_regs.eflags |= 2; - if ( has_hvm_container_vcpu(v) ) { /* diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 3919590333..6efdd8522f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -972,7 +972,7 @@ static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) v->arch.user_regs.edi = ctxt.rdi; v->arch.user_regs.esp = ctxt.rsp; v->arch.user_regs.eip = ctxt.rip; - v->arch.user_regs.eflags = ctxt.rflags | 2; + v->arch.user_regs.eflags = ctxt.rflags | X86_EFLAGS_MBS; v->arch.user_regs.r8 = ctxt.r8; v->arch.user_regs.r9 = ctxt.r9; v->arch.user_regs.r10 = ctxt.r10; @@ -1170,8 +1170,6 @@ int hvm_vcpu_initialise(struct vcpu *v) (void(*)(unsigned long))hvm_assert_evtchn_irq, (unsigned long)v); - v->arch.user_regs.eflags = 2; - v->arch.hvm_vcpu.inject_trap.vector = -1; if ( is_pvh_vcpu(v) ) @@ -3636,7 +3634,7 @@ void hvm_vcpu_reset_state(struct vcpu *v, uint16_t cs, uint16_t ip) v->arch.vgc_flags = VGCF_online; memset(&v->arch.user_regs, 0, sizeof(v->arch.user_regs)); - v->arch.user_regs.eflags = 2; + v->arch.user_regs.eflags = X86_EFLAGS_MBS; v->arch.user_regs.edx = 0x00000f00; v->arch.user_regs.eip = ip; memset(&v->arch.debugreg, 0, sizeof(v->arch.debugreg)); diff --git a/xen/arch/x86/hvm/svm/entry.S b/xen/arch/x86/hvm/svm/entry.S index aeddf64984..ef4d5f4102 100644 --- a/xen/arch/x86/hvm/svm/entry.S +++ b/xen/arch/x86/hvm/svm/entry.S @@ -76,6 +76,7 @@ UNLIKELY_END(svm_trace) mov UREGS_rsp(%rsp),%rax mov %rax,VMCB_rsp(%rcx) mov UREGS_eflags(%rsp),%rax + or $X86_EFLAGS_MBS,%rax mov %rax,VMCB_rflags(%rcx) pop %r15 diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 1c91e098af..f0132a46e1 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3048,7 +3048,7 @@ void vmx_vmenter_helper(const struct cpu_user_regs *regs) __vmwrite(GUEST_RIP, regs->rip); __vmwrite(GUEST_RSP, regs->rsp); - __vmwrite(GUEST_RFLAGS, regs->rflags); + __vmwrite(GUEST_RFLAGS, regs->rflags | X86_EFLAGS_MBS); } /* diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index 551036db81..73a320235f 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -35,6 +35,7 @@ * EFLAGS bits */ #define X86_EFLAGS_CF 0x00000001 /* Carry Flag */ +#define X86_EFLAGS_MBS 0x00000002 /* Resvd bit */ #define X86_EFLAGS_PF 0x00000004 /* Parity Flag */ #define X86_EFLAGS_AF 0x00000010 /* Auxillary carry Flag */ #define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */ -- 2.39.5