Skip to content

Commit 37c0bdd

Browse files
committed
powerpc/powernv: Use the security flags in pnv_setup_rfi_flush()
Now that we have the security flags we can significantly simplify the code in pnv_setup_rfi_flush(), because we can use the flags instead of checking device tree properties and because the security flags have pessimistic defaults. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent ff34835 commit 37c0bdd

File tree

1 file changed

+10
-31
lines changed
  • arch/powerpc/platforms/powernv

1 file changed

+10
-31
lines changed

arch/powerpc/platforms/powernv/setup.c

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void init_fw_feat_flags(struct device_node *np)
6666
if (fw_feature_is("enabled", "fw-bcctrl-serialized", np))
6767
security_ftr_set(SEC_FTR_BCCTRL_SERIALISED);
6868

69-
if (fw_feature_is("enabled", "inst-spec-barrier-ori31,31,0", np))
69+
if (fw_feature_is("enabled", "inst-l1d-flush-ori30,30,0", np))
7070
security_ftr_set(SEC_FTR_L1D_FLUSH_ORI30);
7171

7272
if (fw_feature_is("enabled", "inst-l1d-flush-trig2", np))
@@ -99,52 +99,31 @@ static void pnv_setup_rfi_flush(void)
9999
{
100100
struct device_node *np, *fw_features;
101101
enum l1d_flush_type type;
102-
int enable;
102+
bool enable;
103103

104104
/* Default to fallback in case fw-features are not available */
105105
type = L1D_FLUSH_FALLBACK;
106-
enable = 1;
107106

108107
np = of_find_node_by_name(NULL, "ibm,opal");
109108
fw_features = of_get_child_by_name(np, "fw-features");
110109
of_node_put(np);
111110

112111
if (fw_features) {
113112
init_fw_feat_flags(fw_features);
113+
of_node_put(fw_features);
114114

115-
np = of_get_child_by_name(fw_features, "inst-l1d-flush-trig2");
116-
if (np && of_property_read_bool(np, "enabled"))
115+
if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_TRIG2))
117116
type = L1D_FLUSH_MTTRIG;
118117

119-
of_node_put(np);
120-
121-
np = of_get_child_by_name(fw_features, "inst-l1d-flush-ori30,30,0");
122-
if (np && of_property_read_bool(np, "enabled"))
118+
if (security_ftr_enabled(SEC_FTR_L1D_FLUSH_ORI30))
123119
type = L1D_FLUSH_ORI;
124-
125-
of_node_put(np);
126-
127-
/* Enable unless firmware says NOT to */
128-
enable = 2;
129-
np = of_get_child_by_name(fw_features, "needs-l1d-flush-msr-hv-1-to-0");
130-
if (np && of_property_read_bool(np, "disabled"))
131-
enable--;
132-
133-
of_node_put(np);
134-
135-
np = of_get_child_by_name(fw_features, "needs-l1d-flush-msr-pr-0-to-1");
136-
if (np && of_property_read_bool(np, "disabled"))
137-
enable--;
138-
139-
np = of_get_child_by_name(fw_features, "speculation-policy-favor-security");
140-
if (np && of_property_read_bool(np, "disabled"))
141-
enable = 0;
142-
143-
of_node_put(np);
144-
of_node_put(fw_features);
145120
}
146121

147-
setup_rfi_flush(type, enable > 0);
122+
enable = security_ftr_enabled(SEC_FTR_FAVOUR_SECURITY) && \
123+
(security_ftr_enabled(SEC_FTR_L1D_FLUSH_PR) || \
124+
security_ftr_enabled(SEC_FTR_L1D_FLUSH_HV));
125+
126+
setup_rfi_flush(type, enable);
148127
}
149128

150129
static void __init pnv_setup_arch(void)

0 commit comments

Comments
 (0)