x86/hvm: Don't let hvm_set_efer() raise #GP behind the emulators back
PATCH 1/1 x86/hvm: Don't let hvm_set_efer() raise #GP behind the emulators back
c/s 49de10f3c "x86/hvm: Don't raise #GP behind the emulators back for MSR accesses" missed an edge case.
hvm_set_efer() raises #GP itself, so deliberately avoided the goto gp_fault path in hvm_msr_write_intercept().
With the above change, guest updates to MSR_EFER which end up faulting raises hvm_msr_write_intercept() returning X86EMUL_EXCEPTION. The second #GP gets combined to #DF and handed back to the guest.
Update hvm_set_efer() to avoid raising #GP, requiring its callers to do so.
---
CC: Boris Ostrovsky <[email protected]>
CC: Suravee Suthikulpanit <[email protected]>
--- xen/arch/x86/hvm/hvm.c | 2 -- xen/arch/x86/hvm/svm/nestedsvm.c | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/hvm.c +0 -2
@@ -1989,7 +1989,6 @@ int hvm_set_efer(uint64_t value)printk (XENLOG_G_WARNING "%pv: Invalid EFER update: %#" PRIx64" -> %#" PRIx64" - %s\n" , v, v->arch.hvm_vcpu.guest_efer, value, errstr); -hvm_inject_hw_exception (TRAP_gp_fault,0 );return X86EMUL_EXCEPTION ; }
@@ -1998,7 +1997,6 @@ int hvm_set_efer(uint64_t value) {gdprintk (XENLOG_WARNING ,"Trying to change EFER.LME with paging enabled\n" ); -hvm_inject_hw_exception (TRAP_gp_fault,0 );return X86EMUL_EXCEPTION ; }
xen/arch/x86/hvm/svm/nestedsvm.c +4 -0
@@ -278,6 +278,8 @@ static int nsvm_vcpu_hostrestore(struct vcpu *v, struct cpu_user_regs *regs)/* EFER */ v->arch.hvm_vcpu.guest_efer = n1vmcb->_efer; rc =hvm_set_efer (n1vmcb->_efer); +if ( rc ==X86EMUL_EXCEPTION ) +hvm_inject_hw_exception (TRAP_gp_fault,0 );if (rc !=X86EMUL_OKAY )gdprintk (XENLOG_ERR ,"hvm_set_efer failed, rc: %u\n" , rc);
@@ -538,6 +540,8 @@ static int nsvm_vmcb_prepare4vmrun(struct vcpu *v, struct cpu_user_regs *regs)/* EFER */ v->arch.hvm_vcpu.guest_efer = ns_vmcb->_efer; rc =hvm_set_efer (ns_vmcb->_efer); +if ( rc ==X86EMUL_EXCEPTION ) +hvm_inject_hw_exception (TRAP_gp_fault,0 );if (rc !=X86EMUL_OKAY )gdprintk (XENLOG_ERR ,"hvm_set_efer failed, rc: %u\n" , rc);
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 6 lines · Andrew Cooper
c/s
49de10f3c"x86/hvm: Don't raise #GP behind the emulators back for MSR accesses" missed an edge case.
hvm_set_efer()raises #GP itself, so deliberately avoided the gotogp_faultpath inhvm_msr_write_intercept().
Quoted 8 lines
With the above change, guest updates to
MSR_EFERwhich end up faulting raiseshvm_msr_write_intercept()returningX86EMUL_EXCEPTION. The second #GP gets combined to #DF and handed back to the guest.Update
hvm_set_efer()to avoid raising #GP, requiring its callers to do so.Signed-off-by Andrew Cooper <[email protected]>CC Jan Beulich <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 24.02.17 at 11:59, <[email protected]> wrote:
c/s
49de10f3c"x86/hvm: Don't raise #GP behind the emulators back for MSR accesses" missed an edge case.
hvm_set_efer()raises #GP itself, so deliberately avoided the gotogp_faultpath inhvm_msr_write_intercept().
Quoted 7 lines
With the above change, guest updates to
MSR_EFERwhich end up faulting raiseshvm_msr_write_intercept()returningX86EMUL_EXCEPTION. The second #GP gets combined to #DF and handed back to the guest.Update
hvm_set_efer()to avoid raising #GP, requiring its callers to do so.Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel