[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH] plat/common: Zero out extregs area when creating new thread
Instructions such as xsave and xsaveopt, which are designed to save the extended registers on recent x86 CPUs do not guarantee that they touch the complete xsave header area, but rather only the bits that the need to set. This can lead to invalid xsave header areas if the area is not zeroed out before use, which in turn leads to GP traps on xrstor. Note that simply zeroing out the area is not enough, because an all-zero xsave legacy region is also invalid. Thanks to Radu Nicolau for reporting this bug. Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx> --- plat/common/sw_ctx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plat/common/sw_ctx.c b/plat/common/sw_ctx.c index c69f5fde..06795244 100644 --- a/plat/common/sw_ctx.c +++ b/plat/common/sw_ctx.c @@ -34,6 +34,7 @@ #include <stdint.h> #include <stdlib.h> +#include <string.h> #include <uk/plat/thread.h> #include <uk/alloc.h> #include <sw_ctx.h> @@ -70,7 +71,8 @@ static void *sw_ctx_create(struct uk_alloc *allocator, unsigned long sp) ctx->ip = (unsigned long) asm_thread_starter; ctx->extregs = ALIGN_UP(((uintptr_t)ctx + sizeof(struct sw_ctx)), x86_cpu_features.extregs_align); - // Initialize the extregs area by saving a valid register layout to it + // Initialize extregs area: zero out, then save a valid layout to it. + memset((void *)ctx->extregs, 0, x86_cpu_features.extregs_size); save_extregs(ctx); return ctx; -- 2.21.0 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |