[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87zgrfzj9k.fsf@vitty.brq.redhat.com>
Date: Mon, 11 Oct 2021 17:13:59 +0200
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Maxim Levitsky <mlevitsk@...hat.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/4] KVM: nVMX: Track whether changes in L0 require
MSR bitmap for L2 to be rebuilt
Sean Christopherson <seanjc@...gle.com> writes:
> On Mon, Oct 04, 2021, Vitaly Kuznetsov wrote:
>> Introduce a flag to keep track of whether MSR bitmap for L2 needs to be
>> rebuilt due to changes in MSR bitmap for L1 or switching to a different
>> L2. This information will be used for Enlightened MSR Bitmap feature for
>> Hyper-V guests.
>>
>> Note, setting msr_bitmap_changed to 'true' from set_current_vmptr() is
>> not really needed for Enlightened MSR Bitmap as the feature can only
>> be used in conjunction with Enlightened VMCS but let's keep tracking
>> information complete, it's cheap and in the future similar PV feature can
>> easily be implemented for KVM on KVM too.
>>
>> No functional change intended.
>>
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
>> ---
>
> ...
>
>> void vmx_disable_intercept_for_msr(struct kvm_vcpu *vcpu, u32 msr, int type)
>> diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h
>> index 592217fd7d92..eb7a1697bec2 100644
>> --- a/arch/x86/kvm/vmx/vmx.h
>> +++ b/arch/x86/kvm/vmx/vmx.h
>> @@ -148,6 +148,12 @@ struct nested_vmx {
>> bool need_vmcs12_to_shadow_sync;
>> bool dirty_vmcs12;
>>
>> + /*
>> + * Indicates whether MSR bitmap for L2 needs to be rebuilt due to
>> + * changes in MSR bitmap for L1 or switching to a different L2.
>> + */
>> + bool msr_bitmap_changed;
>
> This is misleading, and arguably wrong. It's only accurate when used in conjuction
> with a paravirt L1 that states if a VMCS has a dirty MSR bitmap. E.g. this flag
> will be wrong if L1 changes the address of the bitmap in the VMCS, and it's
> obviously wrong if L1 changes the MSR bitmap itself.
>
> The changelog kind of covers that, but those details will be completely lost to
> readers of the code.
Would it help if we rename 'msr_bitmap_changed' to something?
>
> Would it be illegal from KVM to simply clear the CLEAN bit in the eVMCS at the
> appropriate points?
It would probably be OK to do that while we're in L2, however, in case
we're running L1 things can get messy. E.g. MSR-bitmap for L1 is changed
and we clear the clean bit in the currently mapped eVMCS for L2. Later,
before L1 runs L2, it sets the bit back again indicating 'no changes in
MSR-bitmap-12' and we (erroneously) skip updating MSR-Bitmap-02.
--
Vitaly
Powered by blists - more mailing lists