Allow configurators to specify the size of a way and the temporary loading address for remapping.
Signed-off-by: Andrea Bastoni <[email protected]> --- driver/cell.c | 4 ++-- driver/cell.h | 1 + driver/main.c | 12 ++++++++++++ hypervisor/arch/arm64/coloring.c | 7 +++++-- hypervisor/arch/arm64/include/asm/coloring.h | 18 ++++++++++++++++-- include/jailhouse/cell-config.h | 9 +++++++-- 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/driver/cell.c b/driver/cell.c index 30a4c501..8a9fccb4 100644 --- a/driver/cell.c +++ b/driver/cell.c @@ -337,8 +337,8 @@ static int load_image(struct cell *cell, /* Tweak the base address to request remapping of * a reserved, high memory region. */ - phys_start = (mem->virt_start + ROOT_MAP_OFFSET + image_offset) - & PAGE_MASK; + phys_start = (mem->virt_start + image_offset + + root_cell->color_root_map_offset) & PAGE_MASK; } else { phys_start = (mem->phys_start + image_offset) & PAGE_MASK; } diff --git a/driver/cell.h b/driver/cell.h index 92afbff8..51afe6d8 100644 --- a/driver/cell.h +++ b/driver/cell.h @@ -32,6 +32,7 @@ struct cell { cpumask_t cpus_assigned; u32 num_memory_regions; struct jailhouse_memory *memory_regions; + u64 color_root_map_offset; #ifdef CONFIG_PCI u32 num_pci_devices; struct jailhouse_pci_device *pci_devices; diff --git a/driver/main.c b/driver/main.c index 78af8e97..9c819281 100644 --- a/driver/main.c +++ b/driver/main.c @@ -362,6 +362,16 @@ console_free_out: return ret; } +static inline void jailhouse_init_color_params( + struct jailhouse_system *config, + struct cell *root) +{ + /* coloring temporary load-mapping address */ + root->color_root_map_offset = + config->platform_info.color.root_map_offset; +} + + /* See Documentation/bootstrap-interface.txt */ static int jailhouse_cmd_enable(struct jailhouse_system __user *arg) { @@ -579,6 +589,8 @@ static int jailhouse_cmd_enable(struct jailhouse_system __user *arg) if (err) goto error_unmap; + jailhouse_init_color_params(config, root_cell); + error_code = 0; preempt_disable(); diff --git a/hypervisor/arch/arm64/coloring.c b/hypervisor/arch/arm64/coloring.c index ea19560c..3748c3f0 100644 --- a/hypervisor/arch/arm64/coloring.c +++ b/hypervisor/arch/arm64/coloring.c @@ -28,6 +28,9 @@ */ u64 coloring_way_size = 0; +/** Temporary load-mapping parameter */ +u64 coloring_root_map_offset = 0; + static inline int coloring_mem_destroy(struct cell *cell, struct jailhouse_memory *mr) { @@ -57,7 +60,7 @@ static inline int coloring_mem_start(struct jailhouse_memory *mr) } /* Match the address specified during load */ - mr->virt_start += ROOT_MAP_OFFSET; + mr->virt_start += coloring_root_map_offset; return arch_unmap_memory_region(&root_cell, mr); } @@ -69,7 +72,7 @@ static inline int coloring_mem_load(struct jailhouse_memory *mr) } /* Fix addr to match the driver's IPA ioremap */ - mr->virt_start += ROOT_MAP_OFFSET; + mr->virt_start += coloring_root_map_offset; /* Create an ad-hoc mapping just to load this image */ return arch_map_memory_region(&root_cell, mr); diff --git a/hypervisor/arch/arm64/include/asm/coloring.h b/hypervisor/arch/arm64/include/asm/coloring.h index 61def877..7d0ebaa9 100644 --- a/hypervisor/arch/arm64/include/asm/coloring.h +++ b/hypervisor/arch/arm64/include/asm/coloring.h @@ -17,6 +17,9 @@ #define _JAILHOUSE_COLORING_H #include <jailhouse/cell.h> +#include <jailhouse/cell-config.h> +#include <jailhouse/utils.h> +#include <jailhouse/control.h> #include <asm/cache_layout.h> #define col_print(fmt, ...) \ @@ -34,6 +37,9 @@ */ extern u64 coloring_way_size; +/** Temporary load-mapping parameter */ +extern u64 coloring_root_map_offset; + /** * Colored operations on a cell / memory region. * @@ -56,11 +62,19 @@ static inline void arm_color_dcache_flush_memory_region( } /** - * Autodetection of coloring_way_size. + * Detection of coloring way size. */ static inline void arm_color_init(void) { - coloring_way_size = arm_cache_layout_detect(); + coloring_way_size = system_config->platform_info.color.way_size; + if (coloring_way_size == 0) { + coloring_way_size = arm_cache_layout_detect(); + } + coloring_root_map_offset = + system_config->platform_info.color.root_map_offset; + + col_print("Way size: 0x%llx, TMP load addr: 0x%llx\n", + coloring_way_size, coloring_root_map_offset); } /* ------------------------- COLORING API ---------------------------------- */ diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h index e62e692b..5f786d57 100644 --- a/include/jailhouse/cell-config.h +++ b/include/jailhouse/cell-config.h @@ -132,8 +132,12 @@ struct jailhouse_memory { size_t colors; } __attribute__((packed)); -// FIXME: COLORING depending on design discussions, keep / remove / adapt -#define ROOT_MAP_OFFSET 0x0C000000000UL +struct jailhouse_coloring { + /* Size of a way to use for coloring, preferred to autoconfig */ + __u64 way_size; + /* Temp offset in the root cell to simplify loading of colored cells */ + __u64 root_map_offset; +} __attribute__((packed)); #define JAILHOUSE_SHMEM_NET_REGIONS(start, dev_id) \ { \ @@ -331,6 +335,7 @@ struct jailhouse_system { __u8 pci_is_virtual; __u16 pci_domain; struct jailhouse_iommu iommu_units[JAILHOUSE_MAX_IOMMU_UNITS]; + struct jailhouse_coloring color; union { struct { __u16 pm_timer_address; -- 2.29.2 -- 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/20201123204613.252563-8-andrea.bastoni%40tum.de.
