Re: [PATCH v2] KVM: selftests: x86: Prioritize getting max_gfn from GuestPhysBits

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

 



On Sat, May 11, 2024 at 03:08:16PM +0800, Xiaoyao Li wrote:

[...]

> > diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> > index 74a4c736c9ae..aa9966ead543 100644
> > --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
> > +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> > @@ -1293,10 +1293,16 @@ const struct kvm_cpuid2 *vcpu_get_supported_hv_cpuid(struct kvm_vcpu *vcpu)
> >   unsigned long vm_compute_max_gfn(struct kvm_vm *vm)
> >   {
> >   	const unsigned long num_ht_pages = 12 << (30 - vm->page_shift); /* 12 GiB */
> > -	unsigned long ht_gfn, max_gfn, max_pfn;
> > +	unsigned long ht_gfn, max_gfn, max_pfn, max_bits = 0;
> >   	uint8_t maxphyaddr;
> > -	max_gfn = (1ULL << (vm->pa_bits - vm->page_shift)) - 1;
> > +	if (kvm_cpu_has_p(X86_PROPERTY_MAX_GUEST_PHY_ADDR))
> > +		max_bits = kvm_cpu_property(X86_PROPERTY_MAX_GUEST_PHY_ADDR);
> 
> We can get rid of the kvm_cpu_has_p(X86_PROPERTY_MAX_GUEST_PHY_ADDR) check
> and call kvm_cpu_property() unconditionally. As a bonus, we don't need to
> init max_bits as 0.

Thanks, good suggestion!

> 
> BTW, could we just name it guest_pa_bits?

Yes, it will be more accurate.





[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