Changes to the ABI of the communication region might break inmates
without noticing. Add the magic JHCOMM together with the ABI version as
a preamble of the structure.

Signed-off-by: Ralf Ramsauer <[email protected]>
---
 hypervisor/control.c          | 7 ++++++-
 include/jailhouse/hypercall.h | 7 +++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/hypervisor/control.c b/hypervisor/control.c
index 5cf96c95..df054cfb 100644
--- a/hypervisor/control.c
+++ b/hypervisor/control.c
@@ -341,6 +341,7 @@ static int cell_create(struct per_cpu *cpu_data, unsigned 
long config_address)
 {
        unsigned long cfg_page_offs = config_address & ~PAGE_MASK;
        unsigned int cfg_pages, cell_pages, cpu, n;
+       struct jailhouse_comm_region *comm_region;
        const struct jailhouse_memory *mem;
        struct jailhouse_cell_desc *cfg;
        unsigned long cfg_total_size;
@@ -475,7 +476,11 @@ static int cell_create(struct per_cpu *cpu_data, unsigned 
long config_address)
 
        config_commit(cell);
 
-       cell->comm_page.comm_region.cell_state = JAILHOUSE_CELL_SHUT_DOWN;
+       comm_region = &cell->comm_page.comm_region;
+       memcpy(comm_region->signature, COMM_REGION_MAGIC,
+              sizeof(comm_region->signature));
+       comm_region->revision = COMM_REGION_ABI_REVISION;
+       comm_region->cell_state = JAILHOUSE_CELL_SHUT_DOWN;
 
        last = &root_cell;
        while (last->next)
diff --git a/include/jailhouse/hypercall.h b/include/jailhouse/hypercall.h
index 08bf73ff..6142b042 100644
--- a/include/jailhouse/hypercall.h
+++ b/include/jailhouse/hypercall.h
@@ -89,7 +89,14 @@
 #define JAILHOUSE_CELL_SHUT_DOWN               2 /* terminal state */
 #define JAILHOUSE_CELL_FAILED                  3 /* terminal state */
 
+#define COMM_REGION_ABI_REVISION               0
+#define COMM_REGION_MAGIC                      "JHCOMM"
+
 #define COMM_REGION_GENERIC_HEADER                                     \
+       /** Communication region magic JHCOMM */                        \
+       char signature[6];                                              \
+       /** Communication region ABI revision */                        \
+       __u16 revision;                                                 \
        /** Message code sent from hypervisor to cell. */               \
        volatile __u32 msg_to_cell;                                     \
        /** Reply code sent from cell to hypervisor. */                 \
-- 
2.17.0

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to