[v4,17/26] x86/boot: Reduce size of the DOS stub

Message ID cb62472011a0c4151276b6a05b83b60b1bf6f352.1671098103.git.baskov@ispras.ru
State New
Headers
Series x86_64: Improvements at compressed kernel stage |

Commit Message

Evgeniy Baskov Dec. 15, 2022, 12:38 p.m. UTC
  This is required to fit more sections in PE section tables,
since its size is restricted by zero page located at specific offset
after the PE header.

Tested-by: Mario Limonciello <mario.limonciello@amd.com>
Tested-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
---
 arch/x86/boot/header.S | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
  

Comments

Ard Biesheuvel March 10, 2023, 2:59 p.m. UTC | #1
On Thu, 15 Dec 2022 at 13:40, Evgeniy Baskov <baskov@ispras.ru> wrote:
>
> This is required to fit more sections in PE section tables,
> since its size is restricted by zero page located at specific offset
> after the PE header.
>
> Tested-by: Mario Limonciello <mario.limonciello@amd.com>
> Tested-by: Peter Jones <pjones@redhat.com>
> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>

I'd prefer to rip this out altogether.

https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?id=9510f6f04f579b9a3f54ad762c75ab2d905e37d8

(and refer to the other thread in linux-efi@)

> ---
>  arch/x86/boot/header.S | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
> index 9338c68e7413..9fec80bc504b 100644
> --- a/arch/x86/boot/header.S
> +++ b/arch/x86/boot/header.S
> @@ -59,17 +59,16 @@ start2:
>         cld
>
>         movw    $bugger_off_msg, %si
> +       movw    $bugger_off_msg_size, %cx
>
>  msg_loop:
>         lodsb
> -       andb    %al, %al
> -       jz      bs_die
>         movb    $0xe, %ah
>         movw    $7, %bx
>         int     $0x10
> -       jmp     msg_loop
> +       decw    %cx
> +       jnz     msg_loop
>
> -bs_die:
>         # Allow the user to press a key, then reboot
>         xorw    %ax, %ax
>         int     $0x16
> @@ -90,10 +89,9 @@ bs_die:
>
>         .section ".bsdata", "a"
>  bugger_off_msg:
> -       .ascii  "Use a boot loader.\r\n"
> -       .ascii  "\n"
> -       .ascii  "Remove disk and press any key to reboot...\r\n"
> -       .byte   0
> +       .ascii  "Use a boot loader. "
> +       .ascii  "Press a key to reboot"
> +       .set    bugger_off_msg_size, . - bugger_off_msg
>
>  #ifdef CONFIG_EFI_STUB
>  pe_header:
> --
> 2.37.4
>
  
Evgeniy Baskov March 11, 2023, 2:49 p.m. UTC | #2
On 2023-03-10 17:59, Ard Biesheuvel wrote:
> On Thu, 15 Dec 2022 at 13:40, Evgeniy Baskov <baskov@ispras.ru> wrote:
>> 
>> This is required to fit more sections in PE section tables,
>> since its size is restricted by zero page located at specific offset
>> after the PE header.
>> 
>> Tested-by: Mario Limonciello <mario.limonciello@amd.com>
>> Tested-by: Peter Jones <pjones@redhat.com>
>> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
> 
> I'd prefer to rip this out altogether.
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?id=9510f6f04f579b9a3f54ad762c75ab2d905e37d8

Sounds great! Can I replace this patch with yours in v5?

> 
> (and refer to the other thread in linux-efi@)

Which thread exactly? The one about the removal of
real-mode code?

> 
>> ---
>>  arch/x86/boot/header.S | 14 ++++++--------
>>  1 file changed, 6 insertions(+), 8 deletions(-)
>> 
>> diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
>> index 9338c68e7413..9fec80bc504b 100644
>> --- a/arch/x86/boot/header.S
>> +++ b/arch/x86/boot/header.S
>> @@ -59,17 +59,16 @@ start2:
>>         cld
>> 
>>         movw    $bugger_off_msg, %si
>> +       movw    $bugger_off_msg_size, %cx
>> 
>>  msg_loop:
>>         lodsb
>> -       andb    %al, %al
>> -       jz      bs_die
>>         movb    $0xe, %ah
>>         movw    $7, %bx
>>         int     $0x10
>> -       jmp     msg_loop
>> +       decw    %cx
>> +       jnz     msg_loop
>> 
>> -bs_die:
>>         # Allow the user to press a key, then reboot
>>         xorw    %ax, %ax
>>         int     $0x16
>> @@ -90,10 +89,9 @@ bs_die:
>> 
>>         .section ".bsdata", "a"
>>  bugger_off_msg:
>> -       .ascii  "Use a boot loader.\r\n"
>> -       .ascii  "\n"
>> -       .ascii  "Remove disk and press any key to reboot...\r\n"
>> -       .byte   0
>> +       .ascii  "Use a boot loader. "
>> +       .ascii  "Press a key to reboot"
>> +       .set    bugger_off_msg_size, . - bugger_off_msg
>> 
>>  #ifdef CONFIG_EFI_STUB
>>  pe_header:
>> --
>> 2.37.4
>>
  
Ard Biesheuvel March 11, 2023, 5:27 p.m. UTC | #3
On Sat, 11 Mar 2023 at 15:49, Evgeniy Baskov <baskov@ispras.ru> wrote:
>
> On 2023-03-10 17:59, Ard Biesheuvel wrote:
> > On Thu, 15 Dec 2022 at 13:40, Evgeniy Baskov <baskov@ispras.ru> wrote:
> >>
> >> This is required to fit more sections in PE section tables,
> >> since its size is restricted by zero page located at specific offset
> >> after the PE header.
> >>
> >> Tested-by: Mario Limonciello <mario.limonciello@amd.com>
> >> Tested-by: Peter Jones <pjones@redhat.com>
> >> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
> >
> > I'd prefer to rip this out altogether.
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?id=9510f6f04f579b9a3f54ad762c75ab2d905e37d8
>
> Sounds great! Can I replace this patch with yours in v5?
>

Of course.

> >
> > (and refer to the other thread in linux-efi@)
>
> Which thread exactly? The one about the removal of
> real-mode code?
>

Yes, this one

https://lore.kernel.org/linux-efi/20230308202209.2980947-1-ardb@kernel.org/
  
Evgeniy Baskov March 12, 2023, 12:10 p.m. UTC | #4
On 2023-03-11 20:27, Ard Biesheuvel wrote:
> On Sat, 11 Mar 2023 at 15:49, Evgeniy Baskov <baskov@ispras.ru> wrote:
>> 
>> On 2023-03-10 17:59, Ard Biesheuvel wrote:
>> > On Thu, 15 Dec 2022 at 13:40, Evgeniy Baskov <baskov@ispras.ru> wrote:
>> >>
>> >> This is required to fit more sections in PE section tables,
>> >> since its size is restricted by zero page located at specific offset
>> >> after the PE header.
>> >>
>> >> Tested-by: Mario Limonciello <mario.limonciello@amd.com>
>> >> Tested-by: Peter Jones <pjones@redhat.com>
>> >> Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
>> >
>> > I'd prefer to rip this out altogether.
>> >
>> > https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/commit/?id=9510f6f04f579b9a3f54ad762c75ab2d905e37d8
>> 
>> Sounds great! Can I replace this patch with yours in v5?
>> 
> 
> Of course.
> 
>> >
>> > (and refer to the other thread in linux-efi@)
>> 
>> Which thread exactly? The one about the removal of
>> real-mode code?
>> 
> 
> Yes, this one
> 
> https://lore.kernel.org/linux-efi/20230308202209.2980947-1-ardb@kernel.org/

Thanks!
  

Patch

diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 9338c68e7413..9fec80bc504b 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -59,17 +59,16 @@  start2:
 	cld
 
 	movw	$bugger_off_msg, %si
+	movw	$bugger_off_msg_size, %cx
 
 msg_loop:
 	lodsb
-	andb	%al, %al
-	jz	bs_die
 	movb	$0xe, %ah
 	movw	$7, %bx
 	int	$0x10
-	jmp	msg_loop
+	decw	%cx
+	jnz	msg_loop
 
-bs_die:
 	# Allow the user to press a key, then reboot
 	xorw	%ax, %ax
 	int	$0x16
@@ -90,10 +89,9 @@  bs_die:
 
 	.section ".bsdata", "a"
 bugger_off_msg:
-	.ascii	"Use a boot loader.\r\n"
-	.ascii	"\n"
-	.ascii	"Remove disk and press any key to reboot...\r\n"
-	.byte	0
+	.ascii	"Use a boot loader. "
+	.ascii	"Press a key to reboot"
+	.set	bugger_off_msg_size, . - bugger_off_msg
 
 #ifdef CONFIG_EFI_STUB
 pe_header: