Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: Introduce helper to calculate fault IPA offset

This 12-bit FAR fault IPA offset mask is hard-coded as 'GENMASK(11, 0)'
in several places to reconstruct the full fault IPA.

Introduce FAR_TO_FIPA_OFFSET() to calculate this value in a shared
header and replace all open-coded instances to improve readability.

No functional change intended.

Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20251211104710.151771-5-tabba@google.com
Signed-off-by: Marc Zyngier <maz@kernel.org>

authored by

Fuad Tabba and committed by
Marc Zyngier
c273feee ebbcaece

+6 -4
+2
arch/arm64/include/asm/kvm_arm.h
··· 344 344 #define PAR_TO_HPFAR(par) \ 345 345 (((par) & GENMASK_ULL(52 - 1, 12)) >> 8) 346 346 347 + #define FAR_TO_FIPA_OFFSET(far) ((far) & GENMASK_ULL(11, 0)) 348 + 347 349 #define ECN(x) { ESR_ELx_EC_##x, #x } 348 350 349 351 #define kvm_arm_exception_class \
+1 -1
arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c
··· 44 44 45 45 /* Build the full address */ 46 46 fault_ipa = kvm_vcpu_get_fault_ipa(vcpu); 47 - fault_ipa |= kvm_vcpu_get_hfar(vcpu) & GENMASK(11, 0); 47 + fault_ipa |= FAR_TO_FIPA_OFFSET(kvm_vcpu_get_hfar(vcpu)); 48 48 49 49 /* If not for GICV, move on */ 50 50 if (fault_ipa < vgic->vgic_cpu_base ||
+1 -1
arch/arm64/kvm/inject_fault.c
··· 258 258 unsigned long addr, esr; 259 259 260 260 addr = kvm_vcpu_get_fault_ipa(vcpu); 261 - addr |= kvm_vcpu_get_hfar(vcpu) & GENMASK(11, 0); 261 + addr |= FAR_TO_FIPA_OFFSET(kvm_vcpu_get_hfar(vcpu)); 262 262 263 263 __kvm_inject_sea(vcpu, kvm_vcpu_trap_is_iabt(vcpu), addr); 264 264
+2 -2
arch/arm64/kvm/mmu.c
··· 2070 2070 2071 2071 /* Falls between the IPA range and the PARange? */ 2072 2072 if (fault_ipa >= BIT_ULL(VTCR_EL2_IPA(vcpu->arch.hw_mmu->vtcr))) { 2073 - fault_ipa |= kvm_vcpu_get_hfar(vcpu) & GENMASK(11, 0); 2073 + fault_ipa |= FAR_TO_FIPA_OFFSET(kvm_vcpu_get_hfar(vcpu)); 2074 2074 2075 2075 return kvm_inject_sea(vcpu, is_iabt, fault_ipa); 2076 2076 } ··· 2175 2175 * faulting VA. This is always 12 bits, irrespective 2176 2176 * of the page size. 2177 2177 */ 2178 - ipa |= kvm_vcpu_get_hfar(vcpu) & GENMASK(11, 0); 2178 + ipa |= FAR_TO_FIPA_OFFSET(kvm_vcpu_get_hfar(vcpu)); 2179 2179 ret = io_mem_abort(vcpu, ipa); 2180 2180 goto out_unlock; 2181 2181 }