unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.33k stars 1.31k forks source link

Backport from qemu : fix do_nonatomic_op_* vs signed operations #1922

Closed redoste closed 5 months ago

redoste commented 5 months ago

This fix makes non-atomic versions of min/max operations aware of sign extension.

The following piece of RISC-V assembly was producing bogus results:

    la a0, .d
    li a2, 1

    amomin.w a5, a2, (a0)
    lw a6, 0(a0)
.d:
    .word -1

The expected result in a6 is -1 but without the fix the result is 1

wtdcode commented 5 months ago

Looks okay, simply wait for CI.