[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 12/23] plat/xen: Paravirtualization context - Yield thread to a previously interrupted thread
Saving the context for the yielding thread is the same as for software contexts. Restoring the context and resuming the execution of the next thread tries to mimic the same behaviour as for hardware contexts, but explicitly enabling events before returning to user. Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> --- plat/xen/Makefile.uk | 1 + plat/xen/include/xen-x86/pv_ctx.h | 3 +++ plat/xen/x86/entry64.S | 18 ++++++++++++++++++ plat/xen/x86/pv_ctx.c | 2 ++ 4 files changed, 24 insertions(+) diff --git a/plat/xen/Makefile.uk b/plat/xen/Makefile.uk index 57589e6f..aaf645f5 100644 --- a/plat/xen/Makefile.uk +++ b/plat/xen/Makefile.uk @@ -55,6 +55,7 @@ LIBXENPLAT_ASFLAGS-y += -DCONFIG_PARAVIRT LIBXENPLAT_CFLAGS-y += -DCONFIG_PARAVIRT LIBXENPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBXENPLAT_BASE)/x86/cpu_pv.c ifeq ($(CONFIG_HAVE_SCHED_PREEMPT),y) +LIBXENPLAT_ASINCLUDES-$(CONFIG_ARCH_X86_64) += -I$(UK_PLAT_COMMON_BASE)/x86 LIBXENPLAT_SRCS-$(CONFIG_ARCH_X86_64) += $(LIBXENPLAT_BASE)/x86/pv_ctx.c endif # CONFIG_HAVE_SCHED_PREEMPT else diff --git a/plat/xen/include/xen-x86/pv_ctx.h b/plat/xen/include/xen-x86/pv_ctx.h index c7a6fa63..b07c2be7 100644 --- a/plat/xen/include/xen-x86/pv_ctx.h +++ b/plat/xen/include/xen-x86/pv_ctx.h @@ -47,4 +47,7 @@ struct pv_ctx { void pv_ctx_callbacks_init(struct ukplat_ctx_callbacks *ctx_cbs); #endif +#define OFFSETOF_SW_CTX_SP 0 +#define OFFSETOF_SW_CTX_IP 8 + #endif /* __PLAT_XEN_PV_CTX_H__ */ diff --git a/plat/xen/x86/entry64.S b/plat/xen/x86/entry64.S index 0df593e5..c1bbdbe4 100644 --- a/plat/xen/x86/entry64.S +++ b/plat/xen/x86/entry64.S @@ -417,6 +417,24 @@ TRAP_ENTRY alignment_check, 1 TRAP_ENTRY simd_error, 0 /* no Virtualization Exception */ +#if CONFIG_HAVE_SCHED_PREEMPT +#include "thread_macros.S" + +ENTRY(asm_pv_ctx_switch_yld2intd) + PROTECTED_REGS_SAVE # save current protected regs + movq %rsp, OFFSETOF_SW_CTX_SP(%rdi) # save current SP + movq OFFSETOF_SW_CTX_SP(%rsi), %rsp # restore next SP + movq $1f, OFFSETOF_SW_CTX_IP(%rdi) # save current IP + + XEN_GET_VCPU_INFO(%rax) # safe to use rax since it is saved + XEN_LOCKED_UNBLOCK_EVENTS(%rax) # enable events + + RESTORE_ALL + HYPERVISOR_IRET +1: + PROTECTED_REGS_RESTORE + ret +#endif /* CONFIG_HAVE_SCHED_PREEMPT */ #ifndef CONFIG_PARAVIRT .data diff --git a/plat/xen/x86/pv_ctx.c b/plat/xen/x86/pv_ctx.c index 9203e6de..603fdf15 100644 --- a/plat/xen/x86/pv_ctx.c +++ b/plat/xen/x86/pv_ctx.c @@ -99,6 +99,7 @@ static void pv_ctx_start(void *ctx) } extern void asm_sw_ctx_switch(void *prevctx, void *nextctx); +extern void asm_pv_ctx_switch_yld2intd(void *prevctx, void *nextctx); static void pv_ctx_switch(void *prevctx, void *nextctx) { @@ -130,6 +131,7 @@ static void pv_ctx_switch(void *prevctx, void *nextctx) if (next_hw_ctx->interrupted) { /* switching yielding to interrupted */ next_hw_ctx->interrupted = false; + asm_pv_ctx_switch_yld2intd(prevctx, nextctx); } else /* switching yielding to yielding */ -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |