@@ -188,11 +188,6 @@ static enum microcode_match_result microcode_fits(
return NEW_UCODE;
}
-static void free_patch(struct microcode_patch *patch)
-{
- xfree(patch);
-}
-
static enum microcode_match_result compare_header(
const struct microcode_patch *new, const struct microcode_patch *old)
{
@@ -418,6 +413,5 @@ const struct microcode_ops amd_ucode_ops = {
.start_update = start_update,
.end_update_percpu = svm_host_osvw_init,
#endif
- .free_patch = free_patch,
.compare_patch = compare_patch,
};
@@ -243,9 +243,9 @@ static struct microcode_patch *parse_blob(const char *buf, size_t len)
return NULL;
}
-static void microcode_free_patch(struct microcode_patch *microcode_patch)
+static void microcode_free_patch(struct microcode_patch *patch)
{
- microcode_ops->free_patch(microcode_patch);
+ xfree(patch);
}
/* Return true if cache gets updated. Otherwise, return false */
@@ -245,11 +245,6 @@ static enum microcode_match_result microcode_update_match(
return mc->rev > cpu_sig->rev ? NEW_UCODE : OLD_UCODE;
}
-static void free_patch(struct microcode_patch *patch)
-{
- xfree(patch);
-}
-
static enum microcode_match_result compare_patch(
const struct microcode_patch *new, const struct microcode_patch *old)
{
@@ -356,6 +351,5 @@ const struct microcode_ops intel_ucode_ops = {
.cpu_request_microcode = cpu_request_microcode,
.collect_cpu_info = collect_cpu_info,
.apply_microcode = apply_microcode,
- .free_patch = free_patch,
.compare_patch = compare_patch,
};
@@ -25,7 +25,7 @@ struct microcode_ops {
*
* If one is found, allocate and return a struct microcode_patch
* encapsulating the appropriate microcode patch. Does not alias the
- * original buffer.
+ * original buffer. Must be suitable to be freed with a single xfree().
*
* 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.
@@ -56,9 +56,6 @@ struct microcode_ops {
*/
void (*end_update_percpu)(void);
- /* Free a patch previously allocated by cpu_request_microcode(). */
- void (*free_patch)(struct microcode_patch *patch);
-
/*
* Given two patches, are they both applicable to the current CPU, and is
* new a higher revision than old?
With the newly cleaned up vendor logic, each struct microcode_patch is a trivial object in memory with no dependent allocations. This is unlikely to change moving forwards, and function pointers are expensive in the days of retpoline. Move the responsibility to xfree() back to common code. If the need does arise in the future, we can consider reintroducing the hook. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Jan Beulich <JBeulich@suse.com> CC: Wei Liu <wl@xen.org> CC: Roger Pau Monné <roger.pau@citrix.com> --- xen/arch/x86/cpu/microcode/amd.c | 6 ------ xen/arch/x86/cpu/microcode/core.c | 4 ++-- xen/arch/x86/cpu/microcode/intel.c | 6 ------ xen/arch/x86/cpu/microcode/private.h | 5 +---- 4 files changed, 3 insertions(+), 18 deletions(-)