From: Andy Lutomirski <luto@amacapital.net>
To: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>, X86 ML <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
"H.J. Lu" <hjl.tools@gmail.com>, Borislav Petkov <bp@alien8.de>,
Jan Beulich <JBeulich@suse.com>,
Binutils <binutils@sourceware.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] x86: Stop relying on magic jmp behavior for early_idt_handlers
Date: Fri, 22 May 2015 06:52:00 -0000 [thread overview]
Message-ID: <CALCETrXja3FHMT9WSZQ86ozyi8KsFKmFeR_JDDrt6GtRSLa8OA@mail.gmail.com> (raw)
In-Reply-To: <20150522062224.GA4736@gmail.com>
On Thu, May 21, 2015 at 11:22 PM, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Andy Lutomirski <luto@kernel.org> wrote:
>
>> --- a/arch/x86/include/asm/segment.h
>> +++ b/arch/x86/include/asm/segment.h
>> @@ -231,9 +231,17 @@
>> #define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES* 8)
>>
>> #ifdef __KERNEL__
>> +
>> +/*
>> + * early_idt_handlers is an array of entry points. For simplicity, it's
>> + * a real array. We allocate nine bytes for each entry: two one-byte
>> + * push instructions and a five-byte jump in the worst case.
>> + */
>> +#define EARLY_IDT_HANDLER_STRIDE 9
>
> So how come that two plus five equals nine? ;-)
A "one-byte push" would be pretty impressive :)
>
> It's two two-bype pushes (sometimes a 2-byte NOP), plus a 5-byte jump,
> in the worst case.
>
> I'd also mention that it's an array of 32 small trampolines that set
> up parameters and jump to a common entry point.
Will do.
>
>> +/* Build the early_idt_handlers array */
>> ENTRY(early_idt_handlers)
>
> Please rename the function accordingly: early_idt_handlers_array, to
> make clear this is never jumped to directly, only through the IDT.
Makes sense.
>
>> # 36(%esp) %eflags
>> # 32(%esp) %cs
>> @@ -531,19 +532,18 @@ ENTRY(early_idt_handlers)
>> # 24(%rsp) error code
>> i = 0
>> .rept NUM_EXCEPTION_VECTORS
>> - .if (EXCEPTION_ERRCODE_MASK >> i) & 1
>> - ASM_NOP2
>> - .else
>> + .fill early_idt_handlers + i * EARLY_IDT_HANDLER_STRIDE - ., 1, 0xcc
>> + .ifeq (EXCEPTION_ERRCODE_MASK >> i) & 1
>> pushl $0 # Dummy error code, to make stack frame uniform
>> .endif
>> pushl $i # 20(%esp) Vector number
>> jmp early_idt_handler
>> i = i + 1
>> .endr
>> + .fill early_idt_handlers + i * EARLY_IDT_HANDLER_STRIDE - ., 1, 0xcc
>> ENDPROC(early_idt_handlers)
>>
>> - /* This is global to keep gas from relaxing the jumps */
>> -ENTRY(early_idt_handler)
>> +early_idt_handler:
>
> Please rename this as well to make it clearer what's happening,
> something like:
>
> early_idt_handler_common:
>
> would work for me.
>
> Ditto for the 64-bit side.
Sounds good. I'll do all this tomorrow and resend.
--Andy
next prev parent reply other threads:[~2015-05-22 6:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 1:27 Andy Lutomirski
2015-05-22 6:22 ` Ingo Molnar
2015-05-22 6:52 ` Andy Lutomirski [this message]
2015-05-22 21:00 ` H. Peter Anvin
2015-05-22 21:00 ` H. Peter Anvin
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=CALCETrXja3FHMT9WSZQ86ozyi8KsFKmFeR_JDDrt6GtRSLa8OA@mail.gmail.com \
--to=luto@amacapital.net \
--cc=JBeulich@suse.com \
--cc=binutils@sourceware.org \
--cc=bp@alien8.de \
--cc=hjl.tools@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).