All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tao Su <tao1.su@linux.intel.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: kvm@vger.kernel.org, seanjc@google.com, pbonzini@redhat.com,
	chao.gao@intel.com, yi1.lai@intel.com
Subject: Re: [PATCH v2] KVM: selftests: x86: Prioritize getting max_gfn from GuestPhysBits
Date: Sat, 11 May 2024 17:13:44 +0800	[thread overview]
Message-ID: <Zj82yMtYW6VrB5z9@linux.bj.intel.com> (raw)
In-Reply-To: <456e2a3b-a96f-46a2-96d2-03dab56f9eb9@intel.com>

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.


  reply	other threads:[~2024-05-11  9:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10  2:03 [PATCH v2] KVM: selftests: x86: Prioritize getting max_gfn from GuestPhysBits Tao Su
2024-05-11  7:08 ` Xiaoyao Li
2024-05-11  9:13   ` Tao Su [this message]
2024-05-13  1:44 ` Chao Gao
2024-05-13  2:00   ` Tao Su
2024-05-13  2:48     ` Chao Gao

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=Zj82yMtYW6VrB5z9@linux.bj.intel.com \
    --to=tao1.su@linux.intel.com \
    --cc=chao.gao@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=xiaoyao.li@intel.com \
    --cc=yi1.lai@intel.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.