Skip to content
  • Stafford Horne's avatar
    e8f0ab0c
    target/openrisc: Do not reset delay slot flag on early tb exit · e8f0ab0c
    Stafford Horne authored
    
    
    This was found when running linux crypto algorithm selftests used by
    wireguard.  We found that randomly the tests would fail.  We found
    through investigation that a combination of a tick timer interrupt,
    raised when executing a delay slot instruction at a page boundary caused
    the issue.
    
    This was caused when handling the TB_EXIT_REQUESTED case in cpu_tb_exec.
    On OpenRISC, which doesn't implement synchronize_from_tb, set_pc was
    being used as a fallback.  The OpenRISC set_pc implementation clears
    dflag, which caused the exception handling logic to not account for the
    delay slot.  This was the bug, because it meant when execution resumed
    after the interrupt was handling it resumed in the wrong place.
    
    Fix this by implementing synchronize_from_tb which simply updates pc,
    and not clear the delay slot flag.
    
    Reported-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    Signed-off-by: default avatarStafford Horne <shorne@gmail.com>
    e8f0ab0c
    target/openrisc: Do not reset delay slot flag on early tb exit
    Stafford Horne authored
    
    
    This was found when running linux crypto algorithm selftests used by
    wireguard.  We found that randomly the tests would fail.  We found
    through investigation that a combination of a tick timer interrupt,
    raised when executing a delay slot instruction at a page boundary caused
    the issue.
    
    This was caused when handling the TB_EXIT_REQUESTED case in cpu_tb_exec.
    On OpenRISC, which doesn't implement synchronize_from_tb, set_pc was
    being used as a fallback.  The OpenRISC set_pc implementation clears
    dflag, which caused the exception handling logic to not account for the
    delay slot.  This was the bug, because it meant when execution resumed
    after the interrupt was handling it resumed in the wrong place.
    
    Fix this by implementing synchronize_from_tb which simply updates pc,
    and not clear the delay slot flag.
    
    Reported-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
    Signed-off-by: default avatarStafford Horne <shorne@gmail.com>
Loading