Skip to contentSkip to conversation

x86, microcode_amd: Add support for CPU family specific container files

PATCH Superseded Andreas Herrmann 1 participant 3 messages Jan 5, 2012 – Jan 26, 2012 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, microcode_amd: Add support for CPU family specific container files

We've decided to provide CPU family specific container files (starting with CPU family 15h). E.g. for family 15h we have to load microcode_amd_fam15h.bin instead of microcode_amd.bin

Rationale is that starting with family 15h patch size is larger than 2KB which was hard coded as maximum patch size in various microcode loaders (not just Linux).

Container files which include patches larger than 2KB cause different kinds of trouble with such old patch loaders. Thus we have to ensure that the default container file provides only patches with size less than 2KB.

---
 arch/x86/kernel/microcode_amd.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/kernel/microcode_amd.c +7 -2
index fe86493..d4e679a 100644
@@ -313,11 +313,16 @@ out:
 
 static enum ucode_state request_microcode_amd(int cpu, struct device *device)
 {
-	const char *fw_name = "amd-ucode/microcode_amd.bin";
+	char fw_name[36] = "amd-ucode/microcode_amd.bin";
 	const struct firmware *fw;
 	enum ucode_state ret = UCODE_NFOUND;
+	struct cpuinfo_x86 *c = &cpu_data(cpu);
+
+	if (c->x86 >= 0x15)
+		snprintf(fw_name, sizeof(fw_name),
+			 "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
 
-	if (request_firmware(&fw, fw_name, device)) {
+	if (request_firmware(&fw, (const char *) fw_name, device)) {
 		pr_err("failed to load file %s\n", fw_name);
 		goto out;
 	}
Signature · 1 line
1.7.8.1
#1 lore raw

PATCH RESEND 1/1 x86, microcode_amd: Add support for CPU family specific container files

We've decided to provide CPU family specific container files (starting with CPU family 15h). E.g. for family 15h we have to load microcode_amd_fam15h.bin instead of microcode_amd.bin

Rationale is that starting with family 15h patch size is larger than 2KB which was hard coded as maximum patch size in various microcode loaders (not just Linux).

Container files which include patches larger than 2KB cause different kinds of trouble with such old patch loaders. Thus we have to ensure that the default container file provides only patches with size less than 2KB.

---
 arch/x86/kernel/microcode_amd.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/kernel/microcode_amd.c +7 -2
index fe86493..d4e679a 100644
@@ -313,11 +313,16 @@ out:
 
 static enum ucode_state request_microcode_amd(int cpu, struct device *device)
 {
-	const char *fw_name = "amd-ucode/microcode_amd.bin";
+	char fw_name[36] = "amd-ucode/microcode_amd.bin";
 	const struct firmware *fw;
 	enum ucode_state ret = UCODE_NFOUND;
+	struct cpuinfo_x86 *c = &cpu_data(cpu);
+
+	if (c->x86 >= 0x15)
+		snprintf(fw_name, sizeof(fw_name),
+			 "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
 
-	if (request_firmware(&fw, fw_name, device)) {
+	if (request_firmware(&fw, (const char *) fw_name, device)) {
 		pr_err("failed to load file %s\n", fw_name);
 		goto out;
 	}
Signature · 1 line
1.7.8.1
#2 lore raw

[tip:x86/urgent] x86/microcode_amd: Add support for CPU family specific container files

Commit-ID:  5b68edc91cdc972c46f76f85eded7ffddc3ff5c2
Gitweb:     http://git.kernel.org/tip/5b68edc91cdc972c46f76f85eded7ffddc3ff5c2
Author:     Andreas Herrmann <[email protected]>
AuthorDate: Fri, 20 Jan 2012 17:44:12 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 26 Jan 2012 12:06:39 +0100

x86/microcode_amd: Add support for CPU family specific container files

We've decided to provide CPU family specific container files (starting with CPU family 15h). E.g. for family 15h we have to load microcode_amd_fam15h.bin instead of microcode_amd.bin

Rationale is that starting with family 15h patch size is larger than 2KB which was hard coded as maximum patch size in various microcode loaders (not just Linux).

Container files which include patches larger than 2KB cause different kinds of trouble with such old patch loaders. Thus we have to ensure that the default container file provides only patches with size less than 2KB.

Cc Borislav Petkov <[email protected]>
[ documented the naming convention and tidied the code a bit. ]
---
 arch/x86/kernel/microcode_amd.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
arch/x86/kernel/microcode_amd.c +22 -2
index fe86493..ac0417b 100644
@@ -311,13 +311,33 @@ out:
 	return state;
 }
 
+/*
+ * AMD microcode firmware naming convention, up to family 15h they are in
+ * the legacy file:
+ *
+ *    amd-ucode/microcode_amd.bin
+ *
+ * This legacy file is always smaller than 2K in size.
+ *
+ * Starting at family 15h they are in family specific firmware files:
+ *
+ *    amd-ucode/microcode_amd_fam15h.bin
+ *    amd-ucode/microcode_amd_fam16h.bin
+ *    ...
+ *
+ * These might be larger than 2K.
+ */
 static enum ucode_state request_microcode_amd(int cpu, struct device *device)
 {
-	const char *fw_name = "amd-ucode/microcode_amd.bin";
+	char fw_name[36] = "amd-ucode/microcode_amd.bin";
 	const struct firmware *fw;
 	enum ucode_state ret = UCODE_NFOUND;
+	struct cpuinfo_x86 *c = &cpu_data(cpu);
+
+	if (c->x86 >= 0x15)
+		snprintf(fw_name, sizeof(fw_name), "amd-ucode/microcode_amd_fam%.2xh.bin", c->x86);
 
-	if (request_firmware(&fw, fw_name, device)) {
+	if (request_firmware(&fw, (const char *)fw_name, device)) {
 		pr_err("failed to load file %s\n", fw_name);
 		goto out;
 	}