[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 06/23] plat: Hardware context - Yield thread to a previously interrupted thread
Saving the context for the yielding thread is not a problem here. What's worth saying here is that we have to setup the same context for the scheduled thread as it was when it was preempted. That is why we have to use the interrupt stack and continue running from its previously save continuation. Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> --- plat/common/x86/hw_ctx.c | 4 ++++ plat/common/x86/thread_start.S | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/plat/common/x86/hw_ctx.c b/plat/common/x86/hw_ctx.c index edee3aee..fd46fbe3 100644 --- a/plat/common/x86/hw_ctx.c +++ b/plat/common/x86/hw_ctx.c @@ -91,6 +91,7 @@ void hw_ctx_start(void *ctx) } extern void asm_hw_ctx_switch(void *prevctx, void *nextctx); +extern void asm_hw_ctx_switch_yld2intd(void *prevctx, void *nextctx); static void hw_ctx_switch(void *prevctx, void *nextctx) { @@ -107,6 +108,9 @@ static void hw_ctx_switch(void *prevctx, void *nextctx) } else { /* yielding */ if (next_hw_ctx->interrupted) { + /* switching yielding to interrupted */ + next_hw_ctx->interrupted = false; + asm_hw_ctx_switch_yld2intd(prevctx, nextctx); } else /* switching yielding to yielding */ diff --git a/plat/common/x86/thread_start.S b/plat/common/x86/thread_start.S index 363d86c3..bb2a8b22 100644 --- a/plat/common/x86/thread_start.S +++ b/plat/common/x86/thread_start.S @@ -80,3 +80,19 @@ ENTRY(asm_hw_ctx_switch) PROTECTED_REGS_RESTORE ret +ENTRY(asm_hw_ctx_switch_yld2intd) + PROTECTED_REGS_SAVE /* save current protected regs */ + movq %rsp, OFFSETOF_REGS_RSP(%rdi) /* save current SP */ + movq $1f, OFFSETOF_REGS_RIP(%rdi) /* save current IP */ + + /* Load the kernel stack */ + call ukplat_irq_stack + mov %rax, %rsp + /* Load thread continuation */ + mov OFFSETOF_REGS_PAD(%rsi), %rax + pushq %rax + ret +1: + PROTECTED_REGS_RESTORE + ret + -- 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 |