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

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


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Tue, 18 Sep 2018 18:27:22 +0300
  • Cc: felipe.huici@xxxxxxxxx, florian.schmidt@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx
  • Delivery-date: Tue, 18 Sep 2018 15:27:41 +0000
  • Ironport-phdr: 9a23:InEwsBJeVI4f2yO5qdmcpTZWNBhigK39O0sv0rFitYgXKv/5rarrMEGX3/hxlliBBdydt6obzbKO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZLebxlKiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr0yRD+s7bpkSAXwhSkHKTA37W/ZhM93gq1ZrhKsvABzz5LObY2JLvdyYr/RcNUHTmRBRMZRUClBD5uiYosIFOoBIedYr4/grFUIsBu+HRSsD/7oxzBUgX/2xrE60+UnEQ3c2AwgAsoOsGnPodrpL6ceS/i1zLTTwjnZdfNW3i7w5Y7VeR4vpvGMWKh/ccvXyUQ3CQzFiEmQqZblPj6U2ekBqXOb4PFmWOmyiGAnsxl8riWgy8sxkIXEhYIYxkra+Slnwos5P9O1RFZmbdOrDZdcrSKXOotsTs88TWxltjw2xqAJtJKleiUB1Y4pyATFa/OddoiF+hfjVOGMLjhmnH9lY7e/hwqq8Uin1+38StG40FZUoSpBldnBrm4N1xnJ5ciGTvtx5Fuu2S2V2wDL9+FLOlo4lbDcK5I5w74wkIQcsVjbEyPrl0j6kbWae0Yk9+Sy9ejrfLfrqoWSOoNsjwHxKKUumsixAeQiNQgOWnCW9vi71L344U35QbNKgucykqnEqJDaON8WqbKiAwNPyoYj9g2wAy280NQfhXUHNk5KeAqbj4j1PFHDOPX4Dfa5g1Stlzdr3OnKMaD/DZXTMHfDlKzsfbJ8605H1Aoz1spT5p1KBbEHOv7zXVXxtNPABB8jLwO02/rnCMl61o4GV2KAHKuZMKLKsVCW/O4vI/SMZI4Jtzb8MPUl4eDhgmM9mVAHZqalx4UYaG2gFPR8P0qZeWbsgssGEWoSsAo+SOvqiEeDUTFJYXa+Rbk86S07CIKjDIfMW5ytjaeH3CilApJWYnpJBUuWHXj2aoWOQ+0MZz6KIs99jjwEUqCsS5Qg1RGrsw/6zaBrLunJ+iIGs5Li1cZ65/fImBE06zN7E8Cd3HuWQG1ugGwIWic83Lpjrkxl1leDza94juRYFNxO/fNJUx02NYDbz+x+F9/yWgHBftCXSFu9RNWpHy0+TtYrzNAVeUpyBcii3Vj/2H+vArkUkKfOCJEq/6b023nqO90723vAkq47gAoIWMxKYEahnbJ+8UD3GpbU2xGSkL22dKJa2DPV6U+I1iyWoUseSgkmAvaNZmwWekaD9Yex3UjFVbL7Ubk=
  • 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>
---
 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 a0683ad..18aba2e 100644
--- a/include/uk/arch/limits.h
+++ b/include/uk/arch/limits.h
@@ -49,6 +49,8 @@
 #include <uk/arch/arm/arm64/limits.h>
 #endif
 
+#define STACK_MASK_TOP           (~(__STACK_SIZE - 1))
+
 #ifndef __ASSEMBLY__
 
 #ifdef __X86_32__
diff --git a/lib/ukdebug/print.c b/lib/ukdebug/print.c
index 6f98d28..31bce98 100644
--- a/lib/ukdebug/print.c
+++ b/lib/ukdebug/print.c
@@ -100,7 +100,7 @@ static void _printd_stack(void)
        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);
        _ukplat_coutd((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®.