From 0d915a9aa4e1f9060dac2c32616a69b391292b84 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 3 Dec 2019 14:20:49 +0900 Subject: [PATCH 1/2] x86: use data32 directive instead of macro for operand-size prefix This file defines 'a32' and 'o32' macros to avoid magic numbers of operand/address-size prefixing. GAS supports 'data32' and 'addr32' for that purpose. Signed-off-by: Masahiro Yamada Reviewed-by: Bin Meng Tested-by: Bin Meng --- arch/x86/cpu/start16.S | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/cpu/start16.S b/arch/x86/cpu/start16.S index 474efe4df5f..bcabd76741e 100644 --- a/arch/x86/cpu/start16.S +++ b/arch/x86/cpu/start16.S @@ -13,8 +13,6 @@ #include #define BOOT_SEG 0xffff0000 /* linear segment of boot code */ -#define a32 .byte 0x67; -#define o32 .byte 0x66; .section .start16, "ax" .code16 @@ -33,8 +31,8 @@ start16: wbinvd /* load the temporary Global Descriptor Table */ -o32 cs lidt idt_ptr -o32 cs lgdt gdt_ptr +data32 cs lidt idt_ptr +data32 cs lgdt gdt_ptr /* Now, we enter protected mode */ movl %cr0, %eax @@ -49,7 +47,7 @@ ff: movw $code32start, %ax movw %ax, %bp movl %ecx, %eax -o32 cs ljmp *(%bp) +data32 cs ljmp *(%bp) /* 48-bit far pointer */ code32start: From 90ab311a7c1ee91201c23726871d20b2287a51a5 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 3 Dec 2019 14:28:58 +0900 Subject: [PATCH 2/2] x86: simplify ljmp to 32-bit code You can directly specify the label as the operand for ljmp. This commit saves 4-byte code. Signed-off-by: Masahiro Yamada Reviewed-by: Bin Meng Tested-by: Bin Meng [bmeng: fixed the gas warning] Signed-off-by: Bin Meng --- arch/x86/cpu/start16.S | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/cpu/start16.S b/arch/x86/cpu/start16.S index bcabd76741e..54f4ff6662a 100644 --- a/arch/x86/cpu/start16.S +++ b/arch/x86/cpu/start16.S @@ -44,10 +44,8 @@ data32 cs lgdt gdt_ptr ff: /* Finally restore BIST and jump to the 32-bit initialization code */ - movw $code32start, %ax - movw %ax, %bp movl %ecx, %eax -data32 cs ljmp *(%bp) +data32 cs ljmp *code32start /* 48-bit far pointer */ code32start: