From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wl@xen.org>, "Jan Beulich" <JBeulich@suse.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH 2/7] x86/ucode/intel: Adjust microcode_sanity_check() to not take void *
Date: Mon, 23 Mar 2020 10:17:19 +0000 [thread overview]
Message-ID: <20200323101724.15655-3-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20200323101724.15655-1-andrew.cooper3@citrix.com>
microcode_sanity_check()'s callers actually call it with a mixture of
microcode_intel and microcode_header_intel pointers, which is fragile.
Rework it to take struct microcode_intel *, which in turn requires
microcode_update_match()'s type to be altered.
No functional change - compiled binary is identical.
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/intel.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/xen/arch/x86/cpu/microcode/intel.c b/xen/arch/x86/cpu/microcode/intel.c
index f26511da98..f0beefe1bb 100644
--- a/xen/arch/x86/cpu/microcode/intel.c
+++ b/xen/arch/x86/cpu/microcode/intel.c
@@ -119,9 +119,9 @@ static int collect_cpu_info(struct cpu_signature *csig)
return 0;
}
-static int microcode_sanity_check(const void *mc)
+static int microcode_sanity_check(const struct microcode_intel *mc)
{
- const struct microcode_header_intel *mc_header = mc;
+ const struct microcode_header_intel *mc_header = &mc->hdr;
const struct extended_sigtable *ext_header = NULL;
const struct extended_signature *ext_sig;
unsigned long total_size, data_size, ext_table_size;
@@ -153,7 +153,7 @@ static int microcode_sanity_check(const void *mc)
"Small exttable size in microcode data file\n");
return -EINVAL;
}
- ext_header = mc + MC_HEADER_SIZE + data_size;
+ ext_header = (void *)mc + MC_HEADER_SIZE + data_size;
if ( ext_table_size != exttable_size(ext_header) )
{
printk(KERN_ERR "microcode: error! "
@@ -211,8 +211,9 @@ static int microcode_sanity_check(const void *mc)
/* Check an update against the CPU signature and current update revision */
static enum microcode_match_result microcode_update_match(
- const struct microcode_header_intel *mc_header)
+ const struct microcode_intel *mc)
{
+ const struct microcode_header_intel *mc_header = &mc->hdr;
const struct extended_sigtable *ext_header;
const struct extended_signature *ext_sig;
unsigned int i;
@@ -223,7 +224,7 @@ static enum microcode_match_result microcode_update_match(
unsigned long data_size = get_datasize(mc_header);
const void *end = (const void *)mc_header + get_totalsize(mc_header);
- ASSERT(!microcode_sanity_check(mc_header));
+ ASSERT(!microcode_sanity_check(mc));
if ( sigmatch(sig, mc_header->sig, pf, mc_header->pf) )
return (mc_header->rev > rev) ? NEW_UCODE : OLD_UCODE;
@@ -249,7 +250,7 @@ static bool match_cpu(const struct microcode_patch *patch)
if ( !patch )
return false;
- return microcode_update_match(&patch->mc_intel->hdr) == NEW_UCODE;
+ return microcode_update_match(patch->mc_intel) == NEW_UCODE;
}
static void free_patch(struct microcode_patch *patch)
@@ -268,8 +269,8 @@ static enum microcode_match_result compare_patch(
* Both patches to compare are supposed to be applicable to local CPU.
* Just compare the revision number.
*/
- ASSERT(microcode_update_match(&old->mc_intel->hdr) != MIS_UCODE);
- ASSERT(microcode_update_match(&new->mc_intel->hdr) != MIS_UCODE);
+ ASSERT(microcode_update_match(old->mc_intel) != MIS_UCODE);
+ ASSERT(microcode_update_match(new->mc_intel) != MIS_UCODE);
return (new->mc_intel->hdr.rev > old->mc_intel->hdr.rev) ? NEW_UCODE
: OLD_UCODE;
@@ -367,7 +368,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf,
* If the new update covers current CPU, compare updates and store the
* one with higher revision.
*/
- if ( (microcode_update_match(&mc->hdr) != MIS_UCODE) &&
+ if ( (microcode_update_match(mc) != MIS_UCODE) &&
(!saved || (mc->hdr.rev > saved->hdr.rev)) )
{
xfree(saved);
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2020-03-23 10:18 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-23 10:17 [Xen-devel] [PATCH 0/7] x86/ucode: Cleanup and fixes - Part 3/n (Intel) Andrew Cooper
2020-03-23 10:17 ` [Xen-devel] [PATCH 1/7] x86/ucode: Document the behaviour of the microcode_ops hooks Andrew Cooper
2020-03-23 12:33 ` Jan Beulich
2020-03-23 13:26 ` Andrew Cooper
2020-03-23 14:24 ` Jan Beulich
2020-03-23 10:17 ` Andrew Cooper [this message]
2020-03-25 13:23 ` [Xen-devel] [PATCH 2/7] x86/ucode/intel: Adjust microcode_sanity_check() to not take void * Jan Beulich
2020-03-23 10:17 ` [Xen-devel] [PATCH 3/7] x86/ucode/intel: Remove gratuitous memory allocations from cpu_request_microcode() Andrew Cooper
2020-03-25 13:34 ` Jan Beulich
2020-03-23 10:17 ` [Xen-devel] [PATCH 4/7] x86/ucode/intel: Reimplement get_{data, total}size() helpers Andrew Cooper
2020-03-25 13:41 ` Jan Beulich
2020-03-26 14:35 ` Andrew Cooper
2020-03-26 14:56 ` Jan Beulich
2020-03-26 15:09 ` Andrew Cooper
2020-03-26 15:19 ` Jan Beulich
2020-03-23 10:17 ` [Xen-devel] [PATCH 5/7] x86/ucode/intel: Clean up microcode_update_match() Andrew Cooper
2020-03-25 13:51 ` Jan Beulich
2020-03-26 14:36 ` Andrew Cooper
2020-03-23 10:17 ` [Xen-devel] [PATCH 6/7] x86/ucode/intel: Clean up microcode_sanity_check() Andrew Cooper
2020-03-25 14:07 ` Jan Beulich
2020-03-26 14:41 ` Andrew Cooper
2020-03-26 15:02 ` Jan Beulich
2020-03-23 10:17 ` [Xen-devel] [PATCH 7/7] x86/ucode/intel: Fold structures together Andrew Cooper
2020-03-25 14:16 ` Jan Beulich
2020-03-25 14:32 ` Andrew Cooper
2020-03-26 12:24 ` Jan Beulich
2020-03-26 14:50 ` Andrew Cooper
2020-03-26 15:05 ` Jan Beulich
2020-03-27 12:40 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200323101724.15655-3-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).