riscv: add multikernel architecture skeleton - #37
Conversation
congwang-mk
left a comment
There was a problem hiding this comment.
Two intent-vs-behavior mismatches in the RISC-V stubs, inline below.
| int mk_repark_instance_to_host(struct mk_instance *instance) | ||
| { | ||
| /* SBI HSM STOPPED harts are not parked on an instance-owned slot. */ | ||
| return 0; |
There was a problem hiding this comment.
mk_repark_instance_to_host() and mk_repark_cpu_to_instance() return 0 (success) while mk_arch_spawn_instance() and mk_arch_confirm_parked() return -EOPNOTSUPP. A generic-core caller that reparks a CPU will believe ownership transferred and proceed to hand the hart to/from an instance that was never actually parked. Returning -EOPNOTSUPP here matches the header comment ("fail explicitly instead of pretending that a hart moved").
There was a problem hiding this comment.
Fixed in dcc1932: all three RISC-V repark hooks now return -EOPNOTSUPP, so the generic core cannot treat an unsupported ownership transfer as successful.
|
|
||
| void __noreturn mk_enter_pool_state(void *info) | ||
| { | ||
| panic("RISC-V multikernel pool parking is not implemented"); |
There was a problem hiding this comment.
mk_enter_pool_state() panics the host. If the generic core reaches this on a CPU-pool path (it is the __noreturn hook other arches use when offlining a CPU into the pool), an unsupported operation takes down the whole host instead of failing the offline request. Same intent-vs-behavior mismatch: better to reject the pool transition earlier (e.g. from mk_arch_register_cpu() or a capability check) so this hook is never reached.
There was a problem hiding this comment.
Fixed in dcc1932 with a temporary ARCH_HAS_MK_POOL_STATE capability. x86 enables it; the RISC-V skeleton leaves it disabled. mk_do_cpu_remove() checks the capability before marking or offlining the CPU and returns -EOPNOTSUPP, so generic pool and hotplug removal paths cannot reach mk_enter_pool_state() on RISC-V. The rv64 Image build and an x86 focused hotplug build both pass.
Wire CONFIG_MULTIKERNEL into the 64-bit RISC-V build and add sparse hart ID translations. Reject the invalid hart sentinel before lookup so it cannot alias an unused logical CPU slot. Declare the generic contiguous-allocation and memory-hotplug dependencies so CONFIG_MULTIKERNEL cannot expose an unbuildable configuration. Reserve the architecture control block for the spawn context, DTB and entry stub. Provide safe stubs for the full architecture interface so the functional SBI HSM, Image loader and doorbell work can land incrementally. Signed-off-by: Nikolay Nikolaev <nicknickolaev@gmail.com>
614578b to
dcc1932
Compare
Summary
INVALID_HARTIDbefore lookupARCH_HAS_MK_POOL_STATE, selected by x86 but intentionally absent from the RISC-V skeletonScope
This is intentionally the compile/link skeleton from issue #22. Runtime SBI HSM spawn and parking, the I-cache entry stub, Image loading, DTB filtering, and the cross-kernel doorbell remain in their follow-up issues.
Unsupported ownership operations fail explicitly: every RISC-V repark hook returns
-EOPNOTSUPP, and the generic CPU-removal path rejects architectures without pool-state support before it marks or offlines a CPU.Validation
MULTIKERNELcannot remain enabled whileCONTIG_ALLOC,MEMORY_HOTPLUG, orMEMORY_HOTREMOVEis absentCONFIG_MULTIKERNEL=ywithARCH_HAS_MK_POOL_STATEdisabledarch/riscv/boot/Imageis readyCONFIG_ARCH_HAS_MK_POOL_STATE=yand compileskernel/multikernel/hotplug.oW=1builds for the RISC-V stubs and generic hotplug path on rv64 and x86Closes #22.