From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424359AbcFHJxi (ORCPT ); Wed, 8 Jun 2016 05:53:38 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56194 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423076AbcFHJxd (ORCPT ); Wed, 8 Jun 2016 05:53:33 -0400 Date: Wed, 8 Jun 2016 02:52:21 -0700 From: tip-bot for Borislav Petkov Message-ID: Cc: luto@amacapital.net, brgerst@gmail.com, bp@suse.de, linux-kernel@vger.kernel.org, tglx@linutronix.de, jim876@xs4all.nl, mingo@kernel.org, hpa@zytor.com, torvalds@linux-foundation.org, dvlasenk@redhat.com, peterz@infradead.org, bp@alien8.de Reply-To: bp@alien8.de, peterz@infradead.org, dvlasenk@redhat.com, tglx@linutronix.de, jim876@xs4all.nl, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, hpa@zytor.com, mingo@kernel.org, bp@suse.de, brgerst@gmail.com, luto@amacapital.net In-Reply-To: <1465225850-7352-3-git-send-email-bp@alien8.de> References: <1465225850-7352-3-git-send-email-bp@alien8.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/microcode] x86/microcode: Fix suspend to RAM with builtin microcode Git-Commit-ID: 4b703305d98bf7350d4b2953ee39a3aa2eeb1778 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4b703305d98bf7350d4b2953ee39a3aa2eeb1778 Gitweb: http://git.kernel.org/tip/4b703305d98bf7350d4b2953ee39a3aa2eeb1778 Author: Borislav Petkov AuthorDate: Mon, 6 Jun 2016 17:10:43 +0200 Committer: Ingo Molnar CommitDate: Wed, 8 Jun 2016 11:04:19 +0200 x86/microcode: Fix suspend to RAM with builtin microcode Usually, after we have found the proper microcode blob for the current machine, we stash it away for later use with save_microcode_in_initrd(). However, with builtin microcode which doesn't come from the initrd, we don't call that function because CONFIG_BLK_DEV_INITRD=n and even if set, we don't have a valid initrd. In order to fix this, let's make save_microcode_in_initrd() an fs_initcall which runs before rootfs_initcall() as this was the time it was called previously through: rootfs_initcall(populate_rootfs) |-> free_initrd() |-> free_initrd_mem() |-> save_microcode_in_initrd() Also, we make it run independently from initrd functionality being present or not. And since it is called in the microcode loader only now, we can also make it static. Reported-and-tested-by: Jim Bos Signed-off-by: Borislav Petkov Cc: # v4.6 Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1465225850-7352-3-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/include/asm/microcode.h | 2 -- arch/x86/kernel/cpu/microcode/core.c | 3 ++- arch/x86/mm/init.c | 7 ------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h index ca2af7e..da0d81f 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h @@ -133,13 +133,11 @@ static inline unsigned int x86_cpuid_family(void) #ifdef CONFIG_MICROCODE extern void __init load_ucode_bsp(void); extern void load_ucode_ap(void); -extern int __init save_microcode_in_initrd(void); void reload_early_microcode(void); extern bool get_builtin_firmware(struct cpio_data *cd, const char *name); #else static inline void __init load_ucode_bsp(void) { } static inline void load_ucode_ap(void) { } -static inline int __init save_microcode_in_initrd(void) { return 0; } static inline void reload_early_microcode(void) { } static inline bool get_builtin_firmware(struct cpio_data *cd, const char *name) { return false; } diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index ac360bf..12823b6 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -175,7 +175,7 @@ void load_ucode_ap(void) } } -int __init save_microcode_in_initrd(void) +static int __init save_microcode_in_initrd(void) { struct cpuinfo_x86 *c = &boot_cpu_data; @@ -691,4 +691,5 @@ int __init microcode_init(void) return error; } +fs_initcall(save_microcode_in_initrd); late_initcall(microcode_init); diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 372aad2..dffd162 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -696,13 +696,6 @@ void free_initmem(void) void __init free_initrd_mem(unsigned long start, unsigned long end) { /* - * Remember, initrd memory may contain microcode or other useful things. - * Before we lose initrd mem, we need to find a place to hold them - * now that normal virtual memory is enabled. - */ - save_microcode_in_initrd(); - - /* * end could be not aligned, and We can not align that, * decompresser could be confused by aligned initrd_end * We already reserve the end partial page before in