All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Ian Jackson <iwj@xenproject.org>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>
Subject: [PATCH v3 01/15] libxenguest: add get_unaligned_le32()
Date: Tue, 26 Jan 2021 10:48:37 +0100	[thread overview]
Message-ID: <a6cafbb2-9a85-e83a-7954-de5f8962c9a6@suse.com> (raw)
In-Reply-To: <2db91183-a7de-0c43-2fef-feb3523ed19b@suse.com>

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
 
 /*



  reply	other threads:[~2021-01-26  9:48 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-01-26 11:51   ` [PATCH v3 01/15] libxenguest: add get_unaligned_le32() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a6cafbb2-9a85-e83a-7954-de5f8962c9a6@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.