Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Documentation/guides/concurrency/fork_vfork_migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ Five architectures do it, and they are worth copying:
* arm64: ``arm64_vectors.S`` hands the frame to ``dispatch_syscall()``, which
stores it in ``xcp.sregs``; ``arm64_fork()`` then dispatches to
``arm64_fork_syscall()`` or ``arm64_fork_direct()`` according to whether
``TCB_FLAG_SYSCALL`` is set, so a kernel thread that calls the entry point
``TCB_EXEC_SYSCALL`` is set, so a kernel thread that calls the entry point
directly still works.
* armv7-a: ``arm_syscall.c`` stores the frame in ``xcp.sregs``, and
``arm_fork()`` dispatches to ``arm_fork_syscall()`` or
``arm_fork_direct()``. The discriminator here is a saved user stack
pointer, ``xcp.ustkptr``, rather than ``TCB_FLAG_SYSCALL``: armv7-a
pointer, ``xcp.ustkptr``, rather than ``TCB_EXEC_SYSCALL``: armv7-a
dispatches a system call by re-pointing the caller's own exception frame at
``dispatch_syscall()``, so the caller *is* the task that runs the kernel
side of the call. What makes its snapshot useless is not the system call
Expand All @@ -181,7 +181,7 @@ Five architectures do it, and they are worth copying:
* x86_64: ``x86_64_syscall()`` stores the frame in ``xcp.sregs``, and
``x86_64_fork()`` dispatches to ``x86_64_fork_syscall()`` or
``x86_64_fork_direct()``. The discriminator here is ``xcp.sregs`` itself
being non-NULL, because raising ``TCB_FLAG_SYSCALL`` would also defer signal
being non-NULL, because raising ``TCB_EXEC_SYSCALL`` would also defer signal
actions -- something x86_64 has never done and its kernel-build signal path
does not currently survive. Two properties of ``SYSCALL``/``SYSRET`` shape
the child's frame: the instruction leaves the caller's RIP and RFLAGS in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Here is the body of some function. It expects to have the following inputs:
* stack will be used.
*/

tcb->flags = TCB_FLAG_TTYPE_KERNEL | TCB_FLAG_CUSTOM_STACK;
tcb->exec_flags = TCB_FLAG_TTYPE_KERNEL;
tcb->flags = TCB_FLAG_CUSTOM_STACK;

/* Allocate the custom stack for the new kernel thread.
*
Expand Down
4 changes: 2 additions & 2 deletions Documentation/os/scheduling/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ gets it only while round robin is switched off, that is, while
most board configurations set a positive value, so in most of those
configurations a new task gets ``SCHED_RR``.
``nxthread_setup_scheduler()`` picks the policy for every new TCB with a
compile-time test, not a runtime one: ``TCB_FLAG_SCHED_RR`` and a timeslice
compile-time test, not a runtime one: ``SCHED_RR`` and a timeslice
of ``CONFIG_RR_INTERVAL`` when that value is positive,
``TCB_FLAG_SCHED_FIFO`` otherwise. So ``CONFIG_RR_INTERVAL`` is not a
``SCHED_FIFO`` otherwise. So ``CONFIG_RR_INTERVAL`` is not a
per-thread opt-in; setting it changes the default policy of the whole
system.

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm/arm_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void up_initial_state(struct tcb_s *tcb)
*/

#ifdef CONFIG_BUILD_KERNEL
if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
if ((tcb->exec_flags & TCB_EXEC_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep exec_flags and macro name as before to reduce the chanage

{
/* It is a kernel thread.. set supervisor mode */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/arm_a_r/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void arm_sigdeliver(void)
#endif

if (!sq_empty(&rtcb->sigpendactionq) &&
(rtcb->flags & TCB_FLAG_SIGNAL_ACTION) == 0)
(rtcb->exec_flags & TCB_EXEC_SIGNAL_ACTION) == 0)
{
#ifdef CONFIG_SMP
leave_critical_section(regs[REG_CPSR]);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/arm_a_r/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ uint32_t *arm_syscall(uint32_t *regs)
* the system call.
*/

rtcb->flags &= ~TCB_FLAG_SYSCALL;
rtcb->exec_flags &= ~TCB_EXEC_SYSCALL;
nxsig_unmask_pendingsignal();
regs = tcb->xcp.regs;
}
Expand Down Expand Up @@ -500,7 +500,7 @@ uint32_t *arm_syscall(uint32_t *regs)

/* Indicate that we are in a syscall handler. */

rtcb->flags |= TCB_FLAG_SYSCALL;
rtcb->exec_flags |= TCB_EXEC_SYSCALL;

#ifdef CONFIG_ARCH_KERNEL_STACK
/* If this is the first SYSCALL and if there is an allocated
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/arm_a_r/arm_userfault.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ bool arm_fault_kill(uint32_t *regs)
struct tcb_s *tcb = this_task();
struct tcb_s *ptcb;

if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL ||
(tcb->flags & TCB_FLAG_SYSCALL) != 0 ||
if ((tcb->exec_flags & TCB_EXEC_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL ||
(tcb->exec_flags & TCB_EXEC_SYSCALL) != 0 ||
(regs[REG_CPSR] & PSR_MODE_MASK) != PSR_MODE_USR)
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void arm_sigdeliver(void)
#endif

if (!sq_empty(&rtcb->sigpendactionq) &&
(rtcb->flags & TCB_FLAG_SIGNAL_ACTION) == 0)
(rtcb->exec_flags & TCB_EXEC_SIGNAL_ACTION) == 0)
{
#ifdef CONFIG_SMP
leave_critical_section((uint16_t)regs[REG_PRIMASK]);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/armv6-m/arm_svcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ int arm_svcall(int irq, void *context, void *arg)
* the system call.
*/

rtcb->flags &= ~TCB_FLAG_SYSCALL;
rtcb->exec_flags &= ~TCB_EXEC_SYSCALL;
nxsig_unmask_pendingsignal();
}
break;
Expand Down Expand Up @@ -345,7 +345,7 @@ int arm_svcall(int irq, void *context, void *arg)

/* Indicate that we are in a syscall handler. */

rtcb->flags |= TCB_FLAG_SYSCALL;
rtcb->exec_flags |= TCB_EXEC_SYSCALL;
#else
svcerr("ERROR: Bad SYS call: %" PRId32 "\n", regs[REG_R0]);
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-m/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void arm_sigdeliver(void)
#endif

if (!sq_empty(&rtcb->sigpendactionq) &&
(rtcb->flags & TCB_FLAG_SIGNAL_ACTION) == 0)
(rtcb->exec_flags & TCB_EXEC_SIGNAL_ACTION) == 0)
{
#ifdef CONFIG_SMP
leave_critical_section((uint8_t)regs[REG_BASEPRI]);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/armv7-m/arm_svcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int arm_svcall(int irq, void *context, void *arg)
* the system call.
*/

rtcb->flags &= ~TCB_FLAG_SYSCALL;
rtcb->exec_flags &= ~TCB_EXEC_SYSCALL;
nxsig_unmask_pendingsignal();
}
break;
Expand Down Expand Up @@ -347,7 +347,7 @@ int arm_svcall(int irq, void *context, void *arg)

/* Indicate that we are in a syscall handler. */

rtcb->flags |= TCB_FLAG_SYSCALL;
rtcb->exec_flags |= TCB_EXEC_SYSCALL;
#else
svcerr("ERROR: Bad SYS call: %" PRId32 "\n", regs[REG_R0]);
#endif
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/armv7-r/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ uint32_t *arm_syscall(uint32_t *regs)
* the system call.
*/

rtcb->flags &= ~TCB_FLAG_SYSCALL;
rtcb->exec_flags &= ~TCB_EXEC_SYSCALL;
nxsig_unmask_pendingsignal();
regs = tcb->xcp.regs;
}
Expand Down Expand Up @@ -513,7 +513,7 @@ uint32_t *arm_syscall(uint32_t *regs)

/* Indicate that we are in a syscall handler. */

rtcb->flags |= TCB_FLAG_SYSCALL;
rtcb->exec_flags |= TCB_EXEC_SYSCALL;

#ifdef CONFIG_ARCH_KERNEL_STACK
/* If this is the first SYSCALL and if there is an allocated
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv8-m/arm_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void arm_sigdeliver(void)
#endif

if (!sq_empty(&rtcb->sigpendactionq) &&
(rtcb->flags & TCB_FLAG_SIGNAL_ACTION) == 0)
(rtcb->exec_flags & TCB_EXEC_SIGNAL_ACTION) == 0)
{
#ifdef CONFIG_SMP
leave_critical_section((uint8_t)regs[REG_BASEPRI]);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/armv8-m/arm_svcall.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int arm_svcall(int irq, void *context, void *arg)
* the system call.
*/

rtcb->flags &= ~TCB_FLAG_SYSCALL;
rtcb->exec_flags &= ~TCB_EXEC_SYSCALL;
nxsig_unmask_pendingsignal();
}
break;
Expand Down Expand Up @@ -352,7 +352,7 @@ int arm_svcall(int irq, void *context, void *arg)

/* Indicate that we are in a syscall handler. */

rtcb->flags |= TCB_FLAG_SYSCALL;
rtcb->exec_flags |= TCB_EXEC_SYSCALL;
#else
svcerr("ERROR: Bad SYS call: %" PRId32 "\n", regs[REG_R0]);
#endif
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/armv8-r/arm_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ uint32_t *arm_syscall(uint32_t *regs)
* the system call.
*/

rtcb->flags &= ~TCB_FLAG_SYSCALL;
rtcb->exec_flags &= ~TCB_EXEC_SYSCALL;
nxsig_unmask_pendingsignal();
regs = tcb->xcp.regs;
}
Expand Down Expand Up @@ -518,7 +518,7 @@ uint32_t *arm_syscall(uint32_t *regs)

/* Indicate that we are in a syscall handler. */

rtcb->flags |= TCB_FLAG_SYSCALL;
rtcb->exec_flags |= TCB_EXEC_SYSCALL;

#ifdef CONFIG_ARCH_KERNEL_STACK
/* If this is the first SYSCALL and if there is an allocated
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/common/arm_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ pid_t arm_fork(bool vfork, const struct fork_s *context)

if (parent->xcp.ustkptr != NULL)
{
DEBUGASSERT((parent->flags & TCB_FLAG_SYSCALL) != 0);
DEBUGASSERT((parent->exec_flags & TCB_EXEC_SYSCALL) != 0);
return arm_fork_syscall(vfork, parent);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/common/arm_usestack.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
{
/* Yes... Release the old stack allocation */

up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK);
up_release_stack(tcb, tcb->exec_flags & TCB_EXEC_TTYPE_MASK);
}

/* The ARM uses a "full descending" stack:
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/tlsr82/tc32/tc32_initialstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void up_initial_state(struct tcb_s *tcb)
*/

#ifdef CONFIG_BUILD_KERNEL
if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
if ((tcb->exec_flags & TCB_EXEC_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
{
/* It is a kernel thread.. set supervisor mode */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/common/arm64_addrenv_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ int up_addrenv_select(const arch_addrenv_t *addrenv)
#if defined(CONFIG_MM_TASK_HEAP) && !defined(CONFIG_ARCH_STACK_PROTECT)
struct tcb_s *tcb = this_task();

if ((atomic_read(&tcb->flags) & TCB_FLAG_TTYPE_MASK) !=
if ((tcb->exec_flags & TCB_EXEC_TTYPE_MASK) !=
TCB_FLAG_TTYPE_KERNEL)
{
mpu_update(tcb);
Expand Down
5 changes: 3 additions & 2 deletions arch/arm64/src/common/arm64_fatal.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,8 +646,9 @@ uint64_t *arm64_fatal_handler(uint64_t *regs)

if (ret != 0)
{
if (((tcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) &&
((tcb->flags & TCB_FLAG_SYSCALL) == 0) &&
if (((tcb->exec_flags & TCB_EXEC_TTYPE_MASK) !=
TCB_FLAG_TTYPE_KERNEL) &&
((tcb->exec_flags & TCB_EXEC_SYSCALL) == 0) &&
((regs[REG_SPSR] & SPSR_MODE_MASK) == SPSR_MODE_EL0T))
{
struct tcb_s *ptcb;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/common/arm64_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ pid_t arm64_fork(bool vfork, const struct fork_s *context)
* that called into arm64_fork_func.S.
*/

if ((parent->flags & TCB_FLAG_SYSCALL) != 0)
if ((parent->exec_flags & TCB_EXEC_SYSCALL) != 0)
{
return arm64_fork_syscall(vfork, parent);
}
Expand Down
3 changes: 2 additions & 1 deletion arch/arm64/src/common/arm64_sigdeliver.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void arm64_sigdeliver(void)

irqstate_t flags;
int16_t saved_irqcount;

flags = (rtcb->xcp.saved_regs[REG_SPSR] & SPSR_DAIF_MASK);
#endif

Expand Down Expand Up @@ -132,7 +133,7 @@ void arm64_sigdeliver(void)
#endif

if (!sq_empty(&rtcb->sigpendactionq) &&
(rtcb->flags & TCB_FLAG_SIGNAL_ACTION) == 0)
(rtcb->exec_flags & TCB_EXEC_SIGNAL_ACTION) == 0)
{
#ifdef CONFIG_SMP
leave_critical_section(flags);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/src/common/arm64_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ uintptr_t dispatch_syscall(unsigned int nbr, uintptr_t parm1,

/* Indicate that we are in a syscall handler */

rtcb->flags |= TCB_FLAG_SYSCALL;
rtcb->exec_flags |= TCB_EXEC_SYSCALL;

/* Offset a0 to account for the reserved syscalls */

Expand All @@ -157,7 +157,7 @@ uintptr_t dispatch_syscall(unsigned int nbr, uintptr_t parm1,

/* System call is now done */

rtcb->flags &= ~TCB_FLAG_SYSCALL;
rtcb->exec_flags &= ~TCB_EXEC_SYSCALL;

/* Unmask any pending signals now */

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/common/arm64_usestack.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
{
/* Yes... Release the old stack allocation */

up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK);
up_release_stack(tcb, tcb->exec_flags & TCB_EXEC_TTYPE_MASK);
}

/* The ARM uses a "full descending" stack:
Expand Down
2 changes: 1 addition & 1 deletion arch/avr/src/avr/avr_usestack.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
{
/* Yes.. Release the old stack allocation */

up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK);
up_release_stack(tcb, tcb->exec_flags & TCB_EXEC_TTYPE_MASK);
}

/* Save the new stack allocation */
Expand Down
2 changes: 1 addition & 1 deletion arch/avr/src/avr32/avr_usestack.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
{
/* Yes.. Release the old stack allocation */

up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK);
up_release_stack(tcb, tcb->exec_flags & TCB_EXEC_TTYPE_MASK);
}

/* Save the new stack allocation */
Expand Down
4 changes: 3 additions & 1 deletion arch/ceva/src/common/ceva_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pid_t ceva_fork(const uint32_t *regs)
/* Allocate the stack for the TCB */

ret = up_create_stack(child, stacksize + argsize,
parent->flags & TCB_FLAG_TTYPE_MASK);
parent->exec_flags & TCB_EXEC_TTYPE_MASK);
if (ret != OK)
{
serr("ERROR: up_create_stack failed: %d\n", ret);
Expand Down Expand Up @@ -171,6 +171,7 @@ pid_t ceva_fork(const uint32_t *regs)
regs[REG_FP] >= (uint32_t)parent->stack_base_ptr - stacksize)
{
uint32_t frameutil = (uint32_t)parent->stack_base_ptr - regs[REG_FP];

newfp = (uint32_t)child->stack_base_ptr - frameutil;
}
else
Expand Down Expand Up @@ -201,6 +202,7 @@ pid_t ceva_fork(const uint32_t *regs)
if (parent->xcp.nsyscalls > 0)
{
int index;

for (index = 0; index < parent->xcp.nsyscalls; index++)
{
child->xcp.syscall[index] = parent->xcp.syscall[index];
Expand Down
2 changes: 1 addition & 1 deletion arch/ceva/src/common/ceva_usestack.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
{
/* Yes... Release the old stack allocation */

up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK);
up_release_stack(tcb, tcb->exec_flags & TCB_EXEC_TTYPE_MASK);
}

/* Save the new stack allocation */
Expand Down
2 changes: 1 addition & 1 deletion arch/hc/src/common/hc_usestack.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size)
{
/* Yes.. Release the old stack allocation */

up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK);
up_release_stack(tcb, tcb->exec_flags & TCB_EXEC_TTYPE_MASK);
}

/* Save the new stack allocation */
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/src/common/mips_usestack.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
{
/* Yes.. Release the old stack allocation */

up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK);
up_release_stack(tcb, tcb->exec_flags & TCB_EXEC_TTYPE_MASK);
}

/* Save the new stack allocation */
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/src/mips32/mips_swint0.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ int mips_swint0(int irq, void *context, void *arg)
* the system call.
*/

rtcb->flags &= ~TCB_FLAG_SYSCALL;
rtcb->exec_flags &= ~TCB_EXEC_SYSCALL;
nxsig_unmask_pendingsignal();
}
break;
Expand Down Expand Up @@ -262,7 +262,7 @@ int mips_swint0(int irq, void *context, void *arg)

/* Indicate that we are in a syscall handler. */

rtcb->flags |= TCB_FLAG_SYSCALL;
rtcb->exec_flags |= TCB_EXEC_SYSCALL;
#else
svcerr("ERROR: Bad SYS call: %" PRId32 "\n", regs[REG_A0]);
#endif
Expand Down
Loading
Loading