You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/30 16:00:54 UTC

[GitHub] [incubator-nuttx] pussuw commented on a change in pull request #5917: arch/risc-v: move REGLOAD/REGSTORE macro to riscv_internal.h

pussuw commented on a change in pull request #5917:
URL: https://github.com/apache/incubator-nuttx/pull/5917#discussion_r838715537



##########
File path: arch/risc-v/src/common/riscv_swint.c
##########
@@ -109,45 +109,24 @@ static void riscv_registerdump(const uintptr_t *regs)
 
 #ifdef CONFIG_LIB_SYSCALL
 static void dispatch_syscall(void) naked_function;
-#ifdef CONFIG_ARCH_RV64
 static void dispatch_syscall(void)
 {
   asm volatile
     (
-     " addi sp, sp, -8\n"         /* Create a stack frame to hold ra */
-     " sd   ra, 0(sp)\n"          /* Save ra in the stack frame */
-     " la   t0, g_stublookup\n"   /* t0=The base of the stub lookup table */
-     " slli a0, a0, 3\n"          /* a0=Offset for the stub lookup table */
-     " add  t0, t0, a0\n"         /* t0=The address in the table */
-     " ld   t0, 0(t0)\n"          /* t0=The address of the stub for this syscall */
-     " jalr ra, t0\n"             /* Call the stub (modifies ra) */
-     " ld   ra, 0(sp)\n"          /* Restore ra */
-     " addi sp, sp, 8\n"          /* Destroy the stack frame */
-     " mv   a2, a0\n"             /* a2=Save return value in a0 */
-     " li   a0, 3\n"              /* a0=SYS_syscall_return (3) */
-     " ecall"                     /* Return from the syscall */
+     "addi sp, sp, -" REGSSIZE "\n" /* Create a stack frame to hold ra */

Review comment:
       Using the register size here is incorrect. The stack pointer has separate alignment requirements, and in this case a 16B alignment should be ensured, if FPU is in use, if I remember correctly. 
   
   It is IMO simpler to just make a 16B stack frame here. Every other place I could find does this, and this is what I did for the S-mode patch too. There is a macro for this too in riscv_internal.h `STACK_ALIGNMENT`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org