From: Alexandru Chirvasitu <achirvasub@gmail.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
kernel list <linux-kernel@vger.kernel.org>,
Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
Denys Vlasenko <dvlasenk@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: PROBLEM: consolidated IDT invalidation causes kexec to reboot
Date: Mon, 25 Dec 2017 16:29:34 -0500 [thread overview]
Message-ID: <20171225212934.GA1410@arch-chirva.localdomain> (raw)
In-Reply-To: <CALCETrWFK0kY7ety3Hsipi3W3Ni-sm2vQ5kbi3N_OhExNrMmHw@mail.gmail.com>
Thanks for that!
On Mon, Dec 25, 2017 at 06:40:14AM -0800, Andy Lutomirski wrote:
> On Sat, Dec 23, 2017 at 7:30 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> > On Sat, Dec 23, 2017 at 5:44 PM, Alexandru Chirvasitu
> > <achirvasub@gmail.com> wrote:
> >>
> >> For testing purposes, I've altered machine_kexec_32.c making the
> >> following toy commit. It naively undoes part of e802a51, solely to
> >> confirm that's where it goes awry in my setup.
> >
> > That's really funky.
> >
> > The idt_invalidate() seems to do *exactly* the same thing. It uses
> > "load_idt()" on an IDT with size 0, and the supplied address.
> >
> > Can you disassemble your "set_idt()" code vs the "idt_invalidate()"?
> >
> >> Is this expected behaviour?
> >
> > No. The code literally seems identical. The only difference is
> >
> > (a) where the 0 limit comes from
> >
> > (b) perhaps build flags and whether it is inlined or not due to being
> > in a different file
> >
> > and neither of those should matter, but maybe they do.
> >
> > Which is why I'd like you to actually look at the generated code and
> > see if you can see any difference..
> >
>
> This is presumably the same call-tracing-without-TLS-working problem.
> idt_invalidate() is out-of-line and is compiled with full tracing on,
> and we're calling it from a context without TLS working (it's
> explicitly disabled in load_segments()) in machine_kexec_32.c. The
> right fix is probably to inline idt_invalidate() and to add a comment.
>
This works.. I went back to the troublesome commit e802a51 and
modified it as follows:
--------------------------------------------------------
make idt_invalidate static inline in header file
diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index 33aff45..87ca363 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -504,6 +504,17 @@ static inline void load_current_idt(void)
load_idt((const struct desc_ptr *)&idt_descr);
}
-extern void idt_invalidate(void *addr);
+
+/**
+ * idt_invalidate - Invalidate interrupt descriptor table
+ * @addr: The virtual address of the 'invalid' IDT
+ */
+static inline void idt_invalidate(void *addr)
+{
+ struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 };
+
+ load_idt(&idt);
+}
+
#endif /* _ASM_X86_DESC_H */
diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
index cd4658c..fec44c6 100644
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -25,13 +25,3 @@ const struct desc_ptr debug_idt_descr = {
};
#endif
-/**
- * idt_invalidate - Invalidate interrupt descriptor table
- * @addr: The virtual address of the 'invalid' IDT
- */
-void idt_invalidate(void *addr)
-{
- struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 };
-
- load_idt(&idt);
-}
--------------------------------------------------------
kexec now works as expected; tested repeatedly, both with direct
execution and crash triggering.
I had to google 'inline function' :)).
> Also, why idt_invalidate(phys_to_virt(0))? That makes rather little
> sense to me.
>
> --Andy
next prev parent reply other threads:[~2017-12-25 21:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-24 1:44 Alexandru Chirvasitu
2017-12-24 3:30 ` Linus Torvalds
2017-12-24 7:28 ` Alexandru Chirvasitu
2017-12-24 11:28 ` Ingo Molnar
2017-12-24 15:27 ` Alexandru Chirvasitu
2017-12-24 16:40 ` Alexandru Chirvasitu
2017-12-25 9:47 ` Ingo Molnar
2017-12-25 14:40 ` Andy Lutomirski
2017-12-25 21:29 ` Alexandru Chirvasitu [this message]
2017-12-26 18:51 ` Linus Torvalds
2017-12-26 19:26 ` hpa
2017-12-26 23:19 ` Alexandru Chirvasitu
2017-12-26 23:39 ` hpa
2017-12-26 23:40 ` hpa
2017-12-26 23:45 ` hpa
2017-12-27 2:16 ` Linus Torvalds
2017-12-27 2:25 ` hpa
2017-12-27 2:54 ` Linus Torvalds
2017-12-27 3:00 ` hpa
2017-12-28 1:30 ` Konrad Rzeszutek Wilk
2017-12-27 4:41 ` Alexandru Chirvasitu
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=20171225212934.GA1410@arch-chirva.localdomain \
--to=achirvasub@gmail.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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®