lkml.org 
[lkml]   [2020]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.6 047/254] x86/boot: Use unsigned comparison for addresses
    Date
    From: Arvind Sankar <nivedita@alum.mit.edu>

    [ Upstream commit 81a34892c2c7c809f9c4e22c5ac936ae673fb9a2 ]

    The load address is compared with LOAD_PHYSICAL_ADDR using a signed
    comparison currently (using jge instruction).

    When loading a 64-bit kernel using the new efi32_pe_entry() point added by:

    97aa276579b2 ("efi/x86: Add true mixed mode entry point into .compat section")

    using Qemu with -m 3072, the firmware actually loads us above 2Gb,
    resulting in a very early crash.

    Use the JAE instruction to perform a unsigned comparison instead, as physical
    addresses should be considered unsigned.

    Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Link: https://lore.kernel.org/r/20200301230436.2246909-6-nivedita@alum.mit.edu
    Link: https://lore.kernel.org/r/20200308080859.21568-14-ardb@kernel.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    arch/x86/boot/compressed/head_32.S | 2 +-
    arch/x86/boot/compressed/head_64.S | 4 ++--
    2 files changed, 3 insertions(+), 3 deletions(-)

    diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
    index 73f17d0544dd5..7f7e8b8518fec 100644
    --- a/arch/x86/boot/compressed/head_32.S
    +++ b/arch/x86/boot/compressed/head_32.S
    @@ -106,7 +106,7 @@ SYM_FUNC_START(startup_32)
    notl %eax
    andl %eax, %ebx
    cmpl $LOAD_PHYSICAL_ADDR, %ebx
    - jge 1f
    + jae 1f
    #endif
    movl $LOAD_PHYSICAL_ADDR, %ebx
    1:
    diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
    index 1f1f6c8139b38..afde2aa8382e9 100644
    --- a/arch/x86/boot/compressed/head_64.S
    +++ b/arch/x86/boot/compressed/head_64.S
    @@ -106,7 +106,7 @@ SYM_FUNC_START(startup_32)
    notl %eax
    andl %eax, %ebx
    cmpl $LOAD_PHYSICAL_ADDR, %ebx
    - jge 1f
    + jae 1f
    #endif
    movl $LOAD_PHYSICAL_ADDR, %ebx
    1:
    @@ -296,7 +296,7 @@ SYM_CODE_START(startup_64)
    notq %rax
    andq %rax, %rbp
    cmpq $LOAD_PHYSICAL_ADDR, %rbp
    - jge 1f
    + jae 1f
    #endif
    movq $LOAD_PHYSICAL_ADDR, %rbp
    1:
    --
    2.20.1


    \
     
     \ /
      Last update: 2020-04-16 17:03    [W:4.235 / U:0.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site