qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Merge remote-tracking branch 'remotes/riscv/tags/riscv-qemu-2.12-critical-fixes' into staging

RISC-V: Critical fixes for QEMU 2.12

This series includes changes that are considered release critical,
such as floating point register file corruption under SMP Linux
due to incorrect handling of mstatus.FS.

This workaround will be replaced with a more comprehensive fix
for mstatus.FS handling in QEMU 2.13.

# gpg: Signature made Thu 29 Mar 2018 18:22:42 BST
# gpg: using DSA key 6BF1D7B357EF3E4F
# gpg: Good signature from "Michael Clark <michaeljclark@mac.com>"
# gpg: aka "Michael Clark <mjc@sifive.com>"
# gpg: aka "Michael Clark <michael@metaparadigm.com>"
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 7C99 930E B17C D8BA 073D 5EFA 6BF1 D7B3 57EF 3E4F

* remotes/riscv/tags/riscv-qemu-2.12-critical-fixes:
RISC-V: Workaround for critical mstatus.FS bug

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+15 -2
+15 -2
target/riscv/op_helper.c
··· 144 144 } 145 145 146 146 mstatus = (mstatus & ~mask) | (val_to_write & mask); 147 - int dirty = (mstatus & MSTATUS_FS) == MSTATUS_FS; 148 - dirty |= (mstatus & MSTATUS_XS) == MSTATUS_XS; 147 + 148 + /* Note: this is a workaround for an issue where mstatus.FS 149 + does not report dirty after floating point operations 150 + that modify floating point state. This workaround is 151 + technically compliant with the RISC-V Privileged 152 + specification as it is legal to return only off, or dirty. 153 + at the expense of extra floating point save/restore. */ 154 + 155 + /* FP is always dirty or off */ 156 + if (mstatus & MSTATUS_FS) { 157 + mstatus |= MSTATUS_FS; 158 + } 159 + 160 + int dirty = ((mstatus & MSTATUS_FS) == MSTATUS_FS) | 161 + ((mstatus & MSTATUS_XS) == MSTATUS_XS); 149 162 mstatus = set_field(mstatus, MSTATUS_SD, dirty); 150 163 env->mstatus = mstatus; 151 164 break;