GithubHelp home page GithubHelp logo

Comments (3)

cliffordwolf avatar cliffordwolf commented on July 30, 2024

Just looking at the first one: The spec says that C.LI with rd=0 is a hint instruction, not a reserved opcode.

If your core decodes C.LI with rd=0 as illegal instruction then your core is broken.

This models are formally verified against Spike. I f their behavior is incorrect then so is the behavior of spike. And spike is the golden reference implementation.

from riscv-formal.

cattius avatar cattius commented on July 30, 2024

Hi Clifford,

C.LI with rd=0 and the other documented hint instructions certainly shouldn't be decoded by any core as illegal instructions, but would it not be better to distinguish them in riscv-formal as distinct instructions from C.li, C.lui, etc., for testing? Given the spec says they must either act as no-ops or have a defined hint implementation, but must never modify architectural state, conceptually it seems wrong to define them as having an architectural effect. Of course in practice having rd=0 should mean that the instructions do nothing and are equivalent to no-ops, but not distinguishing the hint instructions might potentially lead to insidious bugs - perhaps an x0 register in a software emulator which incorrectly can be written to, but would still pass these tests? It seems a concerning precedent to just ignore the hint instructions. Outside of riscv-formal I've found this has led to issues in other tools, such as disassemblers incorrectly decoding them as either compressed instructions or illegal instructions, and I can imagine a developer assuming that they could use riscv-formal's instruction definitions as references for developing their own tool.

I've been testing various RISC-V implementations for (inadvertent) undocumented instructions recently, so these kind of bugs slipping through verification have been on my mind. Would be interested to hear your thoughts on this - thanks!

from riscv-formal.

cliffordwolf avatar cliffordwolf commented on July 30, 2024

C.LI with rd=0 and the other documented hint instructions certainly shouldn't be decoded by any core as illegal instructions, but would it not be better to distinguish them in riscv-formal as distinct instructions from C.li, C.lui, etc., for testing?

That would be possible, but I don't see it adding anything. All hint instructions already are NOPs when interpreted as regular instruction, and that's exactly what all cores do, at least until actual hint instructions are standardized.

There are no additional properties to assert for hint instructions. So what would we gain?

Given the spec says they must either act as no-ops or have a defined hint implementation, but must never modify architectural state

And that's exactly the semantic you get from riscv-formal.

Last time I checked spike is also doing the same thing.

are equivalent to no-ops, but not distinguishing the hint instructions might potentially lead to insidious bugs - perhaps an x0 register in a software emulator which incorrectly can be written to, but would still pass these tests?

Writing anything that isn't 0 to x0 would be identified as bug by riscv-formal. And that has nothing to do with hint instructions at all. It's the same if you have uncompressed instructions that are effectively NOPs.

from riscv-formal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.