grub: add extra patches for ieee1275/disable altivec for ppc64

Closes: #11851 [via git-merge-pr]
Signed-off-by: Jürgen Buchmüller <pullmoll@t-online.de>
This commit is contained in:
q66 2019-05-21 18:37:23 +02:00 committed by Jürgen Buchmüller
parent b965d6cd97
commit fcfba82744
No known key found for this signature in database
GPG key ID: DE55AD8DBEBB4EE8
5 changed files with 350 additions and 1 deletions

View file

@ -0,0 +1,32 @@
From 54b741317568867fc4ad801a65397d05f3ea0f59 Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Thu, 25 Sep 2014 18:41:29 -0300
Subject: Include a text attribute reset in the clear command for ppc
Always clear text attribute for clear command in order to avoid problems
after it boots.
* grub-core/term/terminfo.c: Add escape for text attribute reset
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1295255
Origin: other, https://lists.gnu.org/archive/html/grub-devel/2014-09/msg00076.html
Last-Update: 2014-09-26
Patch-Name: ieee1275-clear-reset.patch
---
grub-core/term/terminfo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c
index f0d3e3deb..7cb7909c8 100644
--- grub-core/term/terminfo.c
+++ grub-core/term/terminfo.c
@@ -151,7 +151,7 @@ grub_terminfo_set_current (struct grub_term_output *term,
/* Clear the screen. Using serial console, screen(1) only recognizes the
* ANSI escape sequence. Using video console, Apple Open Firmware
* (version 3.1.1) only recognizes the literal ^L. So use both. */
- data->cls = grub_strdup (" \e[2J");
+ data->cls = grub_strdup (" \e[2J\e[m");
data->reverse_video_on = grub_strdup ("\e[7m");
data->reverse_video_off = grub_strdup ("\e[m");
if (grub_strcmp ("ieee1275", str) == 0)

View file

@ -0,0 +1,220 @@
From 35118b5023b0d9b4e3ad82f6e15fb696ad8e2a10 Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwatson@debian.org>
Date: Tue, 28 Jan 2014 14:40:02 +0000
Subject: Port yaboot logic for various powerpc machine types
Some powerpc machines require not updating the NVRAM. This can be handled
by existing grub-install command-line options, but it's friendlier to detect
this automatically.
On chrp_ibm machines, use the nvram utility rather than nvsetenv. (This
is possibly suitable for other machines too, but that needs to be
verified.)
Forwarded: no
Last-Update: 2014-10-15
Patch-Name: install_powerpc_machtypes.patch
---
grub-core/osdep/basic/platform.c | 5 +++
grub-core/osdep/linux/platform.c | 72 ++++++++++++++++++++++++++++++
grub-core/osdep/unix/platform.c | 28 +++++++++---
grub-core/osdep/windows/platform.c | 6 +++
include/grub/util/install.h | 3 ++
util/grub-install.c | 11 +++++
6 files changed, 119 insertions(+), 6 deletions(-)
diff --git a/grub-core/osdep/basic/platform.c b/grub-core/osdep/basic/platform.c
index 4b5502aeb..2ab907976 100644
--- grub-core/osdep/basic/platform.c
+++ grub-core/osdep/basic/platform.c
@@ -24,3 +24,8 @@ grub_install_get_default_x86_platform (void)
return "i386-pc";
}
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+ return "generic";
+}
diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c
index 35f1bcc0e..9805c36d4 100644
--- grub-core/osdep/linux/platform.c
+++ grub-core/osdep/linux/platform.c
@@ -23,6 +23,7 @@
#include <grub/emu/misc.h>
#include <sys/types.h>
#include <dirent.h>
+#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
@@ -145,3 +146,74 @@ grub_install_get_default_x86_platform (void)
grub_util_info ("... not found");
return "i386-pc";
}
+
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+ FILE *fp;
+ char *buf = NULL;
+ size_t len = 0;
+ const char *machtype = "generic";
+
+ fp = grub_util_fopen ("/proc/cpuinfo", "r");
+ if (! fp)
+ return machtype;
+
+ while (getline (&buf, &len, fp) > 0)
+ {
+ if (strncmp (buf, "pmac-generation",
+ sizeof ("pmac-generation") - 1) == 0)
+ {
+ if (strstr (buf, "NewWorld"))
+ {
+ machtype = "pmac_newworld";
+ break;
+ }
+ if (strstr (buf, "OldWorld"))
+ {
+ machtype = "pmac_oldworld";
+ break;
+ }
+ }
+
+ if (strncmp (buf, "motherboard", sizeof ("motherboard") - 1) == 0 &&
+ strstr (buf, "AAPL"))
+ {
+ machtype = "pmac_oldworld";
+ break;
+ }
+
+ if (strncmp (buf, "machine", sizeof ("machine") - 1) == 0 &&
+ strstr (buf, "CHRP IBM"))
+ {
+ if (strstr (buf, "qemu"))
+ {
+ machtype = "chrp_ibm_qemu";
+ break;
+ }
+ else
+ {
+ machtype = "chrp_ibm";
+ break;
+ }
+ }
+
+ if (strncmp (buf, "platform", sizeof ("platform") - 1) == 0)
+ {
+ if (strstr (buf, "Maple"))
+ {
+ machtype = "maple";
+ break;
+ }
+ if (strstr (buf, "Cell"))
+ {
+ machtype = "cell";
+ break;
+ }
+ }
+ }
+
+ free (buf);
+ fclose (fp);
+ return machtype;
+}
diff --git a/grub-core/osdep/unix/platform.c b/grub-core/osdep/unix/platform.c
index a3fcfcaca..28cb37e15 100644
--- grub-core/osdep/unix/platform.c
+++ grub-core/osdep/unix/platform.c
@@ -212,13 +212,29 @@ grub_install_register_ieee1275 (int is_prep, const char *install_device,
else
boot_device = get_ofpathname (install_device);
- if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",
- boot_device, NULL }))
+ if (strcmp (grub_install_get_default_powerpc_machtype (), "chrp_ibm") == 0)
{
- char *cmd = xasprintf ("setenv boot-device %s", boot_device);
- grub_util_error (_("`nvsetenv' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
- cmd);
- free (cmd);
+ char *arg = xasprintf ("boot-device=%s", boot_device);
+ if (grub_util_exec ((const char * []){ "nvram",
+ "--update-config", arg, NULL }))
+ {
+ char *cmd = xasprintf ("setenv boot-device %s", boot_device);
+ grub_util_error (_("`nvram' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
+ cmd);
+ free (cmd);
+ }
+ free (arg);
+ }
+ else
+ {
+ if (grub_util_exec ((const char * []){ "nvsetenv", "boot-device",
+ boot_device, NULL }))
+ {
+ char *cmd = xasprintf ("setenv boot-device %s", boot_device);
+ grub_util_error (_("`nvsetenv' failed. \nYou will have to set `boot-device' variable manually. At the IEEE1275 prompt, type:\n %s\n"),
+ cmd);
+ free (cmd);
+ }
}
free (boot_device);
diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c
index 912269191..c30025b13 100644
--- grub-core/osdep/windows/platform.c
+++ grub-core/osdep/windows/platform.c
@@ -128,6 +128,12 @@ grub_install_get_default_x86_platform (void)
return "i386-efi";
}
+const char *
+grub_install_get_default_powerpc_machtype (void)
+{
+ return "generic";
+}
+
static void *
get_efi_variable (const wchar_t *varname, ssize_t *len)
{
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
index 5ca4811cd..9f517a1bb 100644
--- include/grub/util/install.h
+++ include/grub/util/install.h
@@ -206,6 +206,9 @@ grub_install_create_envblk_file (const char *name);
const char *
grub_install_get_default_x86_platform (void);
+const char *
+grub_install_get_default_powerpc_machtype (void);
+
void
grub_install_register_efi (grub_device_t efidir_grub_dev,
const char *efifile_path,
diff --git a/util/grub-install.c b/util/grub-install.c
index e1a0202da..70b22eec4 100644
--- util/grub-install.c
+++ util/grub-install.c
@@ -1155,7 +1155,18 @@ main (int argc, char *argv[])
if (platform == GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
{
+ const char *machtype = grub_install_get_default_powerpc_machtype ();
int is_guess = 0;
+
+ if (strcmp (machtype, "pmac_oldworld") == 0)
+ update_nvram = 0;
+ else if (strcmp (machtype, "cell") == 0)
+ update_nvram = 0;
+ else if (strcmp (machtype, "generic") == 0)
+ update_nvram = 0;
+ else if (strcmp (machtype, "chrp_ibm_qemu") == 0)
+ update_nvram = 0;
+
if (!macppcdir)
{
char *d;

View file

@ -0,0 +1,40 @@
From 7c52efa9093592ade59a986c5606450741fb8e59 Mon Sep 17 00:00:00 2001
From: Julian Andres Klode <julian.klode@canonical.com>
Date: Thu, 23 Aug 2018 13:25:30 +0200
Subject: ofnet: Initialize structs in bootpath parser
Code later on checks if variables inside the struct are
0 to see if they have been set, like if there were addresses
in the bootpath.
The variables were not initialized however, so the check
might suceed with uninitialized data, and a new interface
with random addresses has been added. This caused a weird
bug in Ubuntu, because when booting from network, we now
had two interfaces with the same name, and net_default_mac
pointed to the random one.
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1785859
Signed-off-by: Julian Andres Klode <julian.klode@canonical.com>
Patch-Name: ofnet-init-structs-in-bootpath-parser.patch
Forwarded: https://lists.gnu.org/archive/html/grub-devel/2018-08/msg00074.html
Last-Update: 2018-08-23
---
grub-core/net/drivers/ieee1275/ofnet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
index a78d164db..3a753658b 100644
--- grub-core/net/drivers/ieee1275/ofnet.c
+++ grub-core/net/drivers/ieee1275/ofnet.c
@@ -154,8 +154,8 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath,
char *equal_char = 0;
grub_size_t field_counter = 0;
- grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask;
- grub_net_link_level_address_t hw_addr;
+ grub_net_network_level_address_t client_addr = {}, gateway_addr = {}, subnet_mask = {};
+ grub_net_link_level_address_t hw_addr = {};
grub_net_interface_flags_t flags = 0;
struct grub_net_network_level_interface *inter = NULL;

View file

@ -0,0 +1,52 @@
From efc381a55124b12fc74ed8117283f11367c9372a Mon Sep 17 00:00:00 2001
From: Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Date: Thu, 25 Sep 2014 19:33:39 -0300
Subject: Disable VSX instruction
VSX bit is enabled by default for Power7 and Power8 CPU models,
so we need to disable them in order to avoid instruction exceptions.
Kernel will activate it when necessary.
* grub-core/kern/powerpc/ieee1275/startup.S: Disable VSX.
Also-By: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
Also-By: Colin Watson <cjwatson@debian.org>
Origin: other, https://lists.gnu.org/archive/html/grub-devel/2014-09/msg00078.html
Last-Update: 2015-01-27
Patch-Name: ppc64el-disable-vsx.patch
---
grub-core/kern/powerpc/ieee1275/startup.S | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/grub-core/kern/powerpc/ieee1275/startup.S b/grub-core/kern/powerpc/ieee1275/startup.S
index 21c884b43..de9a9601a 100644
--- grub-core/kern/powerpc/ieee1275/startup.S
+++ grub-core/kern/powerpc/ieee1275/startup.S
@@ -20,6 +20,8 @@
#include <grub/symbol.h>
#include <grub/offsets.h>
+#define MSR_VSX 0x80
+
.extern __bss_start
.extern _end
@@ -28,6 +30,16 @@
.globl start, _start
start:
_start:
+ _start:
+
+ /* Disable VSX instruction */
+ mfmsr 0
+ oris 0,0,MSR_VSX
+ /* The "VSX Available" bit is in the lower half of the MSR, so we
+ don't need mtmsrd, which in any case won't work in 32-bit mode. */
+ mtmsr 0
+ isync
+
li 2, 0
li 13, 0

View file

@ -1,7 +1,7 @@
# Template file for 'grub'
pkgname=grub
version=2.02
revision=4
revision=5
hostmakedepends="flex freetype-devel font-unifont-bdf"
makedepends="libusb-compat-devel ncurses-devel freetype-devel
liblzma-devel device-mapper-devel fuse-devel"
@ -50,6 +50,11 @@ do_configure() {
unset CC AS LD RANLIB CPP
CFLAGS="$CFLAGS -fno-stack-protector"
# building with altivec generates broken grub core
case "$XBPS_TARGET_MACHINE" in
ppc64*) CFLAGS="$CFLAGS -mno-altivec" ;;
esac
configure_args+=" --enable-device-mapper --enable-cache-stats --enable-nls
--enable-grub-mkfont --enable-grub-mount --disable-werror
--sbindir=/usr/bin"