Rebased to newer upstream for fedora-28

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2018-03-16 16:41:23 -04:00
parent dd1f245e52
commit b65b645183
9 changed files with 325 additions and 36 deletions

View File

@ -1,4 +1,4 @@
From 1954221a4b99a4f83500b4a52e41e68b7ca7c4cc Mon Sep 17 00:00:00 2001
From 775dacceb8acc4036737080040f592f48daeb6e8 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 6 Nov 2017 18:31:56 -0500
Subject: [PATCH 210/216] make better backtraces
@ -8,16 +8,16 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
grub-core/Makefile.core.def | 15 ++--
grub-core/{lib => commands}/backtrace.c | 2 +-
grub-core/gdb/cstub.c | 1 -
grub-core/kern/arm64/backtrace.c | 75 ++++++++++++++++++++
grub-core/kern/arm64/backtrace.c | 94 +++++++++++++++++++++++++
grub-core/kern/backtrace.c | 95 +++++++++++++++++++++++++
grub-core/kern/dl.c | 45 ++++++++++++
grub-core/kern/i386/backtrace.c | 120 ++++++++++++++++++++++++++++++++
grub-core/kern/i386/backtrace.c | 121 ++++++++++++++++++++++++++++++++
grub-core/kern/i386/pc/init.c | 4 +-
grub-core/kern/ieee1275/init.c | 1 -
grub-core/kern/misc.c | 13 ++--
grub-core/kern/mm.c | 6 +-
grub-core/lib/arm64/backtrace.c | 62 -----------------
grub-core/lib/i386/backtrace.c | 78 ---------------------
grub-core/lib/arm64/backtrace.c | 62 ----------------
grub-core/lib/i386/backtrace.c | 78 --------------------
include/grub/backtrace.h | 10 ++-
include/grub/dl.h | 2 +
include/grub/kernel.h | 3 +
@ -28,7 +28,7 @@ Signed-off-by: Peter Jones <pjones@redhat.com>
grub-core/kern/ia64/efi/startup.S | 3 +-
grub-core/kern/sparc64/ieee1275/crt0.S | 3 +-
grub-core/Makefile.am | 1 +
23 files changed, 382 insertions(+), 166 deletions(-)
23 files changed, 402 insertions(+), 166 deletions(-)
rename grub-core/{lib => commands}/backtrace.c (98%)
create mode 100644 grub-core/kern/arm64/backtrace.c
create mode 100644 grub-core/kern/backtrace.c
@ -109,10 +109,10 @@ index b64acd70fee..99281472d36 100644
diff --git a/grub-core/kern/arm64/backtrace.c b/grub-core/kern/arm64/backtrace.c
new file mode 100644
index 00000000000..70de1b29414
index 00000000000..019c6fdfef2
--- /dev/null
+++ b/grub-core/kern/arm64/backtrace.c
@@ -0,0 +1,75 @@
@@ -0,0 +1,94 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
@ -139,34 +139,53 @@ index 00000000000..70de1b29414
+#include <grub/term.h>
+#include <grub/backtrace.h>
+
+#define MAX_STACK_FRAME 102400
+
+struct fplr
+{
+ void *lr;
+ struct fplr *fp;
+};
+
+void
+grub_backtrace_pointer (void *frame, unsigned int skip)
+{
+ do
+ unsigned int x = 0;
+ struct fplr *fplr = (struct fplr *)frame;
+
+ while (fplr)
+ {
+ const char *name = NULL;
+ char *addr = NULL;
+
+ void *ret = __builtin_return_address (skip);
+ frame = __builtin_frame_address (skip);
+ if (ret)
+ ret = __builtin_extract_return_addr (ret);
+ grub_dprintf("backtrace", "fp is %p next_fp is %p\n",
+ fplr, fplr->fp);
+
+ grub_dprintf ("backtrace", "frame address:%p return address:%p\n", frame, ret);
+ if (!ret)
+ break;
+
+ name = grub_get_symbol_by_addr (ret, 1);
+ if (x >= skip)
+ {
+ name = grub_get_symbol_by_addr (fplr->lr, 1);
+ if (name)
+ addr = grub_resolve_symbol (name);
+ grub_backtrace_print_address (ret);
+ grub_backtrace_print_address (fplr->lr);
+
+ if (addr && addr != ret)
+ if (addr && addr != fplr->lr)
+ grub_printf (" %s() %p+%p \n", name ? name : "unknown", addr,
+ (char *)((char *)ret - addr));
+ (void *)((grub_uint64_t)fplr->lr - (grub_uint64_t)addr));
+ else
+ grub_printf(" %s() %p \n", name ? name : "unknown", addr);
+ } while (frame);
+
+ }
+
+ x += 1;
+
+ if (fplr->fp < fplr ||
+ (grub_uint64_t)fplr->fp - (grub_uint64_t)fplr > MAX_STACK_FRAME ||
+ fplr->fp == fplr)
+ {
+ break;
+ }
+ fplr = fplr->fp;
+ }
+}
+
+asm ("\t.global \"_text\"\n"
@ -186,7 +205,7 @@ index 00000000000..70de1b29414
+ grub_printf ("Backtrace (.text %p .data %p):\n",
+ (void *)_text, (void *)_data);
+ skip += 1;
+ grub_backtrace_pointer(__builtin_frame_address(skip), skip);
+ grub_backtrace_pointer(__builtin_frame_address(0), skip);
+}
diff --git a/grub-core/kern/backtrace.c b/grub-core/kern/backtrace.c
new file mode 100644
@ -354,10 +373,10 @@ index 621070918d4..5028d157c46 100644
i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
diff --git a/grub-core/kern/i386/backtrace.c b/grub-core/kern/i386/backtrace.c
new file mode 100644
index 00000000000..f3bb839e1d7
index 00000000000..c4f7e3f0e90
--- /dev/null
+++ b/grub-core/kern/i386/backtrace.c
@@ -0,0 +1,120 @@
@@ -0,0 +1,121 @@
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2009 Free Software Foundation, Inc.
@ -463,7 +482,8 @@ index 00000000000..f3bb839e1d7
+ skip += 1;
+#if defined (__x86_64__)
+ asm volatile ("movq %%rbp, %%rdi\n"
+ "movl %0, %%rsi\n"
+ "movq 0, %%rsi\n"
+ "movl %0, %%esi\n"
+ "call " EXT_C("grub_backtrace_pointer")
+ :
+ : "r" (skip));

View File

@ -1,4 +1,4 @@
From 82ae897af2691f21f500fb7bbee11263159236f0 Mon Sep 17 00:00:00 2001
From cc1566933cbc2d8d56aa77ab1ca8a15392ee0d42 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 9 Nov 2017 15:58:52 -0500
Subject: [PATCH 211/216] normal: don't draw our startup message if debug is

View File

@ -1,4 +1,4 @@
From dcf64d8da777158cf00dec1b663f436f3b6bed9b Mon Sep 17 00:00:00 2001
From 1829abfbbb0544a06973eaa76659a282aae8b32d Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 16 Mar 2018 13:28:57 -0400
Subject: [PATCH 212/216] Work around some minor include path weirdnesses

View File

@ -1,4 +1,4 @@
From cdf3041c33ca079b254f24c0e9262abe1efe0a57 Mon Sep 17 00:00:00 2001
From 8e15f2dce2f8b2bdcad2d35da4d068e8af44eb1d Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 25 Jun 2015 15:41:06 -0400
Subject: [PATCH 213/216] Make it possible to enabled --build-id=sha1

View File

@ -1,4 +1,4 @@
From d94879fe76b6b8199afda00c76eafcce4769e1ba Mon Sep 17 00:00:00 2001
From 29216d4ad0f75587c42274ebd63b8526fa9e815c Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Sun, 28 Jun 2015 13:09:58 -0400
Subject: [PATCH 214/216] Add grub_qdprintf() - grub_dprintf() without the

View File

@ -1,4 +1,4 @@
From 0f79e0c4c498ea5b92e5475cb8845d48369b2169 Mon Sep 17 00:00:00 2001
From bc8e33848ee9888fd8b3aa61b4d3ecf9094356aa Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Thu, 25 Jun 2015 15:11:36 -0400
Subject: [PATCH 215/216] Make a "gdb" dprintf that tells us load addresses.

265
0216-Static.patch Normal file
View File

@ -0,0 +1,265 @@
From 808b17c8d8b5a4b4744a7fa0bfe59474ca1509f3 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Fri, 16 Mar 2018 16:22:20 -0400
Subject: [PATCH 216/216] Static
---
Makefile.util.def | 7 +++
util/grub-mkconfig_lib.in | 46 ++++++++++++++++
util/grub-set-uuids.in | 134 ++++++++++++++++++++++++++++++++++++++++++++++
util/grub.d/10_linux.in | 20 ++++---
4 files changed, 199 insertions(+), 8 deletions(-)
create mode 100644 util/grub-set-uuids.in
diff --git a/Makefile.util.def b/Makefile.util.def
index fe392c24351..bbc38b894ad 100644
--- a/Makefile.util.def
+++ b/Makefile.util.def
@@ -1348,6 +1348,13 @@ script = {
installdir = sbin;
};
+script = {
+ name = grub-set-uuids;
+ common = util/grub-set-uuids.in;
+ mansection = 8;
+ installdir = sbin;
+};
+
program = {
name = grub-glue-efi;
mansection = 1;
diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in
index 70dc8d57e92..80674ef714d 100644
--- a/util/grub-mkconfig_lib.in
+++ b/util/grub-mkconfig_lib.in
@@ -128,6 +128,52 @@ EOF
fi
}
+add_device_modules ()
+{
+ local device=$1 && shift
+
+ old_ifs="$IFS"
+ IFS='
+'
+ partmap="`"${grub_probe}" --device ${device} --target=partmap`"
+ for module in ${partmap} ; do
+ case "${module}" in
+ netbsd | openbsd)
+ echo "insmod part_bsd";;
+ *)
+ echo "insmod part_${module}";;
+ esac
+ done
+
+ # Abstraction modules aren't auto-loaded.
+ abstraction="`"${grub_probe}" --device ${device} --target=abstraction`"
+ for module in ${abstraction} ; do
+ echo "insmod ${module}"
+ done
+
+ fs="`"${grub_probe}" --device ${device} --target=fs`"
+ for module in ${fs} ; do
+ echo "insmod ${module}"
+ done
+}
+
+get_device_uuid ()
+{
+ local device=$1 && shift
+ if [ "$#" -gt 0 ]; then
+ local variable=$1 && shift
+ else
+ local variable=root
+ fi
+ old_ifs="$IFS"
+ IFS='
+'
+
+ fs_uuid="`"${grub_probe}" --device ${device} --target=fs_uuid 2> /dev/null`"
+ IFS="$old_ifs"
+ echo "$fs_uuid"
+}
+
prepare_grub_to_access_device ()
{
local device=$1 && shift
diff --git a/util/grub-set-uuids.in b/util/grub-set-uuids.in
new file mode 100644
index 00000000000..72c239b4ef5
--- /dev/null
+++ b/util/grub-set-uuids.in
@@ -0,0 +1,134 @@
+#! /bin/sh
+#
+# Set a default boot entry for GRUB.
+# Copyright (C) 2004,2009 Free Software Foundation, Inc.
+#
+# GRUB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
+
+# Initialize some variables.
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+sysconfdir="@sysconfdir@"
+PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_VERSION=@PACKAGE_VERSION@
+datarootdir="@datarootdir@"
+datadir="@datadir@"
+if [ "x$pkgdatadir" = x ]; then
+ pkgdatadir="${datadir}/@PACKAGE@"
+fi
+
+self=`basename $0`
+
+grub_editenv=${bindir}/@grub_editenv@
+bootdir=`echo "/@bootdirname@" | sed 's,//*,/,g'`
+grubdir=`echo "/@bootdirname@/@grubdirname@" | sed 's,//*,/,g'`
+grubenv=""
+
+export TEXTDOMAIN=@PACKAGE@
+export TEXTDOMAINDIR="@localedir@"
+
+# Usage: usage
+# Print the usage.
+usage () {
+ gettext_printf "Usage: %s [OPTION]\n" "$self"
+ gettext "Set the boot and root UUIDs for GRUB."; echo
+ echo
+ print_option_help "-h, --help" "$(gettext "print this message and exit")"
+ print_option_help "-V, --version" "$(gettext "print the version information and exit")"
+ dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")"
+ print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg"
+ print_option_help "--grub-environment=$(gettext "FILE")" "${grubdir}/grubenv"
+ #echo
+ #gettext "Report bugs to <bug-grub@gnu.org>."; echo
+}
+
+argument () {
+ opt=$1
+ shift
+
+ if test $# -eq 0; then
+ gettext_printf "%s: option requires an argument -- \`%s'\n" "$self" "$opt" 1>&2
+ exit 1
+ fi
+ echo $1
+}
+
+# Check the arguments.
+while test $# -gt 0
+do
+ option=$1
+ shift
+
+ case "$option" in
+ -h | --help)
+ usage
+ exit 0 ;;
+ -V | --version)
+ echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}"
+ exit 0 ;;
+
+# Accept for compatibility
+ --root-directory)
+ rootdir=`argument $option "$@"`; shift ;;
+ --root-directory=*)
+ rootdir=`echo "$option" | sed 's/--root-directory=//'` ;;
+
+ --boot-directory)
+ bootdir=`argument $option "$@"`; shift;;
+ --boot-directory=*)
+ bootdir=`echo "$option" | sed 's/--boot-directory=//'` ;;
+
+ --grub-environment)
+ grubenv=`argument $option "$@"`; shift;;
+ --grub-environment=*)
+ grubenv=`echo "$option" | sed 's/--grub-environment=//'` ;;
+
+ *)
+ gettext_printf "Unrecognized option \`%s'\n" "$option" 1>&2
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [ -z "$bootdir" ]; then
+ # Default bootdir if bootdir not initialized.
+ bootdir=/@bootdirname@
+
+ if [ -n "$rootdir" ] ; then
+ # Initialize bootdir if rootdir was initialized.
+ bootdir=${rootdir}/@bootdirname@
+ fi
+fi
+
+grubdir=`echo "${bootdir}/@grubdirname@" | sed 's,//*,/,g'`
+
+if [ -z "$grubenv" ]; then
+ grubenv="${grubdir}/grubenv"
+fi
+
+# Device containing our /boot partition. Usually the same as GRUB_DEVICE.
+GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
+GRUB_DEVICE_BOOT_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE_BOOT} --target=fs_uuid 2> /dev/null`" || true
+
+# Device containing our /boot/efi partition. Usually not the same as GRUB_DEVICE.
+GRUB_DEVICE_BOOT_EFI="`${grub_probe} --target=device /boot/efi`"
+GRUB_DEVICE_BOOT_EFI_UUID_GENERATED="`${grub_probe} --device ${GRUB_DEVICE_BOOT_EFI} --target=fs_uuid 2> /dev/null`" || true
+
+$grub_editenv "${grubenv}" set "bootuuid=${GRUB_DEVICE_BOOT_EFI_UUID_GENERATED}"
+$grub_editenv "${grubenv}" set "rootuuid=${GRUB_DEVICE_BOOT_UUID_GENERATED}"
+
+# Bye.
+exit 0
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index f5daefb9d24..232f417d3e6 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -129,17 +129,21 @@ linux_entry ()
if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then
if [ x$dirname = x/ ]; then
- if [ -z "${prepare_root_cache}" ]; then
- prepare_grub_to_access_device ${GRUB_DEVICE}
- fi
+ add_device_modules "${GRUB_DEVICE}"
+ uuid="$(get_device_uuid "${GRUB_DEVICE}")"
+ ${grub_editenv} - set rootuuid="${uuid}"
else
- if [ -z "${prepare_boot_cache}" ]; then
- prepare_grub_to_access_device ${GRUB_DEVICE_BOOT}
- fi
+ add_device_modules "${GRUB_DEVICE_BOOT}"
+ uuid="$(get_device_uuid "${GRUB_DEVICE_BOOT}")"
+ ${grub_editenv} - set rootuuid="${uuid}"
fi
+ if [ -d /sys/firmware/efi/efivars ]; then
+ bootefi_device="`${grub_probe} --target=device /boot/efi/`"
+ add_device_modules ${bootefi_device}
- bootefi_device="`${grub_probe} --target=device /boot/efi/`"
- prepare_grub_to_access_device ${bootefi_device} boot
+ uuid="$(get_device_uuid "${bootefi_device}")"
+ ${grub_editenv} - set bootuuid="${uuid}"
+ fi
cat << EOF
insmod blscfg
--
2.15.0

View File

@ -213,3 +213,4 @@ Patch0212: 0212-Work-around-some-minor-include-path-weirdnesses.patch
Patch0213: 0213-Make-it-possible-to-enabled-build-id-sha1.patch
Patch0214: 0214-Add-grub_qdprintf-grub_dprintf-without-the-file-line.patch
Patch0215: 0215-Make-a-gdb-dprintf-that-tells-us-load-addresses.patch
Patch0216: 0216-Static.patch

View File

@ -7,7 +7,7 @@
Name: grub2
Epoch: 1
Version: 2.02
Release: 28%{?dist}
Release: 29%{?dist}
Summary: Bootloader with support for Linux, Multiboot and more
Group: System Environment/Base
License: GPLv3+
@ -452,6 +452,9 @@ fi
%endif
%changelog
* Fri Mar 16 2018 pjones <pjones@redhat.com> - 1:2.02-29
- Rebased to newer upstream for fedora-28
* Fri Mar 16 2018 Peter Jones <pjones@redhat.com> - 2.02-28
- Install kernel-install scripts. (javierm)
- Add grub2-switch-to-blscfg