Accepting request 460052 from Base:System

1

OBS-URL: https://build.opensuse.org/request/show/460052
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=155
This commit is contained in:
Dominique Leuenberger 2017-02-24 01:43:15 +00:00 committed by Git OBS Bridge
commit 9de2b3621f
11 changed files with 793 additions and 57 deletions

View File

@ -0,0 +1,39 @@
From 28f83642deb777cce122c3629ddbd7b44a7f95b4 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
Date: Thu, 23 Feb 2017 22:39:37 +0800
Subject: [PATCH] Revert "efi: properly terminate filepath with NULL in
chainloader"
This reverts commit ce95549cc54b5d6f494608a7c390dba3aab4fba7.
---
grub-core/loader/efi/chainloader.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
index adc8563..522a716 100644
--- a/grub-core/loader/efi/chainloader.c
+++ b/grub-core/loader/efi/chainloader.c
@@ -122,8 +122,6 @@ copy_file_path (grub_efi_file_path_device_path_t *fp,
if (*p == '/')
*p = '\\';
- /* File Path is NULL terminated */
- fp->path_name[size++] = '\0';
fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp);
}
@@ -158,10 +156,8 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename)
d = GRUB_EFI_NEXT_DEVICE_PATH (d);
}
- /* File Path is NULL terminated. Allocate space for 2 extra characters */
- /* FIXME why we split path in two components? */
file_path = grub_malloc (size
- + ((grub_strlen (dir_start) + 2)
+ + ((grub_strlen (dir_start) + 1)
* GRUB_MAX_UTF16_PER_UTF8
* sizeof (grub_efi_char16_t))
+ sizeof (grub_efi_file_path_device_path_t) * 2);
--
2.6.6

View File

@ -0,0 +1,70 @@
From: Raymund Will <rw@suse.com>
Subject: Introduce a 'read_file' sub-command.
References: bsc#892852, bsc#891946
Patch-Mainline: not yet
Needed to allow s390x-emu to be telecontrolled via LOADPARM.
---
grub-core/commands/read.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
--- a/grub-core/commands/read.c
+++ b/grub-core/commands/read.c
@@ -20,6 +20,7 @@
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/mm.h>
+#include <grub/normal.h>
#include <grub/env.h>
#include <grub/term.h>
#include <grub/types.h>
@@ -77,16 +78,49 @@ grub_cmd_read (grub_command_t cmd __attr
return 0;
}
+static grub_err_t
+grub_cmd_read_from_file (grub_command_t cmd __attribute__ ((unused)), int argc, char **args)
+{
+ char *line;
+ int i = 0;
+ grub_file_t file;
+
+ if (argc < 1)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("file name expected"));
+ if (argc < 2)
+ return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("variable name expected"));
+ file = grub_file_open (args[i++]);
+ if (! file)
+ return grub_errno;
+ while ( i < argc )
+ {
+ line = grub_file_getline (file);
+ if ( !line )
+ break;
+ grub_env_set (args[i++], line);
+ grub_free (line);
+ }
+ grub_file_close (file);
+ if (i != argc)
+ return GRUB_ERR_OUT_OF_RANGE;
+ return 0;
+}
+
static grub_command_t cmd;
+static grub_command_t cme;
GRUB_MOD_INIT(read)
{
cmd = grub_register_command ("read", grub_cmd_read,
N_("[ENVVAR]"),
N_("Set variable with user input."));
+ cme = grub_register_command ("read_file", grub_cmd_read_from_file,
+ N_("FILE ENVVAR [...]"),
+ N_("Set variable(s) with line(s) from FILE."));
}
GRUB_MOD_FINI(read)
{
grub_unregister_command (cmd);
+ grub_unregister_command (cme);
}

View File

@ -0,0 +1,103 @@
---
grub-core/loader/efi/chainloader.c | 62 +++++++++++++++++++++----------------
1 file changed, 36 insertions(+), 26 deletions(-)
Index: grub-2.02~beta2/grub-core/loader/efi/chainloader.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/loader/efi/chainloader.c
+++ grub-2.02~beta2/grub-core/loader/efi/chainloader.c
@@ -326,40 +326,41 @@ grub_secure_mode (void)
static grub_efi_boolean_t
read_header (void *data, grub_efi_uint32_t size, pe_coff_loader_image_context_t *context)
{
- grub_efi_guid_t guid = SHIM_LOCK_GUID;
- grub_efi_shim_lock_t *shim_lock;
- grub_efi_status_t status;
-
- shim_lock = grub_efi_locate_protocol (&guid, NULL);
+ char *msdos = (char *)data;
+ struct grub_pe32_header_no_msdos_stub *pe32 = (struct grub_pe32_header_no_msdos_stub *)data;
- if (!shim_lock)
+ if (size < sizeof (*pe32))
{
- grub_error (GRUB_ERR_BAD_ARGUMENT, "no shim lock protocol");
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "Invalid image");
return 0;
}
- status = shim_lock->context (data, size, context);
-
- if (status == GRUB_EFI_SUCCESS)
+ if (grub_memcmp (msdos, "MZ", 2) == 0)
{
- grub_dprintf ("chain", "context success\n");
- return 1;
+ grub_uint32_t off = *((grub_uint32_t *) (msdos + 0x3c));
+ pe32 = (struct grub_pe32_header_no_msdos_stub *) ((char *)data + off);
}
- switch (status)
+ if (grub_memcmp (pe32->signature, "PE\0\0", 4) != 0 ||
+ pe32->coff_header.machine != GRUB_PE32_MACHINE_X86_64 ||
+ pe32->optional_header.magic != GRUB_PE32_PE64_MAGIC)
{
- case GRUB_EFI_UNSUPPORTED:
- grub_error (GRUB_ERR_BAD_ARGUMENT, "context error unsupported");
- break;
- case GRUB_EFI_INVALID_PARAMETER:
- grub_error (GRUB_ERR_BAD_ARGUMENT, "context error invalid parameter");
- break;
- default:
- grub_error (GRUB_ERR_BAD_ARGUMENT, "context error code");
- break;
+ grub_error (GRUB_ERR_BAD_ARGUMENT, "Not supported image");
+ return 0;
}
- return 0;
+ context->number_of_rva_and_sizes = pe32->optional_header.num_data_directories;
+ context->size_of_headers = pe32->optional_header.header_size;
+ context->image_size = pe32->optional_header.image_size;
+ context->image_address = pe32->optional_header.image_base;
+ context->entry_point = pe32->optional_header.entry_addr;
+ context->reloc_dir = &pe32->optional_header.base_relocation_table;
+ context->sec_dir = &pe32->optional_header.certificate_table;
+ context->number_of_sections = pe32->coff_header.num_sections;
+ context->pe_hdr = pe32;
+ context->first_section = (struct grub_pe32_section_table *)((char *)(&pe32->optional_header) + pe32->coff_header.optional_header_size);
+
+ return 1;
}
static void*
@@ -623,6 +624,9 @@ error_exit:
if (buffer)
efi_call_1 (b->free_pool, buffer);
+ if (grub_errno)
+ grub_print_error ();
+
return 0;
}
@@ -845,6 +849,19 @@ grub_cmd_chainloader (grub_command_t cmd
status = efi_call_6 (b->load_image, 0, grub_efi_image_handle, file_path,
boot_image, fsize,
&image_handle);
+#ifdef SUPPORT_SECURE_BOOT
+ if (status == GRUB_EFI_SECURITY_VIOLATION && !grub_secure_mode())
+ {
+ /* If it failed with security violation while not in secure boot mode,
+ the firmware might be broken. We try to workaround on that by forcing
+ the SB method! (bsc#887793) */
+ grub_dprintf ("chain", "Possible firmware flaw! Security violation while not in secure boot mode.\n");
+ grub_file_close (file);
+ grub_loader_set (grub_secureboot_chainloader_boot,
+ grub_secureboot_chainloader_unload, 0);
+ return 0;
+ }
+#endif
if (status != GRUB_EFI_SUCCESS)
{
if (status == GRUB_EFI_OUT_OF_RESOURCES)

170
grub2-emu-4-all.patch Normal file
View File

@ -0,0 +1,170 @@
---
Makefile.util.def | 10 +++++-----
configure.ac | 1 +
grub-core/Makefile.core.def | 14 +++++---------
grub-core/osdep/unix/emuconsole.c | 5 +++--
4 files changed, 14 insertions(+), 16 deletions(-)
Index: grub-2.02~rc1/Makefile.util.def
===================================================================
--- grub-2.02~rc1.orig/Makefile.util.def
+++ grub-2.02~rc1/Makefile.util.def
@@ -352,7 +352,7 @@ program = {
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
cppflags = '-DGRUB_SETUP_FUNC=grub_util_bios_setup';
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
program = {
@@ -373,7 +373,7 @@ program = {
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
cppflags = '-DGRUB_SETUP_FUNC=grub_util_sparc_setup';
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
program = {
@@ -389,7 +389,7 @@ program = {
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
program = {
@@ -420,7 +420,7 @@ program = {
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
data = {
@@ -1345,7 +1345,7 @@ program = {
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
program = {
Index: grub-2.02~rc1/grub-core/Makefile.core.def
===================================================================
--- grub-2.02~rc1.orig/grub-core/Makefile.core.def
+++ grub-2.02~rc1/grub-core/Makefile.core.def
@@ -1057,7 +1057,7 @@ module = {
module = {
name = videotest;
common = commands/videotest.c;
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
module = {
@@ -1470,7 +1470,7 @@ module = {
common = gfxmenu/gui_progress_bar.c;
common = gfxmenu/gui_util.c;
common = gfxmenu/gui_string_util.c;
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
module = {
@@ -1886,13 +1886,13 @@ module = {
name = gfxterm;
common = term/gfxterm.c;
enable = videomodules;
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
module = {
name = gfxterm_background;
common = term/gfxterm_background.c;
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
module = {
@@ -2005,9 +2005,7 @@ module = {
enable = i386_pc;
enable = i386_efi;
enable = x86_64_efi;
- enable = emu;
enable = xen;
- emu_condition = COND_NOT_s390x;
};
module = {
@@ -2054,7 +2052,7 @@ module = {
module = {
name = gfxterm_menu;
common = tests/gfxterm_menu.c;
- emu_condition = COND_NOT_s390x;
+ emu_condition = COND_NOT_emu;
};
module = {
@@ -2205,9 +2203,7 @@ module = {
enable = i386_pc;
enable = i386_efi;
enable = x86_64_efi;
- enable = emu;
enable = xen;
- emu_condition = COND_NOT_s390x;
};
module = {
Index: grub-2.02~rc1/configure.ac
===================================================================
--- grub-2.02~rc1.orig/configure.ac
+++ grub-2.02~rc1/configure.ac
@@ -1884,6 +1884,7 @@ AC_SUBST(BUILD_LIBM)
AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone])
AM_CONDITIONAL([COND_emu], [test x$platform = xemu])
+AM_CONDITIONAL([COND_NOT_emu], [test x$platform != xemu])
AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc])
AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi])
AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi])
Index: grub-2.02~rc1/grub-core/osdep/unix/emuconsole.c
===================================================================
--- grub-2.02~rc1.orig/grub-core/osdep/unix/emuconsole.c
+++ grub-2.02~rc1/grub-core/osdep/unix/emuconsole.c
@@ -50,13 +50,12 @@ static struct termios new_tty;
static int console_mode = 0;
#define MAX_LEN 1023
-#if defined(__s390x__)
+
static int
dummy (void)
{
return 0;
}
-#endif
#if 0
static char msg[MAX_LEN+1];
static void
@@ -128,6 +127,7 @@ readkey (struct grub_term_input *term)
return -1;
}
+#if defined(__s390x__)
#define NO_KEY ((grub_uint8_t)-1)
static int
readkey_dumb (struct grub_term_input *term)
@@ -158,6 +158,7 @@ readkey_dumb (struct grub_term_input *te
p = c;
return c;
}
+#endif
static void
grub_dumb_putchar (struct grub_term_output *term,

View File

@ -8,13 +8,151 @@ use strict;
my $grub2_dir;
my $grub2_reboot;
my $grub2_editenv;
my $show_mapped;
my $id_name;
my @menuentry;
my @enumentry;
my %E;
sub parse_menuentry {
sub dPrint($) {
#print( STDERR @_[0]);
}
my ($parent, $menu) = @_;
sub sh_test($) {
my ( $exp ) = @_;
dPrint( "?? '$exp' ");
$exp .= " ]" if ( $exp =~ m{^\[.*[^\]]\s*$} ); # gnaaa
#my $t = qx{set -x; $exp};
my $t = qx{$exp};
my $ret = $? >> 8;
$ret = ($ret == 0) ? 1 : 0;
dPrint("=> $ret ($t)\n");
return $ret;
}
sub read_cfg($$) {
my ($dir, $cfg) = @_;
my $fh;
my $m = "";
my $state = 1; # 1 == normal, 010 == if-false, 011 == if-true, 110 == else-false, 111 == else-true
my @State = ();
if ($dir) {
%E = ( "config_directory" => $dir );
dPrint("# VE: 'cd'='$dir'\n");
$dir .= "/";
if ($> == 0) {
open($fh, "$grub2_editenv - list |") || die "cannot read grub2 environment: $!\n";
while (<$fh>) {
chomp;
if ( m{^([^\s=]+?)=(.*)$} ) {
my ($k, $v) = ($1, $2);
$v =~ s{^"([^"]*)"$}{$1};
dPrint("# VE: '$k'='$v'\n");
$E{$k} = $v;
}
}
close($fh);
}
}
dPrint("# open($dir$cfg)\n");
open($fh, "<$dir$cfg") || die "cannot read $cfg in $dir: $!\n";
LINE: while ( <$fh> ) {
s{^#.*$}{}; # get rid of trailing comments,
s{\s+$}{}; # trailing whitespace
s{\s*;$}{}; # including semicolons
next if (m{^\s*$}); # and empty lines.
s{^\s*}{ }; # force leading whitespace to one
dPrint(sprintf("#%d: '%s' [%s]%04b\n", $., $_, join(",",@State), $state));
if ( m{^ fi$} ) {
$state = pop( @State);
$m .= "$_\n";
dPrint(sprintf(">FI: [%s]0b%04b\n", join(",",@State), $state));
next;
}
if ($state & 0b10) { # {if,else}-*
if ( m{^ elif\s+(.*?)\s*; then$} && !($state & 0b1000)) {
if ($state & 0b1) {
$state = 0b110; # else-false
} else {
$state = 0b010 + sh_test( $1); # if-?
dPrint(sprintf("=EI: 0b%03b\n", $state));
$m .= "$_\n";
next;
}
} elsif ( m{^ else$} && !($state & 0b1000)) {
if (($state & 0b111) == 0b010) { # in 'if' but neither 'else' nor 'true'
$state = 0b111; # else-true
} else {
$state = 0b110; # else-false
}
$m .= "$_\n";
dPrint(sprintf("=EL: 0b%03b\n", $state));
next;
}
}
if ($state & 0b1) { # *-true or normal
dPrint("-I1: $_\n");
} else { # *-false
dPrint("-I0: $_\n");
if ( m{^ if (.*?)\s*; then$} ) {
push( @State, $state);
$state = 0b1000;
$m .= "$_\n";
}
next;
}
while ( m'(?:[^\\])(\$(?:{([^}]+?)}|([A-Za-z0-9_]+)))' ) {
my ($s, $k1, $k2) = ($1, $2, $3);
my $k = (defined($k1)) ? $k1 : $k2;
dPrint("# VT: '$k'\n");
if (exists( $E{$k})) {
$s =~ s{([\$\{\}\"])}{\\$1}g;
dPrint("# VB: '$_'\n");
s{$s}{$E{$k}} || die;
dPrint("# VR: '$_'\n");
} else {
$s =~ s{([\$\{\}\"])}{\\$1}g;
s{$s}{} || die;
dPrint("# VR: '$_'\n");
}
}
if ( m{^ if (.*?)\s*; then$} ) {
push( @State, $state);
$state = 0b010 + sh_test( $1);
dPrint(sprintf("<IF: 0b%03b [%s]\n", $state, join (",", @State)));
} elsif ( m{^ (?:set\s+)?([^\s=]+?)=(.*)$} ) {
my ($k, $v) = ($1, $2);
$v =~ s{^"([^"]*)"$}{$1};
dPrint("# VA: '$k'='$v'\n");
$E{$k} = $v;
} elsif ( m{^ source\s+(\S+)$} ) {
my $f = $1;
$f =~ s{^"([^"]+)"$}{$1} &&
dPrint("# f='$f'\n");
if ( -r $f ) {
$m .= read_cfg("", $f);
}
next;
}
$m .= "$_\n";
}
close ($fh);
return ($m);
}
sub parse_menuentry($$$) {
my ($parent, $pId, $menu) = @_;
my $c = 0;
my @m = $menu =~ /(submenu|menuentry) \s+ (.*?) ( \{ (?: [^{}]* | (?3))* \} )/sxg;
for (my $i = 0; $i <= $#m; $i += 3) {
@ -23,11 +161,13 @@ sub parse_menuentry {
my $title = `printf "%s\n" $m[$i+1] | head -1 | tr -d '\n'`;
my $data = $m[$i+2];
my $name = ($parent) ? "$parent>$title" : "$title";
my $eId = (($pId ne "") ? "$pId>" : "") . $c++;
if ($type eq "menuentry") {
push @menuentry, $name;
push @enumentry, [$name, $eId];
} elsif ($type eq "submenu") {
&parse_menuentry ($name, $data);
parse_menuentry ($name, $eId, $data);
}
}
}
@ -67,6 +207,7 @@ while (<SYSCONF>) {
if ($bl eq "grub2" || $bl eq "grub2-efi") {
$grub2_dir = "/boot/grub2";
$grub2_reboot = "/usr/sbin/grub2-reboot";
$grub2_editenv = "/usr/bin/grub2-editenv";
}
last;
}
@ -83,26 +224,22 @@ if ($id_name eq "--help" or $id_name eq "-h")
die "no grub2_dir" if ($grub2_dir eq "");
open(MENU, "<$grub2_dir/grub.cfg") || die "cannot read grub.cfg in $grub2_dir: $!\n";
undef $/;
while (<MENU>) {
&parse_menuentry ("", $_);
}
close (MENU);
if (open(MENU, "<$grub2_dir/custom.cfg")) {
while (<MENU>) {
&parse_menuentry ("", $_);
}
close (MENU);
}
my $m = read_cfg( $grub2_dir, "grub.cfg");
# Note: only *one* top-level call to parse_menuentry() is possible
# or else it will start again with 0 (and no parent)!
parse_menuentry ("", "", $m);
my $ret = "";
my $name = "";
my $id = -1;
if ($id_name eq '--enum') {
foreach my $e (@enumentry) {
printf "%-7s %s\n", $e->[1], $e->[0];
}
exit 0;
}
if ($id_name eq '--list')
{
my $c = 0;
@ -151,4 +288,4 @@ if ($show_mapped > 0) {
system "$grub2_reboot \"$name\"";
enable_restore_grubenv_service;
}

View File

@ -41,6 +41,10 @@ V13:
* dracut-grub2.sh: provide /boot from above to grub2-emu in chroot.
V14:
* grub2-zipl-setup: actually remove obsolete kernel/initrds. [bnc#892810]
V15:
* zipl2grub.conf: turn of zipl-prompt and quiescent plymouth. [bsc#898198]
V16:
* dracut-grub2.sh: force read-only '/usr' for kexec. [bsc#932951]
---
Makefile.util.def | 39 +++
@ -52,11 +56,11 @@ V14:
include/grub/util/install.h | 4
util/grub-install-common.c | 1
util/grub-install.c | 43 +++
util/s390x/dracut-grub2.sh.in | 106 ++++++++
util/s390x/dracut-grub2.sh.in | 110 +++++++++
util/s390x/dracut-module-setup.sh.in | 19 +
util/s390x/zipl2grub.conf.in | 26 ++
util/s390x/zipl2grub.pl.in | 424 +++++++++++++++++++++++++++++++++++
13 files changed, 698 insertions(+), 4 deletions(-)
13 files changed, 702 insertions(+), 4 deletions(-)
Index: grub-2.02~rc1/Makefile.util.def
===================================================================
@ -86,15 +90,23 @@ Index: grub-2.02~rc1/Makefile.util.def
};
program = {
@@ -402,6 +405,7 @@ program = {
@@ -417,6 +420,7 @@ program = {
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
+ emu_condition = COND_NOT_s390x;
};
program = {
@@ -697,6 +701,38 @@ script = {
data = {
@@ -628,6 +632,7 @@ program = {
common = grub-core/disk/host.c;
common = util/resolve.c;
+ emu_condition = COND_s390x;
common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c;
@@ -697,6 +702,38 @@ script = {
};
script = {
@ -133,7 +145,7 @@ Index: grub-2.02~rc1/Makefile.util.def
name = grub-mkconfig_lib;
common = util/grub-mkconfig_lib.in;
installdir = noinst;
@@ -1292,6 +1328,7 @@ program = {
@@ -1308,6 +1345,7 @@ program = {
ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
@ -457,7 +469,7 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in
===================================================================
--- /dev/null
+++ grub-2.02~rc1/util/s390x/dracut-grub2.sh.in
@@ -0,0 +1,106 @@
@@ -0,0 +1,110 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
@ -466,12 +478,14 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in
+if getargbool 0 initgrub && [ ! -e /grub2skip ] || [ -e /grub2force ]; then
+ #type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+ checkro() {
+ local tgt="$1"
+ local dev mp fs opts dc
+ local rofs=false
+ local rofs=true
+ while read dev mp fs opts dc; do
+ [ "$mp" = "/sysroot" ] || continue
+ [ "$mp" = "$tgt" ] || continue
+ case ",$opts," in
+ (*,ro,*) rofs=true;;
+ (*) rofs=false;;
+ esac
+ done < /proc/mounts
+ echo $rofs
@ -513,9 +527,9 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in
+ bindir=@bindir@
+ if [ -e /sysroot$bindir/grub2-emu ]; then
+
+
+ export TERM=$(getterm)
+ export grub2rofs=$(checkro)
+ export grub2rofs=$(checkro /sysroot)
+ export grub2roufs=$(checkro /sysroot/usr)
+ export grub2sysfs=$(checkd /sysroot/sys/devices/system/memory)
+ export grub2procfs=$(checkd /sysroot/proc/self)
+ export grub2bootfs=$(checkboot)
@ -540,6 +554,7 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in
+
+ CTTY="$CTTY --wait"
+ $grub2rofs || mount -o remount,ro /sysroot
+ $grub2roufs || mount -o remount,ro /sysroot/usr
+ $grub2sysfs || mount --bind {,/sysroot}/sys
+ $grub2procfs || mount --bind {,/sysroot}/proc
+ $grub2bootfs || mount --bind {,/sysroot}/boot
@ -558,6 +573,7 @@ Index: grub-2.02~rc1/util/s390x/dracut-grub2.sh.in
+ $grub2bootfs || umount /sysroot/boot
+ $grub2procfs || umount /sysroot/proc
+ $grub2sysfs || umount /sysroot/sys
+ $grub2roufs || mount -o remount,rw /sysroot/usr
+ $grub2rofs || mount -o remount,rw /sysroot
+ else
+ info "No $bindir/grub2-emu in /sysroot--trying to proceed without kexec..."
@ -603,7 +619,7 @@ Index: grub-2.02~rc1/util/s390x/zipl2grub.conf.in
+ target = @zipldir@
+ ramdisk = @zipldir@/initrd,0x2000000
+ image = @zipldir@/image
+ parameters = "root=@GRUB_DEVICE@ @GRUB_EMU_CONMODE@ @GRUB_CMDLINE_LINUX@ @GRUB_CMDLINE_LINUX_DEFAULT@ initgrub quiet splash=silent "
+ parameters = "root=@GRUB_DEVICE@ @GRUB_EMU_CONMODE@ @GRUB_CMDLINE_LINUX@ @GRUB_CMDLINE_LINUX_DEFAULT@ initgrub quiet splash=silent plymouth.enable=0 "
+
+[skip-grub2]
+ target = @zipldir@
@ -615,7 +631,7 @@ Index: grub-2.02~rc1/util/s390x/zipl2grub.conf.in
+ target = @zipldir@
+ timeout = 16
+ default = 1
+ prompt = 1
+ prompt = 0
+ 1 = grub2
+ 2 = skip-grub2
+

View File

@ -0,0 +1,47 @@
From: Raymund Will <rw@suse.com>
Subject: Allow s390x-emu to telecontrolled by LOADPARM
References: bsc#892852, bsc#891946
Patch-Mainline: no
---
util/grub.d/00_header.in | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
Index: grub-2.02~beta3/util/grub.d/00_header.in
===================================================================
--- grub-2.02~beta3.orig/util/grub.d/00_header.in
+++ grub-2.02~beta3/util/grub.d/00_header.in
@@ -52,6 +52,33 @@ if [ "\${env_block}" ] ; then
fi
EOF
+if [ "`uname -m`" = "s390x" ]; then
+ cat <<EOF
+if [ ! "\$sys_loadparm" ]; then
+ set sys_loadparm=/sys/firmware/ipl/loadparm
+fi
+while [ -f "\$sys_loadparm" ]; do
+ unset loadparm
+ read_file "\$sys_loadparm" loadparm
+ if [ ! "\${loadparm}" ]; then break; fi
+ unset z_gp # extract grub part
+ regexp -s 2:z_gp '^([^Gg]*)[Gg](.+)$' "\$loadparm"
+ if [ ! "\$z_gp" ]; then break; fi
+ while true; do
+ unset z_1
+ unset z_2 # remap zIPL-compatible "." to grub's '>'
+ regexp -s 1:z_1 -s 2:z_2 '^([0-9][0-9>]*)\.([0-9][0-9.]*)$' "\$z_gp"
+ if [ ! "\$z_1" -o ! "\$z_2" ]; then break; fi
+ set z_gp="\$z_1>\$z_2"
+ done
+ if [ ! "\$z_gp" ]; then break; fi
+ set next_entry="\$z_gp"
+ unset z_gp
+ unset loadparm
+ break
+done
+EOF
+fi
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
cat <<EOF
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then

View File

@ -0,0 +1,41 @@
--- grub-2.02~beta2.orig/util/s390x/zipl2grub.pl.in 2015-09-15 07:29:51.473202000 -0600
+++ grub-2.02~beta2/util/s390x/zipl2grub.pl.in 2015-09-15 07:34:12.559142000 -0600
@@ -7,6 +7,9 @@ my $in = '@sysconfdir@/default/zipl2grub
my $default = '@sysconfdir@/default/grub';
my $fallback = '@sysconfdir@/zipl.conf';
my $sysconfbl = '@sysconfdir@/sysconfig/bootloader';
+my $defimage = "/boot/image";
+my $definitrd = "/boot/initrd";
+my $Image = "$defimage";
my $zipldir = "";
my $running = "";
my $refresh = 1; # needs to default to "on" until most bugs are shaken out!
@@ -166,7 +169,7 @@ sub Usage($) {
my $msg = "";
$msg .= sprintf( "%s: %s\n", $C, $cat[$_[0]]) if ($_[0] > 0);
- $msg .= "Usage: $C [-v] [-d] [-f] [-T template] [-z ZIPLDIR]\n";
+ $msg .= "Usage: $C [-v] [-d] [-f] [-T template] [-z ZIPLDIR] [-i imagepath]\n";
Panic( $_[0], $msg . "\n");
}
@@ -184,6 +187,7 @@ while ( $#ARGV >= 0 ) {
(/^--?help/ || /^-h/) && (Usage(0));
(/^--zipldir$/ || /^-z$/) && ($zipldir = shift || Usage(2), next);
(/^--template$/ || /^-T$/) && ($in = shift || Usage(3), next);
+ (/^--image$/ || /^-i$/) && ($Image = shift || Usage(5), $force = 1, next);
(/^-/) && (Usage(1));
Usage(1);
}
@@ -379,11 +383,8 @@ if ( ! $debug ) {
}
# copy out kernel and initrd
-my $defimage = "/boot/image";
-my $definitrd = "/boot/initrd";
my $ziplimage = "$zipldir/image";
my $ziplinitrd = "$zipldir/initrd";
-my $Image = "$defimage";
if ( ! $running && ! $force ) {
chomp( $running = qx{uname -r});

View File

@ -0,0 +1,15 @@
Index: grub-2.02~beta2/grub-core/osdep/linux/getroot.c
===================================================================
--- grub-2.02~beta2.orig/grub-core/osdep/linux/getroot.c
+++ grub-2.02~beta2/grub-core/osdep/linux/getroot.c
@@ -713,6 +713,10 @@ grub_util_part_to_disk (const char *os_d
if (! realpath (os_dev, path))
return NULL;
+#ifdef __s390x__
+ return path;
+#endif
+
if (strncmp ("/dev/", path, 5) == 0)
{
char *p = path + 5;

View File

@ -1,3 +1,46 @@
-------------------------------------------------------------------
Thu Feb 23 15:06:44 UTC 2017 - mchang@suse.com
- Temporary fix for openQA UEFI USB Boot failure (bsc#1026344)
* 0001-Revert-efi-properly-terminate-filepath-with-NULL-in-.patch
-------------------------------------------------------------------
Fri Feb 17 06:46:11 UTC 2017 - mchang@suse.com
- grub2.spec: fix s390x file list.
-------------------------------------------------------------------
Wed Feb 15 07:25:02 UTC 2017 - mchang@suse.com
- Merge changes from SLE12
- add grub2-emu-4-all.patch
* Build 'grub2-emu' wherever possible, to allow a better
implementation of that feature.
- add grub2-s390x-06-loadparm.patch,
- add grub2-commands-introduce-read_file-subcommand.patch:
* allow s390x to telecontrol grub2. (bsc#891946, bsc#892852)
- add grub2-s390x-06-loadparm.patch:
* ignore case and fix transliteration of parameter. (bsc#891946)
- add grub2-s390x-07-add-image-param-for-zipl-setup.patch
* Add --image switch to force zipl update to specific kernel
(bsc#928131)
- add grub2-s390x-08-workaround-part-to-disk.patch
* Ignore partition tables on s390x. (bsc#935127)
- add grub2-efi-chainload-harder.patch:
* allow XEN to be chain-loaded despite firmware flaws. (bnc#887793)
* Do not use shim lock protocol for reading pe header, it won't be
available when secure boot disabled (bsc#943380)
* Make firmware flaw condition be more precisely detected and add
debug message for the case
* Check msdos header to find PE file header (bsc#954126)
- grub2-s390x-04-grub2-install.patch:
* streamline boot to grub menu. (bsc#898198)
* Force '/usr' to read-only before calling kexec. (bsc#932951)
- grub2-once:
* add '--enum' option to enumerate boot-entries in a way
actually understood by 'grub2'. (bsc#892852, bsc#892811)
* Examine variables from grub environment in 'grub2-once'. (fate#319632)
-------------------------------------------------------------------
Fri Feb 10 17:58:22 UTC 2017 - arvidjaar@gmail.com

View File

@ -64,9 +64,14 @@ BuildRequires: update-bootloader-rpm-macros
# Modules code is dynamically loaded and collected from a _fixed_ path.
%define _libdir %{_exec_prefix}/lib
# Build grub2-emu everywhere (it may be "required" by 'grub2-once')
%define emu 1
%ifarch ppc ppc64 ppc64le
%define grubcpu powerpc
%define platform ieee1275
# emu does not build here yet... :-(
%define emu 0
%endif
%ifarch %{ix86} x86_64
@ -84,15 +89,18 @@ BuildRequires: update-bootloader-rpm-macros
%define platform uboot
%endif
%ifarch aarch64
%define grubcpu arm64
%define platform efi
%define only_efi 1
%endif
%define grubarch %{grubcpu}-%{platform}
# build efi bootloader on some platforms only:
%if ! 0%{?efi:1}
%global efi %{ix86} x86_64 ia64 aarch64 %{arm}
%endif
%ifarch aarch64
%define only_efi 1
%endif
%ifarch %{efi}
%ifarch %{ix86}
@ -118,6 +126,11 @@ BuildRequires: update-bootloader-rpm-macros
%define grubxenarch x86_64-xen
%endif
%if %{platform} == emu
# force %{emu} to 1, e.g. for s390
%define emu 1
%endif
%if 0%{?suse_version} == 1110
%define only_efi %{nil}
%define only_x86_64 %{nil}
@ -187,6 +200,13 @@ Patch70: grub2-default-distributor.patch
Patch71: grub2-menu-unrestricted.patch
Patch72: grub2-mkconfig-arm.patch
Patch74: grub2-accept-empty-module.patch
Patch75: grub2-s390x-06-loadparm.patch
Patch76: grub2-s390x-07-add-image-param-for-zipl-setup.patch
Patch77: grub2-s390x-08-workaround-part-to-disk.patch
Patch78: grub2-commands-introduce-read_file-subcommand.patch
Patch79: grub2-efi-chainload-harder.patch
Patch80: grub2-emu-4-all.patch
Patch81: 0001-Revert-efi-properly-terminate-filepath-with-NULL-in-.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
@ -280,6 +300,7 @@ Requires: %{name} = %{version}-%{release}
%description branding-upstream
Upstream branding for GRUB2's graphical console
%if ! 0%{?only_efi:1}
%package %{grubarch}
Summary: Bootloader with support for Linux, Multiboot and more
@ -309,6 +330,8 @@ bootloader with modular architecture. It supports rich variety of kernel format
file systems, computer architectures and hardware devices. This subpackage
provides support for %{platform} systems.
%endif
%ifarch %{efi}
%package %{grubefiarch}
@ -433,6 +456,13 @@ swap partition while in resuming
%patch71 -p1
%patch72 -p1
%patch74 -p1
%patch75 -p1
%patch76 -p1
%patch77 -p1
%patch78 -p1
%patch79 -p1
%patch80 -p1
%patch81 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
@ -487,6 +517,9 @@ mkdir build-efi
%ifarch %{ix86} x86_64
mkdir build-xen
%endif
%if %{emu}
mkdir build-emu
%endif
%build
# autogen calls autoreconf -vi
@ -502,6 +535,28 @@ CXXFLAGS=" "
FFLAGS=" "
export CFLAGS CXXFLAGS FFLAGS
%if %{emu}
cd build-emu
%define arch_specific --enable-device-mapper --disable-grub-mount
TFLAGS="-fPIC"
# -static is needed so that autoconf script is able to link
# test that looks for _start symbol on 64 bit platforms
../configure TARGET_LDFLAGS=$TFLAGS \
--prefix=%{_prefix} \
--sysconfdir=%{_sysconfdir} \
--target=%{_target_platform} \
--with-platform=emu \
%{arch_specific} \
--program-transform-name=s,grub,%{name},
make %{?_smp_mflags}
cd ..
if [ "%{platform}" = "emu" ]; then
rmdir build
mv build-emu build
fi
%endif
%ifarch %{ix86} x86_64
cd build-xen
../configure \
@ -593,13 +648,9 @@ cd build
%define _target_platform i386-%{_vendor}-%{_target_os}%{?_gnu}
%endif
%ifarch s390x
%define arch_specific --enable-device-mapper --disable-grub-mount
TFLAGS="-fPIC"
%else
%if %{platform} != "emu"
%define arch_specific --enable-device-mapper
TFLAGS="-static"
%endif
# -static is needed so that autoconf script is able to link
# test that looks for _start symbol on 64 bit platforms
@ -612,6 +663,8 @@ TFLAGS="-static"
--program-transform-name=s,grub,%{name},
make %{?_smp_mflags}
%endif
cd ..
%endif
%install
@ -651,10 +704,17 @@ cd ..
%if ! 0%{?only_efi:1}
cd build
make DESTDIR=$RPM_BUILD_ROOT install
%else
cd build-efi
cd ..
%endif
if [ -d build-emu/grub-core ]; then
cd build-emu/grub-core
install -m 755 grub-emu $RPM_BUILD_ROOT%{_bindir}/%{name}-emu
install -m 755 grub-emu-lite $RPM_BUILD_ROOT%{_bindir}/%{name}-emu-lite
install -m 644 grub-emu.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{name}-emu.1
cd ../..
fi
# *.module files are installed with executable bits due to the way grub2 build
# system works. Clear executable bits to not confuse find-debuginfo.sh
find $RPM_BUILD_ROOT%{_libdir}/%{name} \
@ -878,16 +938,11 @@ if [ $1 = 0 ]; then
fi
%endif
fi
%if 0%{?only_efi:1}
%define source_dir build-efi
%else
%define source_dir build
%endif
%postun
%service_del_postun grub2-once.service
%files -f %{source_dir}/%{name}.lang
%files -f %{name}.lang
%defattr(-,root,root,-)
%doc COPYING NEWS README
%doc THANKS TODO ChangeLog
@ -917,7 +972,6 @@ fi
%{_bindir}/%{name}-editenv
%{_bindir}/%{name}-file
%{_bindir}/%{name}-fstest
%{_bindir}/%{name}-glue-efi
%{_bindir}/%{name}-kbdcomp
%{_bindir}/%{name}-menulst2cfg
%{_bindir}/%{name}-mkfont
@ -930,6 +984,7 @@ fi
%{_bindir}/%{name}-mkstandalone
%{_bindir}/%{name}-render-label
%{_bindir}/%{name}-script-check
%{_bindir}/%{name}-syslinux2cfg
%if 0%{?has_systemd:1}
%{_unitdir}/grub2-once.service
%endif
@ -945,7 +1000,6 @@ fi
%{_mandir}/man1/%{name}-editenv.1.*
%{_mandir}/man1/%{name}-file.1.*
%{_mandir}/man1/%{name}-fstest.1.*
%{_mandir}/man1/%{name}-glue-efi.1.*
%{_mandir}/man1/%{name}-kbdcomp.1.*
%{_mandir}/man1/%{name}-menulst2cfg.1.*
%{_mandir}/man1/%{name}-mkfont.1.*
@ -958,29 +1012,30 @@ fi
%{_mandir}/man1/%{name}-mkstandalone.1.*
%{_mandir}/man1/%{name}-render-label.1.*
%{_mandir}/man1/%{name}-script-check.1.*
%{_mandir}/man1/%{name}-syslinux2cfg.1.*
%{_mandir}/man8/%{name}-install.8.*
%{_mandir}/man8/%{name}-mkconfig.8.*
%{_mandir}/man8/%{name}-probe.8.*
%{_mandir}/man8/%{name}-reboot.8.*
%{_mandir}/man8/%{name}-set-default.8.*
%ifarch s390x
%{_bindir}/%{name}-emu
%{_bindir}/%{name}-emu-lite
%if %{emu}
%{_bindir}/%{name}-emu*
%{_mandir}/man1/%{name}-emu.1.*
%else
%endif
%ifnarch s390x
%config %{_sysconfdir}/grub.d/30_os-prober
%{_bindir}/%{name}-glue-efi
%{_bindir}/%{name}-mount
%{_bindir}/%{name}-syslinux2cfg
%{_sbindir}/%{name}-bios-setup
%{_sbindir}/%{name}-macbless
%{_sbindir}/%{name}-ofpathname
%{_sbindir}/%{name}-sparc64-setup
%{_mandir}/man1/%{name}-glue-efi.1.*
%{_mandir}/man1/%{name}-mount.1.*
%{_mandir}/man8/%{name}-bios-setup.8.*
%{_mandir}/man8/%{name}-macbless.8.*
%{_mandir}/man8/%{name}-ofpathname.8.*
%{_mandir}/man8/%{name}-sparc64-setup.8.*
%{_mandir}/man1/%{name}-syslinux2cfg.1.*
%endif
%files branding-upstream