Skip to content

Conversation

@poemonsense
Copy link
Member

The flash device is registered when add_mmio_map is called with the space pointer. The space pointer is fixed after this registration. However, there is a wrong new_space call when flash_img is not defined, which updates the flash space pointer. The flash contents are thus incorrectly loaded to the new pointer. However, the IO device table still uses the legacy pointer.

This commits fix it by using the mmap allocator and the fixed flash_base pointer.

The flash device is registered when `add_mmio_map` is called with
the space pointer. The space pointer is fixed after this registration.
However, there is a wrong `new_space` call when `flash_img` is not
defined, which updates the flash space pointer. The flash contents
are thus incorrectly loaded to the new pointer. However, the IO device
table still uses the legacy pointer.

This commits fix it by using the mmap allocator and the fixed flash_base
pointer.
@poemonsense poemonsense requested a review from lewislzh November 1, 2024 02:52
@lewislzh lewislzh merged commit ab7e079 into master Nov 1, 2024
7 checks passed
@lewislzh lewislzh deleted the fix-flash-pointer branch November 1, 2024 03:12
Tang-Haojin pushed a commit that referenced this pull request Nov 20, 2024
The flash device is registered when `add_mmio_map` is called with
the space pointer. The space pointer is fixed after this registration.
However, there is a wrong `new_space` call when `flash_img` is not
defined, which updates the flash space pointer. The flash contents
are thus incorrectly loaded to the new pointer. However, the IO device
table still uses the legacy pointer.

This commits fix it by using the mmap allocator and the fixed flash_base
pointer.
Tang-Haojin added a commit to OpenXiangShan/XiangShan that referenced this pull request Nov 21, 2024
* NEMU commit: 65b95cbb5d7c36f4d2cb38bfc0e1f6e43435f309
* NEMU configs:
    * riscv64-xs-ref_defconfig
    * riscv64-dual-xs-ref_defconfig

Including:
  * ci: enable ci for kunminghu-v2r2-930
* fix(lrsc): configure NEMU's reservation set size to 64B to match
XiangShan. (OpenXiangShan/NEMU#654)
* fix(gva): fix gva bit set/clear logic in mstatus/hstatus.
(OpenXiangShan/NEMU#642)
  * fix(exception): fix exception type raised in paddr_write.
  * fix(mmio): should use Logm instead of Log
  * fix(mmio): configure mmio space separately
* fix(aes): fix decode logic and exception check for aes64ks1i.
(OpenXiangShan/NEMU#646)
* fix(trap): fix the decoding of nemu_trap to make it consistent with
XiangShan. (OpenXiangShan/NEMU#639)
  * fix(zcmop): fix decode logic of c_mop (OpenXiangShan/NEMU#645)
* fix(rvv): set xstatus.vs dirty when execute vector int instructions
(OpenXiangShan/NEMU#631)
* fix(mmio): check mmio misalign only after confirming addr is an mmio
address.
  * fix(mip): use get_mip method replace mip->val
  * fix(csr, aia): add access siselect(vsiselect) in V mode
  * fix(flash): use mmap to create the io space (OpenXiangShan/NEMU#623)
* fix(fs, vs): fix check fs/vs when executing float/vector instr
(OpenXiangShan/NEMU#621)
  * fix(rvf): fix wrong patterns in the decoder (OpenXiangShan/NEMU#620)
* fix(build): extract .a files before running ar
(OpenXiangShan/NEMU#613)
* fix(device): init_flash should be called only once
(OpenXiangShan/NEMU#618)
* fix(store_queue): clear the queue when init_mem
(OpenXiangShan/NEMU#616)
* fix(ref): use uint64_t for the loop iterator (OpenXiangShan/NEMU#609)
* refactor: handle decode operations with appropriate macros
(OpenXiangShan/NEMU#601)
* fix(rvb): restore the decode table of zext.h (OpenXiangShan/NEMU#612)
  * fix(rvh): fix the decode logic of hsv.d (OpenXiangShan/NEMU#610)
* fix(vf): do not set dirtyFs for some instructions
(OpenXiangShan/NEMU#606)
* fix(vfredusum): set xstatus.fs and xstatus.vs dirty
(OpenXiangShan/NEMU#605)
* fix(format): adjust code format and add one config
(OpenXiangShan/NEMU#603)
* fix(csrrw): add legal write check for mstatus.mpp, mnstatus.mnpp,
hpmevent.optype and wmask for mhpmevent
  * fix(mhpmevent): add rtl guidance for mhpmevent.of logic
  * fix(mhpmevent): add CSRS_M_HPMEVENTS_STRUCT for mhpmevent csr.
  * fix(dbltrp): trap info update in raise_intr (OpenXiangShan/NEMU#596)
  * fix(tval): update cpu.instr when set-jmp (OpenXiangShan/NEMU#599)
* fix(vxred): set xstatus.fs or xstatus.vs dirty unconditionally
(OpenXiangShan/NEMU#598)
* fix(vf): vfclass should not set xstatus.FS to dirty
(OpenXiangShan/NEMU#595)
  * refactor: remove the macro __ICS_EXPORT (OpenXiangShan/NEMU#593)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants