]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
hypervisor, driver: Added signature for .cell files
authorRalf Ramsauer <ralf@ramses-pyramidenbau.de>
Thu, 13 Aug 2015 23:23:58 +0000 (01:23 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Wed, 16 Sep 2015 06:24:50 +0000 (08:24 +0200)
Inserted signature field in struct jailhouse_cell_desc and
jailhouse_system. Jailhouse kernel driver will refuse loading
a system configuration as a cell configuration et vice versa.

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
[Jan: also adjust Linux loader script]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
26 files changed:
configs/apic-demo.c
configs/bananapi-gic-demo.c
configs/bananapi-uart-demo.c
configs/bananapi.c
configs/e1000-demo.c
configs/f2a88xm-hd3.c
configs/h87i.c
configs/imb-a180.c
configs/ioapic-demo.c
configs/ivshmem-demo.c
configs/jetson-tk1-demo.c
configs/jetson-tk1.c
configs/linux-x86-demo.c
configs/pci-demo.c
configs/qemu-vm.c
configs/smp-demo.c
configs/tiny-demo.c
configs/vexpress-gic-demo.c
configs/vexpress-linux-demo.c
configs/vexpress-uart-demo.c
configs/vexpress.c
driver/cell.c
driver/main.c
hypervisor/include/jailhouse/cell-config.h
tools/jailhouse-cell-linux
tools/root-cell-config.c.tmpl

index 046a7826cc50f6e9cadacdc1a9433e586bf11072..1351496e7659373ce6a9a19489d1ba2559a57fd2 100644 (file)
@@ -24,6 +24,7 @@ struct {
        __u8 pio_bitmap[0x2000];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "apic-demo",
 
                .cpu_set_size = sizeof(config.cpus),
index f34a2a41475e5e59e67d74ec7d4cb2203b6ea894..2d633fabaeaae0bc797f6044656b8c240cbfe609 100644 (file)
@@ -24,6 +24,7 @@ struct {
        struct jailhouse_memory mem_regions[3];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "bananapi-gic-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 3934d671aa1a75893198ccb8be8289a0864238da..87ed8d224124f6e77d5752d5a6897daedaee8d23 100644 (file)
@@ -24,6 +24,7 @@ struct {
        struct jailhouse_memory mem_regions[3];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "bananapi-uart-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index edc6477531e1b9f4d60922e041430185756004e9..03cb5f74b879c9fcc529efbd1a3ead17eb612633 100644 (file)
@@ -24,6 +24,7 @@ struct {
        struct jailhouse_irqchip irqchips[1];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = 0x7c000000,
                        .size = 0x4000000,
index 11b87cf32348bf7fb4f350765d508ee0d55781b7..088d92ac9ddce9d1e9ee49006d80992292d2cf92 100644 (file)
@@ -27,6 +27,7 @@ struct {
        struct jailhouse_pci_capability pci_caps[1];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "e1000-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 2736496c258d22c217b1222c306da5d95095a7db..16f0aa0651f1261db70384991e290f9e8a225cdd 100644 (file)
@@ -32,6 +32,7 @@ struct {
        struct jailhouse_pci_capability pci_caps[27];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = 0x3b000000,
                        .size = 0x4000000,
index c5473ac1e56501b52b95220bb48d32bc91768c31..9b36702fe22065a783b1fc7b6941c46de0077300 100644 (file)
@@ -27,6 +27,7 @@ struct {
        struct jailhouse_pci_capability pci_caps[28];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = 0x3b000000,
                        .size = 0x4000000,
index e74cbe8dedb15389ed472acfff7bbcbd79aaf098..ffcd5c782a64d1158c2dbf6186fc72b91e95714f 100644 (file)
@@ -31,6 +31,7 @@ struct {
        struct jailhouse_pci_capability pci_caps[26];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = 0x3b000000,
                        .size = 0x4000000,
index aec1a214fdc2bc4cb5b890eed08b079b82d6c373..fa450d27d16aec63a5d469bf8d48cd769c842ae8 100644 (file)
@@ -26,6 +26,7 @@ struct {
        __u8 pio_bitmap[0x2000];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "ioapic-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 591d9eab43c16080f8e36eebe70df30d38e1a1d5..ac426d48ba2c308bbf54a0ad2139c6f33047acba 100644 (file)
@@ -24,6 +24,7 @@ struct {
        struct jailhouse_pci_capability pci_caps[0];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "ivshmem-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 02c924d5a6866c505427ada6d2718b72b6297a8b..5bf465a5dc9253903ca88b5f50ad94d0d1125ad5 100644 (file)
@@ -24,6 +24,7 @@ struct {
        struct jailhouse_memory mem_regions[2];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "jetson-tk1-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index b3c69efc908ee177ee0c378ffb4890196d47a6dc..746c95624e142e56424345d2bf1c94ee1eebaac0 100644 (file)
@@ -27,6 +27,7 @@ struct {
        struct jailhouse_irqchip irqchips[1];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = 0xfc000000,
                        .size = 0x4000000 - 0x100000, /* -1MB (PSCI) */
index ffb7765693524fd69cea43f8e4d8911c8b6b7ccb..539104f9d4f96efe9042fb21812a4e092cb4514a 100644 (file)
@@ -25,6 +25,7 @@ struct {
        struct jailhouse_pci_device pci_devices[1];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "linux-x86-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 9449aac1fbf376cf3f0a4d7fcedc7ed371664ec3..85fd5b2f0c099019d6361d3dc001513b938dea25 100644 (file)
@@ -27,6 +27,7 @@ struct {
        struct jailhouse_pci_capability pci_caps[1];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "pci-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 637b9c6673d23797c24cde7e6837c3c11c286f8c..f95b1f64ff650ec2585bd3c8e27ec1a3c8d46c59 100644 (file)
@@ -41,6 +41,7 @@ struct {
        struct jailhouse_pci_capability pci_caps[5];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = 0x3b000000,
                        .size = 0x600000,
index 86494662f08eea142750586919410c18caa8b0a4..1bbf65975c4da5d297997784392302c51888057d 100644 (file)
@@ -24,6 +24,7 @@ struct {
        __u8 pio_bitmap[0x2000];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "smp-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 355a330c8fa417dfaff27915175ec46d0c19f93a..b3f612b555515c048d8784e3c2140fbdbbd3a5a0 100644 (file)
@@ -24,6 +24,7 @@ struct {
        __u8 pio_bitmap[0x2000];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "tiny-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 44512d44f72876d6f79d0b0a924392bac45d5b2a..cac296ac1b7a9f6acb3e4d19e226df63e6dd007f 100644 (file)
@@ -21,6 +21,7 @@ struct {
        struct jailhouse_memory mem_regions[2];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "gic-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 5a3d7b5fc28451adb7f5c767d3bb3470158fed79..85a9fcbc417f246b96cf64aa2676fd57bf68f491 100644 (file)
@@ -22,6 +22,7 @@ struct {
        struct jailhouse_irqchip irqchips[1];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "linux-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index 524a08ee8fe505493b4efb1503e753ba653ef110..0054c626a39eaf7e820e67ea2231e05b98202316 100644 (file)
@@ -21,6 +21,7 @@ struct {
        struct jailhouse_memory mem_regions[2];
 } __attribute__((packed)) config = {
        .cell = {
+               .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
                .name = "pl011-demo",
                .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
 
index eb273455feaf671c18ced74692546f1468c8f6ef..0f736add3586cdf1ba1f63ca55381fe00b52df83 100644 (file)
@@ -22,6 +22,7 @@ struct {
        struct jailhouse_irqchip irqchips[1];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = 0xfc000000,
                        .size = 0x4000000,
index e28a96c8fb9212a8c0550d8e118377817aaf92d1..dc1b3c8a1e5584fffafc04c852f17a39fd8ab3ca 100644 (file)
@@ -175,6 +175,14 @@ int jailhouse_cmd_cell_create(struct jailhouse_cell_create __user *arg)
                err = -EFAULT;
                goto kfree_config_out;
        }
+
+       if (memcmp(config->signature, JAILHOUSE_CELL_DESC_SIGNATURE,
+                  sizeof(config->signature)) != 0) {
+               pr_err("jailhouse: Not a cell configuration\n");
+               err = -EINVAL;
+               goto kfree_config_out;
+       }
+
        config->name[JAILHOUSE_CELL_NAME_MAXLEN] = 0;
 
        if (mutex_lock_interruptible(&jailhouse_lock) != 0) {
index a76deb95856543959e8a8c1cd523434affb53bda..92b985a60d1cb25857139e91e5e306c6574ab9bd 100644 (file)
@@ -192,6 +192,13 @@ static int jailhouse_cmd_enable(struct jailhouse_system __user *arg)
 
        if (copy_from_user(&config_header, arg, sizeof(config_header)))
                return -EFAULT;
+
+       if (memcmp(config_header.signature, JAILHOUSE_SYSTEM_SIGNATURE,
+                  sizeof(config_header.signature)) != 0) {
+               pr_err("jailhouse: Not a system configuration\n");
+               return -EINVAL;
+       }
+
        config_header.root_cell.name[JAILHOUSE_CELL_NAME_MAXLEN] = 0;
 
        max_cpus = get_max_cpus(config_header.root_cell.cpu_set_size, arg);
index 261d9c74b29a1c19c0bad5d1388f28bc6c876e0e..ef9de707af05e8f1f852c24548b3d06b6380f1c1 100644 (file)
 
 #define JAILHOUSE_CELL_PASSIVE_COMMREG 0x00000001
 
+#define JAILHOUSE_CELL_DESC_SIGNATURE  "JAILCELL"
+
 struct jailhouse_cell_desc {
+       char signature[8];
        char name[JAILHOUSE_CELL_NAME_MAXLEN+1];
        __u32 flags;
 
@@ -118,7 +121,10 @@ struct jailhouse_pci_capability {
 
 #define JAILHOUSE_MAX_IOMMU_UNITS      8
 
+#define JAILHOUSE_SYSTEM_SIGNATURE     "JAILSYST"
+
 struct jailhouse_system {
+       char signature[8];
        struct jailhouse_memory hypervisor_memory;
        struct jailhouse_memory debug_uart;
        union {
index 4a125f17d730c12efe7be549dccfac54232cba46..0d83e4bec26ece18a42c8f8d22fe3b0354f00453 100755 (executable)
@@ -69,7 +69,7 @@ class MemoryRegion:
 
 
 class Config:
-    _HEADER_FORMAT = '32sIIIIIII'
+    _HEADER_FORMAT = '8x32sIIIIIII'
 
     def __init__(self, config_file):
         self.data = config_file.read()
index fdf8f8b6bfb1f0afe2f0fb95dac9a69cf6029500..04b4ecb56f533929412685fadd671f2f2c5a8d5e 100644 (file)
@@ -54,6 +54,7 @@ struct {
        struct jailhouse_pci_capability pci_caps[${len(pcicaps)}];
 } __attribute__((packed)) config = {
        .header = {
+               .signature = JAILHOUSE_SYSTEM_SIGNATURE,
                .hypervisor_memory = {
                        .phys_start = ${hex(hvmem[0])},
                        .size = ${hex(hvmem[1])},