From: Yang Zhang Date: Thu, 23 Jan 2014 09:27:34 +0000 (+0100) Subject: Nested VMX: prohibit virtual vmentry/vmexit during IO emulation X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5656 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=09bb434748af9bfe3f7fca4b6eef721a7d5042a4;p=xen.git Nested VMX: prohibit virtual vmentry/vmexit during IO emulation Sometimes, L0 needs to decode L2's instruction to handle IO access directly. And L0 may get X86EMUL_RETRY when handling this IO request. At same time, if there is a virtual vmexit pending (for example, an interrupt pending to inject to L1) and hypervisor will switch the VCPU context from L2 to L1. Now we already are in L1's context, but since we got a X86EMUL_RETRY just now and this means hypervisor will retry to handle the IO request later and unfortunately, the retry will happen in L1's context. And it will cause the problem. The fixing is that if there is a pending IO request, no virtual vmexit/vmentry is allowed. Signed-off-by: Yang Zhang Acked-by: Jun Nakajima --- diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index 41db52be44..d2ba435471 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -1395,6 +1395,13 @@ void nvmx_switch_guest(void) struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v); struct cpu_user_regs *regs = guest_cpu_user_regs(); + /* + * a pending IO emualtion may still no finished. In this case, + * no virtual vmswith is allowed. Or else, the following IO + * emulation will handled in a wrong VCPU context. + */ + if ( get_ioreq(v)->state != STATE_IOREQ_NONE ) + return; /* * a softirq may interrupt us between a virtual vmentry is * just handled and the true vmentry. If during this window,