-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated support for SHIM on RISC-V #641
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") | ||
OUTPUT_ARCH(riscv) | ||
ENTRY(_start) | ||
SECTIONS | ||
{ | ||
.text 0x0 : { | ||
_text = .; | ||
*(.text.head) | ||
*(.text) | ||
*(.text.*) | ||
*(.gnu.linkonce.t.*) | ||
_evtext = .; | ||
. = ALIGN(4096); | ||
} | ||
_etext = .; | ||
_text_size = . - _text; | ||
_text_vsize = _evtext - _text; | ||
|
||
. = ALIGN(4096); | ||
.data : | ||
{ | ||
_data = .; | ||
*(.sdata) | ||
*(.data) | ||
*(.data1) | ||
*(.data.*) | ||
*(.got.plt) | ||
*(.got) | ||
|
||
*(.dynamic) | ||
|
||
/* the EFI loader doesn't seem to like a .bss section, so we stick | ||
it all into .data: */ | ||
. = ALIGN(16); | ||
_bss = .; | ||
*(.sbss) | ||
*(.scommon) | ||
*(.dynbss) | ||
*(.bss) | ||
*(COMMON) | ||
_evdata = .; | ||
. = ALIGN(4096); | ||
_bss_end = .; | ||
} | ||
_edata = .; | ||
_data_vsize = _evdata - _data; | ||
_data_size = . - _data; | ||
|
||
/* | ||
* Note that _sbat must be the beginning of the data, and _esbat must be the | ||
* end and must be before any section padding. The sbat self-check uses | ||
* _esbat to find the bounds of the data, and if the padding is included, the | ||
* CSV parser (correctly) rejects the data as having NUL values in one of the | ||
* required columns. | ||
*/ | ||
. = ALIGN(4096); | ||
.sbat : | ||
{ | ||
_sbat = .; | ||
*(.sbat) | ||
*(.sbat.*) | ||
_esbat = .; | ||
. = ALIGN(4096); | ||
_epsbat = .; | ||
} | ||
_sbat_size = _epsbat - _sbat; | ||
_sbat_vsize = _esbat - _sbat; | ||
|
||
. = ALIGN(4096); | ||
.rodata : | ||
{ | ||
_rodata = .; | ||
*(.rodata*) | ||
*(.srodata) | ||
. = ALIGN(16); | ||
*(.note.gnu.build-id) | ||
. = ALIGN(4096); | ||
*(.vendor_cert) | ||
*(.data.ident) | ||
. = ALIGN(4096); | ||
} | ||
. = ALIGN(4096); | ||
.rela : | ||
{ | ||
*(.rela.dyn) | ||
*(.rela.plt) | ||
*(.rela.got) | ||
*(.rela.data) | ||
*(.rela.data*) | ||
} | ||
. = ALIGN(4096); | ||
.dyn : | ||
{ | ||
*(.dynsym) | ||
*(.dynstr) | ||
_evrodata = .; | ||
. = ALIGN(4096); | ||
} | ||
_erodata = .; | ||
_rodata_size = . - _rodata; | ||
_rodata_vsize = _evrodata - _rodata; | ||
_alldata_size = . - _data; | ||
|
||
/DISCARD/ : | ||
{ | ||
*(.rel.reloc) | ||
*(.eh_frame) | ||
*(.note.GNU-stack) | ||
} | ||
.comment 0 : { *(.comment) } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,21 @@ | |
#endif | ||
#endif | ||
|
||
#if defined(__riscv) && __riscv_xlen == 64 | ||
#ifndef DEFAULT_LOADER | ||
#define DEFAULT_LOADER L"\\grubriscv64.efi" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the file name be shorter (as in 8.3 format) given a FAT filesystem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, cool. I was just thinking I've seen some vendors expect/model on it being strict FAT12 in the x86 space, and seeing the longer file name started to bug me. Also interesting Ubuntu beat Debian since I checked Debian packaging yesterday when the question came up in another project of "what would the filename be?!" so we could correctly account for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UEFI requires support for FAT long filenames (LFN) in all FAT12, FAT16 and FAT32 so it's fine |
||
#endif | ||
#ifndef DEFAULT_LOADER_CHAR | ||
#define DEFAULT_LOADER_CHAR "\\grubriscv64.efi" | ||
#endif | ||
#ifndef EFI_ARCH | ||
#define EFI_ARCH L"riscv64" | ||
#endif | ||
#ifndef DEBUGDIR | ||
#define DEBUGDIR L"/usr/lib/debug/usr/share/shim/riscv64/" | ||
#endif | ||
#endif | ||
|
||
#ifndef DEBUGSRC | ||
#define DEBUGSRC L"/usr/src/debug/shim-" VERSIONSTR "." EFI_ARCH | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had some discussions with Peter Jones last year. There was a strong preference not to add more "-O binary" architectures. Two patches landed in binutils 2.42:
[PATCH] Add basic support for RISC-V 64-bit EFI objects
[PATCH] Handle "efi-app-riscv64" and similar targets in objcopy. // From Peter Jones
That means we have
efi-app-riscv64
support. That probably means it should look more like aarch64. I haven't looked deeper or tested it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidlt Shim has an .sbat section with the contents of a CSV file for defining the security patch level. How would you create that section with binutils' efi-app-riscv64 target?
The content of the .sbat section is something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It really seems that the lines
are not needed. SUBSYSTEM defaults to 0x0a in branch main of https://github.com/rhboot/gnu-efi.git:
gnu-efi/gnuefi/crt0-efi-riscv64.S:20:
#define EFI_SUBSYSTEM 10
TIMESTAMP_LOCATION is unused.
FORMAT is a flag passed to riscv64-linux-gnu-objcopy which seems unneded.
@brianredbeard Could you please drop the lines from your merge request.