Skip to content

Commit 59b6d08

Browse files
committed
KVM: arm64: nv: Honor SError routing effects of SCTLR2_ELx.NMEA
As the name might imply, when NMEA is set SErrors are non-maskable and can be taken regardless of PSTATE.A. As is the recurring theme with DoubleFault2, the effects on SError routing are entirely backwards to this. If at EL1, NMEA is *not* considered for SError routing when TMEA is set and the exception is taken to EL2 when PSTATE.A is set. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent ce66109 commit 59b6d08

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

arch/arm64/kvm/inject_fault.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ static bool effective_sctlr2_ease(struct kvm_vcpu *vcpu)
9797
return __effective_sctlr2_bit(vcpu, SCTLR2_EL1_EASE_SHIFT);
9898
}
9999

100+
static bool effective_sctlr2_nmea(struct kvm_vcpu *vcpu)
101+
{
102+
return __effective_sctlr2_bit(vcpu, SCTLR2_EL1_NMEA_SHIFT);
103+
}
104+
100105
static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr)
101106
{
102107
unsigned long cpsr = *vcpu_cpsr(vcpu);
@@ -267,7 +272,7 @@ void kvm_inject_undefined(struct kvm_vcpu *vcpu)
267272

268273
static bool serror_is_masked(struct kvm_vcpu *vcpu)
269274
{
270-
return *vcpu_cpsr(vcpu) & PSR_A_BIT;
275+
return (*vcpu_cpsr(vcpu) & PSR_A_BIT) && !effective_sctlr2_nmea(vcpu);
271276
}
272277

273278
static bool kvm_serror_target_is_el2(struct kvm_vcpu *vcpu)
@@ -278,6 +283,19 @@ static bool kvm_serror_target_is_el2(struct kvm_vcpu *vcpu)
278283
if (!(__vcpu_sys_reg(vcpu, HCRX_EL2) & HCRX_EL2_TMEA))
279284
return false;
280285

286+
/*
287+
* In another example where FEAT_DoubleFault2 is entirely backwards,
288+
* "masked" as it relates to the routing effects of HCRX_EL2.TMEA
289+
* doesn't consider SCTLR2_EL1.NMEA. That is to say, even if EL1 asked
290+
* for non-maskable SErrors, the EL2 bit takes priority if A is set.
291+
*/
292+
if (vcpu_mode_priv(vcpu))
293+
return *vcpu_cpsr(vcpu) & PSR_A_BIT;
294+
295+
/*
296+
* Otherwise SErrors are considered unmasked when taken from EL0 and
297+
* NMEA is set.
298+
*/
281299
return serror_is_masked(vcpu);
282300
}
283301

0 commit comments

Comments
 (0)