Skip to contentSkip to conversation

KVM: arm64: Correctly populate FAR_EL2 on nested SEA injection

PATCH In review Marc Zyngier 3 participants 3 messages Aug 13, 2025 – Aug 15, 2025

Subsystems (3)
lore
Share & tools
lore

Marc Zyngier

author maintainer
#0 lore raw

PATCH 1/1 KVM: arm64: Correctly populate FAR_EL2 on nested SEA injection

vcoy_write_sys_reg()'s signature is not totally obvious, and it is rather easy to write something that looks correct, except that... Oh wait...

Swap addr and FAR_EL2 to restore some sanity in the nested SEA department.

Fixes 9aba641b9ec2a ("KVM: arm64: nv: Respect exception routing rules for SEAs")
---
 arch/arm64/kvm/emulate-nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/emulate-nested.c +1 -1
index 90cb4b7ae0ff7..af69c897c2c3a 100644
@@ -2833,7 +2833,7 @@ int kvm_inject_nested_sea(struct kvm_vcpu *vcpu, bool iabt, u64 addr)
 			     iabt ? ESR_ELx_EC_IABT_LOW : ESR_ELx_EC_DABT_LOW);
 	esr |= ESR_ELx_FSC_EXTABT | ESR_ELx_IL;
 
-	vcpu_write_sys_reg(vcpu, FAR_EL2, addr);
+	vcpu_write_sys_reg(vcpu, addr, FAR_EL2);
 
 	if (__vcpu_sys_reg(vcpu, SCTLR2_EL2) & SCTLR2_EL1_EASE)
 		return kvm_inject_nested(vcpu, esr, except_type_serror);
Signature · 1 line
2.39.2
#1 lore raw

Hi Marc,

This patch looks good to me. Just a typo in the commit message.

Quoted 1 line · Marc Zyngier

vcoy_write_sys_reg()'s signature is not totally obvious, and it

typo: s/vcoy/vcpu/

Quoted 17 lines

is rather easy to write something that looks correct, except that... Oh wait...

Swap addr and FAR_EL2 to restore some sanity in the nested SEA department.

Fixes 9aba641b9ec2a ("KVM: arm64: nv: Respect exception routing rules for SEAs")
---
  arch/arm64/kvm/emulate-nested.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/emulate-nested.c +0 -0
index 90cb4b7ae0ff7..af69c897c2c3a 100644

arch/arm64/kvm/emulate-nested.c int kvm_inject_nested_sea(struct kvm_vcpu *vcpu, bool iabt, u64 addr) · line 2839

Quoted 8 lines
arch/arm64/kvm/emulate-nested.c +1 -1
@@ -2833,7 +2833,7 @@ int kvm_inject_nested_sea(struct kvm_vcpu *vcpu, bool iabt, u64 addr)
  			     iabt ? ESR_ELx_EC_IABT_LOW : ESR_ELx_EC_DABT_LOW);
  	esr |= ESR_ELx_FSC_EXTABT | ESR_ELx_IL;
 
-	vcpu_write_sys_reg(vcpu, FAR_EL2, addr);
+	vcpu_write_sys_reg(vcpu, addr, FAR_EL2);
 
  	if (__vcpu_sys_reg(vcpu, SCTLR2_EL2) & SCTLR2_EL1_EASE)
  		return kvm_inject_nested(vcpu, esr, except_type_serror);

Thanks,

Ben

#2 lore raw
In reply to Marc Zyngier
Quoted 8 lines · Marc Zyngier

vcoy_write_sys_reg()'s signature is not totally obvious, and it is rather easy to write something that looks correct, except that... Oh wait...

Swap addr and FAR_EL2 to restore some sanity in the nested SEA department.

[...]

Sorry I didn't pick this up immediately, had to find my brown bag...

With the typo addressed: applied to fixes, thanks!

[1/1] KVM: arm64: Correctly populate FAR_EL2 on nested SEA injection

      https://git.kernel.org/kvmarm/kvmarm/c/d19c541d269e

--
Best,
Oliver