From nobody Mon Jun 8 07:26:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1780476842; cv=none; d=zohomail.com; s=zohoarc; b=RKg6skTvqRI6H31uU/qISnYaqHQII3OyOUteEO9gu4e00yLGduz9OyR8iI24zzkGP0UnDQ8aX8CEZobK3HRrSAVaIdOfkTBsUX98djjK0811x4r7TPsUNZJAFNkboU4cghNtZ7F8iQV/9CYrZnT56qAdiUp9Y0/xgyBenaZGriw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780476842; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=w38Yjl39w+6P4RkuP/+W/4L2yeNf72EBMIuJEUD/P7o=; b=a+Iyb9E6Wh3i7TmLQDkGWALDwP45grQDhfPCfd5uoo+b3Zw4RxgvzXXV9p0Cxovm8TviM39gGXZJ1/UrXHabRYb9BsgtAset0ut4hrg7Q5EGA8qF7sXcDm4TKU3qW0H5hkc8T0yV39m2D+ck0nBfSJ9xusUal7DNleuiBk8voB8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780476842081478.6022600880374; Wed, 3 Jun 2026 01:54:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1325896.1591258 (Exim 4.92) (envelope-from ) id 1wUhM6-0003OD-9J; Wed, 03 Jun 2026 08:53:42 +0000 Received: by outflank-mailman (output) from mailman id 1325896.1591258; Wed, 03 Jun 2026 08:53:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wUhM6-0003Nc-2z; Wed, 03 Jun 2026 08:53:42 +0000 Received: by outflank-mailman (input) for mailman id 1325896; Wed, 03 Jun 2026 08:53:40 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wUhM4-0003L5-Bh for xen-devel@lists.xenproject.org; Wed, 03 Jun 2026 08:53:40 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wUhM3-006GVP-OU for xen-devel@lists.xenproject.org; Wed, 03 Jun 2026 10:53:39 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a1feb8e-e002-0a2a0a5209dd-0a2a450ac73c-26 for ; Wed, 03 Jun 2026 10:53:39 +0200 Received: from [209.85.128.45] (helo=mail-wm1-f45.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a1feb93-56b3-0a2a450a0019-d155802da550-3 for ; Wed, 03 Jun 2026 10:53:39 +0200 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490b3e03939so3652785e9.1 for ; Wed, 03 Jun 2026 01:53:39 -0700 (PDT) Received: from localhost.localdomain (host-78-146-242-105.as13285.net. [78.146.242.105]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b7c6b966sm24070335e9.2.2026.06.03.01.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 01:53:38 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1780476819; x=1781081619; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w38Yjl39w+6P4RkuP/+W/4L2yeNf72EBMIuJEUD/P7o=; b=R9bwjgl7k1Xl5kEe1Q6UPbX2RhhBioOCLWyOXTZZn/zi76FHc99LYcR49+wIuX1W8q rA1B3ARTsQcvBDhhzitKUt+HmbWRA528TRAEkbYse5fPTbyTwRkFZ6JnsapKeOkzXamf WinV+Y2+hpWSuSkH90h2SPJabNQB/6w2Bt1hM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780476819; x=1781081619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=w38Yjl39w+6P4RkuP/+W/4L2yeNf72EBMIuJEUD/P7o=; b=WIWkHERV33QAV1EnILeqGrP+PugI7OyUJIFaWSeBYyxtPgk0UITuGomqygE+VtIYag iKzzZ5j1jHjGWtW/Usn//L6WKhCIU4U+FICSe0l+Ed01/J3jr5sBiMkIzm7uF6vmVg6H Ml7w9Z07QDnWysV/4IxQ+CKgHqhmXfibsaVdxtUnDLQnEwkt/Nqmn/0NMXOOr7oa9mcs OBj0vwVrBrtAqwIXIiguiH+BKW1zJMqRmCYre/5GxpGb8Alnznv93HBErp9XYO7HBO7+ vCrtlv6Qk5DmyzQ2E058fO1UhNEcmRPS1SnEDkjqoTyT4kX97jBcrYUjRYnmCulUDM9I dJ0Q== X-Gm-Message-State: AOJu0Yy0UEIk/Hy7J//mIS2MSDca6HP+Vtn+Bv5TjMq/qfnsEx/L91OL YgyhebnVo+HZn9Lyr+AlnWZ56zPy9StjB2PhEkjgC6MiYU7bPYBJHbwwJcvivqjldPK5hzx/4M+ 6lL3F X-Gm-Gg: Acq92OEdDO66Nu3rhUBCnntiY0kxe7wBIjSNUQ+AyN+FdvJqhgO/hp45l8VRTh4Ikju l9kpAVfWZDVXD+Wb45z001KL/OhCkO0TxqZ+4e2HwlHuPOqk5kS0wqmNx64xKMPRddb+uuTsI4t BpiBgMEb0/6rAR+eQQ8nPY36iIE6R7/I5gUyY++eYJHe+x9GAi94qqJDUZu+wt+XAcJ/tUkE2Q6 WhJFLz+VmSyYqyJHQ1TXKwZoV6hiQZv2yk+Z2RsJ8VUXq6ygEXPsxBBf5B1xGI6Ha02tiTBxtg3 2SiFyXJCYkBprt+Uz1NFNuCDsGeRiHDLLLkcOKY8NfY+pX+OGufaYfzXWV78gJwHOwcei5cMcLX uXUNDmeIOX1D866c1NPlnd/c0a1vRsZng/hFKXNKMCgS3gebLGzpY7EngprhmPNHNgzxi5l64Zd f1KxM6DQzf5LIamK0hViX3RSDIxOxNleApHB6lqAHKhVQLtcwYsrwCmKsUM6ijxfRGoKrJIcdoY 4cN3yxL6bbiDzw= X-Received: by 2002:a05:600c:8b2a:b0:490:3cf0:8d81 with SMTP id 5b1f17b1804b1-490b614df8dmr29300895e9.13.1780476818608; Wed, 03 Jun 2026 01:53:38 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Anthony PERARD , Juergen Gross , Oleksii Kurochko Subject: [PATCH 1/2] tools/configure: Detect the presence of liblz4 Date: Wed, 3 Jun 2026 09:53:30 +0100 Message-Id: <20260603085331.2704108-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260603085331.2704108-1-andrew.cooper3@citrix.com> References: <20260603085331.2704108-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1780476819-70F618B7-EB8F556F/10/73395122804 X-purgate-type: spam X-purgate-size: 5741 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1780476844508154100 Content-Type: text/plain; charset="utf-8" As with other compression libraries, group liblz4 into ZLIB_{CFLAGS,LIBS}. Add the packages to the Debian Trixie build containers for coverage. Signed-off-by: Andrew Cooper --- CC: Anthony PERARD CC: Juergen Gross CC: Oleksii Kurochko Rebuild the containers when pushed. --- automation/build/debian/13-arm64v8.dockerfile | 1 + automation/build/debian/13-x86_64.dockerfile | 1 + tools/configure | 79 +++++++++++++++++++ tools/configure.ac | 4 + 4 files changed, 85 insertions(+) diff --git a/automation/build/debian/13-arm64v8.dockerfile b/automation/bui= ld/debian/13-arm64v8.dockerfile index b9062ee8b443..ee9bb841eb92 100644 --- a/automation/build/debian/13-arm64v8.dockerfile +++ b/automation/build/debian/13-arm64v8.dockerfile @@ -28,6 +28,7 @@ RUN <&6; } ZLIB_LIBS=3D"$ZLIB_LIBS $libzstd_LIBS" fi =20 +pkg_failed=3Dno +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for liblz4" >&5 +printf %s "checking for liblz4... " >&6; } + +if test -n "$liblz4_CFLAGS"; then + pkg_cv_liblz4_CFLAGS=3D"$liblz4_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists = --print-errors \"liblz4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "liblz4") 2>&5 + ac_status=3D$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? =3D $ac_status" >&5 + test $ac_status =3D 0; }; then + pkg_cv_liblz4_CFLAGS=3D`$PKG_CONFIG --cflags "liblz4" 2>/dev/null` + test "x$?" !=3D "x0" && pkg_failed=3Dyes +else + pkg_failed=3Dyes +fi + else + pkg_failed=3Duntried +fi +if test -n "$liblz4_LIBS"; then + pkg_cv_liblz4_LIBS=3D"$liblz4_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists = --print-errors \"liblz4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "liblz4") 2>&5 + ac_status=3D$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? =3D $ac_status" >&5 + test $ac_status =3D 0; }; then + pkg_cv_liblz4_LIBS=3D`$PKG_CONFIG --libs "liblz4" 2>/dev/null` + test "x$?" !=3D "x0" && pkg_failed=3Dyes +else + pkg_failed=3Dyes +fi + else + pkg_failed=3Duntried +fi + + + +if test $pkg_failed =3D yes; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=3Dyes +else + _pkg_short_errors_supported=3Dno +fi + if test $_pkg_short_errors_supported =3D yes; then + liblz4_PKG_ERRORS=3D`$PKG_CONFIG --short-errors --print-errors --= cflags --libs "liblz4" 2>&1` + else + liblz4_PKG_ERRORS=3D`$PKG_CONFIG --print-errors --cflags --libs "= liblz4" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$liblz4_PKG_ERRORS" >&5 + + true +elif test $pkg_failed =3D untried; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + true +else + liblz4_CFLAGS=3D$pkg_cv_liblz4_CFLAGS + liblz4_LIBS=3D$pkg_cv_liblz4_LIBS + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +printf "%s\n" "yes" >&6; } + ZLIB_CFLAGS=3D"$ZLIB_CFLAGS -DHAVE_LZ4 $liblz4_CFLAGS" + ZLIB_LIBS=3D"$ZLIB_LIBS $liblz4_LIBS" +fi + =20 =20 ac_fn_c_check_header_compile "$LINENO" "ext2fs/ext2fs.h" "ac_cv_header_ext= 2fs_ext2fs_h" "$ac_includes_default" diff --git a/tools/configure.ac b/tools/configure.ac index ecd45e782eb8..74b9f56025cb 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -403,6 +403,10 @@ PKG_CHECK_MODULES([libzstd], [libzstd], [ZLIB_CFLAGS=3D"$ZLIB_CFLAGS -DHAVE_ZSTD $libzstd_CFLAGS" ZLIB_LIBS=3D"$ZLIB_LIBS $libzstd_LIBS"], [true]) +PKG_CHECK_MODULES([liblz4], [liblz4], + [ZLIB_CFLAGS=3D"$ZLIB_CFLAGS -DHAVE_LZ4 $liblz4_CFLAGS" + ZLIB_LIBS=3D"$ZLIB_LIBS $liblz4_LIBS"], + [true]) AC_SUBST([ZLIB_CFLAGS]) AC_SUBST([ZLIB_LIBS]) AX_CHECK_EXTFS --=20 2.39.5 From nobody Mon Jun 8 07:26:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1780476834; cv=none; d=zohomail.com; s=zohoarc; b=LZALQjM+ij0W5yzROViN9EI/LYG+k9AeCPf6mHORMEpB3Jiy6OqdlvHuvhpA4EfX61xOie0KOlWjcCEEuz8K9gYUaRoRR3ZQS2ZTL7lEu+tx8SYaQGZJjPP7fuuV/XAwVvQqBOL7fl9Uym12neV33zXpXom6c9ix/Y9pWuFb3xY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780476834; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7G9hdlfubYAVkY5BTqL/WBD4kbNC0poE5EI/Mq9Bxg0=; b=UBdOizg9HaPbKncHRu1IFpV+7tQM2+Yi12fgbeZ5J3IuWJeG6CMlkoS4OvRI6SS12n0xxHmxaH2J+8hQLhzVNFtLahZMC3mmrNREjYKhK9D6bw7I5JW2n6LKFcqC9ZbFNhXF9e9dj5uWrSuyxQv3zE0JD7rGHUQvQjK/q1PrI7g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780476834577311.68639070468566; Wed, 3 Jun 2026 01:53:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1325897.1591263 (Exim 4.92) (envelope-from ) id 1wUhM6-0003VY-IP; Wed, 03 Jun 2026 08:53:42 +0000 Received: by outflank-mailman (output) from mailman id 1325897.1591263; Wed, 03 Jun 2026 08:53:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wUhM6-0003Ux-Cm; Wed, 03 Jun 2026 08:53:42 +0000 Received: by outflank-mailman (input) for mailman id 1325897; Wed, 03 Jun 2026 08:53:40 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wUhM4-0003L6-Dq for xen-devel@lists.xenproject.org; Wed, 03 Jun 2026 08:53:40 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wUhM3-006GVP-Qd for xen-devel@lists.xenproject.org; Wed, 03 Jun 2026 10:53:39 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a1feb91-e002-0a2a0a5209dd-0a2a450cddea-16 for ; Wed, 03 Jun 2026 10:53:39 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a1feb93-62f1-0a2a450c0019-d155802cc043-3 for ; Wed, 03 Jun 2026 10:53:39 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4903f7a90d1so113292725e9.2 for ; Wed, 03 Jun 2026 01:53:39 -0700 (PDT) Received: from localhost.localdomain (host-78-146-242-105.as13285.net. [78.146.242.105]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490b7c6b966sm24070335e9.2.2026.06.03.01.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 01:53:38 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1780476819; x=1781081619; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7G9hdlfubYAVkY5BTqL/WBD4kbNC0poE5EI/Mq9Bxg0=; b=CwCbnY1b5UdGD0Eu1sUlOOofdu+IQaHFUCyaTwsaWsUTZvmtAYzf1WXoe+tj5F5lwB hBHTKeIBTzFCJ3cGiA+VtARLKMHxD7AvBwK1zOz/Cjwt9BwT4QQhUA3IMAqWxlnKS7jS b7xMQhJ9rd7KLXU0GjfiD+v0fWK8OAZSktwj0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780476819; x=1781081619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7G9hdlfubYAVkY5BTqL/WBD4kbNC0poE5EI/Mq9Bxg0=; b=Yn7h+MowgG+NyjmZywyJqZaYJrEPNjQ2YWTZdXuDsuccIe7MIM3NjUg2s18ultMw5P DNjgFIaW0MGhITtZNwA5IARRmHCr1lJb4WrKaxHJq48DJOhNgrDNEuUTp8y7zcq6r944 AK4uHvONbRd7NBte7Ktba1jrV6hESpzx88A9Souu2wVRfx/F14kwoTC57BCyIv7Sinnq kOHHLFJYmiHzPOulM8kCIm6ncfRG+yhKQ4ESR6vf+/m2AzlA3Sc9Cdl3zNGoXmjsMrR3 qahf1Lqv8qQ0bwxLYulrHdSjoa7kCp+sRuoHHfu/q7NW0jEcx10YDBtOiFahzA97lCZl olbg== X-Gm-Message-State: AOJu0YwZ5u0aODpvpX+yJoGjGNCUbdX6trJ2bhhY+nRhXq7Lwu/xjkHC jPR90WOCiI70qj44JU3o73O3Tbi+2UrmUSPEVg30dKWWkQEUM5DP5OOerlXMN5X74oHsWowUaiF vQ7YK X-Gm-Gg: Acq92OGaJyMVW8s3DTXGh5YMsgPX+2evR9WVmpENBxTFVskqcmKGT9ZyQrP+Pxvvonj YiydUhuuWFGD5XNIU5og7bE2rrOJiZuiSa9FbnKHY2Gh8lSfZpVvD7eLj84ingsL7ANOC5t8RBZ oVGwroL73oEU0y8dXO0Exo9XHSYi41tBTOxGHtsalfFRBUReKPJjxFsmTB1NVRM9+DrDky94zfX kSWetca0paH80Zy2sV32xxHxN7Ffxivj78c9N+j5U0wSdpV1IMUNawRrr1cy9gW3c9zHCCE4KDv 1NL7qWqx8NXC8KzB9N4yo+hcsv6xIyCs3BBv08Dded+5j7JS92DYNO2cEDhrmDvzdpm9tF6HPkR 0sY4eb88MeqwZa3fKFcv6mBX6BnzYpgWCM/5wxiftAaa51O0gNps7lLGus1kbMvkEMBQ/JM9e69 EO9cwQtm8uERK/yOLPE3uVn5u+8AmZWyJZV10mKf+PcGihxI4gSbAqrS1Y5Ovv93+CSrhRPpwfD ux6/yP4AULaFdsW8X/wXi6CwA== X-Received: by 2002:a05:600c:1d86:b0:48a:58ae:9938 with SMTP id 5b1f17b1804b1-490b5fe95ebmr39488945e9.19.1780476819121; Wed, 03 Jun 2026 01:53:39 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Anthony PERARD , Juergen Gross , Oleksii Kurochko Subject: [PATCH 2/2] tools/libs/guest: Use the system liblz4 in the bzimage loader Date: Wed, 3 Jun 2026 09:53:31 +0100 Message-Id: <20260603085331.2704108-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260603085331.2704108-1-andrew.cooper3@citrix.com> References: <20260603085331.2704108-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d25034/1780476819-D996DCF5-EAD92777/10/73395122804 X-purgate-type: spam X-purgate-size: 11004 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1780476837009158500 Content-Type: text/plain; charset="utf-8" Right now lz4, unlike every other compression scheme, unconditionally uses Xen's unsafe decompressor. Make it consistent with all other compression schemes by using liblz4. The unsafe decompression is still required for the MiniOS build, so rename xg_dom_decompress_lz4.c to xg_dom_decompress_unsafe_lz4.c and drop the non-MiniOS content. Signed-off-by: Andrew Cooper --- CC: Anthony PERARD CC: Juergen Gross CC: Oleksii Kurochko --- tools/libs/guest/Makefile.common | 2 +- tools/libs/guest/xg_dom_bzimageloader.c | 128 +++++++++++++++- tools/libs/guest/xg_dom_decompress.h | 6 - tools/libs/guest/xg_dom_decompress_lz4.c | 143 ------------------ tools/libs/guest/xg_dom_decompress_unsafe.h | 2 + .../libs/guest/xg_dom_decompress_unsafe_lz4.c | 39 +++++ 6 files changed, 169 insertions(+), 151 deletions(-) delete mode 100644 tools/libs/guest/xg_dom_decompress.h delete mode 100644 tools/libs/guest/xg_dom_decompress_lz4.c create mode 100644 tools/libs/guest/xg_dom_decompress_unsafe_lz4.c diff --git a/tools/libs/guest/Makefile.common b/tools/libs/guest/Makefile.c= ommon index b928a4a246a9..86b1f160e536 100644 --- a/tools/libs/guest/Makefile.common +++ b/tools/libs/guest/Makefile.common @@ -46,7 +46,6 @@ OBJS-y +=3D xg_dom_core.o OBJS-y +=3D xg_dom_boot.o OBJS-y +=3D xg_dom_elfloader.o OBJS-$(CONFIG_X86) +=3D xg_dom_bzimageloader.o -OBJS-$(CONFIG_X86) +=3D xg_dom_decompress_lz4.o OBJS-$(CONFIG_X86) +=3D xg_dom_hvmloader.o OBJS-$(CONFIG_ARM) +=3D xg_dom_armzimageloader.o OBJS-y +=3D xg_dom_binloader.o @@ -59,6 +58,7 @@ OBJS-$(CONFIG_ARM) +=3D xg_dom_arm.o ifeq ($(CONFIG_LIBXC_MINIOS),y) OBJS-y +=3D xg_dom_decompress_unsafe.o OBJS-y +=3D xg_dom_decompress_unsafe_bzip2.o +OBJS-y +=3D xg_dom_decompress_unsafe_lz4.o OBJS-y +=3D xg_dom_decompress_unsafe_lzma.o OBJS-y +=3D xg_dom_decompress_unsafe_lzo1x.o OBJS-y +=3D xg_dom_decompress_unsafe_xz.o diff --git a/tools/libs/guest/xg_dom_bzimageloader.c b/tools/libs/guest/xg_= dom_bzimageloader.c index 1fb4e5a1f728..32b3c682a447 100644 --- a/tools/libs/guest/xg_dom_bzimageloader.c +++ b/tools/libs/guest/xg_dom_bzimageloader.c @@ -32,7 +32,6 @@ #include =20 #include "xg_private.h" -#include "xg_dom_decompress.h" =20 #include =20 @@ -623,6 +622,133 @@ static int xc_try_zstd_decode( =20 #endif =20 +#if defined(HAVE_LZ4) + +#include + +#define ARCHIVE_MAGICNUMBER 0x184C2102 + +static int xc_try_lz4_decode(struct xc_dom_image *dom, void **blob, size_t= *size) +{ + size_t outsize, insize; + unsigned char *outbuf =3D NULL, *inp =3D *blob, *outp; + uint32_t chunksize; + + /* Magic, descriptor byte, and trailing size field. */ + if ( *size <=3D 8 ) + { + DOMPRINTF("LZ4: insufficient input data"); + goto err; + } + + insize =3D *size - 4; + outsize =3D get_unaligned_le32(*blob + insize); + + if ( xc_dom_kernel_check_size(dom, outsize) ) + { + DOMPRINTF("LZ4: output too large"); + goto err; + } + + outbuf =3D malloc(outsize); + if ( !outbuf ) + { + DOMPRINTF("LZ4: failed to alloc memory"); + goto err; + } + outp =3D outbuf; + + chunksize =3D get_unaligned_le32(inp); + if ( chunksize =3D=3D ARCHIVE_MAGICNUMBER ) + { + inp +=3D 4; + insize -=3D 4; + } + else + { + DOMPRINTF("LZ4: invalid header"); + goto err; + } + + for ( ;; ) + { + int dst_len, len; + + if ( insize < 4 ) + { + DOMPRINTF("LZ4: missing data"); + goto err; + } + + chunksize =3D get_unaligned_le32(inp); + inp +=3D 4; + insize -=3D 4; + + if ( chunksize =3D=3D ARCHIVE_MAGICNUMBER ) + continue; + + if ( chunksize > insize ) + { + DOMPRINTF("LZ4: insufficient input data"); + goto err; + } + + dst_len =3D outsize - (outp - outbuf); + len =3D LZ4_decompress_safe((const void *)inp, + (void *)outp, chunksize, dst_len); + + if ( len < 0 ) + { + DOMPRINTF("LZ4: decoding failed"); + goto err; + } + + outp +=3D len; + inp +=3D chunksize; + insize -=3D chunksize; + + if ( insize =3D=3D 0 ) + break; + } + + if ( (outp - outbuf) !=3D outsize ) + { + DOMPRINTF("LZ4: got 0x%zx bytes instead of 0x%zx", + outp - outbuf, outsize); + goto err; + } + + if ( xc_dom_register_external(dom, outbuf, outsize) ) + { + DOMPRINTF("LZ4: error registering stream output"); + goto err; + } + + DOMPRINTF("%s: LZ4 decompress OK, 0x%zx -> 0x%zx", + __FUNCTION__, insize, outsize); + + *blob =3D outbuf; + *size =3D outsize; + + return 0; + + err: + free(outbuf); + return -1; +} + +#else /* !defined(HAVE_LZ4) */ + +static int xc_try_lz4_decode(struct xc_dom_image *dom, void **blob, size_t= *size) +{ + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, + "%s: LZ4 decompress support unavailable\n", + __FUNCTION__); + return -1; +} + +#endif + #endif /* !__MINIOS__ */ =20 struct setup_header { diff --git a/tools/libs/guest/xg_dom_decompress.h b/tools/libs/guest/xg_dom= _decompress.h deleted file mode 100644 index d7a45f730d67..000000000000 --- a/tools/libs/guest/xg_dom_decompress.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifdef __MINIOS__ -# include "xg_dom_decompress_unsafe.h" -#endif - -int xc_try_lz4_decode(struct xc_dom_image *dom, void **blob, size_t *size); - diff --git a/tools/libs/guest/xg_dom_decompress_lz4.c b/tools/libs/guest/xg= _dom_decompress_lz4.c deleted file mode 100644 index 53ef0bf328ed..000000000000 --- a/tools/libs/guest/xg_dom_decompress_lz4.c +++ /dev/null @@ -1,143 +0,0 @@ -#include -#include -#include -#include - -#include INCLUDE_ENDIAN_H - -#define XG_NEED_UNALIGNED -#include "xg_private.h" -#include "xg_dom_decompress.h" - -#define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -#define likely(a) a -#define unlikely(a) a - -static inline uint16_t le16_to_cpu(uint16_t v) -{ -#if BYTE_ORDER =3D=3D BIG_ENDIAN - return __builtin_bswap16(v); -#else - return v; -#endif -} - -#include "../../xen/include/xen/lz4.h" -#include "../../xen/common/decompress.h" - -#ifndef __MINIOS__ - -#include "../../xen/common/lz4/decompress.c" - -#define ARCHIVE_MAGICNUMBER 0x184C2102 - -int xc_try_lz4_decode( - struct xc_dom_image *dom, void **blob, size_t *psize) -{ - int ret =3D -1; - unsigned char *inp =3D *blob, *output, *outp; - ssize_t size =3D *psize - 4; - size_t out_len, dest_len, chunksize; - const char *msg; - - if (size < 4) { - msg =3D "input too small"; - goto exit_0; - } - - out_len =3D get_unaligned_le32(inp + size); - if (xc_dom_kernel_check_size(dom, out_len)) { - msg =3D "Decompressed image too large"; - goto exit_0; - } - - output =3D malloc(out_len); - if (!output) { - msg =3D "Could not allocate output buffer"; - goto exit_0; - } - outp =3D output; - - chunksize =3D get_unaligned_le32(inp); - if (chunksize =3D=3D ARCHIVE_MAGICNUMBER) { - inp +=3D 4; - size -=3D 4; - } else { - msg =3D "invalid header"; - goto exit_2; - } - - for (;;) { - if (size < 4) { - msg =3D "missing data"; - goto exit_2; - } - chunksize =3D get_unaligned_le32(inp); - if (chunksize =3D=3D ARCHIVE_MAGICNUMBER) { - inp +=3D 4; - size -=3D 4; - continue; - } - inp +=3D 4; - size -=3D 4; - if (chunksize > size) { - msg =3D "insufficient input data"; - goto exit_2; - } - - dest_len =3D out_len - (outp - output); - ret =3D lz4_decompress_unknownoutputsize(inp, chunksize, outp, - &dest_len); - if (ret < 0) { - msg =3D "decoding failed"; - goto exit_2; - } - - ret =3D -1; - outp +=3D dest_len; - size -=3D chunksize; - - if (size =3D=3D 0) - { - if ( xc_dom_register_external(dom, output, out_len) ) - { - msg =3D "Error registering stream output"; - goto exit_2; - } - *blob =3D output; - *psize =3D out_len; - return 0; - } - - if (size < 0) { - msg =3D "data corrupted"; - goto exit_2; - } - - inp +=3D chunksize; - } - -exit_2: - free(output); -exit_0: - DOMPRINTF("LZ4 decompression error: %s\n", msg); - return ret; -} - -#else /* __MINIOS__ */ - -#include "../../xen/common/unlz4.c" - -int xc_try_lz4_decode( - struct xc_dom_image *dom, void **blob, size_t *size) -{ - return xc_dom_decompress_unsafe(unlz4, dom, blob, size); -} - -#endif diff --git a/tools/libs/guest/xg_dom_decompress_unsafe.h b/tools/libs/guest= /xg_dom_decompress_unsafe.h index ac6b94288d5e..5bc222207653 100644 --- a/tools/libs/guest/xg_dom_decompress_unsafe.h +++ b/tools/libs/guest/xg_dom_decompress_unsafe.h @@ -16,6 +16,8 @@ int xc_dom_decompress_unsafe( =20 int xc_try_bzip2_decode(struct xc_dom_image *dom, void **blob, size_t *siz= e) __attribute__((visibility("internal"))); +int xc_try_lz4_decode(struct xc_dom_image *dom, void **blob, size_t *size) + __attribute__((visibility("internal"))); int xc_try_lzma_decode(struct xc_dom_image *dom, void **blob, size_t *size) __attribute__((visibility("internal"))); int xc_try_lzo1x_decode(struct xc_dom_image *dom, void **blob, size_t *siz= e) diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_lz4.c b/tools/libs/g= uest/xg_dom_decompress_unsafe_lz4.c new file mode 100644 index 000000000000..405143aa6182 --- /dev/null +++ b/tools/libs/guest/xg_dom_decompress_unsafe_lz4.c @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +#include INCLUDE_ENDIAN_H + +#define XG_NEED_UNALIGNED +#include "xg_private.h" +#include "xg_dom_decompress.h" + +#define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +#define likely(a) a +#define unlikely(a) a + +static inline uint16_t le16_to_cpu(uint16_t v) +{ +#if BYTE_ORDER =3D=3D BIG_ENDIAN + return __builtin_bswap16(v); +#else + return v; +#endif +} + +#include "../../xen/include/xen/lz4.h" +#include "../../xen/common/decompress.h" +#include "../../xen/common/unlz4.c" + +int xc_try_lz4_decode( + struct xc_dom_image *dom, void **blob, size_t *size) +{ + return xc_dom_decompress_unsafe(unlz4, dom, blob, size); +} --=20 2.39.5