Skip to contentSkip to conversation

defining VIXL_DEBUG?

Qemu-devel Paolo Bonzini 2 participants 5 messages Jan 18, 2016

lore
Share & tools
lore
#0 lore raw

I've gotten four new Coverity reports in libvixl. All of them are caused by Coverity assuming that LaneSizeInBitsFromFormat can return 0.
The actual code in the function is

    default: VIXL_UNREACHABLE(); return 0;

so this is obviously a false positive. Defining VIXL_DEBUG would cause VIXL_UNREACHABLE() to call abort(). Any opinion about whether/where to do so?

Thanks,

Paolo

#1 lore raw
Quoted 2 lines · Paolo Bonzini

I've gotten four new Coverity reports in libvixl. All of them are caused by Coverity assuming that LaneSizeInBitsFromFormat can return 0.

Yeah, I fed these back to upstream.

(There are also some others do do with integer overflow etc which I think are unrelated to LaneSizeInBitsFromFormat.)

Quoted 7 lines

The actual code in the function is

    default: VIXL_UNREACHABLE(); return 0;

so this is obviously a false positive. Defining VIXL_DEBUG would cause VIXL_UNREACHABLE() to call abort(). Any opinion about whether/where to do so?

Does defining it to call abort() result in unreachable-code warnings for the "return 0;" ?

thanks
-- PMM

#2 lore raw
Quoted 9 lines · Peter Maydell
Quoted 7 lines

The actual code in the function is

Quoted 6 lines
    default: VIXL_UNREACHABLE(); return 0;

so this is obviously a false positive. Defining VIXL_DEBUG would cause VIXL_UNREACHABLE() to call abort(). Any opinion about whether/where to do so?

Does defining it to call abort() result in unreachable-code warnings for the "return 0;" ?

I'm not sure, it would be minor though.

One issue I have found after posting is that I'm not sure whether bad instructions (aka reserved encodings) are handled properly by libvixl. See for example this:

    case 'A': {  // IAddSub.
      VIXL_ASSERT(instr->ShiftAddSub() <= 1);
      int64_t imm = instr->ImmAddSub() << (12 * instr->ShiftAddSub());
      AppendToOutput("#0x%" PRIx64 " (%" PRId64 ")", imm, imm);
      return 7;
    }

where the '1x' encodings of bits 22:23 (marked as reserved in the ARMv8 ARM) would cause an abort as far as I can see.

Paolo

#3 lore raw
Quoted 11 lines · Paolo Bonzini

One issue I have found after posting is that I'm not sure whether bad instructions (aka reserved encodings) are handled properly by libvixl. See for example this:

    case 'A': {  // IAddSub.
      VIXL_ASSERT(instr->ShiftAddSub() <= 1);
      int64_t imm = instr->ImmAddSub() << (12 * instr->ShiftAddSub());
      AppendToOutput("#0x%" PRIx64 " (%" PRId64 ")", imm, imm);
      return 7;
    }
Quoted 2 lines

where the '1x' encodings of bits 22:23 (marked as reserved in the ARMv8 ARM) would cause an abort as far as I can see.

Isn't this handled by Decoder::DecodeAddSubImmediate(), which checks bit 23?

In any case if we're worried it would be easy to set up a trivial test loop that just feeds all 2^32 integers to the disassembler.

thanks
-- PMM

#4 lore raw
Quoted 5 lines · Peter Maydell
Quoted 3 lines
Quoted 3 lines

where the '1x' encodings of bits 22:23 (marked as reserved in the ARMv8 ARM) would cause an abort as far as I can see.

Isn't this handled by Decoder::DecodeAddSubImmediate(), which checks bit 23?

Yes, that's right.

Paolo

Quoted 2 lines

In any case if we're worried it would be easy to set up a trivial test loop that just feeds all 2^32 integers to the disassembler.