Skip to content

Commit 3204be4

Browse files
author
Marc Zyngier
committed
KVM: arm64: Make vcpu_cp1x() work on Big Endian hosts
AArch32 CP1x registers are overlayed on their AArch64 counterparts in the vcpu struct. This leads to an interesting problem as they are stored in their CPU-local format, and thus a CP1x register doesn't "hit" the lower 32bit portion of the AArch64 register on a BE host. To workaround this unfortunate situation, introduce a bias trick in the vcpu_cp1x() accessors which picks the correct half of the 64bit register. Cc: [email protected] Reported-by: James Morse <[email protected]> Tested-by: James Morse <[email protected]> Acked-by: James Morse <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent e8679fe commit 3204be4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,10 @@ void vcpu_write_sys_reg(struct kvm_vcpu *vcpu, u64 val, int reg);
404404
* CP14 and CP15 live in the same array, as they are backed by the
405405
* same system registers.
406406
*/
407-
#define vcpu_cp14(v,r) ((v)->arch.ctxt.copro[(r)])
408-
#define vcpu_cp15(v,r) ((v)->arch.ctxt.copro[(r)])
407+
#define CPx_BIAS IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
408+
409+
#define vcpu_cp14(v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])
410+
#define vcpu_cp15(v,r) ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])
409411

410412
struct kvm_vm_stat {
411413
ulong remote_tlb_flush;

0 commit comments

Comments
 (0)