linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Jack Thomson <jackabt.amazon@gmail.com>
Cc: maz@kernel.org, oliver.upton@linux.dev, pbonzini@redhat.com,
	 joey.gouly@arm.com, suzuki.poulose@arm.com,
	yuzenghui@huawei.com,  catalin.marinas@arm.com, will@kernel.org,
	shuah@kernel.org,  linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.linux.dev,  linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org,  isaku.yamahata@intel.com,
	roypat@amazon.co.uk, kalyazin@amazon.co.uk,  jackabt@amazon.com
Subject: Re: [PATCH v2 2/4] KVM: selftests: Fix unaligned mmap allocations
Date: Tue, 4 Nov 2025 12:19:10 -0800	[thread overview]
Message-ID: <aQpfviS-oAmanqpq@google.com> (raw)
In-Reply-To: <0c3db907-7012-43c3-b7fc-36848789da52@gmail.com>

On Tue, Nov 04, 2025, Jack Thomson wrote:
> On 03/11/2025 9:08 pm, Sean Christopherson wrote:
> > On Tue, Oct 28, 2025, Jack Thomson wrote:
> > > 
> > > 
> > > On 23/10/2025 6:16 pm, Sean Christopherson wrote:
> > > > On Mon, Oct 13, 2025, Jack Thomson wrote:
> > > > > From: Jack Thomson <jackabt@amazon.com>
> > > > > 
> > > > > When creating a VM using mmap with huge pages, and the memory amount does
> > > > > not align with the underlying page size. The stored mmap_size value does
> > > > > not account for the fact that mmap will automatically align the length
> > > > > to a multiple of the underlying page size. During the teardown of the
> > > > > test, munmap is used. However, munmap requires the length to be a
> > > > > multiple of the underlying page size.
> > > > 
> > > > What happens when selftests use the wrong map_size?  E.g. is munmap() silently
> > > > failing?  If so, then I should probably take this particular patch through
> > > > kvm-x86/gmem, otherwise it means we'll start getting asserts due to:
> > > > 
> > > >     3223560c93eb ("KVM: selftests: Define wrappers for common syscalls to assert success")
> > > > 
> > > > If munmap() isn't failing, then that begs the question of what this patch is
> > > > actually doing :-)
> > > > 
> > > 
> > > Hi Sean, sorry I completely missed your reply.
> > > 
> > > Yeah currently with a misaligned map_size it causes munmap() to fail, I
> > > noticed when tested with different backings.
> > 
> > Exactly which tests fail?  I ask because I'm not sure we want to fix this by
> > having vm_mem_add() paper over test issues (I vaguely recall looking at this in
> > the past, but I can't find or recall the details).
> 
> The test failures happened with pre_faulting tests after adding the
> option to change the backing page size [1]. If you'd prefer to
> have the test handle with this I'll update there instead.

Ah, yeah, that's a test bug introduced by your patch.  I can't find the thread,
but the issue of hugepage aligntment in vm_mem_add() has come up in the past,
and IIRC the conclusion was that tests need to handle the size+alignment, because
having the library force the alignment risking papering over test bugs/flaws.
And I think there may have even been cases where it introduced failures, as some
tests deliberately wanted to do weird things?

E.g. not updating the pre-faulting test to use the "correct" size+alignment means
the test is missing easy coverage for hugepages, since KVM won't create huge
mappings in stage-2 due to the memslot not being sized+aligned.

  reply	other threads:[~2025-11-04 20:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-13 15:14 [PATCH v2 0/4] KVM ARM64 pre_fault_memory Jack Thomson
2025-10-13 15:14 ` [PATCH v2 1/4] KVM: arm64: Add pre_fault_memory implementation Jack Thomson
2025-10-16 14:01   ` Suzuki K Poulose
2025-10-13 15:14 ` [PATCH v2 2/4] KVM: selftests: Fix unaligned mmap allocations Jack Thomson
2025-10-23 17:16   ` Sean Christopherson
2025-10-28 11:44     ` Thomson, Jack
2025-11-03 21:08       ` Sean Christopherson
2025-11-04 11:40         ` Thomson, Jack
2025-11-04 20:19           ` Sean Christopherson [this message]
2025-11-13 11:34             ` Thomson, Jack
2025-10-13 15:15 ` [PATCH v2 3/4] KVM: selftests: Enable pre_fault_memory_test for arm64 Jack Thomson
2025-10-13 15:15 ` [PATCH v2 4/4] KVM: selftests: Add option for different backing in pre-fault tests Jack Thomson

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=aQpfviS-oAmanqpq@google.com \
    --to=seanjc@google.com \
    --cc=catalin.marinas@arm.com \
    --cc=isaku.yamahata@intel.com \
    --cc=jackabt.amazon@gmail.com \
    --cc=jackabt@amazon.com \
    --cc=joey.gouly@arm.com \
    --cc=kalyazin@amazon.co.uk \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=roypat@amazon.co.uk \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).