@@ -311,7 +311,7 @@ static int scan_equiv_cpu_table(const struct container_equiv_table *et)
return -ESRCH;
}
-static struct microcode_patch *cf_check cpu_request_microcode(
+static struct microcode_patch *cf_check amd_ucode_parse(
const void *buf, size_t size, bool make_copy)
{
const struct microcode_patch *saved = NULL;
@@ -444,7 +444,7 @@ static struct microcode_patch *cf_check cpu_request_microcode(
}
static const struct microcode_ops __initconst_cf_clobber amd_ucode_ops = {
- .cpu_request_microcode = cpu_request_microcode,
+ .parse = amd_ucode_parse,
.collect_cpu_info = collect_cpu_info,
.apply_microcode = apply_microcode,
.compare_patch = compare_patch,
@@ -217,6 +217,18 @@ static void __init microcode_grab_module(struct boot_info *bi)
static struct microcode_ops __ro_after_init ucode_ops;
+/* Parse a ucode blob. Returns a pointer to a heap-allocated copy, or PTR_ERR. */
+static struct microcode_patch *ucode_parse_dup(const char *buf, size_t len)
+{
+ return alternative_call(ucode_ops.parse, buf, len, true);
+}
+
+/* Parse a ucode blob. Returns a pointer into @buf, or PTR_ERR. */
+static const struct microcode_patch *ucode_parse(const char *buf, size_t len)
+{
+ return alternative_call(ucode_ops.parse, buf, len, false);
+}
+
static DEFINE_SPINLOCK(microcode_mutex);
DEFINE_PER_CPU(struct cpu_signature, cpu_sig);
@@ -604,9 +616,7 @@ static long cf_check ucode_update_hcall_cont(void *data)
}
alternative_vcall(ucode_ops.collect_cpu_info);
- patch_with_flags.patch = alternative_call(ucode_ops.cpu_request_microcode,
- (const void *)buffer->buffer,
- buffer->len, true);
+ patch_with_flags.patch = ucode_parse_dup(buffer->buffer, buffer->len);
patch_with_flags.flags = buffer->flags;
xfree(buffer);
if ( IS_ERR(patch_with_flags.patch) )
@@ -788,7 +798,7 @@ static int __init early_update_cache(const void *data, size_t len)
return -ENOMEM;
alternative_vcall(ucode_ops.collect_cpu_info);
- patch = alternative_call(ucode_ops.cpu_request_microcode, data, len, true);
+ patch = ucode_parse_dup(data, len);
if ( IS_ERR(patch) )
{
printk(XENLOG_WARNING "Parsing microcode blob error %ld\n",
@@ -832,7 +842,7 @@ static int __init early_microcode_update_cpu(void)
{
const void *data = NULL;
size_t len;
- struct microcode_patch *patch;
+ const struct microcode_patch *patch;
if ( ucode_blob.size )
{
@@ -848,7 +858,7 @@ static int __init early_microcode_update_cpu(void)
if ( !data )
return -ENOMEM;
- patch = ucode_ops.cpu_request_microcode(data, len, false);
+ patch = ucode_parse(data, len);
if ( IS_ERR(patch) )
{
printk(XENLOG_WARNING "Parsing microcode blob error %ld\n",
@@ -334,7 +334,7 @@ static int cf_check apply_microcode(const struct microcode_patch *patch,
return 0;
}
-static struct microcode_patch *cf_check cpu_request_microcode(
+static struct microcode_patch *cf_check intel_ucode_parse(
const void *buf, size_t size, bool make_copy)
{
int error = 0;
@@ -406,7 +406,7 @@ static bool __init can_load_microcode(void)
}
static const struct microcode_ops __initconst_cf_clobber intel_ucode_ops = {
- .cpu_request_microcode = cpu_request_microcode,
+ .parse = intel_ucode_parse,
.collect_cpu_info = collect_cpu_info,
.apply_microcode = apply_microcode,
.compare_patch = compare_patch,
@@ -37,7 +37,7 @@ struct microcode_ops {
* If one is not found, (nothing matches the current CPU), return NULL.
* Also may return ERR_PTR(-err), e.g. bad container, out of memory.
*/
- struct microcode_patch *(*cpu_request_microcode)(
+ struct microcode_patch *(*parse)(
const void *buf, size_t size, bool make_copy);
/*
cpu_request_microcode() was never a good name, and the microcode suffix is redundant. Rename it to simply parse(). Introduce ucode_parse() and ucode_parse_dup() wrappers around the parse() hook, also abstracting away the make_copy parameter and associated const-correctness. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Jan Beulich <JBeulich@suse.com> CC: Roger Pau Monné <roger.pau@citrix.com> --- xen/arch/x86/cpu/microcode/amd.c | 4 ++-- xen/arch/x86/cpu/microcode/core.c | 22 ++++++++++++++++------ xen/arch/x86/cpu/microcode/intel.c | 4 ++-- xen/arch/x86/cpu/microcode/private.h | 2 +- 4 files changed, 21 insertions(+), 11 deletions(-)