From: Ingo Molnar <mingo@kernel.org>
To: Daniel Verkamp <dverkamp@chromium.org>
Cc: x86@kernel.org, Tony Luck <tony.luck@intel.com>,
Borislav Petkov <bp@suse.de>, Jiri Slaby <jirislaby@kernel.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] x86: combine memmove FSRM and ERMS alternatives
Date: Sat, 14 Jan 2023 10:24:53 +0100 [thread overview]
Message-ID: <Y8J05QINTpERIZfe@gmail.com> (raw)
In-Reply-To: <20230113203427.1111689-1-dverkamp@chromium.org>
* Daniel Verkamp <dverkamp@chromium.org> wrote:
> The x86-64 memmove code has two ALTERNATIVE statements in a row, one to
> handle FSRM ("Fast Short REP MOVSB"), and one to handle ERMS ("Enhanced
> REP MOVSB"). If either of these features is present, the goal is to jump
> directly to a REP MOVSB; otherwise, some setup code that handles short
> lengths is executed. The first comparison of a sequence of specific
> small sizes is included in the first ALTERNATIVE, so it will be replaced
> by NOPs if FSRM is set, and then (assuming ERMS is also set) execution
> will fall through to the JMP to a REP MOVSB in the next ALTERNATIVE.
>
> The two ALTERNATIVE invocations can be combined into a single instance
> of ALTERNATIVE_2 to simplify and slightly shorten the code. If either
> FSRM or ERMS is set, the first instruction in the memmove_begin_forward
> path will be replaced with a jump to the REP MOVSB.
>
> This also prevents a problem when FSRM is set but ERMS is not; in this
> case, the previous code would have replaced both ALTERNATIVEs with NOPs
> and skipped the first check for sizes less than 0x20 bytes. This
> combination of CPU features is arguably a firmware bug, but this patch
> makes the function robust against this badness.
>
> Fixes: f444a5ff95dc ("x86/cpufeatures: Add support for fast short REP; MOVSB")
> Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Could you please extend the changelog with the information about the guest
and baremetal firmware tthat Jiri Slaby pointed out?
Ie. acknowledging Boris's point that these are technically invalid CPUID
combinations, but emphasizing that the x86 memcpy routines should not
behave in an undefined fashion while other OSs boot fine under the same
firmware environment ...
[ Also, please Cc: lkml and don't Cc: -stable. ]
Thanks,
Ingo
next prev parent reply other threads:[~2023-01-14 9:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 20:34 [PATCH] x86: combine memmove FSRM and ERMS alternatives Daniel Verkamp
2023-01-14 6:55 ` Greg KH
2023-01-14 9:24 ` Ingo Molnar [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-01-13 20:32 Daniel Verkamp
2023-01-14 6:55 ` Greg KH
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=Y8J05QINTpERIZfe@gmail.com \
--to=mingo@kernel.org \
--cc=bp@suse.de \
--cc=dverkamp@chromium.org \
--cc=jirislaby@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.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).