From: Andrew Cooper <andrew.cooper3@citrix.com>
To: <peterz@infradead.org>, <x86@kernel.org>
Cc: Juergen Gross <jgross@suse.com>,
LKML <linux-kernel@vger.kernel.org>,
"Andy Lutomirski" <luto@kernel.org>
Subject: Re: [PATCH] x86/entry: Fix AC assertion
Date: Mon, 24 Aug 2020 15:22:06 +0100 [thread overview]
Message-ID: <d2b0c6a5-19d8-f868-e092-e5c197ab0d0e@citrix.com> (raw)
In-Reply-To: <20200824101428.GS1362448@hirez.programming.kicks-ass.net>
On 24/08/2020 11:14, peterz@infradead.org wrote:
> The WARN added in commit 3c73b81a9164 ("x86/entry, selftests: Further
> improve user entry sanity checks") unconditionally triggers on my IVB
> machine because it does not support SMAP.
>
> For !SMAP hardware we patch out CLAC/STAC instructions and thus if
> userspace sets AC, we'll still have it set after entry.
Technically, you don't patch in, rather than patch out.
>
> Fixes: 3c73b81a9164 ("x86/entry, selftests: Further improve user entry sanity checks")
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Acked-by: Andy Lutomirski <luto@kernel.org>
> ---
> arch/x86/include/asm/entry-common.h | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> --- a/arch/x86/include/asm/entry-common.h
> +++ b/arch/x86/include/asm/entry-common.h
> @@ -18,8 +18,15 @@ static __always_inline void arch_check_u
> * state, not the interrupt state as imagined by Xen.
> */
> unsigned long flags = native_save_fl();
> - WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF |
> - X86_EFLAGS_NT));
> + unsigned long mask = X86_EFLAGS_DF | X86_EFLAGS_NT;
> +
> + /*
> + * For !SMAP hardware we patch out CLAC on entry.
> + */
> + if (boot_cpu_has(X86_FEATURE_SMAP))
> + mask |= X86_EFLAGS_AC;
The Xen PV ABI clears AC on entry for 64bit guests, because Linux is
actually running in Ring 3, and therefore susceptible to #AC's which
wouldn't occur natively.
~Andrew
next prev parent reply other threads:[~2020-08-24 14:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 10:14 peterz
2020-08-24 14:22 ` Andrew Cooper [this message]
2020-08-24 15:21 ` peterz
2020-08-24 15:58 ` Andrew Cooper
2020-08-24 16:27 ` Jürgen Groß
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=d2b0c6a5-19d8-f868-e092-e5c197ab0d0e@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--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
all inboxes | Powered by JetHome®