stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] KVM: nVMX: mask unrestricted_guest if disabled on L0
@ 2015-03-17 13:02 Radim Krčmář
  2015-03-17 18:43 ` Kashyap Chamarthy
  2015-03-18  1:09 ` Marcelo Tosatti
  0 siblings, 2 replies; 3+ messages in thread
From: Radim Krčmář @ 2015-03-17 13:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: kvm, Paolo Bonzini, Marcelo Tosatti, Kashyap Chamarthy, stable

If EPT was enabled, unrestricted_guest was allowed in L1 regardless of
L0.  L1 triple faulted when running L2 guest that required emulation.

Another side effect was 'WARN_ON_ONCE(vmx->nested.nested_run_pending)'
in L0's dmesg:
  WARNING: CPU: 0 PID: 0 at arch/x86/kvm/vmx.c:9190 nested_vmx_vmexit+0x96e/0xb00 [kvm_intel] ()

Prevent this scenario by masking SECONDARY_EXEC_UNRESTRICTED_GUEST when
the host doesn't have it enabled.

Fixes: 78051e3b7e35 ("KVM: nVMX: Disable unrestricted mode if ept=0")
Cc: stable@vger.kernel.org
Tested-By: Kashyap Chamarthy <kchamart@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 The resend Cc'd stable, as recommended by Bandan, and added Tested-by.

 arch/x86/kvm/vmx.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 10a481b7674d..ae4f6d35d19c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2479,8 +2479,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
 	if (enable_ept) {
 		/* nested EPT: emulate EPT also to L1 */
 		vmx->nested.nested_vmx_secondary_ctls_high |=
-			SECONDARY_EXEC_ENABLE_EPT |
-			SECONDARY_EXEC_UNRESTRICTED_GUEST;
+			SECONDARY_EXEC_ENABLE_EPT;
 		vmx->nested.nested_vmx_ept_caps = VMX_EPT_PAGE_WALK_4_BIT |
 			 VMX_EPTP_WB_BIT | VMX_EPT_2MB_PAGE_BIT |
 			 VMX_EPT_INVEPT_BIT;
@@ -2494,6 +2493,10 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
 	} else
 		vmx->nested.nested_vmx_ept_caps = 0;
 
+	if (enable_unrestricted_guest)
+		vmx->nested.nested_vmx_secondary_ctls_high |=
+			SECONDARY_EXEC_UNRESTRICTED_GUEST;
+
 	/* miscellaneous data */
 	rdmsr(MSR_IA32_VMX_MISC,
 		vmx->nested.nested_vmx_misc_low,
-- 
2.3.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] KVM: nVMX: mask unrestricted_guest if disabled on L0
  2015-03-17 13:02 [PATCH RESEND] KVM: nVMX: mask unrestricted_guest if disabled on L0 Radim Krčmář
@ 2015-03-17 18:43 ` Kashyap Chamarthy
  2015-03-18  1:09 ` Marcelo Tosatti
  1 sibling, 0 replies; 3+ messages in thread
From: Kashyap Chamarthy @ 2015-03-17 18:43 UTC (permalink / raw)
  To: Radim Krčmář
  Cc: linux-kernel, kvm, Paolo Bonzini, Marcelo Tosatti, stable

On Tue, Mar 17, 2015 at 02:02:32PM +0100, Radim Krčmář wrote:
> If EPT was enabled, unrestricted_guest was allowed in L1 regardless of
> L0.  L1 triple faulted when running L2 guest that required emulation.
> 
> Another side effect was 'WARN_ON_ONCE(vmx->nested.nested_run_pending)'
> in L0's dmesg:
>   WARNING: CPU: 0 PID: 0 at arch/x86/kvm/vmx.c:9190 nested_vmx_vmexit+0x96e/0xb00 [kvm_intel] ()
> 
> Prevent this scenario by masking SECONDARY_EXEC_UNRESTRICTED_GUEST when
> the host doesn't have it enabled.
> 
> Fixes: 78051e3b7e35 ("KVM: nVMX: Disable unrestricted mode if ept=0")
> Cc: stable@vger.kernel.org
> Tested-By: Kashyap Chamarthy <kchamart@redhat.com>

Thanks Radim, for resending it. I was trying to find it in one of the
recent pull requests. :-)

Just for forerence, test confirmation:

    http://article.gmane.org/gmane.comp.emulators.kvm.devel/133075

Complete thread related to this topic:

    http://thread.gmane.org/gmane.comp.emulators.kvm.devel/132863

-- 
/kashyap

> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  The resend Cc'd stable, as recommended by Bandan, and added Tested-by.
> 
>  arch/x86/kvm/vmx.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 10a481b7674d..ae4f6d35d19c 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2479,8 +2479,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
>  	if (enable_ept) {
>  		/* nested EPT: emulate EPT also to L1 */
>  		vmx->nested.nested_vmx_secondary_ctls_high |=
> -			SECONDARY_EXEC_ENABLE_EPT |
> -			SECONDARY_EXEC_UNRESTRICTED_GUEST;
> +			SECONDARY_EXEC_ENABLE_EPT;
>  		vmx->nested.nested_vmx_ept_caps = VMX_EPT_PAGE_WALK_4_BIT |
>  			 VMX_EPTP_WB_BIT | VMX_EPT_2MB_PAGE_BIT |
>  			 VMX_EPT_INVEPT_BIT;
> @@ -2494,6 +2493,10 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
>  	} else
>  		vmx->nested.nested_vmx_ept_caps = 0;
>  
> +	if (enable_unrestricted_guest)
> +		vmx->nested.nested_vmx_secondary_ctls_high |=
> +			SECONDARY_EXEC_UNRESTRICTED_GUEST;
> +
>  	/* miscellaneous data */
>  	rdmsr(MSR_IA32_VMX_MISC,
>  		vmx->nested.nested_vmx_misc_low,
> -- 
> 2.3.2
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND] KVM: nVMX: mask unrestricted_guest if disabled on L0
  2015-03-17 13:02 [PATCH RESEND] KVM: nVMX: mask unrestricted_guest if disabled on L0 Radim Krčmář
  2015-03-17 18:43 ` Kashyap Chamarthy
@ 2015-03-18  1:09 ` Marcelo Tosatti
  1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2015-03-18  1:09 UTC (permalink / raw)
  To: Radim Krčmář
  Cc: linux-kernel, kvm, Paolo Bonzini, Kashyap Chamarthy, stable

On Tue, Mar 17, 2015 at 02:02:32PM +0100, Radim Krčmář wrote:
> If EPT was enabled, unrestricted_guest was allowed in L1 regardless of
> L0.  L1 triple faulted when running L2 guest that required emulation.
> 
> Another side effect was 'WARN_ON_ONCE(vmx->nested.nested_run_pending)'
> in L0's dmesg:
>   WARNING: CPU: 0 PID: 0 at arch/x86/kvm/vmx.c:9190 nested_vmx_vmexit+0x96e/0xb00 [kvm_intel] ()
> 
> Prevent this scenario by masking SECONDARY_EXEC_UNRESTRICTED_GUEST when
> the host doesn't have it enabled.
> 
> Fixes: 78051e3b7e35 ("KVM: nVMX: Disable unrestricted mode if ept=0")
> Cc: stable@vger.kernel.org
> Tested-By: Kashyap Chamarthy <kchamart@redhat.com>
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  The resend Cc'd stable, as recommended by Bandan, and added Tested-by.

Applied to master, thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-18  1:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-17 13:02 [PATCH RESEND] KVM: nVMX: mask unrestricted_guest if disabled on L0 Radim Krčmář
2015-03-17 18:43 ` Kashyap Chamarthy
2015-03-18  1:09 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).