@@ -35,6 +35,7 @@
#include <xen/watchdog.h>
#include <asm/apic.h>
+#include <asm/bootinfo.h>
#include <asm/cpu-policy.h>
#include <asm/nmi.h>
#include <asm/processor.h>
@@ -152,10 +153,8 @@ static int __init cf_check parse_ucode(const char *s)
custom_param("ucode", parse_ucode);
static void __init microcode_scan_module(
- unsigned long *module_map,
- const multiboot_info_t *mbi)
+ unsigned long *module_map, const struct boot_info *bi)
{
- module_t *mod = (module_t *)__va(mbi->mods_addr);
uint64_t *_blob_start;
unsigned long _blob_size;
struct cpio_data cd;
@@ -177,16 +176,16 @@ static void __init microcode_scan_module(
/*
* Try all modules and see whichever could be the microcode blob.
*/
- for ( i = 1 /* Ignore dom0 kernel */; i < mbi->mods_count; i++ )
+ for ( i = 1 /* Ignore dom0 kernel */; i < bi->nr_mods; i++ )
{
if ( !test_bit(i, module_map) )
continue;
- _blob_start = bootstrap_map(&mod[i]);
- _blob_size = mod[i].mod_end;
+ _blob_start = bootstrap_map_bm(&bi->mods[i]);
+ _blob_size = bi->mods[i].size;
if ( !_blob_start )
{
- printk("Could not map multiboot module #%d (size: %ld)\n",
+ printk("Could not map boot module #%d (size: %ld)\n",
i, _blob_size);
continue;
}
@@ -204,20 +203,18 @@ static void __init microcode_scan_module(
}
static void __init microcode_grab_module(
- unsigned long *module_map,
- const multiboot_info_t *mbi)
+ unsigned long *module_map, const struct boot_info *bi)
{
- module_t *mod = (module_t *)__va(mbi->mods_addr);
-
if ( ucode_mod_idx < 0 )
- ucode_mod_idx += mbi->mods_count;
- if ( ucode_mod_idx <= 0 || ucode_mod_idx >= mbi->mods_count ||
+ ucode_mod_idx += bi->nr_mods;
+ if ( ucode_mod_idx <= 0 || ucode_mod_idx >= bi->nr_mods ||
!__test_and_clear_bit(ucode_mod_idx, module_map) )
goto scan;
- ucode_mod = mod[ucode_mod_idx];
+ bi->mods[ucode_mod_idx].type = BOOTMOD_MICROCODE;
+ ucode_mod = *bi->mods[ucode_mod_idx].early_mod;
scan:
if ( ucode_scan )
- microcode_scan_module(module_map, mbi);
+ microcode_scan_module(module_map, bi);
}
static struct microcode_ops __ro_after_init ucode_ops;
@@ -805,8 +802,8 @@ static int __init early_update_cache(const void *data, size_t len)
return rc;
}
-int __init microcode_init_cache(unsigned long *module_map,
- const struct multiboot_info *mbi)
+int __init microcode_init_cache(
+ unsigned long *module_map, const struct boot_info *bi)
{
int rc = 0;
@@ -815,7 +812,7 @@ int __init microcode_init_cache(unsigned long *module_map,
if ( ucode_scan )
/* Need to rescan the modules because they might have been relocated */
- microcode_scan_module(module_map, mbi);
+ microcode_scan_module(module_map, bi);
if ( ucode_mod.mod_end )
rc = early_update_cache(bootstrap_map(&ucode_mod),
@@ -862,7 +859,7 @@ static int __init early_microcode_update_cpu(void)
}
int __init early_microcode_init(unsigned long *module_map,
- const struct multiboot_info *mbi)
+ const struct boot_info *bi)
{
const struct cpuinfo_x86 *c = &boot_cpu_data;
int rc = 0;
@@ -905,7 +902,7 @@ int __init early_microcode_init(unsigned long *module_map,
return -ENODEV;
}
- microcode_grab_module(module_map, mbi);
+ microcode_grab_module(module_map, bi);
if ( ucode_mod.mod_end || ucode_blob.size )
rc = early_microcode_update_cpu();
@@ -17,6 +17,7 @@ enum bootmod_type {
BOOTMOD_XEN,
BOOTMOD_KERNEL,
BOOTMOD_RAMDISK,
+ BOOTMOD_MICROCODE,
};
struct boot_module {
@@ -4,6 +4,8 @@
#include <xen/types.h>
#include <xen/percpu.h>
+#include <asm/bootinfo.h>
+
#include <public/xen.h>
struct multiboot_info;
@@ -22,12 +24,12 @@ struct cpu_signature {
DECLARE_PER_CPU(struct cpu_signature, cpu_sig);
void microcode_set_module(unsigned int idx);
-int microcode_update(XEN_GUEST_HANDLE(const_void) buf,
- unsigned long len, unsigned int flags);
-int early_microcode_init(unsigned long *module_map,
- const struct multiboot_info *mbi);
-int microcode_init_cache(unsigned long *module_map,
- const struct multiboot_info *mbi);
+int microcode_update(
+ XEN_GUEST_HANDLE(const_void) buf, unsigned long len, unsigned int flags);
+int early_microcode_init(
+ unsigned long *module_map, const struct boot_info *bi);
+int microcode_init_cache(
+ unsigned long *module_map, const struct boot_info *bi);
int microcode_update_one(void);
#endif /* ASM_X86__MICROCODE_H */
@@ -1398,7 +1398,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
* TODO: load ucode earlier once multiboot modules become accessible
* at an earlier stage.
*/
- early_microcode_init(module_map, mbi);
+ early_microcode_init(module_map, boot_info);
if ( xen_phys_start )
{
@@ -1952,7 +1952,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
timer_init();
- microcode_init_cache(module_map, mbi); /* Needs xmalloc() */
+ microcode_init_cache(module_map, boot_info); /* Needs xmalloc() */
tsx_init(); /* Needs microcode. May change HLE/RTM feature bits. */
Convert the microcode loading functions to take struct boot_info, and then using struct boot_module to map and check for microcode. To keep the changes focused, continue using the struct mod to hold the reference to the microcode that is used by the late microcode logic. Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> --- xen/arch/x86/cpu/microcode/core.c | 37 +++++++++++++--------------- xen/arch/x86/include/asm/bootinfo.h | 1 + xen/arch/x86/include/asm/microcode.h | 14 ++++++----- xen/arch/x86/setup.c | 4 +-- 4 files changed, 28 insertions(+), 28 deletions(-)