[U-Boot] [PATCH v3] x86: Use microcode update from device tree for all processors

From: Ivan Gorinov ivan.gorinov@intel.com
Built without a ROM image with FSP (u-boot.rom), the U-Boot loader applies the microcode update data block encoded in Device Tree to the bootstrap processor but not passed to the other CPUs when multiprocessing is enabled.
If the bootstrap processor successfully performs a microcode update from Device Tree, use the same data block for the other processors.
Signed-off-by: Ivan Gorinov ivan.gorinov@intel.com Reviewed-by: Bin Meng bmeng.cn@gmail.com [bmeng: fixed build errors on edison and qemu-x86] Signed-off-by: Bin Meng bmeng.cn@gmail.com
---
Changes in v3: - don't change arch/x86/cpu/i386/cpu.c to fix build errors on edison and qemu-x86
arch/x86/cpu/intel_common/car.S | 2 ++ arch/x86/cpu/intel_common/microcode.c | 10 +++++++--- arch/x86/include/asm/microcode.h | 1 + arch/x86/lib/fsp/fsp_car.S | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/x86/cpu/intel_common/car.S b/arch/x86/cpu/intel_common/car.S index fe8dfbc..52a77bb 100644 --- a/arch/x86/cpu/intel_common/car.S +++ b/arch/x86/cpu/intel_common/car.S @@ -239,4 +239,6 @@ _dt_ucode_base_size: .globl ucode_base ucode_base: /* Declared in microcode.h */ .long 0 /* microcode base */ +.globl ucode_size +ucode_size: /* Declared in microcode.h */ .long 0 /* microcode size */ diff --git a/arch/x86/cpu/intel_common/microcode.c b/arch/x86/cpu/intel_common/microcode.c index 11b1ec8..c7a539d 100644 --- a/arch/x86/cpu/intel_common/microcode.c +++ b/arch/x86/cpu/intel_common/microcode.c @@ -43,8 +43,6 @@ static int microcode_decode_node(const void *blob, int node, update->data = fdt_getprop(blob, node, "data", &update->size); if (!update->data) return -ENOENT; - update->data += UCODE_HEADER_LEN; - update->size -= UCODE_HEADER_LEN;
update->header_version = fdtdec_get_int(blob, node, "intel,header-version", 0); @@ -124,6 +122,7 @@ static void microcode_read_cpu(struct microcode_update *cpu) int microcode_update_intel(void) { struct microcode_update cpu, update; + ulong address; const void *blob = gd->fdt_blob; int skipped; int count; @@ -167,7 +166,8 @@ int microcode_update_intel(void) skipped++; continue; } - wrmsr(MSR_IA32_UCODE_WRITE, (ulong)update.data, 0); + address = (ulong)update.data + UCODE_HEADER_LEN; + wrmsr(MSR_IA32_UCODE_WRITE, address, 0); rev = microcode_read_rev(); debug("microcode: updated to revision 0x%x date=%04x-%02x-%02x\n", rev, update.date_code & 0xffff, @@ -178,5 +178,9 @@ int microcode_update_intel(void) return -EFAULT; } count++; + if (!ucode_base) { + ucode_base = (ulong)update.data; + ucode_size = update.size; + } } while (1); } diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h index f7b32a5..4ab7504 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h @@ -10,6 +10,7 @@
/* This is a declaration for ucode_base in start.S */ extern u32 ucode_base; +extern u32 ucode_size;
/** * microcode_update_intel() - Apply microcode updates diff --git a/arch/x86/lib/fsp/fsp_car.S b/arch/x86/lib/fsp/fsp_car.S index 549d863..48edc83 100644 --- a/arch/x86/lib/fsp/fsp_car.S +++ b/arch/x86/lib/fsp/fsp_car.S @@ -102,8 +102,10 @@ temp_ram_init_params: _dt_ucode_base_size: /* These next two fields are filled in by ifdtool */ .globl ucode_base -ucode_base: /* Declared in micrcode.h */ +ucode_base: /* Declared in microcode.h */ .long 0 /* microcode base */ +.globl ucode_size +ucode_size: /* Declared in microcode.h */ .long 0 /* microcode size */ .long CONFIG_SYS_MONITOR_BASE /* code region base */ .long CONFIG_SYS_MONITOR_LEN /* code region size */

Hi Ivan,
On Fri, Jun 22, 2018 at 12:16 PM, Bin Meng bmeng.cn@gmail.com wrote:
From: Ivan Gorinov ivan.gorinov@intel.com
Built without a ROM image with FSP (u-boot.rom), the U-Boot loader applies the microcode update data block encoded in Device Tree to the bootstrap processor but not passed to the other CPUs when multiprocessing is enabled.
If the bootstrap processor successfully performs a microcode update from Device Tree, use the same data block for the other processors.
Signed-off-by: Ivan Gorinov ivan.gorinov@intel.com Reviewed-by: Bin Meng bmeng.cn@gmail.com [bmeng: fixed build errors on edison and qemu-x86] Signed-off-by: Bin Meng bmeng.cn@gmail.com
Changes in v3:
- don't change arch/x86/cpu/i386/cpu.c to fix build errors on edison and qemu-x86
I don't think the update to arch/x86/cpu/i386/cpu.c in previous version is needed as mp_params.microcode_pointer is not needed during the MP boot. Please test this patch to see if it works on your board.
arch/x86/cpu/intel_common/car.S | 2 ++ arch/x86/cpu/intel_common/microcode.c | 10 +++++++--- arch/x86/include/asm/microcode.h | 1 + arch/x86/lib/fsp/fsp_car.S | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-)
Regards, Bin

Hi Ivan,
On Fri, Jun 22, 2018 at 12:13 PM, Bin Meng bmeng.cn@gmail.com wrote:
Hi Ivan,
On Fri, Jun 22, 2018 at 12:16 PM, Bin Meng bmeng.cn@gmail.com wrote:
From: Ivan Gorinov ivan.gorinov@intel.com
Built without a ROM image with FSP (u-boot.rom), the U-Boot loader applies the microcode update data block encoded in Device Tree to the bootstrap processor but not passed to the other CPUs when multiprocessing is enabled.
If the bootstrap processor successfully performs a microcode update from Device Tree, use the same data block for the other processors.
Signed-off-by: Ivan Gorinov ivan.gorinov@intel.com Reviewed-by: Bin Meng bmeng.cn@gmail.com [bmeng: fixed build errors on edison and qemu-x86] Signed-off-by: Bin Meng bmeng.cn@gmail.com
Changes in v3:
- don't change arch/x86/cpu/i386/cpu.c to fix build errors on edison and qemu-x86
I don't think the update to arch/x86/cpu/i386/cpu.c in previous version is needed as mp_params.microcode_pointer is not needed during the MP boot. Please test this patch to see if it works on your board.
arch/x86/cpu/intel_common/car.S | 2 ++ arch/x86/cpu/intel_common/microcode.c | 10 +++++++--- arch/x86/include/asm/microcode.h | 1 + arch/x86/lib/fsp/fsp_car.S | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-)
Did you get a chance to test this? If no issue, I will take this patch for v2018.07.
Regards, Bin

On Tue, Jun 26, 2018 at 03:47:49PM +0800, Bin Meng wrote:
Hi Ivan,
On Fri, Jun 22, 2018 at 12:13 PM, Bin Meng bmeng.cn@gmail.com wrote:
Hi Ivan,
On Fri, Jun 22, 2018 at 12:16 PM, Bin Meng bmeng.cn@gmail.com wrote:
From: Ivan Gorinov ivan.gorinov@intel.com
Built without a ROM image with FSP (u-boot.rom), the U-Boot loader applies the microcode update data block encoded in Device Tree to the bootstrap processor but not passed to the other CPUs when multiprocessing is enabled.
If the bootstrap processor successfully performs a microcode update from Device Tree, use the same data block for the other processors.
Signed-off-by: Ivan Gorinov ivan.gorinov@intel.com Reviewed-by: Bin Meng bmeng.cn@gmail.com [bmeng: fixed build errors on edison and qemu-x86] Signed-off-by: Bin Meng bmeng.cn@gmail.com
Changes in v3:
- don't change arch/x86/cpu/i386/cpu.c to fix build errors on edison and qemu-x86
I don't think the update to arch/x86/cpu/i386/cpu.c in previous version is needed as mp_params.microcode_pointer is not needed during the MP boot. Please test this patch to see if it works on your board.
arch/x86/cpu/intel_common/car.S | 2 ++ arch/x86/cpu/intel_common/microcode.c | 10 +++++++--- arch/x86/include/asm/microcode.h | 1 + arch/x86/lib/fsp/fsp_car.S | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-)
Did you get a chance to test this? If no issue, I will take this patch for v2018.07.
No issues. Thank you!

On Fri, Jun 29, 2018 at 5:06 AM, Ivan Gorinov ivan.gorinov@intel.com wrote:
On Tue, Jun 26, 2018 at 03:47:49PM +0800, Bin Meng wrote:
Hi Ivan,
On Fri, Jun 22, 2018 at 12:13 PM, Bin Meng bmeng.cn@gmail.com wrote:
Hi Ivan,
On Fri, Jun 22, 2018 at 12:16 PM, Bin Meng bmeng.cn@gmail.com wrote:
From: Ivan Gorinov ivan.gorinov@intel.com
Built without a ROM image with FSP (u-boot.rom), the U-Boot loader applies the microcode update data block encoded in Device Tree to the bootstrap processor but not passed to the other CPUs when multiprocessing is enabled.
If the bootstrap processor successfully performs a microcode update from Device Tree, use the same data block for the other processors.
Signed-off-by: Ivan Gorinov ivan.gorinov@intel.com Reviewed-by: Bin Meng bmeng.cn@gmail.com [bmeng: fixed build errors on edison and qemu-x86] Signed-off-by: Bin Meng bmeng.cn@gmail.com
Changes in v3:
- don't change arch/x86/cpu/i386/cpu.c to fix build errors on edison and qemu-x86
I don't think the update to arch/x86/cpu/i386/cpu.c in previous version is needed as mp_params.microcode_pointer is not needed during the MP boot. Please test this patch to see if it works on your board.
arch/x86/cpu/intel_common/car.S | 2 ++ arch/x86/cpu/intel_common/microcode.c | 10 +++++++--- arch/x86/include/asm/microcode.h | 1 + arch/x86/lib/fsp/fsp_car.S | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-)
Did you get a chance to test this? If no issue, I will take this patch for v2018.07.
No issues. Thank you!
applied to u-boot-x86, thanks!
participants (2)
-
Bin Meng
-
Ivan Gorinov