Skip to content

Commit 5e21b29

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Disable hierarchical permissions when S1PIE is enabled
S1PIE implicitly disables hierarchical permissions, as specified in R_JHSVW, by making TCR_ELx.HPDn RES1. Add a predicate for S1PIE being enabled for a given translation regime, and emulate this behaviour by forcing the hpd field to true if S1PIE is enabled for that translation regime. Signed-off-by: Marc Zyngier <[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 4967b87 commit 5e21b29

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

arch/arm64/kvm/at.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,23 @@ static enum trans_regime compute_translation_regime(struct kvm_vcpu *vcpu, u32 o
9393
}
9494
}
9595

96+
static bool s1pie_enabled(struct kvm_vcpu *vcpu, enum trans_regime regime)
97+
{
98+
if (!kvm_has_feat(vcpu->kvm, ID_AA64MMFR3_EL1, S1PIE, IMP))
99+
return false;
100+
101+
switch (regime) {
102+
case TR_EL2:
103+
case TR_EL20:
104+
return vcpu_read_sys_reg(vcpu, TCR2_EL2) & TCR2_EL2_PIE;
105+
case TR_EL10:
106+
return (__vcpu_sys_reg(vcpu, HCRX_EL2) & HCRX_EL2_TCR2En) &&
107+
(__vcpu_sys_reg(vcpu, TCR2_EL1) & TCR2_EL1x_PIE);
108+
default:
109+
BUG();
110+
}
111+
}
112+
96113
static int setup_s1_walk(struct kvm_vcpu *vcpu, u32 op, struct s1_walk_info *wi,
97114
struct s1_walk_result *wr, u64 va)
98115
{
@@ -186,6 +203,8 @@ static int setup_s1_walk(struct kvm_vcpu *vcpu, u32 op, struct s1_walk_info *wi,
186203
(va55 ?
187204
FIELD_GET(TCR_HPD1, tcr) :
188205
FIELD_GET(TCR_HPD0, tcr)));
206+
/* R_JHSVW */
207+
wi->hpd |= s1pie_enabled(vcpu, wi->regime);
189208

190209
/* Someone was silly enough to encode TG0/TG1 differently */
191210
if (va55) {

0 commit comments

Comments
 (0)