Skip to content

Commit 7cd5c27

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Make PAN conditions part of the S1 walk context
Move the conditions describing PAN as part of the s1_walk_info structure, in an effort to declutter the permission processing. Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 8a9b304 commit 7cd5c27

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

arch/arm64/kvm/at.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct s1_walk_info {
2626
bool hpd;
2727
bool e0poe;
2828
bool poe;
29+
bool pan;
2930
bool be;
3031
bool s2;
3132
};
@@ -151,6 +152,8 @@ static int setup_s1_walk(struct kvm_vcpu *vcpu, u32 op, struct s1_walk_info *wi,
151152

152153
wi->regime = compute_translation_regime(vcpu, op);
153154
as_el0 = (op == OP_AT_S1E0R || op == OP_AT_S1E0W);
155+
wi->pan = (op == OP_AT_S1E1RP || op == OP_AT_S1E1WP) &&
156+
(*vcpu_cpsr(vcpu) & PSR_PAN_BIT);
154157

155158
va55 = va & BIT(55);
156159

@@ -1020,10 +1023,12 @@ static void compute_s1_indirect_permissions(struct kvm_vcpu *vcpu,
10201023
}
10211024
}
10221025

1023-
static void compute_s1_permissions(struct kvm_vcpu *vcpu, u32 op,
1026+
static void compute_s1_permissions(struct kvm_vcpu *vcpu,
10241027
struct s1_walk_info *wi,
10251028
struct s1_walk_result *wr)
10261029
{
1030+
bool pan;
1031+
10271032
if (!s1pie_enabled(vcpu, wi->regime))
10281033
compute_s1_direct_permissions(vcpu, wi, wr);
10291034
else
@@ -1032,14 +1037,10 @@ static void compute_s1_permissions(struct kvm_vcpu *vcpu, u32 op,
10321037
if (!wi->hpd)
10331038
compute_s1_hierarchical_permissions(vcpu, wi, wr);
10341039

1035-
if (op == OP_AT_S1E1RP || op == OP_AT_S1E1WP) {
1036-
bool pan;
1037-
1038-
pan = *vcpu_cpsr(vcpu) & PSR_PAN_BIT;
1039-
pan &= wr->ur || wr->uw || (pan3_enabled(vcpu, wi->regime) && wr->ux);
1040-
wr->pw &= !pan;
1041-
wr->pr &= !pan;
1042-
}
1040+
pan = wi->pan && (wr->ur || wr->uw ||
1041+
(pan3_enabled(vcpu, wi->regime) && wr->ux));
1042+
wr->pw &= !pan;
1043+
wr->pr &= !pan;
10431044
}
10441045

10451046
static u64 handle_at_slow(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
@@ -1065,7 +1066,7 @@ static u64 handle_at_slow(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
10651066
if (ret)
10661067
goto compute_par;
10671068

1068-
compute_s1_permissions(vcpu, op, &wi, &wr);
1069+
compute_s1_permissions(vcpu, &wi, &wr);
10691070

10701071
switch (op) {
10711072
case OP_AT_S1E1RP:

0 commit comments

Comments
 (0)