[PATCH] core, driver: Pass rounded-up core size in hypervisor header

3 views
Skip to first unread message

Jan Kiszka

unread,
Jan 25, 2016, 12:24:59 PM1/25/16
to Jailhouse, Antonios Motakis
Hypervisor and root kernel may have different ideas about PAGE_SIZE.
This will cause wrong hypervisor core size calculations as seen on arm64
with 64K Linux PAGE_SIZE.

Avoid this trap by moving the round-up into the hypervisor code, passing
a ready-to-be-used size value in the header.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
driver/main.c | 2 +-
hypervisor/hypervisor.lds.S | 1 -
hypervisor/include/jailhouse/header.h | 2 +-
hypervisor/setup.c | 4 ++--
4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/driver/main.c b/driver/main.c
index 9bb3d5e..60b67bd 100644
--- a/driver/main.c
+++ b/driver/main.c
@@ -228,7 +228,7 @@ static int jailhouse_cmd_enable(struct jailhouse_system __user *arg)
hypervisor->size >= hv_mem->size)
goto error_release_fw;

- hv_core_and_percpu_size = PAGE_ALIGN(header->core_size) +
+ hv_core_and_percpu_size = header->core_size +
max_cpus * header->percpu_size;
config_size = jailhouse_system_config_size(&config_header);
if (hv_core_and_percpu_size >= hv_mem->size ||
diff --git a/hypervisor/hypervisor.lds.S b/hypervisor/hypervisor.lds.S
index e5b1551..09b1a0b 100644
--- a/hypervisor/hypervisor.lds.S
+++ b/hypervisor/hypervisor.lds.S
@@ -34,7 +34,6 @@ SECTIONS

. = ALIGN(16);
.bss : { *(.bss) }
- __hv_core_end = .;

. = ALIGN(PAGE_SIZE);
__page_pool = .;
diff --git a/hypervisor/include/jailhouse/header.h b/hypervisor/include/jailhouse/header.h
index db87b60..4a4d1cb 100644
--- a/hypervisor/include/jailhouse/header.h
+++ b/hypervisor/include/jailhouse/header.h
@@ -29,7 +29,7 @@ struct jailhouse_header {
/** Signature "JAILHOUS".
* @note Filled at build time. */
char signature[8];
- /** Size of hypervisor core.
+ /** Size of hypervisor core, rounded up to page boundary.
* @note Filled at build time. */
unsigned long core_size;
/** Size of per-CPU data structure.
diff --git a/hypervisor/setup.c b/hypervisor/setup.c
index 14a98d3..79f5696 100644
--- a/hypervisor/setup.c
+++ b/hypervisor/setup.c
@@ -20,7 +20,7 @@
#include <generated/version.h>
#include <asm/spinlock.h>

-extern u8 __text_start[], __hv_core_end[];
+extern u8 __text_start[], __page_pool[];

static const __attribute__((aligned(PAGE_SIZE))) u8 empty_page[PAGE_SIZE];

@@ -202,7 +202,7 @@ int entry(unsigned int cpu_id, struct per_cpu *cpu_data)
struct jailhouse_header __attribute__((section(".header")))
hypervisor_header = {
.signature = JAILHOUSE_SIGNATURE,
- .core_size = (unsigned long)__hv_core_end - JAILHOUSE_BASE,
+ .core_size = (unsigned long)__page_pool - JAILHOUSE_BASE,
.percpu_size = sizeof(struct per_cpu),
.entry = arch_entry,
};
--
2.1.4

Antonios Motakis

unread,
Jan 26, 2016, 3:53:48 AM1/26/16
to Jan Kiszka, Jailhouse
I forgot to mention, that 64K page size would break things horribly, but I guess that's not an issue anymore :)

Dankon!
Antonios Motakis
Virtualization Engineer
Huawei Technologies Duesseldorf GmbH
European Research Center
Riesstrasse 25, 80992 München

Reply all
Reply to author
Forward
0 new messages