├── README.rst ├── app-emulation ├── kvmtool │ ├── kvmtool-9999.ebuild │ └── metadata.xml ├── nemu-xiangshan │ ├── files │ │ ├── nemu-xiangshan-add-syncconfig.patch │ │ └── nemu-xiangshan-disable-git-tracking.patch │ ├── metadata.xml │ └── nemu-xiangshan-9999.ebuild ├── riscv-pk │ ├── Manifest │ ├── metadata.xml │ └── riscv-pk-1.0.0_p20240423.ebuild └── spike │ ├── Manifest │ ├── metadata.xml │ ├── spike-1.0.0.ebuild │ ├── spike-1.1.0_p20240324.ebuild │ └── spike-9999.ebuild ├── dev-debug └── valgrind │ ├── files │ ├── valgrind-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch │ └── valgrind-3.7.0-respect-flags.patch │ ├── metadata.xml │ └── valgrind-9999.ebuild ├── dev-lang └── luajit │ ├── Manifest │ ├── luajit-2.1.1727870382.ebuild │ └── metadata.xml ├── licenses └── MulanPSL-2.0 ├── metadata ├── .gitignore └── layout.conf ├── profiles ├── .gitignore ├── eapi ├── license_groups └── repo_name ├── sys-apps └── kexec-tools │ ├── Manifest │ ├── files │ ├── 90_kexec │ ├── README.Gentoo │ ├── kexec-r2.init │ ├── kexec-tools-2.0.24-riscv.patch │ ├── kexec-tools-2.0.4-disable-kexec-test.patch │ ├── kexec-tools-2.0.4-out-of-source.patch │ ├── kexec.conf │ ├── kexec.conf-2.0.4 │ └── kexec.service │ ├── kexec-tools-2.0.24.ebuild │ └── metadata.xml ├── sys-firmware └── u-boot-bin │ ├── Manifest │ ├── metadata.xml │ └── u-boot-bin-2022.10.ebuild └── www-client └── chromium ├── Manifest ├── chromium-136.0.7103.113.ebuild ├── files ├── 0001-Enable-relocate-1-for-ff_h264_weight_funcs_8_rvv.patch ├── 0001-chrome-runtime_api_delegate-add-riscv64-define.patch ├── 0001-extensions-common-api-runtime.json-riscv64-support.patch ├── Debian-fix-rust-linking.patch ├── chromium-109-system-zlib.patch ├── chromium-111-InkDropHost-crash.patch ├── chromium-131-oauth2-client-switches.patch ├── chromium-131-unbundle-icu-target.patch ├── chromium-132-bindgen-custom-toolchain.patch ├── chromium-134-bindgen-custom-toolchain.patch ├── chromium-134-map_droppable-glibc.patch ├── chromium-134-oauth2-client-switches.patch ├── chromium-134-qt5-optional.patch ├── chromium-134-type-mismatch-error.patch ├── chromium-135-fix-non-wayland-build.patch ├── chromium-135-gperf.patch ├── chromium-135-map_droppable-glibc.patch ├── chromium-135-oauth2-client-switches.patch ├── chromium-135-webrtc-pipewire.patch ├── chromium-136-drop-nodejs-ver-check.patch ├── chromium-137-openh264-include-path.patch ├── chromium-137-pdfium-system-libpng.patch ├── chromium-browser.xml ├── chromium-cross-compile.patch ├── chromium-launcher-r7.sh ├── chromium.default ├── compiler-rt-riscv.patch ├── cpuinfo.patch ├── esbuild ├── fix-build-with-pipewire-1.3.82.patch ├── libstdc++-fixup.patch ├── riscv-dav1d.patch ├── riscv-ffmpeg.patch ├── riscv-highway.patch ├── riscv-misc.patch ├── riscv-sandbox.patch ├── riscv-swiftshader.patch └── riscv-v8.patch └── metadata.xml /README.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | Gentoo RISC-V Overlay 3 | ====== 4 | 5 | .. NOTE: If editing this, be sure to update the line numbers in 6 | 'doc/introduction' 7 | 8 | This is a Gentoo overlay dedicated for RISC-V architecture, and collecting 9 | highly experimental ebuilds which aren't ready for official main portage tree. 10 | 11 | .. important:: 12 | 13 | Although the team have tried their best to test all packages, there is no guarentee 14 | that they will always work properly! Do backup before use in case of data loss. 15 | 16 | License 17 | ------------- 18 | 19 | Distributed under the terms of the GNU General Public License v2 20 | -------------------------------------------------------------------------------- /app-emulation/kvmtool/kvmtool-9999.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=8 5 | 6 | EGIT_REPO_URI="https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git" 7 | inherit git-r3 linux-info 8 | 9 | DESCRIPTION="A lightweight tool for hosting KVM guests" 10 | HOMEPAGE="https://git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git/" 11 | 12 | LICENSE="GPL-2" 13 | SLOT="0" 14 | IUSE="" 15 | 16 | DEPEND="riscv? ( sys-apps/dtc )" 17 | BDEPEND="${DEPEND}" 18 | RDEPEND="${DEPEND}" 19 | 20 | function ctarget() { 21 | CTARGET="${ARCH}" 22 | use amd64 && CTARGET='x86_64' 23 | echo $CTARGET 24 | } 25 | 26 | CONFIG_CHECK=" 27 | SERIAL_8250 SERIAL_8250_CONSOLE 28 | VIRTIO VIRTIO_PCI 29 | VIRTIO_RING VIRTIO_PCI 30 | VIRTIO_BLK VIRTIO_NET 31 | ~VIRTIO_BALLOON 32 | ~VIRTIO_CONSOLE 33 | ~HW_RANDOM_VIRTIO 34 | ~FB_VESA 35 | " 36 | 37 | pkg_pretend() { 38 | if use kernel_linux ; then 39 | if kernel_is lt 2 6 25; then 40 | eerror "This version of KVM requires a host kernel of 2.6.25 or higher." 41 | fi 42 | if use riscv && kernel_is lt 5 16; then 43 | ewarn "RISC-V KVM official support landed in kernel 5.16," 44 | ewarn "and requires the hypervisor extension." 45 | fi 46 | 47 | if ! linux_config_exists; then 48 | eerror "Unable to check your kernel for KVM support" 49 | else 50 | check_extra_config 51 | fi 52 | fi 53 | } 54 | 55 | src_prepare() { 56 | default 57 | sed -e 's/^CFLAGS\t:=/CFLAGS := $(CFLAGS)/' \ 58 | -e 's/^LDFLAGS\t:=/LDFLAGS := $(LDFLAGS)/' -i Makefile 59 | } 60 | 61 | src_compile() { 62 | V=1 ARCH=$(ctarget) emake 63 | } 64 | 65 | src_install() { 66 | dobin lkvm vm || die 67 | dodoc README Documentation/virtio-console.txt || die 68 | doman Documentation/${PN}.1 69 | } 70 | -------------------------------------------------------------------------------- /app-emulation/kvmtool/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app-emulation/nemu-xiangshan/files/nemu-xiangshan-add-syncconfig.patch: -------------------------------------------------------------------------------- 1 | diff --git a/scripts/config.mk b/scripts/config.mk 2 | index 7b85f49..f8d994e 100644 3 | --- a/scripts/config.mk 4 | +++ b/scripts/config.mk 5 | @@ -26,6 +26,9 @@ $(MCONF): 6 | $(FIXDEP): 7 | $(Q)$(MAKE) $(silent) -C $(FIXDEP_PATH) 8 | 9 | +syncconfig: $(CONF) $(FIXDEP) 10 | + $(Q)$(CONF) $(silent) --syncconfig $(Kconfig) 11 | + 12 | menuconfig: $(MCONF) $(CONF) $(FIXDEP) 13 | $(Q)$(MCONF) $(Kconfig) 14 | $(Q)$(CONF) $(silent) --syncconfig $(Kconfig) 15 | -------------------------------------------------------------------------------- /app-emulation/nemu-xiangshan/files/nemu-xiangshan-disable-git-tracking.patch: -------------------------------------------------------------------------------- 1 | diff --git a/scripts/git.mk b/scripts/git.mk 2 | index 5400e61..8e0a353 100644 3 | --- a/scripts/git.mk 4 | +++ b/scripts/git.mk 5 | @@ -7,8 +7,4 @@ GITFLAGS = -q --author='tracer-ics2021 ' --no-verify --allow- 6 | 7 | # prototype: git_commit(msg) 8 | define git_commit 9 | - -@git add $(NEMU_HOME)/.. -A --ignore-errors 10 | - -@while (test -e .git/index.lock); do sleep 0.1; done 11 | - -@(echo "> $(1)" && echo $(STUID) && hostnamectl && uptime) | git commit -F - $(GITFLAGS) 12 | - -@sync 13 | endef 14 | -------------------------------------------------------------------------------- /app-emulation/nemu-xiangshan/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | alex.fan.q@gmail.com 6 | Alex Fan 7 | 8 | 9 | proxy-maint@gentoo.org 10 | Proxy Maintainers 11 | 12 | 13 | OpenXiangShan/NEMU 14 | 15 | 16 | -------------------------------------------------------------------------------- /app-emulation/nemu-xiangshan/nemu-xiangshan-9999.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=7 5 | 6 | DISABLE_AUTOFORMATTING="true" 7 | DOC_CONTENTS=' 8 | nemu-xiangshan mini config HOWTO 9 | 10 | Note: nemu-xiangshan is configurable via mconf, like the linux kernel. 11 | Without user config, this ebuild will target minimum riscv64 12 | You are encouraged to configure it on your own. Here are a couple of ways: 13 | 14 | 1) USE="-savedconfig" and set/unset the remaining flags to obtain the features 15 | you want, and possibly a lot more. 16 | 17 | 2) You can create your own configuration file by doing: 18 | 19 | FEATURES="keepwork" USE="savedconfig -*" emerge nemu-xiangshan 20 | cd /var/tmp/portage/app-emulation/nemu-xiangshan*/work/nemu-xiangshan* 21 | make menuconfig 22 | 23 | Now configure nemu-xiangshan as you want. Finally save your config file: 24 | 25 | cp config/.config /etc/portage/savedconfig/app-emulation/nemu-xiangshan-${PV} 26 | 27 | where ${PV} is the current version. You can then run emerge again with 28 | your configuration by doing: 29 | 30 | USE="savedconfig" emerge nemu-xiangshan 31 | ' 32 | 33 | inherit savedconfig readme.gentoo-r1 34 | 35 | DESCRIPTION="NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching" 36 | HOMEPAGE="https://github.com/OpenXiangShan/NEMU" 37 | 38 | LICENSE="MulanPSL-2.0" 39 | SLOT="0" 40 | IUSE="savedconfig" 41 | 42 | EGIT_REPO_URI="https://github.com/OpenXiangShan/NEMU.git" 43 | EGIT_SUBMODULES=( 44 | ready-to-run 45 | ) 46 | inherit git-r3 47 | 48 | DEPEND=" 49 | sys-apps/dtc 50 | media-libs/libsdl2 51 | sys-libs/zlib 52 | sys-libs/readline:= 53 | " 54 | RDEPEND="${DEPEND}" 55 | 56 | PATCHES=( 57 | "${FILESDIR}"/${PN}-disable-git-tracking.patch 58 | "${FILESDIR}"/${PN}-add-syncconfig.patch 59 | ) 60 | 61 | QA_PREBUILT=" 62 | usr/share/${PN}/ready-to-run/coremark-2-iteration.bin 63 | usr/share/${PN}/ready-to-run/linux.bin 64 | usr/share/${PN}/ready-to-run/riscv64-nemu-interpreter-dual-so 65 | usr/share/${PN}/ready-to-run/linux-0xa0000.bin 66 | usr/share/${PN}/ready-to-run/microbench.bin 67 | usr/share/${PN}/ready-to-run/riscv64-nemu-interpreter-so 68 | " 69 | 70 | src_prepare() { 71 | default 72 | sed -i -e "/^CCACHE/d" scripts/build.mk || die 73 | } 74 | 75 | src_configure() { 76 | export NEMU_HOME="${PWD}" 77 | if use savedconfig; then 78 | restore_config .config 79 | if [[ -f .config ]]; then 80 | ewarn "Using saved config" 81 | else 82 | die "No saved config, please consider generate one with 'make menuconfig'" 83 | fi 84 | else 85 | elog "No saved config, seeding minimum riscv64" 86 | cp configs/riscv64-xs_defconfig .config || die 87 | fi 88 | 89 | emake -j1 syncconfig < <(yes '') > /dev/null 90 | } 91 | 92 | src_compile() { 93 | export NEMU_HOME="${PWD}" 94 | emake 95 | # TODO: require cross-compilation 96 | # cd resource/gcpt_restore || die 97 | # emake 98 | } 99 | 100 | src_install() { 101 | dodoc README.md 102 | dodoc -r resource/debian 103 | dodoc -r resource/sdcard 104 | readme.gentoo_create_doc 105 | 106 | insinto "/usr/share/${PN}/" 107 | rm -r ready-to-run/.git || die 108 | doins -r ready-to-run 109 | # Disallow stripping of prebuilt images 110 | dostrip -x ${QA_PREBUILT} 111 | 112 | cd build || die 113 | for binary in $(ls -1 2>/dev/null); do 114 | IFS='-' read -a name <<<"${binary}" || die 115 | if [[ "${name[1]}" == 'nemu' ]]; then 116 | newbin "${binary}" "${name[0]}-nemu-xiangshan-${name[@]:2}" 117 | fi 118 | done 119 | } 120 | 121 | pkg_postinst() { 122 | readme.gentoo_print_elog 123 | } 124 | -------------------------------------------------------------------------------- /app-emulation/riscv-pk/Manifest: -------------------------------------------------------------------------------- 1 | DIST riscv-pk-1.0.0_p20240423.tar.gz 325581 BLAKE2B 9ef2f606f167fa8cf23d2d6d3db65f09d3e0e9214977c0953be951a9918dd149e96b089317b22b9b968804a45358a1996c782e960f33b470501497bcf67eb8f8 SHA512 4825d04d3ca5e57d3acd10e4c27ec8015b48db980674703e6b7dfd98d83113bf29a594d9f55954d30d2ff4880f69b2cfd1c7294a1ebf761fbcde1be0ea850d39 2 | -------------------------------------------------------------------------------- /app-emulation/riscv-pk/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | The RISC-V Proxy Kernel, pk, is a lightweight application execution environment that can host 6 | statically-linked RISC-V ELF binaries. It is designed to support tethered RISC-V implementations 7 | with limited I/O capability and thus handles I/O-related system calls by proxying them to a host 8 | computer. 9 | 10 | This package also contains the Berkeley Boot Loader, bbl, which is a supervisor execution 11 | environment for tethered RISC-V systems. It is designed to host the RISC-V Linux port. 12 | 13 | 14 | Florian Schmaus 15 | flow@gentoo.org 16 | 17 | 18 | riscv-software-src/riscv-pk 19 | 20 | 21 | -------------------------------------------------------------------------------- /app-emulation/riscv-pk/riscv-pk-1.0.0_p20240423.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 2023-2024 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=8 5 | 6 | DESCRIPTION="RISC-V Proxy Kernel" 7 | HOMEPAGE="https://github.com/riscv-software-src/riscv-pk" 8 | 9 | LICENSE="BSD" 10 | SLOT="0" 11 | 12 | if [[ ${PV} == 9999 ]]; then 13 | inherit git-r3 14 | EGIT_REPO_URI="https://github.com/riscv-software-src/riscv-pk.git" 15 | else 16 | MY_COMMIT=9637e60b96b21a7f85a85bf033b87f64fb823b6c 17 | if [[ -v MY_COMMIT ]]; then 18 | SRC_URI="https://github.com/riscv-software-src/riscv-pk/archive/${MY_COMMIT}.tar.gz -> ${P}.tar.gz" 19 | S="${WORKDIR}/riscv-pk-${MY_COMMIT}" 20 | else 21 | SRC_URI="https://github.com/riscv-software-src/riscv-pk/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" 22 | fi 23 | KEYWORDS="~amd64" 24 | fi 25 | 26 | pkg_setup() { 27 | if ! has_version cross-riscv64-linux-gnu/gcc && [[ ! -v I_HAVE_RISCV_LINUX_GNU_GCC ]]; then 28 | die "Building the RISC-V Proxy Kernel (pk) requires cross-riscv64-linux-gnu/gcc" 29 | fi 30 | } 31 | 32 | src_prepare() { 33 | default 34 | 35 | # TODO: consider using filter-flags instead. 36 | unset CFLAGS CXXFLAGS 37 | } 38 | 39 | src_configure() { 40 | mkdir build || die 41 | cd build || die 42 | 43 | ../configure --prefix="${EPREFIX}"/usr/share --host=riscv64-linux-gnu || die 44 | } 45 | 46 | src_compile() { 47 | emake -C build 48 | } 49 | 50 | src_install() { 51 | emake -C build DESTDIR="${D}" install 52 | } 53 | -------------------------------------------------------------------------------- /app-emulation/spike/Manifest: -------------------------------------------------------------------------------- 1 | DIST spike-1.0.0.tar.gz 283500 BLAKE2B a25f5faad1fa76e131f2477c5c103a738a0a5c6a4bec0a147d9233acc3e9ef60d52621e83d54e4025fa50ab402a294564cfdf4244651c14dd1b852fe3d16becf SHA512 e5755fc2bb38d5cb11d340f612f82207f6f77599b4cd38206c70cdb211f43108694ce2807822bccb77de308bb78b60a23978de972c2c8394601712ff1153267c 2 | DIST spike-1.1.0_p20240324.tar.gz 511200 BLAKE2B c925a5e1775d3ffd0d14009a42a7d4d20bd4013e4b95c1ce4551ab6d55d5d3bb8b52df04f237c17d07a439925a7acf18500d2ca34f046e8870bce3b88fccef45 SHA512 6d9bd4f903962a29661cde2e1b26f1457db2fd3602079e433f24bc077c1188cba354570a8f0d2b0c2e1a24445346f4fe73618be7ff93f0962ffd060094956563 3 | -------------------------------------------------------------------------------- /app-emulation/spike/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Spike, the RISC-V ISA Simulator, implements a functional model of 6 | one or more RISC-V harts. It is named after the golden spike used to 7 | celebrate the completion of the US transcontinental railway. 8 | 9 | 10 | dlan@gentoo.org 11 | Yixun Lan 12 | 13 | 14 | riscv/riscv-isa-sim 15 | 16 | 17 | -------------------------------------------------------------------------------- /app-emulation/spike/spike-1.0.0.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI="8" 5 | inherit autotools 6 | 7 | DESCRIPTION="The RISC-V ISA Simulator" 8 | HOMEPAGE="https://github.com/riscv/riscv-isa-sim/" 9 | SRC_URI="https://github.com/riscv/riscv-isa-sim/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" 10 | 11 | LICENSE="BSD" 12 | SLOT="0/${PV}" 13 | KEYWORDS="~amd64" 14 | 15 | S="${WORKDIR}/riscv-isa-sim-${PV}" 16 | src_prepare() { 17 | default 18 | sed -i -e "/install_libs_dir/s:/lib:/$(get_libdir):g" Makefile.in || die 19 | sed -i -e "/" \ 20 | fesvr/dtm.cc riscv/devices.h || die 21 | eautoreconf 22 | } 23 | -------------------------------------------------------------------------------- /app-emulation/spike/spike-1.1.0_p20240324.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=8 5 | 6 | DESCRIPTION="The RISC-V ISA Simulator" 7 | HOMEPAGE="https://github.com/riscv-software-src/riscv-isa-sim" 8 | 9 | LICENSE="BSD" 10 | SLOT="0/${PV}" 11 | 12 | if [[ ${PV} == 9999 ]]; then 13 | inherit git-r3 14 | EGIT_REPO_URI="https://github.com/riscv-software-src/riscv-isa-sim.git" 15 | else 16 | MY_COMMIT=3427b459f88d2334368a1abbdf5a3000957f08e8 17 | if [[ -v MY_COMMIT ]]; then 18 | SRC_URI="https://github.com/riscv-software-src/riscv-isa-sim/archive/${MY_COMMIT}.tar.gz -> ${P}.tar.gz" 19 | S="${WORKDIR}/riscv-isa-sim-${MY_COMMIT}" 20 | else 21 | SRC_URI="https://github.com/riscv/riscv-isa-sim/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" 22 | fi 23 | KEYWORDS="~amd64" 24 | fi 25 | 26 | DEPEND="sys-apps/dtc" 27 | RDEPEND="${DEPEND}" 28 | 29 | src_prepare() { 30 | default 31 | 32 | sed -i -e "/install_libs_dir/s:/lib:/$(get_libdir)/spike:g" \ 33 | Makefile.in || die 34 | } 35 | -------------------------------------------------------------------------------- /app-emulation/spike/spike-9999.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=8 5 | 6 | DESCRIPTION="The RISC-V ISA Simulator" 7 | HOMEPAGE="https://github.com/riscv-software-src/riscv-isa-sim" 8 | 9 | LICENSE="BSD" 10 | SLOT="0/${PV}" 11 | 12 | if [[ ${PV} == 9999 ]]; then 13 | inherit git-r3 14 | EGIT_REPO_URI="https://github.com/riscv-software-src/riscv-isa-sim.git" 15 | else 16 | MY_COMMIT=3427b459f88d2334368a1abbdf5a3000957f08e8 17 | if [[ -v MY_COMMIT ]]; then 18 | SRC_URI="https://github.com/riscv-software-src/riscv-isa-sim/archive/${MY_COMMIT}.tar.gz -> ${P}.tar.gz" 19 | S="${WORKDIR}/riscv-isa-sim-${MY_COMMIT}" 20 | else 21 | SRC_URI="https://github.com/riscv/riscv-isa-sim/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" 22 | fi 23 | KEYWORDS="~amd64" 24 | fi 25 | 26 | DEPEND="sys-apps/dtc" 27 | RDEPEND="${DEPEND}" 28 | 29 | src_prepare() { 30 | default 31 | 32 | sed -i -e "/install_libs_dir/s:/lib:/$(get_libdir)/spike:g" \ 33 | Makefile.in || die 34 | } 35 | -------------------------------------------------------------------------------- /dev-debug/valgrind/files/valgrind-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch: -------------------------------------------------------------------------------- 1 | From beab8d9f8d65230567270331017184c8762faa42 Mon Sep 17 00:00:00 2001 2 | From: Matt Turner 3 | Date: Mon, 4 Nov 2019 09:12:16 -0800 4 | Subject: [PATCH] Build ldst_multiple test with -fno-pie 5 | 6 | Bug: https://bugs.gentoo.org/685070 7 | --- 8 | none/tests/ppc32/Makefile.am | 1 + 9 | 1 file changed, 1 insertion(+) 10 | 11 | diff --git a/none/tests/ppc32/Makefile.am b/none/tests/ppc32/Makefile.am 12 | index 11697c99a..222efd3f2 100644 13 | --- a/none/tests/ppc32/Makefile.am 14 | +++ b/none/tests/ppc32/Makefile.am 15 | @@ -156,3 +156,4 @@ test_isa_2_07_part2_LDADD = -lm 16 | test_tm_LDADD = -lm 17 | test_touch_tm_LDADD = -lm 18 | 19 | +ldst_multiple_CFLAGS = $(AM_CFLAGS) -fno-pie 20 | -- 21 | 2.23.0 22 | 23 | -------------------------------------------------------------------------------- /dev-debug/valgrind/files/valgrind-3.7.0-respect-flags.patch: -------------------------------------------------------------------------------- 1 | diff -Naur valgrind-3.7.0.orig//mpi/Makefile.am valgrind-3.7.0/mpi/Makefile.am 2 | --- valgrind-3.7.0.orig//mpi/Makefile.am 2011-10-26 17:24:23.000000000 -0400 3 | +++ valgrind-3.7.0/mpi/Makefile.am 2011-11-10 16:03:14.000000000 -0500 4 | @@ -7,9 +7,6 @@ 5 | CC = $(MPI_CC) 6 | DEFS = 7 | DEFAULT_INCLUDES = 8 | -CPPFLAGS = 9 | -CFLAGS = 10 | -LDFLAGS = 11 | 12 | EXTRA_DIST = \ 13 | mpiwrap_type_test.c 14 | -------------------------------------------------------------------------------- /dev-debug/valgrind/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | blueness@gentoo.org 6 | Anthony G. Basile 7 | 8 | 9 | Valgrind is a GPL'd tool to help you find memory-management problems 10 | in your programs. When a program is run under Valgrind's supervision, 11 | all reads and writes of memory are checked, and calls to 12 | malloc/new/free/delete are intercepted. As a result, Valgrind can 13 | detect problems such as 14 | 15 | - Use of uninitialised memory 16 | - Reading/writing memory after it has been free'd 17 | - Reading/writing off the end of malloc'd blocks 18 | - Reading/writing inappropriate areas on the stack 19 | - Memory leaks -- where pointers to malloc'd blocks are lost forever 20 | - Passing of uninitialised and/or unaddressible memory to system calls 21 | - Mismatched use of malloc/new/new [] vs free/delete/delete [] 22 | - Some abuses of the POSIX Pthreads API 23 | 24 | 25 | -------------------------------------------------------------------------------- /dev-debug/valgrind/valgrind-9999.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 1999-2022 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=7 5 | inherit autotools flag-o-matic toolchain-funcs multilib pax-utils 6 | 7 | DESCRIPTION="An open-source memory debugger for GNU/Linux" 8 | HOMEPAGE="https://www.valgrind.org" 9 | LICENSE="GPL-2" 10 | SLOT="0" 11 | IUSE="mpi" 12 | 13 | if [[ ${PV} == "9999" ]]; then 14 | EGIT_REPO_URI="https://github.com/petrpavlu/valgrind-riscv64" 15 | EGIT_BRANCH="riscv64-linux" 16 | inherit git-r3 17 | else 18 | SRC_URI="https://sourceware.org/pub/valgrind/${P}.tar.bz2" 19 | KEYWORDS="-* ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris" 20 | fi 21 | 22 | DEPEND="mpi? ( virtual/mpi )" 23 | RDEPEND="${DEPEND}" 24 | 25 | src_prepare() { 26 | # Correct hard coded doc location 27 | sed -i -e "s:doc/valgrind:doc/${PF}:" docs/Makefile.am || die 28 | 29 | # Don't force multiarch stuff on OSX, bug #306467 30 | sed -i -e 's:-arch \(i386\|x86_64\)::g' Makefile.all.am || die 31 | 32 | # Respect CFLAGS, LDFLAGS 33 | eapply "${FILESDIR}"/${PN}-3.7.0-respect-flags.patch 34 | 35 | eapply "${FILESDIR}"/${PN}-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch 36 | 37 | if [[ ${CHOST} == *-solaris* ]] ; then 38 | # upstream doesn't support this, but we don't build with 39 | # Sun/Oracle ld, we have a GNU toolchain, so get some things 40 | # working the Linux/GNU way 41 | find "${S}" -name "Makefile.am" -o -name "Makefile.tool.am" | xargs \ 42 | sed -i -e 's:-M,/usr/lib/ld/map.noexstk:-z,noexecstack:' || die 43 | cp "${S}"/coregrind/link_tool_exe_{linux,solaris}.in 44 | fi 45 | 46 | # Allow users to test their own patches 47 | eapply_user 48 | 49 | # Regenerate autotools files 50 | eautoreconf 51 | } 52 | 53 | src_configure() { 54 | local myconf=() 55 | 56 | # Respect ar, bug #468114 57 | tc-export AR 58 | 59 | # -fomit-frame-pointer "Assembler messages: Error: junk `8' after expression" 60 | # while compiling insn_sse.c in none/tests/x86 61 | # -fstack-protector more undefined references to __guard and __stack_smash_handler 62 | # because valgrind doesn't link to glibc (bug #114347) 63 | # -fstack-protector-all Fails same way as -fstack-protector/-fstack-protector-strong. 64 | # Note: -fstack-protector-explicit is a no-op for Valgrind, no need to strip it 65 | # -fstack-protector-strong See -fstack-protector (bug #620402) 66 | # -m64 -mx32 for multilib-portage, bug #398825 67 | # -ggdb3 segmentation fault on startup 68 | filter-flags -fomit-frame-pointer 69 | filter-flags -fstack-protector 70 | filter-flags -fstack-protector-all 71 | filter-flags -fstack-protector-strong 72 | filter-flags -m64 -mx32 73 | replace-flags -ggdb3 -ggdb2 74 | 75 | if use amd64 || use ppc64; then 76 | ! has_multilib_profile && myconf+=("--enable-only64bit") 77 | fi 78 | 79 | # Force bitness on darwin, bug #306467 80 | use x64-macos && myconf+=("--enable-only64bit") 81 | 82 | # Don't use mpicc unless the user asked for it (bug #258832) 83 | if ! use mpi; then 84 | myconf+=("--without-mpicc") 85 | fi 86 | 87 | econf "${myconf[@]}" 88 | } 89 | 90 | src_install() { 91 | default 92 | 93 | if [[ ${PV} == "9999" ]]; then 94 | # Otherwise FAQ.txt won't exist: 95 | emake -C docs FAQ.txt 96 | mv docs/FAQ.txt . || die "Couldn't move FAQ.txt" 97 | fi 98 | 99 | dodoc FAQ.txt 100 | 101 | pax-mark m "${ED}"/usr/$(get_libdir)/valgrind/*-*-linux 102 | 103 | if [[ ${CHOST} == *-darwin* ]] ; then 104 | # fix install_names on shared libraries, can't turn them into bundles, 105 | # as dyld won't load them any more then, bug #306467 106 | local l 107 | for l in "${ED}"/usr/lib/valgrind/*.so ; do 108 | install_name_tool -id "${EPREFIX}"/usr/lib/valgrind/${l##*/} "${l}" 109 | done 110 | fi 111 | } 112 | 113 | pkg_postinst() { 114 | elog "Valgrind will not work if glibc does not have debug symbols." 115 | elog "To fix this you can add splitdebug to FEATURES in make.conf" 116 | elog "and remerge glibc. See:" 117 | elog "https://bugs.gentoo.org/show_bug.cgi?id=214065" 118 | elog "https://bugs.gentoo.org/show_bug.cgi?id=274771" 119 | elog "https://bugs.gentoo.org/show_bug.cgi?id=388703" 120 | } 121 | -------------------------------------------------------------------------------- /dev-lang/luajit/Manifest: -------------------------------------------------------------------------------- 1 | DIST luajit-2.1.1727870382-RISCV-support.patch 364280 BLAKE2B 790ad563788a5f8b14af483f708e49017b540aaa4c4f04eac3a06174cf9cae1aa2e33dcbdf8305e1922ac144a5504cf541df4b494dca77e5fd79d13323bdb669 SHA512 9055d7ba414cfa28ae2cef762ef8e407848c835c68f0e89f20c765a02e02047561862725ebc8a79f17334129b34a05d60e3bc8dfcb0a1e547a4d000d65f19e94 2 | DIST luajit-2.1.1727870382.tar.gz 1082759 BLAKE2B ca2cca53238b1fcbb5a829b125f6b3efda3a863765027c8c224a01b95756255583e126ec04c115e7acc54314fb387ce1b09b9384acf0a852d51f887409bd702a SHA512 ac26594526f10e878874c02b2bbdfc6a0d1366c60456fbd09a75da5f565a2f81a1c73e385a7e7f0096a3923df5f4ac7f727100faced355bd05a9da0e95fbe1ef 3 | -------------------------------------------------------------------------------- /dev-lang/luajit/luajit-2.1.1727870382.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 1999-2024 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=8 5 | GIT_COMMIT=97813fb924edf822455f91a5fbbdfdb349e5984f 6 | GIT_COMMIT_RISCV=1893cf72c264f837596614a537a18e83b8c1b678 7 | 8 | # Upstream doesn't make releases anymore and instead have a (broken) "rolling 9 | # git tag" model. 10 | # 11 | # https://github.com/LuaJIT/LuaJIT/issues/665#issuecomment-784452583 12 | # https://www.freelists.org/post/luajit/LuaJIT-uses-rolling-releases 13 | # 14 | # Regular snapshots should be made from the v2.1 branch. Get the version with 15 | # `git show -s --format=%ct` 16 | 17 | inherit toolchain-funcs 18 | 19 | DESCRIPTION="Just-In-Time Compiler for the Lua programming language" 20 | HOMEPAGE="https://luajit.org/" 21 | SRC_URI=" 22 | https://github.com/LuaJIT/LuaJIT/archive/${GIT_COMMIT}.tar.gz -> ${P}.tar.gz 23 | https://github.com/plctlab/LuaJIT/compare/${GIT_COMMIT}..${GIT_COMMIT_RISCV}.patch -> ${P}-RISCV-support.patch 24 | " 25 | S="${WORKDIR}/LuaJIT-${GIT_COMMIT}" 26 | 27 | LICENSE="MIT" 28 | # this should probably be pkgmoved to 2.0 for sake of consistency. 29 | SLOT="2/${PV}" 30 | KEYWORDS="-* ~riscv" 31 | IUSE="lua52compat static-libs" 32 | 33 | PATCHES=( 34 | "${DISTDIR}/${P}-RISCV-support.patch" 35 | ) 36 | 37 | _emake() { 38 | emake \ 39 | Q= \ 40 | PREFIX="${EPREFIX}/usr" \ 41 | MULTILIB="$(get_libdir)" \ 42 | DESTDIR="${D}" \ 43 | CFLAGS="" \ 44 | LDFLAGS="" \ 45 | HOST_CC="$(tc-getBUILD_CC)" \ 46 | HOST_CFLAGS="${BUILD_CPPFLAGS} ${BUILD_CFLAGS}" \ 47 | HOST_LDFLAGS="${BUILD_LDFLAGS}" \ 48 | STATIC_CC="$(tc-getCC)" \ 49 | DYNAMIC_CC="$(tc-getCC) -fPIC" \ 50 | TARGET_LD="$(tc-getCC)" \ 51 | TARGET_CFLAGS="${CPPFLAGS} ${CFLAGS}" \ 52 | TARGET_LDFLAGS="${LDFLAGS}" \ 53 | TARGET_AR="$(tc-getAR) rcus" \ 54 | BUILDMODE="$(usex static-libs mixed dynamic)" \ 55 | TARGET_STRIP="true" \ 56 | INSTALL_LIB="${ED}/usr/$(get_libdir)" \ 57 | "$@" 58 | } 59 | 60 | src_compile() { 61 | tc-export_build_env 62 | _emake XCFLAGS="$(usex lua52compat "-DLUAJIT_ENABLE_LUA52COMPAT" "")" 63 | } 64 | 65 | src_install() { 66 | _emake install 67 | dosym luajit-"${PV}" /usr/bin/luajit 68 | 69 | HTML_DOCS="doc/." einstalldocs 70 | } 71 | -------------------------------------------------------------------------------- /dev-lang/luajit/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Enable some upwards-compatible features 8 | from Lua 5.2 that are unlikely to break existing code. 9 | 10 | 11 | 12 | LuaJIT/LuaJIT 13 | 14 | 15 | -------------------------------------------------------------------------------- /licenses/MulanPSL-2.0: -------------------------------------------------------------------------------- 1 | 木兰宽松许可证, 第2版 2 | 木兰宽松许可证, 第2版 3 | 4 | 2020年1月 http://license.coscl.org.cn/MulanPSL2 5 | 6 | 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: 7 | 8 | 0. 定义 9 | 10 | “软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 11 | 12 | “贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 13 | 14 | “贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 15 | 16 | “法人实体” 是指提交贡献的机构及其“关联实体”。 17 | 18 | “关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 19 | 20 | 1. 授予版权许可 21 | 22 | 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 23 | 24 | 2. 授予专利许可 25 | 26 | 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 27 | 28 | 3. 无商标许可 29 | 30 | “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 31 | 32 | 4. 分发限制 33 | 34 | 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 35 | 36 | 5. 免责声明与责任限制 37 | 38 | “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 39 | 40 | 6. 语言 41 | 42 | “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 43 | 44 | 条款结束 45 | 46 | 如何将木兰宽松许可证,第2版,应用到您的软件 47 | 48 | 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: 49 | 50 | 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; 51 | 52 | 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; 53 | 54 | 3, 请将如下声明文本放入每个源文件的头部注释中。 55 | 56 | Copyright (c) [Year] [name of copyright holder] 57 | [Software Name] is licensed under Mulan PSL v2. 58 | You can use this software according to the terms and conditions of the Mulan PSL v2. 59 | You may obtain a copy of Mulan PSL v2 at: 60 | http://license.coscl.org.cn/MulanPSL2 61 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 62 | EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 63 | MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 64 | See the Mulan PSL v2 for more details. 65 | Mulan Permissive Software License,Version 2 66 | Mulan Permissive Software License,Version 2 (Mulan PSL v2) 67 | 68 | January 2020 http://license.coscl.org.cn/MulanPSL2 69 | 70 | Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: 71 | 72 | 0. Definition 73 | 74 | Software means the program and related documents which are licensed under this License and comprise all Contribution(s). 75 | 76 | Contribution means the copyrightable work licensed by a particular Contributor under this License. 77 | 78 | Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. 79 | 80 | Legal Entity means the entity making a Contribution and all its Affiliates. 81 | 82 | Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. 83 | 84 | 1. Grant of Copyright License 85 | 86 | Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 87 | 88 | 2. Grant of Patent License 89 | 90 | Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 91 | 92 | 3. No Trademark License 93 | 94 | No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4. 95 | 96 | 4. Distribution Restriction 97 | 98 | You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 99 | 100 | 5. Disclaimer of Warranty and Limitation of Liability 101 | 102 | THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 103 | 104 | 6. Language 105 | 106 | THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. 107 | 108 | END OF THE TERMS AND CONDITIONS 109 | 110 | How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software 111 | 112 | To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: 113 | 114 | Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; 115 | Create a file named "LICENSE" which contains the whole context of this License in the first directory of your software package; 116 | Attach the statement to the appropriate annotated syntax at the beginning of each source file. 117 | Copyright (c) [Year] [name of copyright holder] 118 | [Software Name] is licensed under Mulan PSL v2. 119 | You can use this software according to the terms and conditions of the Mulan PSL v2. 120 | You may obtain a copy of Mulan PSL v2 at: 121 | http://license.coscl.org.cn/MulanPSL2 122 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 123 | EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 124 | MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 125 | See the Mulan PSL v2 for more details. 126 | -------------------------------------------------------------------------------- /metadata/.gitignore: -------------------------------------------------------------------------------- 1 | /md5-cache/ 2 | /pkg_desc_index 3 | -------------------------------------------------------------------------------- /metadata/layout.conf: -------------------------------------------------------------------------------- 1 | masters = gentoo 2 | 3 | # Use new hashes 4 | manifest-hashes = BLAKE2B SHA512 5 | 6 | # Do not update changelogs 7 | update-changelog = false 8 | 9 | # Use thin manifests 10 | thin-manifests = true 11 | 12 | # Dont sign thin manifests. There is no current policy for git commit signing 13 | sign-manifests = false 14 | 15 | # sign commits using git mechanisms 16 | sign-commits = true 17 | -------------------------------------------------------------------------------- /profiles/.gitignore: -------------------------------------------------------------------------------- 1 | /use.local.desc 2 | -------------------------------------------------------------------------------- /profiles/eapi: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /profiles/license_groups: -------------------------------------------------------------------------------- 1 | OSI-APPROVED MulanPSL-2.0 2 | -------------------------------------------------------------------------------- /profiles/repo_name: -------------------------------------------------------------------------------- 1 | riscv 2 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/Manifest: -------------------------------------------------------------------------------- 1 | DIST kexec-tools-2.0.24.tar.xz 303808 BLAKE2B 8188602f1b843c1dccc0307131f8c9ec0426c6cb3de898040352c1fed5f6d4bd7c58a0c2bf54290b91c8fe3401180df682959ee6c41693d07acc199c087c7db2 SHA512 ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822 2 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/90_kexec: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | version="$1" ; shift 4 | image="$1" ; shift 5 | 6 | exec sed \ 7 | -e "s:\"vmlinuz-.*\":\"vmlinuz-${version}\":" \ 8 | -e "s:/boot/initramfs-.*\.img:/boot/initramfs-${version}\.img:" \ 9 | -i /etc/kexec.conf 10 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/README.Gentoo: -------------------------------------------------------------------------------- 1 | Usage 2 | ===== 3 | 4 | Do 5 | $ man 8 kexec 6 | for full understanding of the underlying kexec command. 7 | Gentoo offers a wrapper to the bare kexec command through 8 | /etc/init.d/kexec. 9 | 10 | Configuration 11 | ------------- 12 | 13 | Configuration is done in /etc/conf.d/kexec, which is self-documented. 14 | 15 | Usage 16 | ----- 17 | 18 | In Gentoo, kexec is invoked, i.e., the new kernel will be booted when 19 | rebooting, by reboot (8) command or by pressing Ctrl+Alt+Del. 20 | 21 | If you want to use kexec once, just run 22 | $ /etc/init.d/kexec start 23 | 24 | It'll reserve kexec call at reboot. Later on, you can reboot anytime, 25 | letting kexec starts another (or the same) kernel. When all is done in 26 | the runlevel 6 - killing processes, unmounting volumes, etc - kexec 27 | starts the new kernel instead of doing the normal hardware reboot. 28 | 29 | If you want kexec to be run every time you reboot, add it to a runlevel: 30 | $ rc-update add kexec 31 | 32 | If you want to reboot in the normal way this time, do: 33 | $ touch /nokexec 34 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/kexec-r2.init: -------------------------------------------------------------------------------- 1 | #!/sbin/openrc-run 2 | # Copyright 1999-2020 Gentoo Authors 3 | # Distributed under the terms of the GNU General Public License v2 4 | 5 | # Set up some defaults. 6 | : "${LOAD_DURING_SHUTDOWN:=yes}" 7 | : "${BOOTPART:=/boot}" 8 | : "${DONT_MOUNT_BOOT:=no}" 9 | 10 | depend() { 11 | need localmount 12 | } 13 | 14 | auto_prefix_bootpath() { 15 | # Only auto-add prefix to relative paths. 16 | case $1 in 17 | */*) echo "$1";; 18 | *) echo "${BOOTPART}/$1" ;; 19 | esac 20 | } 21 | 22 | get_genkernel_arch() { 23 | case $1 in 24 | x86_64) echo "amd64" ;; 25 | i[3456]86) echo "x86" ;; 26 | *) echo "$1" ;; 27 | esac 28 | } 29 | 30 | image_path() { 31 | # Do no sanity checking if the user has set a value. 32 | if [ -n "${KNAME}" ]; then 33 | auto_prefix_bootpath "${KNAME}" 34 | return 35 | fi 36 | 37 | local x kver="$(uname -r)" karch="$(uname -m)" 38 | local gkarch="$(get_genkernel_arch $karch)" 39 | for x in \ 40 | "bzImage" \ 41 | "vmlinux" \ 42 | "vmlinuz" \ 43 | "kernel" \ 44 | "bzImage-${kver}" \ 45 | "vmlinux-${kver}" \ 46 | "vmlinuz-${kver}" \ 47 | "kernel-genkernel-${karch}-${kver}" \ 48 | "kernel-genkernel-${gkarch}-${kver}" \ 49 | "kernel-${kver}" \ 50 | "kernel-${karch}"; do 51 | if [ -e "${BOOTPART}/${x}" ]; then 52 | echo "${BOOTPART}/${x}" 53 | return 54 | fi 55 | done 56 | 57 | return 1 58 | } 59 | 60 | initrd_path() { 61 | # Do no sanity checking if the user has set a value. 62 | if [ -n "${INITRD}" ]; then 63 | auto_prefix_bootpath "${INITRD}" 64 | return 0 65 | fi 66 | 67 | local x kver="$(uname -r)" karch="$(uname -m)" 68 | local gkarch="$(get_genkernel_arch $karch)" 69 | for x in \ 70 | "initrd" \ 71 | "initramfs" \ 72 | "initrd.img-${kver}" \ 73 | "initrd-${kver}.img" \ 74 | "initrd-${kver}" \ 75 | "initramfs-${kver}.img" \ 76 | "initramfs-genkernel-${karch}-${kver}" \ 77 | "initramfs-genkernel-${gkarch}-${kver}"; do 78 | if [ -e "${BOOTPART}/${x}" ]; then 79 | echo "${BOOTPART}/${x}" 80 | return 0 81 | fi 82 | done 83 | 84 | return 1 85 | } 86 | 87 | mount_boot() { 88 | [ "${DONT_MOUNT_BOOT}" != "no" ] && return 1 89 | mountinfo -q "${BOOTPART}" && return 1 90 | 91 | ebegin "Mounting ${BOOTPART}" 92 | mount "${BOOTPART}" 93 | eend $? 94 | } 95 | 96 | load_image() { 97 | if [ "${KNAME}" = "-" ]; then 98 | ebegin "Disabling kexec" 99 | kexec -u 100 | eend $? 101 | return # eend preserved $? for us. 102 | fi 103 | 104 | local img initrd="$(initrd_path)" mounted=false kparamopt initrdopt 105 | 106 | if ! img="$(image_path)"; then 107 | if mount_boot; then 108 | if img="$(image_path)"; then 109 | mounted=true 110 | initrd="$(initrd_path)" 111 | else 112 | eerror "No kernel image found in ${BOOTPART}!" 113 | umount "${BOOTPART}" 114 | return 1 115 | fi 116 | else 117 | eerror "No kernel image found in ${BOOTPART}!" 118 | return 1 119 | fi 120 | fi 121 | 122 | local is_rootpart_autodetected=no 123 | if [ -z "${ROOTPART}" ]; then 124 | ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")" 125 | is_rootpart_autodetected=yes 126 | fi 127 | 128 | local is_reusing_cmdline=no 129 | if [ -z "${KPARAM}" ]; then 130 | kparamopt="--reuse-cmdline" 131 | is_reusing_cmdline=yes 132 | fi 133 | 134 | if ! yesno "${is_rootpart_autodetected}" || ! yesno "${is_reusing_cmdline}"; then 135 | # Only append root when explicit set in config or 136 | # if we aren't re-using kernel cmdline 137 | KPARAM="${KPARAM:+"${KPARAM} "}root=${ROOTPART}" 138 | fi 139 | 140 | if [ -n "${initrd}" ]; then 141 | initrdopt="--initrd=${initrd}" 142 | fi 143 | 144 | local msg 145 | [ -n "${initrd}" ] && \ 146 | msg=" (with ${initrd})" 147 | ebegin "Using kernel image ${img}${msg} for kexec" 148 | 149 | kexec ${KEXEC_OPT_ARGS} ${kparamopt} \ 150 | -l "${img}" ${KPARAM:+--append="${KPARAM}"} ${initrdopt} 151 | local ret=$? 152 | 153 | ${mounted} && umount "${BOOTPART}" 154 | eend ${ret} 155 | return ${ret} 156 | } 157 | 158 | start() { 159 | if [ "${LOAD_DURING_SHUTDOWN}" = "yes" ]; then 160 | local mounted 161 | if mount_boot; then 162 | mounted=true 163 | fi 164 | if ! image_path >/dev/null; then 165 | ewarn "Cannot find kernel image!" 166 | ewarn "Please make sure a valid kernel image is present before reboot." 167 | return 0 168 | fi 169 | if [ -n "${mounted}" ]; then 170 | ebegin "Unmounting ${BOOTPART}" 171 | umount "${BOOTPART}" 172 | eend $? 173 | fi 174 | # $? is already set to the previous calls. 175 | return 176 | else 177 | load_image 178 | fi 179 | } 180 | 181 | stop() { 182 | if ! yesno ${RC_REBOOT}; then 183 | ebegin "Not rebooting; disabling kexec" 184 | kexec -u 185 | eend $? 186 | return 187 | fi 188 | 189 | if [ -f /nokexec ]; then 190 | ebegin "Rebooting; disabling kexec due to /nokexec" 191 | rm -f /nokexec 192 | kexec -u 193 | eend $? 194 | return 195 | fi 196 | 197 | if [ "${LOAD_DURING_SHUTDOWN}" = "yes" ]; then 198 | load_image 199 | fi 200 | } 201 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/kexec-tools-2.0.24-riscv.patch: -------------------------------------------------------------------------------- 1 | From 6975082921e577ed5034e56010d2b433aeaf6907 Mon Sep 17 00:00:00 2001 2 | From: Nick Kossifidis 3 | Date: Tue, 5 Oct 2021 15:01:19 +0300 4 | Subject: [PATCH] RISC-V: Add support for riscv kexec/kdump on kexec-tools 5 | 6 | This patch adds support for loading the ELF kernel image. It parses 7 | the current/provided device tree to determine the system's memory 8 | layout, and /proc/iomem for the various kernel segments. 9 | 10 | Tested on Qemu's rv64 virt machine. 11 | 12 | Signed-off-by: Nick Kossifidis 13 | --- 14 | configure.ac | 3 + 15 | include/elf.h | 3 +- 16 | kexec/Makefile | 1 + 17 | kexec/arch/riscv/Makefile | 35 ++ 18 | kexec/arch/riscv/crashdump-riscv.c | 140 ++++++++ 19 | kexec/arch/riscv/include/arch/options.h | 43 +++ 20 | kexec/arch/riscv/kexec-elf-riscv.c | 255 ++++++++++++++ 21 | kexec/arch/riscv/kexec-riscv.c | 364 +++++++++++++++++++ 22 | kexec/arch/riscv/kexec-riscv.h | 32 ++ 23 | kexec/dt-ops.c | 442 +++++++++++++++++++++++- 24 | kexec/dt-ops.h | 7 + 25 | kexec/kexec-syscall.h | 4 + 26 | purgatory/Makefile | 1 + 27 | purgatory/arch/riscv/Makefile | 7 + 28 | 14 files changed, 1335 insertions(+), 2 deletions(-) 29 | create mode 100644 kexec/arch/riscv/Makefile 30 | create mode 100644 kexec/arch/riscv/crashdump-riscv.c 31 | create mode 100644 kexec/arch/riscv/include/arch/options.h 32 | create mode 100644 kexec/arch/riscv/kexec-elf-riscv.c 33 | create mode 100644 kexec/arch/riscv/kexec-riscv.c 34 | create mode 100644 kexec/arch/riscv/kexec-riscv.h 35 | create mode 100644 purgatory/arch/riscv/Makefile 36 | 37 | diff --git a/configure.ac b/configure.ac 38 | index cf8e8a2..d21552c 100644 39 | --- a/configure.ac 40 | +++ b/configure.ac 41 | @@ -58,6 +58,9 @@ case $target_cpu in 42 | hppa*) 43 | ARCH="hppa" 44 | ;; 45 | + riscv32|riscv64 ) 46 | + ARCH="riscv" 47 | + ;; 48 | * ) 49 | AC_MSG_ERROR([unsupported architecture $target_cpu]) 50 | ;; 51 | diff --git a/include/elf.h b/include/elf.h 52 | index b7677a2..123f167 100644 53 | --- a/include/elf.h 54 | +++ b/include/elf.h 55 | @@ -259,7 +259,8 @@ typedef struct 56 | #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ 57 | #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ 58 | #define EM_AARCH64 183 /* ARM AARCH64 */ 59 | -#define EM_NUM 184 60 | +#define EM_RISCV 243 /* RISC-V */ 61 | +#define EM_NUM 244 62 | 63 | /* If it is necessary to assign new unofficial EM_* values, please 64 | pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the 65 | diff --git a/kexec/Makefile b/kexec/Makefile 66 | index e69e309..ca17831 100644 67 | --- a/kexec/Makefile 68 | +++ b/kexec/Makefile 69 | @@ -88,6 +88,7 @@ include $(srcdir)/kexec/arch/mips/Makefile 70 | include $(srcdir)/kexec/arch/cris/Makefile 71 | include $(srcdir)/kexec/arch/ppc/Makefile 72 | include $(srcdir)/kexec/arch/ppc64/Makefile 73 | +include $(srcdir)/kexec/arch/riscv/Makefile 74 | include $(srcdir)/kexec/arch/s390/Makefile 75 | include $(srcdir)/kexec/arch/sh/Makefile 76 | include $(srcdir)/kexec/arch/x86_64/Makefile 77 | diff --git a/kexec/arch/riscv/Makefile b/kexec/arch/riscv/Makefile 78 | new file mode 100644 79 | index 0000000..f26cc90 80 | --- /dev/null 81 | +++ b/kexec/arch/riscv/Makefile 82 | @@ -0,0 +1,35 @@ 83 | +# 84 | +# kexec riscv 85 | +# 86 | +riscv_KEXEC_SRCS = kexec/arch/riscv/kexec-riscv.c 87 | +riscv_KEXEC_SRCS += kexec/arch/riscv/kexec-elf-riscv.c 88 | +riscv_KEXEC_SRCS += kexec/arch/riscv/crashdump-riscv.c 89 | + 90 | +riscv_MEM_REGIONS = kexec/mem_regions.c 91 | + 92 | +riscv_DT_OPS += kexec/dt-ops.c 93 | + 94 | +riscv_ARCH_REUSE_INITRD = 95 | + 96 | +riscv_CPPFLAGS += -I $(srcdir)/kexec/ 97 | + 98 | +dist += kexec/arch/riscv/Makefile $(riscv_KEXEC_SRCS) \ 99 | + kexec/arch/riscv/kexec-riscv.h \ 100 | + kexec/arch/riscv/include/arch/options.h 101 | + 102 | +ifdef HAVE_LIBFDT 103 | + 104 | +LIBS += -lfdt 105 | + 106 | +else 107 | + 108 | +include $(srcdir)/kexec/libfdt/Makefile.libfdt 109 | + 110 | +libfdt_SRCS += $(LIBFDT_SRCS:%=kexec/libfdt/%) 111 | + 112 | +riscv_CPPFLAGS += -I$(srcdir)/kexec/libfdt 113 | + 114 | +riscv_KEXEC_SRCS += $(libfdt_SRCS) 115 | + 116 | +endif 117 | + 118 | diff --git a/kexec/arch/riscv/crashdump-riscv.c b/kexec/arch/riscv/crashdump-riscv.c 119 | new file mode 100644 120 | index 0000000..7fc041e 121 | --- /dev/null 122 | +++ b/kexec/arch/riscv/crashdump-riscv.c 123 | @@ -0,0 +1,140 @@ 124 | +#include 125 | +#include 126 | +#include 127 | + 128 | +#include "kexec.h" 129 | +#include "crashdump.h" 130 | +#include "kexec-elf.h" 131 | +#include "mem_regions.h" 132 | + 133 | +static struct crash_elf_info elf_info = { 134 | +#if __riscv_xlen == 64 135 | + .class = ELFCLASS64, 136 | +#else 137 | + .class = ELFCLASS32, 138 | +#endif 139 | + .data = ELFDATA2LSB, 140 | + .machine = EM_RISCV, 141 | +}; 142 | + 143 | +static struct memory_ranges crash_mem_ranges = {0}; 144 | +struct memory_range elfcorehdr_mem = {0}; 145 | + 146 | +static unsigned long long get_page_offset(struct kexec_info *info) 147 | +{ 148 | + unsigned long long vaddr_off = 0; 149 | + unsigned long long page_size = sysconf(_SC_PAGESIZE); 150 | + unsigned long long init_start = get_kernel_sym("_sinittext"); 151 | + 152 | + /* 153 | + * Begining of init section is aligned to page size 154 | + */ 155 | + vaddr_off = init_start - page_size; 156 | + 157 | + return vaddr_off; 158 | +} 159 | + 160 | +int load_elfcorehdr(struct kexec_info *info) 161 | +{ 162 | + struct memory_range crashkern_range = {0}; 163 | + struct memory_range *ranges = NULL; 164 | + unsigned long start = 0; 165 | + unsigned long end = 0; 166 | + unsigned long buf_size = 0; 167 | + unsigned long elfcorehdr_addr = 0; 168 | + void* buf = NULL; 169 | + int i = 0; 170 | + int ret = 0; 171 | + 172 | + ret = parse_iomem_single("Kernel code\n", &start, NULL); 173 | + if (ret) { 174 | + fprintf(stderr, "Cannot determine kernel physical base addr\n"); 175 | + return -EINVAL; 176 | + } 177 | + elf_info.kern_paddr_start = start; 178 | + 179 | + ret = parse_iomem_single("Kernel bss\n", NULL, &end); 180 | + if (ret) { 181 | + fprintf(stderr, "Cannot determine kernel physical bss addr\n"); 182 | + return -EINVAL; 183 | + } 184 | + elf_info.kern_paddr_start = start; 185 | + elf_info.kern_size = end - start; 186 | + 187 | + elf_info.kern_vaddr_start = get_kernel_sym("_text"); 188 | + if (!elf_info.kern_vaddr_start) { 189 | + elf_info.kern_vaddr_start = UINT64_MAX; 190 | + } 191 | + 192 | + elf_info.page_offset = get_page_offset(info); 193 | + dbgprintf("page_offset: %016llx\n", elf_info.page_offset); 194 | + 195 | + ret = parse_iomem_single("Crash kernel\n", &start, &end); 196 | + if (ret) { 197 | + fprintf(stderr, "Cannot determine kernel physical bss addr\n"); 198 | + return -EINVAL; 199 | + } 200 | + crashkern_range.start = start; 201 | + crashkern_range.end = end; 202 | + crashkern_range.type = RANGE_RESERVED; 203 | + 204 | + ranges = info->memory_range; 205 | + for (i = 0; i < info->memory_ranges; i++) { 206 | + ret = mem_regions_alloc_and_add(&crash_mem_ranges, 207 | + ranges[i].start, 208 | + ranges[i].end - ranges[i].start, 209 | + ranges[i].type); 210 | + if (ret ) { 211 | + fprintf(stderr, "Could not create crash_mem_ranges\n"); 212 | + return ret; 213 | + } 214 | + } 215 | + 216 | + ret = mem_regions_alloc_and_exclude(&crash_mem_ranges, 217 | + &crashkern_range); 218 | + if (ret) { 219 | + fprintf(stderr, "Could not exclude crashkern_range\n"); 220 | + return ret; 221 | + } 222 | + 223 | +#if __riscv_xlen == 64 224 | + crash_create_elf64_headers(info, &elf_info, crash_mem_ranges.ranges, 225 | + crash_mem_ranges.size, &buf, &buf_size, 226 | + ELF_CORE_HEADER_ALIGN); 227 | + 228 | +#else 229 | + crash_create_elf32_headers(info, &elf_info, crash_mem_ranges.ranges, 230 | + crash_mem_ranges.size, &buf, &buf_size, 231 | + ELF_CORE_HEADER_ALIGN); 232 | +#endif 233 | + 234 | + 235 | + elfcorehdr_addr = add_buffer_phys_virt(info, buf, buf_size, 236 | + buf_size, 0, 237 | + crashkern_range.start, 238 | + crashkern_range.end, 239 | + -1, 0); 240 | + 241 | + elfcorehdr_mem.start = elfcorehdr_addr; 242 | + elfcorehdr_mem.end = elfcorehdr_addr + buf_size - 1; 243 | + 244 | + dbgprintf("%s: elfcorehdr 0x%llx-0x%llx\n", __func__, 245 | + elfcorehdr_mem.start, elfcorehdr_mem.end); 246 | + 247 | + return 0; 248 | +} 249 | + 250 | +int is_crashkernel_mem_reserved(void) 251 | +{ 252 | + uint64_t start = 0; 253 | + uint64_t end = 0; 254 | + 255 | + return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ? 256 | + (start != end) : 0; 257 | +} 258 | + 259 | +int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) 260 | +{ 261 | + return parse_iomem_single("Crash kernel\n", start, end); 262 | +} 263 | + 264 | diff --git a/kexec/arch/riscv/include/arch/options.h b/kexec/arch/riscv/include/arch/options.h 265 | new file mode 100644 266 | index 0000000..7c24184 267 | --- /dev/null 268 | +++ b/kexec/arch/riscv/include/arch/options.h 269 | @@ -0,0 +1,43 @@ 270 | +#ifndef KEXEC_ARCH_RISCV_OPTIONS_H 271 | +#define KEXEC_ARCH_RISCV_OPTIONS_H 272 | + 273 | +#define OPT_APPEND ((OPT_MAX)+0) 274 | +#define OPT_DTB ((OPT_MAX)+1) 275 | +#define OPT_INITRD ((OPT_MAX)+2) 276 | +#define OPT_CMDLINE ((OPT_MAX)+3) 277 | +#define OPT_REUSE_CMDLINE ((OPT_MAX)+4) 278 | +#define OPT_ARCH_MAX ((OPT_MAX)+5) 279 | + 280 | +/* Options relevant to the architecture (excluding loader-specific ones), 281 | + * in this case none: 282 | + */ 283 | +#define KEXEC_ARCH_OPTIONS \ 284 | + KEXEC_OPTIONS \ 285 | + { "append", 1, 0, OPT_APPEND}, \ 286 | + { "dtb", 1, 0, OPT_DTB }, \ 287 | + { "initrd", 1, 0, OPT_INITRD }, \ 288 | + { "command-line", 1, 0, OPT_CMDLINE}, \ 289 | + { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE }, \ 290 | + 291 | + 292 | +#define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR "" 293 | + 294 | +/* The following two #defines list ALL of the options added by all of the 295 | + * architecture's loaders. 296 | + * o main() uses this complete list to scan for its options, ignoring 297 | + * arch-specific/loader-specific ones. 298 | + * o Then, arch_process_options() uses this complete list to scan for its 299 | + * options, ignoring general/loader-specific ones. 300 | + * o Then, the file_type[n].load re-scans for options, using 301 | + * KEXEC_ARCH_OPTIONS plus its loader-specific options subset. 302 | + * Any unrecognised options cause an error here. 303 | + * 304 | + * This is done so that main()'s/arch_process_options()'s getopt_long() calls 305 | + * don't choose a kernel filename from random arguments to options they don't 306 | + * recognise -- as they now recognise (if not act upon) all possible options. 307 | + */ 308 | +#define KEXEC_ALL_OPTIONS KEXEC_ARCH_OPTIONS 309 | + 310 | +#define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR 311 | + 312 | +#endif /* KEXEC_ARCH_RISCV_OPTIONS_H */ 313 | diff --git a/kexec/arch/riscv/kexec-elf-riscv.c b/kexec/arch/riscv/kexec-elf-riscv.c 314 | new file mode 100644 315 | index 0000000..f3c011c 316 | --- /dev/null 317 | +++ b/kexec/arch/riscv/kexec-elf-riscv.c 318 | @@ -0,0 +1,255 @@ 319 | +/* SPDX-License-Identifier: GPL-2.0 */ 320 | +/* 321 | + * Copyright (C) 2019 FORTH-ICS/CARV 322 | + * Nick Kossifidis 323 | + */ 324 | + 325 | +#include "kexec.h" 326 | +#include "dt-ops.h" /* For dtb_set/clear_initrd() */ 327 | +#include /* For ELF header handling */ 328 | +#include /* For EFBIG/EINVAL */ 329 | +#include /* For getpagesize() */ 330 | +#include "kexec-syscall.h" /* For KEXEC_ON_CRASH */ 331 | +#include "kexec-riscv.h" 332 | + 333 | + 334 | +/*********\ 335 | +* HELPERS * 336 | +\*********/ 337 | + 338 | +/* 339 | + * Go through the available physical memory regions and 340 | + * find one that can hold an image of the specified size. 341 | + * Note: This is called after get_memory_ranges so 342 | + * info->memory_range[] should be populated. Also note that 343 | + * memory ranges are sorted, so we'll return the first region 344 | + * that's big enough for holding the image. 345 | + */ 346 | +static int elf_riscv_find_pbase(struct kexec_info *info, off_t *addr, 347 | + off_t size) 348 | +{ 349 | + int i = 0; 350 | + off_t start = 0; 351 | + off_t end = 0; 352 | + int ret = 0; 353 | + 354 | + /* 355 | + * If this image is for a crash kernel, use the region 356 | + * the primary kernel has already reserved for us. 357 | + */ 358 | + if (info->kexec_flags & KEXEC_ON_CRASH) { 359 | + ret = get_crash_kernel_load_range((uint64_t *) &start, 360 | + (uint64_t *) &end); 361 | + if (!ret) { 362 | + /* 363 | + * Kernel should be aligned to the nearest 364 | + * hugepage (2MB for RV64, 4MB for RV32). 365 | + */ 366 | +#if __riscv_xlen == 64 367 | + start = _ALIGN_UP(start, 0x200000); 368 | +#else 369 | + start = _ALIGN_UP(start, 0x400000); 370 | +#endif 371 | + if (end > start && ((end - start) >= size)) { 372 | + *addr = start; 373 | + return 0; 374 | + } 375 | + 376 | + return -EFBIG; 377 | + } else 378 | + return ENOCRASHKERNEL; 379 | + } 380 | + 381 | + for (i = 0; i < info->memory_ranges; i++) { 382 | + if (info->memory_range[i].type != RANGE_RAM) 383 | + continue; 384 | + 385 | + start = info->memory_range[i].start; 386 | + end = info->memory_range[i].end; 387 | + 388 | +#if __riscv_xlen == 64 389 | + start = _ALIGN_UP(start, 0x200000); 390 | +#else 391 | + start = _ALIGN_UP(start, 0x400000); 392 | +#endif 393 | + 394 | + if (end > start && ((end - start) >= size)) { 395 | + *addr = start; 396 | + return 0; 397 | + } 398 | + } 399 | + 400 | + return -EFBIG; 401 | +} 402 | + 403 | +/**************\ 404 | +* ENTRY POINTS * 405 | +\**************/ 406 | + 407 | +int elf_riscv_probe(const char *buf, off_t len) 408 | +{ 409 | + struct mem_ehdr ehdr = {0}; 410 | + int ret = 0; 411 | + 412 | + ret = build_elf_exec_info(buf, len, &ehdr, 0); 413 | + if (ret < 0) 414 | + goto cleanup; 415 | + 416 | + if (ehdr.e_machine != EM_RISCV) { 417 | + fprintf(stderr, "Not for this architecture.\n"); 418 | + ret = -EINVAL; 419 | + goto cleanup; 420 | + } 421 | + 422 | + ret = 0; 423 | + 424 | + cleanup: 425 | + free_elf_info(&ehdr); 426 | + return ret; 427 | +} 428 | + 429 | +void elf_riscv_usage(void) 430 | +{ 431 | +} 432 | + 433 | +int elf_riscv_load(int argc, char **argv, const char *buf, off_t len, 434 | + struct kexec_info *info) 435 | +{ 436 | + struct mem_ehdr ehdr = {0}; 437 | + struct mem_phdr *phdr = NULL; 438 | + off_t new_base_addr = 0; 439 | + off_t kernel_size = 0; 440 | + off_t page_size = getpagesize(); 441 | + off_t max_addr = 0; 442 | + off_t old_base_addr = 0; 443 | + off_t old_start_addr = 0; 444 | + int i = 0; 445 | + int ret = 0; 446 | + 447 | + if (info->file_mode) { 448 | + fprintf(stderr, "kexec_file not supported on this " 449 | + "architecture\n"); 450 | + return -EINVAL; 451 | + } 452 | + 453 | + /* Parse the ELF file */ 454 | + ret = build_elf_exec_info(buf, len, &ehdr, 0); 455 | + if (ret < 0) { 456 | + fprintf(stderr, "ELF exec parse failed\n"); 457 | + return -EINVAL; 458 | + } 459 | + 460 | + max_addr = elf_max_addr(&ehdr); 461 | + old_base_addr = max_addr; 462 | + old_start_addr = max_addr; 463 | + 464 | + /* 465 | + * Get the memory footprint, base physical 466 | + * and start address of the ELF image 467 | + */ 468 | + for (i = 0; i < ehdr.e_phnum; i++) { 469 | + phdr = &ehdr.e_phdr[i]; 470 | + if (phdr->p_type != PT_LOAD) 471 | + continue; 472 | + 473 | + /* 474 | + * Note: According to ELF spec the loadable regions 475 | + * are sorted on p_vaddr, not p_paddr. 476 | + */ 477 | + if (old_base_addr > phdr->p_paddr) 478 | + old_base_addr = phdr->p_paddr; 479 | + 480 | + if (phdr->p_vaddr == ehdr.e_entry || 481 | + phdr->p_paddr == ehdr.e_entry) 482 | + old_start_addr = phdr->p_paddr; 483 | + 484 | + kernel_size += _ALIGN_UP(phdr->p_memsz, page_size); 485 | + } 486 | + 487 | + if (old_base_addr == max_addr || kernel_size == 0) { 488 | + fprintf(stderr, "No loadable segments present on the " 489 | + "provided ELF image\n"); 490 | + return -EINVAL; 491 | + } 492 | + 493 | + if (old_start_addr == max_addr) { 494 | + fprintf(stderr, "Could not find the entry point address of " 495 | + "provided ELF image\n"); 496 | + return -EINVAL; 497 | + } 498 | + 499 | + dbgprintf("Got ELF with total memsz %luKB\n" 500 | + "Base paddr: 0x%lX, start_addr: 0x%lX\n", 501 | + kernel_size / 1024, old_base_addr, old_start_addr); 502 | + 503 | + /* Get a continuous physical region that can hold the kernel */ 504 | + ret = elf_riscv_find_pbase(info, &new_base_addr, kernel_size); 505 | + if (ret < 0) { 506 | + fprintf(stderr, "Could not find a memory region for the " 507 | + "provided ELF image\n"); 508 | + return ret; 509 | + } 510 | + 511 | + dbgprintf("New base paddr for the ELF: 0x%lX\n", new_base_addr); 512 | + 513 | + /* Re-set the base physical address of the ELF */ 514 | + for (i = 0; i < ehdr.e_phnum; i++) { 515 | + phdr = &ehdr.e_phdr[i]; 516 | + if (phdr->p_type != PT_LOAD) 517 | + continue; 518 | + 519 | + phdr->p_paddr -= old_base_addr; 520 | + phdr->p_paddr += new_base_addr; 521 | + } 522 | + 523 | + /* Re-set the entry point address */ 524 | + ehdr.e_entry = (old_start_addr - old_base_addr) + new_base_addr; 525 | + info->entry = (void *) ehdr.e_entry; 526 | + dbgprintf("New entry point for the ELF: 0x%llX\n", ehdr.e_entry); 527 | + 528 | + 529 | + /* Load the ELF executable */ 530 | + ret = elf_exec_load(&ehdr, info); 531 | + if (ret < 0) { 532 | + fprintf(stderr, "ELF exec load failed\n"); 533 | + return ret; 534 | + } 535 | + 536 | + ret = load_extra_segments(info, new_base_addr, 537 | + kernel_size, max_addr); 538 | + return ret; 539 | +} 540 | + 541 | + 542 | +/*******\ 543 | +* STUBS * 544 | +\*******/ 545 | + 546 | +int machine_verify_elf_rel(struct mem_ehdr *ehdr) 547 | +{ 548 | + if (ehdr->ei_data != ELFDATA2LSB) 549 | + return 0; 550 | +#if __riscv_xlen == 64 551 | + if (ehdr->ei_class != ELFCLASS64) 552 | +#else 553 | + if (ehdr->ei_class != ELFCLASS32) 554 | +#endif 555 | + return 0; 556 | + if (ehdr->e_machine != EM_RISCV) 557 | + return 0; 558 | + return 1; 559 | +} 560 | + 561 | +void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), 562 | + struct mem_sym *UNUSED(sym), 563 | + unsigned long r_type, 564 | + void *UNUSED(location), 565 | + unsigned long UNUSED(address), 566 | + unsigned long UNUSED(value)) 567 | +{ 568 | + switch (r_type) { 569 | + default: 570 | + die("Unknown rela relocation: %lu\n", r_type); 571 | + break; 572 | + } 573 | +} 574 | diff --git a/kexec/arch/riscv/kexec-riscv.c b/kexec/arch/riscv/kexec-riscv.c 575 | new file mode 100644 576 | index 0000000..d05c47d 577 | --- /dev/null 578 | +++ b/kexec/arch/riscv/kexec-riscv.c 579 | @@ -0,0 +1,364 @@ 580 | +/* SPDX-License-Identifier: GPL-2.0 */ 581 | +/* 582 | + * Copyright (C) 2019 FORTH-ICS/CARV 583 | + * Nick Kossifidis 584 | + */ 585 | + 586 | +#include "kexec-syscall.h" /* For KEXEC_ARCH_RISCV */ 587 | +#include "kexec.h" /* For OPT_MAX and concat_cmdline() */ 588 | +#include "mem_regions.h" /* For mem_regions_sort() */ 589 | +#include "dt-ops.h" /* For dtb_set_bootargs() */ 590 | +#include /* For KEXEC_ARCH_OPTIONS */ 591 | +#include /* For struct option */ 592 | +#include /* For stat() and struct stat */ 593 | +#include /* For free() */ 594 | +#include /* For EINVAL */ 595 | +#include /* For DeviceTree handling */ 596 | +#include "kexec-riscv.h" 597 | + 598 | +const struct arch_map_entry arches[] = { 599 | + { "riscv32", KEXEC_ARCH_RISCV }, 600 | + { "riscv64", KEXEC_ARCH_RISCV }, 601 | + { NULL, 0 }, 602 | +}; 603 | + 604 | + 605 | +struct file_type file_type[] = { 606 | + {"elf-riscv", elf_riscv_probe, elf_riscv_load, elf_riscv_usage}, 607 | +}; 608 | +int file_types = sizeof(file_type) / sizeof(file_type[0]); 609 | + 610 | +static const char riscv_opts_usage[] = 611 | +" --append=STRING Append STRING to the kernel command line.\n" 612 | +" --dtb=FILE Use FILE as the device tree blob.\n" 613 | +" --initrd=FILE Use FILE as the kernel initial ramdisk.\n" 614 | +" --cmdline=STRING Use STRING as the kernel's command line.\n" 615 | +" --reuse-cmdline Use kernel command line from running system.\n"; 616 | + 617 | +static struct riscv_opts arch_options = {0}; 618 | +static struct fdt_image provided_fdt = {0}; 619 | +static struct memory_ranges sysmem_ranges = {0}; 620 | + 621 | +/****************\ 622 | +* COMMON HELPERS * 623 | +\****************/ 624 | + 625 | +int load_extra_segments(struct kexec_info *info, uint64_t kernel_base, 626 | + uint64_t kernel_size, uint64_t max_addr) 627 | +{ 628 | + struct fdt_image *fdt = arch_options.fdt; 629 | + char *initrd_buf = NULL; 630 | + off_t initrd_size = 0; 631 | + uint64_t initrd_base = 0; 632 | + uint64_t start = 0; 633 | + uint64_t end = 0; 634 | + uint64_t min_usable = kernel_base + kernel_size; 635 | + uint64_t max_usable = max_addr; 636 | + int ret = 0; 637 | + 638 | + /* Prepare the device tree */ 639 | + if (info->kexec_flags & KEXEC_ON_CRASH) { 640 | + ret = load_elfcorehdr(info); 641 | + if (ret) { 642 | + fprintf(stderr, "Couldn't create elfcorehdr\n"); 643 | + return ret; 644 | + } 645 | + 646 | + ret = dtb_add_range_property(&fdt->buf, &fdt->size, 647 | + elfcorehdr_mem.start, elfcorehdr_mem.end, 648 | + "chosen", "linux,elfcorehdr"); 649 | + if (ret) { 650 | + fprintf(stderr, "Couldn't add elfcorehdr to fdt\n"); 651 | + return ret; 652 | + } 653 | + 654 | + ret = get_crash_kernel_load_range(&start, &end); 655 | + if (ret) { 656 | + fprintf(stderr, "Couldn't get crashkenel region\n"); 657 | + return ret; 658 | + } 659 | + 660 | + ret = dtb_add_range_property(&fdt->buf, &fdt->size, start, end, 661 | + "memory", "linux,usable-memory"); 662 | + if (ret) { 663 | + fprintf(stderr, "Couldn't add usable-memory to fdt\n"); 664 | + return ret; 665 | + } 666 | + 667 | + max_usable = end; 668 | + } else { 669 | + /* 670 | + * Make sure we remove elfcorehdr and usable-memory 671 | + * when switching from crash kernel to a normal one. 672 | + */ 673 | + dtb_delete_property(fdt->buf, "chosen", "linux,elfcorehdr"); 674 | + dtb_delete_property(fdt->buf, "memory", "linux,usable-memory"); 675 | + } 676 | + 677 | + /* Do we need to include an initrd image ? */ 678 | + if (!arch_options.initrd_path && !arch_options.initrd_end) 679 | + dtb_clear_initrd(&fdt->buf, &fdt->size); 680 | + else if (arch_options.initrd_path) { 681 | + if (arch_options.initrd_end) 682 | + fprintf(stderr, "Warning: An initrd image was provided" 683 | + ", will ignore reuseinitrd\n"); 684 | + 685 | + initrd_buf = slurp_file(arch_options.initrd_path, 686 | + &initrd_size); 687 | + if (!initrd_buf) { 688 | + fprintf(stderr, "Couldn't read provided initrd\n"); 689 | + return -EINVAL; 690 | + } 691 | + 692 | + initrd_base = add_buffer_phys_virt(info, initrd_buf, 693 | + initrd_size, 694 | + initrd_size, 0, 695 | + min_usable, 696 | + max_usable, -1, 0); 697 | + 698 | + dtb_set_initrd(&fdt->buf, &fdt->size, initrd_base, 699 | + initrd_base + initrd_size); 700 | + 701 | + dbgprintf("Base addr for initrd image: 0x%lX\n", initrd_base); 702 | + max_usable = initrd_base; 703 | + } 704 | + 705 | + /* Add device tree */ 706 | + add_buffer_phys_virt(info, fdt->buf, fdt->size, fdt->size, 0, 707 | + min_usable, max_usable, -1, 0); 708 | + 709 | + return 0; 710 | +} 711 | + 712 | + 713 | +/**************\ 714 | +* ENTRY POINTS * 715 | +\**************/ 716 | + 717 | +void arch_usage(void) 718 | +{ 719 | + printf(riscv_opts_usage); 720 | +} 721 | + 722 | +int arch_process_options(int argc, char **argv) 723 | +{ 724 | + static const struct option options[] = { 725 | + KEXEC_ARCH_OPTIONS 726 | + { 0 }, 727 | + }; 728 | + static const char short_options[] = KEXEC_ARCH_OPT_STR; 729 | + struct stat st = {0}; 730 | + char *append = NULL; 731 | + char *cmdline = NULL; 732 | + void *tmp = NULL; 733 | + off_t tmp_size = 0; 734 | + int opt = 0; 735 | + int ret = 0; 736 | + 737 | + while ((opt = getopt_long(argc, argv, short_options, 738 | + options, 0)) != -1) { 739 | + switch (opt) { 740 | + case OPT_APPEND: 741 | + append = optarg; 742 | + break; 743 | + case OPT_CMDLINE: 744 | + if (cmdline) 745 | + fprintf(stderr, 746 | + "Warning: Kernel's cmdline " 747 | + "set twice !\n"); 748 | + cmdline = optarg; 749 | + break; 750 | + case OPT_REUSE_CMDLINE: 751 | + if (cmdline) 752 | + fprintf(stderr, 753 | + "Warning: Kernel's cmdline " 754 | + "set twice !\n"); 755 | + cmdline = get_command_line(); 756 | + break; 757 | + case OPT_DTB: 758 | + ret = stat(optarg, &st); 759 | + if (ret) { 760 | + fprintf(stderr, 761 | + "Could not find the provided dtb !\n"); 762 | + return -EINVAL; 763 | + } 764 | + arch_options.fdt_path = optarg; 765 | + break; 766 | + case OPT_INITRD: 767 | + ret = stat(optarg, &st); 768 | + if (ret) { 769 | + fprintf(stderr, 770 | + "Could not find the provided " 771 | + "initrd image !\n"); 772 | + return -EINVAL; 773 | + } 774 | + arch_options.initrd_path = optarg; 775 | + break; 776 | + default: 777 | + break; 778 | + } 779 | + } 780 | + 781 | + /* Handle Kernel's command line */ 782 | + if (append && !cmdline) 783 | + fprintf(stderr, "Warning: No cmdline provided, " 784 | + "using append string as cmdline\n"); 785 | + if (!append && !cmdline) 786 | + fprintf(stderr, "Warning: No cmdline or append string " 787 | + "provided\n"); 788 | + 789 | + if (append || cmdline) 790 | + /* 791 | + * Note that this also handles the case where "cmdline" 792 | + * or "append" is NULL. 793 | + */ 794 | + arch_options.cmdline = concat_cmdline(cmdline, append); 795 | + 796 | + /* Handle FDT image */ 797 | + if (!arch_options.fdt_path) { 798 | + ret = stat("/sys/firmware/fdt", &st); 799 | + if (ret) { 800 | + fprintf(stderr, "No dtb provided and " 801 | + "/sys/firmware/fdt is not present\n"); 802 | + return -EINVAL; 803 | + } 804 | + fprintf(stderr, "Warning: No dtb provided, " 805 | + "using /sys/firmware/fdt\n"); 806 | + arch_options.fdt_path = "/sys/firmware/fdt"; 807 | + } 808 | + 809 | + tmp = slurp_file(arch_options.fdt_path, &tmp_size); 810 | + if (!tmp) { 811 | + fprintf(stderr, "Couldn't read provided fdt\n"); 812 | + return -EINVAL; 813 | + } 814 | + 815 | + ret = fdt_check_header(tmp); 816 | + if (ret) { 817 | + fprintf(stderr, "Got an ivalid fdt image !\n"); 818 | + free(tmp); 819 | + return -EINVAL; 820 | + } 821 | + provided_fdt.buf = tmp; 822 | + provided_fdt.size = tmp_size; 823 | + 824 | + if (arch_options.cmdline) { 825 | + ret = dtb_set_bootargs(&provided_fdt.buf, &provided_fdt.size, 826 | + arch_options.cmdline); 827 | + if (ret < 0) { 828 | + fprintf(stderr, "Could not set bootargs on " 829 | + "the fdt image\n"); 830 | + return ret; 831 | + } 832 | + } 833 | + 834 | + arch_options.fdt = &provided_fdt; 835 | + 836 | + return 0; 837 | +} 838 | + 839 | +/* 840 | + * This one is called after arch_process_options so we already 841 | + * have an fdt image in place. 842 | + */ 843 | +void arch_reuse_initrd(void) 844 | +{ 845 | + const uint32_t *prop32 = NULL; 846 | + uint32_t addr_cells = 0; 847 | + const void *prop = 0; 848 | + int prop_size = 0; 849 | + uint64_t initrd_start = 0; 850 | + uint64_t initrd_end = 0; 851 | + int chosen_offset = 0; 852 | + struct fdt_image *fdt = &provided_fdt; 853 | + 854 | + chosen_offset = fdt_subnode_offset(fdt->buf, 0, "chosen"); 855 | + if (chosen_offset < 0) { 856 | + fprintf(stderr, "No /chosen node found on fdt image " 857 | + "unable to reuse initrd\n"); 858 | + return; 859 | + } 860 | + 861 | + prop32 = fdt_getprop(fdt->buf, 0, "#address-cells", NULL); 862 | + if (!prop32) { 863 | + fprintf(stderr, "No #address-cells property on root node\n"); 864 | + return; 865 | + } 866 | + addr_cells = be32_to_cpu(*prop32); 867 | + 868 | + prop = fdt_getprop(fdt->buf, chosen_offset, 869 | + "linux,initrd-start", &prop_size); 870 | + if (!prop) { 871 | + fprintf(stderr, "Could not get linux,initrd-start\n"); 872 | + return; 873 | + } 874 | + dtb_extract_int_property(&initrd_start, prop, addr_cells); 875 | + 876 | + prop = fdt_getprop(fdt->buf, chosen_offset, 877 | + "linux,initrd-end", &prop_size); 878 | + if (!prop) { 879 | + fprintf(stderr, "Could not get linux,initrd-end\n"); 880 | + return; 881 | + } 882 | + dtb_extract_int_property(&initrd_end, prop, addr_cells); 883 | + 884 | + arch_options.initrd_start = initrd_start; 885 | + arch_options.initrd_end = initrd_end; 886 | + dbgprintf("initrd_start: 0x%lX, initrd_end: 0x%lX\n", 887 | + initrd_start, initrd_end); 888 | + 889 | +} 890 | + 891 | +int get_memory_ranges(struct memory_range **range, int *num_ranges, 892 | + unsigned long kexec_flags) 893 | +{ 894 | + const struct fdt_image *fdt = &provided_fdt; 895 | + struct memory_ranges *extra_ranges = NULL; 896 | + int i = 0; 897 | + int ret = 0; 898 | + 899 | + if (arch_options.initrd_start && arch_options.initrd_end) { 900 | + int initrd_size = arch_options.initrd_end - arch_options.initrd_start; 901 | + dbgprintf("Marking current intird image as reserved\n"); 902 | + ret = mem_regions_alloc_and_add(extra_ranges, 903 | + arch_options.initrd_start, 904 | + initrd_size, 905 | + RANGE_RESERVED); 906 | + if (ret) 907 | + return ret; 908 | + } 909 | + 910 | + ret = dtb_get_memory_ranges(fdt->buf, &sysmem_ranges, extra_ranges); 911 | + if (ret) { 912 | + fprintf(stderr, "Could not get memory ranges from device tree (%i) !\n", ret); 913 | + return ret; 914 | + } 915 | + 916 | + *range = sysmem_ranges.ranges; 917 | + *num_ranges = sysmem_ranges.size; 918 | + 919 | + dbgprintf("Memory regions:\n"); 920 | + for (i = 0; i < sysmem_ranges.size; i++) { 921 | + dbgprintf("\t0x%llx - 0x%llx : %s (%i)\n", 922 | + sysmem_ranges.ranges[i].start, 923 | + sysmem_ranges.ranges[i].end, 924 | + sysmem_ranges.ranges[i].type == RANGE_RESERVED ? 925 | + "RANGE_RESERVED" : "RANGE_RAM", 926 | + sysmem_ranges.ranges[i].type); 927 | + } 928 | + 929 | + return 0; 930 | +} 931 | + 932 | +/*******\ 933 | +* STUBS * 934 | +\*******/ 935 | + 936 | +int arch_compat_trampoline(struct kexec_info *UNUSED(info)) 937 | +{ 938 | + return 0; 939 | +} 940 | + 941 | +void arch_update_purgatory(struct kexec_info *UNUSED(info)) 942 | +{ 943 | +} 944 | diff --git a/kexec/arch/riscv/kexec-riscv.h b/kexec/arch/riscv/kexec-riscv.h 945 | new file mode 100644 946 | index 0000000..c4323a6 947 | --- /dev/null 948 | +++ b/kexec/arch/riscv/kexec-riscv.h 949 | @@ -0,0 +1,32 @@ 950 | +/* SPDX-License-Identifier: GPL-2.0 */ 951 | +/* 952 | + * Copyright (C) 2019 FORTH-ICS/CARV 953 | + * Nick Kossifidis 954 | + */ 955 | + 956 | +struct fdt_image { 957 | + char *buf; 958 | + off_t size; 959 | +}; 960 | + 961 | +struct riscv_opts { 962 | + char *cmdline; 963 | + char *fdt_path; 964 | + char *initrd_path; 965 | + uint64_t initrd_start; 966 | + uint64_t initrd_end; 967 | + struct fdt_image *fdt; 968 | +}; 969 | + 970 | +/* crashdump-riscv.c */ 971 | +extern struct memory_range elfcorehdr_mem; 972 | +int load_elfcorehdr(struct kexec_info *info); 973 | + 974 | +/* kexec-riscv.c */ 975 | +int load_extra_segments(struct kexec_info *info, uint64_t kernel_base, 976 | + uint64_t kernel_size, uint64_t max_addr); 977 | + 978 | +int elf_riscv_probe(const char *buf, off_t len); 979 | +void elf_riscv_usage(void); 980 | +int elf_riscv_load(int argc, char **argv, const char *buf, off_t len, 981 | + struct kexec_info *info); 982 | diff --git a/kexec/dt-ops.c b/kexec/dt-ops.c 983 | index 0a96b75..3e285ab 100644 984 | --- a/kexec/dt-ops.c 985 | +++ b/kexec/dt-ops.c 986 | @@ -4,9 +4,11 @@ 987 | #include 988 | #include 989 | #include 990 | +#include 991 | 992 | #include "kexec.h" 993 | #include "dt-ops.h" 994 | +#include "mem_regions.h" 995 | 996 | static const char n_chosen[] = "chosen"; 997 | 998 | @@ -95,7 +97,7 @@ int dtb_set_property(char **dtb, off_t *dtb_size, const char *node, 999 | 1000 | strcpy(new_node, "/"); 1001 | strcat(new_node, node); 1002 | - 1003 | + 1004 | nodeoffset = fdt_path_offset(new_dtb, new_node); 1005 | 1006 | if (nodeoffset == -FDT_ERR_NOTFOUND) { 1007 | @@ -174,3 +176,441 @@ int dtb_delete_property(char *dtb, const char *node, const char *prop) 1008 | free(new_node); 1009 | return result; 1010 | } 1011 | + 1012 | +static int dtb_get_num_cells(char *dtb, int nodeoffset, uint32_t *addr_cells, 1013 | + uint32_t *size_cells, bool recursive) 1014 | +{ 1015 | + const uint32_t *prop32 = NULL; 1016 | + int curr_offset = nodeoffset; 1017 | + int prop_len = 0; 1018 | + *addr_cells = 0; 1019 | + *size_cells = 0; 1020 | + 1021 | + do { 1022 | + prop32 = fdt_getprop(dtb, curr_offset, "#address-cells", &prop_len); 1023 | + curr_offset = fdt_parent_offset(dtb, curr_offset); 1024 | + } while (!prop32 && prop_len == -FDT_ERR_NOTFOUND && recursive); 1025 | + 1026 | + if (!prop32) { 1027 | + dbgprintf("Could not get #address-cells property for %s (%s)\n", 1028 | + fdt_get_name(dtb, nodeoffset, NULL), fdt_strerror(nodeoffset)); 1029 | + return -EINVAL; 1030 | + } 1031 | + *addr_cells = fdt32_to_cpu(*prop32); 1032 | + 1033 | + curr_offset = nodeoffset; 1034 | + do { 1035 | + prop32 = fdt_getprop(dtb, curr_offset, "#size-cells", &prop_len); 1036 | + curr_offset = fdt_parent_offset(dtb, curr_offset); 1037 | + } while (!prop32 && prop_len == -FDT_ERR_NOTFOUND && recursive); 1038 | + 1039 | + if (!prop32) { 1040 | + dbgprintf("Could not get #size-cells property for %s (%s)\n", 1041 | + fdt_get_name(dtb, nodeoffset, NULL), fdt_strerror(nodeoffset)); 1042 | + return -EINVAL; 1043 | + } 1044 | + *size_cells = fdt32_to_cpu(*prop32); 1045 | + 1046 | + dbgprintf("%s: #address-cells:%d #size-cells:%d\n", 1047 | + fdt_get_name(dtb, nodeoffset, NULL), *addr_cells, *size_cells); 1048 | + 1049 | + return 0; 1050 | +} 1051 | + 1052 | +void dtb_extract_int_property(uint64_t *val, const void *buf, uint32_t cells) 1053 | +{ 1054 | + const uint32_t *prop32 = NULL; 1055 | + const uint64_t *prop64 = NULL; 1056 | + 1057 | + if (cells == 1) { 1058 | + prop32 = (const uint32_t *) buf; 1059 | + *val = (uint64_t) be32_to_cpu(*prop32); 1060 | + } else { 1061 | + /* Skip any leading cells */ 1062 | + prop64 = (const uint64_t *) (uint32_t *)buf + cells - 2; 1063 | + *val = (uint64_t) be64_to_cpu(*prop64); 1064 | + } 1065 | +} 1066 | + 1067 | +void dtb_fill_int_property(void *buf, uint64_t val, uint32_t cells) 1068 | +{ 1069 | + uint32_t prop32 = 0; 1070 | + uint64_t prop64 = 0; 1071 | + 1072 | + if (cells == 1) { 1073 | + prop32 = cpu_to_fdt32((uint32_t) val); 1074 | + memcpy(buf, &prop32, sizeof(uint32_t)); 1075 | + } else { 1076 | + prop64 = cpu_to_fdt64(val); 1077 | + /* Skip any leading cells */ 1078 | + memcpy((uint64_t *)(uint32_t *)buf + cells - 2, 1079 | + &prop64, sizeof(uint64_t)); 1080 | + } 1081 | +} 1082 | + 1083 | +int dtb_add_range_property(char **dtb, off_t *dtb_size, uint64_t start, uint64_t end, 1084 | + const char *parent, const char *name) 1085 | +{ 1086 | + uint32_t addr_cells = 0; 1087 | + uint32_t size_cells = 0; 1088 | + char *nodepath = NULL; 1089 | + void *prop = NULL; 1090 | + int nodeoffset = 0; 1091 | + int prop_size = 0; 1092 | + int ret = 0; 1093 | + 1094 | + nodepath = malloc(strlen("/") + strlen(parent) + 1); 1095 | + if (!nodepath) { 1096 | + dbgprintf("%s: malloc failed\n", __func__); 1097 | + return -ENOMEM; 1098 | + } 1099 | + 1100 | + strcpy(nodepath, "/"); 1101 | + strcat(nodepath, parent); 1102 | + 1103 | + nodeoffset = fdt_path_offset(*dtb, nodepath); 1104 | + if (nodeoffset < 0) { 1105 | + dbgprintf("%s: fdt_path_offset(%s) failed: %s\n", __func__, 1106 | + nodepath, fdt_strerror(nodeoffset)); 1107 | + free(nodepath); 1108 | + return nodeoffset; 1109 | + } 1110 | + free(nodepath); 1111 | + 1112 | + ret = dtb_get_num_cells(*dtb, nodeoffset, &addr_cells, &size_cells, true); 1113 | + if (ret < 0) 1114 | + return ret; 1115 | + 1116 | + /* Can the range fit with the given address/size cells ? */ 1117 | + if ((addr_cells == 1) && (start >= (1ULL << 32))) 1118 | + return -EINVAL; 1119 | + 1120 | + if ((size_cells == 1) && ((end - start + 1) >= (1ULL << 32))) 1121 | + return -EINVAL; 1122 | + 1123 | + prop_size = sizeof(uint32_t) * (addr_cells + size_cells); 1124 | + prop = malloc(prop_size); 1125 | + 1126 | + dtb_fill_int_property(prop, start, addr_cells); 1127 | + dtb_fill_int_property((void *)((uint32_t *)prop + addr_cells), 1128 | + end - start + 1, size_cells); 1129 | + 1130 | + /* Add by node path name */ 1131 | + return dtb_set_property(dtb, dtb_size, parent, name, prop, prop_size); 1132 | +} 1133 | + 1134 | +/************************\ 1135 | +* MEMORY RANGES HANDLING * 1136 | +\************************/ 1137 | + 1138 | +static int dtb_add_memory_range(struct memory_ranges *mem_ranges, uint64_t start, 1139 | + uint64_t end, unsigned type) 1140 | +{ 1141 | + struct memory_range this_region = {0}; 1142 | + struct memory_range *ranges = mem_ranges->ranges; 1143 | + int i = 0; 1144 | + int ret = 0; 1145 | + 1146 | + if (start == end) { 1147 | + dbgprintf("Ignoring empty region\n"); 1148 | + return -EINVAL; 1149 | + } 1150 | + 1151 | + /* Check if we are adding an existing region */ 1152 | + for (i = 0; i < mem_ranges->size; i++) { 1153 | + if (start == ranges[i].start && end == ranges[i].end) { 1154 | + dbgprintf("Duplicate: 0x%lx - 0x%lx\n", start, end); 1155 | + 1156 | + if (type == ranges[i].type) 1157 | + return 0; 1158 | + else if (type == RANGE_RESERVED) { 1159 | + ranges[i].type = RANGE_RESERVED; 1160 | + return 0; 1161 | + } 1162 | + 1163 | + dbgprintf("Conflicting types for region: 0x%lx - 0x%lx\n", 1164 | + start, end); 1165 | + return -EINVAL; 1166 | + } 1167 | + } 1168 | + 1169 | + /* 1170 | + * Reserved regions may be part of an existing /memory 1171 | + * region and shouldn't overlap according to spec, so 1172 | + * since we add /memory regions first, we can exclude 1173 | + * reserved regions here from the existing /memory regions 1174 | + * included in ranges[], so that we don't have the same 1175 | + * region twice. 1176 | + */ 1177 | + if (type == RANGE_RESERVED) { 1178 | + this_region.start = start; 1179 | + this_region.end = end - 1; 1180 | + this_region.type = type; 1181 | + ret = mem_regions_exclude(mem_ranges, &this_region); 1182 | + if (ret) 1183 | + return ret; 1184 | + } 1185 | + 1186 | + ret = mem_regions_alloc_and_add(mem_ranges, start, 1187 | + end - start, type); 1188 | + 1189 | + return ret; 1190 | +} 1191 | + 1192 | +static int dtb_add_memory_region(char *dtb, int nodeoffset, 1193 | + struct memory_ranges *mem_ranges, int type) 1194 | +{ 1195 | + uint32_t root_addr_cells = 0; 1196 | + uint32_t root_size_cells = 0; 1197 | + uint64_t addr = 0; 1198 | + uint64_t size = 0; 1199 | + const char *reg = NULL; 1200 | + int prop_size = 0; 1201 | + int offset = 0; 1202 | + int entry_size = 0; 1203 | + int num_entries = 0; 1204 | + int ret = 0; 1205 | + 1206 | + /* 1207 | + * Get address-cells and size-cells properties (according to 1208 | + * binding spec these are the same as in the root node) 1209 | + */ 1210 | + ret = dtb_get_num_cells(dtb, 0, &root_addr_cells, &root_size_cells, false); 1211 | + if (ret < 0) { 1212 | + dbgprintf("No address/size cells on root node !\n"); 1213 | + return ret; 1214 | + } 1215 | + 1216 | + /* 1217 | + * Parse the reg array, acording to device tree spec it includes 1218 | + * an arbitary number of
pairs 1219 | + */ 1220 | + entry_size = (root_addr_cells + root_size_cells) * sizeof(uint32_t); 1221 | + reg = fdt_getprop(dtb, nodeoffset, "reg", &prop_size); 1222 | + if (!reg) { 1223 | + dbgprintf("Warning: Malformed memory region with no reg property (%s) !\n", 1224 | + fdt_get_name(dtb, nodeoffset, NULL)); 1225 | + return -EINVAL; 1226 | + } 1227 | + 1228 | + num_entries = prop_size / entry_size; 1229 | + dbgprintf("Got region with %i entries: %s\n", num_entries, 1230 | + fdt_get_name(dtb, nodeoffset, NULL)); 1231 | + 1232 | + for (num_entries--; num_entries >= 0; num_entries--) { 1233 | + offset = num_entries * entry_size; 1234 | + 1235 | + dtb_extract_int_property(&addr, reg + offset, 1236 | + root_addr_cells); 1237 | + offset += root_addr_cells * sizeof(uint32_t); 1238 | + 1239 | + dtb_extract_int_property(&size, reg + offset, 1240 | + root_size_cells); 1241 | + 1242 | + ret = dtb_add_memory_range(mem_ranges, addr, 1243 | + addr + size, type); 1244 | + if (ret) 1245 | + return ret; 1246 | + } 1247 | + 1248 | + return 0; 1249 | +} 1250 | + 1251 | +static int dtb_parse_memory_reservations_table(char *dtb, struct memory_ranges *mem_ranges) 1252 | +{ 1253 | + int total_memrsrv = 0; 1254 | + uint64_t addr = 0; 1255 | + uint64_t size = 0; 1256 | + int ret = 0; 1257 | + int i = 0; 1258 | + 1259 | + total_memrsrv = fdt_num_mem_rsv(dtb); 1260 | + for (i = 0; i < total_memrsrv; i++) { 1261 | + ret = fdt_get_mem_rsv(dtb, i, &addr, &size); 1262 | + if (ret) 1263 | + continue; 1264 | + ret = dtb_add_memory_range(mem_ranges, addr, addr + size - 1, 1265 | + RANGE_RESERVED); 1266 | + if (ret) 1267 | + return ret; 1268 | + } 1269 | + 1270 | + return 0; 1271 | +} 1272 | + 1273 | +static int dtb_get_reserved_memory_node(char *dtb) 1274 | +{ 1275 | + uint32_t root_addr_cells = 0; 1276 | + uint32_t root_size_cells = 0; 1277 | + uint32_t addr_cells = 0; 1278 | + uint32_t size_cells = 0; 1279 | + int prop_size = 0; 1280 | + int nodeoffset = 0; 1281 | + int ret = 0; 1282 | + 1283 | + /* Get address / size cells from root node */ 1284 | + ret = dtb_get_num_cells(dtb, 0, &root_addr_cells, &root_size_cells, false); 1285 | + if (ret < 0) { 1286 | + dbgprintf("No address/size cells on root node !\n"); 1287 | + return ret; 1288 | + } 1289 | + 1290 | + /* This calls fdt_next_node internaly */ 1291 | + nodeoffset = fdt_subnode_offset(dtb, 0, "reserved-memory"); 1292 | + if (nodeoffset == -FDT_ERR_NOTFOUND) { 1293 | + return nodeoffset; 1294 | + } else if (nodeoffset < 0) { 1295 | + dbgprintf("Error while looking for reserved-memory: %s\n", 1296 | + fdt_strerror(nodeoffset)); 1297 | + return nodeoffset; 1298 | + } 1299 | + 1300 | + /* Look for the ranges property */ 1301 | + fdt_getprop(dtb, nodeoffset, "ranges", &prop_size); 1302 | + if (prop_size < 0) { 1303 | + fprintf(stderr, "Malformed reserved-memory node (no ranges property) !\n"); 1304 | + return -EINVAL; 1305 | + } 1306 | + 1307 | + /* Verify address-cells / size-cells */ 1308 | + ret = dtb_get_num_cells(dtb, nodeoffset, &addr_cells, &size_cells, false); 1309 | + if (ret < 0) { 1310 | + dbgprintf("No address/size cells property on reserved-memory node\n"); 1311 | + return ret; 1312 | + } 1313 | + 1314 | + if (addr_cells != root_addr_cells) { 1315 | + fprintf(stderr, "Invalid #address-cells property on reserved-memory node\n"); 1316 | + return -EINVAL; 1317 | + } 1318 | + 1319 | + if (size_cells != root_size_cells) { 1320 | + fprintf(stderr, "Invalid #size-cells property on reserved-memory node\n"); 1321 | + return -EINVAL; 1322 | + 1323 | + } 1324 | + 1325 | + return nodeoffset; 1326 | +} 1327 | + 1328 | +static int dtb_parse_reserved_memory_node(char *dtb, struct memory_ranges *mem_ranges) 1329 | +{ 1330 | + int nodeoffset = 0; 1331 | + int node_depth = 0; 1332 | + int parent_depth = 0; 1333 | + int ret = 0; 1334 | + 1335 | + nodeoffset = dtb_get_reserved_memory_node(dtb); 1336 | + if (nodeoffset == -FDT_ERR_NOTFOUND) 1337 | + return 0; 1338 | + else if (nodeoffset < 0) 1339 | + return nodeoffset; 1340 | + 1341 | + /* Got the parent node, check for sub-nodes */ 1342 | + 1343 | + /* fdt_next_node() increases or decreases depth */ 1344 | + node_depth = parent_depth; 1345 | + nodeoffset = fdt_next_node(dtb, nodeoffset, &node_depth); 1346 | + if (ret < 0) { 1347 | + dbgprintf("Unable to get next node: %s\n", 1348 | + fdt_strerror(ret)); 1349 | + return -EINVAL; 1350 | + } 1351 | + 1352 | + while (node_depth != parent_depth) { 1353 | + 1354 | + ret = dtb_add_memory_region(dtb, nodeoffset, 1355 | + mem_ranges, RANGE_RESERVED); 1356 | + if (ret) 1357 | + return ret; 1358 | + 1359 | + nodeoffset = fdt_next_node(dtb, nodeoffset, &node_depth); 1360 | + if (ret < 0) { 1361 | + dbgprintf("Unable to get next node: %s\n", 1362 | + fdt_strerror(ret)); 1363 | + return -EINVAL; 1364 | + } 1365 | + } 1366 | + 1367 | + return 0; 1368 | +} 1369 | + 1370 | +static int dtb_parse_memory_nodes(char *dtb, struct memory_ranges *mem_ranges) 1371 | +{ 1372 | + int nodeoffset = 0; 1373 | + int num_regions = 0; 1374 | + const char* dev_type = 0; 1375 | + int prop_size = 0; 1376 | + int ret = 0; 1377 | + 1378 | + for (; ; num_regions++) { 1379 | + nodeoffset = fdt_subnode_offset(dtb, nodeoffset, 1380 | + "memory"); 1381 | + if (nodeoffset < 0) 1382 | + break; 1383 | + 1384 | + dbgprintf("Got memory node at depth: %i\n", fdt_node_depth(dtb, nodeoffset)); 1385 | + 1386 | + /* Look for the device_type property */ 1387 | + dev_type = fdt_getprop(dtb, nodeoffset, "device_type", &prop_size); 1388 | + if (prop_size < 0) { 1389 | + fprintf(stderr, "Malformed /memory node (no device-type property) !\n"); 1390 | + return -EINVAL; 1391 | + } 1392 | + 1393 | + if (strncmp(dev_type, "memory", prop_size)) { 1394 | + dbgprintf("Got unknown dev_type property: %s\n", dev_type); 1395 | + continue; 1396 | + } 1397 | + 1398 | + ret = dtb_add_memory_region(dtb, nodeoffset, mem_ranges, RANGE_RAM); 1399 | + if (ret) 1400 | + return ret; 1401 | + } 1402 | + 1403 | + if (!num_regions) { 1404 | + dbgprintf("Malformed dtb, no /memory nodes present !\n"); 1405 | + return -EINVAL; 1406 | + } 1407 | + 1408 | + dbgprintf("Got %i /memory nodes\n", num_regions); 1409 | + 1410 | + return 0; 1411 | +} 1412 | + 1413 | +int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, struct memory_ranges *extra_ranges) 1414 | +{ 1415 | + int i = 0; 1416 | + int ret = 0; 1417 | + 1418 | + /* Fill mem_ranges[] by parsing the device tree */ 1419 | + ret = dtb_parse_memory_nodes(dtb, mem_ranges); 1420 | + if (ret) 1421 | + return ret; 1422 | + 1423 | + ret = dtb_parse_memory_reservations_table(dtb, mem_ranges); 1424 | + if (ret) 1425 | + return ret; 1426 | + 1427 | + ret = dtb_parse_reserved_memory_node(dtb, mem_ranges); 1428 | + if (ret) 1429 | + return ret; 1430 | + 1431 | + /* Append any extra ranges provided by the caller (e.g. initrd) */ 1432 | + for (i = 0; extra_ranges != NULL && i < extra_ranges->size; i++) { 1433 | + dbgprintf("Adding extra range: 0x%llx - 0x%llx (%s)\n", 1434 | + extra_ranges->ranges[i].start, 1435 | + extra_ranges->ranges[i].end, 1436 | + extra_ranges->ranges[i].type == RANGE_RESERVED ? 1437 | + "RANGE_RESERVED" : "RANGE_RAM"); 1438 | + 1439 | + ret = dtb_add_memory_range(mem_ranges, extra_ranges->ranges[i].start, 1440 | + extra_ranges->ranges[i].end, extra_ranges->ranges[i].type); 1441 | + if (ret) 1442 | + return ret; 1443 | + } 1444 | + 1445 | + mem_regions_sort(mem_ranges); 1446 | + 1447 | + return 0; 1448 | +} 1449 | diff --git a/kexec/dt-ops.h b/kexec/dt-ops.h 1450 | index 03659ce..3014205 100644 1451 | --- a/kexec/dt-ops.h 1452 | +++ b/kexec/dt-ops.h 1453 | @@ -11,4 +11,11 @@ int dtb_set_property(char **dtb, off_t *dtb_size, const char *node, 1454 | 1455 | int dtb_delete_property(char *dtb, const char *node, const char *prop); 1456 | 1457 | +void dtb_extract_int_property(uint64_t *val, const void *buf, uint32_t cells); 1458 | +void dtb_fill_int_property(void *buf, uint64_t val, uint32_t cells); 1459 | +int dtb_add_range_property(char **dtb, off_t *dtb_size, uint64_t start, uint64_t end, 1460 | + const char *node, const char* parent); 1461 | +int dtb_get_memory_ranges(char *dtb, struct memory_ranges *mem_ranges, 1462 | + struct memory_ranges *extra_ranges); 1463 | + 1464 | #endif 1465 | diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h 1466 | index bea29d4..2e99e2b 100644 1467 | --- a/kexec/kexec-syscall.h 1468 | +++ b/kexec/kexec-syscall.h 1469 | @@ -134,6 +134,7 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd, 1470 | #define KEXEC_ARCH_MIPS_LE (10 << 16) 1471 | #define KEXEC_ARCH_MIPS ( 8 << 16) 1472 | #define KEXEC_ARCH_CRIS (76 << 16) 1473 | +#define KEXEC_ARCH_RISCV (243 << 16) 1474 | 1475 | #define KEXEC_MAX_SEGMENTS 16 1476 | 1477 | @@ -177,5 +178,8 @@ static inline long kexec_file_load(int kernel_fd, int initrd_fd, 1478 | #if defined(__arm64__) 1479 | #define KEXEC_ARCH_NATIVE KEXEC_ARCH_ARM64 1480 | #endif 1481 | +#if defined(__riscv__) || defined(__riscv) 1482 | +#define KEXEC_ARCH_NATIVE KEXEC_ARCH_RISCV 1483 | +#endif 1484 | 1485 | #endif /* KEXEC_SYSCALL_H */ 1486 | diff --git a/purgatory/Makefile b/purgatory/Makefile 1487 | index 15adb12..11694e5 100644 1488 | --- a/purgatory/Makefile 1489 | +++ b/purgatory/Makefile 1490 | @@ -25,6 +25,7 @@ include $(srcdir)/purgatory/arch/ia64/Makefile 1491 | include $(srcdir)/purgatory/arch/mips/Makefile 1492 | include $(srcdir)/purgatory/arch/ppc/Makefile 1493 | include $(srcdir)/purgatory/arch/ppc64/Makefile 1494 | +include $(srcdir)/purgatory/arch/riscv/Makefile 1495 | include $(srcdir)/purgatory/arch/s390/Makefile 1496 | include $(srcdir)/purgatory/arch/sh/Makefile 1497 | include $(srcdir)/purgatory/arch/x86_64/Makefile 1498 | diff --git a/purgatory/arch/riscv/Makefile b/purgatory/arch/riscv/Makefile 1499 | new file mode 100644 1500 | index 0000000..8bded71 1501 | --- /dev/null 1502 | +++ b/purgatory/arch/riscv/Makefile 1503 | @@ -0,0 +1,7 @@ 1504 | +# 1505 | +# Purgatory riscv 1506 | +# 1507 | + 1508 | +riscv_PURGATORY_SRCS = 1509 | + 1510 | +dist += purgatory/arch/sh/Makefile $(riscv_PURGATORY_SRCS) 1511 | -- 1512 | 2.35.1 1513 | 1514 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/kexec-tools-2.0.4-disable-kexec-test.patch: -------------------------------------------------------------------------------- 1 | diff --git kexec-tools-2.0.3/kexec_test/Makefile kexec-tools-2.0.3/kexec_test/Makefile 2 | index fec6210..2ed4d51 100644 3 | --- kexec-tools-2.0.3/kexec_test/Makefile 4 | +++ kexec-tools-2.0.3/kexec_test/Makefile 5 | @@ -8,12 +8,6 @@ dist += kexec_test/Makefile $(KEXEC_TEST_SRCS) \ 6 | kexec_test/x86-setup-legacy-pic.S 7 | 8 | BUILD_KEXEC_TEST = no 9 | -ifeq ($(ARCH),i386) 10 | -BUILD_KEXEC_TEST = yes 11 | -endif 12 | -ifeq ($(ARCH),x86_64) 13 | -BUILD_KEXEC_TEST = yes 14 | -endif 15 | 16 | ifeq ($(BUILD_KEXEC_TEST),yes) 17 | 18 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/kexec-tools-2.0.4-out-of-source.patch: -------------------------------------------------------------------------------- 1 | Makefile.in | 3 ++- 2 | 1 file changed, 2 insertions(+), 1 deletion(-) 3 | 4 | diff --git a/Makefile.in b/Makefile.in 5 | index c1859d1..1aa8559 100644 6 | --- a/Makefile.in 7 | +++ b/Makefile.in 8 | @@ -44,7 +44,7 @@ TARGET_CFLAGS = @TARGET_CFLAGS@ 9 | 10 | # Base compiler flags. These are extended by the subcomponent-Makefiles 11 | # where necessary. 12 | -CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -I$(srcdir)/util_lib/include \ 13 | +CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/include -I$(srcdir)/include -I$(srcdir)/util_lib/include \ 14 | -Iinclude/ $($(ARCH)_CPPFLAGS) 15 | CFLAGS = @CFLAGS@ -fno-strict-aliasing -Wall -Wstrict-prototypes 16 | PURGATORY_EXTRA_CFLAGS = @PURGATORY_EXTRA_CFLAGS@ 17 | @@ -77,6 +77,7 @@ pkgincludedir = $(includedir)/$(PACKAGE_NAME) 18 | DESTDIR = 19 | 20 | srcdir = @srcdir@ 21 | +top_builddir = @top_builddir@ 22 | VPATH = .:$(srcdir) 23 | 24 | # install paths 25 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/kexec.conf: -------------------------------------------------------------------------------- 1 | # Kernel image pathname, relative from /boot. 2 | KNAME="bzimage" 3 | 4 | # Additional arguments passed to kexec (8) 5 | # Following arguments are support: 6 | # 7 | # --reuse-cmdline 8 | # Use the current boot command line 9 | # 10 | # --command-line=string 11 | # Use a different command line 12 | # 13 | # --initrd=file 14 | # Specify an initrd to use 15 | # 16 | KEXEC_OPT_ARGS="--reuse-cmdline" 17 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/kexec.conf-2.0.4: -------------------------------------------------------------------------------- 1 | # Load kexec kernel image into memory during shutdown instead of bootup 2 | # (default: yes) 3 | #LOAD_DURING_SHUTDOWN="yes" 4 | 5 | # Additional arguments passed to kexec (8) 6 | #KEXEC_OPT_ARGS="" 7 | 8 | # Kernel image partition. Mounted automatically if not. 9 | # (default: /boot) 10 | #BOOTPART="/boot" 11 | 12 | # Root partition (should be autodetected) 13 | #ROOTPART="/dev/hda3" 14 | 15 | # Kernel image pathname, relative from BOOTPART. 16 | # If it's one of 17 | # {kernel-genkernel,bzImage,vmlinuz,kernel}-, 18 | # or bzImage, vmlinuz (without suffix), 19 | # then it's automaticaly detected. 20 | # Setting it to "-" will disable kexec. 21 | #KNAME="vmlinuz-3.9.0" 22 | 23 | # Initrd 24 | # Same automatic detection restriction as for KNAME apply. 25 | # initramfs-genkernel-, 26 | # initrd{,.img}-{,.img} 27 | # will be detected. 28 | #INITRD="/boot/fbsplash-emergence-1024x768" 29 | 30 | # Kernel parameters (should be autodetected) 31 | #KPARAM="splash=silent,theme:emergence" 32 | 33 | # Do not try to mount /boot 34 | # DONT_MOUNT_BOOT="yes" 35 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/files/kexec.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Gracefully restart the box 3 | Documentation=man:kexec(8) 4 | After=boot.mount 5 | Before=shutdown.target umount.target final.target 6 | ConditionPathExists=!/nokexec 7 | 8 | [Service] 9 | Type=oneshot 10 | RemainAfterExit=yes 11 | EnvironmentFile=/etc/kexec.conf 12 | ExecStart=/usr/sbin/kexec -l /boot/${KNAME} ${KEXEC_OPT_ARGS} 13 | ExecStop=/usr/sbin/kexec -l /boot/${KNAME} ${KEXEC_OPT_ARGS} 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/kexec-tools-2.0.24.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 1999-2022 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=8 5 | 6 | inherit autotools libtool linux-info systemd 7 | 8 | if [[ ${PV} == "9999" ]] ; then 9 | inherit git-r3 autotools 10 | EGIT_REPO_URI="https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git" 11 | else 12 | SRC_URI="https://www.kernel.org/pub/linux/utils/kernel/kexec/${P/_/-}.tar.xz" 13 | [[ "${PV}" == *_rc* ]] || \ 14 | KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86" 15 | fi 16 | 17 | DESCRIPTION="Load another kernel from the currently executing Linux kernel" 18 | HOMEPAGE="https://kernel.org/pub/linux/utils/kernel/kexec/" 19 | 20 | LICENSE="GPL-2" 21 | SLOT="0" 22 | IUSE="booke lzma xen zlib" 23 | 24 | REQUIRED_USE="lzma? ( zlib )" 25 | 26 | DEPEND=" 27 | lzma? ( app-arch/xz-utils ) 28 | zlib? ( sys-libs/zlib )" 29 | RDEPEND="${DEPEND}" 30 | 31 | S="${WORKDIR}/${P/_/-}" 32 | 33 | CONFIG_CHECK="~KEXEC" 34 | 35 | PATCHES=( 36 | "${FILESDIR}"/${PN}-2.0.4-disable-kexec-test.patch 37 | "${FILESDIR}"/${PN}-2.0.4-out-of-source.patch 38 | "${FILESDIR}"/${PN}-2.0.24-riscv.patch 39 | ) 40 | 41 | pkg_setup() { 42 | # GNU Make's $(COMPILE.S) passes ASFLAGS to $(CCAS), CCAS=$(CC) 43 | export ASFLAGS="${CCASFLAGS}" 44 | } 45 | 46 | src_prepare() { 47 | default 48 | 49 | # Append PURGATORY_EXTRA_CFLAGS flags set by configure, instead of overriding them completely. 50 | sed -e "/^PURGATORY_EXTRA_CFLAGS =/s/=/+=/" -i Makefile.in || die 51 | 52 | eautoreconf 53 | } 54 | 55 | src_configure() { 56 | local myeconfargs=( 57 | $(use_with booke) 58 | $(use_with lzma) 59 | $(use_with xen) 60 | $(use_with zlib) 61 | ) 62 | econf "${myeconfargs[@]}" 63 | } 64 | 65 | src_compile() { 66 | # Respect CFLAGS for purgatory. 67 | # purgatory/Makefile uses PURGATORY_EXTRA_CFLAGS variable. 68 | # -mfunction-return=thunk and -mindirect-branch=thunk conflict with 69 | # -mcmodel=large which is added by build system. 70 | # Replace them with -mfunction-return=thunk-inline and -mindirect-branch=thunk-inline. 71 | local flag flags=() 72 | for flag in ${CFLAGS}; do 73 | [[ ${flag} == -mfunction-return=thunk ]] && flag="-mfunction-return=thunk-inline" 74 | [[ ${flag} == -mindirect-branch=thunk ]] && flag="-mindirect-branch=thunk-inline" 75 | flags+=("${flag}") 76 | done 77 | local -x PURGATORY_EXTRA_CFLAGS="${flags[*]}" 78 | 79 | default 80 | } 81 | 82 | src_install() { 83 | default 84 | 85 | dodoc "${FILESDIR}"/README.Gentoo 86 | 87 | newinitd "${FILESDIR}"/kexec-r2.init kexec 88 | newconfd "${FILESDIR}"/kexec.conf-2.0.4 kexec 89 | 90 | insinto /etc 91 | doins "${FILESDIR}"/kexec.conf 92 | 93 | insinto /etc/kernel/postinst.d 94 | doins "${FILESDIR}"/90_kexec 95 | 96 | systemd_dounit "${FILESDIR}"/kexec.service 97 | } 98 | 99 | pkg_postinst() { 100 | if systemd_is_booted || has_version sys-apps/systemd; then 101 | elog "For systemd support the new config file is" 102 | elog " /etc/kexec.conf" 103 | elog "Please adopt it to your needs as there is no autoconfig anymore" 104 | fi 105 | 106 | local n_root_args=$(grep -o -- '\/dev/null | wc -l) 107 | local has_rootpart_set=no 108 | if [[ -f "${EROOT}/etc/conf.d/kexec" ]]; then 109 | if grep -q -E -- '^ROOTPART=' "${EROOT}/etc/conf.d/kexec" 2>/dev/null; then 110 | has_rootpart_set=yes 111 | fi 112 | fi 113 | 114 | if [[ ${n_root_args} -gt 1 && "${has_rootpart_set}" == "no" ]]; then 115 | ewarn "WARNING: Multiple root arguments (root=) on kernel command-line detected!" 116 | ewarn "This was probably caused by a previous version of ${PN}." 117 | ewarn "Please reboot system once *without* kexec to avoid boot problems" 118 | ewarn "in case running system and initramfs do not agree on detected" 119 | ewarn "root device name!" 120 | fi 121 | } 122 | -------------------------------------------------------------------------------- /sys-apps/kexec-tools/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | base-system@gentoo.org 6 | Gentoo Base System 7 | 8 | 9 | Enables support for LZMA compressed kernel images 10 | Include support for Book-E memory management 11 | Enable extended xen support 12 | 13 | 14 | -------------------------------------------------------------------------------- /sys-firmware/u-boot-bin/Manifest: -------------------------------------------------------------------------------- 1 | DIST u-boot-bin-2022.10.tar.xz 281356 BLAKE2B 130bf5c59585355d2fd1c5b62a225cd2f0e82f8221065f0d640649abb52e1c091ef8d3512067253c4be85e787724a1e591557c2289545b032177c39af2b4170d SHA512 4aec0a1a7c7bffa3a5b990e96ebbb3c2fe7e32f3ae5a1d96df8a7d537e63fc77e25c60146be67e3308b9e5b92e3d42732b78e59ab8f2eeb79c5dadcdcb731a5d 2 | -------------------------------------------------------------------------------- /sys-firmware/u-boot-bin/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sys-firmware/u-boot-bin/u-boot-bin-2022.10.ebuild: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Gentoo Authors 2 | # Distributed under the terms of the GNU General Public License v2 3 | 4 | EAPI=8 5 | 6 | DESCRIPTION="U-boot binary firmware which can be used by qemu as bios" 7 | HOMEPAGE="https://www.denx.de/project/u-boot/" 8 | SRC_URI="https://dev.gentoo.org/~dlan/distfiles/${CATEGORY}/${PN}/${P}.tar.xz" 9 | 10 | LICENSE="GPL-2" 11 | SLOT="0" 12 | KEYWORDS="~amd64 ~riscv" 13 | 14 | DEPEND="" 15 | RDEPEND="${DEPEND}" 16 | BDEPEND="" 17 | -------------------------------------------------------------------------------- /www-client/chromium/Manifest: -------------------------------------------------------------------------------- 1 | DIST chromium-136.0.7103.113-linux-testdata.tar.xz 651614116 BLAKE2B ba76c70f3b803e5881e5825612d998256c28c07545815c766809ab9185e41bb263f933fb51bef3f0658c4248c072505542b4ba3b7a77007845c3f4816301ef7a SHA512 5eedfa17054056d5f7110bb7becd4ca77dc73ab2bcc0b722dbb591acbe15d6e569f26c988c59661763a1b239e9a18955975fbae4d172536f42e081674fdbb8d6 2 | DIST chromium-136.0.7103.113-linux.tar.xz 1558575932 BLAKE2B 17a455d4146d942256c177502ea8a7743e899d45875b04d9a65a2cff3224cad79590a6d750c3476d4a4abe0378813e378c463c947b144157cc65b1c4422ec720 SHA512 aff1f8f96f304d15ad984f06a5806733b8cc8689973b620b8ef43bb24cb10b2201f40b48158b7a2508cfbaffad3753c811519237c0e68c7a7303be575611896f 3 | DIST chromium-clang-llvmorg-21-init-5118-g52cd27e6-5.tar.xz 54517328 BLAKE2B 8fdc17f49f17348d648fc55aa3c603ac857bf76d3e7e0ca73d616a1458c80b8e15421e47271958d50db83f5a5d43673c10235938ecd2d3bba6072c414b20b1f0 SHA512 3397eb7157c805df82ca8f33b61b906ab2b9dd111390b78a0d4b3e79bdbdfd6896adf1106e10741b67845d081654fdde3b763abb12aa7b5e94e6ccbdde072b94 4 | DIST chromium-openpower-01dda91015.tar.bz2 382275 BLAKE2B b95781f5f1845b93b02f97c617618255aed140b80a87cbd259d591e32ddc2185b9793d6735dce5c71d2bbf4af51534e8680d802f204c840fb8265e7867798f8d SHA512 981677898c218c573a2942ca0d5d2bc3b7ed687fe31be6e5078c18efb2bdffe4ad8976e8c3fb2b101f69ee3abe588c659130cdd7ccf740c4efa7914f5b44b72d 5 | DIST chromium-patches-136-2.tar.bz2 10500 BLAKE2B d943a397059d4d55871bc4f2191e40b55d92aeab8c954c24604a558149d0df3cc8590c147a685d2e21253728918d47fdf46c24363085be364bf35ab4f3938349 SHA512 f9ff50891ef23c2d129170389c56fa3cd629e8a473dc220008dcc7cdbe86284b3f522f507d1276f0adc1c457e95b33c614a54abdea13cb23cbc7a8c0f777a291 6 | DIST chromium-profiler-0.2.tar 259952640 BLAKE2B 5e82389fce00b267280d633b26551231c558b80f0c92cd7d60271095a3503365ab673e7a46dc5f74f8a82db1f21262cb24dcc0531d954bab5fb3b175dab3394d SHA512 9fa89a5ab728419683e7495ae676567480987d68a2d589f2aa97bfcbcf123f3c8f97f8bca5f65e5e3f6e41475535add473ded83b9c7a33bb4746a9d05b298a6c 7 | DIST chromium-rust-toolchain-f7b4354283-1-llvmorg-21-init-5118-g52cd27e6.tar.xz 118223072 BLAKE2B 2173e53df32fa697932ed55b6cef016ee8e1e7202ee47d947caef82f727b75dee1b466c7dcae0210225b23cfa94acf46af2ae4db10358189f3f32f7f0d84b685 SHA512 36d686342d5e0d984cc147e0a8ce06f665759b5480b086551158e69642cf903dbbbce85484eb8e5314cd1f0aa0e869f47d74cbf33fb125d4bd09586d22b0e3a5 8 | DIST chromium-testfonts-f26f29c9d3.tar.gz 32750602 BLAKE2B 498f8b2e0811c98dc3d4aaa75559e69c782afb4bd12328cfdb7244ddba5cae7ee47becd27b2549d7b36bed417601f70f4c192934b0f08496cef1547d0502d93c SHA512 96b090446862997c8134e2971f0e38793ecc1208d547e554c9b651ccfb4127c4de86754903fea57a7292a2823c45117bae0ec13ed87aed20c248fb779579fbde 9 | -------------------------------------------------------------------------------- /www-client/chromium/files/0001-Enable-relocate-1-for-ff_h264_weight_funcs_8_rvv.patch: -------------------------------------------------------------------------------- 1 | From 7954389e39292980323a986ed21eb47325bbddf8 Mon Sep 17 00:00:00 2001 2 | Message-ID: <7954389e39292980323a986ed21eb47325bbddf8.1731734570.git.rsworktech@outlook.com> 3 | From: Levi Zim 4 | Date: Sat, 16 Nov 2024 13:22:28 +0800 5 | Subject: [PATCH] Enable relocate=1 for ff_h264_weight_funcs_8_rvv 6 | 7 | --- 8 | libavcodec/riscv/h264dsp_rvv.S | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/third_party/ffmpeg/libavcodec/riscv/h264dsp_rvv.S b/third_party/ffmpeg/libavcodec/riscv/h264dsp_rvv.S 12 | index 079896b17b..05d077f44e 100644 13 | --- a/third_party/ffmpeg/libavcodec/riscv/h264dsp_rvv.S 14 | +++ b/third_party/ffmpeg/libavcodec/riscv/h264dsp_rvv.S 15 | @@ -160,7 +160,7 @@ h264_weight 8, 16 16 | 17 | .global ff_h264_weight_funcs_8_rvv 18 | .hidden ff_h264_weight_funcs_8_rvv 19 | -const ff_h264_weight_funcs_8_rvv 20 | +const ff_h264_weight_funcs_8_rvv, relocate=1 21 | .irp w, 16, 8, 4, 2 22 | #if __riscv_xlen == 32 23 | .word ff_h264_weight_pixels\w\()_8_rvv 24 | -- 25 | 2.47.0 26 | 27 | -------------------------------------------------------------------------------- /www-client/chromium/files/0001-chrome-runtime_api_delegate-add-riscv64-define.patch: -------------------------------------------------------------------------------- 1 | From 81033cc7b695b94f8932c29f7812c41fb057aa2b Mon Sep 17 00:00:00 2001 2 | From: kxxt 3 | Date: Sun, 25 Aug 2024 10:46:25 +0200 4 | Subject: [PATCH] chrome: runtime_api_delegate: add riscv64 define 5 | 6 | --- 7 | .../extensions/api/runtime/chrome_runtime_api_delegate.cc | 4 ++++ 8 | 1 file changed, 4 insertions(+) 9 | 10 | diff --git a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc 11 | index 0c2f88ce0d92c..113a8e0010075 100644 12 | --- a/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc 13 | +++ b/chrome/browser/extensions/api/runtime/chrome_runtime_api_delegate.cc 14 | @@ -303,6 +303,8 @@ bool ChromeRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) { 15 | info->arch = extensions::api::runtime::PlatformArch::kMips; 16 | } else if (strcmp(arch, "mips64el") == 0) { 17 | info->arch = extensions::api::runtime::PlatformArch::kMips64; 18 | + } else if (strcmp(arch, "riscv64") == 0) { 19 | + info->arch = extensions::api::runtime::PlatformArch::kRiscv64; 20 | } else { 21 | NOTREACHED_IN_MIGRATION(); 22 | return false; 23 | @@ -319,6 +321,8 @@ bool ChromeRuntimeAPIDelegate::GetPlatformInfo(PlatformInfo* info) { 24 | info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kMips; 25 | } else if (strcmp(nacl_arch, "mips64") == 0) { 26 | info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kMips64; 27 | + } else if (strcmp(arch, "riscv64") == 0) { 28 | + info->nacl_arch = extensions::api::runtime::PlatformNaclArch::kRiscv64; 29 | } else { 30 | NOTREACHED_IN_MIGRATION(); 31 | return false; 32 | -- 33 | 2.39.2 34 | 35 | -------------------------------------------------------------------------------- /www-client/chromium/files/0001-extensions-common-api-runtime.json-riscv64-support.patch: -------------------------------------------------------------------------------- 1 | From 688e2d4d0880e596656f2f079357767d24950c62 Mon Sep 17 00:00:00 2001 2 | From: kxxt 3 | Date: Sat, 10 Feb 2024 09:49:46 +0800 4 | Subject: [PATCH] extensions/common/api/runtime.json: riscv64 support 5 | 6 | --- 7 | extensions/common/api/runtime.json | 6 ++++-- 8 | 1 file changed, 4 insertions(+), 2 deletions(-) 9 | 10 | diff --git a/extensions/common/api/runtime.json b/extensions/common/api/runtime.json 11 | index 65a024c03011e..9965a83545807 100644 12 | --- a/extensions/common/api/runtime.json 13 | +++ b/extensions/common/api/runtime.json 14 | @@ -98,7 +98,8 @@ 15 | {"name": "x86-32", "description": "Specifies the processer architecture as x86-32."}, 16 | {"name": "x86-64", "description": "Specifies the processer architecture as x86-64."}, 17 | {"name": "mips", "description": "Specifies the processer architecture as mips."}, 18 | - {"name": "mips64", "description": "Specifies the processer architecture as mips64."} 19 | + {"name": "mips64", "description": "Specifies the processer architecture as mips64."}, 20 | + {"name": "riscv64", "description": "Specifies the processer architecture as riscv64."} 21 | ], 22 | "description": "The machine's processor architecture." 23 | }, 24 | @@ -111,7 +112,8 @@ 25 | {"name": "x86-32", "description": "Specifies the native client architecture as x86-32."}, 26 | {"name": "x86-64", "description": "Specifies the native client architecture as x86-64."}, 27 | {"name": "mips", "description": "Specifies the native client architecture as mips."}, 28 | - {"name": "mips64", "description": "Specifies the native client architecture as mips64."} 29 | + {"name": "mips64", "description": "Specifies the native client architecture as mips64."}, 30 | + {"name": "riscv64", "description": "Specifies the native client architecture as riscv64."} 31 | ] 32 | }, 33 | { 34 | -- 35 | 2.43.0 36 | 37 | 38 | -------------------------------------------------------------------------------- /www-client/chromium/files/Debian-fix-rust-linking.patch: -------------------------------------------------------------------------------- 1 | --- a/build/toolchain/gcc_toolchain.gni 2024-08-19 14:13:35.233954725 +0200 2 | +++ b/build/toolchain/gcc_toolchain.gni 2024-08-22 00:56:01.438433033 +0200 3 | @@ -441,7 +441,13 @@ 4 | # -soname flag is not available on aix ld 5 | soname_flag = "-Wl,-soname=\"$soname\"" 6 | } 7 | - link_command = "$ld -shared $soname_flag {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" @\"$rspfile\" {{rlibs}}" 8 | + if (target_cpu == "riscv64") { 9 | + # Work around linker failures due to Rust libraries and the use of whole-archive 10 | + link_command = "$ld -shared $soname_flag -Wl,--start-group {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" @\"$rspfile\" {{rlibs}} -Wl,--end-group" 11 | + } 12 | + else { 13 | + link_command = "$ld -shared $soname_flag {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" @\"$rspfile\" {{rlibs}}" 14 | + } 15 | 16 | # Generate a map file to be used for binary size analysis. 17 | # Map file adds ~10% to the link time on a z620. 18 | @@ -553,7 +559,13 @@ 19 | whole_archive_flag = "-Wl,--whole-archive" 20 | no_whole_archive_flag = "-Wl,--no-whole-archive" 21 | } 22 | - command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" $soname_flag @\"$rspfile\"" 23 | + if (target_cpu == "riscv64") { 24 | + # Work around linker failures due to Rust libraries and the use of whole-archive 25 | + command = "$ld -shared -Wl,--start-group {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" $soname_flag @\"$rspfile\" -Wl,--end-group" 26 | + } 27 | + else { 28 | + command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" $soname_flag @\"$rspfile\"" 29 | + } 30 | 31 | if (defined(invoker.strip)) { 32 | strip_command = "${invoker.strip} -o \"$sofile\" \"$unstripped_sofile\"" 33 | @@ -617,8 +629,12 @@ 34 | # We need to specify link groups, at least, for single pass linkers. I.e. 35 | # Rust libraries are alpha-sorted instead of by dependencies so they fail 36 | # to link if not properly ordered or grouped. 37 | - link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" $end_group_flag {{solibs}} {{libs}} $start_group_flag {{rlibs}} $end_group_flag" 38 | - 39 | + if (target_cpu == "riscv64") { 40 | + link_command = "$ld -Wl,--start-group {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" @\"$rspfile\" {{solibs}} {{libs}} {{rlibs}} -Wl,--end-group" 41 | + } 42 | + else { 43 | + link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" $end_group_flag {{solibs}} {{libs}} $start_group_flag {{rlibs}} $end_group_flag" 44 | + } 45 | # Generate a map file to be used for binary size analysis. 46 | # Map file adds ~10% to the link time on a z620. 47 | # With target_os="android", libchrome.so.map.gz is ~20MB. 48 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-109-system-zlib.patch: -------------------------------------------------------------------------------- 1 | --- a/third_party/tflite_support/src/tensorflow_lite_support/metadata/cc/utils/zip_readonly_mem_file.cc 2 | +++ b/third_party/tflite_support/src/tensorflow_lite_support/metadata/cc/utils/zip_readonly_mem_file.cc 3 | @@ -19,7 +19,6 @@ limitations under the License. 4 | #include 5 | 6 | #include "absl/strings/string_view.h" // from @com_google_absl 7 | -#include "third_party/zlib/contrib/minizip/ioapi.h" 8 | 9 | namespace tflite { 10 | namespace metadata { 11 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-111-InkDropHost-crash.patch: -------------------------------------------------------------------------------- 1 | https://chromium-review.googlesource.com/c/chromium/src/+/2959890 2 | 3 | --- a/ui/views/animation/ink_drop_host.h 4 | +++ b/ui/views/animation/ink_drop_host.h 5 | @@ -238,6 +238,11 @@ class VIEWS_EXPORT InkDropHost { 6 | // Used to observe View and inform the InkDrop of host-transform changes. 7 | ViewLayerTransformObserver host_view_transform_observer_; 8 | 9 | + // Declared before |ink_drop_|, because InkDropImpl may call 10 | + // RemoveInkDropLayer on partly destructed InkDropHost. In 11 | + // that case |ink_drop_mask_| must be still valid. 12 | + std::unique_ptr ink_drop_mask_; 13 | + 14 | // Should not be accessed directly. Use GetInkDrop() instead. 15 | std::unique_ptr ink_drop_; 16 | 17 | @@ -261,8 +266,6 @@ class VIEWS_EXPORT InkDropHost { 18 | int ink_drop_small_corner_radius_ = 2; 19 | int ink_drop_large_corner_radius_ = 4; 20 | 21 | - std::unique_ptr ink_drop_mask_; 22 | - 23 | base::RepeatingCallback()> create_ink_drop_callback_; 24 | base::RepeatingCallback()> 25 | create_ink_drop_ripple_callback_; 26 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-131-oauth2-client-switches.patch: -------------------------------------------------------------------------------- 1 | From 54951636d20fa798e148228118863b89a4580479 Mon Sep 17 00:00:00 2001 2 | From: Matt Jolly 3 | Date: Sat, 12 Oct 2024 12:40:16 +1000 4 | Subject: [PATCH] www-client/chromium: work around dead oauth2 credentials - 5 | 131 update 6 | 7 | 131 moved a ton of things around; this is now in api_key_cache.cc 8 | 9 | Google doesn't let us bake in OAuth2 credentials, and for some time, 10 | Google sign-in has been broken. Arch dealt with this in March, and so 11 | did we to some degree, but in the last few months, our sign-in 12 | credentials have been broken. It appears that we actually did remove API 13 | credentials in March around Chrome 89, but they got added back, perhaps 14 | when rotating newer versions to replace older versions. Work around this 15 | by following Arch's lead: we remove the predefined credentials, as 16 | before, but also we patch Chromium so that people can use their own 17 | easily, using Arch's patch for that. 18 | --- a/google_apis/api_key_cache.cc 19 | +++ b/google_apis/api_key_cache.cc 20 | @@ -214,14 +214,14 @@ ApiKeyCache::ApiKeyCache(const DefaultApiKeys& default_api_keys) { 21 | 22 | std::string default_client_id = CalculateKeyValue( 23 | default_api_keys.google_default_client_id, 24 | - STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), std::string(), nullptr, 25 | + STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), std::string(), ::switches::kOAuth2ClientID, 26 | std::string(), environment.get(), command_line, gaia_config, 27 | default_api_keys.allow_override_via_environment, 28 | default_api_keys.allow_unset_values); 29 | std::string default_client_secret = CalculateKeyValue( 30 | default_api_keys.google_default_client_secret, 31 | STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), std::string(), 32 | - nullptr, std::string(), environment.get(), command_line, gaia_config, 33 | + ::switches::kOAuth2ClientSecret, std::string(), environment.get(), command_line, gaia_config, 34 | default_api_keys.allow_override_via_environment, 35 | default_api_keys.allow_unset_values); 36 | 37 | -- 38 | 2.46.2 39 | 40 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-131-unbundle-icu-target.patch: -------------------------------------------------------------------------------- 1 | From a665875b4013eed997bd042326a038e24f3296e7 Mon Sep 17 00:00:00 2001 2 | From: Matt Jolly 3 | Date: Thu, 10 Oct 2024 14:36:51 +1000 4 | Subject: [PATCH] unbundle: add missing icu target 5 | 6 | --- a/build/linux/unbundle/icu.gn 7 | +++ b/build/linux/unbundle/icu.gn 8 | @@ -65,6 +65,10 @@ group("icuuc_public") { 9 | public_deps = [ ":icuuc" ] 10 | } 11 | 12 | +group("icui18n_hidden_visibility") { 13 | + public_deps = [ ":icuuc" ] 14 | +} 15 | + 16 | shim_headers("icui18n_shim") { 17 | root_path = "source/i18n" 18 | headers = [ 19 | -- 20 | 2.46.2 21 | 22 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-132-bindgen-custom-toolchain.patch: -------------------------------------------------------------------------------- 1 | From 84b3b8335f7efbb8ed5ab9c9a260ea4f5d77192b Mon Sep 17 00:00:00 2001 2 | From: Matt Jolly 3 | Date: Mon, 11 Nov 2024 20:52:48 +1000 4 | Subject: [PATCH] Make bindgen wrapper work with unbundled toolchain 5 | 6 | The `run_bindgen.py` wrapper takes a --libclang-path option 7 | and uses it to set the appropriate environment variable. 8 | 9 | This is currently hardcoded to use libclang shipped alongside 10 | bindgen (in our rust toolchain), but distributions may want to 11 | override this and use a system path. 12 | 13 | Additionally enable distros to feed in appropriate library paths. 14 | --- a/build/config/rust.gni 15 | +++ b/build/config/rust.gni 16 | @@ -60,6 +60,17 @@ declare_args() { 17 | # the bindgen exectuable). 18 | rust_bindgen_root = "//third_party/rust-toolchain" 19 | 20 | + # Directory under which to find one of `libclang.{dll,so}` (a `lib[64]` or 21 | + # `bin` directory containing the libclang shared library). 22 | + # We don't need to worry about multlib, but specify the full path here 23 | + # in case a distribution does. 24 | + if (host_os == "win") { 25 | + bindgen_libclang_path = "//third_party/rust-toolchain/bin" 26 | + } else { 27 | + bindgen_libclang_path = "//third_party/rust-toolchain/lib" 28 | + } 29 | + 30 | + 31 | # If you're using a Rust toolchain as specified by rust_sysroot_absolute, 32 | # set this to the output of `rustc -V`. Changing this string will cause all 33 | # Rust targets to be rebuilt, which allows you to update your toolchain and 34 | --- a/build/rust/rust_bindgen.gni 35 | +++ b/build/rust/rust_bindgen.gni 36 | @@ -17,13 +17,13 @@ if (host_os == "win") { 37 | _bindgen_path = "${_bindgen_path}.exe" 38 | } 39 | 40 | -# On Windows, the libclang.dll is beside the bindgen.exe, otherwise it is in 41 | -# ../lib. 42 | -_libclang_path = rust_bindgen_root 43 | -if (host_os == "win") { 44 | - _libclang_path += "/bin" 45 | +if (clang_base_path != default_clang_base_path && custom_toolchain == "//build/toolchain/linux/unbundle:default") { 46 | + # Assume that the user has set this up properly, including handling multilib 47 | + _clang_libpath = clang_base_path + "/include" 48 | + _clang_ld_libpath = bindgen_libclang_path 49 | } else { 50 | - _libclang_path += "/lib" 51 | + _clang_libpath = clang_base_path + "/lib/clang/" + clang_version 52 | + _clang_ld_libpath = clang_base_path + "/lib" 53 | } 54 | 55 | # Template to build Rust/C bindings with bindgen. 56 | --- a/build/rust/rust_bindgen_generator.gni 57 | +++ b/build/rust/rust_bindgen_generator.gni 58 | @@ -151,7 +151,7 @@ template("rust_bindgen_generator") { 59 | "--output", 60 | rebase_path(output_file, root_build_dir), 61 | "--libclang-path", 62 | - rebase_path(_libclang_path, root_build_dir), 63 | + rebase_path(bindgen_libclang_path, root_build_dir), 64 | ] 65 | 66 | if (_wrap_static_fns) { 67 | @@ -172,7 +172,7 @@ template("rust_bindgen_generator") { 68 | # point to. 69 | args += [ 70 | "--ld-library-path", 71 | - rebase_path(clang_base_path + "/lib", root_build_dir), 72 | + rebase_path(bindgen_libclang_path, root_build_dir), 73 | ] 74 | } 75 | 76 | @@ -215,9 +215,7 @@ template("rust_bindgen_generator") { 77 | # says the wrong thing. We point it to our clang's resource dir which will 78 | # make it behave consistently with our other command line flags and allows 79 | # system headers to be found. 80 | - clang_resource_dir = 81 | - rebase_path(clang_base_path + "/lib/clang/" + clang_version, 82 | - root_build_dir) 83 | + clang_resource_dir = rebase_path(clang_base_path + "/include", root_build_dir) 84 | args += [ 85 | "-resource-dir", 86 | clang_resource_dir, 87 | @@ -238,6 +236,15 @@ template("rust_bindgen_generator") { 88 | } 89 | } 90 | 91 | + if (custom_toolchain == "//build/toolchain/linux/unbundle:default") { 92 | + # We need to pass the path to the libstdc++ headers to bindgen so that it 93 | + # can find them when parsing C++ headers. 94 | + args += [ 95 | + "-I", 96 | + rebase_path(clang_base_path + "/include/", root_build_dir), 97 | + ] 98 | + } 99 | + 100 | if (is_win) { 101 | # On Windows we fall back to using system headers from a sysroot from 102 | # depot_tools. This is negotiated by python scripts and the result is 103 | -- 104 | 2.47.0 105 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-134-bindgen-custom-toolchain.patch: -------------------------------------------------------------------------------- 1 | From 04fe2f9010c2cc58eced407e6eb2124c67a60109 Mon Sep 17 00:00:00 2001 2 | From: Matt Jolly 3 | Date: Thu, 6 Feb 2025 11:40:08 +1000 4 | Subject: [PATCH] Make bindgen wrapper work with unbundled toolchain 5 | 6 | The `run_bindgen.py` wrapper takes a --libclang-path option 7 | and uses it to set the appropriate environment variable. 8 | 9 | This is currently hardcoded to use libclang shipped alongside 10 | bindgen (in our rust toolchain), but distributions may want to 11 | override this and use a system path. 12 | 13 | Additionally enable distros to feed in appropriate library paths. 14 | --- 15 | build/config/rust.gni | 11 +++++++++++ 16 | build/rust/rust_bindgen.gni | 12 ++++++------ 17 | build/rust/rust_bindgen_generator.gni | 22 ++++++++++++++++++---- 18 | 3 files changed, 35 insertions(+), 10 deletions(-) 19 | 20 | diff --git a/build/config/rust.gni b/build/config/rust.gni 21 | index 5b9e3e1e65..1e93be41ff 100644 22 | --- a/build/config/rust.gni 23 | +++ b/build/config/rust.gni 24 | @@ -64,6 +64,17 @@ declare_args() { 25 | # the bindgen exectuable). 26 | rust_bindgen_root = "//third_party/rust-toolchain" 27 | 28 | + # Directory under which to find one of `libclang.{dll,so}` (a `lib[64]` or 29 | + # `bin` directory containing the libclang shared library). 30 | + # We don't need to worry about multlib, but specify the full path here 31 | + # in case a distribution does. 32 | + if (host_os == "win") { 33 | + bindgen_libclang_path = "//third_party/rust-toolchain/bin" 34 | + } else { 35 | + bindgen_libclang_path = "//third_party/rust-toolchain/lib" 36 | + } 37 | + 38 | + 39 | # If you're using a Rust toolchain as specified by rust_sysroot_absolute, 40 | # set this to the output of `rustc -V`. Changing this string will cause all 41 | # Rust targets to be rebuilt, which allows you to update your toolchain and 42 | diff --git a/build/rust/rust_bindgen.gni b/build/rust/rust_bindgen.gni 43 | index 5c809c6932..a493daa909 100644 44 | --- a/build/rust/rust_bindgen.gni 45 | +++ b/build/rust/rust_bindgen.gni 46 | @@ -17,13 +17,13 @@ if (host_os == "win") { 47 | _bindgen_path = "${_bindgen_path}.exe" 48 | } 49 | 50 | -# On Windows, the libclang.dll is beside the bindgen.exe, otherwise it is in 51 | -# ../lib. 52 | -_libclang_path = rust_bindgen_root 53 | -if (host_os == "win") { 54 | - _libclang_path += "/bin" 55 | +if (clang_base_path != default_clang_base_path && custom_toolchain == "//build/toolchain/linux/unbundle:default") { 56 | + # Assume that the user has set this up properly, including handling multilib 57 | + _clang_libpath = clang_base_path + "/include" 58 | + _clang_ld_libpath = bindgen_libclang_path 59 | } else { 60 | - _libclang_path += "/lib" 61 | + _clang_libpath = clang_base_path + "/lib/clang/" + clang_version 62 | + _clang_ld_libpath = clang_base_path + "/lib" 63 | } 64 | 65 | # Template to build Rust/C bindings with bindgen. 66 | diff --git a/build/rust/rust_bindgen_generator.gni b/build/rust/rust_bindgen_generator.gni 67 | index c91916be93..6afbef2f31 100644 68 | --- a/build/rust/rust_bindgen_generator.gni 69 | +++ b/build/rust/rust_bindgen_generator.gni 70 | @@ -151,7 +151,7 @@ template("rust_bindgen_generator") { 71 | "--output", 72 | rebase_path(output_file, root_build_dir), 73 | "--libclang-path", 74 | - rebase_path(_libclang_path, root_build_dir), 75 | + rebase_path(bindgen_libclang_path, root_build_dir), 76 | ] 77 | 78 | if (_wrap_static_fns) { 79 | @@ -172,7 +172,7 @@ template("rust_bindgen_generator") { 80 | # point to. 81 | args += [ 82 | "--ld-library-path", 83 | - rebase_path(clang_base_path + "/lib", root_build_dir), 84 | + rebase_path(bindgen_libclang_path, root_build_dir), 85 | ] 86 | } 87 | 88 | @@ -215,9 +215,14 @@ template("rust_bindgen_generator") { 89 | # says the wrong thing. We point it to our clang's resource dir which will 90 | # make it behave consistently with our other command line flags and allows 91 | # system headers to be found. 92 | - clang_resource_dir = 93 | - rebase_path(clang_base_path + "/lib/clang/" + clang_version, 94 | + if (clang_base_path != default_clang_base_path && custom_toolchain == "//build/toolchain/linux/unbundle:default") { 95 | + clang_resource_dir = 96 | + rebase_path(clang_base_path + "/include", root_build_dir) 97 | + } else { 98 | + clang_resource_dir = 99 | + rebase_path(clang_base_path + "/lib/clang/" + clang_version, 100 | root_build_dir) 101 | + } 102 | args += [ 103 | "-resource-dir", 104 | clang_resource_dir, 105 | @@ -238,6 +243,15 @@ template("rust_bindgen_generator") { 106 | } 107 | } 108 | 109 | + if (custom_toolchain == "//build/toolchain/linux/unbundle:default") { 110 | + # We need to pass the path to the libstdc++ headers to bindgen so that it 111 | + # can find them when parsing C++ headers. 112 | + args += [ 113 | + "-I", 114 | + rebase_path(clang_base_path + "/include/", root_build_dir), 115 | + ] 116 | + } 117 | + 118 | if (is_win) { 119 | # On Windows we fall back to using system headers from a sysroot from 120 | # depot_tools. This is negotiated by python scripts and the result is 121 | -- 122 | 2.48.0 123 | 124 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-134-map_droppable-glibc.patch: -------------------------------------------------------------------------------- 1 | From d1e4332f1a2361014175646fae4f4549b8c1abbf Mon Sep 17 00:00:00 2001 2 | From: Matt Jolly 3 | Date: Thu, 13 Feb 2025 16:56:53 +1000 4 | Subject: [PATCH] seccomp: Define MAP_DROPPABLE for glibc 2.41 5 | 6 | Bug: https://bugs.gentoo.org/949654 7 | --- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc 8 | +++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc 9 | @@ -1,3 +1,4 @@ 10 | + 11 | // Copyright 2013 The Chromium Authors 12 | // Use of this source code is governed by a BSD-style license that can be 13 | // found in the LICENSE file. 14 | @@ -35,6 +36,10 @@ 15 | #include "sandbox/linux/system_headers/linux_syscalls.h" 16 | #include "sandbox/linux/system_headers/linux_time.h" 17 | 18 | +#if !defined(MAP_DROPPABLE) 19 | +#define MAP_DROPPABLE 0x08 // Zero memory under memory pressure. 20 | +#endif 21 | + 22 | #if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \ 23 | !defined(__arm__) && !defined(__aarch64__) && \ 24 | !defined(PTRACE_GET_THREAD_AREA) 25 | @@ -238,7 +243,7 @@ ResultExpr RestrictMmapFlags() { 26 | // TODO(davidung), remove MAP_DENYWRITE with updated Tegra libraries. 27 | const uint64_t kAllowedMask = MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS | 28 | MAP_STACK | MAP_NORESERVE | MAP_FIXED | 29 | - MAP_DENYWRITE | MAP_LOCKED | 30 | + MAP_DENYWRITE | MAP_LOCKED | MAP_DROPPABLE | 31 | kArchSpecificAllowedMask; 32 | const Arg flags(3); 33 | return If((flags & ~kAllowedMask) == 0, Allow()).Else(CrashSIGSYS()); 34 | -- 35 | 2.48.0 36 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-134-oauth2-client-switches.patch: -------------------------------------------------------------------------------- 1 | From 628c8aad603791ec1276c6a5b8d3704a03840f86 Mon Sep 17 00:00:00 2001 2 | From: Matt Jolly 3 | Date: Sat, 18 Jan 2025 11:09:46 +1000 4 | Subject: [PATCH] www-client/chromium: work around dead oauth2 credentials 5 | 6 | Google doesn't let us bake in OAuth2 credentials, and for some time, 7 | Google sign-in has been broken. Arch dealt with this in March, and so 8 | did we to some degree, but in the last few months, our sign-in 9 | credentials have been broken. It appears that we actually did remove API 10 | credentials in March around Chrome 89, but they got added back, perhaps 11 | when rotating newer versions to replace older versions. Work around this 12 | by following Arch's lead: we remove the predefined credentials, as 13 | before, but also we patch Chromium so that people can use their own 14 | easily, using Arch's patch for that. 15 | --- a/google_apis/api_key_cache.cc 16 | +++ b/google_apis/api_key_cache.cc 17 | @@ -192,13 +192,13 @@ ApiKeyCache::ApiKeyCache(const DefaultApiKeys& default_api_keys) { 18 | 19 | std::string default_client_id = CalculateKeyValue( 20 | default_api_keys.google_default_client_id, 21 | - STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), nullptr, std::string(), 22 | + STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), ::switches::kOAuth2ClientID, std::string(), 23 | environment.get(), command_line, gaia_config, 24 | default_api_keys.allow_override_via_environment, 25 | default_api_keys.allow_unset_values); 26 | std::string default_client_secret = CalculateKeyValue( 27 | default_api_keys.google_default_client_secret, 28 | - STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), nullptr, 29 | + STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), ::switches::kOAuth2ClientID, 30 | std::string(), environment.get(), command_line, gaia_config, 31 | default_api_keys.allow_override_via_environment, 32 | default_api_keys.allow_unset_values); 33 | -- 34 | 2.48.0 35 | 36 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-134-qt5-optional.patch: -------------------------------------------------------------------------------- 1 | https://chromium.googlesource.com/chromium/src/+/0d8d0e0943489b59e452b4d0214959821880ad7f 2 | From: Matt Jolly 3 | Date: Tue, 28 Jan 2025 12:00:57 -0800 4 | Subject: [PATCH] UI: make QT5 optional 5 | 6 | To build with `use_qt6`, QT5 (`use_qt`) is also required. 7 | This is undesirable for downstreams who are actively working 8 | to drop support for QT5 (e.g. Gentoo). 9 | 10 | To resolve this: 11 | 12 | - Add `use_qt5` 13 | - Replace most `use_qt` conditionals with this option; 14 | these appear to be from before QT6 support was added. 15 | - Use `use_qt5` to gate some previously unconditional QT5-related 16 | items in chrome/installer/linux 17 | - Remove `use_qt` as an argument, instead set to `use_qt5 || use_qt6`. 18 | 19 | This change should not impact the current behaviour; if no options 20 | are selected QT5 and QT6 support will be enabled, using existing logic 21 | unless one is explicitly disabled with `use_qt{x}=false`. 22 | 23 | See-also: https://bugs.gentoo.org/926166, https://bugs.gentoo.org/948836 24 | Signed-off-by: Matt Jolly 25 | Fixed: 328182252 26 | Change-Id: I22ec7a068356412d3f9fce68a19aee4f8c89892c 27 | Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6205488 28 | Reviewed-by: Thomas Anderson 29 | Commit-Queue: Lei Zhang 30 | Reviewed-by: Lei Zhang 31 | Cr-Commit-Position: refs/heads/main@{#1412471} 32 | --- a/chrome/installer/linux/BUILD.gn 33 | +++ b/chrome/installer/linux/BUILD.gn 34 | @@ -77,10 +77,10 @@ if (enable_swiftshader) { 35 | packaging_files += [ "$root_out_dir/vk_swiftshader_icd.json" ] 36 | } 37 | 38 | -if (use_qt) { 39 | - # Even though this is a shared library, add it to `packaging_files` instead of 40 | - # `packaging_files_shlibs` to skip the dependency check. This is intentional 41 | - # to prevent a hard dependency on QT for the package. 42 | +# Even though this is a shared library, add it to `packaging_files` instead of 43 | +# `packaging_files_shlibs` to skip the dependency check. This is intentional 44 | +# to prevent a hard dependency on QT for the package. 45 | +if (use_qt5) { 46 | packaging_files += [ "$root_out_dir/libqt5_shim.so" ] 47 | } 48 | if (use_qt6) { 49 | @@ -206,7 +206,7 @@ if (build_with_internal_optimization_guide) { 50 | } 51 | } 52 | 53 | -if (use_qt) { 54 | +if (use_qt5) { 55 | strip_binary("strip_qt5_shim") { 56 | binary_input = "$root_out_dir/libqt5_shim.so" 57 | deps = [ "//ui/qt:qt5_shim" ] 58 | @@ -399,7 +399,7 @@ group("installer_deps") { 59 | "//components/optimization_guide/internal:optimization_guide_internal", 60 | ] 61 | } 62 | - if (use_qt) { 63 | + if (use_qt5) { 64 | public_deps += [ 65 | ":strip_qt5_shim", 66 | "//ui/qt:qt5_shim", 67 | --- a/ui/qt/BUILD.gn 68 | +++ b/ui/qt/BUILD.gn 69 | @@ -101,10 +101,12 @@ template("qt_shim") { 70 | } 71 | } 72 | } 73 | -qt_shim("qt5_shim") { 74 | - qt_version = "5" 75 | - if (!use_sysroot) { 76 | - moc_qt_path = "$moc_qt5_path" 77 | +if (use_qt5) { 78 | + qt_shim("qt5_shim") { 79 | + qt_version = "5" 80 | + if (!use_sysroot) { 81 | + moc_qt_path = "$moc_qt5_path" 82 | + } 83 | } 84 | } 85 | if (use_qt6) { 86 | @@ -122,7 +124,10 @@ component("qt") { 87 | defines = [ "IS_QT_IMPL" ] 88 | 89 | # qt_shim is in data_deps since we want to load it manually. 90 | - data_deps = [ ":qt5_shim" ] 91 | + data_deps = [] 92 | + if (use_qt5) { 93 | + data_deps += [ ":qt5_shim" ] 94 | + } 95 | if (use_qt6) { 96 | data_deps += [ ":qt6_shim" ] 97 | } 98 | --- a/ui/qt/qt.gni 99 | +++ b/ui/qt/qt.gni 100 | @@ -6,27 +6,20 @@ import("//build/config/cast.gni") 101 | import("//build/config/sanitizers/sanitizers.gni") 102 | import("//build/config/sysroot.gni") 103 | 104 | +# TODO(crbug.com/40260415): Allow QT in MSAN builds once QT is 105 | +# added to the instrumented libraries. 106 | declare_args() { 107 | - # TODO(crbug.com/40260415): Allow QT in MSAN builds once QT is 108 | - # added to the instrumented libraries. 109 | - use_qt = is_linux && !is_castos && !is_msan 110 | + use_qt5 = use_sysroot && is_linux && !is_castos && !is_msan 111 | + use_qt6 = use_sysroot && is_linux && !is_castos && !is_msan 112 | } 113 | 114 | declare_args() { 115 | - if (!use_sysroot && use_qt) { 116 | + if (!use_sysroot && use_qt5) { 117 | moc_qt5_path = "" 118 | } 119 | -} 120 | - 121 | -declare_args() { 122 | - use_qt6 = use_qt && use_sysroot 123 | -} 124 | - 125 | -declare_args() { 126 | if (!use_sysroot && use_qt6) { 127 | moc_qt6_path = "" 128 | } 129 | } 130 | 131 | -# use_qt6 => use_qt 132 | -assert(!use_qt6 || use_qt) 133 | +use_qt = use_qt5 || use_qt6 134 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-134-type-mismatch-error.patch: -------------------------------------------------------------------------------- 1 | diff -up chromium-134.0.6998.23/base/containers/to_value_list.h.me chromium-134.0.6998.23/base/containers/to_value_list.h 2 | --- chromium-134.0.6998.23/base/containers/to_value_list.h.me 2025-02-23 22:39:33.369668072 +0100 3 | +++ chromium-134.0.6998.23/base/containers/to_value_list.h 2025-02-23 22:42:42.653990901 +0100 4 | @@ -36,8 +36,7 @@ Value::List ToValueList(Range&& range, P 5 | auto container = Value::List::with_capacity(std::ranges::size(range)); 6 | std::ranges::for_each( 7 | std::forward(range), 8 | - [&](T&& value) { container.Append(std::forward(value)); }, 9 | - std::move(proj)); 10 | + [&](auto&& value) { container.Append(std::invoke(proj, std::forward(value))); }); 11 | return container; 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-135-fix-non-wayland-build.patch: -------------------------------------------------------------------------------- 1 | From 919cda539b142b51fc2ef2342dbf1803b65f5434 Mon Sep 17 00:00:00 2001 2 | From: Matt Jolly 3 | Date: Wed, 12 Feb 2025 20:13:09 +1000 4 | Subject: [PATCH] remoting: Linux: guard wayland includes 5 | 6 | During the refactor in 53f3429926deb4cb92d9cddcda5fc096a0332db3 7 | wayland support became required to build this component. 8 | 9 | Only include wayland components in the `platform_impls` target 10 | if `ozone_platform_wayland` is true. 11 | 12 | Bug: 391722217 13 | See also: https://bugs.gentoo.org/948384 14 | Signed-off-by: Matt Jolly 15 | --- a/remoting/host/linux/BUILD.gn 16 | +++ b/remoting/host/linux/BUILD.gn 17 | @@ -192,7 +192,6 @@ source_set("platform_impls") { 18 | "wayland_seat.h", 19 | ] 20 | deps = [ 21 | - ":wayland", 22 | ":x11", 23 | ":x11_display_utils", 24 | "//base", 25 | @@ -214,9 +213,16 @@ source_set("platform_impls") { 26 | "//ui/base", 27 | "//ui/base/x", 28 | "//ui/events:dom_keycode_converter", 29 | - "//ui/events/platform/wayland:wayland_event_watcher", 30 | "//ui/gfx/x", 31 | ] 32 | + # ui/events/platform/wayland:wayland_event_watcher asserts that the wayland 33 | + # platform is enabled. 34 | + if (ozone_platform_wayland) { 35 | + deps += [ 36 | + ":wayland", 37 | + "//ui/events/platform/wayland:wayland_event_watcher", 38 | + ] 39 | + } 40 | } 41 | 42 | source_set("x11_display_utils") { 43 | -- 44 | 2.48.0 45 | 46 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-135-gperf.patch: -------------------------------------------------------------------------------- 1 | https://bugs.gentoo.org/953436#c5 2 | --- a/third_party/blink/renderer/build/scripts/gperf.py 3 | +++ b/third_party/blink/renderer/build/scripts/gperf.py 4 | @@ -28,24 +28,6 @@ 5 | stdout=subprocess.PIPE, 6 | universal_newlines=True) 7 | gperf_output = gperf.communicate(gperf_input)[0] 8 | - # Massage gperf output to be more palatable for modern compilers. 9 | - # TODO(thakis): Upstream these to gperf so we don't need massaging. 10 | - # `register` is deprecated in C++11 and removed in C++17, so remove 11 | - # it from gperf's output. 12 | - # https://savannah.gnu.org/bugs/index.php?53028 13 | - gperf_output = re.sub(r'\bregister ', '', gperf_output) 14 | - # -Wimplicit-fallthrough needs an explicit fallthrough statement, 15 | - # so replace gperf's /*FALLTHROUGH*/ comment with the statement. 16 | - # https://savannah.gnu.org/bugs/index.php?53029 17 | - gperf_output = gperf_output.replace('/*FALLTHROUGH*/', 18 | - ' [[fallthrough]];') 19 | - # -Wpointer-to-int-cast warns about casting pointers to smaller ints 20 | - # Replace {(int)(long)&(foo), bar} with 21 | - # {static_cast(reinterpret_cast(&(foo)), bar} 22 | - gperf_output = re.sub( 23 | - r'\(int\)\(long\)(.*?),', 24 | - r'static_cast(reinterpret_cast(\1)),', 25 | - gperf_output) 26 | script = 'third_party/blink/renderer/build/scripts/gperf.py' 27 | return '// Generated by %s\n' % script + gperf_output 28 | except OSError: 29 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-135-map_droppable-glibc.patch: -------------------------------------------------------------------------------- 1 | https://github.com/FireBurn/chromium/commit/28dc20e11a6f6e6d176fc3ed0b74b405112ecb2d 2 | From: Mike Lothian 3 | Date: Wed, 12 Feb 2025 14:33:50 +0000 4 | Subject: [PATCH] Add MAP_DROPPABLE to syscall_parameters_restrictions.cc 5 | 6 | --- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc 7 | +++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc 8 | @@ -34,6 +34,10 @@ 9 | #include "sandbox/linux/system_headers/linux_syscalls.h" 10 | #include "sandbox/linux/system_headers/linux_time.h" 11 | 12 | +#if !defined(MAP_DROPPABLE) 13 | +#define MAP_DROPPABLE 0x08 // Zero memory under memory pressure. 14 | +#endif 15 | + 16 | #if BUILDFLAG(IS_LINUX) && !defined(__arm__) && !defined(__aarch64__) && \ 17 | !defined(PTRACE_GET_THREAD_AREA) 18 | // Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance 19 | @@ -236,7 +240,7 @@ ResultExpr RestrictMmapFlags() { 20 | // TODO(davidung), remove MAP_DENYWRITE with updated Tegra libraries. 21 | const uint64_t kAllowedMask = MAP_SHARED | MAP_PRIVATE | MAP_ANONYMOUS | 22 | MAP_STACK | MAP_NORESERVE | MAP_FIXED | 23 | - MAP_DENYWRITE | MAP_LOCKED | 24 | + MAP_DENYWRITE | MAP_LOCKED | MAP_DROPPABLE | 25 | kArchSpecificAllowedMask; 26 | const Arg flags(3); 27 | return If((flags & ~kAllowedMask) == 0, Allow()).Else(CrashSIGSYS()); 28 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-135-oauth2-client-switches.patch: -------------------------------------------------------------------------------- 1 | From d5ebfd72adff704c046170cf7ab798f5f7415dd5 Mon Sep 17 00:00:00 2001 2 | From: FoldCat 3 | Date: Tue, 4 Mar 2025 13:09:59 +0800 4 | Subject: [PATCH] work around dead oauth2 credentials, correcting the previous bad patch 5 | 6 | Google doesn't let us bake in OAuth2 credentials, and for some time, 7 | Google sign-in has been broken. Arch dealt with this in March, and so 8 | did we to some degree, but in the last few months, our sign-in 9 | credentials have been broken. It appears that we actually did remove API 10 | credentials in March around Chrome 89, but they got added back, perhaps 11 | when rotating newer versions to replace older versions. Work around this 12 | by following Arch's lead: we remove the predefined credentials, as 13 | before, but also we patch Chromium so that people can use their own 14 | easily, using Arch's patch for that. 15 | --- 16 | google_apis/api_key_cache.cc | 4 ++-- 17 | 1 file changed, 2 insertions(+), 2 deletions(-) 18 | 19 | diff --git a/google_apis/api_key_cache.cc b/google_apis/api_key_cache.cc 20 | index 55c6028248..12ccf9e358 100644 21 | --- a/google_apis/api_key_cache.cc 22 | +++ b/google_apis/api_key_cache.cc 23 | @@ -191,13 +191,13 @@ ApiKeyCache::ApiKeyCache(const DefaultApiKeys& default_api_keys) { 24 | 25 | std::string default_client_id = CalculateKeyValue( 26 | default_api_keys.google_default_client_id, 27 | - STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), nullptr, std::string(), 28 | + STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_ID), ::switches::kOAuth2ClientID, std::string(), 29 | environment.get(), command_line, gaia_config, 30 | default_api_keys.allow_override_via_environment, 31 | default_api_keys.allow_unset_values); 32 | std::string default_client_secret = CalculateKeyValue( 33 | default_api_keys.google_default_client_secret, 34 | - STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), nullptr, 35 | + STRINGIZE_NO_EXPANSION(GOOGLE_DEFAULT_CLIENT_SECRET), ::switches::kOAuth2ClientSecret, 36 | std::string(), environment.get(), command_line, gaia_config, 37 | default_api_keys.allow_override_via_environment, 38 | default_api_keys.allow_unset_values); 39 | -- 40 | 2.45.3 41 | 42 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-135-webrtc-pipewire.patch: -------------------------------------------------------------------------------- 1 | https://webrtc.googlesource.com/src/+/0a9787897f3d36055130b0532967d31c31e8408f 2 | 3 | Pipewire 1.4 changed some functions from taking void* 4 | to taking the actual type they expect, which makes 5 | some code that built with 1.2 no longer build with 1.4. 6 | 7 | For older versions, this is effectively a no-op. 8 | 9 | --- a/third_party/webrtc/modules/video_capture/linux/pipewire_session.cc 10 | +++ b/third_party/webrtc/modules/video_capture/linux/pipewire_session.cc 11 | 12 | @@ -87,7 +87,7 @@ 13 | .param = OnNodeParam, 14 | }; 15 | 16 | - pw_node_add_listener(proxy_, &node_listener_, &node_events, this); 17 | + pw_node_add_listener(reinterpret_cast(proxy_), &node_listener_, &node_events, this); 18 | } 19 | 20 | // static 21 | @@ -119,7 +119,7 @@ 22 | uint32_t id = info->params[i].id; 23 | if (id == SPA_PARAM_EnumFormat && 24 | info->params[i].flags & SPA_PARAM_INFO_READ) { 25 | - pw_node_enum_params(that->proxy_, 0, id, 0, UINT32_MAX, nullptr); 26 | + pw_node_enum_params(reinterpret_cast(that->proxy_), 0, id, 0, UINT32_MAX, nullptr); 27 | break; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-136-drop-nodejs-ver-check.patch: -------------------------------------------------------------------------------- 1 | From 3e06125358a050cc6535befd4fbd5b4f160a56b9 Mon Sep 17 00:00:00 2001 2 | From: Matt Jolly 3 | Date: Tue, 25 Mar 2025 13:33:48 +1000 4 | Subject: [PATCH] Remove nodejs version check 5 | 6 | Added in https://github.com/chromium/chromium/commit/0ff8528999941d7182be6fc77aeb12a110a3cd86, 7 | this change is only really useful for gclient checkouts and breaks the 8 | ability for downstreams to provide their own, compatible, nodejs 9 | version via the system package manager (or for use on arches other than 10 | those that Google provides binaries for): 11 | 12 | [ERR_ASSERTION]: Failed NodeJS version check: Expected version 'v22.11.0', but found 'v22.13.1'. Did you run 'gclient sync' 13 | 14 | This is google development footgun protection, working around 15 | poor development practices and gclient's inability to ensure 16 | that the source tree is in a consistent state. We don't need it 17 | here. 18 | 19 | Signed-off-by: Matt Jolly 20 | --- a/third_party/node/node.gni 21 | +++ b/third_party/node/node.gni 22 | @@ -36,15 +36,5 @@ template("node") { 23 | } 24 | } 25 | 26 | - # Automatically add a dependency to ":check_version" to ensure NodeJS is 27 | - # always running the expected version, except when the ':check_version' 28 | - # target itself is running in which case it shouldn't depend on itself. 29 | - if (get_label_info(":" + target_name, "label_no_toolchain") != 30 | - "//third_party/node:check_version") { 31 | - if (!defined(deps)) { 32 | - deps = [] 33 | - } 34 | - deps += [ "//third_party/node:check_version" ] 35 | - } 36 | } 37 | } 38 | -- 39 | 2.48.1 40 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-137-openh264-include-path.patch: -------------------------------------------------------------------------------- 1 | https://chromium-review.googlesource.com/c/chromium/src/+/6554344 2 | From: Matt Jolly 3 | Date: Sat, 17 May 2025 09:01:22 +1000 4 | Subject: [PATCH] make openh264:encoder a public dep 5 | 6 | since M137 (1cc4ddb51296d65544070e42bfea8462e3f16715), the unbundle 7 | path has had consistent build failures in 8 | `third_party/blink/renderer/modules/mediarecorder` due to the 9 | include path for openh264 not being set. 10 | 11 | The include path for openh264 should should come from `media/video` 12 | if proprietary codecs (and openh264) is enabled. a `public_deps` 13 | should handle this. 14 | 15 | Signed-off-by: Matt Jolly 16 | --- a/media/video/BUILD.gn 17 | +++ b/media/video/BUILD.gn 18 | @@ -78,7 +78,7 @@ source_set("video") { 19 | "openh264_video_encoder.cc", 20 | "openh264_video_encoder.h", 21 | ] 22 | - deps += [ "//third_party/openh264:encoder" ] 23 | + public_deps += [ "//third_party/openh264:encoder" ] 24 | } 25 | 26 | if (is_apple) { 27 | -- 28 | 2.49.0 29 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-137-pdfium-system-libpng.patch: -------------------------------------------------------------------------------- 1 | https://pdfium-review.googlesource.com/c/pdfium/+/132130 2 | From: Matt Jolly 3 | Date: Fri, 16 May 2025 14:38:04 +1000 4 | Subject: [PATCH] Fix build with system libpng 5 | 6 | `cbc692a42241970e1da492d5b14326e81ecb1061` refactored 7 | `fxcodec::CFX_DIBAttribute` and changed the name of its members. 8 | 9 | Unfortunately this change appears to have been typo'd in the 10 | 'system libpng' build path, which is not checked by CI, resulting 11 | in downstream build failures in Chromium. 12 | 13 | Signed-off-by: Matt Jolly 14 | --- a/third_party/pdfium/core/fxcodec/png/png_decoder.cpp 15 | +++ b/third_party/pdfium/core/fxcodec/png/png_decoder.cpp 16 | @@ -52,8 +52,8 @@ void _png_load_bmp_attribute(png_structp png_ptr, 17 | CFX_DIBAttribute* pAttribute) { 18 | if (pAttribute) { 19 | #if defined(PNG_pHYs_SUPPORTED) 20 | - pAttribute->xdpi_ = png_get_x_pixels_per_meter(png_ptr, info_ptr); 21 | - pAttribute->ydpi_ = png_get_y_pixels_per_meter(png_ptr, info_ptr); 22 | + pAttribute->x_dpi_ = png_get_x_pixels_per_meter(png_ptr, info_ptr); 23 | + pAttribute->y_dpi_ = png_get_y_pixels_per_meter(png_ptr, info_ptr); 24 | png_uint_32 res_x, res_y; 25 | int unit_type; 26 | png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type); 27 | -- 28 | 2.49.0 29 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-browser.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Chromium 7 | chromium-browser 8 | chromium-browser %s 9 | chromium-browser 10 | false 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-cross-compile.patch: -------------------------------------------------------------------------------- 1 | --- a/build/toolchain/linux/unbundle/BUILD.gn 2 | +++ b/build/toolchain/linux/unbundle/BUILD.gn 3 | @@ -35,7 +35,7 @@ gcc_toolchain("host") { 4 | extra_ldflags = getenv("BUILD_LDFLAGS") 5 | 6 | toolchain_args = { 7 | - current_cpu = current_cpu 8 | - current_os = current_os 9 | + current_cpu = host_cpu 10 | + current_os = host_os 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium-launcher-r7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Allow the user to override command-line flags, bug #357629. 4 | # This is based on Debian's chromium-browser package, and is intended 5 | # to be consistent with Debian. 6 | for f in /etc/chromium/*; do 7 | [[ -f ${f} ]] && source "${f}" 8 | done 9 | 10 | # Prefer user defined CHROMIUM_USER_FLAGS (from env) over system 11 | # default CHROMIUM_FLAGS (from /etc/chromium/default). 12 | CHROMIUM_FLAGS=${CHROMIUM_USER_FLAGS:-"$CHROMIUM_FLAGS"} 13 | 14 | # Let the wrapped binary know that it has been run through the wrapper 15 | export CHROME_WRAPPER=$(readlink -f "$0") 16 | 17 | PROGDIR=${CHROME_WRAPPER%/*} 18 | 19 | case ":$PATH:" in 20 | *:$PROGDIR:*) 21 | # $PATH already contains $PROGDIR 22 | ;; 23 | *) 24 | # Append $PROGDIR to $PATH 25 | export PATH="$PATH:$PROGDIR" 26 | ;; 27 | esac 28 | 29 | if [[ ${EUID} == 0 && -O ${XDG_CONFIG_HOME:-${HOME}} ]]; then 30 | # Running as root with HOME owned by root. 31 | # Pass --user-data-dir to work around upstream failsafe. 32 | CHROMIUM_FLAGS="--user-data-dir=${XDG_CONFIG_HOME:-${HOME}/.config}/chromium 33 | ${CHROMIUM_FLAGS}" 34 | fi 35 | 36 | # Select session type and platform 37 | if @@OZONE_AUTO_SESSION@@; then 38 | platform= 39 | if [[ ${XDG_SESSION_TYPE} == x11 ]]; then 40 | platform=x11 41 | elif [[ ${XDG_SESSION_TYPE} == wayland ]]; then 42 | platform=wayland 43 | else 44 | if [[ -n ${WAYLAND_DISPLAY} ]]; then 45 | platform=wayland 46 | else 47 | platform=x11 48 | fi 49 | fi 50 | if ${DISABLE_OZONE_PLATFORM:-false}; then 51 | platform=x11 52 | fi 53 | CHROMIUM_FLAGS="--ozone-platform=${platform} ${CHROMIUM_FLAGS}" 54 | fi 55 | 56 | # Set the .desktop file name 57 | export CHROME_DESKTOP="chromium-browser-chromium.desktop" 58 | 59 | exec -a "chromium-browser" "$PROGDIR/chrome" --extra-plugin-dir=/usr/lib/nsbrowser/plugins ${CHROMIUM_FLAGS} "$@" 60 | -------------------------------------------------------------------------------- /www-client/chromium/files/chromium.default: -------------------------------------------------------------------------------- 1 | # Default settings for chromium. This file is sourced by /bin/bash from 2 | # the chromium launcher. 3 | 4 | # Options to pass to chromium. 5 | #CHROMIUM_FLAGS="" 6 | -------------------------------------------------------------------------------- /www-client/chromium/files/compiler-rt-riscv.patch: -------------------------------------------------------------------------------- 1 | --- a/build/config/clang/BUILD.gn 2024-09-17 09:40:39.225707556 +0200 2 | +++ b/build/config/clang/BUILD.gn 2024-09-17 09:42:35.703531635 +0200 3 | @@ -186,6 +186,9 @@ 4 | } else if (current_cpu == "arm64") { 5 | _dir = "aarch64-unknown-linux-gnu" 6 | _suffix = "-aarch64" 7 | + } else if (current_cpu == "riscv64") { 8 | + _dir = "riscv64-unknown-linux-gnu" 9 | + _suffix = "-riscv64" 10 | } else { 11 | assert(false) # Unhandled cpu type 12 | } 13 | @@ -201,6 +201,8 @@ 14 | _dir = "armv7-unknown-linux-gnueabihf" 15 | } else if (current_cpu == "arm64") { 16 | _dir = "aarch64-unknown-linux-gnu" 17 | + } else if (current_cpu == "riscv64") { 18 | + _dir = "riscv64-unknown-linux-gnu" 19 | } else { 20 | assert(false) # Unhandled cpu type 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /www-client/chromium/files/cpuinfo.patch: -------------------------------------------------------------------------------- 1 | Index: chromium-129.0.6668.58/third_party/cpuinfo/BUILD.gn 2 | =================================================================== 3 | --- chromium-129.0.6668.58.orig/third_party/cpuinfo/BUILD.gn 4 | +++ chromium-129.0.6668.58/third_party/cpuinfo/BUILD.gn 5 | @@ -105,6 +105,12 @@ source_set("cpu_specific") { 6 | ] 7 | } 8 | 9 | + if (current_cpu == "riscv64") { 10 | + sources = [ 11 | + "src/src/riscv/uarch.c", 12 | + ] 13 | + } 14 | + 15 | # Because "init.c" is reused again, but only has sources in the corresponding 16 | # build config. 17 | deps = [ ":x86_cache" ] 18 | @@ -191,6 +197,14 @@ source_set("cpu_and_os_specific") { 19 | } 20 | } 21 | 22 | + if (is_linux && current_cpu == "riscv64") { 23 | + sources = [ 24 | + "src/src/riscv/linux/init.c", 25 | + "src/src/riscv/linux/riscv-hw.c", 26 | + "src/src/riscv/linux/riscv-isa.c", 27 | + ] 28 | + } 29 | + 30 | if (is_android && (current_cpu == "x86" || current_cpu == "x64")) { 31 | sources = [ 32 | "src/src/x86/linux/cpuinfo.c", 33 | 34 | -------------------------------------------------------------------------------- /www-client/chromium/files/esbuild: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gentoo/riscv/0d33bbaa05e417d600637a9c3221f354f0b84741/www-client/chromium/files/esbuild -------------------------------------------------------------------------------- /www-client/chromium/files/fix-build-with-pipewire-1.3.82.patch: -------------------------------------------------------------------------------- 1 | Index: chromium-133.0.6943.98/third_party/webrtc/modules/video_capture/linux/pipewire_session.cc 2 | =================================================================== 3 | --- chromium-133.0.6943.98.orig/third_party/webrtc/modules/video_capture/linux/pipewire_session.cc 4 | +++ chromium-133.0.6943.98/third_party/webrtc/modules/video_capture/linux/pipewire_session.cc 5 | @@ -87,7 +87,7 @@ PipeWireNode::PipeWireNode(PipeWireSessi 6 | .param = OnNodeParam, 7 | }; 8 | 9 | - pw_node_add_listener(proxy_, &node_listener_, &node_events, this); 10 | + pw_node_add_listener(reinterpret_cast(proxy_), &node_listener_, &node_events, this); 11 | } 12 | 13 | // static 14 | @@ -119,7 +119,7 @@ void PipeWireNode::OnNodeInfo(void* data 15 | uint32_t id = info->params[i].id; 16 | if (id == SPA_PARAM_EnumFormat && 17 | info->params[i].flags & SPA_PARAM_INFO_READ) { 18 | - pw_node_enum_params(that->proxy_, 0, id, 0, UINT32_MAX, nullptr); 19 | + pw_node_enum_params(reinterpret_cast(that->proxy_), 0, id, 0, UINT32_MAX, nullptr); 20 | break; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /www-client/chromium/files/libstdc++-fixup.patch: -------------------------------------------------------------------------------- 1 | ndex: chromium-134.0.6998.35/chrome/browser/ui/lens/lens_overlay_request_id_generator.h 2 | =================================================================== 3 | --- chromium-134.0.6998.35.orig/chrome/browser/ui/lens/lens_overlay_request_id_generator.h 4 | +++ chromium-134.0.6998.35/chrome/browser/ui/lens/lens_overlay_request_id_generator.h 5 | @@ -5,6 +5,8 @@ 6 | #ifndef CHROME_BROWSER_UI_LENS_LENS_OVERLAY_REQUEST_ID_GENERATOR_H_ 7 | #define CHROME_BROWSER_UI_LENS_LENS_OVERLAY_REQUEST_ID_GENERATOR_H_ 8 | 9 | +#include 10 | + 11 | #include "third_party/lens_server_proto/lens_overlay_routing_info.pb.h" 12 | #include "third_party/lens_server_proto/lens_overlay_server.pb.h" 13 | #include "third_party/lens_server_proto/lens_overlay_service_deps.pb.h" 14 | Index: chromium-134.0.6998.35/components/payments/content/payment_method_manifest_table.h 15 | =================================================================== 16 | --- chromium-134.0.6998.35.orig/components/payments/content/payment_method_manifest_table.h 17 | +++ chromium-134.0.6998.35/components/payments/content/payment_method_manifest_table.h 18 | @@ -6,6 +6,7 @@ 19 | #define COMPONENTS_PAYMENTS_CONTENT_PAYMENT_METHOD_MANIFEST_TABLE_H_ 20 | 21 | #include 22 | +#include 23 | #include 24 | #include 25 | 26 | Index: chromium-134.0.6998.35/components/viz/service/display/surface_aggregator.h 27 | =================================================================== 28 | --- chromium-134.0.6998.35.orig/components/viz/service/display/surface_aggregator.h 29 | +++ chromium-134.0.6998.35/components/viz/service/display/surface_aggregator.h 30 | @@ -132,13 +132,18 @@ class VIZ_SERVICE_EXPORT SurfaceAggregat 31 | struct PrewalkResult; 32 | 33 | struct AggregateStatistics { 34 | - int prewalked_surface_count = 0; 35 | - int copied_surface_count = 0; 36 | + AggregateStatistics() 37 | + : prewalked_surface_count(0), 38 | + copied_surface_count(0), 39 | + has_pixel_moving_filter(false), 40 | + has_unembedded_pass(false) {} 41 | + int prewalked_surface_count; 42 | + int copied_surface_count; 43 | // True if the current frame contains a pixel-moving foreground filter 44 | // render pass. 45 | - bool has_pixel_moving_filter = false; 46 | + bool has_pixel_moving_filter; 47 | // True if the current frame contains a unembedded render pass. 48 | - bool has_unembedded_pass = false; 49 | + bool has_unembedded_pass; 50 | 51 | base::TimeDelta prewalk_time; 52 | base::TimeDelta copy_time; 53 | Index: chromium-134.0.6998.35/mojo/public/cpp/bindings/lib/multiplex_router.h 54 | =================================================================== 55 | --- chromium-134.0.6998.35.orig/mojo/public/cpp/bindings/lib/multiplex_router.h 56 | +++ chromium-134.0.6998.35/mojo/public/cpp/bindings/lib/multiplex_router.h 57 | @@ -315,8 +315,9 @@ class COMPONENT_EXPORT(MOJO_CPP_BINDINGS 58 | // are not managed by the MultiplexRouter and thus are not relevant here. 59 | struct ExclusiveSyncWaitInfo { 60 | InterfaceId interface_id = kInvalidInterfaceId; 61 | - uint64_t request_id = 0; 62 | - bool finished = false; 63 | + uint64_t request_id; 64 | + bool finished; 65 | + ExclusiveSyncWaitInfo() : request_id(0), finished(false) {} 66 | }; 67 | std::optional exclusive_sync_wait_; 68 | 69 | Index: chromium-134.0.6998.35/third_party/blink/renderer/core/layout/inline/line_breaker.h 70 | =================================================================== 71 | --- chromium-134.0.6998.35.orig/third_party/blink/renderer/core/layout/inline/line_breaker.h 72 | +++ chromium-134.0.6998.35/third_party/blink/renderer/core/layout/inline/line_breaker.h 73 | @@ -451,9 +451,12 @@ class CORE_EXPORT LineBreaker { 74 | STACK_ALLOCATED(); 75 | 76 | public: 77 | - InlineItemResults* item_results = nullptr; 78 | - wtf_size_t item_result_index = WTF::kNotFound; 79 | - const ShapeResultView* collapsed_shape_result = nullptr; 80 | + TrailingCollapsibleSpace() 81 | + : item_results(nullptr), item_result_index(WTF::kNotFound), 82 | + collapsed_shape_result(nullptr) {} 83 | + InlineItemResults* item_results; 84 | + wtf_size_t item_result_index; 85 | + const ShapeResultView* collapsed_shape_result; 86 | // Ancestors of `item_result`. ancestor_ruby_columns[0] is the parent of 87 | // `item_result`, and ancestor_ruby_columns[n+1] is the parent of 88 | // ancestor_ruby_columns[n]. This list is empty if `item_result` is not 89 | Index: chromium-134.0.6998.35/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h 90 | =================================================================== 91 | --- chromium-134.0.6998.35.orig/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h 92 | +++ chromium-134.0.6998.35/third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h 93 | @@ -890,8 +890,9 @@ class CORE_EXPORT PaintLayerScrollableAr 94 | 95 | struct PendingViewState { 96 | HistoryItem::ViewState state; 97 | - mojom::blink::ScrollBehavior scroll_behavior = 98 | - mojom::blink::ScrollBehavior::kAuto; 99 | + mojom::blink::ScrollBehavior scroll_behavior; 100 | + PendingViewState() 101 | + : scroll_behavior(mojom::blink::ScrollBehavior::kAuto) {} 102 | }; 103 | std::optional pending_view_state_; 104 | }; 105 | Index: chromium-134.0.6998.35/third_party/blink/renderer/modules/media_controls/elements/media_control_timeline_element.h 106 | =================================================================== 107 | --- chromium-134.0.6998.35.orig/third_party/blink/renderer/modules/media_controls/elements/media_control_timeline_element.h 108 | +++ chromium-134.0.6998.35/third_party/blink/renderer/modules/media_controls/elements/media_control_timeline_element.h 109 | @@ -51,7 +51,8 @@ class MediaControlTimelineElement : publ 110 | // Struct used to track the current live time. 111 | struct LiveAnchorTime { 112 | base::TimeTicks clock_time_; 113 | - double media_time_ = 0; 114 | + double media_time_; 115 | + LiveAnchorTime() : media_time_(0) {} 116 | }; 117 | 118 | void DefaultEventHandler(Event&) override; 119 | Index: chromium-134.0.6998.35/third_party/webrtc/call/rtp_config.h 120 | =================================================================== 121 | --- chromium-134.0.6998.35.orig/third_party/webrtc/call/rtp_config.h 122 | +++ chromium-134.0.6998.35/third_party/webrtc/call/rtp_config.h 123 | @@ -79,10 +79,12 @@ struct RtpStreamConfig { 124 | struct Rtx { 125 | std::string ToString() const; 126 | // SSRC to use for the RTX stream. 127 | - uint32_t ssrc = 0; 128 | + uint32_t ssrc; 129 | 130 | // Payload type to use for the RTX stream. 131 | - int payload_type = -1; 132 | + int payload_type; 133 | + 134 | + Rtx() : ssrc(0), payload_type(-1) {} 135 | }; 136 | std::optional rtx; 137 | }; 138 | 139 | -------------------------------------------------------------------------------- /www-client/chromium/files/riscv-dav1d.patch: -------------------------------------------------------------------------------- 1 | Index: chromium-113.0.5672.92/third_party/dav1d/config/linux/riscv64/config.h 2 | =================================================================== 3 | --- /dev/null 4 | +++ chromium-113.0.5672.92/third_party/dav1d/config/linux/riscv64/config.h 5 | @@ -0,0 +1,48 @@ 6 | +/* 7 | + * Autogenerated by the Meson build system. 8 | + * Do not edit, your changes will be lost. 9 | + */ 10 | + 11 | +#pragma once 12 | + 13 | +#define ARCH_AARCH64 0 14 | + 15 | +#define ARCH_ARM 0 16 | + 17 | +#define ARCH_PPC64LE 0 18 | + 19 | +#define ARCH_X86 0 20 | + 21 | +#define ARCH_X86_32 0 22 | + 23 | +#define ARCH_X86_64 0 24 | + 25 | +#define CONFIG_16BPC 1 26 | + 27 | +#define CONFIG_8BPC 1 28 | + 29 | +// #define CONFIG_LOG 1 -- Logging is controlled by Chromium 30 | + 31 | +#define ENDIANNESS_BIG 0 32 | + 33 | +#define HAVE_ASM 0 34 | + 35 | +#define HAVE_AS_FUNC 0 36 | + 37 | +#define HAVE_C11_GENERIC 1 38 | + 39 | +#define HAVE_CLOCK_GETTIME 1 40 | + 41 | +#define HAVE_DLSYM 1 42 | + 43 | +#define HAVE_GETAUXVAL 1 44 | + 45 | +#define HAVE_POSIX_MEMALIGN 1 46 | + 47 | +// #define HAVE_PTHREAD_GETAFFINITY_NP 1 -- Controlled by Chomium 48 | + 49 | +// #define HAVE_PTHREAD_SETAFFINITY_NP 1 -- Controlled by Chomium 50 | + 51 | +#define HAVE_UNISTD_H 1 52 | + 53 | +#define TRIM_DSP_FUNCTIONS 1 54 | -------------------------------------------------------------------------------- /www-client/chromium/files/riscv-highway.patch: -------------------------------------------------------------------------------- 1 | Index: chromium-136.0.7103.92/third_party/highway/BUILD.gn 2 | =================================================================== 3 | --- chromium-136.0.7103.92.orig/third_party/highway/BUILD.gn 4 | +++ chromium-136.0.7103.92/third_party/highway/BUILD.gn 5 | @@ -21,6 +21,9 @@ config("libhwy_external_config") { 6 | # for absl::uint128 is 16. 7 | defines += [ "HWY_BROKEN_TARGETS=HWY_ALL_SVE" ] 8 | } 9 | + if (target_cpu == "riscv64") { 10 | + defines += [ "HWY_BROKEN_TARGETS=HWY_RVV" ] 11 | + } 12 | } 13 | 14 | source_set("libhwy") { 15 | 16 | -------------------------------------------------------------------------------- /www-client/chromium/files/riscv-misc.patch: -------------------------------------------------------------------------------- 1 | Index: chromium-135.0.7049.52/components/metrics/debug/metrics_internals_utils.cc 2 | =================================================================== 3 | --- chromium-135.0.7049.52.orig/components/metrics/debug/metrics_internals_utils.cc 4 | +++ chromium-135.0.7049.52/components/metrics/debug/metrics_internals_utils.cc 5 | @@ -69,6 +69,8 @@ std::string CpuArchitectureToString( 6 | return "arm32"; 7 | case variations::Study::TRANSLATED_X86_64: 8 | return "translated_x86_64"; 9 | + case variations::Study::RISCV64: 10 | + return "riscv64"; 11 | } 12 | NOTREACHED(); 13 | } 14 | Index: chromium-135.0.7049.52/components/variations/proto/study.proto 15 | =================================================================== 16 | --- chromium-135.0.7049.52.orig/components/variations/proto/study.proto 17 | +++ chromium-135.0.7049.52/components/variations/proto/study.proto 18 | @@ -262,6 +262,8 @@ message Study { 19 | // A Mac-only value, indicating an x86-64 binary running on an arm64 host 20 | // via "Rosetta 2" binary translation. 21 | TRANSLATED_X86_64 = 4; 22 | + 23 | + RISCV64 = 5; 24 | } 25 | 26 | // Enum to pass as optional bool. 27 | Index: chromium-135.0.7049.52/components/variations/service/variations_field_trial_creator_base.cc 28 | =================================================================== 29 | --- chromium-135.0.7049.52.orig/components/variations/service/variations_field_trial_creator_base.cc 30 | +++ chromium-135.0.7049.52/components/variations/service/variations_field_trial_creator_base.cc 31 | @@ -128,6 +128,9 @@ Study::CpuArchitecture GetCurrentCpuArch 32 | } 33 | return Study::X86_64; 34 | } 35 | + if (process_arch == "RISCV_64") { 36 | + return Study::RISCV64; 37 | + } 38 | NOTREACHED(); 39 | } 40 | 41 | 42 | -------------------------------------------------------------------------------- /www-client/chromium/files/riscv-swiftshader.patch: -------------------------------------------------------------------------------- 1 | Index: chromium-135.0.7049.52/third_party/swiftshader/src/Reactor/BUILD.gn 2 | =================================================================== 3 | --- chromium-135.0.7049.52.orig/third_party/swiftshader/src/Reactor/BUILD.gn 4 | +++ chromium-135.0.7049.52/third_party/swiftshader/src/Reactor/BUILD.gn 5 | @@ -307,7 +307,7 @@ if (supports_subzero) { 6 | 7 | if (supports_llvm) { 8 | swiftshader_source_set("swiftshader_llvm_reactor") { 9 | - llvm_dir = "../../third_party/llvm-10.0" 10 | + llvm_dir = "../../third_party/llvm-16.0" 11 | 12 | deps = [ 13 | ":swiftshader_reactor_base", 14 | Index: chromium-135.0.7049.52/third_party/swiftshader/third_party/llvm-16.0/BUILD.gn 15 | =================================================================== 16 | --- chromium-135.0.7049.52.orig/third_party/swiftshader/third_party/llvm-16.0/BUILD.gn 17 | +++ chromium-135.0.7049.52/third_party/swiftshader/third_party/llvm-16.0/BUILD.gn 18 | @@ -778,6 +778,7 @@ swiftshader_llvm_source_set("swiftshader 19 | "llvm/lib/MC/MCContext.cpp", 20 | "llvm/lib/MC/MCDXContainerStreamer.cpp", 21 | "llvm/lib/MC/MCDXContainerWriter.cpp", 22 | + "llvm/lib/MC/MCDisassembler/MCDisassembler.cpp", 23 | "llvm/lib/MC/MCDisassembler/MCRelocationInfo.cpp", 24 | "llvm/lib/MC/MCDwarf.cpp", 25 | "llvm/lib/MC/MCELFObjectTargetWriter.cpp", 26 | 27 | -------------------------------------------------------------------------------- /www-client/chromium/files/riscv-v8.patch: -------------------------------------------------------------------------------- 1 | ndex: chromium-136.0.7103.92/v8/gni/v8.gni 2 | =================================================================== 3 | --- chromium-136.0.7103.92.orig/v8/gni/v8.gni 4 | +++ chromium-136.0.7103.92/v8/gni/v8.gni 5 | @@ -233,7 +233,7 @@ assert(!(v8_enable_webassembly && v8_ena 6 | if (v8_enable_pointer_compression == "") { 7 | v8_enable_pointer_compression = 8 | v8_current_cpu == "arm64" || v8_current_cpu == "x64" || 9 | - v8_current_cpu == "loong64" 10 | + v8_current_cpu == "loong64" || v8_current_cpu == "riscv64" 11 | } 12 | 13 | # The Wasm interpreter is currently supported only on arm64 and x64, on 14 | Index: chromium-136.0.7103.92/v8/src/codegen/riscv/assembler-riscv-inl.h 15 | =================================================================== 16 | --- chromium-136.0.7103.92.orig/v8/src/codegen/riscv/assembler-riscv-inl.h 17 | +++ chromium-136.0.7103.92/v8/src/codegen/riscv/assembler-riscv-inl.h 18 | @@ -115,8 +115,9 @@ void Assembler::set_target_compressed_ad 19 | Address pc, Address constant_pool, Tagged_t target, 20 | WritableJitAllocation* jit_allocation, ICacheFlushMode icache_flush_mode) { 21 | if (COMPRESS_POINTERS_BOOL) { 22 | - Assembler::set_uint32_constant_at(pc, constant_pool, target, jit_allocation, 23 | - icache_flush_mode); 24 | + Assembler::set_uint32_constant_at(pc, constant_pool, 25 | + static_cast(target), 26 | + jit_allocation, icache_flush_mode); 27 | } else { 28 | UNREACHABLE(); 29 | } 30 | Index: chromium-136.0.7103.92/v8/src/execution/riscv/simulator-riscv.h 31 | =================================================================== 32 | --- chromium-136.0.7103.92.orig/v8/src/execution/riscv/simulator-riscv.h 33 | +++ chromium-136.0.7103.92/v8/src/execution/riscv/simulator-riscv.h 34 | @@ -538,6 +538,7 @@ class Simulator : public SimulatorBase { 35 | // Return central stack view, without additional safety margins. 36 | // Users, for example wasm::StackMemory, can add their own. 37 | base::Vector GetCentralStackView() const; 38 | + static constexpr int JSStackLimitMargin() { return kAdditionalStackMargin; } 39 | 40 | void IterateRegistersAndStack(::heap::base::StackVisitor* visitor); 41 | 42 | Index: chromium-136.0.7103.92/v8/src/maglev/riscv/maglev-ir-riscv.cc 43 | =================================================================== 44 | --- chromium-136.0.7103.92.orig/v8/src/maglev/riscv/maglev-ir-riscv.cc 45 | +++ chromium-136.0.7103.92/v8/src/maglev/riscv/maglev-ir-riscv.cc 46 | @@ -224,6 +224,40 @@ void CheckedIntPtrToInt32::GenerateCode( 47 | Operand(std::numeric_limits::min())); 48 | } 49 | 50 | +void CheckFloat64SameValue::SetValueLocationConstraints() { 51 | + UseRegister(target_input()); 52 | + // We need two because LoadFPRImmediate needs to acquire one as well in the 53 | + // case where value() is not 0.0 or -0.0. 54 | + set_temporaries_needed((value().get_scalar() == 0) ? 1 : 2); 55 | + set_double_temporaries_needed( 56 | + value().is_nan() || (value().get_scalar() == 0) ? 0 : 1); 57 | +} 58 | + 59 | +void CheckFloat64SameValue::GenerateCode(MaglevAssembler* masm, 60 | + const ProcessingState& state) { 61 | + Label* fail = __ GetDeoptLabel(this, deoptimize_reason()); 62 | + MaglevAssembler::TemporaryRegisterScope temps(masm); 63 | + DoubleRegister target = ToDoubleRegister(target_input()); 64 | + if (value().is_nan()) { 65 | + __ JumpIfNotNan(target, fail); 66 | + } else { 67 | + DoubleRegister double_scratch = temps.AcquireScratchDouble(); 68 | + Register scratch = temps.AcquireScratch(); 69 | + __ Move(double_scratch, value().get_scalar()); 70 | + __ CompareF64(scratch, EQ, double_scratch, target); 71 | + __ BranchFalseF(scratch, fail); 72 | + if (value().get_scalar() == 0) { // +0.0 or -0.0. 73 | + __ MacroAssembler::Move(scratch, target); 74 | + __ And(scratch, scratch, Operand(1ULL << 63)); 75 | + if (value().get_bits() == 0) { 76 | + __ BranchTrueF(scratch, fail); 77 | + } else { 78 | + __ BranchFalseF(scratch, fail); 79 | + } 80 | + } 81 | + } 82 | +} 83 | + 84 | void Int32AddWithOverflow::SetValueLocationConstraints() { 85 | UseRegister(left_input()); 86 | UseRegister(right_input()); 87 | 88 | -------------------------------------------------------------------------------- /www-client/chromium/metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | chromium@gentoo.org 6 | Chromium in Gentoo Project 7 | 8 | 9 | kangie@gentoo.org 10 | Matt Jolly 11 | 12 | 13 | Download and use the upstream binary toolchain(s) to build Chromium 14 | Enable DCHECK feature with severity configurable at runtime. Mostly intended for debugging and development, NOT RECOMMENDED for general use. 15 | (binpkg only) Use Chromium FFmpeg fork (media-video/ffmpeg-chromium) rather than mainline FFmpeg (media-video/ffmpeg) 16 | Build with GTK4 headers. 17 | Enable support for Google Hangouts features such as screen sharing 18 | Build Ozone only with headless backend, NOT RECOMMENDED for general use. 19 | Enable Official build instead of Developer build. 20 | Allow building on a PaX-enabled kernel 21 | Build with Profile Guided Optimizations (2-stage compilation) 22 | Enable codecs for patent-encumbered audio and video formats. 23 | Use system media-libs/harfbuzz instead of the bundled library. 24 | Use system dev-libs/icu instead of the bundled one 25 | Use system media-libs/libpng instead of the bundled library 26 | Use system app-arch/zstd instead of the bundled one. 27 | Unsupported closed-source DRM capability (required by Netflix VOD) 28 | 29 | 30 | chromium/chromium 31 | Matt.Jolly/chromium-patches 32 | 33 | 34 | --------------------------------------------------------------------------------