Skip to content

x86: disable IRQs during CR4 changes

Nadav Amit linux-edac lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest2 patches 4 repliesIn review

Changes in v2 from the cover letter

- Break into two patches (Andy)
- Rename refactored function to __cr4_set() (Andy)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2x86: refactor CR4 setting and shadow writearch/x86/include/asm/tlbflush.h+11 -130 replies
2/2x86: disable IRQs before changing CR4arch/x86/include/asm/mmu_context.h arch/x86/include/asm/tlbflush.h arch/x86/include/asm/virtext.h +10 more+91 -324 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] x86: disable IRQs during CR4 changes

CR4 needs to be updated atomically with its shadow value, as CR4 updates are performed in read-modify-write fashion which are based on the shadow value. If CR4 is changed between the read and the write, CR4 might not be updated correctly.

For this to happen, CR4 needs to be rewritten by an interrupt handler. [Presumably, writes to CR4 take place while preemption is disabled, although due to the experience with CR3 - who knows.] CR4.PGD can be updated by an interrupt handler, but it is restored to its previous value, so it should not introduce a race. However, it seems that allowing CR4 updates without disabling IRQs may present a potential future bug.

Cc Andy Lutomirski <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Tony Luck <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc "Radim Krčmář" <[email protected]>

v1 -> v2:
- Break into two patches (Andy)
- Rename refactored function to __cr4_set() (Andy)

Nadav Amit (2):
x86: refactor CR4 setting and shadow write
x86: disable IRQs before changing CR4

 arch/x86/include/asm/mmu_context.h   |  4 ++--
 arch/x86/include/asm/tlbflush.h      | 40 +++++++++++++++++++++---------------
 arch/x86/include/asm/virtext.h       |  2 +-
 arch/x86/kernel/cpu/common.c         | 38 +++++++++++++++++++++++++---------
 arch/x86/kernel/cpu/mcheck/mce.c     |  5 ++++-
 arch/x86/kernel/cpu/mcheck/p5.c      |  6 +++++-
 arch/x86/kernel/cpu/mcheck/winchip.c |  5 ++++-
 arch/x86/kernel/fpu/init.c           |  2 +-
 arch/x86/kernel/fpu/xstate.c         |  4 ++--
 arch/x86/kernel/process.c            | 20 +++++++++++++-----
 arch/x86/kernel/reboot.c             |  2 +-
 arch/x86/kvm/vmx.c                   | 13 ++++++++++--
 arch/x86/mm/init.c                   |  6 +++++-
 13 files changed, 102 insertions(+), 45 deletions(-)
Signature · 1 line
2.14.1