Accepting request 651971 from Base:System

OBS-URL: https://build.opensuse.org/request/show/651971
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=196
This commit is contained in:
Dominique Leuenberger 2018-11-28 10:10:33 +00:00 committed by Git OBS Bridge
parent 27419df33e
commit acf5ba8f52
4 changed files with 144 additions and 0 deletions

View File

@ -0,0 +1,29 @@
From 446794de8da4329ea532cbee4ca877bcafd0e534 Mon Sep 17 00:00:00 2001
From: "David E. Box" <david.e.box@linux.intel.com>
Date: Fri, 15 Sep 2017 15:37:05 -0700
Subject: [PATCH] tsc: Change default tsc calibration method to pmtimer on EFI
systems
On efi systems, make pmtimer based tsc calibration the default over the
pit. This prevents Grub from hanging on Intel SoC systems that power gate
the pit.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
grub-core/kern/i386/tsc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: grub-2.02/grub-core/kern/i386/tsc.c
===================================================================
--- grub-2.02.orig/grub-core/kern/i386/tsc.c
+++ grub-2.02/grub-core/kern/i386/tsc.c
@@ -68,7 +68,7 @@ grub_tsc_init (void)
#ifdef GRUB_MACHINE_XEN
(void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode());
#elif defined (GRUB_MACHINE_EFI)
- (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
+ (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode());
#elif defined (GRUB_MACHINE_COREBOOT)
(void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode());
#else

View File

@ -0,0 +1,99 @@
Index: grub-2.02/grub-core/kern/ieee1275/openfw.c
===================================================================
--- grub-2.02.orig/grub-core/kern/ieee1275/openfw.c
+++ grub-2.02/grub-core/kern/ieee1275/openfw.c
@@ -592,7 +592,7 @@ grub_ieee1275_canonicalise_devname (cons
/* Check if it's a CAS reboot. If so, set the script to be executed. */
int
-grub_ieee1275_cas_reboot (char *script)
+grub_ieee1275_cas_reboot (char **script)
{
grub_uint32_t ibm_ca_support_reboot;
grub_uint32_t ibm_fw_nbr_reboots;
@@ -625,16 +625,37 @@ grub_ieee1275_cas_reboot (char *script)
if (ibm_ca_support_reboot || ibm_fw_nbr_reboots)
{
- if (! grub_ieee1275_get_property_length (options, "boot-last-label", &actual))
- {
- if (actual > 1024)
- script = grub_realloc (script, actual + 1);
- grub_ieee1275_get_property (options, "boot-last-label", script, actual,
- &actual);
- return 0;
- }
+ grub_ssize_t len;
+ char *buf;
+
+ if (grub_ieee1275_get_property_length (options, "boot-last-label", &len)
+ || len <= 0)
+ {
+ grub_dprintf ("ieee1275", "boot-last-label missing or invalid\n");
+ goto out;
+ }
+ /* The returned property string length may not include terminating null byte, and in
+ a bid to avoid out of bound access we allocate one more byte to add it back */
+ buf = grub_malloc ((grub_size_t)len + 1);
+ if (!buf)
+ {
+ grub_print_error ();
+ goto out;
+ }
+ if (grub_ieee1275_get_property (options, "boot-last-label", buf, (grub_size_t)len + 1, &actual)
+ || actual < 0)
+ {
+ grub_dprintf ("ieee1275", "error while get boot-last-label property\n");
+ grub_free (buf);
+ goto out;
+ }
+ /* Add terminating null byte */
+ buf[len] = '\0';
+ *script = buf;
+ return 0;
}
+out:
grub_ieee1275_set_boot_last_label ("");
return -1;
@@ -648,7 +669,8 @@ int grub_ieee1275_set_boot_last_label (c
grub_dprintf("ieee1275", "set boot_last_label (size: %" PRIxGRUB_SIZE ")\n", grub_strlen(text));
if (! grub_ieee1275_finddevice ("/options", &options) &&
options != (grub_ieee1275_ihandle_t) -1)
+ /* To be on the safe side, set the property string with terminating null byte */
grub_ieee1275_set_property (options, "boot-last-label", text,
- grub_strlen (text), &actual);
+ grub_strlen (text) + 1, &actual);
return 0;
}
Index: grub-2.02/grub-core/normal/main.c
===================================================================
--- grub-2.02.orig/grub-core/normal/main.c
+++ grub-2.02/grub-core/normal/main.c
@@ -281,10 +281,9 @@ grub_normal_execute (const char *config,
#ifdef GRUB_MACHINE_IEEE1275
int boot;
boot = 0;
- char *script;
+ char *script = NULL;
char *dummy[1] = { NULL };
- script = grub_malloc (1024);
- if (! grub_ieee1275_cas_reboot (script))
+ if (! grub_ieee1275_cas_reboot (&script) && script)
{
if (! grub_script_execute_new_scope (script, 0, dummy))
boot = 1;
Index: grub-2.02/include/grub/ieee1275/ieee1275.h
===================================================================
--- grub-2.02.orig/include/grub/ieee1275/ieee1275.h
+++ grub-2.02/include/grub/ieee1275/ieee1275.h
@@ -243,7 +243,7 @@ int EXPORT_FUNC(grub_ieee1275_devalias_n
void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *alias);
void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath,
struct grub_ieee1275_devalias *alias);
-int EXPORT_FUNC(grub_ieee1275_cas_reboot) (char *script);
+int EXPORT_FUNC(grub_ieee1275_cas_reboot) (char **script);
int EXPORT_FUNC(grub_ieee1275_set_boot_last_label) (const char *text);
#define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));)

View File

@ -1,3 +1,15 @@
-------------------------------------------------------------------
Mon Nov 26 06:54:34 UTC 2018 - mchang@suse.com
- Change default tsc calibration method to pmtimer on EFI (bsc#1114754)
* 0001-tsc-Change-default-tsc-calibration-method-to-pmtimer.patch
-------------------------------------------------------------------
Fri Oct 19 07:17:34 UTC 2018 - mchang@suse.com
- ieee1275: Fix double free in CAS reboot (bsc#1111955)
* grub2-ppc64-cas-fix-double-free.patch
-------------------------------------------------------------------
Thu Oct 4 06:52:58 UTC 2018 - glin@suse.com

View File

@ -223,6 +223,7 @@ Patch90: grub2-binutils2.31.patch
Patch91: grub2-msdos-fix-overflow.patch
Patch92: grub2-util-30_os-prober-multiple-initrd.patch
Patch93: grub2-getroot-support-nvdimm.patch
Patch94: 0001-tsc-Change-default-tsc-calibration-method-to-pmtimer.patch
# Btrfs snapshot booting related patches
Patch101: grub2-btrfs-01-add-ability-to-boot-from-subvolumes.patch
Patch102: grub2-btrfs-02-export-subvolume-envvars.patch
@ -261,6 +262,7 @@ Patch214: grub2-ieee1275-open-raw-mode.patch
Patch215: grub2-ppc64-cas-new-scope.patch
Patch216: 0001-ofnet-Initialize-structs-in-bootpath-parser.patch
Patch217: grub2-ieee1275-FCP-methods-for-WWPN-and-LUNs.patch
Patch218: grub2-ppc64-cas-fix-double-free.patch
Patch233: grub2-use-stat-instead-of-udevadm-for-partition-lookup.patch
Patch234: fix-grub2-use-stat-instead-of-udevadm-for-partition-lookup-with-new-glibc.patch
Patch236: grub2-efi_gop-avoid-low-resolution.patch
@ -523,6 +525,7 @@ swap partition while in resuming
%patch91 -p1
%patch92 -p1
%patch93 -p1
%patch94 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
@ -554,6 +557,7 @@ swap partition while in resuming
%patch215 -p1
%patch216 -p1
%patch217 -p1
%patch218 -p1
%patch233 -p1
%patch234 -p1
%patch236 -p1