riscv / riscv-isa-manual

RISC-V Instruction Set Manual
https://riscv.org/
Creative Commons Attribution 4.0 International
3.7k stars 645 forks source link

Can it support misaligned memory access when PBMT=NC? #1735

Open Maxpicca-Li opened 11 hours ago

Maxpicca-Li commented 11 hours ago

The Svpbmt mentions misaligned memory access when PBMT=IO.

Implementations may override additional PMAs not explicitly listed in Table 27. For example, to be consistent with the characteristics of a typical I/O region, a misaligned memory access to a page with PBMT=IO might raise an exception, even if the underlying region were main memory and the same access would have succeeded for PBMT=PMA.

But when PBMT = NC, can it support misaligned memory access with PMA=main_mem or PMA=IO?

gfavor commented 7 hours ago

PBMT= NC or IO is only guaranteed to override the attributes specified in table 27. The following sentence then says "Implementations may override additional PMAs not explicitly listed in Table 27". Note "may".

In the case of PBMT=NC on top of PMA=main memory, one typically would not override the misaligned behavior for main memory since "NC" is intended to represent noncacheable main memory, and hence misaligned accesses would be supported. In the case of PBMT=NC on top of PMA=IO, and similar to the example in the spec, one typically would override the misaligned behavior to be consistent with the characteristics of main memory.

Maxpicca-Li commented 6 hours ago

PBMT= NC or IO is only guaranteed to override the attributes specified in table 27. The following sentence then says "Implementations may override additional PMAs not explicitly listed in Table 27". Note "may".

In the case of PBMT=NC on top of PMA=main memory, one typically would not override the misaligned behavior for main memory since "NC" is intended to represent noncacheable main memory, and hence misaligned accesses would be supported. In the case of PBMT=NC on top of PMA=IO, and similar to the example in the spec, one typically would override the misaligned behavior to be consistent with the characteristics of main memory.

Thank you for your reply. I still have doubts: It is acceptable to report an exception(PBMT=IO) where there is no exception(PMA=main_mem), but if there is no exception(PBMT=NC) in the place where the exception should be reported(PMA=IO), will this affect the correctness?