From: "H. Peter Anvin" <hpa@zytor.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
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: Avoiding unnecessary jump relocations in gas?
Date: Mon, 18 May 2015 20:28:00 -0000 [thread overview]
Message-ID: <555A4B67.4080201@zytor.com> (raw)
In-Reply-To: <CAMe9rOrSP=XW29ae3fkHrFUdjhfvGbB5b5U=EA74wofNC4qEBA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]
On 05/18/2015 01:25 PM, H.J. Lu wrote:
> On Mon, May 18, 2015 at 1:06 PM, H. Peter Anvin <hpa@zytor.com> wrote:
>> On 05/18/2015 01:02 PM, H.J. Lu wrote:
>>>>
>>>> I wonder if it would make sense to have explicit mnemonics for the
>>>> one-byte offset and four-byte offset jump variants. Sometimes users
>>>> want a jump with a 32-bit offset for reasons that have nothing to do
>>>> with link-time or load-time relocations.
>>>>
>>>
>>> There is:
>>>
>>> jmp.d32 foo
>>>
>>
>> How far back does that syntax work?
>>
>
> .d32 support was added by
>
> commit f8a5c266971d7b5b96f973805551c6e88669cada
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date: Thu Oct 14 13:31:13 2010 +0000
>
> Add .d32 encoding suffix.
>
> and .d8 supported was added by
>
> commit a501d77eeba717f6d54dce44f286f9e3aad83144
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date: Fri Jan 20 20:53:50 2012 +0000
>
> Add .d8 suffix support to x86 assembler
>
OK, that is probably too recent. The simplest answer I think is just to
.balign 16 each vector. This is init space... some extra padding really
doesn't matter.
Patch attached (still in compile test).
-hpa
[-- Attachment #2: diff --]
[-- Type: text/plain, Size: 2264 bytes --]
diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
index 5a9856e..f11621f 100644
--- a/arch/x86/include/asm/segment.h
+++ b/arch/x86/include/asm/segment.h
@@ -233,7 +233,7 @@
#ifdef __KERNEL__
#ifndef __ASSEMBLY__
-extern const char early_idt_handlers[NUM_EXCEPTION_VECTORS][2+2+5];
+extern const char early_idt_handlers[NUM_EXCEPTION_VECTORS][16];
#ifdef CONFIG_TRACING
# define trace_early_idt_handlers early_idt_handlers
#endif
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 02d2572..1c18826 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -524,6 +524,7 @@ setup_once:
andl $0,setup_once_ref /* Once is enough, thanks */
ret
+ .balign 16
ENTRY(early_idt_handlers)
# 36(%esp) %eflags
# 32(%esp) %cs
@@ -531,9 +532,8 @@ ENTRY(early_idt_handlers)
# 24(%rsp) error code
i = 0
.rept NUM_EXCEPTION_VECTORS
- .if (EXCEPTION_ERRCODE_MASK >> i) & 1
- ASM_NOP2
- .else
+ .balign 16
+ .if ((EXCEPTION_ERRCODE_MASK >> i) & 1) == 0
pushl $0 # Dummy error code, to make stack frame uniform
.endif
pushl $i # 20(%esp) Vector number
@@ -542,8 +542,7 @@ ENTRY(early_idt_handlers)
.endr
ENDPROC(early_idt_handlers)
- /* This is global to keep gas from relaxing the jumps */
-ENTRY(early_idt_handler)
+early_idt_handler:
cld
cmpl $2,(%esp) # X86_TRAP_NMI
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index 43eafc8..2d80a09 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -321,7 +321,8 @@ bad_address:
jmp bad_address
__INIT
- .globl early_idt_handlers
+ .balign 16
+ENTRY(early_idt_handlers)
early_idt_handlers:
# 104(%rsp) %rflags
# 96(%rsp) %cs
@@ -329,18 +330,17 @@ early_idt_handlers:
# 80(%rsp) error code
i = 0
.rept NUM_EXCEPTION_VECTORS
- .if (EXCEPTION_ERRCODE_MASK >> i) & 1
- ASM_NOP2
- .else
+ .balign 16
+ .if ((EXCEPTION_ERRCODE_MASK >> i) & 1) == 0
pushq $0 # Dummy error code, to make stack frame uniform
.endif
pushq $i # 72(%rsp) Vector number
jmp early_idt_handler
i = i + 1
.endr
+ENDPROC(early_idt_handlers)
-/* This is global to keep gas from relaxing the jumps */
-ENTRY(early_idt_handler)
+early_idt_handler:
cld
cmpl $2,(%rsp) # X86_TRAP_NMI
next prev parent reply other threads:[~2015-05-18 20:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 6:02 Andy Lutomirski
2015-05-07 11:52 ` Jan Beulich
2015-05-07 16:21 ` H.J. Lu
2015-05-08 3:23 ` Andy Lutomirski
2015-05-08 12:09 ` H.J. Lu
2015-05-08 20:16 ` H.J. Lu
2015-05-18 19:37 ` Andy Lutomirski
2015-05-18 20:02 ` H.J. Lu
2015-05-18 20:06 ` H. Peter Anvin
2015-05-18 20:25 ` H.J. Lu
2015-05-18 20:28 ` H. Peter Anvin [this message]
2015-05-18 20:34 ` H. Peter Anvin
2015-05-20 20:54 ` Andy Lutomirski
2015-05-20 21:00 ` H. Peter Anvin
2015-05-20 21:47 ` Andy Lutomirski
2015-05-20 22:00 ` H. Peter Anvin
2015-05-20 22:09 ` H. Peter Anvin
2015-05-20 22:18 ` Andy Lutomirski
2015-05-20 22:22 ` H. Peter Anvin
2015-05-18 20:07 ` H. Peter Anvin
2015-05-18 20:11 ` Borislav Petkov
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=555A4B67.4080201@zytor.com \
--to=hpa@zytor.com \
--cc=JBeulich@suse.com \
--cc=binutils@sourceware.org \
--cc=bp@alien8.de \
--cc=hjl.tools@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
/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).