From: Chao Gao <chao.gao@intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Ashok Raj" <ashok.raj@intel.com>, "Wei Liu" <wl@xen.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>
Subject: Re: [Xen-devel] [PATCH v8 06/16] microcode: introduce a global cache of ucode patch
Date: Mon, 5 Aug 2019 15:02:58 +0800 [thread overview]
Message-ID: <20190805070258.GB19492@gao-cwp> (raw)
In-Reply-To: <87a8ebf4-75f7-2397-204a-794d04404d1f@suse.com>
On Fri, Aug 02, 2019 at 02:46:58PM +0000, Jan Beulich wrote:
>On 01.08.2019 12:22, Chao Gao wrote:
>> +bool microcode_update_cache(struct microcode_patch *patch)
>> +{
>> +
>> + ASSERT(spin_is_locked(µcode_mutex));
>> +
>> + if ( !microcode_cache )
>> + microcode_cache = patch;
>> + else if ( microcode_ops->compare_patch(patch, microcode_cache) ==
>> + NEW_UCODE )
>
>Indentation is wrong here.
>
>> +static struct microcode_patch *alloc_microcode_patch(
>> + const struct microcode_amd *mc_amd)
>> +{
>> + struct microcode_patch *microcode_patch = xmalloc(struct microcode_patch);
>> + struct microcode_amd *cache = xmalloc(struct microcode_amd);
>> + void *mpb = xmalloc_bytes(mc_amd->mpb_size);
>> + struct equiv_cpu_entry *equiv_cpu_table =
>> + xmalloc_bytes(mc_amd->equiv_cpu_table_size);
>> +
>> + if ( !microcode_patch || !cache || !mpb || !equiv_cpu_table )
>> + {
>> + xfree(microcode_patch);
>> + xfree(cache);
>> + xfree(mpb);
>> + xfree(equiv_cpu_table);
>> + return ERR_PTR(-ENOMEM);
>> + }
>> +
>> + memcpy(mpb, mc_amd->mpb, mc_amd->mpb_size);
>> + cache->mpb = mpb;
>> + cache->mpb_size = mc_amd->mpb_size;
>> + memcpy(equiv_cpu_table, mc_amd->equiv_cpu_table,
>> + mc_amd->equiv_cpu_table_size);
>> + cache->equiv_cpu_table = equiv_cpu_table;
>> + cache->equiv_cpu_table_size = mc_amd->equiv_cpu_table_size;
>> + microcode_patch->mc_amd = cache;
>> +
>> + return microcode_patch;
>> +}
>
>Why is it that everything needs to be copied here, rather than
>simply shuffling one (or a few) pointer(s)? Can't the caller
>simply install the argument it passes here as the new cache blob?
The old per-cpu cache would use the pointers. And the old cache struct
is removed in "microcode: remove struct ucode_cpu_info". I can add a
patch after that one to reuse the pointers. Otherwise, I may have to
merge following two patches into this one.
>
>> +static enum microcode_match_result compare_patch(
>> + const struct microcode_patch *new, const struct microcode_patch *old)
>> +{
>> + const struct microcode_header_intel *old_header = &old->mc_intel->hdr;
>> +
>> + return microcode_update_match(&new->mc_intel->hdr, old_header->sig,
>> + old_header->pf, old_header->rev);
>
>So this is exactly what I said on the earlier patch the function
>cannot be used for. The way "pf" works precludes this, as said in
>reply to an earlier version, and no-one corrected me (i.e. I'm in
>no way excluding I'm misunderstanding something here).
How about just check 'rev' here and leave a comment here to explain
why?
We drops all mismatched patches (including that only has 'pf'
mismatched) compared with current CPU signature. Given that, it is
fine to only check the revision number.
Thanks
Chao
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-08-05 7:10 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 10:22 [Xen-devel] [PATCH v8 00/16] improve late microcode loading Chao Gao
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 01/16] misc/xen-ucode: Upload a microcode blob to the hypervisor Chao Gao
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 02/16] x86/microcode: always collect_cpu_info() during boot Chao Gao
2019-08-01 10:35 ` Andrew Cooper
2019-08-02 13:23 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 03/16] microcode/intel: extend microcode_update_match() Chao Gao
2019-08-02 13:29 ` Jan Beulich
2019-08-05 5:58 ` Chao Gao
2019-08-05 9:27 ` Jan Beulich
2019-08-05 11:51 ` Chao Gao
2019-08-05 11:50 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 04/16] microcode/amd: fix memory leak Chao Gao
2019-08-02 13:39 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 05/16] microcode/amd: distinguish old and mismatched ucode in microcode_fits() Chao Gao
2019-08-02 13:41 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 06/16] microcode: introduce a global cache of ucode patch Chao Gao
2019-08-02 14:46 ` Jan Beulich
2019-08-05 7:02 ` Chao Gao [this message]
2019-08-05 9:31 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 07/16] microcode: clean up microcode_resume_cpu Chao Gao
2019-08-02 14:57 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 08/16] microcode: remove struct ucode_cpu_info Chao Gao
2019-08-02 15:03 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 09/16] microcode: remove pointless 'cpu' parameter Chao Gao
2019-08-02 15:15 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 10/16] microcode/amd: call svm_host_osvw_init() in common code Chao Gao
2019-08-02 15:21 ` Jan Beulich
2019-08-05 7:05 ` Chao Gao
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 11/16] microcode: pass a patch pointer to apply_microcode() Chao Gao
2019-08-02 15:25 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 12/16] microcode: split out apply_microcode() from cpu_request_microcode() Chao Gao
2019-08-02 15:40 ` Jan Beulich
2019-08-05 7:36 ` Chao Gao
2019-08-05 9:38 ` Jan Beulich
2019-08-05 12:09 ` Chao Gao
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 13/16] microcode: unify loading update during CPU resuming and AP wakeup Chao Gao
2019-08-05 10:19 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 14/16] x86/microcode: Synchronize late microcode loading Chao Gao
2019-08-05 10:43 ` Jan Beulich
2019-08-05 13:16 ` Chao Gao
2019-08-05 13:28 ` Jan Beulich
2019-08-05 12:07 ` Jan Beulich
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 15/16] microcode: remove microcode_update_lock Chao Gao
2019-08-01 10:22 ` [Xen-devel] [PATCH v8 16/16] microcode: block #NMI handling when loading an ucode Chao Gao
2019-08-05 12:11 ` Jan Beulich
2019-08-07 7:59 ` Chao Gao
2019-08-07 8:44 ` Jan Beulich
2019-08-01 18:15 ` [Xen-devel] [PATCH v8 00/16] improve late microcode loading Andrew Cooper
2019-08-02 10:59 ` Roger Pau Monné
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=20190805070258.GB19492@gao-cwp \
--to=chao.gao@intel.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=ashok.raj@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.