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.inc22
-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.bb30
-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/barebox/barebox-common.inc8
-rw-r--r--meta/recipes-bsp/barebox/barebox-tools.bb55
-rw-r--r--meta/recipes-bsp/barebox/barebox.bb10
-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)11
-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.bb31
-rwxr-xr-xmeta/recipes-bsp/formfactor/files/qemuppc64/machconfig10
-rwxr-xr-xmeta/recipes-bsp/formfactor/files/qemuriscv32/machconfig10
-rwxr-xr-xmeta/recipes-bsp/formfactor/files/qemuriscv64/machconfig10
-rw-r--r--meta/recipes-bsp/formfactor/formfactor_0.0.bb4
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi/0001-Do-not-treat-warnings-as-errors.patch29
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi/gnu-efi-3.0.9-fix-clang-build.patch24
-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/parallel-make-archives.patch38
-rw-r--r--meta/recipes-bsp/gnu-efi/gnu-efi_4.0.1.bb (renamed from meta/recipes-bsp/gnu-efi/gnu-efi_3.0.12.bb)56
-rw-r--r--meta/recipes-bsp/grub/files/0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch43
-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/0001-misc-Implement-grub_strlcpy.patch68
-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/CVE-2024-45774.patch37
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-45775.patch38
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-45776.patch39
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-45777.patch57
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-45778_CVE-2024-45779.patch55
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-45780.patch93
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-45781.patch35
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-45782_CVE-2024-56737.patch36
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-45783.patch39
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2025-0622-01.patch35
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2025-0622-02.patch41
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2025-0622-03.patch38
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2025-0624.patch84
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2025-0677_CVE-2025-0684_CVE-2025-0685_CVE-2025-0686_CVE-2025-0689.patch377
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2025-0678_CVE-2025-1125.patch87
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2025-0690.patch73
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2025-1118.patch37
-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.patch9
-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.bb8
-rw-r--r--meta/recipes-bsp/grub/grub-efi_2.12.bb (renamed from meta/recipes-bsp/grub/grub-efi_2.04.bb)39
-rw-r--r--meta/recipes-bsp/grub/grub2.inc77
-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.bb20
-rw-r--r--meta/recipes-bsp/libacpi/files/0001-libacpi-Fix-build-witth-fno-commom.patch2
-rw-r--r--meta/recipes-bsp/libacpi/files/ldflags.patch3
-rw-r--r--meta/recipes-bsp/libacpi/files/libacpi_fix_for_x32.patch2
-rw-r--r--meta/recipes-bsp/libacpi/files/makefile-fix.patch2
-rw-r--r--meta/recipes-bsp/libacpi/files/use_correct_strip_in_cross_environment.patch2
-rw-r--r--meta/recipes-bsp/libacpi/libacpi_0.2.bb4
-rw-r--r--meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-build-with-GCC-15.patch186
-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.bb20
-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.7.bb (renamed from meta/recipes-bsp/opensbi/opensbi_0.9.bb)35
-rw-r--r--meta/recipes-bsp/pciutils/pciutils/configure.patch81
-rw-r--r--meta/recipes-bsp/pciutils/pciutils_3.14.0.bb55
-rw-r--r--meta/recipes-bsp/pciutils/pciutils_3.7.0.bb59
-rw-r--r--meta/recipes-bsp/pm-utils/pm-utils_1.4.1.bb16
-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.bb10
-rw-r--r--meta/recipes-bsp/u-boot/files/disable-CONFIG_BLOBLIST.cfg1
-rw-r--r--meta/recipes-bsp/u-boot/files/disable_CONFIG_USB.cfg1
-rw-r--r--meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_a.cfg1
-rw-r--r--meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_c.cfg1
-rw-r--r--meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_clear.cfg6
-rw-r--r--meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_d.cfg1
-rw-r--r--meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_f.cfg1
-rw-r--r--meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zbb.cfg1
-rw-r--r--meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zicbom.cfg1
-rw-r--r--meta/recipes-bsp/u-boot/libubootenv/0001-Update-cmake_minimum_required-to-3.5.patch50
-rw-r--r--meta/recipes-bsp/u-boot/libubootenv_0.3.1.bb30
-rw-r--r--meta/recipes-bsp/u-boot/libubootenv_0.3.6.bb26
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-common.inc27
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-configure.inc52
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-tools.inc55
-rw-r--r--meta/recipes-bsp/u-boot/u-boot-tools_2025.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.inc410
-rw-r--r--meta/recipes-bsp/u-boot/u-boot_2021.01.bb4
-rw-r--r--meta/recipes-bsp/u-boot/u-boot_2025.04.bb8
-rw-r--r--meta/recipes-bsp/usbinit/usbinit.bb25
-rw-r--r--meta/recipes-bsp/usbinit/usbinit/COPYING.GPL339
-rwxr-xr-xmeta/recipes-bsp/usbinit/usbinit/usb-gether23
-rw-r--r--meta/recipes-bsp/usbutils/usbutils_013.bb30
-rw-r--r--meta/recipes-bsp/usbutils/usbutils_018.bb34
-rw-r--r--meta/recipes-bsp/v86d/v86d_0.1.10.bb7
121 files changed, 2535 insertions, 6583 deletions
diff --git a/meta/recipes-bsp/acpid/acpid.inc b/meta/recipes-bsp/acpid/acpid.inc
index 1e43e7a9db..ba954563b6 100644
--- a/meta/recipes-bsp/acpid/acpid.inc
+++ b/meta/recipes-bsp/acpid/acpid.inc
@@ -8,31 +8,33 @@ 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 \ 13SOURCEFORGE_PROJECT = "acpid2"
14SRC_URI = "${SOURCEFORGE_MIRROR}/${SOURCEFORGE_PROJECT}/acpid-${PV}.tar.xz \
14 file://init \ 15 file://init \
15 file://acpid.service \ 16 file://acpid.service \
16 " 17 file://0001-Replace-stat64-with-stat.patch \
18 "
17 19
18CVE_PRODUCT = "acpid2" 20CVE_PRODUCT = "acpid2"
19 21
20inherit autotools update-rc.d systemd 22inherit autotools update-rc.d systemd sourceforge-releases
21 23
22INITSCRIPT_NAME = "acpid" 24INITSCRIPT_NAME = "acpid"
23INITSCRIPT_PARAMS = "defaults" 25INITSCRIPT_PARAMS = "defaults"
24 26
25SYSTEMD_SERVICE_${PN} = "acpid.service" 27SYSTEMD_SERVICE:${PN} = "acpid.service"
26 28
27do_install_append () { 29do_install:append () {
28 install -d ${D}${sysconfdir}/init.d 30 install -d ${D}${sysconfdir}/init.d
29 sed -e 's,/usr/sbin,${sbindir},g' ${WORKDIR}/init > ${D}${sysconfdir}/init.d/acpid 31 sed -e 's,/usr/sbin,${sbindir},g' ${UNPACKDIR}/init > ${D}${sysconfdir}/init.d/acpid
30 chmod 755 ${D}${sysconfdir}/init.d/acpid 32 chmod 755 ${D}${sysconfdir}/init.d/acpid
31 33
32 install -d ${D}${sysconfdir}/acpi 34 install -d ${D}${sysconfdir}/acpi
33 install -d ${D}${sysconfdir}/acpi/events 35 install -d ${D}${sysconfdir}/acpi/events
34 36
35 install -d ${D}${systemd_unitdir}/system 37 install -d ${D}${systemd_system_unitdir}
36 install -m 0644 ${WORKDIR}/acpid.service ${D}${systemd_unitdir}/system 38 install -m 0644 ${UNPACKDIR}/acpid.service ${D}${systemd_system_unitdir}
37 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/acpid.service 39 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_system_unitdir}/acpid.service
38} 40}
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..9452a1a4ce 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 \
@@ -19,7 +21,7 @@ SRC_URI = "\
19 file://alsa-state-init \ 21 file://alsa-state-init \
20" 22"
21 23
22S = "${WORKDIR}" 24S = "${UNPACKDIR}"
23 25
24# As the recipe doesn't inherit systemd.bbclass, we need to set this variable 26# As the recipe doesn't inherit systemd.bbclass, we need to set this variable
25# manually to avoid unnecessary postinst/preinst generated. 27# manually to avoid unnecessary postinst/preinst generated.
@@ -36,28 +38,28 @@ INITSCRIPT_PARAMS = "start 39 S . stop 31 0 6 ."
36do_install() { 38do_install() {
37 # Only install the init script when 'sysvinit' is in DISTRO_FEATURES. 39 # Only install the init script when 'sysvinit' is in DISTRO_FEATURES.
38 if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then 40 if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
39 sed -i -e "s:#STATEDIR#:${localstatedir}/lib/alsa:g" ${WORKDIR}/alsa-state-init 41 sed -i -e "s:#STATEDIR#:${localstatedir}/lib/alsa:g" ${S}/alsa-state-init
40 install -d ${D}${sysconfdir}/init.d 42 install -d ${D}${sysconfdir}/init.d
41 install -m 0755 ${WORKDIR}/alsa-state-init ${D}${sysconfdir}/init.d/alsa-state 43 install -m 0755 ${S}/alsa-state-init ${D}${sysconfdir}/init.d/alsa-state
42 fi 44 fi
43 45
44 install -d ${D}/${localstatedir}/lib/alsa 46 install -d ${D}/${localstatedir}/lib/alsa
45 install -d ${D}${sysconfdir} 47 install -d ${D}${sysconfdir}
46 install -m 0644 ${WORKDIR}/asound.conf ${D}${sysconfdir} 48 install -m 0644 ${S}/asound.conf ${D}${sysconfdir}
47 install -m 0644 ${WORKDIR}/*.state ${D}${localstatedir}/lib/alsa 49 install -m 0644 ${S}/*.state ${D}${localstatedir}/lib/alsa
48} 50}
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/barebox/barebox-common.inc b/meta/recipes-bsp/barebox/barebox-common.inc
new file mode 100644
index 0000000000..67bc964188
--- /dev/null
+++ b/meta/recipes-bsp/barebox/barebox-common.inc
@@ -0,0 +1,8 @@
1HOMEPAGE = "https://barebox.org/"
2SECTION = "bootloaders"
3
4LIC_FILES_CHKSUM = "file://COPYING;md5=f5125d13e000b9ca1f0d3364286c4192"
5
6PV = "2025.06.0"
7SRC_URI = "https://barebox.org/download/barebox-${PV}.tar.bz2"
8SRC_URI[sha256sum] = "d05bc1f85dc1d95b0b6b6a52cac0a469148fbb8f1edb0d352c3ca3b632426941"
diff --git a/meta/recipes-bsp/barebox/barebox-tools.bb b/meta/recipes-bsp/barebox/barebox-tools.bb
new file mode 100644
index 0000000000..e519796c1d
--- /dev/null
+++ b/meta/recipes-bsp/barebox/barebox-tools.bb
@@ -0,0 +1,55 @@
1SUMMARY = "barebox bootloader tools"
2
3require barebox-common.inc
4
5LICENSE = "GPL-2.0-only"
6
7DEPENDS = "bison-native flex-native libusb1"
8
9S = "${UNPACKDIR}/barebox-${PV}"
10B = "${WORKDIR}/build"
11
12inherit pkgconfig
13
14EXTRA_OEMAKE = " \
15 ARCH=sandbox \
16 CROSS_COMPILE=${TARGET_PREFIX} -C ${S} O=${B} \
17 CROSS_PKG_CONFIG=pkg-config \
18 CC='${CC}' \
19 LD='${LD}' \
20 "
21
22do_compile:class-target () {
23 export userccflags="${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
24 export userldflags="${TARGET_LDFLAGS}${TOOLCHAIN_OPTIONS}"
25 oe_runmake targettools_defconfig
26 oe_runmake scripts
27}
28
29do_compile:class-native () {
30 oe_runmake hosttools_defconfig
31 oe_runmake scripts
32}
33
34BAREBOX_TOOLS = " \
35 bareboxenv \
36 bareboxcrc32 \
37 kernel-install \
38 bareboximd \
39 omap3-usb-loader \
40 omap4_usbboot \
41 imx/imx-usb-loader \
42 "
43
44BAREBOX_TOOLS_SUFFIX = ""
45BAREBOX_TOOLS_SUFFIX:class-target = "-target"
46
47do_install () {
48 install -d ${D}${bindir}
49
50 for tool in ${BAREBOX_TOOLS}; do
51 install -m 0755 scripts/${tool}${BAREBOX_TOOLS_SUFFIX} ${D}${bindir}/${tool##*/}
52 done
53}
54
55BBCLASSEXTEND = "native nativesdk"
diff --git a/meta/recipes-bsp/barebox/barebox.bb b/meta/recipes-bsp/barebox/barebox.bb
new file mode 100644
index 0000000000..a48d97941c
--- /dev/null
+++ b/meta/recipes-bsp/barebox/barebox.bb
@@ -0,0 +1,10 @@
1SUMMARY = "barebox is a bootloader designed for embedded systems. It runs on a variety of architectures including x86, ARM, MIPS, PowerPC and others."
2DESCRIPTION = "barebox aims to be a versatile and flexible bootloader not only for booting embedded Linux systems, \
3but also for initial hardware bringup and development. \
4Users should feel right at home with a shell with UNIX-like virtual file system access to hardware, \
5Linux kernel driver API for making driver porting easier, \
6and a subset of the POSIX C library for writing more command-line utilities."
7
8require barebox-common.inc
9inherit barebox
10
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..6f4178216b 100644
--- a/meta/recipes-bsp/efibootmgr/efibootmgr_17.bb
+++ b/meta/recipes-bsp/efibootmgr/efibootmgr_18.bb
@@ -3,20 +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
19S = "${WORKDIR}/git"
20 15
21inherit pkgconfig 16inherit pkgconfig
22 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..fb6b6b3821
--- /dev/null
+++ b/meta/recipes-bsp/efivar/efivar_39.bb
@@ -0,0 +1,31 @@
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|riscv64).*-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"
14
15inherit pkgconfig
16
17export CCLD_FOR_BUILD = "${BUILD_CCLD}"
18
19do_compile() {
20 oe_runmake ERRORS= HOST_CFLAGS="${BUILD_CFLAGS}" HOST_LDFLAGS="${BUILD_LDFLAGS}"
21}
22
23do_install() {
24 oe_runmake install DESTDIR=${D}
25}
26
27BBCLASSEXTEND = "native"
28
29RRECOMMENDS:${PN}:class-target = "kernel-module-efivarfs"
30
31CLEANBROKEN = "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/files/qemuriscv32/machconfig b/meta/recipes-bsp/formfactor/files/qemuriscv32/machconfig
new file mode 100755
index 0000000000..2789b5fc2a
--- /dev/null
+++ b/meta/recipes-bsp/formfactor/files/qemuriscv32/machconfig
@@ -0,0 +1,10 @@
1HAVE_TOUCHSCREEN=1
2HAVE_KEYBOARD=1
3
4DISPLAY_CAN_ROTATE=0
5DISPLAY_ORIENTATION=0
6DISPLAY_WIDTH_PIXELS=640
7DISPLAY_HEIGHT_PIXELS=480
8DISPLAY_BPP=16
9DISPLAY_DPI=150
10DISPLAY_SUBPIXEL_ORDER=vrgb
diff --git a/meta/recipes-bsp/formfactor/files/qemuriscv64/machconfig b/meta/recipes-bsp/formfactor/files/qemuriscv64/machconfig
new file mode 100755
index 0000000000..2789b5fc2a
--- /dev/null
+++ b/meta/recipes-bsp/formfactor/files/qemuriscv64/machconfig
@@ -0,0 +1,10 @@
1HAVE_TOUCHSCREEN=1
2HAVE_KEYBOARD=1
3
4DISPLAY_CAN_ROTATE=0
5DISPLAY_ORIENTATION=0
6DISPLAY_WIDTH_PIXELS=640
7DISPLAY_HEIGHT_PIXELS=480
8DISPLAY_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..f8d5613ffa 100644
--- a/meta/recipes-bsp/formfactor/formfactor_0.0.bb
+++ b/meta/recipes-bsp/formfactor/formfactor_0.0.bb
@@ -5,10 +5,10 @@ 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}" 10
11S = "${UNPACKDIR}"
12 12
13PACKAGE_ARCH = "${MACHINE_ARCH}" 13PACKAGE_ARCH = "${MACHINE_ARCH}"
14INHIBIT_DEFAULT_DEPS = "1" 14INHIBIT_DEFAULT_DEPS = "1"
diff --git a/meta/recipes-bsp/gnu-efi/gnu-efi/0001-Do-not-treat-warnings-as-errors.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/0001-Do-not-treat-warnings-as-errors.patch
new file mode 100644
index 0000000000..0c10e66a12
--- /dev/null
+++ b/meta/recipes-bsp/gnu-efi/gnu-efi/0001-Do-not-treat-warnings-as-errors.patch
@@ -0,0 +1,29 @@
1From 80e17bcdf45dcf40b8f356cf68389612407b9f7b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 16 May 2024 21:38:32 +0800
4Subject: [PATCH] Do not treat warnings as errors
5
6There are additional warnings found with musl which are
7treated as errors and fails the build, we have more combinations
8then upstream supports to handle
9
10Upstream-Status: Inappropriate [OE specific]
11
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 Make.defaults | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/Make.defaults b/Make.defaults
18index 6d3cf51..23b9383 100755
19--- a/Make.defaults
20+++ b/Make.defaults
21@@ -267,7 +267,7 @@ CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
22 -fno-strict-aliasing \
23 -ffreestanding -fno-stack-protector
24 else
25-CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
26+CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra \
27 -fno-strict-aliasing \
28 -ffreestanding -fno-stack-protector \
29 $(if $(findstring 0,$(USING_CLANG)),-fno-merge-all-constants,)
diff --git a/meta/recipes-bsp/gnu-efi/gnu-efi/gnu-efi-3.0.9-fix-clang-build.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/gnu-efi-3.0.9-fix-clang-build.patch
deleted file mode 100644
index c6d660095e..0000000000
--- a/meta/recipes-bsp/gnu-efi/gnu-efi/gnu-efi-3.0.9-fix-clang-build.patch
+++ /dev/null
@@ -1,24 +0,0 @@
1Fix building with CLANG-9.0.0
2
3Fixes
4clang-9: error: unknown argument: '-maccumulate-outgoing-args'
5
6Upstream-Status: Submitted [https://sourceforge.net/p/gnu-efi/patches/70/]
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8
9--- a/Make.defaults
10+++ b/Make.defaults
11@@ -110,10 +110,10 @@
12 || ( [ $(GCCVERSION) -eq "4" ] \
13 && [ $(GCCMINOR) -ge "7" ] ) ) \
14 && echo 1)
15- ifeq ($(GCCNEWENOUGH),1)
16- CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11
17- else ifeq ($(USING_CLANG),clang)
18+ ifeq ($(USING_CLANG),clang)
19 CPPFLAGS += -DGNU_EFI_USE_MS_ABI --std=c11
20+ else ifeq ($(GCCNEWENOUGH),1)
21+ CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11
22 endif
23
24 CFLAGS += -mno-red-zone
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/parallel-make-archives.patch b/meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch
deleted file mode 100644
index 8a0138bbe5..0000000000
--- a/meta/recipes-bsp/gnu-efi/gnu-efi/parallel-make-archives.patch
+++ /dev/null
@@ -1,38 +0,0 @@
1From 48b2cdbcd761105e8ebad412fcbf23db1ac4ef7c Mon Sep 17 00:00:00 2001
2From: Saul Wold <sgw@linux.intel.com>
3Date: Sun, 9 Mar 2014 15:22:15 +0200
4Subject: [PATCH 1/3] Fix parallel make failure for archives
5
6Upstream-Status: Pending
7
8The lib and gnuefi makefiles were using the lib.a() form which compiles
9and ar's as a pair instead of compiling all and then ar'ing which can
10parallelize better. This was resulting in build failures on larger values
11of -j.
12
13See http://www.chemie.fu-berlin.de/chemnet/use/info/make/make_toc.html#TOC105
14for details.
15
16Signed-off-by: Saul Wold <sgw@linux.intel.com>
17Signed-off-by: Darren Hart <dvhart@linux.intel.com>
18[Rebased for 3.0.6]
19Signed-off-by: California Sullivan <california.l.sullivan@intel.com>
20[Rebased for 3.0.8]
21Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
22
23diff --git a/lib/Makefile b/lib/Makefile
24index 0e6410d..048751a 100644
25--- a/lib/Makefile
26+++ b/lib/Makefile
27@@ -75,7 +75,7 @@ libsubdirs:
28 for sdir in $(SUBDIRS); do mkdir -p $$sdir; done
29
30 libefi.a: $(OBJS)
31- $(AR) $(ARFLAGS) $@ $^
32+ $(AR) $(ARFLAGS) $@ $(OBJS)
33
34 clean:
35 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_4.0.1.bb
index d27126603f..10a4ab6800 100644
--- a/meta/recipes-bsp/gnu-efi/gnu-efi_3.0.12.bb
+++ b/meta/recipes-bsp/gnu-efi/gnu-efi_4.0.1.bb
@@ -2,30 +2,31 @@ 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=8b0a86085b86eda7a3c7e8a1eb7ec753 \
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=8b0a86085b86eda7a3c7e8a1eb7ec753 \
8 file://inc/efishellintf.h;beginline=13;endline=20;md5=202766b79d708eff3cc70fce15fb80c7 \ 8 file://inc/efishellintf.h;beginline=13;endline=20;md5=ee14c1530c341a7050837adead6bc9a5 \
9 file://inc/efishellparm.h;beginline=4;endline=11;md5=468b1231b05bbc84bae3a0d5774e3bb5 \ 9 file://lib/arm/math.c;beginline=2;endline=15;md5=ccb5c6b51053d1ee7277539ec38513d7 \
10 file://lib/arm/math.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \ 10 file://lib/arm/initplat.c;beginline=2;endline=15;md5=ccb5c6b51053d1ee7277539ec38513d7 \
11 file://lib/arm/initplat.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \ 11 file://lib/aarch64/math.c;beginline=2;endline=15;md5=ccb5c6b51053d1ee7277539ec38513d7 \
12 file://lib/aarch64/math.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \ 12 file://lib/aarch64/initplat.c;beginline=2;endline=15;md5=ccb5c6b51053d1ee7277539ec38513d7 \
13 file://lib/aarch64/initplat.c;beginline=2;endline=15;md5=8ed772501da77b2b3345aa6df8744c9e \
14 " 13 "
15 14
16SRC_URI = "${SOURCEFORGE_MIRROR}/${BPN}/files/${BP}.tar.bz2 \ 15COMPATIBLE_HOST = "(x86_64.*|i.86.*|aarch64.*|arm.*|riscv64.*)-linux"
17 file://parallel-make-archives.patch \ 16COMPATIBLE_HOST:armv4 = 'null'
18 file://lib-Makefile-fix-parallel-issue.patch \ 17
19 file://gnu-efi-3.0.9-fix-clang-build.patch \ 18SRC_URI = "git://github.com/ncroxon/gnu-efi;protocol=https;branch=master \
19 file://0001-Do-not-treat-warnings-as-errors.patch \
20 " 20 "
21SRCREV = "00cdfa66e923ab2f6683bb52cab0d0d1a9083b16"
21 22
22SRC_URI[md5sum] = "926763ff37bc9db3a9035cec41eb2f45" 23# llvm-objcopy fails
23SRC_URI[sha256sum] = "0196f2e1fd3c334b66e610a608a0e59233474c7a01bec7bc53989639aa327669" 24# arm-poky-linux-gnueabi-llvm-objcopy: error: 't8.so': section '.dynstr' cannot be removed because it is referenced by the section '.dynamic'
25OBJCOPY:toolchain-clang = "${HOST_PREFIX}objcopy"
24 26
25COMPATIBLE_HOST = "(x86_64.*|i.86.*|aarch64.*|arm.*)-linux" 27inherit github-releases
26COMPATIBLE_HOST_armv4 = 'null'
27 28
28do_configure_linux-gnux32_prepend() { 29do_configure:linux-gnux32:prepend() {
29 cp ${STAGING_INCDIR}/gnu/stubs-x32.h ${STAGING_INCDIR}/gnu/stubs-64.h 30 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 31 cp ${STAGING_INCDIR}/bits/long-double-32.h ${STAGING_INCDIR}/bits/long-double-64.h
31} 32}
@@ -37,8 +38,15 @@ def gnu_efi_arch(d):
37 return "ia32" 38 return "ia32"
38 return tarch 39 return tarch
39 40
40EXTRA_OEMAKE = "'ARCH=${@gnu_efi_arch(d)}' 'CC=${CC}' 'AS=${AS}' 'LD=${LD}' 'AR=${AR}' \ 41do_compile:prepend() {
41 'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}' 'PREFIX=${prefix}' 'LIBDIR=${libdir}' \ 42 unset LDFLAGS
43}
44
45EXTRA_OEMAKE = "'V=1' 'ARCH=${@gnu_efi_arch(d)}' \
46 'HOSTCC=${BUILD_CC}' 'CC=${CC}' \
47 'AS=${AS}' 'LD=${LD}' 'AR=${AR}' \
48 'RANLIB=${RANLIB}' 'OBJCOPY=${OBJCOPY}' \
49 'PREFIX=${prefix}' 'LIBDIR=${libdir}' 'INCLUDEDIR=${includedir}' \
42 " 50 "
43 51
44# gnu-efi's Makefile treats prefix as toolchain prefix, so don't 52# gnu-efi's Makefile treats prefix as toolchain prefix, so don't
@@ -49,18 +57,18 @@ do_install() {
49 oe_runmake install INSTALLROOT="${D}" 57 oe_runmake install INSTALLROOT="${D}"
50} 58}
51 59
52FILES_${PN} += "${libdir}/*.lds" 60FILES:${PN} += "${libdir}/*.lds ${libdir}/gnuefi/apps"
53 61
54# 64-bit binaries are expected for EFI when targeting X32 62# 64-bit binaries are expected for EFI when targeting X32
55INSANE_SKIP_${PN}-dev_append_linux-gnux32 = " arch" 63INSANE_SKIP:${PN}-dev:append:linux-gnux32 = " arch"
56INSANE_SKIP_${PN}-dev_append_linux-muslx32 = " arch" 64INSANE_SKIP:${PN}-dev:append:linux-muslx32 = " arch"
57 65
58BBCLASSEXTEND = "native" 66BBCLASSEXTEND = "native"
59 67
60# It doesn't support sse, its make.defaults sets: 68# It doesn't support sse, its make.defaults sets:
61# CFLAGS += -mno-mmx -mno-sse 69# CFLAGS += -mno-mmx -mno-sse
62# So also remove -mfpmath=sse from TUNE_CCARGS 70# So also remove -mfpmath=sse from TUNE_CCARGS
63TUNE_CCARGS_remove = "-mfpmath=sse" 71TUNE_CCARGS:remove = "-mfpmath=sse"
64 72
65python () { 73python () {
66 ccargs = d.getVar('TUNE_CCARGS').split() 74 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
deleted file mode 100644
index 6b73878cc0..0000000000
--- a/meta/recipes-bsp/grub/files/0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch
+++ /dev/null
@@ -1,43 +0,0 @@
1From 96d9aa55d29b24e2490d5647a9efc66940fc400f Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 13 Jan 2016 19:17:31 +0000
4Subject: [PATCH] Disable -mfpmath=sse as well when SSE is disabled
5
6Fixes
7
8configure:20574: i586-poky-linux-gcc -m32 -march=core2 -msse3
9-mtune=generic -mfpmath=sse
10--sysroot=/usr/local/dev/yocto/grubtest2/build/tmp/sysroots/emenlow -o
11conftest -O2 -pipe -g -feliminate-unused-debug-types -Wall -W -Wshadow
12-Wpointer-arith -Wmissing-prototypes -Wundef -Wstrict-prototypes -g
13-falign-jumps=1 -falign-loops=1 -falign-functions=1 -mno-mmx -mno-sse
14-mno-sse2 -mno-3dnow -fno-dwarf2-cfi-asm -m32 -fno-stack-protector
15-mno-stack-arg-probe -Werror -nostdlib -Wl,--defsym,___main=0x8100
16-Wall -W -I$(top_srcdir)/include -I$(top_builddir)/include
17-DGRUB_MACHINE_PCBIOS=1 -DGRUB_MACHINE=I386_PC -Wl,-O1
18-Wl,--hash-style=gnu -Wl,--as-needed conftest.c >&5
19conftest.c:1:0: error: SSE instruction set disabled, using 387
20arithmetics [-Werror]
21cc1: all warnings being treated as errors
22
23Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
24Signed-off-by: Khem Raj <raj.khem@gmail.com>
25
26Upstream-Status: Pending
27---
28 configure.ac | 2 +-
29 1 file changed, 1 insertion(+), 1 deletion(-)
30
31diff --git a/configure.ac b/configure.ac
32index 7656f24..0868ea9 100644
33--- a/configure.ac
34+++ b/configure.ac
35@@ -824,7 +824,7 @@ fi
36 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 # registers that aren't set up properly in GRUB.
39- TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow"
40+ TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow -mfpmath=387"
41 fi
42
43 # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
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/0001-misc-Implement-grub_strlcpy.patch b/meta/recipes-bsp/grub/files/0001-misc-Implement-grub_strlcpy.patch
new file mode 100644
index 0000000000..0ff6dff33a
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/0001-misc-Implement-grub_strlcpy.patch
@@ -0,0 +1,68 @@
1From ea703528a8581a2ea7e0bad424a70fdf0aec7d8f Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Sat, 15 Jun 2024 02:33:08 +0100
4Subject: [PATCH 1/2] misc: Implement grub_strlcpy()
5
6grub_strlcpy() acts the same way as strlcpy() does on most *NIX,
7returning the length of src and ensuring dest is always NUL
8terminated except when size is 0.
9
10Signed-off-by: B Horn <b@horn.uk>
11Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
12
13Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=ea703528a8581a2ea7e0bad424a70fdf0aec7d8f]
14Signed-off-by: Peter Marko <peter.marko@siemens.com>
15---
16 include/grub/misc.h | 39 +++++++++++++++++++++++++++++++++++++++
17 1 file changed, 39 insertions(+)
18
19diff --git a/include/grub/misc.h b/include/grub/misc.h
20index 1578f36c3..14d8f37ac 100644
21--- a/include/grub/misc.h
22+++ b/include/grub/misc.h
23@@ -64,6 +64,45 @@ grub_stpcpy (char *dest, const char *src)
24 return d - 1;
25 }
26
27+static inline grub_size_t
28+grub_strlcpy (char *dest, const char *src, grub_size_t size)
29+{
30+ char *d = dest;
31+ grub_size_t res = 0;
32+ /*
33+ * We do not subtract one from size here to avoid dealing with underflowing
34+ * the value, which is why to_copy is always checked to be greater than one
35+ * throughout this function.
36+ */
37+ grub_size_t to_copy = size;
38+
39+ /* Copy size - 1 bytes to dest. */
40+ if (to_copy > 1)
41+ while ((*d++ = *src++) != '\0' && ++res && --to_copy > 1)
42+ ;
43+
44+ /*
45+ * NUL terminate if size != 0. The previous step may have copied a NUL byte
46+ * if it reached the end of the string, but we know dest[size - 1] must always
47+ * be a NUL byte.
48+ */
49+ if (size != 0)
50+ dest[size - 1] = '\0';
51+
52+ /* If there is still space in dest, but are here, we reached the end of src. */
53+ if (to_copy > 1)
54+ return res;
55+
56+ /*
57+ * If we haven't reached the end of the string, iterate through to determine
58+ * the strings total length.
59+ */
60+ while (*src++ != '\0' && ++res)
61+ ;
62+
63+ return res;
64+}
65+
66 /* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
67 static inline void *
68 grub_memcpy (void *dest, const void *src, grub_size_t n)
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/CVE-2024-45774.patch b/meta/recipes-bsp/grub/files/CVE-2024-45774.patch
new file mode 100644
index 0000000000..55aecc17d7
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45774.patch
@@ -0,0 +1,37 @@
1From 2c34af908ebf4856051ed29e46d88abd2b20387f Mon Sep 17 00:00:00 2001
2From: Daniel Axtens <dja@axtens.net>
3Date: Fri, 8 Mar 2024 22:47:20 +1100
4Subject: [PATCH] video/readers/jpeg: Do not permit duplicate SOF0 markers in
5 JPEG
6
7Otherwise a subsequent header could change the height and width
8allowing future OOB writes.
9
10Fixes: CVE-2024-45774
11
12Reported-by: Nils Langius <nils@langius.de>
13Signed-off-by: Daniel Axtens <dja@axtens.net>
14Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
15
16CVE: CVE-2024-45774
17Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=2c34af908ebf4856051ed29e46d88abd2b20387f]
18Signed-off-by: Peter Marko <peter.marko@siemens.com>
19---
20 grub-core/video/readers/jpeg.c | 4 ++++
21 1 file changed, 4 insertions(+)
22
23diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
24index ae634fd41..631a89356 100644
25--- a/grub-core/video/readers/jpeg.c
26+++ b/grub-core/video/readers/jpeg.c
27@@ -339,6 +339,10 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data)
28 if (grub_errno != GRUB_ERR_NONE)
29 return grub_errno;
30
31+ if (data->image_height != 0 || data->image_width != 0)
32+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
33+ "jpeg: cannot have duplicate SOF0 markers");
34+
35 if (grub_jpeg_get_byte (data) != 8)
36 return grub_error (GRUB_ERR_BAD_FILE_TYPE,
37 "jpeg: only 8-bit precision is supported");
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-45775.patch b/meta/recipes-bsp/grub/files/CVE-2024-45775.patch
new file mode 100644
index 0000000000..70492b8c2e
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45775.patch
@@ -0,0 +1,38 @@
1From 05be856a8c3aae41f5df90cab7796ab7ee34b872 Mon Sep 17 00:00:00 2001
2From: Lidong Chen <lidong.chen@oracle.com>
3Date: Fri, 22 Nov 2024 06:27:55 +0000
4Subject: [PATCH] commands/extcmd: Missing check for failed allocation
5
6The grub_extcmd_dispatcher() calls grub_arg_list_alloc() to allocate
7a grub_arg_list struct but it does not verify the allocation was successful.
8In case of failed allocation the NULL state pointer can be accessed in
9parse_option() through grub_arg_parse() which may lead to a security issue.
10
11Fixes: CVE-2024-45775
12
13Reported-by: Nils Langius <nils@langius.de>
14Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
15Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
16Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
17
18CVE: CVE-2024-45775
19Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=05be856a8c3aae41f5df90cab7796ab7ee34b872]
20Signed-off-by: Peter Marko <peter.marko@siemens.com>
21---
22 grub-core/commands/extcmd.c | 3 +++
23 1 file changed, 3 insertions(+)
24
25diff --git a/grub-core/commands/extcmd.c b/grub-core/commands/extcmd.c
26index 90a5ca24a..c236be13a 100644
27--- a/grub-core/commands/extcmd.c
28+++ b/grub-core/commands/extcmd.c
29@@ -49,6 +49,9 @@ grub_extcmd_dispatcher (struct grub_command *cmd, int argc, char **args,
30 }
31
32 state = grub_arg_list_alloc (ext, argc, args);
33+ if (state == NULL)
34+ return grub_errno;
35+
36 if (grub_arg_parse (ext, argc, args, state, &new_args, &new_argc))
37 {
38 context.state = state;
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-45776.patch b/meta/recipes-bsp/grub/files/CVE-2024-45776.patch
new file mode 100644
index 0000000000..8deea958b8
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45776.patch
@@ -0,0 +1,39 @@
1From 09bd6eb58b0f71ec273916070fa1e2de16897a91 Mon Sep 17 00:00:00 2001
2From: Lidong Chen <lidong.chen@oracle.com>
3Date: Fri, 22 Nov 2024 06:27:56 +0000
4Subject: [PATCH] gettext: Integer overflow leads to heap OOB write or read
5
6Calculation of ctx->grub_gettext_msg_list size in grub_mofile_open() may
7overflow leading to subsequent OOB write or read. This patch fixes the
8issue by replacing grub_zalloc() and explicit multiplication with
9grub_calloc() which does the same thing in safe manner.
10
11Fixes: CVE-2024-45776
12
13Reported-by: Nils Langius <nils@langius.de>
14Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
15Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
16Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
17
18CVE: CVE-2024-45776
19Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=09bd6eb58b0f71ec273916070fa1e2de16897a91]
20Signed-off-by: Peter Marko <peter.marko@siemens.com>
21---
22 grub-core/gettext/gettext.c | 4 ++--
23 1 file changed, 2 insertions(+), 2 deletions(-)
24
25diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c
26index e4f4f8ee6..63bb1ab73 100644
27--- a/grub-core/gettext/gettext.c
28+++ b/grub-core/gettext/gettext.c
29@@ -323,8 +323,8 @@ grub_mofile_open (struct grub_gettext_context *ctx,
30 for (ctx->grub_gettext_max_log = 0; ctx->grub_gettext_max >> ctx->grub_gettext_max_log;
31 ctx->grub_gettext_max_log++);
32
33- ctx->grub_gettext_msg_list = grub_zalloc (ctx->grub_gettext_max
34- * sizeof (ctx->grub_gettext_msg_list[0]));
35+ ctx->grub_gettext_msg_list = grub_calloc (ctx->grub_gettext_max,
36+ sizeof (ctx->grub_gettext_msg_list[0]));
37 if (!ctx->grub_gettext_msg_list)
38 {
39 grub_file_close (fd);
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-45777.patch b/meta/recipes-bsp/grub/files/CVE-2024-45777.patch
new file mode 100644
index 0000000000..0305a95fd5
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45777.patch
@@ -0,0 +1,57 @@
1From b970a5ed967816bbca8225994cd0ee2557bad515 Mon Sep 17 00:00:00 2001
2From: Lidong Chen <lidong.chen@oracle.com>
3Date: Fri, 22 Nov 2024 06:27:57 +0000
4Subject: [PATCH] gettext: Integer overflow leads to heap OOB write
5
6The size calculation of the translation buffer in
7grub_gettext_getstr_from_position() may overflow
8to 0 leading to heap OOB write. This patch fixes
9the issue by using grub_add() and checking for
10an overflow.
11
12Fixes: CVE-2024-45777
13
14Reported-by: Nils Langius <nils@langius.de>
15Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
16Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
18
19CVE: CVE-2024-45777
20Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=b970a5ed967816bbca8225994cd0ee2557bad515]
21Signed-off-by: Peter Marko <peter.marko@siemens.com>
22---
23 grub-core/gettext/gettext.c | 7 ++++++-
24 1 file changed, 6 insertions(+), 1 deletion(-)
25
26diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c
27index 63bb1ab73..9ffc73428 100644
28--- a/grub-core/gettext/gettext.c
29+++ b/grub-core/gettext/gettext.c
30@@ -26,6 +26,7 @@
31 #include <grub/file.h>
32 #include <grub/kernel.h>
33 #include <grub/i18n.h>
34+#include <grub/safemath.h>
35
36 GRUB_MOD_LICENSE ("GPLv3+");
37
38@@ -99,6 +100,7 @@ grub_gettext_getstr_from_position (struct grub_gettext_context *ctx,
39 char *translation;
40 struct string_descriptor desc;
41 grub_err_t err;
42+ grub_size_t alloc_sz;
43
44 internal_position = (off + position * sizeof (desc));
45
46@@ -109,7 +111,10 @@ grub_gettext_getstr_from_position (struct grub_gettext_context *ctx,
47 length = grub_cpu_to_le32 (desc.length);
48 offset = grub_cpu_to_le32 (desc.offset);
49
50- translation = grub_malloc (length + 1);
51+ if (grub_add (length, 1, &alloc_sz))
52+ return NULL;
53+
54+ translation = grub_malloc (alloc_sz);
55 if (!translation)
56 return NULL;
57
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-45778_CVE-2024-45779.patch b/meta/recipes-bsp/grub/files/CVE-2024-45778_CVE-2024-45779.patch
new file mode 100644
index 0000000000..eba013897f
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45778_CVE-2024-45779.patch
@@ -0,0 +1,55 @@
1From 26db6605036bd9e5b16d9068a8cc75be63b8b630 Mon Sep 17 00:00:00 2001
2From: Daniel Axtens <dja@axtens.net>
3Date: Sat, 23 Mar 2024 15:59:43 +1100
4Subject: [PATCH] fs/bfs: Disable under lockdown
5
6The BFS is not fuzz-clean. Don't allow it to be loaded under lockdown.
7This will also disable the AFS.
8
9Fixes: CVE-2024-45778
10Fixes: CVE-2024-45779
11
12Reported-by: Nils Langius <nils@langius.de>
13Signed-off-by: Daniel Axtens <dja@axtens.net>
14Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
15
16CVE: CVE-2024-45778
17CVE: CVE-2024-45779
18Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=]
19Signed-off-by: Peter Marko <peter.marko@siemens.com>
20---
21 grub-core/fs/bfs.c | 9 +++++++--
22 1 file changed, 7 insertions(+), 2 deletions(-)
23
24diff --git a/grub-core/fs/bfs.c b/grub-core/fs/bfs.c
25index 022f69fe2..78aeb051f 100644
26--- a/grub-core/fs/bfs.c
27+++ b/grub-core/fs/bfs.c
28@@ -30,6 +30,7 @@
29 #include <grub/types.h>
30 #include <grub/i18n.h>
31 #include <grub/fshelp.h>
32+#include <grub/lockdown.h>
33
34 GRUB_MOD_LICENSE ("GPLv3+");
35
36@@ -1106,7 +1107,10 @@ GRUB_MOD_INIT (bfs)
37 {
38 COMPILE_TIME_ASSERT (1 << LOG_EXTENT_SIZE ==
39 sizeof (struct grub_bfs_extent));
40- grub_fs_register (&grub_bfs_fs);
41+ if (!grub_is_lockdown ())
42+ {
43+ grub_fs_register (&grub_bfs_fs);
44+ }
45 }
46
47 #ifdef MODE_AFS
48@@ -1115,5 +1119,6 @@ GRUB_MOD_FINI (afs)
49 GRUB_MOD_FINI (bfs)
50 #endif
51 {
52- grub_fs_unregister (&grub_bfs_fs);
53+ if (!grub_is_lockdown ())
54+ grub_fs_unregister (&grub_bfs_fs);
55 }
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-45780.patch b/meta/recipes-bsp/grub/files/CVE-2024-45780.patch
new file mode 100644
index 0000000000..1de0099f94
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45780.patch
@@ -0,0 +1,93 @@
1From 0087bc6902182fe5cedce2d034c75a79cf6dd4f3 Mon Sep 17 00:00:00 2001
2From: Lidong Chen <lidong.chen@oracle.com>
3Date: Fri, 22 Nov 2024 06:27:58 +0000
4Subject: [PATCH] fs/tar: Integer overflow leads to heap OOB write
5
6Both namesize and linksize are derived from hd.size, a 12-digit octal
7number parsed by read_number(). Later direct arithmetic calculation like
8"namesize + 1" and "linksize + 1" may exceed the maximum value of
9grub_size_t leading to heap OOB write. This patch fixes the issue by
10using grub_add() and checking for an overflow.
11
12Fixes: CVE-2024-45780
13
14Reported-by: Nils Langius <nils@langius.de>
15Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
16Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
18
19CVE: CVE-2024-45780
20Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=0087bc6902182fe5cedce2d034c75a79cf6dd4f3]
21Signed-off-by: Peter Marko <peter.marko@siemens.com>
22---
23 grub-core/fs/tar.c | 23 ++++++++++++++++++-----
24 1 file changed, 18 insertions(+), 5 deletions(-)
25
26diff --git a/grub-core/fs/tar.c b/grub-core/fs/tar.c
27index 646bce5eb..386c09022 100644
28--- a/grub-core/fs/tar.c
29+++ b/grub-core/fs/tar.c
30@@ -25,6 +25,7 @@
31 #include <grub/mm.h>
32 #include <grub/dl.h>
33 #include <grub/i18n.h>
34+#include <grub/safemath.h>
35
36 GRUB_MOD_LICENSE ("GPLv3+");
37
38@@ -76,6 +77,7 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
39 {
40 struct head hd;
41 int reread = 0, have_longname = 0, have_longlink = 0;
42+ grub_size_t sz;
43
44 data->hofs = data->next_hofs;
45
46@@ -97,7 +99,11 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
47 {
48 grub_err_t err;
49 grub_size_t namesize = read_number (hd.size, sizeof (hd.size));
50- *name = grub_malloc (namesize + 1);
51+
52+ if (grub_add (namesize, 1, &sz))
53+ return grub_error (GRUB_ERR_BAD_FS, N_("name size overflow"));
54+
55+ *name = grub_malloc (sz);
56 if (*name == NULL)
57 return grub_errno;
58 err = grub_disk_read (data->disk, 0,
59@@ -117,15 +123,19 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
60 {
61 grub_err_t err;
62 grub_size_t linksize = read_number (hd.size, sizeof (hd.size));
63- if (data->linkname_alloc < linksize + 1)
64+
65+ if (grub_add (linksize, 1, &sz))
66+ return grub_error (GRUB_ERR_BAD_FS, N_("link size overflow"));
67+
68+ if (data->linkname_alloc < sz)
69 {
70 char *n;
71- n = grub_calloc (2, linksize + 1);
72+ n = grub_calloc (2, sz);
73 if (!n)
74 return grub_errno;
75 grub_free (data->linkname);
76 data->linkname = n;
77- data->linkname_alloc = 2 * (linksize + 1);
78+ data->linkname_alloc = 2 * (sz);
79 }
80
81 err = grub_disk_read (data->disk, 0,
82@@ -148,7 +158,10 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
83 while (extra_size < sizeof (hd.prefix)
84 && hd.prefix[extra_size])
85 extra_size++;
86- *name = grub_malloc (sizeof (hd.name) + extra_size + 2);
87+
88+ if (grub_add (sizeof (hd.name) + 2, extra_size, &sz))
89+ return grub_error (GRUB_ERR_BAD_FS, N_("long name size overflow"));
90+ *name = grub_malloc (sz);
91 if (*name == NULL)
92 return grub_errno;
93 if (hd.prefix[0])
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-45781.patch b/meta/recipes-bsp/grub/files/CVE-2024-45781.patch
new file mode 100644
index 0000000000..bd0b6aa04a
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45781.patch
@@ -0,0 +1,35 @@
1From c1a291b01f4f1dcd6a22b61f1c81a45a966d16ba Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Sun, 12 May 2024 02:03:33 +0100
4Subject: [PATCH 2/2] fs/ufs: Fix a heap OOB write
5
6grub_strcpy() was used to copy a symlink name from the filesystem
7image to a heap allocated buffer. This led to a OOB write to adjacent
8heap allocations. Fix by using grub_strlcpy().
9
10Fixes: CVE-2024-45781
11
12Reported-by: B Horn <b@horn.uk>
13Signed-off-by: B Horn <b@horn.uk>
14Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
15
16CVE: CVE-2024-45781
17Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=c1a291b01f4f1dcd6a22b61f1c81a45a966d16ba]
18Signed-off-by: Peter Marko <peter.marko@siemens.com>
19---
20 grub-core/fs/ufs.c | 2 +-
21 1 file changed, 1 insertion(+), 1 deletion(-)
22
23diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c
24index a354c92d9..01235101b 100644
25--- a/grub-core/fs/ufs.c
26+++ b/grub-core/fs/ufs.c
27@@ -463,7 +463,7 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
28 /* Check against zero is paylindromic, no need to swap. */
29 if (data->inode.nblocks == 0
30 && INODE_SIZE (data) <= sizeof (data->inode.symlink))
31- grub_strcpy (symlink, (char *) data->inode.symlink);
32+ grub_strlcpy (symlink, (char *) data->inode.symlink, sz);
33 else
34 {
35 if (grub_ufs_read_file (data, 0, 0, 0, sz, symlink) < 0)
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-45782_CVE-2024-56737.patch b/meta/recipes-bsp/grub/files/CVE-2024-45782_CVE-2024-56737.patch
new file mode 100644
index 0000000000..41cc025b81
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45782_CVE-2024-56737.patch
@@ -0,0 +1,36 @@
1From 417547c10410b714e43f08f74137c24015f8f4c3 Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Sun, 12 May 2024 02:48:33 +0100
4Subject: [PATCH] fs/hfs: Fix stack OOB write with grub_strcpy()
5
6Replaced with grub_strlcpy().
7
8Fixes: CVE-2024-45782
9Fixes: CVE-2024-56737
10Fixes: https://savannah.gnu.org/bugs/?66599
11
12Reported-by: B Horn <b@horn.uk>
13Signed-off-by: B Horn <b@horn.uk>
14Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
15
16CVE: CVE-2024-45782
17CVE: CVE-2024-56737
18Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=417547c10410b714e43f08f74137c24015f8f4c3]
19Signed-off-by: Peter Marko <peter.marko@siemens.com>
20---
21 grub-core/fs/hfs.c | 2 +-
22 1 file changed, 1 insertion(+), 1 deletion(-)
23
24diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c
25index 91dc0e69c..920112b03 100644
26--- a/grub-core/fs/hfs.c
27+++ b/grub-core/fs/hfs.c
28@@ -379,7 +379,7 @@ grub_hfs_mount (grub_disk_t disk)
29 volume name. */
30 key.parent_dir = grub_cpu_to_be32_compile_time (1);
31 key.strlen = data->sblock.volname[0];
32- grub_strcpy ((char *) key.str, (char *) (data->sblock.volname + 1));
33+ grub_strlcpy ((char *) key.str, (char *) (data->sblock.volname + 1), sizeof (key.str));
34
35 if (grub_hfs_find_node (data, (char *) &key, data->cat_root,
36 0, (char *) &dir, sizeof (dir)) == 0)
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-45783.patch b/meta/recipes-bsp/grub/files/CVE-2024-45783.patch
new file mode 100644
index 0000000000..99c769961b
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-45783.patch
@@ -0,0 +1,39 @@
1From f7c070a2e28dfab7137db0739fb8db1dc02d8898 Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Sun, 12 May 2024 06:22:51 +0100
4Subject: [PATCH] fs/hfsplus: Set a grub_errno if mount fails
5
6It was possible for mount to fail but not set grub_errno. This led to
7a possible double decrement of the module reference count if the NULL
8page was mapped.
9
10Fixing in general as a similar bug was fixed in commit 61b13c187
11(fs/hfsplus: Set grub_errno to prevent NULL pointer access) and there
12are likely more variants around.
13
14Fixes: CVE-2024-45783
15
16Reported-by: B Horn <b@horn.uk>
17Signed-off-by: B Horn <b@horn.uk>
18Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
19
20CVE: CVE-2024-45783
21Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=f7c070a2e28dfab7137db0739fb8db1dc02d8898]
22Signed-off-by: Peter Marko <peter.marko@siemens.com>
23---
24 grub-core/fs/hfsplus.c | 2 +-
25 1 file changed, 1 insertion(+), 1 deletion(-)
26
27diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c
28index 295822f69..de71fd486 100644
29--- a/grub-core/fs/hfsplus.c
30+++ b/grub-core/fs/hfsplus.c
31@@ -405,7 +405,7 @@ grub_hfsplus_mount (grub_disk_t disk)
32
33 fail:
34
35- if (grub_errno == GRUB_ERR_OUT_OF_RANGE)
36+ if (grub_errno == GRUB_ERR_OUT_OF_RANGE || grub_errno == GRUB_ERR_NONE)
37 grub_error (GRUB_ERR_BAD_FS, "not a HFS+ filesystem");
38
39 grub_free (data);
diff --git a/meta/recipes-bsp/grub/files/CVE-2025-0622-01.patch b/meta/recipes-bsp/grub/files/CVE-2025-0622-01.patch
new file mode 100644
index 0000000000..09dbfce5f8
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2025-0622-01.patch
@@ -0,0 +1,35 @@
1From 2123c5bca7e21fbeb0263df4597ddd7054700726 Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Fri, 1 Nov 2024 19:24:29 +0000
4Subject: [PATCH 1/3] commands/pgp: Unregister the "check_signatures" hooks on
5 module unload
6
7If the hooks are not removed they can be called after the module has
8been unloaded leading to an use-after-free.
9
10Fixes: CVE-2025-0622
11
12Reported-by: B Horn <b@horn.uk>
13Signed-off-by: B Horn <b@horn.uk>
14Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
15
16CVE: CVE-2025-0622
17Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=2123c5bca7e21fbeb0263df4597ddd7054700726]
18Signed-off-by: Peter Marko <peter.marko@siemens.com>
19---
20 grub-core/commands/pgp.c | 2 ++
21 1 file changed, 2 insertions(+)
22
23diff --git a/grub-core/commands/pgp.c b/grub-core/commands/pgp.c
24index c6766f044..5fadc33c4 100644
25--- a/grub-core/commands/pgp.c
26+++ b/grub-core/commands/pgp.c
27@@ -1010,6 +1010,8 @@ GRUB_MOD_INIT(pgp)
28
29 GRUB_MOD_FINI(pgp)
30 {
31+ grub_register_variable_hook ("check_signatures", NULL, NULL);
32+ grub_env_unset ("check_signatures");
33 grub_verifier_unregister (&grub_pubkey_verifier);
34 grub_unregister_extcmd (cmd);
35 grub_unregister_extcmd (cmd_trust);
diff --git a/meta/recipes-bsp/grub/files/CVE-2025-0622-02.patch b/meta/recipes-bsp/grub/files/CVE-2025-0622-02.patch
new file mode 100644
index 0000000000..be01da3355
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2025-0622-02.patch
@@ -0,0 +1,41 @@
1From 9c16197734ada8d0838407eebe081117799bfe67 Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Fri, 1 Nov 2024 23:46:55 +0000
4Subject: [PATCH 2/3] normal: Remove variables hooks on module unload
5
6The normal module does not entirely cleanup after itself in
7its GRUB_MOD_FINI() leaving a few variables hooks in place.
8It is not possible to unload normal module now but fix the
9issues for completeness.
10
11On the occasion replace 0s with NULLs for "pager" variable
12hooks unregister.
13
14Fixes: CVE-2025-0622
15
16Reported-by: B Horn <b@horn.uk>
17Signed-off-by: B Horn <b@horn.uk>
18Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
19
20CVE: CVE-2025-0622
21Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=9c16197734ada8d0838407eebe081117799bfe67]
22Signed-off-by: Peter Marko <peter.marko@siemens.com>
23---
24 grub-core/normal/main.c | 4 +++-
25 1 file changed, 3 insertions(+), 1 deletion(-)
26
27diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
28index 838f57fa5..04d058f55 100644
29--- a/grub-core/normal/main.c
30+++ b/grub-core/normal/main.c
31@@ -582,7 +582,9 @@ GRUB_MOD_FINI(normal)
32 grub_xputs = grub_xputs_saved;
33
34 grub_set_history (0);
35- grub_register_variable_hook ("pager", 0, 0);
36+ grub_register_variable_hook ("pager", NULL, NULL);
37+ grub_register_variable_hook ("color_normal", NULL, NULL);
38+ grub_register_variable_hook ("color_highlight", NULL, NULL);
39 grub_fs_autoload_hook = 0;
40 grub_unregister_command (cmd_clear);
41 }
diff --git a/meta/recipes-bsp/grub/files/CVE-2025-0622-03.patch b/meta/recipes-bsp/grub/files/CVE-2025-0622-03.patch
new file mode 100644
index 0000000000..79078a4350
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2025-0622-03.patch
@@ -0,0 +1,38 @@
1From 7580addfc8c94cedb0cdfd7a1fd65b539215e637 Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Fri, 1 Nov 2024 23:52:06 +0000
4Subject: [PATCH 3/3] gettext: Remove variables hooks on module unload
5
6The gettext module does not entirely cleanup after itself in
7its GRUB_MOD_FINI() leaving a few variables hooks in place.
8It is not possible to unload gettext module because normal
9module depends on it. Though fix the issues for completeness.
10
11Fixes: CVE-2025-0622
12
13Reported-by: B Horn <b@horn.uk>
14Signed-off-by: B Horn <b@horn.uk>
15Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
16
17CVE: CVE-2025-0622
18Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=7580addfc8c94cedb0cdfd7a1fd65b539215e637]
19Signed-off-by: Peter Marko <peter.marko@siemens.com>
20---
21 grub-core/gettext/gettext.c | 4 ++++
22 1 file changed, 4 insertions(+)
23
24diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c
25index 7a1c14e4f..e4f4f8ee6 100644
26--- a/grub-core/gettext/gettext.c
27+++ b/grub-core/gettext/gettext.c
28@@ -535,6 +535,10 @@ GRUB_MOD_INIT (gettext)
29
30 GRUB_MOD_FINI (gettext)
31 {
32+ grub_register_variable_hook ("locale_dir", NULL, NULL);
33+ grub_register_variable_hook ("secondary_locale_dir", NULL, NULL);
34+ grub_register_variable_hook ("lang", NULL, NULL);
35+
36 grub_gettext_delete_list (&main_context);
37 grub_gettext_delete_list (&secondary_context);
38
diff --git a/meta/recipes-bsp/grub/files/CVE-2025-0624.patch b/meta/recipes-bsp/grub/files/CVE-2025-0624.patch
new file mode 100644
index 0000000000..229fe6399e
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2025-0624.patch
@@ -0,0 +1,84 @@
1From 5eef88152833062a3f7e017535372d64ac8ef7e1 Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Fri, 15 Nov 2024 13:12:09 +0000
4Subject: [PATCH] net: Fix OOB write in grub_net_search_config_file()
5
6The function included a call to grub_strcpy() which copied data from an
7environment variable to a buffer allocated in grub_cmd_normal(). The
8grub_cmd_normal() didn't consider the length of the environment variable.
9So, the copy operation could exceed the allocation and lead to an OOB
10write. Fix the issue by replacing grub_strcpy() with grub_strlcpy() and
11pass the underlying buffers size to the grub_net_search_config_file().
12
13Fixes: CVE-2025-0624
14
15Reported-by: B Horn <b@horn.uk>
16Signed-off-by: B Horn <b@horn.uk>
17Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
18
19CVE: CVE-2025-0624
20Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=5eef88152833062a3f7e017535372d64ac8ef7e1]
21Signed-off-by: Peter Marko <peter.marko@siemens.com>
22---
23 grub-core/net/net.c | 7 ++++---
24 grub-core/normal/main.c | 2 +-
25 include/grub/net.h | 2 +-
26 3 files changed, 6 insertions(+), 5 deletions(-)
27
28diff --git a/grub-core/net/net.c b/grub-core/net/net.c
29index 0e41e21a5..9939ff601 100644
30--- a/grub-core/net/net.c
31+++ b/grub-core/net/net.c
32@@ -1909,14 +1909,15 @@ grub_config_search_through (char *config, char *suffix,
33 }
34
35 grub_err_t
36-grub_net_search_config_file (char *config)
37+grub_net_search_config_file (char *config, grub_size_t config_buf_len)
38 {
39- grub_size_t config_len;
40+ grub_size_t config_len, suffix_len;
41 char *suffix;
42
43 config_len = grub_strlen (config);
44 config[config_len] = '-';
45 suffix = config + config_len + 1;
46+ suffix_len = config_buf_len - (config_len + 1);
47
48 struct grub_net_network_level_interface *inf;
49 FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
50@@ -1942,7 +1943,7 @@ grub_net_search_config_file (char *config)
51
52 if (client_uuid)
53 {
54- grub_strcpy (suffix, client_uuid);
55+ grub_strlcpy (suffix, client_uuid, suffix_len);
56 if (grub_config_search_through (config, suffix, 1, 0) == 0)
57 return GRUB_ERR_NONE;
58 }
59diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
60index 90879dc21..838f57fa5 100644
61--- a/grub-core/normal/main.c
62+++ b/grub-core/normal/main.c
63@@ -344,7 +344,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
64
65 if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 &&
66 !disable_net_search)
67- grub_net_search_config_file (config);
68+ grub_net_search_config_file (config, config_len);
69
70 grub_enter_normal_mode (config);
71 grub_free (config);
72diff --git a/include/grub/net.h b/include/grub/net.h
73index 228d04963..58a4f83fc 100644
74--- a/include/grub/net.h
75+++ b/include/grub/net.h
76@@ -579,7 +579,7 @@ void
77 grub_net_remove_dns_server (const struct grub_net_network_level_address *s);
78
79 grub_err_t
80-grub_net_search_config_file (char *config);
81+grub_net_search_config_file (char *config, grub_size_t config_buf_len);
82
83 extern char *grub_net_default_server;
84
diff --git a/meta/recipes-bsp/grub/files/CVE-2025-0677_CVE-2025-0684_CVE-2025-0685_CVE-2025-0686_CVE-2025-0689.patch b/meta/recipes-bsp/grub/files/CVE-2025-0677_CVE-2025-0684_CVE-2025-0685_CVE-2025-0686_CVE-2025-0689.patch
new file mode 100644
index 0000000000..d5563cecc4
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2025-0677_CVE-2025-0684_CVE-2025-0685_CVE-2025-0686_CVE-2025-0689.patch
@@ -0,0 +1,377 @@
1From 47b2dfc7953f70f98ddf35dfdd6e7f4f20283b10 Mon Sep 17 00:00:00 2001
2From: Daniel Axtens <dja@axtens.net>
3Date: Sat, 23 Mar 2024 16:20:45 +1100
4Subject: [PATCH] fs: Disable many filesystems under lockdown
5
6The idea is to permit the following: btrfs, cpio, exfat, ext, f2fs, fat,
7hfsplus, iso9660, squash4, tar, xfs and zfs.
8
9The JFS, ReiserFS, romfs, UDF and UFS security vulnerabilities were
10reported by Jonathan Bar Or <jonathanbaror@gmail.com>.
11
12Fixes: CVE-2025-0677
13Fixes: CVE-2025-0684
14Fixes: CVE-2025-0685
15Fixes: CVE-2025-0686
16Fixes: CVE-2025-0689
17
18Suggested-by: Daniel Axtens <dja@axtens.net>
19Signed-off-by: Daniel Axtens <dja@axtens.net>
20Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
21
22CVE: CVE-2025-0677
23CVE: CVE-2025-0684
24CVE: CVE-2025-0685
25CVE: CVE-2025-0686
26CVE: CVE-2025-0689
27Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=47b2dfc7953f70f98ddf35dfdd6e7f4f20283b10]
28Signed-off-by: Peter Marko <peter.marko@siemens.com>
29---
30 grub-core/fs/affs.c | 9 +++++++--
31 grub-core/fs/cbfs.c | 9 +++++++--
32 grub-core/fs/jfs.c | 9 +++++++--
33 grub-core/fs/minix.c | 9 +++++++--
34 grub-core/fs/nilfs2.c | 9 +++++++--
35 grub-core/fs/ntfs.c | 9 +++++++--
36 grub-core/fs/reiserfs.c | 9 +++++++--
37 grub-core/fs/romfs.c | 9 +++++++--
38 grub-core/fs/sfs.c | 9 +++++++--
39 grub-core/fs/udf.c | 9 +++++++--
40 grub-core/fs/ufs.c | 9 +++++++--
41 11 files changed, 77 insertions(+), 22 deletions(-)
42
43diff --git a/grub-core/fs/affs.c b/grub-core/fs/affs.c
44index ed606b3f1..352f5d232 100644
45--- a/grub-core/fs/affs.c
46+++ b/grub-core/fs/affs.c
47@@ -26,6 +26,7 @@
48 #include <grub/types.h>
49 #include <grub/fshelp.h>
50 #include <grub/charset.h>
51+#include <grub/lockdown.h>
52
53 GRUB_MOD_LICENSE ("GPLv3+");
54
55@@ -703,11 +704,15 @@ static struct grub_fs grub_affs_fs =
56
57 GRUB_MOD_INIT(affs)
58 {
59- grub_fs_register (&grub_affs_fs);
60+ if (!grub_is_lockdown ())
61+ {
62+ grub_fs_register (&grub_affs_fs);
63+ }
64 my_mod = mod;
65 }
66
67 GRUB_MOD_FINI(affs)
68 {
69- grub_fs_unregister (&grub_affs_fs);
70+ if (!grub_is_lockdown ())
71+ grub_fs_unregister (&grub_affs_fs);
72 }
73diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c
74index 8ab7106af..f6349df34 100644
75--- a/grub-core/fs/cbfs.c
76+++ b/grub-core/fs/cbfs.c
77@@ -26,6 +26,7 @@
78 #include <grub/dl.h>
79 #include <grub/i18n.h>
80 #include <grub/cbfs_core.h>
81+#include <grub/lockdown.h>
82
83 GRUB_MOD_LICENSE ("GPLv3+");
84
85@@ -390,12 +391,16 @@ GRUB_MOD_INIT (cbfs)
86 #if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
87 init_cbfsdisk ();
88 #endif
89- grub_fs_register (&grub_cbfs_fs);
90+ if (!grub_is_lockdown ())
91+ {
92+ grub_fs_register (&grub_cbfs_fs);
93+ }
94 }
95
96 GRUB_MOD_FINI (cbfs)
97 {
98- grub_fs_unregister (&grub_cbfs_fs);
99+ if (!grub_is_lockdown ())
100+ grub_fs_unregister (&grub_cbfs_fs);
101 #if (defined (__i386__) || defined (__x86_64__)) && !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) && !defined (GRUB_MACHINE_XEN)
102 fini_cbfsdisk ();
103 #endif
104diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c
105index 6f7c43904..c0bbab8a9 100644
106--- a/grub-core/fs/jfs.c
107+++ b/grub-core/fs/jfs.c
108@@ -26,6 +26,7 @@
109 #include <grub/types.h>
110 #include <grub/charset.h>
111 #include <grub/i18n.h>
112+#include <grub/lockdown.h>
113
114 GRUB_MOD_LICENSE ("GPLv3+");
115
116@@ -963,11 +964,15 @@ static struct grub_fs grub_jfs_fs =
117
118 GRUB_MOD_INIT(jfs)
119 {
120- grub_fs_register (&grub_jfs_fs);
121+ if (!grub_is_lockdown ())
122+ {
123+ grub_fs_register (&grub_jfs_fs);
124+ }
125 my_mod = mod;
126 }
127
128 GRUB_MOD_FINI(jfs)
129 {
130- grub_fs_unregister (&grub_jfs_fs);
131+ if (!grub_is_lockdown ())
132+ grub_fs_unregister (&grub_jfs_fs);
133 }
134diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c
135index 5354951d1..c267298b5 100644
136--- a/grub-core/fs/minix.c
137+++ b/grub-core/fs/minix.c
138@@ -25,6 +25,7 @@
139 #include <grub/dl.h>
140 #include <grub/types.h>
141 #include <grub/i18n.h>
142+#include <grub/lockdown.h>
143
144 GRUB_MOD_LICENSE ("GPLv3+");
145
146@@ -734,7 +735,10 @@ GRUB_MOD_INIT(minix)
147 #endif
148 #endif
149 {
150- grub_fs_register (&grub_minix_fs);
151+ if (!grub_is_lockdown ())
152+ {
153+ grub_fs_register (&grub_minix_fs);
154+ }
155 my_mod = mod;
156 }
157
158@@ -756,5 +760,6 @@ GRUB_MOD_FINI(minix)
159 #endif
160 #endif
161 {
162- grub_fs_unregister (&grub_minix_fs);
163+ if (!grub_is_lockdown ())
164+ grub_fs_unregister (&grub_minix_fs);
165 }
166diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c
167index fc7374ead..08abf173f 100644
168--- a/grub-core/fs/nilfs2.c
169+++ b/grub-core/fs/nilfs2.c
170@@ -34,6 +34,7 @@
171 #include <grub/dl.h>
172 #include <grub/types.h>
173 #include <grub/fshelp.h>
174+#include <grub/lockdown.h>
175
176 GRUB_MOD_LICENSE ("GPLv3+");
177
178@@ -1231,11 +1232,15 @@ GRUB_MOD_INIT (nilfs2)
179 grub_nilfs2_dat_entry));
180 COMPILE_TIME_ASSERT (1 << LOG_INODE_SIZE
181 == sizeof (struct grub_nilfs2_inode));
182- grub_fs_register (&grub_nilfs2_fs);
183+ if (!grub_is_lockdown ())
184+ {
185+ grub_fs_register (&grub_nilfs2_fs);
186+ }
187 my_mod = mod;
188 }
189
190 GRUB_MOD_FINI (nilfs2)
191 {
192- grub_fs_unregister (&grub_nilfs2_fs);
193+ if (!grub_is_lockdown ())
194+ grub_fs_unregister (&grub_nilfs2_fs);
195 }
196diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c
197index de435aa14..8cc2ba3d5 100644
198--- a/grub-core/fs/ntfs.c
199+++ b/grub-core/fs/ntfs.c
200@@ -27,6 +27,7 @@
201 #include <grub/fshelp.h>
202 #include <grub/ntfs.h>
203 #include <grub/charset.h>
204+#include <grub/lockdown.h>
205
206 GRUB_MOD_LICENSE ("GPLv3+");
207
208@@ -1320,11 +1321,15 @@ static struct grub_fs grub_ntfs_fs =
209
210 GRUB_MOD_INIT (ntfs)
211 {
212- grub_fs_register (&grub_ntfs_fs);
213+ if (!grub_is_lockdown ())
214+ {
215+ grub_fs_register (&grub_ntfs_fs);
216+ }
217 my_mod = mod;
218 }
219
220 GRUB_MOD_FINI (ntfs)
221 {
222- grub_fs_unregister (&grub_ntfs_fs);
223+ if (!grub_is_lockdown ())
224+ grub_fs_unregister (&grub_ntfs_fs);
225 }
226diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c
227index 36b26ac98..cdef2eba0 100644
228--- a/grub-core/fs/reiserfs.c
229+++ b/grub-core/fs/reiserfs.c
230@@ -39,6 +39,7 @@
231 #include <grub/types.h>
232 #include <grub/fshelp.h>
233 #include <grub/i18n.h>
234+#include <grub/lockdown.h>
235
236 GRUB_MOD_LICENSE ("GPLv3+");
237
238@@ -1417,11 +1418,15 @@ static struct grub_fs grub_reiserfs_fs =
239
240 GRUB_MOD_INIT(reiserfs)
241 {
242- grub_fs_register (&grub_reiserfs_fs);
243+ if (!grub_is_lockdown ())
244+ {
245+ grub_fs_register (&grub_reiserfs_fs);
246+ }
247 my_mod = mod;
248 }
249
250 GRUB_MOD_FINI(reiserfs)
251 {
252- grub_fs_unregister (&grub_reiserfs_fs);
253+ if (!grub_is_lockdown ())
254+ grub_fs_unregister (&grub_reiserfs_fs);
255 }
256diff --git a/grub-core/fs/romfs.c b/grub-core/fs/romfs.c
257index 1f7dcfca1..acf8dd21e 100644
258--- a/grub-core/fs/romfs.c
259+++ b/grub-core/fs/romfs.c
260@@ -23,6 +23,7 @@
261 #include <grub/disk.h>
262 #include <grub/fs.h>
263 #include <grub/fshelp.h>
264+#include <grub/lockdown.h>
265
266 GRUB_MOD_LICENSE ("GPLv3+");
267
268@@ -475,10 +476,14 @@ static struct grub_fs grub_romfs_fs =
269
270 GRUB_MOD_INIT(romfs)
271 {
272- grub_fs_register (&grub_romfs_fs);
273+ if (!grub_is_lockdown ())
274+ {
275+ grub_fs_register (&grub_romfs_fs);
276+ }
277 }
278
279 GRUB_MOD_FINI(romfs)
280 {
281- grub_fs_unregister (&grub_romfs_fs);
282+ if (!grub_is_lockdown ())
283+ grub_fs_unregister (&grub_romfs_fs);
284 }
285diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c
286index 983e88008..f64bdd2df 100644
287--- a/grub-core/fs/sfs.c
288+++ b/grub-core/fs/sfs.c
289@@ -26,6 +26,7 @@
290 #include <grub/types.h>
291 #include <grub/fshelp.h>
292 #include <grub/charset.h>
293+#include <grub/lockdown.h>
294 #include <grub/safemath.h>
295
296 GRUB_MOD_LICENSE ("GPLv3+");
297@@ -779,11 +780,15 @@ static struct grub_fs grub_sfs_fs =
298
299 GRUB_MOD_INIT(sfs)
300 {
301- grub_fs_register (&grub_sfs_fs);
302+ if (!grub_is_lockdown ())
303+ {
304+ grub_fs_register (&grub_sfs_fs);
305+ }
306 my_mod = mod;
307 }
308
309 GRUB_MOD_FINI(sfs)
310 {
311- grub_fs_unregister (&grub_sfs_fs);
312+ if (!grub_is_lockdown ())
313+ grub_fs_unregister (&grub_sfs_fs);
314 }
315diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c
316index b836e6107..a60643be1 100644
317--- a/grub-core/fs/udf.c
318+++ b/grub-core/fs/udf.c
319@@ -27,6 +27,7 @@
320 #include <grub/fshelp.h>
321 #include <grub/charset.h>
322 #include <grub/datetime.h>
323+#include <grub/lockdown.h>
324 #include <grub/udf.h>
325 #include <grub/safemath.h>
326
327@@ -1455,11 +1456,15 @@ static struct grub_fs grub_udf_fs = {
328
329 GRUB_MOD_INIT (udf)
330 {
331- grub_fs_register (&grub_udf_fs);
332+ if (!grub_is_lockdown ())
333+ {
334+ grub_fs_register (&grub_udf_fs);
335+ }
336 my_mod = mod;
337 }
338
339 GRUB_MOD_FINI (udf)
340 {
341- grub_fs_unregister (&grub_udf_fs);
342+ if (!grub_is_lockdown ())
343+ grub_fs_unregister (&grub_udf_fs);
344 }
345diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c
346index 01235101b..6b496e7b8 100644
347--- a/grub-core/fs/ufs.c
348+++ b/grub-core/fs/ufs.c
349@@ -25,6 +25,7 @@
350 #include <grub/dl.h>
351 #include <grub/types.h>
352 #include <grub/i18n.h>
353+#include <grub/lockdown.h>
354
355 GRUB_MOD_LICENSE ("GPLv3+");
356
357@@ -899,7 +900,10 @@ GRUB_MOD_INIT(ufs1)
358 #endif
359 #endif
360 {
361- grub_fs_register (&grub_ufs_fs);
362+ if (!grub_is_lockdown ())
363+ {
364+ grub_fs_register (&grub_ufs_fs);
365+ }
366 my_mod = mod;
367 }
368
369@@ -913,6 +917,7 @@ GRUB_MOD_FINI(ufs1)
370 #endif
371 #endif
372 {
373- grub_fs_unregister (&grub_ufs_fs);
374+ if (!grub_is_lockdown ())
375+ grub_fs_unregister (&grub_ufs_fs);
376 }
377
diff --git a/meta/recipes-bsp/grub/files/CVE-2025-0678_CVE-2025-1125.patch b/meta/recipes-bsp/grub/files/CVE-2025-0678_CVE-2025-1125.patch
new file mode 100644
index 0000000000..14e67cf35b
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2025-0678_CVE-2025-1125.patch
@@ -0,0 +1,87 @@
1From 84bc0a9a68835952ae69165c11709811dae7634e Mon Sep 17 00:00:00 2001
2From: Lidong Chen <lidong.chen@oracle.com>
3Date: Tue, 21 Jan 2025 19:02:37 +0000
4Subject: [PATCH] fs: Prevent overflows when allocating memory for arrays
5
6Use grub_calloc() when allocating memory for arrays to ensure proper
7overflow checks are in place.
8
9The HFS+ and squash4 security vulnerabilities were reported by
10Jonathan Bar Or <jonathanbaror@gmail.com>.
11
12Fixes: CVE-2025-0678
13Fixes: CVE-2025-1125
14
15Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
16Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17
18CVE: CVE-2025-0678
19CVE: CVE-2025-1125
20Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=84bc0a9a68835952ae69165c11709811dae7634e]
21Signed-off-by: Peter Marko <peter.marko@siemens.com>
22---
23 grub-core/fs/btrfs.c | 4 ++--
24 grub-core/fs/hfspluscomp.c | 9 +++++++--
25 grub-core/fs/squash4.c | 8 ++++----
26 3 files changed, 13 insertions(+), 8 deletions(-)
27
28diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
29index 0625b1166..9c1e925c9 100644
30--- a/grub-core/fs/btrfs.c
31+++ b/grub-core/fs/btrfs.c
32@@ -1276,8 +1276,8 @@ grub_btrfs_mount (grub_device_t dev)
33 }
34
35 data->n_devices_allocated = 16;
36- data->devices_attached = grub_malloc (sizeof (data->devices_attached[0])
37- * data->n_devices_allocated);
38+ data->devices_attached = grub_calloc (data->n_devices_allocated,
39+ sizeof (data->devices_attached[0]));
40 if (!data->devices_attached)
41 {
42 grub_free (data);
43diff --git a/grub-core/fs/hfspluscomp.c b/grub-core/fs/hfspluscomp.c
44index 48ae438d8..a80954ee6 100644
45--- a/grub-core/fs/hfspluscomp.c
46+++ b/grub-core/fs/hfspluscomp.c
47@@ -244,14 +244,19 @@ hfsplus_open_compressed_real (struct grub_hfsplus_file *node)
48 return 0;
49 }
50 node->compress_index_size = grub_le_to_cpu32 (index_size);
51- node->compress_index = grub_malloc (node->compress_index_size
52- * sizeof (node->compress_index[0]));
53+ node->compress_index = grub_calloc (node->compress_index_size,
54+ sizeof (node->compress_index[0]));
55 if (!node->compress_index)
56 {
57 node->compressed = 0;
58 grub_free (attr_node);
59 return grub_errno;
60 }
61+
62+ /*
63+ * The node->compress_index_size * sizeof (node->compress_index[0]) is safe here
64+ * due to relevant checks done in grub_calloc() above.
65+ */
66 if (grub_hfsplus_read_file (node, 0, 0,
67 0x104 + sizeof (index_size),
68 node->compress_index_size
69diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c
70index f91ff3bfa..cf2bca822 100644
71--- a/grub-core/fs/squash4.c
72+++ b/grub-core/fs/squash4.c
73@@ -816,10 +816,10 @@ direct_read (struct grub_squash_data *data,
74 break;
75 }
76 total_blocks = ((total_size + data->blksz - 1) >> data->log2_blksz);
77- ino->block_sizes = grub_malloc (total_blocks
78- * sizeof (ino->block_sizes[0]));
79- ino->cumulated_block_sizes = grub_malloc (total_blocks
80- * sizeof (ino->cumulated_block_sizes[0]));
81+ ino->block_sizes = grub_calloc (total_blocks,
82+ sizeof (ino->block_sizes[0]));
83+ ino->cumulated_block_sizes = grub_calloc (total_blocks,
84+ sizeof (ino->cumulated_block_sizes[0]));
85 if (!ino->block_sizes || !ino->cumulated_block_sizes)
86 {
87 grub_free (ino->block_sizes);
diff --git a/meta/recipes-bsp/grub/files/CVE-2025-0690.patch b/meta/recipes-bsp/grub/files/CVE-2025-0690.patch
new file mode 100644
index 0000000000..be585c96ad
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2025-0690.patch
@@ -0,0 +1,73 @@
1From dad8f502974ed9ad0a70ae6820d17b4b142558fc Mon Sep 17 00:00:00 2001
2From: Jonathan Bar Or <jonathanbaror@gmail.com>
3Date: Thu, 23 Jan 2025 19:17:05 +0100
4Subject: [PATCH] commands/read: Fix an integer overflow when supplying more
5 than 2^31 characters
6
7The grub_getline() function currently has a signed integer variable "i"
8that can be overflown when user supplies more than 2^31 characters.
9It results in a memory corruption of the allocated line buffer as well
10as supplying large negative values to grub_realloc().
11
12Fixes: CVE-2025-0690
13
14Reported-by: Jonathan Bar Or <jonathanbaror@gmail.com>
15Signed-off-by: Jonathan Bar Or <jonathanbaror@gmail.com>
16Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
17
18CVE: CVE-2025-0690
19Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=dad8f502974ed9ad0a70ae6820d17b4b142558fc]
20Signed-off-by: Peter Marko <peter.marko@siemens.com>
21---
22 grub-core/commands/read.c | 19 +++++++++++++++----
23 1 file changed, 15 insertions(+), 4 deletions(-)
24
25diff --git a/grub-core/commands/read.c b/grub-core/commands/read.c
26index 597c90706..8d72e45c9 100644
27--- a/grub-core/commands/read.c
28+++ b/grub-core/commands/read.c
29@@ -25,6 +25,7 @@
30 #include <grub/types.h>
31 #include <grub/extcmd.h>
32 #include <grub/i18n.h>
33+#include <grub/safemath.h>
34
35 GRUB_MOD_LICENSE ("GPLv3+");
36
37@@ -37,13 +38,14 @@ static const struct grub_arg_option options[] =
38 static char *
39 grub_getline (int silent)
40 {
41- int i;
42+ grub_size_t i;
43 char *line;
44 char *tmp;
45 int c;
46+ grub_size_t alloc_size;
47
48 i = 0;
49- line = grub_malloc (1 + i + sizeof('\0'));
50+ line = grub_malloc (1 + sizeof('\0'));
51 if (! line)
52 return NULL;
53
54@@ -59,8 +61,17 @@ grub_getline (int silent)
55 line[i] = (char) c;
56 if (!silent)
57 grub_printf ("%c", c);
58- i++;
59- tmp = grub_realloc (line, 1 + i + sizeof('\0'));
60+ if (grub_add (i, 1, &i))
61+ {
62+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
63+ return NULL;
64+ }
65+ if (grub_add (i, 1 + sizeof('\0'), &alloc_size))
66+ {
67+ grub_error (GRUB_ERR_OUT_OF_RANGE, N_("overflow is detected"));
68+ return NULL;
69+ }
70+ tmp = grub_realloc (line, alloc_size);
71 if (! tmp)
72 {
73 grub_free (line);
diff --git a/meta/recipes-bsp/grub/files/CVE-2025-1118.patch b/meta/recipes-bsp/grub/files/CVE-2025-1118.patch
new file mode 100644
index 0000000000..e6906d909c
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2025-1118.patch
@@ -0,0 +1,37 @@
1From 34824806ac6302f91e8cabaa41308eaced25725f Mon Sep 17 00:00:00 2001
2From: B Horn <b@horn.uk>
3Date: Thu, 18 Apr 2024 20:29:39 +0100
4Subject: [PATCH] commands/minicmd: Block the dump command in lockdown mode
5
6The dump enables a user to read memory which should not be possible
7in lockdown mode.
8
9Fixes: CVE-2025-1118
10
11Reported-by: B Horn <b@horn.uk>
12Reported-by: Jonathan Bar Or <jonathanbaror@gmail.com>
13Signed-off-by: B Horn <b@horn.uk>
14Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
15
16CVE: CVE-2025-1118
17Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=34824806ac6302f91e8cabaa41308eaced25725f]
18Signed-off-by: Peter Marko <peter.marko@siemens.com>
19---
20 grub-core/commands/minicmd.c | 4 ++--
21 1 file changed, 2 insertions(+), 2 deletions(-)
22
23diff --git a/grub-core/commands/minicmd.c b/grub-core/commands/minicmd.c
24index 286290866..8c5ee3e60 100644
25--- a/grub-core/commands/minicmd.c
26+++ b/grub-core/commands/minicmd.c
27@@ -203,8 +203,8 @@ GRUB_MOD_INIT(minicmd)
28 grub_register_command ("help", grub_mini_cmd_help,
29 0, N_("Show this message."));
30 cmd_dump =
31- grub_register_command ("dump", grub_mini_cmd_dump,
32- N_("ADDR [SIZE]"), N_("Show memory contents."));
33+ grub_register_command_lockdown ("dump", grub_mini_cmd_dump,
34+ N_("ADDR [SIZE]"), N_("Show memory contents."));
35 cmd_rmmod =
36 grub_register_command ("rmmod", grub_mini_cmd_rmmod,
37 N_("MODULE"), N_("Remove a module."));
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..7c8770ce8b 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:
@@ -37,15 +37,16 @@ SYMBOL TABLE:
370000000000000000 l d .modname 0000000000000000 .modname 370000000000000000 l d .modname 0000000000000000 .modname
38-------------- 38--------------
39 39
40Upstream-Status: Pending 40Upstream-Status: Inappropriate [workaround that needs investigation into @TARGET_STRIP@ behaviour in oe-core vs toolchain used by upstream]
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..0b4005e5bf 100644
--- a/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
+++ b/meta/recipes-bsp/grub/grub-bootconf_1.00.bb
@@ -5,13 +5,13 @@ 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
12require conf/image-uefi.conf 12require conf/image-uefi.conf
13 13
14S = "${WORKDIR}" 14S = "${UNPACKDIR}"
15 15
16GRUB_CFG = "${S}/grub-bootconf" 16GRUB_CFG = "${S}/grub-bootconf"
17LABELS = "boot" 17LABELS = "boot"
@@ -22,11 +22,11 @@ python do_configure() {
22 bb.build.exec_func('build_efi_cfg', d) 22 bb.build.exec_func('build_efi_cfg', d)
23} 23}
24 24
25do_configure[vardeps] += "APPEND ROOT" 25do_configure[vardeps] += "APPEND ROOT GRUB_TITLE"
26 26
27do_install() { 27do_install() {
28 install -d ${D}${EFI_FILES_PATH} 28 install -d ${D}${EFI_FILES_PATH}
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..6354b43989 100644
--- a/meta/recipes-bsp/grub/grub-efi_2.04.bb
+++ b/meta/recipes-bsp/grub/grub-efi_2.12.bb
@@ -4,14 +4,14 @@ 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 \
12 " 12 "
13 13
14S = "${WORKDIR}/grub-${PV}" 14S = "${UNPACKDIR}/grub-${PV}"
15 15
16# Determine the target arch for the grub modules 16# Determine the target arch for the grub modules
17python __anonymous () { 17python __anonymous () {
@@ -30,6 +30,8 @@ python __anonymous () {
30 grubtarget = 'riscv64' 30 grubtarget = 'riscv64'
31 elif re.match('riscv32', target): 31 elif re.match('riscv32', target):
32 grubtarget = 'riscv32' 32 grubtarget = 'riscv32'
33 elif re.match('loongarch64', target):
34 grubtarget = 'loongarch64'
33 else: 35 else:
34 raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target) 36 raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)
35 grubimage = prefix + d.getVar("EFI_BOOT_IMAGE") 37 grubimage = prefix + d.getVar("EFI_BOOT_IMAGE")
@@ -44,13 +46,26 @@ inherit deploy
44CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN=" 46CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN="
45EXTRA_OECONF += "--enable-efiemu=no" 47EXTRA_OECONF += "--enable-efiemu=no"
46 48
49# Define GRUB_MKIMAGE_OPTS variable for additional grub-mkimage options (e.g., disabling shim lock)
50GRUB_MKIMAGE_OPTS ?= ""
51
47do_mkimage() { 52do_mkimage() {
48 cd ${B} 53 cd ${B}
54
55 GRUB_MKIMAGE_MODULES="${GRUB_BUILDIN}"
56
57 # If 'all' is included in GRUB_BUILDIN we will include all available grub2 modules
58 if [ "${@ bb.utils.contains('GRUB_BUILDIN', 'all', 'True', 'False', d)}" = "True" ]; then
59 bbdebug 1 "Including all available modules"
60 # Get the list of all .mod files in grub-core build directory
61 GRUB_MKIMAGE_MODULES=$(find ${B}/grub-core/ -type f -name "*.mod" -exec basename {} .mod \;)
62 fi
63
49 # Search for the grub.cfg on the local boot media by using the 64 # Search for the grub.cfg on the local boot media by using the
50 # built in cfg file provided via this recipe 65 # built in cfg file provided via this recipe
51 grub-mkimage -c ../cfg -p ${EFIDIR} -d ./grub-core/ \ 66 grub-mkimage -v -c ${UNPACKDIR}/cfg -p ${EFIDIR} -d ./grub-core/ \
52 -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \ 67 -O ${GRUB_TARGET}-efi -o ./${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} \
53 ${GRUB_BUILDIN} 68 ${GRUB_MKIMAGE_OPTS} ${GRUB_MKIMAGE_MODULES}
54} 69}
55 70
56addtask mkimage before do_install after do_compile 71addtask mkimage before do_install after do_compile
@@ -70,22 +85,26 @@ do_install() {
70 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE} 85 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${D}${EFI_FILES_PATH}/${GRUB_IMAGE}
71} 86}
72 87
88# To include all available modules, add 'all' to GRUB_BUILDIN
73GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \ 89GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal \
74 efi_gop iso9660 configfile search loadenv test" 90 efi_gop iso9660 configfile search loadenv test"
75 91
92# 'xen_boot' is a module valid only for aarch64
93GRUB_BUILDIN:append:aarch64 = "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' xen_boot', '', d)}"
94
76do_deploy() { 95do_deploy() {
77 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR} 96 install -m 644 ${B}/${GRUB_IMAGE_PREFIX}${GRUB_IMAGE} ${DEPLOYDIR}
78} 97}
79 98
80addtask deploy after do_install before do_build 99addtask deploy after do_install before do_build
81 100
82FILES_${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \ 101FILES:${PN} = "${libdir}/grub/${GRUB_TARGET}-efi \
83 ${datadir}/grub \ 102 ${datadir}/grub \
84 ${EFI_FILES_PATH}/${GRUB_IMAGE} \ 103 ${EFI_FILES_PATH}/${GRUB_IMAGE} \
85 " 104 "
86 105
87# 64-bit binaries are expected for the bootloader with an x32 userland 106# 64-bit binaries are expected for the bootloader with an x32 userland
88INSANE_SKIP_${PN}_append_linux-gnux32 = " arch" 107INSANE_SKIP:${PN}:append:linux-gnux32 = " arch"
89INSANE_SKIP_${PN}-dbg_append_linux-gnux32 = " arch" 108INSANE_SKIP:${PN}-dbg:append:linux-gnux32 = " arch"
90INSANE_SKIP_${PN}_append_linux-muslx32 = " arch" 109INSANE_SKIP:${PN}:append:linux-muslx32 = " arch"
91INSANE_SKIP_${PN}-dbg_append_linux-muslx32 = " arch" 110INSANE_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..ffa04e415d 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -8,48 +8,70 @@ 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"
15 15
16SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \ 16SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
17 file://0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch \
18 file://autogen.sh-exclude-pc.patch \ 17 file://autogen.sh-exclude-pc.patch \
19 file://grub-module-explicitly-keeps-symbole-.module_license.patch \ 18 file://grub-module-explicitly-keeps-symbole-.module_license.patch \
20 file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \ 19 file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
21 file://CVE-2020-10713.patch \ 20 file://0001-RISC-V-Restore-the-typcast-to-long.patch \
22 file://calloc-Make-sure-we-always-have-an-overflow-checking.patch \ 21 file://0001-misc-Implement-grub_strlcpy.patch \
23 file://lvm-Add-LVM-cache-logical-volume-handling.patch \ 22 file://CVE-2024-45781.patch \
24 file://CVE-2020-14308-calloc-Use-calloc-at-most-places.patch \ 23 file://CVE-2024-45782_CVE-2024-56737.patch \
25 file://safemath-Add-some-arithmetic-primitives-that-check-f.patch \ 24 file://CVE-2024-45780.patch \
26 file://CVE-2020-14309-CVE-2020-14310-CVE-2020-14311-malloc-Use-overflow-checking-primitives-where-we-do-.patch \ 25 file://CVE-2024-45783.patch \
27 file://script-Remove-unused-fields-from-grub_script_functio.patch \ 26 file://CVE-2025-0624.patch \
28 file://CVE-2020-15706-script-Avoid-a-use-after-free-when-redefining-a-func.patch \ 27 file://CVE-2024-45774.patch \
29 file://CVE-2020-15707-linux-Fix-integer-overflows-in-initrd-size-handling.patch \ 28 file://CVE-2024-45775.patch \
30 file://6643507ce30f775008e093580f0c9499dfb2c485.patch \ 29 file://CVE-2025-0622-01.patch \
31 file://determinism.patch \ 30 file://CVE-2025-0622-02.patch \
31 file://CVE-2025-0622-03.patch \
32 file://CVE-2024-45776.patch \
33 file://CVE-2024-45777.patch \
34 file://CVE-2025-0690.patch \
35 file://CVE-2025-1118.patch \
36 file://CVE-2024-45778_CVE-2024-45779.patch \
37 file://CVE-2025-0677_CVE-2025-0684_CVE-2025-0685_CVE-2025-0686_CVE-2025-0689.patch \
38 file://CVE-2025-0678_CVE-2025-1125.patch \
32" 39"
33SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934" 40
34SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea" 41SRC_URI[sha256sum] = "b30919fa5be280417c17ac561bb1650f60cfb80cc6237fa1e2b6f56154cb9c91"
42
43CVE_STATUS[CVE-2019-14865] = "not-applicable-platform: applies only to RHEL"
44CVE_STATUS[CVE-2023-4001] = "not-applicable-platform: Applies only to RHEL/Fedora"
45CVE_STATUS[CVE-2024-1048] = "not-applicable-platform: Applies only to RHEL/Fedora"
35 46
36DEPENDS = "flex-native bison-native gettext-native" 47DEPENDS = "flex-native bison-native gettext-native"
37 48
38COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|riscv.*)-(linux.*|freebsd.*)' 49GRUB_COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|loongarch64.*|riscv.*)-(linux.*|freebsd.*)'
39COMPATIBLE_HOST_armv7a = 'null' 50COMPATIBLE_HOST = "${GRUB_COMPATIBLE_HOST}"
40COMPATIBLE_HOST_armv7ve = 'null' 51# Grub doesn't support hard float toolchain and won't be able to forcefully
52# disable it on some of the target CPUs. See 'configure.ac' for
53# supported/unsupported CPUs in hardfp.
54COMPATIBLE_HOST:armv7a = "${@'null' if bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', True, False, d) else d.getVar('GRUB_COMPATIBLE_HOST')}"
55COMPATIBLE_HOST:armv7ve = "${@'null' if bb.utils.contains('TUNE_CCARGS_MFLOAT', 'hard', True, False, d) else d.getVar('GRUB_COMPATIBLE_HOST')}"
41 56
42# configure.ac has code to set this automagically from the target tuple 57# 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. 58# but the OE freeform one (core2-foo-bar-linux) don't work with that.
44 59
45GRUBPLATFORM_arm = "efi" 60GRUBPLATFORM:arm = "efi"
46GRUBPLATFORM_aarch64 = "efi" 61GRUBPLATFORM:aarch64 = "efi"
47GRUBPLATFORM_riscv32 = "efi" 62GRUBPLATFORM:loongarch64 = "efi"
48GRUBPLATFORM_riscv64 = "efi" 63GRUBPLATFORM:riscv32 = "efi"
64GRUBPLATFORM:riscv64 = "efi"
49GRUBPLATFORM ??= "pc" 65GRUBPLATFORM ??= "pc"
50 66
51inherit autotools gettext texinfo pkgconfig 67inherit autotools gettext texinfo pkgconfig
52 68
69CFLAGS:remove = "-O2"
70# It doesn't support sse, its make.defaults sets:
71# CFLAGS += -mno-mmx -mno-sse
72# So also remove -mfpmath=sse from TUNE_CCARGS
73TUNE_CCARGS:remove = "-mfpmath=sse"
74
53EXTRA_OECONF = "--with-platform=${GRUBPLATFORM} \ 75EXTRA_OECONF = "--with-platform=${GRUBPLATFORM} \
54 --disable-grub-mkfont \ 76 --disable-grub-mkfont \
55 --program-prefix="" \ 77 --program-prefix="" \
@@ -74,8 +96,17 @@ BUILD_LDFLAGS = ""
74 96
75export PYTHON = "python3" 97export PYTHON = "python3"
76 98
77do_configure_prepend() { 99do_configure:prepend() {
78 cd ${S} 100 cd ${S}
101
102 # Remove in next version.
103 # See: https://git.savannah.gnu.org/cgit/grub.git/commit/?id=b835601c7639ed1890f2d3db91900a8506011a8e
104 echo "depends bli part_gpt" > ${S}/grub-core/extra_deps.lst
105
79 FROM_BOOTSTRAP=1 ${S}/autogen.sh 106 FROM_BOOTSTRAP=1 ${S}/autogen.sh
80 cd ${B} 107 cd ${B}
81} 108}
109
110# | aarch64-poky-linux-clang: error: invalid argument '-mcmodel=large' only allowed with '-fno-pic'
111# see - https://bugs.gentoo.org/942843
112TOOLCHAIN:aarch64 = "gcc"
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..ab2d68d6a1 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,25 +19,24 @@ 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 ."
28 26
29S = "${WORKDIR}" 27S = "${UNPACKDIR}"
30 28
31do_install () { 29do_install () {
32 # Only install the script if 'sysvinit' is in DISTRO_FEATURES 30 # Only install the script if 'sysvinit' is in DISTRO_FEATURES
33 # THe ulitity this script provides could be achieved by systemd-vconsole-setup.service 31 # THe ulitity this script provides could be achieved by systemd-vconsole-setup.service
34 if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then 32 if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then
35 install -d ${D}${sysconfdir}/init.d/ 33 install -d ${D}${sysconfdir}/init.d/
36 install -m 0755 ${WORKDIR}/keymap.sh ${D}${sysconfdir}/init.d/ 34 install -m 0755 ${S}/keymap.sh ${D}${sysconfdir}/init.d/
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/files/0001-libacpi-Fix-build-witth-fno-commom.patch b/meta/recipes-bsp/libacpi/files/0001-libacpi-Fix-build-witth-fno-commom.patch
index 32808fb92a..e8ff78082c 100644
--- a/meta/recipes-bsp/libacpi/files/0001-libacpi-Fix-build-witth-fno-commom.patch
+++ b/meta/recipes-bsp/libacpi/files/0001-libacpi-Fix-build-witth-fno-commom.patch
@@ -3,7 +3,7 @@ From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 5 Aug 2020 12:06:01 -0700 3Date: Wed, 5 Aug 2020 12:06:01 -0700
4Subject: [PATCH] libacpi: Fix build witth -fno-commom 4Subject: [PATCH] libacpi: Fix build witth -fno-commom
5 5
6Upstream-Status: Pending 6Upstream-Status: Inactive-Upstream [last release before 2008, no vcs]
7 7
8Signed-off-by: Khem Raj <raj.khem@gmail.com> 8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9--- 9---
diff --git a/meta/recipes-bsp/libacpi/files/ldflags.patch b/meta/recipes-bsp/libacpi/files/ldflags.patch
index a7424c39da..db0974104b 100644
--- a/meta/recipes-bsp/libacpi/files/ldflags.patch
+++ b/meta/recipes-bsp/libacpi/files/ldflags.patch
@@ -1,7 +1,6 @@
1libacpi: Remove QA warning: No GNU_HASH in the elf binary 1libacpi: Remove QA warning: No GNU_HASH in the elf binary
2 2
3Upstream-Status: Inappropriate [other] 3Upstream-Status: Inactive-Upstream [last release before 2008, no vcs]
4 Useful within bitbake environment only.
5 4
6Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com> 5Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com>
7 6
diff --git a/meta/recipes-bsp/libacpi/files/libacpi_fix_for_x32.patch b/meta/recipes-bsp/libacpi/files/libacpi_fix_for_x32.patch
index 06f20e5a78..955a175c96 100644
--- a/meta/recipes-bsp/libacpi/files/libacpi_fix_for_x32.patch
+++ b/meta/recipes-bsp/libacpi/files/libacpi_fix_for_x32.patch
@@ -1,4 +1,4 @@
1Upstream-Status: Pending 1Upstream-Status: Inactive-Upstream [last release before 2008, no vcs]
2 2
3Fix libacpi for x32 3Fix libacpi for x32
4 4
diff --git a/meta/recipes-bsp/libacpi/files/makefile-fix.patch b/meta/recipes-bsp/libacpi/files/makefile-fix.patch
index c34ef34e09..3b91bfaee1 100644
--- a/meta/recipes-bsp/libacpi/files/makefile-fix.patch
+++ b/meta/recipes-bsp/libacpi/files/makefile-fix.patch
@@ -1,4 +1,4 @@
1Upstream-Status: Pending 1Upstream-Status: Inactive-Upstream [last release before 2008, no vcs]
2 2
3--- 3---
4 Makefile | 6 +++--- 4 Makefile | 6 +++---
diff --git a/meta/recipes-bsp/libacpi/files/use_correct_strip_in_cross_environment.patch b/meta/recipes-bsp/libacpi/files/use_correct_strip_in_cross_environment.patch
index ef376aa316..901e5fa3b4 100644
--- a/meta/recipes-bsp/libacpi/files/use_correct_strip_in_cross_environment.patch
+++ b/meta/recipes-bsp/libacpi/files/use_correct_strip_in_cross_environment.patch
@@ -1,4 +1,4 @@
1Upstream-Status: Pending 1Upstream-Status: Inactive-Upstream [last release before 2008, no vcs]
2 2
3Used the cross strip instead of host strip to avoid this build error: 3Used the cross strip instead of host strip to avoid this build error:
4 4
diff --git a/meta/recipes-bsp/libacpi/libacpi_0.2.bb b/meta/recipes-bsp/libacpi/libacpi_0.2.bb
index fa9e3d4894..f939d11f4c 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 \
@@ -15,14 +14,13 @@ SRC_URI = "http://www.ngolde.de/download/libacpi-${PV}.tar.gz \
15 file://0001-libacpi-Fix-build-witth-fno-commom.patch \ 14 file://0001-libacpi-Fix-build-witth-fno-commom.patch \
16 " 15 "
17 16
18SRC_URI[md5sum] = "05b53dd7bead66dda35fec502b91066c"
19SRC_URI[sha256sum] = "13086e31d428b9c125954d48ac497b754bbbce2ef34ea29ecd903e82e25bad29" 17SRC_URI[sha256sum] = "13086e31d428b9c125954d48ac497b754bbbce2ef34ea29ecd903e82e25bad29"
20 18
21UPSTREAM_CHECK_URI = "http://www.ngolde.de/libacpi.html" 19UPSTREAM_CHECK_URI = "http://www.ngolde.de/libacpi.html"
22 20
23inherit lib_package 21inherit lib_package
24 22
25COMPATIBLE_HOST = '(x86_64|i.86).*-(linux|freebsd.*)' 23COMPATIBLE_HOST = '(x86_64|i.86|aarch64).*-(linux|freebsd.*)'
26 24
27CFLAGS += "-fPIC" 25CFLAGS += "-fPIC"
28EXTRA_OEMAKE = '-e MAKEFLAGS= STRIP="echo"' 26EXTRA_OEMAKE = '-e MAKEFLAGS= STRIP="echo"'
diff --git a/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-build-with-GCC-15.patch b/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-build-with-GCC-15.patch
new file mode 100644
index 0000000000..e5e9125eea
--- /dev/null
+++ b/meta/recipes-bsp/lrzsz/lrzsz-0.12.20/0001-Fix-build-with-GCC-15.patch
@@ -0,0 +1,186 @@
1From 3739faa41f60841d5277344b17ddc69e78ed8996 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 22 Mar 2025 22:58:33 -0700
4Subject: [PATCH] Fix build with GCC 15
5
6This is collection of changes needed to get compiling with gcc-15
7which switched to use C23 as default std.
8
9Upstream-Status: Submitted [https://github.com/UweOhse/lrzsz/pull/8]
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 lib/error.c | 2 +-
13 lib/getopt.h | 2 +-
14 lib/long-options.c | 4 ++--
15 lib/long-options.h | 2 +-
16 lib/xstrtol.c | 2 --
17 src/lrz.c | 8 +-------
18 src/lsz.c | 8 +-------
19 src/tcp.c | 2 +-
20 src/zglobal.h | 2 +-
21 src/zreadline.c | 2 +-
22 10 files changed, 10 insertions(+), 24 deletions(-)
23
24diff --git a/lib/error.c b/lib/error.c
25index 8f679c7..4632c9c 100644
26--- a/lib/error.c
27+++ b/lib/error.c
28@@ -73,7 +73,7 @@ extern char *program_name;
29
30 # if HAVE_STRERROR
31 # ifndef strerror /* On some systems, strerror is a macro */
32-char *strerror ();
33+char *strerror (int);
34 # endif
35 # else
36 static char *
37diff --git a/lib/getopt.h b/lib/getopt.h
38index 4ac33b7..46971cb 100644
39--- a/lib/getopt.h
40+++ b/lib/getopt.h
41@@ -101,7 +101,7 @@ struct option
42 errors, only prototype getopt for the GNU C library. */
43 extern int getopt (int argc, char *const *argv, const char *shortopts);
44 #else /* not __GNU_LIBRARY__ */
45-extern int getopt ();
46+extern int getopt (int, char * const [], const char *);
47 #endif /* __GNU_LIBRARY__ */
48 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
49 const struct option *longopts, int *longind);
50diff --git a/lib/long-options.c b/lib/long-options.c
51index 9ee8f66..2c8d267 100644
52--- a/lib/long-options.c
53+++ b/lib/long-options.c
54@@ -40,7 +40,7 @@ parse_long_options (argc, argv,version, usage)
55 int argc;
56 char **argv;
57 void (*version)();
58- void (*usage)();
59+ void (*usage)(int);
60 {
61 int c;
62 int saved_opterr;
63@@ -61,7 +61,7 @@ parse_long_options (argc, argv,version, usage)
64 (*usage) (0);
65
66 case 'v':
67- (*version) (0);
68+ (*version) ();
69 /* printf ("%s (%s) %s\n", command_name, package, version_string); */
70 exit (0);
71
72diff --git a/lib/long-options.h b/lib/long-options.h
73index 14459cd..3fb8fa6 100644
74--- a/lib/long-options.h
75+++ b/lib/long-options.h
76@@ -6,5 +6,5 @@
77 #endif
78
79 void parse_long_options __P ((int _argc, char **_argv,
80- void (*_version) (void),
81+ void (*_version) (),
82 void (*_usage) (int)));
83diff --git a/lib/xstrtol.c b/lib/xstrtol.c
84index 8755cf4..0ab337d 100644
85--- a/lib/xstrtol.c
86+++ b/lib/xstrtol.c
87@@ -65,8 +65,6 @@ extern int errno;
88 } \
89 while (0)
90
91-__unsigned long int __strtol ();
92-
93 /* FIXME: comment. */
94
95 strtol_error
96diff --git a/src/lrz.c b/src/lrz.c
97index b3cf1d5..ae3c62d 100644
98--- a/src/lrz.c
99+++ b/src/lrz.c
100@@ -41,12 +41,6 @@
101 #include "xstrtoul.h"
102 #include "error.h"
103
104-#ifndef STRICT_PROTOTYPES
105-extern time_t time();
106-extern char *strerror();
107-extern char *strstr();
108-#endif
109-
110 #ifndef HAVE_ERRNO_DECLARATION
111 extern int errno;
112 #endif
113@@ -191,7 +185,7 @@ int enable_syslog=FALSE;
114
115
116 /* called by signal interrupt or terminate to clean things up */
117-RETSIGTYPE
118+void
119 bibi(int n)
120 {
121 if (zmodem_requested)
122diff --git a/src/lsz.c b/src/lsz.c
123index e9e4660..69f4fb8 100644
124--- a/src/lsz.c
125+++ b/src/lsz.c
126@@ -50,12 +50,6 @@ void *mm_addr=NULL;
127 #include "xstrtoul.h"
128 #include "error.h"
129
130-#ifndef STRICT_PROTOTYPES
131-extern time_t time();
132-extern char *strerror();
133-extern char *strstr();
134-#endif
135-
136 #ifndef HAVE_ERRNO_DECLARATION
137 extern int errno;
138 #endif
139@@ -218,7 +212,7 @@ static int zrqinits_sent=0;
140 static int play_with_sigint=0;
141
142 /* called by signal interrupt or terminate to clean things up */
143-RETSIGTYPE
144+void
145 bibi (int n)
146 {
147 canit(STDOUT_FILENO);
148diff --git a/src/tcp.c b/src/tcp.c
149index 137f94c..a885d5b 100644
150--- a/src/tcp.c
151+++ b/src/tcp.c
152@@ -38,7 +38,7 @@
153 #include <stdlib.h>
154 #include "error.h"
155
156-static RETSIGTYPE
157+static void
158 tcp_alarm_handler(int dummy LRZSZ_ATTRIB_UNUSED)
159 {
160 /* doesn't need to do anything */
161diff --git a/src/zglobal.h b/src/zglobal.h
162index 573b461..55bd58f 100644
163--- a/src/zglobal.h
164+++ b/src/zglobal.h
165@@ -357,7 +357,7 @@ extern int no_timeout;
166 extern int Zctlesc; /* Encode control characters */
167 extern int under_rsh;
168
169-RETSIGTYPE bibi __P ((int n));
170+void bibi __P ((int n));
171
172 #define sendline(c) putchar((c) & 0377)
173 #define xsendline(c) putchar(c)
174diff --git a/src/zreadline.c b/src/zreadline.c
175index aeda95c..c8f8263 100644
176--- a/src/zreadline.c
177+++ b/src/zreadline.c
178@@ -43,7 +43,7 @@ static char *readline_buffer;
179 int readline_left=0;
180 char *readline_ptr;
181
182-static RETSIGTYPE
183+static void
184 zreadline_alarm_handler(int dummy LRZSZ_ATTRIB_UNUSED)
185 {
186 /* doesn't need to do anything */
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..777560bd22 100644
--- a/meta/recipes-bsp/lrzsz/lrzsz_0.12.20.bb
+++ b/meta/recipes-bsp/lrzsz/lrzsz_0.12.20.bb
@@ -5,24 +5,22 @@ 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 = "https://www.ohse.de/uwe/releases/lrzsz-${PV}.tar.gz \
16 file://autotools-update.patch \ 15 file://autotools-update.patch \
17 file://autotools.patch \ 16 file://autotools.patch \
18 file://makefile.patch \ 17 file://makefile.patch \
19 file://lrzsz-check-locale.h.patch \ 18 file://lrzsz-check-locale.h.patch \
20 file://cve-2018-10195.patch \ 19 file://cve-2018-10195.patch \
21 file://include.patch \ 20 file://include.patch \
22 file://0001-Fix-cross-compilation-using-autoconf-detected-AR.patch \ 21 file://0001-Fix-cross-compilation-using-autoconf-detected-AR.patch \
22 file://0001-Fix-build-with-GCC-15.patch \
23 " 23 "
24
25SRC_URI[md5sum] = "b5ce6a74abc9b9eb2af94dffdfd372a4"
26SRC_URI[sha256sum] = "c28b36b14bddb014d9e9c97c52459852f97bd405f89113f30bee45ed92728ff1" 24SRC_URI[sha256sum] = "c28b36b14bddb014d9e9c97c52459852f97bd405f89113f30bee45ed92728ff1"
27 25
28UPSTREAM_CHECK_URI = "http://ohse.de/uwe/software/lrzsz.html" 26UPSTREAM_CHECK_URI = "http://ohse.de/uwe/software/lrzsz.html"
@@ -38,7 +36,7 @@ inherit update-alternatives
38 36
39ALTERNATIVE_PRIORITY = "100" 37ALTERNATIVE_PRIORITY = "100"
40 38
41ALTERNATIVE_${PN} = "rz rx rb sz sx sb" 39ALTERNATIVE:${PN} = "rz rx rb sz sx sb"
42 40
43ALTERNATIVE_TARGET[rz] = "${bindir}/lrz" 41ALTERNATIVE_TARGET[rz] = "${bindir}/lrz"
44ALTERNATIVE_TARGET[rx] = "${bindir}/lrz" 42ALTERNATIVE_TARGET[rx] = "${bindir}/lrz"
@@ -47,3 +45,9 @@ ALTERNATIVE_TARGET[rb] = "${bindir}/lrz"
47ALTERNATIVE_TARGET[sz] = "${bindir}/lsz" 45ALTERNATIVE_TARGET[sz] = "${bindir}/lsz"
48ALTERNATIVE_TARGET[sx] = "${bindir}/lsz" 46ALTERNATIVE_TARGET[sx] = "${bindir}/lsz"
49ALTERNATIVE_TARGET[sb] = "${bindir}/lsz" 47ALTERNATIVE_TARGET[sb] = "${bindir}/lsz"
48
49# http://errors.yoctoproject.org/Errors/Details/766929/
50# lrzsz-0.12.20/src/tcp.c:75:56: error: passing argument 3 of 'getsockname' from incompatible pointer type [-Wincompatible-pointer-types]
51# lrzsz-0.12.20/src/tcp.c:83:52: error: passing argument 3 of 'getsockname' from incompatible pointer type [-Wincompatible-pointer-types]
52# lrzsz-0.12.20/src/tcp.c:103:51: error: passing argument 3 of 'accept' from incompatible pointer type [-Wincompatible-pointer-types]
53CFLAGS += "-Wno-error=incompatible-pointer-types"
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.7.bb
index cb1c3f2ebf..a460062e93 100644
--- a/meta/recipes-bsp/opensbi/opensbi_0.9.bb
+++ b/meta/recipes-bsp/opensbi/opensbi_1.7.bb
@@ -6,23 +6,31 @@ LIC_FILES_CHKSUM = "file://COPYING.BSD;md5=42dd9555eb177f35150cf9aa240b61e5"
6 6
7require opensbi-payloads.inc 7require opensbi-payloads.inc
8 8
9inherit autotools-brokensep deploy 9inherit deploy
10 10
11SRCREV = "234ed8e427f4d92903123199f6590d144e0d9351" 11SRCREV = "a32a91069119e7a5aa31e6bc51d5e00860be3d80"
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" 14TARGET_DBGSRC_DIR = "/share/opensbi/*/generic/firmware/"
17 15
18EXTRA_OEMAKE += "PLATFORM=${RISCV_SBI_PLAT} I=${D}" 16TARGET_CC_ARCH += "${LDFLAGS}"
17
18RISCV_SBI_FW_TEXT_START ??= "0x80000000"
19EXTRA_OEMAKE += "REPRODUCIBLE=y CROSS_COMPILE=${HOST_PREFIX} ELFFLAGS="${LDFLAGS}" PLATFORM=${RISCV_SBI_PLAT} I=${D} FW_TEXT_START=${RISCV_SBI_FW_TEXT_START}"
20EXTRA_OEMAKE:append:toolchain-clang = " LLVM=y"
19# If RISCV_SBI_PAYLOAD is set then include it as a payload 21# If RISCV_SBI_PAYLOAD is set then include it as a payload
20EXTRA_OEMAKE_append = " ${@riscv_get_extra_oemake_image(d)}" 22EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_image(d)}"
23EXTRA_OEMAKE:append = " ${@riscv_get_extra_oemake_fdt(d)}"
21 24
22# Required if specifying a custom payload 25# Required if specifying a custom payload
23do_compile[depends] += "${@riscv_get_do_compile_depends(d)}" 26do_compile[depends] += "${@riscv_get_do_compile_depends(d)}"
24 27
25do_install_append() { 28do_compile() {
29 oe_runmake
30}
31
32do_install() {
33 oe_runmake DESTDIR=${D} install
26 # In the future these might be required as a dependency for other packages. 34 # In the future these might be required as a dependency for other packages.
27 # At the moment just delete them to avoid warnings 35 # At the moment just delete them to avoid warnings
28 rm -r ${D}/include 36 rm -r ${D}/include
@@ -38,11 +46,8 @@ do_deploy () {
38 46
39addtask deploy before do_build after do_install 47addtask deploy before do_build after do_install
40 48
41FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*" 49FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_jump.*"
42FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*" 50FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_payload.*"
43FILES_${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_dynamic.*" 51FILES:${PN} += "/share/opensbi/*/${RISCV_SBI_PLAT}/firmware/fw_dynamic.*"
44 52
45COMPATIBLE_HOST = "(riscv64|riscv32).*" 53COMPATIBLE_HOST = "(riscv64|riscv32).*"
46INHIBIT_PACKAGE_STRIP = "1"
47
48SECURITY_CFLAGS = ""
diff --git a/meta/recipes-bsp/pciutils/pciutils/configure.patch b/meta/recipes-bsp/pciutils/pciutils/configure.patch
deleted file mode 100644
index e444c13975..0000000000
--- a/meta/recipes-bsp/pciutils/pciutils/configure.patch
+++ /dev/null
@@ -1,81 +0,0 @@
1This patch:
2* ensures we link correctly
3* 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
5
6This is a merge of various tweaks to allow us to build pciutils including
7work from:
8
97/30/2010 - Qing He <qing.he@intel.com>
101/22/2012 - Shane Wang <shane.wang@intel.com>
11Ionut Radu <ionutx.radu@intel.com>
122017/6/15 - RP - Cleanups and merging patches
13
14Upstream-Status: Inappropriate [embedded specific]
15
16Index: pciutils-3.5.6/Makefile
17===================================================================
18--- pciutils-3.5.6.orig/Makefile
19+++ pciutils-3.5.6/Makefile
20@@ -96,7 +96,7 @@ example: example.o lib/$(PCILIB)
21 example.o: example.c $(PCIINC)
22
23 %: %.o
24- $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
25+ $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LIB_LDLIBS) $(LDLIBS) -o $@
26
27 %.8 %.7 %.5: %.man
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)#"
29Index: pciutils-3.5.6/lib/configure
30===================================================================
31--- pciutils-3.5.6.orig/lib/configure
32+++ pciutils-3.5.6/lib/configure
33@@ -9,6 +9,10 @@ echo_n() {
34 printf '%s' "$*"
35 }
36
37+VERSION=$1
38+IDSDIR=$2
39+DNS=yes
40+
41 if [ -z "$VERSION" -o -z "$IDSDIR" ] ; then
42 echo >&2 "Please run the configure script from the top-level Makefile"
43 exit 1
44@@ -16,8 +20,8 @@ fi
45
46 echo_n "Configuring libpci for your system..."
47 if [ -z "$HOST" ] ; then
48- sys=`uname -s`
49- rel=`uname -r`
50+ sys=${3:-`uname -s`}
51+ rel=
52 realsys="$sys"
53 if [ "$sys" = "AIX" -a -x /usr/bin/oslevel -a -x /usr/sbin/lsattr ]
54 then
55@@ -25,7 +29,7 @@ if [ -z "$HOST" ] ; then
56 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/_.*//'`
58 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/'`
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/'`}
61 fi
62 if [ "$sys" = "GNU/kFreeBSD" -o "$sys" = "DragonFly" ]
63 then
64@@ -35,7 +39,7 @@ if [ -z "$HOST" ] ; then
65 then
66 sys=cygwin
67 fi
68- HOST=${3:-$cpu-$sys}
69+ HOST=$cpu-$sys
70 fi
71 [ -n "$RELEASE" ] && rel="${RELEASE}"
72 # 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/'`
74 sys=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
75 echo " $host $rel $cpu $sys"
76
77+{ echo "$host" | grep linux; } && sys=linux
78+
79 c=config.h
80 m=config.mk
81 echo >$c '#define PCI_CONFIG_H'
diff --git a/meta/recipes-bsp/pciutils/pciutils_3.14.0.bb b/meta/recipes-bsp/pciutils/pciutils_3.14.0.bb
new file mode 100644
index 0000000000..a267ea34b7
--- /dev/null
+++ b/meta/recipes-bsp/pciutils/pciutils_3.14.0.bb
@@ -0,0 +1,55 @@
1SUMMARY = "PCI utilities"
2DESCRIPTION = 'The PCI Utilities package contains a library for portable access \
3to PCI bus configuration space and several utilities based on this library.'
4HOMEPAGE = "https://mj.ucw.cz/sw/pciutils/"
5SECTION = "console/utils"
6
7LICENSE = "GPL-2.0-or-later"
8LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
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 = "make-native"
13
14SRC_URI = "${KERNELORG_MIRROR}/software/utils/pciutils/pciutils-${PV}.tar.xz"
15SRC_URI[sha256sum] = "e7713409882813991d2269d125e40dad1f54a019a52b78b3962941c1d4a6f86f"
16
17inherit multilib_header pkgconfig update-alternatives
18
19PACKAGECONFIG ??= "hwdb kmod zlib"
20PACKAGECONFIG[hwdb] = "HWDB=yes,HWDB=no,udev"
21PACKAGECONFIG[kmod] = "LIBKMOD=yes,LIBKMOD=no,kmod"
22PACKAGECONFIG[zlib] = "ZLIB=yes,ZLIB=no,zlib"
23
24# Configuration options
25EXTRA_OEMAKE += "${PACKAGECONFIG_CONFARGS} DNS=yes SHARED=yes"
26# Construct a HOST that matches what lib/configure expects
27EXTRA_OEMAKE += "HOST="${HOST_ARCH}-${HOST_OS}""
28# Toolchain. We need to pass CFLAGS via CC as this is the only variable
29# available to the caller without clobbering assignments (notably, -fPIC)
30EXTRA_OEMAKE += "CC="${CC} ${CFLAGS}" AR="${AR}" STRIP= LDFLAGS="${LDFLAGS}""
31# Paths
32EXTRA_OEMAKE += "PREFIX=${prefix} LIBDIR=${libdir} SBINDIR=${sbindir} SHAREDIR=${datadir} MANDIR=${mandir}"
33
34do_install () {
35 # Do these in separate calls as they expose a race in pseudo when creating
36 # symlinks when ran in parallel.
37 oe_runmake DESTDIR=${D} install
38 oe_runmake DESTDIR=${D} install-lib
39
40 install -d ${D}${bindir}
41
42 oe_multilib_header pci/config.h
43}
44
45PACKAGES =+ "${PN}-ids libpci"
46
47FILES:${PN}-ids = "${datadir}/pci.ids*"
48SUMMARY:${PN}-ids = "PCI utilities - device ID database"
49DESCRIPTION:${PN}-ids = "Package providing the PCI device ID database for pciutils."
50RDEPENDS:${PN} += "${PN}-ids"
51
52FILES:libpci = "${libdir}/libpci.so.*"
53
54ALTERNATIVE:${PN} = "lspci"
55ALTERNATIVE_PRIORITY = "100"
diff --git a/meta/recipes-bsp/pciutils/pciutils_3.7.0.bb b/meta/recipes-bsp/pciutils/pciutils_3.7.0.bb
deleted file mode 100644
index 4f0edc01ed..0000000000
--- a/meta/recipes-bsp/pciutils/pciutils_3.7.0.bb
+++ /dev/null
@@ -1,59 +0,0 @@
1SUMMARY = "PCI utilities"
2DESCRIPTION = 'The PCI Utilities package contains a library for portable access \
3to PCI bus configuration space and several utilities based on this library.'
4HOMEPAGE = "http://atrey.karlin.mff.cuni.cz/~mj/pciutils.shtml"
5SECTION = "console/utils"
6
7LICENSE = "GPLv2+"
8LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
9DEPENDS = "zlib kmod"
10
11SRC_URI = "${KERNELORG_MIRROR}/software/utils/pciutils/pciutils-${PV}.tar.xz \
12 file://configure.patch"
13
14SRC_URI[sha256sum] = "9d40b97be8b6a2cdf96aead5a61881d1f7e4e0da9544a9bac4fba1ae9dcd40eb"
15
16inherit multilib_header pkgconfig
17
18PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'hwdb', '', d)}"
19PACKAGECONFIG[hwdb] = "HWDB=yes,HWDB=no,udev"
20
21PCI_CONF_FLAG = "ZLIB=yes DNS=yes SHARED=yes STRIP= LIBDIR=${libdir}"
22
23# see configure.patch
24do_configure () {
25 (
26 cd lib && \
27 # PACKAGECONFIG_CONFARGS for this recipe could only possibly contain 'HWDB=yes/no',
28 # so we put it before ./configure
29 ${PCI_CONF_FLAG} ${PACKAGECONFIG_CONFARGS} ./configure ${PV} ${datadir} ${TARGET_OS} ${TARGET_ARCH}
30 )
31}
32
33export PREFIX = "${prefix}"
34export SBINDIR = "${sbindir}"
35export SHAREDIR = "${datadir}"
36export MANDIR = "${mandir}"
37
38EXTRA_OEMAKE = "-e MAKEFLAGS= ${PCI_CONF_FLAG}"
39
40ASNEEDED = ""
41
42# The configure script breaks if the HOST variable is set
43HOST[unexport] = "1"
44
45do_install () {
46 oe_runmake DESTDIR=${D} install install-lib
47
48 install -d ${D}${bindir}
49 ln -s ../sbin/lspci ${D}${bindir}/lspci
50
51 oe_multilib_header pci/config.h
52}
53
54PACKAGES =+ "${PN}-ids libpci"
55FILES_${PN}-ids = "${datadir}/pci.ids*"
56FILES_libpci = "${libdir}/libpci.so.*"
57SUMMARY_${PN}-ids = "PCI utilities - device ID database"
58DESCRIPTION_${PN}-ids = "Package providing the PCI device ID database for pciutils."
59RDEPENDS_${PN} += "${PN}-ids"
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..8756511c17 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,26 +2,26 @@ 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
11SRC_URI = "http://pm-utils.freedesktop.org/releases/pm-utils-${PV}.tar.gz" 9SRC_URI = "http://pm-utils.freedesktop.org/releases/pm-utils-${PV}.tar.gz"
12 10
13SRC_URI[md5sum] = "1742a556089c36c3a89eb1b957da5a60"
14SRC_URI[sha256sum] = "8ed899032866d88b2933a1d34cc75e8ae42dcde20e1cc21836baaae3d4370c0b" 11SRC_URI[sha256sum] = "8ed899032866d88b2933a1d34cc75e8ae42dcde20e1cc21836baaae3d4370c0b"
15 12
16inherit pkgconfig autotools manpages 13inherit pkgconfig autotools manpages
17 14
18PACKAGECONFIG[manpages] = "--enable-doc, --disable-doc, libxslt-native xmlto-native" 15PACKAGECONFIG[manpages] = "--enable-doc, --disable-doc, libxslt-native xmlto-native"
19 16
20RDEPENDS_${PN} = "grep bash" 17RDEPENDS:${PN} = "bash"
18
19EXTRA_OECONF = "--libdir=${nonarch_libdir}"
21 20
22do_configure_prepend () { 21do_configure:prepend () {
23 ( cd ${S}; autoreconf -f -i -s ) 22 ( cd ${S}; autoreconf -f -i -s )
24} 23}
25 24
26FILES_${PN} += "${libdir}/${BPN}/*" 25FILES:${PN} += "${nonarch_libdir}/${BPN}/*"
27FILES_${PN}-dbg += "${datadir}/doc/pm-utils/README.debugging" 26FILES:${PN}-dbg += "${datadir}/doc/pm-utils/README.debugging"
27FILES:${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..e1e80e31ae 100644
--- a/meta/recipes-bsp/setserial/setserial_2.17.bb
+++ b/meta/recipes-bsp/setserial/setserial_2.17.bb
@@ -1,23 +1,21 @@
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
13inherit autotools-brokensep 11inherit autotools-brokensep sourceforge-releases
14 12
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"
21SRC_URI[sha256sum] = "7e4487d320ac31558563424189435d396ddf77953bb23111a17a3d1487b5794a" 19SRC_URI[sha256sum] = "7e4487d320ac31558563424189435d396ddf77953bb23111a17a3d1487b5794a"
22 20
23do_install() { 21do_install() {
diff --git a/meta/recipes-bsp/u-boot/files/disable-CONFIG_BLOBLIST.cfg b/meta/recipes-bsp/u-boot/files/disable-CONFIG_BLOBLIST.cfg
new file mode 100644
index 0000000000..d01d3d12d8
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/disable-CONFIG_BLOBLIST.cfg
@@ -0,0 +1 @@
# CONFIG_BLOBLIST is not set
diff --git a/meta/recipes-bsp/u-boot/files/disable_CONFIG_USB.cfg b/meta/recipes-bsp/u-boot/files/disable_CONFIG_USB.cfg
new file mode 100644
index 0000000000..1d2509982b
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/disable_CONFIG_USB.cfg
@@ -0,0 +1 @@
# CONFIG_USB is not set
diff --git a/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_a.cfg b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_a.cfg
new file mode 100644
index 0000000000..fc45b64480
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_a.cfg
@@ -0,0 +1 @@
CONFIG_RISCV_ISA_A=y
diff --git a/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_c.cfg b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_c.cfg
new file mode 100644
index 0000000000..1cb459f636
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_c.cfg
@@ -0,0 +1 @@
CONFIG_RISCV_ISA_C=y
diff --git a/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_clear.cfg b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_clear.cfg
new file mode 100644
index 0000000000..ce90da23ce
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_clear.cfg
@@ -0,0 +1,6 @@
1# CONFIG_RISCV_ISA_C is not set
2# CONFIG_RISCV_ISA_F is not set
3# CONFIG_RISCV_ISA_D is not set
4# CONFIG_RISCV_ISA_ZBB is not set
5# CONFIG_RISCV_ISA_A is not set
6# CONFIG_RISCV_ISA_ZICBOM is not set
diff --git a/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_d.cfg b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_d.cfg
new file mode 100644
index 0000000000..fd25fa4e89
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_d.cfg
@@ -0,0 +1 @@
CONFIG_RISCV_ISA_D=y
diff --git a/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_f.cfg b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_f.cfg
new file mode 100644
index 0000000000..dfa9876f82
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_f.cfg
@@ -0,0 +1 @@
CONFIG_RISCV_ISA_F=y
diff --git a/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zbb.cfg b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zbb.cfg
new file mode 100644
index 0000000000..2b71b016f8
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zbb.cfg
@@ -0,0 +1 @@
CONFIG_RISCV_ISA_ZBB=y
diff --git a/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zicbom.cfg b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zicbom.cfg
new file mode 100644
index 0000000000..96daf04b20
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/files/u-boot-riscv-isa_zicbom.cfg
@@ -0,0 +1 @@
CONFIG_RISCV_ISA_ZICBOM=y
diff --git a/meta/recipes-bsp/u-boot/libubootenv/0001-Update-cmake_minimum_required-to-3.5.patch b/meta/recipes-bsp/u-boot/libubootenv/0001-Update-cmake_minimum_required-to-3.5.patch
new file mode 100644
index 0000000000..ee174ca59e
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/libubootenv/0001-Update-cmake_minimum_required-to-3.5.patch
@@ -0,0 +1,50 @@
1From cd12d9dd2bea8e4580f458df77229477fc55ba70 Mon Sep 17 00:00:00 2001
2From: James Hilliard <james.hilliard1@gmail.com>
3Date: Wed, 14 May 2025 14:17:40 -0600
4Subject: [PATCH] Update cmake_minimum_required to 3.5
5
6This supports compilation with cmake-4.0.0.
7
8Fixes:
9CMake Error at CMakeLists.txt:5 (cmake_minimum_required):
10 Compatibility with CMake < 3.5 has been removed from CMake.
11
12 Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
13 to tell CMake that the project requires at least <min> but has been updated
14 to work with policies introduced by <max> or earlier.
15
16 Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
17
18Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
19Upstream-Status: Backport [cd12d9dd2bea8e4580f458df77229477fc55ba70]
20---
21 CMakeLists.txt | 2 +-
22 src/CMakeLists.txt | 2 +-
23 2 files changed, 2 insertions(+), 2 deletions(-)
24
25diff --git a/CMakeLists.txt b/CMakeLists.txt
26index 796d7bc..0a11730 100644
27--- a/CMakeLists.txt
28+++ b/CMakeLists.txt
29@@ -2,7 +2,7 @@
30 #
31 # SPDX-License-Identifier: LGPL-2.1-or-later
32
33-cmake_minimum_required (VERSION 2.6)
34+cmake_minimum_required (VERSION 3.5)
35 project (libubootenv C)
36
37 # The version number.
38diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
39index c56d0c7..3370232 100644
40--- a/src/CMakeLists.txt
41+++ b/src/CMakeLists.txt
42@@ -1,7 +1,7 @@
43 # SPDX-FileCopyrightText: 2019-2021 Stefano Babic <stefano.babic@swupdate.org>
44 #
45 # SPDX-License-Identifier: LGPL-2.1-or-later
46-cmake_minimum_required (VERSION 2.6)
47+cmake_minimum_required (VERSION 3.5)
48 # Sources and private headers
49 SET(libubootenv_SOURCES
50 uboot_env.c
diff --git a/meta/recipes-bsp/u-boot/libubootenv_0.3.1.bb b/meta/recipes-bsp/u-boot/libubootenv_0.3.1.bb
deleted file mode 100644
index 613e3161fb..0000000000
--- a/meta/recipes-bsp/u-boot/libubootenv_0.3.1.bb
+++ /dev/null
@@ -1,30 +0,0 @@
1SUMMARY = "U-Boot libraries and tools to access environment"
2
3DESCRIPTION = "This package contains tools and libraries to read \
4and modify U-Boot environment. \
5It provides a hardware-independent replacement for fw_printenv/setenv utilities \
6provided by U-Boot"
7
8HOMEPAGE = "https://github.com/sbabic/libubootenv"
9LICENSE = "LGPL-2.1"
10LIC_FILES_CHKSUM = "file://Licenses/lgpl-2.1.txt;md5=4fbd65380cdd255951079008b364516c"
11SECTION = "libs"
12
13SRC_URI = "git://github.com/sbabic/libubootenv;protocol=https"
14SRCREV = "824551ac77bab1d0f7ae34d7a7c77b155240e754"
15
16S = "${WORKDIR}/git"
17
18inherit uboot-config cmake lib_package
19
20EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release"
21
22DEPENDS = "zlib"
23PROVIDES += "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
30BBCLASSEXTEND = "native"
diff --git a/meta/recipes-bsp/u-boot/libubootenv_0.3.6.bb b/meta/recipes-bsp/u-boot/libubootenv_0.3.6.bb
new file mode 100644
index 0000000000..b63b8ff87d
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/libubootenv_0.3.6.bb
@@ -0,0 +1,26 @@
1SUMMARY = "U-Boot libraries and tools to access environment"
2
3DESCRIPTION = "This package contains tools and libraries to read \
4and modify U-Boot environment. \
5It provides a hardware-independent replacement for fw_printenv/setenv utilities \
6provided by U-Boot"
7
8HOMEPAGE = "https://github.com/sbabic/libubootenv"
9LICENSE = "LGPL-2.1-or-later"
10LIC_FILES_CHKSUM = "file://LICENSES/LGPL-2.1-or-later.txt;md5=4fbd65380cdd255951079008b364516c"
11SECTION = "libs"
12
13SRC_URI = "git://github.com/sbabic/libubootenv;protocol=https;branch=master \
14 file://0001-Update-cmake_minimum_required-to-3.5.patch \
15 "
16SRCREV = "5507339628b5caf244e1ff9d58cb3fa534b16beb"
17
18inherit cmake lib_package
19
20EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=Release"
21
22DEPENDS = "zlib libyaml"
23PROVIDES += "u-boot-fw-utils"
24RPROVIDES:${PN}-bin += "u-boot-fw-utils"
25
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..8600d4bab6 100644
--- a/meta/recipes-bsp/u-boot/u-boot-common.inc
+++ b/meta/recipes-bsp/u-boot/u-boot-common.inc
@@ -4,19 +4,32 @@ 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 = "34820924edbc4ec7803eb89d9852f4b870fa760a"
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;tag=v${PV}"
18 " 18
19SRC_URI_RISCV = "\
20 file://u-boot-riscv-isa_clear.cfg \
21 ${@bb.utils.contains ("TUNE_FEATURES", "a", "file://u-boot-riscv-isa_a.cfg", "", d)} \
22 ${@bb.utils.contains ("TUNE_FEATURES", "f", "file://u-boot-riscv-isa_f.cfg", "", d)} \
23 ${@bb.utils.contains ("TUNE_FEATURES", "d", "file://u-boot-riscv-isa_d.cfg", "", d)} \
24 ${@bb.utils.contains_any("TUNE_FEATURES", "b zbb", "file://u-boot-riscv-isa_zbb.cfg", "", d)} \
25 ${@bb.utils.contains ("TUNE_FEATURES", "zicbom", "file://u-boot-riscv-isa_zicbom.cfg", "", d)} \
26 "
27
28SRC_URI:append:riscv32 = "${SRC_URI_RISCV}"
29SRC_URI:append:riscv64 = "${SRC_URI_RISCV}"
19 30
20S = "${WORKDIR}/git"
21B = "${WORKDIR}/build" 31B = "${WORKDIR}/build"
32
33inherit pkgconfig
34
22do_configure[cleandirs] = "${B}" 35do_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..a15511f8b2
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/u-boot-configure.inc
@@ -0,0 +1,52 @@
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 uboot_configure_config $config $type
22 fi
23 done
24 unset j
25 done
26 unset i
27 else
28 uboot_configure
29 fi
30}
31
32uboot_configure_config () {
33 config=$1
34 type=$2
35
36 oe_runmake -C ${S} O=${B}/${config} ${config}
37 if [ -n "${@' '.join(find_cfgs(d))}" ]; then
38 merge_config.sh -m -O ${B}/${config} ${B}/${config}/.config ${@" ".join(find_cfgs(d))}
39 oe_runmake -C ${S} O=${B}/${config} oldconfig
40 fi
41}
42
43uboot_configure () {
44 if [ -n "${UBOOT_MACHINE}" ]; then
45 oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE}
46 else
47 oe_runmake -C ${S} O=${B} oldconfig
48 fi
49 merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
50 cml1_do_configure
51}
52
diff --git a/meta/recipes-bsp/u-boot/u-boot-tools.inc b/meta/recipes-bsp/u-boot/u-boot-tools.inc
index 4ed936a70d..4e4f7fa092 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_2025.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_2025.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..b7242de5de 100644
--- a/meta/recipes-bsp/u-boot/u-boot.inc
+++ b/meta/recipes-bsp/u-boot/u-boot.inc
@@ -3,13 +3,14 @@ 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} V=1'
13EXTRA_OEMAKE += 'CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS} ${DEBUG_PREFIX_MAP}"'
13EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"' 14EXTRA_OEMAKE += 'HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}"'
14EXTRA_OEMAKE += 'STAGING_INCDIR=${STAGING_INCDIR_NATIVE} STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}' 15EXTRA_OEMAKE += 'STAGING_INCDIR=${STAGING_INCDIR_NATIVE} STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}'
15 16
@@ -19,92 +20,21 @@ PACKAGECONFIG ??= "openssl"
19# a host build dependency. 20# a host build dependency.
20PACKAGECONFIG[openssl] = ",,openssl-native" 21PACKAGECONFIG[openssl] = ",,openssl-native"
21 22
23CVE_PRODUCT = "denx:u-boot"
24
22# Allow setting an additional version string that will be picked up by the 25# Allow setting an additional version string that will be picked up by the
23# u-boot build system and appended to the u-boot version. If the .scmversion 26# u-boot build system and appended to the u-boot version. If the .scmversion
24# file already exists it will not be overwritten. 27# file already exists it will not be overwritten.
25UBOOT_LOCALVERSION ?= "" 28UBOOT_LOCALVERSION ?= ""
26 29
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 30# Default name of u-boot initial env, but enable individual recipes to change
64# this value. 31# this value.
65UBOOT_INITIAL_ENV ?= "${PN}-initial-env" 32UBOOT_INITIAL_ENV ?= "${PN}-initial-env"
66 33
67# U-Boot EXTLINUX variables. U-Boot searches for /boot/extlinux/extlinux.conf 34require 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
73do_configure () {
74 if [ -n "${UBOOT_CONFIG}" ]; then
75 unset i j
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}
102 35
36UBOOT_ARCH_DIR = "${@'arm' if d.getVar('UBOOT_ARCH').startswith('arm') else d.getVar('UBOOT_ARCH')}"
103do_compile () { 37do_compile () {
104 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
106 fi
107
108 unset LDFLAGS 38 unset LDFLAGS
109 unset CFLAGS 39 unset CFLAGS
110 unset CPPFLAGS 40 unset CPPFLAGS
@@ -117,40 +47,66 @@ do_compile () {
117 47
118 if [ -n "${UBOOT_CONFIG}" -o -n "${UBOOT_DELTA_CONFIG}" ] 48 if [ -n "${UBOOT_CONFIG}" -o -n "${UBOOT_DELTA_CONFIG}" ]
119 then 49 then
120 unset i j k 50 unset i j
121 for config in ${UBOOT_MACHINE}; do 51 for config in ${UBOOT_MACHINE}; do
122 i=$(expr $i + 1); 52 i=$(expr $i + 1);
123 for type in ${UBOOT_CONFIG}; do 53 for type in ${UBOOT_CONFIG}; do
124 j=$(expr $j + 1); 54 j=$(expr $j + 1);
125 if [ $j -eq $i ] 55 if [ $j -eq $i ]
126 then 56 then
127 oe_runmake -C ${S} O=${B}/${config} ${UBOOT_MAKE_TARGET} 57 uboot_compile_config $i $config $type
128 for binary in ${UBOOT_BINARIES}; do
129 k=$(expr $k + 1);
130 if [ $k -eq $i ]; then
131 cp ${B}/${config}/${binary} ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX}
132 fi
133 done
134
135 # Generate the uboot-initial-env
136 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
137 oe_runmake -C ${S} O=${B}/${config} u-boot-initial-env
138 cp ${B}/${config}/u-boot-initial-env ${B}/${config}/u-boot-initial-env-${type}
139 fi
140
141 unset k
142 fi 58 fi
143 done 59 done
144 unset j 60 unset j
145 done 61 done
146 unset i 62 unset i
147 else 63 else
148 oe_runmake -C ${S} O=${B} ${UBOOT_MAKE_TARGET} 64 uboot_compile
65 fi
66
67 if [ -n "${UBOOT_ENV}" ] && [ "${UBOOT_ENV_SUFFIX}" = "scr" ]
68 then
69 ${UBOOT_MKIMAGE} -C none -A ${UBOOT_ARCH} -T script -d ${UNPACKDIR}/${UBOOT_ENV_SRC} ${B}/${UBOOT_ENV_BINARY}
70 fi
71}
72
73uboot_compile_config () {
74 i=$1
75 config=$2
76 type=$3
149 77
150 # Generate the uboot-initial-env 78 oe_runmake -C ${S} O=${B}/${config} ${UBOOT_MAKE_TARGET}
151 if [ -n "${UBOOT_INITIAL_ENV}" ]; then 79
152 oe_runmake -C ${S} O=${B} u-boot-initial-env 80 unset k
81 for binary in ${UBOOT_BINARIES}; do
82 k=$(expr $k + 1);
83 if [ $k -eq $i ]; then
84 uboot_compile_config_copy_binary $config $type $binary
153 fi 85 fi
86 done
87 unset k
88
89 # Generate the uboot-initial-env
90 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
91 oe_runmake -C ${S} O=${B}/${config} u-boot-initial-env
92 cp ${B}/${config}/u-boot-initial-env ${B}/${config}/u-boot-initial-env-${type}
93 fi
94}
95
96uboot_compile_config_copy_binary () {
97 config=$1
98 type=$2
99 binary=$3
100
101 cp ${B}/${config}/${binary} ${B}/${config}/${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX}
102}
103
104uboot_compile () {
105 oe_runmake -C ${S} O=${B} ${UBOOT_MAKE_TARGET}
106
107 # Generate the uboot-initial-env
108 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
109 oe_runmake -C ${S} O=${B} u-boot-initial-env
154 fi 110 fi
155} 111}
156 112
@@ -163,32 +119,14 @@ do_install () {
163 j=$(expr $j + 1); 119 j=$(expr $j + 1);
164 if [ $j -eq $i ] 120 if [ $j -eq $i ]
165 then 121 then
166 install -D -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} 122 uboot_install_config $config $type
167 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
168 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}
169
170 # Install the uboot-initial-env
171 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
172 install -D -m 644 ${B}/${config}/u-boot-initial-env-${type} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}
173 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}
174 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${type}
175 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}
176 fi
177 fi 123 fi
178 done 124 done
179 unset j 125 unset j
180 done 126 done
181 unset i 127 unset i
182 else 128 else
183 install -D -m 644 ${B}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE} 129 uboot_install
184 ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY}
185
186 # Install the uboot-initial-env
187 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
188 install -D -m 644 ${B}/u-boot-initial-env ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR}
189 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}
190 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}
191 fi
192 fi 130 fi
193 131
194 if [ -n "${UBOOT_ELF}" ] 132 if [ -n "${UBOOT_ELF}" ]
@@ -201,23 +139,20 @@ do_install () {
201 j=$(expr $j + 1); 139 j=$(expr $j + 1);
202 if [ $j -eq $i ] 140 if [ $j -eq $i ]
203 then 141 then
204 install -m 644 ${B}/${config}/${UBOOT_ELF} ${D}/boot/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} 142 uboot_install_elf_config $config $type
205 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
206 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}
207 fi 143 fi
208 done 144 done
209 unset j 145 unset j
210 done 146 done
211 unset i 147 unset i
212 else 148 else
213 install -m 644 ${B}/${UBOOT_ELF} ${D}/boot/${UBOOT_ELF_IMAGE} 149 uboot_install_elf
214 ln -sf ${UBOOT_ELF_IMAGE} ${D}/boot/${UBOOT_ELF_BINARY}
215 fi 150 fi
216 fi 151 fi
217 152
218 if [ -e ${WORKDIR}/fw_env.config ] ; then 153 if [ -e ${UNPACKDIR}/fw_env.config ] ; then
219 install -d ${D}${sysconfdir} 154 install -d ${D}${sysconfdir}
220 install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config 155 install -m 644 ${UNPACKDIR}/fw_env.config ${D}${sysconfdir}/fw_env.config
221 fi 156 fi
222 157
223 if [ -n "${SPL_BINARY}" ] 158 if [ -n "${SPL_BINARY}" ]
@@ -230,23 +165,20 @@ do_install () {
230 j=$(expr $j + 1); 165 j=$(expr $j + 1);
231 if [ $j -eq $i ] 166 if [ $j -eq $i ]
232 then 167 then
233 install -m 644 ${B}/${config}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}-${type}-${PV}-${PR} 168 uboot_install_spl_config $config $type
234 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}-${type}
235 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${D}/boot/${SPL_BINARYNAME}
236 fi 169 fi
237 done 170 done
238 unset j 171 unset j
239 done 172 done
240 unset i 173 unset i
241 else 174 else
242 install -m 644 ${B}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE} 175 uboot_install_spl
243 ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARYNAME}
244 fi 176 fi
245 fi 177 fi
246 178
247 if [ -n "${UBOOT_ENV}" ] 179 if [ -n "${UBOOT_ENV}" ]
248 then 180 then
249 install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE} 181 install -m 644 ${B}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE}
250 ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY} 182 ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY}
251 fi 183 fi
252 184
@@ -256,68 +188,104 @@ do_install () {
256 fi 188 fi
257} 189}
258 190
259PACKAGE_BEFORE_PN += "${PN}-env" 191uboot_install_config () {
192 config=$1
193 type=$2
194
195 install -D -m 644 ${B}/${config}/${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARYNAME}-${type}-${UBOOT_VERSION}.${UBOOT_SUFFIX}
196 ln -sf ${UBOOT_BINARYNAME}-${type}-${UBOOT_VERSION}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
197 ln -sf ${UBOOT_BINARYNAME}-${type}-${UBOOT_VERSION}.${UBOOT_SUFFIX} ${D}/boot/${UBOOT_BINARY}
260 198
261RPROVIDES_${PN}-env += "u-boot-default-env" 199 # Install the uboot-initial-env
262ALLOW_EMPTY_${PN}-env = "1" 200 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
263FILES_${PN}-env = " \ 201 install -D -m 644 ${B}/${config}/u-boot-initial-env-${type} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION}
202 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}
203 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${type}
204 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}
205 fi
206}
207
208uboot_install () {
209 install -D -m 644 ${B}/${UBOOT_BINARY} ${D}/boot/${UBOOT_IMAGE}
210 ln -sf ${UBOOT_IMAGE} ${D}/boot/${UBOOT_BINARY}
211
212 # Install the uboot-initial-env
213 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
214 install -D -m 644 ${B}/u-boot-initial-env ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}
215 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}-${MACHINE}
216 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION} ${D}/${sysconfdir}/${UBOOT_INITIAL_ENV}
217 fi
218}
219
220uboot_install_elf_config () {
221 config=$1
222 type=$2
223
224 install -m 644 ${B}/${config}/${UBOOT_ELF} ${D}/boot/u-boot-${type}-${UBOOT_VERSION}.${UBOOT_ELF_SUFFIX}
225 ln -sf u-boot-${type}-${UBOOT_VERSION}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}-${type}
226 ln -sf u-boot-${type}-${UBOOT_VERSION}.${UBOOT_ELF_SUFFIX} ${D}/boot/${UBOOT_BINARY}
227}
228
229uboot_install_elf () {
230 install -m 644 ${B}/${UBOOT_ELF} ${D}/boot/${UBOOT_ELF_IMAGE}
231 ln -sf ${UBOOT_ELF_IMAGE} ${D}/boot/${UBOOT_ELF_BINARY}
232}
233
234uboot_install_spl_config () {
235 config=$1
236 type=$2
237
238 install -m 644 ${B}/${config}/${SPL_BINARY} ${D}/boot/${SPL_BINARYNAME}-${type}-${UBOOT_VERSION}${SPL_DELIMITER}${SPL_SUFFIX}
239 ln -sf ${SPL_BINARYNAME}-${type}-${UBOOT_VERSION}${SPL_DELIMITER}${SPL_SUFFIX} ${D}/boot/${SPL_BINARYFILE}-${type}
240 ln -sf ${SPL_BINARYNAME}-${type}-${UBOOT_VERSION}${SPL_DELIMITER}${SPL_SUFFIX} ${D}/boot/${SPL_BINARYFILE}
241}
242
243uboot_install_spl () {
244 install -m 644 ${B}/${SPL_BINARY} ${D}/boot/${SPL_IMAGE}
245 ln -sf ${SPL_IMAGE} ${D}/boot/${SPL_BINARYFILE}
246}
247
248PACKAGE_BEFORE_PN += "${PN}-env ${PN}-extlinux"
249
250RPROVIDES:${PN}-env += "u-boot-default-env"
251ALLOW_EMPTY:${PN}-env = "1"
252FILES:${PN}-env = " \
264 ${@ '${sysconfdir}/${UBOOT_INITIAL_ENV}*' if d.getVar('UBOOT_INITIAL_ENV') else ''} \ 253 ${@ '${sysconfdir}/${UBOOT_INITIAL_ENV}*' if d.getVar('UBOOT_INITIAL_ENV') else ''} \
265 ${sysconfdir}/fw_env.config \ 254 ${sysconfdir}/fw_env.config \
266" 255"
267 256
268FILES_${PN} = "/boot ${datadir}" 257FILES:${PN}-extlinux = "${UBOOT_EXTLINUX_INSTALL_DIR}/${UBOOT_EXTLINUX_CONF_NAME}"
269RDEPENDS_${PN} += "${PN}-env" 258RDEPENDS:${PN} += "${@bb.utils.contains('UBOOT_EXTLINUX', '1', '${PN}-extlinux', '', d)}"
259
260SYSROOT_DIRS += "/boot"
261FILES:${PN} = "/boot ${datadir}"
262RDEPENDS:${PN} += "${PN}-env"
270 263
271do_deploy () { 264do_deploy () {
272 if [ -n "${UBOOT_CONFIG}" ] 265 if [ -n "${UBOOT_CONFIG}" ]
273 then 266 then
267 unset i j
274 for config in ${UBOOT_MACHINE}; do 268 for config in ${UBOOT_MACHINE}; do
275 i=$(expr $i + 1); 269 i=$(expr $i + 1);
276 for type in ${UBOOT_CONFIG}; do 270 for type in ${UBOOT_CONFIG}; do
277 j=$(expr $j + 1); 271 j=$(expr $j + 1);
278 if [ $j -eq $i ] 272 if [ $j -eq $i ]
279 then 273 then
280 install -D -m 644 ${B}/${config}/u-boot-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} 274 uboot_deploy_config $config $type
281 cd ${DEPLOYDIR}
282 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type}
283 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}
284 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type}
285 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_SUFFIX} ${UBOOT_BINARY}
286
287 # Deploy the uboot-initial-env
288 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
289 install -D -m 644 ${B}/${config}/u-boot-initial-env-${type} ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR}
290 cd ${DEPLOYDIR}
291 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR} ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}
292 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${PV}-${PR} ${UBOOT_INITIAL_ENV}-${type}
293 fi
294 fi 275 fi
295 done 276 done
296 unset j 277 unset j
297 done 278 done
298 unset i 279 unset i
299 else 280 else
300 install -D -m 644 ${B}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE} 281 uboot_deploy
301
302 cd ${DEPLOYDIR}
303 rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK}
304 ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK}
305 ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY}
306
307 # Deploy the uboot-initial-env
308 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
309 install -D -m 644 ${B}/u-boot-initial-env ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR}
310 cd ${DEPLOYDIR}
311 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR} ${UBOOT_INITIAL_ENV}-${MACHINE}
312 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${PV}-${PR} ${UBOOT_INITIAL_ENV}
313 fi
314 fi 282 fi
315 283
316 if [ -e ${WORKDIR}/fw_env.config ] ; then 284 if [ -e ${UNPACKDIR}/fw_env.config ] ; then
317 install -D -m 644 ${WORKDIR}/fw_env.config ${DEPLOYDIR}/fw_env.config-${MACHINE}-${PV}-${PR} 285 install -D -m 644 ${UNPACKDIR}/fw_env.config ${DEPLOYDIR}/fw_env.config-${MACHINE}-${UBOOT_VERSION}
318 cd ${DEPLOYDIR} 286 cd ${DEPLOYDIR}
319 ln -sf fw_env.config-${MACHINE}-${PV}-${PR} fw_env.config-${MACHINE} 287 ln -sf fw_env.config-${MACHINE}-${UBOOT_VERSION} fw_env.config-${MACHINE}
320 ln -sf fw_env.config-${MACHINE}-${PV}-${PR} fw_env.config 288 ln -sf fw_env.config-${MACHINE}-${UBOOT_VERSION} fw_env.config
321 fi 289 fi
322 290
323 if [ -n "${UBOOT_ELF}" ] 291 if [ -n "${UBOOT_ELF}" ]
@@ -330,24 +298,17 @@ do_deploy () {
330 j=$(expr $j + 1); 298 j=$(expr $j + 1);
331 if [ $j -eq $i ] 299 if [ $j -eq $i ]
332 then 300 then
333 install -m 644 ${B}/${config}/${UBOOT_ELF} ${DEPLOYDIR}/u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} 301 uboot_deploy_elf_config $config $type
334 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}-${type}
335 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}
336 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}-${type}
337 ln -sf u-boot-${type}-${PV}-${PR}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}
338 fi 302 fi
339 done 303 done
340 unset j 304 unset j
341 done 305 done
342 unset i 306 unset i
343 else 307 else
344 install -m 644 ${B}/${UBOOT_ELF} ${DEPLOYDIR}/${UBOOT_ELF_IMAGE} 308 uboot_deploy_elf
345 ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}
346 ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}
347 fi 309 fi
348 fi 310 fi
349 311
350
351 if [ -n "${SPL_BINARY}" ] 312 if [ -n "${SPL_BINARY}" ]
352 then 313 then
353 if [ -n "${UBOOT_CONFIG}" ] 314 if [ -n "${UBOOT_CONFIG}" ]
@@ -358,30 +319,20 @@ do_deploy () {
358 j=$(expr $j + 1); 319 j=$(expr $j + 1);
359 if [ $j -eq $i ] 320 if [ $j -eq $i ]
360 then 321 then
361 install -m 644 ${B}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}-${type}-${PV}-${PR} 322 uboot_deploy_spl_config $config $type
362 rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
363 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type}
364 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_BINARYNAME}
365 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
366 ln -sf ${SPL_IMAGE}-${type}-${PV}-${PR} ${DEPLOYDIR}/${SPL_SYMLINK}
367 fi 323 fi
368 done 324 done
369 unset j 325 unset j
370 done 326 done
371 unset i 327 unset i
372 else 328 else
373 install -m 644 ${B}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE} 329 uboot_deploy_spl
374 rm -f ${DEPLOYDIR}/${SPL_BINARYNAME} ${DEPLOYDIR}/${SPL_SYMLINK}
375 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME}
376 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
377 fi 330 fi
378 fi 331 fi
379 332
380
381 if [ -n "${UBOOT_ENV}" ] 333 if [ -n "${UBOOT_ENV}" ]
382 then 334 then
383 install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE} 335 install -m 644 ${B}/${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} 336 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY}
386 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK} 337 ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
387 fi 338 fi
@@ -392,6 +343,83 @@ do_deploy () {
392 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE} 343 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}-${MACHINE}
393 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME} 344 ln -sf ${UBOOT_EXTLINUX_SYMLINK} ${DEPLOYDIR}/${UBOOT_EXTLINUX_CONF_NAME}
394 fi 345 fi
346
347 if [ -n "${UBOOT_DTB}" ]
348 then
349 install -m 644 ${B}/arch/${UBOOT_ARCH_DIR}/dts/${UBOOT_DTB_BINARY} ${DEPLOYDIR}/
350 fi
351}
352
353uboot_deploy_config () {
354 config=$1
355 type=$2
356
357 install -D -m 644 ${B}/${config}/${UBOOT_BINARYNAME}-${type}.${UBOOT_SUFFIX} ${DEPLOYDIR}/${UBOOT_BINARYNAME}-${type}-${UBOOT_VERSION}.${UBOOT_SUFFIX}
358 cd ${DEPLOYDIR}
359 ln -sf ${UBOOT_BINARYNAME}-${type}-${UBOOT_VERSION}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}-${type}
360 ln -sf ${UBOOT_BINARYNAME}-${type}-${UBOOT_VERSION}.${UBOOT_SUFFIX} ${UBOOT_SYMLINK}
361 ln -sf ${UBOOT_BINARYNAME}-${type}-${UBOOT_VERSION}.${UBOOT_SUFFIX} ${UBOOT_BINARY}-${type}
362 ln -sf ${UBOOT_BINARYNAME}-${type}-${UBOOT_VERSION}.${UBOOT_SUFFIX} ${UBOOT_BINARY}
363
364 # Deploy the uboot-initial-env
365 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
366 install -D -m 644 ${B}/${config}/u-boot-initial-env-${type} ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION}
367 cd ${DEPLOYDIR}
368 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}
369 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${type}-${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}-${type}
370 fi
371}
372
373uboot_deploy () {
374 install -D -m 644 ${B}/${UBOOT_BINARY} ${DEPLOYDIR}/${UBOOT_IMAGE}
375
376 cd ${DEPLOYDIR}
377 rm -f ${UBOOT_BINARY} ${UBOOT_SYMLINK}
378 ln -sf ${UBOOT_IMAGE} ${UBOOT_SYMLINK}
379 ln -sf ${UBOOT_IMAGE} ${UBOOT_BINARY}
380
381 # Deploy the uboot-initial-env
382 if [ -n "${UBOOT_INITIAL_ENV}" ]; then
383 install -D -m 644 ${B}/u-boot-initial-env ${DEPLOYDIR}/${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION}
384 cd ${DEPLOYDIR}
385 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}-${MACHINE}
386 ln -sf ${UBOOT_INITIAL_ENV}-${MACHINE}-${UBOOT_VERSION} ${UBOOT_INITIAL_ENV}
387 fi
388}
389
390uboot_deploy_elf_config () {
391 config=$1
392 type=$2
393
394 install -m 644 ${B}/${config}/${UBOOT_ELF} ${DEPLOYDIR}/u-boot-${type}-${UBOOT_VERSION}.${UBOOT_ELF_SUFFIX}
395 ln -sf u-boot-${type}-${UBOOT_VERSION}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}-${type}
396 ln -sf u-boot-${type}-${UBOOT_VERSION}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}
397 ln -sf u-boot-${type}-${UBOOT_VERSION}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}-${type}
398 ln -sf u-boot-${type}-${UBOOT_VERSION}.${UBOOT_ELF_SUFFIX} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}
399}
400
401uboot_deploy_elf () {
402 install -m 644 ${B}/${UBOOT_ELF} ${DEPLOYDIR}/${UBOOT_ELF_IMAGE}
403 ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_BINARY}
404 ln -sf ${UBOOT_ELF_IMAGE} ${DEPLOYDIR}/${UBOOT_ELF_SYMLINK}
405}
406
407uboot_deploy_spl_config () {
408 config=$1
409 type=$2
410
411 install -m 644 ${B}/${config}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_BINARYNAME}-${type}-${UBOOT_VERSION}${SPL_DELIMITER}${SPL_SUFFIX}
412 rm -f ${DEPLOYDIR}/${SPL_BINARYFILE} ${DEPLOYDIR}/${SPL_SYMLINK}
413 ln -sf ${SPL_BINARYNAME}-${type}-${UBOOT_VERSION}${SPL_DELIMITER}${SPL_SUFFIX} ${DEPLOYDIR}/${SPL_BINARYFILE}-${type}
414 ln -sf ${SPL_BINARYNAME}-${type}-${UBOOT_VERSION}${SPL_DELIMITER}${SPL_SUFFIX} ${DEPLOYDIR}/${SPL_BINARYFILE}
415 ln -sf ${SPL_BINARYNAME}-${type}-${UBOOT_VERSION}${SPL_DELIMITER}${SPL_SUFFIX} ${DEPLOYDIR}/${SPL_SYMLINK}-${type}
416 ln -sf ${SPL_BINARYNAME}-${type}-${UBOOT_VERSION}${SPL_DELIMITER}${SPL_SUFFIX} ${DEPLOYDIR}/${SPL_SYMLINK}
417}
418
419uboot_deploy_spl () {
420 install -m 644 ${B}/${SPL_BINARY} ${DEPLOYDIR}/${SPL_IMAGE}
421 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_BINARYNAME}
422 ln -sf ${SPL_IMAGE} ${DEPLOYDIR}/${SPL_SYMLINK}
395} 423}
396 424
397addtask deploy before do_build after do_compile 425addtask 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_2025.04.bb b/meta/recipes-bsp/u-boot/u-boot_2025.04.bb
new file mode 100644
index 0000000000..89e964f627
--- /dev/null
+++ b/meta/recipes-bsp/u-boot/u-boot_2025.04.bb
@@ -0,0 +1,8 @@
1require u-boot-common.inc
2require u-boot.inc
3
4DEPENDS += "bc-native dtc-native gnutls-native python3-pyelftools-native"
5
6# workarounds for aarch64 kvm qemu boot regressions
7SRC_URI:append:qemuarm64 = " file://disable-CONFIG_BLOBLIST.cfg file://disable_CONFIG_USB.cfg"
8SRC_URI:append:genericarm64 = " file://disable-CONFIG_BLOBLIST.cfg file://disable_CONFIG_USB.cfg"
diff --git a/meta/recipes-bsp/usbinit/usbinit.bb b/meta/recipes-bsp/usbinit/usbinit.bb
deleted file mode 100644
index ef98f0bf62..0000000000
--- a/meta/recipes-bsp/usbinit/usbinit.bb
+++ /dev/null
@@ -1,25 +0,0 @@
1SUMMARY = "Initscript for enabling USB gadget Ethernet"
2DESCRIPTION = "This module allows ethernet emulation over USB, allowing for \
3all sorts of nifty things like SSH and NFS in one go plus charging over the \
4same wire, at higher speeds than most Wifi connections."
5HOMEPAGE = "http://linux-sunxi.org/USB_Gadget/Ethernet"
6
7LICENSE = "GPLv2"
8LIC_FILES_CHKSUM = "file://${WORKDIR}/COPYING.GPL;md5=751419260aa954499f7abaabaa882bbe"
9
10PR = "r3"
11
12SRC_URI = "file://usb-gether \
13 file://COPYING.GPL"
14S = "${WORKDIR}"
15
16do_install() {
17 install -d ${D}${sysconfdir}
18 install -d ${D}${sysconfdir}/init.d
19 install usb-gether ${D}${sysconfdir}/init.d
20}
21
22inherit update-rc.d allarch
23
24INITSCRIPT_NAME = "usb-gether"
25INITSCRIPT_PARAMS = "start 99 5 2 . stop 20 0 1 6 ."
diff --git a/meta/recipes-bsp/usbinit/usbinit/COPYING.GPL b/meta/recipes-bsp/usbinit/usbinit/COPYING.GPL
deleted file mode 100644
index d511905c16..0000000000
--- a/meta/recipes-bsp/usbinit/usbinit/COPYING.GPL
+++ /dev/null
@@ -1,339 +0,0 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 2, June 1991
3
4 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The licenses for most software are designed to take away your
12freedom to share and change it. By contrast, the GNU General Public
13License is intended to guarantee your freedom to share and change free
14software--to make sure the software is free for all its users. This
15General Public License applies to most of the Free Software
16Foundation's software and to any other program whose authors commit to
17using it. (Some other Free Software Foundation software is covered by
18the GNU Lesser General Public License instead.) You can apply it to
19your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22price. Our General Public Licenses are designed to make sure that you
23have the freedom to distribute copies of free software (and charge for
24this service if you wish), that you receive source code or can get it
25if you want it, that you can change the software or use pieces of it
26in new free programs; and that you know you can do these things.
27
28 To protect your rights, we need to make restrictions that forbid
29anyone to deny you these rights or to ask you to surrender the rights.
30These restrictions translate to certain responsibilities for you if you
31distribute copies of the software, or if you modify it.
32
33 For example, if you distribute copies of such a program, whether
34gratis or for a fee, you must give the recipients all the rights that
35you have. You must make sure that they, too, receive or can get the
36source code. And you must show them these terms so they know their
37rights.
38
39 We protect your rights with two steps: (1) copyright the software, and
40(2) offer you this license which gives you legal permission to copy,
41distribute and/or modify the software.
42
43 Also, for each author's protection and ours, we want to make certain
44that everyone understands that there is no warranty for this free
45software. If the software is modified by someone else and passed on, we
46want its recipients to know that what they have is not the original, so
47that any problems introduced by others will not reflect on the original
48authors' reputations.
49
50 Finally, any free program is threatened constantly by software
51patents. We wish to avoid the danger that redistributors of a free
52program will individually obtain patent licenses, in effect making the
53program proprietary. To prevent this, we have made it clear that any
54patent must be licensed for everyone's free use or not licensed at all.
55
56 The precise terms and conditions for copying, distribution and
57modification follow.
58
59 GNU GENERAL PUBLIC LICENSE
60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62 0. This License applies to any program or other work which contains
63a notice placed by the copyright holder saying it may be distributed
64under the terms of this General Public License. The "Program", below,
65refers to any such program or work, and a "work based on the Program"
66means either the Program or any derivative work under copyright law:
67that is to say, a work containing the Program or a portion of it,
68either verbatim or with modifications and/or translated into another
69language. (Hereinafter, translation is included without limitation in
70the term "modification".) Each licensee is addressed as "you".
71
72Activities other than copying, distribution and modification are not
73covered by this License; they are outside its scope. The act of
74running the Program is not restricted, and the output from the Program
75is covered only if its contents constitute a work based on the
76Program (independent of having been made by running the Program).
77Whether that is true depends on what the Program does.
78
79 1. You may copy and distribute verbatim copies of the Program's
80source code as you receive it, in any medium, provided that you
81conspicuously and appropriately publish on each copy an appropriate
82copyright notice and disclaimer of warranty; keep intact all the
83notices that refer to this License and to the absence of any warranty;
84and give any other recipients of the Program a copy of this License
85along with the Program.
86
87You may charge a fee for the physical act of transferring a copy, and
88you may at your option offer warranty protection in exchange for a fee.
89
90 2. You may modify your copy or copies of the Program or any portion
91of it, thus forming a work based on the Program, and copy and
92distribute such modifications or work under the terms of Section 1
93above, provided that you also meet all of these conditions:
94
95 a) You must cause the modified files to carry prominent notices
96 stating that you changed the files and the date of any change.
97
98 b) You must cause any work that you distribute or publish, that in
99 whole or in part contains or is derived from the Program or any
100 part thereof, to be licensed as a whole at no charge to all third
101 parties under the terms of this License.
102
103 c) If the modified program normally reads commands interactively
104 when run, you must cause it, when started running for such
105 interactive use in the most ordinary way, to print or display an
106 announcement including an appropriate copyright notice and a
107 notice that there is no warranty (or else, saying that you provide
108 a warranty) and that users may redistribute the program under
109 these conditions, and telling the user how to view a copy of this
110 License. (Exception: if the Program itself is interactive but
111 does not normally print such an announcement, your work based on
112 the Program is not required to print an announcement.)
113
114These requirements apply to the modified work as a whole. If
115identifiable sections of that work are not derived from the Program,
116and can be reasonably considered independent and separate works in
117themselves, then this License, and its terms, do not apply to those
118sections when you distribute them as separate works. But when you
119distribute the same sections as part of a whole which is a work based
120on the Program, the distribution of the whole must be on the terms of
121this License, whose permissions for other licensees extend to the
122entire whole, and thus to each and every part regardless of who wrote it.
123
124Thus, it is not the intent of this section to claim rights or contest
125your rights to work written entirely by you; rather, the intent is to
126exercise the right to control the distribution of derivative or
127collective works based on the Program.
128
129In addition, mere aggregation of another work not based on the Program
130with the Program (or with a work based on the Program) on a volume of
131a storage or distribution medium does not bring the other work under
132the scope of this License.
133
134 3. You may copy and distribute the Program (or a work based on it,
135under Section 2) in object code or executable form under the terms of
136Sections 1 and 2 above provided that you also do one of the following:
137
138 a) Accompany it with the complete corresponding machine-readable
139 source code, which must be distributed under the terms of Sections
140 1 and 2 above on a medium customarily used for software interchange; or,
141
142 b) Accompany it with a written offer, valid for at least three
143 years, to give any third party, for a charge no more than your
144 cost of physically performing source distribution, a complete
145 machine-readable copy of the corresponding source code, to be
146 distributed under the terms of Sections 1 and 2 above on a medium
147 customarily used for software interchange; or,
148
149 c) Accompany it with the information you received as to the offer
150 to distribute corresponding source code. (This alternative is
151 allowed only for noncommercial distribution and only if you
152 received the program in object code or executable form with such
153 an offer, in accord with Subsection b above.)
154
155The source code for a work means the preferred form of the work for
156making modifications to it. For an executable work, complete source
157code means all the source code for all modules it contains, plus any
158associated interface definition files, plus the scripts used to
159control compilation and installation of the executable. However, as a
160special exception, the source code distributed need not include
161anything that is normally distributed (in either source or binary
162form) with the major components (compiler, kernel, and so on) of the
163operating system on which the executable runs, unless that component
164itself accompanies the executable.
165
166If distribution of executable or object code is made by offering
167access to copy from a designated place, then offering equivalent
168access to copy the source code from the same place counts as
169distribution of the source code, even though third parties are not
170compelled to copy the source along with the object code.
171
172 4. You may not copy, modify, sublicense, or distribute the Program
173except as expressly provided under this License. Any attempt
174otherwise to copy, modify, sublicense or distribute the Program is
175void, and will automatically terminate your rights under this License.
176However, parties who have received copies, or rights, from you under
177this License will not have their licenses terminated so long as such
178parties remain in full compliance.
179
180 5. You are not required to accept this License, since you have not
181signed it. However, nothing else grants you permission to modify or
182distribute the Program or its derivative works. These actions are
183prohibited by law if you do not accept this License. Therefore, by
184modifying or distributing the Program (or any work based on the
185Program), you indicate your acceptance of this License to do so, and
186all its terms and conditions for copying, distributing or modifying
187the Program or works based on it.
188
189 6. Each time you redistribute the Program (or any work based on the
190Program), the recipient automatically receives a license from the
191original licensor to copy, distribute or modify the Program subject to
192these terms and conditions. You may not impose any further
193restrictions on the recipients' exercise of the rights granted herein.
194You are not responsible for enforcing compliance by third parties to
195this License.
196
197 7. If, as a consequence of a court judgment or allegation of patent
198infringement or for any other reason (not limited to patent issues),
199conditions are imposed on you (whether by court order, agreement or
200otherwise) that contradict the conditions of this License, they do not
201excuse you from the conditions of this License. If you cannot
202distribute so as to satisfy simultaneously your obligations under this
203License and any other pertinent obligations, then as a consequence you
204may not distribute the Program at all. For example, if a patent
205license would not permit royalty-free redistribution of the Program by
206all those who receive copies directly or indirectly through you, then
207the only way you could satisfy both it and this License would be to
208refrain entirely from distribution of the Program.
209
210If any portion of this section is held invalid or unenforceable under
211any particular circumstance, the balance of the section is intended to
212apply and the section as a whole is intended to apply in other
213circumstances.
214
215It is not the purpose of this section to induce you to infringe any
216patents or other property right claims or to contest validity of any
217such claims; this section has the sole purpose of protecting the
218integrity of the free software distribution system, which is
219implemented by public license practices. Many people have made
220generous contributions to the wide range of software distributed
221through that system in reliance on consistent application of that
222system; it is up to the author/donor to decide if he or she is willing
223to distribute software through any other system and a licensee cannot
224impose that choice.
225
226This section is intended to make thoroughly clear what is believed to
227be a consequence of the rest of this License.
228
229 8. If the distribution and/or use of the Program is restricted in
230certain countries either by patents or by copyrighted interfaces, the
231original copyright holder who places the Program under this License
232may add an explicit geographical distribution limitation excluding
233those countries, so that distribution is permitted only in or among
234countries not thus excluded. In such case, this License incorporates
235the limitation as if written in the body of this License.
236
237 9. The Free Software Foundation may publish revised and/or new versions
238of the General Public License from time to time. Such new versions will
239be similar in spirit to the present version, but may differ in detail to
240address new problems or concerns.
241
242Each version is given a distinguishing version number. If the Program
243specifies a version number of this License which applies to it and "any
244later version", you have the option of following the terms and conditions
245either of that version or of any later version published by the Free
246Software Foundation. If the Program does not specify a version number of
247this License, you may choose any version ever published by the Free Software
248Foundation.
249
250 10. If you wish to incorporate parts of the Program into other free
251programs whose distribution conditions are different, write to the author
252to ask for permission. For software which is copyrighted by the Free
253Software Foundation, write to the Free Software Foundation; we sometimes
254make exceptions for this. Our decision will be guided by the two goals
255of preserving the free status of all derivatives of our free software and
256of promoting the sharing and reuse of software generally.
257
258 NO WARRANTY
259
260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268REPAIR OR CORRECTION.
269
270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278POSSIBILITY OF SUCH DAMAGES.
279
280 END OF TERMS AND CONDITIONS
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285possible use to the public, the best way to achieve this is to make it
286free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289to attach them to the start of each source file to most effectively
290convey the exclusion of warranty; and each file should have at least
291the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) <year> <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License along
307 with this program; if not, write to the Free Software Foundation, Inc.,
308 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
310Also add information on how to contact you by electronic and paper mail.
311
312If the program is interactive, make it output a short notice like this
313when it starts in an interactive mode:
314
315 Gnomovision version 69, Copyright (C) year name of author
316 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 This is free software, and you are welcome to redistribute it
318 under certain conditions; type `show c' for details.
319
320The hypothetical commands `show w' and `show c' should show the appropriate
321parts of the General Public License. Of course, the commands you use may
322be called something other than `show w' and `show c'; they could even be
323mouse-clicks or menu items--whatever suits your program.
324
325You should also get your employer (if you work as a programmer) or your
326school, if any, to sign a "copyright disclaimer" for the program, if
327necessary. Here is a sample; alter the names:
328
329 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
332 <signature of Ty Coon>, 1 April 1989
333 Ty Coon, President of Vice
334
335This General Public License does not permit incorporating your program into
336proprietary programs. If your program is a subroutine library, you may
337consider it more useful to permit linking proprietary applications with the
338library. If this is what you want to do, use the GNU Lesser General
339Public License instead of this License.
diff --git a/meta/recipes-bsp/usbinit/usbinit/usb-gether b/meta/recipes-bsp/usbinit/usbinit/usb-gether
deleted file mode 100755
index e80a0bb30e..0000000000
--- a/meta/recipes-bsp/usbinit/usbinit/usb-gether
+++ /dev/null
@@ -1,23 +0,0 @@
1#! /bin/sh
2#
3# usb-ether Start up the gadget usb ethernet interface.
4#
5
6case "$1" in
7 start|"")
8 test "$VERBOSE" != no && echo "Initializing g_ether gadget..."
9 modprobe g_ether
10 ifup usb0
11 ;;
12 stop)
13 test "$VERBOSE" != no && echo "Disabling g_ether..."
14 ifdown usb0
15 rmmod g_ether
16 ;;
17 *)
18 echo "Usage: usb-ether {start|stop}" >&2
19 exit 1
20 ;;
21esac
22
23exit 0
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_018.bb b/meta/recipes-bsp/usbutils/usbutils_018.bb
new file mode 100644
index 0000000000..b96a1b4f19
--- /dev/null
+++ b/meta/recipes-bsp/usbutils/usbutils_018.bb
@@ -0,0 +1,34 @@
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) & CC0-1.0 & LGPL-2.1-or-later & MIT"
7LIC_FILES_CHKSUM = "file://LICENSES/CC0-1.0.txt;md5=cf1af55fc6f5b9a23e12086005298dcd \
8 file://LICENSES/GPL-2.0-only.txt;md5=c89d4ad08368966d8df5a90ea96bebe4 \
9 file://LICENSES/GPL-2.0-or-later.txt;md5=c89d4ad08368966d8df5a90ea96bebe4 \
10 file://LICENSES/GPL-3.0-only.txt;md5=050f496cfea7876fc13cdea643e041e0 \
11 file://LICENSES/LGPL-2.1-or-later.txt;md5=8c6e7513c570546f65ae570dae278c17 \
12 file://LICENSES/MIT.txt;md5=e8f57dd048e186199433be2c41bd3d6d \
13 "
14DEPENDS = "libusb1 virtual/libiconv udev"
15
16SRC_URI = "${KERNELORG_MIRROR}/linux/utils/usb/usbutils/usbutils-${PV}.tar.gz \
17 "
18SRC_URI[sha256sum] = "0048d2d8518fb0cc7c0516e16e52af023e52b55ddb3b2068a77041b5ef285768"
19
20inherit meson pkgconfig update-alternatives
21
22ALTERNATIVE:${PN} = "lsusb"
23ALTERNATIVE_PRIORITY = "100"
24
25# The binaries are mostly GPL-2.0-or-later apart from lsusb.py which is
26# GPL-2.0-only or GPL-3.0-only.
27LICENSE:${PN} = "GPL-2.0-or-later"
28LICENSE:${PN}-python = "GPL-2.0-only | GPL-3.0-only"
29
30RRECOMMENDS:${PN} = "udev-hwdb"
31
32PACKAGE_BEFORE_PN =+ "${PN}-python"
33FILES:${PN}-python += "${bindir}/lsusb.py"
34RDEPENDS:${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..3bc9b24487 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 \
@@ -16,7 +14,6 @@ SRC_URI = "http://snapshot.debian.org/archive/debian/20110427T035506Z/pool/main/
16 file://Support-for-cross-compilation.patch \ 14 file://Support-for-cross-compilation.patch \
17" 15"
18 16
19SRC_URI[md5sum] = "889686ec8424468fe0d205742e77a4c2"
20SRC_URI[sha256sum] = "93575c82e4307d8c4c370ec6b767f5cf87e527b2378146d652a6d8e25d5bdbc5" 17SRC_URI[sha256sum] = "93575c82e4307d8c4c370ec6b767f5cf87e527b2378146d652a6d8e25d5bdbc5"
21 18
22PACKAGE_ARCH = "${MACHINE_ARCH}" 19PACKAGE_ARCH = "${MACHINE_ARCH}"