NetBSD-Bugs archive

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

Re: misc/59151: efiboot hangs on new motherboard



> Date: Fri, 7 Mar 2025 21:56:28 +1100
> From: Paul Ripke <stix%stix.id.au@localhost>
> 
> On Fri, Mar 07, 2025 at 10:25:01AM +0000, RVP via gnats wrote:
> >  On Fri, 7 Mar 2025, stix%stix.id.au@localhost wrote:
> >  
> >  >> Fix:
> >  > I suspect that this firmware implements memory protection on the efiboot
> >  > image. I also assume that the variables written to as defined in the asm
> >  > are read-only, generating an exception, resulting in a silent hang.
> >  >
> >  
> >  Yeah, I think this makes sense. Can you see if the patch below also fixes
> >  this issue?
> >  
> >  ```
> >  diff -urN a/src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S b/src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S
> >  --- a/sys/arch/i386/stand/efiboot/bootx64/startprog64.S	2023-06-24 05:31:04.000000000 +0000
> >  +++ b/sys/arch/i386/stand/efiboot/bootx64/startprog64.S	2025-03-07 10:11:13.394064579 +0000
> >  @@ -65,6 +65,7 @@
> >    #define	CODE_SEGMENT	0x08
> >    #define	DATA_SEGMENT	0x10
> >  
> >  +	.data
> >    	.align	16
> >    	.globl _C_LABEL(startprog64)
> >    _C_LABEL(startprog64):
> >  ```
> 
> Interesting... when I saw what the code was doing, I decided to clean it
> up - afaict, there's no need for writable symbols in the asm.
> 
> Anyway, I expected your very simple patch to work - but it doesn't!
> I get what looks to be the same hang. I've removed all my debug prints
> else I'd confirm if it was hanging at the same point, but it is a pretty
> safe assumption it is.

Did you also apply the same change to add `.data' to multiboot64.S?

Because efi_md_init writes to both startprog64 and multiboot64,
unconditionally, even if the bootloader will only use one or the other
later on:

     43 void
     44 efi_md_init(void)
     45 {
...
     57 	startprog64 = (void *)addr;
...
     67 	multiboot64 = (void *)addr;

https://nxr.NetBSD.org/xref/src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.c?r=1.6#43

If so, that would explain the mystery of the difference between those
two patches.



Home | Main Index | Thread Index | Old Index