From nobody Fri Sep 25 12:37:28 2026 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9B1B390613 for ; Sat, 12 Sep 2026 19:55:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789242950; cv=none; b=ERo/P7d6Tjwqdv3GBgN1+Ml8yohVTCjv2mBP1H2YGmH5Xc1T5aqP4Nzik5BDcoIhtthff3iNVtToqZVogXnJY52QQ5EY9foTE6ZbeUtLJTSCYB/NSfoaVlzixvxYuBnKMN60QCtis+e/7ZA6meSW6k59OP+5apY30nCktDW3yF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789242950; c=relaxed/simple; bh=6WBpY++pP4wmpap/0jVFlCXobQj6RCxIU3+Y23QnWmU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GdUi5Og3u64cP6aPNCjw2qRKlMbHl9gGFPybDnGljuKO52Hpicj9kfQQZUhxH92JTA8ZD/iMbDgYu7RmYyBdvkFo6xIyTz/U6zBHTO9HX+aTLH1FKxRfjwkTLhjV2DAYEtEyCB1uca3ggiZz7jE8P9+Rfcb4Z7xRiIgQd6JtyY4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HJeK0VnX; arc=none smtp.client-ip=209.85.128.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HJeK0VnX" Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-86d43cdee51so19064187b3.2 for ; Sat, 12 Sep 2026 12:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789242947; x=1789847747; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=h/xtiDuXddajfEeaRITCEbehQWNBkWU4am5Icja8HbQ=; b=HJeK0VnXP9ECADtzJcxWj//e1WtIUx3EPRMeyFHQAG+5wJslD3Y/wCo6VUAJnWO9ho TJYZl47xdPMzcapMIyaJVpIg2qJZChQ8Bg+TwOf0KVNObfS2XHxG5REz8R/PoRL/nOBc 5QcYOUymylfrozIXclI40okjR+lbFBsAY5DG72bkfTnARRayribPR67dvZI1+NJq7eaZ xqJ97J7CIGwfAiS3Cy2pyK1EWCJKcltOWmRnYr9pL0sd5fl/hkZ/hHo1PQbPB9PyLe+T sCCG3L10Ihy9dbN15QZpwg54UH23T2ryDTliZ2c9vmYUy6rlg0w1qdLXJ0cNB5ahc9nH Zdcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789242947; x=1789847747; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=h/xtiDuXddajfEeaRITCEbehQWNBkWU4am5Icja8HbQ=; b=cCd1IGjhDClZKDDL+pa53FdsiYL7yObvbzetlFozKh8w+0HdsvBDtE7xI7wzkxl6YR iO8Hgi6zyk5YjWSVQnj1M7hVKavyaeoI6e2NmsZIlfYWFFV/XKpDLDDf6PTGnjQajbX/ T7n/wvx+9DG8ZFVbXbu94+cdn6NERkAHPxHaNjRaP09GIdNIqkDZJVyIZgZ+mtGJYmKi dIA0WfWrjfzqHjgznx/rniG+WlzcZRto04cuc/oOedNiMIYPPY9KxCI91e+Rpya0cS+/ OsQcmtjBvBlTiAtG0+XeGXjMRuYIa9b6XjYMiWTpBcMEgx9RUhnPvGrB0ET9gMJTqsLl 9ObA== X-Gm-Message-State: AFuF++nGpYtdbCGLTNHc/eu/YK90kahlXxb2Q88DQGGS1KtvabdlT4Ak dG/W6f1fPgKdoLckVbEs7JOgrfbffKkSxS6ePXk0dbRQB30FXT1sGe895dcqpYGb X-Gm-Gg: AYBFou3Omi4GGGwxjPpzjRb8CThxGqgbP51b+wKAjZDmFn1eYu8XSydMt9/uxn06fmC /ogx7U+qye2B++9mcTlRoExauvWulcAg7mIggPLdLdnq+j/er1YJoFvCinbtpKiX1U9XEs+O72L ylFiaVrpjgN5Bm+qLUW/RHVAwcyfmrZhFwHlVJxlhG4utoF3PalfkuW/va6Y54Dqjmwy54RXtsm xtNGmQhRMKXmiHcuQZdKAHnvg2YnkpHiaJz/B5Js2WAmu6DNyTM0swUgrZ+eqKv1UE+gNvgBMJh duk6HMDeuR3yBDtTl0fx29UnhqXUKjhBRdlrzjx3MNwPtZbHGMJVWZs0vWdfNYYOQbEfOalZGbK zgLYbbL6wvc1z0DLmrtxM007PMNFnWpC8xHIQHK3lzHhscA7ianKTHQxk51Icp5Lz5E9AxhHOYs 1bvy27SWdEsEcY7HOF2W3SF1BRkWE+XAeCtHjZgiVpx/nOlK8t6QGEubIFX3xi+7rPXVKKnLlo X-Received: by 2002:a05:690c:dc9:b0:873:17c9:afca with SMTP id 00721157ae682-884af455988mr32505057b3.29.1789242947517; Sat, 12 Sep 2026 12:55:47 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 00721157ae682-88487ea6026sm22569527b3.32.2026.09.12.12.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2026 12:55:46 -0700 (PDT) From: Matt Turner Date: Sat, 12 Sep 2026 15:55:43 -0400 Subject: [PATCH 1/3] xz: add arch-specific tuning for alpha Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260912-alpha-kernel-compression-v1-1-ce9d55330193@gmail.com> References: <20260912-alpha-kernel-compression-v1-0-ce9d55330193@gmail.com> In-Reply-To: <20260912-alpha-kernel-compression-v1-0-ce9d55330193@gmail.com> To: Lasse Collin , Richard Henderson , Magnus Lindholm , Nick Terrell , David Sterba Cc: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1237; i=mattst88@gmail.com; h=from:subject:message-id; bh=6WBpY++pP4wmpap/0jVFlCXobQj6RCxIU3+Y23QnWmU=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLKWrrP3bfLPW3lE+iqTE+MCvXx+4yTf6EX3GjYt2tX/6 /D5i33/Oz6yMIhxMcwUU2SJW6/IMqttx1Kf09K/YOawMoEMkRZpYAACFga+3MS8UiMdIz1TbUM9 QyBDxygeIqfHoJFZXFyaWqSbVlDkkJdfkliSmZ9XrJdfkJpXkF6gl5aZVpKRkV9UnAo0Qi8vtcT U1dHNyNDAxNLRwszJwtHUxNnZydDJzdHR2dXJyNLcxMDZ0tHE1dKcgYtTAOaae3MY/ils79i75e nlO12C2Zdv35omH5VzkFN8i9JNRuF/dZ5NJzwYGZZ/0hP9xvTiRSXn6VxD05OT22b+if7TsuHwt LzV+10VV/EDAA== X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A Alpha has fixed-length, 4-byte-aligned instructions and no XZ BCJ filter, so it wants the same LZMA2 settings as the other 4-byte-aligned targets. Without an entry it hits the default case, which warns scripts/xz_wrap.sh: Arch-specific tuning is missing for 'alpha' and conservatively assumes 2-byte alignment. Alpha gains HAVE_KERNEL_XZ later in this series; the correct alignment also shrinks a UP1500 kernel's XZ image from 6469320 to 6448840 bytes. Signed-off-by: Matt Turner Reviewed-by: Lasse Collin Reviewed-by: Magnus Lindholm Tested-by: Magnus Lindholm --- scripts/xz_wrap.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh index f19369687030..5af0d9045cbc 100755 --- a/scripts/xz_wrap.sh +++ b/scripts/xz_wrap.sh @@ -10,6 +10,7 @@ # XZ-compressed kernel isn't currently supported on every listed arch. # # Arch Align Notes +# alpha 4 # arm 2/4 ARM and ARM-Thumb2 # arm64 4 # csky 2 @@ -44,6 +45,10 @@ BCJ=3D # Set the BCJ filter if one is available. # It must match the #ifdef usage in lib/decompress_unxz.c. case $SRCARCH in + alpha) + ALIGN=3D4 + ;; + arm) if is_enabled CONFIG_THUMB2_KERNEL; then ALIGN=3D2 --=20 2.54.0 From nobody Fri Sep 25 12:37:28 2026 Received: from mail-yx2-f12.google.com (mail-yx2-f12.google.com [74.125.224.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E085390C9F for ; Sat, 12 Sep 2026 19:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789242954; cv=none; b=aImM7OUuScQdOGeSMNhPB/HfkuR33jZh/iqORGPTbM57DFDHM/ns+Eyze9sT6Qo+2/Cfm5XVq6eOHroR+XXDZ3mu9F+ghex6nI+3AD3/KF2LL4auxBYKHYE7SLE0JRxXoJZrsxYASDAsHS/qqYEOOiN46ZgaV1yMLM3NR0rgbCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789242954; c=relaxed/simple; bh=TLG+FXxYj02zo3kFa0FcfgOuzRpjmn0I45fl4soM91s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WT+4JFU33VsFxexBNIuA35D+ngozS8Kg1B+EIAbNMinwNzeoEF2jr17XlBYZtk90/OB8C1mL/5RJ/3YMM5xnKFYwywcAXty65NV0YF7NFOgVQMC1BYpxiWixTIDZme8r+EL989x4esYHAayxoU3JBeTnGtWRKpDvoXEHZbuGMbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KNYHIzkd; arc=none smtp.client-ip=74.125.224.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KNYHIzkd" Received: by mail-yx2-f12.google.com with SMTP id 956f58d0204a3-66f7f72a284so627302d50.2 for ; Sat, 12 Sep 2026 12:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789242950; x=1789847750; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=LAJFGKkQwja5Ngco4ah+sb/VGagRIkZqgTZaNgWxDv8=; b=KNYHIzkdSZSaIu+jkiXgG1sC1BpEacu4sDCSHHpLmDD89CxBYXXAPlOknKONFDyyGG PnoyoSKDeKKsDrh/Em/Ud0dj3eVeHmq9YqWmgsjWKTG667s/LqdFo5+pMtIGkR+hLYjl eA9lqj4gv2tQK1W64+Nen3gBRHLXDvfVb7uEMqflXSxYTS1E23FzIHdG7GnZzxmveW62 IAE+3uWYdTh8C/g4MlMH41JSP74ZE25+enRHAs/J0/67Auv1cUzZmlOjRiboryZ1UCpS jshUS/5NVR8HTwU37GuwvKmrUwPzYulNG2NSxB041P38KQB8nP1wWvpdoXzQp4rRH9+A iyJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789242950; x=1789847750; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=LAJFGKkQwja5Ngco4ah+sb/VGagRIkZqgTZaNgWxDv8=; b=Zd/ixOparZepjBtzxuWQnG9OIaRb7lXmfovFB120W3fDkBgsKsrwlEGG5y3bYM/QUX QPtACpRFZBM4b6/0Wqcx5LB56ZHBx+D1YndyqS2YdLSmWclIsWwboTnTUsHuzhbzR0VM WGXsV0ORBLpgNVVUlpoNvLdtroEUsMiqnNswBvZz7jdl1EaMdp29heKGN7SiBHXnovNd 2G1ePZpzVG7/jsPNgnSjB7uwXi/1KVcXxxXXcQBWxTtp7fbmVqzc5t3CdVJQk2Jw2sL1 pKiBFYfvraq1zjbouYhvmbW27LJwLQB4R4xwx1vgGoNPZVVPpY4XX/u/dk0yASggGdce gEmg== X-Gm-Message-State: AFuF++nv/PogJRxXSBIABh0jJ279Wv34yl/0iaNEuNUuf59FdbMzI0Ic Ws6dGF85koUErkeuqJfacviy0YencwNU/liPv6jirTCSPNtcOVMNZsf+1nTavQhD X-Gm-Gg: AYBFou31Fe899F0WmBodv2fgxcLKlEu7eC8iap3zP/6w2pygUmqcMJ0/2BvynaoeprU ZdWTQwiaLiDVnbc9pJCDYNb2lqsLpGctjRDdsdY/fOGXR5PzLy27BOMzTNxvejAmYqvjuQRM9CB OHte5w03GCsL+lwXwIYZXmnKLX8ZoC4qgbegul3qapyGGdMrD5imZdmCosq+gjuQi+bz5JUj8qG fb6KTOp9TaKRpl4BZAzZ3FY1yu06GVLLc5hKq8yfeYaSBnXohmgJG6TuuOHjefvxZu43BxHosI4 qLickNGUeT5vQ05JI2HRrVuZkAKVvzPaxbJH67npO8Ucs14ZhZgaoWZtz1yYjiou1CuHKTPyjcd Obxc/GdS3TvJZv/LeoX08IvVGl9t591GKNZtEwf3JsBdhGnRbwzxsNO78gwKR8dqeC+0yoo1UYb hF6fybBiYTb6s8edszqPugpJONujtExldA5lsmWhYDDhq8Gkr/er7XnVcZ5HBSlCZorXLh0jQ= X-Received: by 2002:a05:690e:1301:b0:671:3b52:60ef with SMTP id 956f58d0204a3-6713b52629bmr548164d50.93.1789242950165; Sat, 12 Sep 2026 12:55:50 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67125db4fecsm2562366d50.4.2026.09.12.12.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2026 12:55:49 -0700 (PDT) From: Matt Turner Date: Sat, 12 Sep 2026 15:55:44 -0400 Subject: [PATCH 2/3] alpha: add self-extracting compressed kernel boot stub Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260912-alpha-kernel-compression-v1-2-ce9d55330193@gmail.com> References: <20260912-alpha-kernel-compression-v1-0-ce9d55330193@gmail.com> In-Reply-To: <20260912-alpha-kernel-compression-v1-0-ce9d55330193@gmail.com> To: Lasse Collin , Richard Henderson , Magnus Lindholm , Nick Terrell , David Sterba Cc: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=17649; i=mattst88@gmail.com; h=from:subject:message-id; bh=TLG+FXxYj02zo3kFa0FcfgOuzRpjmn0I45fl4soM91s=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLKWrrNvm5xlr54mfXYtP1+Q2Gmmh7/q9p2+rq2QH70kc /OGy30nOz6yMIhxMcwUU2SJW6/IMqttx1Kf09K/YOawMoEMkRZpYAACFga+3MS8UiMdIz1TbUM9 QyBDxygeIqfHoJFZXFyaWqSbVlDkkJdfkliSmZ9XrJdfkJpXkF6gl5aZVpKRkV9UnAo0Qi8vtcT U1dHNyNDAxNLRwszJwtHUxNnZydDJzdHR2dXJyNLcxMDZ0tHE1dKcgYtTAOaaej1GhgVvb6To1g v25/r93/NHQePlqi0ZZmfjDmY37NepeXzdVY6RYU7mRM5/y1dHqG3zPTlTLiP4no/ZR5YIq68sP OvmrAy1ZwcA X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A Alpha only ever supported gzip for the kernel image, and did so in a way out of step with every other architecture: aboot, the disk boot loader, decompresses vmlinux.gz itself with its own bundled inflate code, so adding a compression format meant writing a new decompressor inside aboot as well as in the kernel. Build a proper self-extracting arch/alpha/boot/compressed/vmlinux instead, modeled on parisc: a small ELF stub with the real, compressed vmlinux linked in, which decompresses the kernel, relocates it into place and jumps to its entry point. aboot needs no changes. The build now emits arch/alpha/boot/vmlinuz rather than vmlinux.gz, which was never a name aboot cared about and would be a lie for an ELF stub: the bootpz path in the same directory still produces real gzip data as vmlinux.nh.gz. Existing aboot.conf files name the image as it was installed in /boot, so only the command that copies it out of the build tree changes. Unlike parisc and mips, the stub is linked at START_ADDR rather than at a separate low address; see compressed/vmlinux.lds.S. It has no console output, since bringing up the HWRPB console callbacks needs more than the CRB dispatch the kernel proper does much later, so error() just halts. The legacy SRM netboot path (bootpz.c) is left alone: it has its own boot protocol (PALcode reinitialization, self-populated ZERO_PGE, build-time-computed image sizes) that does not fit this design without a separate rewrite, and keeps using plain gzip via vmlinux.nh.gz. Signed-off-by: Matt Turner Reviewed-by: Magnus Lindholm Tested-by: Magnus Lindholm --- arch/alpha/Kconfig | 1 + arch/alpha/Makefile | 6 +- arch/alpha/boot/.gitignore | 2 + arch/alpha/boot/Makefile | 16 ++- arch/alpha/boot/compressed/.gitignore | 3 + arch/alpha/boot/compressed/Makefile | 36 +++++++ arch/alpha/boot/compressed/head.S | 36 +++++++ arch/alpha/boot/compressed/misc.c | 178 +++++++++++++++++++++++++++= ++++ arch/alpha/boot/compressed/trampoline.S | 46 ++++++++ arch/alpha/boot/compressed/vmlinux.lds.S | 83 ++++++++++++++ arch/alpha/boot/compressed/vmlinux.scr | 10 ++ 11 files changed, 409 insertions(+), 8 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 04511242506b..2688bb00f175 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -30,6 +30,7 @@ config ALPHA select HAVE_ASM_MODVERSIONS select HAVE_DEBUG_KMEMLEAK select HAVE_GUP_FAST + select HAVE_KERNEL_GZIP select HAVE_PAGE_SIZE_8KB select HAVE_PCSPKR_PLATFORM select HAVE_PERF_EVENTS diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile index 7074602dca94..405d4bfd644c 100644 --- a/arch/alpha/Makefile +++ b/arch/alpha/Makefile @@ -47,9 +47,9 @@ export LIBS_Y boot :=3D arch/alpha/boot =20 #Default target when executing make with no arguments -all boot: $(boot)/vmlinux.gz +all boot: $(boot)/vmlinuz =20 -$(boot)/vmlinux.gz: vmlinux +$(boot)/vmlinuz: vmlinux $(Q)$(MAKE) $(build)=3D$(boot) $@ =20 bootimage bootpfile bootpzfile: vmlinux @@ -59,7 +59,7 @@ archheaders: $(Q)$(MAKE) $(build)=3Darch/alpha/kernel/syscalls all =20 define archhelp - echo '* boot - Compressed kernel image (arch/alpha/boot/vmlinux.gz)' + echo '* boot - Compressed kernel image (arch/alpha/boot/vmlinuz)' echo ' bootimage - SRM bootable image (arch/alpha/boot/bootimage)' echo ' bootpfile - BOOTP bootable image (arch/alpha/boot/bootpfile)' echo ' bootpzfile - compressed kernel BOOTP image (arch/alpha/boot/boot= pzfile)' diff --git a/arch/alpha/boot/.gitignore b/arch/alpha/boot/.gitignore new file mode 100644 index 000000000000..4125506521f6 --- /dev/null +++ b/arch/alpha/boot/.gitignore @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +vmlinuz diff --git a/arch/alpha/boot/Makefile b/arch/alpha/boot/Makefile index d8dba85e606c..7c2a41c1e2a0 100644 --- a/arch/alpha/boot/Makefile +++ b/arch/alpha/boot/Makefile @@ -9,9 +9,10 @@ # =20 hostprogs :=3D tools/mkbb tools/objstrip -targets :=3D vmlinux.gz vmlinux \ +targets :=3D vmlinuz vmlinux \ vmlinux.nh tools/lxboot tools/bootlx tools/bootph \ - tools/bootpzh bootloader bootpheader bootpzheader=20 + tools/bootpzh bootloader bootpheader bootpzheader +subdir- :=3D compressed OBJSTRIP :=3D $(obj)/tools/objstrip =20 KBUILD_HOSTCFLAGS :=3D -Wall -I$(objtree)/usr/include @@ -38,9 +39,14 @@ ifdef INITRD cat $(INITRD) >> $@ endif =20 -# Compressed kernel image -$(obj)/vmlinux.gz: $(obj)/vmlinux FORCE - $(call if_changed,gzip) +# Self-extracting compressed kernel image: a small ELF stub (see +# compressed/) with the real vmlinux linked in compressed, which aboot +# loads and enters like a plain vmlinux. +$(obj)/compressed/vmlinux: vmlinux FORCE + $(Q)$(MAKE) $(build)=3D$(obj)/compressed $@ + +$(obj)/vmlinuz: $(obj)/compressed/vmlinux FORCE + $(call if_changed,copy) @echo ' Kernel $@ is ready' =20 $(obj)/main.o: $(obj)/ksize.h diff --git a/arch/alpha/boot/compressed/.gitignore b/arch/alpha/boot/compre= ssed/.gitignore new file mode 100644 index 000000000000..765a08f1bd77 --- /dev/null +++ b/arch/alpha/boot/compressed/.gitignore @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +vmlinux +vmlinux.lds diff --git a/arch/alpha/boot/compressed/Makefile b/arch/alpha/boot/compress= ed/Makefile new file mode 100644 index 000000000000..d826f7e4384d --- /dev/null +++ b/arch/alpha/boot/compressed/Makefile @@ -0,0 +1,36 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Create a self-extracting compressed vmlinux image from the original +# vmlinux. aboot loads and enters it like a plain vmlinux. +# + +OBJECTS :=3D head.o misc.o trampoline.o piggy.o +targets :=3D vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz +targets +=3D $(OBJECTS) + +# The stub runs before the kernel has identified the CPU it booted on, so +# build it for the base Alpha instruction set rather than inheriting the +# kernel's -mcpu=3D. +KBUILD_CFLAGS :=3D -D__KERNEL__ -std=3Dgnu11 -Os -fno-strict-aliasing +KBUILD_CFLAGS +=3D -fno-PIE -ffreestanding -fno-stack-protector +KBUILD_CFLAGS +=3D -fno-asynchronous-unwind-tables +KBUILD_CFLAGS +=3D -pipe -mno-fp-regs -ffixed-8 +KBUILD_CFLAGS +=3D -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS +KBUILD_CFLAGS +=3D $(CC_FLAGS_DIALECT) + +LDFLAGS_vmlinux :=3D -X --orphan-handling=3Dwarn -T +$(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBS= _Y) FORCE + $(call if_changed,ld) + +OBJCOPYFLAGS_vmlinux.bin :=3D -R .comment -R .note -S +$(obj)/vmlinux.bin: vmlinux FORCE + $(call if_changed,objcopy) + +suffix-$(CONFIG_KERNEL_GZIP) :=3D gz + +$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE + $(call if_changed,gzip) + +LDFLAGS_piggy.o :=3D -r --format binary --oformat elf64-alpha -T +$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE + $(call if_changed,ld) diff --git a/arch/alpha/boot/compressed/head.S b/arch/alpha/boot/compressed= /head.S new file mode 100644 index 000000000000..c689ac439d15 --- /dev/null +++ b/arch/alpha/boot/compressed/head.S @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Entry point for the self-extracting compressed kernel stub. aboot + * jumps here with the OSF/1 parameter page (ZERO_PGE) already populated + * and $30 set to INIT_STACK, exactly as it would for an uncompressed + * vmlinux. + */ + +#include +#include + + .set noreorder + +__HEAD + .globl __start + .ent __start +__start: + br $29,1f +1: ldgp $29,0($29) + + /* + * Clear our own bss. The decompressors keep state there, and + * nothing guarantees that aboot zeroed the part of our PT_LOAD + * segment that has no file backing. + */ + lda $1,_bss + lda $2,_ebss +2: cmpult $1,$2,$3 + beq $3,3f + stq $31,0($1) + addq $1,8,$1 + br $31,2b + +3: jsr $26,decompress_and_boot + call_pal PAL_halt + .end __start diff --git a/arch/alpha/boot/compressed/misc.c b/arch/alpha/boot/compressed= /misc.c new file mode 100644 index 000000000000..72998582be68 --- /dev/null +++ b/arch/alpha/boot/compressed/misc.c @@ -0,0 +1,178 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Decompression and self-relocation for the compressed kernel boot stub, + * based on arch/parisc/boot/compressed/misc.c. + * + * aboot loads the stub as an ordinary ELF at START_ADDR and jumps to it + * with the parameter page and stack already set up; vmlinux.lds.S + * explains why the stub has to be linked there. We decompress above our + * own bss and never write below START_ADDR, so what aboot prepared stays + * valid for the real kernel. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#define STATIC static +#define memzero(s, n) memset((s), 0, (n)) + +extern char input_data[]; +extern int input_len; +/* output_len is inserted by the linker, possibly at an unaligned address = */ +extern char output_len; + +extern char _ebss[]; +extern char trampoline_start[], trampoline_end[]; + +static unsigned long free_mem_ptr; +static unsigned long free_mem_end_ptr; +static unsigned long mem_end; + +/* The stub has no console, so the message is only for debuggers. */ +void __noreturn error(char *m) +{ + while (1) + __halt(); +} + +#ifdef CONFIG_KERNEL_GZIP +#include "../../../../lib/decompress_inflate.c" +#endif + +/* Scratch heap for the decompressors, larger than any of them needs. */ +#define STUB_HEAP_SIZE (4 * 1024 * 1024) + +/* + * Type punning through a packed struct, to avoid the warnings the regular + * get_unaligned_le32() produces when reading a char-typed symbol as an + * integer. + */ +static u32 punned_get_unaligned_le32(const void *p) +{ + const struct { __le32 x; } __packed *pp =3D p; + + return le32_to_cpu(pp->x); +} + +/* + * End of the usable memory cluster that holds the kernel, or 0 if the + * HWRPB does not describe one. Used to check that the decompressed image + * and the stub's scratch space fit before anything is written. + */ +static unsigned long usable_memory_end(void) +{ + struct hwrpb_struct *hwrpb; + struct memdesc_struct *memdesc; + unsigned long pfn =3D (START_ADDR - PAGE_OFFSET) >> PAGE_SHIFT; + unsigned long i; + + hwrpb =3D (struct hwrpb_struct *)(PAGE_OFFSET + INIT_HWRPB->phys_addr); + memdesc =3D (struct memdesc_struct *)((unsigned long)hwrpb + + hwrpb->mddt_offset); + + for (i =3D 0; i < memdesc->numclusters; i++) { + struct memclust_struct *cluster =3D &memdesc->cluster[i]; + unsigned long end_pfn =3D cluster->start_pfn + cluster->numpages; + + if (cluster->usage) + continue; + if (pfn >=3D cluster->start_pfn && pfn < end_pfn) + return PAGE_OFFSET + (end_pfn << PAGE_SHIFT); + } + + return 0; +} + +/* + * Move the decompressed kernel's single PT_LOAD segment down onto + * START_ADDR and jump to its entry point. The kernel is always linked + * with exactly one PT_LOAD whose p_vaddr equals its e_entry equals + * START_ADDR (see arch/alpha/kernel/vmlinux.lds.S); anything else we do + * not know how to boot. + * + * The copy cannot run from this stub, which is itself executing at + * START_ADDR; see trampoline.S. + */ +static void __noreturn relocate_and_jump(void *image) +{ + void (*trampoline)(unsigned long dest, unsigned long src, + unsigned long filesz, unsigned long memsz, + unsigned long entry); + unsigned long tramp_len =3D trampoline_end - trampoline_start; + Elf64_Phdr phdr, load_phdr =3D {}; + Elf64_Ehdr ehdr; + int i, found_load =3D 0; + unsigned long tramp; + + memcpy(&ehdr, image, sizeof(ehdr)); + + if (ehdr.e_ident[EI_MAG0] !=3D ELFMAG0 || + ehdr.e_ident[EI_MAG1] !=3D ELFMAG1 || + ehdr.e_ident[EI_MAG2] !=3D ELFMAG2 || + ehdr.e_ident[EI_MAG3] !=3D ELFMAG3 || + ehdr.e_ident[EI_CLASS] !=3D ELFCLASS64 || + ehdr.e_ident[EI_DATA] !=3D ELFDATA2LSB || + ehdr.e_machine !=3D EM_ALPHA || + ehdr.e_type !=3D ET_EXEC || + ehdr.e_entry !=3D START_ADDR) + error("Not a bootable Alpha kernel image"); + + for (i =3D 0; i < ehdr.e_phnum; i++) { + memcpy(&phdr, image + ehdr.e_phoff + i * ehdr.e_phentsize, + sizeof(phdr)); + + if (phdr.p_type !=3D PT_LOAD) + continue; + if (found_load || phdr.p_vaddr !=3D START_ADDR) + error("Unexpected kernel segment layout"); + found_load =3D 1; + load_phdr =3D phdr; + } + if (!found_load) + error("Kernel image has no PT_LOAD segment"); + + /* + * The trampoline has to outlive both the scratch heap it is copied + * into and the region it is about to write, which extends past the + * kernel's file image to the end of its bss. + */ + tramp =3D ALIGN(max(free_mem_end_ptr, START_ADDR + load_phdr.p_memsz), 8); + if (mem_end && tramp + tramp_len > mem_end) + error("Not enough memory to relocate the kernel"); + + memcpy((void *)tramp, trampoline_start, tramp_len); + imb(); + + trampoline =3D (void *)tramp; + trampoline(load_phdr.p_vaddr, + (unsigned long)image + load_phdr.p_offset, + load_phdr.p_filesz, load_phdr.p_memsz, ehdr.e_entry); + unreachable(); +} + +void __noreturn decompress_and_boot(void) +{ + unsigned long image_len =3D punned_get_unaligned_le32(&output_len); + void *image =3D (void *)ALIGN((unsigned long)_ebss, PAGE_SIZE); + + free_mem_ptr =3D ALIGN((unsigned long)image + image_len, PAGE_SIZE); + free_mem_end_ptr =3D free_mem_ptr + STUB_HEAP_SIZE; + + mem_end =3D usable_memory_end(); + if (mem_end && free_mem_end_ptr > mem_end) + error("Not enough memory to decompress the kernel"); + + /* Some decompressors report failure only through the return value. */ + if (__decompress(input_data, input_len, NULL, NULL, image, image_len, + NULL, error)) + error("Kernel decompression failed"); + + relocate_and_jump(image); +} diff --git a/arch/alpha/boot/compressed/trampoline.S b/arch/alpha/boot/comp= ressed/trampoline.S new file mode 100644 index 000000000000..bf57d3b0fd7f --- /dev/null +++ b/arch/alpha/boot/compressed/trampoline.S @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copy the decompressed kernel onto START_ADDR, clear its bss and jump to + * its entry point. See relocate_and_jump() in misc.c for why this cannot + * run from the stub itself. It is position independent (no data or + * rodata references, no gp) and clobbers only its argument registers and + * $1, so misc.c can copy it anywhere and call it there. + */ + + .set noreorder + + .globl trampoline_start + .globl trampoline_end + .ent trampoline_start +trampoline_start: + /* $16 =3D dest, $17 =3D src, $18 =3D p_filesz, $19 =3D p_memsz, $20 =3D = entry */ + + /* + * dest and src are both page aligned, and everything above + * p_filesz is bss, so round both lengths up and work in quadwords + * only, using instructions every Alpha implements. + */ + addq $18,7,$18 + bic $18,7,$18 + addq $19,7,$19 + bic $19,7,$19 + subq $19,$18,$19 /* bytes to zero after the copy */ + +1: beq $18,2f + ldq $1,0($17) + stq $1,0($16) + addq $17,8,$17 + addq $16,8,$16 + subq $18,8,$18 + br $31,1b + +2: beq $19,3f + stq $31,0($16) + addq $16,8,$16 + subq $19,8,$19 + br $31,2b + +3: imb + jmp $31,($20) + .end trampoline_start +trampoline_end: diff --git a/arch/alpha/boot/compressed/vmlinux.lds.S b/arch/alpha/boot/com= pressed/vmlinux.lds.S new file mode 100644 index 000000000000..5328c1ccaccf --- /dev/null +++ b/arch/alpha/boot/compressed/vmlinux.lds.S @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include +#include +#include + +OUTPUT_FORMAT("elf64-alpha") +OUTPUT_ARCH(alpha) +ENTRY(__start) + +SECTIONS +{ + /* + * Link the stub at the address the real, uncompressed vmlinux has + * always occupied. aboot derives the OSF/1 parameter-page + * (ZERO_PGE) and initial stack (INIT_STACK) addresses from the + * loaded image's own p_vaddr, so a stub linked anywhere else would + * hand the real kernel a parameter page it does not expect. + */ + . =3D START_ADDR; + + .head.text : { + _head =3D .; + HEAD_TEXT + _ehead =3D .; + } + + . =3D ALIGN(8); + .rodata.compressed : { + *(.rodata.compressed) + } + + . =3D ALIGN(PAGE_SIZE); + .text : { + _text =3D .; + *(.text) + *(.text.*) + _etext =3D .; + } + . =3D ALIGN(8); + .rodata : { + *(.rodata) + *(.rodata.*) + } + . =3D ALIGN(8); + .data : { + *(.data) + *(.data.*) + } + .got : { + *(.got) + } + .sdata : { + *(.sdata) + } + /* + * misc.c decompresses to _ebss, so nothing that the stub still + * needs may be placed after .bss. --orphan-handling=3Dwarn keeps a + * new section from silently landing there. + */ + . =3D ALIGN(8); + .bss : { + _bss =3D .; + *(.sbss) + *(.scommon) + *(.bss) + *(.bss.*) + *(COMMON) + . =3D ALIGN(8); + _ebss =3D .; + } + + STABS_DEBUG + DWARF_DEBUG + ELF_DETAILS + + DISCARDS + /DISCARD/ : { + *(.eh_frame) + *(.modinfo) + *(.note) + *(.note.*) + } +} diff --git a/arch/alpha/boot/compressed/vmlinux.scr b/arch/alpha/boot/compr= essed/vmlinux.scr new file mode 100644 index 000000000000..dac2d142bcfa --- /dev/null +++ b/arch/alpha/boot/compressed/vmlinux.scr @@ -0,0 +1,10 @@ +SECTIONS +{ + .rodata.compressed : { + input_len =3D .; + LONG(input_data_end - input_data) input_data =3D .; + *(.data) + output_len =3D . - 4; /* can be at unaligned address */ + input_data_end =3D .; + } +} --=20 2.54.0 From nobody Fri Sep 25 12:37:28 2026 Received: from mail-yx2-f12.google.com (mail-yx2-f12.google.com [74.125.224.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5DD4390603 for ; Sat, 12 Sep 2026 19:55:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789242956; cv=none; b=Bgm9HJP6XiXYDgEIwgVrgaBhdGxFEAUJQ17aA8BIcUOcAEKMwr51fNNV10T9wR2xkNOGyJ3GyTZRDErALPV25Oqs6g/gK2O9P7nO6vNC6V9ysXRwl2eW2SMX3zSB1DzVFBtB6DhKBzFqiA0eFOsotaHUMwiseRiAUM8R9DgFzjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789242956; c=relaxed/simple; bh=Z9d6JzR5Uhj2Cd5rBHm8HgYcaDCfhxyZeJSyHLpwZiI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IycJu0Bs2GQCs1M/n/SpC2eoaSGuRTlpyZKHIQnIIlCHfc9+NcuoH1oNFw7SyV8qcf4U+yWR4jHLPyQ9PwdNV/FeWiH+IUDaVvLCR8/QPCMd2XOE24hpY0HS/Tm5xBiKW1N2UonoK0CpCym5Z0Z+BcRtqvzSVmXB3Zc/XkKYyxc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IgMI95U7; arc=none smtp.client-ip=74.125.224.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IgMI95U7" Received: by mail-yx2-f12.google.com with SMTP id 956f58d0204a3-66e4ab201f9so626587d50.0 for ; Sat, 12 Sep 2026 12:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789242954; x=1789847754; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WOUV8mAvBSbMZ90ppsa99TwLjB+SJahPtVIVptfXwoQ=; b=IgMI95U7JeCauiO2fdlZZ2K+CnSB84Q0L3n3aavqARJr8ocrLnPwwkZYJU1kxC49QN z2/UKCZiTyVNcka87BDXzbCBdfo1TbApMnOXhoffcO5wGDOCGiZFb3DofRWJBdUJU3tn iESuB4VNyLYCrEw0nYgu+Mj4fY7wRHqP01Gma0bKiqm3OrbQESdsYynfChnpA9D7p5yk K7PTe7mvzcpJhdQMA17b1Bbe8HH8vmPcjI6Naq2C5dKrEDUxoYGNugUtpKmP15SFaE2S z4auoJeSRwfS/VOAlf57RMdbgMC+3A9V3Joy8tCPDtrwlNtA0s2/lRl8uLY1yh1SAAKj zKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789242954; x=1789847754; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=WOUV8mAvBSbMZ90ppsa99TwLjB+SJahPtVIVptfXwoQ=; b=Ur9hUjK59vpaxAH7SRPlmyqT+JSrcWiDfH8FgaqADR8QoC22JZ/tQVTmb11u9CM5UT td13rcHkwRG6pEiyT3MFo8NVr9SNp5X3quFhdXQQpY77XBG9WBIttA0gx7/ghtMt87tA tqQkB8k0vto2/T/33RxYClhFHgU4Pum+iLt29zRdO+xyIVt918Ny4DtMWpjTvyy+n1+N Xt3XG6mcFGstCaXAxAWIqlD42TNOwav+sCWv3tLv/vmTPCOFwrVJ45BEyRTeqKUORaU3 aTo12tGqDuiA1BcrX5L2+sw+dMkY3HzTlwLUZHZaq0xReqde8cuXf8qIrSlnTxoOtxWf ETmA== X-Gm-Message-State: AFuF++mJOfyjThlChd4eCV8hD9s9FyLHK+7byHgkrA8xJcrzrAW3vwS1 wwbahNSl8mqJKQHAMEXp+oYq1y8388E4pJi639lHMK5uqgbVoYzPWqWNjXSgu2qS X-Gm-Gg: AYBFou1Ejr4RGiss4++X1Z6OihqO6wwSlut8wXTggPTaXh1aePIJ+ug5+dFYtQVgWIW cIgdL50ixti7n709S+CFpeaQuA/S7arBxmPeU/LpDa/1/osiEGFWF24iUkTriRI85+qLs7HYmGy mouLWxRUVA05mx1yWmFJp5bWEzWZWtoSudlxsVjE9mWP4iGRJfGVTFG8zD24703aYFurKgejGez +kVs7IESSGcbupAW8Wal26Ew3KBzD/R9FAftaDU99W8exfZlFe9r/cB9bCk3yUjJavC4AY/+9M6 4FyL/eXGl4BTPjnEWhaYx5PrD47C6L52ahFA80ILi1sPtQzYtcUlTR9SkGiFQmlMCIuV6P080Vp J2D6n4jfu/r1CwdjO9bZyUiDrCQ+Gv2fcVvdyHaNc3bi9P4M+sETe8objVwESYTvj70lN7XIsRx ImXvVa/2UXbMVTXEzaMNwpY5nk67rwLaATVWuMYiGdwI8k2bneZdsO5Sd+uwcKft1/jJJvbJq9s RkFq2/0tw== X-Received: by 2002:a05:690e:4198:b0:671:22e4:6602 with SMTP id 956f58d0204a3-671249bc6abmr2628896d50.56.1789242953751; Sat, 12 Sep 2026 12:55:53 -0700 (PDT) Received: from localhost ([2600:1702:7a90:6f9f:8bc4:8aec:108d:7a04]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67125ea8a35sm2596291d50.19.2026.09.12.12.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Sep 2026 12:55:52 -0700 (PDT) From: Matt Turner Date: Sat, 12 Sep 2026 15:55:45 -0400 Subject: [PATCH 3/3] alpha: support the remaining kernel compression formats Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260912-alpha-kernel-compression-v1-3-ce9d55330193@gmail.com> References: <20260912-alpha-kernel-compression-v1-0-ce9d55330193@gmail.com> In-Reply-To: <20260912-alpha-kernel-compression-v1-0-ce9d55330193@gmail.com> To: Lasse Collin , Richard Henderson , Magnus Lindholm , Nick Terrell , David Sterba Cc: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, Matt Turner X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5407; i=mattst88@gmail.com; h=from:subject:message-id; bh=Z9d6JzR5Uhj2Cd5rBHm8HgYcaDCfhxyZeJSyHLpwZiI=; b=owGbwMvMwCW25rVmCc8sv+mMp9WSGLKWrrN3mXlr06yVbtr7+fLsO02O7RAUmNV4Jvnp7VdN2 T6Hy2af6/jIwiDGxTBTTJElbr0iy6y2HUt9Tkv/gpnDygQyRFqkgQEIWBj4chPzSo10jPRMtQ31 DIEMHaN4iJweg0ZmcXFpapFuWkGRQ15+SWJJZn5esV5+QWpeQXqBXlpmWklGRn5RcSrQCL281BJ TV0c3I0MDE0tHCzMnC0dTE2dnJ0MnN0dHZ1cnI0tzEwNnS0cTV0tzBi5OAZhrJuUyMixw3xVXML nueq+j4OW4NRUv+t/l2z8y5m2+eDPsxLQ9ywsZGd7GdtWueepzOWDxhqJkuVdCDpx7bDslNuqd3 WsnbrTlBxsA X-Developer-Key: i=mattst88@gmail.com; a=openpgp; fpr=3BB639E56F861FA2E86505690FDD682D974CA72A Nothing about the boot stub is specific to gzip, so wire up bzip2, lz4, lzma, lzo, xz and zstd as well: select the matching HAVE_KERNEL_* symbol, add a suffix-y entry and a compression rule for the piggy-backed image, and include the decompressor into the stub's misc.c. Only gzip's trailer already carries the uncompressed size, so the other formats use the _with_size variants; output_len, which vmlinux.scr takes from the last 4 bytes of the payload, then works for all of them. The stub passes it to __decompress(), which zstd requires. Signed-off-by: Matt Turner Reviewed-by: Magnus Lindholm Tested-by: Magnus Lindholm Tested-by: Magnus Lindholm _LZO) :=3D lzo --- arch/alpha/Kconfig | 6 ++++++ arch/alpha/boot/compressed/Makefile | 31 +++++++++++++++++++++++++++++-- arch/alpha/boot/compressed/misc.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index 2688bb00f175..92cc7bb8d29a 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -30,7 +30,13 @@ config ALPHA select HAVE_ASM_MODVERSIONS select HAVE_DEBUG_KMEMLEAK select HAVE_GUP_FAST + select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_GZIP + select HAVE_KERNEL_LZ4 + select HAVE_KERNEL_LZMA + select HAVE_KERNEL_LZO + select HAVE_KERNEL_XZ + select HAVE_KERNEL_ZSTD select HAVE_PAGE_SIZE_8KB select HAVE_PCSPKR_PLATFORM select HAVE_PERF_EVENTS diff --git a/arch/alpha/boot/compressed/Makefile b/arch/alpha/boot/compress= ed/Makefile index d826f7e4384d..06deaf51fcfa 100644 --- a/arch/alpha/boot/compressed/Makefile +++ b/arch/alpha/boot/compressed/Makefile @@ -5,7 +5,10 @@ # =20 OBJECTS :=3D head.o misc.o trampoline.o piggy.o -targets :=3D vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz +targets :=3D vmlinux.lds vmlinux vmlinux.bin +targets +=3D vmlinux.bin.bz2 vmlinux.bin.gz vmlinux.bin.lz4 +targets +=3D vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.xz +targets +=3D vmlinux.bin.zst targets +=3D $(OBJECTS) =20 # The stub runs before the kernel has identified the CPU it booted on, so @@ -18,18 +21,42 @@ KBUILD_CFLAGS +=3D -pipe -mno-fp-regs -ffixed-8 KBUILD_CFLAGS +=3D -DDISABLE_BRANCH_PROFILING -D__DISABLE_EXPORTS KBUILD_CFLAGS +=3D $(CC_FLAGS_DIALECT) =20 +# zstd's decompressor uses __builtin_ctzll()/__builtin_clzll(). Those are +# inline code only with the CIX extension, which the base instruction set +# the stub is built for does not have, so they become calls to libgcc's +# __ctzdi2/__clzdi2. +LIBGCC :=3D $(shell $(CC) -print-libgcc-file-name) + LDFLAGS_vmlinux :=3D -X --orphan-handling=3Dwarn -T -$(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBS= _Y) FORCE +$(obj)/vmlinux: $(obj)/vmlinux.lds $(addprefix $(obj)/, $(OBJECTS)) $(LIBS= _Y) $(LIBGCC) FORCE $(call if_changed,ld) =20 OBJCOPYFLAGS_vmlinux.bin :=3D -R .comment -R .note -S $(obj)/vmlinux.bin: vmlinux FORCE $(call if_changed,objcopy) =20 +suffix-$(CONFIG_KERNEL_BZIP2) :=3D bz2 suffix-$(CONFIG_KERNEL_GZIP) :=3D gz +suffix-$(CONFIG_KERNEL_LZ4) :=3D lz4 +suffix-$(CONFIG_KERNEL_LZMA) :=3D lzma +suffix-$(CONFIG_KERNEL_LZO) :=3D lzo +suffix-$(CONFIG_KERNEL_XZ) :=3D xz +suffix-$(CONFIG_KERNEL_ZSTD) :=3D zst =20 +$(obj)/vmlinux.bin.bz2: $(obj)/vmlinux.bin FORCE + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE $(call if_changed,gzip) +$(obj)/vmlinux.bin.lz4: $(obj)/vmlinux.bin FORCE + $(call if_changed,lz4_with_size) +$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE + $(call if_changed,lzma_with_size) +$(obj)/vmlinux.bin.lzo: $(obj)/vmlinux.bin FORCE + $(call if_changed,lzo_with_size) +$(obj)/vmlinux.bin.xz: $(obj)/vmlinux.bin FORCE + $(call if_changed,xzkern_with_size) +$(obj)/vmlinux.bin.zst: $(obj)/vmlinux.bin FORCE + $(call if_changed,zstd22_with_size) =20 LDFLAGS_piggy.o :=3D -r --format binary --oformat elf64-alpha -T $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE diff --git a/arch/alpha/boot/compressed/misc.c b/arch/alpha/boot/compressed= /misc.c index 72998582be68..8ffc546e1a15 100644 --- a/arch/alpha/boot/compressed/misc.c +++ b/arch/alpha/boot/compressed/misc.c @@ -23,6 +23,13 @@ #define STATIC static #define memzero(s, n) memset((s), 0, (n)) =20 +/* + * decompress_unxz.c supplies its own memmove() unless the identifier is + * already a macro. arch/alpha/lib/ has a better one and is already on + * our link line, so take that instead. + */ +#define memmove memmove + extern char input_data[]; extern int input_len; /* output_len is inserted by the linker, possibly at an unaligned address = */ @@ -42,10 +49,34 @@ void __noreturn error(char *m) __halt(); } =20 +#ifdef CONFIG_KERNEL_BZIP2 +#include "../../../../lib/decompress_bunzip2.c" +#endif + #ifdef CONFIG_KERNEL_GZIP #include "../../../../lib/decompress_inflate.c" #endif =20 +#ifdef CONFIG_KERNEL_LZ4 +#include "../../../../lib/decompress_unlz4.c" +#endif + +#ifdef CONFIG_KERNEL_LZMA +#include "../../../../lib/decompress_unlzma.c" +#endif + +#ifdef CONFIG_KERNEL_LZO +#include "../../../../lib/decompress_unlzo.c" +#endif + +#ifdef CONFIG_KERNEL_XZ +#include "../../../../lib/decompress_unxz.c" +#endif + +#ifdef CONFIG_KERNEL_ZSTD +#include "../../../../lib/decompress_unzstd.c" +#endif + /* Scratch heap for the decompressors, larger than any of them needs. */ #define STUB_HEAP_SIZE (4 * 1024 * 1024) =20 --=20 2.54.0