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

arm/arm64: KVM: PSCI: propagate caller endianness to the incoming vcpu

When booting a vcpu using PSCI, make sure we start it with the
endianness of the caller. Otherwise, secondaries can be pretty
unhappy to execute a BE kernel in LE mode...

This conforms to PSCI spec Rev B, 5.13.3.

Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

+17
+5
arch/arm/include/asm/kvm_emulate.h
··· 157 157 return kvm_vcpu_get_hsr(vcpu) & HSR_HVC_IMM_MASK; 158 158 } 159 159 160 + static inline void kvm_vcpu_set_be(struct kvm_vcpu *vcpu) 161 + { 162 + *vcpu_cpsr(vcpu) |= PSR_E_BIT; 163 + } 164 + 160 165 static inline bool kvm_vcpu_is_be(struct kvm_vcpu *vcpu) 161 166 { 162 167 return !!(*vcpu_cpsr(vcpu) & PSR_E_BIT);
+4
arch/arm/kvm/psci.c
··· 62 62 vcpu_set_thumb(vcpu); 63 63 } 64 64 65 + /* Propagate caller endianness */ 66 + if (kvm_vcpu_is_be(source_vcpu)) 67 + kvm_vcpu_set_be(vcpu); 68 + 65 69 *vcpu_pc(vcpu) = target_pc; 66 70 vcpu->arch.pause = false; 67 71 smp_mb(); /* Make sure the above is visible */
+8
arch/arm64/include/asm/kvm_emulate.h
··· 177 177 return kvm_vcpu_get_hsr(vcpu) & ESR_EL2_FSC_TYPE; 178 178 } 179 179 180 + static inline void kvm_vcpu_set_be(struct kvm_vcpu *vcpu) 181 + { 182 + if (vcpu_mode_is_32bit(vcpu)) 183 + *vcpu_cpsr(vcpu) |= COMPAT_PSR_E_BIT; 184 + else 185 + vcpu_sys_reg(vcpu, SCTLR_EL1) |= (1 << 25); 186 + } 187 + 180 188 static inline bool kvm_vcpu_is_be(struct kvm_vcpu *vcpu) 181 189 { 182 190 if (vcpu_mode_is_32bit(vcpu))