From: Jan Kiszka <[email protected]> This registers the VExpress specific hooks as unit with the core and shows the power of units: no more special mach hooks.
Signed-off-by: Jan Kiszka <[email protected]> --- hypervisor/arch/arm/Kbuild | 7 +++- hypervisor/arch/arm/control.c | 4 -- hypervisor/arch/arm/include/asm/mach.h | 27 ------------- hypervisor/arch/arm/mach-stubs.c | 30 -------------- hypervisor/arch/arm/mmio.c | 3 +- hypervisor/arch/arm/setup.c | 7 ---- .../arch/arm/{mach-vexpress.c => vexpress.c} | 47 +++++++++++++--------- 7 files changed, 33 insertions(+), 92 deletions(-) delete mode 100644 hypervisor/arch/arm/include/asm/mach.h delete mode 100644 hypervisor/arch/arm/mach-stubs.c rename hypervisor/arch/arm/{mach-vexpress.c => vexpress.c} (83%) diff --git a/hypervisor/arch/arm/Kbuild b/hypervisor/arch/arm/Kbuild index 158759c13..eec346902 100644 --- a/hypervisor/arch/arm/Kbuild +++ b/hypervisor/arch/arm/Kbuild @@ -16,9 +16,12 @@ KBUILD_AFLAGS := $(subst -include asm/unified.h,,$(KBUILD_AFLAGS)) always := built-in.o +# units initialization order as defined by linking order: +# [vexpress], <generic units> + obj-y := $(COMMON_OBJECTS) obj-y += entry.o setup.o control.o traps.o mmio.o lib.o -obj-y += mmu_hyp.o caches.o mach-stubs.o +obj-y += mmu_hyp.o caches.o # in here we switch of the MMU and stuff, cant profile such code # NOTE @@ -26,4 +29,4 @@ obj-y += mmu_hyp.o caches.o mach-stubs.o # should switch to that for higher granularity, but gcc7 is not even there CFLAGS_mmu_hyp.o += -fno-profile-arcs -fno-test-coverage -obj-$(CONFIG_MACH_VEXPRESS) += mach-vexpress.o +obj-$(CONFIG_MACH_VEXPRESS) += vexpress.o diff --git a/hypervisor/arch/arm/control.c b/hypervisor/arch/arm/control.c index 1934ae4c1..8693aab7a 100644 --- a/hypervisor/arch/arm/control.c +++ b/hypervisor/arch/arm/control.c @@ -17,7 +17,6 @@ #include <jailhouse/string.h> #include <asm/control.h> #include <asm/irqchip.h> -#include <asm/mach.h> #include <asm/psci.h> #include <asm/sysregs.h> @@ -185,8 +184,6 @@ int arch_cell_create(struct cell *cell) return err; } - mach_cell_init(cell); - return 0; } @@ -199,7 +196,6 @@ void arch_cell_destroy(struct cell *cell) for_each_cpu(cpu, cell->cpu_set) per_cpu(cpu)->cpu_on_entry = PSCI_INVALID_ADDRESS; - mach_cell_exit(cell); irqchip_cell_exit(cell); arm_paging_cell_destroy(cell); diff --git a/hypervisor/arch/arm/include/asm/mach.h b/hypervisor/arch/arm/include/asm/mach.h deleted file mode 100644 index fc4dd0127..000000000 --- a/hypervisor/arch/arm/include/asm/mach.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Jailhouse, a Linux-based partitioning hypervisor - * - * Copyright (c) ARM Limited, 2014 - * Copyright (c) Siemens AG, 2016 - * - * 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. - */ - -#ifndef JAILHOUSE_ASM_SMP_H_ -#define JAILHOUSE_ASM_SMP_H_ - -struct cell; - -extern const unsigned int mach_mmio_regions; - -int mach_init(void); - -void mach_cell_init(struct cell *cell); -void mach_cell_exit(struct cell *cell); - -#endif /* !JAILHOUSE_ASM_SMP_H_ */ diff --git a/hypervisor/arch/arm/mach-stubs.c b/hypervisor/arch/arm/mach-stubs.c deleted file mode 100644 index f2b9c0306..000000000 --- a/hypervisor/arch/arm/mach-stubs.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Jailhouse, a Linux-based partitioning hypervisor - * - * Copyright (c) ARM Limited, 2014 - * Copyright (c) Siemens AG, 2016 - * - * 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 <asm/mach.h> - -const unsigned int __attribute__((weak)) mach_mmio_regions; - -int __attribute__((weak)) mach_init(void) -{ - return 0; -} - -void __attribute__((weak)) mach_cell_init(struct cell *cell) -{ -} - -void __attribute__((weak)) mach_cell_exit(struct cell *cell) -{ -} diff --git a/hypervisor/arch/arm/mmio.c b/hypervisor/arch/arm/mmio.c index 25e4b52a2..44f9e0832 100644 --- a/hypervisor/arch/arm/mmio.c +++ b/hypervisor/arch/arm/mmio.c @@ -15,14 +15,13 @@ #include <jailhouse/printk.h> #include <asm/bitops.h> #include <asm/irqchip.h> -#include <asm/mach.h> #include <asm/percpu.h> #include <asm/processor.h> #include <asm/traps.h> unsigned int arch_mmio_count_regions(struct cell *cell) { - return irqchip_mmio_count_regions(cell) + mach_mmio_regions; + return irqchip_mmio_count_regions(cell); } /* Taken from the ARM ARM pseudocode for taking a data abort */ diff --git a/hypervisor/arch/arm/setup.c b/hypervisor/arch/arm/setup.c index c466ae1eb..eb8aa2a64 100644 --- a/hypervisor/arch/arm/setup.c +++ b/hypervisor/arch/arm/setup.c @@ -15,7 +15,6 @@ #include <jailhouse/processor.h> #include <jailhouse/string.h> #include <asm/control.h> -#include <asm/mach.h> #include <asm/mmu_hyp.h> #include <asm/setup.h> #include <asm/sysregs.h> @@ -81,12 +80,6 @@ int arch_cpu_init(struct per_cpu *cpu_data) int arch_init_late(void) { - int err; - - err = mach_init(); - if (err) - return err; - return arm_init_late(); } diff --git a/hypervisor/arch/arm/mach-vexpress.c b/hypervisor/arch/arm/vexpress.c similarity index 83% rename from hypervisor/arch/arm/mach-vexpress.c rename to hypervisor/arch/arm/vexpress.c index bb834b4e9..77c8483fe 100644 --- a/hypervisor/arch/arm/mach-vexpress.c +++ b/hypervisor/arch/arm/vexpress.c @@ -14,17 +14,20 @@ #include <jailhouse/control.h> #include <jailhouse/mmio.h> +#include <jailhouse/unit.h> #include <asm/control.h> -#include <asm/mach.h> #define SYSREGS_BASE 0x1c010000 #define VEXPRESS_FLAGSSET 0x30 -const unsigned int mach_mmio_regions = 1; - static unsigned long root_entry; +static unsigned int vexpress_mmio_count_regions(struct cell *cell) +{ + return 1; +} + static enum mmio_result sysregs_access_handler(void *arg, struct mmio_access *mmio) { @@ -56,28 +59,14 @@ sysregs_access_handler(void *arg, struct mmio_access *mmio) return MMIO_HANDLED; } -int mach_init(void) -{ - void *sysregs_base; - - sysregs_base = paging_map_device(SYSREGS_BASE, PAGE_SIZE); - if (!sysregs_base) - return -ENOMEM; - root_entry = mmio_read32(sysregs_base + VEXPRESS_FLAGSSET); - paging_unmap_device(SYSREGS_BASE, sysregs_base, PAGE_SIZE); - - mach_cell_init(&root_cell); - - return 0; -} - -void mach_cell_init(struct cell *cell) +static int vexpress_cell_init(struct cell *cell) { mmio_region_register(cell, (unsigned long)SYSREGS_BASE, PAGE_SIZE, sysregs_access_handler, NULL); + return 0; } -void mach_cell_exit(struct cell *cell) +static void vexpress_cell_exit(struct cell *cell) { unsigned int cpu; @@ -88,3 +77,21 @@ void mach_cell_exit(struct cell *cell) arch_reset_cpu(cpu); } } + +static int vexpress_init(void) +{ + void *sysregs_base; + + sysregs_base = paging_map_device(SYSREGS_BASE, PAGE_SIZE); + if (!sysregs_base) + return -ENOMEM; + root_entry = mmio_read32(sysregs_base + VEXPRESS_FLAGSSET); + paging_unmap_device(SYSREGS_BASE, sysregs_base, PAGE_SIZE); + + vexpress_cell_init(&root_cell); + + return 0; +} + +DEFINE_UNIT_SHUTDOWN_STUB(vexpress); +DEFINE_UNIT(vexpress, "VExpress"); -- 2.13.6 -- 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.
