Skip to content

Commit fbff560

Browse files
jgoulyctmarinas
authored andcommitted
KVM: arm64: Save/restore TCR2_EL1
Define the new system register TCR2_EL1 and context switch it. Signed-off-by: Joey Gouly <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Oliver Upton <[email protected]> Cc: James Morse <[email protected]> Cc: Suzuki K Poulose <[email protected]> Cc: Zenghui Yu <[email protected]> Cc: Will Deacon <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent e43454c commit fbff560

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ enum vcpu_sysreg {
279279
TTBR0_EL1, /* Translation Table Base Register 0 */
280280
TTBR1_EL1, /* Translation Table Base Register 1 */
281281
TCR_EL1, /* Translation Control Register */
282+
TCR2_EL1, /* Extended Translation Control Register */
282283
ESR_EL1, /* Exception Syndrome Register */
283284
AFSR0_EL1, /* Auxiliary Fault Status Register 0 */
284285
AFSR1_EL1, /* Auxiliary Fault Status Register 1 */

arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt)
4444
ctxt_sys_reg(ctxt, TTBR0_EL1) = read_sysreg_el1(SYS_TTBR0);
4545
ctxt_sys_reg(ctxt, TTBR1_EL1) = read_sysreg_el1(SYS_TTBR1);
4646
ctxt_sys_reg(ctxt, TCR_EL1) = read_sysreg_el1(SYS_TCR);
47+
if (cpus_have_final_cap(ARM64_HAS_TCR2))
48+
ctxt_sys_reg(ctxt, TCR2_EL1) = read_sysreg_el1(SYS_TCR2);
4749
ctxt_sys_reg(ctxt, ESR_EL1) = read_sysreg_el1(SYS_ESR);
4850
ctxt_sys_reg(ctxt, AFSR0_EL1) = read_sysreg_el1(SYS_AFSR0);
4951
ctxt_sys_reg(ctxt, AFSR1_EL1) = read_sysreg_el1(SYS_AFSR1);
@@ -114,6 +116,8 @@ static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)
114116
write_sysreg_el1(ctxt_sys_reg(ctxt, CPACR_EL1), SYS_CPACR);
115117
write_sysreg_el1(ctxt_sys_reg(ctxt, TTBR0_EL1), SYS_TTBR0);
116118
write_sysreg_el1(ctxt_sys_reg(ctxt, TTBR1_EL1), SYS_TTBR1);
119+
if (cpus_have_final_cap(ARM64_HAS_TCR2))
120+
write_sysreg_el1(ctxt_sys_reg(ctxt, TCR2_EL1), SYS_TCR2);
117121
write_sysreg_el1(ctxt_sys_reg(ctxt, ESR_EL1), SYS_ESR);
118122
write_sysreg_el1(ctxt_sys_reg(ctxt, AFSR0_EL1), SYS_AFSR0);
119123
write_sysreg_el1(ctxt_sys_reg(ctxt, AFSR1_EL1), SYS_AFSR1);

arch/arm64/kvm/sys_regs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
18931893
{ SYS_DESC(SYS_TTBR0_EL1), access_vm_reg, reset_unknown, TTBR0_EL1 },
18941894
{ SYS_DESC(SYS_TTBR1_EL1), access_vm_reg, reset_unknown, TTBR1_EL1 },
18951895
{ SYS_DESC(SYS_TCR_EL1), access_vm_reg, reset_val, TCR_EL1, 0 },
1896+
{ SYS_DESC(SYS_TCR2_EL1), access_vm_reg, reset_val, TCR2_EL1, 0 },
18961897

18971898
PTRAUTH_KEY(APIA),
18981899
PTRAUTH_KEY(APIB),

0 commit comments

Comments
 (0)