From: Jan Beulich <jbeulich@suse.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH 3/7] x86/ucode/intel: Remove gratuitous memory allocations from cpu_request_microcode()
Date: Wed, 25 Mar 2020 14:34:07 +0100 [thread overview]
Message-ID: <f3aa9bde-1cf7-f400-ba0b-dc9defb687d3@suse.com> (raw)
In-Reply-To: <20200323101724.15655-4-andrew.cooper3@citrix.com>
On 23.03.2020 11:17, Andrew Cooper wrote:
> static struct microcode_patch *cpu_request_microcode(const void *buf,
> size_t size)
> {
> - long offset = 0;
> int error = 0;
> - struct microcode_intel *mc, *saved = NULL;
> + const struct microcode_intel *saved = NULL;
> struct microcode_patch *patch = NULL;
>
> - while ( (offset = get_next_ucode_from_buffer(&mc, buf, size, offset)) > 0 )
> + while ( size )
> {
> - error = microcode_sanity_check(mc);
> - if ( error )
> + const struct microcode_intel *mc;
> + unsigned int blob_size;
> +
> + if ( size < MC_HEADER_SIZE || /* Insufficient space for header? */
> + (mc = buf)->hdr.hdrver != 1 || /* Unrecognised header version? */
> + mc->hdr.ldrver != 1 || /* Unrecognised loader version? */
These two duplicate what microcode_sanity_check() does,
plus the function issues a log message when either check
fails. Since I think ...
> + size < (blob_size = /* Insufficient space for patch? */
> + get_totalsize(&mc->hdr)) )
... this wants to come after the two version checks, how
about lifting the printk() here? The other user of
microcode_sanity_check() is an ASSERT(), where it's rather
less relevant to have such a printk().
Jan
next prev parent reply other threads:[~2020-03-25 13:34 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 ` [Xen-devel] [PATCH 2/7] x86/ucode/intel: Adjust microcode_sanity_check() to not take void * Andrew Cooper
2020-03-25 13:23 ` 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 [this message]
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=f3aa9bde-1cf7-f400-ba0b-dc9defb687d3@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.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).