lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150426170314.210e921c@netblarch.fritz.box>
Date:	Sun, 26 Apr 2015 17:03:14 +0200
From:	Alexander Hirsch <1zeeky@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	x86@...nel.org
Subject: [PATCH] x86/microcode: Allow early loading without initrd

Microcode can be baked into the kernel image via CONFIG_EXTRA_FIRMWARE
and the early loader supports that, but still depended on
BLK_DEV_INITRD.
This dependency is removed.

Signed-off-by: Alexander Hirsch <1zeeky@...il.com>
---
This patch depends on the "Parse built-in microcode early" patch by Borislav Petkov (https://lkml.org/lkml/2015/4/1/331).
I only tested this on two Intel machines (an i3 M330 and an i5-4690). There is no change in amd_early.c because it compiles fine - only intel_early.c complained without BLK_DEV_INITRD.

 arch/x86/Kconfig                            |  2 +-
 arch/x86/kernel/cpu/microcode/intel_early.c | 30 +++++++++++++++++++++--------
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 226d569..bc7e187 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1144,7 +1144,7 @@ config MICROCODE_AMD_EARLY
 
 config MICROCODE_EARLY
 	bool "Early load microcode"
-	depends on MICROCODE=y && BLK_DEV_INITRD
+	depends on MICROCODE=y
 	select MICROCODE_INTEL_EARLY if MICROCODE_INTEL
 	select MICROCODE_AMD_EARLY if MICROCODE_AMD
 	default y
diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c
index 98d320c..3d5906e 100644
--- a/arch/x86/kernel/cpu/microcode/intel_early.c
+++ b/arch/x86/kernel/cpu/microcode/intel_early.c
@@ -691,6 +691,9 @@ int __init save_microcode_in_initrd_intel(void)
 	unsigned int count = mc_saved_data.mc_saved_count;
 	struct microcode_intel *mc_saved[MAX_UCODE_COUNT];
 	int ret = 0;
+#ifndef BLK_DEV_INITRD
+	unsigned long initrd_start = 0;
+#endif
 
 	if (count == 0)
 		return ret;
@@ -728,24 +731,32 @@ _load_ucode_intel_bsp(struct mc_saved_data *mc_saved_data,
 
 void __init load_ucode_intel_bsp(void)
 {
-	u64 start, size;
+	u64 start = 0, size = 0;
+	struct mc_saved_data *mc_saved_data_p;
+	unsigned long *mc_saved_in_initrd_p;
+#ifdef BLK_DEV_INITRD
 #ifdef CONFIG_X86_32
 	struct boot_params *p;
 
 	p	= (struct boot_params *)__pa_nodebug(&boot_params);
 	start	= p->hdr.ramdisk_image;
 	size	= p->hdr.ramdisk_size;
-
-	_load_ucode_intel_bsp(
-			(struct mc_saved_data *)__pa_nodebug(&mc_saved_data),
-			(unsigned long *)__pa_nodebug(&mc_saved_in_initrd),
-			start, size);
 #else
 	start	= boot_params.hdr.ramdisk_image + PAGE_OFFSET;
 	size	= boot_params.hdr.ramdisk_size;
-
-	_load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd, start, size);
 #endif
+#endif
+
+#ifdef CONFIG_X86_32
+	mc_saved_in_initrd_p =
+		(unsigned long *)__pa_nodebug(mc_saved_in_initrd);
+	mc_saved_data_p = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
+#else
+	mc_saved_data_p = &mc_saved_data;
+	mc_saved_in_initrd_p = mc_saved_in_initrd;
+#endif
+
+	_load_ucode_intel_bsp(mc_saved_data_p, mc_saved_in_initrd_p, start, size);
 }
 
 void load_ucode_intel_ap(void)
@@ -755,6 +766,9 @@ void load_ucode_intel_ap(void)
 	unsigned long *mc_saved_in_initrd_p;
 	unsigned long initrd_start_addr;
 	enum ucode_state ret;
+#ifndef BLK_DEV_INITRD
+	unsigned long initrd_start = 0;
+#endif
 #ifdef CONFIG_X86_32
 	unsigned long *initrd_start_p;
 
-- 
2.3.6


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ