| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- From e80edf9b45a0465ce8fbded75f6d5f218039a67c Mon Sep 17 00:00:00 2001
- From: Peter Zijlstra <[email protected]>
- Date: Tue, 5 Dec 2017 13:34:51 +0100
- Subject: [PATCH 175/242] x86/microcode: Dont abuse the TLB-flush interface
- MIME-Version: 1.0
- Content-Type: text/plain; charset=UTF-8
- Content-Transfer-Encoding: 8bit
- CVE-2017-5754
- Commit:
- ec400ddeff20 ("x86/microcode_intel_early.c: Early update ucode on Intel's CPU")
- ... grubbed into tlbflush internals without coherent explanation.
- Since it says its a precaution and the SDM doesn't mention anything like
- this, take it out back.
- Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
- Signed-off-by: Thomas Gleixner <[email protected]>
- Cc: Andy Lutomirski <[email protected]>
- Cc: Boris Ostrovsky <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Brian Gerst <[email protected]>
- Cc: Dave Hansen <[email protected]>
- Cc: David Laight <[email protected]>
- Cc: Denys Vlasenko <[email protected]>
- Cc: Eduardo Valentin <[email protected]>
- Cc: Greg KH <[email protected]>
- Cc: H. Peter Anvin <[email protected]>
- Cc: Josh Poimboeuf <[email protected]>
- Cc: Juergen Gross <[email protected]>
- Cc: Linus Torvalds <[email protected]>
- Cc: Peter Zijlstra <[email protected]>
- Cc: Will Deacon <[email protected]>
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Signed-off-by: Ingo Molnar <[email protected]>
- (cherry picked from commit 23cb7d46f371844c004784ad9552a57446f73e5a)
- Signed-off-by: Andy Whitcroft <[email protected]>
- Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
- (cherry picked from commit 0f3d96d1e5aa4d9538ab1a918fb49f2c57ebb6f5)
- Signed-off-by: Fabian Grünbichler <[email protected]>
- ---
- arch/x86/include/asm/tlbflush.h | 19 ++++++-------------
- arch/x86/kernel/cpu/microcode/intel.c | 13 -------------
- 2 files changed, 6 insertions(+), 26 deletions(-)
- diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
- index 6533da3036c9..6d2688a6fda0 100644
- --- a/arch/x86/include/asm/tlbflush.h
- +++ b/arch/x86/include/asm/tlbflush.h
- @@ -234,20 +234,9 @@ static inline void __native_flush_tlb(void)
- preempt_enable();
- }
-
- -static inline void __native_flush_tlb_global_irq_disabled(void)
- -{
- - unsigned long cr4;
- -
- - cr4 = this_cpu_read(cpu_tlbstate.cr4);
- - /* clear PGE */
- - native_write_cr4(cr4 & ~X86_CR4_PGE);
- - /* write old PGE again and flush TLBs */
- - native_write_cr4(cr4);
- -}
- -
- static inline void __native_flush_tlb_global(void)
- {
- - unsigned long flags;
- + unsigned long cr4, flags;
-
- if (static_cpu_has(X86_FEATURE_INVPCID)) {
- /*
- @@ -265,7 +254,11 @@ static inline void __native_flush_tlb_global(void)
- */
- raw_local_irq_save(flags);
-
- - __native_flush_tlb_global_irq_disabled();
- + cr4 = this_cpu_read(cpu_tlbstate.cr4);
- + /* toggle PGE */
- + native_write_cr4(cr4 ^ X86_CR4_PGE);
- + /* write old PGE again and flush TLBs */
- + native_write_cr4(cr4);
-
- raw_local_irq_restore(flags);
- }
- diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
- index 636a5fcfdeb7..d9a8f69101aa 100644
- --- a/arch/x86/kernel/cpu/microcode/intel.c
- +++ b/arch/x86/kernel/cpu/microcode/intel.c
- @@ -564,15 +564,6 @@ static void print_ucode(struct ucode_cpu_info *uci)
- }
- #else
-
- -/*
- - * Flush global tlb. We only do this in x86_64 where paging has been enabled
- - * already and PGE should be enabled as well.
- - */
- -static inline void flush_tlb_early(void)
- -{
- - __native_flush_tlb_global_irq_disabled();
- -}
- -
- static inline void print_ucode(struct ucode_cpu_info *uci)
- {
- struct microcode_intel *mc;
- @@ -601,10 +592,6 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
- if (rev != mc->hdr.rev)
- return -1;
-
- -#ifdef CONFIG_X86_64
- - /* Flush global tlb. This is precaution. */
- - flush_tlb_early();
- -#endif
- uci->cpu_sig.rev = rev;
-
- if (early)
- --
- 2.14.2
|