From patchwork Tue Jan 26 09:48:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26BAEC433DB for ; Tue, 26 Jan 2021 09:48:50 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B494F2255F for ; Tue, 26 Jan 2021 09:48:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B494F2255F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74702.134252 (Exim 4.92) (envelope-from ) id 1l4Kxk-00083Z-7e; Tue, 26 Jan 2021 09:48:40 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74702.134252; Tue, 26 Jan 2021 09:48:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4Kxk-00083S-4r; Tue, 26 Jan 2021 09:48:40 +0000 Received: by outflank-mailman (input) for mailman id 74702; Tue, 26 Jan 2021 09:48:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4Kxi-00083J-M6 for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:48:38 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a388354e-e6a0-4e78-94f2-546165a81326; Tue, 26 Jan 2021 09:48:37 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 233FBAC4F; Tue, 26 Jan 2021 09:48:37 +0000 (UTC) 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" X-Inumbo-ID: a388354e-e6a0-4e78-94f2-546165a81326 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654517; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6LNszWFUAzLqr7lzoTEEIij7QH8NvHbiS55vXjywYvs=; b=TbIMgSUJi8H5jOVhyJV7dPdh87gLkGgplEA9OOswTALic7olkcUOIpoZJtzuvKnlTwsKM+ KrAygWQEAkzJn1mKJ1YwpoQO7XcEp5x+ZXO4OIS9XvXjEmb4RxoWanXo5/F0aU2Ye1rh7N RyBwBTPKNq7YpbHal6j8rXJNx2PyJSI= Subject: [PATCH v3 01/15] libxenguest: add get_unaligned_le32() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: Date: Tue, 26 Jan 2021 10:48:37 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US Abstract xc_dom_check_gzip()'s reading of the uncompressed size into a helper re-usable, in particular, by other decompressor code. Sadly in the mini-os case this conflicts with other functions of the same name (and purpose), which can't be easily replaced individually. Yet it was requested that no full set of helpers be introduced at this point in the release cycle. Hence the awkward XG_NEED_UNALIGNED. Requested-by: Ian Jackson Signed-off-by: Jan Beulich Reviewed-by: Ian Jackson --- v3: New. --- a/tools/libs/guest/xg_dom_core.c +++ b/tools/libs/guest/xg_dom_core.c @@ -31,6 +31,7 @@ #include #include +#define XG_NEED_UNALIGNED #include "xg_private.h" #include "_paths.h" @@ -325,7 +326,6 @@ int xc_dom_kernel_check_size(struct xc_d size_t xc_dom_check_gzip(xc_interface *xch, void *blob, size_t ziplen) { - unsigned char *gzlen; size_t unziplen; if ( ziplen < 6 ) @@ -337,8 +337,7 @@ size_t xc_dom_check_gzip(xc_interface *x /* not gzipped */ return 0; - gzlen = blob + ziplen - 4; - unziplen = (size_t)gzlen[3] << 24 | gzlen[2] << 16 | gzlen[1] << 8 | gzlen[0]; + unziplen = get_unaligned_le32(blob + ziplen - 4); if ( unziplen > XC_DOM_DECOMPRESS_MAX ) { xc_dom_printf --- a/tools/libs/guest/xg_dom_decompress_lz4.c +++ b/tools/libs/guest/xg_dom_decompress_lz4.c @@ -3,6 +3,7 @@ #include #include +#define XG_NEED_UNALIGNED #include "xg_private.h" #include "xg_dom_decompress.h" --- a/tools/libs/guest/xg_private.h +++ b/tools/libs/guest/xg_private.h @@ -62,6 +62,15 @@ char *xc_inflate_buffer(xc_interface *xc unsigned long in_size, unsigned long *out_size); +#if !defined(__MINIOS__) || defined(XG_NEED_UNALIGNED) + +static inline unsigned int get_unaligned_le32(const uint8_t *buf) +{ + return ((unsigned int)buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; +} + +#endif /* !__MINIOS__ || XG_NEED_UNALIGNED */ + unsigned long csum_page (void * page); #define _PAGE_PRESENT 0x001 --- a/xen/common/lz4/defs.h +++ b/xen/common/lz4/defs.h @@ -18,11 +18,6 @@ static inline u16 get_unaligned_le16(con return le16_to_cpup(p); } -static inline u32 get_unaligned_le32(const void *p) -{ - return le32_to_cpup(p); -} - #endif /* From patchwork Tue Jan 26 09:49:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-22.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB855C433E0 for ; Tue, 26 Jan 2021 09:49:19 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4C1122311D for ; Tue, 26 Jan 2021 09:49:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C1122311D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74707.134264 (Exim 4.92) (envelope-from ) id 1l4KyD-0008F5-Hj; Tue, 26 Jan 2021 09:49:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74707.134264; Tue, 26 Jan 2021 09:49:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4KyD-0008Ey-DY; Tue, 26 Jan 2021 09:49:09 +0000 Received: by outflank-mailman (input) for mailman id 74707; Tue, 26 Jan 2021 09:49:08 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4KyC-0008En-3M for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:49:08 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 13b54e0f-b225-4ef2-8bba-164b6b15dde9; Tue, 26 Jan 2021 09:49:01 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C086FAE66; Tue, 26 Jan 2021 09:49:00 +0000 (UTC) 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" X-Inumbo-ID: 13b54e0f-b225-4ef2-8bba-164b6b15dde9 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654540; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AQDXmkSi1oc7I0pyRNhai60MxF0mbxb6bDIizjQ4VPo=; b=ThA7a4kf6erA3XCsYj3fpgvP88sy9BpJvWyds0PR0Ow4Qnm/wWmZXO3+INOmZUGNR0KlTQ ZunHdX5AglKSvBBBUpQnbK0NPQnSazRtIdY57bOjXvwEpjIS0yDvdZLHm3QzAAdW1cPIYN KNIXzGh707CqkqDmOpy9ZENzuG052q0= Subject: [PATCH v3 02/15] libxenguest: support zstd compressed kernels From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: <02b2a15a-debc-e066-72ff-ab9ca9429839@suse.com> Date: Tue, 26 Jan 2021 10:49:01 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US This follows the logic used for other decompression methods utilizing an external library, albeit here we can't ignore the 32-bit size field appended to the compressed image - its presence causes decompression to fail. Leverage the field instead to allocate the output buffer in one go, i.e. without incrementally realloc()ing. As far as configure.ac goes, I'm pretty sure there is a better (more "standard") way of using PKG_CHECK_MODULES(). The construct also gets put next to the other decompression library checks, albeit I think they all ought to be x86-specific (e.g. placed in the existing case block a few lines down). Note that, where possible, instead of #ifdef-ing xen/*.h inclusions, they get removed. Signed-off-by: Jan Beulich Acked-by: Wei Liu Release-Acked-by: Ian Jackson Reviewed-by: Ian Jackson --- Note for committer: As an alternative to patching tools/configure here, autoconf may want re-running. --- v3: Drop AC_MSG_WARN(). Avoid use of $libzstd_PKG_ERRORS. Use helper for unaligned reads. v2.5: Don't make libzstd a hard dependency. Adjust ./README. v2: New. --- a/README +++ b/README @@ -84,6 +84,8 @@ disabled at compile time: * 16-bit x86 assembler, loader and compiler for qemu-traditional / rombios (dev86 rpm or bin86 & bcc debs) * Development install of liblzma for rombios + * Development install of libbz2, liblzma, liblzo2, and libzstd for DomU + kernel decompression. Second, you need to acquire a suitable kernel for use in domain 0. If possible you should use a kernel provided by your OS distributor. If --- a/tools/configure +++ b/tools/configure @@ -643,6 +643,8 @@ PTHREAD_CFLAGS EXTFS_LIBS system_aio zlib +libzstd_LIBS +libzstd_CFLAGS FETCHER FTP FALSE @@ -857,6 +859,8 @@ glib_CFLAGS glib_LIBS pixman_CFLAGS pixman_LIBS +libzstd_CFLAGS +libzstd_LIBS LIBNL3_CFLAGS LIBNL3_LIBS SYSTEMD_CFLAGS @@ -1605,6 +1609,10 @@ Some influential environment variables: pixman_CFLAGS C compiler flags for pixman, overriding pkg-config pixman_LIBS linker flags for pixman, overriding pkg-config + libzstd_CFLAGS + C compiler flags for libzstd, overriding pkg-config + libzstd_LIBS + linker flags for libzstd, overriding pkg-config LIBNL3_CFLAGS C compiler flags for LIBNL3, overriding pkg-config LIBNL3_LIBS linker flags for LIBNL3, overriding pkg-config @@ -8744,6 +8752,77 @@ fi +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libzstd" >&5 +$as_echo_n "checking for libzstd... " >&6; } + +if test -n "$libzstd_CFLAGS"; then + pkg_cv_libzstd_CFLAGS="$libzstd_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_libzstd_CFLAGS=`$PKG_CONFIG --cflags "libzstd" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$libzstd_LIBS"; then + pkg_cv_libzstd_LIBS="$libzstd_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libzstd\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libzstd") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_libzstd_LIBS=`$PKG_CONFIG --libs "libzstd" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + libzstd_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libzstd" 2>&1` + else + libzstd_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libzstd" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$libzstd_PKG_ERRORS" >&5 + + true +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + true +else + libzstd_CFLAGS=$pkg_cv_libzstd_CFLAGS + libzstd_LIBS=$pkg_cv_libzstd_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + zlib="$zlib -DHAVE_ZSTD $libzstd_CFLAGS $libzstd_LIBS" +fi + ac_fn_c_check_header_mongrel "$LINENO" "ext2fs/ext2fs.h" "ac_cv_header_ext2fs_ext2fs_h" "$ac_includes_default" --- a/tools/configure.ac +++ b/tools/configure.ac @@ -414,6 +414,8 @@ AC_CHECK_LIB([lzma], [lzma_stream_decode AC_CHECK_HEADER([lzo/lzo1x.h], [ AC_CHECK_LIB([lzo2], [lzo1x_decompress], [zlib="$zlib -DHAVE_LZO1X -llzo2"]) ]) +PKG_CHECK_MODULES([libzstd], [libzstd], + [zlib="$zlib -DHAVE_ZSTD $libzstd_CFLAGS $libzstd_LIBS"], [true]) AC_SUBST(zlib) AC_SUBST(system_aio) AX_CHECK_EXTFS --- a/tools/libs/guest/Makefile +++ b/tools/libs/guest/Makefile @@ -64,6 +64,7 @@ SRCS-y += xg_dom_decompr SRCS-y += xg_dom_decompress_unsafe_lzma.c SRCS-y += xg_dom_decompress_unsafe_lzo1x.c SRCS-y += xg_dom_decompress_unsafe_xz.c +SRCS-y += xg_dom_decompress_unsafe_zstd.c endif -include $(XEN_TARGET_ARCH)/Makefile --- a/tools/libs/guest/xg_dom_bzimageloader.c +++ b/tools/libs/guest/xg_dom_bzimageloader.c @@ -589,6 +589,85 @@ static int xc_try_lzo1x_decode( #endif +#if defined(HAVE_ZSTD) + +#include + +static int xc_try_zstd_decode( + struct xc_dom_image *dom, void **blob, size_t *size) +{ + size_t outsize, insize, actual; + unsigned char *outbuf; + + /* Magic, descriptor byte, and trailing size field. */ + if ( *size <= 9 ) + { + DOMPRINTF("ZSTD: insufficient input data"); + return -1; + } + + insize = *size - 4; + outsize = get_unaligned_le32(*blob + insize); + + if ( xc_dom_kernel_check_size(dom, outsize) ) + { + DOMPRINTF("ZSTD: output too large"); + return -1; + } + + outbuf = malloc(outsize); + if ( !outbuf ) + { + DOMPRINTF("ZSTD: failed to alloc memory"); + return -1; + } + + actual = ZSTD_decompress(outbuf, outsize, *blob, insize); + + if ( ZSTD_isError(actual) ) + { + DOMPRINTF("ZSTD: error: %s", ZSTD_getErrorName(actual)); + free(outbuf); + return -1; + } + + if ( actual != outsize ) + { + DOMPRINTF("ZSTD: got 0x%zx bytes instead of 0x%zx", + actual, outsize); + free(outbuf); + return -1; + } + + if ( xc_dom_register_external(dom, outbuf, outsize) ) + { + DOMPRINTF("ZSTD: error registering stream output"); + free(outbuf); + return -1; + } + + DOMPRINTF("%s: ZSTD decompress OK, 0x%zx -> 0x%zx", + __FUNCTION__, insize, outsize); + + *blob = outbuf; + *size = outsize; + + return 0; +} + +#else /* !defined(HAVE_ZSTD) */ + +static int xc_try_zstd_decode( + struct xc_dom_image *dom, void **blob, size_t *size) +{ + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, + "%s: ZSTD decompress support unavailable\n", + __FUNCTION__); + return -1; +} + +#endif + #else /* __MINIOS__ */ int xc_try_bzip2_decode(struct xc_dom_image *dom, void **blob, size_t *size); @@ -735,6 +814,17 @@ static int xc_dom_probe_bzimage_kernel(s __FUNCTION__); return -EINVAL; } + } + else if ( check_magic(dom, "\x28\xb5\x2f\xfd", 4) ) + { + ret = xc_try_zstd_decode(dom, &dom->kernel_blob, &dom->kernel_size); + if ( ret < 0 ) + { + xc_dom_panic(dom->xch, XC_INVALID_KERNEL, + "%s unable to ZSTD decompress kernel", + __FUNCTION__); + return -EINVAL; + } } else if ( check_magic(dom, "\135\000", 2) ) { --- /dev/null +++ b/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include + +#include "xg_private.h" +#include "xg_dom_decompress_unsafe.h" + +typedef uint8_t u8; + +typedef uint16_t __u16; +typedef uint32_t __u32; +typedef uint64_t __u64; + +typedef uint16_t __le16; +typedef uint32_t __le32; +typedef uint64_t __le64; + +typedef uint16_t __be16; +typedef uint32_t __be32; +typedef uint64_t __be64; + +#define __attribute_const__ +#define __force +#define always_inline +#define noinline + +#undef ERROR + +#define __BYTEORDER_HAS_U64__ +#define __TYPES_H__ /* xen/types.h guard */ +#include "../../xen/include/xen/byteorder/little_endian.h" +#define __ASM_UNALIGNED_H__ /* asm/unaligned.h guard */ +#include "../../xen/include/xen/unaligned.h" +#include "../../xen/include/xen/xxhash.h" +#include "../../xen/lib/xxhash64.c" +#include "../../xen/common/unzstd.c" + +int xc_try_zstd_decode( + struct xc_dom_image *dom, void **blob, size_t *size) +{ + return xc_dom_decompress_unsafe(unzstd, dom, blob, size); +} --- a/tools/libs/guest/xg_dom_decompress_unsafe.h +++ b/tools/libs/guest/xg_dom_decompress_unsafe.h @@ -16,3 +16,5 @@ int xc_try_lzo1x_decode(struct xc_dom_im __attribute__((visibility("internal"))); int xc_try_xz_decode(struct xc_dom_image *dom, void **blob, size_t *size) __attribute__((visibility("internal"))); +int xc_try_zstd_decode(struct xc_dom_image *dom, void **blob, size_t *size) + __attribute__((visibility("internal"))); --- a/xen/common/zstd/decompress.c +++ b/xen/common/zstd/decompress.c @@ -33,7 +33,6 @@ #include "huf.h" #include "mem.h" /* low level memory routines */ #include "zstd_internal.h" -#include /* memcpy, memmove, memset */ #define ZSTD_PREFETCH(ptr) __builtin_prefetch(ptr, 0, 0) @@ -99,9 +98,12 @@ struct ZSTD_DCtx_s { BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX]; }; /* typedef'd to ZSTD_DCtx within "zstd.h" */ -size_t INIT ZSTD_DCtxWorkspaceBound(void) { return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DCtx)); } +STATIC size_t INIT ZSTD_DCtxWorkspaceBound(void) +{ + return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DCtx)); +} -size_t INIT ZSTD_decompressBegin(ZSTD_DCtx *dctx) +STATIC size_t INIT ZSTD_decompressBegin(ZSTD_DCtx *dctx) { dctx->expected = ZSTD_frameHeaderSize_prefix; dctx->stage = ZSTDds_getFrameHeaderSize; @@ -121,7 +123,7 @@ size_t INIT ZSTD_decompressBegin(ZSTD_DC return 0; } -ZSTD_DCtx *INIT ZSTD_createDCtx_advanced(ZSTD_customMem customMem) +STATIC ZSTD_DCtx *INIT ZSTD_createDCtx_advanced(ZSTD_customMem customMem) { ZSTD_DCtx *dctx; @@ -136,7 +138,7 @@ ZSTD_DCtx *INIT ZSTD_createDCtx_advanced return dctx; } -ZSTD_DCtx *INIT ZSTD_initDCtx(void *workspace, size_t workspaceSize) +STATIC ZSTD_DCtx *INIT ZSTD_initDCtx(void *workspace, size_t workspaceSize) { ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize); return ZSTD_createDCtx_advanced(stackMem); @@ -150,11 +152,13 @@ size_t INIT ZSTD_freeDCtx(ZSTD_DCtx *dct return 0; /* reserved as a potential error code in the future */ } +#ifdef BUILD_DEAD_CODE void INIT ZSTD_copyDCtx(ZSTD_DCtx *dstDCtx, const ZSTD_DCtx *srcDCtx) { size_t const workSpaceSize = (ZSTD_BLOCKSIZE_ABSOLUTEMAX + WILDCOPY_OVERLENGTH) + ZSTD_frameHeaderSize_max; memcpy(dstDCtx, srcDCtx, sizeof(ZSTD_DCtx) - workSpaceSize); /* no need to copy workspace */ } +#endif STATIC size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize); STATIC size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, @@ -166,6 +170,7 @@ static void ZSTD_refDDict(ZSTD_DCtx *dst * Decompression section ***************************************************************/ +#ifdef BUILD_DEAD_CODE /*! ZSTD_isFrame() : * Tells if the content of `buffer` starts with a valid Frame Identifier. * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. @@ -184,6 +189,7 @@ unsigned INIT ZSTD_isFrame(const void *b } return 0; } +#endif /** ZSTD_frameHeaderSize() : * srcSize must be >= ZSTD_frameHeaderSize_prefix. @@ -206,7 +212,7 @@ static size_t INIT ZSTD_frameHeaderSize( * @return : 0, `fparamsPtr` is correctly filled, * >0, `srcSize` is too small, result is expected `srcSize`, * or an error code, which can be tested using ZSTD_isError() */ -size_t INIT ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize) +STATIC size_t INIT ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize) { const BYTE *ip = (const BYTE *)src; @@ -291,6 +297,7 @@ size_t INIT ZSTD_getFrameParams(ZSTD_fra return 0; } +#ifdef BUILD_DEAD_CODE /** ZSTD_getFrameContentSize() : * compatible with legacy mode * @return : decompressed size of the single frame pointed to be `src` if known, otherwise @@ -367,6 +374,7 @@ unsigned long long INIT ZSTD_findDecompr return totalDstSize; } } +#endif /* BUILD_DEAD_CODE */ /** ZSTD_decodeFrameHeader() : * `headerSize` must be the size provided by ZSTD_frameHeaderSize(). @@ -393,7 +401,7 @@ typedef struct { /*! ZSTD_getcBlockSize() : * Provides the size of compressed block from block header `src` */ -size_t INIT ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr) +STATIC size_t INIT ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr) { if (srcSize < ZSTD_blockHeaderSize) return ERROR(srcSize_wrong); @@ -431,7 +439,7 @@ static size_t INIT ZSTD_setRleBlock(void /*! ZSTD_decodeLiteralsBlock() : @return : nb of bytes read from src (< srcSize ) */ -size_t INIT ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize) /* note : srcSize < BLOCKSIZE */ +STATIC size_t INIT ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize) /* note : srcSize < BLOCKSIZE */ { if (srcSize < MIN_CBLOCK_SIZE) return ERROR(corruption_detected); @@ -795,7 +803,7 @@ static size_t INIT ZSTD_buildSeqTable(FS } } -size_t INIT ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize) +STATIC size_t INIT ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize) { const BYTE *const istart = (const BYTE *const)src; const BYTE *const iend = istart + srcSize; @@ -1481,6 +1489,7 @@ static void INIT ZSTD_checkContinuity(ZS } } +#ifdef BUILD_DEAD_CODE size_t INIT ZSTD_decompressBlock(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) { size_t dSize; @@ -1498,8 +1507,9 @@ size_t INIT ZSTD_insertBlock(ZSTD_DCtx * dctx->previousDstEnd = (const char *)blockStart + blockSize; return blockSize; } +#endif /* BUILD_DEAD_CODE */ -size_t INIT ZSTD_generateNxBytes(void *dst, size_t dstCapacity, BYTE byte, size_t length) +STATIC size_t INIT ZSTD_generateNxBytes(void *dst, size_t dstCapacity, BYTE byte, size_t length) { if (length > dstCapacity) return ERROR(dstSize_tooSmall); @@ -1512,7 +1522,7 @@ size_t INIT ZSTD_generateNxBytes(void *d * `src` must point to the start of a ZSTD frame, ZSTD legacy frame, or skippable frame * `srcSize` must be at least as large as the frame contained * @return : the compressed size of the frame starting at `src` */ -size_t INIT ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) +STATIC size_t INIT ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) { if (srcSize >= ZSTD_skippableHeaderSize && (ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { return ZSTD_skippableHeaderSize + ZSTD_readLE32((const BYTE *)src + 4); @@ -1709,12 +1719,12 @@ static size_t INIT ZSTD_decompressMultiF return (BYTE *)dst - (BYTE *)dststart; } -size_t INIT ZSTD_decompress_usingDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize) +STATIC size_t INIT ZSTD_decompress_usingDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize) { return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, dict, dictSize, NULL); } -size_t INIT ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) +STATIC size_t INIT ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) { return ZSTD_decompress_usingDict(dctx, dst, dstCapacity, src, srcSize, NULL, 0); } @@ -1723,9 +1733,12 @@ size_t INIT ZSTD_decompressDCtx(ZSTD_DCt * Advanced Streaming Decompression API * Bufferless and synchronous ****************************************/ -size_t INIT ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx) { return dctx->expected; } +STATIC size_t INIT ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx) +{ + return dctx->expected; +} -ZSTD_nextInputType_e INIT ZSTD_nextInputType(ZSTD_DCtx *dctx) +STATIC ZSTD_nextInputType_e INIT ZSTD_nextInputType(ZSTD_DCtx *dctx) { switch (dctx->stage) { default: /* should not happen */ @@ -1745,7 +1758,7 @@ int INIT ZSTD_isSkipFrame(ZSTD_DCtx *dct /** ZSTD_decompressContinue() : * @return : nb of bytes generated into `dst` (necessarily <= `dstCapacity) * or an error code, which can be tested using ZSTD_isError() */ -size_t INIT ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) +STATIC size_t INIT ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) { /* Sanity check */ if (srcSize != dctx->expected) @@ -1971,7 +1984,7 @@ static size_t INIT ZSTD_decompress_inser return ZSTD_refDictContent(dctx, dict, dictSize); } -size_t INIT ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize) +STATIC size_t INIT ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize) { CHECK_F(ZSTD_decompressBegin(dctx)); if (dict && dictSize) @@ -1991,7 +2004,9 @@ struct ZSTD_DDict_s { ZSTD_customMem cMem; }; /* typedef'd to ZSTD_DDict within "zstd.h" */ +#ifdef BUILD_DEAD_CODE size_t INIT ZSTD_DDictWorkspaceBound(void) { return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DDict)); } +#endif static const void *INIT ZSTD_DDictDictContent(const ZSTD_DDict *ddict) { return ddict->dictContent; } @@ -2023,6 +2038,7 @@ static void INIT ZSTD_refDDict(ZSTD_DCtx } } +#ifdef BUILD_DEAD_CODE static size_t INIT ZSTD_loadEntropy_inDDict(ZSTD_DDict *ddict) { ddict->dictID = 0; @@ -2090,6 +2106,7 @@ ZSTD_DDict *INIT ZSTD_initDDict(const vo ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize); return ZSTD_createDDict_advanced(dict, dictSize, 1, stackMem); } +#endif /* BUILD_DEAD_CODE */ size_t INIT ZSTD_freeDDict(ZSTD_DDict *ddict) { @@ -2103,6 +2120,7 @@ size_t INIT ZSTD_freeDDict(ZSTD_DDict *d } } +#ifdef BUILD_DEAD_CODE /*! ZSTD_getDictID_fromDict() : * Provides the dictID stored within dictionary. * if @return == 0, the dictionary is not conformant with Zstandard specification. @@ -2145,11 +2163,12 @@ unsigned INIT ZSTD_getDictID_fromFrame(c return 0; return zfp.dictID; } +#endif /* BUILD_DEAD_CODE */ /*! ZSTD_decompress_usingDDict() : * Decompression using a pre-digested Dictionary * Use dictionary without significant overhead. */ -size_t INIT ZSTD_decompress_usingDDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_DDict *ddict) +STATIC size_t INIT ZSTD_decompress_usingDDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_DDict *ddict) { /* pass content and size in case legacy frames are encountered */ return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, NULL, 0, ddict); @@ -2186,7 +2205,7 @@ struct ZSTD_DStream_s { U32 hostageByte; }; /* typedef'd to ZSTD_DStream within "zstd.h" */ -size_t INIT ZSTD_DStreamWorkspaceBound(size_t maxWindowSize) +STATIC size_t INIT ZSTD_DStreamWorkspaceBound(size_t maxWindowSize) { size_t const blockSize = MIN(maxWindowSize, ZSTD_BLOCKSIZE_ABSOLUTEMAX); size_t const inBuffSize = blockSize; @@ -2216,7 +2235,7 @@ static ZSTD_DStream *INIT ZSTD_createDSt return zds; } -ZSTD_DStream *INIT ZSTD_initDStream(size_t maxWindowSize, void *workspace, size_t workspaceSize) +STATIC ZSTD_DStream *INIT ZSTD_initDStream(size_t maxWindowSize, void *workspace, size_t workspaceSize) { ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize); ZSTD_DStream *zds = ZSTD_createDStream_advanced(stackMem); @@ -2249,6 +2268,7 @@ ZSTD_DStream *INIT ZSTD_initDStream(size return zds; } +#ifdef BUILD_DEAD_CODE ZSTD_DStream *INIT ZSTD_initDStream_usingDDict(size_t maxWindowSize, const ZSTD_DDict *ddict, void *workspace, size_t workspaceSize) { ZSTD_DStream *zds = ZSTD_initDStream(maxWindowSize, workspace, workspaceSize); @@ -2257,6 +2277,7 @@ ZSTD_DStream *INIT ZSTD_initDStream_usin } return zds; } +#endif size_t INIT ZSTD_freeDStream(ZSTD_DStream *zds) { @@ -2279,10 +2300,12 @@ size_t INIT ZSTD_freeDStream(ZSTD_DStrea /* *** Initialization *** */ +#ifdef BUILD_DEAD_CODE size_t INIT ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX + ZSTD_blockHeaderSize; } size_t INIT ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX; } +#endif -size_t INIT ZSTD_resetDStream(ZSTD_DStream *zds) +STATIC size_t INIT ZSTD_resetDStream(ZSTD_DStream *zds) { zds->stage = zdss_loadHeader; zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0; @@ -2300,7 +2323,7 @@ ZSTD_STATIC size_t INIT ZSTD_limitCopy(v return length; } -size_t INIT ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input) +STATIC size_t INIT ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input) { const char *const istart = (const char *)(input->src) + input->pos; const char *const iend = (const char *)(input->src) + input->size; --- a/xen/common/zstd/error_private.h +++ b/xen/common/zstd/error_private.h @@ -19,11 +19,6 @@ #ifndef ERROR_H_MODULE #define ERROR_H_MODULE -/* **************************************** -* Dependencies -******************************************/ -#include /* size_t */ - /** * enum ZSTD_ErrorCode - zstd error codes * --- a/xen/common/zstd/fse.h +++ b/xen/common/zstd/fse.h @@ -41,11 +41,6 @@ #define FSE_H /*-***************************************** -* Dependencies -******************************************/ -#include /* size_t, ptrdiff_t */ - -/*-***************************************** * FSE_PUBLIC_API : control library symbols visibility ******************************************/ #define FSE_PUBLIC_API --- a/xen/common/zstd/fse_decompress.c +++ b/xen/common/zstd/fse_decompress.c @@ -48,8 +48,6 @@ #include "bitstream.h" #include "fse.h" #include "zstd_internal.h" -#include -#include /* memcpy, memset */ /* ************************************************************** * Error Management --- a/xen/common/zstd/huf.h +++ b/xen/common/zstd/huf.h @@ -40,9 +40,6 @@ #ifndef HUF_H_298734234 #define HUF_H_298734234 -/* *** Dependencies *** */ -#include /* size_t */ - /* *** Tool functions *** */ #define HUF_BLOCKSIZE_MAX (128 * 1024) /**< maximum input size for a single block compressed with HUF_compress */ size_t HUF_compressBound(size_t size); /**< maximum compressed size (worst case) */ --- a/xen/common/zstd/huf_decompress.c +++ b/xen/common/zstd/huf_decompress.c @@ -48,8 +48,6 @@ #include "bitstream.h" /* BIT_* */ #include "fse.h" /* header compression */ #include "huf.h" -#include -#include /* memcpy, memset */ /* ************************************************************** * Error Management --- a/xen/common/zstd/mem.h +++ b/xen/common/zstd/mem.h @@ -20,9 +20,11 @@ /*-**************************************** * Dependencies ******************************************/ +#ifdef __XEN__ #include /* memcpy */ #include /* size_t, ptrdiff_t */ #include +#endif /*-**************************************** * Compiler specifics --- a/xen/common/zstd/zstd_internal.h +++ b/xen/common/zstd/zstd_internal.h @@ -28,8 +28,10 @@ ***************************************/ #include "error_private.h" #include "mem.h" +#ifdef __XEN__ #include #include +#endif #define ALIGN(x, a) ((x + (a) - 1) & ~((a) - 1)) #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) @@ -95,8 +97,10 @@ typedef struct ZSTD_DStream_s ZSTD_DStre /*-************************************* * shared macros ***************************************/ +#ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif #define CHECK_F(f) \ { \ size_t const errcod = f; \ --- a/xen/include/xen/unaligned.h +++ b/xen/include/xen/unaligned.h @@ -10,8 +10,10 @@ #ifndef __XEN_UNALIGNED_H__ #define __XEN_UNALIGNED_H__ +#ifdef __XEN__ #include #include +#endif #define get_unaligned(p) (*(p)) #define put_unaligned(val, p) (*(p) = (val)) --- a/xen/lib/xxhash64.c +++ b/xen/lib/xxhash64.c @@ -38,11 +38,13 @@ * - xxHash source repository: https://github.com/Cyan4973/xxHash */ +#ifdef __XEN__ #include #include #include #include #include +#endif /*-************************************* * Macros From patchwork Tue Jan 26 09:49:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 573C7C433E0 for ; Tue, 26 Jan 2021 09:49:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F40C820780 for ; Tue, 26 Jan 2021 09:49:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F40C820780 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74709.134276 (Exim 4.92) (envelope-from ) id 1l4KyT-0008KQ-0f; Tue, 26 Jan 2021 09:49:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74709.134276; Tue, 26 Jan 2021 09:49:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4KyS-0008KI-Sd; Tue, 26 Jan 2021 09:49:24 +0000 Received: by outflank-mailman (input) for mailman id 74709; Tue, 26 Jan 2021 09:49:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4KyS-0008K6-Ab for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:49:24 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d35e3c06-1905-4f6a-931a-9a8072b05581; Tue, 26 Jan 2021 09:49:23 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 62723AE40; Tue, 26 Jan 2021 09:49:22 +0000 (UTC) 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" X-Inumbo-ID: d35e3c06-1905-4f6a-931a-9a8072b05581 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654562; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eVmMIy5O87CMi7zsqnSGDrT7n4RL6KGiJLriSkhGBXM=; b=JicT2UDtSta6+/FwxML3+Jo5MK8CSf9fJLWJI2+fV2BK5P4f/ZTrNoz8JOIy9dzQabBaOr Ntb6mpxU+jUm3p0IbHs8dlQcDTp6GpMPX6aRsYskYtg3/BzHB5geCfA00hkHrU5YnFBRp/ jFlqNIcb/PW1xme1sII4vcpiRTwREco= Subject: [PATCH v3 03/15] xen/decompress: make helper symbols static From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: <99b620e4-bff9-76c3-9a0d-936171971407@suse.com> Date: Tue, 26 Jan 2021 10:49:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US The individual decompression CUs need to only surface their top level functions to other code. Arrange for everything else to be static, to make sure no undue uses of that code exist or will appear without explicitly noticing. (In some cases this also results in code size reduction, but since this is all init-only code this probably doesn't matter very much.) In the LZO case also take the opportunity and convert u8 where lines get touched anyway. The downside is that the top level functions will now be non-static in stubdom builds of libxenguest, but I think that's acceptable. This does require declaring them first, though, as the compiler warns about the lack of declarations. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper Acked-by: Wei Liu --- v2: Fix stubdom build. --- a/tools/libs/guest/xg_dom_decompress_unsafe.h +++ b/tools/libs/guest/xg_dom_decompress_unsafe.h @@ -1,8 +1,12 @@ +#ifdef __MINIOS__ +# include "../../xen/include/xen/decompress.h" +#else typedef int decompress_fn(unsigned char *inbuf, unsigned int len, int (*fill)(void*, unsigned int), int (*flush)(void*, unsigned int), unsigned char *outbuf, unsigned int *posp, void (*error)(const char *x)); +#endif int xc_dom_decompress_unsafe( decompress_fn fn, struct xc_dom_image *dom, void **blob, size_t *size) --- a/xen/common/bunzip2.c +++ b/xen/common/bunzip2.c @@ -665,12 +665,11 @@ static int INIT start_bunzip(struct bunz /* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip2 data, not end of file.) */ -STATIC int INIT bunzip2(unsigned char *buf, unsigned int len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), - unsigned char *outbuf, - unsigned int *pos, - void(*error)(const char *x)) +int INIT bunzip2(unsigned char *buf, unsigned int len, + int(*fill)(void*, unsigned int), + int(*flush)(void*, unsigned int), + unsigned char *outbuf, unsigned int *pos, + void(*error)(const char *x)) { struct bunzip_data *bd; int i = -1; --- a/xen/common/decompress.h +++ b/xen/common/decompress.h @@ -7,7 +7,7 @@ #include #include -#define STATIC +#define STATIC static #define INIT __init #define INITDATA __initdata --- a/xen/common/unlz4.c +++ b/xen/common/unlz4.c @@ -22,12 +22,11 @@ #define LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE (8 << 20) #define ARCHIVE_MAGICNUMBER 0x184C2102 -STATIC int INIT unlz4(unsigned char *input, unsigned int in_len, - int (*fill)(void *, unsigned int), - int (*flush)(void *, unsigned int), - unsigned char *output, - unsigned int *posp, - void (*error)(const char *x)) +int INIT unlz4(unsigned char *input, unsigned int in_len, + int (*fill)(void *, unsigned int), + int (*flush)(void *, unsigned int), + unsigned char *output, unsigned int *posp, + void (*error)(const char *x)) { int ret = -1; size_t chunksize = 0; --- a/xen/common/unlzma.c +++ b/xen/common/unlzma.c @@ -528,13 +528,11 @@ static inline int INIT process_bit1(stru -STATIC int INIT unlzma(unsigned char *buf, unsigned int in_len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), - unsigned char *output, - unsigned int *posp, - void(*error)(const char *x) - ) +int INIT unlzma(unsigned char *buf, unsigned int in_len, + int(*fill)(void*, unsigned int), + int(*flush)(void*, unsigned int), + unsigned char *output, unsigned int *posp, + void(*error)(const char *x)) { struct lzma_header header; int lc, pb, lp; --- a/xen/common/unlzo.c +++ b/xen/common/unlzo.c @@ -114,11 +114,11 @@ static int INIT parse_header(u8 *input, return 1; } -STATIC int INIT unlzo(u8 *input, unsigned int in_len, - int (*fill) (void *, unsigned int), - int (*flush) (void *, unsigned int), - u8 *output, unsigned int *posp, - void (*error) (const char *x)) +int INIT unlzo(unsigned char *input, unsigned int in_len, + int (*fill) (void *, unsigned int), + int (*flush) (void *, unsigned int), + unsigned char *output, unsigned int *posp, + void (*error) (const char *x)) { u8 r = 0; int skip = 0; --- a/xen/common/unxz.c +++ b/xen/common/unxz.c @@ -157,11 +157,11 @@ * both input and output buffers are available as a single chunk, i.e. when * fill() and flush() won't be used. */ -STATIC int INIT unxz(unsigned char *in, unsigned int in_size, - int (*fill)(void *dest, unsigned int size), - int (*flush)(void *src, unsigned int size), - unsigned char *out, unsigned int *in_used, - void (*error)(const char *x)) +int INIT unxz(unsigned char *in, unsigned int in_size, + int (*fill)(void *dest, unsigned int size), + int (*flush)(void *src, unsigned int size), + unsigned char *out, unsigned int *in_used, + void (*error)(const char *x)) { struct xz_buf b; struct xz_dec *s; --- a/xen/common/unzstd.c +++ b/xen/common/unzstd.c @@ -142,12 +142,11 @@ out: return err; } -STATIC int INIT unzstd(unsigned char *in_buf, unsigned int in_len, - int (*fill)(void*, unsigned int), - int (*flush)(void*, unsigned int), - unsigned char *out_buf, - unsigned int *in_pos, - void (*error)(const char *x)) +int INIT unzstd(unsigned char *in_buf, unsigned int in_len, + int (*fill)(void*, unsigned int), + int (*flush)(void*, unsigned int), + unsigned char *out_buf, unsigned int *in_pos, + void (*error)(const char *x)) { ZSTD_inBuffer in; ZSTD_outBuffer out; From patchwork Tue Jan 26 09:49:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA10BC433E0 for ; Tue, 26 Jan 2021 09:49:54 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 668E820780 for ; Tue, 26 Jan 2021 09:49:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 668E820780 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74714.134288 (Exim 4.92) (envelope-from ) id 1l4Kyo-0008Rk-8O; Tue, 26 Jan 2021 09:49:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74714.134288; Tue, 26 Jan 2021 09:49:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4Kyo-0008Rd-5C; Tue, 26 Jan 2021 09:49:46 +0000 Received: by outflank-mailman (input) for mailman id 74714; Tue, 26 Jan 2021 09:49:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4Kym-0008RQ-Pf for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:49:44 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 68cd4557-f601-4ef0-83d7-aa9c844d6dfb; Tue, 26 Jan 2021 09:49:43 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1A3C1AE40; Tue, 26 Jan 2021 09:49:43 +0000 (UTC) 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" X-Inumbo-ID: 68cd4557-f601-4ef0-83d7-aa9c844d6dfb X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654583; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QX8/cPAcmhUJDAaeMJZCNy+hflROg1060DEkwWtrtPo=; b=SZUO77Pe7gMAKaIweSIB6BYEF8CvRuCVMiAJPpYKS84vBGNxize0z01SDOnbGNJ9JjknYf QYWUz4PP0ql093s6DZJilHAdlt6FxmaG9R0RGWNHiar3/w2ZfOtI3iE2dNtYvoCpN5kOdx gAFc4z0XHqJT53wcwoIJIXHEtvB3X8A= Subject: [PATCH v3 04/15] libxenguest: "standardize" LZO kernel decompression code From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: <44286280-0203-8eb9-8006-43125aeb77c7@suse.com> Date: Tue, 26 Jan 2021 10:49:43 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US Add a DOMPRINTF() other methods have, indicating success. To facilitate this, introduce an "outsize" local variable and update *size as well as *blob only once done. The latter then also avoids leaving a pointer to freed memory in dom->kernel_blob in case of a decompression error. Signed-off-by: Jan Beulich Acked-by: Wei Liu Release-Acked-by: Ian Jackson --- v2: New. --- a/tools/libs/guest/xg_dom_bzimageloader.c +++ b/tools/libs/guest/xg_dom_bzimageloader.c @@ -409,7 +409,7 @@ static int xc_try_lzo1x_decode( int ret; const unsigned char *cur = dom->kernel_blob; unsigned char *out_buf = NULL; - size_t left = dom->kernel_size; + size_t left = dom->kernel_size, outsize; const char *msg; unsigned version; static const unsigned char magic[] = { @@ -471,7 +471,7 @@ static int xc_try_lzo1x_decode( cur += ret; left -= ret; - for ( *size = 0; ; ) + for ( outsize = 0; ; ) { lzo_uint src_len, dst_len, out_len; unsigned char *tmp_buf; @@ -484,9 +484,15 @@ static int xc_try_lzo1x_decode( if ( !dst_len ) { msg = "Error registering stream output"; - if ( xc_dom_register_external(dom, out_buf, *size) ) + if ( xc_dom_register_external(dom, out_buf, outsize) ) break; + DOMPRINTF("%s: LZO decompress OK, 0x%zx -> 0x%zx", + __FUNCTION__, *size, outsize); + + *blob = out_buf; + *size = outsize; + return 0; } @@ -508,15 +514,15 @@ static int xc_try_lzo1x_decode( break; msg = "Output buffer overflow"; - if ( *size > SIZE_MAX - dst_len ) + if ( outsize > SIZE_MAX - dst_len ) break; msg = "Decompressed image too large"; - if ( xc_dom_kernel_check_size(dom, *size + dst_len) ) + if ( xc_dom_kernel_check_size(dom, outsize + dst_len) ) break; msg = "Failed to (re)alloc memory"; - tmp_buf = realloc(out_buf, *size + dst_len); + tmp_buf = realloc(out_buf, outsize + dst_len); if ( tmp_buf == NULL ) break; @@ -524,7 +530,7 @@ static int xc_try_lzo1x_decode( out_len = dst_len; ret = lzo1x_decompress_safe(cur, src_len, - out_buf + *size, &out_len, NULL); + out_buf + outsize, &out_len, NULL); switch ( ret ) { case LZO_E_OK: @@ -532,8 +538,7 @@ static int xc_try_lzo1x_decode( if ( out_len != dst_len ) break; - *blob = out_buf; - *size += out_len; + outsize += out_len; cur += src_len; left -= src_len; continue; From patchwork Tue Jan 26 09:50:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FE5DC433E6 for ; Tue, 26 Jan 2021 09:50:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B46CE20780 for ; Tue, 26 Jan 2021 09:50:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B46CE20780 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74718.134300 (Exim 4.92) (envelope-from ) id 1l4Kz7-0000gP-IA; Tue, 26 Jan 2021 09:50:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74718.134300; Tue, 26 Jan 2021 09:50:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4Kz7-0000gI-DR; Tue, 26 Jan 2021 09:50:05 +0000 Received: by outflank-mailman (input) for mailman id 74718; Tue, 26 Jan 2021 09:50:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4Kz5-0000Np-JL for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:50:03 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2b2e6df6-4c61-46f2-902c-5c3df5f833ac; Tue, 26 Jan 2021 09:50:02 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2C730AC4F; Tue, 26 Jan 2021 09:50:02 +0000 (UTC) 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" X-Inumbo-ID: 2b2e6df6-4c61-46f2-902c-5c3df5f833ac X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654602; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RCJANwvw1+ZBF+eonfJAxK5yWWsPMdyFkF5XXFdTgPQ=; b=dPgtXdyHwIe1DQUaCMLbHLqIVXdmGdIIb118m0vpM63HOVUPP0ppUbxH1oN4C8i81X/PSw FPF6RhF9n4f82ECBsPWu+7M1YvsxxtyaYn6WgUZOiA+QPwA5Gsr9uDUgJid6svvuCDwwnq k3/X4sx7ZMF6tla9mcsurCTq1YSIkvU= Subject: [PATCH v3 05/15] libxenguest: drop redundant decompression declarations From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: Date: Tue, 26 Jan 2021 10:50:02 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US The ones in xg_dom_decompress_unsafe.h suffice. Signed-off-by: Jan Beulich Acked-by: Wei Liu --- v2: New. --- a/tools/libs/guest/xg_dom_bzimageloader.c +++ b/tools/libs/guest/xg_dom_bzimageloader.c @@ -673,13 +673,6 @@ static int xc_try_zstd_decode( #endif -#else /* __MINIOS__ */ - -int xc_try_bzip2_decode(struct xc_dom_image *dom, void **blob, size_t *size); -int xc_try_lzma_decode(struct xc_dom_image *dom, void **blob, size_t *size); -int xc_try_lzo1x_decode(struct xc_dom_image *dom, void **blob, size_t *size); -int xc_try_xz_decode(struct xc_dom_image *dom, void **blob, size_t *size); - #endif /* !__MINIOS__ */ struct setup_header { From patchwork Tue Jan 26 09:50:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF718C433DB for ; Tue, 26 Jan 2021 09:50:35 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9640E2255F for ; Tue, 26 Jan 2021 09:50:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9640E2255F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74723.134312 (Exim 4.92) (envelope-from ) id 1l4KzS-0000uj-R2; Tue, 26 Jan 2021 09:50:26 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74723.134312; Tue, 26 Jan 2021 09:50:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4KzS-0000uc-NM; Tue, 26 Jan 2021 09:50:26 +0000 Received: by outflank-mailman (input) for mailman id 74723; Tue, 26 Jan 2021 09:50:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4KzQ-0000u6-Vx for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:50:25 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 7cc9d731-213c-4701-84ce-e09da51100d4; Tue, 26 Jan 2021 09:50:23 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D96E0AC4F; Tue, 26 Jan 2021 09:50:22 +0000 (UTC) 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" X-Inumbo-ID: 7cc9d731-213c-4701-84ce-e09da51100d4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654623; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y/DRrMi+eT87xxX0mS2gn1WxPDEKCjta7yHMaI2+K/E=; b=tPBcLDSjOh0isQnMjd7MEUi9L5x7J37zNI1ybHTlm9ZRBknaPiEt1o7ApjHjCIWtEBmz+b ezVm3/dkSUNMfo8RXgYq5QL4sdqHdCaaqVe3GFSNGyHVfht7X2on5tO+LFeRwxKoAh6YSe B3b8W6vkjxE/6/u5Nb44kNDnNMnIbhI= Subject: [PATCH v3 06/15] libxenguest: simplify kernel decompression From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: <0f5a2958-8847-772a-5fe4-06264867470a@suse.com> Date: Tue, 26 Jan 2021 10:50:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US In all cases the kernel build makes available the uncompressed size in the final 4 bytes of the bzImage payload. Utilize this to avoid repeated realloc()ing of the output buffer. As a side effect this also addresses the previous mistaken return of 0 (success) from xc_try_{bzip2,lzma,xz}_decode() in case xc_dom_register_external() would have failed. As another side effect this also addresses the first error path of _xc_try_lzma_decode() previously bypassing lzma_end(). Signed-off-by: Jan Beulich Acked-by: Wei Liu --- v3: Use helper for unaligned reads. v2: New. --- a/tools/libs/guest/xg_dom_bzimageloader.c +++ b/tools/libs/guest/xg_dom_bzimageloader.c @@ -48,18 +48,16 @@ static int xc_try_bzip2_decode( bz_stream stream; int ret; char *out_buf; - char *tmp_buf; int retval = -1; - unsigned int outsize; - uint64_t total; + unsigned int insize, outsize; stream.bzalloc = NULL; stream.bzfree = NULL; stream.opaque = NULL; - if ( dom->kernel_size == 0) + if ( *size <= 8 ) { - DOMPRINTF("BZIP2: Input is 0 size"); + DOMPRINTF("BZIP2: insufficient input data"); return -1; } @@ -70,22 +68,25 @@ static int xc_try_bzip2_decode( return -1; } - /* sigh. We don't know up-front how much memory we are going to need - * for the output buffer. Allocate the output buffer to be equal - * the input buffer to start, and we'll realloc as needed. - */ - outsize = dom->kernel_size; + insize = *size - 4; + outsize = get_unaligned_le32(*blob + insize); /* - * stream.avail_in and outsize are unsigned int, while kernel_size + * stream.avail_in and insize are unsigned int, while *size * is a size_t. Check we aren't overflowing. */ - if ( outsize != dom->kernel_size ) + if ( insize + 4 != *size ) { DOMPRINTF("BZIP2: Input too large"); goto bzip2_cleanup; } + if ( xc_dom_kernel_check_size(dom, outsize) ) + { + DOMPRINTF("BZIP2: output too large"); + goto bzip2_cleanup; + } + out_buf = malloc(outsize); if ( out_buf == NULL ) { @@ -94,86 +95,45 @@ static int xc_try_bzip2_decode( } stream.next_in = dom->kernel_blob; - stream.avail_in = dom->kernel_size; + stream.avail_in = insize; stream.next_out = out_buf; - stream.avail_out = dom->kernel_size; + stream.avail_out = outsize; - for ( ; ; ) + ret = BZ2_bzDecompress(&stream); + if ( ret == BZ_STREAM_END ) + DOMPRINTF("BZIP2: Saw data stream end"); + else if ( ret != BZ_OK ) { - ret = BZ2_bzDecompress(&stream); - if ( ret == BZ_STREAM_END ) - { - DOMPRINTF("BZIP2: Saw data stream end"); - retval = 0; - break; - } - if ( ret != BZ_OK ) - { - DOMPRINTF("BZIP2: error %d", ret); - free(out_buf); - goto bzip2_cleanup; - } + DOMPRINTF("BZIP2: error %d", ret); + free(out_buf); + goto bzip2_cleanup; + } - if ( stream.avail_out == 0 ) - { - /* Protect against output buffer overflow */ - if ( outsize > UINT_MAX / 2 ) - { - DOMPRINTF("BZIP2: output buffer overflow"); - free(out_buf); - goto bzip2_cleanup; - } - - if ( xc_dom_kernel_check_size(dom, outsize * 2) ) - { - DOMPRINTF("BZIP2: output too large"); - free(out_buf); - goto bzip2_cleanup; - } - - tmp_buf = realloc(out_buf, outsize * 2); - if ( tmp_buf == NULL ) - { - DOMPRINTF("BZIP2: Failed to realloc memory"); - free(out_buf); - goto bzip2_cleanup; - } - out_buf = tmp_buf; - - stream.next_out = out_buf + outsize; - stream.avail_out = (outsize * 2) - outsize; - outsize *= 2; - } - else if ( stream.avail_in == 0 ) - { - /* - * If there is output buffer available then this indicates - * that BZ2_bzDecompress would like more input data to be - * provided. However our complete input buffer is in - * memory and provided upfront so if avail_in is zero this - * actually indicates a truncated input. - */ - DOMPRINTF("BZIP2: not enough input"); - free(out_buf); - goto bzip2_cleanup; - } + if ( stream.total_out_lo32 != outsize || stream.total_out_hi32 ) + { + DOMPRINTF("BZIP2: got 0x%x%08x bytes instead of 0x%09x", + stream.total_out_hi32, stream.total_out_lo32, outsize); + free(out_buf); + goto bzip2_cleanup; } - total = (((uint64_t)stream.total_out_hi32) << 32) | stream.total_out_lo32; + if ( stream.avail_in ) + DOMPRINTF("BZIP2: Warning: %#x unconsumed bytes", stream.avail_in); - if ( xc_dom_register_external(dom, out_buf, total) ) + if ( xc_dom_register_external(dom, out_buf, outsize) ) { DOMPRINTF("BZIP2: Error registering stream output"); free(out_buf); goto bzip2_cleanup; } - DOMPRINTF("%s: BZIP2 decompress OK, 0x%zx -> 0x%lx", - __FUNCTION__, *size, (long unsigned int) total); + DOMPRINTF("%s: BZIP2 decompress OK, 0x%zx -> 0x%x", + __FUNCTION__, *size, outsize); *blob = out_buf; - *size = total; + *size = outsize; + retval = 0; bzip2_cleanup: BZ2_bzDecompressEnd(&stream); @@ -205,22 +165,24 @@ static int _xc_try_lzma_decode( lzma_ret ret; lzma_action action = LZMA_RUN; unsigned char *out_buf; - unsigned char *tmp_buf; int retval = -1; - size_t outsize; - const char *msg; + size_t insize, outsize; - if ( dom->kernel_size == 0) + if ( *size < 8 ) { - DOMPRINTF("%s: Input is 0 size", what); - return -1; + DOMPRINTF("%s: insufficient input data", what); + goto lzma_cleanup; + } + + insize = *size - 4; + outsize = get_unaligned_le32(*blob + insize); + + if ( xc_dom_kernel_check_size(dom, outsize) ) + { + DOMPRINTF("%s: output too large", what); + goto lzma_cleanup; } - /* sigh. We don't know up-front how much memory we are going to need - * for the output buffer. Allocate the output buffer to be equal - * the input buffer to start, and we'll realloc as needed. - */ - outsize = dom->kernel_size; out_buf = malloc(outsize); if ( out_buf == NULL ) { @@ -229,92 +191,68 @@ static int _xc_try_lzma_decode( } stream->next_in = dom->kernel_blob; - stream->avail_in = dom->kernel_size; + stream->avail_in = insize; stream->next_out = out_buf; - stream->avail_out = dom->kernel_size; + stream->avail_out = outsize; - for ( ; ; ) + ret = lzma_code(stream, action); + if ( ret == LZMA_STREAM_END ) + DOMPRINTF("%s: Saw data stream end", what); + else if ( ret != LZMA_OK ) { - ret = lzma_code(stream, action); - if ( ret == LZMA_STREAM_END ) + const char *msg; + + switch ( ret ) { - DOMPRINTF("%s: Saw data stream end", what); - retval = 0; + case LZMA_MEM_ERROR: + msg = strerror(ENOMEM); break; - } - if ( ret != LZMA_OK ) - { - switch ( ret ) - { - case LZMA_MEM_ERROR: - msg = strerror(ENOMEM); - break; - case LZMA_MEMLIMIT_ERROR: - msg = "Memory usage limit reached"; - break; + case LZMA_MEMLIMIT_ERROR: + msg = "Memory usage limit reached"; + break; - case LZMA_FORMAT_ERROR: - msg = "File format not recognized"; - break; + case LZMA_FORMAT_ERROR: + msg = "File format not recognized"; + break; - case LZMA_OPTIONS_ERROR: - // FIXME: Better message? - msg = "Unsupported compression options"; - break; + case LZMA_OPTIONS_ERROR: + // FIXME: Better message? + msg = "Unsupported compression options"; + break; - case LZMA_DATA_ERROR: - msg = "File is corrupt"; - break; + case LZMA_DATA_ERROR: + msg = "File is corrupt"; + break; - case LZMA_BUF_ERROR: - msg = "Unexpected end of input"; - break; + case LZMA_BUF_ERROR: + msg = "Unexpected end of input"; + break; - default: - msg = "Internal program error (bug)"; - break; - } - DOMPRINTF("%s: %s decompression error: %s", - __FUNCTION__, what, msg); - free(out_buf); - goto lzma_cleanup; + default: + msg = "Internal program error (bug)"; + break; } - if ( stream->avail_out == 0 ) - { - /* Protect against output buffer overflow */ - if ( outsize > SIZE_MAX / 2 ) - { - DOMPRINTF("%s: output buffer overflow", what); - free(out_buf); - goto lzma_cleanup; - } - - if ( xc_dom_kernel_check_size(dom, outsize * 2) ) - { - DOMPRINTF("%s: output too large", what); - free(out_buf); - goto lzma_cleanup; - } - - tmp_buf = realloc(out_buf, outsize * 2); - if ( tmp_buf == NULL ) - { - DOMPRINTF("%s: Failed to realloc memory", what); - free(out_buf); - goto lzma_cleanup; - } - out_buf = tmp_buf; - - stream->next_out = out_buf + outsize; - stream->avail_out = (outsize * 2) - outsize; - outsize *= 2; - } + DOMPRINTF("%s: %s decompression error: %s", + __FUNCTION__, what, msg); + free(out_buf); + goto lzma_cleanup; + } + + if ( stream->total_out != outsize ) + { + DOMPRINTF("%s: got 0x%"PRIx64" bytes instead of 0x%zx", + what, stream->total_out, outsize); + free(out_buf); + goto lzma_cleanup; } - if ( xc_dom_register_external(dom, out_buf, stream->total_out) ) + if ( stream->avail_in ) + DOMPRINTF("%s: Warning: %#zx unconsumed bytes", what, stream->avail_in); + + if ( xc_dom_register_external(dom, out_buf, outsize) ) { DOMPRINTF("%s: Error registering stream output", what); free(out_buf); @@ -322,10 +260,11 @@ static int _xc_try_lzma_decode( } DOMPRINTF("%s: %s decompress OK, 0x%zx -> 0x%zx", - __FUNCTION__, what, *size, (size_t)stream->total_out); + __FUNCTION__, what, *size, outsize); *blob = out_buf; - *size = stream->total_out; + *size = outsize; + retval = 0; lzma_cleanup: lzma_end(stream); @@ -408,8 +347,8 @@ static int xc_try_lzo1x_decode( { int ret; const unsigned char *cur = dom->kernel_blob; - unsigned char *out_buf = NULL; - size_t left = dom->kernel_size, outsize; + unsigned char *out_buf; + size_t left = dom->kernel_size, outsize, outtot; const char *msg; unsigned version; static const unsigned char magic[] = { @@ -435,6 +374,15 @@ static int xc_try_lzo1x_decode( return -1; } + left -= 4; + outtot = get_unaligned_le32(*blob + left); + + if ( xc_dom_kernel_check_size(dom, outtot) ) + { + DOMPRINTF("LZO1x: output too large"); + return -1; + } + /* get version (2bytes), skip library version (2), * 'need to be extracted' version (2) and method (1) */ version = lzo_read_16(cur + 9); @@ -471,10 +419,16 @@ static int xc_try_lzo1x_decode( cur += ret; left -= ret; + out_buf = malloc(outtot); + if ( !out_buf ) + { + DOMPRINTF("LZO1x: failed to alloc memory"); + return -1; + } + for ( outsize = 0; ; ) { lzo_uint src_len, dst_len, out_len; - unsigned char *tmp_buf; msg = "Short input"; if ( left < 4 ) @@ -483,6 +437,13 @@ static int xc_try_lzo1x_decode( dst_len = lzo_read_32(cur); if ( !dst_len ) { + msg = "Unexpected output size"; + if ( outsize != outtot ) + break; + + if ( left != 4 ) + DOMPRINTF("LZO1x: Warning: %#zx unconsumed bytes", left - 4); + msg = "Error registering stream output"; if ( xc_dom_register_external(dom, out_buf, outsize) ) break; @@ -514,19 +475,9 @@ static int xc_try_lzo1x_decode( break; msg = "Output buffer overflow"; - if ( outsize > SIZE_MAX - dst_len ) - break; - - msg = "Decompressed image too large"; - if ( xc_dom_kernel_check_size(dom, outsize + dst_len) ) - break; - - msg = "Failed to (re)alloc memory"; - tmp_buf = realloc(out_buf, outsize + dst_len); - if ( tmp_buf == NULL ) + if ( dst_len > outtot - outsize ) break; - out_buf = tmp_buf; out_len = dst_len; ret = lzo1x_decompress_safe(cur, src_len, From patchwork Tue Jan 26 09:51:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28533C433DB for ; Tue, 26 Jan 2021 09:51:15 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9A38206B5 for ; Tue, 26 Jan 2021 09:51:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9A38206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74732.134335 (Exim 4.92) (envelope-from ) id 1l4L06-00019Y-Ik; Tue, 26 Jan 2021 09:51:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74732.134335; Tue, 26 Jan 2021 09:51:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L06-00019R-FS; Tue, 26 Jan 2021 09:51:06 +0000 Received: by outflank-mailman (input) for mailman id 74732; Tue, 26 Jan 2021 09:51:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L05-00019E-9l for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:51:05 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 847934c1-74f9-41b2-864e-a4791bbcc5b9; Tue, 26 Jan 2021 09:51:04 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 7801CAE40; Tue, 26 Jan 2021 09:51:03 +0000 (UTC) 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" X-Inumbo-ID: 847934c1-74f9-41b2-864e-a4791bbcc5b9 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kI7/dlB+nykep5k8tkQbgg5svw4MBZtWSOUhKGSPGrs=; b=ASg9I2mgrIPFqWXfQXI/ZjhdaPIh2gkoTMFNxQ4mOyeOMrIk1TW8w156fYxuN8HjjOYIdl wlTxzULVge0h+BMIbu8Bilu0mHGErOELdb/dgYR3ubR5Xs7Q7aMti0zzTtHIFAuhfqi9T+ UDRXa8Uc+dZPryUGFDEWCkGlwkmf1g4= Subject: [PATCH v3 08/15] bunzip: replace INIT From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: <9069acc9-7e86-a0c7-5ec9-e12d674bb834@suse.com> Date: Tue, 26 Jan 2021 10:51:04 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US While tools/libs/guest/xg_private.h has its own (non-conflicting for our purposes) __init, which hence needs to be #undef-ed, there's no other need for this abstraction. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Acked-by: Julien Grall --- v3: New. --- a/xen/common/decompress.h +++ b/xen/common/decompress.h @@ -23,6 +23,10 @@ #define INIT #define INITDATA +#undef __init /* tools/libs/guest/xg_private.h has its own one */ +#define __init +#define __initdata + #define large_malloc malloc #define large_free free --- a/xen/common/bunzip2.c +++ b/xen/common/bunzip2.c @@ -104,7 +104,7 @@ struct bunzip_data { /* Return the next nnn bits of input. All reads from the compressed input are done through this function. All reads are big endian */ -static unsigned int INIT get_bits(struct bunzip_data *bd, char bits_wanted) +static unsigned int __init get_bits(struct bunzip_data *bd, char bits_wanted) { unsigned int bits = 0; @@ -144,7 +144,7 @@ static unsigned int INIT get_bits(struct /* Unpacks the next block and sets up for the inverse burrows-wheeler step. */ -static int INIT get_next_block(struct bunzip_data *bd) +static int __init get_next_block(struct bunzip_data *bd) { struct group_data *hufGroup = NULL; int *base = NULL; @@ -509,7 +509,7 @@ got_huff_bits: are ignored, data is written to out_fd and return is RETVAL_OK or error. */ -static int INIT read_bunzip(struct bunzip_data *bd, unsigned char *outbuf, int len) +static int __init read_bunzip(struct bunzip_data *bd, unsigned char *outbuf, int len) { const unsigned int *dbuf; int pos, xcurrent, previous, gotcount; @@ -607,7 +607,7 @@ decode_next_byte: goto decode_next_byte; } -static int INIT nofill(void *buf, unsigned int len) +static int __init nofill(void *buf, unsigned int len) { return -1; } @@ -615,8 +615,8 @@ static int INIT nofill(void *buf, unsign /* Allocate the structure, read file header. If in_fd ==-1, inbuf must contain a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are ignored, and data is read from file handle into temporary buffer. */ -static int INIT start_bunzip(struct bunzip_data **bdp, void *inbuf, int len, - int (*fill)(void*, unsigned int)) +static int __init start_bunzip(struct bunzip_data **bdp, void *inbuf, int len, + int (*fill)(void*, unsigned int)) { struct bunzip_data *bd; unsigned int i, j, c; @@ -665,11 +665,11 @@ static int INIT start_bunzip(struct bunz /* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip2 data, not end of file.) */ -int INIT bunzip2(unsigned char *buf, unsigned int len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), - unsigned char *outbuf, unsigned int *pos, - void(*error)(const char *x)) +int __init bunzip2(unsigned char *buf, unsigned int len, + int(*fill)(void*, unsigned int), + int(*flush)(void*, unsigned int), + unsigned char *outbuf, unsigned int *pos, + void(*error)(const char *x)) { struct bunzip_data *bd; int i = -1; From patchwork Tue Jan 26 09:51:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABF37C433E0 for ; Tue, 26 Jan 2021 09:51:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 58733206B5 for ; Tue, 26 Jan 2021 09:51:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58733206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74735.134348 (Exim 4.92) (envelope-from ) id 1l4L0P-0001Ga-RT; Tue, 26 Jan 2021 09:51:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74735.134348; Tue, 26 Jan 2021 09:51:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L0P-0001GT-Nn; Tue, 26 Jan 2021 09:51:25 +0000 Received: by outflank-mailman (input) for mailman id 74735; Tue, 26 Jan 2021 09:51:24 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L0O-0001G7-Cw for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:51:24 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ddf7a50c-8962-4546-b371-1dcafdcb598a; Tue, 26 Jan 2021 09:51:23 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A1BC6AE40; Tue, 26 Jan 2021 09:51:22 +0000 (UTC) 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" X-Inumbo-ID: ddf7a50c-8962-4546-b371-1dcafdcb598a X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654682; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ei0fpeiiAKGtY8+oZt/tf9Q3mew4s0SgaZQoWt8z3PE=; b=M7WhP6UKn/HeIuyo1huiOoOsgDFjRhWachYqvl1wrvtoS2Ho8a0VGsHuKV1j5xc4LFqWOA zyjrd0cUYpDAdLZXkh/qQgq/NIMOM/gghs7SaLJvgH48cKQouLIML98dzl31YmcqgnDstz 2CGVfvv7hJLsoAsH4s2kCw3xa3vgdEY= Subject: [PATCH v3 09/15] unlzo: replace INIT From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: Date: Tue, 26 Jan 2021 10:51:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US There's no need for this abstraction. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Acked-by: Julien Grall --- v3: New. --- a/xen/common/lzo.c +++ b/xen/common/lzo.c @@ -135,8 +135,8 @@ */ #define MAX_255_COUNT ((((size_t)~0) / 255) - 2) -int INIT lzo1x_decompress_safe(const unsigned char *in, size_t in_len, - unsigned char *out, size_t *out_len) +int __init lzo1x_decompress_safe(const unsigned char *in, size_t in_len, + unsigned char *out, size_t *out_len) { unsigned char *op; const unsigned char *ip; --- a/xen/common/unlzo.c +++ b/xen/common/unlzo.c @@ -57,7 +57,7 @@ static const unsigned char lzop_magic[] #define HEADER_SIZE_MIN (9 + 7 + 4 + 8 + 1 + 4) #define HEADER_SIZE_MAX (9 + 7 + 1 + 8 + 8 + 4 + 1 + 255 + 4) -static int INIT parse_header(u8 *input, int *skip, int in_len) +static int __init parse_header(u8 *input, int *skip, int in_len) { int l; u8 *parse = input; @@ -114,11 +114,11 @@ static int INIT parse_header(u8 *input, return 1; } -int INIT unlzo(unsigned char *input, unsigned int in_len, - int (*fill) (void *, unsigned int), - int (*flush) (void *, unsigned int), - unsigned char *output, unsigned int *posp, - void (*error) (const char *x)) +int __init unlzo(unsigned char *input, unsigned int in_len, + int (*fill) (void *, unsigned int), + int (*flush) (void *, unsigned int), + unsigned char *output, unsigned int *posp, + void (*error) (const char *x)) { u8 r = 0; int skip = 0; From patchwork Tue Jan 26 09:51:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A51A2C433DB for ; Tue, 26 Jan 2021 09:51:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 62857206B5 for ; Tue, 26 Jan 2021 09:51:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62857206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74742.134360 (Exim 4.92) (envelope-from ) id 1l4L0p-0001OP-59; Tue, 26 Jan 2021 09:51:51 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74742.134360; Tue, 26 Jan 2021 09:51:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L0p-0001OI-0C; Tue, 26 Jan 2021 09:51:51 +0000 Received: by outflank-mailman (input) for mailman id 74742; Tue, 26 Jan 2021 09:51:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L0n-0001O4-Od for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:51:49 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 45470abb-f0e0-4948-b497-f378f54a6531; Tue, 26 Jan 2021 09:51:48 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D48C9AF17; Tue, 26 Jan 2021 09:51:47 +0000 (UTC) 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" X-Inumbo-ID: 45470abb-f0e0-4948-b497-f378f54a6531 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654708; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=azZcQFU/ZVnloJg9e2l3sLBy83G0faybtBUm3/hBATU=; b=TJClGczvJPfeJr4QweEM1cgE3vACvhAGQr8ecl/oi21g8ZE7jsA80SH0q6hlubjj1RamCa mR8D/L5W2GAHg3uWBMTWvvVxEL4d9l2WkvJr+29UkS/EWoWf4gNpZQQ2ppVPCjdgZ6jlnA 46YOOseV8J9cbXom9ruTYjPAJNpWQc0= Subject: [PATCH v3 10/15] unlzma: replace INIT From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: Date: Tue, 26 Jan 2021 10:51:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US There's no need for this abstraction. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Acked-by: Julien Grall --- v3: New. --- a/xen/common/unlzma.c +++ b/xen/common/unlzma.c @@ -30,7 +30,7 @@ #include "decompress.h" -static long long INIT read_int(unsigned char *ptr, int size) +static long long __init read_int(unsigned char *ptr, int size) { int i; long long ret = 0; @@ -76,13 +76,13 @@ struct rc { #define RC_MODEL_TOTAL_BITS 11 -static int INIT nofill(void *buffer, unsigned int len) +static int __init nofill(void *buffer, unsigned int len) { return -1; } /* Called twice: once at startup and once in rc_normalize() */ -static void INIT rc_read(struct rc *rc) +static void __init rc_read(struct rc *rc) { rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE); if (rc->buffer_size <= 0) @@ -92,9 +92,9 @@ static void INIT rc_read(struct rc *rc) } /* Called once */ -static inline void INIT rc_init(struct rc *rc, - int (*fill)(void*, unsigned int), - unsigned char *buffer, int buffer_size) +static inline void __init rc_init(struct rc *rc, + int (*fill)(void*, unsigned int), + unsigned char *buffer, int buffer_size) { if (fill) rc->fill = fill; @@ -109,7 +109,7 @@ static inline void INIT rc_init(struct r rc->range = 0xFFFFFFFF; } -static inline void INIT rc_init_code(struct rc *rc) +static inline void __init rc_init_code(struct rc *rc) { int i; @@ -122,14 +122,14 @@ static inline void INIT rc_init_code(str /* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */ -static void INIT rc_do_normalize(struct rc *rc) +static void __init rc_do_normalize(struct rc *rc) { if (rc->ptr >= rc->buffer_end) rc_read(rc); rc->range <<= 8; rc->code = (rc->code << 8) | *rc->ptr++; } -static inline void INIT rc_normalize(struct rc *rc) +static inline void __init rc_normalize(struct rc *rc) { if (rc->range < (1 << RC_TOP_BITS)) rc_do_normalize(rc); @@ -139,20 +139,20 @@ static inline void INIT rc_normalize(str /* Why rc_is_bit_0_helper exists? *Because we want to always expose (rc->code < rc->bound) to optimizer */ -static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p) +static inline uint32_t __init rc_is_bit_0_helper(struct rc *rc, uint16_t *p) { rc_normalize(rc); rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); return rc->bound; } -static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p) +static inline int __init rc_is_bit_0(struct rc *rc, uint16_t *p) { uint32_t t = rc_is_bit_0_helper(rc, p); return rc->code < t; } /* Called ~10 times, but very small, thus inlined */ -static inline void INIT rc_update_bit_0(struct rc *rc, uint16_t *p) +static inline void __init rc_update_bit_0(struct rc *rc, uint16_t *p) { rc->range = rc->bound; *p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS; @@ -165,7 +165,7 @@ static inline void rc_update_bit_1(struc } /* Called 4 times in unlzma loop */ -static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol) +static int __init rc_get_bit(struct rc *rc, uint16_t *p, int *symbol) { if (rc_is_bit_0(rc, p)) { rc_update_bit_0(rc, p); @@ -179,7 +179,7 @@ static int INIT rc_get_bit(struct rc *rc } /* Called once */ -static inline int INIT rc_direct_bit(struct rc *rc) +static inline int __init rc_direct_bit(struct rc *rc) { rc_normalize(rc); rc->range >>= 1; @@ -191,7 +191,7 @@ static inline int INIT rc_direct_bit(str } /* Called twice */ -static inline void INIT +static inline void __init rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol) { int i = num_levels; @@ -283,14 +283,14 @@ struct cstate { uint32_t rep0, rep1, rep2, rep3; }; -static inline size_t INIT get_pos(struct writer *wr) +static inline size_t __init get_pos(struct writer *wr) { return wr->global_pos + wr->buffer_pos; } -static inline uint8_t INIT peek_old_byte(struct writer *wr, - uint32_t offs) +static inline uint8_t __init peek_old_byte(struct writer *wr, + uint32_t offs) { if (!wr->flush) { int32_t pos; @@ -307,7 +307,7 @@ static inline uint8_t INIT peek_old_byte } -static inline int INIT write_byte(struct writer *wr, uint8_t byte) +static inline int __init write_byte(struct writer *wr, uint8_t byte) { wr->buffer[wr->buffer_pos++] = wr->previous_byte = byte; if (wr->flush && wr->buffer_pos == wr->header->dict_size) { @@ -321,13 +321,13 @@ static inline int INIT write_byte(struct } -static inline int INIT copy_byte(struct writer *wr, uint32_t offs) +static inline int __init copy_byte(struct writer *wr, uint32_t offs) { return write_byte(wr, peek_old_byte(wr, offs)); } -static inline int INIT copy_bytes(struct writer *wr, - uint32_t rep0, int len) +static inline int __init copy_bytes(struct writer *wr, + uint32_t rep0, int len) { do { if (copy_byte(wr, rep0)) @@ -338,10 +338,10 @@ static inline int INIT copy_bytes(struct return len; } -static inline int INIT process_bit0(struct writer *wr, struct rc *rc, - struct cstate *cst, uint16_t *p, - int pos_state, uint16_t *prob, - int lc, uint32_t literal_pos_mask) { +static inline int __init process_bit0(struct writer *wr, struct rc *rc, + struct cstate *cst, uint16_t *p, + int pos_state, uint16_t *prob, + int lc, uint32_t literal_pos_mask) { int mi = 1; rc_update_bit_0(rc, prob); prob = (p + LZMA_LITERAL + @@ -382,9 +382,9 @@ static inline int INIT process_bit0(stru return write_byte(wr, mi); } -static inline int INIT process_bit1(struct writer *wr, struct rc *rc, - struct cstate *cst, uint16_t *p, - int pos_state, uint16_t *prob) { +static inline int __init process_bit1(struct writer *wr, struct rc *rc, + struct cstate *cst, uint16_t *p, + int pos_state, uint16_t *prob) { int offset; uint16_t *prob_len; int num_bits; @@ -528,11 +528,11 @@ static inline int INIT process_bit1(stru -int INIT unlzma(unsigned char *buf, unsigned int in_len, - int(*fill)(void*, unsigned int), - int(*flush)(void*, unsigned int), - unsigned char *output, unsigned int *posp, - void(*error)(const char *x)) +int __init unlzma(unsigned char *buf, unsigned int in_len, + int(*fill)(void*, unsigned int), + int(*flush)(void*, unsigned int), + unsigned char *output, unsigned int *posp, + void(*error)(const char *x)) { struct lzma_header header; int lc, pb, lp; From patchwork Tue Jan 26 09:52:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AD22C433DB for ; Tue, 26 Jan 2021 09:52:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EFB8B206B5 for ; Tue, 26 Jan 2021 09:52:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFB8B206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74747.134372 (Exim 4.92) (envelope-from ) id 1l4L1B-0001Vd-DQ; Tue, 26 Jan 2021 09:52:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74747.134372; Tue, 26 Jan 2021 09:52:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L1B-0001VW-9v; Tue, 26 Jan 2021 09:52:13 +0000 Received: by outflank-mailman (input) for mailman id 74747; Tue, 26 Jan 2021 09:52:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L1A-0001VI-0m for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:52:12 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 872d0d08-5352-419d-a981-3309dab0055c; Tue, 26 Jan 2021 09:52:11 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6499BAE66; Tue, 26 Jan 2021 09:52:10 +0000 (UTC) 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" X-Inumbo-ID: 872d0d08-5352-419d-a981-3309dab0055c X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654730; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JRFVVYygJfSJptNngeIO54NYglKiK3pqJ6XrFt4X+XY=; b=TAU3u81g4lgui3UUbF+gOSS7UPg/C6IA2M0vUbyFJGwR094M5AIU1kzTkoViLEttAKuF7Z HpagrCoXfX/DFvKXJNHBgpZ5ZThiOROj5RBwxqfj92erUcqGcoPIAgMol11iPeFkeLD6nx iTk2F9VFD7T2dSKwSsbOupcN5YDR6dY= Subject: [PATCH v3 11/15] unlz4: replace INIT From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: Date: Tue, 26 Jan 2021 10:52:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US There's no need for this abstraction. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Reviewed-by: Julien Grall --- v3: New. --- a/xen/common/lz4/decompress.c +++ b/xen/common/lz4/decompress.c @@ -46,8 +46,8 @@ static const int8_t dec64table[] = {0, 0 #if defined(__XEN__) || defined(__MINIOS__) -static int INIT lz4_uncompress(const unsigned char *source, unsigned char *dest, - int osize) +static int __init lz4_uncompress(const unsigned char *source, unsigned char *dest, + int osize) { const BYTE *ip = (const BYTE *) source; const BYTE *ref; @@ -302,8 +302,8 @@ _output_error: #if defined(__XEN__) || defined(__MINIOS__) -int INIT lz4_decompress(const unsigned char *src, size_t *src_len, - unsigned char *dest, size_t actual_dest_len) +int __init lz4_decompress(const unsigned char *src, size_t *src_len, + unsigned char *dest, size_t actual_dest_len) { int ret = -1; int input_len = 0; --- a/xen/common/unlz4.c +++ b/xen/common/unlz4.c @@ -22,11 +22,11 @@ #define LZ4_DEFAULT_UNCOMPRESSED_CHUNK_SIZE (8 << 20) #define ARCHIVE_MAGICNUMBER 0x184C2102 -int INIT unlz4(unsigned char *input, unsigned int in_len, - int (*fill)(void *, unsigned int), - int (*flush)(void *, unsigned int), - unsigned char *output, unsigned int *posp, - void (*error)(const char *x)) +int __init unlz4(unsigned char *input, unsigned int in_len, + int (*fill)(void *, unsigned int), + int (*flush)(void *, unsigned int), + unsigned char *output, unsigned int *posp, + void (*error)(const char *x)) { int ret = -1; size_t chunksize = 0; From patchwork Tue Jan 26 09:52:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A8F2C433E0 for ; Tue, 26 Jan 2021 09:52:44 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4684206B5 for ; Tue, 26 Jan 2021 09:52:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4684206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74753.134384 (Exim 4.92) (envelope-from ) id 1l4L1W-0001dI-Tw; Tue, 26 Jan 2021 09:52:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74753.134384; Tue, 26 Jan 2021 09:52:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L1W-0001dB-Qf; Tue, 26 Jan 2021 09:52:34 +0000 Received: by outflank-mailman (input) for mailman id 74753; Tue, 26 Jan 2021 09:52:33 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L1V-0001cu-3t for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:52:33 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a7e55a7a-0a65-4c9e-a28e-93f149f818db; Tue, 26 Jan 2021 09:52:30 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 14BF0AE40; Tue, 26 Jan 2021 09:52:30 +0000 (UTC) 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" X-Inumbo-ID: a7e55a7a-0a65-4c9e-a28e-93f149f818db X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/4i3wadAj9OqzzCi0apOSgqGm1GFZ9A6DvjcMwsMXrQ=; b=NwGWLw4VYFdj40EY4EOCdybeT/Nk9duoQr79zYrl4EVI0jYOGaP705NtnuY+zQB/GEEe8O S4ZLD9nNXiht2NEwGqIZ/d3dvxUQ6G3DFYmWjaSVGBepIrPqldSlIJf3m/m7uW6XkUQSNg 1QbVUnjcyy9DHhbcZuuyKoxE+Y2S/Z4= Subject: [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: <4e0a0db2-db34-a738-2f5e-1d5cd2c37e19@suse.com> Date: Tue, 26 Jan 2021 10:52:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US With xen/common/decompress.h now agreeing in both build modes about what STATIC expands to, there's no need for this abstraction anymore. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Acked-by: Julien Grall --- v3: New. --- a/xen/common/decompress.h +++ b/xen/common/decompress.h @@ -9,7 +9,6 @@ #define STATIC static #define INIT __init -#define INITDATA __initdata #define malloc xmalloc_bytes #define free xfree @@ -21,7 +20,6 @@ #define STATIC static #define INIT -#define INITDATA #undef __init /* tools/libs/guest/xg_private.h has its own one */ #define __init --- a/xen/common/unxz.c +++ b/xen/common/unxz.c @@ -95,7 +95,7 @@ #include "decompress.h" -#define XZ_EXTERN STATIC +#define XZ_EXTERN static /* * For boot time use, we enable only the BCJ filter of the current @@ -157,11 +157,11 @@ * both input and output buffers are available as a single chunk, i.e. when * fill() and flush() won't be used. */ -int INIT unxz(unsigned char *in, unsigned int in_size, - int (*fill)(void *dest, unsigned int size), - int (*flush)(void *src, unsigned int size), - unsigned char *out, unsigned int *in_used, - void (*error)(const char *x)) +int __init unxz(unsigned char *in, unsigned int in_size, + int (*fill)(void *dest, unsigned int size), + int (*flush)(void *src, unsigned int size), + unsigned char *out, unsigned int *in_used, + void (*error)(const char *x)) { struct xz_buf b; struct xz_dec *s; --- a/xen/common/xz/crc32.c +++ b/xen/common/xz/crc32.c @@ -15,9 +15,9 @@ * but they are bigger and use more memory for the lookup table. */ -XZ_EXTERN uint32_t INITDATA xz_crc32_table[256]; +XZ_EXTERN uint32_t __initdata xz_crc32_table[256]; -XZ_EXTERN void INIT xz_crc32_init(void) +XZ_EXTERN void __init xz_crc32_init(void) { const uint32_t poly = 0xEDB88320; @@ -36,7 +36,7 @@ XZ_EXTERN void INIT xz_crc32_init(void) return; } -XZ_EXTERN uint32_t INIT xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) +XZ_EXTERN uint32_t __init xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) { crc = ~crc; --- a/xen/common/xz/dec_bcj.c +++ b/xen/common/xz/dec_bcj.c @@ -80,12 +80,12 @@ struct xz_dec_bcj { * This is used to test the most significant byte of a memory address * in an x86 instruction. */ -static inline int INIT bcj_x86_test_msbyte(uint8_t b) +static inline int __init bcj_x86_test_msbyte(uint8_t b) { return b == 0x00 || b == 0xFF; } -static size_t INIT bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size) +static size_t __init bcj_x86(struct xz_dec_bcj *s, uint8_t *buf, size_t size) { static const bool_t mask_to_allowed_status[8] = { true, true, true, false, true, false, false, false }; @@ -157,7 +157,7 @@ static size_t INIT bcj_x86(struct xz_dec #endif #ifdef XZ_DEC_POWERPC -static size_t INIT bcj_powerpc(struct xz_dec_bcj *s, uint8_t *buf, size_t size) +static size_t __init bcj_powerpc(struct xz_dec_bcj *s, uint8_t *buf, size_t size) { size_t i; uint32_t instr; @@ -178,7 +178,7 @@ static size_t INIT bcj_powerpc(struct xz #endif #ifdef XZ_DEC_IA64 -static size_t INIT bcj_ia64(struct xz_dec_bcj *s, uint8_t *buf, size_t size) +static size_t __init bcj_ia64(struct xz_dec_bcj *s, uint8_t *buf, size_t size) { static const uint8_t branch_table[32] = { 0, 0, 0, 0, 0, 0, 0, 0, @@ -262,7 +262,7 @@ static size_t INIT bcj_ia64(struct xz_de #endif #ifdef XZ_DEC_ARM -static size_t INIT bcj_arm(struct xz_dec_bcj *s, uint8_t *buf, size_t size) +static size_t __init bcj_arm(struct xz_dec_bcj *s, uint8_t *buf, size_t size) { size_t i; uint32_t addr; @@ -285,7 +285,7 @@ static size_t INIT bcj_arm(struct xz_dec #endif #ifdef XZ_DEC_ARMTHUMB -static size_t INIT bcj_armthumb(struct xz_dec_bcj *s, uint8_t *buf, size_t size) +static size_t __init bcj_armthumb(struct xz_dec_bcj *s, uint8_t *buf, size_t size) { size_t i; uint32_t addr; @@ -313,7 +313,7 @@ static size_t INIT bcj_armthumb(struct x #endif #ifdef XZ_DEC_SPARC -static size_t INIT bcj_sparc(struct xz_dec_bcj *s, uint8_t *buf, size_t size) +static size_t __init bcj_sparc(struct xz_dec_bcj *s, uint8_t *buf, size_t size) { size_t i; uint32_t instr; @@ -342,8 +342,8 @@ static size_t INIT bcj_sparc(struct xz_d * pointers, which could be problematic in the kernel boot code, which must * avoid pointers to static data (at least on x86). */ -static void INIT bcj_apply(struct xz_dec_bcj *s, - uint8_t *buf, size_t *pos, size_t size) +static void __init bcj_apply(struct xz_dec_bcj *s, + uint8_t *buf, size_t *pos, size_t size) { size_t filtered; @@ -396,7 +396,7 @@ static void INIT bcj_apply(struct xz_dec * Move the remaining mixture of possibly filtered and unfiltered * data to the beginning of temp. */ -static void INIT bcj_flush(struct xz_dec_bcj *s, struct xz_buf *b) +static void __init bcj_flush(struct xz_dec_bcj *s, struct xz_buf *b) { size_t copy_size; @@ -414,9 +414,9 @@ static void INIT bcj_flush(struct xz_dec * data in chunks of 1-16 bytes. To hide this issue, this function does * some buffering. */ -XZ_EXTERN enum xz_ret INIT xz_dec_bcj_run(struct xz_dec_bcj *s, - struct xz_dec_lzma2 *lzma2, - struct xz_buf *b) +XZ_EXTERN enum xz_ret __init xz_dec_bcj_run(struct xz_dec_bcj *s, + struct xz_dec_lzma2 *lzma2, + struct xz_buf *b) { size_t out_start; @@ -524,7 +524,7 @@ XZ_EXTERN enum xz_ret INIT xz_dec_bcj_ru return s->ret; } -XZ_EXTERN struct xz_dec_bcj *INIT xz_dec_bcj_create(bool_t single_call) +XZ_EXTERN struct xz_dec_bcj *__init xz_dec_bcj_create(bool_t single_call) { struct xz_dec_bcj *s = malloc(sizeof(*s)); if (s != NULL) @@ -533,7 +533,7 @@ XZ_EXTERN struct xz_dec_bcj *INIT xz_dec return s; } -XZ_EXTERN enum xz_ret INIT xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id) +XZ_EXTERN enum xz_ret __init xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id) { switch (id) { #ifdef XZ_DEC_X86 --- a/xen/common/xz/dec_lzma2.c +++ b/xen/common/xz/dec_lzma2.c @@ -283,7 +283,7 @@ struct xz_dec_lzma2 { * Reset the dictionary state. When in single-call mode, set up the beginning * of the dictionary to point to the actual output buffer. */ -static void INIT dict_reset(struct dictionary *dict, struct xz_buf *b) +static void __init dict_reset(struct dictionary *dict, struct xz_buf *b) { if (DEC_IS_SINGLE(dict->mode)) { dict->buf = b->out + b->out_pos; @@ -297,7 +297,7 @@ static void INIT dict_reset(struct dicti } /* Set dictionary write limit */ -static void INIT dict_limit(struct dictionary *dict, size_t out_max) +static void __init dict_limit(struct dictionary *dict, size_t out_max) { if (dict->end - dict->pos <= out_max) dict->limit = dict->end; @@ -306,7 +306,7 @@ static void INIT dict_limit(struct dicti } /* Return true if at least one byte can be written into the dictionary. */ -static inline bool_t INIT dict_has_space(const struct dictionary *dict) +static inline bool_t __init dict_has_space(const struct dictionary *dict) { return dict->pos < dict->limit; } @@ -317,7 +317,7 @@ static inline bool_t INIT dict_has_space * still empty. This special case is needed for single-call decoding to * avoid writing a '\0' to the end of the destination buffer. */ -static inline uint32_t INIT dict_get(const struct dictionary *dict, uint32_t dist) +static inline uint32_t __init dict_get(const struct dictionary *dict, uint32_t dist) { size_t offset = dict->pos - dist - 1; @@ -330,7 +330,7 @@ static inline uint32_t INIT dict_get(con /* * Put one byte into the dictionary. It is assumed that there is space for it. */ -static inline void INIT dict_put(struct dictionary *dict, uint8_t byte) +static inline void __init dict_put(struct dictionary *dict, uint8_t byte) { dict->buf[dict->pos++] = byte; @@ -343,7 +343,7 @@ static inline void INIT dict_put(struct * invalid, false is returned. On success, true is returned and *len is * updated to indicate how many bytes were left to be repeated. */ -static bool_t INIT dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist) +static bool_t __init dict_repeat(struct dictionary *dict, uint32_t *len, uint32_t dist) { size_t back; uint32_t left; @@ -371,8 +371,8 @@ static bool_t INIT dict_repeat(struct di } /* Copy uncompressed data as is from input to dictionary and output buffers. */ -static void INIT dict_uncompressed(struct dictionary *dict, struct xz_buf *b, - uint32_t *left) +static void __init dict_uncompressed(struct dictionary *dict, struct xz_buf *b, + uint32_t *left) { size_t copy_size; @@ -413,7 +413,7 @@ static void INIT dict_uncompressed(struc * enough space in b->out. This is guaranteed because caller uses dict_limit() * before decoding data into the dictionary. */ -static uint32_t INIT dict_flush(struct dictionary *dict, struct xz_buf *b) +static uint32_t __init dict_flush(struct dictionary *dict, struct xz_buf *b) { size_t copy_size = dict->pos - dict->start; @@ -435,7 +435,7 @@ static uint32_t INIT dict_flush(struct d *****************/ /* Reset the range decoder. */ -static void INIT rc_reset(struct rc_dec *rc) +static void __init rc_reset(struct rc_dec *rc) { rc->range = (uint32_t)-1; rc->code = 0; @@ -446,7 +446,7 @@ static void INIT rc_reset(struct rc_dec * Read the first five initial bytes into rc->code if they haven't been * read already. (Yes, the first byte gets completely ignored.) */ -static bool_t INIT rc_read_init(struct rc_dec *rc, struct xz_buf *b) +static bool_t __init rc_read_init(struct rc_dec *rc, struct xz_buf *b) { while (rc->init_bytes_left > 0) { if (b->in_pos == b->in_size) @@ -460,7 +460,7 @@ static bool_t INIT rc_read_init(struct r } /* Return true if there may not be enough input for the next decoding loop. */ -static inline bool_t INIT rc_limit_exceeded(const struct rc_dec *rc) +static inline bool_t __init rc_limit_exceeded(const struct rc_dec *rc) { return rc->in_pos > rc->in_limit; } @@ -469,7 +469,7 @@ static inline bool_t INIT rc_limit_excee * Return true if it is possible (from point of view of range decoder) that * we have reached the end of the LZMA chunk. */ -static inline bool_t INIT rc_is_finished(const struct rc_dec *rc) +static inline bool_t __init rc_is_finished(const struct rc_dec *rc) { return rc->code == 0; } @@ -550,7 +550,7 @@ static always_inline void rc_bittree_rev } /* Decode direct bits (fixed fifty-fifty probability) */ -static inline void INIT rc_direct(struct rc_dec *rc, uint32_t *dest, uint32_t limit) +static inline void __init rc_direct(struct rc_dec *rc, uint32_t *dest, uint32_t limit) { uint32_t mask; @@ -569,7 +569,7 @@ static inline void INIT rc_direct(struct ********/ /* Get pointer to literal coder probability array. */ -static uint16_t *INIT lzma_literal_probs(struct xz_dec_lzma2 *s) +static uint16_t *__init lzma_literal_probs(struct xz_dec_lzma2 *s) { uint32_t prev_byte = dict_get(&s->dict, 0); uint32_t low = prev_byte >> (8 - s->lzma.lc); @@ -578,7 +578,7 @@ static uint16_t *INIT lzma_literal_probs } /* Decode a literal (one 8-bit byte) */ -static void INIT lzma_literal(struct xz_dec_lzma2 *s) +static void __init lzma_literal(struct xz_dec_lzma2 *s) { uint16_t *probs; uint32_t symbol; @@ -616,8 +616,8 @@ static void INIT lzma_literal(struct xz_ } /* Decode the length of the match into s->lzma.len. */ -static void INIT lzma_len(struct xz_dec_lzma2 *s, struct lzma_len_dec *l, - uint32_t pos_state) +static void __init lzma_len(struct xz_dec_lzma2 *s, struct lzma_len_dec *l, + uint32_t pos_state) { uint16_t *probs; uint32_t limit; @@ -643,7 +643,7 @@ static void INIT lzma_len(struct xz_dec_ } /* Decode a match. The distance will be stored in s->lzma.rep0. */ -static void INIT lzma_match(struct xz_dec_lzma2 *s, uint32_t pos_state) +static void __init lzma_match(struct xz_dec_lzma2 *s, uint32_t pos_state) { uint16_t *probs; uint32_t dist_slot; @@ -685,7 +685,7 @@ static void INIT lzma_match(struct xz_de * Decode a repeated match. The distance is one of the four most recently * seen matches. The distance will be stored in s->lzma.rep0. */ -static void INIT lzma_rep_match(struct xz_dec_lzma2 *s, uint32_t pos_state) +static void __init lzma_rep_match(struct xz_dec_lzma2 *s, uint32_t pos_state) { uint32_t tmp; @@ -719,7 +719,7 @@ static void INIT lzma_rep_match(struct x } /* LZMA decoder core */ -static bool_t INIT lzma_main(struct xz_dec_lzma2 *s) +static bool_t __init lzma_main(struct xz_dec_lzma2 *s) { uint32_t pos_state; @@ -764,7 +764,7 @@ static bool_t INIT lzma_main(struct xz_d * Reset the LZMA decoder and range decoder state. Dictionary is nore reset * here, because LZMA state may be reset without resetting the dictionary. */ -static void INIT lzma_reset(struct xz_dec_lzma2 *s) +static void __init lzma_reset(struct xz_dec_lzma2 *s) { uint16_t *probs; size_t i; @@ -796,7 +796,7 @@ static void INIT lzma_reset(struct xz_de * from the decoded lp and pb values. On success, the LZMA decoder state is * reset and true is returned. */ -static bool_t INIT lzma_props(struct xz_dec_lzma2 *s, uint8_t props) +static bool_t __init lzma_props(struct xz_dec_lzma2 *s, uint8_t props) { if (props > (4 * 5 + 4) * 9 + 8) return false; @@ -843,7 +843,7 @@ static bool_t INIT lzma_props(struct xz_ * function. We decode a few bytes from the temporary buffer so that we can * continue decoding from the caller-supplied input buffer again. */ -static bool_t INIT lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b) +static bool_t __init lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b) { size_t in_avail; uint32_t tmp; @@ -928,8 +928,8 @@ static bool_t INIT lzma2_lzma(struct xz_ * Take care of the LZMA2 control layer, and forward the job of actual LZMA * decoding or copying of uncompressed chunks to other functions. */ -XZ_EXTERN enum xz_ret INIT xz_dec_lzma2_run(struct xz_dec_lzma2 *s, - struct xz_buf *b) +XZ_EXTERN enum xz_ret __init xz_dec_lzma2_run(struct xz_dec_lzma2 *s, + struct xz_buf *b) { uint32_t tmp; @@ -1105,8 +1105,8 @@ XZ_EXTERN enum xz_ret INIT xz_dec_lzma2_ return XZ_OK; } -XZ_EXTERN struct xz_dec_lzma2 *INIT xz_dec_lzma2_create(enum xz_mode mode, - uint32_t dict_max) +XZ_EXTERN struct xz_dec_lzma2 *__init xz_dec_lzma2_create(enum xz_mode mode, + uint32_t dict_max) { struct xz_dec_lzma2 *s = malloc(sizeof(*s)); if (s == NULL) @@ -1129,7 +1129,7 @@ XZ_EXTERN struct xz_dec_lzma2 *INIT xz_d return s; } -XZ_EXTERN enum xz_ret INIT xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) +XZ_EXTERN enum xz_ret __init xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) { /* This limits dictionary size to 3 GiB to keep parsing simpler. */ if (props > 39) @@ -1166,7 +1166,7 @@ XZ_EXTERN enum xz_ret INIT xz_dec_lzma2_ return XZ_OK; } -XZ_EXTERN void INIT xz_dec_lzma2_end(struct xz_dec_lzma2 *s) +XZ_EXTERN void __init xz_dec_lzma2_end(struct xz_dec_lzma2 *s) { if (DEC_IS_MULTI(s->dict.mode)) large_free(s->dict.buf); --- a/xen/common/xz/dec_stream.c +++ b/xen/common/xz/dec_stream.c @@ -154,7 +154,7 @@ static const uint8_t check_sizes[16] = { * to copy into s->temp.buf. Return true once s->temp.pos has reached * s->temp.size. */ -static bool_t INIT fill_temp(struct xz_dec *s, struct xz_buf *b) +static bool_t __init fill_temp(struct xz_dec *s, struct xz_buf *b) { size_t copy_size = min_t(size_t, b->in_size - b->in_pos, s->temp.size - s->temp.pos); @@ -172,8 +172,8 @@ static bool_t INIT fill_temp(struct xz_d } /* Decode a variable-length integer (little-endian base-128 encoding) */ -static enum xz_ret INIT dec_vli(struct xz_dec *s, const uint8_t *in, - size_t *in_pos, size_t in_size) +static enum xz_ret __init dec_vli(struct xz_dec *s, const uint8_t *in, + size_t *in_pos, size_t in_size) { uint8_t byte; @@ -215,7 +215,7 @@ static enum xz_ret INIT dec_vli(struct x * the sizes possibly stored in the Block Header. Update the hash and * Block count, which are later used to validate the Index field. */ -static enum xz_ret INIT dec_block(struct xz_dec *s, struct xz_buf *b) +static enum xz_ret __init dec_block(struct xz_dec *s, struct xz_buf *b) { enum xz_ret ret; @@ -278,7 +278,7 @@ static enum xz_ret INIT dec_block(struct } /* Update the Index size and the CRC32 value. */ -static void INIT index_update(struct xz_dec *s, const struct xz_buf *b) +static void __init index_update(struct xz_dec *s, const struct xz_buf *b) { size_t in_used = b->in_pos - s->in_start; s->index.size += in_used; @@ -293,7 +293,7 @@ static void INIT index_update(struct xz_ * This can return XZ_OK (more input needed), XZ_STREAM_END (everything * successfully decoded), or XZ_DATA_ERROR (input is corrupt). */ -static enum xz_ret INIT dec_index(struct xz_dec *s, struct xz_buf *b) +static enum xz_ret __init dec_index(struct xz_dec *s, struct xz_buf *b) { enum xz_ret ret; @@ -343,7 +343,7 @@ static enum xz_ret INIT dec_index(struct * Validate that the next four input bytes match the value of s->crc32. * s->pos must be zero when starting to validate the first byte. */ -static enum xz_ret INIT crc32_validate(struct xz_dec *s, struct xz_buf *b) +static enum xz_ret __init crc32_validate(struct xz_dec *s, struct xz_buf *b) { do { if (b->in_pos == b->in_size) @@ -367,7 +367,7 @@ static enum xz_ret INIT crc32_validate(s * Skip over the Check field when the Check ID is not supported. * Returns true once the whole Check field has been skipped over. */ -static bool_t INIT check_skip(struct xz_dec *s, struct xz_buf *b) +static bool_t __init check_skip(struct xz_dec *s, struct xz_buf *b) { while (s->pos < check_sizes[s->check_type]) { if (b->in_pos == b->in_size) @@ -384,7 +384,7 @@ static bool_t INIT check_skip(struct xz_ #endif /* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */ -static enum xz_ret INIT dec_stream_header(struct xz_dec *s) +static enum xz_ret __init dec_stream_header(struct xz_dec *s) { if (!memeq(s->temp.buf, HEADER_MAGIC, HEADER_MAGIC_SIZE)) return XZ_FORMAT_ERROR; @@ -419,7 +419,7 @@ static enum xz_ret INIT dec_stream_heade } /* Decode the Stream Footer field (the last 12 bytes of the .xz Stream) */ -static enum xz_ret INIT dec_stream_footer(struct xz_dec *s) +static enum xz_ret __init dec_stream_footer(struct xz_dec *s) { if (!memeq(s->temp.buf + 10, FOOTER_MAGIC, FOOTER_MAGIC_SIZE)) return XZ_DATA_ERROR; @@ -446,7 +446,7 @@ static enum xz_ret INIT dec_stream_foote } /* Decode the Block Header and initialize the filter chain. */ -static enum xz_ret INIT dec_block_header(struct xz_dec *s) +static enum xz_ret __init dec_block_header(struct xz_dec *s) { enum xz_ret ret; @@ -546,7 +546,7 @@ static enum xz_ret INIT dec_block_header return XZ_OK; } -static enum xz_ret INIT dec_main(struct xz_dec *s, struct xz_buf *b) +static enum xz_ret __init dec_main(struct xz_dec *s, struct xz_buf *b) { enum xz_ret ret; @@ -706,7 +706,7 @@ static enum xz_ret INIT dec_main(struct /* Never reached */ } -XZ_EXTERN void INIT xz_dec_reset(struct xz_dec *s) +XZ_EXTERN void __init xz_dec_reset(struct xz_dec *s) { s->sequence = SEQ_STREAM_HEADER; s->allow_buf_error = false; @@ -743,7 +743,7 @@ XZ_EXTERN void INIT xz_dec_reset(struct * actually succeeds (that's the price to pay of using the output buffer as * the workspace). */ -XZ_EXTERN enum xz_ret INIT xz_dec_run(struct xz_dec *s, struct xz_buf *b) +XZ_EXTERN enum xz_ret __init xz_dec_run(struct xz_dec *s, struct xz_buf *b) { size_t in_start; size_t out_start; @@ -779,7 +779,7 @@ XZ_EXTERN enum xz_ret INIT xz_dec_run(st return ret; } -XZ_EXTERN struct xz_dec *INIT xz_dec_init(enum xz_mode mode, uint32_t dict_max) +XZ_EXTERN struct xz_dec *__init xz_dec_init(enum xz_mode mode, uint32_t dict_max) { struct xz_dec *s = malloc(sizeof(*s)); if (s == NULL) @@ -809,7 +809,7 @@ error_bcj: return NULL; } -XZ_EXTERN void INIT xz_dec_end(struct xz_dec *s) +XZ_EXTERN void __init xz_dec_end(struct xz_dec *s) { if (s != NULL) { xz_dec_lzma2_end(s->lzma2); --- a/xen/common/xz/lzma2.h +++ b/xen/common/xz/lzma2.h @@ -61,7 +61,7 @@ enum lzma_state { #define LIT_STATES 7 /* Indicate that the latest symbol was a literal. */ -static inline void INIT lzma_state_literal(enum lzma_state *state) +static inline void __init lzma_state_literal(enum lzma_state *state) { if (*state <= STATE_SHORTREP_LIT_LIT) *state = STATE_LIT_LIT; @@ -72,25 +72,25 @@ static inline void INIT lzma_state_liter } /* Indicate that the latest symbol was a match. */ -static inline void INIT lzma_state_match(enum lzma_state *state) +static inline void __init lzma_state_match(enum lzma_state *state) { *state = *state < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH; } /* Indicate that the latest state was a long repeated match. */ -static inline void INIT lzma_state_long_rep(enum lzma_state *state) +static inline void __init lzma_state_long_rep(enum lzma_state *state) { *state = *state < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP; } /* Indicate that the latest symbol was a short match. */ -static inline void INIT lzma_state_short_rep(enum lzma_state *state) +static inline void __init lzma_state_short_rep(enum lzma_state *state) { *state = *state < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP; } /* Test if the previous symbol was a literal. */ -static inline bool_t INIT lzma_state_is_literal(enum lzma_state state) +static inline bool_t __init lzma_state_is_literal(enum lzma_state state) { return state < LIT_STATES; } @@ -144,7 +144,7 @@ static inline bool_t INIT lzma_state_is_ * Get the index of the appropriate probability array for decoding * the distance slot. */ -static inline uint32_t INIT lzma_get_dist_state(uint32_t len) +static inline uint32_t __init lzma_get_dist_state(uint32_t len) { return len < DIST_STATES + MATCH_LEN_MIN ? len - MATCH_LEN_MIN : DIST_STATES - 1; From patchwork Tue Jan 26 09:52:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 790C8C433E6 for ; Tue, 26 Jan 2021 09:53:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0450720780 for ; Tue, 26 Jan 2021 09:53:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0450720780 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74759.134396 (Exim 4.92) (envelope-from ) id 1l4L21-0001lb-8F; Tue, 26 Jan 2021 09:53:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74759.134396; Tue, 26 Jan 2021 09:53:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L21-0001lU-4y; Tue, 26 Jan 2021 09:53:05 +0000 Received: by outflank-mailman (input) for mailman id 74759; Tue, 26 Jan 2021 09:53:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L1z-0001lK-RO for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:53:03 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 802f611d-c987-4cbf-b5ea-61fdec6eb219; Tue, 26 Jan 2021 09:53:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 484BBAE40; Tue, 26 Jan 2021 09:52:59 +0000 (UTC) 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" X-Inumbo-ID: 802f611d-c987-4cbf-b5ea-61fdec6eb219 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654779; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jDmA+RHW8h36/HWylJ4DdviDgbqX+mpcKKh9geHfEmA=; b=bUXcEmFX/tZH56OXYHBdMntIFqRKkwUhDzvbjibdFTF700vl/Se4k039jeyvYUy0dPD3yi pbEah85ZiJ2EyHnLMnu7DXhxpSa3Cn+muV0MrVbqBD1QxRyMXJ9plY9RSmre+3sndQ6Hbx Cm2TpQK3L7/1P/p/xIqxd2IfxOfWOvY= Subject: [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: <19f12930-df0e-5a00-9e5e-53edffcf51d7@suse.com> Date: Tue, 26 Jan 2021 10:52:59 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US With xen/common/decompress.h now agreeing in both build modes about what STATIC expands to, there's no need for this abstraction anymore. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich --- v3: New. --- a/xen/common/unzstd.c +++ b/xen/common/unzstd.c @@ -71,7 +71,7 @@ */ #define ZSTD_IOBUF_SIZE (1 << 17) -static int INIT handle_zstd_error(size_t ret, void (*error)(const char *x)) +static int __init handle_zstd_error(size_t ret, void (*error)(const char *x)) { const int err = ZSTD_getErrorCode(ret); @@ -102,9 +102,9 @@ static int INIT handle_zstd_error(size_t * We can allocate less memory (no circular buffer for the sliding window), * and avoid some memcpy() calls. */ -static int INIT decompress_single(const u8 *in_buf, long in_len, u8 *out_buf, - long out_len, unsigned int *in_pos, - void (*error)(const char *x)) +static int __init decompress_single(const u8 *in_buf, long in_len, u8 *out_buf, + long out_len, unsigned int *in_pos, + void (*error)(const char *x)) { const size_t wksp_size = ZSTD_DCtxWorkspaceBound(); void *wksp = large_malloc(wksp_size); @@ -142,11 +142,11 @@ out: return err; } -int INIT unzstd(unsigned char *in_buf, unsigned int in_len, - int (*fill)(void*, unsigned int), - int (*flush)(void*, unsigned int), - unsigned char *out_buf, unsigned int *in_pos, - void (*error)(const char *x)) +int __init unzstd(unsigned char *in_buf, unsigned int in_len, + int (*fill)(void*, unsigned int), + int (*flush)(void*, unsigned int), + unsigned char *out_buf, unsigned int *in_pos, + void (*error)(const char *x)) { ZSTD_inBuffer in; ZSTD_outBuffer out; --- a/xen/common/zstd/decompress.c +++ b/xen/common/zstd/decompress.c @@ -46,7 +46,7 @@ /*_******************************************************* * Memory operations **********************************************************/ -static void INIT ZSTD_copy4(void *dst, const void *src) { memcpy(dst, src, 4); } +static void __init ZSTD_copy4(void *dst, const void *src) { memcpy(dst, src, 4); } /*-************************************************************* * Context management @@ -98,12 +98,12 @@ struct ZSTD_DCtx_s { BYTE headerBuffer[ZSTD_FRAMEHEADERSIZE_MAX]; }; /* typedef'd to ZSTD_DCtx within "zstd.h" */ -STATIC size_t INIT ZSTD_DCtxWorkspaceBound(void) +static size_t __init ZSTD_DCtxWorkspaceBound(void) { return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DCtx)); } -STATIC size_t INIT ZSTD_decompressBegin(ZSTD_DCtx *dctx) +static size_t __init ZSTD_decompressBegin(ZSTD_DCtx *dctx) { dctx->expected = ZSTD_frameHeaderSize_prefix; dctx->stage = ZSTDds_getFrameHeaderSize; @@ -123,7 +123,7 @@ STATIC size_t INIT ZSTD_decompressBegin( return 0; } -STATIC ZSTD_DCtx *INIT ZSTD_createDCtx_advanced(ZSTD_customMem customMem) +static ZSTD_DCtx *__init ZSTD_createDCtx_advanced(ZSTD_customMem customMem) { ZSTD_DCtx *dctx; @@ -138,13 +138,13 @@ STATIC ZSTD_DCtx *INIT ZSTD_createDCtx_a return dctx; } -STATIC ZSTD_DCtx *INIT ZSTD_initDCtx(void *workspace, size_t workspaceSize) +static ZSTD_DCtx *__init ZSTD_initDCtx(void *workspace, size_t workspaceSize) { ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize); return ZSTD_createDCtx_advanced(stackMem); } -size_t INIT ZSTD_freeDCtx(ZSTD_DCtx *dctx) +size_t __init ZSTD_freeDCtx(ZSTD_DCtx *dctx) { if (dctx == NULL) return 0; /* support free on NULL */ @@ -153,15 +153,15 @@ size_t INIT ZSTD_freeDCtx(ZSTD_DCtx *dct } #ifdef BUILD_DEAD_CODE -void INIT ZSTD_copyDCtx(ZSTD_DCtx *dstDCtx, const ZSTD_DCtx *srcDCtx) +void __init ZSTD_copyDCtx(ZSTD_DCtx *dstDCtx, const ZSTD_DCtx *srcDCtx) { size_t const workSpaceSize = (ZSTD_BLOCKSIZE_ABSOLUTEMAX + WILDCOPY_OVERLENGTH) + ZSTD_frameHeaderSize_max; memcpy(dstDCtx, srcDCtx, sizeof(ZSTD_DCtx) - workSpaceSize); /* no need to copy workspace */ } #endif -STATIC size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize); -STATIC size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, +static size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize); +static size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize); static void ZSTD_refDDict(ZSTD_DCtx *dstDCtx, const ZSTD_DDict *ddict); @@ -176,7 +176,7 @@ static void ZSTD_refDDict(ZSTD_DCtx *dst * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled. * Note 3 : Skippable Frame Identifiers are considered valid. */ -unsigned INIT ZSTD_isFrame(const void *buffer, size_t size) +unsigned __init ZSTD_isFrame(const void *buffer, size_t size) { if (size < 4) return 0; @@ -194,7 +194,7 @@ unsigned INIT ZSTD_isFrame(const void *b /** ZSTD_frameHeaderSize() : * srcSize must be >= ZSTD_frameHeaderSize_prefix. * @return : size of the Frame Header */ -static size_t INIT ZSTD_frameHeaderSize(const void *src, size_t srcSize) +static size_t __init ZSTD_frameHeaderSize(const void *src, size_t srcSize) { if (srcSize < ZSTD_frameHeaderSize_prefix) return ERROR(srcSize_wrong); @@ -212,7 +212,7 @@ static size_t INIT ZSTD_frameHeaderSize( * @return : 0, `fparamsPtr` is correctly filled, * >0, `srcSize` is too small, result is expected `srcSize`, * or an error code, which can be tested using ZSTD_isError() */ -STATIC size_t INIT ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize) +static size_t __init ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize) { const BYTE *ip = (const BYTE *)src; @@ -303,7 +303,7 @@ STATIC size_t INIT ZSTD_getFrameParams(Z * @return : decompressed size of the single frame pointed to be `src` if known, otherwise * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */ -unsigned long long INIT ZSTD_getFrameContentSize(const void *src, size_t srcSize) +unsigned long long __init ZSTD_getFrameContentSize(const void *src, size_t srcSize) { { ZSTD_frameParams fParams; @@ -325,7 +325,7 @@ unsigned long long INIT ZSTD_getFrameCon * `srcSize` must be the exact length of some number of ZSTD compressed and/or * skippable frames * @return : decompressed size of the frames contained */ -unsigned long long INIT ZSTD_findDecompressedSize(const void *src, size_t srcSize) +unsigned long long __init ZSTD_findDecompressedSize(const void *src, size_t srcSize) { { unsigned long long totalDstSize = 0; @@ -379,7 +379,7 @@ unsigned long long INIT ZSTD_findDecompr /** ZSTD_decodeFrameHeader() : * `headerSize` must be the size provided by ZSTD_frameHeaderSize(). * @return : 0 if success, or an error code, which can be tested using ZSTD_isError() */ -static size_t INIT ZSTD_decodeFrameHeader(ZSTD_DCtx *dctx, const void *src, size_t headerSize) +static size_t __init ZSTD_decodeFrameHeader(ZSTD_DCtx *dctx, const void *src, size_t headerSize) { size_t const result = ZSTD_getFrameParams(&(dctx->fParams), src, headerSize); if (ZSTD_isError(result)) @@ -401,7 +401,7 @@ typedef struct { /*! ZSTD_getcBlockSize() : * Provides the size of compressed block from block header `src` */ -STATIC size_t INIT ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr) +static size_t __init ZSTD_getcBlockSize(const void *src, size_t srcSize, blockProperties_t *bpPtr) { if (srcSize < ZSTD_blockHeaderSize) return ERROR(srcSize_wrong); @@ -419,7 +419,7 @@ STATIC size_t INIT ZSTD_getcBlockSize(co } } -static size_t INIT ZSTD_copyRawBlock(void *dst, size_t dstCapacity, const void *src, size_t srcSize) +static size_t __init ZSTD_copyRawBlock(void *dst, size_t dstCapacity, const void *src, size_t srcSize) { if (srcSize > dstCapacity) return ERROR(dstSize_tooSmall); @@ -427,7 +427,7 @@ static size_t INIT ZSTD_copyRawBlock(voi return srcSize; } -static size_t INIT ZSTD_setRleBlock(void *dst, size_t dstCapacity, const void *src, size_t srcSize, size_t regenSize) +static size_t __init ZSTD_setRleBlock(void *dst, size_t dstCapacity, const void *src, size_t srcSize, size_t regenSize) { if (srcSize != 1) return ERROR(srcSize_wrong); @@ -439,7 +439,7 @@ static size_t INIT ZSTD_setRleBlock(void /*! ZSTD_decodeLiteralsBlock() : @return : nb of bytes read from src (< srcSize ) */ -STATIC size_t INIT ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize) /* note : srcSize < BLOCKSIZE */ +static size_t __init ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize) /* note : srcSize < BLOCKSIZE */ { if (srcSize < MIN_CBLOCK_SIZE) return ERROR(corruption_detected); @@ -759,10 +759,10 @@ static const FSE_decode_t4 OF_defaultDTa @return : nb bytes read from src, or an error code if it fails, testable with ZSTD_isError() */ -static size_t INIT ZSTD_buildSeqTable(FSE_DTable *DTableSpace, const FSE_DTable **DTablePtr, - symbolEncodingType_e type, U32 max, U32 maxLog, const void *src, - size_t srcSize, const FSE_decode_t4 *defaultTable, - U32 flagRepeatTable, void *workspace, size_t workspaceSize) +static size_t __init ZSTD_buildSeqTable(FSE_DTable *DTableSpace, const FSE_DTable **DTablePtr, + symbolEncodingType_e type, U32 max, U32 maxLog, const void *src, + size_t srcSize, const FSE_decode_t4 *defaultTable, + U32 flagRepeatTable, void *workspace, size_t workspaceSize) { const void *const tmpPtr = defaultTable; /* bypass strict aliasing */ switch (type) { @@ -803,7 +803,7 @@ static size_t INIT ZSTD_buildSeqTable(FS } } -STATIC size_t INIT ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize) +static size_t __init ZSTD_decodeSeqHeaders(ZSTD_DCtx *dctx, int *nbSeqPtr, const void *src, size_t srcSize) { const BYTE *const istart = (const BYTE *const)src; const BYTE *const iend = istart + srcSize; @@ -940,7 +940,7 @@ size_t ZSTD_execSequenceLast7(BYTE *op, return sequenceLength; } -static seq_t INIT ZSTD_decodeSequence(seqState_t *seqState) +static seq_t __init ZSTD_decodeSequence(seqState_t *seqState) { seq_t seq; @@ -1102,7 +1102,7 @@ size_t ZSTD_execSequence(BYTE *op, BYTE return sequenceLength; } -static size_t INIT ZSTD_decompressSequences(ZSTD_DCtx *dctx, void *dst, size_t maxDstSize, const void *seqStart, size_t seqSize) +static size_t __init ZSTD_decompressSequences(ZSTD_DCtx *dctx, void *dst, size_t maxDstSize, const void *seqStart, size_t seqSize) { const BYTE *ip = (const BYTE *)seqStart; const BYTE *const iend = ip + seqSize; @@ -1262,7 +1262,7 @@ FORCE_INLINE seq_t ZSTD_decodeSequenceLo return seq; } -static seq_t INIT ZSTD_decodeSequenceLong(seqState_t *seqState, unsigned const windowSize) +static seq_t __init ZSTD_decodeSequenceLong(seqState_t *seqState, unsigned const windowSize) { if (ZSTD_highbit32(windowSize) > STREAM_ACCUMULATOR_MIN) { return ZSTD_decodeSequenceLong_generic(seqState, 1); @@ -1272,9 +1272,9 @@ static seq_t INIT ZSTD_decodeSequenceLon } FORCE_INLINE -size_t INIT ZSTD_execSequenceLong(BYTE *op, BYTE *const oend, seq_t sequence, const BYTE **litPtr, - const BYTE *const litLimit, const BYTE *const base, - const BYTE *const vBase, const BYTE *const dictEnd) +size_t __init ZSTD_execSequenceLong(BYTE *op, BYTE *const oend, seq_t sequence, const BYTE **litPtr, + const BYTE *const litLimit, const BYTE *const base, + const BYTE *const vBase, const BYTE *const dictEnd) { BYTE *const oLitEnd = op + sequence.litLength; size_t const sequenceLength = sequence.litLength + sequence.matchLength; @@ -1358,7 +1358,7 @@ size_t INIT ZSTD_execSequenceLong(BYTE * return sequenceLength; } -static size_t INIT ZSTD_decompressSequencesLong(ZSTD_DCtx *dctx, void *dst, size_t maxDstSize, const void *seqStart, size_t seqSize) +static size_t __init ZSTD_decompressSequencesLong(ZSTD_DCtx *dctx, void *dst, size_t maxDstSize, const void *seqStart, size_t seqSize) { const BYTE *ip = (const BYTE *)seqStart; const BYTE *const iend = ip + seqSize; @@ -1455,7 +1455,7 @@ static size_t INIT ZSTD_decompressSequen return op - ostart; } -static size_t INIT ZSTD_decompressBlock_internal(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) +static size_t __init ZSTD_decompressBlock_internal(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) { /* blockType == blockCompressed */ const BYTE *ip = (const BYTE *)src; @@ -1479,7 +1479,7 @@ static size_t INIT ZSTD_decompressBlock_ return ZSTD_decompressSequences(dctx, dst, dstCapacity, ip, srcSize); } -static void INIT ZSTD_checkContinuity(ZSTD_DCtx *dctx, const void *dst) +static void __init ZSTD_checkContinuity(ZSTD_DCtx *dctx, const void *dst) { if (dst != dctx->previousDstEnd) { /* not contiguous */ dctx->dictEnd = dctx->previousDstEnd; @@ -1490,7 +1490,7 @@ static void INIT ZSTD_checkContinuity(ZS } #ifdef BUILD_DEAD_CODE -size_t INIT ZSTD_decompressBlock(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) +size_t __init ZSTD_decompressBlock(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) { size_t dSize; ZSTD_checkContinuity(dctx, dst); @@ -1501,7 +1501,7 @@ size_t INIT ZSTD_decompressBlock(ZSTD_DC /** ZSTD_insertBlock() : insert `src` block into `dctx` history. Useful to track uncompressed blocks. */ -size_t INIT ZSTD_insertBlock(ZSTD_DCtx *dctx, const void *blockStart, size_t blockSize) +size_t __init ZSTD_insertBlock(ZSTD_DCtx *dctx, const void *blockStart, size_t blockSize) { ZSTD_checkContinuity(dctx, blockStart); dctx->previousDstEnd = (const char *)blockStart + blockSize; @@ -1509,7 +1509,7 @@ size_t INIT ZSTD_insertBlock(ZSTD_DCtx * } #endif /* BUILD_DEAD_CODE */ -STATIC size_t INIT ZSTD_generateNxBytes(void *dst, size_t dstCapacity, BYTE byte, size_t length) +static size_t __init ZSTD_generateNxBytes(void *dst, size_t dstCapacity, BYTE byte, size_t length) { if (length > dstCapacity) return ERROR(dstSize_tooSmall); @@ -1522,7 +1522,7 @@ STATIC size_t INIT ZSTD_generateNxBytes( * `src` must point to the start of a ZSTD frame, ZSTD legacy frame, or skippable frame * `srcSize` must be at least as large as the frame contained * @return : the compressed size of the frame starting at `src` */ -STATIC size_t INIT ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) +static size_t __init ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) { if (srcSize >= ZSTD_skippableHeaderSize && (ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { return ZSTD_skippableHeaderSize + ZSTD_readLE32((const BYTE *)src + 4); @@ -1578,7 +1578,7 @@ STATIC size_t INIT ZSTD_findFrameCompres /*! ZSTD_decompressFrame() : * @dctx must be properly initialized */ -static size_t INIT ZSTD_decompressFrame(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void **srcPtr, size_t *srcSizePtr) +static size_t __init ZSTD_decompressFrame(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void **srcPtr, size_t *srcSizePtr) { const BYTE *ip = (const BYTE *)(*srcPtr); BYTE *const ostart = (BYTE * const)dst; @@ -1655,7 +1655,7 @@ static size_t INIT ZSTD_decompressFrame( static const void *ZSTD_DDictDictContent(const ZSTD_DDict *ddict); static size_t ZSTD_DDictDictSize(const ZSTD_DDict *ddict); -static size_t INIT ZSTD_decompressMultiFrame(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize, +static size_t __init ZSTD_decompressMultiFrame(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize, const ZSTD_DDict *ddict) { void *const dststart = dst; @@ -1719,12 +1719,12 @@ static size_t INIT ZSTD_decompressMultiF return (BYTE *)dst - (BYTE *)dststart; } -STATIC size_t INIT ZSTD_decompress_usingDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize) +static size_t __init ZSTD_decompress_usingDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const void *dict, size_t dictSize) { return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, dict, dictSize, NULL); } -STATIC size_t INIT ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) +static size_t __init ZSTD_decompressDCtx(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) { return ZSTD_decompress_usingDict(dctx, dst, dstCapacity, src, srcSize, NULL, 0); } @@ -1733,12 +1733,12 @@ STATIC size_t INIT ZSTD_decompressDCtx(Z * Advanced Streaming Decompression API * Bufferless and synchronous ****************************************/ -STATIC size_t INIT ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx) +static size_t __init ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx *dctx) { return dctx->expected; } -STATIC ZSTD_nextInputType_e INIT ZSTD_nextInputType(ZSTD_DCtx *dctx) +static ZSTD_nextInputType_e __init ZSTD_nextInputType(ZSTD_DCtx *dctx) { switch (dctx->stage) { default: /* should not happen */ @@ -1753,12 +1753,12 @@ STATIC ZSTD_nextInputType_e INIT ZSTD_ne } } -int INIT ZSTD_isSkipFrame(ZSTD_DCtx *dctx) { return dctx->stage == ZSTDds_skipFrame; } /* for zbuff */ +int __init ZSTD_isSkipFrame(ZSTD_DCtx *dctx) { return dctx->stage == ZSTDds_skipFrame; } /* for zbuff */ /** ZSTD_decompressContinue() : * @return : nb of bytes generated into `dst` (necessarily <= `dstCapacity) * or an error code, which can be tested using ZSTD_isError() */ -STATIC size_t INIT ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) +static size_t __init ZSTD_decompressContinue(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize) { /* Sanity check */ if (srcSize != dctx->expected) @@ -1877,7 +1877,7 @@ STATIC size_t INIT ZSTD_decompressContin } } -static size_t INIT ZSTD_refDictContent(ZSTD_DCtx *dctx, const void *dict, size_t dictSize) +static size_t __init ZSTD_refDictContent(ZSTD_DCtx *dctx, const void *dict, size_t dictSize) { dctx->dictEnd = dctx->previousDstEnd; dctx->vBase = (const char *)dict - ((const char *)(dctx->previousDstEnd) - (const char *)(dctx->base)); @@ -1889,7 +1889,7 @@ static size_t INIT ZSTD_refDictContent(Z /* ZSTD_loadEntropy() : * dict : must point at beginning of a valid zstd dictionary * @return : size of entropy tables read */ -static size_t INIT ZSTD_loadEntropy(ZSTD_entropyTables_t *entropy, const void *const dict, size_t const dictSize) +static size_t __init ZSTD_loadEntropy(ZSTD_entropyTables_t *entropy, const void *const dict, size_t const dictSize) { const BYTE *dictPtr = (const BYTE *)dict; const BYTE *const dictEnd = dictPtr + dictSize; @@ -1958,7 +1958,7 @@ static size_t INIT ZSTD_loadEntropy(ZSTD return dictPtr - (const BYTE *)dict; } -static size_t INIT ZSTD_decompress_insertDictionary(ZSTD_DCtx *dctx, const void *dict, size_t dictSize) +static size_t __init ZSTD_decompress_insertDictionary(ZSTD_DCtx *dctx, const void *dict, size_t dictSize) { if (dictSize < 8) return ZSTD_refDictContent(dctx, dict, dictSize); @@ -1984,7 +1984,7 @@ static size_t INIT ZSTD_decompress_inser return ZSTD_refDictContent(dctx, dict, dictSize); } -STATIC size_t INIT ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize) +static size_t __init ZSTD_decompressBegin_usingDict(ZSTD_DCtx *dctx, const void *dict, size_t dictSize) { CHECK_F(ZSTD_decompressBegin(dctx)); if (dict && dictSize) @@ -2005,14 +2005,14 @@ struct ZSTD_DDict_s { }; /* typedef'd to ZSTD_DDict within "zstd.h" */ #ifdef BUILD_DEAD_CODE -size_t INIT ZSTD_DDictWorkspaceBound(void) { return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DDict)); } +size_t __init ZSTD_DDictWorkspaceBound(void) { return ZSTD_ALIGN(sizeof(ZSTD_stack)) + ZSTD_ALIGN(sizeof(ZSTD_DDict)); } #endif -static const void *INIT ZSTD_DDictDictContent(const ZSTD_DDict *ddict) { return ddict->dictContent; } +static const void *__init ZSTD_DDictDictContent(const ZSTD_DDict *ddict) { return ddict->dictContent; } -static size_t INIT ZSTD_DDictDictSize(const ZSTD_DDict *ddict) { return ddict->dictSize; } +static size_t __init ZSTD_DDictDictSize(const ZSTD_DDict *ddict) { return ddict->dictSize; } -static void INIT ZSTD_refDDict(ZSTD_DCtx *dstDCtx, const ZSTD_DDict *ddict) +static void __init ZSTD_refDDict(ZSTD_DCtx *dstDCtx, const ZSTD_DDict *ddict) { ZSTD_decompressBegin(dstDCtx); /* init */ if (ddict) { /* support refDDict on NULL */ @@ -2039,7 +2039,7 @@ static void INIT ZSTD_refDDict(ZSTD_DCtx } #ifdef BUILD_DEAD_CODE -static size_t INIT ZSTD_loadEntropy_inDDict(ZSTD_DDict *ddict) +static size_t __init ZSTD_loadEntropy_inDDict(ZSTD_DDict *ddict) { ddict->dictID = 0; ddict->entropyPresent = 0; @@ -2058,7 +2058,7 @@ static size_t INIT ZSTD_loadEntropy_inDD return 0; } -static ZSTD_DDict *INIT ZSTD_createDDict_advanced(const void *dict, size_t dictSize, unsigned byReference, ZSTD_customMem customMem) +static ZSTD_DDict *__init ZSTD_createDDict_advanced(const void *dict, size_t dictSize, unsigned byReference, ZSTD_customMem customMem) { if (!customMem.customAlloc || !customMem.customFree) return NULL; @@ -2101,14 +2101,14 @@ static ZSTD_DDict *INIT ZSTD_createDDict * Create a digested dictionary, to start decompression without startup delay. * `dict` content is copied inside DDict. * Consequently, `dict` can be released after `ZSTD_DDict` creation */ -ZSTD_DDict *INIT ZSTD_initDDict(const void *dict, size_t dictSize, void *workspace, size_t workspaceSize) +ZSTD_DDict *__init ZSTD_initDDict(const void *dict, size_t dictSize, void *workspace, size_t workspaceSize) { ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize); return ZSTD_createDDict_advanced(dict, dictSize, 1, stackMem); } #endif /* BUILD_DEAD_CODE */ -size_t INIT ZSTD_freeDDict(ZSTD_DDict *ddict) +size_t __init ZSTD_freeDDict(ZSTD_DDict *ddict) { if (ddict == NULL) return 0; /* support free on NULL */ @@ -2125,7 +2125,7 @@ size_t INIT ZSTD_freeDDict(ZSTD_DDict *d * Provides the dictID stored within dictionary. * if @return == 0, the dictionary is not conformant with Zstandard specification. * It can still be loaded, but as a content-only dictionary. */ -unsigned INIT ZSTD_getDictID_fromDict(const void *dict, size_t dictSize) +unsigned __init ZSTD_getDictID_fromDict(const void *dict, size_t dictSize) { if (dictSize < 8) return 0; @@ -2138,7 +2138,7 @@ unsigned INIT ZSTD_getDictID_fromDict(co * Provides the dictID of the dictionary loaded into `ddict`. * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ -unsigned INIT ZSTD_getDictID_fromDDict(const ZSTD_DDict *ddict) +unsigned __init ZSTD_getDictID_fromDDict(const ZSTD_DDict *ddict) { if (ddict == NULL) return 0; @@ -2155,7 +2155,7 @@ unsigned INIT ZSTD_getDictID_fromDDict(c * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`). * - This is not a Zstandard frame. * When identifying the exact failure cause, it's possible to used ZSTD_getFrameParams(), which will provide a more precise error code. */ -unsigned INIT ZSTD_getDictID_fromFrame(const void *src, size_t srcSize) +unsigned __init ZSTD_getDictID_fromFrame(const void *src, size_t srcSize) { ZSTD_frameParams zfp = {0, 0, 0, 0}; size_t const hError = ZSTD_getFrameParams(&zfp, src, srcSize); @@ -2168,7 +2168,7 @@ unsigned INIT ZSTD_getDictID_fromFrame(c /*! ZSTD_decompress_usingDDict() : * Decompression using a pre-digested Dictionary * Use dictionary without significant overhead. */ -STATIC size_t INIT ZSTD_decompress_usingDDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_DDict *ddict) +static size_t __init ZSTD_decompress_usingDDict(ZSTD_DCtx *dctx, void *dst, size_t dstCapacity, const void *src, size_t srcSize, const ZSTD_DDict *ddict) { /* pass content and size in case legacy frames are encountered */ return ZSTD_decompressMultiFrame(dctx, dst, dstCapacity, src, srcSize, NULL, 0, ddict); @@ -2205,7 +2205,7 @@ struct ZSTD_DStream_s { U32 hostageByte; }; /* typedef'd to ZSTD_DStream within "zstd.h" */ -STATIC size_t INIT ZSTD_DStreamWorkspaceBound(size_t maxWindowSize) +static size_t __init ZSTD_DStreamWorkspaceBound(size_t maxWindowSize) { size_t const blockSize = MIN(maxWindowSize, ZSTD_BLOCKSIZE_ABSOLUTEMAX); size_t const inBuffSize = blockSize; @@ -2213,7 +2213,7 @@ STATIC size_t INIT ZSTD_DStreamWorkspace return ZSTD_DCtxWorkspaceBound() + ZSTD_ALIGN(sizeof(ZSTD_DStream)) + ZSTD_ALIGN(inBuffSize) + ZSTD_ALIGN(outBuffSize); } -static ZSTD_DStream *INIT ZSTD_createDStream_advanced(ZSTD_customMem customMem) +static ZSTD_DStream *__init ZSTD_createDStream_advanced(ZSTD_customMem customMem) { ZSTD_DStream *zds; @@ -2235,7 +2235,7 @@ static ZSTD_DStream *INIT ZSTD_createDSt return zds; } -STATIC ZSTD_DStream *INIT ZSTD_initDStream(size_t maxWindowSize, void *workspace, size_t workspaceSize) +static ZSTD_DStream *__init ZSTD_initDStream(size_t maxWindowSize, void *workspace, size_t workspaceSize) { ZSTD_customMem const stackMem = ZSTD_initStack(workspace, workspaceSize); ZSTD_DStream *zds = ZSTD_createDStream_advanced(stackMem); @@ -2269,7 +2269,7 @@ STATIC ZSTD_DStream *INIT ZSTD_initDStre } #ifdef BUILD_DEAD_CODE -ZSTD_DStream *INIT ZSTD_initDStream_usingDDict(size_t maxWindowSize, const ZSTD_DDict *ddict, void *workspace, size_t workspaceSize) +ZSTD_DStream *__init ZSTD_initDStream_usingDDict(size_t maxWindowSize, const ZSTD_DDict *ddict, void *workspace, size_t workspaceSize) { ZSTD_DStream *zds = ZSTD_initDStream(maxWindowSize, workspace, workspaceSize); if (zds) { @@ -2279,7 +2279,7 @@ ZSTD_DStream *INIT ZSTD_initDStream_usin } #endif -size_t INIT ZSTD_freeDStream(ZSTD_DStream *zds) +size_t __init ZSTD_freeDStream(ZSTD_DStream *zds) { if (zds == NULL) return 0; /* support free on null */ @@ -2301,11 +2301,11 @@ size_t INIT ZSTD_freeDStream(ZSTD_DStrea /* *** Initialization *** */ #ifdef BUILD_DEAD_CODE -size_t INIT ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX + ZSTD_blockHeaderSize; } -size_t INIT ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX; } +size_t __init ZSTD_DStreamInSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX + ZSTD_blockHeaderSize; } +size_t __init ZSTD_DStreamOutSize(void) { return ZSTD_BLOCKSIZE_ABSOLUTEMAX; } #endif -STATIC size_t INIT ZSTD_resetDStream(ZSTD_DStream *zds) +static size_t __init ZSTD_resetDStream(ZSTD_DStream *zds) { zds->stage = zdss_loadHeader; zds->lhSize = zds->inPos = zds->outStart = zds->outEnd = 0; @@ -2316,14 +2316,14 @@ STATIC size_t INIT ZSTD_resetDStream(ZST /* ***** Decompression ***** */ -ZSTD_STATIC size_t INIT ZSTD_limitCopy(void *dst, size_t dstCapacity, const void *src, size_t srcSize) +ZSTD_STATIC size_t __init ZSTD_limitCopy(void *dst, size_t dstCapacity, const void *src, size_t srcSize) { size_t const length = MIN(dstCapacity, srcSize); memcpy(dst, src, length); return length; } -STATIC size_t INIT ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input) +static size_t __init ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inBuffer *input) { const char *const istart = (const char *)(input->src) + input->pos; const char *const iend = (const char *)(input->src) + input->size; --- a/xen/common/zstd/entropy_common.c +++ b/xen/common/zstd/entropy_common.c @@ -46,17 +46,17 @@ #include "mem.h" /*=== Version ===*/ -unsigned INIT FSE_versionNumber(void) { return FSE_VERSION_NUMBER; } +unsigned __init FSE_versionNumber(void) { return FSE_VERSION_NUMBER; } /*=== Error Management ===*/ -unsigned INIT FSE_isError(size_t code) { return ERR_isError(code); } +unsigned __init FSE_isError(size_t code) { return ERR_isError(code); } -unsigned INIT HUF_isError(size_t code) { return ERR_isError(code); } +unsigned __init HUF_isError(size_t code) { return ERR_isError(code); } /*-************************************************************** * FSE NCount encoding-decoding ****************************************************************/ -size_t INIT FSE_readNCount(short *normalizedCounter, unsigned *maxSVPtr, unsigned *tableLogPtr, const void *headerBuffer, size_t hbSize) +size_t __init FSE_readNCount(short *normalizedCounter, unsigned *maxSVPtr, unsigned *tableLogPtr, const void *headerBuffer, size_t hbSize) { const BYTE *const istart = (const BYTE *)headerBuffer; const BYTE *const iend = istart + hbSize; @@ -164,7 +164,7 @@ size_t INIT FSE_readNCount(short *normal @return : size read from `src` , or an error Code . Note : Needed by HUF_readCTable() and HUF_readDTableX?() . */ -size_t INIT HUF_readStats_wksp(BYTE *huffWeight, size_t hwSize, U32 *rankStats, U32 *nbSymbolsPtr, U32 *tableLogPtr, const void *src, size_t srcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_readStats_wksp(BYTE *huffWeight, size_t hwSize, U32 *rankStats, U32 *nbSymbolsPtr, U32 *tableLogPtr, const void *src, size_t srcSize, void *workspace, size_t workspaceSize) { U32 weightTotal; const BYTE *ip = (const BYTE *)src; --- a/xen/common/zstd/error_private.h +++ b/xen/common/zstd/error_private.h @@ -67,9 +67,9 @@ typedef ZSTD_ErrorCode ERR_enum; ******************************************/ #define ERROR(name) ((size_t)-PREFIX(name)) -ERR_STATIC unsigned INIT ERR_isError(size_t code) { return (code > ERROR(maxCode)); } +ERR_STATIC unsigned __init ERR_isError(size_t code) { return (code > ERROR(maxCode)); } -ERR_STATIC ERR_enum INIT ERR_getErrorCode(size_t code) +ERR_STATIC ERR_enum __init ERR_getErrorCode(size_t code) { if (!ERR_isError(code)) return (ERR_enum)0; @@ -82,7 +82,7 @@ ERR_STATIC ERR_enum INIT ERR_getErrorCod * * Return: Non-zero iff the code is an error. */ -static __attribute__((unused)) unsigned int INIT ZSTD_isError(size_t code) +static __attribute__((unused)) unsigned int __init ZSTD_isError(size_t code) { return code > (size_t)-ZSTD_error_maxCode; } @@ -94,7 +94,7 @@ static __attribute__((unused)) unsigned * Return: The ZSTD_ErrorCode corresponding to the functionResult or 0 * if the functionResult isn't an error. */ -static __attribute__((unused)) ZSTD_ErrorCode INIT ZSTD_getErrorCode( +static __attribute__((unused)) ZSTD_ErrorCode __init ZSTD_getErrorCode( size_t functionResult) { if (!ZSTD_isError(functionResult)) --- a/xen/common/zstd/fse_decompress.c +++ b/xen/common/zstd/fse_decompress.c @@ -82,7 +82,7 @@ /* Function templates */ -size_t INIT FSE_buildDTable_wksp(FSE_DTable *dt, const short *normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void *workspace, size_t workspaceSize) +size_t __init FSE_buildDTable_wksp(FSE_DTable *dt, const short *normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void *workspace, size_t workspaceSize) { void *const tdPtr = dt + 1; /* because *dt is unsigned, 32-bits aligned on 32-bits */ FSE_DECODE_TYPE *const tableDecode = (FSE_DECODE_TYPE *)(tdPtr); @@ -157,7 +157,7 @@ size_t INIT FSE_buildDTable_wksp(FSE_DTa /*-******************************************************* * Decompression (Byte symbols) *********************************************************/ -size_t INIT FSE_buildDTable_rle(FSE_DTable *dt, BYTE symbolValue) +size_t __init FSE_buildDTable_rle(FSE_DTable *dt, BYTE symbolValue) { void *ptr = dt; FSE_DTableHeader *const DTableH = (FSE_DTableHeader *)ptr; @@ -174,7 +174,7 @@ size_t INIT FSE_buildDTable_rle(FSE_DTab return 0; } -size_t INIT FSE_buildDTable_raw(FSE_DTable *dt, unsigned nbBits) +size_t __init FSE_buildDTable_raw(FSE_DTable *dt, unsigned nbBits) { void *ptr = dt; FSE_DTableHeader *const DTableH = (FSE_DTableHeader *)ptr; @@ -269,7 +269,7 @@ FORCE_INLINE size_t FSE_decompress_using return op - ostart; } -size_t INIT FSE_decompress_usingDTable(void *dst, size_t originalSize, const void *cSrc, size_t cSrcSize, const FSE_DTable *dt) +size_t __init FSE_decompress_usingDTable(void *dst, size_t originalSize, const void *cSrc, size_t cSrcSize, const FSE_DTable *dt) { const void *ptr = dt; const FSE_DTableHeader *DTableH = (const FSE_DTableHeader *)ptr; @@ -281,7 +281,7 @@ size_t INIT FSE_decompress_usingDTable(v return FSE_decompress_usingDTable_generic(dst, originalSize, cSrc, cSrcSize, dt, 0); } -size_t INIT FSE_decompress_wksp(void *dst, size_t dstCapacity, const void *cSrc, size_t cSrcSize, unsigned maxLog, void *workspace, size_t workspaceSize) +size_t __init FSE_decompress_wksp(void *dst, size_t dstCapacity, const void *cSrc, size_t cSrcSize, unsigned maxLog, void *workspace, size_t workspaceSize) { const BYTE *const istart = (const BYTE *)cSrc; const BYTE *ip = istart; --- a/xen/common/zstd/huf_decompress.c +++ b/xen/common/zstd/huf_decompress.c @@ -68,7 +68,7 @@ typedef struct { BYTE reserved; } DTableDesc; -static DTableDesc INIT HUF_getDTableDesc(const HUF_DTable *table) +static DTableDesc __init HUF_getDTableDesc(const HUF_DTable *table) { DTableDesc dtd; memcpy(&dtd, table, sizeof(dtd)); @@ -84,7 +84,7 @@ typedef struct { BYTE nbBits; } HUF_DEltX2; /* single-symbol decoding */ -size_t INIT HUF_readDTableX2_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_readDTableX2_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workspace, size_t workspaceSize) { U32 tableLog = 0; U32 nbSymbols = 0; @@ -152,7 +152,7 @@ size_t INIT HUF_readDTableX2_wksp(HUF_DT return iSize; } -static BYTE INIT HUF_decodeSymbolX2(BIT_DStream_t *Dstream, const HUF_DEltX2 *dt, const U32 dtLog) +static BYTE __init HUF_decodeSymbolX2(BIT_DStream_t *Dstream, const HUF_DEltX2 *dt, const U32 dtLog) { size_t const val = BIT_lookBitsFast(Dstream, dtLog); /* note : dtLog >= 1 */ BYTE const c = dt[val].byte; @@ -193,7 +193,7 @@ FORCE_INLINE size_t HUF_decodeStreamX2(B return pEnd - pStart; } -static size_t INIT HUF_decompress1X2_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +static size_t __init HUF_decompress1X2_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { BYTE *op = (BYTE *)dst; BYTE *const oend = op + dstSize; @@ -218,7 +218,7 @@ static size_t INIT HUF_decompress1X2_usi return dstSize; } -size_t INIT HUF_decompress1X2_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +size_t __init HUF_decompress1X2_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc dtd = HUF_getDTableDesc(DTable); if (dtd.tableType != 0) @@ -226,7 +226,7 @@ size_t INIT HUF_decompress1X2_usingDTabl return HUF_decompress1X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable); } -size_t INIT HUF_decompress1X2_DCtx_wksp(HUF_DTable *DCtx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_decompress1X2_DCtx_wksp(HUF_DTable *DCtx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { const BYTE *ip = (const BYTE *)cSrc; @@ -241,7 +241,7 @@ size_t INIT HUF_decompress1X2_DCtx_wksp( return HUF_decompress1X2_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx); } -static size_t INIT HUF_decompress4X2_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +static size_t __init HUF_decompress4X2_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { /* Check */ if (cSrcSize < 10) @@ -349,7 +349,7 @@ static size_t INIT HUF_decompress4X2_usi } } -size_t INIT HUF_decompress4X2_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +size_t __init HUF_decompress4X2_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc dtd = HUF_getDTableDesc(DTable); if (dtd.tableType != 0) @@ -357,7 +357,7 @@ size_t INIT HUF_decompress4X2_usingDTabl return HUF_decompress4X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable); } -size_t INIT HUF_decompress4X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_decompress4X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { const BYTE *ip = (const BYTE *)cSrc; @@ -388,7 +388,7 @@ typedef struct { /* HUF_fillDTableX4Level2() : * `rankValOrigin` must be a table of at least (HUF_TABLELOG_MAX + 1) U32 */ -static void INIT HUF_fillDTableX4Level2(HUF_DEltX4 *DTable, U32 sizeLog, const U32 consumed, const U32 *rankValOrigin, const int minWeight, +static void __init HUF_fillDTableX4Level2(HUF_DEltX4 *DTable, U32 sizeLog, const U32 consumed, const U32 *rankValOrigin, const int minWeight, const sortedSymbol_t *sortedSymbols, const U32 sortedListSize, U32 nbBitsBaseline, U16 baseSeq) { HUF_DEltX4 DElt; @@ -434,7 +434,7 @@ static void INIT HUF_fillDTableX4Level2( typedef U32 rankVal_t[HUF_TABLELOG_MAX][HUF_TABLELOG_MAX + 1]; typedef U32 rankValCol_t[HUF_TABLELOG_MAX + 1]; -static void INIT HUF_fillDTableX4(HUF_DEltX4 *DTable, const U32 targetLog, const sortedSymbol_t *sortedList, +static void __init HUF_fillDTableX4(HUF_DEltX4 *DTable, const U32 targetLog, const sortedSymbol_t *sortedList, const U32 sortedListSize, const U32 *rankStart, rankVal_t rankValOrigin, const U32 maxWeight, const U32 nbBitsBaseline) { @@ -477,7 +477,7 @@ static void INIT HUF_fillDTableX4(HUF_DE } } -size_t INIT HUF_readDTableX4_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_readDTableX4_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workspace, size_t workspaceSize) { U32 tableLog, maxW, sizeOfSort, nbSymbols; DTableDesc dtd = HUF_getDTableDesc(DTable); @@ -590,7 +590,7 @@ size_t INIT HUF_readDTableX4_wksp(HUF_DT return iSize; } -static U32 INIT HUF_decodeSymbolX4(void *op, BIT_DStream_t *DStream, const HUF_DEltX4 *dt, const U32 dtLog) +static U32 __init HUF_decodeSymbolX4(void *op, BIT_DStream_t *DStream, const HUF_DEltX4 *dt, const U32 dtLog) { size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */ memcpy(op, dt + val, 2); @@ -598,7 +598,7 @@ static U32 INIT HUF_decodeSymbolX4(void return dt[val].length; } -static U32 INIT HUF_decodeLastSymbolX4(void *op, BIT_DStream_t *DStream, const HUF_DEltX4 *dt, const U32 dtLog) +static U32 __init HUF_decodeLastSymbolX4(void *op, BIT_DStream_t *DStream, const HUF_DEltX4 *dt, const U32 dtLog) { size_t const val = BIT_lookBitsFast(DStream, dtLog); /* note : dtLog >= 1 */ memcpy(op, dt + val, 1); @@ -650,7 +650,7 @@ FORCE_INLINE size_t HUF_decodeStreamX4(B return p - pStart; } -static size_t INIT HUF_decompress1X4_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +static size_t __init HUF_decompress1X4_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { BIT_DStream_t bitD; @@ -679,7 +679,7 @@ static size_t INIT HUF_decompress1X4_usi return dstSize; } -size_t INIT HUF_decompress1X4_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +size_t __init HUF_decompress1X4_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc dtd = HUF_getDTableDesc(DTable); if (dtd.tableType != 1) @@ -687,7 +687,7 @@ size_t INIT HUF_decompress1X4_usingDTabl return HUF_decompress1X4_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable); } -size_t INIT HUF_decompress1X4_DCtx_wksp(HUF_DTable *DCtx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_decompress1X4_DCtx_wksp(HUF_DTable *DCtx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { const BYTE *ip = (const BYTE *)cSrc; @@ -702,7 +702,7 @@ size_t INIT HUF_decompress1X4_DCtx_wksp( return HUF_decompress1X4_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx); } -static size_t INIT HUF_decompress4X4_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +static size_t __init HUF_decompress4X4_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { if (cSrcSize < 10) return ERROR(corruption_detected); /* strict minimum : jump table + 1 byte per stream */ @@ -812,7 +812,7 @@ static size_t INIT HUF_decompress4X4_usi } } -size_t INIT HUF_decompress4X4_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +size_t __init HUF_decompress4X4_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc dtd = HUF_getDTableDesc(DTable); if (dtd.tableType != 1) @@ -820,7 +820,7 @@ size_t INIT HUF_decompress4X4_usingDTabl return HUF_decompress4X4_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable); } -size_t INIT HUF_decompress4X4_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_decompress4X4_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { const BYTE *ip = (const BYTE *)cSrc; @@ -839,14 +839,14 @@ size_t INIT HUF_decompress4X4_DCtx_wksp( /* Generic decompression selector */ /* ********************************/ -size_t INIT HUF_decompress1X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +size_t __init HUF_decompress1X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc const dtd = HUF_getDTableDesc(DTable); return dtd.tableType ? HUF_decompress1X4_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable) : HUF_decompress1X2_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable); } -size_t INIT HUF_decompress4X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) +size_t __init HUF_decompress4X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc const dtd = HUF_getDTableDesc(DTable); return dtd.tableType ? HUF_decompress4X4_usingDTable_internal(dst, maxDstSize, cSrc, cSrcSize, DTable) @@ -882,7 +882,7 @@ static const algo_time_t algoTime[16 /* * based on a set of pre-determined metrics. * @return : 0==HUF_decompress4X2, 1==HUF_decompress4X4 . * Assumption : 0 < cSrcSize < dstSize <= 128 KB */ -U32 INIT HUF_selectDecoder(size_t dstSize, size_t cSrcSize) +U32 __init HUF_selectDecoder(size_t dstSize, size_t cSrcSize) { /* decoder timing evaluation */ U32 const Q = (U32)(cSrcSize * 16 / dstSize); /* Q < 16 since dstSize > cSrcSize */ @@ -896,7 +896,7 @@ U32 INIT HUF_selectDecoder(size_t dstSiz typedef size_t (*decompressionAlgo)(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize); -size_t INIT HUF_decompress4X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_decompress4X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { /* validation checks */ if (dstSize == 0) @@ -919,7 +919,7 @@ size_t INIT HUF_decompress4X_DCtx_wksp(H } } -size_t INIT HUF_decompress4X_hufOnly_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_decompress4X_hufOnly_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { /* validation checks */ if (dstSize == 0) @@ -934,7 +934,7 @@ size_t INIT HUF_decompress4X_hufOnly_wks } } -size_t INIT HUF_decompress1X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) +size_t __init HUF_decompress1X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { /* validation checks */ if (dstSize == 0) --- a/xen/common/zstd/zstd_common.c +++ b/xen/common/zstd/zstd_common.c @@ -31,7 +31,7 @@ (stack)->ptr <= (stack)->end ? ptr : NULL; \ }) -ZSTD_customMem INIT ZSTD_initStack(void *workspace, size_t workspaceSize) +ZSTD_customMem __init ZSTD_initStack(void *workspace, size_t workspaceSize) { ZSTD_customMem stackMem = {ZSTD_stackAlloc, ZSTD_stackFree, workspace}; ZSTD_stack *stack = (ZSTD_stack *)workspace; @@ -47,27 +47,27 @@ ZSTD_customMem INIT ZSTD_initStack(void return stackMem; } -void *INIT ZSTD_stackAllocAll(void *opaque, size_t *size) +void *__init ZSTD_stackAllocAll(void *opaque, size_t *size) { ZSTD_stack *stack = (ZSTD_stack *)opaque; *size = (BYTE const *)stack->end - (BYTE *)ZSTD_PTR_ALIGN(stack->ptr); return stack_push(stack, *size); } -void *INIT ZSTD_stackAlloc(void *opaque, size_t size) +void *__init ZSTD_stackAlloc(void *opaque, size_t size) { ZSTD_stack *stack = (ZSTD_stack *)opaque; return stack_push(stack, size); } -void INIT ZSTD_stackFree(void *opaque, void *address) +void __init ZSTD_stackFree(void *opaque, void *address) { (void)opaque; (void)address; } -void *INIT ZSTD_malloc(size_t size, ZSTD_customMem customMem) { return customMem.customAlloc(customMem.opaque, size); } +void *__init ZSTD_malloc(size_t size, ZSTD_customMem customMem) { return customMem.customAlloc(customMem.opaque, size); } -void INIT ZSTD_free(void *ptr, ZSTD_customMem customMem) +void __init ZSTD_free(void *ptr, ZSTD_customMem customMem) { if (ptr != NULL) customMem.customFree(customMem.opaque, ptr); --- a/xen/common/zstd/zstd_internal.h +++ b/xen/common/zstd/zstd_internal.h @@ -21,7 +21,7 @@ * Compiler specifics *********************************************************/ #define FORCE_INLINE static always_inline -#define FORCE_NOINLINE static noinline INIT +#define FORCE_NOINLINE static noinline __init /*-************************************* * Dependencies From patchwork Tue Jan 26 09:53:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F647C433DB for ; Tue, 26 Jan 2021 09:53:32 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2855C2251D for ; Tue, 26 Jan 2021 09:53:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2855C2251D Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74763.134408 (Exim 4.92) (envelope-from ) id 1l4L2J-0001rw-MW; Tue, 26 Jan 2021 09:53:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74763.134408; Tue, 26 Jan 2021 09:53:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L2J-0001rp-J8; Tue, 26 Jan 2021 09:53:23 +0000 Received: by outflank-mailman (input) for mailman id 74763; Tue, 26 Jan 2021 09:53:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L2I-0001rV-It for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:53:22 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9ab18644-5c73-4252-9397-d0191bea755f; Tue, 26 Jan 2021 09:53:21 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 23552AC4F; Tue, 26 Jan 2021 09:53:21 +0000 (UTC) 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" X-Inumbo-ID: 9ab18644-5c73-4252-9397-d0191bea755f X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654801; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LQlclHoS+nUGybmGYXjRPm/SPP0Rd+6eAGn+tH7nB2g=; b=PJ74bLu93lWq5+OIfl5PcZA8O9IDrhjfvoE3PrNS7nHvTCRPzmdEPHLH2n6WKzFpzcWoPB CLaS6DKQCHiDk5A5bq7BCqUYNTVmNChKIhWUCZlzFW/482kPiMlMZV/wAyZFBiWI6rNC2v VZtarnrhP9gv4/SSlT4YJIj5kFdTUkY= Subject: [PATCH v3 14/15] xen/decompress: drop STATIC and INIT From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: Date: Tue, 26 Jan 2021 10:53:21 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US All users have been removed in earlier changes. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Acked-by: Julien Grall --- v3: New. --- a/xen/arch/arm/efi/efi-dom0.c +++ b/xen/arch/arm/efi/efi-dom0.c @@ -28,7 +28,7 @@ #include #include #include "../../../common/decompress.h" -#define XZ_EXTERN STATIC +#define XZ_EXTERN static #include "../../../common/xz/crc32.c" /* Constant to indicate "Xen" in unicode u16 format */ --- a/xen/common/decompress.h +++ b/xen/common/decompress.h @@ -7,9 +7,6 @@ #include #include -#define STATIC static -#define INIT __init - #define malloc xmalloc_bytes #define free xfree @@ -18,9 +15,6 @@ #else -#define STATIC static -#define INIT - #undef __init /* tools/libs/guest/xg_private.h has its own one */ #define __init #define __initdata From patchwork Tue Jan 26 09:53:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12046047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D992C433DB for ; Tue, 26 Jan 2021 09:53:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 987CD206B5 for ; Tue, 26 Jan 2021 09:53:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 987CD206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.74771.134420 (Exim 4.92) (envelope-from ) id 1l4L2i-00020X-Vl; Tue, 26 Jan 2021 09:53:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 74771.134420; Tue, 26 Jan 2021 09:53:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L2i-00020P-SL; Tue, 26 Jan 2021 09:53:48 +0000 Received: by outflank-mailman (input) for mailman id 74771; Tue, 26 Jan 2021 09:53:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l4L2h-00020A-PX for xen-devel@lists.xenproject.org; Tue, 26 Jan 2021 09:53:47 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7ae2e427-071e-4cf6-b5e6-3125eeeb49cb; Tue, 26 Jan 2021 09:53:46 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 37C87ACF4; Tue, 26 Jan 2021 09:53:45 +0000 (UTC) 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" X-Inumbo-ID: 7ae2e427-071e-4cf6-b5e6-3125eeeb49cb X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1611654825; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TNwBS5CqZiz6ZS6XTeoRh5oALwnQG2gs/BtgNSkMD0o=; b=NAkyNLxstySUWv9KBfM3Aqo5AL/ejLfZZm6hksz+eAbXJlcu5J96Z0EoBgjmSZhUcVm4mM oOLh/4J6LRzOi0iWqSneO6BiitU0BVDf39mxQCV7ikQRrK10Nf2BQRcLvsPvfVHIX9hNyh tUfqmYpFTHFGVeoVEdNh/zMjZyCyWh0= Subject: [PATCH v3 15/15] unzstd: make helper symbols static From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu References: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Message-ID: <22549ef3-62a7-955e-e2ad-8bd47f832b68@suse.com> Date: Tue, 26 Jan 2021 10:53:45 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com> Content-Language: en-US While for the original library's purposes these functions of course want to be externally exposed, we don't need this, and we also don't want this both to prevent unintended use and to keep the name space tidy. (When functions have no callers at all, wrap them with a suitable #ifdef.) This has the added benefit of reducing the resulting binary size - while this is all .init code, it's still desirable to not carry dead code. Additionally in the hypervisor we don't need the bulk of unzstd(), so insert a conditional allowing the compiler to DCE the rest (including the called functions). Signed-off-by: Jan Beulich --- v3: New. --- a/xen/common/unzstd.c +++ b/xen/common/unzstd.c @@ -53,6 +53,10 @@ * <= 22 + (uncompressed_size >> 15) + 131072 */ +#ifdef __XEN__ +#include +#endif + #include "decompress.h" #include "zstd/entropy_common.c" @@ -173,6 +177,11 @@ int __init unzstd(unsigned char *in_buf, return decompress_single(in_buf, in_len, out_buf, out_len, in_pos, error); +#ifdef __XEN__ + ASSERT_UNREACHABLE(); + return -1; +#endif + /* * If in_buf is not provided, we must be using fill(), so allocate * a large enough buffer. If it is provided, it must be at least --- a/xen/common/zstd/entropy_common.c +++ b/xen/common/zstd/entropy_common.c @@ -45,8 +45,10 @@ #include "huf.h" #include "mem.h" +#ifdef BUILD_DEAD_CODE /*=== Version ===*/ unsigned __init FSE_versionNumber(void) { return FSE_VERSION_NUMBER; } +#endif /*=== Error Management ===*/ unsigned __init FSE_isError(size_t code) { return ERR_isError(code); } --- a/xen/common/zstd/fse.h +++ b/xen/common/zstd/fse.h @@ -64,7 +64,7 @@ FSE_PUBLIC_API unsigned FSE_versionNumbe FSE_PUBLIC_API size_t FSE_compressBound(size_t size); /* maximum compressed size */ /* Error Management */ -FSE_PUBLIC_API unsigned FSE_isError(size_t code); /* tells if a return value is an error code */ +static unsigned FSE_isError(size_t code); /* tells if a return value is an error code */ /*-***************************************** * FSE detailed API @@ -173,7 +173,7 @@ If there is an error, the function will @return : size read from 'rBuffer', or an errorCode, which can be tested using FSE_isError(). maxSymbolValuePtr[0] and tableLogPtr[0] will also be updated with their respective values */ -FSE_PUBLIC_API size_t FSE_readNCount(short *normalizedCounter, unsigned *maxSymbolValuePtr, unsigned *tableLogPtr, const void *rBuffer, size_t rBuffSize); +static size_t FSE_readNCount(short *normalizedCounter, unsigned *maxSymbolValuePtr, unsigned *tableLogPtr, const void *rBuffer, size_t rBuffSize); /*! Constructor and Destructor of FSE_DTable. Note that its size depends on 'tableLog' */ @@ -182,14 +182,14 @@ typedef unsigned FSE_DTable; /* don't al /*! FSE_buildDTable(): Builds 'dt', which must be already allocated, using FSE_createDTable(). return : 0, or an errorCode, which can be tested using FSE_isError() */ -FSE_PUBLIC_API size_t FSE_buildDTable_wksp(FSE_DTable *dt, const short *normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void *workspace, size_t workspaceSize); +static size_t FSE_buildDTable_wksp(FSE_DTable *dt, const short *normalizedCounter, unsigned maxSymbolValue, unsigned tableLog, void *workspace, size_t workspaceSize); /*! FSE_decompress_usingDTable(): Decompress compressed source `cSrc` of size `cSrcSize` using `dt` into `dst` which must be already allocated. @return : size of regenerated data (necessarily <= `dstCapacity`), or an errorCode, which can be tested using FSE_isError() */ -FSE_PUBLIC_API size_t FSE_decompress_usingDTable(void *dst, size_t dstCapacity, const void *cSrc, size_t cSrcSize, const FSE_DTable *dt); +static size_t FSE_decompress_usingDTable(void *dst, size_t dstCapacity, const void *cSrc, size_t cSrcSize, const FSE_DTable *dt); /*! Tutorial : @@ -273,10 +273,10 @@ size_t FSE_buildCTable_wksp(FSE_CTable * size_t FSE_buildDTable_raw(FSE_DTable *dt, unsigned nbBits); /**< build a fake FSE_DTable, designed to read a flat distribution where each symbol uses nbBits */ -size_t FSE_buildDTable_rle(FSE_DTable *dt, unsigned char symbolValue); +static size_t FSE_buildDTable_rle(FSE_DTable *dt, unsigned char symbolValue); /**< build a fake FSE_DTable, designed to always generate the same symbolValue */ -size_t FSE_decompress_wksp(void *dst, size_t dstCapacity, const void *cSrc, size_t cSrcSize, unsigned maxLog, void *workspace, size_t workspaceSize); +static size_t FSE_decompress_wksp(void *dst, size_t dstCapacity, const void *cSrc, size_t cSrcSize, unsigned maxLog, void *workspace, size_t workspaceSize); /**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DTABLE_SIZE_U32(maxLog)` */ /* ***************************************** --- a/xen/common/zstd/fse_decompress.c +++ b/xen/common/zstd/fse_decompress.c @@ -174,6 +174,7 @@ size_t __init FSE_buildDTable_rle(FSE_DT return 0; } +#ifdef BUILD_DEAD_CODE size_t __init FSE_buildDTable_raw(FSE_DTable *dt, unsigned nbBits) { void *ptr = dt; @@ -200,6 +201,7 @@ size_t __init FSE_buildDTable_raw(FSE_DT return 0; } +#endif FORCE_INLINE size_t FSE_decompress_usingDTable_generic(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const FSE_DTable *dt, const unsigned fast) --- a/xen/common/zstd/huf.h +++ b/xen/common/zstd/huf.h @@ -45,7 +45,7 @@ size_t HUF_compressBound(size_t size); /**< maximum compressed size (worst case) */ /* Error Management */ -unsigned HUF_isError(size_t code); /**< tells if a return value is an error code */ +static unsigned HUF_isError(size_t code); /**< tells if a return value is an error code */ /* *** Advanced function *** */ @@ -99,12 +99,12 @@ typedef U32 HUF_DTable; * Advanced decompression functions ******************************************/ size_t HUF_decompress4X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize); /**< decodes RLE and uncompressed */ -size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, - size_t workspaceSize); /**< considers RLE and uncompressed as errors */ -size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, - size_t workspaceSize); /**< single-symbol decoder */ -size_t HUF_decompress4X4_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, - size_t workspaceSize); /**< double-symbols decoder */ +static size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, + size_t workspaceSize); /**< considers RLE and uncompressed as errors */ +static size_t HUF_decompress4X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, + size_t workspaceSize); /**< single-symbol decoder */ +static size_t HUF_decompress4X4_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, + size_t workspaceSize); /**< double-symbols decoder */ /* **************************************** * HUF detailed API @@ -153,8 +153,8 @@ size_t HUF_buildCTable_wksp(HUF_CElt *tr `huffWeight` is destination buffer. @return : size read from `src` , or an error Code . Note : Needed by HUF_readCTable() and HUF_readDTableXn() . */ -size_t HUF_readStats_wksp(BYTE *huffWeight, size_t hwSize, U32 *rankStats, U32 *nbSymbolsPtr, U32 *tableLogPtr, const void *src, size_t srcSize, - void *workspace, size_t workspaceSize); +static size_t HUF_readStats_wksp(BYTE *huffWeight, size_t hwSize, U32 *rankStats, U32 *nbSymbolsPtr, U32 *tableLogPtr, const void *src, size_t srcSize, + void *workspace, size_t workspaceSize); /** HUF_readCTable() : * Loading a CTable saved with HUF_writeCTable() */ @@ -172,12 +172,12 @@ HUF_decompress() does the following: * based on a set of pre-determined metrics. * @return : 0==HUF_decompress4X2, 1==HUF_decompress4X4 . * Assumption : 0 < cSrcSize < dstSize <= 128 KB */ -U32 HUF_selectDecoder(size_t dstSize, size_t cSrcSize); +static U32 HUF_selectDecoder(size_t dstSize, size_t cSrcSize); -size_t HUF_readDTableX2_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workspace, size_t workspaceSize); -size_t HUF_readDTableX4_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workspace, size_t workspaceSize); +static size_t HUF_readDTableX2_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workspace, size_t workspaceSize); +static size_t HUF_readDTableX4_wksp(HUF_DTable *DTable, const void *src, size_t srcSize, void *workspace, size_t workspaceSize); -size_t HUF_decompress4X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable); +static size_t HUF_decompress4X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable); size_t HUF_decompress4X2_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable); size_t HUF_decompress4X4_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable); @@ -196,13 +196,13 @@ size_t HUF_compress1X_repeat(void *dst, int preferRepeat); /**< `workSpace` must be a table of at least HUF_COMPRESS_WORKSPACE_SIZE_U32 unsigned */ size_t HUF_decompress1X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize); -size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, - size_t workspaceSize); /**< single-symbol decoder */ +static size_t HUF_decompress1X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, + size_t workspaceSize); /**< single-symbol decoder */ size_t HUF_decompress1X4_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize); /**< double-symbols decoder */ -size_t HUF_decompress1X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, - const HUF_DTable *DTable); /**< automatic selection of sing or double symbol decoder, based on DTable */ +static size_t HUF_decompress1X_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, + const HUF_DTable *DTable); /**< automatic selection of sing or double symbol decoder, based on DTable */ size_t HUF_decompress1X2_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable); size_t HUF_decompress1X4_usingDTable(void *dst, size_t maxDstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable); --- a/xen/common/zstd/huf_decompress.c +++ b/xen/common/zstd/huf_decompress.c @@ -218,6 +218,7 @@ static size_t __init HUF_decompress1X2_u return dstSize; } +#ifdef BUILD_DEAD_CODE size_t __init HUF_decompress1X2_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc dtd = HUF_getDTableDesc(DTable); @@ -225,6 +226,7 @@ size_t __init HUF_decompress1X2_usingDTa return ERROR(GENERIC); return HUF_decompress1X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable); } +#endif size_t __init HUF_decompress1X2_DCtx_wksp(HUF_DTable *DCtx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { @@ -349,6 +351,7 @@ static size_t __init HUF_decompress4X2_u } } +#ifdef BUILD_DEAD_CODE size_t __init HUF_decompress4X2_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc dtd = HUF_getDTableDesc(DTable); @@ -356,6 +359,7 @@ size_t __init HUF_decompress4X2_usingDTa return ERROR(GENERIC); return HUF_decompress4X2_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable); } +#endif size_t __init HUF_decompress4X2_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { @@ -679,6 +683,7 @@ static size_t __init HUF_decompress1X4_u return dstSize; } +#ifdef BUILD_DEAD_CODE size_t __init HUF_decompress1X4_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc dtd = HUF_getDTableDesc(DTable); @@ -701,6 +706,7 @@ size_t __init HUF_decompress1X4_DCtx_wks return HUF_decompress1X4_usingDTable_internal(dst, dstSize, ip, cSrcSize, DCtx); } +#endif static size_t __init HUF_decompress4X4_usingDTable_internal(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { @@ -812,6 +818,7 @@ static size_t __init HUF_decompress4X4_u } } +#ifdef BUILD_DEAD_CODE size_t __init HUF_decompress4X4_usingDTable(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, const HUF_DTable *DTable) { DTableDesc dtd = HUF_getDTableDesc(DTable); @@ -819,6 +826,7 @@ size_t __init HUF_decompress4X4_usingDTa return ERROR(GENERIC); return HUF_decompress4X4_usingDTable_internal(dst, dstSize, cSrc, cSrcSize, DTable); } +#endif size_t __init HUF_decompress4X4_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { @@ -896,6 +904,7 @@ U32 __init HUF_selectDecoder(size_t dstS typedef size_t (*decompressionAlgo)(void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize); +#ifdef BUILD_DEAD_CODE size_t __init HUF_decompress4X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { /* validation checks */ @@ -918,6 +927,7 @@ size_t __init HUF_decompress4X_DCtx_wksp : HUF_decompress4X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workspace, workspaceSize); } } +#endif size_t __init HUF_decompress4X_hufOnly_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { @@ -934,6 +944,7 @@ size_t __init HUF_decompress4X_hufOnly_w } } +#ifdef BUILD_DEAD_CODE size_t __init HUF_decompress1X_DCtx_wksp(HUF_DTable *dctx, void *dst, size_t dstSize, const void *cSrc, size_t cSrcSize, void *workspace, size_t workspaceSize) { /* validation checks */ @@ -956,3 +967,4 @@ size_t __init HUF_decompress1X_DCtx_wksp : HUF_decompress1X2_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workspace, workspaceSize); } } +#endif --- a/xen/common/zstd/zstd_common.c +++ b/xen/common/zstd/zstd_common.c @@ -47,12 +47,14 @@ ZSTD_customMem __init ZSTD_initStack(voi return stackMem; } +#ifdef BUILD_DEAD_CODE void *__init ZSTD_stackAllocAll(void *opaque, size_t *size) { ZSTD_stack *stack = (ZSTD_stack *)opaque; *size = (BYTE const *)stack->end - (BYTE *)ZSTD_PTR_ALIGN(stack->ptr); return stack_push(stack, *size); } +#endif void *__init ZSTD_stackAlloc(void *opaque, size_t size) { --- a/xen/common/zstd/zstd_internal.h +++ b/xen/common/zstd/zstd_internal.h @@ -324,7 +324,7 @@ typedef struct { const seqStore_t *ZSTD_getSeqStore(const ZSTD_CCtx *ctx); void ZSTD_seqToCodes(const seqStore_t *seqStorePtr); -int ZSTD_isSkipFrame(ZSTD_DCtx *dctx); +static int ZSTD_isSkipFrame(ZSTD_DCtx *dctx); /*= Custom memory allocation functions */ typedef void *(*ZSTD_allocFunction)(void *opaque, size_t size); @@ -335,8 +335,8 @@ typedef struct { void *opaque; } ZSTD_customMem; -void *ZSTD_malloc(size_t size, ZSTD_customMem customMem); -void ZSTD_free(void *ptr, ZSTD_customMem customMem); +static void *ZSTD_malloc(size_t size, ZSTD_customMem customMem); +static void ZSTD_free(void *ptr, ZSTD_customMem customMem); /*====== stack allocation ======*/ @@ -348,11 +348,11 @@ typedef struct { #define ZSTD_ALIGN(x) ALIGN(x, sizeof(size_t)) #define ZSTD_PTR_ALIGN(p) PTR_ALIGN(p, sizeof(size_t)) -ZSTD_customMem ZSTD_initStack(void *workspace, size_t workspaceSize); +static ZSTD_customMem ZSTD_initStack(void *workspace, size_t workspaceSize); void *ZSTD_stackAllocAll(void *opaque, size_t *size); -void *ZSTD_stackAlloc(void *opaque, size_t size); -void ZSTD_stackFree(void *opaque, void *address); +static void *ZSTD_stackAlloc(void *opaque, size_t size); +static void ZSTD_stackFree(void *opaque, void *address); /*====== common function ======*/ @@ -367,10 +367,10 @@ ZSTD_STATIC U32 ZSTD_highbit32(U32 val) void ZSTD_invalidateRepCodes(ZSTD_CCtx *cctx); size_t ZSTD_freeCCtx(ZSTD_CCtx *cctx); -size_t ZSTD_freeDCtx(ZSTD_DCtx *dctx); +static size_t ZSTD_freeDCtx(ZSTD_DCtx *dctx); size_t ZSTD_freeCDict(ZSTD_CDict *cdict); -size_t ZSTD_freeDDict(ZSTD_DDict *cdict); +static size_t ZSTD_freeDDict(ZSTD_DDict *cdict); size_t ZSTD_freeCStream(ZSTD_CStream *zcs); -size_t ZSTD_freeDStream(ZSTD_DStream *zds); +static size_t ZSTD_freeDStream(ZSTD_DStream *zds); #endif /* ZSTD_CCOMMON_H_MODULE */