[PATCH v5 07/20] x86/kexec: Invoke copy of relocate_kernel() instead of the original

Josh Poimboeuf jpoimboe at kernel.org
Wed Dec 18 16:20:15 PST 2024


On Wed, Dec 18, 2024 at 11:27:27PM +0100, David Woodhouse wrote:
> On Wed, 2024-12-18 at 13:23 -0800, Josh Poimboeuf wrote:
> > 
> > The linker script does place it in .data, but objtool runs on the object
> > file before linking, where it's still in an executable section
> > (.text..relocate_kernel).
> > 
> > How about something like below?
> > 
> >   - move text to .data..relocate_kernel
> >   - remove objtool annotations
> >   - replace the alternative with a runtime check
> 
> That leaves me unable to use 'objdump -S
> arch/x86/kernel/relocate_kernel_64.o' so I hate it :)

Well, it's already written in assembly, there's not much benefit in
disassembling it ;-)  But you can still force gdb to do so with
something like "x/50i <addr>".

Isn't that easier than putting in all these hacks to make objtool happy
(and continue to keep it happy over the coming years), when it doesn't
need to care about this code in the first place?

Anyway, what I think you're looking for is UNWIND_HINT_UNDEFINED.  In
fact all the unwind annotations in that file should be UNDEFINED since
the hints are all referring to the wrong addresses (because copied code)
and the ORC unwinder isn't reachable for most of that code anyway.

Also, it's fine to make relocate_kernel() a proper function with
SYM_FUNC_END, you'd just need to add the following line afterwards:

  STACK_FRAME_NON_STANDARD relocate_kernel

-- 
Josh



More information about the kexec mailing list