On 10/7/19 11:41 AM, Dayeol Lee wrote: > 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.
You certainly could do if (size == 0) { size = -(addr | TARGET_PAGE_MASK); } to assume that all bytes from addr to the end of the page are accessed. That would avoid changing too much of the rest of the logic. That said, this code will continue to not work for mis-aligned boundaries. r~ > (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).