diff options
-rw-r--r-- | .SRCINFO | 32 | ||||
-rw-r--r-- | PKGBUILD | 158 | ||||
-rwxr-xr-x | choose-gcc-optimization.sh | 191 | ||||
-rw-r--r-- | disable-per-VMA_v4_1.patch | 118 | ||||
-rw-r--r-- | disable-per-VMA_v4_2.patch | 75 |
5 files changed, 406 insertions, 168 deletions
@@ -1,37 +1,45 @@ pkgbase = linux-xanmod-anbox - pkgdesc = Linux Xanmod with ashmem and binder enabled for Anbox - Current Stable (STABLE) - pkgver = 5.14.20 + pkgdesc = Linux Xanmod with ashmem and binder enabled for Anbox - Stable Mainline [MAIN] + pkgver = 6.8.9 pkgrel = 1 url = http://www.xanmod.org/ arch = x86_64 license = GPL2 makedepends = bc makedepends = cpio - makedepends = kmod + makedepends = gettext makedepends = libelf + makedepends = pahole makedepends = perl + makedepends = python makedepends = tar makedepends = xz options = !strip - source = https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.tar.xz - source = https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.tar.sign - source = https://github.com/xanmod/linux/releases/download/5.14.20-xanmod1/patch-5.14.20-xanmod1.xz + source = https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.8.tar.xz + source = https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.8.tar.sign + source = patch-6.8.9-xanmod1.xz::https://sourceforge.net/projects/xanmod/files/releases/main/6.8.9-xanmod1/patch-6.8.9-xanmod1.xz/download source = choose-gcc-optimization.sh validpgpkeys = ABAF11C65A2970B130ABE3C479BE3E4300411886 validpgpkeys = 647F28654894E3BD457199BE38DBBDC86092693E - sha256sums = 7e068b5e0d26a62b10e5320b25dce57588cbbc6f781c090442138c9c9c3271b2 + sha256sums = c969dea4e8bb6be991bbf7c010ba0e0a5643a3a8d8fb0a2aaa053406f1e965f3 sha256sums = SKIP - sha256sums = d55cc1215f637d853721adff37f919a4a4f601a61c2fba9c0f5d0c70d3a003bd - sha256sums = 1ac18cad2578df4a70f9346f7c6fccbb62f042a0ee0594817fdef9f2704904ee + sha256sums = 59556cb5c51d70141200ac0d8d8d2b240601e77549e22034e7166451e0c6f9f1 + sha256sums = a8b38eb482eb685944757182c4886404abc12703e5e56ec39c7d61298d17d71f pkgname = linux-xanmod-anbox pkgdesc = The Linux kernel and modules with Xanmod patches and ashmem and binder enabled depends = coreutils - depends = kmod depends = initramfs - optdepends = crda: to set the correct wireless channels of your country + depends = kmod + optdepends = wireless-regdb: to set the correct wireless channels of your country optdepends = linux-firmware: firmware images needed for some devices + provides = KSMBD-MODULE + provides = VIRTUALBOX-GUEST-MODULES + provides = WIREGUARD-MODULE + provides = NTFS3-MODULE + replaces = virtualbox-guest-modules-arch + replaces = wireguard-arch pkgname = linux-xanmod-anbox-headers - pkgdesc = Headers and scripts for building modules for the Linux Xanmod with ashmem and binder enabled for Anbox - Current Stable (STABLE) kernel + pkgdesc = Headers and scripts for building modules for the Linux Xanmod with ashmem and binder enabled for Anbox - Stable Mainline [MAIN] kernel depends = pahole @@ -1,9 +1,6 @@ # Maintainer: Joan Figueras <ffigue at gmail dot com> # Contributor: Torge Matthies <openglfreak at googlemail dot com> -# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> -# Contributor: Yoshi2889 <rick.2889 at gmail dot com> -# Contributor: Tobias Powalowski <tpowa@archlinux.org> -# Contributor: Thomas Baechler <thomas@archlinux.org> +# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org> ## ## The following variables can be customized at build time. Use env or export to change at your wish @@ -26,17 +23,28 @@ if [ -z ${use_numa+x} ]; then use_numa=y fi -## For performance you can disable FUNCTION_TRACER/GRAPH_TRACER. Limits debugging and analyzing of the kernel. -## Stock Archlinux and Xanmod have this enabled. -## Set variable "use_tracers" to: n to disable (possibly increase performance) -## y to enable (stock default) +## Since upstream disabled CONFIG_STACK_TRACER (limits debugging and analyzing of the kernel) +## you can enable them setting this option. Caution, because they have an impact in performance. +## Stock Archlinux has this enabled. +## Set variable "use_tracers" to: n to disable (possibly increase performance, XanMod default) +## y to enable (Archlinux default) if [ -z ${use_tracers+x} ]; then - use_tracers=y + use_tracers=n fi +# Unique compiler supported upstream is GCC ## Choose between GCC and CLANG config (default is GCC) -if [ -z ${_compiler+x} ]; then - _compiler=gcc +## Use the environment variable "_compiler=clang" +if [ "${_compiler}" = "clang" ]; then + _compiler_flags="CC=clang HOSTCC=clang LLVM=1 LLVM_IAS=1" +fi + +# Choose between the 4 main configs for stable branch. Default x86-64-v1 which use CONFIG_GENERIC_CPU2: +# Possible values: config_x86-64-v1 / config_x86-64-v2 (default) / config_x86-64-v3 / config_x86-64-v4 +# This will be overwritten by selecting any option in microarchitecture script +# Source files: https://github.com/xanmod/linux/tree/5.17/CONFIGS/xanmod/gcc +if [ -z ${_config+x} ]; then + _config=config_x86-64-v2 fi # Compress modules with ZSTD (to save disk space) @@ -57,34 +65,44 @@ if [ -z ${_localmodcfg} ]; then fi # Tweak kernel options prior to a build via nconfig -_makenconfig= +if [ -z ${_makenconfig} ]; then + _makenconfig=n +fi ### IMPORTANT: Do no edit below this line unless you know what you're doing pkgbase=linux-xanmod-anbox -_major=5.14 -pkgver=${_major}.20 -_branch=5.x +_major=6.8 +pkgver=${_major}.9 +_branch=6.x xanmod=1 +_revision= +_sf_branch=main pkgrel=${xanmod} -pkgdesc='Linux Xanmod with ashmem and binder enabled for Anbox - Current Stable (STABLE)' +pkgdesc='Linux Xanmod with ashmem and binder enabled for Anbox - Stable Mainline [MAIN]' url="http://www.xanmod.org/" arch=(x86_64) - license=(GPL2) makedepends=( - bc cpio kmod libelf perl tar xz + bc + cpio + gettext + libelf + pahole + perl + python + tar + xz ) if [ "${_compiler}" = "clang" ]; then - makedepends+=(clang llvm lld python) + makedepends+=(clang llvm lld) fi options=('!strip') _srcname="linux-${pkgver}-xanmod${xanmod}" source=("https://cdn.kernel.org/pub/linux/kernel/v${_branch}/linux-${_major}.tar."{xz,sign} - "https://github.com/xanmod/linux/releases/download/${pkgver}-xanmod${xanmod}/patch-${pkgver}-xanmod${xanmod}.xz" + "patch-${pkgver}-xanmod${xanmod}${_revision}.xz::https://sourceforge.net/projects/xanmod/files/releases/${_sf_branch}/${pkgver}-xanmod${xanmod}/patch-${pkgver}-xanmod${xanmod}.xz/download" choose-gcc-optimization.sh) - #"patch-${pkgver}-xanmod${xanmod}.xz::https://sourceforge.net/projects/xanmod/files/releases/stable/${pkgver}-xanmod${xanmod}/patch-${pkgver}-xanmod${xanmod}.xz/download" validpgpkeys=( 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linux Torvalds '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman @@ -94,14 +112,13 @@ validpgpkeys=( _commit="ec9e9a4219fe221dec93fa16fddbe44a34933d8d" _patches=() for _patch in ${_patches[@]}; do - #source+=("${_patch}::https://git.archlinux.org/svntogit/packages.git/plain/trunk/${_patch}?h=packages/linux&id=${_commit}") source+=("${_patch}::https://raw.githubusercontent.com/archlinux/svntogit-packages/${_commit}/trunk/${_patch}") done -sha256sums=('7e068b5e0d26a62b10e5320b25dce57588cbbc6f781c090442138c9c9c3271b2' +sha256sums=('c969dea4e8bb6be991bbf7c010ba0e0a5643a3a8d8fb0a2aaa053406f1e965f3' 'SKIP' - 'd55cc1215f637d853721adff37f919a4a4f601a61c2fba9c0f5d0c70d3a003bd' - '1ac18cad2578df4a70f9346f7c6fccbb62f042a0ee0594817fdef9f2704904ee') + '59556cb5c51d70141200ac0d8d8d2b240601e77549e22034e7166451e0c6f9f1' + 'a8b38eb482eb685944757182c4886404abc12703e5e56ec39c7d61298d17d71f') export KBUILD_BUILD_HOST=${KBUILD_BUILD_HOST:-archlinux} export KBUILD_BUILD_USER=${KBUILD_BUILD_USER:-makepkg} @@ -111,10 +128,9 @@ prepare() { cd linux-${_major} # Apply Xanmod patch - patch -Np1 -i ../patch-${pkgver}-xanmod${xanmod} + patch -Np1 -i ../patch-${pkgver}-xanmod${xanmod}${_revision} msg2 "Setting version..." - scripts/setlocalversion --save-scmversion echo "-$pkgrel" > localversion.10-pkgrel echo "${pkgbase#linux-xanmod-anbox}" > localversion.20-pkgname @@ -129,7 +145,7 @@ prepare() { done # Applying configuration - cp -vf CONFIGS/xanmod/${_compiler}/config .config + cp -vf CONFIGS/xanmod/gcc/${_config} .config # enable LTO_CLANG_THIN if [ "${_compiler}" = "clang" ]; then scripts/config --disable LTO_CLANG_FULL @@ -142,7 +158,6 @@ prepare() { scripts/config --enable CONFIG_ANDROID_BINDERFS scripts/config --set-str CONFIG_ANDROID_BINDER_DEVICES "binder,hwbinder,vndbinder" scripts/config --enable LTO_CLANG_THIN - _LLVM=1 fi # CONFIG_STACK_VALIDATION gives better stack traces. Also is enabled in all official kernel packages by Archlinux team @@ -152,12 +167,17 @@ prepare() { scripts/config --enable CONFIG_IKCONFIG \ --enable CONFIG_IKCONFIG_PROC + # Requested by Alexandre Frade to fix issues in python-gbinder + scripts/config --enable CONFIG_ANDROID_BINDERFS + scripts/config --enable CONFIG_ANDROID_BINDER_IPC + # User set. See at the top of this file - if [ "$use_tracers" = "n" ]; then - msg2 "Disabling FUNCTION_TRACER/GRAPH_TRACER only if we are not compiling with clang..." - if [ "${_compiler}" = "gcc" ]; then - scripts/config --disable CONFIG_FUNCTION_TRACER \ - --disable CONFIG_STACK_TRACER + if [ "$use_tracers" = "y" ]; then + msg2 "Enabling CONFIG_FTRACE only if we are not compiling with clang..." + if [ "${_compiler}" = "gcc" ] || [ "${_compiler}q" = "q" ]; then + scripts/config --enable CONFIG_FTRACE \ + --enable CONFIG_FUNCTION_TRACER \ + --enable CONFIG_STACK_TRACER fi fi @@ -172,7 +192,10 @@ prepare() { fi # Let's user choose microarchitecture optimization in GCC - sh ${srcdir}/choose-gcc-optimization.sh $_microarchitecture + # Use default microarchitecture only if we have not choosen another microarchitecture + if [ "$_microarchitecture" -ne "0" ]; then + ../choose-gcc-optimization.sh $_microarchitecture + fi # This is intended for the people that want to build this package with their own config # Put the file "myconfig" at the package folder (this will take preference) or "${XDG_CONFIG_HOME}/linux-xanmod-anbox/myconfig" @@ -199,19 +222,23 @@ prepare() { if [ "$_localmodcfg" = "y" ]; then if [ -f $HOME/.config/modprobed.db ]; then msg2 "Running Steven Rostedt's make localmodconfig now" - make LLVM=$_LLVM LLVM_IAS=$_LLVM LSMOD=$HOME/.config/modprobed.db localmodconfig + make ${_compiler_flags} LSMOD=$HOME/.config/modprobed.db localmodconfig else msg2 "No modprobed.db data found" exit 1 fi fi - make LLVM=$_LLVM LLVM_IAS=$_LLVM olddefconfig + msg2 "make ${_compiler_flags} olddefconfig" + make ${_compiler_flags} olddefconfig + #diff -u CONFIGS/xanmod/gcc/${_config} .config || : make -s kernelrelease > version msg2 "Prepared %s version %s" "$pkgbase" "$(<version)" - [[ -z "$_makenconfig" ]] || make LLVM=$_LLVM LLVM_IAS=$_LLVM nconfig + if [ "$_makenconfig" = "y" ]; then + make ${_compiler_flags} nconfig + fi # save configuration for later reuse cat .config > "${SRCDEST}/config.last" @@ -219,18 +246,34 @@ prepare() { build() { cd linux-${_major} - make LLVM=$_LLVM LLVM_IAS=$_LLVM all + make ${_compiler_flags} all + make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1 } _package() { pkgdesc="The Linux kernel and modules with Xanmod patches and ashmem and binder enabled" - depends=(coreutils kmod initramfs) - optdepends=('crda: to set the correct wireless channels of your country' - 'linux-firmware: firmware images needed for some devices') + depends=( + coreutils + initramfs + kmod + ) + optdepends=( + 'wireless-regdb: to set the correct wireless channels of your country' + 'linux-firmware: firmware images needed for some devices' + ) + provides=( + KSMBD-MODULE + VIRTUALBOX-GUEST-MODULES + WIREGUARD-MODULE + NTFS3-MODULE + ) + replaces=( + virtualbox-guest-modules-arch + wireguard-arch + ) cd linux-${_major} - local kernver="$(<version)" - local modulesdir="$pkgdir/usr/lib/modules/$kernver" + local modulesdir="$pkgdir/usr/lib/modules/$(<version)" msg2 "Installing boot image..." # systemd expects to find the kernel here to allow hibernation @@ -241,10 +284,11 @@ _package() { echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase" msg2 "Installing modules..." - make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install + ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 \ + DEPMOD=/doesnt/exist modules_install # Suppress depmod - # remove build and source links - rm "$modulesdir"/{source,build} + # remove build link + rm "$modulesdir"/build } _package-headers() { @@ -256,16 +300,16 @@ _package-headers() { msg2 "Installing build files..." install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \ - localversion.* version vmlinux + localversion.* version vmlinux tools/bpf/bpftool/vmlinux.h install -Dt "$builddir/kernel" -m644 kernel/Makefile install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile cp -t "$builddir" -a scripts - # add objtool for external module building and enabled VALIDATION_STACK option + # required when STACK_VALIDATION is enabled install -Dt "$builddir/tools/objtool" tools/objtool/objtool - # add xfs and shmem for aufs building - mkdir -p "$builddir"/{fs/xfs,mm} + # required when DEBUG_INFO_BTF_MODULES is enabled + install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids msg2 "Installing headers..." cp -t "$builddir" -a include @@ -275,15 +319,18 @@ _package-headers() { install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h - # http://bugs.archlinux.org/task/13146 + # https://bugs.archlinux.org/task/13146 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h - # http://bugs.archlinux.org/task/20402 + # https://bugs.archlinux.org/task/20402 install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h - msg2 "Installing KConfig files..." + # https://bugs.archlinux.org/task/71392 + install -Dt "$builddir/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h + + echo "Installing KConfig files..." find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \; msg2 "Removing unneeded architectures..." @@ -306,7 +353,7 @@ _package-headers() { msg2 "Stripping build tools..." local file while read -rd '' file; do - case "$(file -bi "$file")" in + case "$(file -Sib "$file")" in application/x-sharedlib\;*) # Libraries (.so) strip -v $STRIP_SHARED "$file" ;; application/x-archive\;*) # Libraries (.a) @@ -320,6 +367,7 @@ _package-headers() { msg2 "Stripping vmlinux..." strip -v $STRIP_STATIC "$builddir/vmlinux" + msg2 "Adding symlink..." mkdir -p "$pkgdir/usr/src" ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase" diff --git a/choose-gcc-optimization.sh b/choose-gcc-optimization.sh index f10eec54b81d..38772443028a 100755 --- a/choose-gcc-optimization.sh +++ b/choose-gcc-optimization.sh @@ -11,54 +11,44 @@ cat << EOF Available CPU microarchitectures: - 1) AMD K6/K6-II/K6-III - 2) AMD Athlon/Duron/K7 - 3) AMD Opteron/Athlon64/Hammer/K8 - 4) AMD Opteron/Athlon64/Hammer/K8 with SSE3 - 5) AMD 61xx/7x50/PhenomX3/X4/II/K10 - 6) AMD Family 10h (Barcelona) - 7) AMD Family 14h (Bobcat) - 8) AMD Family 16h (Jaguar) - 9) AMD Family 15h (Bulldozer) - 10) AMD Family 15h (Piledriver) - 11) AMD Family 15h (Steamroller) - 12) AMD Family 15h (Excavator) - 13) AMD Family 17h (Zen) - 14) AMD Family 17h (Zen 2) - 15) AMD Family 19h Zen 3 processors (Zen 3) - 16) Transmeta Crusoe - 17) Transmeta Efficeon - 18) IDT Winchip C6 - 19) Winchip-2/Winchip-2A/Winchip-3 - 20) AMD Elan - 21) Geode GX1 (Cyrix MediaGX) - 22) AMD Geode GX and LX - 23) Cyrix III or C3 - 24) VIA C3 "Nehemiah" - 25) VIA C7 - 26) Intel Pentium 4, Pentium D and older Nocona/Dempsey Xeon CPUs with Intel 64bit - 27) Intel Atom - 28) Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and 53xx) - 29) Intel 1st Gen Core i3/i5/i7-family (Nehalem) - 30) Intel 1.5 Gen Core i3/i5/i7-family (Westmere) - 31) Intel Silvermont - 32) Intel Goldmont (Apollo Lake and Denverton) - 33) Intel Goldmont Plus (Gemini Lake) - 34) Intel 2nd Gen Core i3/i5/i7-family (Sandybridge) - 35) Intel 3rd Gen Core i3/i5/i7-family (Ivybridge) - 36) Intel 4th Gen Core i3/i5/i7-family (Haswell) - 37) Intel 5th Gen Core i3/i5/i7-family (Broadwell) - 38) Intel 6th Gen Core i3/i5/i7-family (Skylake) - 39) Intel 6th Gen Core i7/i9-family (Skylake X) - 40) Intel 8th Gen Core i3/i5/i7-family (Cannon Lake) - 41) Intel 8th Gen Core i7/i9-family (Ice Lake) - 42) Xeon processors in the Cascade Lake family - 43) Intel Xeon (Cooper Lake) - 44) Intel 3rd Gen 10nm++ i3/i5/i7/i9-family (Tiger Lake) - 45) Intel Sapphire Rapids - 46) Intel Rocket Lake - 47) Intel Alder Lake + 1) AMD Opteron/Athlon64/Hammer/K8 + 2) AMD Opteron/Athlon64/Hammer/K8 with SSE3 + 3) AMD 61xx/7x50/PhenomX3/X4/II/K10 + 4) AMD Family 10h (Barcelona) + 5) AMD Family 14h (Bobcat) + 6) AMD Family 16h (Jaguar) + 7) AMD Family 15h (Bulldozer) + 8) AMD Family 15h (Piledriver) + 9) AMD Family 15h (Steamroller) + 10) AMD Family 15h (Excavator) + 11) AMD Family 17h (Zen) + 12) AMD Family 17h (Zen 2) + 13) AMD Family 19h (Zen 3) + 14) AMD Family 19h (Zen 4) + 15) Intel P4 / older Netburst based Xeon + 16) Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and 53xx) + 17) Intel Atom + 18) Intel 1st Gen Core i3/i5/i7-family (Nehalem) + 19) Intel 1.5 Gen Core i3/i5/i7-family (Westmere) + 20) Intel Silvermont + 21) Intel Goldmont (Apollo Lake and Denverton) + 22) Intel Goldmont Plus (Gemini Lake) + 23) Intel 2nd Gen Core i3/i5/i7-family (Sandybridge) + 24) Intel 3rd Gen Core i3/i5/i7-family (Ivybridge) + 25) Intel 4th Gen Core i3/i5/i7-family (Haswell) + 26) Intel 5th Gen Core i3/i5/i7-family (Broadwell) + 27) Intel 6th Gen Core i3/i5/i7-family (Skylake) + 28) Intel 6th Gen Core i7/i9-family (Skylake X) + 29) Intel 8th Gen Core i3/i5/i7-family (Cannon Lake) + 30) Intel 8th Gen Core i7/i9-family (Ice Lake) + 31) Xeon processors in the Cascade Lake family + 32) Intel Xeon (Cooper Lake) + 33) Intel 3rd Gen 10nm++ i3/i5/i7/i9-family (Tiger Lake) + 34) Intel Sapphire Rapids + 35) Intel Rocket Lake + 36) Intel Alder Lake + 91) Generic-x86-64-v1 (LEGACY < 2003. Not supported by XanMod project) 92) Generic-x86-64-v2 (Nehalem and newer) 93) Generic-x86-64-v3 (Haswell and newer) 94) Generic-x86-64-v4 (AVX512 CPUs) @@ -66,7 +56,7 @@ cat << EOF 98) Intel-Native optimizations autodetected by GCC 99) AMD-Native optimizations autodetected by GCC - 0) Generic (default) + 0) Generic x64-v2 (default) EOF @@ -74,66 +64,65 @@ sleep 1 answer=$1 case $answer in - 1) Microarchitecture=CONFIG_MK6 ;; - 2) Microarchitecture=CONFIG_MK7 ;; - 3) Microarchitecture=CONFIG_MK8 ;; - 4) Microarchitecture=CONFIG_MK8SSE3 ;; - 5) Microarchitecture=CONFIG_MK10 ;; - 6) Microarchitecture=CONFIG_MBARCELONA ;; - 7) Microarchitecture=CONFIG_MBOBCAT ;; - 8) Microarchitecture=CONFIG_MJAGUAR ;; - 9) Microarchitecture=CONFIG_MBULLDOZER ;; - 10) Microarchitecture=CONFIG_MPILEDRIVER ;; - 11) Microarchitecture=CONFIG_MSTEAMROLLER ;; - 12) Microarchitecture=CONFIG_MEXCAVATOR ;; - 13) Microarchitecture=CONFIG_MZEN ;; - 14) Microarchitecture=CONFIG_MZEN2 ;; - 15) Microarchitecture=CONFIG_MZEN3 ;; - 16) Microarchitecture=CONFIG_MCRUSOE ;; - 17) Microarchitecture=CONFIG_MEFFICEON ;; - 18) Microarchitecture=CONFIG_MWINCHIPC6 ;; - 19) Microarchitecture=CONFIG_MWINCHIP3D ;; - 20) Microarchitecture=CONFIG_MELAN ;; - 21) Microarchitecture=CONFIG_MGEODEGX1 ;; - 22) Microarchitecture=CONFIG_MGEODE_LX ;; - 23) Microarchitecture=CONFIG_MCYRIXIII ;; - 24) Microarchitecture=CONFIG_MVIAC3_2 ;; - 25) Microarchitecture=CONFIG_MVIAC7 ;; - 26) Microarchitecture=CONFIG_MPSC ;; - 27) Microarchitecture=CONFIG_MATOM ;; - 28) Microarchitecture=CONFIG_MCORE2 ;; - 29) Microarchitecture=CONFIG_MNEHALEM ;; - 30) Microarchitecture=CONFIG_MWESTMERE ;; - 31) Microarchitecture=CONFIG_MSILVERMONT ;; - 32) Microarchitecture=CONFIG_MGOLDMONT ;; - 33) Microarchitecture=CONFIG_MGOLDMONTPLUS ;; - 34) Microarchitecture=CONFIG_MSANDYBRIDGE ;; - 35) Microarchitecture=CONFIG_MIVYBRIDGE ;; - 36) Microarchitecture=CONFIG_MHASWELL ;; - 37) Microarchitecture=CONFIG_MBROADWELL ;; - 38) Microarchitecture=CONFIG_MSKYLAKE ;; - 39) Microarchitecture=CONFIG_MSKYLAKEX ;; - 40) Microarchitecture=CONFIG_MCANNONLAKE ;; - 41) Microarchitecture=CONFIG_MICELAKE ;; - 42) Microarchitecture=CONFIG_MCASCADELAKE ;; - 43) Microarchitecture=CONFIG_MCOOPERLAKE ;; - 44) Microarchitecture=CONFIG_MTIGERLAKE ;; - 45) Microarchitecture=CONFIG_MSAPPHIRERAPIDS ;; - 46) Microarchitecture=CONFIG_MROCKETLAKE ;; - 47) Microarchitecture=CONFIG_MALDERLAKE ;; - 92) Microarchitecture=CONFIG_GENERIC_CPU2 ;; - 93) Microarchitecture=CONFIG_GENERIC_CPU3 ;; - 94) Microarchitecture=CONFIG_GENERIC_CPU4 ;; - 98) Microarchitecture=CONFIG_MNATIVE_INTEL ;; - 99) Microarchitecture=CONFIG_MNATIVE_AMD ;; - *) default=CONFIG_GENERIC_CPU ;; + 1) Microarchitecture=CONFIG_MK8 ;; + 2) Microarchitecture=CONFIG_MK8SSE3 ;; + 3) Microarchitecture=CONFIG_MK10 ;; + 4) Microarchitecture=CONFIG_MBARCELONA ;; + 5) Microarchitecture=CONFIG_MBOBCAT ;; + 6) Microarchitecture=CONFIG_MJAGUAR ;; + 7) Microarchitecture=CONFIG_MBULLDOZER ;; + 8) Microarchitecture=CONFIG_MPILEDRIVER ;; + 9) Microarchitecture=CONFIG_MSTEAMROLLER ;; + 10) Microarchitecture=CONFIG_MEXCAVATOR ;; + 11) Microarchitecture=CONFIG_MZEN ;; + 12) Microarchitecture=CONFIG_MZEN2 ;; + 13) Microarchitecture=CONFIG_MZEN3 ;; + 14) Microarchitecture=CONFIG_MZEN4 ;; + 15) Microarchitecture=CONFIG_MPSC ;; + 16) Microarchitecture=CONFIG_MCORE2 ;; + 17) Microarchitecture=CONFIG_MATOM ;; + 18) Microarchitecture=CONFIG_MNEHALEM ;; + 19) Microarchitecture=CONFIG_MWESTMERE ;; + 20) Microarchitecture=CONFIG_MSILVERMONT ;; + 21) Microarchitecture=CONFIG_MGOLDMONT ;; + 22) Microarchitecture=CONFIG_MGOLDMONTPLUS ;; + 23) Microarchitecture=CONFIG_MSANDYBRIDGE ;; + 24) Microarchitecture=CONFIG_MIVYBRIDGE ;; + 25) Microarchitecture=CONFIG_MHASWELL ;; + 26) Microarchitecture=CONFIG_MBROADWELL ;; + 27) Microarchitecture=CONFIG_MSKYLAKE ;; + 28) Microarchitecture=CONFIG_MSKYLAKEX ;; + 29) Microarchitecture=CONFIG_MCANNONLAKE ;; + 30) Microarchitecture=CONFIG_MICELAKE ;; + 31) Microarchitecture=CONFIG_MCASCADELAKE ;; + 32) Microarchitecture=CONFIG_MCOOPERLAKE ;; + 33) Microarchitecture=CONFIG_MTIGERLAKE ;; + 34) Microarchitecture=CONFIG_MSAPPHIRERAPIDS ;; + 35) Microarchitecture=CONFIG_MROCKETLAKE ;; + 36) Microarchitecture=CONFIG_MALDERLAKE ;; + 91) Microarchitecture=CONFIG_GENERIC_CPU ;; + 92) Microarchitecture=CONFIG_GENERIC_CPU2 ;; + 93) Microarchitecture=CONFIG_GENERIC_CPU3 ;; + 94) Microarchitecture=CONFIG_GENERIC_CPU4 ;; + 98) Microarchitecture=CONFIG_MNATIVE_INTEL ;; + 99) Microarchitecture=CONFIG_MNATIVE_AMD ;; + *) default=CONFIG_GENERIC_CPU2 ;; esac warning "According to PKGBUILD variable _microarchitecture, your choice is $answer" msg "Building this package for microarchitecture: $Microarchitecture$default" sleep 5 +_defaultmicro=$(grep ^CONFIG_LOCALVERSION .config) +if [ -z "${default}" ]; then + _localversion=$(echo ${Microarchitecture,,} | sed -e 's/config_m/-/g' -e 's/config_generic_cpu/-x64v/g') + sed -e "s|^$_defaultmicro|CONFIG_LOCALVERSION=\"$_localversion\"|g" -i .config +fi + sed -e 's|^CONFIG_GENERIC_CPU=y|# CONFIG_GENERIC_CPU is not set|g' -i .config +sed -e 's|^CONFIG_GENERIC_CPU2=y|# CONFIG_GENERIC_CPU2 is not set|g' -i .config +sed -e 's|^CONFIG_GENERIC_CPU3=y|# CONFIG_GENERIC_CPU3 is not set|g' -i .config +sed -e 's|^CONFIG_GENERIC_CPU4=y|# CONFIG_GENERIC_CPU4 is not set|g' -i .config sed -e "s|^# $Microarchitecture is not set|$Microarchitecture=y|g" -i .config echo diff --git a/disable-per-VMA_v4_1.patch b/disable-per-VMA_v4_1.patch new file mode 100644 index 000000000000..b8ca1a18b40f --- /dev/null +++ b/disable-per-VMA_v4_1.patch @@ -0,0 +1,118 @@ +From mboxrd@z Thu Jan 1 00:00:00 1970 +Return-Path: <linux-kernel-owner@vger.kernel.org> +X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on + aws-us-west-2-korg-lkml-1.web.codeaurora.org +Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) + by smtp.lore.kernel.org (Postfix) with ESMTP id C2403EB64DD + for <linux-kernel@archiver.kernel.org>; Thu, 6 Jul 2023 01:14:14 +0000 (UTC) +Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand + id S232489AbjGFBON (ORCPT <rfc822;linux-kernel@archiver.kernel.org>); + Wed, 5 Jul 2023 21:14:13 -0400 +Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40440 "EHLO + lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org + with ESMTP id S232282AbjGFBOL (ORCPT + <rfc822;linux-kernel@vger.kernel.org>); + Wed, 5 Jul 2023 21:14:11 -0400 +Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) + by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACA7219AD + for <linux-kernel@vger.kernel.org>; Wed, 5 Jul 2023 18:14:09 -0700 (PDT) +Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-bb0d11a56abso104585276.2 + for <linux-kernel@vger.kernel.org>; Wed, 05 Jul 2023 18:14:09 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20221208; t=1688606049; x=1691198049; + h=cc:to:from:subject:message-id:references:mime-version:in-reply-to + :date:from:to:cc:subject:date:message-id:reply-to; + bh=BMMaNFIuSTODACKQNg6XDNNsjL1Pfx6pMDgwoYH4Ut0=; + b=Yn5aRyUWACvrhkw4W9c/RrQ1vZVkQ3aETLIOHYDXUyaoQSnxwBiG3WfF5wRFwIFEvw + weJQdiFsuoHFg7+9Knuii4aazDz880sQWUsYnqjniz/RcD+lsmIUy0RtMfI3EZOdknvG + lfux25ysmzhfKTDzbuUftCdRHhS3/CZtHh7uU502n9ZsPETUnBcunocCrRCWmY4NthQM + NYWKscTrHCCVV2l9q6DYpMlOWBsc7125yZXvQvDPOkzqa2jEVxhh++SxzCEucUU7Sj9Y + PqugueozRZVh1tS8qAnhcSciZ/GC8dmxTaNU5U27m8aw8+rjObbB60wx6Je9TqxLz6zX + mKCA== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20221208; t=1688606049; x=1691198049; + h=cc:to:from:subject:message-id:references:mime-version:in-reply-to + :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; + bh=BMMaNFIuSTODACKQNg6XDNNsjL1Pfx6pMDgwoYH4Ut0=; + b=gNTKDQRLYtT59SsSRj64wrCj7CcrLwfU/UCrBJ2k1+U7gDfP108Ue/sUa++jGjNiQT + sXK7ZiBpvA8F41LSwxayYpymwC6pCAdrhPNw0Gm2FR2GAYFaxqKCDVOuRx6R1+FoRj6L + LBRA0KKVRldVWpiS0sRE2XWuDrzv+eK+gbyyfXdkhZghk2gvFGw4nMlbgggWGuy5n8Vj + uZxXPygKqnDglvyPWiuL6+O61l8NBLnzgyoSC/txVS6WbzaeF/T5m9xgBIPqUUs4pEwb + +ZfLfxsY2n9sTNR2J7tVeJBQkzBpAfeHAVgjUpBpondUzwdGjy+ZjlcSMQUTpvmJshag + vB1w== +X-Gm-Message-State: ABy/qLY0hYMSeqI1aJGaKO7qUST7eAFCAkN0O5qMf32amw8IodaghgVH + cODpwOJWQWRlps20ccRqM/Gi1GURPnc= +X-Google-Smtp-Source: APBJJlHam+3Kw1wwiprnqdWZZWRe4i9qQ9FP0XUelvhsWWC81rNfZCgy8OD9hwPRpPw8+Oh35ka/px6hTPY= +X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:946c:be30:90d9:9093]) + (user=surenb job=sendgmr) by 2002:a25:c6:0:b0:c4d:c7cb:5a4e with SMTP id + 189-20020a2500c6000000b00c4dc7cb5a4emr2822yba.3.1688606048773; Wed, 05 Jul + 2023 18:14:08 -0700 (PDT) +Date: Wed, 5 Jul 2023 18:14:00 -0700 +In-Reply-To: <20230706011400.2949242-1-surenb@google.com> +Mime-Version: 1.0 +References: <20230706011400.2949242-1-surenb@google.com> +X-Mailer: git-send-email 2.41.0.255.g8b1d071c50-goog +Message-ID: <20230706011400.2949242-3-surenb@google.com> +Subject: [PATCH v4 2/2] mm: disable CONFIG_PER_VMA_LOCK until its fixed +From: Suren Baghdasaryan <surenb@google.com> +To: akpm@linux-foundation.org +Cc: jirislaby@kernel.org, jacobly.alt@gmail.com, + holger@applied-asynchrony.com, hdegoede@redhat.com, + michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, + vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, + dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, + peterz@infradead.org, ldufour@linux.ibm.com, paulmck@kernel.org, + mingo@redhat.com, will@kernel.org, luto@kernel.org, + songliubraving@fb.com, peterx@redhat.com, david@redhat.com, + dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, + kent.overstreet@linux.dev, punit.agrawal@bytedance.com, + lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, + chriscli@google.com, axelrasmussen@google.com, joelaf@google.com, + minchan@google.com, rppt@kernel.org, jannh@google.com, + shakeelb@google.com, tatashin@google.com, edumazet@google.com, + gthelen@google.com, linux-mm@kvack.org, + linux-kernel@vger.kernel.org, stable@vger.kernel.org, + Suren Baghdasaryan <surenb@google.com> +Content-Type: text/plain; charset="UTF-8" +Precedence: bulk +List-ID: <linux-kernel.vger.kernel.org> +X-Mailing-List: linux-kernel@vger.kernel.org + +A memory corruption was reported in [1] with bisection pointing to the +patch [2] enabling per-VMA locks for x86. +Disable per-VMA locks config to prevent this issue until the fix is +confirmed. This is expected to be a temporary measure. + +[1] https://bugzilla.kernel.org/show_bug.cgi?id=217624 +[2] https://lore.kernel.org/all/20230227173632.3292573-30-surenb@google.com + +Reported-by: Jiri Slaby <jirislaby@kernel.org> +Closes: https://lore.kernel.org/all/dbdef34c-3a07-5951-e1ae-e9c6e3cdf51b@kernel.org/ +Reported-by: Jacob Young <jacobly.alt@gmail.com> +Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217624 +Fixes: 0bff0aaea03e ("x86/mm: try VMA lock-based page fault handling first") +Cc: stable@vger.kernel.org +Signed-off-by: Suren Baghdasaryan <surenb@google.com> +--- + mm/Kconfig | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/mm/Kconfig b/mm/Kconfig +index 09130434e30d..0abc6c71dd89 100644 +--- a/mm/Kconfig ++++ b/mm/Kconfig +@@ -1224,8 +1224,9 @@ config ARCH_SUPPORTS_PER_VMA_LOCK + def_bool n + + config PER_VMA_LOCK +- def_bool y ++ bool "Enable per-vma locking during page fault handling." + depends on ARCH_SUPPORTS_PER_VMA_LOCK && MMU && SMP ++ depends on BROKEN + help + Allow per-vma locking during page fault handling. + +-- +2.41.0.255.g8b1d071c50-goog + + diff --git a/disable-per-VMA_v4_2.patch b/disable-per-VMA_v4_2.patch new file mode 100644 index 000000000000..a86c966a4110 --- /dev/null +++ b/disable-per-VMA_v4_2.patch @@ -0,0 +1,75 @@ +From: Suren Baghdasaryan <surenb@google.com> +To: akpm@linux-foundation.org +Cc: jirislaby@kernel.org, jacobly.alt@gmail.com, + holger@applied-asynchrony.com, hdegoede@redhat.com, + michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, + vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, + dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, + peterz@infradead.org, ldufour@linux.ibm.com, paulmck@kernel.org, + mingo@redhat.com, will@kernel.org, luto@kernel.org, + songliubraving@fb.com, peterx@redhat.com, david@redhat.com, + dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, + kent.overstreet@linux.dev, punit.agrawal@bytedance.com, + lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, + chriscli@google.com, axelrasmussen@google.com, joelaf@google.com, + minchan@google.com, rppt@kernel.org, jannh@google.com, + shakeelb@google.com, tatashin@google.com, edumazet@google.com, + gthelen@google.com, linux-mm@kvack.org, + linux-kernel@vger.kernel.org, stable@vger.kernel.org, + Suren Baghdasaryan <surenb@google.com> +Subject: [PATCH v4 1/2] fork: lock VMAs of the parent process when forking +Date: Wed, 5 Jul 2023 18:13:59 -0700 [thread overview] +Message-ID: <20230706011400.2949242-2-surenb@google.com> (raw) +In-Reply-To: <20230706011400.2949242-1-surenb@google.com> + +When forking a child process, parent write-protects an anonymous page +and COW-shares it with the child being forked using copy_present_pte(). +Parent's TLB is flushed right before we drop the parent's mmap_lock in +dup_mmap(). If we get a write-fault before that TLB flush in the parent, +and we end up replacing that anonymous page in the parent process in +do_wp_page() (because, COW-shared with the child), this might lead to +some stale writable TLB entries targeting the wrong (old) page. +Similar issue happened in the past with userfaultfd (see flush_tlb_page() +call inside do_wp_page()). +Lock VMAs of the parent process when forking a child, which prevents +concurrent page faults during fork operation and avoids this issue. +This fix can potentially regress some fork-heavy workloads. Kernel build +time did not show noticeable regression on a 56-core machine while a +stress test mapping 10000 VMAs and forking 5000 times in a tight loop +shows ~7% regression. If such fork time regression is unacceptable, +disabling CONFIG_PER_VMA_LOCK should restore its performance. Further +optimizations are possible if this regression proves to be problematic. + +Suggested-by: David Hildenbrand <david@redhat.com> +Reported-by: Jiri Slaby <jirislaby@kernel.org> +Closes: https://lore.kernel.org/all/dbdef34c-3a07-5951-e1ae-e9c6e3cdf51b@kernel.org/ +Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com> +Closes: https://lore.kernel.org/all/b198d649-f4bf-b971-31d0-e8433ec2a34c@applied-asynchrony.com/ +Reported-by: Jacob Young <jacobly.alt@gmail.com> +Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217624 +Fixes: 0bff0aaea03e ("x86/mm: try VMA lock-based page fault handling first") +Cc: stable@vger.kernel.org +Signed-off-by: Suren Baghdasaryan <surenb@google.com> +--- + kernel/fork.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/kernel/fork.c b/kernel/fork.c +index b85814e614a5..2ba918f83bde 100644 +--- a/kernel/fork.c ++++ b/kernel/fork.c +@@ -658,6 +658,12 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, + retval = -EINTR; + goto fail_uprobe_end; + } ++#ifdef CONFIG_PER_VMA_LOCK ++ /* Disallow any page faults before calling flush_cache_dup_mm */ ++ for_each_vma(old_vmi, mpnt) ++ vma_start_write(mpnt); ++ vma_iter_set(&old_vmi, 0); ++#endif + flush_cache_dup_mm(oldmm); + uprobe_dup_mmap(oldmm, mm); + /* +-- +2.41.0.255.g8b1d071c50-goog |