All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ladi Prosek <lprosek@redhat.com>
To: David Hildenbrand <david@redhat.com>
Cc: KVM list <kvm@vger.kernel.org>,
	kai.huang@linux.intel.com, Wanpeng Li <wanpeng.li@hotmail.com>
Subject: Re: [PATCH] KVM: nVMX: initialize PML fields in vmcs02
Date: Tue, 4 Apr 2017 14:55:50 +0200	[thread overview]
Message-ID: <CABdb7342nVi7yMY0r2my2vwwFxLs-Oqfn3eXssR=qKAkVi-Xyw@mail.gmail.com> (raw)
In-Reply-To: <d596ffae-1379-e8b7-8d9e-8065ef41e119@redhat.com>

On Tue, Apr 4, 2017 at 2:44 PM, David Hildenbrand <david@redhat.com> wrote:
> On 04.04.2017 14:18, Ladi Prosek wrote:
>> L2 was running with uninitialized PML fields which led to incomplete
>> dirty bitmap logging. This manifested as all kinds of subtle erratic
>> behavior of the nested guest.
>>
>> Fixes: 843e4330573c ("KVM: VMX: Add PML support in VMX")
>> Signed-off-by: Ladi Prosek <lprosek@redhat.com>
>> ---
>>  arch/x86/kvm/vmx.c | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
>> index 2ee00db..f47d701 100644
>> --- a/arch/x86/kvm/vmx.c
>> +++ b/arch/x86/kvm/vmx.c
>> @@ -10267,6 +10267,18 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
>>
>>       }
>>
>> +     if (enable_pml) {
>> +             /*
>> +              * Conceptually we want to copy the PML address and index from
>> +              * vmcs01 here, and then back to vmcs01 on nested vmexit. But,
>> +              * since we always flush the log on each vmexit, this happens
>
> we == KVM running in g2?
>
> If so, other hypervisors might handle this differently.

No, we as KVM in L0. Hypervisors running in L1 do not see PML at all,
this is L0-only code.

I hope the comment is not confusing. The desired behavior is that PML
maintains the same state, regardless of whether we are in guest mode
or not. But the implementation allows for this shortcut where we just
reset the fields to their initial values on each nested entry.

>> +              * to be equivalent to simply resetting the fields in vmcs02.
>> +              */
>> +             ASSERT(vmx->pml_pg);
>> +             vmcs_write64(PML_ADDRESS, page_to_phys(vmx->pml_pg));
>> +             vmcs_write16(GUEST_PML_INDEX, PML_ENTITY_NUM - 1);
>> +     }
>> +
>>       if (nested_cpu_has_ept(vmcs12)) {
>>               kvm_mmu_unload(vcpu);
>>               nested_ept_init_mmu_context(vcpu);
>>
>
>
> --
>
> Thanks,
>
> David

  reply	other threads:[~2017-04-04 12:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 12:18 [PATCH] KVM: nVMX: initialize PML fields in vmcs02 Ladi Prosek
2017-04-04 12:44 ` David Hildenbrand
2017-04-04 12:55   ` Ladi Prosek [this message]
2017-04-04 13:09     ` David Hildenbrand
2017-04-04 13:19       ` Ladi Prosek
2017-04-04 13:34         ` David Hildenbrand
2017-04-04 13:25       ` David Hildenbrand
2017-04-04 13:37         ` Ladi Prosek
2017-04-04 13:55         ` Paolo Bonzini
2017-04-04 14:22           ` David Hildenbrand
2017-04-05 14:49 ` Radim Krčmář

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='CABdb7342nVi7yMY0r2my2vwwFxLs-Oqfn3eXssR=qKAkVi-Xyw@mail.gmail.com' \
    --to=lprosek@redhat.com \
    --cc=david@redhat.com \
    --cc=kai.huang@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=wanpeng.li@hotmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.