Skip to content

Commit 69f8fe9

Browse files
committed
KVM: arm64: nv: Handle SEAs due to VNCR redirection
System register accesses redirected to the VNCR page can also generate external aborts just like any other form of memory access. Route to kvm_handle_guest_sea() for potential APEI handling, falling back to a vSError if the kernel didn't handle the abort. Take the opportunity to throw out the useless kvm_ras.h which provided a helper with a single callsite... Cc: Jiaqi Yan <jiaqiyan@google.com> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20250729182342.3281742-1-oliver.upton@linux.dev Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 07f557f commit 69f8fe9

File tree

4 files changed

+21
-37
lines changed

4 files changed

+21
-37
lines changed

arch/arm64/include/asm/kvm_mmu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu);
180180
int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
181181
phys_addr_t pa, unsigned long size, bool writable);
182182

183+
int kvm_handle_guest_sea(struct kvm_vcpu *vcpu);
183184
int kvm_handle_guest_abort(struct kvm_vcpu *vcpu);
184185

185186
phys_addr_t kvm_mmu_get_httbr(void);

arch/arm64/include/asm/kvm_ras.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

arch/arm64/kvm/mmu.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
* Author: Christoffer Dall <c.dall@virtualopensystems.com>
55
*/
66

7+
#include <linux/acpi.h>
78
#include <linux/mman.h>
89
#include <linux/kvm_host.h>
910
#include <linux/io.h>
1011
#include <linux/hugetlb.h>
1112
#include <linux/sched/signal.h>
1213
#include <trace/events/kvm.h>
14+
#include <asm/acpi.h>
1315
#include <asm/pgalloc.h>
1416
#include <asm/cacheflush.h>
1517
#include <asm/kvm_arm.h>
1618
#include <asm/kvm_mmu.h>
1719
#include <asm/kvm_pgtable.h>
1820
#include <asm/kvm_pkvm.h>
19-
#include <asm/kvm_ras.h>
2021
#include <asm/kvm_asm.h>
2122
#include <asm/kvm_emulate.h>
2223
#include <asm/virt.h>
@@ -1811,6 +1812,19 @@ static void handle_access_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa)
18111812
read_unlock(&vcpu->kvm->mmu_lock);
18121813
}
18131814

1815+
int kvm_handle_guest_sea(struct kvm_vcpu *vcpu)
1816+
{
1817+
/*
1818+
* Give APEI the opportunity to claim the abort before handling it
1819+
* within KVM. apei_claim_sea() expects to be called with IRQs enabled.
1820+
*/
1821+
lockdep_assert_irqs_enabled();
1822+
if (apei_claim_sea(NULL) == 0)
1823+
return 1;
1824+
1825+
return kvm_inject_serror(vcpu);
1826+
}
1827+
18141828
/**
18151829
* kvm_handle_guest_abort - handles all 2nd stage aborts
18161830
* @vcpu: the VCPU pointer
@@ -1834,17 +1848,8 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu)
18341848
gfn_t gfn;
18351849
int ret, idx;
18361850

1837-
/* Synchronous External Abort? */
1838-
if (kvm_vcpu_abt_issea(vcpu)) {
1839-
/*
1840-
* For RAS the host kernel may handle this abort.
1841-
* There is no need to pass the error into the guest.
1842-
*/
1843-
if (kvm_handle_guest_sea())
1844-
return kvm_inject_serror(vcpu);
1845-
1846-
return 1;
1847-
}
1851+
if (kvm_vcpu_abt_issea(vcpu))
1852+
return kvm_handle_guest_sea(vcpu);
18481853

18491854
esr = kvm_vcpu_get_esr(vcpu);
18501855

arch/arm64/kvm/nested.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,9 @@ int kvm_handle_vncr_abort(struct kvm_vcpu *vcpu)
12891289

12901290
WARN_ON_ONCE(!(esr & ESR_ELx_VNCR));
12911291

1292+
if (kvm_vcpu_abt_issea(vcpu))
1293+
return kvm_handle_guest_sea(vcpu);
1294+
12921295
if (esr_fsc_is_permission_fault(esr)) {
12931296
inject_vncr_perm(vcpu);
12941297
} else if (esr_fsc_is_translation_fault(esr)) {

0 commit comments

Comments
 (0)