From: Sean Christopherson <seanjc@google.com>
To: Marc Zyngier <maz@kernel.org>, Oliver Upton <oliver.upton@linux.dev>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
linux-kernel@vger.kernel.org,
Sean Christopherson <seanjc@google.com>,
James Houghton <jthoughton@google.com>
Subject: [RFC PATCH 06/16] KVM: arm64: Pass kvm_page_fault pointer to transparent_hugepage_adjust()
Date: Thu, 21 Aug 2025 14:00:32 -0700 [thread overview]
Message-ID: <20250821210042.3451147-7-seanjc@google.com> (raw)
In-Reply-To: <20250821210042.3451147-1-seanjc@google.com>
Use the local kvm_page_fault structure to adjust for transparent hugepages
when resolving guest aborts, to reduce the number of parameters from 5=>2,
and to eliminate the less-than-pleasant pointer dereferences.
No functional change intended.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/arm64/kvm/mmu.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index ca98778989b2..047aba00388c 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -1361,19 +1361,15 @@ static bool fault_supports_stage2_huge_mapping(struct kvm_memory_slot *memslot,
* Returns the size of the mapping.
*/
static long
-transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot,
- unsigned long hva, kvm_pfn_t *pfnp,
- phys_addr_t *ipap)
+transparent_hugepage_adjust(struct kvm *kvm, struct kvm_page_fault *fault)
{
- kvm_pfn_t pfn = *pfnp;
-
/*
* Make sure the adjustment is done only for THP pages. Also make
* sure that the HVA and IPA are sufficiently aligned and that the
* block map is contained within the memslot.
*/
- if (fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE)) {
- int sz = get_user_mapping_size(kvm, hva);
+ if (fault_supports_stage2_huge_mapping(fault->slot, fault->hva, PMD_SIZE)) {
+ int sz = get_user_mapping_size(kvm, fault->hva);
if (sz < 0)
return sz;
@@ -1381,10 +1377,8 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot,
if (sz < PMD_SIZE)
return PAGE_SIZE;
- *ipap &= PMD_MASK;
- pfn &= ~(PTRS_PER_PMD - 1);
- *pfnp = pfn;
-
+ fault->ipa &= PMD_MASK;
+ fault->pfn &= ~(PTRS_PER_PMD - 1);
return PMD_SIZE;
}
@@ -1724,9 +1718,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
if (fault->is_perm && fault_granule > PAGE_SIZE)
vma_pagesize = fault_granule;
else
- vma_pagesize = transparent_hugepage_adjust(kvm, fault->slot,
- fault->hva, &fault->pfn,
- &fault->fault_ipa);
+ vma_pagesize = transparent_hugepage_adjust(kvm, fault);
if (vma_pagesize < 0) {
ret = vma_pagesize;
--
2.51.0.261.g7ce5a0a67e-goog
next prev parent reply other threads:[~2025-08-21 21:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 21:00 [RFC PATCH 00/16] KVM: arm64: Add "struct kvm_page_fault" Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 01/16] KVM: arm64: Drop nested "esr" to eliminate variable shadowing Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 02/16] KVM: arm64: Get iabt status on-demand Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 03/16] KVM: arm64: Move SRCU-protected region of kvm_handle_guest_abort() to helper Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 04/16] KVM: arm64: Use guard(srcu) in kvm_handle_guest_abort() Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 05/16] KVM: arm64: Introduce "struct kvm_page_fault" for tracking abort state Sean Christopherson
2025-08-21 22:31 ` Oliver Upton
2025-08-26 18:58 ` Sean Christopherson
2025-08-26 19:29 ` Oliver Upton
2025-08-26 21:29 ` Sean Christopherson
2025-08-21 21:00 ` Sean Christopherson [this message]
2025-08-21 21:00 ` [RFC PATCH 07/16] KVM: arm64: Pass @fault to fault_supports_stage2_huge_mapping() Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 08/16] KVM: arm64: Add helper to get permission fault granule from ESR Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 09/16] KVM: arm64: Track perm fault granule in "struct kvm_page_fault" Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 10/16] KVM: arm64: Drop local vfio_allow_any_uc, use vm_flags snapshot Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 11/16] KVM: arm64: Drop local mte_allowed, " Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 12/16] KVM: arm64: Move VMA-related information into "struct kvm_page_fault" Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 13/16] KVM: arm64: Stash "mmu_seq" in " Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 14/16] KVM: arm64: Track "forced" information " Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 15/16] KVM: arm64: Extract mmap_lock-protected code to helper for user mem aborts Sean Christopherson
2025-08-21 21:00 ` [RFC PATCH 16/16] KVM: arm64: Don't bother nullifying "vma" in mem abort path Sean Christopherson
2025-08-21 22:39 ` [RFC PATCH 00/16] KVM: arm64: Add "struct kvm_page_fault" Oliver Upton
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=20250821210042.3451147-7-seanjc@google.com \
--to=seanjc@google.com \
--cc=jthoughton@google.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@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