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

Re: [Minios-devel] [UNIKRAFT PATCH v2 2/5] plat/*: Set current thread on IRQ stack



Hi Costin,

I was personally wondering whether this might be easier done by simply having a global variable "current_thread" or something like that (and then, eventually, with SMP, a per-cpu variable), because it means you don't have to implement platform-specific handlers for this. But on the other side, this is how the current setup works for normal threads, so I think this is fine. It can always be reconsidered at a later point.

Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>

On 5/29/19 6:56 AM, Costin Lupu wrote:
Current thread address is saved on the top of the current thread stack.
This patch extends this behavior for the interrupt stack in order to
access the current thread address from interrupt context as well.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
  include/uk/plat/memory.h | 6 ++++++
  plat/kvm/memory.c        | 6 ++++++
  plat/linuxu/memory.c     | 5 +++++
  plat/xen/memory.c        | 7 +++++++
  4 files changed, 24 insertions(+)

diff --git a/include/uk/plat/memory.h b/include/uk/plat/memory.h
index 1bb15685..4c4e4dc4 100644
--- a/include/uk/plat/memory.h
+++ b/include/uk/plat/memory.h
@@ -158,6 +158,12 @@ int ukplat_memallocator_set(struct uk_alloc *a);
   */
  struct uk_alloc *ukplat_memallocator_get(void);
+/**
+ * Sets the current thread address on top of kernel stack
+ * @param thread_addr Current thread address
+ */
+void ukplat_stack_set_current_thread(void *thread_addr);
+
  #ifdef __cplusplus
  }
  #endif
diff --git a/plat/kvm/memory.c b/plat/kvm/memory.c
index 7f2fb46a..e96bad2c 100644
--- a/plat/kvm/memory.c
+++ b/plat/kvm/memory.c
@@ -178,3 +178,9 @@ int _ukplat_mem_mappings_init(void)
  {
        return 0;
  }
+
+void ukplat_stack_set_current_thread(void *thread_addr)
+{
+       *((unsigned long *) _libkvmplat_cfg.bstack.end) =
+               (unsigned long) thread_addr;
+}
diff --git a/plat/linuxu/memory.c b/plat/linuxu/memory.c
index 35d0d95c..8bfb645d 100644
--- a/plat/linuxu/memory.c
+++ b/plat/linuxu/memory.c
@@ -74,3 +74,8 @@ int _ukplat_mem_mappings_init(void)
  {
        return 0;
  }
+
+void ukplat_stack_set_current_thread(void *thread_addr __unused)
+{
+       /* For now, signals use the current process stack */
+}
diff --git a/plat/xen/memory.c b/plat/xen/memory.c
index cb1c3552..8f170dd3 100644
--- a/plat/xen/memory.c
+++ b/plat/xen/memory.c
@@ -148,3 +148,10 @@ int _ukplat_mem_mappings_init(void)
  #endif
        return 0;
  }
+
+void ukplat_stack_set_current_thread(void *thread_addr)
+{
+       /* TODO revisit for HVM */
+       extern char irqstack[];
+       *((unsigned long *) irqstack) = (unsigned long) thread_addr;
+}


--
Dr. Florian Schmidt
フローリアン・シュミット
Research Scientist,
Systems and Machine Learning Group
NEC Laboratories Europe
Kurfürsten-Anlage 36, D-69115 Heidelberg
Tel.     +49 (0)6221 4342-265
Fax:     +49 (0)6221 4342-155
e-mail:  florian.schmidt@xxxxxxxxx
============================================================
Registered at Amtsgericht Mannheim, Germany, HRB728558

_______________________________________________
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®.