Skip to content

Commit b3ad940

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Add save/restore for PIR{,E0}_EL2
Like their EL1 equivalent, the EL2-specific FEAT_S1PIE registers are context-switched. This is made conditional on both FEAT_TCRX and FEAT_S1PIE being adversised. Note that this change only makes sense if read together with the issue D22677 contained in 102105_K.a_04_en. Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 5f8d5a1 commit b3ad940

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

arch/arm64/kvm/hyp/vhe/sysreg-sr.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,15 @@ static void __sysreg_save_vel2_state(struct kvm_vcpu *vcpu)
5151
__vcpu_sys_reg(vcpu, TTBR1_EL2) = read_sysreg_el1(SYS_TTBR1);
5252
__vcpu_sys_reg(vcpu, TCR_EL2) = read_sysreg_el1(SYS_TCR);
5353

54-
if (ctxt_has_tcrx(&vcpu->arch.ctxt))
54+
if (ctxt_has_tcrx(&vcpu->arch.ctxt)) {
5555
__vcpu_sys_reg(vcpu, TCR2_EL2) = read_sysreg_el1(SYS_TCR2);
5656

57+
if (ctxt_has_s1pie(&vcpu->arch.ctxt)) {
58+
__vcpu_sys_reg(vcpu, PIRE0_EL2) = read_sysreg_el1(SYS_PIRE0);
59+
__vcpu_sys_reg(vcpu, PIR_EL2) = read_sysreg_el1(SYS_PIR);
60+
}
61+
}
62+
5763
/*
5864
* The EL1 view of CNTKCTL_EL1 has a bunch of RES0 bits where
5965
* the interesting CNTHCTL_EL2 bits live. So preserve these
@@ -110,9 +116,14 @@ static void __sysreg_restore_vel2_state(struct kvm_vcpu *vcpu)
110116
write_sysreg_el1(val, SYS_TCR);
111117
}
112118

113-
if (ctxt_has_tcrx(&vcpu->arch.ctxt))
119+
if (ctxt_has_tcrx(&vcpu->arch.ctxt)) {
114120
write_sysreg_el1(__vcpu_sys_reg(vcpu, TCR2_EL2), SYS_TCR2);
115121

122+
if (ctxt_has_s1pie(&vcpu->arch.ctxt)) {
123+
write_sysreg_el1(__vcpu_sys_reg(vcpu, PIR_EL2), SYS_PIR);
124+
write_sysreg_el1(__vcpu_sys_reg(vcpu, PIRE0_EL2), SYS_PIRE0);
125+
}
126+
}
116127

117128
write_sysreg_el1(__vcpu_sys_reg(vcpu, ESR_EL2), SYS_ESR);
118129
write_sysreg_el1(__vcpu_sys_reg(vcpu, AFSR0_EL2), SYS_AFSR0);

0 commit comments

Comments
 (0)