@@ -434,9 +434,17 @@ static struct microcode_patch *cf_check cpu_request_microcode(
return patch;
}
-const struct microcode_ops __initconst_cf_clobber amd_ucode_ops = {
+static const struct microcode_ops __initconst_cf_clobber amd_ucode_ops = {
.cpu_request_microcode = cpu_request_microcode,
.collect_cpu_info = collect_cpu_info,
.apply_microcode = apply_microcode,
.compare_patch = compare_patch,
};
+
+void __init ucode_probe_amd(struct microcode_ops *ops)
+{
+ if ( boot_cpu_data.x86 < 0x10 )
+ return;
+
+ *ops = amd_ucode_ops;
+}
@@ -847,25 +847,19 @@ int __init early_microcode_init(unsigned long *module_map,
{
const struct cpuinfo_x86 *c = &boot_cpu_data;
int rc = 0;
- bool can_load = false;
switch ( c->x86_vendor )
{
case X86_VENDOR_AMD:
- if ( c->x86 >= 0x10 )
- {
- ucode_ops = amd_ucode_ops;
- can_load = true;
- }
+ ucode_probe_amd(&ucode_ops);
break;
case X86_VENDOR_INTEL:
- ucode_ops = intel_ucode_ops;
- can_load = intel_can_load_microcode();
+ ucode_probe_intel(&ucode_ops);
break;
}
- if ( !ucode_ops.apply_microcode )
+ if ( !ucode_ops.collect_cpu_info )
{
printk(XENLOG_INFO "Microcode loading not available\n");
return -ENODEV;
@@ -882,10 +876,10 @@ int __init early_microcode_init(unsigned long *module_map,
*
* Take the hint in either case and ignore the microcode interface.
*/
- if ( this_cpu(cpu_sig).rev == ~0 || !can_load )
+ if ( !ucode_ops.apply_microcode || this_cpu(cpu_sig).rev == ~0 )
{
printk(XENLOG_INFO "Microcode loading disabled due to: %s\n",
- can_load ? "rev = ~0" : "HW toggle");
+ ucode_ops.apply_microcode ? "rev = ~0" : "HW toggle");
ucode_ops.apply_microcode = NULL;
return -ENODEV;
}
@@ -385,7 +385,7 @@ static struct microcode_patch *cf_check cpu_request_microcode(
return patch;
}
-bool __init intel_can_load_microcode(void)
+static bool __init can_load_microcode(void)
{
uint64_t mcu_ctrl;
@@ -398,9 +398,17 @@ bool __init intel_can_load_microcode(void)
return !(mcu_ctrl & MCU_CONTROL_DIS_MCU_LOAD);
}
-const struct microcode_ops __initconst_cf_clobber intel_ucode_ops = {
+static const struct microcode_ops __initconst_cf_clobber intel_ucode_ops = {
.cpu_request_microcode = cpu_request_microcode,
.collect_cpu_info = collect_cpu_info,
.apply_microcode = apply_microcode,
.compare_patch = compare_patch,
};
+
+void __init ucode_probe_intel(struct microcode_ops *ops)
+{
+ *ops = intel_ucode_ops;
+
+ if ( !can_load_microcode() )
+ ops->apply_microcode = NULL;
+}
@@ -60,13 +60,17 @@ struct microcode_ops {
const struct microcode_patch *new, const struct microcode_patch *old);
};
-/**
- * Checks whether we can perform microcode updates on this Intel system
+/*
+ * Microcode loading falls into one of 3 states.
+ * - No support at all
+ * - Read-only (locked by firmware, or we're virtualised)
+ * - Loading available
*
- * @return True iff the microcode update facilities are enabled
+ * These are encoded by (not) filling in ops->collect_cpu_info (i.e. no
+ * support available) and (not) ops->apply_microcode (i.e. read only).
+ * Otherwise, all hooks must be filled in.
*/
-bool intel_can_load_microcode(void);
-
-extern const struct microcode_ops amd_ucode_ops, intel_ucode_ops;
+void ucode_probe_amd(struct microcode_ops *ops);
+void ucode_probe_intel(struct microcode_ops *ops);
#endif /* ASM_X86_MICROCODE_PRIVATE_H */