Re: Still did not succeed to boot on Lenovo Yoga C630
Hiroo Ono (小野寛生) <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.arm |
|---|---|
| Message-ID | <CANtk6SjStgG4fR19ZCmK3SwMVCkTAP4q06zGj5ivdXASpjEFGg@mail.gmail.com> |
Sorry again. The patch is needed for * stand/efi/loader/arch/arm64/start.S * stand/efi/loader/arch/arm64/ldscript.arm64 * stand/efi/loader/Makefile I forgot the last one. I remade the patch for three. 2022年12月24日(土) 22:11 Hiroo Ono (小野寛生) <[email protected]>: > > 2022年12月24日(土) 10:35 Hiroo Ono (小野寛生) <[email protected]>: > > > > > I run other arm64 machines w/o issue with the current code. > > > > Yes, Qualcomm's snapdragon is weird. I saw Linux people complain about > > it somewhere... Wanted to know before I bought this Yoga C630. > > > > 2022年12月24日(土) 10:03 Warner Losh <[email protected]>: > > > > > > > > > > > > On Fri, Dec 23, 2022 at 5:49 PM Hiroo Ono (小野寛生) <[email protected]> wrote: > > >> > > >> The current status of FreeBSD 14-current on Lenovo Yoga C630 is as follows: > > >> > > >> 1) Merging from OpenBSD's loader code made the loader boot apart from > > >> 3 points (#2 to 4 ). > > >> 2) when comconsole->c_init() runs the 2nd time, it seems to freeze. > > >> (might be C630 specific) > > >> 3) SetVirtualAddressMap() in efi_do_vmap() freezes. (might also > > >> affect other snapdragon systems like Microsoft Arm Developer Kit) > > >> 4) The kernel is kicked but does not start. > > >> > > >> 1) is quite straightforward. What needs to be changed is > > >> stand/efi/loader/arch/arm64/start.S. > > > > > > > > > Can you share what needs to be done? To my eye, we don't need any changes, so it would be good to know what you've had to do exactly. > > > > Attached is the diff to start.S. There are 3 points. > > 1) The loader has to be aligned to 4kb. > > 2) Proper characteristic value should be in the PE header. > > 3) .text and .data segment have to be separate. > > > > It is from OpenBSD: > > https://github.com/openbsd/src/blob/master/sys/arch/arm64/stand/efiboot/start.S > > Sorry patch to ldscript.arm64 was missing. > I am going to test your serial patch now. > > > > >> For 2), I do not know what to do. Currently, I commented out > > >> comconsole from struct console *consoles[] in stand/efi/loader/conf.c > > >> as a workaround. Maybe, I should write a fault handler that helps > > >> returning from the fault. > > > > > > > > > There were problems with this with HyperV on aarch64 too. > > > > > > Something like > > > diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/loader/efiserialio.c > > > index 8b3f8e83e0b3..54ee39096685 100644 > > > --- a/stand/efi/loader/efiserialio.c > > > +++ b/stand/efi/loader/efiserialio.c > > > @@ -261,11 +261,11 @@ comc_probe(struct console *sc) > > > if (comc_port == NULL) > > > return; > > > } > > > - comc_port->baudrate = COMSPEED; > > > + comc_port->baudrate = 0; > > > comc_port->ioaddr = 0; /* default port */ > > > - comc_port->databits = 8; /* 8,n,1 */ > > > - comc_port->parity = NoParity; /* 8,n,1 */ > > > - comc_port->stopbits = OneStopBit; /* 8,n,1 */ > > > + comc_port->databits = 0; /* 8,n,1 */ > > > + comc_port->parity = 0; /* 8,n,1 */ > > > + comc_port->stopbits = 0; /* 8,n,1 */ > > > comc_port->ignore_cd = 1; /* ignore cd */ > > > comc_port->rtsdtr_off = 0; /* rts-dtr is on */ > > > comc_port->sio = NULL; > > > > > > was needed. Possibly the following would be better: > > > > > > diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/loader/efiserialio.c > > > index 8b3f8e83e0b3..54ee39096685 100644 > > > --- a/stand/efi/loader/efiserialio.c > > > +++ b/stand/efi/loader/efiserialio.c > > > @@ -494,8 +494,7 @@ comc_setup(void) > > > return (false); > > > > > > status = comc_port->sio->SetAttributes(comc_port->sio, > > > - comc_port->baudrate, 0, 0, comc_port->parity, > > > - comc_port->databits, comc_port->stopbits); > > > + 0, 0, 0, 0, 0, 0); > > > if (EFI_ERROR(status)) > > > return (false); > > >
stand.diff.txt
(text/plain, 4.3 KB)
diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile
index 2aaba4fbb377..4483f524e43a 100644
--- a/stand/efi/loader/Makefile
+++ b/stand/efi/loader/Makefile
@@ -114,8 +114,9 @@ ${LOADER}.efi: ${PROG}
fi
SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \
${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \
- -j .dynamic -j .dynsym -j .rel.dyn \
- -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
+ -j .dynamic -j .dynsym -j .dynstr -j .rel -j .rel.dyn \
+ -j .rela -j .rela.dyn -j .reloc -j .eh_frame \
+ -j set_Xcommand_set \
-j set_Xficl_compile_set \
--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
diff --git a/stand/efi/loader/arch/arm64/ldscript.arm64 b/stand/efi/loader/arch/arm64/ldscript.arm64
index d0ed320a319c..8abf4104273e 100644
--- a/stand/efi/loader/arch/arm64/ldscript.arm64
+++ b/stand/efi/loader/arch/arm64/ldscript.arm64
@@ -16,7 +16,9 @@ SECTIONS
*(.gnu.warning)
*(.plt)
} =0xD4200000
- . = ALIGN(16);
+ . = ALIGN(4096);
+ _etext = .;
+ __data_start = .;
.data : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
*(.rodata1)
@@ -77,10 +79,11 @@ SECTIONS
.reloc : { *(.reloc) }
. = ALIGN(16);
.dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
_edata = .;
+ __data_size = . - __data_start;
/* Unused sections */
.interp : { *(.interp) }
- .dynstr : { *(.dynstr) }
.hash : { *(.hash) }
}
diff --git a/stand/efi/loader/arch/arm64/start.S b/stand/efi/loader/arch/arm64/start.S
index 675d4e153f36..37e117d679a0 100644
--- a/stand/efi/loader/arch/arm64/start.S
+++ b/stand/efi/loader/arch/arm64/start.S
@@ -39,6 +39,7 @@
#define IMAGE_SCN_MEM_DISCARDABLE 0x02000000
#define IMAGE_SCN_MEM_EXECUTE 0x20000000
#define IMAGE_SCN_MEM_READ 0x40000000
+#define IMAGE_SCN_MEM_WRITE 0x80000000
.section .peheader,"a"
efi_start:
@@ -55,27 +56,27 @@ pe_sig:
.short 0
coff_head:
.short IMAGE_FILE_MACHINE_ARM64 /* AArch64 file */
- .short 2 /* 2 Sections */
+ .short 3 /* 2 Sections */
.long 0 /* Timestamp */
.long 0 /* No symbol table */
.long 0 /* No symbols */
.short section_table - optional_header /* Optional header size */
- .short 0 /* Characteristics TODO: Fill in */
+ .short 0x0206 /* Characteristics */
optional_header:
.short 0x020b /* PE32+ (64-bit addressing) */
.byte 0 /* Major linker version */
.byte 0 /* Minor linker version */
- .long _edata - _end_header /* Code size */
- .long 0 /* No initialized data */
+ .long _etext - _end_header /* Code size */
+ .long __data_size /* No initialized data */
.long 0 /* No uninitialized data */
.long _start - efi_start /* Entry point */
.long _end_header - efi_start /* Start of code */
optional_windows_header:
.quad 0 /* Image base */
- .long 32 /* Section Alignment */
- .long 8 /* File alignment */
+ .long 4096 /* Section Alignment */
+ .long 512 /* File alignment */
.short 0 /* Major OS version */
.short 0 /* Minor OS version */
.short 0 /* Major image version */
@@ -124,9 +125,9 @@ section_table:
.byte 0
.byte 0
.byte 0 /* Pad to 8 bytes */
- .long _edata - _end_header /* Virtual size */
+ .long _etext - _end_header /* Virtual size */
.long _end_header - efi_start /* Virtual address */
- .long _edata - _end_header /* Size of raw data */
+ .long _etext - _end_header /* Size of raw data */
.long _end_header - efi_start /* Pointer to raw data */
.long 0 /* Pointer to relocations */
.long 0 /* Pointer to line numbers */
@@ -134,6 +135,24 @@ section_table:
.short 0 /* Number of line numbers */
.long (IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | \
IMAGE_SCN_MEM_READ) /* Characteristics */
+
+ /* The contents of the loader */
+ .ascii ".data"
+ .byte 0
+ .byte 0
+ .byte 0 /* Pad to 8 bytes */
+ .long __data_size /* Virtual size */
+ .long __data_start - efi_start /* Virtual address */
+ .long __data_size /* Size of raw data */
+ .long __data_start - efi_start /* Pointer to raw data */
+ .long 0 /* Pointer to relocations */
+ .long 0 /* Pointer to line numbers */
+ .short 0 /* Number of relocations */
+ .short 0 /* Number of line numbers */
+ .long (IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | \
+ IMAGE_SCN_MEM_WRITE) /* Characteristics */
+
+ .align 12
_end_header:
.text
@@ -185,3 +204,6 @@ initstack:
.space (64 * 1024)
initstack_end:
#endif
+
+ .data
+ .align 4