[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 05/23] plat: Hardware context - Yield thread to a previously yielding thread


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 8 Jul 2019 11:33:34 +0300
  • Cc: felipe.huici@xxxxxxxxx, simon.kuenzer@xxxxxxxxx
  • Delivery-date: Mon, 08 Jul 2019 08:50:15 +0000
  • Ironport-phdr: 9a23:S3LzixCbFslBVGViJw+OUyQJP3N1i/DPJgcQr6AfoPdwSPX7rsbcNUDSrc9gkEXOFd2Cra4d0ayK6+u4BSQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagf79+Nhq7oRneusUKjoZpN7o8xAbOrnZUYepd2HlmJUiUnxby58ew+IBs/iFNsP8/9MBOTLv3cb0gQbNXEDopPWY15Nb2tRbYVguA+mEcUmQNnRVWBQXO8Qz3UY3wsiv+sep9xTWaMMjrRr06RTiu86FmQwLuhSwaNTA27XvXh9RwgqxFvRyvqR9xzYnWb4GbL/dyYr/RcMkGSWdbQspdSypMCZ68YYsVCOoBOP5Vopf6p1sVsRu+BA+sD/7pxD9Vnn/2wLAx3uM9HgHBxwwgA9MOsHLOoNXxKacSSf21wbLUwjXYdf9WwSr955PSfhA7pvGBRLR9etffx0koEgPKlFSQqYr9MjOOyuQCqXKb7/Z6WeK0kGEqrRx6rDu3xso0l4XEiZ8ZxkrH+Ch52oo5O8O0RUxhbdOqCJdcqi6XO5ZsTs4hQ2xkojg2x7MItJKhYSQHx4oryhjCYPKdaYeI+AjsVOOJLDd9g3JqZaywig6p8Uil1u38Ts600EtWriZdktnDqHQN1xvL58iZT/ty5Eah2TKV2w/P8eFIO1g0lbfAJJI72L4wkYIfsUXFHiDohEX7lLKae0o59uSy6OnqYq/qqoGCO4J2kA3zPLwimsmlDuQ5NggOUXKb+eO51LD74UL5R65KjuE3kqnfqpzaIdkbprakAwJOzokj8AyzDy+70NsDh3UHNlVFdAqdj4f1I1HOPOz4DfCnjlSpkTdrwfHGPrr6ApnUM3fMjqnhcqh560NHzAozzMtf545PCr0bL/P8REnxuMbfDh8jPAy+2/znB8ll1oMCRWKPBbeUMK3Mvl+M5+IvO/eDaJUVuDbgKvgq+//ugGQ/mVADYaap2YEYZ2uiEvt4PkWTeWDsjcsZEWcWogo+S/TniEaDUT5WYHayWbgw5jImCI24C4fCR56igKaa0Se9AJJZemRGBUqXHnvyaYqERqREVCXHJ85nkzsfELSsVYIl/RWvrxPhjapqKKzT4CJLm4jk0Y1e4PbPlBd60SFsEozJ2GaWU2By2GcVXyIe17s5uVF3jE2Eh/sry8dEHMBesqsaGjwxMoTRmrR3
  • Ironport-sdr: dtJUJgDkS4KgL9C/KXmjKmFWCwnWKD38+R/tW0PigrcLUmcZv7QVlV88hrNdGUojATeB/6VDNL Al99d1eTvKRQ==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

This is the switching scenario that also occurs for cooperative scheduling,
therefore the isn't anything special with it. We just use the hardware context
instead of the software context.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 plat/common/x86/hw_ctx.c       | 10 ++++++++++
 plat/common/x86/thread_start.S | 12 ++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/plat/common/x86/hw_ctx.c b/plat/common/x86/hw_ctx.c
index 778e546d..edee3aee 100644
--- a/plat/common/x86/hw_ctx.c
+++ b/plat/common/x86/hw_ctx.c
@@ -90,6 +90,8 @@ void hw_ctx_start(void *ctx)
        UK_CRASH("Thread did not start.");
 }
 
+extern void asm_hw_ctx_switch(void *prevctx, void *nextctx);
+
 static void hw_ctx_switch(void *prevctx, void *nextctx)
 {
        struct hw_ctx *prev_hw_ctx = prevctx;
@@ -101,6 +103,14 @@ static void hw_ctx_switch(void *prevctx, void *nextctx)
                /* IRQ context */
                prev_hw_ctx->interrupted = true;
                next_hw_ctx->interrupted = false;
+
+       } else {
+               /* yielding */
+               if (next_hw_ctx->interrupted) {
+
+               } else
+                       /* switching yielding to yielding */
+                       asm_hw_ctx_switch(prevctx, nextctx);
        }
 }
 
diff --git a/plat/common/x86/thread_start.S b/plat/common/x86/thread_start.S
index 105691ee..363d86c3 100644
--- a/plat/common/x86/thread_start.S
+++ b/plat/common/x86/thread_start.S
@@ -68,3 +68,15 @@ ENTRY(asm_sw_ctx_switch)
 1:
        PROTECTED_REGS_RESTORE
        ret
+
+ENTRY(asm_hw_ctx_switch)
+       PROTECTED_REGS_SAVE
+       movq %rsp, OFFSETOF_REGS_RSP(%rdi)       /* save ESP */
+       movq OFFSETOF_REGS_RSP(%rsi), %rsp       /* restore ESP */
+       movq $1f, OFFSETOF_REGS_RIP(%rdi)        /* save EIP */
+       pushq OFFSETOF_REGS_RIP(%rsi)            /* restore EIP */
+       ret
+1:
+       PROTECTED_REGS_RESTORE
+       ret
+
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.