From: Xin Li <xin@zytor.com>
To: Brian Gerst <brgerst@gmail.com>
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
Subject: Re: [PATCH v1 1/1] x86/fred: Fix init_task thread stack pointer initialization
Date: Fri, 1 Mar 2024 20:17:44 -0800 [thread overview]
Message-ID: <c4fb7c39-c99c-4e4c-bd85-470f5d0dc4dd@zytor.com> (raw)
In-Reply-To: <CAMzpN2j7xKcGx=+z8mu_2z2RsqjB-mpODdrOH7N1J2_OzuyEUQ@mail.gmail.com>
On 3/1/2024 5:15 AM, Brian Gerst wrote:
> On Fri, Mar 1, 2024 at 3:41 AM Xin Li (Intel) <xin@zytor.com> wrote:
> There is another spot in head_64.S that also needs this offset:
I checked all references to __end_init_task before sending out this
patch, and I doubt we need to make more similar changes.
First of all, "movq TASK_threadsp(%rcx), %rsp" you added in
3adee777ad0d ("x86/smpboot: Remove initial_stack on 64-bit") is exactly
what we need to set up %rsp for the init task.
> /* Set up the stack for verify_cpu() */
> leaq (__end_init_task - PTREGS_SIZE)(%rip), %rsp
As the comment says, it's a _temporary_ stack for calling verify_cpu()
(but only for BSP, as APs use a different bring up stack), at which
stage the concept of "task" has not formed. I'm thinking maybe it's
better to do:
/* Set up the stack for verify_cpu() */
leaq __end_init_task(%rip), %rsp
Previously it was "leaq (__end_init_task - FRAME_SIZE)(%rip), %rsp",
but the kernel unwinder goes up only to secondary_startup_64_no_verify()
after the new way you introduced to set up %rsp for the init task, and
it seems to me that there is no point to subtract FRAME_SIZE or
PTREGS_SIZE.
On the other hand, TOP_OF_KERNEL_STACK_PADDING is required for x86_32,
but probably not for x86_64 (defined as 0 before FRED). The most
important usage of TOP_OF_KERNEL_STACK_PADDING is to get the pt_regs
pointer for a task, i.e., task_pt_regs(task), which assumes a fixed
offset from the top of a task stack, but also limits the space that
could be used by future hardware above the pt_regs structure. Thus I
prefer to limit the usage of TOP_OF_KERNEL_STACK_PADDING on x86_64.
Thanks!
Xin
next prev parent reply other threads:[~2024-03-02 4:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 8:40 Xin Li (Intel)
2024-03-01 13:15 ` Brian Gerst
2024-03-02 4:17 ` Xin Li [this message]
2024-03-02 13:20 ` Brian Gerst
2024-03-04 3:42 ` Xin Li
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=c4fb7c39-c99c-4e4c-bd85-470f5d0dc4dd@zytor.com \
--to=xin@zytor.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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®