From: Jan Kiszka <[email protected]> This simplifies the code as it obsoletes arch_config_commit. The programmatic order of commit functions called by config_commit and arch_config_commit were already in line with the unit order.
Signed-off-by: Jan Kiszka <[email protected]> --- hypervisor/arch/arm-common/control.c | 6 ------ hypervisor/arch/arm-common/include/asm/iommu.h | 1 - hypervisor/arch/arm-common/include/asm/irqchip.h | 2 -- hypervisor/arch/arm-common/irqchip.c | 4 ++-- hypervisor/arch/arm/iommu.c | 4 ---- hypervisor/arch/arm64/Kbuild | 4 ++-- hypervisor/arch/arm64/include/asm/smmu.h | 12 ------------ hypervisor/arch/arm64/include/asm/ti-pvu.h | 2 -- hypervisor/arch/arm64/iommu.c | 7 ------- hypervisor/arch/arm64/smmu-v3.c | 1 + hypervisor/arch/arm64/smmu.c | 7 +++---- hypervisor/arch/arm64/ti-pvu.c | 14 +++++++------- hypervisor/arch/x86/amd_iommu.c | 4 ++-- hypervisor/arch/x86/cat.c | 3 ++- hypervisor/arch/x86/control.c | 6 ------ hypervisor/arch/x86/include/asm/ioapic.h | 4 +--- hypervisor/arch/x86/include/asm/iommu.h | 2 -- hypervisor/arch/x86/ioapic.c | 4 ++-- hypervisor/arch/x86/test-device.c | 3 ++- hypervisor/arch/x86/vtd.c | 4 ++-- hypervisor/control.c | 9 ++++----- hypervisor/include/jailhouse/control.h | 10 ---------- hypervisor/include/jailhouse/pci.h | 4 +--- hypervisor/include/jailhouse/unit.h | 7 ++++++- hypervisor/pci.c | 11 ++--------- 25 files changed, 39 insertions(+), 96 deletions(-) delete mode 100644 hypervisor/arch/arm64/include/asm/smmu.h diff --git a/hypervisor/arch/arm-common/control.c b/hypervisor/arch/arm-common/control.c index 44c66225..d61c81d9 100644 --- a/hypervisor/arch/arm-common/control.c +++ b/hypervisor/arch/arm-common/control.c @@ -211,12 +211,6 @@ void arch_flush_cell_vcpu_caches(struct cell *cell) public_per_cpu(cpu)->flush_vcpu_caches = true; } -void arch_config_commit(struct cell *cell_added_removed) -{ - irqchip_config_commit(cell_added_removed); - iommu_config_commit(cell_added_removed); -} - void __attribute__((noreturn)) arch_panic_stop(void) { asm volatile ("1: wfi; b 1b"); diff --git a/hypervisor/arch/arm-common/include/asm/iommu.h b/hypervisor/arch/arm-common/include/asm/iommu.h index dde762c0..33f05011 100644 --- a/hypervisor/arch/arm-common/include/asm/iommu.h +++ b/hypervisor/arch/arm-common/include/asm/iommu.h @@ -27,5 +27,4 @@ int iommu_map_memory_region(struct cell *cell, const struct jailhouse_memory *mem); int iommu_unmap_memory_region(struct cell *cell, const struct jailhouse_memory *mem); -void iommu_config_commit(struct cell *cell); #endif diff --git a/hypervisor/arch/arm-common/include/asm/irqchip.h b/hypervisor/arch/arm-common/include/asm/irqchip.h index 06401f91..d058093a 100644 --- a/hypervisor/arch/arm-common/include/asm/irqchip.h +++ b/hypervisor/arch/arm-common/include/asm/irqchip.h @@ -87,8 +87,6 @@ void irqchip_cpu_shutdown(struct public_per_cpu *cpu_public); void irqchip_cell_reset(struct cell *cell); -void irqchip_config_commit(struct cell *cell_added_removed); - void irqchip_send_sgi(unsigned int cpu_id, u16 sgi_id); void irqchip_handle_irq(void); diff --git a/hypervisor/arch/arm-common/irqchip.c b/hypervisor/arch/arm-common/irqchip.c index 256af114..fdb15c9d 100644 --- a/hypervisor/arch/arm-common/irqchip.c +++ b/hypervisor/arch/arm-common/irqchip.c @@ -2,7 +2,7 @@ * Jailhouse, a Linux-based partitioning hypervisor * * Copyright (c) ARM Limited, 2014 - * Copyright (c) Siemens AG, 2016 + * Copyright (c) Siemens AG, 2016-2022 * * Authors: * Jean-Philippe Brucker <[email protected]> @@ -506,7 +506,7 @@ static void irqchip_cell_exit(struct cell *cell) irqchip.cell_exit(cell); } -void irqchip_config_commit(struct cell *cell_added_removed) +static void irqchip_config_commit(struct cell *cell_added_removed) { unsigned int n; diff --git a/hypervisor/arch/arm/iommu.c b/hypervisor/arch/arm/iommu.c index 2c02c812..30ecbb2d 100644 --- a/hypervisor/arch/arm/iommu.c +++ b/hypervisor/arch/arm/iommu.c @@ -28,7 +28,3 @@ int iommu_unmap_memory_region(struct cell *cell, { return 0; } - -void iommu_config_commit(struct cell *cell) -{ -} diff --git a/hypervisor/arch/arm64/Kbuild b/hypervisor/arch/arm64/Kbuild index 4d328021..59102226 100644 --- a/hypervisor/arch/arm64/Kbuild +++ b/hypervisor/arch/arm64/Kbuild @@ -2,7 +2,7 @@ # Jailhouse AArch64 support # # Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH -# Copyright (c) Siemens AG, 2016 +# Copyright (c) Siemens AG, 2016-2022 # # Authors: # Antonios Motakis <[email protected]> @@ -17,7 +17,7 @@ include $(src)/../arm-common/Kbuild always-y := lib.a # units initialization order as defined by linking order: -# irqchip (common-objs-y), <generic units> +# irqchip (common-objs-y), smmu-v3, ti-pvu, <generic units> lib-y := $(common-objs-y) lib-y += entry.o setup.o control.o mmio.o paging.o caches.o traps.o diff --git a/hypervisor/arch/arm64/include/asm/smmu.h b/hypervisor/arch/arm64/include/asm/smmu.h deleted file mode 100644 index def7cbde..00000000 --- a/hypervisor/arch/arm64/include/asm/smmu.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Jailhouse, a Linux-based partitioning hypervisor - * - * Copyright Siemens AG, 2020 - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -#include <jailhouse/cell.h> - -void arm_smmu_config_commit(struct cell *cell); diff --git a/hypervisor/arch/arm64/include/asm/ti-pvu.h b/hypervisor/arch/arm64/include/asm/ti-pvu.h index 62aec7c0..da04fbf6 100644 --- a/hypervisor/arch/arm64/include/asm/ti-pvu.h +++ b/hypervisor/arch/arm64/include/asm/ti-pvu.h @@ -126,6 +126,4 @@ int pvu_iommu_map_memory(struct cell *cell, int pvu_iommu_unmap_memory(struct cell *cell, const struct jailhouse_memory *mem); -void pvu_iommu_config_commit(struct cell *cell); - #endif /* _IOMMMU_PVU_H_ */ diff --git a/hypervisor/arch/arm64/iommu.c b/hypervisor/arch/arm64/iommu.c index ca998789..ff1aa7bd 100644 --- a/hypervisor/arch/arm64/iommu.c +++ b/hypervisor/arch/arm64/iommu.c @@ -12,7 +12,6 @@ #include <jailhouse/control.h> #include <asm/iommu.h> -#include <asm/smmu.h> #include <asm/ti-pvu.h> unsigned int iommu_count_units(void) @@ -36,9 +35,3 @@ int iommu_unmap_memory_region(struct cell *cell, { return pvu_iommu_unmap_memory(cell, mem); } - -void iommu_config_commit(struct cell *cell) -{ - arm_smmu_config_commit(cell); - pvu_iommu_config_commit(cell); -} diff --git a/hypervisor/arch/arm64/smmu-v3.c b/hypervisor/arch/arm64/smmu-v3.c index 5a76a68d..b93aff35 100644 --- a/hypervisor/arch/arm64/smmu-v3.c +++ b/hypervisor/arch/arm64/smmu-v3.c @@ -1134,4 +1134,5 @@ static int arm_smmuv3_init(void) DEFINE_UNIT_MMIO_COUNT_REGIONS_STUB(arm_smmuv3); DEFINE_UNIT_SHUTDOWN_STUB(arm_smmuv3); +DEFINE_UNIT_CONFIG_COMMIT_STUB(arm_smmuv3); DEFINE_UNIT(arm_smmuv3, "ARM SMMU v3"); diff --git a/hypervisor/arch/arm64/smmu.c b/hypervisor/arch/arm64/smmu.c index 7869b66b..73b780b2 100644 --- a/hypervisor/arch/arm64/smmu.c +++ b/hypervisor/arch/arm64/smmu.c @@ -2,7 +2,7 @@ * Jailhouse, a Linux-based partitioning hypervisor * * Copyright 2018-2020 NXP - * Copyright Siemens AG, 2020 + * Copyright Siemens AG, 2020-2022 * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. @@ -14,7 +14,6 @@ #include <jailhouse/printk.h> #include <jailhouse/unit.h> #include <asm/iommu.h> -#include <asm/smmu.h> #include <jailhouse/cell-config.h> @@ -522,12 +521,12 @@ static void arm_smmu_cell_exit(struct cell *cell) } } -void arm_smmu_config_commit(struct cell *cell) +static void arm_smmu_config_commit(struct cell *cell_added_removed) { struct arm_smmu_device *smmu; unsigned int dev; - if (cell != &root_cell) + if (cell_added_removed != &root_cell) return; for_each_smmu(smmu, dev) { diff --git a/hypervisor/arch/arm64/ti-pvu.c b/hypervisor/arch/arm64/ti-pvu.c index 5da85b5c..629f3dd7 100644 --- a/hypervisor/arch/arm64/ti-pvu.c +++ b/hypervisor/arch/arm64/ti-pvu.c @@ -442,12 +442,12 @@ int pvu_iommu_unmap_memory(struct cell *cell, return 0; } -void pvu_iommu_config_commit(struct cell *cell) +static void pvu_iommu_config_commit(struct cell *cell_added_removed) { union jailhouse_stream_id virtid; unsigned int i; - if (pvu_count == 0 || !cell) + if (pvu_count == 0 || !cell_added_removed) return; /* @@ -456,17 +456,17 @@ void pvu_iommu_config_commit(struct cell *cell) * Sort the entries in descending order of page sizes to reduce effects * of chaining and thus reducing average translation latency */ - pvu_entrylist_sort(cell->arch.iommu_pvu.entries, - cell->arch.iommu_pvu.ent_count); + pvu_entrylist_sort(cell_added_removed->arch.iommu_pvu.entries, + cell_added_removed->arch.iommu_pvu.ent_count); - for_each_stream_id(virtid, cell->config, i) { + for_each_stream_id(virtid, cell_added_removed->config, i) { if (virtid.id > MAX_VIRTID) continue; - pvu_iommu_program_entries(cell, virtid.id); + pvu_iommu_program_entries(cell_added_removed, virtid.id); } - cell->arch.iommu_pvu.ent_count = 0; + cell_added_removed->arch.iommu_pvu.ent_count = 0; } static int pvu_iommu_cell_init(struct cell *cell) diff --git a/hypervisor/arch/x86/amd_iommu.c b/hypervisor/arch/x86/amd_iommu.c index 40ec4e20..894d92ef 100644 --- a/hypervisor/arch/x86/amd_iommu.c +++ b/hypervisor/arch/x86/amd_iommu.c @@ -2,7 +2,7 @@ * Jailhouse, a Linux-based partitioning hypervisor * * Copyright (c) Valentine Sinitsyn, 2014, 2015 - * Copyright (c) Siemens AG, 2016 + * Copyright (c) Siemens AG, 2016-2022 * * Authors: * Valentine Sinitsyn <[email protected]> @@ -472,7 +472,7 @@ static void amd_iommu_init_fault_nmi(void) apic_send_nmi_ipi(target_data); } -void iommu_config_commit(struct cell *cell_added_removed) +static void amd_iommu_config_commit(struct cell *cell_added_removed) { struct amd_iommu *iommu; diff --git a/hypervisor/arch/x86/cat.c b/hypervisor/arch/x86/cat.c index 051ac296..790584e1 100644 --- a/hypervisor/arch/x86/cat.c +++ b/hypervisor/arch/x86/cat.c @@ -1,7 +1,7 @@ /* * Jailhouse, a Linux-based partitioning hypervisor * - * Copyright (c) Siemens AG, 2015, 2016 + * Copyright (c) Siemens AG, 2015-2022 * * Authors: * Jan Kiszka <[email protected]> @@ -226,4 +226,5 @@ static int cat_init(void) DEFINE_UNIT_SHUTDOWN_STUB(cat); DEFINE_UNIT_MMIO_COUNT_REGIONS_STUB(cat); +DEFINE_UNIT_CONFIG_COMMIT_STUB(cat); DEFINE_UNIT(cat, "Cache Allocation Technology"); diff --git a/hypervisor/arch/x86/control.c b/hypervisor/arch/x86/control.c index 9a2c6680..11cfee49 100644 --- a/hypervisor/arch/x86/control.c +++ b/hypervisor/arch/x86/control.c @@ -101,12 +101,6 @@ void arch_cell_reset(struct cell *cell) ioapic_cell_reset(cell); } -void arch_config_commit(struct cell *cell_added_removed) -{ - iommu_config_commit(cell_added_removed); - ioapic_config_commit(cell_added_removed); -} - void arch_prepare_shutdown(void) { ioapic_prepare_handover(); diff --git a/hypervisor/arch/x86/include/asm/ioapic.h b/hypervisor/arch/x86/include/asm/ioapic.h index f58ea2fc..327d4412 100644 --- a/hypervisor/arch/x86/include/asm/ioapic.h +++ b/hypervisor/arch/x86/include/asm/ioapic.h @@ -1,7 +1,7 @@ /* * Jailhouse, a Linux-based partitioning hypervisor * - * Copyright (c) Siemens AG, 2014-2017 + * Copyright (c) Siemens AG, 2014-2022 * * Authors: * Jan Kiszka <[email protected]> @@ -92,5 +92,3 @@ int ioapic_get_or_add_phys(const struct jailhouse_irqchip *irqchip, struct phys_ioapic **phys_ioapic_ptr); void ioapic_cell_reset(struct cell *cell); - -void ioapic_config_commit(struct cell *cell_added_removed); diff --git a/hypervisor/arch/x86/include/asm/iommu.h b/hypervisor/arch/x86/include/asm/iommu.h index 848feb77..a5b32a00 100644 --- a/hypervisor/arch/x86/include/asm/iommu.h +++ b/hypervisor/arch/x86/include/asm/iommu.h @@ -41,8 +41,6 @@ int iommu_map_interrupt(struct cell *cell, unsigned int vector, struct apic_irq_message irq_msg); -void iommu_config_commit(struct cell *cell_added_removed); - void iommu_prepare_shutdown(void); struct public_per_cpu *iommu_select_fault_reporting_cpu(void); diff --git a/hypervisor/arch/x86/ioapic.c b/hypervisor/arch/x86/ioapic.c index 65ac00f2..41dd0ee0 100644 --- a/hypervisor/arch/x86/ioapic.c +++ b/hypervisor/arch/x86/ioapic.c @@ -1,7 +1,7 @@ /* * Jailhouse, a Linux-based partitioning hypervisor * - * Copyright (c) Siemens AG, 2014-2017 + * Copyright (c) Siemens AG, 2014-2022 * * Authors: * Jan Kiszka <[email protected]> @@ -412,7 +412,7 @@ static void ioapic_cell_exit(struct cell *cell) page_free(&mem_pool, cell->arch.ioapics, 1); } -void ioapic_config_commit(struct cell *cell_added_removed) +static void ioapic_config_commit(struct cell *cell_added_removed) { struct apic_irq_message irq_msg; union ioapic_redir_entry entry; diff --git a/hypervisor/arch/x86/test-device.c b/hypervisor/arch/x86/test-device.c index d9cee834..44142816 100644 --- a/hypervisor/arch/x86/test-device.c +++ b/hypervisor/arch/x86/test-device.c @@ -1,7 +1,7 @@ /* * Jailhouse, a Linux-based partitioning hypervisor * - * Copyright (c) Siemens AG, 2018 + * Copyright (c) Siemens AG, 2018-2022 * * Authors: * Jan Kiszka <[email protected]> @@ -102,4 +102,5 @@ static int testdev_init(void) } DEFINE_UNIT_SHUTDOWN_STUB(testdev); +DEFINE_UNIT_CONFIG_COMMIT_STUB(testdev); DEFINE_UNIT(testdev, "Test device"); diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index acc97919..5f991d3b 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -1,7 +1,7 @@ /* * Jailhouse, a Linux-based partitioning hypervisor * - * Copyright (c) Siemens AG, 2013-2016 + * Copyright (c) Siemens AG, 2013-2022 * Copyright (c) Valentine Sinitsyn, 2014 * * Authors: @@ -885,7 +885,7 @@ static void vtd_cell_exit(struct cell *cell) */ } -void iommu_config_commit(struct cell *cell_added_removed) +static void vtd_config_commit(struct cell *cell_added_removed) { void *inv_queue = unit_inv_queue; void *reg_base = dmar_reg_base; diff --git a/hypervisor/control.c b/hypervisor/control.c index 5da95ada..1e1c7f03 100644 --- a/hypervisor/control.c +++ b/hypervisor/control.c @@ -279,12 +279,11 @@ static void cell_exit(struct cell *cell) * Apply system configuration changes. * @param cell_added_removed Cell that was added or removed to/from the * system or NULL. - * - * @see arch_config_commit - * @see pci_config_commit */ void config_commit(struct cell *cell_added_removed) { + struct unit *unit; + /* * We do not need to flush the caches during setup, i.e. when the root * cell was added, because there was no reconfiguration of the new @@ -296,8 +295,8 @@ void config_commit(struct cell *cell_added_removed) arch_flush_cell_vcpu_caches(cell_added_removed); } - arch_config_commit(cell_added_removed); - pci_config_commit(cell_added_removed); + for_each_unit(unit) + unit->config_commit(cell_added_removed); } static bool address_in_region(unsigned long addr, diff --git a/hypervisor/include/jailhouse/control.h b/hypervisor/include/jailhouse/control.h index 9d1e74fa..ececa026 100644 --- a/hypervisor/include/jailhouse/control.h +++ b/hypervisor/include/jailhouse/control.h @@ -263,16 +263,6 @@ void arch_cell_destroy(struct cell *cell); */ void arch_cell_reset(struct cell *cell); -/** - * Performs the architecture-specific steps for applying configuration changes. - * @param cell_added_removed Cell that was added or removed to/from the - * system or NULL. - * - * @see config_commit - * @see pci_config_commit - */ -void arch_config_commit(struct cell *cell_added_removed); - /** * Architecture-specific preparations before shutting down the hypervisor. */ diff --git a/hypervisor/include/jailhouse/pci.h b/hypervisor/include/jailhouse/pci.h index ee530c03..0d332a1b 100644 --- a/hypervisor/include/jailhouse/pci.h +++ b/hypervisor/include/jailhouse/pci.h @@ -1,7 +1,7 @@ /* * Jailhouse, a Linux-based partitioning hypervisor * - * Copyright (c) Siemens AG, 2014 + * Copyright (c) Siemens AG, 2014-2022 * * Authors: * Ivan Kolchin <[email protected]> @@ -157,8 +157,6 @@ void pci_reset_device(struct pci_device *device); void pci_cell_reset(struct cell *cell); -void pci_config_commit(struct cell *cell_added_removed); - unsigned int pci_enabled_msi_vectors(struct pci_device *device); void pci_prepare_handover(void); diff --git a/hypervisor/include/jailhouse/unit.h b/hypervisor/include/jailhouse/unit.h index 40e1cbfe..377a5de1 100644 --- a/hypervisor/include/jailhouse/unit.h +++ b/hypervisor/include/jailhouse/unit.h @@ -1,7 +1,7 @@ /* * Jailhouse, a Linux-based partitioning hypervisor * - * Copyright (c) Siemens AG, 2018 + * Copyright (c) Siemens AG, 2018-2022 * * Authors: * Jan Kiszka <[email protected]> @@ -21,6 +21,7 @@ struct unit { unsigned int (*mmio_count_regions)(struct cell *); int (*cell_init)(struct cell *); void (*cell_exit)(struct cell *); + void (*config_commit)(struct cell *); }; #define DEFINE_UNIT(__name, __description) \ @@ -32,6 +33,7 @@ struct unit { .mmio_count_regions = __name##_mmio_count_regions, \ .cell_init = __name##_cell_init, \ .cell_exit = __name##_cell_exit, \ + .config_commit = __name##_config_commit, \ } #define DEFINE_UNIT_SHUTDOWN_STUB(__name) \ @@ -41,6 +43,9 @@ struct unit { static unsigned int __name##_mmio_count_regions(struct cell *cell) \ { return 0; } +#define DEFINE_UNIT_CONFIG_COMMIT_STUB(__name) \ + static void __name##_config_commit(struct cell *cell_added_removed) { } + extern struct unit __unit_array_start[0], __unit_array_end[0]; #define for_each_unit(unit) \ diff --git a/hypervisor/pci.c b/hypervisor/pci.c index 6934c33d..4a485357 100644 --- a/hypervisor/pci.c +++ b/hypervisor/pci.c @@ -1,7 +1,7 @@ /* * Jailhouse, a Linux-based partitioning hypervisor * - * Copyright (c) Siemens AG, 2014-2016 + * Copyright (c) Siemens AG, 2014-2022 * * Authors: * Ivan Kolchin <[email protected]> @@ -785,14 +785,7 @@ static void pci_cell_exit(struct cell *cell) page_free(&mem_pool, cell->pci_devices, devlist_pages); } -/** - * Apply PCI-specific configuration changes. - * @param cell_added_removed Cell that was added or removed to/from the - * system or NULL. - * - * @see arch_config_commit - */ -void pci_config_commit(struct cell *cell_added_removed) +static void pci_config_commit(struct cell *cell_added_removed) { const struct jailhouse_pci_capability *cap; struct pci_device *device; -- 2.36.1 -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/20220627131329.3659-6-ralf.ramsauer%40oth-regensburg.de.
