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

[Minios-devel] [UNIKRAFT PATCH v2 1/8] arch/*: Add STACK_MASK_TOP bit mask


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Thu, 10 Jan 2019 17:22:05 +0200
  • Cc: felipe.huici@xxxxxxxxx, Florian.Schmidt@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx
  • Delivery-date: Thu, 10 Jan 2019 15:22:24 +0000
  • Ironport-phdr: 9a23:wxudARcH8OTBgivmW7r4CvTGlGMj4u6mDksu8pMizoh2WeGdxc26ZxaN2/xhgRfzUJnB7Loc0qyK6/CmATRIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfbB/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbDVwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4qF2QxHqlSgHLSY0/mHJhMJtgqxVoxWvqB5xw4PPfI2ZKOBzcr/HcN8GWWZMWNtaWSxbAoO7aosCF/QMPeFDr4nhplsOqwa1Cw+xBOP31z9Dm3j70rE90+Q6DQHG3QogE8gKsHTJtNX1KbwfXvyuzKXS1TXDcuhZ1S3n6IjPax0sp+yHU7x3ccrU00YvFgXFg02OpozjIzOVzOQMvmmU4uZ6TuKgkGgqoBxyrDi33sogl4bEip8Pxl3H9Sh12pg5KcO6RUJhb9OoCIZcui6HO4dsQc4vQ3tktDg0x7AIo5K3YScHxIohyhXCcfKIaZKI7QjmVOuJJDd4g29qd6ynihap9Eig1vX8Vs6p0FZWtiZFksfDtnQK1xHL9MiHT+Fy/kal2TqVyw/T8ftIIVgplaXAMZIh2LkwmoISsUTFACD2hF37gLKZe0k54OSl6OTqbq/4qpOCNYJ4kA/zPrwrmsOlAOQ4NgYOX3Kc+eS5zLDs4Ur5QK5Wjv03lKnVqpTaJdkDpq6kGAJazp0j5wynDze7y9sUh2MHLFVddBKdk4fpI03OIOz/DfqnhlSskTFrx/HBPr36G5nCM2bMkKn/crZ58ENczAszzctD55JPEL0AL+z8WknruNzfFB85PBS+w/z7B9VlyoMeRWWPD7eZPqPWtl+I/OMvLPOKZIMPpTjyN/gl5/vvjXAkhV8QZq+p0oULZ3C8BPtpOF+VbmTxgt0ZC2cFohI+TPD2iF2FSTNTaWi9X6Y95jEjFo2qF4fDRp2sgLOd3Se2BZtWaX5aBVCIC3jnbJ+IVOkRaCiKOM9ujiQEVaS9S48mzRyurw76y79gLurS4CEYto/j28Zz5+zSix4y7yd5D8KD3G6RS2F7hHgHSyUo06BiuUZ90EuM0bBkg/xEEtxe//NIUhogNZ7d1eB6FdfyWgbdcdeJS1amRcumDCo3Tt0v39AOZ1xyFM64gh/dwir5S4MSwrmKAp0z6efQ0mb8I+55ym3az+8xgl9gRdFAZkO8gasq3A/IG4/P22GEj7viIa8bxzLM8iGH0HKTlEpDFhZtW+PfWiZMNQPtsd3l6xaaHPeVArM9P14ZxA==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

STACK_MASK_TOP is used for getting the current stack address (e.g. sp &
STACK_MASK_TOP).

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
Reviewed-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 include/uk/arch/limits.h        | 2 ++
 lib/ukdebug/print.c             | 2 +-
 lib/uksched/include/uk/thread.h | 2 +-
 plat/xen/x86/arch_events.c      | 2 +-
 plat/xen/x86/entry64.S          | 2 +-
 5 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/uk/arch/limits.h b/include/uk/arch/limits.h
index f1b5831..b11bf7d 100644
--- a/include/uk/arch/limits.h
+++ b/include/uk/arch/limits.h
@@ -38,6 +38,8 @@
 
 #include <uk/asm/limits.h>
 
+#define STACK_MASK_TOP           (~(__STACK_SIZE - 1))
+
 #ifndef __ASSEMBLY__
 
 #include <uk/asm/intsizes.h>
diff --git a/lib/ukdebug/print.c b/lib/ukdebug/print.c
index 27f03cb..9c70a81 100644
--- a/lib/ukdebug/print.c
+++ b/lib/ukdebug/print.c
@@ -96,7 +96,7 @@ static void _print_stack(struct _vprint_console *cons)
        char buf[BUFLEN];
        int len;
 
-       stackb = (ukarch_read_sp() & ~(__STACK_SIZE - 1)) + __STACK_SIZE;
+       stackb = (ukarch_read_sp() & STACK_MASK_TOP) + __STACK_SIZE;
 
        len = snprintf(buf, BUFLEN, "<%p> ", (void *) stackb);
        cons->cout((char *)buf, len);
diff --git a/lib/uksched/include/uk/thread.h b/lib/uksched/include/uk/thread.h
index 4ffb002..e66a05b 100644
--- a/lib/uksched/include/uk/thread.h
+++ b/lib/uksched/include/uk/thread.h
@@ -70,7 +70,7 @@ struct uk_thread *uk_thread_current(void)
        struct uk_thread **current;
        unsigned long sp = ukarch_read_sp();
 
-       current = (struct uk_thread **) (sp & ~(__STACK_SIZE - 1));
+       current = (struct uk_thread **) (sp & STACK_MASK_TOP);
 
        return *current;
 }
diff --git a/plat/xen/x86/arch_events.c b/plat/xen/x86/arch_events.c
index 5b88065..1e165c8 100644
--- a/plat/xen/x86/arch_events.c
+++ b/plat/xen/x86/arch_events.c
@@ -49,7 +49,7 @@ void arch_init_events(void)
        cpu0_pda.irqcount = -1;
        cpu0_pda.irqstackptr =
                        (void *) (((unsigned long)irqstack + 2 * STACK_SIZE)
-                       & ~(STACK_SIZE - 1));
+                       & STACK_MASK_TOP);
 #endif
 }
 
diff --git a/plat/xen/x86/entry64.S b/plat/xen/x86/entry64.S
index c266804..be2f6e8 100644
--- a/plat/xen/x86/entry64.S
+++ b/plat/xen/x86/entry64.S
@@ -62,7 +62,7 @@ _libxenplat_start:
 #endif
         cld
         movq stack_start(%rip),%rsp
-        andq $(~(__STACK_SIZE-1)), %rsp
+        andq $STACK_MASK_TOP, %rsp
         movq %rsi,%rdi
         call _libxenplat_x86entry
 
-- 
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®.