public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Bandan Das <bsd@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	"Kashyap Chamarthy" <kchamart@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	kvm@vger.kernel.org, dgilbert@redhat.com, mtosatti@redhat.com
Subject: Re: [PATCH] KVM: nVMX: mask unrestricted_guest if disabled on L0
Date: Tue, 24 Feb 2015 13:32:58 -0500	[thread overview]
Message-ID: <jpgtwyb2m91.fsf@redhat.com> (raw)
In-Reply-To: <54ECA942.6050308@siemens.com> (Jan Kiszka's message of "Tue, 24 Feb 2015 17:39:30 +0100")

Jan Kiszka <jan.kiszka@siemens.com> writes:

> On 2015-02-24 17:30, Radim Krčmář wrote:
>> 2015-02-23 19:05+0100, Kashyap Chamarthy:
>>> Tested with the _correct_ Kernel[1] (that has Radim's patch) now --
>>> applied it on both L0 and L1.
>>>
>>> Result: Same as before -- Booting L2 causes L1 to reboot. However, the
>>>         stack trace from `dmesg` on L0 is took slightly different path than
>>>         before -- it's using MSR handling:
>> 
>> Thanks, the problem was deeper ... L1 enabled unrestricted mode while L0
>> had it disabled.  L1 could then vmrun a L2 state that L0 would have to
>> emulate, but that doesn't work.  There are at least these solutions:
>> 
>>  1) don't expose unrestricted_guest when L0 doesn't have it
>
> Reminds me of a patch called "KVM: nVMX: Disable unrestricted mode if
> ept=0" by Bandan. I thought that would have caught it - apparently not.

Yeah... Unrestricted guest could be disabled even if ept=0,
and I incorrectly didn't take that into account.

>>  2) fix unrestricted mode emulation code
>>  3) handle the failure a without killing L1
>> 
>> I'd do just (1) -- emulating unrestricted mode is a loss.
>
> Agreed.
>
> Jan
>
>> 
>> I have done initial testing and at least qemu-sanity-check works now:
>> 
>> ---8<---
>> 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")
>> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>

We should Cc stable on this patch.

Bandan
>> ---
>>  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 f7b20b417a3a..dbabea21357b 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -2476,8 +2476,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;
>> @@ -2491,6 +2490,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,
>> 

  reply	other threads:[~2015-02-24 18:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-16 20:40 [nVMX] With 3.20.0-0.rc0.git5.1 on L0, booting L2 guest results in L1 *rebooting* Kashyap Chamarthy
2015-02-17  6:02 ` Jan Kiszka
2015-02-17 11:24   ` Kashyap Chamarthy
2015-02-17 18:00     ` Bandan Das
2015-02-17 18:07       ` Jan Kiszka
2015-02-18 10:20         ` Kashyap Chamarthy
2015-02-18 16:42     ` Paolo Bonzini
2015-02-19 12:07       ` Kashyap Chamarthy
2015-02-19 15:01         ` Radim Krčmář
2015-02-19 16:02           ` Radim Krčmář
2015-02-19 16:07             ` Radim Krčmář
2015-02-19 21:10             ` Kashyap Chamarthy
2015-02-19 22:28               ` Kashyap Chamarthy
2015-02-20 16:14                 ` Radim Krčmář
2015-02-20 19:45                   ` Kashyap Chamarthy
2015-02-22 15:46                     ` Kashyap Chamarthy
2015-02-23 13:56                       ` Radim Krčmář
2015-02-23 16:14                         ` Kashyap Chamarthy
2015-02-23 17:09                           ` Kashyap Chamarthy
2015-02-23 18:05                             ` Kashyap Chamarthy
2015-02-24 16:30                               ` [PATCH] KVM: nVMX: mask unrestricted_guest if disabled on L0 Radim Krčmář
2015-02-24 16:39                                 ` Jan Kiszka
2015-02-24 18:32                                   ` Bandan Das [this message]
2015-02-25 15:50                                 ` Kashyap Chamarthy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jpgtwyb2m91.fsf@redhat.com \
    --to=bsd@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kchamart@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox