Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: David Woodhouse <dwmw2@infradead.org>,
	"peterz@infradead.org" <peterz@infradead.org>,
	"kexec@lists.infradead.org" <kexec@lists.infradead.org>,
	"jpoimboe@kernel.org" <jpoimboe@kernel.org>
Cc: "horms@kernel.org" <horms@kernel.org>,
	"x86@kernel.org" <x86@kernel.org>, "bp@alien8.de" <bp@alien8.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"kai.huang@intel.com" <kai.huang@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kirill.shutemov@linux.intel.com"
	<kirill.shutemov@linux.intel.com>,
	"nik.borisov@suse.com" <nik.borisov@suse.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Subject: Re:  [RFC PATCH 6/7] x86/kexec: Debugging support: Dump registers on exception
Date: Tue, 05 Nov 2024 14:08:35 -0800	[thread overview]
Message-ID: <3008CD3D-FF34-4FD1-83EB-DD74398685A5@zytor.com> (raw)
In-Reply-To: <07117fe234cb1396a59bdb815ada26a90e02b394.camel@infradead.org>

On November 5, 2024 1:29:54 PM PST, David Woodhouse <dwmw2@infradead.org> wrote:
>On Tue, 2024-11-05 at 12:50 -0800, H. Peter Anvin wrote:
>> On November 5, 2024 12:38:10 PM PST, "Woodhouse, David" <dwmw@amazon.co.uk> wrote:
>> > On Sun, 2024-11-03 at 05:35 +0000, David Woodhouse wrote:
>> > > 
>> > > +
>> > > +/* Print the byte in %bl, clobber %rax */
>> > > +SYM_CODE_START_LOCAL_NOALIGN(pr_byte)
>> > > +       movb    %bl, %al
>> > > +       nop
>> > > +       andb    $0x0f, %al
>> > > +       addb    $0x30, %al
>> > > +       cmpb    $0x3a, %al
>> > > +       jb      1f
>> > > +       addb    $('a' - '0' - 10), %al
>> > > +1:     pr_char
>> > > +       ANNOTATE_UNRET_SAFE
>> > > +       ret
>> > > +SYM_CODE_END(pr_byte)
>> > > +
>> > 
>> > Obviously that function name (and comment) are wrong; fixed in my tree.
>> > at
>> > https://git.infradead.org/users/dwmw2/linux.git/shortlog/refs/heads/kexec-debug
>> > 
>> > This function (and also pr_qword) are also what objtool is complaining
>> > about:
>> > 
>> > vmlinux.o: warning: objtool: relocate_range+0x2f6: unreachable instruction
>> > vmlinux.o: warning: objtool: relocate_range+0x305: unreachable instruction
>> > 
>> > I don't quite see why, because pr_qword() quite blatantly calls
>> > pr_nyblle(), as it's now named. And exc_handler() repeatedly calls
>> > pr_qword().
>> > 
>> > But most of the objtool annotations I've added here were just to make
>> > it shut up and build, without much though. Peter, Josh, any chance you
>> > can help me fix it up please?
>> > 
>> > It would also be really useful if objtool would let me have data inside
>> > a "code" segment, without complaining that it can't decode it as
>> > instructions — and without also failing to decode the first instruction
>> > of the *subsequent* function. I've put the GDT at the end to work
>> > around that, but it's a bit nasty.
>> 
>> code in the data *section* or *segment*? Either is nasty, though. That's what .rodata is for.
>
>This is the relocate_kernel() function in
>arch/x86/kernel/relocate_kernel_64.S
>
>It's copied into a separate page, called (in its original location) as
>a simple function from the kernel, changes %cr3 to set of identity-
>mapped page tables and jumps to its *identity-mapped* address, then
>copies all the right pages for kexec and jumps into the new kernel.
>
>So it's all in a single page, and currently it plays nasty tricks to
>store data after the code. Perhaps it *should* have its own code and
>data sections and a linker script to keep them together...

Yes, it should.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2024-11-05 22:09 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 [this message]
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
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=3008CD3D-FF34-4FD1-83EB-DD74398685A5@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw2@infradead.org \
    --cc=horms@kernel.org \
    --cc=jpoimboe@kernel.org \
    --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