NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-amd64/54775 (PXE netboot fails again)



The following reply was made to PR port-amd64/54775; it has been noted by GNATS.

From: Emmanuel Dreyfus <manu%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: manu%netbsd.org@localhost, gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost,
	Andreas Gustafsson <gson%gson.org@localhost>
Subject: Re: port-amd64/54775 (PXE netboot fails again)
Date: Thu, 26 Dec 2019 16:59:37 +0000

 --B0nZA57HJSoPbsHY
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Mon, Dec 23, 2019 at 01:55:01AM +0000, Emmanuel Dreyfus wrote:
 >  After a few exchange off-gnats with Andreas, we came to the conclusion
 >  that pxeboot_ia32.bin is confused by the presence of the empty multiboot
 >  section in the kernel. 
 
 Here is a new patch to test. Boot failure reports with EFI seem
 to require this alternative fix. Here is the explanation posted
 with the patch to source-changes-d%netbsd.org@localhost
 
 It adds the -n flag to ld, which disable auto-alignment of sections
 in the file. I undestand alignement is highly desirable for userland
 programs that may be mapped from file, but useless for the kernel,
 which is just readen once by the bootloader.
 
 Without auto-alignement, the .text segment starts right after the
 ELF headers. This means the multiboot header can go in .text and
 stay below 32k (as required by the multiboot specification). There
 is no need for a multiboot section for that, and therefore no
 need to modify the linker script.
 
 A side effect is that the kernel file shrinks of 2 MB, because there
 is not an alignement hole between ELF headers and the .text section
 anymore.
 
 My patch also enable the MULTIBOOT option so that we can check
 nothing gets broken with it. You can also try with the option
 disabled, of course.
 
 
 -- 
 Emmanuel Dreyfus
 manu%netbsd.org@localhost
 
 --B0nZA57HJSoPbsHY
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=patch
 
 ? sys/arch/amd64/compile/obj
 ? sys/arch/amd64/stand/prekern/obj
 Index: sys/arch/amd64/amd64/locore.S
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/amd64/amd64/locore.S,v
 retrieving revision 1.195
 diff -U4 -r1.195 locore.S
 --- sys/arch/amd64/amd64/locore.S	15 Dec 2019 02:58:21 -0000	1.195
 +++ sys/arch/amd64/amd64/locore.S	26 Dec 2019 16:44:10 -0000
 @@ -431,51 +431,8 @@
  	.size	tmpstk, tmpstk - .
  	.space	512
  tmpstk:
  
 -.section multiboot,"a"
 -#if defined(MULTIBOOT)
 -	.align	8
 -	.globl	Multiboot2_Header
 -_C_LABEL(Multiboot2_Header):
 -	.int	MULTIBOOT2_HEADER_MAGIC
 -	.int	MULTIBOOT2_ARCHITECTURE_I386
 -	.int	Multiboot2_Header_end - Multiboot2_Header
 -	.int	-(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \
 -		+ (Multiboot2_Header_end - Multiboot2_Header))
 -
 -	.int	1	/* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */
 -	.int	12	/* sizeof(multiboot_header_tag_information_request) */
 -			/* + sizeof(uint32_t) * requests */
 -	.int	4	/* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */
 -	.align	8
 -
 -	.int	3	/* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS */
 -	.int	16	/* sizeof(struct multiboot_tag_efi64) */
 -	.quad	(multiboot2_entry - KERNBASE)
 -	.align	8
 -
 -	.int	9	/* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 */
 -	.int	16	/* sizeof(struct multiboot_tag_efi64) */
 -	.quad	(multiboot2_entry - KERNBASE)
 -	.align	8
 -
 -#if notyet
 -	/*
 -	 * Could be used to get an early console for debug,
 -	 * but this is broken.
 -	 */
 -	.int	7	/* MULTIBOOT_HEADER_TAG_EFI_BS */
 -	.int	8	/* sizeof(struct multiboot_tag) */
 -	.align	8
 -#endif
 -
 -	.int	0	/* MULTIBOOT_HEADER_TAG_END */
 -	.int	8	/* sizeof(struct multiboot_tag) */
 -	.align	8
 -	.globl	Multiboot2_Header_end
 -_C_LABEL(Multiboot2_Header_end):
 -#endif	/* MULTIBOOT */
  
  /*
   * Some hackage to deal with 64bit symbols in 32 bit mode.
   * This may not be needed if things are cleaned up a little.
 @@ -2179,8 +2136,50 @@
  SYSCALL_ENTRY	syscall,is_svs=0
  
  	TEXT_USER_BEGIN
  
 +#if defined(MULTIBOOT)
 +	.align	8
 +	.globl	Multiboot2_Header
 +_C_LABEL(Multiboot2_Header):
 +	.int	MULTIBOOT2_HEADER_MAGIC
 +	.int	MULTIBOOT2_ARCHITECTURE_I386
 +	.int	Multiboot2_Header_end - Multiboot2_Header
 +	.int	-(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \
 +		+ (Multiboot2_Header_end - Multiboot2_Header))
 +
 +	.int	1	/* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */
 +	.int	12	/* sizeof(multiboot_header_tag_information_request) */
 +			/* + sizeof(uint32_t) * requests */
 +	.int	4	/* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */
 +	.align	8
 +
 +	.int	3	/* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS */
 +	.int	16	/* sizeof(struct multiboot_tag_efi64) */
 +	.quad	(multiboot2_entry - KERNBASE)
 +	.align	8
 +
 +	.int	9	/* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 */
 +	.int	16	/* sizeof(struct multiboot_tag_efi64) */
 +	.quad	(multiboot2_entry - KERNBASE)
 +	.align	8
 +
 +#if notyet
 +	/*
 +	 * Could be used to get an early console for debug,
 +	 * but this is broken.
 +	 */
 +	.int	7	/* MULTIBOOT_HEADER_TAG_EFI_BS */
 +	.int	8	/* sizeof(struct multiboot_tag) */
 +	.align	8
 +#endif
 +
 +	.int	0	/* MULTIBOOT_HEADER_TAG_END */
 +	.int	8	/* sizeof(struct multiboot_tag) */
 +	.align	8
 +	.globl	Multiboot2_Header_end
 +_C_LABEL(Multiboot2_Header_end):
 +#endif /* MULTIBOOT */
  #ifdef SVS
  SYSCALL_ENTRY	syscall_svs,is_svs=1
  #endif
  
 Index: sys/arch/amd64/conf/GENERIC
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/amd64/conf/GENERIC,v
 retrieving revision 1.551
 diff -U4 -r1.551 GENERIC
 --- sys/arch/amd64/conf/GENERIC	14 Dec 2019 07:45:20 -0000	1.551
 +++ sys/arch/amd64/conf/GENERIC	26 Dec 2019 16:44:10 -0000
 @@ -25,9 +25,9 @@
  #ident		"GENERIC-$Revision: 1.551 $"
  
  maxusers	64		# estimated number of users
  
 -#options 	MULTIBOOT	# Multiboot support (see multiboot(8)) 
 +options 	MULTIBOOT	# Multiboot support (see multiboot(8)) 
  
  # delay between "rebooting ..." message and hardware reset, in milliseconds
  #options 	CPURESET_DELAY=2000
  
 Index: sys/arch/amd64/conf/Makefile.amd64
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/amd64/conf/Makefile.amd64,v
 retrieving revision 1.80
 diff -U4 -r1.80 Makefile.amd64
 --- sys/arch/amd64/conf/Makefile.amd64	14 Nov 2019 16:23:52 -0000	1.80
 +++ sys/arch/amd64/conf/Makefile.amd64	26 Dec 2019 16:44:10 -0000
 @@ -90,12 +90,12 @@
  ## (5) link settings
  ##
  TEXTADDR?=	0xffffffff80200000
  .if defined(KASLR)
 -EXTRA_LINKFLAGS=	--split-by-file=0x100000 -r -d
 +EXTRA_LINKFLAGS=	--split-by-file=0x100000 -r -d -n
  KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
  .else
 -EXTRA_LINKFLAGS=	-z max-page-size=0x200000
 +EXTRA_LINKFLAGS=	-z max-page-size=0x200000 -n
  KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
  .endif
  LINKFLAGS_NORMAL=	-X
  
 Index: sys/arch/amd64/conf/kern.ldscript
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/amd64/conf/kern.ldscript,v
 retrieving revision 1.30
 diff -U4 -r1.30 kern.ldscript
 --- sys/arch/amd64/conf/kern.ldscript	15 Dec 2019 02:56:40 -0000	1.30
 +++ sys/arch/amd64/conf/kern.ldscript	26 Dec 2019 16:44:10 -0000
 @@ -12,19 +12,9 @@
  
  ENTRY(_start)
  SECTIONS
  {
 -	/*
 -	 * multiboot (file_offset) : AT (load_address) 
 -	 * file_offset must be below 32k for multiboot 2 specification
 -	 * BIOS boot requires load_address above 0x200000
 -	 */
 -	multiboot 0x1000 : AT (0x200000)
 -	{
 -		. = ALIGN(8);
 -		KEEP(*(multiboot));
 -	}
 -	.text : AT (0x200000 + SIZEOF(multiboot))
 +	.text : AT (ADDR(.text) & 0x0fffffff)
  	{
  		. = ALIGN(__PAGE_SIZE);
  		__text_user_start = . ;
  		*(.text.user)
 
 --B0nZA57HJSoPbsHY--
 


Home | Main Index | Thread Index | Old Index