Re: [PATCH v2] KVM: arm64: Correctly handle page aging notifiers for unaligned memslot

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

 



On Tue, Jun 27, 2023 at 11:54:05PM +0000, Oliver Upton wrote:
> Userspace is allowed to select any PAGE_SIZE aligned hva to back guest
> memory. This is even the case with hugepages, although it is a rather
> suboptimal configuration as PTE level mappings are used at stage-2.
> 
> The arm64 page aging handlers have an assumption that the specified
> range is exactly one page/block of memory, which in the aforementioned
> case is not necessarily true. All together this leads to the WARN() in
> kvm_age_gfn() firing.
> 
> However, the WARN is only part of the issue as the table walkers visit
> at most a single leaf PTE. For hugepage-backed memory in a memslot that
> isn't hugepage-aligned, page aging entirely misses accesses to the
> hugepage beyond the first page in the memslot.
> 
> Add a new walker dedicated to handling page aging MMU notifiers capable
> of walking a range of PTEs. Convert kvm(_test)_age_gfn() over to the new
> walker and drop the WARN that caught the issue in the first place. The
> implementation of this walker was inspired by the test_clear_young()
> implementation by Yu Zhao [*], but repurposed to address a bug in the
> existing aging implementation.
> 
> Cc: stable@xxxxxxxxxxxxxxx # v5.15
> Fixes: 056aad67f836 ("kvm: arm/arm64: Rework gpa callback handlers")
> Link: https://lore.kernel.org/kvmarm/20230526234435.662652-6-yuzhao@xxxxxxxxxx/
> Co-developed-by: Yu Zhao <yuzhao@xxxxxxxxxx>
> Signed-off-by: Yu Zhao <yuzhao@xxxxxxxxxx>
> Reported-by: Reiji Watanabe <reijiw@xxxxxxxxxx>
> Signed-off-by: Oliver Upton <oliver.upton@xxxxxxxxx>
> ---

Derp. I blew away my patch that had comments here.

Marc, per our discussion forever ago, I went about implementing a
dedicated walker for handling the page aging notifiers. This aligns
pretty well with the test_clear_young() changes that Yu is working on.
So much so that I repurposed some of the plumbing.

I'd like to limit backports to 5.15, as making this patch work with the
old hva-to-gfn notifier dance doesn't seem worth the effort to me.
Tested with access_tracking_perf_test.

v1: https://lore.kernel.org/kvmarm/20230111000300.2034799-1-oliver.upton@xxxxxxxxx/

--
Thanks,
Oliver



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux