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

[Minios-devel] [UNIKRAFT PATCH v4 01/12] arch/*: Add STACK_MASK_TOP bit mask


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Fri, 22 Mar 2019 16:16:28 +0200
  • Cc: Florian.Schmidt@xxxxxxxxx
  • Delivery-date: Fri, 22 Mar 2019 14:16:48 +0000
  • Ironport-phdr: 9a23:jZXnPxDZCUC+Ujlm6OGMUyQJP3N1i/DPJgcQr6AfoPdwSPT+oMbcNUDSrc9gkEXOFd2Cra4d06yJ6uu9BiQp2tWoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6nK94iQPFRrhKAF7Ovr6GpLIj8Swyuu+54Dfbx9HiTagfb9+Nhe7oRjeusQWg4ZpN7o8xAbOrnZUYepd2HlmJUiUnxby58ew+IBs/iFNsP8/9MBOTLv3cb0gQbNXEDopPWY15Nb2tRbYVguA+mEcUmQNnRVWBQXO8Qz3UY3wsiv+sep9xTWaMMjrRr06RTiu86FmQwLuhSwaNTA27XvXh9RwgqxFvRyvqR9xzYnWb4GbL/dyYr/RcMkGSWdbQspdSypMCZ68YYsVCOoBOP5Vopf6p1sVsRu+BA+sD/7pxD9Vnn/2wLAx3uM9HgHBxwwgA9MOsHLOoNXxKacSSf21wbLUwjXYdf9WwSr955PSfhA7pvGBRLR9etffx0koEgPKlFSQqYr9MjyL0OQNr3Kb7uphWO+gkWInsBp+rz6yzckvkonEnp8Zx1/Z+Sljw4s4Jce0RFBlbdOmCpdduTmWO5Z5T88/WW1luyY3xqcYtZO1ciUG0okryhHBZ/GBboOG+AjsVPyLLjd9nH9lfbW/iAus/kW40e38U9W00E5NripYjtnArnAN2ALX6siAUvZ94EKh1iyO1wDX8O1LPVs0mbDDK5482bE8jIATsUPbEi/3nkX5krOWe1059uWn9ujreLbrq5+GO4NqlA3zML4il8KnDeQ9KAcOXmyb+eqm1L3k+E30WKlFjvotkqnFsZDaI94XpqqkAw9Nz4Yu8AqwDyy83NQAgHkIN0hJeAiAj4TxIVHBPOj4Deujg1SriDprwvHGPrvgApXKNXjPiarucqhj60FCzAo+1tRf55NPCrEdO/L/QEDwu8LeDhMjNAy02ennAs1n1owCQWKPHrOZMKTKvFGI4uIvJPOMZI4Ptzb7MfQr+uLhjX88mV8cYKapwYAaaHamEft6J0WWe2Hjjs0fHmcX7UICS7nviVuDViUWa3usUqYU4jAgFJngHYrFAIe3j++vxiC+S7ZRfXxHDBioDG/1P9GPXOwQaSTUJtJ5jxQPTv65VoVnzxb451yy8KZuMueBon5QjpnkztUgv+A=
  • Ironport-sdr: qO2Z/YbArnGgJ8U14JNCg7H5p08/zvcA3E/romfF/KKW9SGaud1ghuh5RM0bw5gZRArPcdIxS2 kCLtXBK6ziYQ==
  • 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 f1b58318..b11bf7d8 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 27f03cb9..9c70a81f 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 4ffb0027..e66a05b5 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 5b88065d..1e165c81 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 65401968..d34181be 100644
--- a/plat/xen/x86/entry64.S
+++ b/plat/xen/x86/entry64.S
@@ -63,7 +63,7 @@ _libxenplat_start:
 #endif
        cld
        movq stack_start(%rip),%rsp
-       andq $(~(__STACK_SIZE-1)), %rsp
+       andq $STACK_MASK_TOP, %rsp
        movq %rsi, %r8 /* esi contains pointer to start_info page */
        /* We will work on cr0 and cr4 multiple times.
         * We put cr0 into rsi and cr4 into rdi, because cpuid and
-- 
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®.