kernel: Synchronize instructions before context execution

b6ea2575fc2c9418e52f9a25dfdf17ab51030cb1bbba1f134f8e4c7f18822da3
Alexis Sellier committed ago 1 parent 3342aa20
kernel/kernel/dispatch.rad +2 -0
393 393
    frame: &mut trap::Frame, anchor: &mut trap::Hart, now: u64) -> Choice throws (abi::Error)
394 394
{
395 395
    let choice = try select(windows, contexts, state.hart, now);
396 396
    save(state, contexts, frame);
397 397
    if let next = choice.context {
398 +
        // The metadata lock makes published code visible before local fetch synchronization.
399 +
        sync::syncInstructions();
398 400
        let context = contexts.contexts[next.index];
399 401
        assert context.kernelStack.start < context.kernelStack.end;
400 402
        set *frame = context.frame;
401 403
        set anchor.stackBottom = context.kernelStack.start;
402 404
        set anchor.stackTop = context.kernelStack.end;