From 1fad37949d9352fc0e04033f729d645734136f86 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Thu, 28 Aug 2014 13:36:18 +0200 Subject: [PATCH] tools: Remove dependency of jailhouse tool on cell-config.h Two things caused jailhouse.h and, thus, tools/jailhouse.c to depend on the cell configuration header: the definition of the JAILHOUSE_ENABLE IOCTL and the maximum cell name length in config files. The first dependency is not only unneeded (the command line tool passed the an uninterpreted blob via JAILHOUSE_ENABLE), it also made the driver ABI change each time we updated the config format. So replace the reference to struct jailhouse_system in JAILHOUSE_ENABLE with a symbolic "void *". The second dependency is also unneeded: While the name length used in configs and, thus, also inside the driver to reference cells should be identical to the lengths we use in struct jailhouse_cell_id, there is no hard dependency. In the worst case (different lengths), we would fail to address cells by name. However, these lengths are unlikely to change. So simply define our own name length for that struct and test for deviations during the driver build. Signed-off-by: Jan Kiszka --- driver.c | 7 ++++++- jailhouse.h | 7 ++++--- tools/Makefile | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/driver.c b/driver.c index f0e68a1..a7e91de 100644 --- a/driver.c +++ b/driver.c @@ -28,6 +28,7 @@ #include #include "jailhouse.h" +#include #include #include @@ -35,6 +36,10 @@ #error 64-bit kernel required! #endif +#if JAILHOUSE_CELL_ID_NAMELEN != JAILHOUSE_CELL_NAME_MAXLEN +# warning JAILHOUSE_CELL_ID_NAMELEN and JAILHOUSE_CELL_NAME_MAXLEN out of sync! +#endif + /* For compatibility with older kernel versions */ #include @@ -656,7 +661,7 @@ error_cell_delete: static int cell_management_prologue(struct jailhouse_cell_id *cell_id, struct cell **cell_ptr) { - cell_id->name[JAILHOUSE_CELL_NAME_MAXLEN] = 0; + cell_id->name[JAILHOUSE_CELL_ID_NAMELEN] = 0; if (mutex_lock_interruptible(&lock) != 0) return -EINTR; diff --git a/jailhouse.h b/jailhouse.h index c6bf15f..9a776ae 100644 --- a/jailhouse.h +++ b/jailhouse.h @@ -12,7 +12,8 @@ #include #include -#include + +#define JAILHOUSE_CELL_ID_NAMELEN 31 struct jailhouse_cell_create { __u64 config_address; @@ -30,7 +31,7 @@ struct jailhouse_preload_image { struct jailhouse_cell_id { __s32 id; __u32 padding; - char name[JAILHOUSE_CELL_NAME_MAXLEN+1]; + char name[JAILHOUSE_CELL_ID_NAMELEN + 1]; }; struct jailhouse_cell_load { @@ -42,7 +43,7 @@ struct jailhouse_cell_load { #define JAILHOUSE_CELL_ID_UNUSED (-1) -#define JAILHOUSE_ENABLE _IOW(0, 0, struct jailhouse_system) +#define JAILHOUSE_ENABLE _IOW(0, 0, void *) #define JAILHOUSE_DISABLE _IO(0, 1) #define JAILHOUSE_CELL_CREATE _IOW(0, 2, struct jailhouse_cell_create) #define JAILHOUSE_CELL_LOAD _IOW(0, 3, struct jailhouse_cell_load) diff --git a/tools/Makefile b/tools/Makefile index 9d24a9d..13fc671 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -30,7 +30,7 @@ INSTALL_DIR ?= $(INSTALL) -d -m 755 CC = $(CROSS_COMPILE)gcc -CFLAGS = -g -O3 -I.. -I../hypervisor/include -DLIBEXECDIR=\"$(libexecdir)\" \ +CFLAGS = -g -O3 -I.. -DLIBEXECDIR=\"$(libexecdir)\" \ -Wall -Wmissing-declarations -Wmissing-prototypes TARGETS := jailhouse @@ -59,7 +59,7 @@ endef all: $(TARGETS) -jailhouse: jailhouse.c ../jailhouse.h ../hypervisor/include/jailhouse/cell-config.h +jailhouse: jailhouse.c ../jailhouse.h $(CC) $(CFLAGS) -o $@ $< jailhouse-config-collect: jailhouse-config-create jailhouse-config-collect.tmpl -- 2.39.2