From d81b35d85ca7c051e9935b1aca7c44ffaa4b9851 Mon Sep 17 00:00:00 2001 From: Jia He Date: Fri, 14 May 2021 09:21:12 +0800 Subject: [PATCH] plat/arm64: Fix extregs allocation on Arm MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Implement the extregs (currently only fpsimd registers) allocation related helpers. Otherwise, Unikraft can't be built on Arm kvm plat due to the missing of several helpers. Signed-off-by: Jia He Reviewed-by: Răzvan Vîrtan Tested-by: Unikraft CI GitHub-Pull-Request: #206 --- plat/common/include/arm/arm64/cpu.h | 35 +++++++++++------------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/plat/common/include/arm/arm64/cpu.h b/plat/common/include/arm/arm64/cpu.h index e82f8fba1..153d45a8c 100644 --- a/plat/common/include/arm/arm64/cpu.h +++ b/plat/common/include/arm/arm64/cpu.h @@ -169,24 +169,19 @@ static inline void restore_extregs(struct sw_ctx *ctx) fpsimd_restore_state(ctx->extregs); } -static inline struct sw_ctx *arch_alloc_sw_ctx(struct uk_alloc *allocator) +static inline void arch_init_extregs(struct sw_ctx *ctx) { - struct sw_ctx *ctx; - - ctx = (struct sw_ctx *)uk_malloc(allocator, - sizeof(struct sw_ctx) + sizeof(struct fpsimd_state)); if (ctx) - ctx->extregs = (uintptr_t)((void *)ctx + sizeof(struct sw_ctx)); + ctx->extregs = (uintptr_t)ctx->_extregs; uk_pr_debug("Allocating %lu + %lu bytes for sw ctx at %p, extregs at %p\n", - sizeof(struct sw_ctx), sizeof(struct fpsimd_state), - ctx, (void *)ctx->extregs); - - return ctx; + sizeof(struct sw_ctx), sizeof(struct fpsimd_state), + ctx, (void *)ctx->extregs); } -static inline void arch_init_extregs(struct sw_ctx *ctx __unused) +static inline __sz arch_extregs_size(void) { + return sizeof(struct fpsimd_state); } #else /* !CONFIG_FPSIMD */ @@ -198,21 +193,17 @@ static inline void restore_extregs(struct sw_ctx *ctx __unused) { } -static inline struct sw_ctx *arch_alloc_sw_ctx(struct uk_alloc *allocator) +static inline void arch_init_extregs(struct sw_ctx *ctx) { - struct sw_ctx *ctx; - - ctx = (struct sw_ctx *)uk_malloc(allocator, sizeof(struct sw_ctx)); - uk_pr_debug("Allocating %lu bytes for sw ctx at %p\n", - sizeof(struct sw_ctx), ctx); - - return ctx; + if (ctx) + ctx->extregs = (uintptr_t)ctx->_extregs; } -static inline void arch_init_extregs(struct sw_ctx *ctx) +static inline __sz arch_extregs_size(void) { - ctx->extregs = (uintptr_t)ctx + sizeof(struct sw_ctx); + return 0; } - #endif /* CONFIG_FPSIMD */ + + #endif /* __PLAT_COMMON_ARM64_CPU_H__ */ -- 2.39.5