|
16 | 16 | #include <asm/kvm_hyp.h> |
17 | 17 | #include <asm/kvm_mmu.h> |
18 | 18 |
|
| 19 | +#define SYS_IMP_APL_ACTLR_EL12 sys_reg(3, 6, 15, 14, 6) |
| 20 | +#define SYS_ACTLR_EL12 sys_reg(3, 5, 1, 0, 1) |
| 21 | + |
19 | 22 | static inline bool ctxt_has_s1poe(struct kvm_cpu_context *ctxt); |
20 | 23 |
|
21 | 24 | static inline struct kvm_vcpu *ctxt_to_vcpu(struct kvm_cpu_context *ctxt) |
@@ -147,6 +150,12 @@ static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt) |
147 | 150 | ctxt_sys_reg(ctxt, SP_EL1) = read_sysreg(sp_el1); |
148 | 151 | ctxt_sys_reg(ctxt, ELR_EL1) = read_sysreg_el1(SYS_ELR); |
149 | 152 | ctxt_sys_reg(ctxt, SPSR_EL1) = read_sysreg_el1(SYS_SPSR); |
| 153 | + if (IS_ENABLED(CONFIG_ARM64_ACTLR_STATE)) { |
| 154 | + if (alternative_has_cap_unlikely(ARM64_HAS_ACTLR_VIRT)) |
| 155 | + ctxt_sys_reg(ctxt, ACTLR_EL1) = read_sysreg_s(SYS_ACTLR_EL12); |
| 156 | + else if (alternative_has_cap_unlikely(ARM64_HAS_ACTLR_VIRT_APPLE)) |
| 157 | + ctxt_sys_reg(ctxt, ACTLR_EL1) = read_sysreg_s(SYS_IMP_APL_ACTLR_EL12); |
| 158 | + } |
150 | 159 | } |
151 | 160 |
|
152 | 161 | static inline void __sysreg_save_el2_return_state(struct kvm_cpu_context *ctxt) |
@@ -226,6 +235,13 @@ static inline void __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt, |
226 | 235 | write_sysreg(ctxt_sys_reg(ctxt, PAR_EL1), par_el1); |
227 | 236 | write_sysreg(ctxt_sys_reg(ctxt, TPIDR_EL1), tpidr_el1); |
228 | 237 |
|
| 238 | + if (IS_ENABLED(CONFIG_ARM64_ACTLR_STATE)) { |
| 239 | + if (alternative_has_cap_unlikely(ARM64_HAS_ACTLR_VIRT)) |
| 240 | + write_sysreg_s(ctxt_sys_reg(ctxt, ACTLR_EL1), SYS_ACTLR_EL12); |
| 241 | + else if (alternative_has_cap_unlikely(ARM64_HAS_ACTLR_VIRT_APPLE)) |
| 242 | + write_sysreg_s(ctxt_sys_reg(ctxt, ACTLR_EL1), SYS_IMP_APL_ACTLR_EL12); |
| 243 | + } |
| 244 | + |
229 | 245 | if (ctxt_has_mte(ctxt)) { |
230 | 246 | write_sysreg_el1(ctxt_sys_reg(ctxt, TFSR_EL1), SYS_TFSR); |
231 | 247 | write_sysreg_s(ctxt_sys_reg(ctxt, TFSRE0_EL1), SYS_TFSRE0_EL1); |
|
0 commit comments