Skip to content

Commit 86f9de9

Browse files
jgoulyctmarinas
authored andcommitted
KVM: arm64: Save/restore PIE registers
Define the new system registers that PIE introduces and context switch them. The PIE feature is still hidden from the ID register, and not exposed to a VM. 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 fbff560 commit 86f9de9

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ enum vcpu_sysreg {
340340
TFSR_EL1, /* Tag Fault Status Register (EL1) */
341341
TFSRE0_EL1, /* Tag Fault Status Register (EL0) */
342342

343+
/* Permission Indirection Extension registers */
344+
PIR_EL1, /* Permission Indirection Register 1 (EL1) */
345+
PIRE0_EL1, /* Permission Indirection Register 0 (EL1) */
346+
343347
/* 32bit specific registers. */
344348
DACR32_EL2, /* Domain Access Control Register */
345349
IFSR32_EL2, /* Instruction Fault Status Register */

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt)
5555
ctxt_sys_reg(ctxt, CONTEXTIDR_EL1) = read_sysreg_el1(SYS_CONTEXTIDR);
5656
ctxt_sys_reg(ctxt, AMAIR_EL1) = read_sysreg_el1(SYS_AMAIR);
5757
ctxt_sys_reg(ctxt, CNTKCTL_EL1) = read_sysreg_el1(SYS_CNTKCTL);
58+
if (cpus_have_final_cap(ARM64_HAS_S1PIE)) {
59+
ctxt_sys_reg(ctxt, PIR_EL1) = read_sysreg_el1(SYS_PIR);
60+
ctxt_sys_reg(ctxt, PIRE0_EL1) = read_sysreg_el1(SYS_PIRE0);
61+
}
5862
ctxt_sys_reg(ctxt, PAR_EL1) = read_sysreg_par();
5963
ctxt_sys_reg(ctxt, TPIDR_EL1) = read_sysreg(tpidr_el1);
6064

@@ -127,6 +131,10 @@ static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)
127131
write_sysreg_el1(ctxt_sys_reg(ctxt, CONTEXTIDR_EL1), SYS_CONTEXTIDR);
128132
write_sysreg_el1(ctxt_sys_reg(ctxt, AMAIR_EL1), SYS_AMAIR);
129133
write_sysreg_el1(ctxt_sys_reg(ctxt, CNTKCTL_EL1), SYS_CNTKCTL);
134+
if (cpus_have_final_cap(ARM64_HAS_S1PIE)) {
135+
write_sysreg_el1(ctxt_sys_reg(ctxt, PIR_EL1), SYS_PIR);
136+
write_sysreg_el1(ctxt_sys_reg(ctxt, PIRE0_EL1), SYS_PIRE0);
137+
}
130138
write_sysreg(ctxt_sys_reg(ctxt, PAR_EL1), par_el1);
131139
write_sysreg(ctxt_sys_reg(ctxt, TPIDR_EL1), tpidr_el1);
132140

arch/arm64/kvm/sys_regs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,8 @@ static const struct sys_reg_desc sys_reg_descs[] = {
19431943
{ SYS_DESC(SYS_PMMIR_EL1), trap_raz_wi },
19441944

19451945
{ SYS_DESC(SYS_MAIR_EL1), access_vm_reg, reset_unknown, MAIR_EL1 },
1946+
{ SYS_DESC(SYS_PIRE0_EL1), access_vm_reg, reset_unknown, PIRE0_EL1 },
1947+
{ SYS_DESC(SYS_PIR_EL1), access_vm_reg, reset_unknown, PIR_EL1 },
19461948
{ SYS_DESC(SYS_AMAIR_EL1), access_vm_reg, reset_amair_el1, AMAIR_EL1 },
19471949

19481950
{ SYS_DESC(SYS_LORSA_EL1), trap_loregion },

0 commit comments

Comments
 (0)