Secure Boot Advanced Targeting (SBAT) support on powerpc
cover Secure Boot Advanced Targeting (SBAT) support on powerpc
In powerpc, PE format Binary are not supported and can't use shim (https://github.com/rhboot/shim/blob/main/SBAT.md).
However, ELF binary are supported. So, we created new ELF note for SBAT in ELF binary which store the SBAT data and SBAT verifier will be there in firmware to read SBAT data from ELF note and validate it.
this patch series consists of 2 parts:
1) Patch 1: create new ELF Note for SBAT
we add a new ELF note for SBAT which store the SBAT data.
The name field of shall be the string "Secure-Boot-Advanced-Targeting", zero-padded to 4 byte alignment. The type field shall be 0x41536967 (the ASCII values for the string "sbat").
2) Patch 2: adding sbat data into sbat ELF Note
it reads the SBAT data from sbat.csv and create the ELF Note for it then store the SBAT data on it while generate image with -s option
Sudhakar Kuppusamy (2):
mkimage: create new ELF Note for SBAT
mkimage: adding sbat data into sbat ELF Note on powerpc
include/grub/util/mkimage.h | 4 +-- util/grub-mkimagexx.c | 59 ++++++++++++++++++++++++++++++++----- util/mkimage.c | 19 +++++++++--- 3 files changed, 68 insertions(+), 14 deletions(-)
Signature · 7 lines
2.39.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 1/2 mkimage: create new ELF Note for SBAT
we add a new ELF note for SBAT which store the SBAT data.
The name field of shall be the string "Secure-Boot-Advanced-Targeting", zero-padded to 4 byte alignment. The type field shall be 0x41536967 (the ASCII values for the string "sbat").
--- include/grub/util/mkimage.h | 4 +-- util/grub-mkimagexx.c | 59 ++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 10 deletions(-)
include/grub/util/mkimage.h +2 -2
@@ -51,12 +51,12 @@ grub_mkimage_load_image64 (const char *kernel_path, const struct grub_install_image_target_desc *image_target);void grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target, -int note,size_t appsig_size,char **core_img,size_t *core_size, +int note,size_t appsig_size,char *sbat,char **core_img,size_t *core_size,Elf32_Addr target_addr,struct grub_mkimage_layout *layout);void grub_mkimage_generate_elf64 (const struct grub_install_image_target_desc *image_target, -int note,size_t appsig_size,char **core_img,size_t *core_size, +int note,size_t appsig_size,char *sbat,char **core_img,size_t *core_size,Elf64_Addr target_addr,struct grub_mkimage_layout *layout);
util/grub-mkimagexx.c +51 -8
115 lines not on this page · raw message
Signature · 7 lines
2.39.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/2 mkimage: adding sbat data into sbat ELF Note on powerpc
In reply to Sudhakar Kuppusamyit reads the SBAT data from sbat.csv and create the ELF Note for it then store the SBAT data on it while generate image with -s option
--- util/mkimage.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
util/mkimage.c +15 -4
@@ -954,8 +954,9 @@ grub_install_generate_image (const char *dir, const char *prefix, total_module_size += dtb_size +sizeof (struct grub_module_header ); } -if (sbat_path !=NULL && image_target->id !=IMAGE_EFI ) -grub_util_error (_ (".sbat section can be embedded into EFI images only" )); +if (sbat_path !=NULL && (image_target->id !=IMAGE_EFI && image_target->id !=IMAGE_PPC )) +grub_util_error (_ (".sbat section can be embedded into EFI images/" +"sbat ELF Note cab be added into powerpc-ieee1275 images only" ));if (disable_shim_lock) total_module_size +=sizeof (struct grub_module_header );
@@ -1828,6 +1829,16 @@ grub_install_generate_image (const char *dir, const char *prefix,case IMAGE_I386_IEEE1275 : {grub_uint64_t target_addr; +char *sbat =NULL ; + +if (sbat_path !=NULL ) + { + sbat_size =grub_util_get_image_size (sbat_path); + sbat =xmalloc (sbat_size); +grub_util_load_image (sbat_path, sbat); + layout.sbat_size = sbat_size; + } +if (image_target->id ==IMAGE_LOONGSON_ELF ) {if (comp ==GRUB_COMPRESSION_NONE )
@@ -1839,10 +1850,10 @@ grub_install_generate_image (const char *dir, const char *prefix,else target_addr = image_target->link_addr;if (image_target->voidp_sizeof ==4 ) -grub_mkimage_generate_elf32 (image_target, note, appsig_size, &core_img, &core_size, +grub_mkimage_generate_elf32 (image_target, note, appsig_size, sbat, &core_img, &core_size, target_addr, &layout);else -grub_mkimage_generate_elf64 (image_target, note, appsig_size, &core_img, &core_size, +grub_mkimage_generate_elf64 (image_target, note, appsig_size, sbat, &core_img, &core_size, target_addr, &layout); }break ;
Signature · 7 lines
2.39.3 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH v1 2/2] mkimage: adding sbat data into sbat ELF Note on powerpc
Quoted 2 lines · Sudhakar Kuppusamy
it reads the SBAT data from sbat.csv and create the ELF Note for it then store the SBAT data on it while generate image with -s option
May I ask you to use proper English sentences in the commit messages?
Quoted 11 lines
Signed-off-by Sudhakar Kuppusamy <[email protected]>Co-authored-by Daniel Axtens <[email protected]>--- util/mkimage.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)util/mkimage.c +0
-0
util/mkimage.c grub_install_generate_image (const char *dir, const char *prefix, · line 959
Quoted 8 lines
util/mkimage.c +3
-2@@ -954,8 +954,9 @@ grub_install_generate_image (const char *dir, const char *prefix, total_module_size += dtb_size +sizeof (struct grub_module_header ); } -if (sbat_path !=NULL && image_target->id !=IMAGE_EFI ) -grub_util_error (_ (".sbat section can be embedded into EFI images only" )); +if (sbat_path !=NULL && (image_target->id !=IMAGE_EFI && image_target->id !=IMAGE_PPC )) +grub_util_error (_ (".sbat section can be embedded into EFI images/" +"sbat ELF Note cab be added into powerpc-ieee1275 images only" ));
s/cab/can/
util/mkimage.c grub_install_generate_image (const char *dir, const char *prefix, · line 1837
Quoted 13 lines
util/mkimage.c +6
-0if (disable_shim_lock) total_module_size +=sizeof (struct grub_module_header );@@ -1828,6 +1829,16 @@ grub_install_generate_image (const char *dir, const char *prefix,case IMAGE_I386_IEEE1275 : {grub_uint64_t target_addr; +char *sbat =NULL ; + +if (sbat_path !=NULL ) + { + sbat_size =grub_util_get_image_size (sbat_path); + sbat =xmalloc (sbat_size);
Please use tabs and spaces to properly format the code. E.g. one line above is correct.
util/mkimage.c grub_install_generate_image (const char *dir, const char *prefix, · line 1839
Quoted 2 lines
util/mkimage.c +2
-0+grub_util_load_image (sbat_path, sbat); + layout.sbat_size = sbat_size;
Ditto.
Quoted 8 lines
util/mkimage.c +2
-0+ } +if (image_target->id ==IMAGE_LOONGSON_ELF ) {if (comp ==GRUB_COMPRESSION_NONE )@@ -1839,10 +1850,10 @@ grub_install_generate_image (const char *dir, const char *prefix,else target_addr = image_target->link_addr;
util/mkimage.c grub_install_generate_image (const char *dir, const char *prefix, · line 1859
Quoted 10 lines
util/mkimage.c +2
-2if (image_target->voidp_sizeof ==4 ) -grub_mkimage_generate_elf32 (image_target, note, appsig_size, &core_img, &core_size, +grub_mkimage_generate_elf32 (image_target, note, appsig_size, sbat, &core_img, &core_size, target_addr, &layout);else -grub_mkimage_generate_elf64 (image_target, note, appsig_size, &core_img, &core_size, +grub_mkimage_generate_elf64 (image_target, note, appsig_size, sbat, &core_img, &core_size, target_addr, &layout); }break ;
I have a feeling this hunk should go to the first patch.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel