lkml.org 
[lkml]   [2022]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v3 09/17] x86/compressed: avoid touching ECX in startup32_set_idt_entry()
    Date
    Avoid touching register %ecx in startup32_set_idt_entry(), by folding
    the MOV, SHL and ORL instructions into a single ORL which no longer
    requires a temp register.

    This permits ECX to be used as a function argument in a subsequent
    patch.

    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    ---
    arch/x86/boot/compressed/head_64.S | 8 ++------
    1 file changed, 2 insertions(+), 6 deletions(-)

    diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
    index 66ad3ab802ca9d0c..f31277f455e63f5f 100644
    --- a/arch/x86/boot/compressed/head_64.S
    +++ b/arch/x86/boot/compressed/head_64.S
    @@ -741,7 +741,6 @@ SYM_DATA_END_LABEL(boot32_idt, SYM_L_GLOBAL, boot32_idt_end)
    */
    SYM_FUNC_START(startup32_set_idt_entry)
    push %ebx
    - push %ecx

    /* IDT entry address to %ebx */
    leal rva(boot32_idt)(%ebp), %ebx
    @@ -750,10 +749,8 @@ SYM_FUNC_START(startup32_set_idt_entry)

    /* Build IDT entry, lower 4 bytes */
    movl %eax, %edx
    - andl $0x0000ffff, %edx # Target code segment offset [15:0]
    - movl $__KERNEL32_CS, %ecx # Target code segment selector
    - shl $16, %ecx
    - orl %ecx, %edx
    + andl $0x0000ffff, %edx # Target code segment offset [15:0]
    + orl $(__KERNEL32_CS << 16), %edx # Target code segment selector

    /* Store lower 4 bytes to IDT */
    movl %edx, (%ebx)
    @@ -766,7 +763,6 @@ SYM_FUNC_START(startup32_set_idt_entry)
    /* Store upper 4 bytes to IDT */
    movl %edx, 4(%ebx)

    - pop %ecx
    pop %ebx
    RET
    SYM_FUNC_END(startup32_set_idt_entry)
    --
    2.35.1
    \
     
     \ /
      Last update: 2022-11-22 17:12    [W:4.511 / U:0.008 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site