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.