aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_dom_decompress_unsafe_lzo1x.c
diff options
context:
space:
mode:
authorBastian Blank <bastian@waldi.eu.org>2013-04-18 12:49:54 +0100
committerIan Campbell <ian.campbell@citrix.com>2013-04-22 12:46:30 +0100
commit592d3ef961cafda917a7f123999dc04d426254ee (patch)
tree98f82705cbb7348589b2c2630f069dc25e05ed5b /tools/libxc/xc_dom_decompress_unsafe_lzo1x.c
parent071c61e7367987a9f71dc18c3c58a5dba659a5c8 (diff)
downloadxen-592d3ef961cafda917a7f123999dc04d426254ee.tar.gz
xen-592d3ef961cafda917a7f123999dc04d426254ee.tar.bz2
xen-592d3ef961cafda917a7f123999dc04d426254ee.zip
libxc: Add unsafe decompressors
Add decompressors based on hypervisor code. This are used in mini-os by pv-grub. This enables pv-grub to boot kernels compressed with e.g. xz, which are becoming more common. Signed-off-by: Bastian Blank <waldi@debian.org> Adjusted to use terminology "unsafe" rather than "trusted" to indicate that the user had better sanitise the data (or not care, as in stub domains) as suggested by Tim Deegan. This was effectively a sed script. Minimise the changes to hypervisor code by moving the "compat layer" into the relevant libxc source files (which include the Xen ones). Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Diffstat (limited to 'tools/libxc/xc_dom_decompress_unsafe_lzo1x.c')
-rw-r--r--tools/libxc/xc_dom_decompress_unsafe_lzo1x.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/libxc/xc_dom_decompress_unsafe_lzo1x.c b/tools/libxc/xc_dom_decompress_unsafe_lzo1x.c
new file mode 100644
index 0000000000..57c73e30c1
--- /dev/null
+++ b/tools/libxc/xc_dom_decompress_unsafe_lzo1x.c
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <endian.h>
+#include <stdint.h>
+
+#include "xg_private.h"
+#include "xc_dom_decompress_unsafe.h"
+
+typedef uint8_t u8;
+typedef uint32_t u32;
+typedef uint16_t u16;
+
+#define likely(a) a
+#define noinline
+#define unlikely(a) a
+
+static inline u16 be16_to_cpup(const u16 *p)
+{
+ u16 v = *p;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ return (((v & 0x00ffU) << 8) |
+ ((v & 0xff00U) >> 8));
+#else
+ return v;
+#endif
+}
+
+static inline u32 be32_to_cpup(const u32 *p)
+{
+ u32 v = *p;
+#if BYTE_ORDER == LITTLE_ENDIAN
+ return (((v & 0x000000ffUL) << 24) |
+ ((v & 0x0000ff00UL) << 8) |
+ ((v & 0x00ff0000UL) >> 8) |
+ ((v & 0xff000000UL) >> 24));
+#else
+ return v;
+#endif
+}
+
+#include "../../xen/common/lzo.c"
+#include "../../xen/common/unlzo.c"
+
+int xc_try_lzo1x_decode(
+ struct xc_dom_image *dom, void **blob, size_t *size)
+{
+ return xc_dom_decompress_unsafe(unlzo, dom, blob, size);
+}