aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaj Vishwanathan <raj.vishwanathan@gmail.com>2025-02-11 13:46:39 -0800
committerAnup Patel <anup@brainfault.org>2025-02-12 09:14:43 +0530
commit4f12f8b02f669e7cd3286a543f2cb6308fe5a0fe (patch)
tree9472319ec5c4e31171473d2f353de057cc1f4475
parent3f25380d85df0c8b8f188d23d0f80a560b416fb3 (diff)
downloadopensbi-4f12f8b02f669e7cd3286a543f2cb6308fe5a0fe.zip
opensbi-4f12f8b02f669e7cd3286a543f2cb6308fe5a0fe.tar.gz
opensbi-4f12f8b02f669e7cd3286a543f2cb6308fe5a0fe.tar.bz2
include: sbi: Align SBI trap registers to a nice boundary
Align SBI_TRAP_CONTEXT_SIZE to a multiple of 16 bytes. If it is not aligned to 16 bytes for RV64, it can create performance problems. Aligning it correctly can fix the performance issues. Signed-off-by: Raj Vishwanathan <Raj.Vishwanathan@gmail.com> Reviewed-by: Anup Patel <anup@brainfault.org>
-rw-r--r--include/sbi/sbi_trap.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/sbi/sbi_trap.h b/include/sbi/sbi_trap.h
index d5182bf..5eec4da 100644
--- a/include/sbi/sbi_trap.h
+++ b/include/sbi/sbi_trap.h
@@ -112,10 +112,13 @@
/** Size (in bytes) of sbi_trap_info */
#define SBI_TRAP_INFO_SIZE SBI_TRAP_INFO_OFFSET(last)
+#define STACK_BOUNDARY 16
+#define ALIGN_TO_BOUNDARY(x, a) (((x) + (a) - 1) & ~((a) - 1))
+
/** Size (in bytes) of sbi_trap_context */
-#define SBI_TRAP_CONTEXT_SIZE (SBI_TRAP_REGS_SIZE + \
+#define SBI_TRAP_CONTEXT_SIZE ALIGN_TO_BOUNDARY((SBI_TRAP_REGS_SIZE + \
SBI_TRAP_INFO_SIZE + \
- __SIZEOF_POINTER__)
+ __SIZEOF_POINTER__), STACK_BOUNDARY)
#ifndef __ASSEMBLER__