From 9f644579b38c3978e7a8a6636acf1179a34676c1 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Mon, 17 Jul 2023 16:33:37 +0800 Subject: [PATCH] fix sim register & tcb info typo Signed-off-by: anjiahao --- arch/sim/include/setjmp.h | 16 +++++++++------- fs/procfs/fs_procfstcbinfo.c | 2 +- include/nuttx/sched.h | 4 +++- libs/libc/machine/sim/arch_setjmp_x86_64.S | 6 +++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/arch/sim/include/setjmp.h b/arch/sim/include/setjmp.h index 7e510ef005..879e31c0f2 100644 --- a/arch/sim/include/setjmp.h +++ b/arch/sim/include/setjmp.h @@ -49,7 +49,7 @@ # define JB_R13 (4*8) # define JB_R14 (5*8) # define JB_R15 (6*8) -# define JB_RSI (7*8) +# define JB_RIP (7*8) # define JB_FLAG (8*8) # else @@ -61,7 +61,7 @@ # define JB_R13 (4) # define JB_R14 (5) # define JB_R15 (6) -# define JB_RSI (7) +# define JB_RIP (7) # define JB_FLAG (8) # endif /* __ASSEMBLY__ */ @@ -70,7 +70,7 @@ # define JB_FP JB_RBP # define JB_SP JB_RSP -# define JB_PC JB_RSI +# define JB_PC JB_RIP #elif defined(CONFIG_HOST_X86) || defined(CONFIG_SIM_M32) /* Storage order: %ebx, %esi, %edi, %ebp, sp, and return PC */ @@ -84,8 +84,8 @@ # define JB_ESI (1*4) # define JB_EDI (2*4) # define JB_EBP (3*4) -# define JB_SP (4*4) -# define JB_PC (5*4) +# define JB_ESP (4*4) +# define JB_EIP (5*4) # define JB_FLAG (6*4) # define JB_FLAG1 (7*4) @@ -95,8 +95,8 @@ # define JB_ESI (1) # define JB_EDI (2) # define JB_EBP (3) -# define JB_SP (4) -# define JB_PC (5) +# define JB_ESP (4) +# define JB_EIP (5) # define JB_FLAG (6) # define JB_FLAG1 (7) @@ -105,6 +105,8 @@ /* Compatibility definitions */ # define JB_FP JB_EBP +# define JB_SP JB_ESP +# define JB_PC JB_EIP #elif defined(CONFIG_HOST_ARM) diff --git a/fs/procfs/fs_procfstcbinfo.c b/fs/procfs/fs_procfstcbinfo.c index ce65726e60..083fde59f0 100644 --- a/fs/procfs/fs_procfstcbinfo.c +++ b/fs/procfs/fs_procfstcbinfo.c @@ -195,7 +195,7 @@ static ssize_t tcbinfo_read(FAR struct file *filep, FAR char *buffer, if (filep->f_pos == 0) { linesize = procfs_snprintf(attr->line, TCBINFO_LINELEN, - "pointer %p size %d\n", &g_tcbinfo, + "pointer %p size %zu\n", &g_tcbinfo, sizeof(struct tcbinfo_s)); /* Save the linesize in case we are re-entered with f_pos > 0 */ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index a0815966ac..e56ca2bcc2 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -183,7 +183,9 @@ # define TCB_NAME_OFF 0 #endif # define TCB_REGS_OFF offsetof(struct tcb_s, xcp.regs) -# define TCB_REG_OFF(reg) (reg * sizeof(uint32_t)) +# define TCB_REG_OFF(reg) (reg * sizeof(uintptr_t)) +# define TCB_STACK_OFF offsetof(struct tcb_s, stack_base_ptr) +# define TCB_STACK_SIZE_OFF offsetof(struct tcb_s, adj_stack_size) #endif /* Get a pointer to the process' memory map struct from the task_group */ diff --git a/libs/libc/machine/sim/arch_setjmp_x86_64.S b/libs/libc/machine/sim/arch_setjmp_x86_64.S index 0dccb23980..cc747f8f8a 100644 --- a/libs/libc/machine/sim/arch_setjmp_x86_64.S +++ b/libs/libc/machine/sim/arch_setjmp_x86_64.S @@ -110,7 +110,7 @@ SYMBOL(setjmp): movq %r13, JB_R13(REGS) /* Save 5: r13 */ movq %r14, JB_R14(REGS) /* Save 6: r14 */ movq %r15, JB_R15(REGS) /* Save 7: r15 */ - movq %rsi, JB_RSI(REGS) /* Save 8: Return address */ + movq %rsi, JB_RIP(REGS) /* Save 8: Return address */ ret @@ -139,9 +139,9 @@ SYMBOL(longjmp): movq JB_R14(REGS),%r14 /* Load 6: r14 */ movq JB_R15(REGS),%r15 /* Load 7: rbp */ - /* Jump to the saved return address (rsi) */ + /* Jump to the saved return address (rip) */ - jmp *JB_RSI(REGS) + jmp *JB_RIP(REGS) #ifdef __ELF__ .size SYMBOL(longjmp), . - SYMBOL(longjmp)