diff mbox

[U-Boot,BUG] x86: invalid size calculations in interrupts.c with newer GCC

Message ID 79D7C5E5-3DFD-4818-9F22-7F096FF5C179@jtang.org
State Superseded
Delegated to: Bin Meng
Headers show

Commit Message

J. Tang Feb. 7, 2017, 2:51 a.m. UTC
> On 2017-02-06, at 01:35, Bin Meng <bmeng.cn@gmail.com> wrote:
> 
> +Simon,
> 
> I do not have a GCC5 toolchain to test this. I suspect this is only
> exposed with GCC5, or GCC 5.4? Is there any parameter to control the
> behavior?

I observed a similar behavior with GCC 5.3.

As an experiment, I disabled CONFIG_CC_OPTIMIZE_FOR_SIZE. This did not change the sizes; the handler for IRQs 0 through 19 were still 4 bytes while the rest were 7 bytes.

Although I am not an expert x86 assembly writer, I was able to force the assembler to generate 32-bit jumps with the following:


This worked for both GCC 5.4 and 4.9.

Comments

Bin Meng Feb. 10, 2017, 1:40 a.m. UTC | #1
On Tue, Feb 7, 2017 at 10:51 AM, J. Tang <tang@jtang.org> wrote:
>
>> On 2017-02-06, at 01:35, Bin Meng <bmeng.cn@gmail.com> wrote:
>>
>> +Simon,
>>
>> I do not have a GCC5 toolchain to test this. I suspect this is only
>> exposed with GCC5, or GCC 5.4? Is there any parameter to control the
>> behavior?
>
> I observed a similar behavior with GCC 5.3.
>
> As an experiment, I disabled CONFIG_CC_OPTIMIZE_FOR_SIZE. This did not change the sizes; the handler for IRQs 0 through 19 were still 4 bytes while the rest were 7 bytes.
>
> Although I am not an expert x86 assembly writer, I was able to force the assembler to generate 32-bit jumps with the following:
>
> diff --git a/arch/x86/cpu/interrupts.c b/arch/x86/cpu/interrupts.c
> index 5f6cdd3..9917d09 100644
> --- a/arch/x86/cpu/interrupts.c
> +++ b/arch/x86/cpu/interrupts.c
> @@ -32,7 +32,7 @@ DECLARE_GLOBAL_DATA_PTR;
>         ".type irq_"#x", @function\n" \
>         "irq_"#x":\n" \
>         "pushl $"#x"\n" \
> -       "jmp irq_common_entry\n"
> +       "jmp.d32 irq_common_entry\n"
>
>  static char *exceptions[] = {
>         "Divide Error",
>
> This worked for both GCC 5.4 and 4.9.
>

Looks good. Can you prepare a patch?

Regards,
Bin
diff mbox

Patch

diff --git a/arch/x86/cpu/interrupts.c b/arch/x86/cpu/interrupts.c
index 5f6cdd3..9917d09 100644
--- a/arch/x86/cpu/interrupts.c
+++ b/arch/x86/cpu/interrupts.c
@@ -32,7 +32,7 @@  DECLARE_GLOBAL_DATA_PTR;
        ".type irq_"#x", @function\n" \
        "irq_"#x":\n" \
        "pushl $"#x"\n" \
-       "jmp irq_common_entry\n"
+       "jmp.d32 irq_common_entry\n"
 
 static char *exceptions[] = {
        "Divide Error",