Accepting request 962679 from Base:System
OBS-URL: https://build.opensuse.org/request/show/962679 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=262
This commit is contained in:
commit
757cee2c64
110
0001-grub-probe-Deduplicate-probed-partmap-output.patch
Normal file
110
0001-grub-probe-Deduplicate-probed-partmap-output.patch
Normal file
@ -0,0 +1,110 @@
|
||||
From ed0ac581ad3866197fc05c7cf48e39419a51f606 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Fri, 18 Mar 2022 13:19:33 +0800
|
||||
Subject: [PATCH] grub-probe: Deduplicate probed partmap output
|
||||
|
||||
If the target device being probed is staked on top of other physical or logical
|
||||
devices, all containing device's partition map type will be printed once if
|
||||
--target=partmap is used. This usually results in duplicated output as same
|
||||
partition map type.
|
||||
|
||||
This in turn may clutter grub.cfg with many duplicated insmod part_[a-z]+ if
|
||||
the /boot is RAIDed because --target=partmap output is used to producing
|
||||
partmap modules required to access disk device.
|
||||
|
||||
Let's deduplicate that to make the grub.cfg looks better and disciplined.
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
util/grub-probe.c | 59 +++++++++++++++++++++++++++++++++++++++++++----
|
||||
1 file changed, 55 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/util/grub-probe.c b/util/grub-probe.c
|
||||
index c08e46bbb..fb94f28fd 100644
|
||||
--- a/util/grub-probe.c
|
||||
+++ b/util/grub-probe.c
|
||||
@@ -153,6 +153,50 @@ do_print (const char *x, void *data)
|
||||
grub_printf ("%s%c", x, delim);
|
||||
}
|
||||
|
||||
+static int
|
||||
+check_duplicate_partmap (const char *name)
|
||||
+{
|
||||
+ static int alloc, used;
|
||||
+ static char **partmaps;
|
||||
+ int i;
|
||||
+
|
||||
+ if (!name)
|
||||
+ {
|
||||
+ if (partmaps)
|
||||
+ {
|
||||
+ for (i= 0; i < used; ++i)
|
||||
+ free (partmaps[i]);
|
||||
+ free (partmaps);
|
||||
+ partmaps = NULL;
|
||||
+ alloc = 0;
|
||||
+ used = 0;
|
||||
+ }
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ for (i= 0; i < used; ++i)
|
||||
+ if (strcmp (partmaps[i], name) == 0)
|
||||
+ return 1;
|
||||
+
|
||||
+ if (alloc <= used)
|
||||
+ {
|
||||
+ alloc = (alloc) ? (alloc << 1) : 4;
|
||||
+ partmaps = xrealloc (partmaps, alloc * sizeof (*partmaps));
|
||||
+ }
|
||||
+
|
||||
+ partmaps[used++] = strdup (name);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+do_print_partmap (const char *x, void *data)
|
||||
+{
|
||||
+ char delim = *(const char *) data;
|
||||
+ if (check_duplicate_partmap (x) != 0)
|
||||
+ return;
|
||||
+ grub_printf ("%s%c", x, delim);
|
||||
+}
|
||||
+
|
||||
static void
|
||||
probe_partmap (grub_disk_t disk, char delim)
|
||||
{
|
||||
@@ -165,10 +209,14 @@ probe_partmap (grub_disk_t disk, char delim)
|
||||
}
|
||||
|
||||
for (part = disk->partition; part; part = part->parent)
|
||||
- printf ("%s%c", part->partmap->name, delim);
|
||||
+ {
|
||||
+ if (check_duplicate_partmap (part->partmap->name) != 0)
|
||||
+ continue;
|
||||
+ printf ("%s%c", part->partmap->name, delim);
|
||||
+ }
|
||||
|
||||
if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID)
|
||||
- grub_diskfilter_get_partmap (disk, do_print, &delim);
|
||||
+ grub_diskfilter_get_partmap (disk, do_print_partmap, &delim);
|
||||
|
||||
/* In case of LVM/RAID, check the member devices as well. */
|
||||
if (disk->dev->disk_memberlist)
|
||||
@@ -674,8 +722,11 @@ probe (const char *path, char **device_names, char delim)
|
||||
probe_cryptodisk_uuid (dev->disk, delim);
|
||||
|
||||
else if (print == PRINT_PARTMAP)
|
||||
- /* Check if dev->disk itself is contained in a partmap. */
|
||||
- probe_partmap (dev->disk, delim);
|
||||
+ {
|
||||
+ /* Check if dev->disk itself is contained in a partmap. */
|
||||
+ probe_partmap (dev->disk, delim);
|
||||
+ check_duplicate_partmap (NULL);
|
||||
+ }
|
||||
|
||||
else if (print == PRINT_PARTUUID)
|
||||
{
|
||||
--
|
||||
2.35.1
|
||||
|
86
0001-mkimage-Fix-dangling-pointer-may-be-used-error.patch
Normal file
86
0001-mkimage-Fix-dangling-pointer-may-be-used-error.patch
Normal file
@ -0,0 +1,86 @@
|
||||
From a0fcb7f7075901aa12079c39a534837755652d9d Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Wed, 16 Mar 2022 14:17:32 +0800
|
||||
Subject: [PATCH 1/3] mkimage: Fix dangling pointer may be used error
|
||||
|
||||
The warning is real as long as dangling pointer to 'tmp_' may be used if
|
||||
o32 and o64 are both null. However that is not going to happen and can
|
||||
be ignored safely because the PE_OHDR is being used in a context that
|
||||
either o32 or o64 must have been properly initialized. Sadly compiler
|
||||
seems not to always optimize that unused _tmp away so explicit
|
||||
suppression remain needed here.
|
||||
|
||||
../util/mkimage.c: In function 'grub_install_generate_image':
|
||||
../util/mkimage.c:1422:41: error: dangling pointer to 'tmp_' may be used [-Werror=dangling-pointer=]
|
||||
1422 | PE_OHDR (o32, o64, header_size) = grub_host_to_target32 (header_size);
|
||||
../util/mkimage.c:857:28: note: 'tmp_' declared here
|
||||
857 | __typeof__((o64)->field) tmp_; \
|
||||
| ^~~~
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
util/mkimage.c | 21 +++++++++++++++++++++
|
||||
1 file changed, 21 insertions(+)
|
||||
|
||||
diff --git a/util/mkimage.c b/util/mkimage.c
|
||||
index 5a8021a213..659824c140 100644
|
||||
--- a/util/mkimage.c
|
||||
+++ b/util/mkimage.c
|
||||
@@ -1419,6 +1419,10 @@ grub_install_generate_image (const char *dir, const char *prefix,
|
||||
section = (struct grub_pe32_section_table *)(o64 + 1);
|
||||
}
|
||||
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wdangling-pointer"
|
||||
+#endif
|
||||
PE_OHDR (o32, o64, header_size) = grub_host_to_target32 (header_size);
|
||||
PE_OHDR (o32, o64, entry_addr) = grub_host_to_target32 (layout.start_address);
|
||||
PE_OHDR (o32, o64, image_base) = 0;
|
||||
@@ -1438,6 +1442,9 @@ grub_install_generate_image (const char *dir, const char *prefix,
|
||||
/* The sections. */
|
||||
PE_OHDR (o32, o64, code_base) = grub_host_to_target32 (vma);
|
||||
PE_OHDR (o32, o64, code_size) = grub_host_to_target32 (layout.exec_size);
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
section = init_pe_section (image_target, section, ".text",
|
||||
&vma, layout.exec_size,
|
||||
image_target->section_align,
|
||||
@@ -1447,10 +1454,17 @@ grub_install_generate_image (const char *dir, const char *prefix,
|
||||
GRUB_PE32_SCN_MEM_READ);
|
||||
|
||||
scn_size = ALIGN_UP (layout.kernel_size - layout.exec_size, GRUB_PE32_FILE_ALIGNMENT);
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wdangling-pointer"
|
||||
+#endif
|
||||
/* ALIGN_UP (sbat_size, GRUB_PE32_FILE_ALIGNMENT) is done earlier. */
|
||||
PE_OHDR (o32, o64, data_size) = grub_host_to_target32 (scn_size + sbat_size +
|
||||
ALIGN_UP (total_module_size,
|
||||
GRUB_PE32_FILE_ALIGNMENT));
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
|
||||
section = init_pe_section (image_target, section, ".data",
|
||||
&vma, scn_size, image_target->section_align,
|
||||
@@ -1481,8 +1495,15 @@ grub_install_generate_image (const char *dir, const char *prefix,
|
||||
}
|
||||
|
||||
scn_size = layout.reloc_size;
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Wdangling-pointer"
|
||||
+#endif
|
||||
PE_OHDR (o32, o64, base_relocation_table.rva) = grub_host_to_target32 (vma);
|
||||
PE_OHDR (o32, o64, base_relocation_table.size) = grub_host_to_target32 (scn_size);
|
||||
+#if __GNUC__ >= 12
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
memcpy (pe_img + raw_data, layout.reloc_section, scn_size);
|
||||
init_pe_section (image_target, section, ".reloc",
|
||||
&vma, scn_size, image_target->section_align,
|
||||
--
|
||||
2.34.1
|
||||
|
533
0002-Fix-Werror-array-bounds-array-subscript-0-is-outside.patch
Normal file
533
0002-Fix-Werror-array-bounds-array-subscript-0-is-outside.patch
Normal file
@ -0,0 +1,533 @@
|
||||
From 04de53cb4adc0ae6429b0715c3f1dd8a62ff9a0f Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Wed, 16 Mar 2022 17:05:01 +0800
|
||||
Subject: [PATCH 2/3] Fix -Werror=array-bounds array subscript 0 is outside
|
||||
array bounds
|
||||
|
||||
The grub is failing to build with gcc-12 in many places like this:
|
||||
|
||||
In function 'init_cbfsdisk',
|
||||
inlined from 'grub_mod_init' at ../../grub-core/fs/cbfs.c:391:3:
|
||||
../../grub-core/fs/cbfs.c:345:7: error: array subscript 0 is outside array bounds of 'grub_uint32_t[0]' {aka 'unsigned int[]'} [-Werror=array-bounds]
|
||||
345 | ptr = *(grub_uint32_t *) 0xfffffffc;
|
||||
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This is caused by gcc regression in 11/12 [1]. In a nut shell, the
|
||||
warning is about detected invalid accesses at non-zero offsets to null
|
||||
pointers. Since hardwired constant address is treated as NULL plus an
|
||||
offset in the same underlying code, the warning is therefore triggered.
|
||||
|
||||
Instead of inserting #pragma all over the places where literal pointers
|
||||
are accessed to avoid diagnosing array-bounds, we can try to borrow the
|
||||
idea from linux kernel that the absolute_pointer macro [2][3] is used to
|
||||
disconnect a pointer using literal address from it's original object,
|
||||
hence gcc won't be able to make assumptions on the boundary while doing
|
||||
pointer arithmetic. With that we can greatly reduce the code we have to
|
||||
cover up by making initial literal pointer assignment to use the new
|
||||
wrapper but not having to track everywhere literal pointers are
|
||||
accessed. This also makes code looks cleaner.
|
||||
|
||||
[1]
|
||||
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
|
||||
[2]
|
||||
https://elixir.bootlin.com/linux/v5.16.14/source/include/linux/compiler.h#L180
|
||||
[3]
|
||||
https://elixir.bootlin.com/linux/v5.16.14/source/include/linux/compiler-gcc.h#L31
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
grub-core/bus/cs5536.c | 4 ++--
|
||||
grub-core/commands/acpi.c | 4 ++--
|
||||
grub-core/commands/efi/loadbios.c | 9 +++++----
|
||||
grub-core/commands/i386/pc/drivemap.c | 9 ++++++---
|
||||
grub-core/commands/i386/pc/sendkey.c | 12 ++++++------
|
||||
grub-core/disk/i386/pc/biosdisk.c | 4 ++--
|
||||
grub-core/fs/cbfs.c | 2 +-
|
||||
grub-core/kern/i386/pc/acpi.c | 4 ++--
|
||||
grub-core/kern/i386/pc/mmap.c | 2 +-
|
||||
grub-core/loader/i386/multiboot_mbi.c | 2 +-
|
||||
grub-core/loader/multiboot_mbi2.c | 4 ++--
|
||||
grub-core/mmap/i386/pc/mmap.c | 26 +++++++++++++-------------
|
||||
grub-core/net/drivers/i386/pc/pxe.c | 12 ++++++------
|
||||
grub-core/term/i386/pc/console.c | 5 ++---
|
||||
grub-core/term/i386/pc/vga_text.c | 6 +++---
|
||||
grub-core/term/ns8250.c | 7 ++++++-
|
||||
grub-core/video/i386/pc/vbe.c | 6 +++---
|
||||
include/grub/compiler.h | 11 +++++++++++
|
||||
18 files changed, 74 insertions(+), 55 deletions(-)
|
||||
|
||||
diff --git a/grub-core/bus/cs5536.c b/grub-core/bus/cs5536.c
|
||||
index bb9aa27e5b..bccaeeeccb 100644
|
||||
--- a/grub-core/bus/cs5536.c
|
||||
+++ b/grub-core/bus/cs5536.c
|
||||
@@ -331,8 +331,8 @@ grub_cs5536_init_geode (grub_pci_device_t dev)
|
||||
|
||||
{
|
||||
volatile grub_uint32_t *oc;
|
||||
- oc = grub_pci_device_map_range (dev, 0x05022000,
|
||||
- GRUB_CS5536_USB_OPTION_REGS_SIZE);
|
||||
+ oc = grub_absolute_pointer (grub_pci_device_map_range (dev, 0x05022000,
|
||||
+ GRUB_CS5536_USB_OPTION_REGS_SIZE));
|
||||
|
||||
oc[GRUB_CS5536_USB_OPTION_REG_UOCMUX] =
|
||||
(oc[GRUB_CS5536_USB_OPTION_REG_UOCMUX]
|
||||
diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
|
||||
index 1215f2a62e..4721730b39 100644
|
||||
--- a/grub-core/commands/acpi.c
|
||||
+++ b/grub-core/commands/acpi.c
|
||||
@@ -168,7 +168,7 @@ grub_acpi_create_ebda (void)
|
||||
struct grub_acpi_rsdp_v10 *v1;
|
||||
struct grub_acpi_rsdp_v20 *v2;
|
||||
|
||||
- ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4);
|
||||
+ ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)grub_absolute_pointer(0x40e))) << 4);
|
||||
grub_dprintf ("acpi", "EBDA @%p\n", ebda);
|
||||
if (ebda)
|
||||
ebda_kb_len = *(grub_uint16_t *) ebda;
|
||||
@@ -298,7 +298,7 @@ grub_acpi_create_ebda (void)
|
||||
*target = 0;
|
||||
|
||||
grub_dprintf ("acpi", "Switching EBDA\n");
|
||||
- (*((grub_uint16_t *) 0x40e)) = ((grub_addr_t) targetebda) >> 4;
|
||||
+ (*((grub_uint16_t *) grub_absolute_pointer(0x40e))) = ((grub_addr_t) targetebda) >> 4;
|
||||
grub_dprintf ("acpi", "EBDA switched\n");
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
diff --git a/grub-core/commands/efi/loadbios.c b/grub-core/commands/efi/loadbios.c
|
||||
index 5c7725f8bd..574e410466 100644
|
||||
--- a/grub-core/commands/efi/loadbios.c
|
||||
+++ b/grub-core/commands/efi/loadbios.c
|
||||
@@ -46,7 +46,7 @@ enable_rom_area (void)
|
||||
grub_uint32_t *rom_ptr;
|
||||
grub_pci_device_t dev = { .bus = 0, .device = 0, .function = 0};
|
||||
|
||||
- rom_ptr = (grub_uint32_t *) VBIOS_ADDR;
|
||||
+ rom_ptr = grub_absolute_pointer (VBIOS_ADDR);
|
||||
if (*rom_ptr != BLANK_MEM)
|
||||
{
|
||||
grub_puts_ (N_("ROM image is present."));
|
||||
@@ -96,8 +96,8 @@ fake_bios_data (int use_rom)
|
||||
void *acpi, *smbios;
|
||||
grub_uint16_t *ebda_seg_ptr, *low_mem_ptr;
|
||||
|
||||
- ebda_seg_ptr = (grub_uint16_t *) EBDA_SEG_ADDR;
|
||||
- low_mem_ptr = (grub_uint16_t *) LOW_MEM_ADDR;
|
||||
+ ebda_seg_ptr = grub_absolute_pointer (EBDA_SEG_ADDR);
|
||||
+ low_mem_ptr = grub_absolute_pointer (LOW_MEM_ADDR);
|
||||
if ((*ebda_seg_ptr) || (*low_mem_ptr))
|
||||
return;
|
||||
|
||||
@@ -132,7 +132,8 @@ fake_bios_data (int use_rom)
|
||||
*ebda_seg_ptr = FAKE_EBDA_SEG;
|
||||
*low_mem_ptr = (FAKE_EBDA_SEG >> 6);
|
||||
|
||||
- *((grub_uint16_t *) (FAKE_EBDA_SEG << 4)) = 640 - *low_mem_ptr;
|
||||
+ /* *((grub_uint16_t *) (FAKE_EBDA_SEG << 4)) = 640 - *low_mem_ptr; */
|
||||
+ *((grub_uint16_t *) (grub_absolute_pointer (FAKE_EBDA_SEG << 4))) = 640 - *low_mem_ptr;
|
||||
|
||||
if (acpi)
|
||||
grub_memcpy ((char *) ((FAKE_EBDA_SEG << 4) + 16), acpi, 1024 - 16);
|
||||
diff --git a/grub-core/commands/i386/pc/drivemap.c b/grub-core/commands/i386/pc/drivemap.c
|
||||
index 7f7f2d41c0..6a4d923613 100644
|
||||
--- a/grub-core/commands/i386/pc/drivemap.c
|
||||
+++ b/grub-core/commands/i386/pc/drivemap.c
|
||||
@@ -31,9 +31,6 @@
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
-/* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
|
||||
-static grub_uint32_t *const int13slot = (grub_uint32_t *) (4 * 0x13);
|
||||
-
|
||||
/* Remember to update enum opt_idxs accordingly. */
|
||||
static const struct grub_arg_option options[] = {
|
||||
/* TRANSLATORS: In this file "mapping" refers to a change GRUB makes so if
|
||||
@@ -280,6 +277,9 @@ install_int13_handler (int noret __attribute__ ((unused)))
|
||||
grub_uint8_t *handler_base = 0;
|
||||
/* Address of the map within the deployed bundle. */
|
||||
int13map_node_t *handler_map;
|
||||
+ /* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
|
||||
+ grub_uint32_t *int13slot = (grub_uint32_t *) grub_absolute_pointer (4 * 0x13);
|
||||
+
|
||||
|
||||
int i;
|
||||
int entries = 0;
|
||||
@@ -354,6 +354,9 @@ install_int13_handler (int noret __attribute__ ((unused)))
|
||||
static grub_err_t
|
||||
uninstall_int13_handler (void)
|
||||
{
|
||||
+ /* Real mode IVT slot (seg:off far pointer) for interrupt 0x13. */
|
||||
+ grub_uint32_t *int13slot = (grub_uint32_t *) grub_absolute_pointer (4 * 0x13);
|
||||
+
|
||||
if (! grub_drivemap_oldhandler)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
diff --git a/grub-core/commands/i386/pc/sendkey.c b/grub-core/commands/i386/pc/sendkey.c
|
||||
index 26d9acd3de..532a66497f 100644
|
||||
--- a/grub-core/commands/i386/pc/sendkey.c
|
||||
+++ b/grub-core/commands/i386/pc/sendkey.c
|
||||
@@ -216,12 +216,12 @@ static grub_err_t
|
||||
grub_sendkey_postboot (void)
|
||||
{
|
||||
/* For convention: pointer to flags. */
|
||||
- grub_uint32_t *flags = (grub_uint32_t *) 0x417;
|
||||
+ grub_uint32_t *flags = grub_absolute_pointer (0x417);
|
||||
|
||||
*flags = oldflags;
|
||||
|
||||
- *((char *) 0x41a) = 0x1e;
|
||||
- *((char *) 0x41c) = 0x1e;
|
||||
+ *((char *) grub_absolute_pointer (0x41a)) = 0x1e;
|
||||
+ *((char *) grub_absolute_pointer (0x41c)) = 0x1e;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
@@ -231,13 +231,13 @@ static grub_err_t
|
||||
grub_sendkey_preboot (int noret __attribute__ ((unused)))
|
||||
{
|
||||
/* For convention: pointer to flags. */
|
||||
- grub_uint32_t *flags = (grub_uint32_t *) 0x417;
|
||||
+ grub_uint32_t *flags = grub_absolute_pointer (0x417);
|
||||
|
||||
oldflags = *flags;
|
||||
|
||||
/* Set the sendkey. */
|
||||
- *((char *) 0x41a) = 0x1e;
|
||||
- *((char *) 0x41c) = keylen + 0x1e;
|
||||
+ *((char *) grub_absolute_pointer (0x41a)) = 0x1e;
|
||||
+ *((char *) grub_absolute_pointer (0x41c)) = keylen + 0x1e;
|
||||
grub_memcpy ((char *) 0x41e, sendkey, 0x20);
|
||||
|
||||
/* Transform "any ctrl" to "right ctrl" flag. */
|
||||
diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c
|
||||
index 8ca250c77b..89746ed940 100644
|
||||
--- a/grub-core/disk/i386/pc/biosdisk.c
|
||||
+++ b/grub-core/disk/i386/pc/biosdisk.c
|
||||
@@ -367,7 +367,7 @@ grub_biosdisk_open (const char *name, grub_disk_t disk)
|
||||
if (version)
|
||||
{
|
||||
struct grub_biosdisk_drp *drp
|
||||
- = (struct grub_biosdisk_drp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ = (struct grub_biosdisk_drp *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
|
||||
/* Clear out the DRP. */
|
||||
grub_memset (drp, 0, sizeof (*drp));
|
||||
@@ -654,7 +654,7 @@ grub_disk_biosdisk_fini (void)
|
||||
GRUB_MOD_INIT(biosdisk)
|
||||
{
|
||||
struct grub_biosdisk_cdrp *cdrp
|
||||
- = (struct grub_biosdisk_cdrp *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ = (struct grub_biosdisk_cdrp *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
grub_uint8_t boot_drive;
|
||||
|
||||
if (grub_disk_firmware_is_tainted)
|
||||
diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c
|
||||
index 581215ef18..8ab7106afb 100644
|
||||
--- a/grub-core/fs/cbfs.c
|
||||
+++ b/grub-core/fs/cbfs.c
|
||||
@@ -342,7 +342,7 @@ init_cbfsdisk (void)
|
||||
grub_uint32_t ptr;
|
||||
struct cbfs_header *head;
|
||||
|
||||
- ptr = *(grub_uint32_t *) 0xfffffffc;
|
||||
+ ptr = *((grub_uint32_t *) grub_absolute_pointer (0xfffffffc));
|
||||
head = (struct cbfs_header *) (grub_addr_t) ptr;
|
||||
grub_dprintf ("cbfs", "head=%p\n", head);
|
||||
|
||||
diff --git a/grub-core/kern/i386/pc/acpi.c b/grub-core/kern/i386/pc/acpi.c
|
||||
index 297f5d05f3..0a69eba7b5 100644
|
||||
--- a/grub-core/kern/i386/pc/acpi.c
|
||||
+++ b/grub-core/kern/i386/pc/acpi.c
|
||||
@@ -27,7 +27,7 @@ grub_machine_acpi_get_rsdpv1 (void)
|
||||
grub_uint8_t *ebda, *ptr;
|
||||
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
|
||||
- ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
|
||||
+ ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) grub_absolute_pointer (0x40e))) << 4);
|
||||
ebda_len = * (grub_uint16_t *) ebda;
|
||||
if (! ebda_len) /* FIXME do we really need this check? */
|
||||
goto scan_bios;
|
||||
@@ -55,7 +55,7 @@ grub_machine_acpi_get_rsdpv2 (void)
|
||||
grub_uint8_t *ebda, *ptr;
|
||||
|
||||
grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n");
|
||||
- ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4);
|
||||
+ ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) grub_absolute_pointer (0x40e))) << 4);
|
||||
ebda_len = * (grub_uint16_t *) ebda;
|
||||
if (! ebda_len) /* FIXME do we really need this check? */
|
||||
goto scan_bios;
|
||||
diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c
|
||||
index c0c3c35858..a4a1a75af4 100644
|
||||
--- a/grub-core/kern/i386/pc/mmap.c
|
||||
+++ b/grub-core/kern/i386/pc/mmap.c
|
||||
@@ -143,7 +143,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
|
||||
{
|
||||
grub_uint32_t cont = 0;
|
||||
struct grub_machine_mmap_entry *entry
|
||||
- = (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ = (struct grub_machine_mmap_entry *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
int e820_works = 0;
|
||||
|
||||
while (1)
|
||||
diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c
|
||||
index a67d9d0a80..434e694ffb 100644
|
||||
--- a/grub-core/loader/i386/multiboot_mbi.c
|
||||
+++ b/grub-core/loader/i386/multiboot_mbi.c
|
||||
@@ -293,7 +293,7 @@ fill_vbe_info (struct multiboot_info *mbi, grub_uint8_t *ptrorig,
|
||||
struct grub_vbe_mode_info_block *mode_info;
|
||||
#if GRUB_MACHINE_HAS_VBE
|
||||
grub_vbe_status_t status;
|
||||
- void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ void *scratch = grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
|
||||
status = grub_vbe_bios_get_controller_info (scratch);
|
||||
if (status != GRUB_VBE_STATUS_OK)
|
||||
diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
|
||||
index 9a943d7bdd..2ad210e7f9 100644
|
||||
--- a/grub-core/loader/multiboot_mbi2.c
|
||||
+++ b/grub-core/loader/multiboot_mbi2.c
|
||||
@@ -504,7 +504,7 @@ static void
|
||||
fill_vbe_tag (struct multiboot_tag_vbe *tag)
|
||||
{
|
||||
grub_vbe_status_t status;
|
||||
- void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ void *scratch = grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
|
||||
tag->type = MULTIBOOT_TAG_TYPE_VBE;
|
||||
tag->size = 0;
|
||||
@@ -577,7 +577,7 @@ retrieve_video_parameters (grub_properly_aligned_t **ptrorig)
|
||||
#if defined (GRUB_MACHINE_PCBIOS)
|
||||
{
|
||||
grub_vbe_status_t status;
|
||||
- void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ void *scratch = grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
status = grub_vbe_bios_get_mode (scratch);
|
||||
vbe_mode = *(grub_uint32_t *) scratch;
|
||||
if (status != GRUB_VBE_STATUS_OK)
|
||||
diff --git a/grub-core/mmap/i386/pc/mmap.c b/grub-core/mmap/i386/pc/mmap.c
|
||||
index 6ab4f67309..b9c5b0a002 100644
|
||||
--- a/grub-core/mmap/i386/pc/mmap.c
|
||||
+++ b/grub-core/mmap/i386/pc/mmap.c
|
||||
@@ -80,13 +80,13 @@ preboot (int noreturn __attribute__ ((unused)))
|
||||
= min (grub_mmap_get_post64 (), 0xfc000000ULL) >> 16;
|
||||
|
||||
/* Correct BDA. */
|
||||
- *((grub_uint16_t *) 0x413) = grub_mmap_get_lower () >> 10;
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x413)) = grub_mmap_get_lower () >> 10;
|
||||
|
||||
/* Save old interrupt handlers. */
|
||||
- grub_machine_mmaphook_int12offset = *((grub_uint16_t *) 0x48);
|
||||
- grub_machine_mmaphook_int12segment = *((grub_uint16_t *) 0x4a);
|
||||
- grub_machine_mmaphook_int15offset = *((grub_uint16_t *) 0x54);
|
||||
- grub_machine_mmaphook_int15segment = *((grub_uint16_t *) 0x56);
|
||||
+ grub_machine_mmaphook_int12offset = *((grub_uint16_t *) grub_absolute_pointer (0x48));
|
||||
+ grub_machine_mmaphook_int12segment = *((grub_uint16_t *) grub_absolute_pointer (0x4a));
|
||||
+ grub_machine_mmaphook_int15offset = *((grub_uint16_t *) grub_absolute_pointer (0x54));
|
||||
+ grub_machine_mmaphook_int15segment = *((grub_uint16_t *) grub_absolute_pointer (0x56));
|
||||
|
||||
grub_dprintf ("mmap", "hooktarget = %p\n", hooktarget);
|
||||
|
||||
@@ -94,11 +94,11 @@ preboot (int noreturn __attribute__ ((unused)))
|
||||
grub_memcpy (hooktarget, &grub_machine_mmaphook_start,
|
||||
&grub_machine_mmaphook_end - &grub_machine_mmaphook_start);
|
||||
|
||||
- *((grub_uint16_t *) 0x4a) = ((grub_addr_t) hooktarget) >> 4;
|
||||
- *((grub_uint16_t *) 0x56) = ((grub_addr_t) hooktarget) >> 4;
|
||||
- *((grub_uint16_t *) 0x48) = &grub_machine_mmaphook_int12
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x4a)) = ((grub_addr_t) hooktarget) >> 4;
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x56)) = ((grub_addr_t) hooktarget) >> 4;
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x48)) = &grub_machine_mmaphook_int12
|
||||
- &grub_machine_mmaphook_start;
|
||||
- *((grub_uint16_t *) 0x54) = &grub_machine_mmaphook_int15
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x54)) = &grub_machine_mmaphook_int15
|
||||
- &grub_machine_mmaphook_start;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
@@ -108,10 +108,10 @@ static grub_err_t
|
||||
preboot_rest (void)
|
||||
{
|
||||
/* Restore old interrupt handlers. */
|
||||
- *((grub_uint16_t *) 0x48) = grub_machine_mmaphook_int12offset;
|
||||
- *((grub_uint16_t *) 0x4a) = grub_machine_mmaphook_int12segment;
|
||||
- *((grub_uint16_t *) 0x54) = grub_machine_mmaphook_int15offset;
|
||||
- *((grub_uint16_t *) 0x56) = grub_machine_mmaphook_int15segment;
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x48)) = grub_machine_mmaphook_int12offset;
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x4a)) = grub_machine_mmaphook_int12segment;
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x54)) = grub_machine_mmaphook_int15offset;
|
||||
+ *((grub_uint16_t *) grub_absolute_pointer (0x56)) = grub_machine_mmaphook_int15segment;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c
|
||||
index 3f4152d036..313ed250e8 100644
|
||||
--- a/grub-core/net/drivers/i386/pc/pxe.c
|
||||
+++ b/grub-core/net/drivers/i386/pc/pxe.c
|
||||
@@ -174,7 +174,7 @@ grub_pxe_recv (struct grub_net_card *dev __attribute__ ((unused)))
|
||||
grub_uint8_t *ptr, *end;
|
||||
struct grub_net_buff *buf;
|
||||
|
||||
- isr = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ isr = (void *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
|
||||
if (!in_progress)
|
||||
{
|
||||
@@ -256,11 +256,11 @@ grub_pxe_send (struct grub_net_card *dev __attribute__ ((unused)),
|
||||
struct grub_pxe_undi_tbd *tbd;
|
||||
char *buf;
|
||||
|
||||
- trans = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ trans = (void *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
grub_memset (trans, 0, sizeof (*trans));
|
||||
- tbd = (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 128);
|
||||
+ tbd = (void *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 128);
|
||||
grub_memset (tbd, 0, sizeof (*tbd));
|
||||
- buf = (void *) (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 256);
|
||||
+ buf = (void *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 256);
|
||||
grub_memcpy (buf, pack->data, pack->tail - pack->data);
|
||||
|
||||
trans->tbd = SEGOFS ((grub_addr_t) tbd);
|
||||
@@ -287,7 +287,7 @@ static grub_err_t
|
||||
grub_pxe_open (struct grub_net_card *dev __attribute__ ((unused)))
|
||||
{
|
||||
struct grub_pxe_undi_open *ou;
|
||||
- ou = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ ou = (void *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
grub_memset (ou, 0, sizeof (*ou));
|
||||
ou->pkt_filter = 4;
|
||||
grub_pxe_call (GRUB_PXENV_UNDI_OPEN, ou, pxe_rm_entry);
|
||||
@@ -382,7 +382,7 @@ GRUB_MOD_INIT(pxe)
|
||||
if (! pxenv)
|
||||
return;
|
||||
|
||||
- ui = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ ui = (void *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
grub_memset (ui, 0, sizeof (*ui));
|
||||
grub_pxe_call (GRUB_PXENV_UNDI_GET_INFORMATION, ui, pxe_rm_entry);
|
||||
|
||||
diff --git a/grub-core/term/i386/pc/console.c b/grub-core/term/i386/pc/console.c
|
||||
index f6142a2dea..d70ee4af05 100644
|
||||
--- a/grub-core/term/i386/pc/console.c
|
||||
+++ b/grub-core/term/i386/pc/console.c
|
||||
@@ -238,12 +238,11 @@ grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||
return (regs.eax & 0xff) + (('a' - 1) | GRUB_TERM_CTRL);
|
||||
}
|
||||
|
||||
-static const struct grub_machine_bios_data_area *bios_data_area =
|
||||
- (struct grub_machine_bios_data_area *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
|
||||
-
|
||||
static int
|
||||
grub_console_getkeystatus (struct grub_term_input *term __attribute__ ((unused)))
|
||||
{
|
||||
+ const struct grub_machine_bios_data_area *bios_data_area =
|
||||
+ (struct grub_machine_bios_data_area *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR);
|
||||
/* conveniently GRUB keystatus is modelled after BIOS one. */
|
||||
return bios_data_area->keyboard_flag_lower & ~0x80;
|
||||
}
|
||||
diff --git a/grub-core/term/i386/pc/vga_text.c b/grub-core/term/i386/pc/vga_text.c
|
||||
index 88fecc5ea5..669d06fad7 100644
|
||||
--- a/grub-core/term/i386/pc/vga_text.c
|
||||
+++ b/grub-core/term/i386/pc/vga_text.c
|
||||
@@ -45,15 +45,15 @@ GRUB_MOD_LICENSE ("GPLv3+");
|
||||
static struct grub_term_coordinate grub_curr_pos;
|
||||
|
||||
#ifdef __mips__
|
||||
-#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb00b8000)
|
||||
+#define VGA_TEXT_SCREEN ((grub_uint16_t *) grub_absolute_pointer (0xb00b8000))
|
||||
#define cr_read grub_vga_cr_read
|
||||
#define cr_write grub_vga_cr_write
|
||||
#elif defined (MODE_MDA)
|
||||
-#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb0000)
|
||||
+#define VGA_TEXT_SCREEN ((grub_uint16_t *) grub_absolute_pointer (0xb0000))
|
||||
#define cr_read grub_vga_cr_bw_read
|
||||
#define cr_write grub_vga_cr_bw_write
|
||||
#else
|
||||
-#define VGA_TEXT_SCREEN ((grub_uint16_t *) 0xb8000)
|
||||
+#define VGA_TEXT_SCREEN ((grub_uint16_t *) grub_absolute_pointer (0xb8000))
|
||||
#define cr_read grub_vga_cr_read
|
||||
#define cr_write grub_vga_cr_write
|
||||
#endif
|
||||
diff --git a/grub-core/term/ns8250.c b/grub-core/term/ns8250.c
|
||||
index 39809d0423..622670d179 100644
|
||||
--- a/grub-core/term/ns8250.c
|
||||
+++ b/grub-core/term/ns8250.c
|
||||
@@ -28,7 +28,6 @@
|
||||
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/memory.h>
|
||||
-static const unsigned short *serial_hw_io_addr = (const unsigned short *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
|
||||
#define GRUB_SERIAL_PORT_NUM 4
|
||||
#else
|
||||
#include <grub/machine/serial.h>
|
||||
@@ -237,6 +236,9 @@ static struct grub_serial_port com_ports[GRUB_SERIAL_PORT_NUM];
|
||||
void
|
||||
grub_ns8250_init (void)
|
||||
{
|
||||
+#ifdef GRUB_MACHINE_PCBIOS
|
||||
+ const unsigned short *serial_hw_io_addr = (const unsigned short *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR);
|
||||
+#endif
|
||||
unsigned i;
|
||||
for (i = 0; i < GRUB_SERIAL_PORT_NUM; i++)
|
||||
if (serial_hw_io_addr[i])
|
||||
@@ -272,6 +274,9 @@ grub_ns8250_init (void)
|
||||
grub_port_t
|
||||
grub_ns8250_hw_get_port (const unsigned int unit)
|
||||
{
|
||||
+#ifdef GRUB_MACHINE_PCBIOS
|
||||
+ const unsigned short *serial_hw_io_addr = (const unsigned short *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR);
|
||||
+#endif
|
||||
if (unit < GRUB_SERIAL_PORT_NUM
|
||||
&& !(dead_ports & (1 << unit)))
|
||||
return serial_hw_io_addr[unit];
|
||||
diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c
|
||||
index 68700ecda1..8c8cbf07eb 100644
|
||||
--- a/grub-core/video/i386/pc/vbe.c
|
||||
+++ b/grub-core/video/i386/pc/vbe.c
|
||||
@@ -514,7 +514,7 @@ grub_vbe_probe (struct grub_vbe_info_block *info_block)
|
||||
|
||||
/* Use low memory scratch area as temporary storage
|
||||
for VESA BIOS call. */
|
||||
- vbe_ib = (struct grub_vbe_info_block *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ vbe_ib = (struct grub_vbe_info_block *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
|
||||
/* Prepare info block. */
|
||||
grub_memset (vbe_ib, 0, sizeof (*vbe_ib));
|
||||
@@ -574,7 +574,7 @@ grub_vbe_get_preferred_mode (unsigned int *width, unsigned int *height)
|
||||
|
||||
/* Use low memory scratch area as temporary storage for VESA BIOS calls. */
|
||||
flat_panel_info = (struct grub_vbe_flat_panel_info *)
|
||||
- (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + sizeof (struct grub_video_edid_info));
|
||||
+ grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR + sizeof (struct grub_video_edid_info));
|
||||
|
||||
if (controller_info.version >= 0x200
|
||||
&& (grub_vbe_bios_get_ddc_capabilities (&ddc_level) & 0xff)
|
||||
@@ -676,7 +676,7 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
|
||||
== GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL)
|
||||
{
|
||||
struct grub_vbe_palette_data *palette
|
||||
- = (struct grub_vbe_palette_data *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
|
||||
+ = (struct grub_vbe_palette_data *) grub_absolute_pointer (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
|
||||
unsigned i;
|
||||
|
||||
/* Make sure that the BIOS can reach the palette. */
|
||||
diff --git a/include/grub/compiler.h b/include/grub/compiler.h
|
||||
index 8f3be3ae70..e159f0e292 100644
|
||||
--- a/include/grub/compiler.h
|
||||
+++ b/include/grub/compiler.h
|
||||
@@ -56,4 +56,15 @@
|
||||
# define CLANG_PREREQ(maj,min) 0
|
||||
#endif
|
||||
|
||||
+#if defined(__GNUC__)
|
||||
+# define grub_absolute_pointer(val) \
|
||||
+({ \
|
||||
+ unsigned long __ptr; \
|
||||
+ __asm__ ("" : "=r"(__ptr) : "0"((void *)(val))); \
|
||||
+ (void *) (__ptr); \
|
||||
+})
|
||||
+#else
|
||||
+# define grub_absolute_pointer(val) ((void *)(val))
|
||||
+#endif
|
||||
+
|
||||
#endif /* ! GRUB_COMPILER_HEADER */
|
||||
--
|
||||
2.34.1
|
||||
|
@ -10,12 +10,15 @@ since there is no function implemented to handle this case.
|
||||
This patch implements a function that will look into /sys/block/dm-*
|
||||
devices and search recursively inside slaves directory to find the root
|
||||
disk.
|
||||
|
||||
v2:
|
||||
Fix gcc-12 error: pointer 'device_path' may be used after 'free'
|
||||
[-Werror=use-after-free]
|
||||
|
||||
---
|
||||
grub-core/osdep/linux/ofpath.c | 64 +++++++++++++++++++++++++++++++++-
|
||||
grub-core/osdep/linux/ofpath.c | 64 ++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 63 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c
|
||||
index f2bc9fc5c..d1040c4e6 100644
|
||||
--- a/grub-core/osdep/linux/ofpath.c
|
||||
+++ b/grub-core/osdep/linux/ofpath.c
|
||||
@@ -37,6 +37,7 @@
|
||||
@ -26,7 +29,7 @@ index f2bc9fc5c..d1040c4e6 100644
|
||||
|
||||
#ifdef __sparc__
|
||||
typedef enum
|
||||
@@ -754,13 +755,74 @@ strip_trailing_digits (const char *p)
|
||||
@@ -754,13 +755,74 @@
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -75,7 +78,7 @@ index f2bc9fc5c..d1040c4e6 100644
|
||||
+ closedir (dp);
|
||||
+ }
|
||||
+ else
|
||||
+ grub_util_warn (_("cannot open directory `%s'"), device_path);
|
||||
+ grub_util_warn (_("cannot open directory `/sys/block/%s/slaves'"), curr_device);
|
||||
+ }
|
||||
+
|
||||
+ free (directory);
|
||||
@ -102,6 +105,3 @@ index f2bc9fc5c..d1040c4e6 100644
|
||||
device = get_basename (name_buf);
|
||||
devnode = strip_trailing_digits (name_buf);
|
||||
devicenode = strip_trailing_digits (device);
|
||||
--
|
||||
2.26.2
|
||||
|
||||
|
@ -0,0 +1,51 @@
|
||||
From 0b1b1666ecd98d577cb72b3f4acdbe3af2e86a84 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Chang <mchang@suse.com>
|
||||
Date: Wed, 16 Mar 2022 17:59:30 +0800
|
||||
Subject: [PATCH 3/3] reed_solomon: Fix array subscript 0 is outside array
|
||||
bounds
|
||||
|
||||
The grub_absolute_pointer() is a compound expression that can only work
|
||||
within a function. We are out of luck here when the pointer variables
|
||||
require global definition due to ATTRIBUTE_TEXT that have to use fully
|
||||
initialized global definition because of the way linkers work.
|
||||
|
||||
static gf_single_t * const gf_powx ATTRIBUTE_TEXT = (void *) 0x100000;
|
||||
|
||||
For the reason given above, use gcc diagnostic pragmas to suppress the
|
||||
array-bounds warning.
|
||||
|
||||
Signed-off-by: Michael Chang <mchang@suse.com>
|
||||
---
|
||||
grub-core/lib/reed_solomon.c | 9 +++++++++
|
||||
1 file changed, 9 insertions(+)
|
||||
|
||||
diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c
|
||||
index 467305b46a..817db6a234 100644
|
||||
--- a/grub-core/lib/reed_solomon.c
|
||||
+++ b/grub-core/lib/reed_solomon.c
|
||||
@@ -102,6 +102,11 @@ static gf_single_t errvals[256];
|
||||
static gf_single_t eqstat[65536 + 256];
|
||||
#endif
|
||||
|
||||
+#if __GNUC__ == 12
|
||||
+#pragma GCC diagnostic push
|
||||
+#pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
+#endif
|
||||
+
|
||||
static gf_single_t
|
||||
gf_mul (gf_single_t a, gf_single_t b)
|
||||
{
|
||||
@@ -319,6 +324,10 @@ decode_block (gf_single_t *ptr, grub_size_t s,
|
||||
}
|
||||
}
|
||||
|
||||
+#if __GNUC__ == 12
|
||||
+#pragma GCC diagnostic pop
|
||||
+#endif
|
||||
+
|
||||
#if !defined (STANDALONE)
|
||||
static void
|
||||
encode_block (gf_single_t *ptr, grub_size_t s,
|
||||
--
|
||||
2.34.1
|
||||
|
@ -21,15 +21,18 @@ V1:
|
||||
* Use overflow checking primitives where the arithmetic expression for
|
||||
buffer allocations may include unvalidated data
|
||||
|
||||
V2:
|
||||
* Fix gcc-12 error: the comparison will always evaluate as 'true' for the
|
||||
address of 'label' will never be NULL [-Werror=address]
|
||||
|
||||
---
|
||||
|
||||
grub-core/fs/btrfs.c | 529 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 518 insertions(+), 11 deletions(-)
|
||||
grub-core/fs/btrfs.c | 561 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
include/grub/btrfs.h | 1
|
||||
2 files changed, 544 insertions(+), 18 deletions(-)
|
||||
|
||||
Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
===================================================================
|
||||
--- grub-2.06~rc1.orig/grub-core/fs/btrfs.c
|
||||
+++ grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
--- a/grub-core/fs/btrfs.c
|
||||
+++ b/grub-core/fs/btrfs.c
|
||||
@@ -41,6 +41,9 @@
|
||||
#include <grub/crypto.h>
|
||||
#include <grub/diskfilter.h>
|
||||
@ -40,7 +43,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
@@ -79,9 +82,11 @@ struct grub_btrfs_superblock
|
||||
@@ -79,9 +82,11 @@
|
||||
grub_uint64_t generation;
|
||||
grub_uint64_t root_tree;
|
||||
grub_uint64_t chunk_tree;
|
||||
@ -54,7 +57,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
struct grub_btrfs_device this_device;
|
||||
char label[0x100];
|
||||
grub_uint8_t dummy4[0x100];
|
||||
@@ -121,6 +126,7 @@ struct grub_btrfs_data
|
||||
@@ -121,6 +126,7 @@
|
||||
grub_uint64_t exttree;
|
||||
grub_size_t extsize;
|
||||
struct grub_btrfs_extent_data *extent;
|
||||
@ -62,7 +65,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
};
|
||||
|
||||
struct grub_btrfs_chunk_item
|
||||
@@ -191,6 +197,14 @@ struct grub_btrfs_leaf_descriptor
|
||||
@@ -191,6 +197,14 @@
|
||||
} *data;
|
||||
};
|
||||
|
||||
@ -77,7 +80,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
struct grub_btrfs_time
|
||||
{
|
||||
grub_int64_t sec;
|
||||
@@ -236,6 +250,14 @@ struct grub_btrfs_extent_data
|
||||
@@ -236,6 +250,14 @@
|
||||
|
||||
#define GRUB_BTRFS_OBJECT_ID_CHUNK 0x100
|
||||
|
||||
@ -92,7 +95,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
static grub_disk_addr_t superblock_sectors[] = { 64 * 2, 64 * 1024 * 2,
|
||||
256 * 1048576 * 2, 1048576ULL * 1048576ULL * 2
|
||||
};
|
||||
@@ -1173,6 +1195,62 @@ grub_btrfs_read_logical (struct grub_btr
|
||||
@@ -1173,6 +1195,62 @@
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
@ -155,7 +158,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
static struct grub_btrfs_data *
|
||||
grub_btrfs_mount (grub_device_t dev)
|
||||
{
|
||||
@@ -1208,6 +1286,13 @@ grub_btrfs_mount (grub_device_t dev)
|
||||
@@ -1208,6 +1286,13 @@
|
||||
data->devices_attached[0].dev = dev;
|
||||
data->devices_attached[0].id = data->sblock.this_device.device_id;
|
||||
|
||||
@ -169,7 +172,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1674,6 +1759,98 @@ get_root (struct grub_btrfs_data *data,
|
||||
@@ -1674,6 +1759,98 @@
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
@ -268,7 +271,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
find_path (struct grub_btrfs_data *data,
|
||||
const char *path, struct grub_btrfs_key *key,
|
||||
grub_uint64_t *tree, grub_uint8_t *type)
|
||||
@@ -1691,14 +1868,26 @@ find_path (struct grub_btrfs_data *data,
|
||||
@@ -1691,14 +1868,26 @@
|
||||
char *origpath = NULL;
|
||||
unsigned symlinks_max = 32;
|
||||
|
||||
@ -299,7 +302,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
while (1)
|
||||
{
|
||||
while (path[0] == '/')
|
||||
@@ -1871,9 +2060,21 @@ find_path (struct grub_btrfs_data *data,
|
||||
@@ -1871,9 +2060,21 @@
|
||||
path = path_alloc = tmp;
|
||||
if (path[0] == '/')
|
||||
{
|
||||
@ -324,7 +327,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -2114,6 +2315,20 @@ grub_btrfs_read (grub_file_t file, char
|
||||
@@ -2114,6 +2315,20 @@
|
||||
data->tree, file->offset, buf, len);
|
||||
}
|
||||
|
||||
@ -345,7 +348,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
static grub_err_t
|
||||
grub_btrfs_uuid (grub_device_t device, char **uuid)
|
||||
{
|
||||
@@ -2125,15 +2340,7 @@ grub_btrfs_uuid (grub_device_t device, c
|
||||
@@ -2125,15 +2340,7 @@
|
||||
if (!data)
|
||||
return grub_errno;
|
||||
|
||||
@ -362,7 +365,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
|
||||
grub_btrfs_unmount (data);
|
||||
|
||||
@@ -2190,6 +2397,248 @@ grub_btrfs_embed (grub_device_t device _
|
||||
@@ -2190,6 +2397,248 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -395,7 +398,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, "failed to open fs");
|
||||
+ }
|
||||
+
|
||||
+ if (data->sblock.label)
|
||||
+ if (*data->sblock.label != '\0')
|
||||
+ grub_printf("Label: '%s' ", data->sblock.label);
|
||||
+ else
|
||||
+ grub_printf("Label: none ");
|
||||
@ -611,7 +614,7 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
static struct grub_fs grub_btrfs_fs = {
|
||||
.name = "btrfs",
|
||||
.fs_dir = grub_btrfs_dir,
|
||||
@@ -2205,12 +2654,88 @@ static struct grub_fs grub_btrfs_fs = {
|
||||
@@ -2205,12 +2654,88 @@
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -700,11 +703,9 @@ Index: grub-2.06~rc1/grub-core/fs/btrfs.c
|
||||
}
|
||||
+
|
||||
+// vim: si et sw=2:
|
||||
Index: grub-2.06~rc1/include/grub/btrfs.h
|
||||
===================================================================
|
||||
--- grub-2.06~rc1.orig/include/grub/btrfs.h
|
||||
+++ grub-2.06~rc1/include/grub/btrfs.h
|
||||
@@ -29,6 +29,7 @@ enum
|
||||
--- a/include/grub/btrfs.h
|
||||
+++ b/include/grub/btrfs.h
|
||||
@@ -29,6 +29,7 @@
|
||||
GRUB_BTRFS_ITEM_TYPE_ROOT_ITEM = 0x84,
|
||||
GRUB_BTRFS_ITEM_TYPE_ROOT_BACKREF = 0x90,
|
||||
GRUB_BTRFS_ITEM_TYPE_DEVICE = 0xd8,
|
||||
|
@ -1,3 +1,20 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 18 09:10:07 UTC 2022 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Fix duplicated insmod part_gpt lines in grub.cfg (bsc#1197186)
|
||||
* 0001-grub-probe-Deduplicate-probed-partmap-output.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 16 14:57:02 UTC 2022 - Michael Chang <mchang@suse.com>
|
||||
|
||||
- Fix GCC 12 build failure (bsc#1196546)
|
||||
* 0001-mkimage-Fix-dangling-pointer-may-be-used-error.patch
|
||||
* 0002-Fix-Werror-array-bounds-array-subscript-0-is-outside.patch
|
||||
* 0003-reed_solomon-Fix-array-subscript-0-is-outside-array-.patch
|
||||
- Revised
|
||||
* grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
|
||||
* 0002-ieee1275-powerpc-enables-device-mapper-discovery.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 11 09:30:05 UTC 2022 - Michael Chang <mchang@suse.com>
|
||||
|
||||
|
@ -359,6 +359,10 @@ Patch841: 0005-export-environment-at-start-up.patch
|
||||
Patch842: 0001-grub-install-bailout-root-device-probing.patch
|
||||
Patch843: 0001-RISC-V-Adjust-march-flags-for-binutils-2.38.patch
|
||||
Patch844: 0001-install-fix-software-raid1-on-esp.patch
|
||||
Patch845: 0001-mkimage-Fix-dangling-pointer-may-be-used-error.patch
|
||||
Patch846: 0002-Fix-Werror-array-bounds-array-subscript-0-is-outside.patch
|
||||
Patch847: 0003-reed_solomon-Fix-array-subscript-0-is-outside-array-.patch
|
||||
Patch848: 0001-grub-probe-Deduplicate-probed-partmap-output.patch
|
||||
|
||||
Requires: gettext-runtime
|
||||
%if 0%{?suse_version} >= 1140
|
||||
|
Loading…
Reference in New Issue
Block a user