On 12/5/26 13:15, Peter Maydell wrote:
The MIPS GIC does a check for a guest error in the write path for the
SH_MAP*_VP registers which triggers a Coverity complaint because it
assigns -1 to a uint64_t. The code doesn't misbehave because the -1
case will be caught by the following OFFSET_CHECK(), but the code
could be improved:
  * there is no need to special case to avoid passing 0 to ctz64(),
    because (unlike the compiler builtins) QEMU defines that this
    has a specific behaviour, returning 64
  * the OFFSET_CHECK() macro will go to the "bad_offset" label and
    print an error implying that the guest wrote to an invalid
    register offset. This is misleading about the actual problem,
    which is that the guest wrote a bogus value to a valid register
    offset

Make the error check print a better log message, and avoid the
special casing on ctz64(); in passing, this should also make
Coverity happier.

CID: 1547545
Signed-off-by: Peter Maydell <[email protected]>
---
  hw/intc/mips_gic.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)

Patch queued, thanks.

Reply via email to