Skip to content
  • Jan Kiszka's avatar
    cobalt/thread: Move xnthread_signal work off the stack · 850b3789
    Jan Kiszka authored
    
    
    Unlike the I-pipe, Dovetail does not copy the work descriptor but
    merely hands over the request to the common irq_work() mechanism. We
    must guarantee that such descriptor lives in a portion of memory which
    won't go stale until the handler has run, which by design can only
    happen once the calling out-of-band context unwinds.
    
    Therefore, we have to create signal slots per possible cause in the
    thread's control block in order to overcome sigwork in xnthread_signal.
    
    For SIGDEBUG, we are only interested in the very first event coming in,
    so one slot is enough. All SIGSHADOW_* events need their own slot:
    SIGSHADOW_ACTION_HARDEN and SIGSHADOW_ACTION_HOME can be raised by
    remote threads asynchronously to the target thread.
    SIGSHADOW_ACTION_BACKTRACE comes in addition to SIGDEBUG_MIGRATE_*. For
    the latter reason, SIGSHADOW_ACTION_BACKTRACE cannot pile up though.
    
    Including SIGTERM, we have totally 5 slots.
    
    To ensure that multiple asynchronous signals on the same slot do not
    overwrite each other (e.g. SIGSHADOW_ACTION_HOME or SIGDEBUG reasons),
    synchronize the slot usage under nklock. Create a __xnthread_signal
    variant that can be called from already locked contexts (the majority of
    xnthread_signal users).
    
    Based on original patch by Hongzhan Chen.
    
    Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
    850b3789