[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


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 8 Jul 2019 11:33:35 +0300
  • Cc: felipe.huici@xxxxxxxxx, simon.kuenzer@xxxxxxxxx
  • Delivery-date: Mon, 08 Jul 2019 08:50:15 +0000
  • Ironport-phdr: 9a23:p1qbUR/zQhq8bf9uRHKM819IXTAuvvDOBiVQ1KB20+McTK2v8tzYMVDF4r011RmVBN+dt6oP07aempujcFRI2YyGvnEGfc4EfD4+ouJSoTYdBtWYA1bwNv/gYn9yNs1DUFh44yPzahANS47xaFLIv3K98yMZFAnhOgppPOT1HZPZg9iq2+yo9JDffhtEiCCybL9uIxm6sQrcvdQKjIV/Lao81gHHqWZSdeRMwmNoK1OTnxLi6cq14ZVu7Sdete8/+sBZSan1cLg2QrJeDDQ9LmA6/9brugXZTQuO/XQTTGMbmQdVDgff7RH6WpDxsjbmtud4xSKXM9H6QawyVD+/6apgVR3mhzodNzMh8G/ZlNF+gqxYrhympRN/zZXZbJ2JOPdkYq/QZ88WSXZHU81MVyJBGIS8b44XAucfOuZYtJX9p1oIrRCjAwesGfvvyiJVjXLxwaI61P8hER3H3AwmBd4OtGnUrM3oNKoJTe+117PEzS3eb/xNwzv98o/IfwknrPqRU7xwds/RxlMuFwPDlliQspDlMCmP1uQRqWSb9PFvWOSygGAkswF8uiWjy8gxhoXThY8YykrI+TtnzIs3P9G1RlZ3bcOrHZdNrS2XNIt7Ttk8T2xmtis20KAKtJGlcCUM1Z8p3QTQa+adfIiN+h/jUeGRLipmi399Y7K/ggqy8VCnyu3hSsm4yFZKoTRBktnLrn0NyRnT5dKGSvt55EuuxS2P2xrL6uFZOk84j7DbK5k5zr4xkJocr1jDEzfrlEj5kaOabEYp9+iy5+j5fLnrpIWQOoFshgH7KKsum8i/AeoiMggJWmiW4fiz1Lr4/U3lQbVKiOc6kq3EsJDCOMQWvbK2AxRP3oY79hawFC2q0M4fnXUfNlJKZAqHj5T1O1HJOP34CPa/g1KtkDds3PDKJ6DuDYvTLnfdlLfsZrJ9609HyAov1tBT/Z1VBa8HIP7pXU/xrtPYBAcjMwOo2+bnFMl91oQGVGKBHKCZNKLSsUeW6e41I+mMeY4Vtyr8K/U+4f7hk2M2mVsHcqayx5cYdm24FOx8I0qFeXrsnssBEWASswolTezqjVqCUThJa3axQqIz+Dc7CYO4AofZXY2thqKO0zu/HpJMfW9KEE6DEWq7P7mDDvINbiOVOYptnyIJUZClSpQ9zle+uQm8zKBofcTO/ShNnpX4yNlzr8nOjQx6oTdzFNic1SeJUnlptmgTAScr1uZlphoumR+4zaFkjqkARpRo7PRTX1JiOA==
  • Ironport-sdr: n705LJtie5WxmT/oJrO4I8fZOinKcnhdHpB+4dL3/opxcSvKBneFKtzh9XEBkjCbhK3cj8zQts PQpL0bv9FTFw==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

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

 


Rackspace

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