【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.

Assessment

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

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.

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]

Dominant language
Scala
Stars
14
Forks
8
Avg merge
2d 22h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from OpenXiangShan/ChiselAIA

All issues in OpenXiangShan/ChiselAIA

Similar issues

More Scala issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.