xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation
@ 2021-01-26  9:46 Jan Beulich
  2021-01-26  9:48 ` [PATCH v3 01/15] libxenguest: add get_unaligned_le32() Jan Beulich
                   ` (16 more replies)
  0 siblings, 17 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:46 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

Only patches 1 and 2 are strictly intended for 4.15, paralleling
the recent Dom0 side work (and re-using many of the files
introduced there, for the stubdom build), but ones up to at least
patch 6 may still want considering (and 4 already has a release
ack).

01: libxenguest: add get_unaligned_le32()
02: libxenguest: support zstd compressed kernels
03: xen/decompress: make helper symbols static
04: libxenguest: "standardize" LZO kernel decompression code
05: libxenguest: drop redundant decompression declarations
06: libxenguest: simplify kernel decompression
07: gunzip: drop INIT{,DATA} and STATIC
08: bunzip: replace INIT
09: unlzo: replace INIT
10: unlzma: replace INIT
11: unlz4: replace INIT
12: unxz: replace INIT{,DATA} and STATIC
13: unzstd: replace INIT{,DATA} and STATIC
14: xen/decompress: drop STATIC and INIT
15: unzstd: make helper symbols static

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 01/15] libxenguest: add get_unaligned_le32()
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
@ 2021-01-26  9:48 ` Jan Beulich
  2021-01-26 11:51   ` Ian Jackson
  2021-01-26  9:49 ` [PATCH v3 02/15] libxenguest: support zstd compressed kernels Jan Beulich
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:48 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <iwj@xenproject.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v3: New.

--- a/tools/libs/guest/xg_dom_core.c
+++ b/tools/libs/guest/xg_dom_core.c
@@ -31,6 +31,7 @@
 #include <zlib.h>
 #include <assert.h>
 
+#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 <inttypes.h>
 #include <stdint.h>
 
+#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
 
 /*



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 02/15] libxenguest: support zstd compressed kernels
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
  2021-01-26  9:48 ` [PATCH v3 01/15] libxenguest: add get_unaligned_le32() Jan Beulich
@ 2021-01-26  9:49 ` Jan Beulich
  2021-01-26 11:53   ` Ian Jackson
  2021-01-26  9:49 ` [PATCH v3 03/15] xen/decompress: make helper symbols static Jan Beulich
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:49 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <jbeulich@suse.com>
Acked-by: Wei Liu <wl@xen.org>
Release-Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
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 <zstd.h>
+
+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 <stdio.h>
+#include <endian.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#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 <xen/string.h> /* 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 <xen/types.h> /* 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 <xen/types.h> /* 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 <xen/compiler.h>
-#include <xen/string.h> /* 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 <xen/types.h> /* 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 <xen/compiler.h>
-#include <xen/string.h> /* memcpy, memset */
 
 /* **************************************************************
 *  Error Management
--- a/xen/common/zstd/mem.h
+++ b/xen/common/zstd/mem.h
@@ -20,9 +20,11 @@
 /*-****************************************
 *  Dependencies
 ******************************************/
+#ifdef __XEN__
 #include <xen/string.h> /* memcpy */
 #include <xen/types.h>  /* size_t, ptrdiff_t */
 #include <asm/unaligned.h>
+#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 <xen/compiler.h>
 #include <xen/xxhash.h>
+#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 <xen/types.h>
 #include <asm/byteorder.h>
+#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 <xen/compiler.h>
 #include <xen/errno.h>
 #include <xen/string.h>
 #include <xen/xxhash.h>
 #include <asm/unaligned.h>
+#endif
 
 /*-*************************************
  * Macros



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 03/15] xen/decompress: make helper symbols static
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
  2021-01-26  9:48 ` [PATCH v3 01/15] libxenguest: add get_unaligned_le32() Jan Beulich
  2021-01-26  9:49 ` [PATCH v3 02/15] libxenguest: support zstd compressed kernels Jan Beulich
@ 2021-01-26  9:49 ` Jan Beulich
  2021-01-26  9:49 ` [PATCH v3 04/15] libxenguest: "standardize" LZO kernel decompression code Jan Beulich
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:49 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wl@xen.org>
---
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 <xen/types.h>
 #include <xen/xmalloc.h>
 
-#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;



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 04/15] libxenguest: "standardize" LZO kernel decompression code
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (2 preceding siblings ...)
  2021-01-26  9:49 ` [PATCH v3 03/15] xen/decompress: make helper symbols static Jan Beulich
@ 2021-01-26  9:49 ` Jan Beulich
  2021-01-26  9:50 ` [PATCH v3 05/15] libxenguest: drop redundant decompression declarations Jan Beulich
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:49 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <jbeulich@suse.com>
Acked-by: Wei Liu <wl@xen.org>
Release-Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
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;



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 05/15] libxenguest: drop redundant decompression declarations
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (3 preceding siblings ...)
  2021-01-26  9:49 ` [PATCH v3 04/15] libxenguest: "standardize" LZO kernel decompression code Jan Beulich
@ 2021-01-26  9:50 ` Jan Beulich
  2021-01-26  9:50 ` [PATCH v3 06/15] libxenguest: simplify kernel decompression Jan Beulich
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:50 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

The ones in xg_dom_decompress_unsafe.h suffice.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
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 {



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 06/15] libxenguest: simplify kernel decompression
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (4 preceding siblings ...)
  2021-01-26  9:50 ` [PATCH v3 05/15] libxenguest: drop redundant decompression declarations Jan Beulich
@ 2021-01-26  9:50 ` Jan Beulich
  2021-01-26  9:50 ` [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC Jan Beulich
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:50 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <jbeulich@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
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,



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (5 preceding siblings ...)
  2021-01-26  9:50 ` [PATCH v3 06/15] libxenguest: simplify kernel decompression Jan Beulich
@ 2021-01-26  9:50 ` Jan Beulich
  2021-01-26  9:54   ` Jan Beulich
  2021-01-26 11:56   ` Ian Jackson
  2021-01-26  9:51 ` [PATCH v3 08/15] bunzip: replace INIT Jan Beulich
                   ` (9 subsequent siblings)
  16 siblings, 2 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:50 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

There's no need for the extra abstraction.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v3: New.

--- a/xen/common/gunzip.c
+++ b/xen/common/gunzip.c
@@ -22,7 +22,6 @@ static unsigned __initdata inptr;
 static unsigned __initdata outcnt;
 
 #define OF(args)        args
-#define STATIC          static
 
 #define memzero(s, n)   memset((s), 0, (n))
 
@@ -30,9 +29,6 @@ typedef unsigned char   uch;
 typedef unsigned short  ush;
 typedef unsigned long   ulg;
 
-#define INIT            __init
-#define INITDATA        __initdata
-
 #define get_byte()      (inptr < insize ? inbuf[inptr++] : fill_inbuf())
 
 /* Diagnostic functions */
--- a/xen/common/inflate.c
+++ b/xen/common/inflate.c
@@ -107,7 +107,7 @@
 static char rcsid[] = "#Id: inflate.c,v 0.14 1993/06/10 13:27:04 jloup Exp #";
 #endif
 
-#ifndef STATIC
+#ifndef __XEN__
 
 #if defined(STDC_HEADERS) || defined(HAVE_STDLIB_H)
 #  include <sys/types.h>
@@ -115,14 +115,9 @@ static char rcsid[] = "#Id: inflate.c,v
 #endif
 
 #include "gzip.h"
-#define STATIC
-#endif /* !STATIC */
 
-#ifndef INIT
-#define INIT
-#define INITDATA
-#endif
- 
+#endif /* !__XEN__ */
+
 #define slide window
 
 /* Huffman code lookup table entry--this entry is four bytes for machines
@@ -143,15 +138,15 @@ struct huft {
 
 
 /* Function prototypes */
-STATIC int INIT huft_build OF((unsigned *, unsigned, unsigned, 
-                               const ush *, const ush *, struct huft **, int *));
-STATIC int INIT huft_free OF((struct huft *));
-STATIC int INIT inflate_codes OF((struct huft *, struct huft *, int, int));
-STATIC int INIT inflate_stored OF((void));
-STATIC int INIT inflate_fixed OF((void));
-STATIC int INIT inflate_dynamic OF((void));
-STATIC int INIT inflate_block OF((int *));
-STATIC int INIT inflate OF((void));
+static int huft_build OF((unsigned *, unsigned, unsigned,
+                          const ush *, const ush *, struct huft **, int *));
+static int huft_free OF((struct huft *));
+static int inflate_codes OF((struct huft *, struct huft *, int, int));
+static int inflate_stored OF((void));
+static int inflate_fixed OF((void));
+static int inflate_dynamic OF((void));
+static int inflate_block OF((int *));
+static int inflate OF((void));
 
 
 /* The inflate algorithm uses a sliding 32 K byte window on the uncompressed
@@ -217,10 +212,10 @@ static const ush cpdext[] = {         /*
    the stream.
  */
 
-STATIC ulg INITDATA bb;                /* bit buffer */
-STATIC unsigned INITDATA bk;           /* bits in bit buffer */
+static ulg __initdata bb;                /* bit buffer */
+static unsigned __initdata bk;           /* bits in bit buffer */
 
-STATIC const ush mask_bits[] = {
+static const ush mask_bits[] = {
     0x0000,
     0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
     0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
@@ -235,10 +230,10 @@ STATIC const ush mask_bits[] = {
  *  malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
  */
 
-static unsigned long INITDATA malloc_ptr;
-static int INITDATA malloc_count;
+static unsigned long __initdata malloc_ptr;
+static int __initdata malloc_count;
 
-static void *INIT malloc(int size)
+static void *__init malloc(int size)
 {
     void *p;
 
@@ -259,7 +254,7 @@ static void *INIT malloc(int size)
     return p;
 }
 
-static void INIT free(void *where)
+static void __init free(void *where)
 {
     malloc_count--;
     if (!malloc_count)
@@ -303,8 +298,8 @@ static void INIT free(void *where)
  */
 
 
-STATIC const int lbits = 9;          /* bits in base literal/length lookup table */
-STATIC const int dbits = 6;          /* bits in base distance lookup table */
+static const int lbits = 9;          /* bits in base literal/length lookup table */
+static const int dbits = 6;          /* bits in base distance lookup table */
 
 
 /* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
@@ -312,10 +307,10 @@ STATIC const int dbits = 6;          /*
 #define N_MAX 288       /* maximum number of codes in any set */
 
 
-STATIC unsigned INITDATA hufts;      /* track memory usage */
+static unsigned __initdata hufts;      /* track memory usage */
 
 
-STATIC int INIT huft_build(
+static int __init huft_build(
     unsigned *b,            /* code lengths in bits (all assumed <= BMAX) */
     unsigned n,             /* number of codes (assumed <= N_MAX) */
     unsigned s,             /* number of simple-valued codes (0..s-1) */
@@ -560,7 +555,7 @@ STATIC int INIT huft_build(
 
 
 
-STATIC int INIT huft_free(
+static int __init huft_free(
     struct huft *t         /* table to free */
     )
 /* Free the malloc'ed tables built by huft_build(), which makes a linked
@@ -582,7 +577,7 @@ STATIC int INIT huft_free(
 }
 
 
-STATIC int INIT inflate_codes(
+static int __init inflate_codes(
     struct huft *tl,    /* literal/length decoder tables */
     struct huft *td,    /* distance decoder tables */
     int bl,             /* number of bits decoded by tl[] */
@@ -697,7 +692,7 @@ STATIC int INIT inflate_codes(
 
 
 
-STATIC int INIT inflate_stored(void)
+static int __init inflate_stored(void)
 /* "decompress" an inflated type 0 (stored) block. */
 {
     unsigned n;           /* number of bytes in block */
@@ -758,7 +753,7 @@ STATIC int INIT inflate_stored(void)
 /*
  * We use `noinline' here to prevent gcc-3.5 from using too much stack space
  */
-STATIC int noinline INIT inflate_fixed(void)
+static int noinline __init inflate_fixed(void)
 /* decompress an inflated type 1 (fixed Huffman codes) block.  We should
    either replace this with a custom decoder, or at least precompute the
    Huffman tables. */
@@ -822,7 +817,7 @@ STATIC int noinline INIT inflate_fixed(v
 /*
  * We use `noinline' here to prevent gcc-3.5 from using too much stack space
  */
-STATIC int noinline INIT inflate_dynamic(void)
+static int noinline __init inflate_dynamic(void)
 /* decompress an inflated type 2 (dynamic Huffman codes) block. */
 {
     int i;                /* temporary variables */
@@ -1027,7 +1022,7 @@ goto out;
 
 
 
-STATIC int INIT inflate_block(
+static int __init inflate_block(
 int *e                  /* last block flag */
 )
 /* decompress an inflated block */
@@ -1078,7 +1073,7 @@ NEEDBITS(1)
 
 
 
-STATIC int INIT inflate(void)
+static int __init inflate(void)
 /* decompress an inflated entry */
 {
     int e;                /* last block flag */
@@ -1130,8 +1125,8 @@ STATIC int INIT inflate(void)
  *
  **********************************************************************/
 
-static ulg INITDATA crc_32_tab[256];
-static ulg INITDATA crc;  /* initialized in makecrc() so it'll reside in bss */
+static ulg __initdata crc_32_tab[256];
+static ulg __initdata crc;  /* initialized in makecrc() so it'll reside in bss */
 #define CRC_VALUE (crc ^ 0xffffffffUL)
 
 /*
@@ -1139,7 +1134,7 @@ static ulg INITDATA crc;  /* initialized
  * gzip-1.0.3/makecrc.c.
  */
 
-static void INIT
+static void __init
 makecrc(void)
 {
 /* Not copyrighted 1990 Mark Adler */
@@ -1187,7 +1182,7 @@ makecrc(void)
 /*
  * Do the uncompression!
  */
-static int INIT gunzip(void)
+static int __init gunzip(void)
 {
     uch flags;
     unsigned char magic[2]; /* magic header */



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 08/15] bunzip: replace INIT
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (6 preceding siblings ...)
  2021-01-26  9:50 ` [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC Jan Beulich
@ 2021-01-26  9:51 ` Jan Beulich
  2021-04-15 11:50   ` Julien Grall
  2021-01-26  9:51 ` [PATCH v3 09/15] unlzo: " Jan Beulich
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:51 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
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;



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 09/15] unlzo: replace INIT
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (7 preceding siblings ...)
  2021-01-26  9:51 ` [PATCH v3 08/15] bunzip: replace INIT Jan Beulich
@ 2021-01-26  9:51 ` Jan Beulich
  2021-04-15 11:51   ` Julien Grall
  2021-01-26  9:51 ` [PATCH v3 10/15] unlzma: " Jan Beulich
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:51 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

There's no need for this abstraction.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
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;



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 10/15] unlzma: replace INIT
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (8 preceding siblings ...)
  2021-01-26  9:51 ` [PATCH v3 09/15] unlzo: " Jan Beulich
@ 2021-01-26  9:51 ` Jan Beulich
  2021-04-15 11:52   ` Julien Grall
  2021-01-26  9:52 ` [PATCH v3 11/15] unlz4: " Jan Beulich
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:51 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

There's no need for this abstraction.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
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;



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 11/15] unlz4: replace INIT
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (9 preceding siblings ...)
  2021-01-26  9:51 ` [PATCH v3 10/15] unlzma: " Jan Beulich
@ 2021-01-26  9:52 ` Jan Beulich
  2021-04-15 11:56   ` Julien Grall
  2021-01-26  9:52 ` [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC Jan Beulich
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:52 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

There's no need for this abstraction.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
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;



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (10 preceding siblings ...)
  2021-01-26  9:52 ` [PATCH v3 11/15] unlz4: " Jan Beulich
@ 2021-01-26  9:52 ` Jan Beulich
  2021-04-15 11:58   ` Julien Grall
  2021-01-26  9:52 ` [PATCH v3 13/15] unzstd: " Jan Beulich
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:52 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
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;



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (11 preceding siblings ...)
  2021-01-26  9:52 ` [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC Jan Beulich
@ 2021-01-26  9:52 ` Jan Beulich
  2021-04-15 11:59   ` Julien Grall
  2021-01-26  9:53 ` [PATCH v3 14/15] xen/decompress: drop STATIC and INIT Jan Beulich
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:52 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
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



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 14/15] xen/decompress: drop STATIC and INIT
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (12 preceding siblings ...)
  2021-01-26  9:52 ` [PATCH v3 13/15] unzstd: " Jan Beulich
@ 2021-01-26  9:53 ` Jan Beulich
  2021-04-15 14:21   ` Julien Grall
  2021-01-26  9:53 ` [PATCH v3 15/15] unzstd: make helper symbols static Jan Beulich
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:53 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

All users have been removed in earlier changes.

Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v3: New.

--- a/xen/arch/arm/efi/efi-dom0.c
+++ b/xen/arch/arm/efi/efi-dom0.c
@@ -28,7 +28,7 @@
 #include <asm/setup.h>
 #include <asm/acpi.h>
 #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 <xen/types.h>
 #include <xen/xmalloc.h>
 
-#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



^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 15/15] unzstd: make helper symbols static
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (13 preceding siblings ...)
  2021-01-26  9:53 ` [PATCH v3 14/15] xen/decompress: drop STATIC and INIT Jan Beulich
@ 2021-01-26  9:53 ` Jan Beulich
  2021-04-15 12:09   ` Julien Grall
  2021-01-26 12:05 ` [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Ian Jackson
  2021-04-15  9:20 ` Ping: " Jan Beulich
  16 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:53 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

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 <jbeulich@suse.com>
---
v3: New.

--- a/xen/common/unzstd.c
+++ b/xen/common/unzstd.c
@@ -53,6 +53,10 @@
  *                 <= 22 + (uncompressed_size >> 15) + 131072
  */
 
+#ifdef __XEN__
+#include <xen/lib.h>
+#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 */



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC
  2021-01-26  9:50 ` [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC Jan Beulich
@ 2021-01-26  9:54   ` Jan Beulich
  2021-01-26 11:56   ` Ian Jackson
  1 sibling, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26  9:54 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu

On 26.01.2021 10:50, Jan Beulich wrote:
> There's no need for the extra abstraction.
> 
> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

This, of course, is 07/15. Sorry.

Jan

> ---
> v3: New.
> 
> --- a/xen/common/gunzip.c
> +++ b/xen/common/gunzip.c
> @@ -22,7 +22,6 @@ static unsigned __initdata inptr;
>  static unsigned __initdata outcnt;
>  
>  #define OF(args)        args
> -#define STATIC          static
>  
>  #define memzero(s, n)   memset((s), 0, (n))
>  
> @@ -30,9 +29,6 @@ typedef unsigned char   uch;
>  typedef unsigned short  ush;
>  typedef unsigned long   ulg;
>  
> -#define INIT            __init
> -#define INITDATA        __initdata
> -
>  #define get_byte()      (inptr < insize ? inbuf[inptr++] : fill_inbuf())
>  
>  /* Diagnostic functions */
> --- a/xen/common/inflate.c
> +++ b/xen/common/inflate.c
> @@ -107,7 +107,7 @@
>  static char rcsid[] = "#Id: inflate.c,v 0.14 1993/06/10 13:27:04 jloup Exp #";
>  #endif
>  
> -#ifndef STATIC
> +#ifndef __XEN__
>  
>  #if defined(STDC_HEADERS) || defined(HAVE_STDLIB_H)
>  #  include <sys/types.h>
> @@ -115,14 +115,9 @@ static char rcsid[] = "#Id: inflate.c,v
>  #endif
>  
>  #include "gzip.h"
> -#define STATIC
> -#endif /* !STATIC */
>  
> -#ifndef INIT
> -#define INIT
> -#define INITDATA
> -#endif
> - 
> +#endif /* !__XEN__ */
> +
>  #define slide window
>  
>  /* Huffman code lookup table entry--this entry is four bytes for machines
> @@ -143,15 +138,15 @@ struct huft {
>  
>  
>  /* Function prototypes */
> -STATIC int INIT huft_build OF((unsigned *, unsigned, unsigned, 
> -                               const ush *, const ush *, struct huft **, int *));
> -STATIC int INIT huft_free OF((struct huft *));
> -STATIC int INIT inflate_codes OF((struct huft *, struct huft *, int, int));
> -STATIC int INIT inflate_stored OF((void));
> -STATIC int INIT inflate_fixed OF((void));
> -STATIC int INIT inflate_dynamic OF((void));
> -STATIC int INIT inflate_block OF((int *));
> -STATIC int INIT inflate OF((void));
> +static int huft_build OF((unsigned *, unsigned, unsigned,
> +                          const ush *, const ush *, struct huft **, int *));
> +static int huft_free OF((struct huft *));
> +static int inflate_codes OF((struct huft *, struct huft *, int, int));
> +static int inflate_stored OF((void));
> +static int inflate_fixed OF((void));
> +static int inflate_dynamic OF((void));
> +static int inflate_block OF((int *));
> +static int inflate OF((void));
>  
>  
>  /* The inflate algorithm uses a sliding 32 K byte window on the uncompressed
> @@ -217,10 +212,10 @@ static const ush cpdext[] = {         /*
>     the stream.
>   */
>  
> -STATIC ulg INITDATA bb;                /* bit buffer */
> -STATIC unsigned INITDATA bk;           /* bits in bit buffer */
> +static ulg __initdata bb;                /* bit buffer */
> +static unsigned __initdata bk;           /* bits in bit buffer */
>  
> -STATIC const ush mask_bits[] = {
> +static const ush mask_bits[] = {
>      0x0000,
>      0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
>      0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
> @@ -235,10 +230,10 @@ STATIC const ush mask_bits[] = {
>   *  malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
>   */
>  
> -static unsigned long INITDATA malloc_ptr;
> -static int INITDATA malloc_count;
> +static unsigned long __initdata malloc_ptr;
> +static int __initdata malloc_count;
>  
> -static void *INIT malloc(int size)
> +static void *__init malloc(int size)
>  {
>      void *p;
>  
> @@ -259,7 +254,7 @@ static void *INIT malloc(int size)
>      return p;
>  }
>  
> -static void INIT free(void *where)
> +static void __init free(void *where)
>  {
>      malloc_count--;
>      if (!malloc_count)
> @@ -303,8 +298,8 @@ static void INIT free(void *where)
>   */
>  
>  
> -STATIC const int lbits = 9;          /* bits in base literal/length lookup table */
> -STATIC const int dbits = 6;          /* bits in base distance lookup table */
> +static const int lbits = 9;          /* bits in base literal/length lookup table */
> +static const int dbits = 6;          /* bits in base distance lookup table */
>  
>  
>  /* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
> @@ -312,10 +307,10 @@ STATIC const int dbits = 6;          /*
>  #define N_MAX 288       /* maximum number of codes in any set */
>  
>  
> -STATIC unsigned INITDATA hufts;      /* track memory usage */
> +static unsigned __initdata hufts;      /* track memory usage */
>  
>  
> -STATIC int INIT huft_build(
> +static int __init huft_build(
>      unsigned *b,            /* code lengths in bits (all assumed <= BMAX) */
>      unsigned n,             /* number of codes (assumed <= N_MAX) */
>      unsigned s,             /* number of simple-valued codes (0..s-1) */
> @@ -560,7 +555,7 @@ STATIC int INIT huft_build(
>  
>  
>  
> -STATIC int INIT huft_free(
> +static int __init huft_free(
>      struct huft *t         /* table to free */
>      )
>  /* Free the malloc'ed tables built by huft_build(), which makes a linked
> @@ -582,7 +577,7 @@ STATIC int INIT huft_free(
>  }
>  
>  
> -STATIC int INIT inflate_codes(
> +static int __init inflate_codes(
>      struct huft *tl,    /* literal/length decoder tables */
>      struct huft *td,    /* distance decoder tables */
>      int bl,             /* number of bits decoded by tl[] */
> @@ -697,7 +692,7 @@ STATIC int INIT inflate_codes(
>  
>  
>  
> -STATIC int INIT inflate_stored(void)
> +static int __init inflate_stored(void)
>  /* "decompress" an inflated type 0 (stored) block. */
>  {
>      unsigned n;           /* number of bytes in block */
> @@ -758,7 +753,7 @@ STATIC int INIT inflate_stored(void)
>  /*
>   * We use `noinline' here to prevent gcc-3.5 from using too much stack space
>   */
> -STATIC int noinline INIT inflate_fixed(void)
> +static int noinline __init inflate_fixed(void)
>  /* decompress an inflated type 1 (fixed Huffman codes) block.  We should
>     either replace this with a custom decoder, or at least precompute the
>     Huffman tables. */
> @@ -822,7 +817,7 @@ STATIC int noinline INIT inflate_fixed(v
>  /*
>   * We use `noinline' here to prevent gcc-3.5 from using too much stack space
>   */
> -STATIC int noinline INIT inflate_dynamic(void)
> +static int noinline __init inflate_dynamic(void)
>  /* decompress an inflated type 2 (dynamic Huffman codes) block. */
>  {
>      int i;                /* temporary variables */
> @@ -1027,7 +1022,7 @@ goto out;
>  
>  
>  
> -STATIC int INIT inflate_block(
> +static int __init inflate_block(
>  int *e                  /* last block flag */
>  )
>  /* decompress an inflated block */
> @@ -1078,7 +1073,7 @@ NEEDBITS(1)
>  
>  
>  
> -STATIC int INIT inflate(void)
> +static int __init inflate(void)
>  /* decompress an inflated entry */
>  {
>      int e;                /* last block flag */
> @@ -1130,8 +1125,8 @@ STATIC int INIT inflate(void)
>   *
>   **********************************************************************/
>  
> -static ulg INITDATA crc_32_tab[256];
> -static ulg INITDATA crc;  /* initialized in makecrc() so it'll reside in bss */
> +static ulg __initdata crc_32_tab[256];
> +static ulg __initdata crc;  /* initialized in makecrc() so it'll reside in bss */
>  #define CRC_VALUE (crc ^ 0xffffffffUL)
>  
>  /*
> @@ -1139,7 +1134,7 @@ static ulg INITDATA crc;  /* initialized
>   * gzip-1.0.3/makecrc.c.
>   */
>  
> -static void INIT
> +static void __init
>  makecrc(void)
>  {
>  /* Not copyrighted 1990 Mark Adler */
> @@ -1187,7 +1182,7 @@ makecrc(void)
>  /*
>   * Do the uncompression!
>   */
> -static int INIT gunzip(void)
> +static int __init gunzip(void)
>  {
>      uch flags;
>      unsigned char magic[2]; /* magic header */
> 
> 



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 01/15] libxenguest: add get_unaligned_le32()
  2021-01-26  9:48 ` [PATCH v3 01/15] libxenguest: add get_unaligned_le32() Jan Beulich
@ 2021-01-26 11:51   ` Ian Jackson
  0 siblings, 0 replies; 49+ messages in thread
From: Ian Jackson @ 2021-01-26 11:51 UTC (permalink / raw)
  To: Jan Beulich
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

Jan Beulich writes ("[PATCH v3 01/15] libxenguest: add get_unaligned_le32()"):
> 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.

How irritating.

> Requested-by: Ian Jackson <iwj@xenproject.org>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Release-Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Thanks,
Ian.


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 02/15] libxenguest: support zstd compressed kernels
  2021-01-26  9:49 ` [PATCH v3 02/15] libxenguest: support zstd compressed kernels Jan Beulich
@ 2021-01-26 11:53   ` Ian Jackson
  0 siblings, 0 replies; 49+ messages in thread
From: Ian Jackson @ 2021-01-26 11:53 UTC (permalink / raw)
  To: Jan Beulich
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

Jan Beulich writes ("[PATCH v3 02/15] libxenguest: support zstd compressed kernels"):
> 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 <jbeulich@suse.com>
> Acked-by: Wei Liu <wl@xen.org>
> Release-Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
> ---
> Note for committer: As an alternative to patching tools/configure here,
> autoconf may want re-running.

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>

Thanks,
Ian.


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC
  2021-01-26  9:50 ` [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC Jan Beulich
  2021-01-26  9:54   ` Jan Beulich
@ 2021-01-26 11:56   ` Ian Jackson
  2021-01-26 12:49     ` Jan Beulich
  1 sibling, 1 reply; 49+ messages in thread
From: Ian Jackson @ 2021-01-26 11:56 UTC (permalink / raw)
  To: Jan Beulich
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

Jan Beulich writes ("[PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC"):
> There's no need for the extra abstraction.

Thanks for tidying things up.

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

However, I think this is a refactoring commit which wasn't posted
before the last posting date and can easily be postponed ?  So:

Release-Nacked-by: Ian Jackson <ian.jackson@eu.citrix.com>
        ^^^^^^

Please correct me if I am wrong and you (Jan, or Andy, or anyone)
think this should go into 4.15.

Thanks,
Ian.


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (14 preceding siblings ...)
  2021-01-26  9:53 ` [PATCH v3 15/15] unzstd: make helper symbols static Jan Beulich
@ 2021-01-26 12:05 ` Ian Jackson
  2021-01-26 13:04   ` Jan Beulich
  2021-04-15  9:20 ` Ping: " Jan Beulich
  16 siblings, 1 reply; 49+ messages in thread
From: Ian Jackson @ 2021-01-26 12:05 UTC (permalink / raw)
  To: Jan Beulich
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

Jan Beulich writes ("[PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation"):
> Only patches 1 and 2 are strictly intended for 4.15, paralleling
> the recent Dom0 side work (and re-using many of the files
> introduced there, for the stubdom build), but ones up to at least
> patch 6 may still want considering (and 4 already has a release
> ack).

Thanks.

> 01: libxenguest: add get_unaligned_le32()
> 02: libxenguest: support zstd compressed kernels

So these two are fine.

> 03: xen/decompress: make helper symbols static
> 04: libxenguest: "standardize" LZO kernel decompression code
> 05: libxenguest: drop redundant decompression declarations
> 06: libxenguest: simplify kernel decompression

I approve of cleanups of course.  But:

Which of these cleanups were posted before the LPD ?  I'm not
currently aware of any reason for a freeze exception here, so I think
those patches which didn't meet the LPD should wait.  Ones which *did*
meet the LPD should be considered on their merits.

If you could direct me to which those are I would be happy to review
them.

> 07: gunzip: drop INIT{,DATA} and STATIC

I release-nacked this because I saw you posted it with this Subject
  Subject: [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC
which made me think you were targeting it for 4.15.  If not then fine.

Thanks,
Ian.


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC
  2021-01-26 11:56   ` Ian Jackson
@ 2021-01-26 12:49     ` Jan Beulich
  0 siblings, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26 12:49 UTC (permalink / raw)
  To: Ian Jackson
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

On 26.01.2021 12:56, Ian Jackson wrote:
> Jan Beulich writes ("[PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC"):
>> There's no need for the extra abstraction.
> 
> Thanks for tidying things up.
> 
> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Thanks.

>> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> However, I think this is a refactoring commit which wasn't posted
> before the last posting date and can easily be postponed ?  So:
> 
> Release-Nacked-by: Ian Jackson <ian.jackson@eu.citrix.com>
>         ^^^^^^
> 
> Please correct me if I am wrong and you (Jan, or Andy, or anyone)
> think this should go into 4.15.

No, that's fine (and expected, as per the cover letter).

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation
  2021-01-26 12:05 ` [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Ian Jackson
@ 2021-01-26 13:04   ` Jan Beulich
  2021-01-26 13:25     ` Ian Jackson
  0 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-01-26 13:04 UTC (permalink / raw)
  To: Ian Jackson
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

On 26.01.2021 13:05, Ian Jackson wrote:
> Jan Beulich writes ("[PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation"):
>> Only patches 1 and 2 are strictly intended for 4.15, paralleling
>> the recent Dom0 side work (and re-using many of the files
>> introduced there, for the stubdom build), but ones up to at least
>> patch 6 may still want considering (and 4 already has a release
>> ack).
> 
> Thanks.
> 
>> 01: libxenguest: add get_unaligned_le32()
>> 02: libxenguest: support zstd compressed kernels
> 
> So these two are fine.
> 
>> 03: xen/decompress: make helper symbols static
>> 04: libxenguest: "standardize" LZO kernel decompression code
>> 05: libxenguest: drop redundant decompression declarations
>> 06: libxenguest: simplify kernel decompression
> 
> I approve of cleanups of course.  But:
> 
> Which of these cleanups were posted before the LPD ?  I'm not
> currently aware of any reason for a freeze exception here, so I think
> those patches which didn't meet the LPD should wait.  Ones which *did*
> meet the LPD should be considered on their merits.
> 
> If you could direct me to which those are I would be happy to review
> them.

All of them were posted after that date; only the Dom0 zstd
decompression part was ready in time. I view this entire
series as a logical extension to the earlier patches though.
I'm unsure anyway how new patches in a previously submitted
series would be treated in general; so far I've been under
the impression that if in doubt the series as a whole would
count, not every individual patch.

As said (still visible above) I'm not meaning to insist on
patches 3 and onwards to be taken. In fact it was you to
ask whether patch 3 would possibly want a freeze exception.
And you did give patch 4 a release ack already, based on it
containing a bug fix. (The latter is true of patch 6 as
well, btw.) Are you implying you withdraw that release ack
now?

While we're at this - how are bug fixes to be treated in
this two week window? Do they need a release ack too if
they did miss the LPD? I'm asking with specifically
"xen/include: compat/xlat.h may change with .config
changes" in mind, but there may be others, like Roger's
3-patch series posted today, which I intend to look at
rather sooner than later.

>> 07: gunzip: drop INIT{,DATA} and STATIC
> 
> I release-nacked this because I saw you posted it with this Subject
>   Subject: [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC
> which made me think you were targeting it for 4.15.  If not then fine.

FAOD - indeed it was a mistake of mine and was meant to
be 07/15.

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation
  2021-01-26 13:04   ` Jan Beulich
@ 2021-01-26 13:25     ` Ian Jackson
  2021-01-26 13:50       ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Ian Jackson @ 2021-01-26 13:25 UTC (permalink / raw)
  To: Jan Beulich
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

Jan Beulich writes ("Re: [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation"):
> On 26.01.2021 13:05, Ian Jackson wrote:
> > I approve of cleanups of course.  But:
> > 
> > Which of these cleanups were posted before the LPD ?  I'm not
> > currently aware of any reason for a freeze exception here, so I think
> > those patches which didn't meet the LPD should wait.  Ones which *did*
> > meet the LPD should be considered on their merits.
> > 
> > If you could direct me to which those are I would be happy to review
> > them.
> 
> All of them were posted after that date; only the Dom0 zstd
> decompression part was ready in time. I view this entire
> series as a logical extension to the earlier patches though.
> I'm unsure anyway how new patches in a previously submitted
> series would be treated in general; so far I've been under
> the impression that if in doubt the series as a whole would
> count, not every individual patch.

I think as a general rule, I don't think "logical extensions" to
things posted before the LPD count.  But bugfixes, and smallish
changes necessary to make the rest of a previously-posted series are
OK.

> As said (still visible above) I'm not meaning to insist on
> patches 3 and onwards to be taken. In fact it was you to
> ask whether patch 3 would possibly want a freeze exception.
> And you did give patch 4 a release ack already, based on it
> containing a bug fix. (The latter is true of patch 6 as
> well, btw.) Are you implying you withdraw that release ack
> now?

I'm afraid that I don't keep all this state in my head.  I rely on
written materials.  Where the written materials in front of me seem
self-sufficient and don't contain unresolved references or things that
are confusing, I rely on what is in front of me being sufficient.
ISTM that the point of a summary mail like yours is to save us going
and rereading all the background each time.

None of the subject lines in your mail mentioned that these were
bugfixes.  So I'm afraid I had forgotten that.

I'm not withdrawing my release ack for anything.  But whena commit is
being justified for 4.15 because it is (or contains) a bugfix then it
would be really good if the bugfix were mentioned in the summary line.

> While we're at this - how are bug fixes to be treated in
> this two week window? Do they need a release ack too if
> they did miss the LPD?

No.

>  I'm asking with specifically
> "xen/include: compat/xlat.h may change with .config
> changes" in mind, but there may be others, like Roger's
> 3-patch series posted today, which I intend to look at
> rather sooner than later.

Things that are just bugfixes do not need a release ack at this stage.
Things that are a mixture should either get a release ack, or be
separated out in which case the bugfix part does not need a release
ack.  I am happy to give out (or decline) acks in cases of doubt.

I appreciate your looking at bugfixes as a priority, so thanks.

> >> 07: gunzip: drop INIT{,DATA} and STATIC
> > 
> > I release-nacked this because I saw you posted it with this Subject
> >   Subject: [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC
> > which made me think you were targeting it for 4.15.  If not then fine.
> 
> FAOD - indeed it was a mistake of mine and was meant to
> be 07/15.

NP.

I hope this explanation makes some kind of sense and sorry for the
confusion.

Ian.


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation
  2021-01-26 13:25     ` Ian Jackson
@ 2021-01-26 13:50       ` Jan Beulich
  0 siblings, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-01-26 13:50 UTC (permalink / raw)
  To: Ian Jackson
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

On 26.01.2021 14:25, Ian Jackson wrote:
> I hope this explanation makes some kind of sense and sorry for the
> confusion.

It does and no, I don't think there was any confusion caused. Some
thinks merely needed clarifying, on my end at least. Thanks for
doing so.

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Ping: [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation
  2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
                   ` (15 preceding siblings ...)
  2021-01-26 12:05 ` [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Ian Jackson
@ 2021-04-15  9:20 ` Jan Beulich
  16 siblings, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-04-15  9:20 UTC (permalink / raw)
  To: Andrew Cooper, George Dunlap, Ian Jackson, Julien Grall,
	Stefano Stabellini, Wei Liu
  Cc: xen-devel

On 26.01.2021 10:46, Jan Beulich wrote:
> Only patches 1 and 2 are strictly intended for 4.15, paralleling
> the recent Dom0 side work (and re-using many of the files
> introduced there, for the stubdom build), but ones up to at least
> patch 6 may still want considering (and 4 already has a release
> ack).
> 
> 01: libxenguest: add get_unaligned_le32()
> 02: libxenguest: support zstd compressed kernels
> 03: xen/decompress: make helper symbols static
> 04: libxenguest: "standardize" LZO kernel decompression code
> 05: libxenguest: drop redundant decompression declarations
> 06: libxenguest: simplify kernel decompression
> 07: gunzip: drop INIT{,DATA} and STATIC

While these have all gone in, ...

> 08: bunzip: replace INIT
> 09: unlzo: replace INIT
> 10: unlzma: replace INIT
> 11: unlz4: replace INIT
> 12: unxz: replace INIT{,DATA} and STATIC
> 13: unzstd: replace INIT{,DATA} and STATIC
> 14: xen/decompress: drop STATIC and INIT
> 15: unzstd: make helper symbols static

... may I please ask for an ack (or otherwise) on these?

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 08/15] bunzip: replace INIT
  2021-01-26  9:51 ` [PATCH v3 08/15] bunzip: replace INIT Jan Beulich
@ 2021-04-15 11:50   ` Julien Grall
  0 siblings, 0 replies; 49+ messages in thread
From: Julien Grall @ 2021-04-15 11:50 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu

Hi Jan,

On 26/01/2021 09:51, Jan Beulich wrote:
> 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 <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

> ---
> 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;
> 
> 

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 09/15] unlzo: replace INIT
  2021-01-26  9:51 ` [PATCH v3 09/15] unlzo: " Jan Beulich
@ 2021-04-15 11:51   ` Julien Grall
  0 siblings, 0 replies; 49+ messages in thread
From: Julien Grall @ 2021-04-15 11:51 UTC (permalink / raw)
  To: xen-devel

Hi Jan,

On 26/01/2021 09:51, Jan Beulich wrote:
> There's no need for this abstraction.
> 
> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

> ---
> 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;
> 
> 

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 10/15] unlzma: replace INIT
  2021-01-26  9:51 ` [PATCH v3 10/15] unlzma: " Jan Beulich
@ 2021-04-15 11:52   ` Julien Grall
  0 siblings, 0 replies; 49+ messages in thread
From: Julien Grall @ 2021-04-15 11:52 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu

Hi Jan,

On 26/01/2021 09:51, Jan Beulich wrote:
> There's no need for this abstraction.
> 
> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 11/15] unlz4: replace INIT
  2021-01-26  9:52 ` [PATCH v3 11/15] unlz4: " Jan Beulich
@ 2021-04-15 11:56   ` Julien Grall
  0 siblings, 0 replies; 49+ messages in thread
From: Julien Grall @ 2021-04-15 11:56 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu

Hi Jan,

On 26/01/2021 09:52, Jan Beulich wrote:
> There's no need for this abstraction.
> 
> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC
  2021-01-26  9:52 ` [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC Jan Beulich
@ 2021-04-15 11:58   ` Julien Grall
  2021-04-15 14:16     ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Julien Grall @ 2021-04-15 11:58 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu

Hi Jan,

On 26/01/2021 09:52, Jan Beulich wrote:
> 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 <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> 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

Shouldn't the two changes be part of patch #14?

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC
  2021-01-26  9:52 ` [PATCH v3 13/15] unzstd: " Jan Beulich
@ 2021-04-15 11:59   ` Julien Grall
  2021-04-15 14:21     ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Julien Grall @ 2021-04-15 11:59 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu

Hi Jan,

On 26/01/2021 09:52, Jan Beulich wrote:
> With xen/common/decompress.h now agreeing in both build modes about
> what STATIC expands to, there's no need for this abstraction anymore.

Shouldn't you also mention "INIT" and "INITDATA" here?

Cheers,

> 
> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> 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
> 
> 

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 15/15] unzstd: make helper symbols static
  2021-01-26  9:53 ` [PATCH v3 15/15] unzstd: make helper symbols static Jan Beulich
@ 2021-04-15 12:09   ` Julien Grall
  2021-04-15 14:37     ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Julien Grall @ 2021-04-15 12:09 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu

Hi Jan,

On 26/01/2021 09:53, Jan Beulich wrote:
> 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.

So why do we keep the code if it is not used? Do you expect it to be 
re-used in the future?

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC
  2021-04-15 11:58   ` Julien Grall
@ 2021-04-15 14:16     ` Jan Beulich
  2021-04-15 14:18       ` Julien Grall
  0 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-04-15 14:16 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 15.04.2021 13:58, Julien Grall wrote:
> On 26/01/2021 09:52, Jan Beulich wrote:
>> --- 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
> 
> Shouldn't the two changes be part of patch #14?

One could do it that way, sure, but the last uses are gone here,
and hence I wanted to get rid of this one item right away.

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC
  2021-04-15 14:16     ` Jan Beulich
@ 2021-04-15 14:18       ` Julien Grall
  2021-04-15 14:22         ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Julien Grall @ 2021-04-15 14:18 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel



On 15/04/2021 15:16, Jan Beulich wrote:
> On 15.04.2021 13:58, Julien Grall wrote:
>> On 26/01/2021 09:52, Jan Beulich wrote:
>>> --- 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
>>
>> Shouldn't the two changes be part of patch #14?
> 
> One could do it that way, sure, but the last uses are gone here,
> and hence I wanted to get rid of this one item right away.

AFAICT, the same is true for STATIC and INIT. So it doesn't sense to not 
be consistent in the way you treat them.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 14/15] xen/decompress: drop STATIC and INIT
  2021-01-26  9:53 ` [PATCH v3 14/15] xen/decompress: drop STATIC and INIT Jan Beulich
@ 2021-04-15 14:21   ` Julien Grall
  2021-04-15 14:32     ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Julien Grall @ 2021-04-15 14:21 UTC (permalink / raw)
  To: Jan Beulich, xen-devel
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini, Wei Liu



On 26/01/2021 09:53, Jan Beulich wrote:
> All users have been removed in earlier changes.

This is not entirely correct given there is a still a user of...

> 
> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> v3: New.
> 
> --- a/xen/arch/arm/efi/efi-dom0.c
> +++ b/xen/arch/arm/efi/efi-dom0.c
> @@ -28,7 +28,7 @@
>   #include <asm/setup.h>
>   #include <asm/acpi.h>
>   #include "../../../common/decompress.h"
> -#define XZ_EXTERN STATIC
> +#define XZ_EXTERN static

STATIC here. So maybe you want to say "all but one users"?

Also, for consistency, I think you want to either remove INITDATA here 
or remove INIT in the patch that drop the last user.

Cheers,

>   #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 <xen/types.h>
>   #include <xen/xmalloc.h>
>   
> -#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
> 
> 

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC
  2021-04-15 11:59   ` Julien Grall
@ 2021-04-15 14:21     ` Jan Beulich
  2021-04-15 14:22       ` Julien Grall
  0 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-04-15 14:21 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 15.04.2021 13:59, Julien Grall wrote:
> On 26/01/2021 09:52, Jan Beulich wrote:
>> With xen/common/decompress.h now agreeing in both build modes about
>> what STATIC expands to, there's no need for this abstraction anymore.
> 
> Shouldn't you also mention "INIT" and "INITDATA" here?

Two parts: INITDATA was mistakenly mentioned in the title. I've
dropped that. And what I'm saying about STATIC does not apply to
INIT - for it, we replace the extra level of abstraction by
directly using __init, just like was done in the earlier patches.

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC
  2021-04-15 14:18       ` Julien Grall
@ 2021-04-15 14:22         ` Jan Beulich
  2021-04-15 14:24           ` Julien Grall
  0 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-04-15 14:22 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 15.04.2021 16:18, Julien Grall wrote:
> 
> 
> On 15/04/2021 15:16, Jan Beulich wrote:
>> On 15.04.2021 13:58, Julien Grall wrote:
>>> On 26/01/2021 09:52, Jan Beulich wrote:
>>>> --- 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
>>>
>>> Shouldn't the two changes be part of patch #14?
>>
>> One could do it that way, sure, but the last uses are gone here,
>> and hence I wanted to get rid of this one item right away.
> 
> AFAICT, the same is true for STATIC and INIT. So it doesn't sense to not 
> be consistent in the way you treat them.

No, further uses of STATIC and INIT get dropped by later patches.

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC
  2021-04-15 14:21     ` Jan Beulich
@ 2021-04-15 14:22       ` Julien Grall
  2021-04-15 14:25         ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Julien Grall @ 2021-04-15 14:22 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel



On 15/04/2021 15:21, Jan Beulich wrote:
> On 15.04.2021 13:59, Julien Grall wrote:
>> On 26/01/2021 09:52, Jan Beulich wrote:
>>> With xen/common/decompress.h now agreeing in both build modes about
>>> what STATIC expands to, there's no need for this abstraction anymore.
>>
>> Shouldn't you also mention "INIT" and "INITDATA" here?
> 
> Two parts: INITDATA was mistakenly mentioned in the title. I've
> dropped that. 

Ok.

And what I'm saying about STATIC does not apply to
> INIT - for it, we replace the extra level of abstraction by
> directly using __init, just like was done in the earlier patches.

This should be mention in the commit message.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC
  2021-04-15 14:22         ` Jan Beulich
@ 2021-04-15 14:24           ` Julien Grall
  2021-04-15 14:28             ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Julien Grall @ 2021-04-15 14:24 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel



On 15/04/2021 15:22, Jan Beulich wrote:
> On 15.04.2021 16:18, Julien Grall wrote:
>>
>>
>> On 15/04/2021 15:16, Jan Beulich wrote:
>>> On 15.04.2021 13:58, Julien Grall wrote:
>>>> On 26/01/2021 09:52, Jan Beulich wrote:
>>>>> --- 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
>>>>
>>>> Shouldn't the two changes be part of patch #14?
>>>
>>> One could do it that way, sure, but the last uses are gone here,
>>> and hence I wanted to get rid of this one item right away.
>>
>> AFAICT, the same is true for STATIC and INIT. So it doesn't sense to not
>> be consistent in the way you treat them.
> 
> No, further uses of STATIC and INIT get dropped by later patches.

I think you misundertood my comment. What I meant is you drop INIT in 
patch #14 when the last caller was dropped in a previous patch.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC
  2021-04-15 14:22       ` Julien Grall
@ 2021-04-15 14:25         ` Jan Beulich
  2021-04-15 14:30           ` Julien Grall
  0 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-04-15 14:25 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 15.04.2021 16:22, Julien Grall wrote:
> On 15/04/2021 15:21, Jan Beulich wrote:
>> On 15.04.2021 13:59, Julien Grall wrote:
>>> On 26/01/2021 09:52, Jan Beulich wrote:
>>>> With xen/common/decompress.h now agreeing in both build modes about
>>>> what STATIC expands to, there's no need for this abstraction anymore.
>>>
>>> Shouldn't you also mention "INIT" and "INITDATA" here?
>>
>> Two parts: INITDATA was mistakenly mentioned in the title. I've
>> dropped that. 
> 
> Ok.
> 
> And what I'm saying about STATIC does not apply to
>> INIT - for it, we replace the extra level of abstraction by
>> directly using __init, just like was done in the earlier patches.
> 
> This should be mention in the commit message.

It already is by what is being said after the comma. May I direct
you back to the commit messages of earlier patches in this series
(when talk was of just INIT)?

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC
  2021-04-15 14:24           ` Julien Grall
@ 2021-04-15 14:28             ` Jan Beulich
  2021-04-15 14:55               ` Julien Grall
  0 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-04-15 14:28 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 15.04.2021 16:24, Julien Grall wrote:
> 
> 
> On 15/04/2021 15:22, Jan Beulich wrote:
>> On 15.04.2021 16:18, Julien Grall wrote:
>>>
>>>
>>> On 15/04/2021 15:16, Jan Beulich wrote:
>>>> On 15.04.2021 13:58, Julien Grall wrote:
>>>>> On 26/01/2021 09:52, Jan Beulich wrote:
>>>>>> --- 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
>>>>>
>>>>> Shouldn't the two changes be part of patch #14?
>>>>
>>>> One could do it that way, sure, but the last uses are gone here,
>>>> and hence I wanted to get rid of this one item right away.
>>>
>>> AFAICT, the same is true for STATIC and INIT. So it doesn't sense to not
>>> be consistent in the way you treat them.
>>
>> No, further uses of STATIC and INIT get dropped by later patches.
> 
> I think you misundertood my comment. What I meant is you drop INIT in 
> patch #14 when the last caller was dropped in a previous patch.

Now this and some other of your comments are getting really nitpicky.
The end result is the same. I can certainly move removals around
further, but I think I ought to have some leeway on how exactly I
achieve an identical end result. Things would be different, I agree,
if the end result was not suitably consistent.

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC
  2021-04-15 14:25         ` Jan Beulich
@ 2021-04-15 14:30           ` Julien Grall
  2021-04-15 14:34             ` Jan Beulich
  0 siblings, 1 reply; 49+ messages in thread
From: Julien Grall @ 2021-04-15 14:30 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel



On 15/04/2021 15:25, Jan Beulich wrote:
> On 15.04.2021 16:22, Julien Grall wrote:
>> On 15/04/2021 15:21, Jan Beulich wrote:
>>> On 15.04.2021 13:59, Julien Grall wrote:
>>>> On 26/01/2021 09:52, Jan Beulich wrote:
>>>>> With xen/common/decompress.h now agreeing in both build modes about
>>>>> what STATIC expands to, there's no need for this abstraction anymore.
>>>>
>>>> Shouldn't you also mention "INIT" and "INITDATA" here?
>>>
>>> Two parts: INITDATA was mistakenly mentioned in the title. I've
>>> dropped that.
>>
>> Ok.
>>
>> And what I'm saying about STATIC does not apply to
>>> INIT - for it, we replace the extra level of abstraction by
>>> directly using __init, just like was done in the earlier patches.
>>
>> This should be mention in the commit message.
> 
> It already is by what is being said after the comma. May I direct
> you back to the commit messages of earlier patches in this series
> (when talk was of just INIT)?
 From the way the commit message is written it sounds like more you are 
referring to STATIC only. This is a clearer on the other commit messages 
because there is no other way to interpret "this".

So I would suggest to clarify it.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 14/15] xen/decompress: drop STATIC and INIT
  2021-04-15 14:21   ` Julien Grall
@ 2021-04-15 14:32     ` Jan Beulich
  2021-04-15 14:45       ` Julien Grall
  0 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-04-15 14:32 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 15.04.2021 16:21, Julien Grall wrote:
> On 26/01/2021 09:53, Jan Beulich wrote:
>> All users have been removed in earlier changes.
> 
> This is not entirely correct given there is a still a user of...
> 
>>
>> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>> ---
>> v3: New.
>>
>> --- a/xen/arch/arm/efi/efi-dom0.c
>> +++ b/xen/arch/arm/efi/efi-dom0.c
>> @@ -28,7 +28,7 @@
>>   #include <asm/setup.h>
>>   #include <asm/acpi.h>
>>   #include "../../../common/decompress.h"
>> -#define XZ_EXTERN STATIC
>> +#define XZ_EXTERN static
> 
> STATIC here. So maybe you want to say "all but one users"?

Sigh. Of course I re-word this. But does it really matter? The
more that the thing here is more of an abuse than a proper use
anyway? I didn't create this hackery ... In fact this odd use
is why I made this a separate patch in the first place.

> Also, for consistency, I think you want to either remove INITDATA here 
> or remove INIT in the patch that drop the last user.

See my other reply - what matters, I think, is a consistent
end result. I would really like to ask that I be left with some
room on how precisely to get there.

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC
  2021-04-15 14:30           ` Julien Grall
@ 2021-04-15 14:34             ` Jan Beulich
  2021-04-15 14:47               ` Julien Grall
  0 siblings, 1 reply; 49+ messages in thread
From: Jan Beulich @ 2021-04-15 14:34 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 15.04.2021 16:30, Julien Grall wrote:
> On 15/04/2021 15:25, Jan Beulich wrote:
>> On 15.04.2021 16:22, Julien Grall wrote:
>>> On 15/04/2021 15:21, Jan Beulich wrote:
>>>> On 15.04.2021 13:59, Julien Grall wrote:
>>>>> On 26/01/2021 09:52, Jan Beulich wrote:
>>>>>> With xen/common/decompress.h now agreeing in both build modes about
>>>>>> what STATIC expands to, there's no need for this abstraction anymore.
>>>>>
>>>>> Shouldn't you also mention "INIT" and "INITDATA" here?
>>>>
>>>> Two parts: INITDATA was mistakenly mentioned in the title. I've
>>>> dropped that.
>>>
>>> Ok.
>>>
>>> And what I'm saying about STATIC does not apply to
>>>> INIT - for it, we replace the extra level of abstraction by
>>>> directly using __init, just like was done in the earlier patches.
>>>
>>> This should be mention in the commit message.
>>
>> It already is by what is being said after the comma. May I direct
>> you back to the commit messages of earlier patches in this series
>> (when talk was of just INIT)?
>  From the way the commit message is written it sounds like more you are 
> referring to STATIC only. This is a clearer on the other commit messages 
> because there is no other way to interpret "this".

If the commit message is taken together with the title, I think
all is clear.

> So I would suggest to clarify it.

And I would like to avoid doing so. As a compromise, I'll change
"this abstraction" to "these abstractions".

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 15/15] unzstd: make helper symbols static
  2021-04-15 12:09   ` Julien Grall
@ 2021-04-15 14:37     ` Jan Beulich
  0 siblings, 0 replies; 49+ messages in thread
From: Jan Beulich @ 2021-04-15 14:37 UTC (permalink / raw)
  To: Julien Grall
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

On 15.04.2021 14:09, Julien Grall wrote:
> On 26/01/2021 09:53, Jan Beulich wrote:
>> 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.
> 
> So why do we keep the code if it is not used? Do you expect it to be 
> re-used in the future?

I expect future patch imports from Linux to be easier to apply when the
code is at least fundamentally the same as what we took from there
originally.

Jan


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 14/15] xen/decompress: drop STATIC and INIT
  2021-04-15 14:32     ` Jan Beulich
@ 2021-04-15 14:45       ` Julien Grall
  0 siblings, 0 replies; 49+ messages in thread
From: Julien Grall @ 2021-04-15 14:45 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel



On 15/04/2021 15:32, Jan Beulich wrote:
> On 15.04.2021 16:21, Julien Grall wrote:
>> On 26/01/2021 09:53, Jan Beulich wrote:
>>> All users have been removed in earlier changes.
>>
>> This is not entirely correct given there is a still a user of...
>>
>>>
>>> Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>> ---
>>> v3: New.
>>>
>>> --- a/xen/arch/arm/efi/efi-dom0.c
>>> +++ b/xen/arch/arm/efi/efi-dom0.c
>>> @@ -28,7 +28,7 @@
>>>    #include <asm/setup.h>
>>>    #include <asm/acpi.h>
>>>    #include "../../../common/decompress.h"
>>> -#define XZ_EXTERN STATIC
>>> +#define XZ_EXTERN static
>>
>> STATIC here. So maybe you want to say "all but one users"?
> 
> Sigh. Of course I re-word this. But does it really matter? 

Just consistency between the diff and the commit message.

> The
> more that the thing here is more of an abuse than a proper use
> anyway? I didn't create this hackery ... In fact this odd use
> is why I made this a separate patch in the first place.
>> Also, for consistency, I think you want to either remove INITDATA here
>> or remove INIT in the patch that drop the last user.
> 
> See my other reply - what matters, I think, is a consistent
> end result. I would really like to ask that I be left with some
> room on how precisely to get there.

I thought I would point out because we often request to shuffle code to 
make a series more logical.

This is not a must to me. The code is fine it is.

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 13/15] unzstd: replace INIT{,DATA} and STATIC
  2021-04-15 14:34             ` Jan Beulich
@ 2021-04-15 14:47               ` Julien Grall
  0 siblings, 0 replies; 49+ messages in thread
From: Julien Grall @ 2021-04-15 14:47 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel

Hi Jan,

On 15/04/2021 15:34, Jan Beulich wrote:
> On 15.04.2021 16:30, Julien Grall wrote:
>> On 15/04/2021 15:25, Jan Beulich wrote:
>>> On 15.04.2021 16:22, Julien Grall wrote:
>>>> On 15/04/2021 15:21, Jan Beulich wrote:
>>>>> On 15.04.2021 13:59, Julien Grall wrote:
>>>>>> On 26/01/2021 09:52, Jan Beulich wrote:
>>>>>>> With xen/common/decompress.h now agreeing in both build modes about
>>>>>>> what STATIC expands to, there's no need for this abstraction anymore.
>>>>>>
>>>>>> Shouldn't you also mention "INIT" and "INITDATA" here?
>>>>>
>>>>> Two parts: INITDATA was mistakenly mentioned in the title. I've
>>>>> dropped that.
>>>>
>>>> Ok.
>>>>
>>>> And what I'm saying about STATIC does not apply to
>>>>> INIT - for it, we replace the extra level of abstraction by
>>>>> directly using __init, just like was done in the earlier patches.
>>>>
>>>> This should be mention in the commit message.
>>>
>>> It already is by what is being said after the comma. May I direct
>>> you back to the commit messages of earlier patches in this series
>>> (when talk was of just INIT)?
>>   From the way the commit message is written it sounds like more you are
>> referring to STATIC only. This is a clearer on the other commit messages
>> because there is no other way to interpret "this".
> 
> If the commit message is taken together with the title, I think
> all is clear.

I have to admit, I view the commit title as a one line summary. So I 
often read them separately.

> 
>> So I would suggest to clarify it.
> 
> And I would like to avoid doing so. As a compromise, I'll change
> "this abstraction" to "these abstractions".

Sounds good to me.

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC
  2021-04-15 14:28             ` Jan Beulich
@ 2021-04-15 14:55               ` Julien Grall
  0 siblings, 0 replies; 49+ messages in thread
From: Julien Grall @ 2021-04-15 14:55 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Andrew Cooper, George Dunlap, Ian Jackson, Stefano Stabellini,
	Wei Liu, xen-devel



On 15/04/2021 15:28, Jan Beulich wrote:
> On 15.04.2021 16:24, Julien Grall wrote:
>>
>>
>> On 15/04/2021 15:22, Jan Beulich wrote:
>>> On 15.04.2021 16:18, Julien Grall wrote:
>>>>
>>>>
>>>> On 15/04/2021 15:16, Jan Beulich wrote:
>>>>> On 15.04.2021 13:58, Julien Grall wrote:
>>>>>> On 26/01/2021 09:52, Jan Beulich wrote:
>>>>>>> --- 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
>>>>>>
>>>>>> Shouldn't the two changes be part of patch #14?
>>>>>
>>>>> One could do it that way, sure, but the last uses are gone here,
>>>>> and hence I wanted to get rid of this one item right away.
>>>>
>>>> AFAICT, the same is true for STATIC and INIT. So it doesn't sense to not
>>>> be consistent in the way you treat them.
>>>
>>> No, further uses of STATIC and INIT get dropped by later patches.
>>
>> I think you misundertood my comment. What I meant is you drop INIT in
>> patch #14 when the last caller was dropped in a previous patch.
> 
> Now this and some other of your comments are getting really nitpicky.

You misundertood my question, so I was clarifying what I meant.

> The end result is the same. I can certainly move removals around
> further, but I think I ought to have some leeway on how exactly I
> achieve an identical end result. Things would be different, I agree,
> if the end result was not suitably consistent.

As I mentionned in patch #14, this is not very different from requesting 
to reshuffle the code. I find a bit surprising you are complaining about 
this...

I guess I could have add NIT in front to make clearer this was only a 
suggestion.

 From your answer, I am assuming this is a no which is fair:

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

-- 
Julien Grall


^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2021-04-15 14:56 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26  9:46 [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Jan Beulich
2021-01-26  9:48 ` [PATCH v3 01/15] libxenguest: add get_unaligned_le32() Jan Beulich
2021-01-26 11:51   ` Ian Jackson
2021-01-26  9:49 ` [PATCH v3 02/15] libxenguest: support zstd compressed kernels Jan Beulich
2021-01-26 11:53   ` Ian Jackson
2021-01-26  9:49 ` [PATCH v3 03/15] xen/decompress: make helper symbols static Jan Beulich
2021-01-26  9:49 ` [PATCH v3 04/15] libxenguest: "standardize" LZO kernel decompression code Jan Beulich
2021-01-26  9:50 ` [PATCH v3 05/15] libxenguest: drop redundant decompression declarations Jan Beulich
2021-01-26  9:50 ` [PATCH v3 06/15] libxenguest: simplify kernel decompression Jan Beulich
2021-01-26  9:50 ` [PATCH v3 01/15] gunzip: drop INIT{,DATA} and STATIC Jan Beulich
2021-01-26  9:54   ` Jan Beulich
2021-01-26 11:56   ` Ian Jackson
2021-01-26 12:49     ` Jan Beulich
2021-01-26  9:51 ` [PATCH v3 08/15] bunzip: replace INIT Jan Beulich
2021-04-15 11:50   ` Julien Grall
2021-01-26  9:51 ` [PATCH v3 09/15] unlzo: " Jan Beulich
2021-04-15 11:51   ` Julien Grall
2021-01-26  9:51 ` [PATCH v3 10/15] unlzma: " Jan Beulich
2021-04-15 11:52   ` Julien Grall
2021-01-26  9:52 ` [PATCH v3 11/15] unlz4: " Jan Beulich
2021-04-15 11:56   ` Julien Grall
2021-01-26  9:52 ` [PATCH v3 12/15] unxz: replace INIT{,DATA} and STATIC Jan Beulich
2021-04-15 11:58   ` Julien Grall
2021-04-15 14:16     ` Jan Beulich
2021-04-15 14:18       ` Julien Grall
2021-04-15 14:22         ` Jan Beulich
2021-04-15 14:24           ` Julien Grall
2021-04-15 14:28             ` Jan Beulich
2021-04-15 14:55               ` Julien Grall
2021-01-26  9:52 ` [PATCH v3 13/15] unzstd: " Jan Beulich
2021-04-15 11:59   ` Julien Grall
2021-04-15 14:21     ` Jan Beulich
2021-04-15 14:22       ` Julien Grall
2021-04-15 14:25         ` Jan Beulich
2021-04-15 14:30           ` Julien Grall
2021-04-15 14:34             ` Jan Beulich
2021-04-15 14:47               ` Julien Grall
2021-01-26  9:53 ` [PATCH v3 14/15] xen/decompress: drop STATIC and INIT Jan Beulich
2021-04-15 14:21   ` Julien Grall
2021-04-15 14:32     ` Jan Beulich
2021-04-15 14:45       ` Julien Grall
2021-01-26  9:53 ` [PATCH v3 15/15] unzstd: make helper symbols static Jan Beulich
2021-04-15 12:09   ` Julien Grall
2021-04-15 14:37     ` Jan Beulich
2021-01-26 12:05 ` [PATCH v3 00/15] zstd decompression for DomU-s + fallout / consolidation Ian Jackson
2021-01-26 13:04   ` Jan Beulich
2021-01-26 13:25     ` Ian Jackson
2021-01-26 13:50       ` Jan Beulich
2021-04-15  9:20 ` Ping: " Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).