Skip to content

Commit 1c9fe44

Browse files
amlutotorvalds
authored andcommitted
x86/mm: Document how CR4.PCIDE restore works
While debugging a problem, I thought that using cr4_set_bits_and_update_boot() to restore CR4.PCIDE would be helpful. It turns out to be counterproductive. Add a comment documenting how this works. Signed-off-by: Andy Lutomirski <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 72c0098 commit 1c9fe44

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/x86/kernel/cpu/common.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,19 @@ static void setup_pcid(struct cpuinfo_x86 *c)
333333
{
334334
if (cpu_has(c, X86_FEATURE_PCID)) {
335335
if (cpu_has(c, X86_FEATURE_PGE)) {
336+
/*
337+
* We'd like to use cr4_set_bits_and_update_boot(),
338+
* but we can't. CR4.PCIDE is special and can only
339+
* be set in long mode, and the early CPU init code
340+
* doesn't know this and would try to restore CR4.PCIDE
341+
* prior to entering long mode.
342+
*
343+
* Instead, we rely on the fact that hotplug, resume,
344+
* etc all fully restore CR4 before they write anything
345+
* that could have nonzero PCID bits to CR3. CR4.PCIDE
346+
* has no effect on the page tables themselves, so we
347+
* don't need it to be restored early.
348+
*/
336349
cr4_set_bits(X86_CR4_PCIDE);
337350
} else {
338351
/*

0 commit comments

Comments
 (0)