Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-23 Thread Palmer Dabbelt
On Tue, 22 Oct 2019 14:21:29 PDT (-0700), day...@berkeley.edu wrote: riscv_cpu_tlb_fill() uses the `size` parameter to check PMP violation using pmp_hart_has_privs(). However, if the size is unknown (=0), the ending address will be `addr - 1` as it is `addr + size - 1` in `pmp_hart_has_privs()`.

[PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-22 Thread Dayeol Lee
riscv_cpu_tlb_fill() uses the `size` parameter to check PMP violation using pmp_hart_has_privs(). However, if the size is unknown (=0), the ending address will be `addr - 1` as it is `addr + size - 1` in `pmp_hart_has_privs()`. This always causes a false PMP violation on the starting address of the

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-18 Thread Dayeol Lee
I'll move the entire check into pmp_hart_has_privs as it makes more sense. Thanks! On Fri, Oct 18, 2019, 3:01 PM Palmer Dabbelt wrote: > On Tue, 15 Oct 2019 10:04:32 PDT (-0700), day...@berkeley.edu wrote: > > Hi, > > > > Could this patch go through? > > If not please let me know so that I can

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-18 Thread Palmer Dabbelt
On Tue, 15 Oct 2019 10:04:32 PDT (-0700), day...@berkeley.edu wrote: Hi, Could this patch go through? If not please let me know so that I can fix. Thank you! Sorry, I dropped this one. It's in the patch queue now. We should also check for size==0 in pmp_hart_has_privs(), as that won't work.

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-15 Thread Dayeol Lee
Hi, Could this patch go through? If not please let me know so that I can fix. Thank you! Dayeol On Sat, Oct 12, 2019, 11:30 AM Dayeol Lee wrote: > No it doesn't mean that. > But the following code will make the size TARGET_PAGE_SIZE - (page offset) > if the address is not aligned. > > pmp_siz

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-12 Thread Dayeol Lee
No it doesn't mean that. But the following code will make the size TARGET_PAGE_SIZE - (page offset) if the address is not aligned. pmp_size = -(address | TARGET_PAGE_MASK) On Fri, Oct 11, 2019, 7:37 PM Jonathan Behrens wrote: > How do you know that the access won't straddle a page boundary? Is

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-11 Thread Jonathan Behrens
How do you know that the access won't straddle a page boundary? Is there a guarantee somewhere that size=0 means that the access is naturally aligned? Jonathan On Fri, Oct 11, 2019 at 7:14 PM Dayeol Lee wrote: > riscv_cpu_tlb_fill() uses the `size` parameter to check PMP violation > using pmp_

[PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-11 Thread Dayeol Lee
riscv_cpu_tlb_fill() uses the `size` parameter to check PMP violation using pmp_hart_has_privs(). However, if the size is unknown (=0), the ending address will be `addr - 1` as it is `addr + size - 1` in `pmp_hart_has_privs()`. This always causes a false PMP violation on the starting address of the

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-07 Thread Richard Henderson
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

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-07 Thread Dayeol Lee
On Mon, Oct 7, 2019 at 11:25 AM Richard Henderson < richard.hender...@linaro.org> wrote: > 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 se

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-07 Thread Richard Henderson
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 max

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-07 Thread Dayeol Lee
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. If that's the only way to reduce PMP granularity to less than TARGET_PAGE_SIZE, Can we just set the PMP default granularity to TARGET_P

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-07 Thread Richard Henderson
On 10/6/19 10:28 PM, Dayeol Lee wrote: > riscv_cpu_tlb_fill() uses the `size` parameter to check PMP violation > using pmp_hart_has_privs(). > However, the size passed from tlb_fill(), which is called by > get_page_addr_code(), is always a hard-coded value 0. > This causes a false PMP violation if

Re: [PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-06 Thread no-reply
Patchew URL: https://patchew.org/QEMU/20191007052813.25814-1-day...@berkeley.edu/ Hi, This series seems to have some coding style problems. See output below for more information: Type: series Message-id: 20191007052813.25814-1-day...@berkeley.edu Subject: [PATCH] target/riscv: PMP violation

[PATCH] target/riscv: PMP violation due to wrong size parameter

2019-10-06 Thread Dayeol Lee
riscv_cpu_tlb_fill() uses the `size` parameter to check PMP violation using pmp_hart_has_privs(). However, the size passed from tlb_fill(), which is called by get_page_addr_code(), is always a hard-coded value 0. This causes a false PMP violation if the instruction presents on a PMP boundary. In o