|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 3/4] plat: Add ukplat_irq_stack() function
On interrupts, a stack different than the stack of the interrupted thread may
be used, depending on the virtualization platoform. The ukplat_irq_stack()
function retrieves the address of this stack. This patch also introduces
ukplat_irq_context() function which returns non-zero if running in interrupt
context.
Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
include/uk/plat/memory.h | 17 +++++++++++++++++
plat/kvm/x86/memory.c | 5 +++++
plat/xen/memory.c | 9 ++++++++-
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/include/uk/plat/memory.h b/include/uk/plat/memory.h
index 4c4e4dc4..a2cd1492 100644
--- a/include/uk/plat/memory.h
+++ b/include/uk/plat/memory.h
@@ -164,6 +164,23 @@ struct uk_alloc *ukplat_memallocator_get(void);
*/
void ukplat_stack_set_current_thread(void *thread_addr);
+/**
+ * Interrupt stack address
+ * @return Address of the stack
+ */
+void *ukplat_irq_stack(void);
+
+/**
+ * Returns non-zero if running in interrupt context.
+ * @return Non-zero if running in interrupt context.
+ */
+static inline int ukplat_irq_context(void)
+{
+ unsigned long sp = ukarch_read_sp();
+
+ return ((sp & STACK_MASK_TOP) == (unsigned long) ukplat_irq_stack());
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/plat/kvm/x86/memory.c b/plat/kvm/x86/memory.c
index b8c7c7e7..a16f2f5d 100644
--- a/plat/kvm/x86/memory.c
+++ b/plat/kvm/x86/memory.c
@@ -42,3 +42,8 @@ void ukplat_stack_set_current_thread(void *thread_addr)
*((unsigned long *) cpu_intr_stack) =
(unsigned long) thread_addr;
}
+
+void *ukplat_irq_stack(void)
+{
+ return (void *) cpu_intr_stack;
+}
diff --git a/plat/xen/memory.c b/plat/xen/memory.c
index 8f170dd3..c3d224dc 100644
--- a/plat/xen/memory.c
+++ b/plat/xen/memory.c
@@ -149,9 +149,16 @@ int _ukplat_mem_mappings_init(void)
return 0;
}
+extern char irqstack[];
+
void ukplat_stack_set_current_thread(void *thread_addr)
{
/* TODO revisit for HVM */
- extern char irqstack[];
*((unsigned long *) irqstack) = (unsigned long) thread_addr;
}
+
+void *ukplat_irq_stack(void)
+{
+ /* TODO revisit for HVM */
+ return irqstack;
+}
--
2.11.0
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |