@@ -203,34 +203,44 @@ static void __init probe_page_size_mask(void)
203
203
204
204
static void setup_pcid (void )
205
205
{
206
- #ifdef CONFIG_X86_64
207
- if (boot_cpu_has (X86_FEATURE_PCID )) {
208
- if (boot_cpu_has (X86_FEATURE_PGE )) {
209
- /*
210
- * This can't be cr4_set_bits_and_update_boot() --
211
- * the trampoline code can't handle CR4.PCIDE and
212
- * it wouldn't do any good anyway. Despite the name,
213
- * cr4_set_bits_and_update_boot() doesn't actually
214
- * cause the bits in question to remain set all the
215
- * way through the secondary boot asm.
216
- *
217
- * Instead, we brute-force it and set CR4.PCIDE
218
- * manually in start_secondary().
219
- */
220
- cr4_set_bits (X86_CR4_PCIDE );
221
- } else {
222
- /*
223
- * flush_tlb_all(), as currently implemented, won't
224
- * work if PCID is on but PGE is not. Since that
225
- * combination doesn't exist on real hardware, there's
226
- * no reason to try to fully support it, but it's
227
- * polite to avoid corrupting data if we're on
228
- * an improperly configured VM.
229
- */
230
- setup_clear_cpu_cap (X86_FEATURE_PCID );
231
- }
206
+ if (!IS_ENABLED (CONFIG_X86_64 ))
207
+ return ;
208
+
209
+ if (!boot_cpu_has (X86_FEATURE_PCID ))
210
+ return ;
211
+
212
+ if (boot_cpu_has (X86_FEATURE_PGE )) {
213
+ /*
214
+ * This can't be cr4_set_bits_and_update_boot() -- the
215
+ * trampoline code can't handle CR4.PCIDE and it wouldn't
216
+ * do any good anyway. Despite the name,
217
+ * cr4_set_bits_and_update_boot() doesn't actually cause
218
+ * the bits in question to remain set all the way through
219
+ * the secondary boot asm.
220
+ *
221
+ * Instead, we brute-force it and set CR4.PCIDE manually in
222
+ * start_secondary().
223
+ */
224
+ cr4_set_bits (X86_CR4_PCIDE );
225
+
226
+ /*
227
+ * INVPCID's single-context modes (2/3) only work if we set
228
+ * X86_CR4_PCIDE, *and* we INVPCID support. It's unusable
229
+ * on systems that have X86_CR4_PCIDE clear, or that have
230
+ * no INVPCID support at all.
231
+ */
232
+ if (boot_cpu_has (X86_FEATURE_INVPCID ))
233
+ setup_force_cpu_cap (X86_FEATURE_INVPCID_SINGLE );
234
+ } else {
235
+ /*
236
+ * flush_tlb_all(), as currently implemented, won't work if
237
+ * PCID is on but PGE is not. Since that combination
238
+ * doesn't exist on real hardware, there's no reason to try
239
+ * to fully support it, but it's polite to avoid corrupting
240
+ * data if we're on an improperly configured VM.
241
+ */
242
+ setup_clear_cpu_cap (X86_FEATURE_PCID );
232
243
}
233
- #endif
234
244
}
235
245
236
246
#ifdef CONFIG_X86_32
0 commit comments