arm/common: fix KERNEL build vfork
This fixes vfork test for kernel build, checked with qemu-armv7a:nsh and qemu-armv7a:knsh Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
This commit is contained in:
parent
b973bf3191
commit
d385d9f7d2
1 changed files with 11 additions and 6 deletions
|
|
@ -98,6 +98,11 @@ pid_t arm_fork(const struct fork_s *context)
|
|||
uint32_t newtop;
|
||||
uint32_t stacktop;
|
||||
uint32_t stackutil;
|
||||
#ifdef CONFIG_ARCH_KERNEL_STACK
|
||||
uint32_t oldsp = (uint32_t)parent->xcp.ustkptr;
|
||||
#else
|
||||
uint32_t oldsp = context->sp;
|
||||
#endif
|
||||
|
||||
sinfo("fork context [%p]:\n", context);
|
||||
sinfo(" r4:%08" PRIx32 " r5:%08" PRIx32
|
||||
|
|
@ -106,7 +111,7 @@ pid_t arm_fork(const struct fork_s *context)
|
|||
sinfo(" r8:%08" PRIx32 " r9:%08" PRIx32 " r10:%08" PRIx32 "\n",
|
||||
context->r8, context->r9, context->r10);
|
||||
sinfo(" r11:%08" PRIx32 " sp:%08" PRIx32 " lr:%08" PRIx32 "\n",
|
||||
context->r11, context->sp, context->lr);
|
||||
context->r11, oldsp, context->lr);
|
||||
|
||||
/* Allocate and initialize a TCB for the child task. */
|
||||
|
||||
|
|
@ -127,8 +132,8 @@ pid_t arm_fork(const struct fork_s *context)
|
|||
|
||||
stacktop = (uint32_t)parent->stack_base_ptr +
|
||||
parent->adj_stack_size;
|
||||
DEBUGASSERT(stacktop > context->sp);
|
||||
stackutil = stacktop - context->sp;
|
||||
DEBUGASSERT(stacktop > oldsp && oldsp >= (uint32_t)parent->stack_base_ptr);
|
||||
stackutil = stacktop - oldsp;
|
||||
|
||||
sinfo("Parent: stackutil:%" PRIu32 "\n", stackutil);
|
||||
|
||||
|
|
@ -151,11 +156,11 @@ pid_t arm_fork(const struct fork_s *context)
|
|||
|
||||
child->cmn.xcp.regs = (void *)(newsp - XCPTCONTEXT_SIZE);
|
||||
|
||||
memcpy((void *)newsp, (const void *)context->sp, stackutil);
|
||||
memcpy((void *)newsp, (const void *)oldsp, stackutil);
|
||||
|
||||
/* Was there a frame pointer in place before? */
|
||||
|
||||
if (context->fp >= context->sp && context->fp < stacktop)
|
||||
if (context->fp >= oldsp && context->fp < stacktop)
|
||||
{
|
||||
uint32_t frameutil = stacktop - context->fp;
|
||||
newfp = newtop - frameutil;
|
||||
|
|
@ -166,7 +171,7 @@ pid_t arm_fork(const struct fork_s *context)
|
|||
}
|
||||
|
||||
sinfo("Old stack top:%08" PRIx32 " SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
|
||||
stacktop, context->sp, context->fp);
|
||||
stacktop, oldsp, context->fp);
|
||||
sinfo("New stack top:%08" PRIx32 " SP:%08" PRIx32 " FP:%08" PRIx32 "\n",
|
||||
newtop, newsp, newfp);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue