All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/5] x86, AMD: cleanup: merge common code in early microcode loading
@ 2013-07-23 21:00 Torsten Kaiser
  2013-07-24 13:32 ` Borislav Petkov
  0 siblings, 1 reply; 10+ messages in thread
From: Torsten Kaiser @ 2013-07-23 21:00 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Borislav Petkov,
	Jacob Shin, Johannes Hirte, linux-kernel

Extract common checks and initialisations from load_ucode_ap() and
save_microcode_in_initrd_amd() to load_microcode_amd_early().
load_ucode_ap() gets a quick exit for !cpu, because for the BSP there is
already a different function dealing with its update.

The original code already didn't anything, because without load_microcode_amd()
getting called apply_microcode_amd() could not do anything.

Signed-off-by: Torsten Kaiser <just.for.lkml@googlemail.com>

--- a/arch/x86/kernel/microcode_amd_early.c	2013-07-22 06:22:32.000000000 +0200
+++ b/arch/x86/kernel/microcode_amd_early.c	2013-07-23 20:00:04.889508712 +0200
@@ -196,6 +196,23 @@ void __init load_ucode_amd_bsp(void)
 	apply_ucode_in_initrd(cd.data, cd.size);
 }
 
+static int load_microcode_amd_early(void)
+{
+	enum ucode_state ret;
+	void *ucode;
+
+	if (ucode_loaded || !ucode_size || !initrd_start)
+		return 0;
+
+	ucode = (void *)(initrd_start + ucode_offset);
+	ret = load_microcode_amd(0, ucode, ucode_size);
+	if (ret != UCODE_OK)
+		return -EINVAL;
+
+	ucode_loaded = true;
+	return 0;
+}
+
 #ifdef CONFIG_X86_32
 u8 amd_bsp_mpb[MPB_MAX_SIZE];
 
@@ -258,17 +275,13 @@ void load_ucode_amd_ap(void)
 
 	collect_cpu_info_amd_early(&cpu_data(cpu), ucode_cpu_info + cpu);
 
-	if (cpu && !ucode_loaded) {
-		void *ucode;
-
-		if (!ucode_size || !initrd_start)
-			return;
+	/* BSP via load_ucode_amd_bsp() */
+	if (!cpu)
+		return;
 
-		ucode = (void *)(initrd_start + ucode_offset);
-		if (load_microcode_amd(0, ucode, ucode_size) != UCODE_OK)
-			return;
-		ucode_loaded = true;
-	}
+	load_microcode_amd_early();
+	if (!ucode_loaded)
+		return;
 
 	apply_microcode_amd(cpu);
 }
@@ -276,8 +289,6 @@ void load_ucode_amd_ap(void)
 
 int __init save_microcode_in_initrd_amd(void)
 {
-	enum ucode_state ret;
-	void *ucode;
 #ifdef CONFIG_X86_32
 	unsigned int bsp = boot_cpu_data.cpu_index;
 	struct ucode_cpu_info *uci = ucode_cpu_info + bsp;
@@ -289,14 +300,5 @@ int __init save_microcode_in_initrd_amd(
 		pr_info("microcode: updated early to new patch_level=0x%08x\n",
 			ucode_new_rev);
 
-	if (ucode_loaded || !ucode_size || !initrd_start)
-		return 0;
-
-	ucode = (void *)(initrd_start + ucode_offset);
-	ret = load_microcode_amd(0, ucode, ucode_size);
-	if (ret != UCODE_OK)
-		return -EINVAL;
-
-	ucode_loaded = true;
-	return 0;
+	return load_microcode_amd_early();
 }

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-08-09 18:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-23 21:00 [PATCH 3/5] x86, AMD: cleanup: merge common code in early microcode loading Torsten Kaiser
2013-07-24 13:32 ` Borislav Petkov
2013-08-07 22:46   ` Yu, Fenghua
2013-08-07 23:34   ` Yu, Fenghua
2013-08-08  2:22     ` H. Peter Anvin
2013-08-08 10:02       ` Borislav Petkov
2013-08-08 18:28         ` Borislav Petkov
2013-08-09 18:44           ` Yu, Fenghua
2013-08-08 17:49     ` Borislav Petkov
2013-08-09 18:38       ` Yu, Fenghua

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.