From: Xin Li <xin@zytor.com>
To: "H. Peter Anvin" <hpa@zytor.com>,
Hou Wenlong <houwenlong.hwl@antgroup.com>
Cc: linux-kernel@vger.kernel.org,
Lai Jiangshan <jiangshan.ljs@antgroup.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, Xin Li <xin3.li@intel.com>,
Jacob Pan <jacob.jun.pan@linux.intel.com>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 0/2] x86/fred: Fix two problems during the FRED initialization
Date: Tue, 25 Jun 2024 10:31:54 -0700 [thread overview]
Message-ID: <0926bc9e-3d70-4ee1-b861-a8ab220ffec1@zytor.com> (raw)
In-Reply-To: <6D3EF8F0-9D70-438B-9B9C-9BC1A64E17E3@zytor.com>
On 6/25/2024 10:24 AM, H. Peter Anvin wrote:
> On June 25, 2024 2:09:29 AM PDT, Xin Li <xin@zytor.com> wrote:
>> On 6/23/2024 11:21 PM, Hou Wenlong wrote:
>>> I'm not sure if there will be a #PF during that gap; I just received the
>>> wrong fault address when I made a mistake in that gap and a #PF
>>> occurred. Before idt_setup_early_pf(), the registered page fault handler
>>> is do_early_exception(), which uses native_read_cr2(). However, after
>>> that, the page fault handler had been changed to exc_page_fault(), so if
>>> something bad happened and an unexpected #PF occurred, the fault address
>>> in the error output will be wrong, although the CR2 in __show_regs() is
>>> correct. I'm not sure if this matters or not since the kernel will panic
>>> at that time.
>>
>> So this doesn't sound a real problem, right?
>>
>> We could simply do:
>>
>> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
>> index e6c469b323cc..e500777ed2b4 100644
>> --- a/arch/x86/mm/fault.c
>> +++ b/arch/x86/mm/fault.c
>> @@ -1495,7 +1495,7 @@ DEFINE_IDTENTRY_RAW_ERRORCODE(exc_page_fault)
>> irqentry_state_t state;
>> unsigned long address;
>>
>> - address = cpu_feature_enabled(X86_FEATURE_FRED) ? fred_event_data(regs) : read_cr2();
>> + address = native_read_cr4() & X86_CR4_FRED ? fred_event_data(regs) : read_cr2();
>>
>> prefetchw(¤t->mm->mmap_lock);
>>
>>
>> But the page fault handler is an extreme hot path, it's not worth it.
>>
>> Thanks!
>> Xin
> Reading CR4 is insane from a performance perspective. Also, there is pretty much never a reason to, since CR4 is programmed by the OS.
Agreed!
>
> But this is basically insane. We should enable FRED from the point we cut over from the early exception vector. That is:
>
> Early IDT → Final IDT
> or
> Early IDT → FRED
>
> But not
>
> Early IDT → Final IDT → FRED
>
> Eventually we should enable FRED for early exceptions too (which ought to be quite trivial, but makes the whole CLI enable/disable a bit of a mess.)
>
I think you and tglx are talking the same thing :)
Thanks!
Xin
prev parent reply other threads:[~2024-06-25 17:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 13:12 Hou Wenlong
2024-06-21 13:12 ` [PATCH 1/2] x86/fred: Always install system interrupt handler into IDT Hou Wenlong
2024-06-25 9:19 ` Xin Li
2024-06-25 12:31 ` Thomas Gleixner
2024-06-25 16:30 ` Xin Li
2024-06-25 17:01 ` Thomas Gleixner
2024-06-25 17:08 ` Li, Xin3
2024-06-25 17:11 ` Thomas Gleixner
2024-06-28 9:36 ` Hou Wenlong
2024-06-28 15:18 ` Xin Li
2024-07-02 17:16 ` Xin Li
2024-07-03 2:44 ` Hou Wenlong
2024-07-03 3:42 ` Xin Li
2024-06-21 13:12 ` [PATCH 2/2] x86/fred: Add a page fault entry stub for FRED Hou Wenlong
2024-06-22 0:31 ` [PATCH 0/2] x86/fred: Fix two problems during the FRED initialization Xin Li
2024-06-24 6:21 ` Hou Wenlong
2024-06-25 9:09 ` Xin Li
2024-06-25 17:24 ` H. Peter Anvin
2024-06-25 17:31 ` 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=0926bc9e-3d70-4ee1-b861-a8ab220ffec1@zytor.com \
--to=xin@zytor.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=houwenlong.hwl@antgroup.com \
--cc=hpa@zytor.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jiangshan.ljs@antgroup.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=xin3.li@intel.com \
/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®