summaryrefslogtreecommitdiffstats
path: root/meta/recipes-bsp
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-bsp')
-rw-r--r--meta/recipes-bsp/acpid/acpid.inc15
-rw-r--r--meta/recipes-bsp/acpid/acpid/0001-Replace-stat64-with-stat.patch31
-rw-r--r--meta/recipes-bsp/acpid/acpid_2.0.34.bb (renamed from meta/recipes-bsp/acpid/acpid_2.0.32.bb)3
-rw-r--r--meta/recipes-bsp/alsa-state/alsa-state.bb20
-rwxr-xr-xmeta/recipes-bsp/alsa-state/alsa-state/alsa-state-init3
-rw-r--r--meta/recipes-bsp/apmd/apmd/apmd.service7
-rw-r--r--meta/recipes-bsp/apmd/apmd/apmd_proxy91
-rw-r--r--meta/recipes-bsp/apmd/apmd/apmd_proxy.conf16
-rw-r--r--meta/recipes-bsp/apmd/apmd/default8
-rwxr-xr-xmeta/recipes-bsp/apmd/apmd/init51
-rw-r--r--meta/recipes-bsp/apmd/apmd/legacy.patch133
-rw-r--r--meta/recipes-bsp/apmd/apmd/libtool.patch33
-rw-r--r--meta/recipes-bsp/apmd/apmd/linkage.patch53
-rw-r--r--meta/recipes-bsp/apmd/apmd/unlinux.patch25
-rw-r--r--meta/recipes-bsp/apmd/apmd/wexitcode.patch26
-rw-r--r--meta/recipes-bsp/apmd/apmd_3.2.2-15.bb85
-rw-r--r--meta/recipes-bsp/efibootmgr/efibootmgr/0001-remove-extra-decl.patch31
-rw-r--r--meta/recipes-bsp/efibootmgr/efibootmgr/97668ae0bce776a36ea2001dea63d376be8274ac.patch83
-rw-r--r--meta/recipes-bsp/efibootmgr/efibootmgr_18.bb (renamed from meta/recipes-bsp/efibootmgr/efibootmgr_17.bb)9
-rw-r--r--meta/recipes-bsp/efivar/efivar/0001-docs-do-not-build-efisecdb-manpage.patch26
-rw-r--r--meta/recipes-bsp/efivar/efivar/determinism.patch18
-rw-r--r--meta/recipes-bsp/efivar/efivar/no-werror.patch18
-rw-r--r--meta/recipes-bsp/efivar/efivar_37.bb41
-rw-r--r--meta/recipes-bsp/efivar/efivar_39.bb34
-rwxr-xr-xmeta/recipes-bsp/formfactor/files/qemuppc64/machconfig10
-rw-r--r--meta/recipes-bsp/formfactor/formfactor_0.0.bb1
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi/0001-riscv64-adjust-type-definitions.patch34
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi/0001-riscv64-ignore-unknown-relocs.patch32
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi/lib-Makefile-fix-parallel-issue.patch38
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi/no-werror.patch19
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch17
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi_3.0.17.bb (renamed from meta/recipes-bsp/gnu-efi/gnu-efi_3.0.12.bb)29
-rw-r--r--meta/recipes-bsp/grub/files/0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch9
-rw-r--r--meta/recipes-bsp/grub/files/0001-RISC-V-Restore-the-typcast-to-long.patch37
-rw-r--r--meta/recipes-bsp/grub/files/0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch10
-rw-r--r--meta/recipes-bsp/grub/files/6643507ce30f775008e093580f0c9499dfb2c485.patch47
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2020-10713.patch73
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2020-14308-calloc-Use-calloc-at-most-places.patch1863
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2020-14309-CVE-2020-14310-CVE-2020-14311-malloc-Use-overflow-checking-primitives-where-we-do-.patch1330
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch117
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch177
-rw-r--r--meta/recipes-bsp/grub/files/autogen.sh-exclude-pc.patch19
-rw-r--r--meta/recipes-bsp/grub/files/calloc-Make-sure-we-always-have-an-overflow-checking.patch246
-rw-r--r--meta/recipes-bsp/grub/files/determinism.patch56
-rw-r--r--meta/recipes-bsp/grub/files/grub-module-explicitly-keeps-symbole-.module_license.patch7
-rw-r--r--meta/recipes-bsp/grub/files/lvm-Add-LVM-cache-logical-volume-handling.patch287
-rw-r--r--meta/recipes-bsp/grub/files/safemath-Add-some-arithmetic-primitives-that-check-f.patch94
-rw-r--r--meta/recipes-bsp/grub/files/script-Remove-unused-fields-from-grub_script_functio.patch37
-rw-r--r--meta/recipes-bsp/grub/grub-bootconf_1.00.bb4
-rw-r--r--meta/recipes-bsp/grub/grub-efi_2.12.bb (renamed from meta/recipes-bsp/grub/grub-efi_2.04.bb)32
-rw-r--r--meta/recipes-bsp/grub/grub2.inc52
-rw-r--r--meta/recipes-bsp/grub/grub_2.12.bb (renamed from meta/recipes-bsp/grub/grub_2.04.bb)22
-rw-r--r--meta/recipes-bsp/keymaps/files/GPLv2.patch347
-rwxr-xr-xmeta/recipes-bsp/keymaps/files/keymap.sh3
-rw-r--r--meta/recipes-bsp/keymaps/keymaps_1.0.bb16
-rw-r--r--meta/recipes-bsp/libacpi/libacpi_0.2.bb3
-rw-r--r--meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-cross-compilation-using-autoconf-detected-AR.patch2
-rw-r--r--meta/recipes-bsp/lrzsz/lrzsz-0.12.20/autotools-update.patch2
-rw-r--r--meta/recipes-bsp/lrzsz/lrzsz_0.12.20.bb5
-rw-r--r--meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch36
-rw-r--r--meta/recipes-bsp/opensbi/opensbi-payloads.inc27
-rw-r--r--meta/recipes-bsp/opensbi/opensbi_1.4.bb (renamed from meta/recipes-bsp/opensbi/opensbi_0.9.bb)23
-rw-r--r--meta/recipes-bsp/pciutils/pciutils/configure.patch49
-rw-r--r--meta/recipes-bsp/pciutils/pciutils_3.11.1.bb (renamed from meta/recipes-bsp/pciutils/pciutils_3.7.0.bb)25
-rw-r--r--meta/recipes-bsp/pm-utils/pm-utils_1.4.1.bb14
-rw-r--r--meta/recipes-bsp/setserial/setserial/0001-setserial.c-Add-needed-system-headers-for-ioctl-and-.patch41
-rw-r--r--meta/recipes-bsp/setserial/setserial_2.17.bb7
-rw-r--r--meta/recipes-bsp/u-boot/libubootenv_0.3.5.bb (renamed from meta/recipes-bsp/u-boot/libubootenv_0.3.1.bb)18
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-common.inc14
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-configure.inc40
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-tools.inc55
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-tools_2024.04.bb (renamed from meta/recipes-bsp/u-boot/u-boot-tools_2021.01.bb)1
-rw-r--r--meta/recipes-bsp/u-boot/u-boot.inc150
-rw-r--r--meta/recipes-bsp/u-boot/u-boot_2021.01.bb4
-rw-r--r--meta/recipes-bsp/u-boot/u-boot_2024.04.bb5
-rw-r--r--meta/recipes-bsp/usbinit/usbinit.bb3
-rw-r--r--meta/recipes-bsp/usbutils/usbutils/0001-usbutils.pc.in-Fix-Cflags-entry.patch34
-rw-r--r--meta/recipes-bsp/usbutils/usbutils_013.bb30
-rw-r--r--meta/recipes-bsp/usbutils/usbutils_017.bb33
-rw-r--r--meta/recipes-bsp/v86d/v86d_0.1.10.bb6
80 files changed, 716 insertions, 5836 deletions
diff --git a/meta/recipes-bsp/acpid/acpid.inc b/meta/recipes-bsp/acpid/acpid.inc
index 1e43e7a9db..7b2f1c71c5 100644
--- a/meta/recipes-bsp/acpid/acpid.inc
+++ b/meta/recipes-bsp/acpid/acpid.inc
@@ -8,12 +8,13 @@ admin."
8HOMEPAGE = "http://sourceforge.net/projects/acpid2" 8HOMEPAGE = "http://sourceforge.net/projects/acpid2"
9BUGTRACKER = "http://sourceforge.net/p/acpid2/tickets/?source=navbar" 9BUGTRACKER = "http://sourceforge.net/p/acpid2/tickets/?source=navbar"
10SECTION = "base" 10SECTION = "base"
11LICENSE = "GPLv2+" 11LICENSE = "GPL-2.0-or-later"
12 12
13SRC_URI = "${SOURCEFORGE_MIRROR}/acpid2/acpid-${PV}.tar.xz \ 13SRC_URI = "${SOURCEFORGE_MIRROR}/acpid2/acpid-${PV}.tar.xz \
14 file://init \ 14 file://init \
15 file://acpid.service \ 15 file://acpid.service \
16 " 16 file://0001-Replace-stat64-with-stat.patch \
17 "
17 18
18CVE_PRODUCT = "acpid2" 19CVE_PRODUCT = "acpid2"
19 20
@@ -22,9 +23,9 @@ inherit autotools update-rc.d systemd
22INITSCRIPT_NAME = "acpid" 23INITSCRIPT_NAME = "acpid"
23INITSCRIPT_PARAMS = "defaults" 24INITSCRIPT_PARAMS = "defaults"
24 25
25SYSTEMD_SERVICE_${PN} = "acpid.service" 26SYSTEMD_SERVICE:${PN} = "acpid.service"
26 27
27do_install_append () { 28do_install:append () {
28 install -d ${D}${sysconfdir}/init.d 29 install -d ${D}${sysconfdir}/init.d
29 sed -e 's,/usr/sbin,${sbindir},g' ${WORKDIR}/init > ${D}${sysconfdir}/init.d/acpid 30 sed -e 's,/usr/sbin,${sbindir},g' ${WORKDIR}/init > ${D}${sysconfdir}/init.d/acpid
30 chmod 755 ${D}${sysconfdir}/init.d/acpid 31 chmod 755 ${D}${sysconfdir}/init.d/acpid
@@ -32,7 +33,7 @@ do_install_append () {
32 install -d ${D}${sysconfdir}/acpi 33 install -d ${D}${sysconfdir}/acpi
33 install -d ${D}${sysconfdir}/acpi/events 34 install -d ${D}${sysconfdir}/acpi/events
34 35
35 install -d ${D}${systemd_unitdir}/system 36 install -d ${D}${systemd_system_unitdir}
36 install -m 0644 ${WORKDIR}/acpid.service ${D}${systemd_unitdir}/system 37 install -m 0644 ${WORKDIR}/acpid.service ${D}${systemd_system_unitdir}
37 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/acpid.service 38 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_system_unitdir}/acpid.service
38} 39}
diff --git a/meta/recipes-bsp/acpid/acpid/0001-Replace-stat64-with-stat.patch b/meta/recipes-bsp/acpid/acpid/0001-Replace-stat64-with-stat.patch
new file mode 100644
index 0000000000..10abfc8388
--- /dev/null
+++ b/meta/recipes-bsp/acpid/acpid/0001-Replace-stat64-with-stat.patch
@@ -0,0 +1,31 @@
1From 4b729235a9e96f120feee7e3746818aad0f3b924 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 14 Dec 2022 15:04:30 -0800
4Subject: [PATCH] Replace stat64 with stat
5
6It already checks for largefile support in configure.ac via
7AC_SYS_LARGEFILE macro, which will ensure that 64bit elements
8are correctly setup for stat APIs on platforms needing large
9file support.
10
11Upstream-Status: Submitted [https://sourceforge.net/p/acpid2/code/merge-requests/5/]
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 sock.c | 4 ++--
15 1 file changed, 2 insertions(+), 2 deletions(-)
16
17diff --git a/sock.c b/sock.c
18index 9e04501..3121fb7 100644
19--- a/sock.c
20+++ b/sock.c
21@@ -54,8 +54,8 @@ int non_root_clients;
22 static int
23 isfdtype(int fd, int fdtype)
24 {
25- struct stat64 st;
26- if (fstat64(fd, &st) != 0)
27+ struct stat st;
28+ if (fstat(fd, &st) != 0)
29 return -1;
30 return ((st.st_mode & S_IFMT) == (mode_t)fdtype);
31 }
diff --git a/meta/recipes-bsp/acpid/acpid_2.0.32.bb b/meta/recipes-bsp/acpid/acpid_2.0.34.bb
index 227e4a4675..1e0a6d5f24 100644
--- a/meta/recipes-bsp/acpid/acpid_2.0.32.bb
+++ b/meta/recipes-bsp/acpid/acpid_2.0.34.bb
@@ -3,5 +3,4 @@ require acpid.inc
3LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \ 3LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \
4 file://acpid.h;endline=24;md5=324a9cf225ae69ddaad1bf9d942115b5" 4 file://acpid.h;endline=24;md5=324a9cf225ae69ddaad1bf9d942115b5"
5 5
6SRC_URI[md5sum] = "248995264b9d1cd8bdb923d5b190fd44" 6SRC_URI[sha256sum] = "2d095c8cfcbc847caec746d62cdc8d0bff1ec1bc72ef7c674c721e04da6ab333"
7SRC_URI[sha256sum] = "f2d2d30b3edc3234bd82f6f7186699a6aa3c85c8d20bc4e30e9b3c68a1ed157e"
diff --git a/meta/recipes-bsp/alsa-state/alsa-state.bb b/meta/recipes-bsp/alsa-state/alsa-state.bb
index cec2272c80..bd7f610f46 100644
--- a/meta/recipes-bsp/alsa-state/alsa-state.bb
+++ b/meta/recipes-bsp/alsa-state/alsa-state.bb
@@ -8,10 +8,12 @@ SUMMARY = "Alsa scenario files to enable alsa state restoration"
8HOMEPAGE = "http://www.alsa-project.org/" 8HOMEPAGE = "http://www.alsa-project.org/"
9DESCRIPTION = "Alsa Scenario Files - an init script and state files to restore \ 9DESCRIPTION = "Alsa Scenario Files - an init script and state files to restore \
10sound state at system boot and save it at system shut down." 10sound state at system boot and save it at system shut down."
11LICENSE = "MIT" 11LICENSE = "MIT & GPL-2.0-or-later"
12LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 12LIC_FILES_CHKSUM = " \
13 file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420 \
14 file://alsa-state-init;beginline=3;endline=4;md5=3ff7ecbf534d7d503941abe8e268ef50 \
15"
13PV = "0.2.0" 16PV = "0.2.0"
14PR = "r5"
15 17
16SRC_URI = "\ 18SRC_URI = "\
17 file://asound.conf \ 19 file://asound.conf \
@@ -49,15 +51,15 @@ do_install() {
49 51
50PACKAGES += "alsa-states" 52PACKAGES += "alsa-states"
51 53
52RRECOMMENDS_alsa-state = "alsa-states" 54RRECOMMENDS:alsa-state = "alsa-states"
53 55
54RDEPENDS_${PN} = "alsa-utils-alsactl" 56RDEPENDS:${PN} = "alsa-utils-alsactl"
55FILES_${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf" 57FILES:${PN} = "${sysconfdir}/init.d ${sysconfdir}/asound.conf"
56CONFFILES_${PN} = "${sysconfdir}/asound.conf" 58CONFFILES:${PN} = "${sysconfdir}/asound.conf"
57 59
58FILES_alsa-states = "${localstatedir}/lib/alsa/*.state" 60FILES:alsa-states = "${localstatedir}/lib/alsa/*.state"
59 61
60pkg_postinst_${PN}() { 62pkg_postinst:${PN}() {
61 if test -z "$D" 63 if test -z "$D"
62 then 64 then
63 if test -x ${sbindir}/alsactl 65 if test -x ${sbindir}/alsactl
diff --git a/meta/recipes-bsp/alsa-state/alsa-state/alsa-state-init b/meta/recipes-bsp/alsa-state/alsa-state/alsa-state-init
index eee59cb321..a04cc27004 100755
--- a/meta/recipes-bsp/alsa-state/alsa-state/alsa-state-init
+++ b/meta/recipes-bsp/alsa-state/alsa-state/alsa-state-init
@@ -1,10 +1,9 @@
1#! /bin/sh 1#! /bin/sh
2# 2#
3# Copyright Matthias Hentges <devel@hentges.net> (c) 2007 3# Copyright Matthias Hentges <devel@hentges.net> (c) 2007
4# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the license) 4# SPDX-License-Identifier: GPL-2.0-or-later
5# 5#
6# Filename: alsa-state 6# Filename: alsa-state
7# Date: 20070308 (YMD)
8 7
9# source function library 8# source function library
10. /etc/init.d/functions 9. /etc/init.d/functions
diff --git a/meta/recipes-bsp/apmd/apmd/apmd.service b/meta/recipes-bsp/apmd/apmd/apmd.service
deleted file mode 100644
index ffab82334f..0000000000
--- a/meta/recipes-bsp/apmd/apmd/apmd.service
+++ /dev/null
@@ -1,7 +0,0 @@
1[Unit]
2Description=Advanced Power Management daemon
3After=remote-fs.target
4
5[Service]
6EnvironmentFile=-@SYSCONFDIR@/default/apmd
7ExecStart=@SBINDIR@/apmd -P @SYSCONFDIR@/apm/apmd_proxy $APMD
diff --git a/meta/recipes-bsp/apmd/apmd/apmd_proxy b/meta/recipes-bsp/apmd/apmd/apmd_proxy
deleted file mode 100644
index c48ee4e5d5..0000000000
--- a/meta/recipes-bsp/apmd/apmd/apmd_proxy
+++ /dev/null
@@ -1,91 +0,0 @@
1#!/bin/sh
2#
3# apmd_proxy - program dispatcher for APM daemon
4#
5# Written by Craig Markwardt (craigm@lheamail.gsfc.nasa.gov) 21 May 1999
6# Modified for Debian by Avery Pennarun
7#
8# This shell script is called by the APM daemon (apmd) when a power
9# management event occurs. Its first and second arguments describe the
10# event. For example, apmd will call "apmd_proxy suspend system" just
11# before the system is suspended.
12#
13# Here are the possible arguments:
14#
15# start - APM daemon has started
16# stop - APM daemon is shutting down
17# suspend critical - APM system indicates critical suspend (++)
18# suspend system - APM system has requested suspend mode
19# suspend user - User has requested suspend mode
20# standby system - APM system has requested standby mode
21# standby user - User has requested standby mode
22# resume suspend - System has resumed from suspend mode
23# resume standby - System has resumed from standby mode
24# resume critical - System has resumed from critical suspend
25# change battery - APM system reported low battery
26# change power - APM system reported AC/battery change
27# change time - APM system reported time change (*)
28# change capability - APM system reported config. change (+)
29#
30# (*) - APM daemon may be configured to not call these sequences
31# (+) - Available if APM kernel supports it.
32# (++) - "suspend critical" is never passed to apmd from the kernel,
33# so we will never see it here. Scripts that process "resume
34# critical" events need to take this into account.
35#
36# It is the proxy script's responsibility to examine the APM status
37# (via /proc/apm) or other status and to take appropriate actions.
38# For example, the script might unmount network drives before the
39# machine is suspended.
40#
41# In Debian, the usual way of adding functionality to the proxy is to
42# add a script to /etc/apm/event.d. This script will be called by
43# apmd_proxy (via run-parts) with the same arguments.
44#
45# If it is important that a certain set of script be run in a certain
46# order on suspend and in a different order on resume, then put all
47# the scripts in /etc/apm/scripts.d instead of /etc/apm/event.d and
48# symlink to these from /etc/apm/suspend.d, /etc/apm/resume.d and
49# /etc/apm/other.d using names whose lexicographical order is the same
50# as the desired order of execution.
51#
52# If the kernel's APM driver supports it, apmd_proxy can return a non-zero
53# exit status on suspend and standby events, indicating that the suspend
54# or standby event should be rejected.
55#
56# *******************************************************************
57
58set -e
59
60# The following doesn't yet work, because current kernels (up to at least
61# 2.4.20) do not support rejection of APM events. Supporting this would
62# require substantial modifications to the APM driver. We will re-enable
63# this feature if the driver is ever modified. -- cph@debian.org
64#
65#SUSPEND_ON_AC=false
66#[ -r /etc/apm/apmd_proxy.conf ] && . /etc/apm/apmd_proxy.conf
67#
68#if [ "${SUSPEND_ON_AC}" = "false" -a "${2}" = "system" ] \
69# && on_ac_power >/dev/null; then
70# # Reject system suspends and standbys if we are on AC power
71# exit 1 # Reject (NOTE kernel support must be enabled)
72#fi
73
74if [ "${1}" = "suspend" -o "${1}" = "standby" ]; then
75 run-parts -a "${1}" -a "${2}" /etc/apm/event.d
76 if [ -d /etc/apm/suspend.d ]; then
77 run-parts -a "${1}" -a "${2}" /etc/apm/suspend.d
78 fi
79elif [ "${1}" = "resume" ]; then
80 if [ -d /etc/apm/resume.d ]; then
81 run-parts -a "${1}" -a "${2}" /etc/apm/resume.d
82 fi
83 run-parts -a "${1}" -a "${2}" /etc/apm/event.d
84else
85 run-parts -a "${1}" -a "${2}" /etc/apm/event.d
86 if [ -d /etc/apm/other.d ]; then
87 run-parts -a "${1}" -a "${2}" /etc/apm/other.d
88 fi
89fi
90
91exit 0
diff --git a/meta/recipes-bsp/apmd/apmd/apmd_proxy.conf b/meta/recipes-bsp/apmd/apmd/apmd_proxy.conf
deleted file mode 100644
index 751145c522..0000000000
--- a/meta/recipes-bsp/apmd/apmd/apmd_proxy.conf
+++ /dev/null
@@ -1,16 +0,0 @@
1# /etc/apm/apmd_proxy.conf: configuration file for apmd.
2#
3# This file is managed by debconf when installing or reconfiguring the
4# package. It is generated by merging the answers gathered by debconf
5# into the template file "/usr/share/apmd/apmd_proxy.conf".
6
7# The following doesn't yet work, because current kernels (up to at least
8# 2.4.20) do not support rejection of APM events. Supporting this would
9# require substantial modifications to the APM driver. We will re-enable
10# this feature if the driver is ever modified. -- cph@debian.org
11#
12# Set the following to "false" if you want to reject system suspend or
13# system standby requests when the computer is running on AC power.
14# Otherwise set this to "true". Such requests are never rejected when
15# the computer is running on battery power.
16#SUSPEND_ON_AC=true
diff --git a/meta/recipes-bsp/apmd/apmd/default b/meta/recipes-bsp/apmd/apmd/default
deleted file mode 100644
index 4b7965abf8..0000000000
--- a/meta/recipes-bsp/apmd/apmd/default
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Default for /etc/init.d/apmd
3#
4
5# As apmd can be called with arguments, we use the following variable
6# to store them, e.g., APMD="-w 5 -p 2".
7# See the manual page apmd(8) for details.
8APMD="--proxy-timeout 30"
diff --git a/meta/recipes-bsp/apmd/apmd/init b/meta/recipes-bsp/apmd/apmd/init
deleted file mode 100755
index c0b41aa9d1..0000000000
--- a/meta/recipes-bsp/apmd/apmd/init
+++ /dev/null
@@ -1,51 +0,0 @@
1#!/bin/sh
2### BEGIN INIT INFO
3# Provides: apmd
4# Required-Start: $remote_fs
5# Required-Stop: $remote_fs
6# Default-Start: 2 3 4 5
7# Default-Stop: 0 1 6
8# Short-Description: Advanced Power Management daemon
9### END INIT INFO
10
11# Source function library.
12. /etc/init.d/functions
13
14PATH=/bin:/usr/bin:/sbin:/usr/sbin
15
16[ -f /etc/default/rcS ] && . /etc/default/rcS
17[ -f /etc/default/apmd ] && . /etc/default/apmd
18
19case "$1" in
20 start)
21 echo -n "Starting advanced power management daemon: "
22 start-stop-daemon -S -x /usr/sbin/apmd -- \
23 -P /etc/apm/apmd_proxy $APMD
24 if [ $? = 0 ]; then
25 echo "apmd."
26 else
27 echo "(failed.)"
28 fi
29 ;;
30 stop)
31 echo -n "Stopping advanced power management daemon: "
32 start-stop-daemon -K \
33 -x /usr/sbin/apmd
34 echo "apmd."
35 ;;
36 status)
37 status /usr/sbin/apmd;
38 exit $?
39 ;;
40 restart|force-reload)
41 $0 stop
42 $0 start
43 exit
44 ;;
45 *)
46 echo "Usage: /etc/init.d/apmd {start|stop|status|restart|force-reload}"
47 exit 1
48 ;;
49esac
50
51exit 0
diff --git a/meta/recipes-bsp/apmd/apmd/legacy.patch b/meta/recipes-bsp/apmd/apmd/legacy.patch
deleted file mode 100644
index 8871311805..0000000000
--- a/meta/recipes-bsp/apmd/apmd/legacy.patch
+++ /dev/null
@@ -1,133 +0,0 @@
1From 3595933d221f0ba836917debc0776b8723972ec9 Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Tue, 11 Aug 2015 17:40:50 +0300
4Subject: [PATCH 1/3] Patch with fixes provided by Debian.
5
6This patch is taken from
7ftp://ftp.debian.org/debian/pool/main/a/apmd/apmd_3.2.2-15.debian.tar.xz
8
9Upstream-Status: Inappropriate [upstream is dead]
10Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
11
12---
13 Makefile | 2 +-
14 apm.c | 3 ++-
15 apm.h | 9 +++++++++
16 apmd.c | 15 ++++++++-------
17 4 files changed, 20 insertions(+), 9 deletions(-)
18
19diff --git a/Makefile b/Makefile
20index bf346d9..92fc0fd 100644
21--- a/Makefile
22+++ b/Makefile
23@@ -43,7 +43,7 @@ DESTDIR=
24
25 CC=gcc
26 CFLAGS=-O -g
27-XTRACFLAGS=-Wall -pipe -I. -I/usr/src/linux/include \
28+XTRACFLAGS=-Wall -pipe -I. -I/usr/src/linux/include -I/usr/X11R6/include \
29 -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include \
30 -DVERSION=\"$(VERSION)\" \
31 -DDEFAULT_PROXY_NAME=\"$(PROXY_DIR)/apmd_proxy\"
32diff --git a/apm.c b/apm.c
33index b21c057..0359b1c 100644
34--- a/apm.c
35+++ b/apm.c
36@@ -219,12 +219,13 @@ int main(int argc, char **argv)
37 }
38 }
39
40-
41+#if 0
42 if (!(i.apm_flags & APM_32_BIT_SUPPORT))
43 {
44 fprintf(stderr, "32-bit APM interface not supported\n");
45 exit(1);
46 }
47+#endif
48
49 if (verbose && (i.apm_flags & 0x10))
50 printf("APM BIOS Power Management is currently disabled\n");
51diff --git a/apm.h b/apm.h
52index fb24dfd..824cc06 100644
53--- a/apm.h
54+++ b/apm.h
55@@ -20,6 +20,13 @@
56 * $Id: apm.h,v 1.7 1999/07/05 22:31:11 apenwarr Exp $
57 *
58 */
59+#ifndef _APM_H
60+#define _APM_H 1
61+
62+#ifndef __KERNEL_STRICT_NAMES
63+#define __KERNEL_STRICT_NAMES
64+#endif
65+
66 #include <linux/apm_bios.h>
67 #include <sys/types.h>
68
69@@ -93,3 +100,5 @@ extern int apm_reject(int fd);
70 #else
71 #define apm_reject(fd) (-EINVAL)
72 #endif
73+
74+#endif
75diff --git a/apmd.c b/apmd.c
76index 49ed3a1..560f536 100644
77--- a/apmd.c
78+++ b/apmd.c
79@@ -343,7 +343,7 @@ static int call_proxy(apm_event_t event)
80 /* parent */
81 int status, retval;
82 ssize_t len;
83- time_t time_limit;
84+ time_t countdown;
85
86 if (pid < 0) {
87 /* Couldn't fork */
88@@ -356,8 +356,9 @@ static int call_proxy(apm_event_t event)
89 /* Capture the child's output, if any, but only until it terminates */
90 close(fds[1]);
91 fcntl(fds[0], F_SETFL, O_RDONLY|O_NONBLOCK);
92- time_limit = time(0) + proxy_timeout;
93+ countdown = proxy_timeout;
94 do {
95+ countdown -= 1;
96 while ((len = read(fds[0], line, sizeof(line)-1)) > 0) {
97 line[len] = 0;
98 APMD_SYSLOG(LOG_INFO, "+ %s", line);
99@@ -372,16 +373,16 @@ static int call_proxy(apm_event_t event)
100 goto proxy_done;
101 }
102
103- sleep(1);
104+ while (sleep(1) > 0) ;
105 } while (
106- (time(0) < time_limit)
107+ (countdown >= 0)
108 || (proxy_timeout < 0)
109 );
110
111 APMD_SYSLOG(LOG_NOTICE, "Proxy has been running more than %d seconds; killing it", proxy_timeout);
112
113 kill(pid, SIGTERM);
114- time_limit = time(0) + 5;
115+ countdown = 5;
116 do {
117 retval = waitpid(pid, &status, WNOHANG);
118 if (retval == pid)
119@@ -392,9 +393,9 @@ static int call_proxy(apm_event_t event)
120 goto proxy_done;
121 }
122
123- sleep(1);
124+ while (sleep(1) > 0) ;
125
126- } while (time(0) < time_limit);
127+ } while (countdown >= 0);
128
129 kill(pid, SIGKILL);
130 status = __W_EXITCODE(0, SIGKILL);
131--
1322.1.4
133
diff --git a/meta/recipes-bsp/apmd/apmd/libtool.patch b/meta/recipes-bsp/apmd/apmd/libtool.patch
deleted file mode 100644
index 834ee080a1..0000000000
--- a/meta/recipes-bsp/apmd/apmd/libtool.patch
+++ /dev/null
@@ -1,33 +0,0 @@
1Add by RP to address "unable to infer tagged configuration" error:
2 commit 35de05e61b88c0808a5e885bb0efdf420555d5ad
3 Author: Richard Purdie <rpurdie@rpsys.net>
4 Date: Sun Jun 1 16:13:38 2008 +0000
5
6 apmd: Use libtool --tag options to avoid problems with libtool 2.2.4 (from poky)
7
8However I didn't see same issue with current libtool-2.2.10. Also per my understanding,
9the default tag, if not specified, falls back to CC. So disable it from patching, but
10keep it here. If we encounter similar issue in the future, we could then push upstream
11
12Comment added by Kevin Tian <kevin.tian@intel.com>, 2010-07-16
13
14Upstream-Status: Pending
15
16Signed-off-by: Scott Garman <scott.a.garman@intel.com>
17
18Index: apmd-3.2.2.orig/Makefile
19===================================================================
20--- apmd-3.2.2.orig.orig/Makefile 2004-01-04 08:13:18.000000000 +0000
21+++ apmd-3.2.2.orig/Makefile 2008-04-21 17:10:03.000000000 +0100
22@@ -58,9 +57,8 @@
23 #CFLAGS=-O3 -m486 -fomit-frame-pointer
24 #LDFLAGS=-s
25
26-LIBTOOL=libtool --quiet
27-LT_COMPILE = $(LIBTOOL) --mode=compile $(CC)
28-LT_LINK = $(LIBTOOL) --mode=link $(CC)
29+LT_COMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC)
30+LT_LINK = $(LIBTOOL) --tag=CC --mode=link $(CC)
31 LT_INSTALL = $(LIBTOOL) --mode=install install
32 LT_CLEAN = $(LIBTOOL) --mode=clean rm
33
diff --git a/meta/recipes-bsp/apmd/apmd/linkage.patch b/meta/recipes-bsp/apmd/apmd/linkage.patch
deleted file mode 100644
index 3d32c49cd2..0000000000
--- a/meta/recipes-bsp/apmd/apmd/linkage.patch
+++ /dev/null
@@ -1,53 +0,0 @@
1When building use the libtool intermediate .lo files instead of explicitly using
2the .o files. Under libtool foo.lo is the libtool intermediate wrapper, foo.o is
3a static build, and .libs/foo.o is a shared build.
4
5If static libraries have been disabled globally then libtool won't generate them
6and explicit references to foo.o won't be satisfied.
7
8Upstream-Status: Pending
9Signed-off-by: Ross Burton <ross.burton@intel.com>
10
11diff --git a/Makefile b/Makefile
12index bb695c6..5f60146 100644
13--- a/Makefile
14+++ b/Makefile
15@@ -28,7 +28,7 @@ endif
16
17 .SUFFIXES:
18
19-OBJS=apmlib.o
20+OBJS=apmlib.lo
21 EXES=apm apmd xapm apmsleep
22 HEADERS=apm.h
23
24@@ -66,22 +66,22 @@ all: $(EXES)
25
26 $(OBJS): $(HEADERS)
27
28-%.o: %.c
29+%.lo: %.c
30 $(LT_COMPILE) -c $(CPPFLAGS) $(CFLAGS) $(XTRACFLAGS) $<
31
32-%: %.o $(LIBAPM)
33+%: %.lo $(LIBAPM)
34 $(LT_LINK) -o $@ $< $(LDFLAGS) $(LIBAPM)
35
36-xapm.o: xapm.c
37+xapm.lo: xapm.c
38 $(LT_COMPILE) -c $(CPPFLAGS) $(CFLAGS) $(XTRACFLAGS) -DNARROWPROTO $<
39
40-apmd: apmd.o
41+apmd: apmd.lo
42
43-apmsleep: apmsleep.o
44+apmsleep: apmsleep.lo
45
46-apmexists: apmexists.o
47+apmexists: apmexists.lo
48
49-xapm: xapm.o $(LIBAPM)
50+xapm: xapm.lo $(LIBAPM)
51 $(LT_LINK) -o $@ $< $(LDFLAGS) $(LIBAPM) $(XLDFLAGS) $(XLIBS)
52
53 $(LIBAPM): apmlib.lo
diff --git a/meta/recipes-bsp/apmd/apmd/unlinux.patch b/meta/recipes-bsp/apmd/apmd/unlinux.patch
deleted file mode 100644
index ec8206cf17..0000000000
--- a/meta/recipes-bsp/apmd/apmd/unlinux.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1copy OE commit message here:
2 commit 9456cdc1cf43e3ba9e6d88c63560c1b6fdee4359
3 Author: Michael Krelin <hacker@klever.net>
4 Date: Tue May 29 12:27:45 2007 +0000
5
6 apmd: prevent build from interferring with host kernel headers. Closes #1257
7
8comment added by Kevin Tian <kevin.tian@intel.com>, 2010-07-13
9
10Upstream-Status: Pending
11
12Signed-off-by: Scott Garman <scott.a.garman@intel.com>
13
14--- apmd-3.2.2.orig/Makefile
15+++ apmd-3.2.2/Makefile
16@@ -43,8 +43,7 @@
17
18 CC=gcc
19 CFLAGS=-O -g
20-XTRACFLAGS=-Wall -pipe -I. -I/usr/src/linux/include -I/usr/X11R6/include \
21- -I/usr/src/linux-2.2/include -I /usr/src/linux-2.0/include \
22+XTRACFLAGS=-Wall -pipe -I. \
23 -DVERSION=\"$(VERSION)\" \
24 -DDEFAULT_PROXY_NAME=\"$(PROXY_DIR)/apmd_proxy\"
25 LDFLAGS=
diff --git a/meta/recipes-bsp/apmd/apmd/wexitcode.patch b/meta/recipes-bsp/apmd/apmd/wexitcode.patch
deleted file mode 100644
index c5faa85fa7..0000000000
--- a/meta/recipes-bsp/apmd/apmd/wexitcode.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1Define non-posix W* funcitons
2
3C libraries like musl dont define them
4
5Signed-off-by: Khem Raj <raj.khem@gmail.com>
6Upstream-Status: Pending
7
8Index: apmd-3.2.2.orig/apmd.c
9===================================================================
10--- apmd-3.2.2.orig.orig/apmd.c
11+++ apmd-3.2.2.orig/apmd.c
12@@ -55,6 +55,14 @@
13 #define MINIMUM_RATE_CALC_TIME 120
14 #endif
15
16+#ifndef _POSIX_SOURCE
17+
18+#define __WCOREFLAG 0200
19+#define __WCOREDUMP(x) (_W_INT(x) & __WCOREFLAG)
20+#define __W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
21+
22+#endif
23+
24 /*
25 * For the verbosity level feature to be useful,
26 * we rely on the fact that syslog.h assigns adjacent
diff --git a/meta/recipes-bsp/apmd/apmd_3.2.2-15.bb b/meta/recipes-bsp/apmd/apmd_3.2.2-15.bb
deleted file mode 100644
index 82c2649340..0000000000
--- a/meta/recipes-bsp/apmd/apmd_3.2.2-15.bb
+++ /dev/null
@@ -1,85 +0,0 @@
1SUMMARY = "Utilities for Advanced Power Management"
2DESCRIPTION = "The Advanced Power Management (APM) support provides \
3access to battery status information and a set of tools for managing \
4notebook power consumption."
5HOMEPAGE = "http://apenwarr.ca/apmd/"
6SECTION = "base"
7LICENSE = "GPLv2+"
8LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
9 file://apm.h;beginline=6;endline=18;md5=7d4acc1250910a89f84ce3cc6557c4c2"
10DEPENDS = "libtool-cross"
11
12SRC_URI = "http://snapshot.debian.org/archive/debian/20160728T043443Z/pool/main/a/${BPN}/${BPN}_3.2.2.orig.tar.gz;name=tarball \
13 file://legacy.patch \
14 file://libtool.patch \
15 file://unlinux.patch \
16 file://wexitcode.patch \
17 file://linkage.patch \
18 file://init \
19 file://default \
20 file://apmd_proxy \
21 file://apmd_proxy.conf \
22 file://apmd.service"
23
24SRC_URI[tarball.md5sum] = "b1e6309e8331e0f4e6efd311c2d97fa8"
25SRC_URI[tarball.sha256sum] = "7f7d9f60b7766b852881d40b8ff91d8e39fccb0d1d913102a5c75a2dbb52332d"
26
27# for this package we're mostly interested in tracking debian patches,
28# and not in the upstream version where all development has effectively stopped
29UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/a/apmd/"
30UPSTREAM_CHECK_REGEX = "(?P<pver>((\d+\.*)+)-((\d+\.*)+))\.(diff|debian\.tar)\.(gz|xz)"
31
32S = "${WORKDIR}/apmd-3.2.2.orig"
33
34inherit update-rc.d systemd
35
36INITSCRIPT_NAME = "apmd"
37INITSCRIPT_PARAMS = "defaults"
38
39SYSTEMD_SERVICE_${PN} = "apmd.service"
40SYSTEMD_AUTO_ENABLE = "disable"
41
42EXTRA_OEMAKE = "-e MAKEFLAGS="
43
44do_compile() {
45 # apmd doesn't use whole autotools. Just libtool for installation
46 oe_runmake "LIBTOOL=${STAGING_BINDIR_CROSS}/${HOST_SYS}-libtool" apm apmd
47}
48
49do_install() {
50 install -d ${D}${sysconfdir}
51 install -d ${D}${sysconfdir}/apm
52 install -d ${D}${sysconfdir}/apm/event.d
53 install -d ${D}${sysconfdir}/apm/other.d
54 install -d ${D}${sysconfdir}/apm/suspend.d
55 install -d ${D}${sysconfdir}/apm/resume.d
56 install -d ${D}${sysconfdir}/apm/scripts.d
57 install -d ${D}${sysconfdir}/default
58 install -d ${D}${sysconfdir}/init.d
59 install -d ${D}${sbindir}
60 install -d ${D}${bindir}
61 install -d ${D}${libdir}
62 install -d ${D}${datadir}/apmd
63 install -d ${D}${includedir}
64
65 install -m 4755 ${S}/.libs/apm ${D}${bindir}/apm
66 install -m 0755 ${S}/.libs/apmd ${D}${sbindir}/apmd
67 install -m 0755 ${WORKDIR}/apmd_proxy ${D}${sysconfdir}/apm/
68 install -m 0644 ${WORKDIR}/apmd_proxy.conf ${D}${datadir}/apmd/
69 install -m 0644 ${WORKDIR}/default ${D}${sysconfdir}/default/apmd
70 oe_libinstall -so libapm ${D}${libdir}
71 install -m 0644 apm.h ${D}${includedir}
72
73 sed -e 's,/usr/sbin,${sbindir},g; s,/etc,${sysconfdir},g;' ${WORKDIR}/init > ${D}${sysconfdir}/init.d/apmd
74 chmod 755 ${D}${sysconfdir}/init.d/apmd
75
76 install -d ${D}${systemd_unitdir}/system
77 install -m 0644 ${WORKDIR}/apmd.service ${D}${systemd_unitdir}/system/
78 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
79 -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/apmd.service
80}
81
82PACKAGES =+ "libapm apm"
83
84FILES_libapm = "${libdir}/libapm${SOLIBS}"
85FILES_apm = "${bindir}/apm*"
diff --git a/meta/recipes-bsp/efibootmgr/efibootmgr/0001-remove-extra-decl.patch b/meta/recipes-bsp/efibootmgr/efibootmgr/0001-remove-extra-decl.patch
deleted file mode 100644
index 42f3a8182d..0000000000
--- a/meta/recipes-bsp/efibootmgr/efibootmgr/0001-remove-extra-decl.patch
+++ /dev/null
@@ -1,31 +0,0 @@
1From 99b578501643377e0b1994b2a068b790d189d5ad Mon Sep 17 00:00:00 2001
2From: Peter Jones <pjones@redhat.com>
3Date: Wed, 13 Jun 2018 09:41:01 -0400
4Subject: [PATCH] remove extra decl
5
6Signed-off-by: Peter Jones <pjones@redhat.com>
7
8Upstream-Status: Backport [git://github.com/rhinstaller/efibootmgr.git]
9Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
10
11---
12 src/efibootmgr.c | 3 ---
13 1 file changed, 3 deletions(-)
14
15diff --git a/src/efibootmgr.c b/src/efibootmgr.c
16index de38f01..4e1a680 100644
17--- a/src/efibootmgr.c
18+++ b/src/efibootmgr.c
19@@ -1536,9 +1536,6 @@ parse_opts(int argc, char **argv)
20 "invalid numeric value %s\n",
21 optarg);
22 }
23- /* XXX efivar-36 accidentally doesn't have a public
24- * header for this */
25- extern int efi_set_verbose(int verbosity, FILE *errlog);
26 efi_set_verbose(opts.verbose - 2, stderr);
27 break;
28 case 'V':
29--
302.7.4
31
diff --git a/meta/recipes-bsp/efibootmgr/efibootmgr/97668ae0bce776a36ea2001dea63d376be8274ac.patch b/meta/recipes-bsp/efibootmgr/efibootmgr/97668ae0bce776a36ea2001dea63d376be8274ac.patch
deleted file mode 100644
index 9525ed8c54..0000000000
--- a/meta/recipes-bsp/efibootmgr/efibootmgr/97668ae0bce776a36ea2001dea63d376be8274ac.patch
+++ /dev/null
@@ -1,83 +0,0 @@
1From 97668ae0bce776a36ea2001dea63d376be8274ac Mon Sep 17 00:00:00 2001
2From: Peter Jones <pjones@redhat.com>
3Date: Wed, 6 Mar 2019 13:08:33 -0500
4Subject: [PATCH] Make sure PKGS= is propogated into the submake for "make
5 deps"
6
7When we're doing make deps with "$(CC) -MF", gcc and clang have different
8behavior, both broken in different ways, which we're hitting because of a
9missing -I argument for libefivar's includes. On clang, when a header can't
10be found, it emits a rule with the header as a prerequisite without a path,
11such as efivar.h here:
12
13efibootmgr.o: efibootmgr.c fix_coverity.h efivar.h efiboot.h \
14 /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \
15 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
16 /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \
17 /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \
18 error.h
19
20Then the build that utilizes that rule will fail to find the
21prerequisite and tell you something like:
22
23make[1]: *** No rule to make target 'efivar.h', needed by 'efibootmgr.o'. Stop.
24make[1]: Leaving directory '/home/pjones/devel/github.com/efibootmgr/master/src'
25
26With gcc, when a header can't be found, it emits a rule without that header
27as a prerequisite, as such (again with efivar.h):
28
29efibootmgr.o: efibootmgr.c fix_coverity.h \
30 /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \
31 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
32 /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \
33 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
34 /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \
35 error.h
36
37And then your build will fail if you haven't adjusted CFLAGS to tell it
38where to find the header.
39
40Both of these would be better just erroring, but at least gcc's doesn't
41insert a *wrong* dependency.
42
43This patch adds "PKGS=efivar efibootmgr popt" for all deps under src/.
44Technically that's overkill, as efibootmgr itself doesn't need popt, but it
45doesn't hurt anything to have the extra part there. The resulting
46.efibootmgr.d file has the prerequisites expressed correctly:
47
48efibootmgr.o: efibootmgr.c fix_coverity.h /usr/include/efivar/efivar.h \
49 /usr/include/efivar/efiboot.h \
50 /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \
51 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
52 /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \
53 /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \
54 /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \
55 error.h
56
57This fixes the issue described in github PR #96
58
59Signed-off-by: Peter Jones <pjones@redhat.com>
60Upstream-Status: Backport [https://github.com/rhboot/efibootmgr/commit/97668ae0bce776a36ea2001dea63d376be8274ac]
61---
62 src/Makefile | 7 ++++++-
63 1 file changed, 6 insertions(+), 1 deletion(-)
64
65diff --git a/src/Makefile b/src/Makefile
66index 258bac1..32fa188 100644
67--- a/src/Makefile
68+++ b/src/Makefile
69@@ -31,8 +31,13 @@ efibootdump : PKGS=efivar efiboot popt
70 efibootnext : $(call objects-of,$(EFIBOOTNEXT_SOURCES))
71 efibootnext : PKGS=efivar efiboot popt
72
73+deps : PKGS=efivar efiboot popt
74 deps : $(ALL_SOURCES)
75- $(MAKE) -f $(TOPDIR)/Make.deps deps SOURCES="$(ALL_SOURCES)" SUBDIR_CFLAGS="$(SUBDIR_CFLAGS)"
76+ $(MAKE) -f $(TOPDIR)/Make.deps \
77+ SOURCES="$(ALL_SOURCES)" \
78+ SUBDIR_CFLAGS="$(SUBDIR_CFLAGS)" \
79+ PKGS="$(PKGS)" \
80+ deps
81
82 clean :
83 @rm -rfv *.o *.a *.so $(TARGETS)
diff --git a/meta/recipes-bsp/efibootmgr/efibootmgr_17.bb b/meta/recipes-bsp/efibootmgr/efibootmgr_18.bb
index 5d6f200a73..fbd2f5dbc8 100644
--- a/meta/recipes-bsp/efibootmgr/efibootmgr_17.bb
+++ b/meta/recipes-bsp/efibootmgr/efibootmgr_18.bb
@@ -3,18 +3,15 @@ SUMMARY = "EFI Boot Manager"
3HOMEPAGE = "https://github.com/rhboot/efibootmgr" 3HOMEPAGE = "https://github.com/rhboot/efibootmgr"
4SECTION = "base" 4SECTION = "base"
5 5
6LICENSE = "GPLv2+" 6LICENSE = "GPL-2.0-or-later"
7LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3" 7LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3"
8 8
9DEPENDS = "efivar popt" 9DEPENDS = "efivar popt"
10 10
11COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux" 11COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux"
12 12
13SRC_URI = "git://github.com/rhinstaller/efibootmgr.git;protocol=https \ 13SRC_URI = "git://github.com/rhinstaller/efibootmgr.git;protocol=https;branch=main"
14 file://0001-remove-extra-decl.patch \ 14SRCREV = "c3f9f0534e32158f62c43564036878b93b9e0fd6"
15 file://97668ae0bce776a36ea2001dea63d376be8274ac.patch \
16 "
17SRCREV = "e067160ecef8208e1944002e5d50b275733211fb"
18 15
19S = "${WORKDIR}/git" 16S = "${WORKDIR}/git"
20 17
diff --git a/meta/recipes-bsp/efivar/efivar/0001-docs-do-not-build-efisecdb-manpage.patch b/meta/recipes-bsp/efivar/efivar/0001-docs-do-not-build-efisecdb-manpage.patch
new file mode 100644
index 0000000000..cb30d3c430
--- /dev/null
+++ b/meta/recipes-bsp/efivar/efivar/0001-docs-do-not-build-efisecdb-manpage.patch
@@ -0,0 +1,26 @@
1From f39a1481a9e465387901d52b07ae56dedcc3838b Mon Sep 17 00:00:00 2001
2From: Alexander Kanavin <alex@linutronix.de>
3Date: Sun, 16 Jan 2022 18:25:33 +0100
4Subject: [PATCH] docs: do not build efisecdb manpage
5
6It requires mandoc, which oe-core does not have.
7
8Upstream-Status: Inappropriate [oe-core specific]
9Signed-off-by: Alexander Kanavin <alex@linutronix.de>
10---
11 docs/Makefile | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/docs/Makefile b/docs/Makefile
15index c9bf585..91a6078 100644
16--- a/docs/Makefile
17+++ b/docs/Makefile
18@@ -5,7 +5,7 @@ include $(TOPDIR)/src/include/version.mk
19 include $(TOPDIR)/src/include/rules.mk
20 include $(TOPDIR)/src/include/defaults.mk
21
22-MAN1TARGETS = efisecdb.1 \
23+MAN1TARGETS = \
24 efivar.1
25
26 MAN3TARGETS = efi_append_variable.3 \
diff --git a/meta/recipes-bsp/efivar/efivar/determinism.patch b/meta/recipes-bsp/efivar/efivar/determinism.patch
deleted file mode 100644
index bdf6bfc4a8..0000000000
--- a/meta/recipes-bsp/efivar/efivar/determinism.patch
+++ /dev/null
@@ -1,18 +0,0 @@
1Fix reproducibility issue caused by unsorted wildcard expansion.
2
3Upstream-Status: Pending
4RP 2021/3/1
5
6Index: git/src/Makefile
7===================================================================
8--- git.orig/src/Makefile
9+++ git/src/Makefile
10@@ -15,7 +15,7 @@ TARGETS=$(LIBTARGETS) $(BINTARGETS) $(PC
11 STATICTARGETS=$(STATICLIBTARGETS) $(STATICBINTARGETS)
12
13 LIBEFIBOOT_SOURCES = crc32.c creator.c disk.c gpt.c loadopt.c path-helpers.c \
14- linux.c $(wildcard linux-*.c)
15+ linux.c $(sort $(wildcard linux-*.c))
16 LIBEFIBOOT_OBJECTS = $(patsubst %.c,%.o,$(LIBEFIBOOT_SOURCES))
17 LIBEFIVAR_SOURCES = dp.c dp-acpi.c dp-hw.c dp-media.c dp-message.c \
18 efivarfs.c error.c export.c guid.c guids.S guid-symbols.c \
diff --git a/meta/recipes-bsp/efivar/efivar/no-werror.patch b/meta/recipes-bsp/efivar/efivar/no-werror.patch
deleted file mode 100644
index 50a0b1023a..0000000000
--- a/meta/recipes-bsp/efivar/efivar/no-werror.patch
+++ /dev/null
@@ -1,18 +0,0 @@
1Don't use -Werror because newer compilers introduce newer warnings.
2
3Upstream-Status: Inappropriate [https://github.com/rhboot/efivar/issues/131]
4Signed-off-by: Ross Burton <ross.burton@intel.com>
5
6diff --git a/gcc.specs b/gcc.specs
7index 45d43d1..1baf11a 100644
8--- a/gcc.specs
9+++ b/gcc.specs
10@@ -2,7 +2,7 @@
11 + -D_GNU_SOURCE
12
13 *efivar_cpp_options:
14- -Werror -Wall -std=gnu11 -Wextra
15+ -Wall -std=gnu11 -Wextra
16
17 *cpp_options:
18 + %(efivar_cpp_options)
diff --git a/meta/recipes-bsp/efivar/efivar_37.bb b/meta/recipes-bsp/efivar/efivar_37.bb
deleted file mode 100644
index 5bf121ff6e..0000000000
--- a/meta/recipes-bsp/efivar/efivar_37.bb
+++ /dev/null
@@ -1,41 +0,0 @@
1SUMMARY = "Tools to manipulate UEFI variables"
2DESCRIPTION = "efivar provides a simple command line interface to the UEFI variable facility"
3HOMEPAGE = "https://github.com/rhboot/efivar"
4
5LICENSE = "LGPLv2.1+"
6LIC_FILES_CHKSUM = "file://COPYING;md5=6626bb1e20189cfa95f2c508ba286393"
7
8COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux"
9
10SRC_URI = "git://github.com/rhinstaller/efivar.git \
11 file://determinism.patch \
12 file://no-werror.patch"
13SRCREV = "c1d6b10e1ed4ba2be07f385eae5bceb694478a10"
14
15S = "${WORKDIR}/git"
16
17inherit pkgconfig
18
19export CCLD_FOR_BUILD = "${BUILD_CCLD}"
20
21# Upstream uses --add-needed in gcc.specs which gold doesn't support, so
22# enforce BFD.
23LDFLAGS += "-fuse-ld=bfd"
24
25do_compile_prepend() {
26 # Remove when https://github.com/rhboot/efivar/issues/130 is fixed
27 oe_runmake \
28 CFLAGS="${BUILD_CFLAGS}" \
29 LDFLAGS="${BUILD_LDFLAGS}" \
30 -C src makeguids
31}
32
33do_install() {
34 oe_runmake install DESTDIR=${D}
35}
36
37BBCLASSEXTEND = "native"
38
39RRECOMMENDS_${PN}_class-target = "kernel-module-efivarfs"
40
41CLEANBROKEN = "1"
diff --git a/meta/recipes-bsp/efivar/efivar_39.bb b/meta/recipes-bsp/efivar/efivar_39.bb
new file mode 100644
index 0000000000..aab319be91
--- /dev/null
+++ b/meta/recipes-bsp/efivar/efivar_39.bb
@@ -0,0 +1,34 @@
1SUMMARY = "Tools to manipulate UEFI variables"
2DESCRIPTION = "efivar provides a simple command line interface to the UEFI variable facility"
3HOMEPAGE = "https://github.com/rhboot/efivar"
4
5LICENSE = "LGPL-2.1-or-later"
6LIC_FILES_CHKSUM = "file://COPYING;md5=6626bb1e20189cfa95f2c508ba286393"
7
8COMPATIBLE_HOST = "(i.86|x86_64|arm|aarch64).*-linux"
9
10SRC_URI = "git://github.com/rhinstaller/efivar.git;branch=main;protocol=https \
11 file://0001-docs-do-not-build-efisecdb-manpage.patch \
12 "
13SRCREV = "c47820c37ac26286559ec004de07d48d05f3308c"
14PV .= "+39+git"
15
16S = "${WORKDIR}/git"
17
18inherit pkgconfig
19
20export CCLD_FOR_BUILD = "${BUILD_CCLD}"
21
22do_compile() {
23 oe_runmake ERRORS= HOST_CFLAGS="${BUILD_CFLAGS}" HOST_LDFLAGS="${BUILD_LDFLAGS}"
24}
25
26do_install() {
27 oe_runmake install DESTDIR=${D}
28}
29
30BBCLASSEXTEND = "native"
31
32RRECOMMENDS:${PN}:class-target = "kernel-module-efivarfs"
33
34CLEANBROKEN = "1"
diff --git a/meta/recipes-bsp/formfactor/files/qemuppc64/machconfig b/meta/recipes-bsp/formfactor/files/qemuppc64/machconfig
new file mode 100755
index 0000000000..e4717730ea
--- /dev/null
+++ b/meta/recipes-bsp/formfactor/files/qemuppc64/machconfig
@@ -0,0 +1,10 @@
1HAVE_TOUCHSCREEN=0
2HAVE_KEYBOARD=0
3
4DISPLAY_CAN_ROTATE=0
5DISPLAY_ORIENTATION=0
6#DISPLAY_WIDTH_PIXELS=640
7#DISPLAY_HEIGHT_PIXELS=480
8#DISPLAY_BPP=16
9DISPLAY_DPI=150
10DISPLAY_SUBPIXEL_ORDER=vrgb
diff --git a/meta/recipes-bsp/formfactor/formfactor_0.0.bb b/meta/recipes-bsp/formfactor/formfactor_0.0.bb
index ea1fa4c754..1eaf30746b 100644
--- a/meta/recipes-bsp/formfactor/formfactor_0.0.bb
+++ b/meta/recipes-bsp/formfactor/formfactor_0.0.bb
@@ -5,7 +5,6 @@ build system cannot obtain from other sources such as the kernel."
5SECTION = "base" 5SECTION = "base"
6LICENSE = "MIT" 6LICENSE = "MIT"
7LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 7LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
8PR = "r45"
9 8
10SRC_URI = "file://config file://machconfig" 9SRC_URI = "file://config file://machconfig"
11S = "${WORKDIR}" 10S = "${WORKDIR}"
diff --git a/meta/recipes-bsp/gnu-efi/gnu-efi/0001-riscv64-adjust-type-definitions.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/0001-riscv64-adjust-type-definitions.patch
new file mode 100644
index 0000000000..3475606264
--- /dev/null
+++ b/meta/recipes-bsp/gnu-efi/gnu-efi/0001-riscv64-adjust-type-definitions.patch
@@ -0,0 +1,34 @@
1From 1de509497826faa0ad84b82f5e2c3d21ee613459 Mon Sep 17 00:00:00 2001
2From: Moody Liu <mooodyhunter@outlook.com>
3Date: Sat, 13 May 2023 17:39:16 +0100
4Subject: [PATCH] riscv64: adjust type definitions
5
6CHAR8 needs to be defined while BOOLEAN should be removed
7here to prevent typedef conflicts
8
9Upstream-Status: Backport [https://sourceforge.net/p/gnu-efi/code/ci/1de509497826faa0ad84b82f5e2c3d21ee613459/]
10Signed-off-by: Moody Liu <mooodyhunter@outlook.com>
11---
12 inc/riscv64/efibind.h | 4 +---
13 1 file changed, 1 insertion(+), 3 deletions(-)
14
15diff --git a/inc/riscv64/efibind.h b/inc/riscv64/efibind.h
16index 4fdf81d..d8b4f39 100644
17--- a/inc/riscv64/efibind.h
18+++ b/inc/riscv64/efibind.h
19@@ -32,11 +32,9 @@ typedef uint16_t UINT16;
20 typedef int16_t INT16;
21 typedef uint8_t UINT8;
22 typedef int8_t INT8;
23+typedef char CHAR8;
24 typedef wchar_t CHAR16;
25 #define WCHAR CHAR16
26-#ifndef BOOLEAN
27-typedef uint8_t BOOLEAN;
28-#endif
29 #undef VOID
30 typedef void VOID;
31 typedef int64_t INTN;
32--
332.41.0
34
diff --git a/meta/recipes-bsp/gnu-efi/gnu-efi/0001-riscv64-ignore-unknown-relocs.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/0001-riscv64-ignore-unknown-relocs.patch
new file mode 100644
index 0000000000..5b3c152c5e
--- /dev/null
+++ b/meta/recipes-bsp/gnu-efi/gnu-efi/0001-riscv64-ignore-unknown-relocs.patch
@@ -0,0 +1,32 @@
1From 708f66acfec9a86f237726d45095cbd380fd83ca Mon Sep 17 00:00:00 2001
2From: Callum Farmer <gmbr3@opensuse.org>
3Date: Wed, 21 Jun 2023 11:32:28 +0100
4Subject: [PATCH] riscv64: ignore unknown relocs
5
6Sometimes ld emits relocs such as R_RISCV_64 for unwind symbols
7these don't need to be handled yet so just can be skipped otherwise
8the binary will never load
9
10Upstream-Status: Backport [https://sourceforge.net/p/gnu-efi/code/ci/708f66acfec9a86f237726d45095cbd380fd83ca/]
11Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
12---
13 gnuefi/reloc_riscv64.c | 3 +--
14 1 file changed, 1 insertion(+), 2 deletions(-)
15
16diff --git a/gnuefi/reloc_riscv64.c b/gnuefi/reloc_riscv64.c
17index 0b02d83..e429602 100644
18--- a/gnuefi/reloc_riscv64.c
19+++ b/gnuefi/reloc_riscv64.c
20@@ -81,8 +81,7 @@ EFI_STATUS EFIAPI _relocate(long ldbase, Elf_Dyn *dyn)
21 *addr = ldbase + rel->r_addend;
22 break;
23 default:
24- /* Panic */
25- while (1) ;
26+ break;
27 }
28 rel = (Elf_Rela *)((char *)rel + relent);
29 relsz -= relent;
30--
312.41.0
32
diff --git a/meta/recipes-bsp/gnu-efi/gnu-efi/lib-Makefile-fix-parallel-issue.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/lib-Makefile-fix-parallel-issue.patch
deleted file mode 100644
index dc00b8fa4d..0000000000
--- a/meta/recipes-bsp/gnu-efi/gnu-efi/lib-Makefile-fix-parallel-issue.patch
+++ /dev/null
@@ -1,38 +0,0 @@
1From 3ec8c2a70304eabd5760937a4ec3fbc4068a77ed Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Thu, 23 Apr 2015 01:49:31 -0700
4Subject: [PATCH 2/3] lib/Makefile: fix parallel issue
5
6Fixed:
7Assembler messages:
8Fatal error: can't create runtime/rtlock.o: No such file or directory
9Assembler messages:
10Fatal error: can't create runtime/rtdata.o: No such file or directory
11Assembler messages:
12Fatal error: can't create runtime/vm.o: No such file or directory
13Assembler messages:
14Fatal error: can't create runtime/efirtlib.o: No such file or directory
15
16Upstream-Status: Pending
17
18Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
19---
20 lib/Makefile | 2 ++
21 1 file changed, 2 insertions(+)
22
23diff --git a/lib/Makefile b/lib/Makefile
24index 048751a..ed39bbb 100644
25--- a/lib/Makefile
26+++ b/lib/Makefile
27@@ -74,6 +74,8 @@ all: libsubdirs libefi.a
28 libsubdirs:
29 for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
30
31+$(OBJS): libsubdirs
32+
33 libefi.a: $(OBJS)
34 $(AR) $(ARFLAGS) $@ $(OBJS)
35
36--
372.7.4
38
diff --git a/meta/recipes-bsp/gnu-efi/gnu-efi/no-werror.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/no-werror.patch
new file mode 100644
index 0000000000..db2bcf70b7
--- /dev/null
+++ b/meta/recipes-bsp/gnu-efi/gnu-efi/no-werror.patch
@@ -0,0 +1,19 @@
1Do not treat warnings as errors
2
3There are additional warnings found with musl which are
4treated as errors and fails the build, we have more combinations
5then upstream supports to handle
6
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8Upstream-Status: Inappropriate [OE specific]
9--- a/Make.defaults
10+++ b/Make.defaults
11@@ -187,7 +187,7 @@ CFLAGS += $(ARCH3264) -g -O2 -Wall -Wex
12 -funsigned-char -fshort-wchar -fno-strict-aliasing \
13 -ffreestanding -fno-stack-protector
14 else
15-CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Wno-pointer-sign -Werror \
16+CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Wno-pointer-sign \
17 -funsigned-char -fshort-wchar -fno-strict-aliasing \
18 -ffreestanding -fno-stack-protector -fno-stack-check \
19 -fno-stack-check \
diff --git a/meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch
index 8a0138bbe5..63d9b6fc31 100644
--- a/meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch
+++ b/meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch
@@ -1,7 +1,7 @@
1From 48b2cdbcd761105e8ebad412fcbf23db1ac4ef7c Mon Sep 17 00:00:00 2001 1From f56ddb00a656af2e84f839738fad19909ac65047 Mon Sep 17 00:00:00 2001
2From: Saul Wold <sgw@linux.intel.com> 2From: Saul Wold <sgw@linux.intel.com>
3Date: Sun, 9 Mar 2014 15:22:15 +0200 3Date: Sun, 9 Mar 2014 15:22:15 +0200
4Subject: [PATCH 1/3] Fix parallel make failure for archives 4Subject: [PATCH] Fix parallel make failure for archives
5 5
6Upstream-Status: Pending 6Upstream-Status: Pending
7 7
@@ -20,12 +20,16 @@ Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
20[Rebased for 3.0.8] 20[Rebased for 3.0.8]
21Signed-off-by: Yi Zhao <yi.zhao@windriver.com> 21Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
22 22
23---
24 lib/Makefile | 2 +-
25 1 file changed, 1 insertion(+), 1 deletion(-)
26
23diff --git a/lib/Makefile b/lib/Makefile 27diff --git a/lib/Makefile b/lib/Makefile
24index 0e6410d..048751a 100644 28index 1fc6a47..54b0ca7 100644
25--- a/lib/Makefile 29--- a/lib/Makefile
26+++ b/lib/Makefile 30+++ b/lib/Makefile
27@@ -75,7 +75,7 @@ libsubdirs: 31@@ -77,7 +77,7 @@ libsubdirs:
28 for sdir in $(SUBDIRS); do mkdir -p $$sdir; done 32 $(OBJS): libsubdirs
29 33
30 libefi.a: $(OBJS) 34 libefi.a: $(OBJS)
31- $(AR) $(ARFLAGS) $@ $^ 35- $(AR) $(ARFLAGS) $@ $^
@@ -33,6 +37,3 @@ index 0e6410d..048751a 100644
33 37
34 clean: 38 clean:
35 rm -f libefi.a *~ $(OBJS) */*.o 39 rm -f libefi.a *~ $(OBJS) */*.o
36--
372.7.4
38
diff --git a/meta/recipes-bsp/gnu-efi/gnu-efi_3.0.12.bb b/meta/recipes-bsp/gnu-efi/gnu-efi_3.0.17.bb
index d27126603f..43b7cc7529 100644
--- a/meta/recipes-bsp/gnu-efi/gnu-efi_3.0.12.bb
+++ b/meta/recipes-bsp/gnu-efi/gnu-efi_3.0.17.bb
@@ -2,11 +2,10 @@ SUMMARY = "Libraries for producing EFI binaries"
2HOMEPAGE = "http://sourceforge.net/projects/gnu-efi/" 2HOMEPAGE = "http://sourceforge.net/projects/gnu-efi/"
3DESCRIPTION = "GNU-EFI aims to Develop EFI applications for ARM-64, ARM-32, x86_64, IA-64 (IPF), IA-32 (x86), and MIPS platforms using the GNU toolchain and the EFI development environment." 3DESCRIPTION = "GNU-EFI aims to Develop EFI applications for ARM-64, ARM-32, x86_64, IA-64 (IPF), IA-32 (x86), and MIPS platforms using the GNU toolchain and the EFI development environment."
4SECTION = "devel" 4SECTION = "devel"
5LICENSE = "GPLv2+ | BSD-2-Clause" 5LICENSE = "GPL-2.0-or-later | BSD-2-Clause"
6LIC_FILES_CHKSUM = "file://gnuefi/crt0-efi-arm.S;beginline=4;endline=16;md5=e582764a4776e60c95bf9ab617343d36 \ 6LIC_FILES_CHKSUM = "file://gnuefi/crt0-efi-arm.S;beginline=4;endline=16;md5=e582764a4776e60c95bf9ab617343d36 \
7 file://gnuefi/crt0-efi-aarch64.S;beginline=4;endline=16;md5=e582764a4776e60c95bf9ab617343d36 \ 7 file://gnuefi/crt0-efi-aarch64.S;beginline=4;endline=16;md5=e582764a4776e60c95bf9ab617343d36 \
8 file://inc/efishellintf.h;beginline=13;endline=20;md5=202766b79d708eff3cc70fce15fb80c7 \ 8 file://inc/efishellintf.h;beginline=13;endline=20;md5=202766b79d708eff3cc70fce15fb80c7 \
9 file://inc/efishellparm.h;beginline=4;endline=11;md5=468b1231b05bbc84bae3a0d5774e3bb5 \
10 file://lib/arm/math.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \ 9 file://lib/arm/math.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \
11 file://lib/arm/initplat.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \ 10 file://lib/arm/initplat.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \
12 file://lib/aarch64/math.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \ 11 file://lib/aarch64/math.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \
@@ -15,17 +14,17 @@ LIC_FILES_CHKSUM = "file://gnuefi/crt0-efi-arm.S;beginline=4;endline=16;md5=e582
15 14
16SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/files/${BP}.tar.bz2 \ 15SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/files/${BP}.tar.bz2 \
17 file://parallel-make-archives.patch \ 16 file://parallel-make-archives.patch \
18 file://lib-Makefile-fix-parallel-issue.patch \
19 file://gnu-efi-3.0.9-fix-clang-build.patch \ 17 file://gnu-efi-3.0.9-fix-clang-build.patch \
18 file://0001-riscv64-adjust-type-definitions.patch \
19 file://0001-riscv64-ignore-unknown-relocs.patch \
20 file://no-werror.patch \
20 " 21 "
22SRC_URI[sha256sum] = "7807e903349343a7a142ebb934703a2872235e89688cf586c032b0a1087bcaf4"
21 23
22SRC_URI[md5sum] = "926763ff37bc9db3a9035cec41eb2f45" 24COMPATIBLE_HOST = "(x86_64.*|i.86.*|aarch64.*|arm.*|riscv64.*)-linux"
23SRC_URI[sha256sum] = "0196f2e1fd3c334b66e610a608a0e59233474c7a01bec7bc53989639aa327669" 25COMPATIBLE_HOST:armv4 = 'null'
24 26
25COMPATIBLE_HOST = "(x86_64.*|i.86.*|aarch64.*|arm.*)-linux" 27do_configure:linux-gnux32:prepend() {
26COMPATIBLE_HOST_armv4 = 'null'
27
28do_configure_linux-gnux32_prepend() {
29 cp ${STAGING_INCDIR}/gnu/stubs-x32.h ${STAGING_INCDIR}/gnu/stubs-64.h 28 cp ${STAGING_INCDIR}/gnu/stubs-x32.h ${STAGING_INCDIR}/gnu/stubs-64.h
30 cp ${STAGING_INCDIR}/bits/long-double-32.h ${STAGING_INCDIR}/bits/long-double-64.h 29 cp ${STAGING_INCDIR}/bits/long-double-32.h ${STAGING_INCDIR}/bits/long-double-64.h
31} 30}
@@ -37,6 +36,10 @@ def gnu_efi_arch(d):
37 return "ia32" 36 return "ia32"
38 return tarch 37 return tarch
39 38
39do_compile:prepend() {
40 unset LDFLAGS
41}
42
40EXTRA_OEMAKE = "'ARCH=${@gnu_efi_arch(d)}' 'CC=${CC}' 'AS=${AS}' 'LD=${LD}' 'AR=${AR}' \ 43EXTRA_OEMAKE = "'ARCH=${@gnu_efi_arch(d)}' 'CC=${CC}' 'AS=${AS}' 'LD=${LD}' 'AR=${AR}' \
41 'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}' 'PREFIX=${prefix}' 'LIBDIR=${libdir}' \ 44 'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}' 'PREFIX=${prefix}' 'LIBDIR=${libdir}' \
42 " 45 "
@@ -49,18 +52,18 @@ do_install() {
49 oe_runmake install INSTALLROOT="${D}" 52 oe_runmake install INSTALLROOT="${D}"
50} 53}
51 54
52FILES_${PN} += "${libdir}/*.lds" 55FILES:${PN} += "${libdir}/*.lds ${libdir}/gnuefi/apps"
53 56
54# 64-bit binaries are expected for EFI when targeting X32 57# 64-bit binaries are expected for EFI when targeting X32
55INSANE_SKIP_${PN}-dev_append_linux-gnux32 = " arch" 58INSANE_SKIP:${PN}-dev:append:linux-gnux32 = " arch"
56INSANE_SKIP_${PN}-dev_append_linux-muslx32 = " arch" 59INSANE_SKIP:${PN}-dev:append:linux-muslx32 = " arch"
57 60
58BBCLASSEXTEND = "native" 61BBCLASSEXTEND = "native"
59 62
60# It doesn't support sse, its make.defaults sets: 63# It doesn't support sse, its make.defaults sets:
61# CFLAGS += -mno-mmx -mno-sse 64# CFLAGS += -mno-mmx -mno-sse
62# So also remove -mfpmath=sse from TUNE_CCARGS 65# So also remove -mfpmath=sse from TUNE_CCARGS
63TUNE_CCARGS_remove = "-mfpmath=sse" 66TUNE_CCARGS:remove = "-mfpmath=sse"
64 67
65python () { 68python () {
66 ccargs = d.getVar('TUNE_CCARGS').split() 69 ccargs = d.getVar('TUNE_CCARGS').split()
diff --git a/meta/recipes-bsp/grub/files/0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch b/meta/recipes-bsp/grub/files/0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch
index 6b73878cc0..05a4697a73 100644
--- a/meta/recipes-bsp/grub/files/0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch
+++ b/meta/recipes-bsp/grub/files/0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch
@@ -1,4 +1,4 @@
1From 96d9aa55d29b24e2490d5647a9efc66940fc400f Mon Sep 17 00:00:00 2001 1From 006799e9c4babe8a8340a24501b253e759614a2d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 13 Jan 2016 19:17:31 +0000 3Date: Wed, 13 Jan 2016 19:17:31 +0000
4Subject: [PATCH] Disable -mfpmath=sse as well when SSE is disabled 4Subject: [PATCH] Disable -mfpmath=sse as well when SSE is disabled
@@ -24,15 +24,16 @@ Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
24Signed-off-by: Khem Raj <raj.khem@gmail.com> 24Signed-off-by: Khem Raj <raj.khem@gmail.com>
25 25
26Upstream-Status: Pending 26Upstream-Status: Pending
27
27--- 28---
28 configure.ac | 2 +- 29 configure.ac | 2 +-
29 1 file changed, 1 insertion(+), 1 deletion(-) 30 1 file changed, 1 insertion(+), 1 deletion(-)
30 31
31diff --git a/configure.ac b/configure.ac 32diff --git a/configure.ac b/configure.ac
32index 7656f24..0868ea9 100644 33index cd667a2..8263876 100644
33--- a/configure.ac 34--- a/configure.ac
34+++ b/configure.ac 35+++ b/configure.ac
35@@ -824,7 +824,7 @@ fi 36@@ -846,7 +846,7 @@ fi
36 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then 37 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then
37 # Some toolchains enable these features by default, but they need 38 # Some toolchains enable these features by default, but they need
38 # registers that aren't set up properly in GRUB. 39 # registers that aren't set up properly in GRUB.
@@ -40,4 +41,4 @@ index 7656f24..0868ea9 100644
40+ TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -mfpmath=387" 41+ TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -mfpmath=387"
41 fi 42 fi
42 43
43 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide 44 if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ); then
diff --git a/meta/recipes-bsp/grub/files/0001-RISC-V-Restore-the-typcast-to-long.patch b/meta/recipes-bsp/grub/files/0001-RISC-V-Restore-the-typcast-to-long.patch
new file mode 100644
index 0000000000..cafa711731
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/0001-RISC-V-Restore-the-typcast-to-long.patch
@@ -0,0 +1,37 @@
1From b47029e8e582d17c6874d2622fe1a5b834377dbb Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 26 Mar 2021 11:59:43 -0700
4Subject: [PATCH] RISC-V: Restore the typcast to 64bit type
5
6this makes the type promotions clear and explicit
7It was already typecasted to long but was accidentally dropped in [1]
8which stated to cause failures on riscv32 as reported in [2]
9
10[1] https://git.savannah.gnu.org/cgit/grub.git/commit/?id=2bf40e9e5be9808b17852e688eead87acff14420
11[2] https://savannah.gnu.org/bugs/index.php?60283
12
13Upstream-Status: Submitted
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15Cc: Andreas Schwab <schwab@suse.de>
16Cc: Daniel Kiper <daniel.kiper@oracle.com>
17Cc: Chester Lin <clin@suse.com>
18Cc: Nikita Ermakov <arei@altlinux.org>
19Cc: Alistair Francis <alistair.francis@wdc.com>
20
21---
22 util/grub-mkimagexx.c | 2 +-
23 1 file changed, 1 insertion(+), 1 deletion(-)
24
25diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
26index e50b295..2f09255 100644
27--- a/util/grub-mkimagexx.c
28+++ b/util/grub-mkimagexx.c
29@@ -1310,7 +1310,7 @@ SUFFIX (relocate_addrs) (Elf_Ehdr *e, struct section_metadata *smd,
30 */
31
32 sym_addr += addend;
33- off = sym_addr - target_section_addr - offset - image_target->vaddr_offset;
34+ off = (grub_int64_t)sym_addr - target_section_addr - offset - image_target->vaddr_offset;
35
36 switch (ELF_R_TYPE (info))
37 {
diff --git a/meta/recipes-bsp/grub/files/0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch b/meta/recipes-bsp/grub/files/0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch
index 69b04aa56f..69dec7695a 100644
--- a/meta/recipes-bsp/grub/files/0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch
+++ b/meta/recipes-bsp/grub/files/0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch
@@ -1,4 +1,4 @@
1From 8f47ed4aaefba087b6ca76e59c9f832b6a0702bc Mon Sep 17 00:00:00 2001 1From a80592e20f6c4b928a22862f52f268ab9d9908b2 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 13 Jan 2016 19:28:00 +0000 3Date: Wed, 13 Jan 2016 19:28:00 +0000
4Subject: [PATCH] grub.d/10_linux.in: add oe's kernel name 4Subject: [PATCH] grub.d/10_linux.in: add oe's kernel name
@@ -20,10 +20,10 @@ Upstream-Status: Inappropriate [OE specific]
20 2 files changed, 4 insertions(+), 4 deletions(-) 20 2 files changed, 4 insertions(+), 4 deletions(-)
21 21
22diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in 22diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
23index 4532266..cba2617 100644 23index cc393be..8545cb6 100644
24--- a/util/grub.d/10_linux.in 24--- a/util/grub.d/10_linux.in
25+++ b/util/grub.d/10_linux.in 25+++ b/util/grub.d/10_linux.in
26@@ -164,12 +164,12 @@ machine=`uname -m` 26@@ -166,12 +166,12 @@ machine=`uname -m`
27 case "x$machine" in 27 case "x$machine" in
28 xi?86 | xx86_64) 28 xi?86 | xx86_64)
29 list= 29 list=
@@ -40,10 +40,10 @@ index 4532266..cba2617 100644
40 done ;; 40 done ;;
41 esac 41 esac
42diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in 42diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in
43index 96179ea..98d16ae 100644 43index 94dd8be..36cd554 100644
44--- a/util/grub.d/20_linux_xen.in 44--- a/util/grub.d/20_linux_xen.in
45+++ b/util/grub.d/20_linux_xen.in 45+++ b/util/grub.d/20_linux_xen.in
46@@ -154,7 +154,7 @@ EOF 46@@ -181,7 +181,7 @@ EOF
47 } 47 }
48 48
49 linux_list= 49 linux_list=
diff --git a/meta/recipes-bsp/grub/files/6643507ce30f775008e093580f0c9499dfb2c485.patch b/meta/recipes-bsp/grub/files/6643507ce30f775008e093580f0c9499dfb2c485.patch
deleted file mode 100644
index 8aa2091444..0000000000
--- a/meta/recipes-bsp/grub/files/6643507ce30f775008e093580f0c9499dfb2c485.patch
+++ /dev/null
@@ -1,47 +0,0 @@
1From 6643507ce30f775008e093580f0c9499dfb2c485 Mon Sep 17 00:00:00 2001
2From: Simon Hardy <simon.hardy@itdev.co.uk>
3Date: Tue, 24 Mar 2020 13:29:12 +0000
4Subject: build: Fix GRUB i386-pc build with Ubuntu gcc
5
6With recent versions of gcc on Ubuntu a very large lzma_decompress.img file is
7output. (e.g. 134479600 bytes instead of 2864.) This causes grub-mkimage to
8fail with: "error: Decompressor is too big."
9
10This seems to be caused by a section .note.gnu.property that is placed at an
11offset such that objcopy needs to pad the img file with zeros.
12
13This issue is present on:
14Ubuntu 19.10 with gcc (Ubuntu 8.3.0-26ubuntu1~19.10) 8.3.0
15Ubuntu 19.10 with gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008
16
17This issue is not present on:
18Ubuntu 19.10 with gcc (Ubuntu 7.5.0-3ubuntu1~19.10) 7.5.0
19RHEL 8.0 with gcc 8.3.1 20190507 (Red Hat 8.3.1-4)
20
21The issue can be fixed by removing the section using objcopy as shown in
22this patch.
23
24Signed-off-by: Simon Hardy <simon.hardy@itdev.co.uk>
25Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
26---
27 gentpl.py | 2 +-
28 1 file changed, 1 insertion(+), 1 deletion(-)
29
30Upstream-Status: Backport
31
32diff --git a/gentpl.py b/gentpl.py
33index 387588c05..c86550d4f 100644
34--- a/gentpl.py
35+++ b/gentpl.py
36@@ -766,7 +766,7 @@ def image(defn, platform):
37 if test x$(TARGET_APPLE_LINKER) = x1; then \
38 $(MACHO2IMG) $< $@; \
39 else \
40- $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx $< $@; \
41+ $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx $< $@; \
42 fi
43 """)
44
45--
46cgit v1.2.1
47
diff --git a/meta/recipes-bsp/grub/files/CVE-2020-10713.patch b/meta/recipes-bsp/grub/files/CVE-2020-10713.patch
deleted file mode 100644
index c507ed3ea8..0000000000
--- a/meta/recipes-bsp/grub/files/CVE-2020-10713.patch
+++ /dev/null
@@ -1,73 +0,0 @@
1From a4d3fbdff1e3ca8f87642af2ac8752c30c617a3e Mon Sep 17 00:00:00 2001
2From: Peter Jones <pjones@redhat.com>
3Date: Wed, 15 Apr 2020 15:45:02 -0400
4Subject: yylex: Make lexer fatal errors actually be fatal
5
6When presented with a command that can't be tokenized to anything
7smaller than YYLMAX characters, the parser calls YY_FATAL_ERROR(errmsg),
8expecting that will stop further processing, as such:
9
10 #define YY_DO_BEFORE_ACTION \
11 yyg->yytext_ptr = yy_bp; \
12 yyleng = (int) (yy_cp - yy_bp); \
13 yyg->yy_hold_char = *yy_cp; \
14 *yy_cp = '\0'; \
15 if ( yyleng >= YYLMAX ) \
16 YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
17 yy_flex_strncpy( yytext, yyg->yytext_ptr, yyleng + 1 , yyscanner); \
18 yyg->yy_c_buf_p = yy_cp;
19
20The code flex generates expects that YY_FATAL_ERROR() will either return
21for it or do some form of longjmp(), or handle the error in some way at
22least, and so the strncpy() call isn't in an "else" clause, and thus if
23YY_FATAL_ERROR() is *not* actually fatal, it does the call with the
24questionable limit, and predictable results ensue.
25
26Unfortunately, our implementation of YY_FATAL_ERROR() is:
27
28 #define YY_FATAL_ERROR(msg) \
29 do { \
30 grub_printf (_("fatal error: %s\n"), _(msg)); \
31 } while (0)
32
33The same pattern exists in yyless(), and similar problems exist in users
34of YY_INPUT(), several places in the main parsing loop,
35yy_get_next_buffer(), yy_load_buffer_state(), yyensure_buffer_stack,
36yy_scan_buffer(), etc.
37
38All of these callers expect YY_FATAL_ERROR() to actually be fatal, and
39the things they do if it returns after calling it are wildly unsafe.
40
41Fixes: CVE-2020-10713
42
43Signed-off-by: Peter Jones <pjones@redhat.com>
44Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
45
46Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=a4d3fbdff1e3ca8f87642af2ac8752c30c617a3e]
47CVE: CVE-2020-10713
48Signed-off-by: Chee Yang Lee <chee.yang.lee@intel.com>
49---
50 grub-core/script/yylex.l | 4 ++--
51 1 file changed, 2 insertions(+), 2 deletions(-)
52
53diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l
54index 7b44c37b7..b7203c823 100644
55--- a/grub-core/script/yylex.l
56+++ b/grub-core/script/yylex.l
57@@ -37,11 +37,11 @@
58
59 /*
60 * As we don't have access to yyscanner, we cannot do much except to
61- * print the fatal error.
62+ * print the fatal error and exit.
63 */
64 #define YY_FATAL_ERROR(msg) \
65 do { \
66- grub_printf (_("fatal error: %s\n"), _(msg)); \
67+ grub_fatal (_("fatal error: %s\n"), _(msg));\
68 } while (0)
69
70 #define COPY(str, hint) \
71--
72cgit v1.2.1
73
diff --git a/meta/recipes-bsp/grub/files/CVE-2020-14308-calloc-Use-calloc-at-most-places.patch b/meta/recipes-bsp/grub/files/CVE-2020-14308-calloc-Use-calloc-at-most-places.patch
deleted file mode 100644
index 637e368cb0..0000000000
--- a/meta/recipes-bsp/grub/files/CVE-2020-14308-calloc-Use-calloc-at-most-places.patch
+++ /dev/null
@@ -1,1863 +0,0 @@
1From bcdd6a55952222ec9829a59348240a4f983b0b56 Mon Sep 17 00:00:00 2001
2From: Peter Jones <pjones@redhat.com>
3Date: Mon, 15 Jun 2020 12:26:01 -0400
4Subject: [PATCH 4/9] calloc: Use calloc() at most places
5
6This modifies most of the places we do some form of:
7
8 X = malloc(Y * Z);
9
10to use calloc(Y, Z) instead.
11
12Among other issues, this fixes:
13 - allocation of integer overflow in grub_png_decode_image_header()
14 reported by Chris Coulson,
15 - allocation of integer overflow in luks_recover_key()
16 reported by Chris Coulson,
17 - allocation of integer overflow in grub_lvm_detect()
18 reported by Chris Coulson.
19
20Fixes: CVE-2020-14308
21
22Signed-off-by: Peter Jones <pjones@redhat.com>
23Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
24
25Upstream-Status: Backport
26CVE: CVE-2020-14308
27
28Reference to upstream patch:
29https://git.savannah.gnu.org/cgit/grub.git/commit/?id=f725fa7cb2ece547c5af01eeeecfe8d95802ed41
30
31[YL: don't patch on grub-core/lib/json/json.c, which is not existing in grub 2.04]
32Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
33---
34 grub-core/bus/usb/usbhub.c | 8 ++++----
35 grub-core/commands/efi/lsefisystab.c | 3 ++-
36 grub-core/commands/legacycfg.c | 6 +++---
37 grub-core/commands/menuentry.c | 2 +-
38 grub-core/commands/nativedisk.c | 2 +-
39 grub-core/commands/parttool.c | 12 +++++++++---
40 grub-core/commands/regexp.c | 2 +-
41 grub-core/commands/search_wrap.c | 2 +-
42 grub-core/disk/diskfilter.c | 4 ++--
43 grub-core/disk/ieee1275/ofdisk.c | 2 +-
44 grub-core/disk/ldm.c | 14 +++++++-------
45 grub-core/disk/luks.c | 2 +-
46 grub-core/disk/lvm.c | 12 ++++++------
47 grub-core/disk/xen/xendisk.c | 2 +-
48 grub-core/efiemu/loadcore.c | 2 +-
49 grub-core/efiemu/mm.c | 6 +++---
50 grub-core/font/font.c | 3 +--
51 grub-core/fs/affs.c | 6 +++---
52 grub-core/fs/btrfs.c | 6 +++---
53 grub-core/fs/hfs.c | 2 +-
54 grub-core/fs/hfsplus.c | 6 +++---
55 grub-core/fs/iso9660.c | 2 +-
56 grub-core/fs/ntfs.c | 4 ++--
57 grub-core/fs/sfs.c | 2 +-
58 grub-core/fs/tar.c | 2 +-
59 grub-core/fs/udf.c | 4 ++--
60 grub-core/fs/zfs/zfs.c | 4 ++--
61 grub-core/gfxmenu/gui_string_util.c | 2 +-
62 grub-core/gfxmenu/widget-box.c | 4 ++--
63 grub-core/io/gzio.c | 2 +-
64 grub-core/kern/efi/efi.c | 6 +++---
65 grub-core/kern/emu/hostdisk.c | 2 +-
66 grub-core/kern/fs.c | 2 +-
67 grub-core/kern/misc.c | 2 +-
68 grub-core/kern/parser.c | 2 +-
69 grub-core/kern/uboot/uboot.c | 2 +-
70 grub-core/lib/libgcrypt/cipher/ac.c | 8 ++++----
71 grub-core/lib/libgcrypt/cipher/primegen.c | 4 ++--
72 grub-core/lib/libgcrypt/cipher/pubkey.c | 4 ++--
73 grub-core/lib/priority_queue.c | 2 +-
74 grub-core/lib/reed_solomon.c | 7 +++----
75 grub-core/lib/relocator.c | 10 +++++-----
76 grub-core/lib/zstd/fse_decompress.c | 2 +-
77 grub-core/loader/arm/linux.c | 2 +-
78 grub-core/loader/efi/chainloader.c | 2 +-
79 grub-core/loader/i386/bsdXX.c | 2 +-
80 grub-core/loader/i386/xnu.c | 4 ++--
81 grub-core/loader/macho.c | 2 +-
82 grub-core/loader/multiboot_elfxx.c | 2 +-
83 grub-core/loader/xnu.c | 2 +-
84 grub-core/mmap/mmap.c | 4 ++--
85 grub-core/net/bootp.c | 2 +-
86 grub-core/net/dns.c | 10 +++++-----
87 grub-core/net/net.c | 4 ++--
88 grub-core/normal/charset.c | 10 +++++-----
89 grub-core/normal/cmdline.c | 14 +++++++-------
90 grub-core/normal/menu_entry.c | 14 +++++++-------
91 grub-core/normal/menu_text.c | 4 ++--
92 grub-core/normal/term.c | 4 ++--
93 grub-core/osdep/linux/getroot.c | 6 +++---
94 grub-core/osdep/unix/config.c | 2 +-
95 grub-core/osdep/windows/getroot.c | 2 +-
96 grub-core/osdep/windows/hostdisk.c | 4 ++--
97 grub-core/osdep/windows/init.c | 2 +-
98 grub-core/osdep/windows/platform.c | 4 ++--
99 grub-core/osdep/windows/relpath.c | 2 +-
100 grub-core/partmap/gpt.c | 2 +-
101 grub-core/partmap/msdos.c | 2 +-
102 grub-core/script/execute.c | 2 +-
103 grub-core/tests/fake_input.c | 2 +-
104 grub-core/tests/video_checksum.c | 6 +++---
105 grub-core/video/capture.c | 2 +-
106 grub-core/video/emu/sdl.c | 2 +-
107 grub-core/video/i386/pc/vga.c | 2 +-
108 grub-core/video/readers/png.c | 2 +-
109 include/grub/unicode.h | 4 ++--
110 util/getroot.c | 2 +-
111 util/grub-file.c | 2 +-
112 util/grub-fstest.c | 4 ++--
113 util/grub-install-common.c | 2 +-
114 util/grub-install.c | 4 ++--
115 util/grub-mkimagexx.c | 6 ++----
116 util/grub-mkrescue.c | 4 ++--
117 util/grub-mkstandalone.c | 2 +-
118 util/grub-pe2elf.c | 12 +++++-------
119 util/grub-probe.c | 4 ++--
120 86 files changed, 178 insertions(+), 177 deletions(-)
121
122diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
123index 34a7ff1..a06cce3 100644
124--- a/grub-core/bus/usb/usbhub.c
125+++ b/grub-core/bus/usb/usbhub.c
126@@ -149,8 +149,8 @@ grub_usb_add_hub (grub_usb_device_t dev)
127 grub_usb_set_configuration (dev, 1);
128
129 dev->nports = hubdesc.portcnt;
130- dev->children = grub_zalloc (hubdesc.portcnt * sizeof (dev->children[0]));
131- dev->ports = grub_zalloc (dev->nports * sizeof (dev->ports[0]));
132+ dev->children = grub_calloc (hubdesc.portcnt, sizeof (dev->children[0]));
133+ dev->ports = grub_calloc (dev->nports, sizeof (dev->ports[0]));
134 if (!dev->children || !dev->ports)
135 {
136 grub_free (dev->children);
137@@ -268,8 +268,8 @@ grub_usb_controller_dev_register_iter (grub_usb_controller_t controller, void *d
138
139 /* Query the number of ports the root Hub has. */
140 hub->nports = controller->dev->hubports (controller);
141- hub->devices = grub_zalloc (sizeof (hub->devices[0]) * hub->nports);
142- hub->ports = grub_zalloc (sizeof (hub->ports[0]) * hub->nports);
143+ hub->devices = grub_calloc (hub->nports, sizeof (hub->devices[0]));
144+ hub->ports = grub_calloc (hub->nports, sizeof (hub->ports[0]));
145 if (!hub->devices || !hub->ports)
146 {
147 grub_free (hub->devices);
148diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c
149index df10302..cd81507 100644
150--- a/grub-core/commands/efi/lsefisystab.c
151+++ b/grub-core/commands/efi/lsefisystab.c
152@@ -71,7 +71,8 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)),
153 grub_printf ("Vendor: ");
154
155 for (vendor_utf16 = st->firmware_vendor; *vendor_utf16; vendor_utf16++);
156- vendor = grub_malloc (4 * (vendor_utf16 - st->firmware_vendor) + 1);
157+ /* Allocate extra 3 bytes to simplify math. */
158+ vendor = grub_calloc (4, vendor_utf16 - st->firmware_vendor + 1);
159 if (!vendor)
160 return grub_errno;
161 *grub_utf16_to_utf8 ((grub_uint8_t *) vendor, st->firmware_vendor,
162diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
163index db7a8f0..5e3ec0d 100644
164--- a/grub-core/commands/legacycfg.c
165+++ b/grub-core/commands/legacycfg.c
166@@ -314,7 +314,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
167 if (argc < 2)
168 return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
169
170- cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1));
171+ cutargs = grub_calloc (argc - 1, sizeof (cutargs[0]));
172 if (!cutargs)
173 return grub_errno;
174 cutargc = argc - 1;
175@@ -436,7 +436,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
176 {
177 char rbuf[3] = "-r";
178 bsdargc = cutargc + 2;
179- bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc);
180+ bsdargs = grub_calloc (bsdargc, sizeof (bsdargs[0]));
181 if (!bsdargs)
182 {
183 err = grub_errno;
184@@ -559,7 +559,7 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused
185 return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"),
186 "module");
187
188- newargs = grub_malloc ((argc + 1) * sizeof (newargs[0]));
189+ newargs = grub_calloc (argc + 1, sizeof (newargs[0]));
190 if (!newargs)
191 return grub_errno;
192 grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0]));
193diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c
194index 2c5363d..9164df7 100644
195--- a/grub-core/commands/menuentry.c
196+++ b/grub-core/commands/menuentry.c
197@@ -154,7 +154,7 @@ grub_normal_add_menu_entry (int argc, const char **args,
198 goto fail;
199
200 /* Save argc, args to pass as parameters to block arg later. */
201- menu_args = grub_malloc (sizeof (char*) * (argc + 1));
202+ menu_args = grub_calloc (argc + 1, sizeof (char *));
203 if (! menu_args)
204 goto fail;
205
206diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c
207index 699447d..7c8f97f 100644
208--- a/grub-core/commands/nativedisk.c
209+++ b/grub-core/commands/nativedisk.c
210@@ -195,7 +195,7 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
211 else
212 path_prefix = prefix;
213
214- mods = grub_malloc (argc * sizeof (mods[0]));
215+ mods = grub_calloc (argc, sizeof (mods[0]));
216 if (!mods)
217 return grub_errno;
218
219diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c
220index 22b46b1..051e313 100644
221--- a/grub-core/commands/parttool.c
222+++ b/grub-core/commands/parttool.c
223@@ -59,7 +59,13 @@ grub_parttool_register(const char *part_name,
224 for (nargs = 0; args[nargs].name != 0; nargs++);
225 cur->nargs = nargs;
226 cur->args = (struct grub_parttool_argdesc *)
227- grub_malloc ((nargs + 1) * sizeof (struct grub_parttool_argdesc));
228+ grub_calloc (nargs + 1, sizeof (struct grub_parttool_argdesc));
229+ if (!cur->args)
230+ {
231+ grub_free (cur);
232+ curhandle--;
233+ return -1;
234+ }
235 grub_memcpy (cur->args, args,
236 (nargs + 1) * sizeof (struct grub_parttool_argdesc));
237
238@@ -257,7 +263,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
239 return err;
240 }
241
242- parsed = (int *) grub_zalloc (argc * sizeof (int));
243+ parsed = (int *) grub_calloc (argc, sizeof (int));
244
245 for (i = 1; i < argc; i++)
246 if (! parsed[i])
247@@ -290,7 +296,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
248 }
249 ptool = cur;
250 pargs = (struct grub_parttool_args *)
251- grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args));
252+ grub_calloc (ptool->nargs, sizeof (struct grub_parttool_args));
253 for (j = i; j < argc; j++)
254 if (! parsed[j])
255 {
256diff --git a/grub-core/commands/regexp.c b/grub-core/commands/regexp.c
257index f00b184..4019164 100644
258--- a/grub-core/commands/regexp.c
259+++ b/grub-core/commands/regexp.c
260@@ -116,7 +116,7 @@ grub_cmd_regexp (grub_extcmd_context_t ctxt, int argc, char **args)
261 if (ret)
262 goto fail;
263
264- matches = grub_zalloc (sizeof (*matches) * (regex.re_nsub + 1));
265+ matches = grub_calloc (regex.re_nsub + 1, sizeof (*matches));
266 if (! matches)
267 goto fail;
268
269diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c
270index d7fd26b..47fc8eb 100644
271--- a/grub-core/commands/search_wrap.c
272+++ b/grub-core/commands/search_wrap.c
273@@ -122,7 +122,7 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args)
274 for (i = 0; state[SEARCH_HINT_BAREMETAL].args[i]; i++)
275 nhints++;
276
277- hints = grub_malloc (sizeof (hints[0]) * nhints);
278+ hints = grub_calloc (nhints, sizeof (hints[0]));
279 if (!hints)
280 return grub_errno;
281 j = 0;
282diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c
283index c3b578a..68ca9e0 100644
284--- a/grub-core/disk/diskfilter.c
285+++ b/grub-core/disk/diskfilter.c
286@@ -1134,7 +1134,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb,
287 array->lvs->segments->node_count = nmemb;
288 array->lvs->segments->raid_member_size = disk_size;
289 array->lvs->segments->nodes
290- = grub_zalloc (nmemb * sizeof (array->lvs->segments->nodes[0]));
291+ = grub_calloc (nmemb, sizeof (array->lvs->segments->nodes[0]));
292 array->lvs->segments->stripe_size = stripe_size;
293 for (i = 0; i < nmemb; i++)
294 {
295@@ -1226,7 +1226,7 @@ insert_array (grub_disk_t disk, const struct grub_diskfilter_pv_id *id,
296 grub_partition_t p;
297 for (p = disk->partition; p; p = p->parent)
298 s++;
299- pv->partmaps = xmalloc (s * sizeof (pv->partmaps[0]));
300+ pv->partmaps = xcalloc (s, sizeof (pv->partmaps[0]));
301 s = 0;
302 for (p = disk->partition; p; p = p->parent)
303 pv->partmaps[s++] = xstrdup (p->partmap->name);
304diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
305index f73257e..03674cb 100644
306--- a/grub-core/disk/ieee1275/ofdisk.c
307+++ b/grub-core/disk/ieee1275/ofdisk.c
308@@ -297,7 +297,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
309 /* Power machines documentation specify 672 as maximum SAS disks in
310 one system. Using a slightly larger value to be safe. */
311 table_size = 768;
312- table = grub_malloc (table_size * sizeof (grub_uint64_t));
313+ table = grub_calloc (table_size, sizeof (grub_uint64_t));
314
315 if (!table)
316 {
317diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
318index 2a22d2d..e632370 100644
319--- a/grub-core/disk/ldm.c
320+++ b/grub-core/disk/ldm.c
321@@ -323,8 +323,8 @@ make_vg (grub_disk_t disk,
322 lv->segments->type = GRUB_DISKFILTER_MIRROR;
323 lv->segments->node_count = 0;
324 lv->segments->node_alloc = 8;
325- lv->segments->nodes = grub_zalloc (sizeof (*lv->segments->nodes)
326- * lv->segments->node_alloc);
327+ lv->segments->nodes = grub_calloc (lv->segments->node_alloc,
328+ sizeof (*lv->segments->nodes));
329 if (!lv->segments->nodes)
330 goto fail2;
331 ptr = vblk[i].dynamic;
332@@ -543,8 +543,8 @@ make_vg (grub_disk_t disk,
333 {
334 comp->segment_alloc = 8;
335 comp->segment_count = 0;
336- comp->segments = grub_malloc (sizeof (*comp->segments)
337- * comp->segment_alloc);
338+ comp->segments = grub_calloc (comp->segment_alloc,
339+ sizeof (*comp->segments));
340 if (!comp->segments)
341 goto fail2;
342 }
343@@ -590,8 +590,8 @@ make_vg (grub_disk_t disk,
344 }
345 comp->segments->node_count = read_int (ptr + 1, *ptr);
346 comp->segments->node_alloc = comp->segments->node_count;
347- comp->segments->nodes = grub_zalloc (sizeof (*comp->segments->nodes)
348- * comp->segments->node_alloc);
349+ comp->segments->nodes = grub_calloc (comp->segments->node_alloc,
350+ sizeof (*comp->segments->nodes));
351 if (!lv->segments->nodes)
352 goto fail2;
353 }
354@@ -1017,7 +1017,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors,
355 *nsectors = lv->size;
356 if (*nsectors > max_nsectors)
357 *nsectors = max_nsectors;
358- *sectors = grub_malloc (*nsectors * sizeof (**sectors));
359+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
360 if (!*sectors)
361 return grub_errno;
362 for (i = 0; i < *nsectors; i++)
363diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c
364index 86c50c6..18b3a8b 100644
365--- a/grub-core/disk/luks.c
366+++ b/grub-core/disk/luks.c
367@@ -336,7 +336,7 @@ luks_recover_key (grub_disk_t source,
368 && grub_be_to_cpu32 (header.keyblock[i].stripes) > max_stripes)
369 max_stripes = grub_be_to_cpu32 (header.keyblock[i].stripes);
370
371- split_key = grub_malloc (keysize * max_stripes);
372+ split_key = grub_calloc (keysize, max_stripes);
373 if (!split_key)
374 return grub_errno;
375
376diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
377index dc6b83b..7b5fbbc 100644
378--- a/grub-core/disk/lvm.c
379+++ b/grub-core/disk/lvm.c
380@@ -209,7 +209,7 @@ grub_lvm_detect (grub_disk_t disk,
381 first one. */
382
383 /* Allocate buffer space for the circular worst-case scenario. */
384- metadatabuf = grub_malloc (2 * mda_size);
385+ metadatabuf = grub_calloc (2, mda_size);
386 if (! metadatabuf)
387 goto fail;
388
389@@ -464,7 +464,7 @@ grub_lvm_detect (grub_disk_t disk,
390 #endif
391 goto lvs_fail;
392 }
393- lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count);
394+ lv->segments = grub_calloc (lv->segment_count, sizeof (*seg));
395 seg = lv->segments;
396
397 for (i = 0; i < lv->segment_count; i++)
398@@ -521,8 +521,8 @@ grub_lvm_detect (grub_disk_t disk,
399 if (seg->node_count != 1)
400 seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = ");
401
402- seg->nodes = grub_zalloc (sizeof (*stripe)
403- * seg->node_count);
404+ seg->nodes = grub_calloc (seg->node_count,
405+ sizeof (*stripe));
406 stripe = seg->nodes;
407
408 p = grub_strstr (p, "stripes = [");
409@@ -898,7 +898,7 @@ grub_lvm_detect (grub_disk_t disk,
410 break;
411 if (lv)
412 {
413- cache->lv->segments = grub_malloc (lv->segment_count * sizeof (*lv->segments));
414+ cache->lv->segments = grub_calloc (lv->segment_count, sizeof (*lv->segments));
415 if (!cache->lv->segments)
416 {
417 grub_lvm_free_cache_lvs (cache_lvs);
418@@ -911,7 +911,7 @@ grub_lvm_detect (grub_disk_t disk,
419 struct grub_diskfilter_node *nodes = lv->segments[i].nodes;
420 grub_size_t node_count = lv->segments[i].node_count;
421
422- cache->lv->segments[i].nodes = grub_malloc (node_count * sizeof (*nodes));
423+ cache->lv->segments[i].nodes = grub_calloc (node_count, sizeof (*nodes));
424 if (!cache->lv->segments[i].nodes)
425 {
426 for (j = 0; j < i; ++j)
427diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c
428index 48476cb..d6612ee 100644
429--- a/grub-core/disk/xen/xendisk.c
430+++ b/grub-core/disk/xen/xendisk.c
431@@ -426,7 +426,7 @@ grub_xendisk_init (void)
432 if (!ctr)
433 return;
434
435- virtdisks = grub_malloc (ctr * sizeof (virtdisks[0]));
436+ virtdisks = grub_calloc (ctr, sizeof (virtdisks[0]));
437 if (!virtdisks)
438 return;
439 if (grub_xenstore_dir ("device/vbd", fill, &ctr))
440diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c
441index 44085ef..2b92462 100644
442--- a/grub-core/efiemu/loadcore.c
443+++ b/grub-core/efiemu/loadcore.c
444@@ -201,7 +201,7 @@ grub_efiemu_count_symbols (const Elf_Ehdr *e)
445
446 grub_efiemu_nelfsyms = (unsigned) s->sh_size / (unsigned) s->sh_entsize;
447 grub_efiemu_elfsyms = (struct grub_efiemu_elf_sym *)
448- grub_malloc (sizeof (struct grub_efiemu_elf_sym) * grub_efiemu_nelfsyms);
449+ grub_calloc (grub_efiemu_nelfsyms, sizeof (struct grub_efiemu_elf_sym));
450
451 /* Relocators */
452 for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
453diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c
454index 52a032f..9b8e0d0 100644
455--- a/grub-core/efiemu/mm.c
456+++ b/grub-core/efiemu/mm.c
457@@ -554,11 +554,11 @@ grub_efiemu_mmap_sort_and_uniq (void)
458 /* Initialize variables*/
459 grub_memset (present, 0, sizeof (int) * GRUB_EFI_MAX_MEMORY_TYPE);
460 scanline_events = (struct grub_efiemu_mmap_scan *)
461- grub_malloc (sizeof (struct grub_efiemu_mmap_scan) * 2 * mmap_num);
462+ grub_calloc (mmap_num, sizeof (struct grub_efiemu_mmap_scan) * 2);
463
464 /* Number of chunks can't increase more than by factor of 2 */
465 result = (grub_efi_memory_descriptor_t *)
466- grub_malloc (sizeof (grub_efi_memory_descriptor_t) * 2 * mmap_num);
467+ grub_calloc (mmap_num, sizeof (grub_efi_memory_descriptor_t) * 2);
468 if (!result || !scanline_events)
469 {
470 grub_free (result);
471@@ -660,7 +660,7 @@ grub_efiemu_mm_do_alloc (void)
472
473 /* Preallocate mmap */
474 efiemu_mmap = (grub_efi_memory_descriptor_t *)
475- grub_malloc (mmap_reserved_size * sizeof (grub_efi_memory_descriptor_t));
476+ grub_calloc (mmap_reserved_size, sizeof (grub_efi_memory_descriptor_t));
477 if (!efiemu_mmap)
478 {
479 grub_efiemu_unload ();
480diff --git a/grub-core/font/font.c b/grub-core/font/font.c
481index 85a2925..8e118b3 100644
482--- a/grub-core/font/font.c
483+++ b/grub-core/font/font.c
484@@ -293,8 +293,7 @@ load_font_index (grub_file_t file, grub_uint32_t sect_length, struct
485 font->num_chars = sect_length / FONT_CHAR_INDEX_ENTRY_SIZE;
486
487 /* Allocate the character index array. */
488- font->char_index = grub_malloc (font->num_chars
489- * sizeof (struct char_index_entry));
490+ font->char_index = grub_calloc (font->num_chars, sizeof (struct char_index_entry));
491 if (!font->char_index)
492 return 1;
493 font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
494diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c
495index 6b6a2bc..220b371 100644
496--- a/grub-core/fs/affs.c
497+++ b/grub-core/fs/affs.c
498@@ -301,7 +301,7 @@ grub_affs_read_symlink (grub_fshelp_node_t node)
499 return 0;
500 }
501 latin1[symlink_size] = 0;
502- utf8 = grub_malloc (symlink_size * GRUB_MAX_UTF8_PER_LATIN1 + 1);
503+ utf8 = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, symlink_size);
504 if (!utf8)
505 {
506 grub_free (latin1);
507@@ -422,7 +422,7 @@ grub_affs_iterate_dir (grub_fshelp_node_t dir,
508 return 1;
509 }
510
511- hashtable = grub_zalloc (data->htsize * sizeof (*hashtable));
512+ hashtable = grub_calloc (data->htsize, sizeof (*hashtable));
513 if (!hashtable)
514 return 1;
515
516@@ -628,7 +628,7 @@ grub_affs_label (grub_device_t device, char **label)
517 len = file.namelen;
518 if (len > sizeof (file.name))
519 len = sizeof (file.name);
520- *label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1);
521+ *label = grub_calloc (GRUB_MAX_UTF8_PER_LATIN1 + 1, len);
522 if (*label)
523 *grub_latin1_to_utf8 ((grub_uint8_t *) *label, file.name, len) = '\0';
524 }
525diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
526index 48bd3d0..11272ef 100644
527--- a/grub-core/fs/btrfs.c
528+++ b/grub-core/fs/btrfs.c
529@@ -413,7 +413,7 @@ lower_bound (struct grub_btrfs_data *data,
530 {
531 desc->allocated = 16;
532 desc->depth = 0;
533- desc->data = grub_malloc (sizeof (desc->data[0]) * desc->allocated);
534+ desc->data = grub_calloc (desc->allocated, sizeof (desc->data[0]));
535 if (!desc->data)
536 return grub_errno;
537 }
538@@ -752,7 +752,7 @@ raid56_read_retry (struct grub_btrfs_data *data,
539 grub_err_t ret = GRUB_ERR_OUT_OF_MEMORY;
540 grub_uint64_t i, failed_devices;
541
542- buffers = grub_zalloc (sizeof(*buffers) * nstripes);
543+ buffers = grub_calloc (nstripes, sizeof (*buffers));
544 if (!buffers)
545 goto cleanup;
546
547@@ -2160,7 +2160,7 @@ grub_btrfs_embed (grub_device_t device __attribute__ ((unused)),
548 *nsectors = 64 * 2 - 1;
549 if (*nsectors > max_nsectors)
550 *nsectors = max_nsectors;
551- *sectors = grub_malloc (*nsectors * sizeof (**sectors));
552+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
553 if (!*sectors)
554 return grub_errno;
555 for (i = 0; i < *nsectors; i++)
556diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c
557index ac0a409..3fe842b 100644
558--- a/grub-core/fs/hfs.c
559+++ b/grub-core/fs/hfs.c
560@@ -1360,7 +1360,7 @@ grub_hfs_label (grub_device_t device, char **label)
561 grub_size_t len = data->sblock.volname[0];
562 if (len > sizeof (data->sblock.volname) - 1)
563 len = sizeof (data->sblock.volname) - 1;
564- *label = grub_malloc (len * MAX_UTF8_PER_MAC_ROMAN + 1);
565+ *label = grub_calloc (MAX_UTF8_PER_MAC_ROMAN + 1, len);
566 if (*label)
567 macroman_to_utf8 (*label, data->sblock.volname + 1,
568 len + 1, 0);
569diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c
570index 54786bb..dae43be 100644
571--- a/grub-core/fs/hfsplus.c
572+++ b/grub-core/fs/hfsplus.c
573@@ -720,7 +720,7 @@ list_nodes (void *record, void *hook_arg)
574 if (! filename)
575 return 0;
576
577- keyname = grub_malloc (grub_be_to_cpu16 (catkey->namelen) * sizeof (*keyname));
578+ keyname = grub_calloc (grub_be_to_cpu16 (catkey->namelen), sizeof (*keyname));
579 if (!keyname)
580 {
581 grub_free (filename);
582@@ -1007,7 +1007,7 @@ grub_hfsplus_label (grub_device_t device, char **label)
583 grub_hfsplus_btree_recptr (&data->catalog_tree, node, ptr);
584
585 label_len = grub_be_to_cpu16 (catkey->namelen);
586- label_name = grub_malloc (label_len * sizeof (*label_name));
587+ label_name = grub_calloc (label_len, sizeof (*label_name));
588 if (!label_name)
589 {
590 grub_free (node);
591@@ -1029,7 +1029,7 @@ grub_hfsplus_label (grub_device_t device, char **label)
592 }
593 }
594
595- *label = grub_malloc (label_len * GRUB_MAX_UTF8_PER_UTF16 + 1);
596+ *label = grub_calloc (label_len, GRUB_MAX_UTF8_PER_UTF16 + 1);
597 if (! *label)
598 {
599 grub_free (label_name);
600diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c
601index 49c0c63..4f1b52a 100644
602--- a/grub-core/fs/iso9660.c
603+++ b/grub-core/fs/iso9660.c
604@@ -331,7 +331,7 @@ grub_iso9660_convert_string (grub_uint8_t *us, int len)
605 int i;
606 grub_uint16_t t[MAX_NAMELEN / 2 + 1];
607
608- p = grub_malloc (len * GRUB_MAX_UTF8_PER_UTF16 + 1);
609+ p = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1);
610 if (! p)
611 return NULL;
612
613diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c
614index fc4e1f6..2f34f76 100644
615--- a/grub-core/fs/ntfs.c
616+++ b/grub-core/fs/ntfs.c
617@@ -556,8 +556,8 @@ get_utf8 (grub_uint8_t *in, grub_size_t len)
618 grub_uint16_t *tmp;
619 grub_size_t i;
620
621- buf = grub_malloc (len * GRUB_MAX_UTF8_PER_UTF16 + 1);
622- tmp = grub_malloc (len * sizeof (tmp[0]));
623+ buf = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1);
624+ tmp = grub_calloc (len, sizeof (tmp[0]));
625 if (!buf || !tmp)
626 {
627 grub_free (buf);
628diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c
629index 50c1fe7..90f7fb3 100644
630--- a/grub-core/fs/sfs.c
631+++ b/grub-core/fs/sfs.c
632@@ -266,7 +266,7 @@ grub_sfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
633 node->next_extent = node->block;
634 node->cache_size = 0;
635
636- node->cache = grub_malloc (sizeof (node->cache[0]) * cache_size);
637+ node->cache = grub_calloc (cache_size, sizeof (node->cache[0]));
638 if (!node->cache)
639 {
640 grub_errno = 0;
641diff --git a/grub-core/fs/tar.c b/grub-core/fs/tar.c
642index 7d63e0c..c551ed6 100644
643--- a/grub-core/fs/tar.c
644+++ b/grub-core/fs/tar.c
645@@ -120,7 +120,7 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
646 if (data->linkname_alloc < linksize + 1)
647 {
648 char *n;
649- n = grub_malloc (2 * (linksize + 1));
650+ n = grub_calloc (2, linksize + 1);
651 if (!n)
652 return grub_errno;
653 grub_free (data->linkname);
654diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c
655index dc8b6e2..a837616 100644
656--- a/grub-core/fs/udf.c
657+++ b/grub-core/fs/udf.c
658@@ -873,7 +873,7 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf)
659 {
660 unsigned i;
661 utf16len = sz - 1;
662- utf16 = grub_malloc (utf16len * sizeof (utf16[0]));
663+ utf16 = grub_calloc (utf16len, sizeof (utf16[0]));
664 if (!utf16)
665 return NULL;
666 for (i = 0; i < utf16len; i++)
667@@ -883,7 +883,7 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf)
668 {
669 unsigned i;
670 utf16len = (sz - 1) / 2;
671- utf16 = grub_malloc (utf16len * sizeof (utf16[0]));
672+ utf16 = grub_calloc (utf16len, sizeof (utf16[0]));
673 if (!utf16)
674 return NULL;
675 for (i = 0; i < utf16len; i++)
676diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
677index 2f72e42..381dde5 100644
678--- a/grub-core/fs/zfs/zfs.c
679+++ b/grub-core/fs/zfs/zfs.c
680@@ -3325,7 +3325,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol,
681 }
682 subvol->nkeys = 0;
683 zap_iterate (&keychain_dn, 8, count_zap_keys, &ctx, data);
684- subvol->keyring = grub_zalloc (subvol->nkeys * sizeof (subvol->keyring[0]));
685+ subvol->keyring = grub_calloc (subvol->nkeys, sizeof (subvol->keyring[0]));
686 if (!subvol->keyring)
687 {
688 grub_free (fsname);
689@@ -4336,7 +4336,7 @@ grub_zfs_embed (grub_device_t device __attribute__ ((unused)),
690 *nsectors = (VDEV_BOOT_SIZE >> GRUB_DISK_SECTOR_BITS);
691 if (*nsectors > max_nsectors)
692 *nsectors = max_nsectors;
693- *sectors = grub_malloc (*nsectors * sizeof (**sectors));
694+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
695 if (!*sectors)
696 return grub_errno;
697 for (i = 0; i < *nsectors; i++)
698diff --git a/grub-core/gfxmenu/gui_string_util.c b/grub-core/gfxmenu/gui_string_util.c
699index a9a415e..ba1e1ea 100644
700--- a/grub-core/gfxmenu/gui_string_util.c
701+++ b/grub-core/gfxmenu/gui_string_util.c
702@@ -55,7 +55,7 @@ canonicalize_path (const char *path)
703 if (*p == '/')
704 components++;
705
706- char **path_array = grub_malloc (components * sizeof (*path_array));
707+ char **path_array = grub_calloc (components, sizeof (*path_array));
708 if (! path_array)
709 return 0;
710
711diff --git a/grub-core/gfxmenu/widget-box.c b/grub-core/gfxmenu/widget-box.c
712index b606028..470597d 100644
713--- a/grub-core/gfxmenu/widget-box.c
714+++ b/grub-core/gfxmenu/widget-box.c
715@@ -303,10 +303,10 @@ grub_gfxmenu_create_box (const char *pixmaps_prefix,
716 box->content_height = 0;
717 box->raw_pixmaps =
718 (struct grub_video_bitmap **)
719- grub_malloc (BOX_NUM_PIXMAPS * sizeof (struct grub_video_bitmap *));
720+ grub_calloc (BOX_NUM_PIXMAPS, sizeof (struct grub_video_bitmap *));
721 box->scaled_pixmaps =
722 (struct grub_video_bitmap **)
723- grub_malloc (BOX_NUM_PIXMAPS * sizeof (struct grub_video_bitmap *));
724+ grub_calloc (BOX_NUM_PIXMAPS, sizeof (struct grub_video_bitmap *));
725
726 /* Initialize all pixmap pointers to NULL so that proper destruction can
727 be performed if an error is encountered partway through construction. */
728diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c
729index 6208a97..43d98a7 100644
730--- a/grub-core/io/gzio.c
731+++ b/grub-core/io/gzio.c
732@@ -554,7 +554,7 @@ huft_build (unsigned *b, /* code lengths in bits (all assumed <= BMAX) */
733 z = 1 << j; /* table entries for j-bit table */
734
735 /* allocate and link in new table */
736- q = (struct huft *) grub_zalloc ((z + 1) * sizeof (struct huft));
737+ q = (struct huft *) grub_calloc (z + 1, sizeof (struct huft));
738 if (! q)
739 {
740 if (h)
741diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
742index 6e1ceb9..dc31caa 100644
743--- a/grub-core/kern/efi/efi.c
744+++ b/grub-core/kern/efi/efi.c
745@@ -202,7 +202,7 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid,
746
747 len = grub_strlen (var);
748 len16 = len * GRUB_MAX_UTF16_PER_UTF8;
749- var16 = grub_malloc ((len16 + 1) * sizeof (var16[0]));
750+ var16 = grub_calloc (len16 + 1, sizeof (var16[0]));
751 if (!var16)
752 return grub_errno;
753 len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL);
754@@ -237,7 +237,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid,
755
756 len = grub_strlen (var);
757 len16 = len * GRUB_MAX_UTF16_PER_UTF8;
758- var16 = grub_malloc ((len16 + 1) * sizeof (var16[0]));
759+ var16 = grub_calloc (len16 + 1, sizeof (var16[0]));
760 if (!var16)
761 return NULL;
762 len16 = grub_utf8_to_utf16 (var16, len16, (grub_uint8_t *) var, len, NULL);
763@@ -383,7 +383,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0)
764 while (len > 0 && fp->path_name[len - 1] == 0)
765 len--;
766
767- dup_name = grub_malloc (len * sizeof (*dup_name));
768+ dup_name = grub_calloc (len, sizeof (*dup_name));
769 if (!dup_name)
770 {
771 grub_free (name);
772diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c
773index e9ec680..d975265 100644
774--- a/grub-core/kern/emu/hostdisk.c
775+++ b/grub-core/kern/emu/hostdisk.c
776@@ -615,7 +615,7 @@ static char *
777 grub_util_path_concat_real (size_t n, int ext, va_list ap)
778 {
779 size_t totlen = 0;
780- char **l = xmalloc ((n + ext) * sizeof (l[0]));
781+ char **l = xcalloc (n + ext, sizeof (l[0]));
782 char *r, *p, *pi;
783 size_t i;
784 int first = 1;
785diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c
786index 2b85f49..f90be65 100644
787--- a/grub-core/kern/fs.c
788+++ b/grub-core/kern/fs.c
789@@ -151,7 +151,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
790 while (p);
791
792 /* Allocate a block list. */
793- blocks = grub_zalloc (sizeof (struct grub_fs_block) * (num + 1));
794+ blocks = grub_calloc (num + 1, sizeof (struct grub_fs_block));
795 if (! blocks)
796 return 0;
797
798diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
799index 3b633d5..a7abd36 100644
800--- a/grub-core/kern/misc.c
801+++ b/grub-core/kern/misc.c
802@@ -690,7 +690,7 @@ parse_printf_args (const char *fmt0, struct printf_args *args,
803 args->ptr = args->prealloc;
804 else
805 {
806- args->ptr = grub_malloc (args->count * sizeof (args->ptr[0]));
807+ args->ptr = grub_calloc (args->count, sizeof (args->ptr[0]));
808 if (!args->ptr)
809 {
810 grub_errno = GRUB_ERR_NONE;
811diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c
812index 78175aa..619db31 100644
813--- a/grub-core/kern/parser.c
814+++ b/grub-core/kern/parser.c
815@@ -213,7 +213,7 @@ grub_parser_split_cmdline (const char *cmdline,
816 return grub_errno;
817 grub_memcpy (args, buffer, bp - buffer);
818
819- *argv = grub_malloc (sizeof (char *) * (*argc + 1));
820+ *argv = grub_calloc (*argc + 1, sizeof (char *));
821 if (!*argv)
822 {
823 grub_free (args);
824diff --git a/grub-core/kern/uboot/uboot.c b/grub-core/kern/uboot/uboot.c
825index be4816f..aac8f9a 100644
826--- a/grub-core/kern/uboot/uboot.c
827+++ b/grub-core/kern/uboot/uboot.c
828@@ -133,7 +133,7 @@ grub_uboot_dev_enum (void)
829 return num_devices;
830
831 max_devices = 2;
832- enum_devices = grub_malloc (sizeof(struct device_info) * max_devices);
833+ enum_devices = grub_calloc (max_devices, sizeof(struct device_info));
834 if (!enum_devices)
835 return 0;
836
837diff --git a/grub-core/lib/libgcrypt/cipher/ac.c b/grub-core/lib/libgcrypt/cipher/ac.c
838index f5e946a..63f6fcd 100644
839--- a/grub-core/lib/libgcrypt/cipher/ac.c
840+++ b/grub-core/lib/libgcrypt/cipher/ac.c
841@@ -185,7 +185,7 @@ ac_data_mpi_copy (gcry_ac_mpi_t *data_mpis, unsigned int data_mpis_n,
842 gcry_mpi_t mpi;
843 char *label;
844
845- data_mpis_new = gcry_malloc (sizeof (*data_mpis_new) * data_mpis_n);
846+ data_mpis_new = gcry_calloc (data_mpis_n, sizeof (*data_mpis_new));
847 if (! data_mpis_new)
848 {
849 err = gcry_error_from_errno (errno);
850@@ -572,7 +572,7 @@ _gcry_ac_data_to_sexp (gcry_ac_data_t data, gcry_sexp_t *sexp,
851 }
852
853 /* Add MPI list. */
854- arg_list = gcry_malloc (sizeof (*arg_list) * (data_n + 1));
855+ arg_list = gcry_calloc (data_n + 1, sizeof (*arg_list));
856 if (! arg_list)
857 {
858 err = gcry_error_from_errno (errno);
859@@ -1283,7 +1283,7 @@ ac_data_construct (const char *identifier, int include_flags,
860 /* We build a list of arguments to pass to
861 gcry_sexp_build_array(). */
862 data_length = _gcry_ac_data_length (data);
863- arg_list = gcry_malloc (sizeof (*arg_list) * (data_length * 2));
864+ arg_list = gcry_calloc (data_length, sizeof (*arg_list) * 2);
865 if (! arg_list)
866 {
867 err = gcry_error_from_errno (errno);
868@@ -1593,7 +1593,7 @@ _gcry_ac_key_pair_generate (gcry_ac_handle_t handle, unsigned int nbits,
869 arg_list_n += 2;
870
871 /* Allocate list. */
872- arg_list = gcry_malloc (sizeof (*arg_list) * arg_list_n);
873+ arg_list = gcry_calloc (arg_list_n, sizeof (*arg_list));
874 if (! arg_list)
875 {
876 err = gcry_error_from_errno (errno);
877diff --git a/grub-core/lib/libgcrypt/cipher/primegen.c b/grub-core/lib/libgcrypt/cipher/primegen.c
878index 2788e34..b12e79b 100644
879--- a/grub-core/lib/libgcrypt/cipher/primegen.c
880+++ b/grub-core/lib/libgcrypt/cipher/primegen.c
881@@ -383,7 +383,7 @@ prime_generate_internal (int need_q_factor,
882 }
883
884 /* Allocate an array to track pool usage. */
885- pool_in_use = gcry_malloc (n * sizeof *pool_in_use);
886+ pool_in_use = gcry_calloc (n, sizeof *pool_in_use);
887 if (!pool_in_use)
888 {
889 err = gpg_err_code_from_errno (errno);
890@@ -765,7 +765,7 @@ gen_prime (unsigned int nbits, int secret, int randomlevel,
891 if (nbits < 16)
892 log_fatal ("can't generate a prime with less than %d bits\n", 16);
893
894- mods = gcry_xmalloc( no_of_small_prime_numbers * sizeof *mods );
895+ mods = gcry_xcalloc( no_of_small_prime_numbers, sizeof *mods);
896 /* Make nbits fit into gcry_mpi_t implementation. */
897 val_2 = mpi_alloc_set_ui( 2 );
898 val_3 = mpi_alloc_set_ui( 3);
899diff --git a/grub-core/lib/libgcrypt/cipher/pubkey.c b/grub-core/lib/libgcrypt/cipher/pubkey.c
900index 9109821..ca087ad 100644
901--- a/grub-core/lib/libgcrypt/cipher/pubkey.c
902+++ b/grub-core/lib/libgcrypt/cipher/pubkey.c
903@@ -2941,7 +2941,7 @@ gcry_pk_encrypt (gcry_sexp_t *r_ciph, gcry_sexp_t s_data, gcry_sexp_t s_pkey)
904 * array to a format string, so we have to do it this way :-(. */
905 /* FIXME: There is now such a format specifier, so we can
906 change the code to be more clear. */
907- arg_list = malloc (nelem * sizeof *arg_list);
908+ arg_list = calloc (nelem, sizeof *arg_list);
909 if (!arg_list)
910 {
911 rc = gpg_err_code_from_syserror ();
912@@ -3233,7 +3233,7 @@ gcry_pk_sign (gcry_sexp_t *r_sig, gcry_sexp_t s_hash, gcry_sexp_t s_skey)
913 }
914 strcpy (p, "))");
915
916- arg_list = malloc (nelem * sizeof *arg_list);
917+ arg_list = calloc (nelem, sizeof *arg_list);
918 if (!arg_list)
919 {
920 rc = gpg_err_code_from_syserror ();
921diff --git a/grub-core/lib/priority_queue.c b/grub-core/lib/priority_queue.c
922index 659be0b..7d5e7c0 100644
923--- a/grub-core/lib/priority_queue.c
924+++ b/grub-core/lib/priority_queue.c
925@@ -92,7 +92,7 @@ grub_priority_queue_new (grub_size_t elsize,
926 {
927 struct grub_priority_queue *ret;
928 void *els;
929- els = grub_malloc (elsize * 8);
930+ els = grub_calloc (8, elsize);
931 if (!els)
932 return 0;
933 ret = (struct grub_priority_queue *) grub_malloc (sizeof (*ret));
934diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c
935index ee9fa7b..467305b 100644
936--- a/grub-core/lib/reed_solomon.c
937+++ b/grub-core/lib/reed_solomon.c
938@@ -20,6 +20,7 @@
939 #include <stdio.h>
940 #include <string.h>
941 #include <stdlib.h>
942+#define xcalloc calloc
943 #define xmalloc malloc
944 #define grub_memset memset
945 #define grub_memcpy memcpy
946@@ -158,11 +159,9 @@ rs_encode (gf_single_t *data, grub_size_t s, grub_size_t rs)
947 gf_single_t *rs_polynomial;
948 int i, j;
949 gf_single_t *m;
950- m = xmalloc ((s + rs) * sizeof (gf_single_t));
951+ m = xcalloc (s + rs, sizeof (gf_single_t));
952 grub_memcpy (m, data, s * sizeof (gf_single_t));
953- grub_memset (m + s, 0, rs * sizeof (gf_single_t));
954- rs_polynomial = xmalloc ((rs + 1) * sizeof (gf_single_t));
955- grub_memset (rs_polynomial, 0, (rs + 1) * sizeof (gf_single_t));
956+ rs_polynomial = xcalloc (rs + 1, sizeof (gf_single_t));
957 rs_polynomial[rs] = 1;
958 /* Multiply with X - a^r */
959 for (j = 0; j < rs; j++)
960diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
961index ea3ebc7..5847aac 100644
962--- a/grub-core/lib/relocator.c
963+++ b/grub-core/lib/relocator.c
964@@ -495,9 +495,9 @@ malloc_in_range (struct grub_relocator *rel,
965 }
966 #endif
967
968- eventt = grub_malloc (maxevents * sizeof (events[0]));
969+ eventt = grub_calloc (maxevents, sizeof (events[0]));
970 counter = grub_malloc ((DIGITSORT_MASK + 2) * sizeof (counter[0]));
971- events = grub_malloc (maxevents * sizeof (events[0]));
972+ events = grub_calloc (maxevents, sizeof (events[0]));
973 if (!events || !eventt || !counter)
974 {
975 grub_dprintf ("relocator", "events or counter allocation failed %d\n",
976@@ -963,7 +963,7 @@ malloc_in_range (struct grub_relocator *rel,
977 #endif
978 unsigned cural = 0;
979 int oom = 0;
980- res->subchunks = grub_malloc (sizeof (res->subchunks[0]) * nallocs);
981+ res->subchunks = grub_calloc (nallocs, sizeof (res->subchunks[0]));
982 if (!res->subchunks)
983 oom = 1;
984 res->nsubchunks = nallocs;
985@@ -1562,8 +1562,8 @@ grub_relocator_prepare_relocs (struct grub_relocator *rel, grub_addr_t addr,
986 count[(chunk->src & 0xff) + 1]++;
987 }
988 }
989- from = grub_malloc (nchunks * sizeof (sorted[0]));
990- to = grub_malloc (nchunks * sizeof (sorted[0]));
991+ from = grub_calloc (nchunks, sizeof (sorted[0]));
992+ to = grub_calloc (nchunks, sizeof (sorted[0]));
993 if (!from || !to)
994 {
995 grub_free (from);
996diff --git a/grub-core/lib/zstd/fse_decompress.c b/grub-core/lib/zstd/fse_decompress.c
997index 72bbead..2227b84 100644
998--- a/grub-core/lib/zstd/fse_decompress.c
999+++ b/grub-core/lib/zstd/fse_decompress.c
1000@@ -82,7 +82,7 @@
1001 FSE_DTable* FSE_createDTable (unsigned tableLog)
1002 {
1003 if (tableLog > FSE_TABLELOG_ABSOLUTE_MAX) tableLog = FSE_TABLELOG_ABSOLUTE_MAX;
1004- return (FSE_DTable*)malloc( FSE_DTABLE_SIZE_U32(tableLog) * sizeof (U32) );
1005+ return (FSE_DTable*)calloc( FSE_DTABLE_SIZE_U32(tableLog), sizeof (U32) );
1006 }
1007
1008 void FSE_freeDTable (FSE_DTable* dt)
1009diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c
1010index 5168491..d70c174 100644
1011--- a/grub-core/loader/arm/linux.c
1012+++ b/grub-core/loader/arm/linux.c
1013@@ -78,7 +78,7 @@ linux_prepare_atag (void *target_atag)
1014
1015 /* some place for cmdline, initrd and terminator. */
1016 tmp_size = get_atag_size (atag_orig) + 20 + (arg_size) / 4;
1017- tmp_atag = grub_malloc (tmp_size * sizeof (grub_uint32_t));
1018+ tmp_atag = grub_calloc (tmp_size, sizeof (grub_uint32_t));
1019 if (!tmp_atag)
1020 return grub_errno;
1021
1022diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
1023index cd92ea3..daf8c6b 100644
1024--- a/grub-core/loader/efi/chainloader.c
1025+++ b/grub-core/loader/efi/chainloader.c
1026@@ -116,7 +116,7 @@ copy_file_path (grub_efi_file_path_device_path_t *fp,
1027 fp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE;
1028 fp->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE;
1029
1030- path_name = grub_malloc (len * GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name));
1031+ path_name = grub_calloc (len, GRUB_MAX_UTF16_PER_UTF8 * sizeof (*path_name));
1032 if (!path_name)
1033 return;
1034
1035diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c
1036index af6741d..a8d8bf7 100644
1037--- a/grub-core/loader/i386/bsdXX.c
1038+++ b/grub-core/loader/i386/bsdXX.c
1039@@ -48,7 +48,7 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr)
1040 if (e->e_ident[EI_CLASS] != SUFFIX (ELFCLASS))
1041 return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
1042
1043- *shdr = grub_malloc ((grub_uint32_t) e->e_shnum * e->e_shentsize);
1044+ *shdr = grub_calloc (e->e_shnum, e->e_shentsize);
1045 if (! *shdr)
1046 return grub_errno;
1047
1048diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
1049index e64ed08..b7d176b 100644
1050--- a/grub-core/loader/i386/xnu.c
1051+++ b/grub-core/loader/i386/xnu.c
1052@@ -295,7 +295,7 @@ grub_xnu_devprop_add_property_utf8 (struct grub_xnu_devprop_device_descriptor *d
1053 return grub_errno;
1054
1055 len = grub_strlen (name);
1056- utf16 = grub_malloc (sizeof (grub_uint16_t) * len);
1057+ utf16 = grub_calloc (len, sizeof (grub_uint16_t));
1058 if (!utf16)
1059 {
1060 grub_free (utf8);
1061@@ -331,7 +331,7 @@ grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor *
1062 grub_uint16_t *utf16;
1063 grub_err_t err;
1064
1065- utf16 = grub_malloc (sizeof (grub_uint16_t) * namelen);
1066+ utf16 = grub_calloc (namelen, sizeof (grub_uint16_t));
1067 if (!utf16)
1068 return grub_errno;
1069 grub_memcpy (utf16, name, sizeof (grub_uint16_t) * namelen);
1070diff --git a/grub-core/loader/macho.c b/grub-core/loader/macho.c
1071index 085f9c6..05710c4 100644
1072--- a/grub-core/loader/macho.c
1073+++ b/grub-core/loader/macho.c
1074@@ -97,7 +97,7 @@ grub_macho_file (grub_file_t file, const char *filename, int is_64bit)
1075 if (grub_file_seek (macho->file, sizeof (struct grub_macho_fat_header))
1076 == (grub_off_t) -1)
1077 goto fail;
1078- archs = grub_malloc (sizeof (struct grub_macho_fat_arch) * narchs);
1079+ archs = grub_calloc (narchs, sizeof (struct grub_macho_fat_arch));
1080 if (!archs)
1081 goto fail;
1082 if (grub_file_read (macho->file, archs,
1083diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c
1084index 70cd1db..cc68536 100644
1085--- a/grub-core/loader/multiboot_elfxx.c
1086+++ b/grub-core/loader/multiboot_elfxx.c
1087@@ -217,7 +217,7 @@ CONCAT(grub_multiboot_load_elf, XX) (mbi_load_data_t *mld)
1088 {
1089 grub_uint8_t *shdr, *shdrptr;
1090
1091- shdr = grub_malloc ((grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize);
1092+ shdr = grub_calloc (ehdr->e_shnum, ehdr->e_shentsize);
1093 if (!shdr)
1094 return grub_errno;
1095
1096diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
1097index 7f74d1d..77d7060 100644
1098--- a/grub-core/loader/xnu.c
1099+++ b/grub-core/loader/xnu.c
1100@@ -800,7 +800,7 @@ grub_cmd_xnu_mkext (grub_command_t cmd __attribute__ ((unused)),
1101 if (grub_be_to_cpu32 (head.magic) == GRUB_MACHO_FAT_MAGIC)
1102 {
1103 narchs = grub_be_to_cpu32 (head.nfat_arch);
1104- archs = grub_malloc (sizeof (struct grub_macho_fat_arch) * narchs);
1105+ archs = grub_calloc (narchs, sizeof (struct grub_macho_fat_arch));
1106 if (! archs)
1107 {
1108 grub_file_close (file);
1109diff --git a/grub-core/mmap/mmap.c b/grub-core/mmap/mmap.c
1110index 6a31cba..57b4e9a 100644
1111--- a/grub-core/mmap/mmap.c
1112+++ b/grub-core/mmap/mmap.c
1113@@ -143,9 +143,9 @@ grub_mmap_iterate (grub_memory_hook_t hook, void *hook_data)
1114
1115 /* Initialize variables. */
1116 ctx.scanline_events = (struct grub_mmap_scan *)
1117- grub_malloc (sizeof (struct grub_mmap_scan) * 2 * mmap_num);
1118+ grub_calloc (mmap_num, sizeof (struct grub_mmap_scan) * 2);
1119
1120- present = grub_zalloc (sizeof (present[0]) * current_priority);
1121+ present = grub_calloc (current_priority, sizeof (present[0]));
1122
1123 if (! ctx.scanline_events || !present)
1124 {
1125diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c
1126index 04cfbb0..6539572 100644
1127--- a/grub-core/net/bootp.c
1128+++ b/grub-core/net/bootp.c
1129@@ -766,7 +766,7 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)),
1130 if (ncards == 0)
1131 return grub_error (GRUB_ERR_NET_NO_CARD, N_("no network card found"));
1132
1133- ifaces = grub_zalloc (ncards * sizeof (ifaces[0]));
1134+ ifaces = grub_calloc (ncards, sizeof (ifaces[0]));
1135 if (!ifaces)
1136 return grub_errno;
1137
1138diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c
1139index 5d9afe0..e332d5e 100644
1140--- a/grub-core/net/dns.c
1141+++ b/grub-core/net/dns.c
1142@@ -285,8 +285,8 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
1143 ptr++;
1144 ptr += 4;
1145 }
1146- *data->addresses = grub_malloc (sizeof ((*data->addresses)[0])
1147- * grub_be_to_cpu16 (head->ancount));
1148+ *data->addresses = grub_calloc (grub_be_to_cpu16 (head->ancount),
1149+ sizeof ((*data->addresses)[0]));
1150 if (!*data->addresses)
1151 {
1152 grub_errno = GRUB_ERR_NONE;
1153@@ -406,8 +406,8 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),
1154 dns_cache[h].addresses = 0;
1155 dns_cache[h].name = grub_strdup (data->oname);
1156 dns_cache[h].naddresses = *data->naddresses;
1157- dns_cache[h].addresses = grub_malloc (*data->naddresses
1158- * sizeof (dns_cache[h].addresses[0]));
1159+ dns_cache[h].addresses = grub_calloc (*data->naddresses,
1160+ sizeof (dns_cache[h].addresses[0]));
1161 dns_cache[h].limit_time = grub_get_time_ms () + 1000 * ttl_all;
1162 if (!dns_cache[h].addresses || !dns_cache[h].name)
1163 {
1164@@ -479,7 +479,7 @@ grub_net_dns_lookup (const char *name,
1165 }
1166 }
1167
1168- sockets = grub_malloc (sizeof (sockets[0]) * n_servers);
1169+ sockets = grub_calloc (n_servers, sizeof (sockets[0]));
1170 if (!sockets)
1171 return grub_errno;
1172
1173diff --git a/grub-core/net/net.c b/grub-core/net/net.c
1174index d5d726a..38f19df 100644
1175--- a/grub-core/net/net.c
1176+++ b/grub-core/net/net.c
1177@@ -333,8 +333,8 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)),
1178 ncards++;
1179 }
1180
1181- ifaces = grub_zalloc (ncards * sizeof (ifaces[0]));
1182- slaacs = grub_zalloc (ncards * sizeof (slaacs[0]));
1183+ ifaces = grub_calloc (ncards, sizeof (ifaces[0]));
1184+ slaacs = grub_calloc (ncards, sizeof (slaacs[0]));
1185 if (!ifaces || !slaacs)
1186 {
1187 grub_free (ifaces);
1188diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
1189index b0ab47d..d57fb72 100644
1190--- a/grub-core/normal/charset.c
1191+++ b/grub-core/normal/charset.c
1192@@ -203,7 +203,7 @@ grub_utf8_to_ucs4_alloc (const char *msg, grub_uint32_t **unicode_msg,
1193 {
1194 grub_size_t msg_len = grub_strlen (msg);
1195
1196- *unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t));
1197+ *unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t));
1198
1199 if (!*unicode_msg)
1200 return -1;
1201@@ -488,7 +488,7 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
1202 }
1203 else
1204 {
1205- n = grub_malloc (sizeof (n[0]) * (out->ncomb + 1));
1206+ n = grub_calloc (out->ncomb + 1, sizeof (n[0]));
1207 if (!n)
1208 {
1209 grub_errno = GRUB_ERR_NONE;
1210@@ -842,7 +842,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,
1211 } \
1212 }
1213
1214- visual = grub_malloc (sizeof (visual[0]) * logical_len);
1215+ visual = grub_calloc (logical_len, sizeof (visual[0]));
1216 if (!visual)
1217 return -1;
1218
1219@@ -1165,8 +1165,8 @@ grub_bidi_logical_to_visual (const grub_uint32_t *logical,
1220 {
1221 const grub_uint32_t *line_start = logical, *ptr;
1222 struct grub_unicode_glyph *visual_ptr;
1223- *visual_out = visual_ptr = grub_malloc (3 * sizeof (visual_ptr[0])
1224- * (logical_len + 2));
1225+ *visual_out = visual_ptr = grub_calloc (logical_len + 2,
1226+ 3 * sizeof (visual_ptr[0]));
1227 if (!visual_ptr)
1228 return -1;
1229 for (ptr = logical; ptr <= logical + logical_len; ptr++)
1230diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c
1231index c037d50..c57242e 100644
1232--- a/grub-core/normal/cmdline.c
1233+++ b/grub-core/normal/cmdline.c
1234@@ -41,7 +41,7 @@ grub_err_t
1235 grub_set_history (int newsize)
1236 {
1237 grub_uint32_t **old_hist_lines = hist_lines;
1238- hist_lines = grub_malloc (sizeof (grub_uint32_t *) * newsize);
1239+ hist_lines = grub_calloc (newsize, sizeof (grub_uint32_t *));
1240
1241 /* Copy the old lines into the new buffer. */
1242 if (old_hist_lines)
1243@@ -114,7 +114,7 @@ static void
1244 grub_history_set (int pos, grub_uint32_t *s, grub_size_t len)
1245 {
1246 grub_free (hist_lines[pos]);
1247- hist_lines[pos] = grub_malloc ((len + 1) * sizeof (grub_uint32_t));
1248+ hist_lines[pos] = grub_calloc (len + 1, sizeof (grub_uint32_t));
1249 if (!hist_lines[pos])
1250 {
1251 grub_print_error ();
1252@@ -349,7 +349,7 @@ grub_cmdline_get (const char *prompt_translated)
1253 char *ret;
1254 unsigned nterms;
1255
1256- buf = grub_malloc (max_len * sizeof (grub_uint32_t));
1257+ buf = grub_calloc (max_len, sizeof (grub_uint32_t));
1258 if (!buf)
1259 return 0;
1260
1261@@ -377,7 +377,7 @@ grub_cmdline_get (const char *prompt_translated)
1262 FOR_ACTIVE_TERM_OUTPUTS(cur)
1263 nterms++;
1264
1265- cl_terms = grub_malloc (sizeof (cl_terms[0]) * nterms);
1266+ cl_terms = grub_calloc (nterms, sizeof (cl_terms[0]));
1267 if (!cl_terms)
1268 {
1269 grub_free (buf);
1270@@ -385,7 +385,7 @@ grub_cmdline_get (const char *prompt_translated)
1271 }
1272 cl_term_cur = cl_terms;
1273
1274- unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t));
1275+ unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t));
1276 if (!unicode_msg)
1277 {
1278 grub_free (buf);
1279@@ -495,7 +495,7 @@ grub_cmdline_get (const char *prompt_translated)
1280 grub_uint32_t *insert;
1281
1282 insertlen = grub_strlen (insertu8);
1283- insert = grub_malloc ((insertlen + 1) * sizeof (grub_uint32_t));
1284+ insert = grub_calloc (insertlen + 1, sizeof (grub_uint32_t));
1285 if (!insert)
1286 {
1287 grub_free (insertu8);
1288@@ -602,7 +602,7 @@ grub_cmdline_get (const char *prompt_translated)
1289
1290 grub_free (kill_buf);
1291
1292- kill_buf = grub_malloc ((n + 1) * sizeof(grub_uint32_t));
1293+ kill_buf = grub_calloc (n + 1, sizeof (grub_uint32_t));
1294 if (grub_errno)
1295 {
1296 grub_print_error ();
1297diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
1298index cdf3590..1993995 100644
1299--- a/grub-core/normal/menu_entry.c
1300+++ b/grub-core/normal/menu_entry.c
1301@@ -95,8 +95,8 @@ init_line (struct screen *screen, struct line *linep)
1302 {
1303 linep->len = 0;
1304 linep->max_len = 80;
1305- linep->buf = grub_malloc ((linep->max_len + 1) * sizeof (linep->buf[0]));
1306- linep->pos = grub_zalloc (screen->nterms * sizeof (linep->pos[0]));
1307+ linep->buf = grub_calloc (linep->max_len + 1, sizeof (linep->buf[0]));
1308+ linep->pos = grub_calloc (screen->nterms, sizeof (linep->pos[0]));
1309 if (! linep->buf || !linep->pos)
1310 {
1311 grub_free (linep->buf);
1312@@ -287,7 +287,7 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen,
1313 pos = linep->pos + (term_screen - screen->terms);
1314
1315 if (!*pos)
1316- *pos = grub_zalloc ((linep->len + 1) * sizeof (**pos));
1317+ *pos = grub_calloc (linep->len + 1, sizeof (**pos));
1318
1319 if (i == region_start || linep == screen->lines + screen->line
1320 || (i > region_start && mode == ALL_LINES))
1321@@ -471,7 +471,7 @@ insert_string (struct screen *screen, const char *s, int update)
1322
1323 /* Insert the string. */
1324 current_linep = screen->lines + screen->line;
1325- unicode_msg = grub_malloc ((p - s) * sizeof (grub_uint32_t));
1326+ unicode_msg = grub_calloc (p - s, sizeof (grub_uint32_t));
1327
1328 if (!unicode_msg)
1329 return 0;
1330@@ -1023,7 +1023,7 @@ complete (struct screen *screen, int continuous, int update)
1331 if (completion_buffer.buf)
1332 {
1333 buflen = grub_strlen (completion_buffer.buf);
1334- ucs4 = grub_malloc (sizeof (grub_uint32_t) * (buflen + 1));
1335+ ucs4 = grub_calloc (buflen + 1, sizeof (grub_uint32_t));
1336
1337 if (!ucs4)
1338 {
1339@@ -1268,7 +1268,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
1340 for (i = 0; i < (unsigned) screen->num_lines; i++)
1341 {
1342 grub_free (screen->lines[i].pos);
1343- screen->lines[i].pos = grub_zalloc (screen->nterms * sizeof (screen->lines[i].pos[0]));
1344+ screen->lines[i].pos = grub_calloc (screen->nterms, sizeof (screen->lines[i].pos[0]));
1345 if (! screen->lines[i].pos)
1346 {
1347 grub_print_error ();
1348@@ -1278,7 +1278,7 @@ grub_menu_entry_run (grub_menu_entry_t entry)
1349 }
1350 }
1351
1352- screen->terms = grub_zalloc (screen->nterms * sizeof (screen->terms[0]));
1353+ screen->terms = grub_calloc (screen->nterms, sizeof (screen->terms[0]));
1354 if (!screen->terms)
1355 {
1356 grub_print_error ();
1357diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c
1358index e22bb91..18240e7 100644
1359--- a/grub-core/normal/menu_text.c
1360+++ b/grub-core/normal/menu_text.c
1361@@ -78,7 +78,7 @@ grub_print_message_indented_real (const char *msg, int margin_left,
1362 grub_size_t msg_len = grub_strlen (msg) + 2;
1363 int ret = 0;
1364
1365- unicode_msg = grub_malloc (msg_len * sizeof (grub_uint32_t));
1366+ unicode_msg = grub_calloc (msg_len, sizeof (grub_uint32_t));
1367
1368 if (!unicode_msg)
1369 return 0;
1370@@ -211,7 +211,7 @@ print_entry (int y, int highlight, grub_menu_entry_t entry,
1371
1372 title = entry ? entry->title : "";
1373 title_len = grub_strlen (title);
1374- unicode_title = grub_malloc (title_len * sizeof (*unicode_title));
1375+ unicode_title = grub_calloc (title_len, sizeof (*unicode_title));
1376 if (! unicode_title)
1377 /* XXX How to show this error? */
1378 return;
1379diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
1380index a1e5c5a..cc8c173 100644
1381--- a/grub-core/normal/term.c
1382+++ b/grub-core/normal/term.c
1383@@ -264,7 +264,7 @@ grub_term_save_pos (void)
1384 FOR_ACTIVE_TERM_OUTPUTS(cur)
1385 cnt++;
1386
1387- ret = grub_malloc (cnt * sizeof (ret[0]));
1388+ ret = grub_calloc (cnt, sizeof (ret[0]));
1389 if (!ret)
1390 return NULL;
1391
1392@@ -1013,7 +1013,7 @@ grub_xnputs (const char *str, grub_size_t msg_len)
1393
1394 grub_error_push ();
1395
1396- unicode_str = grub_malloc (msg_len * sizeof (grub_uint32_t));
1397+ unicode_str = grub_calloc (msg_len, sizeof (grub_uint32_t));
1398
1399 grub_error_pop ();
1400
1401diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
1402index 90d92d3..5b41ad0 100644
1403--- a/grub-core/osdep/linux/getroot.c
1404+++ b/grub-core/osdep/linux/getroot.c
1405@@ -168,7 +168,7 @@ grub_util_raid_getmembers (const char *name, int bootable)
1406 if (ret != 0)
1407 grub_util_error (_("ioctl GET_ARRAY_INFO error: %s"), strerror (errno));
1408
1409- devicelist = xmalloc ((info.nr_disks + 1) * sizeof (char *));
1410+ devicelist = xcalloc (info.nr_disks + 1, sizeof (char *));
1411
1412 for (i = 0, j = 0; j < info.nr_disks; i++)
1413 {
1414@@ -241,7 +241,7 @@ grub_find_root_devices_from_btrfs (const char *dir)
1415 return NULL;
1416 }
1417
1418- ret = xmalloc ((fsi.num_devices + 1) * sizeof (ret[0]));
1419+ ret = xcalloc (fsi.num_devices + 1, sizeof (ret[0]));
1420
1421 for (i = 1; i <= fsi.max_id && j < fsi.num_devices; i++)
1422 {
1423@@ -396,7 +396,7 @@ grub_find_root_devices_from_mountinfo (const char *dir, char **relroot)
1424 if (relroot)
1425 *relroot = NULL;
1426
1427- entries = xmalloc (entry_max * sizeof (*entries));
1428+ entries = xcalloc (entry_max, sizeof (*entries));
1429
1430 again:
1431 fp = grub_util_fopen ("/proc/self/mountinfo", "r");
1432diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c
1433index 65effa9..7d63251 100644
1434--- a/grub-core/osdep/unix/config.c
1435+++ b/grub-core/osdep/unix/config.c
1436@@ -89,7 +89,7 @@ grub_util_load_config (struct grub_util_config *cfg)
1437 argv[0] = "sh";
1438 argv[1] = "-c";
1439
1440- script = xmalloc (4 * strlen (cfgfile) + 300);
1441+ script = xcalloc (4, strlen (cfgfile) + 300);
1442
1443 ptr = script;
1444 memcpy (ptr, ". '", 3);
1445diff --git a/grub-core/osdep/windows/getroot.c b/grub-core/osdep/windows/getroot.c
1446index 661d954..eada663 100644
1447--- a/grub-core/osdep/windows/getroot.c
1448+++ b/grub-core/osdep/windows/getroot.c
1449@@ -59,7 +59,7 @@ grub_get_mount_point (const TCHAR *path)
1450
1451 for (ptr = path; *ptr; ptr++);
1452 allocsize = (ptr - path + 10) * 2;
1453- out = xmalloc (allocsize * sizeof (out[0]));
1454+ out = xcalloc (allocsize, sizeof (out[0]));
1455
1456 /* When pointing to EFI system partition GetVolumePathName fails
1457 for ESP root and returns abberant information for everything
1458diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c
1459index 3551007..0be3273 100644
1460--- a/grub-core/osdep/windows/hostdisk.c
1461+++ b/grub-core/osdep/windows/hostdisk.c
1462@@ -111,7 +111,7 @@ grub_util_get_windows_path_real (const char *path)
1463
1464 while (1)
1465 {
1466- fpa = xmalloc (alloc * sizeof (fpa[0]));
1467+ fpa = xcalloc (alloc, sizeof (fpa[0]));
1468
1469 len = GetFullPathName (tpath, alloc, fpa, NULL);
1470 if (len >= alloc)
1471@@ -399,7 +399,7 @@ grub_util_fd_opendir (const char *name)
1472 for (l = 0; name_windows[l]; l++);
1473 for (l--; l >= 0 && (name_windows[l] == '\\' || name_windows[l] == '/'); l--);
1474 l++;
1475- pattern = xmalloc ((l + 3) * sizeof (pattern[0]));
1476+ pattern = xcalloc (l + 3, sizeof (pattern[0]));
1477 memcpy (pattern, name_windows, l * sizeof (pattern[0]));
1478 pattern[l] = '\\';
1479 pattern[l + 1] = '*';
1480diff --git a/grub-core/osdep/windows/init.c b/grub-core/osdep/windows/init.c
1481index e8ffd62..6297de6 100644
1482--- a/grub-core/osdep/windows/init.c
1483+++ b/grub-core/osdep/windows/init.c
1484@@ -161,7 +161,7 @@ grub_util_host_init (int *argc __attribute__ ((unused)),
1485 LPWSTR *targv;
1486
1487 targv = CommandLineToArgvW (tcmdline, argc);
1488- *argv = xmalloc ((*argc + 1) * sizeof (argv[0]));
1489+ *argv = xcalloc (*argc + 1, sizeof (argv[0]));
1490
1491 for (i = 0; i < *argc; i++)
1492 (*argv)[i] = grub_util_tchar_to_utf8 (targv[i]);
1493diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c
1494index 7eb53fe..1ef86bf 100644
1495--- a/grub-core/osdep/windows/platform.c
1496+++ b/grub-core/osdep/windows/platform.c
1497@@ -225,8 +225,8 @@ grub_install_register_efi (grub_device_t efidir_grub_dev,
1498 grub_util_error ("%s", _("no EFI routines are available when running in BIOS mode"));
1499
1500 distrib8_len = grub_strlen (efi_distributor);
1501- distributor16 = xmalloc ((distrib8_len + 1) * GRUB_MAX_UTF16_PER_UTF8
1502- * sizeof (grub_uint16_t));
1503+ distributor16 = xcalloc (distrib8_len + 1,
1504+ GRUB_MAX_UTF16_PER_UTF8 * sizeof (grub_uint16_t));
1505 distrib16_len = grub_utf8_to_utf16 (distributor16, distrib8_len * GRUB_MAX_UTF16_PER_UTF8,
1506 (const grub_uint8_t *) efi_distributor,
1507 distrib8_len, 0);
1508diff --git a/grub-core/osdep/windows/relpath.c b/grub-core/osdep/windows/relpath.c
1509index cb08617..478e8ef 100644
1510--- a/grub-core/osdep/windows/relpath.c
1511+++ b/grub-core/osdep/windows/relpath.c
1512@@ -72,7 +72,7 @@ grub_make_system_path_relative_to_its_root (const char *path)
1513 if (dirwindows[0] && dirwindows[1] == ':')
1514 offset = 2;
1515 }
1516- ret = xmalloc (sizeof (ret[0]) * (flen - offset + 2));
1517+ ret = xcalloc (flen - offset + 2, sizeof (ret[0]));
1518 if (dirwindows[offset] != '\\'
1519 && dirwindows[offset] != '/'
1520 && dirwindows[offset])
1521diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c
1522index 103f679..72a2e37 100644
1523--- a/grub-core/partmap/gpt.c
1524+++ b/grub-core/partmap/gpt.c
1525@@ -199,7 +199,7 @@ gpt_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
1526 *nsectors = ctx.len;
1527 if (*nsectors > max_nsectors)
1528 *nsectors = max_nsectors;
1529- *sectors = grub_malloc (*nsectors * sizeof (**sectors));
1530+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
1531 if (!*sectors)
1532 return grub_errno;
1533 for (i = 0; i < *nsectors; i++)
1534diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c
1535index 7b8e450..ee3f249 100644
1536--- a/grub-core/partmap/msdos.c
1537+++ b/grub-core/partmap/msdos.c
1538@@ -337,7 +337,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors,
1539 avail_nsectors = *nsectors;
1540 if (*nsectors > max_nsectors)
1541 *nsectors = max_nsectors;
1542- *sectors = grub_malloc (*nsectors * sizeof (**sectors));
1543+ *sectors = grub_calloc (*nsectors, sizeof (**sectors));
1544 if (!*sectors)
1545 return grub_errno;
1546 for (i = 0; i < *nsectors; i++)
1547diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
1548index ee299fd..c8d6806 100644
1549--- a/grub-core/script/execute.c
1550+++ b/grub-core/script/execute.c
1551@@ -553,7 +553,7 @@ gettext_append (struct grub_script_argv *result, const char *orig_str)
1552 for (iptr = orig_str; *iptr; iptr++)
1553 if (*iptr == '$')
1554 dollar_cnt++;
1555- ctx.allowed_strings = grub_malloc (sizeof (ctx.allowed_strings[0]) * dollar_cnt);
1556+ ctx.allowed_strings = grub_calloc (dollar_cnt, sizeof (ctx.allowed_strings[0]));
1557
1558 if (parse_string (orig_str, gettext_save_allow, &ctx, 0))
1559 goto fail;
1560diff --git a/grub-core/tests/fake_input.c b/grub-core/tests/fake_input.c
1561index 2d60852..b5eb516 100644
1562--- a/grub-core/tests/fake_input.c
1563+++ b/grub-core/tests/fake_input.c
1564@@ -49,7 +49,7 @@ grub_terminal_input_fake_sequence (int *seq_in, int nseq_in)
1565 saved = grub_term_inputs;
1566 if (seq)
1567 grub_free (seq);
1568- seq = grub_malloc (nseq_in * sizeof (seq[0]));
1569+ seq = grub_calloc (nseq_in, sizeof (seq[0]));
1570 if (!seq)
1571 return;
1572
1573diff --git a/grub-core/tests/video_checksum.c b/grub-core/tests/video_checksum.c
1574index 74d5b65..44d0810 100644
1575--- a/grub-core/tests/video_checksum.c
1576+++ b/grub-core/tests/video_checksum.c
1577@@ -336,7 +336,7 @@ grub_video_capture_write_bmp (const char *fname,
1578 {
1579 case 4:
1580 {
1581- grub_uint8_t *buffer = xmalloc (mode_info->width * 3);
1582+ grub_uint8_t *buffer = xcalloc (3, mode_info->width);
1583 grub_uint32_t rmask = ((1 << mode_info->red_mask_size) - 1);
1584 grub_uint32_t gmask = ((1 << mode_info->green_mask_size) - 1);
1585 grub_uint32_t bmask = ((1 << mode_info->blue_mask_size) - 1);
1586@@ -367,7 +367,7 @@ grub_video_capture_write_bmp (const char *fname,
1587 }
1588 case 3:
1589 {
1590- grub_uint8_t *buffer = xmalloc (mode_info->width * 3);
1591+ grub_uint8_t *buffer = xcalloc (3, mode_info->width);
1592 grub_uint32_t rmask = ((1 << mode_info->red_mask_size) - 1);
1593 grub_uint32_t gmask = ((1 << mode_info->green_mask_size) - 1);
1594 grub_uint32_t bmask = ((1 << mode_info->blue_mask_size) - 1);
1595@@ -407,7 +407,7 @@ grub_video_capture_write_bmp (const char *fname,
1596 }
1597 case 2:
1598 {
1599- grub_uint8_t *buffer = xmalloc (mode_info->width * 3);
1600+ grub_uint8_t *buffer = xcalloc (3, mode_info->width);
1601 grub_uint16_t rmask = ((1 << mode_info->red_mask_size) - 1);
1602 grub_uint16_t gmask = ((1 << mode_info->green_mask_size) - 1);
1603 grub_uint16_t bmask = ((1 << mode_info->blue_mask_size) - 1);
1604diff --git a/grub-core/video/capture.c b/grub-core/video/capture.c
1605index 4f83c74..4d3195e 100644
1606--- a/grub-core/video/capture.c
1607+++ b/grub-core/video/capture.c
1608@@ -89,7 +89,7 @@ grub_video_capture_start (const struct grub_video_mode_info *mode_info,
1609 framebuffer.mode_info = *mode_info;
1610 framebuffer.mode_info.blit_format = grub_video_get_blit_format (&framebuffer.mode_info);
1611
1612- framebuffer.ptr = grub_malloc (framebuffer.mode_info.height * framebuffer.mode_info.pitch);
1613+ framebuffer.ptr = grub_calloc (framebuffer.mode_info.height, framebuffer.mode_info.pitch);
1614 if (!framebuffer.ptr)
1615 return grub_errno;
1616
1617diff --git a/grub-core/video/emu/sdl.c b/grub-core/video/emu/sdl.c
1618index a2f639f..0ebab6f 100644
1619--- a/grub-core/video/emu/sdl.c
1620+++ b/grub-core/video/emu/sdl.c
1621@@ -172,7 +172,7 @@ grub_video_sdl_set_palette (unsigned int start, unsigned int count,
1622 if (start + count > mode_info.number_of_colors)
1623 count = mode_info.number_of_colors - start;
1624
1625- tmp = grub_malloc (count * sizeof (tmp[0]));
1626+ tmp = grub_calloc (count, sizeof (tmp[0]));
1627 for (i = 0; i < count; i++)
1628 {
1629 tmp[i].r = palette_data[i].r;
1630diff --git a/grub-core/video/i386/pc/vga.c b/grub-core/video/i386/pc/vga.c
1631index 01f4711..b2f776c 100644
1632--- a/grub-core/video/i386/pc/vga.c
1633+++ b/grub-core/video/i386/pc/vga.c
1634@@ -127,7 +127,7 @@ grub_video_vga_setup (unsigned int width, unsigned int height,
1635
1636 vga_height = height ? : 480;
1637
1638- framebuffer.temporary_buffer = grub_malloc (vga_height * VGA_WIDTH);
1639+ framebuffer.temporary_buffer = grub_calloc (vga_height, VGA_WIDTH);
1640 framebuffer.front_page = 0;
1641 framebuffer.back_page = 0;
1642 if (!framebuffer.temporary_buffer)
1643diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c
1644index 777e713..61bd645 100644
1645--- a/grub-core/video/readers/png.c
1646+++ b/grub-core/video/readers/png.c
1647@@ -309,7 +309,7 @@ grub_png_decode_image_header (struct grub_png_data *data)
1648 if (data->is_16bit || data->is_gray || data->is_palette)
1649 #endif
1650 {
1651- data->image_data = grub_malloc (data->image_height * data->row_bytes);
1652+ data->image_data = grub_calloc (data->image_height, data->row_bytes);
1653 if (grub_errno)
1654 return grub_errno;
1655
1656diff --git a/include/grub/unicode.h b/include/grub/unicode.h
1657index a0403e9..4de986a 100644
1658--- a/include/grub/unicode.h
1659+++ b/include/grub/unicode.h
1660@@ -293,7 +293,7 @@ grub_unicode_glyph_dup (const struct grub_unicode_glyph *in)
1661 grub_memcpy (out, in, sizeof (*in));
1662 if (in->ncomb > ARRAY_SIZE (out->combining_inline))
1663 {
1664- out->combining_ptr = grub_malloc (in->ncomb * sizeof (out->combining_ptr[0]));
1665+ out->combining_ptr = grub_calloc (in->ncomb, sizeof (out->combining_ptr[0]));
1666 if (!out->combining_ptr)
1667 {
1668 grub_free (out);
1669@@ -315,7 +315,7 @@ grub_unicode_set_glyph (struct grub_unicode_glyph *out,
1670 grub_memcpy (out, in, sizeof (*in));
1671 if (in->ncomb > ARRAY_SIZE (out->combining_inline))
1672 {
1673- out->combining_ptr = grub_malloc (in->ncomb * sizeof (out->combining_ptr[0]));
1674+ out->combining_ptr = grub_calloc (in->ncomb, sizeof (out->combining_ptr[0]));
1675 if (!out->combining_ptr)
1676 return;
1677 grub_memcpy (out->combining_ptr, in->combining_ptr,
1678diff --git a/util/getroot.c b/util/getroot.c
1679index 847406f..a5eaa64 100644
1680--- a/util/getroot.c
1681+++ b/util/getroot.c
1682@@ -200,7 +200,7 @@ make_device_name (const char *drive)
1683 char *ret, *ptr;
1684 const char *iptr;
1685
1686- ret = xmalloc (strlen (drive) * 2);
1687+ ret = xcalloc (2, strlen (drive));
1688 ptr = ret;
1689 for (iptr = drive; *iptr; iptr++)
1690 {
1691diff --git a/util/grub-file.c b/util/grub-file.c
1692index 50c18b6..b2e7dd6 100644
1693--- a/util/grub-file.c
1694+++ b/util/grub-file.c
1695@@ -54,7 +54,7 @@ main (int argc, char *argv[])
1696
1697 grub_util_host_init (&argc, &argv);
1698
1699- argv2 = xmalloc (argc * sizeof (argv2[0]));
1700+ argv2 = xcalloc (argc, sizeof (argv2[0]));
1701
1702 if (argc == 2 && strcmp (argv[1], "--version") == 0)
1703 {
1704diff --git a/util/grub-fstest.c b/util/grub-fstest.c
1705index f14e02d..57246af 100644
1706--- a/util/grub-fstest.c
1707+++ b/util/grub-fstest.c
1708@@ -650,7 +650,7 @@ argp_parser (int key, char *arg, struct argp_state *state)
1709 if (args_count < num_disks)
1710 {
1711 if (args_count == 0)
1712- images = xmalloc (num_disks * sizeof (images[0]));
1713+ images = xcalloc (num_disks, sizeof (images[0]));
1714 images[args_count] = grub_canonicalize_file_name (arg);
1715 args_count++;
1716 return 0;
1717@@ -734,7 +734,7 @@ main (int argc, char *argv[])
1718
1719 grub_util_host_init (&argc, &argv);
1720
1721- args = xmalloc (argc * sizeof (args[0]));
1722+ args = xcalloc (argc, sizeof (args[0]));
1723
1724 argp_parse (&argp, argc, argv, 0, 0, 0);
1725
1726diff --git a/util/grub-install-common.c b/util/grub-install-common.c
1727index ca0ac61..0295d40 100644
1728--- a/util/grub-install-common.c
1729+++ b/util/grub-install-common.c
1730@@ -286,7 +286,7 @@ handle_install_list (struct install_list *il, const char *val,
1731 il->n_entries++;
1732 }
1733 il->n_alloc = il->n_entries + 1;
1734- il->entries = xmalloc (il->n_alloc * sizeof (il->entries[0]));
1735+ il->entries = xcalloc (il->n_alloc, sizeof (il->entries[0]));
1736 ptr = val;
1737 for (ce = il->entries; ; ce++)
1738 {
1739diff --git a/util/grub-install.c b/util/grub-install.c
1740index 8a55ad4..a82725f 100644
1741--- a/util/grub-install.c
1742+++ b/util/grub-install.c
1743@@ -626,7 +626,7 @@ device_map_check_duplicates (const char *dev_map)
1744 if (! fp)
1745 return;
1746
1747- d = xmalloc (alloced * sizeof (d[0]));
1748+ d = xcalloc (alloced, sizeof (d[0]));
1749
1750 while (fgets (buf, sizeof (buf), fp))
1751 {
1752@@ -1260,7 +1260,7 @@ main (int argc, char *argv[])
1753 ndev++;
1754 }
1755
1756- grub_drives = xmalloc (sizeof (grub_drives[0]) * (ndev + 1));
1757+ grub_drives = xcalloc (ndev + 1, sizeof (grub_drives[0]));
1758
1759 for (curdev = grub_devices, curdrive = grub_drives; *curdev; curdev++,
1760 curdrive++)
1761diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
1762index bc087c2..d97d0e7 100644
1763--- a/util/grub-mkimagexx.c
1764+++ b/util/grub-mkimagexx.c
1765@@ -2294,10 +2294,8 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path,
1766 + grub_host_to_target16 (e->e_shstrndx) * smd.section_entsize);
1767 smd.strtab = (char *) e + grub_host_to_target_addr (s->sh_offset);
1768
1769- smd.addrs = xmalloc (sizeof (*smd.addrs) * smd.num_sections);
1770- memset (smd.addrs, 0, sizeof (*smd.addrs) * smd.num_sections);
1771- smd.vaddrs = xmalloc (sizeof (*smd.vaddrs) * smd.num_sections);
1772- memset (smd.vaddrs, 0, sizeof (*smd.vaddrs) * smd.num_sections);
1773+ smd.addrs = xcalloc (smd.num_sections, sizeof (*smd.addrs));
1774+ smd.vaddrs = xcalloc (smd.num_sections, sizeof (*smd.vaddrs));
1775
1776 SUFFIX (locate_sections) (e, kernel_path, &smd, layout, image_target);
1777
1778diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
1779index ce2cbc4..5183102 100644
1780--- a/util/grub-mkrescue.c
1781+++ b/util/grub-mkrescue.c
1782@@ -441,8 +441,8 @@ main (int argc, char *argv[])
1783 xorriso = xstrdup ("xorriso");
1784 label_font = grub_util_path_concat (2, pkgdatadir, "unicode.pf2");
1785
1786- argp_argv = xmalloc (sizeof (argp_argv[0]) * argc);
1787- xorriso_tail_argv = xmalloc (sizeof (argp_argv[0]) * argc);
1788+ argp_argv = xcalloc (argc, sizeof (argp_argv[0]));
1789+ xorriso_tail_argv = xcalloc (argc, sizeof (argp_argv[0]));
1790
1791 xorriso_tail_argc = 0;
1792 /* Program name */
1793diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c
1794index 4907d44..edf3097 100644
1795--- a/util/grub-mkstandalone.c
1796+++ b/util/grub-mkstandalone.c
1797@@ -296,7 +296,7 @@ main (int argc, char *argv[])
1798 grub_util_host_init (&argc, &argv);
1799 grub_util_disable_fd_syncs ();
1800
1801- files = xmalloc ((argc + 1) * sizeof (files[0]));
1802+ files = xcalloc (argc + 1, sizeof (files[0]));
1803
1804 argp_parse (&argp, argc, argv, 0, 0, 0);
1805
1806diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c
1807index 0d4084a..1133129 100644
1808--- a/util/grub-pe2elf.c
1809+++ b/util/grub-pe2elf.c
1810@@ -100,9 +100,9 @@ write_section_data (FILE* fp, const char *name, char *image,
1811 char *pe_strtab = (image + pe_chdr->symtab_offset
1812 + pe_chdr->num_symbols * sizeof (struct grub_pe32_symbol));
1813
1814- section_map = xmalloc ((2 * pe_chdr->num_sections + 5) * sizeof (int));
1815+ section_map = xcalloc (2 * pe_chdr->num_sections + 5, sizeof (int));
1816 section_map[0] = 0;
1817- shdr = xmalloc ((2 * pe_chdr->num_sections + 5) * sizeof (shdr[0]));
1818+ shdr = xcalloc (2 * pe_chdr->num_sections + 5, sizeof (shdr[0]));
1819 idx = 1;
1820 idx_reloc = pe_chdr->num_sections + 1;
1821
1822@@ -233,7 +233,7 @@ write_reloc_section (FILE* fp, const char *name, char *image,
1823
1824 pe_sec = pe_shdr + shdr[i].sh_link;
1825 pe_rel = (struct grub_pe32_reloc *) (image + pe_sec->relocations_offset);
1826- rel = (elf_reloc_t *) xmalloc (pe_sec->num_relocations * sizeof (elf_reloc_t));
1827+ rel = (elf_reloc_t *) xcalloc (pe_sec->num_relocations, sizeof (elf_reloc_t));
1828 num_rels = 0;
1829 modified = 0;
1830
1831@@ -365,12 +365,10 @@ write_symbol_table (FILE* fp, const char *name, char *image,
1832 pe_symtab = (struct grub_pe32_symbol *) (image + pe_chdr->symtab_offset);
1833 pe_strtab = (char *) (pe_symtab + pe_chdr->num_symbols);
1834
1835- symtab = (Elf_Sym *) xmalloc ((pe_chdr->num_symbols + 1) *
1836- sizeof (Elf_Sym));
1837- memset (symtab, 0, (pe_chdr->num_symbols + 1) * sizeof (Elf_Sym));
1838+ symtab = (Elf_Sym *) xcalloc (pe_chdr->num_symbols + 1, sizeof (Elf_Sym));
1839 num_syms = 1;
1840
1841- symtab_map = (int *) xmalloc (pe_chdr->num_symbols * sizeof (int));
1842+ symtab_map = (int *) xcalloc (pe_chdr->num_symbols, sizeof (int));
1843
1844 for (i = 0; i < (int) pe_chdr->num_symbols;
1845 i += pe_symtab->num_aux + 1, pe_symtab += pe_symtab->num_aux + 1)
1846diff --git a/util/grub-probe.c b/util/grub-probe.c
1847index 81d27ee..cbe6ed9 100644
1848--- a/util/grub-probe.c
1849+++ b/util/grub-probe.c
1850@@ -361,8 +361,8 @@ probe (const char *path, char **device_names, char delim)
1851 grub_util_pull_device (*curdev);
1852 ndev++;
1853 }
1854-
1855- drives_names = xmalloc (sizeof (drives_names[0]) * (ndev + 1));
1856+
1857+ drives_names = xcalloc (ndev + 1, sizeof (drives_names[0]));
1858
1859 for (curdev = device_names, curdrive = drives_names; *curdev; curdev++,
1860 curdrive++)
1861--
18622.14.4
1863
diff --git a/meta/recipes-bsp/grub/files/CVE-2020-14309-CVE-2020-14310-CVE-2020-14311-malloc-Use-overflow-checking-primitives-where-we-do-.patch b/meta/recipes-bsp/grub/files/CVE-2020-14309-CVE-2020-14310-CVE-2020-14311-malloc-Use-overflow-checking-primitives-where-we-do-.patch
deleted file mode 100644
index 7214ead9a7..0000000000
--- a/meta/recipes-bsp/grub/files/CVE-2020-14309-CVE-2020-14310-CVE-2020-14311-malloc-Use-overflow-checking-primitives-where-we-do-.patch
+++ /dev/null
@@ -1,1330 +0,0 @@
1From eb77d1ef65e25746acff43545f62a71360b15eec Mon Sep 17 00:00:00 2001
2From: Peter Jones <pjones@redhat.com>
3Date: Mon, 15 Jun 2020 12:28:27 -0400
4Subject: [PATCH 6/9] malloc: Use overflow checking primitives where we do
5 complex allocations
6
7This attempts to fix the places where we do the following where
8arithmetic_expr may include unvalidated data:
9
10 X = grub_malloc(arithmetic_expr);
11
12It accomplishes this by doing the arithmetic ahead of time using grub_add(),
13grub_sub(), grub_mul() and testing for overflow before proceeding.
14
15Among other issues, this fixes:
16 - allocation of integer overflow in grub_video_bitmap_create()
17 reported by Chris Coulson,
18 - allocation of integer overflow in grub_png_decode_image_header()
19 reported by Chris Coulson,
20 - allocation of integer overflow in grub_squash_read_symlink()
21 reported by Chris Coulson,
22 - allocation of integer overflow in grub_ext2_read_symlink()
23 reported by Chris Coulson,
24 - allocation of integer overflow in read_section_as_string()
25 reported by Chris Coulson.
26
27Fixes: CVE-2020-14309, CVE-2020-14310, CVE-2020-14311
28
29Signed-off-by: Peter Jones <pjones@redhat.com>
30Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
31
32Upstream-Status: Backport
33CVE: CVE-2020-14309 CVE-2020-14310 CVE-2020-14311
34
35Reference to upstream patch:
36https://git.savannah.gnu.org/cgit/grub.git/commit/?id=3f05d693d1274965ffbe4ba99080dc2c570944c6
37
38Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
39---
40 grub-core/commands/legacycfg.c | 29 +++++++++++++++++++-----
41 grub-core/commands/wildcard.c | 36 ++++++++++++++++++++++++-----
42 grub-core/disk/ldm.c | 32 ++++++++++++++++++--------
43 grub-core/font/font.c | 7 +++++-
44 grub-core/fs/btrfs.c | 28 +++++++++++++++--------
45 grub-core/fs/ext2.c | 10 ++++++++-
46 grub-core/fs/iso9660.c | 51 +++++++++++++++++++++++++++++-------------
47 grub-core/fs/sfs.c | 27 +++++++++++++++++-----
48 grub-core/fs/squash4.c | 45 ++++++++++++++++++++++++++++---------
49 grub-core/fs/udf.c | 41 +++++++++++++++++++++------------
50 grub-core/fs/xfs.c | 11 +++++----
51 grub-core/fs/zfs/zfs.c | 22 ++++++++++++------
52 grub-core/fs/zfs/zfscrypt.c | 7 +++++-
53 grub-core/lib/arg.c | 20 +++++++++++++++--
54 grub-core/loader/i386/bsd.c | 8 ++++++-
55 grub-core/net/dns.c | 9 +++++++-
56 grub-core/normal/charset.c | 10 +++++++--
57 grub-core/normal/cmdline.c | 14 ++++++++++--
58 grub-core/normal/menu_entry.c | 13 +++++++++--
59 grub-core/script/argv.c | 16 +++++++++++--
60 grub-core/script/lexer.c | 21 ++++++++++++++---
61 grub-core/video/bitmap.c | 25 +++++++++++++--------
62 grub-core/video/readers/png.c | 13 +++++++++--
63 23 files changed, 382 insertions(+), 113 deletions(-)
64
65diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
66index 5e3ec0d..cc5971f 100644
67--- a/grub-core/commands/legacycfg.c
68+++ b/grub-core/commands/legacycfg.c
69@@ -32,6 +32,7 @@
70 #include <grub/auth.h>
71 #include <grub/disk.h>
72 #include <grub/partition.h>
73+#include <grub/safemath.h>
74
75 GRUB_MOD_LICENSE ("GPLv3+");
76
77@@ -104,13 +105,22 @@ legacy_file (const char *filename)
78 if (newsuffix)
79 {
80 char *t;
81-
82+ grub_size_t sz;
83+
84+ if (grub_add (grub_strlen (suffix), grub_strlen (newsuffix), &sz) ||
85+ grub_add (sz, 1, &sz))
86+ {
87+ grub_errno = GRUB_ERR_OUT_OF_RANGE;
88+ goto fail_0;
89+ }
90+
91 t = suffix;
92- suffix = grub_realloc (suffix, grub_strlen (suffix)
93- + grub_strlen (newsuffix) + 1);
94+ suffix = grub_realloc (suffix, sz);
95 if (!suffix)
96 {
97 grub_free (t);
98+
99+ fail_0:
100 grub_free (entrysrc);
101 grub_free (parsed);
102 grub_free (newsuffix);
103@@ -154,13 +164,22 @@ legacy_file (const char *filename)
104 else
105 {
106 char *t;
107+ grub_size_t sz;
108+
109+ if (grub_add (grub_strlen (entrysrc), grub_strlen (parsed), &sz) ||
110+ grub_add (sz, 1, &sz))
111+ {
112+ grub_errno = GRUB_ERR_OUT_OF_RANGE;
113+ goto fail_1;
114+ }
115
116 t = entrysrc;
117- entrysrc = grub_realloc (entrysrc, grub_strlen (entrysrc)
118- + grub_strlen (parsed) + 1);
119+ entrysrc = grub_realloc (entrysrc, sz);
120 if (!entrysrc)
121 {
122 grub_free (t);
123+
124+ fail_1:
125 grub_free (parsed);
126 grub_free (suffix);
127 return grub_errno;
128diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c
129index 4a106ca..cc32903 100644
130--- a/grub-core/commands/wildcard.c
131+++ b/grub-core/commands/wildcard.c
132@@ -23,6 +23,7 @@
133 #include <grub/file.h>
134 #include <grub/device.h>
135 #include <grub/script_sh.h>
136+#include <grub/safemath.h>
137
138 #include <regex.h>
139
140@@ -48,6 +49,7 @@ merge (char **dest, char **ps)
141 int i;
142 int j;
143 char **p;
144+ grub_size_t sz;
145
146 if (! dest)
147 return ps;
148@@ -60,7 +62,12 @@ merge (char **dest, char **ps)
149 for (j = 0; ps[j]; j++)
150 ;
151
152- p = grub_realloc (dest, sizeof (char*) * (i + j + 1));
153+ if (grub_add (i, j, &sz) ||
154+ grub_add (sz, 1, &sz) ||
155+ grub_mul (sz, sizeof (char *), &sz))
156+ return dest;
157+
158+ p = grub_realloc (dest, sz);
159 if (! p)
160 {
161 grub_free (dest);
162@@ -115,8 +122,15 @@ make_regex (const char *start, const char *end, regex_t *regexp)
163 char ch;
164 int i = 0;
165 unsigned len = end - start;
166- char *buffer = grub_malloc (len * 2 + 2 + 1); /* worst case size. */
167+ char *buffer;
168+ grub_size_t sz;
169
170+ /* Worst case size is (len * 2 + 2 + 1). */
171+ if (grub_mul (len, 2, &sz) ||
172+ grub_add (sz, 3, &sz))
173+ return 1;
174+
175+ buffer = grub_malloc (sz);
176 if (! buffer)
177 return 1;
178
179@@ -226,6 +240,7 @@ match_devices_iter (const char *name, void *data)
180 struct match_devices_ctx *ctx = data;
181 char **t;
182 char *buffer;
183+ grub_size_t sz;
184
185 /* skip partitions if asked to. */
186 if (ctx->noparts && grub_strchr (name, ','))
187@@ -239,11 +254,16 @@ match_devices_iter (const char *name, void *data)
188 if (regexec (ctx->regexp, buffer, 0, 0, 0))
189 {
190 grub_dprintf ("expand", "not matched\n");
191+ fail:
192 grub_free (buffer);
193 return 0;
194 }
195
196- t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2));
197+ if (grub_add (ctx->ndev, 2, &sz) ||
198+ grub_mul (sz, sizeof (char *), &sz))
199+ goto fail;
200+
201+ t = grub_realloc (ctx->devs, sz);
202 if (! t)
203 {
204 grub_free (buffer);
205@@ -300,6 +320,7 @@ match_files_iter (const char *name,
206 struct match_files_ctx *ctx = data;
207 char **t;
208 char *buffer;
209+ grub_size_t sz;
210
211 /* skip . and .. names */
212 if (grub_strcmp(".", name) == 0 || grub_strcmp("..", name) == 0)
213@@ -315,9 +336,14 @@ match_files_iter (const char *name,
214 if (! buffer)
215 return 1;
216
217- t = grub_realloc (ctx->files, sizeof (char*) * (ctx->nfile + 2));
218- if (! t)
219+ if (grub_add (ctx->nfile, 2, &sz) ||
220+ grub_mul (sz, sizeof (char *), &sz))
221+ goto fail;
222+
223+ t = grub_realloc (ctx->files, sz);
224+ if (!t)
225 {
226+ fail:
227 grub_free (buffer);
228 return 1;
229 }
230diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
231index e632370..58f8a53 100644
232--- a/grub-core/disk/ldm.c
233+++ b/grub-core/disk/ldm.c
234@@ -25,6 +25,7 @@
235 #include <grub/msdos_partition.h>
236 #include <grub/gpt_partition.h>
237 #include <grub/i18n.h>
238+#include <grub/safemath.h>
239
240 #ifdef GRUB_UTIL
241 #include <grub/emu/misc.h>
242@@ -289,6 +290,7 @@ make_vg (grub_disk_t disk,
243 struct grub_ldm_vblk vblk[GRUB_DISK_SECTOR_SIZE
244 / sizeof (struct grub_ldm_vblk)];
245 unsigned i;
246+ grub_size_t sz;
247 err = grub_disk_read (disk, cursec, 0,
248 sizeof(vblk), &vblk);
249 if (err)
250@@ -350,7 +352,13 @@ make_vg (grub_disk_t disk,
251 grub_free (lv);
252 goto fail2;
253 }
254- lv->name = grub_malloc (*ptr + 1);
255+ if (grub_add (*ptr, 1, &sz))
256+ {
257+ grub_free (lv->internal_id);
258+ grub_free (lv);
259+ goto fail2;
260+ }
261+ lv->name = grub_malloc (sz);
262 if (!lv->name)
263 {
264 grub_free (lv->internal_id);
265@@ -599,10 +607,13 @@ make_vg (grub_disk_t disk,
266 if (lv->segments->node_alloc == lv->segments->node_count)
267 {
268 void *t;
269- lv->segments->node_alloc *= 2;
270- t = grub_realloc (lv->segments->nodes,
271- sizeof (*lv->segments->nodes)
272- * lv->segments->node_alloc);
273+ grub_size_t sz;
274+
275+ if (grub_mul (lv->segments->node_alloc, 2, &lv->segments->node_alloc) ||
276+ grub_mul (lv->segments->node_alloc, sizeof (*lv->segments->nodes), &sz))
277+ goto fail2;
278+
279+ t = grub_realloc (lv->segments->nodes, sz);
280 if (!t)
281 goto fail2;
282 lv->segments->nodes = t;
283@@ -723,10 +734,13 @@ make_vg (grub_disk_t disk,
284 if (comp->segment_alloc == comp->segment_count)
285 {
286 void *t;
287- comp->segment_alloc *= 2;
288- t = grub_realloc (comp->segments,
289- comp->segment_alloc
290- * sizeof (*comp->segments));
291+ grub_size_t sz;
292+
293+ if (grub_mul (comp->segment_alloc, 2, &comp->segment_alloc) ||
294+ grub_mul (comp->segment_alloc, sizeof (*comp->segments), &sz))
295+ goto fail2;
296+
297+ t = grub_realloc (comp->segments, sz);
298 if (!t)
299 goto fail2;
300 comp->segments = t;
301diff --git a/grub-core/font/font.c b/grub-core/font/font.c
302index 8e118b3..5edb477 100644
303--- a/grub-core/font/font.c
304+++ b/grub-core/font/font.c
305@@ -30,6 +30,7 @@
306 #include <grub/unicode.h>
307 #include <grub/fontformat.h>
308 #include <grub/env.h>
309+#include <grub/safemath.h>
310
311 GRUB_MOD_LICENSE ("GPLv3+");
312
313@@ -360,9 +361,13 @@ static char *
314 read_section_as_string (struct font_file_section *section)
315 {
316 char *str;
317+ grub_size_t sz;
318 grub_ssize_t ret;
319
320- str = grub_malloc (section->length + 1);
321+ if (grub_add (section->length, 1, &sz))
322+ return NULL;
323+
324+ str = grub_malloc (sz);
325 if (!str)
326 return 0;
327
328diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
329index 11272ef..2b65bd5 100644
330--- a/grub-core/fs/btrfs.c
331+++ b/grub-core/fs/btrfs.c
332@@ -40,6 +40,7 @@
333 #include <grub/btrfs.h>
334 #include <grub/crypto.h>
335 #include <grub/diskfilter.h>
336+#include <grub/safemath.h>
337
338 GRUB_MOD_LICENSE ("GPLv3+");
339
340@@ -329,9 +330,13 @@ save_ref (struct grub_btrfs_leaf_descriptor *desc,
341 if (desc->allocated < desc->depth)
342 {
343 void *newdata;
344- desc->allocated *= 2;
345- newdata = grub_realloc (desc->data, sizeof (desc->data[0])
346- * desc->allocated);
347+ grub_size_t sz;
348+
349+ if (grub_mul (desc->allocated, 2, &desc->allocated) ||
350+ grub_mul (desc->allocated, sizeof (desc->data[0]), &sz))
351+ return GRUB_ERR_OUT_OF_RANGE;
352+
353+ newdata = grub_realloc (desc->data, sz);
354 if (!newdata)
355 return grub_errno;
356 desc->data = newdata;
357@@ -622,16 +627,21 @@ find_device (struct grub_btrfs_data *data, grub_uint64_t id)
358 if (data->n_devices_attached > data->n_devices_allocated)
359 {
360 void *tmp;
361- data->n_devices_allocated = 2 * data->n_devices_attached + 1;
362- data->devices_attached
363- = grub_realloc (tmp = data->devices_attached,
364- data->n_devices_allocated
365- * sizeof (data->devices_attached[0]));
366+ grub_size_t sz;
367+
368+ if (grub_mul (data->n_devices_attached, 2, &data->n_devices_allocated) ||
369+ grub_add (data->n_devices_allocated, 1, &data->n_devices_allocated) ||
370+ grub_mul (data->n_devices_allocated, sizeof (data->devices_attached[0]), &sz))
371+ goto fail;
372+
373+ data->devices_attached = grub_realloc (tmp = data->devices_attached, sz);
374 if (!data->devices_attached)
375 {
376+ data->devices_attached = tmp;
377+
378+ fail:
379 if (ctx.dev_found)
380 grub_device_close (ctx.dev_found);
381- data->devices_attached = tmp;
382 return NULL;
383 }
384 }
385diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c
386index 9b38980..ac33bcd 100644
387--- a/grub-core/fs/ext2.c
388+++ b/grub-core/fs/ext2.c
389@@ -46,6 +46,7 @@
390 #include <grub/dl.h>
391 #include <grub/types.h>
392 #include <grub/fshelp.h>
393+#include <grub/safemath.h>
394
395 GRUB_MOD_LICENSE ("GPLv3+");
396
397@@ -703,6 +704,7 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
398 {
399 char *symlink;
400 struct grub_fshelp_node *diro = node;
401+ grub_size_t sz;
402
403 if (! diro->inode_read)
404 {
405@@ -717,7 +719,13 @@ grub_ext2_read_symlink (grub_fshelp_node_t node)
406 }
407 }
408
409- symlink = grub_malloc (grub_le_to_cpu32 (diro->inode.size) + 1);
410+ if (grub_add (grub_le_to_cpu32 (diro->inode.size), 1, &sz))
411+ {
412+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
413+ return NULL;
414+ }
415+
416+ symlink = grub_malloc (sz);
417 if (! symlink)
418 return 0;
419
420diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c
421index 4f1b52a..7ba5b30 100644
422--- a/grub-core/fs/iso9660.c
423+++ b/grub-core/fs/iso9660.c
424@@ -28,6 +28,7 @@
425 #include <grub/fshelp.h>
426 #include <grub/charset.h>
427 #include <grub/datetime.h>
428+#include <grub/safemath.h>
429
430 GRUB_MOD_LICENSE ("GPLv3+");
431
432@@ -531,8 +532,13 @@ add_part (struct iterate_dir_ctx *ctx,
433 int len2)
434 {
435 int size = ctx->symlink ? grub_strlen (ctx->symlink) : 0;
436+ grub_size_t sz;
437
438- ctx->symlink = grub_realloc (ctx->symlink, size + len2 + 1);
439+ if (grub_add (size, len2, &sz) ||
440+ grub_add (sz, 1, &sz))
441+ return;
442+
443+ ctx->symlink = grub_realloc (ctx->symlink, sz);
444 if (! ctx->symlink)
445 return;
446
447@@ -560,17 +566,24 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry,
448 {
449 grub_size_t off = 0, csize = 1;
450 char *old;
451+ grub_size_t sz;
452+
453 csize = entry->len - 5;
454 old = ctx->filename;
455 if (ctx->filename_alloc)
456 {
457 off = grub_strlen (ctx->filename);
458- ctx->filename = grub_realloc (ctx->filename, csize + off + 1);
459+ if (grub_add (csize, off, &sz) ||
460+ grub_add (sz, 1, &sz))
461+ return GRUB_ERR_OUT_OF_RANGE;
462+ ctx->filename = grub_realloc (ctx->filename, sz);
463 }
464 else
465 {
466 off = 0;
467- ctx->filename = grub_zalloc (csize + 1);
468+ if (grub_add (csize, 1, &sz))
469+ return GRUB_ERR_OUT_OF_RANGE;
470+ ctx->filename = grub_zalloc (sz);
471 }
472 if (!ctx->filename)
473 {
474@@ -776,14 +789,18 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
475 if (node->have_dirents >= node->alloc_dirents)
476 {
477 struct grub_fshelp_node *new_node;
478- node->alloc_dirents *= 2;
479- new_node = grub_realloc (node,
480- sizeof (struct grub_fshelp_node)
481- + ((node->alloc_dirents
482- - ARRAY_SIZE (node->dirents))
483- * sizeof (node->dirents[0])));
484+ grub_size_t sz;
485+
486+ if (grub_mul (node->alloc_dirents, 2, &node->alloc_dirents) ||
487+ grub_sub (node->alloc_dirents, ARRAY_SIZE (node->dirents), &sz) ||
488+ grub_mul (sz, sizeof (node->dirents[0]), &sz) ||
489+ grub_add (sz, sizeof (struct grub_fshelp_node), &sz))
490+ goto fail_0;
491+
492+ new_node = grub_realloc (node, sz);
493 if (!new_node)
494 {
495+ fail_0:
496 if (ctx.filename_alloc)
497 grub_free (ctx.filename);
498 grub_free (node);
499@@ -799,14 +816,18 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
500 * sizeof (node->dirents[0]) < grub_strlen (ctx.symlink) + 1)
501 {
502 struct grub_fshelp_node *new_node;
503- new_node = grub_realloc (node,
504- sizeof (struct grub_fshelp_node)
505- + ((node->alloc_dirents
506- - ARRAY_SIZE (node->dirents))
507- * sizeof (node->dirents[0]))
508- + grub_strlen (ctx.symlink) + 1);
509+ grub_size_t sz;
510+
511+ if (grub_sub (node->alloc_dirents, ARRAY_SIZE (node->dirents), &sz) ||
512+ grub_mul (sz, sizeof (node->dirents[0]), &sz) ||
513+ grub_add (sz, sizeof (struct grub_fshelp_node) + 1, &sz) ||
514+ grub_add (sz, grub_strlen (ctx.symlink), &sz))
515+ goto fail_1;
516+
517+ new_node = grub_realloc (node, sz);
518 if (!new_node)
519 {
520+ fail_1:
521 if (ctx.filename_alloc)
522 grub_free (ctx.filename);
523 grub_free (node);
524diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c
525index 90f7fb3..de2b107 100644
526--- a/grub-core/fs/sfs.c
527+++ b/grub-core/fs/sfs.c
528@@ -26,6 +26,7 @@
529 #include <grub/types.h>
530 #include <grub/fshelp.h>
531 #include <grub/charset.h>
532+#include <grub/safemath.h>
533
534 GRUB_MOD_LICENSE ("GPLv3+");
535
536@@ -307,10 +308,15 @@ grub_sfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
537 if (node->cache && node->cache_size >= node->cache_allocated)
538 {
539 struct cache_entry *e = node->cache;
540- e = grub_realloc (node->cache,node->cache_allocated * 2
541- * sizeof (e[0]));
542+ grub_size_t sz;
543+
544+ if (grub_mul (node->cache_allocated, 2 * sizeof (e[0]), &sz))
545+ goto fail;
546+
547+ e = grub_realloc (node->cache, sz);
548 if (!e)
549 {
550+ fail:
551 grub_errno = 0;
552 grub_free (node->cache);
553 node->cache = 0;
554@@ -477,10 +483,16 @@ grub_sfs_create_node (struct grub_fshelp_node **node,
555 grub_size_t len = grub_strlen (name);
556 grub_uint8_t *name_u8;
557 int ret;
558+ grub_size_t sz;
559+
560+ if (grub_mul (len, GRUB_MAX_UTF8_PER_LATIN1, &sz) ||
561+ grub_add (sz, 1, &sz))
562+ return 1;
563+
564 *node = grub_malloc (sizeof (**node));
565 if (!*node)
566 return 1;
567- name_u8 = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1);
568+ name_u8 = grub_malloc (sz);
569 if (!name_u8)
570 {
571 grub_free (*node);
572@@ -724,8 +736,13 @@ grub_sfs_label (grub_device_t device, char **label)
573 data = grub_sfs_mount (disk);
574 if (data)
575 {
576- grub_size_t len = grub_strlen (data->label);
577- *label = grub_malloc (len * GRUB_MAX_UTF8_PER_LATIN1 + 1);
578+ grub_size_t sz, len = grub_strlen (data->label);
579+
580+ if (grub_mul (len, GRUB_MAX_UTF8_PER_LATIN1, &sz) ||
581+ grub_add (sz, 1, &sz))
582+ return GRUB_ERR_OUT_OF_RANGE;
583+
584+ *label = grub_malloc (sz);
585 if (*label)
586 *grub_latin1_to_utf8 ((grub_uint8_t *) *label,
587 (const grub_uint8_t *) data->label,
588diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c
589index 95d5c1e..7851238 100644
590--- a/grub-core/fs/squash4.c
591+++ b/grub-core/fs/squash4.c
592@@ -26,6 +26,7 @@
593 #include <grub/types.h>
594 #include <grub/fshelp.h>
595 #include <grub/deflate.h>
596+#include <grub/safemath.h>
597 #include <minilzo.h>
598
599 #include "xz.h"
600@@ -459,7 +460,17 @@ grub_squash_read_symlink (grub_fshelp_node_t node)
601 {
602 char *ret;
603 grub_err_t err;
604- ret = grub_malloc (grub_le_to_cpu32 (node->ino.symlink.namelen) + 1);
605+ grub_size_t sz;
606+
607+ if (grub_add (grub_le_to_cpu32 (node->ino.symlink.namelen), 1, &sz))
608+ {
609+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
610+ return NULL;
611+ }
612+
613+ ret = grub_malloc (sz);
614+ if (!ret)
615+ return NULL;
616
617 err = read_chunk (node->data, ret,
618 grub_le_to_cpu32 (node->ino.symlink.namelen),
619@@ -506,11 +517,16 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir,
620
621 {
622 grub_fshelp_node_t node;
623- node = grub_malloc (sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
624+ grub_size_t sz;
625+
626+ if (grub_mul (dir->stsize, sizeof (dir->stack[0]), &sz) ||
627+ grub_add (sz, sizeof (*node), &sz))
628+ return 0;
629+
630+ node = grub_malloc (sz);
631 if (!node)
632 return 0;
633- grub_memcpy (node, dir,
634- sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
635+ grub_memcpy (node, dir, sz);
636 if (hook (".", GRUB_FSHELP_DIR, node, hook_data))
637 return 1;
638
639@@ -518,12 +534,15 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir,
640 {
641 grub_err_t err;
642
643- node = grub_malloc (sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
644+ if (grub_mul (dir->stsize, sizeof (dir->stack[0]), &sz) ||
645+ grub_add (sz, sizeof (*node), &sz))
646+ return 0;
647+
648+ node = grub_malloc (sz);
649 if (!node)
650 return 0;
651
652- grub_memcpy (node, dir,
653- sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
654+ grub_memcpy (node, dir, sz);
655
656 node->stsize--;
657 err = read_chunk (dir->data, &node->ino, sizeof (node->ino),
658@@ -557,6 +576,7 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir,
659 enum grub_fshelp_filetype filetype = GRUB_FSHELP_REG;
660 struct grub_squash_dirent di;
661 struct grub_squash_inode ino;
662+ grub_size_t sz;
663
664 err = read_chunk (dir->data, &di, sizeof (di),
665 grub_le_to_cpu64 (dir->data->sb.diroffset)
666@@ -589,13 +609,16 @@ grub_squash_iterate_dir (grub_fshelp_node_t dir,
667 if (grub_le_to_cpu16 (di.type) == SQUASH_TYPE_SYMLINK)
668 filetype = GRUB_FSHELP_SYMLINK;
669
670- node = grub_malloc (sizeof (*node)
671- + (dir->stsize + 1) * sizeof (dir->stack[0]));
672+ if (grub_add (dir->stsize, 1, &sz) ||
673+ grub_mul (sz, sizeof (dir->stack[0]), &sz) ||
674+ grub_add (sz, sizeof (*node), &sz))
675+ return 0;
676+
677+ node = grub_malloc (sz);
678 if (! node)
679 return 0;
680
681- grub_memcpy (node, dir,
682- sizeof (*node) + dir->stsize * sizeof (dir->stack[0]));
683+ grub_memcpy (node, dir, sz - sizeof(dir->stack[0]));
684
685 node->ino = ino;
686 node->stack[node->stsize].ino_chunk = grub_le_to_cpu32 (dh.ino_chunk);
687diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c
688index a837616..21ac7f4 100644
689--- a/grub-core/fs/udf.c
690+++ b/grub-core/fs/udf.c
691@@ -28,6 +28,7 @@
692 #include <grub/charset.h>
693 #include <grub/datetime.h>
694 #include <grub/udf.h>
695+#include <grub/safemath.h>
696
697 GRUB_MOD_LICENSE ("GPLv3+");
698
699@@ -890,9 +891,19 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf)
700 utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2];
701 }
702 if (!outbuf)
703- outbuf = grub_malloc (utf16len * GRUB_MAX_UTF8_PER_UTF16 + 1);
704+ {
705+ grub_size_t size;
706+
707+ if (grub_mul (utf16len, GRUB_MAX_UTF8_PER_UTF16, &size) ||
708+ grub_add (size, 1, &size))
709+ goto fail;
710+
711+ outbuf = grub_malloc (size);
712+ }
713 if (outbuf)
714 *grub_utf16_to_utf8 ((grub_uint8_t *) outbuf, utf16, utf16len) = '\0';
715+
716+ fail:
717 grub_free (utf16);
718 return outbuf;
719 }
720@@ -1005,7 +1016,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node)
721 grub_size_t sz = U64 (node->block.fe.file_size);
722 grub_uint8_t *raw;
723 const grub_uint8_t *ptr;
724- char *out, *optr;
725+ char *out = NULL, *optr;
726
727 if (sz < 4)
728 return NULL;
729@@ -1013,14 +1024,16 @@ grub_udf_read_symlink (grub_fshelp_node_t node)
730 if (!raw)
731 return NULL;
732 if (grub_udf_read_file (node, NULL, NULL, 0, sz, (char *) raw) < 0)
733- {
734- grub_free (raw);
735- return NULL;
736- }
737+ goto fail_1;
738
739- out = grub_malloc (sz * 2 + 1);
740+ if (grub_mul (sz, 2, &sz) ||
741+ grub_add (sz, 1, &sz))
742+ goto fail_0;
743+
744+ out = grub_malloc (sz);
745 if (!out)
746 {
747+ fail_0:
748 grub_free (raw);
749 return NULL;
750 }
751@@ -1031,17 +1044,17 @@ grub_udf_read_symlink (grub_fshelp_node_t node)
752 {
753 grub_size_t s;
754 if ((grub_size_t) (ptr - raw + 4) > sz)
755- goto fail;
756+ goto fail_1;
757 if (!(ptr[2] == 0 && ptr[3] == 0))
758- goto fail;
759+ goto fail_1;
760 s = 4 + ptr[1];
761 if ((grub_size_t) (ptr - raw + s) > sz)
762- goto fail;
763+ goto fail_1;
764 switch (*ptr)
765 {
766 case 1:
767 if (ptr[1])
768- goto fail;
769+ goto fail_1;
770 /* Fallthrough. */
771 case 2:
772 /* in 4 bytes. out: 1 byte. */
773@@ -1066,11 +1079,11 @@ grub_udf_read_symlink (grub_fshelp_node_t node)
774 if (optr != out)
775 *optr++ = '/';
776 if (!read_string (ptr + 4, s - 4, optr))
777- goto fail;
778+ goto fail_1;
779 optr += grub_strlen (optr);
780 break;
781 default:
782- goto fail;
783+ goto fail_1;
784 }
785 ptr += s;
786 }
787@@ -1078,7 +1091,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node)
788 grub_free (raw);
789 return out;
790
791- fail:
792+ fail_1:
793 grub_free (raw);
794 grub_free (out);
795 grub_error (GRUB_ERR_BAD_FS, "invalid symlink");
796diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
797index 96ffecb..ea65902 100644
798--- a/grub-core/fs/xfs.c
799+++ b/grub-core/fs/xfs.c
800@@ -25,6 +25,7 @@
801 #include <grub/dl.h>
802 #include <grub/types.h>
803 #include <grub/fshelp.h>
804+#include <grub/safemath.h>
805
806 GRUB_MOD_LICENSE ("GPLv3+");
807
808@@ -899,6 +900,7 @@ static struct grub_xfs_data *
809 grub_xfs_mount (grub_disk_t disk)
810 {
811 struct grub_xfs_data *data = 0;
812+ grub_size_t sz;
813
814 data = grub_zalloc (sizeof (struct grub_xfs_data));
815 if (!data)
816@@ -913,10 +915,11 @@ grub_xfs_mount (grub_disk_t disk)
817 if (!grub_xfs_sb_valid(data))
818 goto fail;
819
820- data = grub_realloc (data,
821- sizeof (struct grub_xfs_data)
822- - sizeof (struct grub_xfs_inode)
823- + grub_xfs_inode_size(data) + 1);
824+ if (grub_add (grub_xfs_inode_size (data),
825+ sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) + 1, &sz))
826+ goto fail;
827+
828+ data = grub_realloc (data, sz);
829
830 if (! data)
831 goto fail;
832diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
833index 381dde5..36d0373 100644
834--- a/grub-core/fs/zfs/zfs.c
835+++ b/grub-core/fs/zfs/zfs.c
836@@ -55,6 +55,7 @@
837 #include <grub/deflate.h>
838 #include <grub/crypto.h>
839 #include <grub/i18n.h>
840+#include <grub/safemath.h>
841
842 GRUB_MOD_LICENSE ("GPLv3+");
843
844@@ -773,11 +774,14 @@ fill_vdev_info (struct grub_zfs_data *data,
845 if (data->n_devices_attached > data->n_devices_allocated)
846 {
847 void *tmp;
848- data->n_devices_allocated = 2 * data->n_devices_attached + 1;
849- data->devices_attached
850- = grub_realloc (tmp = data->devices_attached,
851- data->n_devices_allocated
852- * sizeof (data->devices_attached[0]));
853+ grub_size_t sz;
854+
855+ if (grub_mul (data->n_devices_attached, 2, &data->n_devices_allocated) ||
856+ grub_add (data->n_devices_allocated, 1, &data->n_devices_allocated) ||
857+ grub_mul (data->n_devices_allocated, sizeof (data->devices_attached[0]), &sz))
858+ return GRUB_ERR_OUT_OF_RANGE;
859+
860+ data->devices_attached = grub_realloc (tmp = data->devices_attached, sz);
861 if (!data->devices_attached)
862 {
863 data->devices_attached = tmp;
864@@ -3468,14 +3472,18 @@ grub_zfs_nvlist_lookup_nvlist (const char *nvlist, const char *name)
865 {
866 char *nvpair;
867 char *ret;
868- grub_size_t size;
869+ grub_size_t size, sz;
870 int found;
871
872 found = nvlist_find_value (nvlist, name, DATA_TYPE_NVLIST, &nvpair,
873 &size, 0);
874 if (!found)
875 return 0;
876- ret = grub_zalloc (size + 3 * sizeof (grub_uint32_t));
877+
878+ if (grub_add (size, 3 * sizeof (grub_uint32_t), &sz))
879+ return 0;
880+
881+ ret = grub_zalloc (sz);
882 if (!ret)
883 return 0;
884 grub_memcpy (ret, nvlist, sizeof (grub_uint32_t));
885diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c
886index 1402e0b..de3b015 100644
887--- a/grub-core/fs/zfs/zfscrypt.c
888+++ b/grub-core/fs/zfs/zfscrypt.c
889@@ -22,6 +22,7 @@
890 #include <grub/misc.h>
891 #include <grub/disk.h>
892 #include <grub/partition.h>
893+#include <grub/safemath.h>
894 #include <grub/dl.h>
895 #include <grub/types.h>
896 #include <grub/zfs/zfs.h>
897@@ -82,9 +83,13 @@ grub_zfs_add_key (grub_uint8_t *key_in,
898 int passphrase)
899 {
900 struct grub_zfs_wrap_key *key;
901+ grub_size_t sz;
902+
903 if (!passphrase && keylen > 32)
904 keylen = 32;
905- key = grub_malloc (sizeof (*key) + keylen);
906+ if (grub_add (sizeof (*key), keylen, &sz))
907+ return GRUB_ERR_OUT_OF_RANGE;
908+ key = grub_malloc (sz);
909 if (!key)
910 return grub_errno;
911 key->is_passphrase = passphrase;
912diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c
913index fd7744a..3288609 100644
914--- a/grub-core/lib/arg.c
915+++ b/grub-core/lib/arg.c
916@@ -23,6 +23,7 @@
917 #include <grub/term.h>
918 #include <grub/extcmd.h>
919 #include <grub/i18n.h>
920+#include <grub/safemath.h>
921
922 /* Built-in parser for default options. */
923 static const struct grub_arg_option help_options[] =
924@@ -216,7 +217,13 @@ static inline grub_err_t
925 add_arg (char ***argl, int *num, char *s)
926 {
927 char **p = *argl;
928- *argl = grub_realloc (*argl, (++(*num) + 1) * sizeof (char *));
929+ grub_size_t sz;
930+
931+ if (grub_add (++(*num), 1, &sz) ||
932+ grub_mul (sz, sizeof (char *), &sz))
933+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
934+
935+ *argl = grub_realloc (*argl, sz);
936 if (! *argl)
937 {
938 grub_free (p);
939@@ -431,6 +438,7 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc,
940 grub_size_t argcnt;
941 struct grub_arg_list *list;
942 const struct grub_arg_option *options;
943+ grub_size_t sz0, sz1;
944
945 options = extcmd->options;
946 if (! options)
947@@ -443,7 +451,15 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc,
948 argcnt += ((grub_size_t) argc + 1) / 2 + 1; /* max possible for any option */
949 }
950
951- list = grub_zalloc (sizeof (*list) * i + sizeof (char*) * argcnt);
952+ if (grub_mul (sizeof (*list), i, &sz0) ||
953+ grub_mul (sizeof (char *), argcnt, &sz1) ||
954+ grub_add (sz0, sz1, &sz0))
955+ {
956+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
957+ return 0;
958+ }
959+
960+ list = grub_zalloc (sz0);
961 if (! list)
962 return 0;
963
964diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
965index 3730ed3..b92cbe9 100644
966--- a/grub-core/loader/i386/bsd.c
967+++ b/grub-core/loader/i386/bsd.c
968@@ -35,6 +35,7 @@
969 #include <grub/ns8250.h>
970 #include <grub/bsdlabel.h>
971 #include <grub/crypto.h>
972+#include <grub/safemath.h>
973 #include <grub/verify.h>
974 #ifdef GRUB_MACHINE_PCBIOS
975 #include <grub/machine/int.h>
976@@ -1012,11 +1013,16 @@ grub_netbsd_add_modules (void)
977 struct grub_netbsd_btinfo_modules *mods;
978 unsigned i;
979 grub_err_t err;
980+ grub_size_t sz;
981
982 for (mod = netbsd_mods; mod; mod = mod->next)
983 modcnt++;
984
985- mods = grub_malloc (sizeof (*mods) + sizeof (mods->mods[0]) * modcnt);
986+ if (grub_mul (modcnt, sizeof (mods->mods[0]), &sz) ||
987+ grub_add (sz, sizeof (*mods), &sz))
988+ return GRUB_ERR_OUT_OF_RANGE;
989+
990+ mods = grub_malloc (sz);
991 if (!mods)
992 return grub_errno;
993
994diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c
995index e332d5e..906ec7d 100644
996--- a/grub-core/net/dns.c
997+++ b/grub-core/net/dns.c
998@@ -22,6 +22,7 @@
999 #include <grub/i18n.h>
1000 #include <grub/err.h>
1001 #include <grub/time.h>
1002+#include <grub/safemath.h>
1003
1004 struct dns_cache_element
1005 {
1006@@ -51,9 +52,15 @@ grub_net_add_dns_server (const struct grub_net_network_level_address *s)
1007 {
1008 int na = dns_servers_alloc * 2;
1009 struct grub_net_network_level_address *ns;
1010+ grub_size_t sz;
1011+
1012 if (na < 8)
1013 na = 8;
1014- ns = grub_realloc (dns_servers, na * sizeof (ns[0]));
1015+
1016+ if (grub_mul (na, sizeof (ns[0]), &sz))
1017+ return GRUB_ERR_OUT_OF_RANGE;
1018+
1019+ ns = grub_realloc (dns_servers, sz);
1020 if (!ns)
1021 return grub_errno;
1022 dns_servers_alloc = na;
1023diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
1024index d57fb72..4dfcc31 100644
1025--- a/grub-core/normal/charset.c
1026+++ b/grub-core/normal/charset.c
1027@@ -48,6 +48,7 @@
1028 #include <grub/unicode.h>
1029 #include <grub/term.h>
1030 #include <grub/normal.h>
1031+#include <grub/safemath.h>
1032
1033 #if HAVE_FONT_SOURCE
1034 #include "widthspec.h"
1035@@ -464,6 +465,7 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
1036 {
1037 struct grub_unicode_combining *n;
1038 unsigned j;
1039+ grub_size_t sz;
1040
1041 if (!haveout)
1042 continue;
1043@@ -477,10 +479,14 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
1044 n = out->combining_inline;
1045 else if (out->ncomb > (int) ARRAY_SIZE (out->combining_inline))
1046 {
1047- n = grub_realloc (out->combining_ptr,
1048- sizeof (n[0]) * (out->ncomb + 1));
1049+ if (grub_add (out->ncomb, 1, &sz) ||
1050+ grub_mul (sz, sizeof (n[0]), &sz))
1051+ goto fail;
1052+
1053+ n = grub_realloc (out->combining_ptr, sz);
1054 if (!n)
1055 {
1056+ fail:
1057 grub_errno = GRUB_ERR_NONE;
1058 continue;
1059 }
1060diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c
1061index c57242e..de03fe6 100644
1062--- a/grub-core/normal/cmdline.c
1063+++ b/grub-core/normal/cmdline.c
1064@@ -28,6 +28,7 @@
1065 #include <grub/env.h>
1066 #include <grub/i18n.h>
1067 #include <grub/charset.h>
1068+#include <grub/safemath.h>
1069
1070 static grub_uint32_t *kill_buf;
1071
1072@@ -307,12 +308,21 @@ cl_insert (struct cmdline_term *cl_terms, unsigned nterms,
1073 if (len + (*llen) >= (*max_len))
1074 {
1075 grub_uint32_t *nbuf;
1076- (*max_len) *= 2;
1077- nbuf = grub_realloc ((*buf), sizeof (grub_uint32_t) * (*max_len));
1078+ grub_size_t sz;
1079+
1080+ if (grub_mul (*max_len, 2, max_len) ||
1081+ grub_mul (*max_len, sizeof (grub_uint32_t), &sz))
1082+ {
1083+ grub_errno = GRUB_ERR_OUT_OF_RANGE;
1084+ goto fail;
1085+ }
1086+
1087+ nbuf = grub_realloc ((*buf), sz);
1088 if (nbuf)
1089 (*buf) = nbuf;
1090 else
1091 {
1092+ fail:
1093 grub_print_error ();
1094 grub_errno = GRUB_ERR_NONE;
1095 (*max_len) /= 2;
1096diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
1097index 1993995..50eef91 100644
1098--- a/grub-core/normal/menu_entry.c
1099+++ b/grub-core/normal/menu_entry.c
1100@@ -27,6 +27,7 @@
1101 #include <grub/auth.h>
1102 #include <grub/i18n.h>
1103 #include <grub/charset.h>
1104+#include <grub/safemath.h>
1105
1106 enum update_mode
1107 {
1108@@ -113,10 +114,18 @@ ensure_space (struct line *linep, int extra)
1109 {
1110 if (linep->max_len < linep->len + extra)
1111 {
1112- linep->max_len = 2 * (linep->len + extra);
1113- linep->buf = grub_realloc (linep->buf, (linep->max_len + 1) * sizeof (linep->buf[0]));
1114+ grub_size_t sz0, sz1;
1115+
1116+ if (grub_add (linep->len, extra, &sz0) ||
1117+ grub_mul (sz0, 2, &sz0) ||
1118+ grub_add (sz0, 1, &sz1) ||
1119+ grub_mul (sz1, sizeof (linep->buf[0]), &sz1))
1120+ return 0;
1121+
1122+ linep->buf = grub_realloc (linep->buf, sz1);
1123 if (! linep->buf)
1124 return 0;
1125+ linep->max_len = sz0;
1126 }
1127
1128 return 1;
1129diff --git a/grub-core/script/argv.c b/grub-core/script/argv.c
1130index 217ec5d..5751fdd 100644
1131--- a/grub-core/script/argv.c
1132+++ b/grub-core/script/argv.c
1133@@ -20,6 +20,7 @@
1134 #include <grub/mm.h>
1135 #include <grub/misc.h>
1136 #include <grub/script_sh.h>
1137+#include <grub/safemath.h>
1138
1139 /* Return nearest power of two that is >= v. */
1140 static unsigned
1141@@ -81,11 +82,16 @@ int
1142 grub_script_argv_next (struct grub_script_argv *argv)
1143 {
1144 char **p = argv->args;
1145+ grub_size_t sz;
1146
1147 if (argv->args && argv->argc && argv->args[argv->argc - 1] == 0)
1148 return 0;
1149
1150- p = grub_realloc (p, round_up_exp ((argv->argc + 2) * sizeof (char *)));
1151+ if (grub_add (argv->argc, 2, &sz) ||
1152+ grub_mul (sz, sizeof (char *), &sz))
1153+ return 1;
1154+
1155+ p = grub_realloc (p, round_up_exp (sz));
1156 if (! p)
1157 return 1;
1158
1159@@ -105,13 +111,19 @@ grub_script_argv_append (struct grub_script_argv *argv, const char *s,
1160 {
1161 grub_size_t a;
1162 char *p = argv->args[argv->argc - 1];
1163+ grub_size_t sz;
1164
1165 if (! s)
1166 return 0;
1167
1168 a = p ? grub_strlen (p) : 0;
1169
1170- p = grub_realloc (p, round_up_exp ((a + slen + 1) * sizeof (char)));
1171+ if (grub_add (a, slen, &sz) ||
1172+ grub_add (sz, 1, &sz) ||
1173+ grub_mul (sz, sizeof (char), &sz))
1174+ return 1;
1175+
1176+ p = grub_realloc (p, round_up_exp (sz));
1177 if (! p)
1178 return 1;
1179
1180diff --git a/grub-core/script/lexer.c b/grub-core/script/lexer.c
1181index c6bd317..5fb0cbd 100644
1182--- a/grub-core/script/lexer.c
1183+++ b/grub-core/script/lexer.c
1184@@ -24,6 +24,7 @@
1185 #include <grub/mm.h>
1186 #include <grub/script_sh.h>
1187 #include <grub/i18n.h>
1188+#include <grub/safemath.h>
1189
1190 #define yytext_ptr char *
1191 #include "grub_script.tab.h"
1192@@ -110,10 +111,14 @@ grub_script_lexer_record (struct grub_parser_param *parser, char *str)
1193 old = lexer->recording;
1194 if (lexer->recordlen < len)
1195 lexer->recordlen = len;
1196- lexer->recordlen *= 2;
1197+
1198+ if (grub_mul (lexer->recordlen, 2, &lexer->recordlen))
1199+ goto fail;
1200+
1201 lexer->recording = grub_realloc (lexer->recording, lexer->recordlen);
1202 if (!lexer->recording)
1203 {
1204+ fail:
1205 grub_free (old);
1206 lexer->recordpos = 0;
1207 lexer->recordlen = 0;
1208@@ -130,7 +135,7 @@ int
1209 grub_script_lexer_yywrap (struct grub_parser_param *parserstate,
1210 const char *input)
1211 {
1212- grub_size_t len = 0;
1213+ grub_size_t len = 0, sz;
1214 char *p = 0;
1215 char *line = 0;
1216 YY_BUFFER_STATE buffer;
1217@@ -168,12 +173,22 @@ grub_script_lexer_yywrap (struct grub_parser_param *parserstate,
1218 }
1219 else if (len && line[len - 1] != '\n')
1220 {
1221- p = grub_realloc (line, len + 2);
1222+ if (grub_add (len, 2, &sz))
1223+ {
1224+ grub_free (line);
1225+ grub_script_yyerror (parserstate, N_("overflow is detected"));
1226+ return 1;
1227+ }
1228+
1229+ p = grub_realloc (line, sz);
1230 if (p)
1231 {
1232 p[len++] = '\n';
1233 p[len] = '\0';
1234 }
1235+ else
1236+ grub_free (line);
1237+
1238 line = p;
1239 }
1240
1241diff --git a/grub-core/video/bitmap.c b/grub-core/video/bitmap.c
1242index b2e0315..6256e20 100644
1243--- a/grub-core/video/bitmap.c
1244+++ b/grub-core/video/bitmap.c
1245@@ -23,6 +23,7 @@
1246 #include <grub/mm.h>
1247 #include <grub/misc.h>
1248 #include <grub/i18n.h>
1249+#include <grub/safemath.h>
1250
1251 GRUB_MOD_LICENSE ("GPLv3+");
1252
1253@@ -58,7 +59,7 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
1254 enum grub_video_blit_format blit_format)
1255 {
1256 struct grub_video_mode_info *mode_info;
1257- unsigned int size;
1258+ grub_size_t size;
1259
1260 if (!bitmap)
1261 return grub_error (GRUB_ERR_BUG, "invalid argument");
1262@@ -137,19 +138,25 @@ grub_video_bitmap_create (struct grub_video_bitmap **bitmap,
1263
1264 mode_info->pitch = width * mode_info->bytes_per_pixel;
1265
1266- /* Calculate size needed for the data. */
1267- size = (width * mode_info->bytes_per_pixel) * height;
1268+ /* Calculate size needed for the data. */
1269+ if (grub_mul (width, mode_info->bytes_per_pixel, &size) ||
1270+ grub_mul (size, height, &size))
1271+ {
1272+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
1273+ goto fail;
1274+ }
1275
1276 (*bitmap)->data = grub_zalloc (size);
1277 if (! (*bitmap)->data)
1278- {
1279- grub_free (*bitmap);
1280- *bitmap = 0;
1281-
1282- return grub_errno;
1283- }
1284+ goto fail;
1285
1286 return GRUB_ERR_NONE;
1287+
1288+ fail:
1289+ grub_free (*bitmap);
1290+ *bitmap = NULL;
1291+
1292+ return grub_errno;
1293 }
1294
1295 /* Frees all resources allocated by bitmap. */
1296diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c
1297index 61bd645..0157ff7 100644
1298--- a/grub-core/video/readers/png.c
1299+++ b/grub-core/video/readers/png.c
1300@@ -23,6 +23,7 @@
1301 #include <grub/mm.h>
1302 #include <grub/misc.h>
1303 #include <grub/bufio.h>
1304+#include <grub/safemath.h>
1305
1306 GRUB_MOD_LICENSE ("GPLv3+");
1307
1308@@ -301,9 +302,17 @@ grub_png_decode_image_header (struct grub_png_data *data)
1309 data->bpp <<= 1;
1310
1311 data->color_bits = color_bits;
1312- data->row_bytes = data->image_width * data->bpp;
1313+
1314+ if (grub_mul (data->image_width, data->bpp, &data->row_bytes))
1315+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
1316+
1317 if (data->color_bits <= 4)
1318- data->row_bytes = (data->image_width * data->color_bits + 7) / 8;
1319+ {
1320+ if (grub_mul (data->image_width, data->color_bits + 7, &data->row_bytes))
1321+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
1322+
1323+ data->row_bytes >>= 3;
1324+ }
1325
1326 #ifndef GRUB_CPU_WORDS_BIGENDIAN
1327 if (data->is_16bit || data->is_gray || data->is_palette)
1328--
13292.14.4
1330
diff --git a/meta/recipes-bsp/grub/files/CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch b/meta/recipes-bsp/grub/files/CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch
deleted file mode 100644
index 329e554a68..0000000000
--- a/meta/recipes-bsp/grub/files/CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch
+++ /dev/null
@@ -1,117 +0,0 @@
1From c65fc7e75b7b7e880d90766057040011701e97f4 Mon Sep 17 00:00:00 2001
2From: Chris Coulson <chris.coulson@canonical.com>
3Date: Fri, 10 Jul 2020 14:41:45 +0100
4Subject: [PATCH 8/9] script: Avoid a use-after-free when redefining a function
5 during execution
6
7Defining a new function with the same name as a previously defined
8function causes the grub_script and associated resources for the
9previous function to be freed. If the previous function is currently
10executing when a function with the same name is defined, this results
11in use-after-frees when processing subsequent commands in the original
12function.
13
14Instead, reject a new function definition if it has the same name as
15a previously defined function, and that function is currently being
16executed. Although a behavioural change, this should be backwards
17compatible with existing configurations because they can't be
18dependent on the current behaviour without being broken.
19
20Fixes: CVE-2020-15706
21
22Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
23Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
24
25Upstream-Status: Backport
26CVE: CVE-2020-15706
27
28Reference to upstream patch:
29https://git.savannah.gnu.org/cgit/grub.git/commit/?id=426f57383d647406ae9c628c472059c27cd6e040
30
31Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
32---
33 grub-core/script/execute.c | 2 ++
34 grub-core/script/function.c | 16 +++++++++++++---
35 grub-core/script/parser.y | 3 ++-
36 include/grub/script_sh.h | 2 ++
37 4 files changed, 19 insertions(+), 4 deletions(-)
38
39diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
40index c8d6806..7e028e1 100644
41--- a/grub-core/script/execute.c
42+++ b/grub-core/script/execute.c
43@@ -838,7 +838,9 @@ grub_script_function_call (grub_script_function_t func, int argc, char **args)
44 old_scope = scope;
45 scope = &new_scope;
46
47+ func->executing++;
48 ret = grub_script_execute (func->func);
49+ func->executing--;
50
51 function_return = 0;
52 active_loops = loops;
53diff --git a/grub-core/script/function.c b/grub-core/script/function.c
54index d36655e..3aad04b 100644
55--- a/grub-core/script/function.c
56+++ b/grub-core/script/function.c
57@@ -34,6 +34,7 @@ grub_script_function_create (struct grub_script_arg *functionname_arg,
58 func = (grub_script_function_t) grub_malloc (sizeof (*func));
59 if (! func)
60 return 0;
61+ func->executing = 0;
62
63 func->name = grub_strdup (functionname_arg->str);
64 if (! func->name)
65@@ -60,10 +61,19 @@ grub_script_function_create (struct grub_script_arg *functionname_arg,
66 grub_script_function_t q;
67
68 q = *p;
69- grub_script_free (q->func);
70- q->func = cmd;
71 grub_free (func);
72- func = q;
73+ if (q->executing > 0)
74+ {
75+ grub_error (GRUB_ERR_BAD_ARGUMENT,
76+ N_("attempt to redefine a function being executed"));
77+ func = NULL;
78+ }
79+ else
80+ {
81+ grub_script_free (q->func);
82+ q->func = cmd;
83+ func = q;
84+ }
85 }
86 else
87 {
88diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y
89index 4f0ab83..f80b86b 100644
90--- a/grub-core/script/parser.y
91+++ b/grub-core/script/parser.y
92@@ -289,7 +289,8 @@ function: "function" "name"
93 grub_script_mem_free (state->func_mem);
94 else {
95 script->children = state->scripts;
96- grub_script_function_create ($2, script);
97+ if (!grub_script_function_create ($2, script))
98+ grub_script_free (script);
99 }
100
101 state->scripts = $<scripts>3;
102diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h
103index b382bcf..6c48e07 100644
104--- a/include/grub/script_sh.h
105+++ b/include/grub/script_sh.h
106@@ -361,6 +361,8 @@ struct grub_script_function
107
108 /* The next element. */
109 struct grub_script_function *next;
110+
111+ unsigned executing;
112 };
113 typedef struct grub_script_function *grub_script_function_t;
114
115--
1162.14.4
117
diff --git a/meta/recipes-bsp/grub/files/CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch b/meta/recipes-bsp/grub/files/CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch
deleted file mode 100644
index d4f9300c0a..0000000000
--- a/meta/recipes-bsp/grub/files/CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch
+++ /dev/null
@@ -1,177 +0,0 @@
1From 68a09a74f6d726d79709847f3671c0a08e4fb5a0 Mon Sep 17 00:00:00 2001
2From: Colin Watson <cjwatson@debian.org>
3Date: Sat, 25 Jul 2020 12:15:37 +0100
4Subject: [PATCH 9/9] linux: Fix integer overflows in initrd size handling
5
6These could be triggered by a crafted filesystem with very large files.
7
8Fixes: CVE-2020-15707
9
10Signed-off-by: Colin Watson <cjwatson@debian.org>
11Reviewed-by: Jan Setje-Eilers <jan.setjeeilers@oracle.com>
12Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
13
14Upstream-Status: Backport
15CVE: CVE-2020-15707
16
17Reference to upstream patch:
18https://git.savannah.gnu.org/cgit/grub.git/commit/?id=e7b8856f8be3292afdb38d2e8c70ad8d62a61e10
19
20Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
21---
22 grub-core/loader/linux.c | 74 +++++++++++++++++++++++++++++++++++-------------
23 1 file changed, 54 insertions(+), 20 deletions(-)
24
25diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c
26index 471b214..8c8565a 100644
27--- a/grub-core/loader/linux.c
28+++ b/grub-core/loader/linux.c
29@@ -4,6 +4,7 @@
30 #include <grub/misc.h>
31 #include <grub/file.h>
32 #include <grub/mm.h>
33+#include <grub/safemath.h>
34
35 struct newc_head
36 {
37@@ -98,13 +99,13 @@ free_dir (struct dir *root)
38 grub_free (root);
39 }
40
41-static grub_size_t
42+static grub_err_t
43 insert_dir (const char *name, struct dir **root,
44- grub_uint8_t *ptr)
45+ grub_uint8_t *ptr, grub_size_t *size)
46 {
47 struct dir *cur, **head = root;
48 const char *cb, *ce = name;
49- grub_size_t size = 0;
50+ *size = 0;
51 while (1)
52 {
53 for (cb = ce; *cb == '/'; cb++);
54@@ -130,14 +131,22 @@ insert_dir (const char *name, struct dir **root,
55 ptr = make_header (ptr, name, ce - name,
56 040777, 0);
57 }
58- size += ALIGN_UP ((ce - (char *) name)
59- + sizeof (struct newc_head), 4);
60+ if (grub_add (*size,
61+ ALIGN_UP ((ce - (char *) name)
62+ + sizeof (struct newc_head), 4),
63+ size))
64+ {
65+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
66+ grub_free (n->name);
67+ grub_free (n);
68+ return grub_errno;
69+ }
70 *head = n;
71 cur = n;
72 }
73 root = &cur->next;
74 }
75- return size;
76+ return GRUB_ERR_NONE;
77 }
78
79 grub_err_t
80@@ -173,26 +182,33 @@ grub_initrd_init (int argc, char *argv[],
81 eptr = grub_strchr (ptr, ':');
82 if (eptr)
83 {
84+ grub_size_t dir_size, name_len;
85+
86 initrd_ctx->components[i].newc_name = grub_strndup (ptr, eptr - ptr);
87- if (!initrd_ctx->components[i].newc_name)
88+ if (!initrd_ctx->components[i].newc_name ||
89+ insert_dir (initrd_ctx->components[i].newc_name, &root, 0,
90+ &dir_size))
91 {
92 grub_initrd_close (initrd_ctx);
93 return grub_errno;
94 }
95- initrd_ctx->size
96- += ALIGN_UP (sizeof (struct newc_head)
97- + grub_strlen (initrd_ctx->components[i].newc_name),
98- 4);
99- initrd_ctx->size += insert_dir (initrd_ctx->components[i].newc_name,
100- &root, 0);
101+ name_len = grub_strlen (initrd_ctx->components[i].newc_name);
102+ if (grub_add (initrd_ctx->size,
103+ ALIGN_UP (sizeof (struct newc_head) + name_len, 4),
104+ &initrd_ctx->size) ||
105+ grub_add (initrd_ctx->size, dir_size, &initrd_ctx->size))
106+ goto overflow;
107 newc = 1;
108 fname = eptr + 1;
109 }
110 }
111 else if (newc)
112 {
113- initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
114- + sizeof ("TRAILER!!!") - 1, 4);
115+ if (grub_add (initrd_ctx->size,
116+ ALIGN_UP (sizeof (struct newc_head)
117+ + sizeof ("TRAILER!!!") - 1, 4),
118+ &initrd_ctx->size))
119+ goto overflow;
120 free_dir (root);
121 root = 0;
122 newc = 0;
123@@ -208,19 +224,29 @@ grub_initrd_init (int argc, char *argv[],
124 initrd_ctx->nfiles++;
125 initrd_ctx->components[i].size
126 = grub_file_size (initrd_ctx->components[i].file);
127- initrd_ctx->size += initrd_ctx->components[i].size;
128+ if (grub_add (initrd_ctx->size, initrd_ctx->components[i].size,
129+ &initrd_ctx->size))
130+ goto overflow;
131 }
132
133 if (newc)
134 {
135 initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4);
136- initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head)
137- + sizeof ("TRAILER!!!") - 1, 4);
138+ if (grub_add (initrd_ctx->size,
139+ ALIGN_UP (sizeof (struct newc_head)
140+ + sizeof ("TRAILER!!!") - 1, 4),
141+ &initrd_ctx->size))
142+ goto overflow;
143 free_dir (root);
144 root = 0;
145 }
146
147 return GRUB_ERR_NONE;
148+
149+ overflow:
150+ free_dir (root);
151+ grub_initrd_close (initrd_ctx);
152+ return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
153 }
154
155 grub_size_t
156@@ -261,8 +287,16 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
157
158 if (initrd_ctx->components[i].newc_name)
159 {
160- ptr += insert_dir (initrd_ctx->components[i].newc_name,
161- &root, ptr);
162+ grub_size_t dir_size;
163+
164+ if (insert_dir (initrd_ctx->components[i].newc_name, &root, ptr,
165+ &dir_size))
166+ {
167+ free_dir (root);
168+ grub_initrd_close (initrd_ctx);
169+ return grub_errno;
170+ }
171+ ptr += dir_size;
172 ptr = make_header (ptr, initrd_ctx->components[i].newc_name,
173 grub_strlen (initrd_ctx->components[i].newc_name),
174 0100777,
175--
1762.14.4
177
diff --git a/meta/recipes-bsp/grub/files/autogen.sh-exclude-pc.patch b/meta/recipes-bsp/grub/files/autogen.sh-exclude-pc.patch
index faa7fde232..f8dfda90ab 100644
--- a/meta/recipes-bsp/grub/files/autogen.sh-exclude-pc.patch
+++ b/meta/recipes-bsp/grub/files/autogen.sh-exclude-pc.patch
@@ -1,6 +1,6 @@
1From 72c30928d3d461e0e2d20c5ff33bd96b6991d585 Mon Sep 17 00:00:00 2001 1From 14c1d0459fb3561e627d3a5f6e91a0d2f7b4aa45 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com> 2From: Naveen Saini <naveen.kumar.saini@intel.com>
3Date: Sat, 25 Jan 2014 23:49:44 -0500 3Date: Mon, 15 Mar 2021 14:44:15 +0800
4Subject: [PATCH] autogen.sh: exclude .pc from po/POTFILES.in 4Subject: [PATCH] autogen.sh: exclude .pc from po/POTFILES.in
5 5
6Exclude the .pc from po/POTFILES.in since quilt uses "patch --backup", 6Exclude the .pc from po/POTFILES.in since quilt uses "patch --backup",
@@ -13,23 +13,22 @@ Upstream-Status: Inappropriate [OE specific]
13 13
14Signed-off-by: Robert Yang <liezhi.yang@windriver.com> 14Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
15Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> 15Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
16Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com>
17
16--- 18---
17 autogen.sh | 2 +- 19 autogen.sh | 2 +-
18 1 file changed, 1 insertion(+), 1 deletion(-) 20 1 file changed, 1 insertion(+), 1 deletion(-)
19 21
20diff --git a/autogen.sh b/autogen.sh 22diff --git a/autogen.sh b/autogen.sh
21index ef43270..a7067a7 100755 23index 195daa5..773b7b4 100755
22--- a/autogen.sh 24--- a/autogen.sh
23+++ b/autogen.sh 25+++ b/autogen.sh
24@@ -13,7 +13,7 @@ fi 26@@ -26,7 +26,7 @@ fi
25 export LC_COLLATE=C 27 export LC_COLLATE=C
26 unset LC_ALL 28 unset LC_ALL
27 29
28-find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -iname './grub-core/lib/gnulib/*' |sort > po/POTFILES.in 30-find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -ipath './grub-core/lib/gnulib/*' |sort > po/POTFILES.in
29+find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -iname './grub-core/lib/gnulib/*' ! -path './.pc/*' |sort > po/POTFILES.in 31+find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './build-aux/*' ! -ipath './grub-core/lib/libgcrypt/src/misc.c' ! -ipath './grub-core/lib/libgcrypt/src/global.c' ! -ipath './grub-core/lib/libgcrypt/src/secmem.c' ! -ipath './util/grub-gen-widthspec.c' ! -ipath './util/grub-gen-asciih.c' ! -ipath './gnulib/*' ! -ipath './grub-core/lib/gnulib/*' ! -path './.pc/*' |sort > po/POTFILES.in
30 find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in 32 find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in
31 33
32 echo "Importing unicode..." 34 echo "Importing unicode..."
33--
342.7.4
35
diff --git a/meta/recipes-bsp/grub/files/calloc-Make-sure-we-always-have-an-overflow-checking.patch b/meta/recipes-bsp/grub/files/calloc-Make-sure-we-always-have-an-overflow-checking.patch
deleted file mode 100644
index c9536e68ef..0000000000
--- a/meta/recipes-bsp/grub/files/calloc-Make-sure-we-always-have-an-overflow-checking.patch
+++ /dev/null
@@ -1,246 +0,0 @@
1From c005f62f5c4b26a77b916c8f76a852324439ecb3 Mon Sep 17 00:00:00 2001
2From: Peter Jones <pjones@redhat.com>
3Date: Mon, 15 Jun 2020 12:15:29 -0400
4Subject: [PATCH 2/9] calloc: Make sure we always have an overflow-checking
5 calloc() available
6
7This tries to make sure that everywhere in this source tree, we always have
8an appropriate version of calloc() (i.e. grub_calloc(), xcalloc(), etc.)
9available, and that they all safely check for overflow and return NULL when
10it would occur.
11
12Upstream-Status: Backport [commit 64e26162ebfe68317c143ca5ec996c892019f8f8
13from https://git.savannah.gnu.org/git/grub.git]
14
15Signed-off-by: Peter Jones <pjones@redhat.com>
16Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
18---
19 grub-core/kern/emu/misc.c | 12 ++++++++++++
20 grub-core/kern/emu/mm.c | 10 ++++++++++
21 grub-core/kern/mm.c | 40 ++++++++++++++++++++++++++++++++++++++
22 grub-core/lib/libgcrypt_wrap/mem.c | 11 +++++++++--
23 grub-core/lib/posix_wrap/stdlib.h | 8 +++++++-
24 include/grub/emu/misc.h | 1 +
25 include/grub/mm.h | 6 ++++++
26 7 files changed, 85 insertions(+), 3 deletions(-)
27
28diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c
29index 65db79b..dfd8a8e 100644
30--- a/grub-core/kern/emu/misc.c
31+++ b/grub-core/kern/emu/misc.c
32@@ -85,6 +85,18 @@ grub_util_error (const char *fmt, ...)
33 exit (1);
34 }
35
36+void *
37+xcalloc (grub_size_t nmemb, grub_size_t size)
38+{
39+ void *p;
40+
41+ p = calloc (nmemb, size);
42+ if (!p)
43+ grub_util_error ("%s", _("out of memory"));
44+
45+ return p;
46+}
47+
48 void *
49 xmalloc (grub_size_t size)
50 {
51diff --git a/grub-core/kern/emu/mm.c b/grub-core/kern/emu/mm.c
52index f262e95..145b01d 100644
53--- a/grub-core/kern/emu/mm.c
54+++ b/grub-core/kern/emu/mm.c
55@@ -25,6 +25,16 @@
56 #include <string.h>
57 #include <grub/i18n.h>
58
59+void *
60+grub_calloc (grub_size_t nmemb, grub_size_t size)
61+{
62+ void *ret;
63+ ret = calloc (nmemb, size);
64+ if (!ret)
65+ grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
66+ return ret;
67+}
68+
69 void *
70 grub_malloc (grub_size_t size)
71 {
72diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
73index ee88ff6..f2822a8 100644
74--- a/grub-core/kern/mm.c
75+++ b/grub-core/kern/mm.c
76@@ -67,8 +67,10 @@
77 #include <grub/dl.h>
78 #include <grub/i18n.h>
79 #include <grub/mm_private.h>
80+#include <grub/safemath.h>
81
82 #ifdef MM_DEBUG
83+# undef grub_calloc
84 # undef grub_malloc
85 # undef grub_zalloc
86 # undef grub_realloc
87@@ -375,6 +377,30 @@ grub_memalign (grub_size_t align, grub_size_t size)
88 return 0;
89 }
90
91+/*
92+ * Allocate NMEMB instances of SIZE bytes and return the pointer, or error on
93+ * integer overflow.
94+ */
95+void *
96+grub_calloc (grub_size_t nmemb, grub_size_t size)
97+{
98+ void *ret;
99+ grub_size_t sz = 0;
100+
101+ if (grub_mul (nmemb, size, &sz))
102+ {
103+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
104+ return NULL;
105+ }
106+
107+ ret = grub_memalign (0, sz);
108+ if (!ret)
109+ return NULL;
110+
111+ grub_memset (ret, 0, sz);
112+ return ret;
113+}
114+
115 /* Allocate SIZE bytes and return the pointer. */
116 void *
117 grub_malloc (grub_size_t size)
118@@ -561,6 +587,20 @@ grub_mm_dump (unsigned lineno)
119 grub_printf ("\n");
120 }
121
122+void *
123+grub_debug_calloc (const char *file, int line, grub_size_t nmemb, grub_size_t size)
124+{
125+ void *ptr;
126+
127+ if (grub_mm_debug)
128+ grub_printf ("%s:%d: calloc (0x%" PRIxGRUB_SIZE ", 0x%" PRIxGRUB_SIZE ") = ",
129+ file, line, size);
130+ ptr = grub_calloc (nmemb, size);
131+ if (grub_mm_debug)
132+ grub_printf ("%p\n", ptr);
133+ return ptr;
134+}
135+
136 void *
137 grub_debug_malloc (const char *file, int line, grub_size_t size)
138 {
139diff --git a/grub-core/lib/libgcrypt_wrap/mem.c b/grub-core/lib/libgcrypt_wrap/mem.c
140index beeb661..74c6eaf 100644
141--- a/grub-core/lib/libgcrypt_wrap/mem.c
142+++ b/grub-core/lib/libgcrypt_wrap/mem.c
143@@ -4,6 +4,7 @@
144 #include <grub/crypto.h>
145 #include <grub/dl.h>
146 #include <grub/env.h>
147+#include <grub/safemath.h>
148
149 GRUB_MOD_LICENSE ("GPLv3+");
150
151@@ -36,7 +37,10 @@ void *
152 gcry_xcalloc (size_t n, size_t m)
153 {
154 void *ret;
155- ret = grub_zalloc (n * m);
156+ size_t sz;
157+ if (grub_mul (n, m, &sz))
158+ grub_fatal ("gcry_xcalloc would overflow");
159+ ret = grub_zalloc (sz);
160 if (!ret)
161 grub_fatal ("gcry_xcalloc failed");
162 return ret;
163@@ -56,7 +60,10 @@ void *
164 gcry_xcalloc_secure (size_t n, size_t m)
165 {
166 void *ret;
167- ret = grub_zalloc (n * m);
168+ size_t sz;
169+ if (grub_mul (n, m, &sz))
170+ grub_fatal ("gcry_xcalloc would overflow");
171+ ret = grub_zalloc (sz);
172 if (!ret)
173 grub_fatal ("gcry_xcalloc failed");
174 return ret;
175diff --git a/grub-core/lib/posix_wrap/stdlib.h b/grub-core/lib/posix_wrap/stdlib.h
176index 3b46f47..7a8d385 100644
177--- a/grub-core/lib/posix_wrap/stdlib.h
178+++ b/grub-core/lib/posix_wrap/stdlib.h
179@@ -21,6 +21,7 @@
180
181 #include <grub/mm.h>
182 #include <grub/misc.h>
183+#include <grub/safemath.h>
184
185 static inline void
186 free (void *ptr)
187@@ -37,7 +38,12 @@ malloc (grub_size_t size)
188 static inline void *
189 calloc (grub_size_t size, grub_size_t nelem)
190 {
191- return grub_zalloc (size * nelem);
192+ grub_size_t sz;
193+
194+ if (grub_mul (size, nelem, &sz))
195+ return NULL;
196+
197+ return grub_zalloc (sz);
198 }
199
200 static inline void *
201diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h
202index ce464cf..ff9c48a 100644
203--- a/include/grub/emu/misc.h
204+++ b/include/grub/emu/misc.h
205@@ -47,6 +47,7 @@ grub_util_device_is_mapped (const char *dev);
206 #define GRUB_HOST_PRIuLONG_LONG "llu"
207 #define GRUB_HOST_PRIxLONG_LONG "llx"
208
209+void * EXPORT_FUNC(xcalloc) (grub_size_t nmemb, grub_size_t size) WARN_UNUSED_RESULT;
210 void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
211 void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT;
212 char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;
213diff --git a/include/grub/mm.h b/include/grub/mm.h
214index 28e2e53..9c38dd3 100644
215--- a/include/grub/mm.h
216+++ b/include/grub/mm.h
217@@ -29,6 +29,7 @@
218 #endif
219
220 void grub_mm_init_region (void *addr, grub_size_t size);
221+void *EXPORT_FUNC(grub_calloc) (grub_size_t nmemb, grub_size_t size);
222 void *EXPORT_FUNC(grub_malloc) (grub_size_t size);
223 void *EXPORT_FUNC(grub_zalloc) (grub_size_t size);
224 void EXPORT_FUNC(grub_free) (void *ptr);
225@@ -48,6 +49,9 @@ extern int EXPORT_VAR(grub_mm_debug);
226 void grub_mm_dump_free (void);
227 void grub_mm_dump (unsigned lineno);
228
229+#define grub_calloc(nmemb, size) \
230+ grub_debug_calloc (GRUB_FILE, __LINE__, nmemb, size)
231+
232 #define grub_malloc(size) \
233 grub_debug_malloc (GRUB_FILE, __LINE__, size)
234
235@@ -63,6 +67,8 @@ void grub_mm_dump (unsigned lineno);
236 #define grub_free(ptr) \
237 grub_debug_free (GRUB_FILE, __LINE__, ptr)
238
239+void *EXPORT_FUNC(grub_debug_calloc) (const char *file, int line,
240+ grub_size_t nmemb, grub_size_t size);
241 void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line,
242 grub_size_t size);
243 void *EXPORT_FUNC(grub_debug_zalloc) (const char *file, int line,
244--
2452.14.4
246
diff --git a/meta/recipes-bsp/grub/files/determinism.patch b/meta/recipes-bsp/grub/files/determinism.patch
deleted file mode 100644
index 3c1f562c71..0000000000
--- a/meta/recipes-bsp/grub/files/determinism.patch
+++ /dev/null
@@ -1,56 +0,0 @@
1The output in moddep.lst generated from syminfo.lst using genmoddep.awk is
2not deterministic since the order of the dependencies on each line can vary
3depending on how awk sorts the values in the array.
4
5Be deterministic in the output by sorting the dependencies on each line.
6
7Also, the output of the SOURCES lines in grub-core/Makefile.core.am, generated
8from grub-core/Makefile.core.def with gentpl.py is not deterministic due to
9missing sorting of the list used to generate it. Add such a sort.
10
11Also ensure the generated unidata.c file is deterministic by sorting the
12keys of the dict.
13
14Upstream-Status: Pending
15Richard Purdie <richard.purdie@linuxfoundation.org>
16
17Index: grub-2.04/grub-core/genmoddep.awk
18===================================================================
19--- grub-2.04.orig/grub-core/genmoddep.awk
20+++ grub-2.04/grub-core/genmoddep.awk
21@@ -59,7 +59,9 @@ END {
22 }
23 modlist = ""
24 depcount[mod] = 0
25- for (depmod in uniqmods) {
26+ n = asorti(uniqmods, w)
27+ for (i = 1; i <= n; i++) {
28+ depmod = w[i]
29 modlist = modlist " " depmod;
30 inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod
31 depcount[mod]++
32Index: grub-2.04/gentpl.py
33===================================================================
34--- grub-2.04.orig/gentpl.py
35+++ grub-2.04/gentpl.py
36@@ -568,6 +568,7 @@ def foreach_platform_value(defn, platfor
37 for group in RMAP[platform]:
38 for value in defn.find_all(group + suffix):
39 r.append(closure(value))
40+ r.sort()
41 return ''.join(r)
42
43 def platform_conditional(platform, closure):
44Index: grub-2.04/util/import_unicode.py
45===================================================================
46--- grub-2.04.orig/util/import_unicode.py
47+++ grub-2.04/util/import_unicode.py
48@@ -174,7 +174,7 @@ infile.close ()
49
50 outfile.write ("struct grub_unicode_arabic_shape grub_unicode_arabic_shapes[] = {\n ")
51
52-for x in arabicsubst:
53+for x in sorted(arabicsubst):
54 try:
55 if arabicsubst[x]['join'] == "DUAL":
56 outfile.write ("{0x%x, 0x%x, 0x%x, 0x%x, 0x%x},\n " % (arabicsubst[x][0], arabicsubst[x][1], arabicsubst[x][2], arabicsubst[x][3], arabicsubst[x][4]))
diff --git a/meta/recipes-bsp/grub/files/grub-module-explicitly-keeps-symbole-.module_license.patch b/meta/recipes-bsp/grub/files/grub-module-explicitly-keeps-symbole-.module_license.patch
index 26890261b7..d9012d1dd6 100644
--- a/meta/recipes-bsp/grub/files/grub-module-explicitly-keeps-symbole-.module_license.patch
+++ b/meta/recipes-bsp/grub/files/grub-module-explicitly-keeps-symbole-.module_license.patch
@@ -1,4 +1,4 @@
1From 917133acc701dbc4636165d3b08d15dc5829a06f Mon Sep 17 00:00:00 2001 1From b316ed326bd492106006d78f5bfcd767b49a4f2e Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com> 2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Wed, 17 Aug 2016 04:06:34 -0400 3Date: Wed, 17 Aug 2016 04:06:34 -0400
4Subject: [PATCH] grub module explicitly keeps symbole .module_license 4Subject: [PATCH] grub module explicitly keeps symbole .module_license
@@ -8,7 +8,7 @@ it stripped symbol table:
8 8
9--------------- 9---------------
10root@localhost:~# objdump -t all_video.mod 10root@localhost:~# objdump -t all_video.mod
11 11
12all_video.mod: file format elf64-x86-64 12all_video.mod: file format elf64-x86-64
13 13
14SYMBOL TABLE: 14SYMBOL TABLE:
@@ -40,12 +40,13 @@ SYMBOL TABLE:
40Upstream-Status: Pending 40Upstream-Status: Pending
41 41
42Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> 42Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
43
43--- 44---
44 grub-core/genmod.sh.in | 2 +- 45 grub-core/genmod.sh.in | 2 +-
45 1 file changed, 1 insertion(+), 1 deletion(-) 46 1 file changed, 1 insertion(+), 1 deletion(-)
46 47
47diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in 48diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in
48index 1250589..dd14308 100644 49index e57c4d9..42bb1ba 100644
49--- a/grub-core/genmod.sh.in 50--- a/grub-core/genmod.sh.in
50+++ b/grub-core/genmod.sh.in 51+++ b/grub-core/genmod.sh.in
51@@ -56,7 +56,7 @@ if test x@TARGET_APPLE_LINKER@ != x1; then 52@@ -56,7 +56,7 @@ if test x@TARGET_APPLE_LINKER@ != x1; then
diff --git a/meta/recipes-bsp/grub/files/lvm-Add-LVM-cache-logical-volume-handling.patch b/meta/recipes-bsp/grub/files/lvm-Add-LVM-cache-logical-volume-handling.patch
deleted file mode 100644
index 2b8157f592..0000000000
--- a/meta/recipes-bsp/grub/files/lvm-Add-LVM-cache-logical-volume-handling.patch
+++ /dev/null
@@ -1,287 +0,0 @@
1From 8eb02bcb5897b238b29ff762402bb0c3028f0eab Mon Sep 17 00:00:00 2001
2From: Michael Chang <mchang@suse.com>
3Date: Thu, 19 Mar 2020 13:56:13 +0800
4Subject: [PATCH 3/9] lvm: Add LVM cache logical volume handling
5
6The LVM cache logical volume is the logical volume consisting of the original
7and the cache pool logical volume. The original is usually on a larger and
8slower storage device while the cache pool is on a smaller and faster one. The
9performance of the original volume can be improved by storing the frequently
10used data on the cache pool to utilize the greater performance of faster
11device.
12
13The default cache mode "writethrough" ensures that any data written will be
14stored both in the cache and on the origin LV, therefore grub can be straight
15to read the original lv as no data loss is guarenteed.
16
17The second cache mode is "writeback", which delays writing from the cache pool
18back to the origin LV to have increased performance. The drawback is potential
19data loss if losing the associated cache device.
20
21During the boot time grub reads the LVM offline i.e. LVM volumes are not
22activated and mounted, hence it should be fine to read directly from original
23lv since all cached data should have been flushed back in the process of taking
24it offline.
25
26It is also not much helpful to the situation by adding fsync calls to the
27install code. The fsync did not force to write back dirty cache to the original
28device and rather it would update associated cache metadata to complete the
29write transaction with the cache device. IOW the writes to cached blocks still
30go only to the cache device.
31
32To write back dirty cache, as LVM cache did not support dirty cache flush per
33block range, there'no way to do it for file. On the other hand the "cleaner"
34policy is implemented and can be used to write back "all" dirty blocks in a
35cache, which effectively drain all dirty cache gradually to attain and last in
36the "clean" state, which can be useful for shrinking or decommissioning a
37cache. The result and effect is not what we are looking for here.
38
39In conclusion, as it seems no way to enforce file writes to the original
40device, grub may suffer from power failure as it cannot assemble the cache
41device and read the dirty data from it. However since the case is only
42applicable to writeback mode which is sensitive to data lost in nature, I'd
43still like to propose my (relatively simple) patch and treat reading dirty
44cache as improvement.
45
46Upstream-Status: Backport [commit 0454b0445393aafc5600e92ef0c39494e333b135
47from https://git.savannah.gnu.org/git/grub.git]
48
49Signed-off-by: Michael Chang <mchang@suse.com>
50Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
51Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
52---
53 grub-core/disk/lvm.c | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++
54 1 file changed, 190 insertions(+)
55
56diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c
57index 7b265c7..dc6b83b 100644
58--- a/grub-core/disk/lvm.c
59+++ b/grub-core/disk/lvm.c
60@@ -33,6 +33,14 @@
61
62 GRUB_MOD_LICENSE ("GPLv3+");
63
64+struct cache_lv
65+{
66+ struct grub_diskfilter_lv *lv;
67+ char *cache_pool;
68+ char *origin;
69+ struct cache_lv *next;
70+};
71+
72
73 /* Go the string STR and return the number after STR. *P will point
74 at the number. In case STR is not found, *P will be NULL and the
75@@ -95,6 +103,34 @@ grub_lvm_check_flag (char *p, const char *str, const char *flag)
76 }
77 }
78
79+static void
80+grub_lvm_free_cache_lvs (struct cache_lv *cache_lvs)
81+{
82+ struct cache_lv *cache;
83+
84+ while ((cache = cache_lvs))
85+ {
86+ cache_lvs = cache_lvs->next;
87+
88+ if (cache->lv)
89+ {
90+ unsigned int i;
91+
92+ for (i = 0; i < cache->lv->segment_count; ++i)
93+ if (cache->lv->segments)
94+ grub_free (cache->lv->segments[i].nodes);
95+ grub_free (cache->lv->segments);
96+ grub_free (cache->lv->fullname);
97+ grub_free (cache->lv->idname);
98+ grub_free (cache->lv->name);
99+ }
100+ grub_free (cache->lv);
101+ grub_free (cache->origin);
102+ grub_free (cache->cache_pool);
103+ grub_free (cache);
104+ }
105+}
106+
107 static struct grub_diskfilter_vg *
108 grub_lvm_detect (grub_disk_t disk,
109 struct grub_diskfilter_pv_id *id,
110@@ -242,6 +278,8 @@ grub_lvm_detect (grub_disk_t disk,
111
112 if (! vg)
113 {
114+ struct cache_lv *cache_lvs = NULL;
115+
116 /* First time we see this volume group. We've to create the
117 whole volume group structure. */
118 vg = grub_malloc (sizeof (*vg));
119@@ -671,6 +709,106 @@ grub_lvm_detect (grub_disk_t disk,
120 seg->nodes[seg->node_count - 1].name = tmp;
121 }
122 }
123+ else if (grub_memcmp (p, "cache\"",
124+ sizeof ("cache\"") - 1) == 0)
125+ {
126+ struct cache_lv *cache = NULL;
127+
128+ char *p2, *p3;
129+ grub_size_t sz;
130+
131+ cache = grub_zalloc (sizeof (*cache));
132+ if (!cache)
133+ goto cache_lv_fail;
134+ cache->lv = grub_zalloc (sizeof (*cache->lv));
135+ if (!cache->lv)
136+ goto cache_lv_fail;
137+ grub_memcpy (cache->lv, lv, sizeof (*cache->lv));
138+
139+ if (lv->fullname)
140+ {
141+ cache->lv->fullname = grub_strdup (lv->fullname);
142+ if (!cache->lv->fullname)
143+ goto cache_lv_fail;
144+ }
145+ if (lv->idname)
146+ {
147+ cache->lv->idname = grub_strdup (lv->idname);
148+ if (!cache->lv->idname)
149+ goto cache_lv_fail;
150+ }
151+ if (lv->name)
152+ {
153+ cache->lv->name = grub_strdup (lv->name);
154+ if (!cache->lv->name)
155+ goto cache_lv_fail;
156+ }
157+
158+ skip_lv = 1;
159+
160+ p2 = grub_strstr (p, "cache_pool = \"");
161+ if (!p2)
162+ goto cache_lv_fail;
163+
164+ p2 = grub_strchr (p2, '"');
165+ if (!p2)
166+ goto cache_lv_fail;
167+
168+ p3 = ++p2;
169+ p3 = grub_strchr (p3, '"');
170+ if (!p3)
171+ goto cache_lv_fail;
172+
173+ sz = p3 - p2;
174+
175+ cache->cache_pool = grub_malloc (sz + 1);
176+ if (!cache->cache_pool)
177+ goto cache_lv_fail;
178+ grub_memcpy (cache->cache_pool, p2, sz);
179+ cache->cache_pool[sz] = '\0';
180+
181+ p2 = grub_strstr (p, "origin = \"");
182+ if (!p2)
183+ goto cache_lv_fail;
184+
185+ p2 = grub_strchr (p2, '"');
186+ if (!p2)
187+ goto cache_lv_fail;
188+
189+ p3 = ++p2;
190+ p3 = grub_strchr (p3, '"');
191+ if (!p3)
192+ goto cache_lv_fail;
193+
194+ sz = p3 - p2;
195+
196+ cache->origin = grub_malloc (sz + 1);
197+ if (!cache->origin)
198+ goto cache_lv_fail;
199+ grub_memcpy (cache->origin, p2, sz);
200+ cache->origin[sz] = '\0';
201+
202+ cache->next = cache_lvs;
203+ cache_lvs = cache;
204+ break;
205+
206+ cache_lv_fail:
207+ if (cache)
208+ {
209+ grub_free (cache->origin);
210+ grub_free (cache->cache_pool);
211+ if (cache->lv)
212+ {
213+ grub_free (cache->lv->fullname);
214+ grub_free (cache->lv->idname);
215+ grub_free (cache->lv->name);
216+ }
217+ grub_free (cache->lv);
218+ grub_free (cache);
219+ }
220+ grub_lvm_free_cache_lvs (cache_lvs);
221+ goto fail4;
222+ }
223 else
224 {
225 #ifdef GRUB_UTIL
226@@ -747,6 +885,58 @@ grub_lvm_detect (grub_disk_t disk,
227 }
228
229 }
230+
231+ {
232+ struct cache_lv *cache;
233+
234+ for (cache = cache_lvs; cache; cache = cache->next)
235+ {
236+ struct grub_diskfilter_lv *lv;
237+
238+ for (lv = vg->lvs; lv; lv = lv->next)
239+ if (grub_strcmp (lv->name, cache->origin) == 0)
240+ break;
241+ if (lv)
242+ {
243+ cache->lv->segments = grub_malloc (lv->segment_count * sizeof (*lv->segments));
244+ if (!cache->lv->segments)
245+ {
246+ grub_lvm_free_cache_lvs (cache_lvs);
247+ goto fail4;
248+ }
249+ grub_memcpy (cache->lv->segments, lv->segments, lv->segment_count * sizeof (*lv->segments));
250+
251+ for (i = 0; i < lv->segment_count; ++i)
252+ {
253+ struct grub_diskfilter_node *nodes = lv->segments[i].nodes;
254+ grub_size_t node_count = lv->segments[i].node_count;
255+
256+ cache->lv->segments[i].nodes = grub_malloc (node_count * sizeof (*nodes));
257+ if (!cache->lv->segments[i].nodes)
258+ {
259+ for (j = 0; j < i; ++j)
260+ grub_free (cache->lv->segments[j].nodes);
261+ grub_free (cache->lv->segments);
262+ cache->lv->segments = NULL;
263+ grub_lvm_free_cache_lvs (cache_lvs);
264+ goto fail4;
265+ }
266+ grub_memcpy (cache->lv->segments[i].nodes, nodes, node_count * sizeof (*nodes));
267+ }
268+
269+ if (cache->lv->segments)
270+ {
271+ cache->lv->segment_count = lv->segment_count;
272+ cache->lv->vg = vg;
273+ cache->lv->next = vg->lvs;
274+ vg->lvs = cache->lv;
275+ cache->lv = NULL;
276+ }
277+ }
278+ }
279+ }
280+
281+ grub_lvm_free_cache_lvs (cache_lvs);
282 if (grub_diskfilter_vg_register (vg))
283 goto fail4;
284 }
285--
2862.14.4
287
diff --git a/meta/recipes-bsp/grub/files/safemath-Add-some-arithmetic-primitives-that-check-f.patch b/meta/recipes-bsp/grub/files/safemath-Add-some-arithmetic-primitives-that-check-f.patch
deleted file mode 100644
index 29021e8d8f..0000000000
--- a/meta/recipes-bsp/grub/files/safemath-Add-some-arithmetic-primitives-that-check-f.patch
+++ /dev/null
@@ -1,94 +0,0 @@
1From 06c361a71c4998635493610e5d76d0d223925251 Mon Sep 17 00:00:00 2001
2From: Peter Jones <pjones@redhat.com>
3Date: Mon, 15 Jun 2020 10:58:42 -0400
4Subject: [PATCH 5/9] safemath: Add some arithmetic primitives that check for
5 overflow
6
7This adds a new header, include/grub/safemath.h, that includes easy to
8use wrappers for __builtin_{add,sub,mul}_overflow() declared like:
9
10 bool OP(a, b, res)
11
12where OP is grub_add, grub_sub or grub_mul. OP() returns true in the
13case where the operation would overflow and res is not modified.
14Otherwise, false is returned and the operation is executed.
15
16These arithmetic primitives require newer compiler versions. So, bump
17these requirements in the INSTALL file too.
18
19Upstream-Status: Backport [commit 68708c4503018d61dbcce7ac11cbb511d6425f4d
20from https://git.savannah.gnu.org/git/grub.git]
21
22Signed-off-by: Peter Jones <pjones@redhat.com>
23Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
24[YL: omit the change to INSTALL from original patch]
25Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
26---
27 include/grub/compiler.h | 8 ++++++++
28 include/grub/safemath.h | 37 +++++++++++++++++++++++++++++++++++++
29 2 files changed, 45 insertions(+)
30 create mode 100644 include/grub/safemath.h
31
32diff --git a/include/grub/compiler.h b/include/grub/compiler.h
33index c9e1d7a..8f3be3a 100644
34--- a/include/grub/compiler.h
35+++ b/include/grub/compiler.h
36@@ -48,4 +48,12 @@
37 # define WARN_UNUSED_RESULT
38 #endif
39
40+#if defined(__clang__) && defined(__clang_major__) && defined(__clang_minor__)
41+# define CLANG_PREREQ(maj,min) \
42+ ((__clang_major__ > (maj)) || \
43+ (__clang_major__ == (maj) && __clang_minor__ >= (min)))
44+#else
45+# define CLANG_PREREQ(maj,min) 0
46+#endif
47+
48 #endif /* ! GRUB_COMPILER_HEADER */
49diff --git a/include/grub/safemath.h b/include/grub/safemath.h
50new file mode 100644
51index 0000000..c17b89b
52--- /dev/null
53+++ b/include/grub/safemath.h
54@@ -0,0 +1,37 @@
55+/*
56+ * GRUB -- GRand Unified Bootloader
57+ * Copyright (C) 2020 Free Software Foundation, Inc.
58+ *
59+ * GRUB is free software: you can redistribute it and/or modify
60+ * it under the terms of the GNU General Public License as published by
61+ * the Free Software Foundation, either version 3 of the License, or
62+ * (at your option) any later version.
63+ *
64+ * GRUB is distributed in the hope that it will be useful,
65+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
66+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67+ * GNU General Public License for more details.
68+ *
69+ * You should have received a copy of the GNU General Public License
70+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
71+ *
72+ * Arithmetic operations that protect against overflow.
73+ */
74+
75+#ifndef GRUB_SAFEMATH_H
76+#define GRUB_SAFEMATH_H 1
77+
78+#include <grub/compiler.h>
79+
80+/* These appear in gcc 5.1 and clang 3.8. */
81+#if GNUC_PREREQ(5, 1) || CLANG_PREREQ(3, 8)
82+
83+#define grub_add(a, b, res) __builtin_add_overflow(a, b, res)
84+#define grub_sub(a, b, res) __builtin_sub_overflow(a, b, res)
85+#define grub_mul(a, b, res) __builtin_mul_overflow(a, b, res)
86+
87+#else
88+#error gcc 5.1 or newer or clang 3.8 or newer is required
89+#endif
90+
91+#endif /* GRUB_SAFEMATH_H */
92--
932.14.4
94
diff --git a/meta/recipes-bsp/grub/files/script-Remove-unused-fields-from-grub_script_functio.patch b/meta/recipes-bsp/grub/files/script-Remove-unused-fields-from-grub_script_functio.patch
deleted file mode 100644
index 84a80d5ffd..0000000000
--- a/meta/recipes-bsp/grub/files/script-Remove-unused-fields-from-grub_script_functio.patch
+++ /dev/null
@@ -1,37 +0,0 @@
1From e219bad8cee67b2bb21712df8f055706f8da25d2 Mon Sep 17 00:00:00 2001
2From: Chris Coulson <chris.coulson@canonical.com>
3Date: Fri, 10 Jul 2020 11:21:14 +0100
4Subject: [PATCH 7/9] script: Remove unused fields from grub_script_function
5 struct
6
7Upstream-Status: Backport [commit 1a8d9c9b4ab6df7669b5aa36a56477f297825b96
8from https://git.savannah.gnu.org/git/grub.git]
9
10Signed-off-by: Chris Coulson <chris.coulson@canonical.com>
11Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
12Signed-off-by: Yongxin Liu <yongxin.liu@windriver.com>
13---
14 include/grub/script_sh.h | 5 -----
15 1 file changed, 5 deletions(-)
16
17diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h
18index 360c2be..b382bcf 100644
19--- a/include/grub/script_sh.h
20+++ b/include/grub/script_sh.h
21@@ -359,13 +359,8 @@ struct grub_script_function
22 /* The script function. */
23 struct grub_script *func;
24
25- /* The flags. */
26- unsigned flags;
27-
28 /* The next element. */
29 struct grub_script_function *next;
30-
31- int references;
32 };
33 typedef struct grub_script_function *grub_script_function_t;
34
35--
362.14.4
37
diff --git a/meta/recipes-bsp/grub/grub-bootconf_1.00.bb b/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
index 572580313b..783e30bf38 100644
--- a/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
+++ b/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
@@ -5,7 +5,7 @@ DESCRIPTION = "Grub might require different configuration file for \
5different machines." 5different machines."
6HOMEPAGE = "https://www.gnu.org/software/grub/manual/grub/grub.html#Configuration" 6HOMEPAGE = "https://www.gnu.org/software/grub/manual/grub/grub.html#Configuration"
7 7
8RPROVIDES_${PN} += "virtual/grub-bootconf" 8RPROVIDES:${PN} += "virtual-grub-bootconf"
9 9
10inherit grub-efi-cfg 10inherit grub-efi-cfg
11 11
@@ -29,4 +29,4 @@ do_install() {
29 install grub-bootconf ${D}${EFI_FILES_PATH}/grub.cfg 29 install grub-bootconf ${D}${EFI_FILES_PATH}/grub.cfg
30} 30}
31 31
32FILES_${PN} = "${EFI_FILES_PATH}/grub.cfg" 32FILES:${PN} = "${EFI_FILES_PATH}/grub.cfg"
diff --git a/meta/recipes-bsp/grub/grub-efi_2.04.bb b/meta/recipes-bsp/grub/grub-efi_2.12.bb
index 287845c507..9857e8e036 100644
--- a/meta/recipes-bsp/grub/grub-efi_2.04.bb
+++ b/meta/recipes-bsp/grub/grub-efi_2.12.bb
@@ -4,8 +4,8 @@ require conf/image-uefi.conf
4 4
5GRUBPLATFORM = "efi" 5GRUBPLATFORM = "efi"
6 6
7DEPENDS_append = " grub-native" 7DEPENDS:append = " grub-native"
8RDEPENDS_${PN} = "grub-common virtual/grub-bootconf" 8RDEPENDS:${PN} = "grub-common virtual-grub-bootconf"
9 9
10SRC_URI += " \ 10SRC_URI += " \
11 file://cfg \ 11 file://cfg \
@@ -46,11 +46,21 @@ EXTRA_OECONF += "--enable-efiemu=no"
46 46
47do_mkimage() { 47do_mkimage() {
48 cd ${B} 48 cd ${B}
49
50 GRUB_MKIMAGE_MODULES="${GRUB_BUILDIN}"
51
52 # If 'all' is included in GRUB_BUILDIN we will include all available grub2 modules
53 if [ "${@ bb.utils.contains('GRUB_BUILDIN', 'all', 'True', 'False', d)}" = "True" ]; then
54 bbdebug 1 "Including all available modules"
55 # Get the list of all .mod files in grub-core build directory
56 GRUB_MKIMAGE_MODULES=$(find ${B}/grub-core/ -type f -name "*.mod" -exec basename {} .mod \;)
57 fi
58
49 # Search for the grub.cfg on the local boot media by using the 59 # Search for the grub.cfg on the local boot media by using the
50 # built in cfg file provided via this recipe 60 # built in cfg file provided via this recipe
51 grub-mkimage -c ../cfg -p ${EFIDIR} -d ./grub-core/ \ 61 grub-mkimage -v -c ../cfg -p ${EFIDIR} -d ./grub-core/ \
52 -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \ 62 -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \
53 ${GRUB_BUILDIN} 63 ${GRUB_MKIMAGE_MODULES}
54} 64}
55 65
56addtask mkimage before do_install after do_compile 66addtask mkimage before do_install after do_compile
@@ -70,22 +80,26 @@ do_install() {
70 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE} 80 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE}
71} 81}
72 82
83# To include all available modules, add 'all' to GRUB_BUILDIN
73GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \ 84GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
74 efi_gop iso9660 configfile search loadenv test" 85 efi_gop iso9660 configfile search loadenv test"
75 86
87# 'xen_boot' is a module valid only for aarch64
88GRUB_BUILDIN:append:aarch64 = "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' xen_boot', '', d)}"
89
76do_deploy() { 90do_deploy() {
77 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR} 91 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
78} 92}
79 93
80addtask deploy after do_install before do_build 94addtask deploy after do_install before do_build
81 95
82FILES_${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \ 96FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
83 ${datadir}/grub \ 97 ${datadir}/grub \
84 ${EFI_FILES_PATH}/${GRUB_IMAGE} \ 98 ${EFI_FILES_PATH}/${GRUB_IMAGE} \
85 " 99 "
86 100
87# 64-bit binaries are expected for the bootloader with an x32 userland 101# 64-bit binaries are expected for the bootloader with an x32 userland
88INSANE_SKIP_${PN}_append_linux-gnux32 = " arch" 102INSANE_SKIP:${PN}:append:linux-gnux32 = " arch"
89INSANE_SKIP_${PN}-dbg_append_linux-gnux32 = " arch" 103INSANE_SKIP:${PN}-dbg:append:linux-gnux32 = " arch"
90INSANE_SKIP_${PN}_append_linux-muslx32 = " arch" 104INSANE_SKIP:${PN}:append:linux-muslx32 = " arch"
91INSANE_SKIP_${PN}-dbg_append_linux-muslx32 = " arch" 105INSANE_SKIP:${PN}-dbg:append:linux-muslx32 = " arch"
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
index f870d41f6a..bb9aacb478 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -8,7 +8,7 @@ standard, which allows for flexible loading of multiple boot images."
8HOMEPAGE = "http://www.gnu.org/software/grub/" 8HOMEPAGE = "http://www.gnu.org/software/grub/"
9SECTION = "bootloaders" 9SECTION = "bootloaders"
10 10
11LICENSE = "GPLv3" 11LICENSE = "GPL-3.0-only"
12LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504" 12LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
13 13
14CVE_PRODUCT = "grub2" 14CVE_PRODUCT = "grub2"
@@ -18,38 +18,41 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
18 file://autogen.sh-exclude-pc.patch \ 18 file://autogen.sh-exclude-pc.patch \
19 file://grub-module-explicitly-keeps-symbole-.module_license.patch \ 19 file://grub-module-explicitly-keeps-symbole-.module_license.patch \
20 file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \ 20 file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
21 file://CVE-2020-10713.patch \ 21 file://0001-RISC-V-Restore-the-typcast-to-long.patch \
22 file://calloc-Make-sure-we-always-have-an-overflow-checking.patch \
23 file://lvm-Add-LVM-cache-logical-volume-handling.patch \
24 file://CVE-2020-14308-calloc-Use-calloc-at-most-places.patch \
25 file://safemath-Add-some-arithmetic-primitives-that-check-f.patch \
26 file://CVE-2020-14309-CVE-2020-14310-CVE-2020-14311-malloc-Use-overflow-checking-primitives-where-we-do-.patch \
27 file://script-Remove-unused-fields-from-grub_script_functio.patch \
28 file://CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch \
29 file://CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch \
30 file://6643507ce30f775008e093580f0c9499dfb2c485.patch \
31 file://determinism.patch \
32" 22"
33SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934" 23
34SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea" 24SRC_URI[sha256sum] = "b30919fa5be280417c17ac561bb1650f60cfb80cc6237fa1e2b6f56154cb9c91"
25
26CVE_STATUS[CVE-2019-14865] = "not-applicable-platform: applies only to RHEL"
27CVE_STATUS[CVE-2021-46705] = "not-applicable-platform: Applies only to SUSE"
28CVE_STATUS[CVE-2023-4001] = "not-applicable-platform: Applies only to RHEL/Fedora"
29CVE_STATUS[CVE-2024-1048] = "not-applicable-platform: Applies only to RHEL/Fedora"
30CVE_STATUS[CVE-2023-4692] = "cpe-incorrect: Fixed in version 2.12 already"
31CVE_STATUS[CVE-2023-4693] = "cpe-incorrect: Fixed in version 2.12 already"
35 32
36DEPENDS = "flex-native bison-native gettext-native" 33DEPENDS = "flex-native bison-native gettext-native"
37 34
38COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|riscv.*)-(linux.*|freebsd.*)' 35GRUB_COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|riscv.*)-(linux.*|freebsd.*)'
39COMPATIBLE_HOST_armv7a = 'null' 36COMPATIBLE_HOST = "${GRUB_COMPATIBLE_HOST}"
40COMPATIBLE_HOST_armv7ve = 'null' 37# Grub doesn't support hard float toolchain and won't be able to forcefully
38# disable it on some of the target CPUs. See 'configure.ac' for
39# supported/unsupported CPUs in hardfp.
40COMPATIBLE_HOST:armv7a = "${@'null' if bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', True, False, d) else d.getVar('GRUB_COMPATIBLE_HOST')}"
41COMPATIBLE_HOST:armv7ve = "${@'null' if bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', True, False, d) else d.getVar('GRUB_COMPATIBLE_HOST')}"
41 42
42# configure.ac has code to set this automagically from the target tuple 43# configure.ac has code to set this automagically from the target tuple
43# but the OE freeform one (core2-foo-bar-linux) don't work with that. 44# but the OE freeform one (core2-foo-bar-linux) don't work with that.
44 45
45GRUBPLATFORM_arm = "efi" 46GRUBPLATFORM:arm = "efi"
46GRUBPLATFORM_aarch64 = "efi" 47GRUBPLATFORM:aarch64 = "efi"
47GRUBPLATFORM_riscv32 = "efi" 48GRUBPLATFORM:riscv32 = "efi"
48GRUBPLATFORM_riscv64 = "efi" 49GRUBPLATFORM:riscv64 = "efi"
49GRUBPLATFORM ??= "pc" 50GRUBPLATFORM ??= "pc"
50 51
51inherit autotools gettext texinfo pkgconfig 52inherit autotools gettext texinfo pkgconfig
52 53
54CFLAGS:remove = "-O2"
55
53EXTRA_OECONF = "--with-platform=${GRUBPLATFORM} \ 56EXTRA_OECONF = "--with-platform=${GRUBPLATFORM} \
54 --disable-grub-mkfont \ 57 --disable-grub-mkfont \
55 --program-prefix="" \ 58 --program-prefix="" \
@@ -74,8 +77,13 @@ BUILD_LDFLAGS = ""
74 77
75export PYTHON = "python3" 78export PYTHON = "python3"
76 79
77do_configure_prepend() { 80do_configure:prepend() {
78 cd ${S} 81 cd ${S}
82
83 # Remove in next version.
84 # See: https://git.savannah.gnu.org/cgit/grub.git/commit/?id=b835601c7639ed1890f2d3db91900a8506011a8e
85 echo "depends bli part_gpt" > ${S}/grub-core/extra_deps.lst
86
79 FROM_BOOTSTRAP=1 ${S}/autogen.sh 87 FROM_BOOTSTRAP=1 ${S}/autogen.sh
80 cd ${B} 88 cd ${B}
81} 89}
diff --git a/meta/recipes-bsp/grub/grub_2.04.bb b/meta/recipes-bsp/grub/grub_2.12.bb
index d4e09faa40..05d462785c 100644
--- a/meta/recipes-bsp/grub/grub_2.04.bb
+++ b/meta/recipes-bsp/grub/grub_2.12.bb
@@ -1,24 +1,24 @@
1require grub2.inc 1require grub2.inc
2 2
3RDEPENDS_${PN}-common += "${PN}-editenv" 3RDEPENDS:${PN}-common += "${PN}-editenv"
4RDEPENDS_${PN} += "${PN}-common" 4RDEPENDS:${PN} += "${PN}-common"
5RDEPENDS_${PN}_class-native = "" 5RDEPENDS:${PN}:class-native = ""
6 6
7RPROVIDES_${PN}-editenv += "${PN}-efi-editenv" 7RPROVIDES:${PN}-editenv += "${PN}-efi-editenv"
8 8
9PROVIDES_append_class-native = " grub-efi-native" 9PROVIDES:append:class-native = " grub-efi-native"
10 10
11PACKAGES =+ "${PN}-editenv ${PN}-common" 11PACKAGES =+ "${PN}-editenv ${PN}-common"
12FILES_${PN}-editenv = "${bindir}/grub-editenv" 12FILES:${PN}-editenv = "${bindir}/grub-editenv"
13FILES_${PN}-common = " \ 13FILES:${PN}-common = " \
14 ${bindir} \ 14 ${bindir} \
15 ${sysconfdir} \ 15 ${sysconfdir} \
16 ${sbindir} \ 16 ${sbindir} \
17 ${datadir}/grub \ 17 ${datadir}/grub \
18" 18"
19ALLOW_EMPTY_${PN} = "1" 19ALLOW_EMPTY:${PN} = "1"
20 20
21do_install_append () { 21do_install:append () {
22 # Avoid conflicts with the EFI package for systems such as arm64 where we 22 # Avoid conflicts with the EFI package for systems such as arm64 where we
23 # need to build grub and grub-efi but only EFI is supported by removing EFI 23 # need to build grub and grub-efi but only EFI is supported by removing EFI
24 # from this package. 24 # from this package.
@@ -35,7 +35,7 @@ do_install_append () {
35 {} + 35 {} +
36} 36}
37 37
38INSANE_SKIP_${PN} = "arch" 38INSANE_SKIP:${PN} = "arch"
39INSANE_SKIP_${PN}-dbg = "arch" 39INSANE_SKIP:${PN}-dbg = "arch"
40 40
41BBCLASSEXTEND = "native nativesdk" 41BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-bsp/keymaps/files/GPLv2.patch b/meta/recipes-bsp/keymaps/files/GPLv2.patch
deleted file mode 100644
index 1ee8181f12..0000000000
--- a/meta/recipes-bsp/keymaps/files/GPLv2.patch
+++ /dev/null
@@ -1,347 +0,0 @@
1Upstream-Status: Inappropriate [licensing]
2
3diff --git a/COPYING b/COPYING
4new file mode 100644
5index 0000000..d511905
6--- /dev/null
7+++ b/COPYING
8@@ -0,0 +1,339 @@
9+ GNU GENERAL PUBLIC LICENSE
10+ Version 2, June 1991
11+
12+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
13+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
14+ Everyone is permitted to copy and distribute verbatim copies
15+ of this license document, but changing it is not allowed.
16+
17+ Preamble
18+
19+ The licenses for most software are designed to take away your
20+freedom to share and change it. By contrast, the GNU General Public
21+License is intended to guarantee your freedom to share and change free
22+software--to make sure the software is free for all its users. This
23+General Public License applies to most of the Free Software
24+Foundation's software and to any other program whose authors commit to
25+using it. (Some other Free Software Foundation software is covered by
26+the GNU Lesser General Public License instead.) You can apply it to
27+your programs, too.
28+
29+ When we speak of free software, we are referring to freedom, not
30+price. Our General Public Licenses are designed to make sure that you
31+have the freedom to distribute copies of free software (and charge for
32+this service if you wish), that you receive source code or can get it
33+if you want it, that you can change the software or use pieces of it
34+in new free programs; and that you know you can do these things.
35+
36+ To protect your rights, we need to make restrictions that forbid
37+anyone to deny you these rights or to ask you to surrender the rights.
38+These restrictions translate to certain responsibilities for you if you
39+distribute copies of the software, or if you modify it.
40+
41+ For example, if you distribute copies of such a program, whether
42+gratis or for a fee, you must give the recipients all the rights that
43+you have. You must make sure that they, too, receive or can get the
44+source code. And you must show them these terms so they know their
45+rights.
46+
47+ We protect your rights with two steps: (1) copyright the software, and
48+(2) offer you this license which gives you legal permission to copy,
49+distribute and/or modify the software.
50+
51+ Also, for each author's protection and ours, we want to make certain
52+that everyone understands that there is no warranty for this free
53+software. If the software is modified by someone else and passed on, we
54+want its recipients to know that what they have is not the original, so
55+that any problems introduced by others will not reflect on the original
56+authors' reputations.
57+
58+ Finally, any free program is threatened constantly by software
59+patents. We wish to avoid the danger that redistributors of a free
60+program will individually obtain patent licenses, in effect making the
61+program proprietary. To prevent this, we have made it clear that any
62+patent must be licensed for everyone's free use or not licensed at all.
63+
64+ The precise terms and conditions for copying, distribution and
65+modification follow.
66+
67+ GNU GENERAL PUBLIC LICENSE
68+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
69+
70+ 0. This License applies to any program or other work which contains
71+a notice placed by the copyright holder saying it may be distributed
72+under the terms of this General Public License. The "Program", below,
73+refers to any such program or work, and a "work based on the Program"
74+means either the Program or any derivative work under copyright law:
75+that is to say, a work containing the Program or a portion of it,
76+either verbatim or with modifications and/or translated into another
77+language. (Hereinafter, translation is included without limitation in
78+the term "modification".) Each licensee is addressed as "you".
79+
80+Activities other than copying, distribution and modification are not
81+covered by this License; they are outside its scope. The act of
82+running the Program is not restricted, and the output from the Program
83+is covered only if its contents constitute a work based on the
84+Program (independent of having been made by running the Program).
85+Whether that is true depends on what the Program does.
86+
87+ 1. You may copy and distribute verbatim copies of the Program's
88+source code as you receive it, in any medium, provided that you
89+conspicuously and appropriately publish on each copy an appropriate
90+copyright notice and disclaimer of warranty; keep intact all the
91+notices that refer to this License and to the absence of any warranty;
92+and give any other recipients of the Program a copy of this License
93+along with the Program.
94+
95+You may charge a fee for the physical act of transferring a copy, and
96+you may at your option offer warranty protection in exchange for a fee.
97+
98+ 2. You may modify your copy or copies of the Program or any portion
99+of it, thus forming a work based on the Program, and copy and
100+distribute such modifications or work under the terms of Section 1
101+above, provided that you also meet all of these conditions:
102+
103+ a) You must cause the modified files to carry prominent notices
104+ stating that you changed the files and the date of any change.
105+
106+ b) You must cause any work that you distribute or publish, that in
107+ whole or in part contains or is derived from the Program or any
108+ part thereof, to be licensed as a whole at no charge to all third
109+ parties under the terms of this License.
110+
111+ c) If the modified program normally reads commands interactively
112+ when run, you must cause it, when started running for such
113+ interactive use in the most ordinary way, to print or display an
114+ announcement including an appropriate copyright notice and a
115+ notice that there is no warranty (or else, saying that you provide
116+ a warranty) and that users may redistribute the program under
117+ these conditions, and telling the user how to view a copy of this
118+ License. (Exception: if the Program itself is interactive but
119+ does not normally print such an announcement, your work based on
120+ the Program is not required to print an announcement.)
121+
122+These requirements apply to the modified work as a whole. If
123+identifiable sections of that work are not derived from the Program,
124+and can be reasonably considered independent and separate works in
125+themselves, then this License, and its terms, do not apply to those
126+sections when you distribute them as separate works. But when you
127+distribute the same sections as part of a whole which is a work based
128+on the Program, the distribution of the whole must be on the terms of
129+this License, whose permissions for other licensees extend to the
130+entire whole, and thus to each and every part regardless of who wrote it.
131+
132+Thus, it is not the intent of this section to claim rights or contest
133+your rights to work written entirely by you; rather, the intent is to
134+exercise the right to control the distribution of derivative or
135+collective works based on the Program.
136+
137+In addition, mere aggregation of another work not based on the Program
138+with the Program (or with a work based on the Program) on a volume of
139+a storage or distribution medium does not bring the other work under
140+the scope of this License.
141+
142+ 3. You may copy and distribute the Program (or a work based on it,
143+under Section 2) in object code or executable form under the terms of
144+Sections 1 and 2 above provided that you also do one of the following:
145+
146+ a) Accompany it with the complete corresponding machine-readable
147+ source code, which must be distributed under the terms of Sections
148+ 1 and 2 above on a medium customarily used for software interchange; or,
149+
150+ b) Accompany it with a written offer, valid for at least three
151+ years, to give any third party, for a charge no more than your
152+ cost of physically performing source distribution, a complete
153+ machine-readable copy of the corresponding source code, to be
154+ distributed under the terms of Sections 1 and 2 above on a medium
155+ customarily used for software interchange; or,
156+
157+ c) Accompany it with the information you received as to the offer
158+ to distribute corresponding source code. (This alternative is
159+ allowed only for noncommercial distribution and only if you
160+ received the program in object code or executable form with such
161+ an offer, in accord with Subsection b above.)
162+
163+The source code for a work means the preferred form of the work for
164+making modifications to it. For an executable work, complete source
165+code means all the source code for all modules it contains, plus any
166+associated interface definition files, plus the scripts used to
167+control compilation and installation of the executable. However, as a
168+special exception, the source code distributed need not include
169+anything that is normally distributed (in either source or binary
170+form) with the major components (compiler, kernel, and so on) of the
171+operating system on which the executable runs, unless that component
172+itself accompanies the executable.
173+
174+If distribution of executable or object code is made by offering
175+access to copy from a designated place, then offering equivalent
176+access to copy the source code from the same place counts as
177+distribution of the source code, even though third parties are not
178+compelled to copy the source along with the object code.
179+
180+ 4. You may not copy, modify, sublicense, or distribute the Program
181+except as expressly provided under this License. Any attempt
182+otherwise to copy, modify, sublicense or distribute the Program is
183+void, and will automatically terminate your rights under this License.
184+However, parties who have received copies, or rights, from you under
185+this License will not have their licenses terminated so long as such
186+parties remain in full compliance.
187+
188+ 5. You are not required to accept this License, since you have not
189+signed it. However, nothing else grants you permission to modify or
190+distribute the Program or its derivative works. These actions are
191+prohibited by law if you do not accept this License. Therefore, by
192+modifying or distributing the Program (or any work based on the
193+Program), you indicate your acceptance of this License to do so, and
194+all its terms and conditions for copying, distributing or modifying
195+the Program or works based on it.
196+
197+ 6. Each time you redistribute the Program (or any work based on the
198+Program), the recipient automatically receives a license from the
199+original licensor to copy, distribute or modify the Program subject to
200+these terms and conditions. You may not impose any further
201+restrictions on the recipients' exercise of the rights granted herein.
202+You are not responsible for enforcing compliance by third parties to
203+this License.
204+
205+ 7. If, as a consequence of a court judgment or allegation of patent
206+infringement or for any other reason (not limited to patent issues),
207+conditions are imposed on you (whether by court order, agreement or
208+otherwise) that contradict the conditions of this License, they do not
209+excuse you from the conditions of this License. If you cannot
210+distribute so as to satisfy simultaneously your obligations under this
211+License and any other pertinent obligations, then as a consequence you
212+may not distribute the Program at all. For example, if a patent
213+license would not permit royalty-free redistribution of the Program by
214+all those who receive copies directly or indirectly through you, then
215+the only way you could satisfy both it and this License would be to
216+refrain entirely from distribution of the Program.
217+
218+If any portion of this section is held invalid or unenforceable under
219+any particular circumstance, the balance of the section is intended to
220+apply and the section as a whole is intended to apply in other
221+circumstances.
222+
223+It is not the purpose of this section to induce you to infringe any
224+patents or other property right claims or to contest validity of any
225+such claims; this section has the sole purpose of protecting the
226+integrity of the free software distribution system, which is
227+implemented by public license practices. Many people have made
228+generous contributions to the wide range of software distributed
229+through that system in reliance on consistent application of that
230+system; it is up to the author/donor to decide if he or she is willing
231+to distribute software through any other system and a licensee cannot
232+impose that choice.
233+
234+This section is intended to make thoroughly clear what is believed to
235+be a consequence of the rest of this License.
236+
237+ 8. If the distribution and/or use of the Program is restricted in
238+certain countries either by patents or by copyrighted interfaces, the
239+original copyright holder who places the Program under this License
240+may add an explicit geographical distribution limitation excluding
241+those countries, so that distribution is permitted only in or among
242+countries not thus excluded. In such case, this License incorporates
243+the limitation as if written in the body of this License.
244+
245+ 9. The Free Software Foundation may publish revised and/or new versions
246+of the General Public License from time to time. Such new versions will
247+be similar in spirit to the present version, but may differ in detail to
248+address new problems or concerns.
249+
250+Each version is given a distinguishing version number. If the Program
251+specifies a version number of this License which applies to it and "any
252+later version", you have the option of following the terms and conditions
253+either of that version or of any later version published by the Free
254+Software Foundation. If the Program does not specify a version number of
255+this License, you may choose any version ever published by the Free Software
256+Foundation.
257+
258+ 10. If you wish to incorporate parts of the Program into other free
259+programs whose distribution conditions are different, write to the author
260+to ask for permission. For software which is copyrighted by the Free
261+Software Foundation, write to the Free Software Foundation; we sometimes
262+make exceptions for this. Our decision will be guided by the two goals
263+of preserving the free status of all derivatives of our free software and
264+of promoting the sharing and reuse of software generally.
265+
266+ NO WARRANTY
267+
268+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
269+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
270+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
271+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
272+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
273+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
274+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
275+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
276+REPAIR OR CORRECTION.
277+
278+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
279+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
280+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
281+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
282+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
283+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
284+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
285+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
286+POSSIBILITY OF SUCH DAMAGES.
287+
288+ END OF TERMS AND CONDITIONS
289+
290+ How to Apply These Terms to Your New Programs
291+
292+ If you develop a new program, and you want it to be of the greatest
293+possible use to the public, the best way to achieve this is to make it
294+free software which everyone can redistribute and change under these terms.
295+
296+ To do so, attach the following notices to the program. It is safest
297+to attach them to the start of each source file to most effectively
298+convey the exclusion of warranty; and each file should have at least
299+the "copyright" line and a pointer to where the full notice is found.
300+
301+ <one line to give the program's name and a brief idea of what it does.>
302+ Copyright (C) <year> <name of author>
303+
304+ This program is free software; you can redistribute it and/or modify
305+ it under the terms of the GNU General Public License as published by
306+ the Free Software Foundation; either version 2 of the License, or
307+ (at your option) any later version.
308+
309+ This program is distributed in the hope that it will be useful,
310+ but WITHOUT ANY WARRANTY; without even the implied warranty of
311+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
312+ GNU General Public License for more details.
313+
314+ You should have received a copy of the GNU General Public License along
315+ with this program; if not, write to the Free Software Foundation, Inc.,
316+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
317+
318+Also add information on how to contact you by electronic and paper mail.
319+
320+If the program is interactive, make it output a short notice like this
321+when it starts in an interactive mode:
322+
323+ Gnomovision version 69, Copyright (C) year name of author
324+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
325+ This is free software, and you are welcome to redistribute it
326+ under certain conditions; type `show c' for details.
327+
328+The hypothetical commands `show w' and `show c' should show the appropriate
329+parts of the General Public License. Of course, the commands you use may
330+be called something other than `show w' and `show c'; they could even be
331+mouse-clicks or menu items--whatever suits your program.
332+
333+You should also get your employer (if you work as a programmer) or your
334+school, if any, to sign a "copyright disclaimer" for the program, if
335+necessary. Here is a sample; alter the names:
336+
337+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
338+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
339+
340+ <signature of Ty Coon>, 1 April 1989
341+ Ty Coon, President of Vice
342+
343+This General Public License does not permit incorporating your program into
344+proprietary programs. If your program is a subroutine library, you may
345+consider it more useful to permit linking proprietary applications with the
346+library. If this is what you want to do, use the GNU Lesser General
347+Public License instead of this License.
diff --git a/meta/recipes-bsp/keymaps/files/keymap.sh b/meta/recipes-bsp/keymaps/files/keymap.sh
index 6ebc634266..26bda60408 100755
--- a/meta/recipes-bsp/keymaps/files/keymap.sh
+++ b/meta/recipes-bsp/keymaps/files/keymap.sh
@@ -1,6 +1,9 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# load keymap, if existing 3# load keymap, if existing
4#
5# SPDX-License-Identifier: GPL-2.0-only
6#
4 7
5KERNEL_MAJMIN=`uname -r | cut -d '.' -f 1,2` 8KERNEL_MAJMIN=`uname -r | cut -d '.' -f 1,2`
6if [ -e /etc/keymap-$KERNEL_MAJMIN.map ]; then 9if [ -e /etc/keymap-$KERNEL_MAJMIN.map ]; then
diff --git a/meta/recipes-bsp/keymaps/keymaps_1.0.bb b/meta/recipes-bsp/keymaps/keymaps_1.0.bb
index 24b13f920f..3d5d127820 100644
--- a/meta/recipes-bsp/keymaps/keymaps_1.0.bb
+++ b/meta/recipes-bsp/keymaps/keymaps_1.0.bb
@@ -2,12 +2,11 @@ SUMMARY = "Keyboard maps"
2DESCRIPTION = "Keymaps and initscript to set the keymap on bootup." 2DESCRIPTION = "Keymaps and initscript to set the keymap on bootup."
3SECTION = "base" 3SECTION = "base"
4 4
5RDEPENDS_${PN} = "kbd" 5RDEPENDS:${PN} = "kbd"
6 6
7LICENSE = "GPLv2" 7LICENSE = "GPL-2.0-only"
8LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" 8LIC_FILES_CHKSUM = "file://keymap.sh;beginline=5;endline=5;md5=829e563511c9a1d6d41f17a7a4989d6a"
9PACKAGE_ARCH = "${MACHINE_ARCH}" 9PACKAGE_ARCH = "${MACHINE_ARCH}"
10PR = "r31"
11 10
12INHIBIT_DEFAULT_DEPS = "1" 11INHIBIT_DEFAULT_DEPS = "1"
13 12
@@ -20,8 +19,7 @@ python __anonymous() {
20 19
21inherit update-rc.d 20inherit update-rc.d
22 21
23SRC_URI = "file://keymap.sh \ 22SRC_URI = "file://keymap.sh"
24 file://GPLv2.patch"
25 23
26INITSCRIPT_NAME = "keymap.sh" 24INITSCRIPT_NAME = "keymap.sh"
27INITSCRIPT_PARAMS = "start 01 S ." 25INITSCRIPT_PARAMS = "start 01 S ."
@@ -37,8 +35,8 @@ do_install () {
37 fi 35 fi
38} 36}
39 37
40PACKAGE_WRITE_DEPS_append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','systemd-systemctl-native','',d)}" 38PACKAGE_WRITE_DEPS:append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','systemd-systemctl-native','',d)}"
41pkg_postinst_${PN} () { 39pkg_postinst:${PN} () {
42 if ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','true','false',d)}; then 40 if ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','true','false',d)}; then
43 if [ -n "$D" ]; then 41 if [ -n "$D" ]; then
44 OPTS="--root=$D" 42 OPTS="--root=$D"
@@ -47,4 +45,4 @@ pkg_postinst_${PN} () {
47 fi 45 fi
48} 46}
49 47
50ALLOW_EMPTY_${PN} = "1" 48ALLOW_EMPTY:${PN} = "1"
diff --git a/meta/recipes-bsp/libacpi/libacpi_0.2.bb b/meta/recipes-bsp/libacpi/libacpi_0.2.bb
index fa9e3d4894..6aae34b310 100644
--- a/meta/recipes-bsp/libacpi/libacpi_0.2.bb
+++ b/meta/recipes-bsp/libacpi/libacpi_0.2.bb
@@ -5,7 +5,6 @@ SECTION = "base"
5HOMEPAGE = "http://www.ngolde.de/libacpi.html" 5HOMEPAGE = "http://www.ngolde.de/libacpi.html"
6LICENSE = "MIT" 6LICENSE = "MIT"
7LIC_FILES_CHKSUM = "file://LICENSE;md5=fec17f82f16630adf2dfb7d2a46f21c5" 7LIC_FILES_CHKSUM = "file://LICENSE;md5=fec17f82f16630adf2dfb7d2a46f21c5"
8PR = "r6"
9 8
10SRC_URI = "http://www.ngolde.de/download/libacpi-${PV}.tar.gz \ 9SRC_URI = "http://www.ngolde.de/download/libacpi-${PV}.tar.gz \
11 file://makefile-fix.patch \ 10 file://makefile-fix.patch \
@@ -22,7 +21,7 @@ UPSTREAM_CHECK_URI = "http://www.ngolde.de/libacpi.html"
22 21
23inherit lib_package 22inherit lib_package
24 23
25COMPATIBLE_HOST = '(x86_64|i.86).*-(linux|freebsd.*)' 24COMPATIBLE_HOST = '(x86_64|i.86|aarch64).*-(linux|freebsd.*)'
26 25
27CFLAGS += "-fPIC" 26CFLAGS += "-fPIC"
28EXTRA_OEMAKE = '-e MAKEFLAGS= STRIP="echo"' 27EXTRA_OEMAKE = '-e MAKEFLAGS= STRIP="echo"'
diff --git a/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-cross-compilation-using-autoconf-detected-AR.patch b/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-cross-compilation-using-autoconf-detected-AR.patch
index 47c7ec4170..c8f0e2c4fe 100644
--- a/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-cross-compilation-using-autoconf-detected-AR.patch
+++ b/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-cross-compilation-using-autoconf-detected-AR.patch
@@ -6,7 +6,7 @@ Subject: [PATCH] Fix cross compilation using autoconf detected AR
6currently its using 'ar' program from build host, which is not expected, 6currently its using 'ar' program from build host, which is not expected,
7we need to respect AR passed in environment 7we need to respect AR passed in environment
8 8
9Upstream-Status: Pending 9Upstream-Status: Inappropriate [upstream hasn't been active since 1998]
10 10
11Signed-off-by: Khem Raj <raj.khem@gmail.com> 11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12--- 12---
diff --git a/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/autotools-update.patch b/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/autotools-update.patch
index 33af38b4a8..ebd4a88081 100644
--- a/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/autotools-update.patch
+++ b/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/autotools-update.patch
@@ -1,6 +1,6 @@
1Update autotools infrastructure (including gettext) to modern versions. 1Update autotools infrastructure (including gettext) to modern versions.
2 2
3Upstream-Status: Pending 3Upstream-Status: Inappropriate [upstream hasn't been active since 1998]
4Signed-off-by: Phil Blundell <pb@pbcl.net> 4Signed-off-by: Phil Blundell <pb@pbcl.net>
5 5
6diff -uprN clean/lrzsz-0.12.20/configure.in lrzsz-0.12.20/configure.in 6diff -uprN clean/lrzsz-0.12.20/configure.in lrzsz-0.12.20/configure.in
diff --git a/meta/recipes-bsp/lrzsz/lrzsz_0.12.20.bb b/meta/recipes-bsp/lrzsz/lrzsz_0.12.20.bb
index 54c431eeb3..63edcbd864 100644
--- a/meta/recipes-bsp/lrzsz/lrzsz_0.12.20.bb
+++ b/meta/recipes-bsp/lrzsz/lrzsz_0.12.20.bb
@@ -5,12 +5,11 @@ These programs use error correcting protocols ({z,x,y}modem) to send (sz, sx, sb
5receive (rz, rx, rb) files over a dial-in serial port from a variety of programs \ 5receive (rz, rx, rb) files over a dial-in serial port from a variety of programs \
6running under various operating systems. " 6running under various operating systems. "
7HOMEPAGE = "http://www.ohse.de/uwe/software/lrzsz.html" 7HOMEPAGE = "http://www.ohse.de/uwe/software/lrzsz.html"
8LICENSE = "GPLv2+" 8LICENSE = "GPL-2.0-or-later"
9LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \ 9LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
10 file://src/lrz.c;beginline=1;endline=10;md5=5276956373ff7d8758837f6399a1045f" 10 file://src/lrz.c;beginline=1;endline=10;md5=5276956373ff7d8758837f6399a1045f"
11SECTION = "console/network" 11SECTION = "console/network"
12DEPENDS = "" 12DEPENDS = ""
13PR = "r6"
14 13
15SRC_URI = "http://www.ohse.de/uwe/releases/lrzsz-${PV}.tar.gz \ 14SRC_URI = "http://www.ohse.de/uwe/releases/lrzsz-${PV}.tar.gz \
16 file://autotools-update.patch \ 15 file://autotools-update.patch \
@@ -38,7 +37,7 @@ inherit update-alternatives
38 37
39ALTERNATIVE_PRIORITY = "100" 38ALTERNATIVE_PRIORITY = "100"
40 39
41ALTERNATIVE_${PN} = "rz rx rb sz sx sb" 40ALTERNATIVE:${PN} = "rz rx rb sz sx sb"
42 41
43ALTERNATIVE_TARGET[rz] = "${bindir}/lrz" 42ALTERNATIVE_TARGET[rz] = "${bindir}/lrz"
44ALTERNATIVE_TARGET[rx] = "${bindir}/lrz" 43ALTERNATIVE_TARGET[rx] = "${bindir}/lrz"
diff --git a/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch b/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch
deleted file mode 100644
index d2a8048e87..0000000000
--- a/meta/recipes-bsp/opensbi/files/0001-Makefile-Don-t-specify-mabi-or-march.patch
+++ /dev/null
@@ -1,36 +0,0 @@
1From fe9860fd85e49a75bef545e5d9914070491e8002 Mon Sep 17 00:00:00 2001
2From: Alistair Francis <alistair.francis@wdc.com>
3Date: Fri, 15 Feb 2019 14:57:41 -0800
4Subject: [PATCH] Makefile: Don't specify mabi or march
5
6To avoid
7 can't link double-float modules with soft-float modules
8errors when building 32-bit openSBI don't specify mabi or march.
9
10Upstream-Status: Inappropriate [Fixes a 32-bit OE flow bug]
11Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
12
13---
14 Makefile | 2 --
15 1 file changed, 2 deletions(-)
16
17diff --git a/Makefile b/Makefile
18index ccf8ea3..69e5b38 100644
19--- a/Makefile
20+++ b/Makefile
21@@ -169,7 +169,6 @@ GENFLAGS += $(firmware-genflags-y)
22 CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-strict-aliasing -O2
23 CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
24 CFLAGS += -mno-save-restore -mstrict-align
25-CFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
26 CFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
27 CFLAGS += $(GENFLAGS)
28 CFLAGS += $(platform-cflags-y)
29@@ -183,7 +182,6 @@ CPPFLAGS += $(firmware-cppflags-y)
30 ASFLAGS = -g -Wall -nostdlib -D__ASSEMBLY__
31 ASFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
32 ASFLAGS += -mno-save-restore -mstrict-align
33-ASFLAGS += -mabi=$(PLATFORM_RISCV_ABI) -march=$(PLATFORM_RISCV_ISA)
34 ASFLAGS += -mcmodel=$(PLATFORM_RISCV_CODE_MODEL)
35 ASFLAGS += $(GENFLAGS)
36 ASFLAGS += $(platform-asflags-y)
diff --git a/meta/recipes-bsp/opensbi/opensbi-payloads.inc b/meta/recipes-bsp/opensbi/opensbi-payloads.inc
index 2e32943245..a55679632e 100644
--- a/meta/recipes-bsp/opensbi/opensbi-payloads.inc
+++ b/meta/recipes-bsp/opensbi/opensbi-payloads.inc
@@ -1,21 +1,38 @@
1def riscv_get_extra_oemake_image(d): 1def riscv_get_extra_oemake_image(d):
2 sbi_payload = d.getVar('RISCV_SBI_PAYLOAD') 2 sbi_payload = d.getVar('RISCV_SBI_PAYLOAD')
3 deploy_dir = d.getVar('DEPLOY_DIR_IMAGE')
4
5 if sbi_payload is None: 3 if sbi_payload is None:
6 return "" 4 return ""
7 5
6 deploy_dir = d.getVar('DEPLOY_DIR_IMAGE')
7
8 return "FW_PAYLOAD_PATH=" + deploy_dir + "/" + sbi_payload 8 return "FW_PAYLOAD_PATH=" + deploy_dir + "/" + sbi_payload
9 9
10def riscv_get_do_compile_depends(d): 10def riscv_get_extra_oemake_fdt(d):
11 sbi_payload = d.getVar('RISCV_SBI_PAYLOAD') 11 if d.getVar('RISCV_SBI_PAYLOAD') is None:
12 return ""
13 sbi_fdt = d.getVar('RISCV_SBI_FDT')
14 deploy_dir = d.getVar('DEPLOY_DIR_IMAGE')
12 15
13 if sbi_payload is None: 16 if sbi_fdt is None:
17 return ""
18
19 return "FW_FDT_PATH=" + deploy_dir + "/" + sbi_fdt
20
21def riscv_get_do_compile_depends(d):
22 sbi_payload = d.getVar('RISCV_SBI_PAYLOAD') or ""
23 if sbi_payload == "":
14 return "" 24 return ""
15 25
26 sbi_fdt = d.getVar('RISCV_SBI_FDT') or ""
27
28 if sbi_fdt != "" and 'u-boot.bin' in sbi_payload:
29 return "virtual/kernel:do_deploy virtual/bootloader:do_deploy"
30
16 if 'linux' in sbi_payload or 'Image' in sbi_payload: 31 if 'linux' in sbi_payload or 'Image' in sbi_payload:
17 return "virtual/kernel:do_deploy" 32 return "virtual/kernel:do_deploy"
18 if 'u-boot.bin' in sbi_payload: 33 if 'u-boot.bin' in sbi_payload:
19 return "virtual/bootloader:do_deploy" 34 return "virtual/bootloader:do_deploy"
35 if sbi_fdt != "":
36 return "virtual/kernel:do_deploy"
20 37
21 return "" 38 return ""
diff --git a/meta/recipes-bsp/opensbi/opensbi_0.9.bb b/meta/recipes-bsp/opensbi/opensbi_1.4.bb
index cb1c3f2ebf..cf37a41176 100644
--- a/meta/recipes-bsp/opensbi/opensbi_0.9.bb
+++ b/meta/recipes-bsp/opensbi/opensbi_1.4.bb
@@ -8,21 +8,22 @@ require opensbi-payloads.inc
8 8
9inherit autotools-brokensep deploy 9inherit autotools-brokensep deploy
10 10
11SRCREV = "234ed8e427f4d92903123199f6590d144e0d9351" 11SRCREV = "a2b255b88918715173942f2c5e1f97ac9e90c877"
12SRC_URI = "git://github.com/riscv/opensbi.git;branch=master \ 12SRC_URI = "git://github.com/riscv/opensbi.git;branch=master;protocol=https"
13 file://0001-Makefile-Don-t-specify-mabi-or-march.patch \
14 "
15 13
16S = "${WORKDIR}/git" 14S = "${WORKDIR}/git"
17 15
18EXTRA_OEMAKE += "PLATFORM=${RISCV_SBI_PLAT} I=${D}" 16TARGET_CC_ARCH += "${LDFLAGS}"
17
18EXTRA_OEMAKE += "PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_PIC=y CLANG_TARGET= "
19# If RISCV_SBI_PAYLOAD is set then include it as a payload 19# If RISCV_SBI_PAYLOAD is set then include it as a payload
20EXTRA_OEMAKE_append = " ${@riscv_get_extra_oemake_image(d)}" 20EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_image(d)}"
21EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_fdt(d)}"
21 22
22# Required if specifying a custom payload 23# Required if specifying a custom payload
23do_compile[depends] += "${@riscv_get_do_compile_depends(d)}" 24do_compile[depends] += "${@riscv_get_do_compile_depends(d)}"
24 25
25do_install_append() { 26do_install:append() {
26 # In the future these might be required as a dependency for other packages. 27 # In the future these might be required as a dependency for other packages.
27 # At the moment just delete them to avoid warnings 28 # At the moment just delete them to avoid warnings
28 rm -r ${D}/include 29 rm -r ${D}/include
@@ -38,11 +39,9 @@ do_deploy () {
38 39
39addtask deploy before do_build after do_install 40addtask deploy before do_build after do_install
40 41
41FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*" 42FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
42FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*" 43FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
43FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_dynamic.*" 44FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_dynamic.*"
44 45
45COMPATIBLE_HOST = "(riscv64|riscv32).*" 46COMPATIBLE_HOST = "(riscv64|riscv32).*"
46INHIBIT_PACKAGE_STRIP = "1" 47INHIBIT_PACKAGE_STRIP = "1"
47
48SECURITY_CFLAGS = ""
diff --git a/meta/recipes-bsp/pciutils/pciutils/configure.patch b/meta/recipes-bsp/pciutils/pciutils/configure.patch
index e444c13975..5015cf4884 100644
--- a/meta/recipes-bsp/pciutils/pciutils/configure.patch
+++ b/meta/recipes-bsp/pciutils/pciutils/configure.patch
@@ -1,9 +1,14 @@
1From 561216c8cbc280aaa9aecf30cb11835a4a0a78ed Mon Sep 17 00:00:00 2001
2From: Richard Purdie <rpurdie@linux.intel.com>
3Date: Wed, 31 Dec 2008 17:20:38 +0000
4Subject: [PATCH] pciutils: Upgarde 2.2.4 -> 3.0.3
5
1This patch: 6This patch:
2* ensures we link correctly 7* ensures we link correctly
3* allows us to optionally pass target information to configure rather than using uname 8* allows us to optionally pass target information to configure rather than using uname
4* select linux as the platform in most cases we care about 9* select linux as the platform in most cases we care about
5 10
6This is a merge of various tweaks to allow us to build pciutils including 11This is a merge of various tweaks to allow us to build pciutils including
7work from: 12work from:
8 13
97/30/2010 - Qing He <qing.he@intel.com> 147/30/2010 - Qing He <qing.he@intel.com>
@@ -12,24 +17,28 @@ Ionut Radu <ionutx.radu@intel.com>
122017/6/15 - RP - Cleanups and merging patches 172017/6/15 - RP - Cleanups and merging patches
13 18
14Upstream-Status: Inappropriate [embedded specific] 19Upstream-Status: Inappropriate [embedded specific]
20---
21 Makefile | 2 +-
22 lib/configure | 14 ++++++++++----
23 2 files changed, 11 insertions(+), 5 deletions(-)
15 24
16Index: pciutils-3.5.6/Makefile 25diff --git a/Makefile b/Makefile
17=================================================================== 26index aaec04e..9c1dab0 100644
18--- pciutils-3.5.6.orig/Makefile 27--- a/Makefile
19+++ pciutils-3.5.6/Makefile 28+++ b/Makefile
20@@ -96,7 +96,7 @@ example: example.o lib/$(PCILIB) 29@@ -123,7 +123,7 @@ pcilmr$(EXEEXT): pcilmr.o $(LMROBJS) $(COMMON) lib/$(PCIIMPLIB)
21 example.o: example.c $(PCIINC) 30 pcilmr.o: pcilmr.c $(LMRINC)
22 31
23 %: %.o 32 %$(EXEEXT): %.o
24- $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@ 33- $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
25+ $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LIB_LDLIBS) $(LDLIBS) -o $@ 34+ $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LIB_LDLIBS) $(LDLIBS) -o $@
26 35
27 %.8 %.7 %.5: %.man 36 ifdef PCI_OS_WINDOWS
28 M=`echo $(DATE) | sed 's/-01-/-January-/;s/-02-/-February-/;s/-03-/-March-/;s/-04-/-April-/;s/-05-/-May-/;s/-06-/-June-/;s/-07-/-July-/;s/-08-/-August-/;s/-09-/-September-/;s/-10-/-October-/;s/-11-/-November-/;s/-12-/-December-/;s/\(.*\)-\(.*\)-\(.*\)/\3 \2 \1/'` ; sed <$< >$@ "s/@TODAY@/$$M/;s/@VERSION@/pciutils-$(VERSION)/;s#@IDSDIR@#$(IDSDIR)#" 37 comma := ,
29Index: pciutils-3.5.6/lib/configure 38diff --git a/lib/configure b/lib/configure
30=================================================================== 39index 3df057a..c87e71c 100755
31--- pciutils-3.5.6.orig/lib/configure 40--- a/lib/configure
32+++ pciutils-3.5.6/lib/configure 41+++ b/lib/configure
33@@ -9,6 +9,10 @@ echo_n() { 42@@ -9,6 +9,10 @@ echo_n() {
34 printf '%s' "$*" 43 printf '%s' "$*"
35 } 44 }
@@ -38,7 +47,7 @@ Index: pciutils-3.5.6/lib/configure
38+IDSDIR=$2 47+IDSDIR=$2
39+DNS=yes 48+DNS=yes
40+ 49+
41 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then 50 if [ -z "$VERSION" ] ; then
42 echo >&2 "Please run the configure script from the top-level Makefile" 51 echo >&2 "Please run the configure script from the top-level Makefile"
43 exit 1 52 exit 1
44@@ -16,8 +20,8 @@ fi 53@@ -16,8 +20,8 @@ fi
@@ -56,12 +65,12 @@ Index: pciutils-3.5.6/lib/configure
56 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1` 65 proc=`/usr/sbin/lsdev -C -c processor -S available -F name | head -1`
57 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'` 66 cpu=`/usr/sbin/lsattr -F value -l $proc -a type | sed 's/_.*//'`
58 else 67 else
59- cpu=`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'` 68- cpu=`uname -m | sed 's/^i.86-AT386/i386/;s/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'`
60+ cpu=${4:-`uname -m | sed 's/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'`} 69+ cpu=${4:-`uname -m | sed 's/^i.86-AT386/i386/;s/^i.86$/i386/;s/^sun4u$/sparc64/;s/^i86pc$/i386/;s/^BePC$/i386/;s/^BeMac$/powerpc/;s/^BeBox$/powerpc/'`}
61 fi 70 fi
62 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ] 71 if [ "$sys" = "DragonFly" ]
63 then 72 then
64@@ -35,7 +39,7 @@ if [ -z "$HOST" ] ; then 73@@ -43,7 +47,7 @@ if [ -z "$HOST" ] ; then
65 then 74 then
66 sys=cygwin 75 sys=cygwin
67 fi 76 fi
@@ -70,7 +79,7 @@ Index: pciutils-3.5.6/lib/configure
70 fi 79 fi
71 [ -n "$RELEASE" ] && rel="${RELEASE}" 80 [ -n "$RELEASE" ] && rel="${RELEASE}"
72 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless. 81 # CAVEAT: tr on Solaris is a bit weird and the extra [] is otherwise harmless.
73@@ -44,6 +48,8 @@ cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` 82@@ -52,6 +56,8 @@ cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
74 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` 83 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
75 echo " $host $rel $cpu $sys" 84 echo " $host $rel $cpu $sys"
76 85
diff --git a/meta/recipes-bsp/pciutils/pciutils_3.7.0.bb b/meta/recipes-bsp/pciutils/pciutils_3.11.1.bb
index 4f0edc01ed..044074ccc3 100644
--- a/meta/recipes-bsp/pciutils/pciutils_3.7.0.bb
+++ b/meta/recipes-bsp/pciutils/pciutils_3.11.1.bb
@@ -4,16 +4,19 @@ to PCI bus configuration space and several utilities based on this library.'
4HOMEPAGE = "http://atrey.karlin.mff.cuni.cz/~mj/pciutils.shtml" 4HOMEPAGE = "http://atrey.karlin.mff.cuni.cz/~mj/pciutils.shtml"
5SECTION = "console/utils" 5SECTION = "console/utils"
6 6
7LICENSE = "GPLv2+" 7LICENSE = "GPL-2.0-or-later"
8LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe" 8LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
9DEPENDS = "zlib kmod" 9# Can drop make-native when all systems have make 4.3
10# https://git.savannah.gnu.org/cgit/make.git/commit/?id=b90fabc8d6f34fb37d428dc0fb1b8b1951a9fbed
11# causes space issues in lib/libpci.pc
12DEPENDS = "zlib kmod make-native"
10 13
11SRC_URI = "${KERNELORG_MIRROR}/software/utils/pciutils/pciutils-${PV}.tar.xz \ 14SRC_URI = "${KERNELORG_MIRROR}/software/utils/pciutils/pciutils-${PV}.tar.xz \
12 file://configure.patch" 15 file://configure.patch"
13 16
14SRC_URI[sha256sum] = "9d40b97be8b6a2cdf96aead5a61881d1f7e4e0da9544a9bac4fba1ae9dcd40eb" 17SRC_URI[sha256sum] = "3f472ad864473de5ba17f765cc96ef5f33e1b730918d3adda6f945a2a9290df4"
15 18
16inherit multilib_header pkgconfig 19inherit multilib_header pkgconfig update-alternatives
17 20
18PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'hwdb', '', d)}" 21PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'hwdb', '', d)}"
19PACKAGECONFIG[hwdb] = "HWDB=yes,HWDB=no,udev" 22PACKAGECONFIG[hwdb] = "HWDB=yes,HWDB=no,udev"
@@ -46,14 +49,16 @@ do_install () {
46 oe_runmake DESTDIR=${D} install install-lib 49 oe_runmake DESTDIR=${D} install install-lib
47 50
48 install -d ${D}${bindir} 51 install -d ${D}${bindir}
49 ln -s ../sbin/lspci ${D}${bindir}/lspci
50 52
51 oe_multilib_header pci/config.h 53 oe_multilib_header pci/config.h
52} 54}
53 55
54PACKAGES =+ "${PN}-ids libpci" 56PACKAGES =+ "${PN}-ids libpci"
55FILES_${PN}-ids = "${datadir}/pci.ids*" 57FILES:${PN}-ids = "${datadir}/pci.ids*"
56FILES_libpci = "${libdir}/libpci.so.*" 58FILES:libpci = "${libdir}/libpci.so.*"
57SUMMARY_${PN}-ids = "PCI utilities - device ID database" 59SUMMARY:${PN}-ids = "PCI utilities - device ID database"
58DESCRIPTION_${PN}-ids = "Package providing the PCI device ID database for pciutils." 60DESCRIPTION:${PN}-ids = "Package providing the PCI device ID database for pciutils."
59RDEPENDS_${PN} += "${PN}-ids" 61RDEPENDS:${PN} += "${PN}-ids"
62
63ALTERNATIVE:${PN} = "lspci"
64ALTERNATIVE_PRIORITY = "100"
diff --git a/meta/recipes-bsp/pm-utils/pm-utils_1.4.1.bb b/meta/recipes-bsp/pm-utils/pm-utils_1.4.1.bb
index cac09101c4..c7b95e57b0 100644
--- a/meta/recipes-bsp/pm-utils/pm-utils_1.4.1.bb
+++ b/meta/recipes-bsp/pm-utils/pm-utils_1.4.1.bb
@@ -2,11 +2,10 @@ SECTION = "base"
2SUMMARY = "Utilities and scripts for power management" 2SUMMARY = "Utilities and scripts for power management"
3DESCRIPTION = "Simple shell command line tools to suspend and hibernate." 3DESCRIPTION = "Simple shell command line tools to suspend and hibernate."
4HOMEPAGE = "http://pm-utils.freedesktop.org/wiki/" 4HOMEPAGE = "http://pm-utils.freedesktop.org/wiki/"
5LICENSE = "GPLv2" 5LICENSE = "GPL-2.0-only"
6LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \ 6LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
7 file://src/pm-pmu.c;beginline=1;endline=22;md5=3c1ddbc54e735fb4a0386e14c78a3147" 7 file://src/pm-pmu.c;beginline=1;endline=22;md5=3c1ddbc54e735fb4a0386e14c78a3147"
8 8
9PR = "r1"
10 9
11SRC_URI = "http://pm-utils.freedesktop.org/releases/pm-utils-${PV}.tar.gz" 10SRC_URI = "http://pm-utils.freedesktop.org/releases/pm-utils-${PV}.tar.gz"
12 11
@@ -17,11 +16,14 @@ inherit pkgconfig autotools manpages
17 16
18PACKAGECONFIG[manpages] = "--enable-doc, --disable-doc, libxslt-native xmlto-native" 17PACKAGECONFIG[manpages] = "--enable-doc, --disable-doc, libxslt-native xmlto-native"
19 18
20RDEPENDS_${PN} = "grep bash" 19RDEPENDS:${PN} = "bash"
21 20
22do_configure_prepend () { 21EXTRA_OECONF = "--libdir=${nonarch_libdir}"
22
23do_configure:prepend () {
23 ( cd ${S}; autoreconf -f -i -s ) 24 ( cd ${S}; autoreconf -f -i -s )
24} 25}
25 26
26FILES_${PN} += "${libdir}/${BPN}/*" 27FILES:${PN} += "${nonarch_libdir}/${BPN}/*"
27FILES_${PN}-dbg += "${datadir}/doc/pm-utils/README.debugging" 28FILES:${PN}-dbg += "${datadir}/doc/pm-utils/README.debugging"
29FILES:${PN}-dev += "${nonarch_libdir}/pkgconfig/pm-utils.pc"
diff --git a/meta/recipes-bsp/setserial/setserial/0001-setserial.c-Add-needed-system-headers-for-ioctl-and-.patch b/meta/recipes-bsp/setserial/setserial/0001-setserial.c-Add-needed-system-headers-for-ioctl-and-.patch
new file mode 100644
index 0000000000..10c6ae881b
--- /dev/null
+++ b/meta/recipes-bsp/setserial/setserial/0001-setserial.c-Add-needed-system-headers-for-ioctl-and-.patch
@@ -0,0 +1,41 @@
1From 9bbb342f5d9ad5dc75486fd35ada8e287ba19299 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 15 Aug 2022 13:03:17 -0700
4Subject: [PATCH] setserial.c: Add needed system headers for ioctl() and
5 close() calls
6
7Add int return type for main() function
8
9Fixes
10error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
11error: call to undeclared function 'close'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declarat
12ion]
13
14Upstream-Status: Submitted [https://sourceforge.net/p/setserial/discussion/7060/thread/95d874c12c/]
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 setserial.c | 4 +++-
18 1 file changed, 3 insertions(+), 1 deletion(-)
19
20diff --git a/setserial.c b/setserial.c
21index bfda8fd..6a95513 100644
22--- a/setserial.c
23+++ b/setserial.c
24@@ -16,6 +16,8 @@
25 #include <termios.h>
26 #include <string.h>
27 #include <errno.h>
28+#include <unistd.h>
29+#include <sys/ioctl.h>
30
31 #ifdef HAVE_ASM_IOCTLS_H
32 #include <asm/ioctls.h>
33@@ -715,7 +717,7 @@ fprintf(stderr, "\t* port\t\tset the I/O port\n");
34 exit(1);
35 }
36
37-main(int argc, char **argv)
38+int main(int argc, char **argv)
39 {
40 int get_flag = 0, wild_intr_flag = 0;
41 int c;
diff --git a/meta/recipes-bsp/setserial/setserial_2.17.bb b/meta/recipes-bsp/setserial/setserial_2.17.bb
index 8dbddd7dc5..98ab45145f 100644
--- a/meta/recipes-bsp/setserial/setserial_2.17.bb
+++ b/meta/recipes-bsp/setserial/setserial_2.17.bb
@@ -1,12 +1,10 @@
1SUMMARY = "Controls the configuration of serial ports" 1SUMMARY = "Controls the configuration of serial ports"
2DESCRIPTION = "setserial is a program designed to set and/or report the configuration information associated with a serial port" 2DESCRIPTION = "setserial is a program designed to set and/or report the configuration information associated with a serial port"
3HOMEPAGE = "http://setserial.sourceforge.net" 3HOMEPAGE = "http://setserial.sourceforge.net"
4AUTHOR = "Theodore Ts'o <tytso@mit.edu>"
5SECTION = "console/utils" 4SECTION = "console/utils"
6 5
7LICENSE = "GPLv2.0" 6LICENSE = "GPL-2.0-only"
8LIC_FILES_CHKSUM = "file://version.h;beginline=1;endline=6;md5=2e7c59cb9e57e356ae81f50f4e4dfd99" 7LIC_FILES_CHKSUM = "file://version.h;beginline=1;endline=6;md5=2e7c59cb9e57e356ae81f50f4e4dfd99"
9PR = "r3"
10 8
11DEPENDS += "groff-native" 9DEPENDS += "groff-native"
12 10
@@ -15,7 +13,8 @@ inherit autotools-brokensep
15SRC_URI = "${SOURCEFORGE_MIRROR}/setserial/${BPN}-${PV}.tar.gz \ 13SRC_URI = "${SOURCEFORGE_MIRROR}/setserial/${BPN}-${PV}.tar.gz \
16 file://add_stdlib.patch \ 14 file://add_stdlib.patch \
17 file://ldflags.patch \ 15 file://ldflags.patch \
18 " 16 file://0001-setserial.c-Add-needed-system-headers-for-ioctl-and-.patch \
17 "
19 18
20SRC_URI[md5sum] = "c4867d72c41564318e0107745eb7a0f2" 19SRC_URI[md5sum] = "c4867d72c41564318e0107745eb7a0f2"
21SRC_URI[sha256sum] = "7e4487d320ac31558563424189435d396ddf77953bb23111a17a3d1487b5794a" 20SRC_URI[sha256sum] = "7e4487d320ac31558563424189435d396ddf77953bb23111a17a3d1487b5794a"
diff --git a/meta/recipes-bsp/u-boot/libubootenv_0.3.1.bb b/meta/recipes-bsp/u-boot/libubootenv_0.3.5.bb
index 613e3161fb..b68bbb430a 100644
--- a/meta/recipes-bsp/u-boot/libubootenv_0.3.1.bb
+++ b/meta/recipes-bsp/u-boot/libubootenv_0.3.5.bb
@@ -6,25 +6,21 @@ It provides a hardware-independent replacement for fw_printenv/setenv utilities
6provided by U-Boot" 6provided by U-Boot"
7 7
8HOMEPAGE = "https://github.com/sbabic/libubootenv" 8HOMEPAGE = "https://github.com/sbabic/libubootenv"
9LICENSE = "LGPL-2.1" 9LICENSE = "LGPL-2.1-or-later"
10LIC_FILES_CHKSUM = "file://Licenses/lgpl-2.1.txt;md5=4fbd65380cdd255951079008b364516c" 10LIC_FILES_CHKSUM = "file://LICENSES/LGPL-2.1-or-later.txt;md5=4fbd65380cdd255951079008b364516c"
11SECTION = "libs" 11SECTION = "libs"
12 12
13SRC_URI = "git://github.com/sbabic/libubootenv;protocol=https" 13SRC_URI = "git://github.com/sbabic/libubootenv;protocol=https;branch=master"
14SRCREV = "824551ac77bab1d0f7ae34d7a7c77b155240e754" 14SRCREV = "3f4d15e36ceb58085b08dd13f3f2788e9299877b"
15 15
16S = "${WORKDIR}/git" 16S = "${WORKDIR}/git"
17 17
18inherit uboot-config cmake lib_package 18inherit cmake lib_package
19 19
20EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release" 20EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release"
21 21
22DEPENDS = "zlib" 22DEPENDS = "zlib libyaml"
23PROVIDES += "u-boot-fw-utils" 23PROVIDES += "u-boot-fw-utils"
24RPROVIDES_${PN}-bin += "u-boot-fw-utils" 24RPROVIDES:${PN}-bin += "u-boot-fw-utils"
25
26PACKAGE_ARCH = "${MACHINE_ARCH}"
27
28RRECOMMENDS_${PN}-bin_append_class-target = " u-boot-default-env"
29 25
30BBCLASSEXTEND = "native" 26BBCLASSEXTEND = "native"
diff --git a/meta/recipes-bsp/u-boot/u-boot-common.inc b/meta/recipes-bsp/u-boot/u-boot-common.inc
index 5a8035f432..ca5357392a 100644
--- a/meta/recipes-bsp/u-boot/u-boot-common.inc
+++ b/meta/recipes-bsp/u-boot/u-boot-common.inc
@@ -4,19 +4,21 @@ ARM, MIPS and several other processors, which can be installed in a boot \
4ROM and used to initialize and test the hardware or to download and run \ 4ROM and used to initialize and test the hardware or to download and run \
5application code." 5application code."
6SECTION = "bootloaders" 6SECTION = "bootloaders"
7DEPENDS += "flex-native bison-native" 7DEPENDS += "flex-native bison-native python3-setuptools-native"
8 8
9LICENSE = "GPLv2+" 9LICENSE = "GPL-2.0-or-later"
10LIC_FILES_CHKSUM = "file://Licenses/README;md5=5a7450c57ffe5ae63fd732446b988025" 10LIC_FILES_CHKSUM = "file://Licenses/README;md5=2ca5f2c35c8cc335f0a19756634782f1"
11PE = "1" 11PE = "1"
12 12
13# We use the revision in order to avoid having to fetch it from the 13# We use the revision in order to avoid having to fetch it from the
14# repo during parse 14# repo during parse
15SRCREV = "c4fddedc48f336eabc4ce3f74940e6aa372de18c" 15SRCREV = "25049ad560826f7dc1c4740883b0016014a59789"
16 16
17SRC_URI = "git://git.denx.de/u-boot.git \ 17SRC_URI = "git://source.denx.de/u-boot/u-boot.git;protocol=https;branch=master"
18 "
19 18
20S = "${WORKDIR}/git" 19S = "${WORKDIR}/git"
21B = "${WORKDIR}/build" 20B = "${WORKDIR}/build"
21
22inherit pkgconfig
23
22do_configure[cleandirs] = "${B}" 24do_configure[cleandirs] = "${B}"
diff --git a/meta/recipes-bsp/u-boot/u-boot-configure.inc b/meta/recipes-bsp/u-boot/u-boot-configure.inc
new file mode 100644
index 0000000000..378d675364
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/u-boot-configure.inc
@@ -0,0 +1,40 @@
1# This provides the logic for creating the desired u-boot config,
2# accounting for any *.cfg files added to SRC_URI. It's separated
3# from u-boot.inc for use by recipes that need u-boot properly
4# configured but aren't doing a full build of u-boot itself (such as
5# its companion tools).
6
7inherit uboot-config cml1
8
9DEPENDS += "kern-tools-native"
10
11CONFIGURE_FILES = "${@d.getVar('UBOOT_MACHINE') or '.config'}"
12
13do_configure () {
14 if [ -n "${UBOOT_CONFIG}" ]; then
15 unset i j
16 for config in ${UBOOT_MACHINE}; do
17 i=$(expr $i + 1);
18 for type in ${UBOOT_CONFIG}; do
19 j=$(expr $j + 1);
20 if [ $j -eq $i ]; then
21 oe_runmake -C ${S} O=${B}/${config} ${config}
22 if [ -n "${@' '.join(find_cfgs(d))}" ]; then
23 merge_config.sh -m -O ${B}/${config} ${B}/${config}/.config ${@" ".join(find_cfgs(d))}
24 oe_runmake -C ${S} O=${B}/${config} oldconfig
25 fi
26 fi
27 done
28 unset j
29 done
30 unset i
31 else
32 if [ -n "${UBOOT_MACHINE}" ]; then
33 oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE}
34 else
35 oe_runmake -C ${S} O=${B} oldconfig
36 fi
37 merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
38 cml1_do_configure
39 fi
40}
diff --git a/meta/recipes-bsp/u-boot/u-boot-tools.inc b/meta/recipes-bsp/u-boot/u-boot-tools.inc
index 4ed936a70d..f3010763c0 100644
--- a/meta/recipes-bsp/u-boot/u-boot-tools.inc
+++ b/meta/recipes-bsp/u-boot/u-boot-tools.inc
@@ -1,26 +1,30 @@
1SUMMARY = "U-Boot bootloader tools" 1SUMMARY = "U-Boot bootloader tools"
2DEPENDS += "openssl" 2DEPENDS += "gnutls openssl util-linux swig-native"
3 3
4PROVIDES = "${MLPREFIX}u-boot-mkimage ${MLPREFIX}u-boot-mkenvimage" 4inherit python3native
5PROVIDES_class-native = "u-boot-mkimage-native u-boot-mkenvimage-native" 5export STAGING_INCDIR="${STAGING_INCDIR_NATIVE}"
6 6
7PACKAGES += "${PN}-mkimage ${PN}-mkenvimage" 7PROVIDES = "${MLPREFIX}u-boot-mkimage ${MLPREFIX}u-boot-mkenvimage ${MLPREFIX}u-boot-mkeficapsule"
8PROVIDES:class-native = "u-boot-mkimage-native u-boot-mkenvimage-native u-boot-mkeficapsule-native"
9
10PACKAGES += "${PN}-mkimage ${PN}-mkenvimage ${PN}-mkeficapsule"
8 11
9# Required for backward compatibility with "u-boot-mkimage-xxx.bb" 12# Required for backward compatibility with "u-boot-mkimage-xxx.bb"
10RPROVIDES_${PN}-mkimage = "u-boot-mkimage" 13RPROVIDES:${PN}-mkimage = "u-boot-mkimage"
11RREPLACES_${PN}-mkimage = "u-boot-mkimage" 14RREPLACES:${PN}-mkimage = "u-boot-mkimage"
12RCONFLICTS_${PN}-mkimage = "u-boot-mkimage" 15RCONFLICTS:${PN}-mkimage = "u-boot-mkimage"
13 16
14EXTRA_OEMAKE_class-target = 'CROSS_COMPILE="${TARGET_PREFIX}" CC="${CC} ${CFLAGS} ${LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1' 17EXTRA_OEMAKE:class-target = 'CROSS_COMPILE="${TARGET_PREFIX}" CC="${CC} ${CFLAGS} ${LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1'
15EXTRA_OEMAKE_class-native = 'CC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1' 18EXTRA_OEMAKE:class-native = 'CC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1'
16EXTRA_OEMAKE_class-nativesdk = 'CROSS_COMPILE="${HOST_PREFIX}" CC="${CC} ${CFLAGS} ${LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1' 19EXTRA_OEMAKE:class-nativesdk = 'CROSS_COMPILE="${HOST_PREFIX}" CC="${CC} ${CFLAGS} ${LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1'
17 20
18SED_CONFIG_EFI = '-e "s/CONFIG_EFI_LOADER=.*/# CONFIG_EFI_LOADER is not set/"' 21SED_CONFIG_EFI = '-e "s/CONFIG_EFI_LOADER=.*/# CONFIG_EFI_LOADER is not set/"'
19SED_CONFIG_EFI_x86 = '' 22SED_CONFIG_EFI:x86 = ''
20SED_CONFIG_EFI_x86-64 = '' 23SED_CONFIG_EFI:x86-64 = ''
21SED_CONFIG_EFI_arm = '' 24SED_CONFIG_EFI:arm = ''
22SED_CONFIG_EFI_armeb = '' 25SED_CONFIG_EFI:armeb = ''
23SED_CONFIG_EFI_aarch64 = '' 26SED_CONFIG_EFI:aarch64 = ''
27SED_CONFIG_EFI:loongarch64 = ''
24 28
25do_compile () { 29do_compile () {
26 # Yes, this is crazy. If you build on a system with git < 2.14 from scratch, the tree will 30 # Yes, this is crazy. If you build on a system with git < 2.14 from scratch, the tree will
@@ -38,7 +42,7 @@ do_compile () {
38 # (i.e. creating a hardlink dirties the index) 42 # (i.e. creating a hardlink dirties the index)
39 cd ${S}; git diff; cd ${B} 43 cd ${S}; git diff; cd ${B}
40 44
41 oe_runmake -C ${S} sandbox_defconfig O=${B} 45 oe_runmake -C ${S} tools-only_defconfig O=${B}
42 46
43 # Disable CONFIG_CMD_LICENSE, license.h is not used by tools and 47 # Disable CONFIG_CMD_LICENSE, license.h is not used by tools and
44 # generating it requires bin2header tool, which for target build 48 # generating it requires bin2header tool, which for target build
@@ -66,16 +70,21 @@ do_install () {
66 # fit_check_sign 70 # fit_check_sign
67 install -m 0755 tools/fit_check_sign ${D}${bindir}/uboot-fit_check_sign 71 install -m 0755 tools/fit_check_sign ${D}${bindir}/uboot-fit_check_sign
68 ln -sf uboot-fit_check_sign ${D}${bindir}/fit_check_sign 72 ln -sf uboot-fit_check_sign ${D}${bindir}/fit_check_sign
73
74 # mkeficapsule
75 install -m 0755 tools/mkeficapsule ${D}${bindir}/uboot-mkeficapsule
76 ln -sf uboot-mkeficapsule ${D}${bindir}/mkeficapsule
69} 77}
70 78
71ALLOW_EMPTY_${PN} = "1" 79ALLOW_EMPTY:${PN} = "1"
72FILES_${PN} = "" 80FILES:${PN} = ""
73FILES_${PN}-mkimage = "${bindir}/uboot-mkimage ${bindir}/mkimage ${bindir}/uboot-dumpimage ${bindir}/dumpimage ${bindir}/uboot-fit_check_sign ${bindir}/fit_check_sign" 81FILES:${PN}-mkimage = "${bindir}/uboot-mkimage ${bindir}/mkimage ${bindir}/uboot-dumpimage ${bindir}/dumpimage ${bindir}/uboot-fit_check_sign ${bindir}/fit_check_sign"
74FILES_${PN}-mkenvimage = "${bindir}/uboot-mkenvimage ${bindir}/mkenvimage" 82FILES:${PN}-mkenvimage = "${bindir}/uboot-mkenvimage ${bindir}/mkenvimage"
83FILES:${PN}-mkeficapsule = "${bindir}/uboot-mkeficapsule ${bindir}/mkeficapsule"
75 84
76RDEPENDS_${PN}-mkimage += "dtc" 85RDEPENDS:${PN}-mkimage += "dtc"
77RDEPENDS_${PN} += "${PN}-mkimage ${PN}-mkenvimage" 86RDEPENDS:${PN} += "${PN}-mkimage ${PN}-mkenvimage ${PN}-mkeficapsule"
78RDEPENDS_${PN}_class-native = "" 87RDEPENDS:${PN}:class-native = ""
79 88
80BBCLASSEXTEND = "native nativesdk" 89BBCLASSEXTEND = "native nativesdk"
81 90
diff --git a/meta/recipes-bsp/u-boot/u-boot-tools_2021.01.bb b/meta/recipes-bsp/u-boot/u-boot-tools_2024.04.bb
index ef386f76e6..7eaf721ca8 100644
--- a/meta/recipes-bsp/u-boot/u-boot-tools_2021.01.bb
+++ b/meta/recipes-bsp/u-boot/u-boot-tools_2024.04.bb
@@ -1,3 +1,2 @@
1require u-boot-common.inc 1require u-boot-common.inc
2require u-boot-tools.inc 2require u-boot-tools.inc
3
diff --git a/meta/recipes-bsp/u-boot/u-boot.inc b/meta/recipes-bsp/u-boot/u-boot.inc
index 251178db33..f5b43f6e36 100644
--- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc
@@ -3,13 +3,13 @@ PROVIDES = "virtual/bootloader"
3 3
4PACKAGE_ARCH = "${MACHINE_ARCH}" 4PACKAGE_ARCH = "${MACHINE_ARCH}"
5 5
6DEPENDS += "kern-tools-native" 6DEPENDS += "${@bb.utils.contains('UBOOT_ENV_SUFFIX', 'scr', 'u-boot-mkimage-native', '', d)}"
7 7
8inherit uboot-config uboot-extlinux-config uboot-sign deploy cml1 python3native 8inherit uboot-config uboot-extlinux-config uboot-sign deploy python3native kernel-arch
9 9
10DEPENDS += "swig-native" 10DEPENDS += "swig-native"
11 11
12EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1' 12EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS} ${DEBUG_PREFIX_MAP}" V=1'
13EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"' 13EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"'
14EXTRA_OEMAKE += 'STAGING_INCDIR=${STAGING_INCDIR_NATIVE} STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}' 14EXTRA_OEMAKE += 'STAGING_INCDIR=${STAGING_INCDIR_NATIVE} STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}'
15 15
@@ -24,82 +24,19 @@ PACKAGECONFIG[openssl] = ",,openssl-native"
24# file already exists it will not be overwritten. 24# file already exists it will not be overwritten.
25UBOOT_LOCALVERSION ?= "" 25UBOOT_LOCALVERSION ?= ""
26 26
27# Some versions of u-boot use .bin and others use .img. By default use .bin
28# but enable individual recipes to change this value.
29UBOOT_SUFFIX ??= "bin"
30UBOOT_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_SUFFIX}"
31UBOOT_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_SUFFIX}"
32UBOOT_MAKE_TARGET ?= "all"
33
34# Output the ELF generated. Some platforms can use the ELF file and directly
35# load it (JTAG booting, QEMU) additionally the ELF can be used for debugging
36# purposes.
37UBOOT_ELF ?= ""
38UBOOT_ELF_SUFFIX ?= "elf"
39UBOOT_ELF_IMAGE ?= "u-boot-${MACHINE}-${PV}-${PR}.${UBOOT_ELF_SUFFIX}"
40UBOOT_ELF_BINARY ?= "u-boot.${UBOOT_ELF_SUFFIX}"
41UBOOT_ELF_SYMLINK ?= "u-boot-${MACHINE}.${UBOOT_ELF_SUFFIX}"
42
43# Some versions of u-boot build an SPL (Second Program Loader) image that
44# should be packaged along with the u-boot binary as well as placed in the
45# deploy directory. For those versions they can set the following variables
46# to allow packaging the SPL.
47SPL_BINARY ?= ""
48SPL_BINARYNAME ?= "${@os.path.basename(d.getVar("SPL_BINARY"))}"
49SPL_IMAGE ?= "${SPL_BINARYNAME}-${MACHINE}-${PV}-${PR}"
50SPL_SYMLINK ?= "${SPL_BINARYNAME}-${MACHINE}"
51
52# Additional environment variables or a script can be installed alongside
53# u-boot to be used automatically on boot. This file, typically 'uEnv.txt'
54# or 'boot.scr', should be packaged along with u-boot as well as placed in the
55# deploy directory. Machine configurations needing one of these files should
56# include it in the SRC_URI and set the UBOOT_ENV parameter.
57UBOOT_ENV_SUFFIX ?= "txt"
58UBOOT_ENV ?= ""
59UBOOT_ENV_BINARY ?= "${UBOOT_ENV}.${UBOOT_ENV_SUFFIX}"
60UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${PV}-${PR}.${UBOOT_ENV_SUFFIX}"
61UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}"
62
63# Default name of u-boot initial env, but enable individual recipes to change 27# Default name of u-boot initial env, but enable individual recipes to change
64# this value. 28# this value.
65UBOOT_INITIAL_ENV ?= "${PN}-initial-env" 29UBOOT_INITIAL_ENV ?= "${PN}-initial-env"
66 30
67# U-Boot EXTLINUX variables. U-Boot searches for /boot/extlinux/extlinux.conf 31require u-boot-configure.inc
68# to find EXTLINUX conf file.
69UBOOT_EXTLINUX_INSTALL_DIR ?= "/boot/extlinux"
70UBOOT_EXTLINUX_CONF_NAME ?= "extlinux.conf"
71UBOOT_EXTLINUX_SYMLINK ?= "${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE}-${PR}"
72 32
73do_configure () { 33do_savedefconfig() {
74 if [ -n "${UBOOT_CONFIG}" ]; then 34 bbplain "Saving defconfig to:\n${B}/defconfig"
75 unset i j 35 oe_runmake -C ${B} savedefconfig
76 for config in ${UBOOT_MACHINE}; do
77 i=$(expr $i + 1);
78 for type in ${UBOOT_CONFIG}; do
79 j=$(expr $j + 1);
80 if [ $j -eq $i ]; then
81 oe_runmake -C ${S} O=${B}/${config} ${config}
82 if [ -n "${@' '.join(find_cfgs(d))}" ]; then
83 merge_config.sh -m -O ${B}/${config} ${B}/${config}/.config ${@" ".join(find_cfgs(d))}
84 oe_runmake -C ${S} O=${B}/${config} oldconfig
85 fi
86 fi
87 done
88 unset j
89 done
90 unset i
91 DEVTOOL_DISABLE_MENUCONFIG=true
92 else
93 if [ -n "${UBOOT_MACHINE}" ]; then
94 oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE}
95 else
96 oe_runmake -C ${S} O=${B} oldconfig
97 fi
98 merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
99 cml1_do_configure
100 fi
101} 36}
102 37do_savedefconfig[nostamp] = "1"
38addtask savedefconfig after do_configure
39UBOOT_ARCH_DIR = "${@'arm' if d.getVar('UBOOT_ARCH').startswith('arm') else d.getVar('UBOOT_ARCH')}"
103do_compile () { 40do_compile () {
104 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'ld-is-gold', d)}" ]; then 41 if [ "${@bb.utils.filter('DISTRO_FEATURES', 'ld-is-gold', d)}" ]; then
105 sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' ${S}/config.mk 42 sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' ${S}/config.mk
@@ -128,7 +65,7 @@ do_compile () {
128 for binary in ${UBOOT_BINARIES}; do 65 for binary in ${UBOOT_BINARIES}; do
129 k=$(expr $k + 1); 66 k=$(expr $k + 1);
130 if [ $k -eq $i ]; then 67 if [ $k -eq $i ]; then
131 cp ${B}/${config}/${binary} ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} 68 cp ${B}/${config}/${binary} ${B}/${config}/${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX}
132 fi 69 fi
133 done 70 done
134 71
@@ -152,6 +89,11 @@ do_compile () {
152 oe_runmake -C ${S} O=${B} u-boot-initial-env 89 oe_runmake -C ${S} O=${B} u-boot-initial-env
153 fi 90 fi
154 fi 91 fi
92
93 if [ -n "${UBOOT_ENV}" ] && [ "${UBOOT_ENV_SUFFIX}" = "scr" ]
94 then
95 ${UBOOT_MKIMAGE} -C none -A ${UBOOT_ARCH} -T script -d ${WORKDIR}/${UBOOT_ENV_SRC} ${WORKDIR}/${UBOOT_ENV_BINARY}
96 fi
155} 97}
156 98
157do_install () { 99do_install () {
@@ -163,9 +105,9 @@ do_install () {
163 j=$(expr $j + 1); 105 j=$(expr $j + 1);
164 if [ $j -eq $i ] 106 if [ $j -eq $i ]
165 then 107 then
166 install -D -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} 108 install -D -m 644 ${B}/${config}/${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARYNAME}-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
167 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type} 109 ln -sf ${UBOOT_BINARYNAME}-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
168 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY} 110 ln -sf ${UBOOT_BINARYNAME}-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}
169 111
170 # Install the uboot-initial-env 112 # Install the uboot-initial-env
171 if [ -n "${UBOOT_INITIAL_ENV}" ]; then 113 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
@@ -230,9 +172,9 @@ do_install () {
230 j=$(expr $j + 1); 172 j=$(expr $j + 1);
231 if [ $j -eq $i ] 173 if [ $j -eq $i ]
232 then 174 then
233 install -m 644 ${B}/${config}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}-${type}-${PV}-${PR} 175 install -m 644 ${B}/${config}/${SPL_BINARY} ${D}/boot/${SPL_BINARYNAME}-${type}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX}
234 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}-${type} 176 ln -sf ${SPL_BINARYNAME}-${type}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX} ${D}/boot/${SPL_BINARYFILE}-${type}
235 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME} 177 ln -sf ${SPL_BINARYNAME}-${type}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX} ${D}/boot/${SPL_BINARYFILE}
236 fi 178 fi
237 done 179 done
238 unset j 180 unset j
@@ -240,7 +182,7 @@ do_install () {
240 unset i 182 unset i
241 else 183 else
242 install -m 644 ${B}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE} 184 install -m 644 ${B}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}
243 ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARYNAME} 185 ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARYFILE}
244 fi 186 fi
245 fi 187 fi
246 188
@@ -256,17 +198,21 @@ do_install () {
256 fi 198 fi
257} 199}
258 200
259PACKAGE_BEFORE_PN += "${PN}-env" 201PACKAGE_BEFORE_PN += "${PN}-env ${PN}-extlinux"
260 202
261RPROVIDES_${PN}-env += "u-boot-default-env" 203RPROVIDES:${PN}-env += "u-boot-default-env"
262ALLOW_EMPTY_${PN}-env = "1" 204ALLOW_EMPTY:${PN}-env = "1"
263FILES_${PN}-env = " \ 205FILES:${PN}-env = " \
264 ${@ '${sysconfdir}/${UBOOT_INITIAL_ENV}*' if d.getVar('UBOOT_INITIAL_ENV') else ''} \ 206 ${@ '${sysconfdir}/${UBOOT_INITIAL_ENV}*' if d.getVar('UBOOT_INITIAL_ENV') else ''} \
265 ${sysconfdir}/fw_env.config \ 207 ${sysconfdir}/fw_env.config \
266" 208"
267 209
268FILES_${PN} = "/boot ${datadir}" 210FILES:${PN}-extlinux = "${UBOOT_EXTLINUX_INSTALL_DIR}/${UBOOT_EXTLINUX_CONF_NAME}"
269RDEPENDS_${PN} += "${PN}-env" 211RDEPENDS:${PN} += "${@bb.utils.contains('UBOOT_EXTLINUX', '1', '${PN}-extlinux', '', d)}"
212
213SYSROOT_DIRS += "/boot"
214FILES:${PN} = "/boot ${datadir}"
215RDEPENDS:${PN} += "${PN}-env"
270 216
271do_deploy () { 217do_deploy () {
272 if [ -n "${UBOOT_CONFIG}" ] 218 if [ -n "${UBOOT_CONFIG}" ]
@@ -277,12 +223,12 @@ do_deploy () {
277 j=$(expr $j + 1); 223 j=$(expr $j + 1);
278 if [ $j -eq $i ] 224 if [ $j -eq $i ]
279 then 225 then
280 install -D -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} 226 install -D -m 644 ${B}/${config}/${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/${UBOOT_BINARYNAME}-${type}-${PV}-${PR}.${UBOOT_SUFFIX}
281 cd ${DEPLOYDIR} 227 cd ${DEPLOYDIR}
282 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type} 228 ln -sf ${UBOOT_BINARYNAME}-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type}
283 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK} 229 ln -sf ${UBOOT_BINARYNAME}-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}
284 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type} 230 ln -sf ${UBOOT_BINARYNAME}-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type}
285 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY} 231 ln -sf ${UBOOT_BINARYNAME}-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}
286 232
287 # Deploy the uboot-initial-env 233 # Deploy the uboot-initial-env
288 if [ -n "${UBOOT_INITIAL_ENV}" ]; then 234 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
@@ -358,12 +304,12 @@ do_deploy () {
358 j=$(expr $j + 1); 304 j=$(expr $j + 1);
359 if [ $j -eq $i ] 305 if [ $j -eq $i ]
360 then 306 then
361 install -m 644 ${B}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}-${PV}-${PR} 307 install -m 644 ${B}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX}
362 rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}-${type} 308 rm -f ${DEPLOYDIR}/${SPL_BINARYFILE} ${DEPLOYDIR}/${SPL_SYMLINK}
363 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type} 309 ln -sf ${SPL_BINARYNAME}-${type}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX} ${DEPLOYDIR}/${SPL_BINARYFILE}-${type}
364 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME} 310 ln -sf ${SPL_BINARYNAME}-${type}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX} ${DEPLOYDIR}/${SPL_BINARYFILE}
365 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}-${type} 311 ln -sf ${SPL_BINARYNAME}-${type}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
366 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK} 312 ln -sf ${SPL_BINARYNAME}-${type}-${PV}-${PR}${SPL_DELIMITER}${SPL_SUFFIX} ${DEPLOYDIR}/${SPL_SYMLINK}
367 fi 313 fi
368 done 314 done
369 unset j 315 unset j
@@ -371,17 +317,14 @@ do_deploy () {
371 unset i 317 unset i
372 else 318 else
373 install -m 644 ${B}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE} 319 install -m 644 ${B}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}
374 rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}
375 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME} 320 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME}
376 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK} 321 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
377 fi 322 fi
378 fi 323 fi
379 324
380
381 if [ -n "${UBOOT_ENV}" ] 325 if [ -n "${UBOOT_ENV}" ]
382 then 326 then
383 install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE} 327 install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE}
384 rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
385 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY} 328 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY}
386 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK} 329 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
387 fi 330 fi
@@ -392,6 +335,11 @@ do_deploy () {
392 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE} 335 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE}
393 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME} 336 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}
394 fi 337 fi
338
339 if [ -n "${UBOOT_DTB}" ]
340 then
341 install -m 644 ${B}/arch/${UBOOT_ARCH_DIR}/dts/${UBOOT_DTB_BINARY} ${DEPLOYDIR}/
342 fi
395} 343}
396 344
397addtask deploy before do_build after do_compile 345addtask deploy before do_build after do_compile
diff --git a/meta/recipes-bsp/u-boot/u-boot_2021.01.bb b/meta/recipes-bsp/u-boot/u-boot_2021.01.bb
deleted file mode 100644
index 2eef1e900e..0000000000
--- a/meta/recipes-bsp/u-boot/u-boot_2021.01.bb
+++ /dev/null
@@ -1,4 +0,0 @@
1require u-boot-common.inc
2require u-boot.inc
3
4DEPENDS += "bc-native dtc-native python3-setuptools-native"
diff --git a/meta/recipes-bsp/u-boot/u-boot_2024.04.bb b/meta/recipes-bsp/u-boot/u-boot_2024.04.bb
new file mode 100644
index 0000000000..b15bcaa818
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/u-boot_2024.04.bb
@@ -0,0 +1,5 @@
1require u-boot-common.inc
2require u-boot.inc
3
4DEPENDS += "bc-native dtc-native python3-pyelftools-native"
5
diff --git a/meta/recipes-bsp/usbinit/usbinit.bb b/meta/recipes-bsp/usbinit/usbinit.bb
index ef98f0bf62..3a50b835c2 100644
--- a/meta/recipes-bsp/usbinit/usbinit.bb
+++ b/meta/recipes-bsp/usbinit/usbinit.bb
@@ -4,10 +4,9 @@ all sorts of nifty things like SSH and NFS in one go plus charging over the \
4same wire, at higher speeds than most Wifi connections." 4same wire, at higher speeds than most Wifi connections."
5HOMEPAGE = "http://linux-sunxi.org/USB_Gadget/Ethernet" 5HOMEPAGE = "http://linux-sunxi.org/USB_Gadget/Ethernet"
6 6
7LICENSE = "GPLv2" 7LICENSE = "GPL-2.0-only"
8LIC_FILES_CHKSUM = "file://${WORKDIR}/COPYING.GPL;md5=751419260aa954499f7abaabaa882bbe" 8LIC_FILES_CHKSUM = "file://${WORKDIR}/COPYING.GPL;md5=751419260aa954499f7abaabaa882bbe"
9 9
10PR = "r3"
11 10
12SRC_URI = "file://usb-gether \ 11SRC_URI = "file://usb-gether \
13 file://COPYING.GPL" 12 file://COPYING.GPL"
diff --git a/meta/recipes-bsp/usbutils/usbutils/0001-usbutils.pc.in-Fix-Cflags-entry.patch b/meta/recipes-bsp/usbutils/usbutils/0001-usbutils.pc.in-Fix-Cflags-entry.patch
new file mode 100644
index 0000000000..039dd5cd72
--- /dev/null
+++ b/meta/recipes-bsp/usbutils/usbutils/0001-usbutils.pc.in-Fix-Cflags-entry.patch
@@ -0,0 +1,34 @@
1From f558919e858453a31313a3df35906de2e036940c Mon Sep 17 00:00:00 2001
2From: Fabio Estevam <festevam@denx.de>
3Date: Thu, 4 Jan 2024 03:32:11 +0100
4Subject: [PATCH] usbutils.pc.in: Fix Cflags entry
5
6When updating the usbutils version in OpenEmbedded from 015 to 017,
7the following QA error is seen:
8
9QA Issue: File /usr/lib/pkgconfig/usbutils.pc in package usbutils-dev contains reference to TMPDIR [buildpaths]
10
11As this causes reproducibility problem due to the host PC path being
12leaked, it is treated as error.
13
14Fix it by using the standard Cflags entry.
15
16Upstream-Status: Submitted [https://github.com/gregkh/usbutils/pull/184/commits/3b3e5e1ebea7060bfa118d25a91b816dfa176b31]
17Signed-off-by: Fabio Estevam <festevam@denx.de>
18---
19 usbutils.pc.in | 2 +-
20 1 file changed, 1 insertion(+), 1 deletion(-)
21
22diff --git a/usbutils.pc.in b/usbutils.pc.in
23index e69778c3195c..0aa0005de951 100644
24--- a/usbutils.pc.in
25+++ b/usbutils.pc.in
26@@ -15,4 +15,4 @@ Requires: libusb-1.0 >= 1.0.14 libudev >= 196
27 Conflicts:
28 Libs: -L${libdir}
29 Libs.private: @LIBUSB_LIBS@ @UDEV_LIBS@
30-Cflags: @CFLAGS@ @LIBUSB_CFLAGS@ @UDEV_CFLAGS@
31+Cflags: -I${includedir}
32--
332.34.1
34
diff --git a/meta/recipes-bsp/usbutils/usbutils_013.bb b/meta/recipes-bsp/usbutils/usbutils_013.bb
deleted file mode 100644
index 51f909b795..0000000000
--- a/meta/recipes-bsp/usbutils/usbutils_013.bb
+++ /dev/null
@@ -1,30 +0,0 @@
1SUMMARY = "Host side USB console utilities"
2DESCRIPTION = "Contains the lsusb utility for inspecting the devices connected to the USB bus."
3HOMEPAGE = "http://www.linux-usb.org"
4SECTION = "base"
5
6LICENSE = "GPLv2+ & (GPLv2 | GPLv3)"
7# License files went missing in 010, when 011 is released add LICENSES/* back
8LIC_FILES_CHKSUM = "file://lsusb.c;endline=1;md5=7d4861d978ff5ba7cb2b319ed1d4afe3 \
9 file://lsusb.py.in;beginline=2;endline=2;md5=194d6a0226bf90f4f683e8968878b6cd"
10
11DEPENDS = "libusb1 virtual/libiconv udev"
12
13SRC_URI = "${KERNELORG_MIRROR}/linux/utils/usb/usbutils/usbutils-${PV}.tar.gz \
14 "
15SRC_URI[sha256sum] = "efdfd5403dbdd7412de6bb897d5fbaae65ef3eb4332032c0e1f216216618e9a9"
16
17inherit autotools pkgconfig update-alternatives
18
19ALTERNATIVE_${PN} = "lsusb"
20ALTERNATIVE_PRIORITY = "100"
21
22# The binaries are mostly GPLv2+ apart from lsusb.py which is GPLv2 or v3.
23LICENSE_${PN} = "GPLv2+"
24LICENSE_${PN}-python = "GPLv2 | GPLv3"
25
26RRECOMMENDS_${PN} = "udev-hwdb"
27
28PACKAGE_BEFORE_PN =+ "${PN}-python"
29FILES_${PN}-python += "${bindir}/lsusb.py"
30RDEPENDS_${PN}-python = "python3-core"
diff --git a/meta/recipes-bsp/usbutils/usbutils_017.bb b/meta/recipes-bsp/usbutils/usbutils_017.bb
new file mode 100644
index 0000000000..a2e340ea4f
--- /dev/null
+++ b/meta/recipes-bsp/usbutils/usbutils_017.bb
@@ -0,0 +1,33 @@
1SUMMARY = "Host side USB console utilities"
2DESCRIPTION = "Contains the lsusb utility for inspecting the devices connected to the USB bus."
3HOMEPAGE = "http://www.linux-usb.org"
4SECTION = "base"
5
6LICENSE = "GPL-2.0-or-later & (GPL-2.0-only | GPL-3.0-only)"
7# License files went missing in 010, when 011 is released add LICENSES/* back
8LIC_FILES_CHKSUM = "file://lsusb.c;endline=1;md5=7226e442a172bcf25807246d7ef1eba1 \
9 file://lsusb.py.in;beginline=2;endline=2;md5=c443ada211d701156e42ea36d41625b3 \
10 "
11
12DEPENDS = "libusb1 virtual/libiconv udev"
13
14SRC_URI = "${KERNELORG_MIRROR}/linux/utils/usb/usbutils/usbutils-${PV}.tar.gz \
15 file://0001-usbutils.pc.in-Fix-Cflags-entry.patch \
16 "
17SRC_URI[sha256sum] = "f704c4cb78a060db88b43aac6ebfd3d93c2c5cf1d6dd0e42936faaf00814ab00"
18
19inherit autotools pkgconfig update-alternatives
20
21ALTERNATIVE:${PN} = "lsusb"
22ALTERNATIVE_PRIORITY = "100"
23
24# The binaries are mostly GPL-2.0-or-later apart from lsusb.py which is
25# GPL-2.0-only or GPL-3.0-only.
26LICENSE:${PN} = "GPL-2.0-or-later"
27LICENSE:${PN}-python = "GPL-2.0-only | GPL-3.0-only"
28
29RRECOMMENDS:${PN} = "udev-hwdb"
30
31PACKAGE_BEFORE_PN =+ "${PN}-python"
32FILES:${PN}-python += "${bindir}/lsusb.py"
33RDEPENDS:${PN}-python = "python3-core"
diff --git a/meta/recipes-bsp/v86d/v86d_0.1.10.bb b/meta/recipes-bsp/v86d/v86d_0.1.10.bb
index e614de0c48..6151f0a7e2 100644
--- a/meta/recipes-bsp/v86d/v86d_0.1.10.bb
+++ b/meta/recipes-bsp/v86d/v86d_0.1.10.bb
@@ -3,12 +3,10 @@ HOMEPAGE = "https://tracker.debian.org/pkg/v86d"
3DESCRIPTION = "v86d provides a backend for kernel drivers that need to execute x86 BIOS code. The code is executed in a controlled environment and the results are passed back to the kernel via the netlink interface." 3DESCRIPTION = "v86d provides a backend for kernel drivers that need to execute x86 BIOS code. The code is executed in a controlled environment and the results are passed back to the kernel via the netlink interface."
4 4
5# the copyright info is at the bottom of README, expect break 5# the copyright info is at the bottom of README, expect break
6LICENSE = "GPLv2" 6LICENSE = "GPL-2.0-only"
7LIC_FILES_CHKSUM = "file://README;md5=94ac1971e4f2309dc322d598e7b1f7dd" 7LIC_FILES_CHKSUM = "file://README;md5=94ac1971e4f2309dc322d598e7b1f7dd"
8 8
9DEPENDS = "virtual/kernel" 9RRECOMMENDS:${PN} = "kernel-module-uvesafb"
10RRECOMMENDS_${PN} = "kernel-module-uvesafb"
11PR = "r2"
12 10
13SRC_URI = "http://snapshot.debian.org/archive/debian/20110427T035506Z/pool/main/v/${BPN}/${BPN}_${PV}.orig.tar.gz \ 11SRC_URI = "http://snapshot.debian.org/archive/debian/20110427T035506Z/pool/main/v/${BPN}/${BPN}_${PV}.orig.tar.gz \
14 file://Update-x86emu-from-X.org.patch \ 12 file://Update-x86emu-from-X.org.patch \