mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 08/16] KVM: arm64: Add helper to get permission fault granule from ESR
Date: Thu, 21 Aug 2025 14:00:34 -0700	[thread overview]
Message-ID: <20250821210042.3451147-9-seanjc@google.com> (raw)
In-Reply-To: <20250821210042.3451147-1-seanjc@google.com>

Extract KVM's code for getting the granule for a permission fault into a
standalone API that takes in a raw ESR, so that KVM can get the granule
from a local copy of the ESR instead of re-retrieving the value from the
vCPU.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 arch/arm64/include/asm/esr.h         | 6 ++++++
 arch/arm64/include/asm/kvm_emulate.h | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/esr.h b/arch/arm64/include/asm/esr.h
index e1deed824464..5bb99cfd184a 100644
--- a/arch/arm64/include/asm/esr.h
+++ b/arch/arm64/include/asm/esr.h
@@ -8,6 +8,7 @@
 #define __ASM_ESR_H
 
 #include <asm/memory.h>
+#include <asm/pgtable-hwdef.h>
 #include <asm/sysreg.h>
 
 #define ESR_ELx_EC_UNKNOWN	UL(0x00)
@@ -478,6 +479,11 @@ static inline bool esr_fsc_is_permission_fault(unsigned long esr)
 	       (esr == ESR_ELx_FSC_PERM_L(0));
 }
 
+static inline u64 esr_fsc_perm_fault_granule(unsigned long esr)
+{
+	return BIT(ARM64_HW_PGTABLE_LEVEL_SHIFT(esr & ESR_ELx_FSC_LEVEL));
+}
+
 static inline bool esr_fsc_is_access_flag_fault(unsigned long esr)
 {
 	esr = esr & ESR_ELx_FSC;
diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
index fa8a08a1ccd5..8065f54927cb 100644
--- a/arch/arm64/include/asm/kvm_emulate.h
+++ b/arch/arm64/include/asm/kvm_emulate.h
@@ -455,7 +455,7 @@ u64 kvm_vcpu_trap_get_perm_fault_granule(const struct kvm_vcpu *vcpu)
 	unsigned long esr = kvm_vcpu_get_esr(vcpu);
 
 	BUG_ON(!esr_fsc_is_permission_fault(esr));
-	return BIT(ARM64_HW_PGTABLE_LEVEL_SHIFT(esr & ESR_ELx_FSC_LEVEL));
+	return esr_fsc_perm_fault_granule(esr);
 }
 
 static __always_inline bool kvm_vcpu_abt_issea(const struct kvm_vcpu *vcpu)
-- 
2.51.0.261.g7ce5a0a67e-goog


  parent reply	other threads:[~2025-08-21 21:01 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 ` [RFC PATCH 06/16] KVM: arm64: Pass kvm_page_fault pointer to transparent_hugepage_adjust() Sean Christopherson
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 ` Sean Christopherson [this message]
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-9-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

all inboxes | Powered by JetHome®