From: jpoimboe <jpoimboe@kernel.org>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
"H. Peter Anvin" <hpa@zytor.com>,
kexec@lists.infradead.org, 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,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Kai Huang <kai.huang@intel.com>,
Nikolay Borisov <nik.borisov@suse.com>,
linux-kernel@vger.kernel.org, Simon Horman <horms@kernel.org>
Subject: Re: [RFC PATCH 2/2] x86/kexec: Add data section to relocate_kernel
Date: Wed, 13 Nov 2024 17:46:41 -0800 [thread overview]
Message-ID: <20241114014641.pmpdpq7gsowadpqs@jpoimboe> (raw)
In-Reply-To: <785f90158524228a32bc4c22bfb4425ceadb0197.camel@infradead.org>
On Tue, Nov 12, 2024 at 10:45:05AM +0000, David Woodhouse wrote:
> On Tue, 2024-11-12 at 11:14 +0100, Peter Zijlstra wrote:
> > On Tue, Nov 12, 2024 at 08:44:33AM +0000, David Woodhouse wrote:
> > > On Fri, 2024-11-08 at 12:26 +0100, H. Peter Anvin wrote:
> > > >
> > > > > --- a/arch/x86/kernel/vmlinux.lds.S
> > > > > +++ b/arch/x86/kernel/vmlinux.lds.S
> > > > > @@ -100,7 +100,7 @@ const_pcpu_hot = pcpu_hot;
> > > > > . = ALIGN(PAGE_SIZE); \
> > > > > __relocate_kernel_start = .; \
> > > > > *(.text.relocate_kernel); \
> > > > > - *(.rodata.relocate_kernel); \
> > > > > + *(.data.relocate_kernel); \
> >
> > Why are we having data in the middle of the text section?
>
> This is the relocate_kernel() page. It's the last thing the kernel
> calls on kexec.
>
> The kernel first takes a *copy* of it and places it into the identity
> mapping page tables which are set up for kexec.
>
> The relocate_kernel() function is then called at its *original*
> location in the kernel text. Before reloading %cr3, it stores some
> information which is going to become unavailable into its own page
> (currently using a bit of a nasty hack based on a hard-coded
> KEXEC_CONTROL_CODE_MAX_SIZE because we can't just use data symbol
> references).
>
> Then it reloads %cr3 and jumps to the identity-mapped copy of itself.
>
> Could we put .text.relocate_kernel and .data.relocate_kernel somewhere
> *other* than the main kernel text segment? Probably... it use use
> alternative instructions, but we could deal with that. And if we call
> from machine_kexec() directly into the *copy* (having marked it
> executable), maybe...?
I fetched your branch and only saw a "RET before UNTRAIN" warning, did
you happen to already fix the other warnings up?
Something like the below fixes the warning I saw.
Though, maybe it's better to just tell objtool to keep its paws off of
the problematic functions by use of the STACK_FRAME_NON_STANDARD macro?
Then you could get rid of all the unwind hints and annotations.
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 6604f5d038aa..9ba10530b9c7 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -4012,8 +4012,11 @@ static int validate_unret(struct objtool_file *file, struct instruction *insn)
return 0;
case INSN_RETURN:
- WARN_INSN(insn, "RET before UNTRAIN");
- return 1;
+ if (!insn->retpoline_safe) {
+ WARN_INSN(insn, "RET before UNTRAIN");
+ return 1;
+ }
+ break;
case INSN_NOP:
if (insn->retpoline_safe)
next prev parent reply other threads:[~2024-11-14 1:46 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-03 5:35 [RFC PATCH 0/7] x86/kexec: Add exception handling for relocate_kernel David Woodhouse
2024-11-03 5:35 ` [RFC PATCH 1/7] x86/kexec: Clean up and document register use in relocate_kernel_64.S David Woodhouse
2024-11-05 10:00 ` Huang, Kai
2024-11-05 20:17 ` David Woodhouse
2024-11-03 5:35 ` [RFC PATCH 2/7] x86/kexec: Use named labels in swap_pages " David Woodhouse
2024-11-05 10:01 ` Huang, Kai
2024-11-03 5:35 ` [RFC PATCH 3/7] x86/kexec: Only swap pages for preserve_context mode David Woodhouse
2024-11-03 5:35 ` [RFC PATCH 4/7] x86/kexec: Debugging support: load a GDT David Woodhouse
2024-11-03 5:35 ` [RFC PATCH 5/7] x86/kexec: Debugging support: Load an IDT and basic exception entry points David Woodhouse
2024-11-03 5:35 ` [RFC PATCH 6/7] x86/kexec: Debugging support: Dump registers on exception David Woodhouse
2024-11-05 20:38 ` Woodhouse, David
2024-11-05 20:50 ` H. Peter Anvin
2024-11-05 21:29 ` David Woodhouse
2024-11-05 22:08 ` H. Peter Anvin
2024-11-05 21:37 ` H. Peter Anvin
2024-11-05 21:58 ` H. Peter Anvin
2024-11-05 22:27 ` H. Peter Anvin
2024-11-05 22:57 ` H. Peter Anvin
2024-11-14 7:40 ` Andy Shevchenko
2024-11-06 2:43 ` David Woodhouse
2024-11-06 2:47 ` H. Peter Anvin
2024-11-06 3:07 ` David Woodhouse
2024-11-08 5:21 ` David Woodhouse
2024-11-08 5:22 ` [RFC PATCH 1/2] x86/kexec: Use linker script for relocate_kernel page layout David Woodhouse
2024-11-08 5:22 ` [RFC PATCH 2/2] x86/kexec: Add data section to relocate_kernel David Woodhouse
2024-11-08 5:35 ` David Woodhouse
2024-11-08 11:26 ` H. Peter Anvin
2024-11-08 12:29 ` David Woodhouse
2024-11-12 8:44 ` David Woodhouse
2024-11-12 10:14 ` Peter Zijlstra
2024-11-12 10:45 ` David Woodhouse
2024-11-14 1:46 ` jpoimboe [this message]
2024-11-03 5:35 ` [RFC PATCH 7/7] [DO NOT MERGE] x86/kexec: enable DEBUG David Woodhouse
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=20241114014641.pmpdpq7gsowadpqs@jpoimboe \
--to=jpoimboe@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=horms@kernel.org \
--cc=hpa@zytor.com \
--cc=kai.huang@intel.com \
--cc=kexec@lists.infradead.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nik.borisov@suse.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®