Skip to content

riscv spawn: halt/reboot must HART_STOP every hart, never SRST #25

Description

@congwang-mk

Part of the RISC-V port. Prerequisite for the first spawn boot that reaches userspace.

machine_halt(), machine_power_off() and machine_restart() in arch/riscv/kernel/reset.c end in sbi_srst_reset() (SRST extension) or legacy SBI_EXT_0_1_SHUTDOWN, both of which act on the whole machine. A spawn kernel running the stock path powers off or resets the host.

  • Spawn-side override (mirror of mk_spawn_reboot_init() in arch/x86/multikernel/spawn.c:1732): halt/power-off/restart = every hart calls HART_STOP; the last hart too. Never SRST, never legacy shutdown, never emergency_restart() through SRST.
  • Skip register_platform_power_off(sbi_shutdown) (sbi.c:151) and the sbi_srst_reboot_nb notifier when booted as a spawn.
  • smp_send_stop() parks other harts in wait_for_interrupt() inside the image (arch/riscv/kernel/smp.c:86), the "hart still executing the image we are about to overwrite" hazard. Route the stop handler to HART_STOP in a spawn.
  • panic() paths: panic_timeout reboot must also go through the override.
  • mk_instance_settle_halted() completion = HART_STATUS == STOPPED for every instance hart.

Test: poweroff and reboot inside a spawn leave the host running and every instance hart STOPPED.

Metadata

Metadata

Assignees

No one assigned

    Labels

    riscvriscv port

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions