Skip to content

Commit 8a9b304

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Disable hierarchical permissions when POE is enabled
The hierarchical permissions must be disabled when POE is enabled in the translation regime used for a given table walk. We store the two enable bits in the s1_walk_info structure so that they can be retrieved down the line, as they will be useful. 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 846c993 commit 8a9b304

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

arch/arm64/kvm/at.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ struct s1_walk_info {
2424
unsigned int txsz;
2525
int sl;
2626
bool hpd;
27+
bool e0poe;
28+
bool poe;
2729
bool be;
2830
bool s2;
2931
};
@@ -110,6 +112,34 @@ static bool s1pie_enabled(struct kvm_vcpu *vcpu, enum trans_regime regime)
110112
}
111113
}
112114

115+
static void compute_s1poe(struct kvm_vcpu *vcpu, struct s1_walk_info *wi)
116+
{
117+
u64 val;
118+
119+
if (!kvm_has_s1poe(vcpu->kvm)) {
120+
wi->poe = wi->e0poe = false;
121+
return;
122+
}
123+
124+
switch (wi->regime) {
125+
case TR_EL2:
126+
case TR_EL20:
127+
val = vcpu_read_sys_reg(vcpu, TCR2_EL2);
128+
wi->poe = val & TCR2_EL2_POE;
129+
wi->e0poe = (wi->regime == TR_EL20) && (val & TCR2_EL2_E0POE);
130+
break;
131+
case TR_EL10:
132+
if (__vcpu_sys_reg(vcpu, HCRX_EL2) & HCRX_EL2_TCR2En) {
133+
wi->poe = wi->e0poe = false;
134+
return;
135+
}
136+
137+
val = __vcpu_sys_reg(vcpu, TCR2_EL1);
138+
wi->poe = val & TCR2_EL1x_POE;
139+
wi->e0poe = val & TCR2_EL1x_E0POE;
140+
}
141+
}
142+
113143
static int setup_s1_walk(struct kvm_vcpu *vcpu, u32 op, struct s1_walk_info *wi,
114144
struct s1_walk_result *wr, u64 va)
115145
{
@@ -206,6 +236,12 @@ static int setup_s1_walk(struct kvm_vcpu *vcpu, u32 op, struct s1_walk_info *wi,
206236
/* R_JHSVW */
207237
wi->hpd |= s1pie_enabled(vcpu, wi->regime);
208238

239+
/* Do we have POE? */
240+
compute_s1poe(vcpu, wi);
241+
242+
/* R_BVXDG */
243+
wi->hpd |= (wi->poe || wi->e0poe);
244+
209245
/* Someone was silly enough to encode TG0/TG1 differently */
210246
if (va55) {
211247
wi->txsz = FIELD_GET(TCR_T1SZ_MASK, tcr);

0 commit comments

Comments
 (0)