From: Xin Li <xin@zytor.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, andrew.cooper3@citrix.com
Subject: Re: [PATCH v1 1/1] x86/fred: Clear the WFE bit in missing-ENDBRANCH #CP
Date: Thu, 12 Sep 2024 01:25:55 -0700 [thread overview]
Message-ID: <e9376635-f578-41df-9e14-e4cc6def848a@zytor.com> (raw)
In-Reply-To: <20240912075714.GT4723@noisy.programming.kicks-ass.net>
On 9/12/2024 12:57 AM, Peter Zijlstra wrote:
> On Wed, Sep 11, 2024 at 04:19:29PM -0700, Xin Li (Intel) wrote:
>
>> +static void ibt_clear_fred_wfe(struct pt_regs *regs)
>> +{
>> + if (cpu_feature_enabled(X86_FEATURE_FRED))
>> + regs->fred_cs.wfe = 0;
>> +}
>> +
>> static void do_kernel_cp_fault(struct pt_regs *regs, unsigned long error_code)
>> {
>> if ((error_code & CP_EC) != CP_ENDBR) {
>> @@ -90,6 +107,7 @@ static void do_kernel_cp_fault(struct pt_regs *regs, unsigned long error_code)
>>
>> if (unlikely(regs->ip == (unsigned long)&ibt_selftest_noendbr)) {
>> regs->ax = 0;
>> + ibt_clear_fred_wfe(regs);
>> return;
>> }
>>
>> @@ -97,6 +115,7 @@ static void do_kernel_cp_fault(struct pt_regs *regs, unsigned long error_code)
>> if (!ibt_fatal) {
>> printk(KERN_DEFAULT CUT_HERE);
>> __warn(__FILE__, __LINE__, (void *)regs->ip, TAINT_WARN, regs, NULL);
>> + ibt_clear_fred_wfe(regs);
>> return;
>> }
>> BUG();
>
> So, why not clear the bit the moment we know this is CP_ENDBR?
>
> In the fatal case, we'll hit that BUG and die anyway, nobody cares about
> the tracker state in that case.
I did think about it, but preferred to leave it as in BUG().
But as you have asked, will change unless someone else disagrees with a
good reason :)
>
> diff --git a/arch/x86/kernel/cet.c b/arch/x86/kernel/cet.c
> index d2c732a34e5d..fde4bdd25a73 100644
> --- a/arch/x86/kernel/cet.c
> +++ b/arch/x86/kernel/cet.c
> @@ -88,6 +88,8 @@ static void do_kernel_cp_fault(struct pt_regs *regs, unsigned long error_code)
> return;
> }
>
> + ibt_clear_fred_wfe(regs);
> +
> if (unlikely(regs->ip == (unsigned long)&ibt_selftest_noendbr)) {
> regs->ax = 0;
> return;
>
prev parent reply other threads:[~2024-09-12 8:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-11 23:19 Xin Li (Intel)
2024-09-11 23:35 ` Andrew Cooper
2024-09-11 23:44 ` Xin Li
2024-09-15 18:17 ` Xin Li
2024-09-16 9:16 ` Andrew Cooper
2024-09-12 0:22 ` Dave Hansen
2024-09-12 8:53 ` Xin Li
2024-09-12 13:13 ` Andrew Cooper
2024-09-12 7:57 ` Peter Zijlstra
2024-09-12 8:25 ` Xin Li [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=e9376635-f578-41df-9e14-e4cc6def848a@zytor.com \
--to=xin@zytor.com \
--cc=andrew.cooper3@citrix.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--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®