aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2021-08-04 16:40:57 -0700
committerAndrew Waterman <andrew@sifive.com>2021-08-04 16:40:57 -0700
commit423801e35d048187d88fcbff55e20c4c34d27bee (patch)
tree6e39eea46e888224935fa940a19beeb6a2eb5fde
parent50b6b6cc28f7a7252bbd3841222d37737ce28451 (diff)
downloadriscv-pk-423801e35d048187d88fcbff55e20c4c34d27bee.zip
riscv-pk-423801e35d048187d88fcbff55e20c4c34d27bee.tar.gz
riscv-pk-423801e35d048187d88fcbff55e20c4c34d27bee.tar.bz2
Revert "machine: fix a case of undefined behaviour with SP handling (#245)"
This reverts commit 5450c2f731f16abe3a4f244c383c55f559c97359.
-rw-r--r--machine/mtrap.h11
1 files changed, 3 insertions, 8 deletions
diff --git a/machine/mtrap.h b/machine/mtrap.h
index e9ef139..a8dbeff 100644
--- a/machine/mtrap.h
+++ b/machine/mtrap.h
@@ -48,14 +48,9 @@ typedef struct {
volatile uint32_t* plic_s_ie;
} hls_t;
-#define STACK_POINTER() ({ \
- uintptr_t __sp; \
- __asm__("mv %0, sp" : "=r"(__sp)); \
- __sp; \
-})
-
-#define MACHINE_STACK_TOP() \
- ({ (void*)((STACK_POINTER() + RISCV_PGSIZE) & -RISCV_PGSIZE); })
+#define MACHINE_STACK_TOP() ({ \
+ register uintptr_t sp asm ("sp"); \
+ (void*)((sp + RISCV_PGSIZE) & -RISCV_PGSIZE); })
// hart-local storage, at top of stack
#define HLS() ((hls_t*)(MACHINE_STACK_TOP() - HLS_SIZE))