public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Jim Mattson <jmattson@google.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	 Shuah Khan <shuah@kernel.org>, Bibo Mao <maobibo@loongson.cn>,
	 Huacai Chen <chenhuacai@kernel.org>,
	Andrew Jones <ajones@ventanamicro.com>,
	 Claudio Imbrenda <imbrenda@linux.ibm.com>,
	"Pratik R. Sampat" <prsampat@amd.com>,
	 Kai Huang <kai.huang@intel.com>,
	Eric Auger <eric.auger@redhat.com>,
	 linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	 linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 3/4] KVM: selftests: Add VM_MODE_PXXV57_4K VM mode
Date: Wed, 15 Oct 2025 15:58:32 -0700	[thread overview]
Message-ID: <aPAnGDh2u5-VK7gs@google.com> (raw)
In-Reply-To: <2mtjboekfjxmuougyiypg4azeurhqxlk7fovzacv5c74hrmzrb@krfinussf2zd>

On Wed, Oct 15, 2025, Yosry Ahmed wrote:
> On Wed, Sep 17, 2025 at 02:48:39PM -0700, Jim Mattson wrote:
> > Add a new VM mode, VM_MODE_PXXV57_4K, to support tests that require
> > 5-level paging on x86. This mode sets up a 57-bit virtual address
> > space and sets CR4.LA57 in the guest.
> > 
> > Signed-off-by: Jim Mattson <jmattson@google.com>
> > ---
> >  .../testing/selftests/kvm/include/kvm_util.h  |  1 +
> >  tools/testing/selftests/kvm/lib/kvm_util.c    | 21 +++++++++++++++++
> >  .../testing/selftests/kvm/lib/x86/processor.c | 23 ++++++++++++-------
> >  tools/testing/selftests/kvm/lib/x86/vmx.c     |  7 +++---
> >  4 files changed, 41 insertions(+), 11 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
> > index 23a506d7eca3..b6ea5d966715 100644
> > --- a/tools/testing/selftests/kvm/include/kvm_util.h
> > +++ b/tools/testing/selftests/kvm/include/kvm_util.h
> > @@ -175,6 +175,7 @@ enum vm_guest_mode {
> >  	VM_MODE_P40V48_16K,
> >  	VM_MODE_P40V48_64K,
> >  	VM_MODE_PXXV48_4K,	/* For 48bits VA but ANY bits PA */
> > +	VM_MODE_PXXV57_4K,	/* For 48bits VA but ANY bits PA */
> >  	VM_MODE_P47V64_4K,
> >  	VM_MODE_P44V64_4K,
> >  	VM_MODE_P36V48_4K,
> > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
> > index c3f5142b0a54..6b0e499c6e91 100644
> > --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> > @@ -232,6 +232,7 @@ const char *vm_guest_mode_string(uint32_t i)
> >  		[VM_MODE_P40V48_16K]	= "PA-bits:40,  VA-bits:48, 16K pages",
> >  		[VM_MODE_P40V48_64K]	= "PA-bits:40,  VA-bits:48, 64K pages",
> >  		[VM_MODE_PXXV48_4K]	= "PA-bits:ANY, VA-bits:48,  4K pages",
> > +		[VM_MODE_PXXV57_4K]	= "PA-bits:ANY, VA-bits:57,  4K pages",
> >  		[VM_MODE_P47V64_4K]	= "PA-bits:47,  VA-bits:64,  4K pages",
> >  		[VM_MODE_P44V64_4K]	= "PA-bits:44,  VA-bits:64,  4K pages",
> >  		[VM_MODE_P36V48_4K]	= "PA-bits:36,  VA-bits:48,  4K pages",
> > @@ -259,6 +260,7 @@ const struct vm_guest_mode_params vm_guest_mode_params[] = {
> >  	[VM_MODE_P40V48_16K]	= { 40, 48,  0x4000, 14 },
> >  	[VM_MODE_P40V48_64K]	= { 40, 48, 0x10000, 16 },
> >  	[VM_MODE_PXXV48_4K]	= {  0,  0,  0x1000, 12 },
> > +	[VM_MODE_PXXV57_4K]	= {  0,  0,  0x1000, 12 },
> >  	[VM_MODE_P47V64_4K]	= { 47, 64,  0x1000, 12 },
> >  	[VM_MODE_P44V64_4K]	= { 44, 64,  0x1000, 12 },
> >  	[VM_MODE_P36V48_4K]	= { 36, 48,  0x1000, 12 },
> > @@ -358,6 +360,25 @@ struct kvm_vm *____vm_create(struct vm_shape shape)
> >  		vm->va_bits = 48;
> >  #else
> >  		TEST_FAIL("VM_MODE_PXXV48_4K not supported on non-x86 platforms");
> 
> We should probably update TEST_ASSERT(vm->va_bits == 48 || vm->va_bits == 57)
> above to only assert 48 bits now, right?

No, because CPUID reports the _max_ virtual address width.  In theory, the assert
could be ">= 48", but in practice x86-64 only supports 48-bit and 57-bit VAs, so
selftests are paranoid and are sanity checking KVM at the same time.

  reply	other threads:[~2025-10-15 22:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17 21:48 [PATCH 0/4] KVM: selftests: Add test of SET_NESTED_STATE with 48-bit L2 on 57-bit L1 Jim Mattson
2025-09-17 21:48 ` [PATCH 1/4] KVM: selftests: Use a loop to create guest page tables Jim Mattson
2025-10-20 17:10   ` Yosry Ahmed
2025-09-17 21:48 ` [PATCH 2/4] KVM: selftests: Use a loop to walk " Jim Mattson
2025-10-20 17:21   ` Yosry Ahmed
2025-10-21 22:11     ` Jim Mattson
2025-10-21 22:24       ` Yosry Ahmed
2025-09-17 21:48 ` [PATCH 3/4] KVM: selftests: Add VM_MODE_PXXV57_4K VM mode Jim Mattson
2025-10-15 21:23   ` Yosry Ahmed
2025-10-21 22:34     ` Jim Mattson
2025-10-21 22:56       ` Yosry Ahmed
2025-10-15 21:25   ` Yosry Ahmed
2025-10-15 22:58     ` Sean Christopherson [this message]
2025-10-15 22:59   ` Sean Christopherson
2025-10-16  0:40     ` Sean Christopherson
2025-10-21 22:37       ` Jim Mattson
2025-09-17 21:48 ` [PATCH 4/4] KVM: selftests: Add a VMX test for LA57 nested state Jim Mattson
2025-10-20 17:26   ` Yosry Ahmed
2025-10-21 23:40     ` Jim Mattson
2025-10-22 18:07       ` Yosry Ahmed

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=aPAnGDh2u5-VK7gs@google.com \
    --to=seanjc@google.com \
    --cc=ajones@ventanamicro.com \
    --cc=chenhuacai@kernel.org \
    --cc=eric.auger@redhat.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=jmattson@google.com \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maobibo@loongson.cn \
    --cc=pbonzini@redhat.com \
    --cc=prsampat@amd.com \
    --cc=shuah@kernel.org \
    --cc=yosry.ahmed@linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox