]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: x86/mmu: Prevent installing hugepages when mem attributes are changing
authorSean Christopherson <seanjc@google.com>
Wed, 30 Apr 2025 22:09:54 +0000 (15:09 -0700)
committerSean Christopherson <seanjc@google.com>
Fri, 2 May 2025 20:39:34 +0000 (13:39 -0700)
commit9129633d568edd36aa22bf703b12835153cec985
tree87f6ed8cc79bfd4a88a83d341b4288d10ae1ba42
parent5fea0c6c0ebe0a645c247f29fc683852cf51af70
KVM: x86/mmu: Prevent installing hugepages when mem attributes are changing

When changing memory attributes on a subset of a potential hugepage, add
the hugepage to the invalidation range tracking to prevent installing a
hugepage until the attributes are fully updated.  Like the actual hugepage
tracking updates in kvm_arch_post_set_memory_attributes(), process only
the head and tail pages, as any potential hugepages that are entirely
covered by the range will already be tracked.

Note, only hugepage chunks whose current attributes are NOT mixed need to
be added to the invalidation set, as mixed attributes already prevent
installing a hugepage, and it's perfectly safe to install a smaller
mapping for a gfn whose attributes aren't changing.

Fixes: 8dd2eee9d526 ("KVM: x86/mmu: Handle page fault for private memory")
Cc: stable@vger.kernel.org
Reported-by: Michael Roth <michael.roth@amd.com>
Tested-by: Michael Roth <michael.roth@amd.com>
Link: https://lore.kernel.org/r/20250430220954.522672-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/mmu/mmu.c