On 10/7/19 10:19 AM, Dayeol Lee wrote:
> Thank you very much for the clarification!
>
> I found tlb_set_page with size != TARGET_PAGE_SIZE makes the translation way
> too slow; the Linux doesn't seem to boot.
To clarify, PMP specifies a range. That range has only two end points.
Therefore, a maximum of 2 pages may be affected by a mis-aligned PMP boundary.
It sounds like you're getting size != TARGET_PAGE_SIZE for all pages.
The cause of the problem is not a mis-aligned PMP boundary.
Let's say a PMP range is 0x1000 - 0x2000
if pmp_hart_has_privs() gets addr=0x2000 and size=0,
pmp_hart_has_privs() will ALWAYS return false because the code assumes size > 0.
It checks if (addr) and (addr + size - 1) are within the PMP range for each PMP entry.
(addr + size - 1) is supposed to be the last byte address of the memory access, but it ends up with (addr - 1) if size = 0.
Thus, pmp_hart_has_privs() returns false as (addr - 1) = 0x1fff is within the range, and addr = 0x2000 is out of the range (partial match violation).