[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] libxenguest: add get_unaligned_le32()
commit d8099d94dfaa3573bd86ebfc457cbc8f70a3ecda Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Tue Jan 26 14:14:39 2021 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Tue Jan 26 14:14:39 2021 +0100 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. Requested-by: Ian Jackson <iwj@xxxxxxxxxxxxxx> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Release-Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> --- tools/libs/guest/xg_dom_core.c | 5 ++--- tools/libs/guest/xg_dom_decompress_lz4.c | 1 + tools/libs/guest/xg_private.h | 9 +++++++++ xen/common/lz4/defs.h | 5 ----- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/libs/guest/xg_dom_core.c b/tools/libs/guest/xg_dom_core.c index f846d8e1ed..98ef8e8fc9 100644 --- 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_dom_image *dom, size_t sz) 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 *xch, void *blob, size_t ziplen) /* 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 diff --git a/tools/libs/guest/xg_dom_decompress_lz4.c b/tools/libs/guest/xg_dom_decompress_lz4.c index 97ba620d86..34a1a13d84 100644 --- 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" diff --git a/tools/libs/guest/xg_private.h b/tools/libs/guest/xg_private.h index c3ed8c1257..8f9b257a2f 100644 --- a/tools/libs/guest/xg_private.h +++ b/tools/libs/guest/xg_private.h @@ -62,6 +62,15 @@ char *xc_inflate_buffer(xc_interface *xch, 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 diff --git a/xen/common/lz4/defs.h b/xen/common/lz4/defs.h index 4fbea2ac3d..10609f5a53 100644 --- a/xen/common/lz4/defs.h +++ b/xen/common/lz4/defs.h @@ -18,11 +18,6 @@ static inline u16 get_unaligned_le16(const void *p) return le16_to_cpup(p); } -static inline u32 get_unaligned_le32(const void *p) -{ - return le32_to_cpup(p); -} - #endif /* -- generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |