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

[Minios-devel] [UNIKRAFT PATCH 02/23] plat: Hardware context - Set exception stack when switching to a new thread


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 8 Jul 2019 11:33:31 +0300
  • Cc: felipe.huici@xxxxxxxxx, simon.kuenzer@xxxxxxxxx
  • Delivery-date: Mon, 08 Jul 2019 08:50:15 +0000
  • Ironport-phdr: 9a23:B8gtgRLAfq5pOKhj3tmcpTZWNBhigK39O0sv0rFitYgeLfnxwZ3uMQTl6Ol3ixeRBMOHsqgC17Kd6/yocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmSSxbal9IRmqogndqsYbipZ+J6gszRfEvmFGcPlMy2NyIlKTkRf85sOu85Nm7i9dpfEv+dNeXKvjZ6g3QqBWAzogM2Au+c3krgLDQheV5nsdSWoZjBxFCBXY4R7gX5fxtiz6tvdh2CSfIMb7Q6w4VSik4qx2ThLjlSUJOCMj8GzPisJ+kr9VrhyiqRJ4wYHUbpqYOOZicq7HYd8XX3ZNUtpXWidcAo28dYwPD+8ZMOtGqIn9vEcOrRq4BQKxAu3v1ydIhmLr1qA9z+shFhrG3BAhH9IIqnjUqMj1NL8PUe2u0KbI1i/Pb+tL2Tjm8oTIaBchrOiKULltcsTR0VEiGx7Kg1mNs4DoPDOY2v4Tv2SF7edsT+yih3Y6pwx+vzSj3MQhh4nTio4LxF3J+z91zJs6KNGmTkNwfMSqH4FKty6AMot7WsYiQ2Z1tykk0rAGopu7fDQSyJQg2h7fd+SLc4iW7RLnU+acOSl4hHd/d7K+gxa+61SvyvbmWsmszVZFtTBJksPLtnwV1hzT7NaISudl80u81juDyhrf5+JELEwui6bXNZwszqQ+m5YLtETMBC72mEH4jK+McUUk//Cl5PjgYrX9up+cNol0hhv6MqQzgsy/HP81PRQVX2SB4eS8yabs8VfjQLVNlvE2iLXWsIjGJcQHoa60GwpV0ocl6xa+CDemy80UkmQZI1JbZh2Hi5PkO1XPIPDjEfe/mE6gkTh1yPDAJLHhBY/NLnfbmrf7Ybl981JcyBY0zd1H6ZJbFLUBIPPrWkDvrtDYDgI5Mw2ozObmE9h90J0RVn6LAqCDK6zeq0GH5v83KemWeIAVoCr9K+Qi5/P2ln85mFodfa6v3ZcNa3C4A+ppI0OYYHXymNcMCmEKsRQiQ+zuklKNSiRfaGivX/F02jZuDYOgDIDYA4ygnrGF9CO6BYFNIHBLDBaLC3i7WZ+DXqInbzmOI8kptiEcSPD1QIg6yRCo8gvn06dPJfGS4jAS84jkgosmr9bPnA0/oGQnR/+W1HuAGjl5
  • Ironport-sdr: D8tPkQafQOXR49rTmDQGtVKqDdRlKbeg/zL3knC8ttwxJuktTXv77sj16/EDMxxT57l/nJBDCo E0MjDupDxCuw==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

On x86, whenever an exception is generated, SS, SP, EFLAGS, CS and IP registers
are pushed on a stack that needs to be configured beforehand. We keep such an
exception stack for each thread in the system. This patch introduces the
traps_set_interrupt_stack() function used for setting the exception stack.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 plat/common/include/x86/traps.h | 1 +
 plat/common/x86/hw_ctx.c        | 2 ++
 plat/kvm/x86/traps.c            | 4 ++++
 3 files changed, 7 insertions(+)

diff --git a/plat/common/include/x86/traps.h b/plat/common/include/x86/traps.h
index b217b34a..fcd1697e 100644
--- a/plat/common/include/x86/traps.h
+++ b/plat/common/include/x86/traps.h
@@ -109,6 +109,7 @@ void do_##name(struct __regs *regs, unsigned long 
error_code) \
 
 void traps_init(void);
 void traps_fini(void);
+void traps_set_interrupt_stack(void *stack_address);
 
 #endif
 
diff --git a/plat/common/x86/hw_ctx.c b/plat/common/x86/hw_ctx.c
index c7b8dbac..e82beb5f 100644
--- a/plat/common/x86/hw_ctx.c
+++ b/plat/common/x86/hw_ctx.c
@@ -84,6 +84,8 @@ static void hw_ctx_switch(void *prevctx, void *nextctx)
        struct hw_ctx *prev_hw_ctx = prevctx;
        struct hw_ctx *next_hw_ctx = nextctx;
 
+       traps_set_interrupt_stack(&next_hw_ctx->regs + 1);
+
        if (ukplat_irq_context()) {
                /* IRQ context */
                prev_hw_ctx->interrupted = true;
diff --git a/plat/kvm/x86/traps.c b/plat/kvm/x86/traps.c
index fe1dd5a4..a3653c8a 100644
--- a/plat/kvm/x86/traps.c
+++ b/plat/kvm/x86/traps.c
@@ -93,6 +93,10 @@ static void tss_init(void)
        );
 }
 
+void traps_set_interrupt_stack(void *stack_address)
+{
+       cpu_tss.ist[0] = (__u64) stack_address;
+}
 
 /* Declare the traps used only by this platform: */
 DECLARE_TRAP_EC(nmi,           "NMI")
-- 
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®.