lkml.org 
[lkml]   [2020]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/1] x86/boot/compressed/32: Fix reloading of GDTR post-relocation
    Date
    Commit ef5a7b5eb13e ("efi/x86: Remove GDT setup from efi_main")
    introduced GDT setup into startup_32, and reloads the GDTR after
    relocating the kernel for paranoia's sake.

    The GDTR is adjusted by init_size - _end, however this may not be the
    correct offset to apply if the kernel was loaded at a misaligned address
    or below LOAD_PHYSICAL_ADDR, as in that case the decompression buffer
    has an additional offset from the original load address.

    This should never happen for a conformant bootloader, but we're being
    paranoid anyway, so just store the new GDT address in there instead of
    adding any offsets, which is simpler as well.

    Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
    Fixes: ef5a7b5eb13e ("efi/x86: Remove GDT setup from efi_main")
    ---
    arch/x86/boot/compressed/head_32.S | 9 ++++-----
    1 file changed, 4 insertions(+), 5 deletions(-)

    diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
    index 356060c5332c..2f8138b71ea9 100644
    --- a/arch/x86/boot/compressed/head_32.S
    +++ b/arch/x86/boot/compressed/head_32.S
    @@ -139,12 +139,11 @@ SYM_FUNC_START(startup_32)
    /*
    * The GDT may get overwritten either during the copy we just did or
    * during extract_kernel below. To avoid any issues, repoint the GDTR
    - * to the new copy of the GDT. EAX still contains the previously
    - * calculated relocation offset of init_size - _end.
    + * to the new copy of the GDT.
    */
    - leal gdt(%ebx), %edx
    - addl %eax, 2(%edx)
    - lgdt (%edx)
    + leal gdt(%ebx), %eax
    + movl %eax, 2(%eax)
    + lgdt (%eax)

    /*
    * Jump to the relocated address.
    --
    2.24.1
    \
     
     \ /
      Last update: 2020-02-26 21:46    [W:4.610 / U:0.244 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site