Skip to content
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

update grub to 2.06 and implement hybrid boot support for x86_64 #1701

Merged
merged 7 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions macros/aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
%_cross_cpu_family arm
%_cross_endian little

%_cross_grub_target aarch64
%_cross_grub_platform efi
%_cross_grub_tuple arm64-efi
%_cross_grub_image bootaa64.efi
%_cross_grub_prefix /EFI/BOOT
%_cross_grubdir /boot/efi/EFI/BOOT/
%_cross_grub_efi_format arm64-efi
%_cross_grub_efi_image bootaa64.efi

%_cross_go_arch arm64
8 changes: 2 additions & 6 deletions macros/x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
%_cross_cpu_family x86
%_cross_endian little

%_cross_grub_target i386
%_cross_grub_platform pc
%_cross_grub_tuple i386-pc
%_cross_grub_image core.img
%_cross_grub_prefix (hd0,gpt2)/boot/grub
%_cross_grubdir /boot/grub
%_cross_grub_efi_format x86_64-efi
%_cross_grub_efi_image bootx64.efi

%_cross_go_arch amd64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 9ddb865df4ea2fb79edaf6c3a8b0122796800014 Mon Sep 17 00:00:00 2001
From fa856e9d6cce8cac8f55bb00392725961c264b8f Mon Sep 17 00:00:00 2001
tjkirch marked this conversation as resolved.
Show resolved Hide resolved
From: iliana destroyer of worlds <iweller@amazon.com>
Date: Tue, 6 Aug 2019 17:37:19 +0000
Subject: [PATCH] setup: Add root device argument to grub-setup
Expand All @@ -12,50 +12,53 @@ https://github.com/openwrt/openwrt/blob/65c8f2890ca4f41f5b933b5bc1e43de86cc1bd54
util/setup.c | 10 +++++++---
4 files changed, 22 insertions(+), 8 deletions(-)

[bcressey: updated for grub 2.06]
Signed-off-by: Ben Cressey <bcressey@amazon.com>

diff --git a/include/grub/util/install.h b/include/grub/util/install.h
index 2631b1074..ff02c365c 100644
index 51f3b13..18cd28f 100644
--- a/include/grub/util/install.h
+++ b/include/grub/util/install.h
@@ -191,13 +191,13 @@ grub_install_get_image_target (const char *arg);
@@ -205,13 +205,13 @@ grub_install_get_image_target (const char *arg);
void
grub_util_bios_setup (const char *dir,
const char *boot_file, const char *core_file,
- const char *dest, int force,
+ const char *root, const char *dest, int force,
int fs_probe, int allow_floppy,
int add_rs_codes);
int add_rs_codes, int warn_short_mbr_gap);
void
grub_util_sparc_setup (const char *dir,
const char *boot_file, const char *core_file,
- const char *dest, int force,
+ const char *root, const char *dest, int force,
int fs_probe, int allow_floppy,
int add_rs_codes);
int add_rs_codes, int warn_short_mbr_gap);

diff --git a/util/grub-install.c b/util/grub-install.c
index 8a55ad4b8..c0a2c5ec0 100644
index 5babc7a..4233ac8 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -1712,7 +1712,7 @@ main (int argc, char *argv[])
/* Now perform the installation. */
@@ -1770,7 +1770,7 @@ main (int argc, char *argv[])
if (install_bootsector)
grub_util_bios_setup (platdir, "boot.img", "core.img",
- install_drive, force,
+ NULL, install_drive, force,
fs_probe, allow_floppy, add_rs_codes);
break;
}
@@ -1738,7 +1738,7 @@ main (int argc, char *argv[])
/* Now perform the installation. */
{
grub_util_bios_setup (platdir, "boot.img", "core.img",
- install_drive, force,
+ NULL, install_drive, force,
fs_probe, allow_floppy, add_rs_codes,
!grub_install_is_short_mbrgap_supported ());
@@ -1801,7 +1801,7 @@ main (int argc, char *argv[])
if (install_bootsector)
grub_util_sparc_setup (platdir, "boot.img", "core.img",
- install_drive, force,
+ NULL, install_drive, force,
fs_probe, allow_floppy,
0 /* unused */ );
break;
{
grub_util_sparc_setup (platdir, "boot.img", "core.img",
- install_drive, force,
+ NULL, install_drive, force,
fs_probe, allow_floppy,
0 /* unused */, 0 /* unused */ );

diff --git a/util/grub-setup.c b/util/grub-setup.c
index 42b98ad3c..ae1f98f75 100644
index 1783224..48cde49 100644
--- a/util/grub-setup.c
+++ b/util/grub-setup.c
@@ -87,6 +87,8 @@ static struct argp_option options[] = {
Expand Down Expand Up @@ -96,28 +99,29 @@ index 42b98ad3c..ae1f98f75 100644
- dest_dev, arguments.force,
+ arguments.root_dev, dest_dev, arguments.force,
arguments.fs_probe, arguments.allow_floppy,
arguments.add_rs_codes);
arguments.add_rs_codes, 0);

diff --git a/util/setup.c b/util/setup.c
index 6f88f3cc4..bd7bb9c86 100644
index 8b22bb8..960aeda 100644
--- a/util/setup.c
+++ b/util/setup.c
@@ -252,13 +252,12 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)),
@@ -252,14 +252,13 @@ identify_partmap (grub_disk_t disk __attribute__ ((unused)),
void
SETUP (const char *dir,
const char *boot_file, const char *core_file,
- const char *dest, int force,
+ const char *root, const char *dest, int force,
int fs_probe, int allow_floppy,
int add_rs_codes __attribute__ ((unused))) /* unused on sparc64 */
int add_rs_codes __attribute__ ((unused)), /* unused on sparc64 */
int warn_small)
{
char *core_path;
char *boot_img, *core_img, *boot_path;
- char *root = 0;
size_t boot_size, core_size;
grub_uint16_t core_sectors;
grub_device_t root_dev = 0, dest_dev, core_dev;
@@ -307,7 +306,10 @@ SETUP (const char *dir,
@@ -311,7 +310,10 @@ SETUP (const char *dir,

core_dev = dest_dev;

Expand All @@ -129,7 +133,7 @@ index 6f88f3cc4..bd7bb9c86 100644
char **root_devices = grub_guess_root_devices (dir);
char **cur;
int found = 0;
@@ -320,6 +322,8 @@ SETUP (const char *dir,
@@ -324,6 +326,8 @@ SETUP (const char *dir,
char *drive;
grub_device_t try_dev;

Expand All @@ -138,3 +142,6 @@ index 6f88f3cc4..bd7bb9c86 100644
drive = grub_util_get_grub_dev (*cur);
if (!drive)
continue;
--
2.21.3

21 changes: 12 additions & 9 deletions packages/grub/0002-gpt-start-new-GPT-module.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 46217d1569b652fe38169a788a079b373cf6c91f Mon Sep 17 00:00:00 2001
From 6635d2ce6f2b2a0be4049af3ce271cdab3fbd97b Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Sun, 28 Sep 2014 21:26:21 -0700
Subject: [PATCH] gpt: start new GPT module
Expand All @@ -20,10 +20,10 @@ The current code does nothing more than read and verify the table.
create mode 100644 tests/gpt_unit_test.c

diff --git a/Makefile.util.def b/Makefile.util.def
index 969d32f00..af8a008e2 100644
index 3f191aa..c7efe17 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -1270,6 +1270,22 @@ program = {
@@ -1389,6 +1389,22 @@ program = {
ldadd = '$(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
};

Expand All @@ -47,10 +47,10 @@ index 969d32f00..af8a008e2 100644
name = grub-menulst2cfg;
mansection = 1;
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 474a63e68..95dba2d26 100644
index 9cff83f..3443e9c 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -893,6 +893,11 @@ module = {
@@ -932,6 +932,11 @@ module = {
common = commands/gptsync.c;
};

Expand All @@ -64,7 +64,7 @@ index 474a63e68..95dba2d26 100644
nopc = commands/halt.c;
diff --git a/grub-core/lib/gpt.c b/grub-core/lib/gpt.c
new file mode 100644
index 000000000..a308e8537
index 0000000..a308e85
--- /dev/null
+++ b/grub-core/lib/gpt.c
@@ -0,0 +1,288 @@
Expand Down Expand Up @@ -357,7 +357,7 @@ index 000000000..a308e8537
+ grub_free (gpt);
+}
diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
index 7a93f4329..ee9eb0b95 100644
index 8212697..8cffe16 100644
--- a/include/grub/gpt_partition.h
+++ b/include/grub/gpt_partition.h
@@ -21,6 +21,7 @@
Expand All @@ -383,7 +383,7 @@ index 7a93f4329..ee9eb0b95 100644
grub_uint8_t magic[8];
@@ -78,10 +85,63 @@ struct grub_gpt_partentry
char name[72];
} GRUB_PACKED;
} GRUB_PACKED __attribute__ ((aligned(8)));

+/* Basic GPT partmap module. */
grub_err_t
Expand Down Expand Up @@ -447,7 +447,7 @@ index 7a93f4329..ee9eb0b95 100644
#endif /* ! GRUB_GPT_PARTITION_HEADER */
diff --git a/tests/gpt_unit_test.c b/tests/gpt_unit_test.c
new file mode 100644
index 000000000..a824cd967
index 0000000..a824cd9
--- /dev/null
+++ b/tests/gpt_unit_test.c
@@ -0,0 +1,467 @@
Expand Down Expand Up @@ -918,3 +918,6 @@ index 000000000..a824cd967
+ grub_test_unregister ("gpt_read_fallback_test");
+ grub_fini_all ();
+}
--
2.21.3

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From eb194ecfc9137233703e530fa0411bc86405469b Mon Sep 17 00:00:00 2001
From 7bf95046b9123cd7d57df6dee81cbbd75ca722f6 Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Sat, 18 Oct 2014 15:39:13 -0700
Subject: [PATCH] gpt: rename misnamed header location fields
Expand All @@ -13,7 +13,7 @@ field names are backwards for the backup header.
3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/grub-core/lib/gpt.c b/grub-core/lib/gpt.c
index a308e8537..705bd77f9 100644
index a308e85..705bd77 100644
--- a/grub-core/lib/gpt.c
+++ b/grub-core/lib/gpt.c
@@ -137,7 +137,7 @@ grub_gpt_read_backup (grub_disk_t disk, grub_gpt_t gpt)
Expand All @@ -26,7 +26,7 @@ index a308e8537..705bd77f9 100644
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Unable to locate backup GPT");
diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
index ee9eb0b95..6d678fae2 100644
index 8cffe16..1101d85 100644
--- a/include/grub/gpt_partition.h
+++ b/include/grub/gpt_partition.h
@@ -64,8 +64,8 @@ struct grub_gpt_header
Expand All @@ -41,7 +41,7 @@ index ee9eb0b95..6d678fae2 100644
grub_uint64_t end;
grub_uint8_t guid[16];
diff --git a/tests/gpt_unit_test.c b/tests/gpt_unit_test.c
index a824cd967..4d70868af 100644
index a824cd9..4d70868 100644
--- a/tests/gpt_unit_test.c
+++ b/tests/gpt_unit_test.c
@@ -94,8 +94,8 @@ static const struct grub_gpt_header example_primary = {
Expand All @@ -66,3 +66,6 @@ index a824cd967..4d70868af 100644
.start = grub_cpu_to_le64_compile_time (DATA_START_SECTOR),
.end = grub_cpu_to_le64_compile_time (DATA_END_SECTOR),
.guid = {0xad, 0x31, 0xc1, 0x69, 0xd6, 0x67, 0xc6, 0x46,
--
2.21.3

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From b78d543b0ab493f6bd20f2e5d101fc11c9357faf Mon Sep 17 00:00:00 2001
From 42ad151307ad12ca85ae1865f4abc79d25673ae3 Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Sat, 18 Oct 2014 16:46:17 -0700
Subject: [PATCH] gpt: record size of of the entries table
Expand All @@ -11,7 +11,7 @@ to disk. Restructure the entries reading code to flow a little better.
2 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/grub-core/lib/gpt.c b/grub-core/lib/gpt.c
index 705bd77f9..01df7f3e8 100644
index 705bd77..01df7f3 100644
--- a/grub-core/lib/gpt.c
+++ b/grub-core/lib/gpt.c
@@ -153,7 +153,7 @@ grub_gpt_read_backup (grub_disk_t disk, grub_gpt_t gpt)
Expand Down Expand Up @@ -110,7 +110,7 @@ index 705bd77f9..01df7f3e8 100644
fail:
grub_gpt_free (gpt);
diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
index 6d678fae2..451b02a89 100644
index 1101d85..21ea08d 100644
--- a/include/grub/gpt_partition.h
+++ b/include/grub/gpt_partition.h
@@ -106,7 +106,9 @@ typedef enum grub_gpt_status
Expand All @@ -132,3 +132,6 @@ index 6d678fae2..451b02a89 100644

/* Logarithm of sector size, in case GPT and disk driver disagree. */
unsigned int log_sector_size;
--
2.21.3

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 39351efcb1aab82bb86052d21f07308429414a83 Mon Sep 17 00:00:00 2001
From a0481ec20cd8f99f973385b6dcacff6201aa5661 Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Sat, 18 Oct 2014 18:18:17 -0700
Subject: [PATCH] gpt: consolidate crc32 computation code
Expand All @@ -10,7 +10,7 @@ keep this rather common operation easy to use.
1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/grub-core/lib/gpt.c b/grub-core/lib/gpt.c
index 01df7f3e8..43a150942 100644
index 01df7f3..43a1509 100644
--- a/grub-core/lib/gpt.c
+++ b/grub-core/lib/gpt.c
@@ -32,22 +32,17 @@ static grub_uint8_t grub_gpt_magic[] = GRUB_GPT_HEADER_MAGIC;
Expand Down Expand Up @@ -114,3 +114,6 @@ index 01df7f3e8..43a150942 100644
return grub_errno;
}

--
2.21.3

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 5e9049af888cd344990fd031f93d7189ef340805 Mon Sep 17 00:00:00 2001
From 36fc577048523438ffbf51291a40fe59eb479724 Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Sat, 18 Oct 2014 18:21:07 -0700
Subject: [PATCH] gpt: add new repair function to sync up primary and backup
Expand All @@ -11,7 +11,7 @@ Subject: [PATCH] gpt: add new repair function to sync up primary and backup
3 files changed, 142 insertions(+)

diff --git a/grub-core/lib/gpt.c b/grub-core/lib/gpt.c
index 43a150942..2d61df488 100644
index 43a1509..2d61df4 100644
--- a/grub-core/lib/gpt.c
+++ b/grub-core/lib/gpt.c
@@ -31,6 +31,20 @@ GRUB_MOD_LICENSE ("GPLv3+");
Expand Down Expand Up @@ -119,7 +119,7 @@ index 43a150942..2d61df488 100644
grub_gpt_free (grub_gpt_t gpt)
{
diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
index 451b02a89..f367fe50d 100644
index 21ea08d..b45acbd 100644
--- a/include/grub/gpt_partition.h
+++ b/include/grub/gpt_partition.h
@@ -141,6 +141,9 @@ grub_gpt_sector_to_addr (grub_gpt_t gpt, grub_uint64_t sector)
Expand All @@ -133,7 +133,7 @@ index 451b02a89..f367fe50d 100644

grub_err_t grub_gpt_pmbr_check (struct grub_msdos_partition_mbr *mbr);
diff --git a/tests/gpt_unit_test.c b/tests/gpt_unit_test.c
index 4d70868af..83198bebf 100644
index 4d70868..83198be 100644
--- a/tests/gpt_unit_test.c
+++ b/tests/gpt_unit_test.c
@@ -24,6 +24,7 @@
Expand Down Expand Up @@ -212,3 +212,6 @@ index 4d70868af..83198bebf 100644
+ grub_test_unregister ("gpt_repair_test");
grub_fini_all ();
}
--
2.21.3

Loading