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

[Minios-devel] [UNIKRAFT PATCH 3/4] plat: Add ukplat_irq_stack() function


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 8 Jul 2019 00:09:26 +0300
  • Cc: felipe.huici@xxxxxxxxx, simon.kuenzer@xxxxxxxxx
  • Delivery-date: Sun, 07 Jul 2019 21:10:01 +0000
  • Ironport-phdr: 9a23:dpnjXRRkmiYJ8Mhba9veYTXGVdpsv+yvbD5Q0YIujvd0So/mwa6yYxyN2/xhgRfzUJnB7Loc0qyK6vqmAjxLuMjZ+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6KfroEYDOkcu3y/qy+5rOaAlUmTaxe7x/IAiooQnLuMQbgoRuJrswxxfVv3BFZ/lYyWR0KFyJgh3y/N2w/Jlt8yRRv/Iu6ctNWrjkcqo7ULJVEi0oP3g668P3uxbDSxCP5mYHXWUNjhVIGQnF4wrkUZr3ryD3q/By2CiePc3xULA0RTGv5LplRRP0lCsKMSMy/WfKgcJyka1bugqsqRxhzYDJbo+bN/1wcaHTfd4BWWZNQtxcWzBbD4+gc4cCCfcKM+ZCr4n6olsDtQWzBQ63BOPzyz9IgGL906sn0+Q5DAHNwQstEM4JsHTPsNX1NaESXfqxzKnV1TXDcuhb1ivm6ITSahAhvOqDUahqccrW0EQiER7OgFaIqYH9Ij+Y2fkBv3KY4udgT+6jlXArpgNrrjWh3ssgl4bEip8Pxl3H9Sh12pg5KNO2RUJhfNKpH4VcuieHPIVsWMwiWXtnuCMix70Dvp60YTYFxYw8xx7ad/yHa4+I4g//VOqJITd3mnZleLWnihas9Eiv0Oz8Vs2u3FlWtSpJiMHMtm0W2BDJ8MiHTeNx/kan2TmRywDe8vxILE8pmabBKJMswqQ8moQNvUnBBCP7ll36jKqMeUUl/uio5f7nYrLjppKEK4B0jRr+Mrgvmsy5G+g4NhUOX3CG+emnyLLj5lf1QK1XjvItiKXZqpfaKdwBpqGlGw9Vzpoj6xGnAjej0dQYm3gHLFVeeB6ekofmJU/OL+78Dfqkh1SskSxrx+zdPrH7DZTCMH7DnK3mfbZn5E5W0BAzwsxH55JIFrEBJ+r+WkHvu9zcDx85KxK7z/znCNVg14MRRWOPD7SfMKzMrVCI4vggLPKWaIALpTb3M+Il6OL2jX8lhV8derGk3YAWaHC9GfRmJV+VYXnxgtgfF2cLvxQxTPbxhV2ETzFce3KyULgn6T0hFo2mENSLeof4hb2H3SCgW5FbeG1CIlSNCmvzMZWJXbELci3BDNVml2kvUqO9Solp8Qy2qUeuwL18MuvSvCkFrY/L38Mz//DZ0ws1o28nR/+B2n2AGjkn1lgDQCU7ifhy
  • Ironport-sdr: vRqSywv9xlrI1Hlyn4G3440meUMpWO+ZATCmhCjurLivZuqQbTBSKanxXr268RU+6VGks/gAFo LoEMthW3dlKQ==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

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

 


Rackspace

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