From: Antonios Motakis <[email protected]> This is a straightforward port of the inmate demos from AArch32 to AArch64. These can now be loaded as cells onto a Foundation ARMv8 model.
Signed-off-by: Antonios Motakis <[email protected]> --- inmates/Makefile | 4 ++ inmates/demos/arm64/Makefile | 20 +++++++ inmates/lib/arm64/Makefile | 21 +++++++ inmates/lib/arm64/Makefile.lib | 46 +++++++++++++++ inmates/lib/arm64/header.S | 66 ++++++++++++++++++++++ inmates/lib/arm64/include/gic.h | 30 ++++++++++ inmates/lib/arm64/include/inmate.h | 66 ++++++++++++++++++++++ .../arm64/include/mach-amd-seattle/mach/gic_v2.h | 14 +++++ .../arm64/include/mach-amd-seattle/mach/timer.h | 13 +++++ .../lib/arm64/include/mach-amd-seattle/mach/uart.h | 13 +++++ .../arm64/include/mach-foundation-v8/mach/gic_v2.h | 14 +++++ .../arm64/include/mach-foundation-v8/mach/timer.h | 13 +++++ .../arm64/include/mach-foundation-v8/mach/uart.h | 13 +++++ inmates/lib/arm64/inmate.lds | 46 +++++++++++++++ 14 files changed, 379 insertions(+) create mode 100644 inmates/lib/arm64/Makefile.lib create mode 100644 inmates/lib/arm64/header.S create mode 100644 inmates/lib/arm64/include/gic.h create mode 100644 inmates/lib/arm64/include/inmate.h create mode 100644 inmates/lib/arm64/include/mach-amd-seattle/mach/gic_v2.h create mode 100644 inmates/lib/arm64/include/mach-amd-seattle/mach/timer.h create mode 100644 inmates/lib/arm64/include/mach-amd-seattle/mach/uart.h create mode 100644 inmates/lib/arm64/include/mach-foundation-v8/mach/gic_v2.h create mode 100644 inmates/lib/arm64/include/mach-foundation-v8/mach/timer.h create mode 100644 inmates/lib/arm64/include/mach-foundation-v8/mach/uart.h create mode 100644 inmates/lib/arm64/inmate.lds diff --git a/inmates/Makefile b/inmates/Makefile index 0e8f258..c66cb2f 100644 --- a/inmates/Makefile +++ b/inmates/Makefile @@ -17,6 +17,10 @@ INCLUDES := -I$(INMATES_LIB) \ -I$(src)/../hypervisor/arch/$(SRCARCH)/include \ -I$(src)/../hypervisor/include +ifeq ($(SRCARCH),arm64) +INCLUDES += -I$(src)/../hypervisor/arch/arm/include +endif + LINUXINCLUDE := KBUILD_AFLAGS += $(INCLUDES) KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \ diff --git a/inmates/demos/arm64/Makefile b/inmates/demos/arm64/Makefile index e69de29..49abe09 100644 --- a/inmates/demos/arm64/Makefile +++ b/inmates/demos/arm64/Makefile @@ -0,0 +1,20 @@ +# +# Jailhouse AArch64 support +# +# Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH +# +# Authors: +# Antonios Motakis <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. +# + +include $(INMATES_LIB)/Makefile.lib + +INMATES := gic-demo.bin uart-demo.bin + +gic-demo-y := ../arm/gic-demo.o +uart-demo-y := ../arm/uart-demo.o + +$(eval $(call DECLARE_TARGETS,$(INMATES))) diff --git a/inmates/lib/arm64/Makefile b/inmates/lib/arm64/Makefile index e69de29..3661191 100644 --- a/inmates/lib/arm64/Makefile +++ b/inmates/lib/arm64/Makefile @@ -0,0 +1,21 @@ +# +# Jailhouse, a Linux-based partitioning hypervisor +# +# Copyright (c) Siemens AG, 2015 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. +# + +include $(INMATES_LIB)/Makefile.lib + +always := lib.a + +lib-y := header.o +lib-y += ../arm/gic.o ../arm/printk.o ../arm/timer.o +lib-y += ../string.o ../cmdline.o +lib-$(CONFIG_ARM_GIC) += ../arm/gic-v2.o +lib-$(CONFIG_SERIAL_AMBA_PL011) += ../arm/uart-pl011.o diff --git a/inmates/lib/arm64/Makefile.lib b/inmates/lib/arm64/Makefile.lib new file mode 100644 index 0000000..0196c51 --- /dev/null +++ b/inmates/lib/arm64/Makefile.lib @@ -0,0 +1,46 @@ +# +# Jailhouse, a Linux-based partitioning hypervisor +# +# Copyright (c) ARM Limited, 2014 +# Copyright (c) Siemens AG, 2014 +# +# Authors: +# Jean-Philippe Brucker <[email protected]> +# Jan Kiszka <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2. See +# the COPYING file in the top-level directory. +# + +-include $(obj)/../../../hypervisor/include/generated/config.mk + +KBUILD_AFLAGS := $(filter-out -include asm/unified.h,$(KBUILD_AFLAGS)) + +KBUILD_CFLAGS += -I$(INMATES_LIB)/include +KBUILD_AFLAGS += -I$(INMATES_LIB)/include + +define DECLARE_TARGETS = + _TARGETS = $(1) + always := $$(_TARGETS) + # $(NAME-y) NAME-linked.o NAME.bin + targets += $$(foreach t,$$(_TARGETS:.bin=-y),$$($$t)) \ + $$(_TARGETS:.bin=-linked.o) $$(_TARGETS) +endef + +mach-$(CONFIG_MACH_FOUNDATION_V8) := foundation-v8 +mach-$(CONFIG_MACH_AMD_SEATTLE) := amd-seattle + +MACHINE := mach-$(mach-y) +KBUILD_CFLAGS += -I$(INMATES_LIB)/include/$(MACHINE) +KBUILD_AFLAGS += -I$(INMATES_LIB)/include/$(MACHINE) + +# prevent deleting intermediate files which would cause rebuilds +.SECONDARY: $(addprefix $(obj)/,$(targets)) + +.SECONDEXPANSION: +$(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix $$(obj)/,$$($$*-y)) \ + $(INMATES_LIB)/lib.a + $(call if_changed,ld) + +$(obj)/%.bin: $(obj)/%-linked.o + $(call if_changed,objcopy) diff --git a/inmates/lib/arm64/header.S b/inmates/lib/arm64/header.S new file mode 100644 index 0000000..fe7bae7 --- /dev/null +++ b/inmates/lib/arm64/header.S @@ -0,0 +1,66 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +.macro ventry label + .align 7 + b \label +.endm + + .section ".boot", "ax" + .globl __reset_entry +__reset_entry: + ldr x0, =vectors + msr vbar_el1, x0 + + ldr x0, =stack_top + mov sp, x0 + + mov x0, #(3 << 20) + msr cpacr_el1, x0 + + msr daif, xzr + + isb + + b inmate_main + +handle_irq: + bl vector_irq + eret + +.weak vector_irq + b . + + .globl vectors + .align 11 +vectors: + ventry . + ventry . + ventry . + ventry . + + ventry . + ventry handle_irq + ventry . + ventry . + + ventry . + ventry handle_irq + ventry . + ventry . + + ventry . + ventry . + ventry . + ventry . + + .ltorg diff --git a/inmates/lib/arm64/include/gic.h b/inmates/lib/arm64/include/gic.h new file mode 100644 index 0000000..6e00643 --- /dev/null +++ b/inmates/lib/arm64/include/gic.h @@ -0,0 +1,30 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) ARM Limited, 2014 + * + * Authors: + * Jean-Philippe Brucker <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ +#ifndef _JAILHOUSE_INMATES_GIC_H +#define _JAILHOUSE_INMATES_GIC_H + +#include <inmate.h> + +#define GICD_ISENABLER 0x0100 + +#define is_spi(irqn) ((irqn) > 31 && (irqn) < 1020) +#define gic_setup_irq_stack() + +#ifndef __ASSEMBLY__ + +int gic_init(void); +void gic_enable(unsigned int irqn); +void gic_write_eoi(u32 irqn); +u32 gic_read_ack(void); + +#endif /* !__ASSEMBLY__ */ +#endif diff --git a/inmates/lib/arm64/include/inmate.h b/inmates/lib/arm64/include/inmate.h new file mode 100644 index 0000000..f869833 --- /dev/null +++ b/inmates/lib/arm64/include/inmate.h @@ -0,0 +1,66 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) ARM Limited, 2014 + * + * Authors: + * Jean-Philippe Brucker <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#ifndef _JAILHOUSE_INMATE_H +#define _JAILHOUSE_INMATE_H + +#ifndef __ASSEMBLY__ +typedef signed char s8; +typedef unsigned char u8; + +typedef signed short s16; +typedef unsigned short u16; + +typedef signed int s32; +typedef unsigned int u32; + +typedef signed long long s64; +typedef unsigned long long u64; + +static inline u32 mmio_read32(void *address) +{ + return *(volatile u32 *)address; +} + +static inline void mmio_write32(void *address, u32 value) +{ + *(volatile u32 *)address = value; +} + +/* + * To ease the debugging, we can send a spurious hypercall, which should return + * -ENOSYS, but appear in the hypervisor stats for this cell. + */ +static inline void heartbeat(void) +{ + asm volatile ( + "mov x0, %0\n" + "hvc #0\n" + : : "r" (0xbea7) : "x0"); +} + +void __attribute__((used)) vector_irq(void); + +typedef void (*irq_handler_t)(unsigned int); +void gic_setup(irq_handler_t handler); +void gic_enable_irq(unsigned int irq); + +unsigned long timer_get_frequency(void); +u64 timer_get_ticks(void); +u64 timer_ticks_to_ns(u64 ticks); +void timer_start(u64 timeout); + +#endif /* !__ASSEMBLY__ */ + +#include "../inmate_common.h" + +#endif /* !_JAILHOUSE_INMATE_H */ diff --git a/inmates/lib/arm64/include/mach-amd-seattle/mach/gic_v2.h b/inmates/lib/arm64/include/mach-amd-seattle/mach/gic_v2.h new file mode 100644 index 0000000..b357a21 --- /dev/null +++ b/inmates/lib/arm64/include/mach-amd-seattle/mach/gic_v2.h @@ -0,0 +1,14 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#define GICD_BASE ((void *)0xe1110000) +#define GICC_BASE ((void *)0xe112f000) diff --git a/inmates/lib/arm64/include/mach-amd-seattle/mach/timer.h b/inmates/lib/arm64/include/mach-amd-seattle/mach/timer.h new file mode 100644 index 0000000..696b5cb --- /dev/null +++ b/inmates/lib/arm64/include/mach-amd-seattle/mach/timer.h @@ -0,0 +1,13 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#define TIMER_IRQ 27 diff --git a/inmates/lib/arm64/include/mach-amd-seattle/mach/uart.h b/inmates/lib/arm64/include/mach-amd-seattle/mach/uart.h new file mode 100644 index 0000000..512b6cb --- /dev/null +++ b/inmates/lib/arm64/include/mach-amd-seattle/mach/uart.h @@ -0,0 +1,13 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#define UART_BASE ((void *)0xe1010000) diff --git a/inmates/lib/arm64/include/mach-foundation-v8/mach/gic_v2.h b/inmates/lib/arm64/include/mach-foundation-v8/mach/gic_v2.h new file mode 100644 index 0000000..bd3ec88 --- /dev/null +++ b/inmates/lib/arm64/include/mach-foundation-v8/mach/gic_v2.h @@ -0,0 +1,14 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#define GICD_BASE ((void *)0x2c001000) +#define GICC_BASE ((void *)0x2c002000) diff --git a/inmates/lib/arm64/include/mach-foundation-v8/mach/timer.h b/inmates/lib/arm64/include/mach-foundation-v8/mach/timer.h new file mode 100644 index 0000000..696b5cb --- /dev/null +++ b/inmates/lib/arm64/include/mach-foundation-v8/mach/timer.h @@ -0,0 +1,13 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#define TIMER_IRQ 27 diff --git a/inmates/lib/arm64/include/mach-foundation-v8/mach/uart.h b/inmates/lib/arm64/include/mach-foundation-v8/mach/uart.h new file mode 100644 index 0000000..5ac3f87 --- /dev/null +++ b/inmates/lib/arm64/include/mach-foundation-v8/mach/uart.h @@ -0,0 +1,13 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#define UART_BASE ((void *)0x1c090000) diff --git a/inmates/lib/arm64/inmate.lds b/inmates/lib/arm64/inmate.lds new file mode 100644 index 0000000..01ba5f5 --- /dev/null +++ b/inmates/lib/arm64/inmate.lds @@ -0,0 +1,46 @@ +/* + * Jailhouse AArch64 support + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * + * Authors: + * Antonios Motakis <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +SECTIONS { + . = 0; + .boot : { *(.boot) } + + . = 0x1000; + .cmdline : { + *(.cmdline) + BYTE(0); /* empty string in case no buffer is provided */ + } + + bss_start = .; + .bss : { + *(.bss) + } + + . = ALIGN(4); + .text : { + *(.text) + } + + .rodata : { + *(.rodata) + } + + .data : { + *(.data) + } + + . = ALIGN(4096); + . = . + 0x1000; + stack_top = .; +} + +ENTRY(__reset_entry) -- 2.8.0.rc3 -- 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.
