Skip to content

RV32 c.srli instruction with illegal shift amount is disassembled but should be custom extension space #2731

@h01G3r

Description

@h01G3r

Work environment

Questions Answers
System Capstone runs on OS/arch/bits Windows x86_64
Capstone module affected riscv
Source of Capstone git clone
Version/git commit latest next, Commit 280b749

Instruction bytes giving faulty results

0x15, 0x93

Expected results

It should be:

Custom Extension / disassembly failed

Steps to get the wrong result

With cstool:

cstool -d riscv32 1593

or with Python

Additional Logs, screenshots, source code, configuration dump, ...

Instruction is disassembled as

 0  15 93        c.srli a4, 0x25
        ID: 128 (c.srli)
        op_count: 2
                operands[0].type: REG = a4
                operands[1].type: IMM = 0x25

        Groups: hasStdExtC

But according to
https://lists.riscv.org/g/tech-unprivileged/attachment/536/0/unpriv-isa-asciidoc.pdf (p. 105)
the shift value must not be greater than 31 (shamt[5], bit12 must be zero as shamt[5] == 1 is designated space for custom extensions in RISCV32.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RISCVArchoutdated-moduleIssue due to an outdated arch module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions