OpenXiangShan / OpenXiangShan/ChiselAIA

【Bug】APLIC: setipnum/clripnum/setienum/clrienum do not strictly constrain writes to source numbers

Open
#41 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
13
Forks
7
PR merge metrics
No merged PRs in 30d

Description

Violated specification
Image setipnum/clripnum/setienum/clrienum have same constrain.
code

ChiselAIA/src/main/scala/APLIC.scala

Image
Description

According to my understanding, The current implementation truncates the 32-bit write data to the lowest aplicIntSrcWidth bits to form the source index.

As a result, writes with values outside the legal source number range (which should be ignored) are instead alias-mapped to a different valid source number due to truncation, causing erroneous interrupt behavior.

Specifically, after source 1 has been configured as active, writing an out-of-range value 129 (0x81) to the setipnum register should be ignored according to the specification.

However, in the current XiangShan implementation, this write results in execution of ips.wBitUI(1, true.B), setting interrupt-pending for source 1.

So I think the code should probably add an in-range check to these two register writes, and only allow entering wBitUI() when the written 32-bit value falls within [1, intSrcNum-1]

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read ChiselAIA/src/main/scala/APLIC.scala and the cited specification first. Trace the setipnum, clripnum, setienum, and clrienum register writes, then reproduce the source-1 case with an out-of-range value such as 129. Done means out-of-range writes are ignored rather than aliasing to another source number.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.