Skip to content

Commit 14ca930

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Correctly access TCR2_EL1, PIR_EL1, PIRE0_EL1 with VHE
For code that accesses any of the guest registers for emulation purposes, it is crucial to know where the most up-to-date data is. While this is pretty clear for nVHE (memory is the sole repository), things are a lot muddier for VHE, as depending on the SYSREGS_ON_CPU flag, registers can either be loaded on the HW or be in memory. Even worse with NV, where the loaded state is by definition partial. For these reasons, KVM offers the vcpu_read_sys_reg() and vcpu_write_sys_reg() primitives that always do the right thing. However, these primitive must know what register to access, and this is the role of the __vcpu_read_sys_reg_from_cpu() and __vcpu_write_sys_reg_to_cpu() helpers. As it turns out, TCR2_EL1, PIR_EL1, PIRE0_EL1 and not described in the latter helpers, meaning that the AT code cannot use them to emulate S1PIE. Add the three registers to the (long) list. Fixes: 86f9de9 ("KVM: arm64: Save/restore PIE registers") Signed-off-by: Marc Zyngier <[email protected]> Cc: Joey Gouly <[email protected]> Reviewed-by: Joey Gouly <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent b9527b3 commit 14ca930

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,9 @@ static inline bool __vcpu_read_sys_reg_from_cpu(int reg, u64 *val)
10371037
case TTBR0_EL1: *val = read_sysreg_s(SYS_TTBR0_EL12); break;
10381038
case TTBR1_EL1: *val = read_sysreg_s(SYS_TTBR1_EL12); break;
10391039
case TCR_EL1: *val = read_sysreg_s(SYS_TCR_EL12); break;
1040+
case TCR2_EL1: *val = read_sysreg_s(SYS_TCR2_EL12); break;
1041+
case PIR_EL1: *val = read_sysreg_s(SYS_PIR_EL12); break;
1042+
case PIRE0_EL1: *val = read_sysreg_s(SYS_PIRE0_EL12); break;
10401043
case ESR_EL1: *val = read_sysreg_s(SYS_ESR_EL12); break;
10411044
case AFSR0_EL1: *val = read_sysreg_s(SYS_AFSR0_EL12); break;
10421045
case AFSR1_EL1: *val = read_sysreg_s(SYS_AFSR1_EL12); break;
@@ -1083,6 +1086,9 @@ static inline bool __vcpu_write_sys_reg_to_cpu(u64 val, int reg)
10831086
case TTBR0_EL1: write_sysreg_s(val, SYS_TTBR0_EL12); break;
10841087
case TTBR1_EL1: write_sysreg_s(val, SYS_TTBR1_EL12); break;
10851088
case TCR_EL1: write_sysreg_s(val, SYS_TCR_EL12); break;
1089+
case TCR2_EL1: write_sysreg_s(val, SYS_TCR2_EL12); break;
1090+
case PIR_EL1: write_sysreg_s(val, SYS_PIR_EL12); break;
1091+
case PIRE0_EL1: write_sysreg_s(val, SYS_PIRE0_EL12); break;
10861092
case ESR_EL1: write_sysreg_s(val, SYS_ESR_EL12); break;
10871093
case AFSR0_EL1: write_sysreg_s(val, SYS_AFSR0_EL12); break;
10881094
case AFSR1_EL1: write_sysreg_s(val, SYS_AFSR1_EL12); break;

0 commit comments

Comments
 (0)