From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
Jan Beulich <JBeulich@suse.com>, Wei Liu <wl@xen.org>
Subject: Re: [PATCH] x86/cpu-policy: Allow for levelling of VERW side effects
Date: Fri, 1 Mar 2024 20:34:34 +0100 [thread overview]
Message-ID: <ZeItyorCCVHsL-M-@macbook> (raw)
In-Reply-To: <4fedcd61-94e1-4869-b620-27c48e8dafef@citrix.com>
On Fri, Mar 01, 2024 at 03:01:36PM +0000, Andrew Cooper wrote:
> On 01/03/2024 1:28 pm, Roger Pau Monné wrote:
> > On Thu, Feb 29, 2024 at 06:13:54PM +0000, Andrew Cooper wrote:
> >> MD_CLEAR and FB_CLEAR need OR-ing across a migrate pool. Allow this, by
> >> having them unconditinally set in max, with the host values reflected in
> >> default. Annotate the bits as having special properies.
> >>
> >> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> >> ---
> >> CC: Jan Beulich <JBeulich@suse.com>
> >> CC: Roger Pau Monné <roger.pau@citrix.com>
> >> CC: Wei Liu <wl@xen.org>
> >> ---
> >> xen/arch/x86/cpu-policy.c | 24 +++++++++++++++++++++
> >> xen/include/public/arch-x86/cpufeatureset.h | 4 ++--
> >> 2 files changed, 26 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
> >> index f3ed2d3a3227..41123e6cf778 100644
> >> --- a/xen/arch/x86/cpu-policy.c
> >> +++ b/xen/arch/x86/cpu-policy.c
> >> @@ -442,6 +442,16 @@ static void __init guest_common_max_feature_adjustments(uint32_t *fs)
> >> __set_bit(X86_FEATURE_RSBA, fs);
> >> __set_bit(X86_FEATURE_RRSBA, fs);
> >>
> >> + /*
> >> + * These bits indicate that the VERW instruction may have gained
> >> + * scrubbing side effects. With pooling, they mean "you might migrate
> >> + * somewhere where scrubbing is necessary", and may need exposing on
> >> + * unaffected hardware. This is fine, because the VERW instruction
> >> + * has been around since the 286.
> >> + */
> >> + __set_bit(X86_FEATURE_MD_CLEAR, fs);
> >> + __set_bit(X86_FEATURE_FB_CLEAR, fs);
> >> +
> >> /*
> >> * The Gather Data Sampling microcode mitigation (August 2023) has an
> >> * adverse performance impact on the CLWB instruction on SKX/CLX/CPX.
> >> @@ -476,6 +486,20 @@ static void __init guest_common_default_feature_adjustments(uint32_t *fs)
> >> cpu_has_rdrand && !is_forced_cpu_cap(X86_FEATURE_RDRAND) )
> >> __clear_bit(X86_FEATURE_RDRAND, fs);
> >>
> >> + /*
> >> + * These bits indicate that the VERW instruction may have gained
> >> + * scrubbing side effects. The max policy has them set for migration
> >> + * reasons, so reset the default policy back to the host values in
> >> + * case we're unaffected.
> >> + */
> >> + fs[FEATURESET_7d0] &= ~cpufeat_mask(X86_FEATURE_MD_CLEAR);
> >> + fs[FEATURESET_m10Al] &= ~cpufeat_mask(X86_FEATURE_FB_CLEAR);
> >> +
> >> + fs[FEATURESET_7d0] |= (boot_cpu_data.x86_capability[FEATURESET_7d0] &
> >> + cpufeat_mask(X86_FEATURE_MD_CLEAR));
> >> + fs[FEATURESET_m10Al] |= (boot_cpu_data.x86_capability[FEATURESET_m10Al] &
> >> + cpufeat_mask(X86_FEATURE_FB_CLEAR));
> > This seems quite convoluted, why not use:
> >
> > __clear_bit(X86_FEATURE_MD_CLEAR, fs);
> > if ( boot_cpu_has(X86_FEATURE_MD_CLEAR) )
> > __set_bit(X86_FEATURE_MD_CLEAR, fs);
> >
> > And the same for FB_CLEAR. I think that's quite easier to read.
>
> This better?
>
> + /*
> + * These bits indicate that the VERW instruction may have gained
> + * scrubbing side effects. The max policy has them set for
> migration
> + * reasons, so reset the default policy back to the host values in
> + * case we're unaffected.
> + */
> + __clear_bit(X86_FEATURE_MD_CLEAR);
> + if ( cpu_has_md_clear )
> + __set_bit(X86_FEATURE_MD_CLEAR);
> +
> + __clear_bit(X86_FEATURE_FB_CLEAR);
> + if ( cpu_has_fb_clear )
> + __set_bit(X86_FEATURE_FB_CLEAR);
Sure, with that please add my:
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Thanks, Roger.
prev parent reply other threads:[~2024-03-01 19:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 18:13 [PATCH] x86/cpu-policy: Allow for levelling of VERW side effects Andrew Cooper
2024-03-01 13:28 ` Roger Pau Monné
2024-03-01 15:01 ` Andrew Cooper
2024-03-01 19:34 ` Roger Pau Monné [this message]
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=ZeItyorCCVHsL-M-@macbook \
--to=roger.pau@citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@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.