Re: [PATCH v12 04/18] KVM: x86: Rename kvm->arch.has_private_mem to kvm->arch.supports_gmem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ackerley!

On Tue, 2025-06-24 at 21:51 +0100, Ackerley Tng wrote:> Sean Christopherson <seanjc@xxxxxxxxxx> writes:
> 

[...]

>> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
>> index 3d69da6d2d9e..4bc50c1e21bd 100644
>> --- a/arch/x86/include/asm/kvm_host.h
>> +++ b/arch/x86/include/asm/kvm_host.h
>> @@ -1341,7 +1341,7 @@ struct kvm_arch {
>>       unsigned int indirect_shadow_pages;
>>       u8 mmu_valid_gen;
>>       u8 vm_type;
>> -     bool has_private_mem;
>> +     bool supports_gmem;
>>       bool has_protected_state;
>>       bool pre_fault_allowed;
>>       struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
>> @@ -2270,7 +2270,7 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level,
>>
>>
>>  #ifdef CONFIG_KVM_GMEM
>> -#define kvm_arch_supports_gmem(kvm) ((kvm)->arch.has_private_mem)
>> +#define kvm_arch_supports_gmem(kvm) ((kvm)->arch.supports_gmem)
>>  #else
>>  #define kvm_arch_supports_gmem(kvm) false
>>  #endif
>> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
>> index e7ecf089780a..c4e10797610c 100644
>> --- a/arch/x86/kvm/mmu/mmu.c
>> +++ b/arch/x86/kvm/mmu/mmu.c
>> @@ -3488,7 +3488,7 @@ static bool page_fault_can_be_fast(struct kvm *kvm, struct kvm_page_fault *fault
>>        * on RET_PF_SPURIOUS until the update completes, or an actual spurious
>>        * case might go down the slow path. Either case will resolve itself.
>>        */
>> -     if (kvm->arch.has_private_mem &&
>> +     if (kvm->arch.supports_gmem &&
>>           fault->is_private != kvm_mem_is_private(kvm, fault->gfn))
>>               return false;
>>
> 
> This check should remain as a check on has_private_mem.
> 
> If the VM supports private memory, skip fast page faults on fault type
> and KVM memory privacy status mismatches.

...
 
> Patrick, Nikita, am I right that for KVM_X86_DEFAULT_VM to work with
> mmap-able guest_memfd, the usage in page_fault_can_be_fast() need not be
> updated, and that patch 10/18 in this series will be sufficient?
 
Yeah, since KVM_X86_DEFAULT_VM does not and won't ever (?) support private
memory in guest_memfd (e.g. it always has to be used in all-shared mode) from
my understanding, the fault->is_private != kvm_mem_is_private(kvm, fault->gfn))
check should never succeed anyway. kvm_mem_is_private() will always return
false, and fault->is_private should always be false, too (unless the guest does
something it should not be doing, and even then the worst case is that we won't
be handling this weirdness "fast").

In my testing with earlier iterations of this series where
page_fault_can_be_fast() was untouched I also never saw any problems related to
page faults on x86.

Best, 
Patrick





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux