Re: [Qemu-devel] [PATCH] riscv: rv32: Root page table address can be larger than 32-bit

2019-08-07 Thread Bin Meng
Hi Palmer, On Thu, Aug 8, 2019 at 4:55 AM Palmer Dabbelt wrote: > > On Thu, Aug 1, 2019 at 7:58 AM Bin Meng wrote: >> >> On Thu, Aug 1, 2019 at 10:16 PM Richard Henderson >> wrote: >> > >> > On 7/31/19 6:53 PM, Bin Meng wrote: >> > > I am not sure how (idx * ptesize) could overflow. It

Re: [Qemu-devel] [PATCH] riscv: rv32: Root page table address can be larger than 32-bit

2019-08-07 Thread Palmer Dabbelt
On Thu, Aug 1, 2019 at 7:58 AM Bin Meng wrote: > On Thu, Aug 1, 2019 at 10:16 PM Richard Henderson > wrote: > > > > On 7/31/19 6:53 PM, Bin Meng wrote: > > > I am not sure how (idx * ptesize) could overflow. It represents the > > > offset by a page table which is [0, 4096). > > > > You're

Re: [Qemu-devel] [PATCH] riscv: rv32: Root page table address can be larger than 32-bit

2019-08-01 Thread Bin Meng
On Thu, Aug 1, 2019 at 10:16 PM Richard Henderson wrote: > > On 7/31/19 6:53 PM, Bin Meng wrote: > > I am not sure how (idx * ptesize) could overflow. It represents the > > offset by a page table which is [0, 4096). > > You're right, I mis-read what was going on there. > > However, lower down,

Re: [Qemu-devel] [PATCH] riscv: rv32: Root page table address can be larger than 32-bit

2019-08-01 Thread Richard Henderson
On 7/31/19 6:53 PM, Bin Meng wrote: > I am not sure how (idx * ptesize) could overflow. It represents the > offset by a page table which is [0, 4096). You're right, I mis-read what was going on there. However, lower down, "target_ulong ppn" needs to be promoted to hwaddr, so that ppn = pte

Re: [Qemu-devel] [PATCH] riscv: rv32: Root page table address can be larger than 32-bit

2019-07-31 Thread Bin Meng
Hi Richard, On Thu, Aug 1, 2019 at 1:35 AM Richard Henderson wrote: > > On 7/31/19 5:45 AM, Bin Meng wrote: > > -target_ulong base; > > +hwaddr base; > ... > > -target_ulong pte_addr = base + idx * ptesize; > > +hwaddr pte_addr = base + idx * ptesize; > > I believe that

Re: [Qemu-devel] [PATCH] riscv: rv32: Root page table address can be larger than 32-bit

2019-07-31 Thread Richard Henderson
On 7/31/19 5:45 AM, Bin Meng wrote: > -target_ulong base; > +hwaddr base; ... > -target_ulong pte_addr = base + idx * ptesize; > +hwaddr pte_addr = base + idx * ptesize; I believe that you either need base + (hwaddr)idx * ptesize or change the type of idx to hwaddr

[Qemu-devel] [PATCH] riscv: rv32: Root page table address can be larger than 32-bit

2019-07-31 Thread Bin Meng
For RV32, the root page table's PPN has 22 bits hence its address bits could be larger than the maximum bits that target_ulong is able to represent. Use hwaddr instead. Signed-off-by: Bin Meng --- target/riscv/cpu_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git