mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Brian Gerst <brgerst@gmail.com>
To: Xin Li <xin@zytor.com>
Cc: linux-kernel@vger.kernel.org, luto@kernel.org,
	tglx@linutronix.de,  mingo@kernel.org, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org,  hpa@zytor.com,
	peterz@infradead.org
Subject: Re: [RESEND PATCH v2 1/3] x86/fred: Allow variable-sized event frame
Date: Wed, 19 Mar 2025 09:55:51 -0400	[thread overview]
Message-ID: <CAMzpN2jRe1dOpKsAxCOG3RVS_x9yq-1phYuzm9ObdpJYQjb++Q@mail.gmail.com> (raw)
In-Reply-To: <7b0484d2-3608-4243-b3ae-2b49e2a32331@zytor.com>

On Wed, Mar 19, 2025 at 2:47 AM Xin Li <xin@zytor.com> wrote:
>
> On 3/18/2025 6:53 AM, Brian Gerst wrote:
> >> -#define INIT_THREAD_INFO(tsk)                  \
> >> -{                                              \
> >> -       .flags          = 0,                    \
> >> +#define INIT_THREAD_INFO(tsk)                                          \
> >> +{                                                                      \
> >> +       .flags          = 0,                                            \
> >> +       .user_pt_regs   = (struct pt_regs *)TOP_OF_INIT_STACK - 1,      \
> >
> > Use __top_init_kernel_stack here.
>
> Will do.
>
> >
> >>   }
> >>
> >>   #else /* !__ASSEMBLER__ */
> >> diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> >> index 91f6ff618852..58c1cd4ca60a 100644
> >> --- a/arch/x86/kernel/process.c
> >> +++ b/arch/x86/kernel/process.c
> >> @@ -108,6 +108,28 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
> >>          return 0;
> >>   }
> >>
> >> +/*
> >> + * Initialize thread_info.user_pt_regs for IDT event delivery.
> >> + *
> >> + * For IDT user level event delivery, a pt_regs structure is pushed by both
> >> + * hardware and software and always resides at a fixed offset from top of
> >> + * current task kernel stack, thus thread_info.user_pt_regs is a per-task
> >> + * constant and NEVER changes after initialization.
> >> + *
> >> + * While for FRED user level event delivery, user_pt_regs is updated in
> >> + * fred_entry_from_user() immediately after user level event delivery.
> >> + *
> >> + * Note: thread_info.user_pt_regs of the init task is initialized at build
> >> + * time.
> >> + */
> >> +void arch_init_user_pt_regs(struct task_struct *tsk)
> >> +{
> >> +       unsigned long top_of_stack = (unsigned long)task_stack_page(tsk) + THREAD_SIZE;
> >> +
> >> +       top_of_stack -= TOP_OF_KERNEL_STACK_PADDING;
> >> +       tsk->thread_info.user_pt_regs = (struct pt_regs *)top_of_stack - 1;
> >> +}
> >
> > Can this be put into arch_dup_task_struct() instead of creating another hook?
>
> I wanted to do it at the beginning but task stack is no longer part of
> the task_struct on x86.  Make sense?

I see that now.  My concern here is that using a weak function makes
all other arches pay the cost of an empty function call.  That's why
many hooks are static linlines or macros, especially if the default is
a no-op.


Brian Gerst

  reply	other threads:[~2025-03-19 13:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18  7:19 [RESEND PATCH v2 0/3] x86: " Xin Li (Intel)
2025-03-18  7:19 ` [RESEND PATCH v2 1/3] x86/fred: " Xin Li (Intel)
2025-03-18 13:53   ` Brian Gerst
2025-03-19  6:47     ` Xin Li
2025-03-19 13:55       ` Brian Gerst [this message]
2025-03-19 16:34         ` Xin Li
2025-03-18  7:19 ` [RESEND PATCH v2 2/3] x86: Remove the padding space at top of the init stack Xin Li (Intel)
2025-03-18  7:19 ` [RESEND PATCH v2 3/3] x86: Zap TOP_OF_KERNEL_STACK_PADDING on x86_64 Xin Li (Intel)

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=CAMzpN2jRe1dOpKsAxCOG3RVS_x9yq-1phYuzm9ObdpJYQjb++Q@mail.gmail.com \
    --to=brgerst@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xin@zytor.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®