[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
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |