Skip to content

Commit 69adec1

Browse files
author
Marc Zyngier
committed
KVM: arm64: Fix reporting of endianess when the access originates at EL0
We currently check SCTLR_EL1.EE when computing the address of a faulting guest access. However, the fault could have occured at EL0, in which case the right bit to check would be SCTLR_EL1.E0E. This is pretty unlikely to cause any issue in practice: You'd have to have a guest with a LE EL1 and a BE EL0 (or the other way around), and have mapped a device into the EL0 page tables. Good luck with that! Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e26bb75 commit 69adec1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ static inline bool kvm_vcpu_is_be(struct kvm_vcpu *vcpu)
396396
if (vcpu_mode_is_32bit(vcpu))
397397
return !!(*vcpu_cpsr(vcpu) & PSR_AA32_E_BIT);
398398

399-
return !!(vcpu_read_sys_reg(vcpu, SCTLR_EL1) & (1 << 25));
399+
if (vcpu_mode_priv(vcpu))
400+
return !!(vcpu_read_sys_reg(vcpu, SCTLR_EL1) & SCTLR_ELx_EE);
401+
else
402+
return !!(vcpu_read_sys_reg(vcpu, SCTLR_EL1) & SCTLR_EL1_E0E);
400403
}
401404

402405
static inline unsigned long vcpu_data_guest_to_host(struct kvm_vcpu *vcpu,

0 commit comments

Comments
 (0)