Re: [PATCH 2/2] target/riscv: Make the "virt" register writable by GDB

2023-03-08 Thread Jim Shu
On Mon, Mar 6, 2023 at 7:26 PM LIU Zhiwei wrote: > > > On 2023/3/5 17:42, Jim Shu wrote: > > This patch also enables debugger to set current privilege mode to > > VU/VS-mode. > > > > Extend previous commit 81d2929c41d32af138f3562f5a7b309f6eac7ca7 to > >

Re: [PATCH 2/2] target/riscv: Make the "virt" register writable by GDB

2023-03-08 Thread Jim Shu
Thanks for reviewing. I'll fix this issue. On Mon, Mar 6, 2023 at 7:26 PM LIU Zhiwei wrote: > > > On 2023/3/5 17:42, Jim Shu wrote: > > This patch also enables debugger to set current privilege mode to > > VU/VS-mode. > > > > Extend previous commit 81d2929

[PATCH 1/2] target/riscv: Expose "virt" register for GDB for reads

2023-03-05 Thread Jim Shu
This patch enables a debugger to read current virtualization mode via virtual "virt" register. After it, we could get full current privilege mode via both "priv" and "virt" register. Extend previous commit ab9056ff9bdb3f95db6e7a666d10522d289f14ec to support H-exte

[PATCH 2/2] target/riscv: Make the "virt" register writable by GDB

2023-03-05 Thread Jim Shu
This patch also enables debugger to set current privilege mode to VU/VS-mode. Extend previous commit 81d2929c41d32af138f3562f5a7b309f6eac7ca7 to support H-extension. Signed-off-by: Jim Shu Reviewed-by: Frank Chang --- target/riscv/gdbstub.c | 18 -- 1 file changed, 16

[PATCH] hw/intc: sifive_plic: fix out-of-bound access of source_priority array

2022-11-27 Thread Jim Shu
If the number of interrupt is not multiple of 32, PLIC will have out-of-bound access to source_priority array. Compute the number of interrupt in the last word to avoid this out-of-bound access of array. Signed-off-by: Jim Shu --- hw/intc/sifive_plic.c | 12 +++- 1 file changed, 11

[PATCH] target/riscv: support cache-related PMU events in virtual mode

2022-11-23 Thread Jim Shu
let tlb_fill() function also increments PMU counter when it is from two-stage translation, so QEMU could also monitor these PMU events when CPU runs in VS/VU mode (like running guest OS). Signed-off-by: Jim Shu --- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion

Re: [PATCH v3 0/2] Enhance maximum priority support of PLIC

2022-10-10 Thread Jim Shu
Gentle ping. It's a patch for fix and spec alignment of PLIC. On Mon, Oct 3, 2022 at 12:14 PM Jim Shu wrote: > > This patchset fixes hard-coded maximum priority of interrupt priority > register and also changes this register to WARL field to align the PLIC > spec. > >

[PATCH v3 0/2] Enhance maximum priority support of PLIC

2022-10-02 Thread Jim Shu
This patchset fixes hard-coded maximum priority of interrupt priority register and also changes this register to WARL field to align the PLIC spec. Changelog: v3: * fix opposite of power-of-2 max priority checking expression. v2: * change interrupt priority register to WARL field. Jim Shu

[PATCH v3 2/2] hw/intc: sifive_plic: change interrupt priority register to WARL field

2022-10-02 Thread Jim Shu
each bit of interrupt priority register to WARL field when the number of supported priority is power-of-2. [1] https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc#interrupt-priorities Signed-off-by: Jim Shu --- hw/intc/sifive_plic.c | 21 +++-- 1 file changed, 19

[PATCH v3 1/2] hw/intc: sifive_plic: fix hard-coded max priority level

2022-10-02 Thread Jim Shu
Property in maximum priority level. Signed-off-by: Emmanuel Blot Signed-off-by: Jim Shu Reviewed-by: Frank Chang --- hw/intc/sifive_plic.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index af4ae3630e..f864efa761 100644

Re: [PATCH v2 2/2] hw/intc: sifive_plic: change interrupt priority register to WARL field

2022-10-02 Thread Jim Shu
Hi Clément, > > > @@ -180,7 +180,15 @@ static void sifive_plic_write(void *opaque, hwaddr > > > addr, uint64_t value, > > > if (addr_between(addr, plic->priority_base, plic->num_sources << 2)) > > > { > > > uint32_t irq = ((addr - plic->priority_base) >> 2) + 1; > > > > > > -

Re: [PATCH v2 2/2] hw/intc: sifive_plic: change interrupt priority register to WARL field

2022-09-30 Thread Jim Shu
hi Clément, Thank you very much. I'll fix it in the next version patch. Thanks, Jim Shu On Fri, Sep 30, 2022 at 8:58 PM Clément Chigot wrote: > > Hi Jim, > > On Fri, Sep 30, 2022 at 2:32 PM Jim Shu wrote: > > > > PLIC spec [1] requires interrupt source priority regi

[PATCH v2 2/2] hw/intc: sifive_plic: change interrupt priority register to WARL field

2022-09-30 Thread Jim Shu
each bit of interrupt priority register to WARL field when the number of supported priority is power-of-2. [1] https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc#interrupt-priorities Signed-off-by: Jim Shu --- hw/intc/sifive_plic.c | 21 +++-- 1 file changed, 19

[PATCH v2 0/2] Enhance maximum priority support of PLIC

2022-09-30 Thread Jim Shu
This patchset fixes hard-coded maximum priority of interrupt priority register and also changes this register to WARL field to align the PLIC spec. Changelog: v2: * change interrupt priority register to WARL field. Jim Shu (2): hw/intc: sifive_plic: fix hard-coded max priority level hw

[PATCH v2 1/2] hw/intc: sifive_plic: fix hard-coded max priority level

2022-09-30 Thread Jim Shu
Property in maximum priority level. Signed-off-by: Emmanuel Blot Signed-off-by: Jim Shu Reviewed-by: Frank Chang --- hw/intc/sifive_plic.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index af4ae3630e..f864efa761 100644

Re: [PATCH] hw/intc: sifive_plic: fix hard-coded max priority level

2022-09-28 Thread Jim Shu
;num_priorities + 1" should be power-of-2 and SW could discover available bits of interrupt source priority. I'll do this enhancement in the next version patch. [1] https://github.com/riscv/riscv-plic-spec/blob/master/riscv-plic.adoc#interrupt-priorities Thanks, Jim Shu On Mon, Sep 26, 202

Re: [PATCH 2/4] hw/intc: sifive_plic.c: Fix interrupt priority index.

2022-09-26 Thread Jim Shu
Hi Tyler, Thanks for the explanation. I understand the issue here. I think we should align the priority base in each RISC-V platform to the same value (no matter 0x0 or 0x4) if they use PLIC in the same way. Thanks, Jim Shu On Tue, Sep 27, 2022 at 4:04 AM Tyler Ng wrote: > >

Re: [PATCH 2/4] hw/intc: sifive_plic.c: Fix interrupt priority index.

2022-09-25 Thread Jim Shu
formula "irq = ((addr - plic->priority_base) >> 2) + 1" will take offset 0x4 as IRQ source 1, which is correct. Your fix will cause the bug in existing machines. Thanks, Jim Shu On Tue, Sep 6, 2022 at 11:21 PM Tyler Ng wrote: > > Here's the patch SHA t

[PATCH] hw/intc: sifive_plic: fix hard-coded max priority level

2022-09-25 Thread Jim Shu
Property in maximum priority level. Signed-off-by: Emmanuel Blot Signed-off-by: Jim Shu Reviewed-by: Frank Chang --- hw/intc/sifive_plic.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index af4ae3630e..f864efa761 100644

Re: [PATCH] include/hw/riscv/sifive_e.h: Fix the type of parent_obj of SiFiveEState.

2022-08-21 Thread Jim Shu
Reviewed-by: Jim Shu On Fri, Aug 19, 2022 at 3:11 PM Tommy Wu wrote: > > Fix the type of parent_obj of SiFiveEState from 'SysBusDevice' > to 'MachineState'. Because the parent of SiFiveEState is 'MachineState'. > > Signed-off-by: Tommy Wu > --- > include/hw/riscv/sifive

Re: [PATCH] target/riscv: Support SW update of PTE A/D bits and Ssptwad extension

2022-07-25 Thread Jim Shu
Hi Alistair, Why do we want to support that? We can do either and we are > implementing the much more usual scheme. I don't see a reason to > bother implementing the other one. Is anyone ever going to use it? > Thanks for your response. I got it. Regards, Jim Shu

Re: [PATCH] target/riscv: Support SW update of PTE A/D bits and Ssptwad extension

2022-07-19 Thread Jim Shu
in RISC-V priv spec, so I think it's reasonable to implement them in QEMU. The only issue here is to choose a proper CPU option name to turn on/off HW update of A/D bits. Regards, Jim Shu On Mon, Jul 18, 2022 at 12:02 PM Anup Patel wrote: > +Atish > > On Mon, Jul 18, 2022 at 9:23 A

[PATCH] target/riscv: Support SW update of PTE A/D bits and Ssptwad extension

2022-07-17 Thread Jim Shu
spec v1.12: "When a virtual page is accessed and the A bit is clear, or is written and the D bit is clear, a page-fault exception (corresponding to the original access type) is raised." Signed-off-by: Jim Shu Reviewed-by: Frank Chang --- target/riscv/cpu.c| 2 ++ target/r

Re: [PATCH v4 11/14] softmmu/memory: add memory_region_try_add_subregion function

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Fri, Mar 4, 2022 at 7:00 PM Damien Hedde wrote: > > > > On 3/3/22 14:32, Philippe Mathieu-Daudé wrote: > > On 23/2/22 10:12, Damien Hedde wrote: > >> Hi Philippe, > >> > >> I suppose it is ok if I change your mail in the rev

Re: [PATCH v4 09/14] none-machine: allow cold plugging sysbus devices

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Thu, Mar 3, 2022 at 10:46 PM Philippe Mathieu-Daudé < philippe.mathieu.da...@gmail.com> wrote: > On 23/2/22 10:07, Damien Hedde wrote: > > Allow plugging any sysbus device on this machine (the sysbus > > devices still need to be 'user-creatable')

Re: [PATCH v4 13/14] hw/mem/system-memory: add a memory sysbus device

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Wed, Feb 23, 2022 at 5:14 PM Damien Hedde wrote: > This device can be used to create a memory wrapped into a > sysbus device. > This device has one property 'readonly' which allows > to choose between a ram or a rom. > > The purpose for this device is to

Re: [PATCH v4 14/14] hw: set user_creatable on opentitan/sifive_e devices

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Fri, Mar 4, 2022 at 11:23 PM Philippe Mathieu-Daudé < philippe.mathieu.da...@gmail.com> wrote: > On 23/2/22 10:07, Damien Hedde wrote: > > The devices are: > > + ibex-timer > > + ibex-uart > > + riscv.aclint.swi > > + ris

Re: [PATCH v4 08/14] none-machine: add 'ram-addr' property

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Fri, Mar 4, 2022 at 12:36 AM Damien Hedde wrote: > > > On 3/3/22 15:41, Philippe Mathieu-Daudé wrote: > > On 23/2/22 10:07, Damien Hedde wrote: > >> Add the property to configure a the base address of the ram. > >> The default value re

Re: [PATCH v4 12/14] add sysbus-mmio-map qapi command

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Wed, Feb 23, 2022 at 5:37 PM Damien Hedde wrote: > This command allows to map an mmio region of sysbus device onto > the system memory. Its behavior mimics the sysbus_mmio_map() > function apart from the automatic unmap (the C function unmaps > the region if i

Re: [PATCH v4 07/14] none-machine: add the NoneMachineState structure

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Wed, Feb 23, 2022 at 5:59 PM Damien Hedde wrote: > The none machine was using the parent state structure. > We'll need a custom state to add a field in the following commit. > > Signed-off-by: Damien Hedde > --- > hw/core/n

Re: [PATCH v4 05/14] qapi/device_add: handle the rom_order_override when cold-plugging

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Wed, Feb 23, 2022 at 5:18 PM Damien Hedde wrote: > rom_set_order_override() and rom_reset_order_override() were called > in qemu_create_cli_devices() to set the rom_order_override value > once and for all when creating the devices added on CLI. > >

Re: [PATCH v5 3/6] vl: support machine-initialized target in phase_until()

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Thu, May 19, 2022 at 11:36 PM Damien Hedde wrote: > phase_until() now supports the following transitions: > + accel-created -> machine-initialized > + machine-initialized -> machine-ready > > As a consequence we can now support the use of qmp_ex

Re: [PATCH v5 2/6] machine: introduce phase_until() to handle phase transitions

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Thu, May 19, 2022 at 11:41 PM Damien Hedde wrote: > phase_until() is implemented in vl.c and is meant to be used > to make startup progress up to a specified phase being reached(). > At this point, no behavior change is introduced: phase_until() > only suppo

Re: [PATCH v5 4/6] qapi/device_add: compute is_hotplug flag

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Thu, May 19, 2022 at 11:37 PM Damien Hedde wrote: > Instead of checking the phase everytime, just store the result > in a flag. We will use more of it in the following commit. > > Signed-off-by: Damien Hedde > Reviewed-by: Philippe Mathieu-Daudé > -

Re: [PATCH v5 6/6] qapi/device_add: Allow execution in machine initialized phase

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Thu, May 19, 2022 at 11:37 PM Damien Hedde wrote: > From: Mirela Grujic > > This commit allows to use the QMP command to add a cold-plugged > device like we can do with the CLI option -device. > > Note: for device_add command in qdev.json adding th

Re: [PATCH v5 1/6] machine: add phase_get() and document phase_check()/advance()

2022-05-24 Thread Jim Shu
Tested-by: Jim Shu On Thu, May 19, 2022 at 11:41 PM Damien Hedde wrote: > phase_get() returns the current phase, we'll use it in next > commit. > > Signed-off-by: Damien Hedde > Reviewed-by: Philippe Mathieu-Daudé > --- > include/hw/qdev-core.h | 19

Re: [PATCH v4 00/14] Initial support for machine creation via QMP

2022-05-24 Thread Jim Shu
Hi all, Thanks for the work! I'm from SiFive and we are very interested in this feature. QMP/QAPI configurable QEMU machine is a useful feature in our use case. With this feature, we can both model our versatile FPGA-based platforms more easily and model a new platform without modification of

[PATCH v2 0/2] Align SiFive PDMA behavior to real hardware

2022-01-03 Thread Jim Shu
. Changelog: v2: * Fix high 32-bit write access of 64-bit RO registers * Fix commit log Jim Shu (2): hw/dma: sifive_pdma: support high 32-bit access of 64-bit register hw/dma: sifive_pdma: permit 4/8-byte access size of PDMA registers hw/dma/sifive_pdma.c | 181

[PATCH v2 2/2] hw/dma: sifive_pdma: permit 4/8-byte access size of PDMA registers

2022-01-03 Thread Jim Shu
It's obvious that PDMA supports 64-bit access of 64-bit registers, and in previous commit, we confirm that PDMA supports 32-bit access of both 32/64-bit registers. Thus, we configure 32/64-bit memory access of PDMA registers as valid in general. Signed-off-by: Jim Shu Reviewed-by: Frank Chang

[PATCH v2 1/2] hw/dma: sifive_pdma: support high 32-bit access of 64-bit register

2022-01-03 Thread Jim Shu
2 80001000 0002 => md.l 0x28000 1; md.l 0x280001000 1 <= Dump src/dst memory contents 280000000: 12345678 xV4. 280001000: 12345678 xV4. Signed-off-by: Jim Shu Reviewed

Re: [PATCH 1/2] hw/dma: sifive_pdma: support high 32-bit access of 64-bit register

2022-01-03 Thread Jim Shu
Hi Bin, Thanks for the review. I will fix the commit log and the behavior of writing high 32-bit of RO registers in v2 patch. Thanks, Jim Shu On Tue, Jan 4, 2022 at 10:55 AM Bin Meng wrote: > Hi Jim, > > On Tue, Dec 28, 2021 at 8:53 AM Jim Shu wrote: > > > > Real PDM

[PATCH 2/2] hw/dma: sifive_pdma: permit 4/8-byte access size of PDMA registers

2021-12-27 Thread Jim Shu
It's obvious that PDMA support 64-bit access of 64-bit registers, and in previous commit, we confirm that PDMA support 32-bit access of both 32/64-bit registers. Thus, we configure 32/64-bit memory access of PDMA registers as valid in general. Signed-off-by: Jim Shu Reviewed-by: Frank Chang

[PATCH 1/2] hw/dma: sifive_pdma: support high 32-bit access of 64-bit register

2021-12-27 Thread Jim Shu
2 80001000 0002 => md.l 0x28000 1; md.l 0x280001000 1 <= Dump src/dst memory contents 280000000: 12345678 xV4. 280001000: 12345678 xV4. Signed-off-by: Jim Shu Reviewed-by: Frank Chang --- hw/dma/sif

[PATCH 0/2] Align SiFive PDMA behavior to real hardware

2021-12-27 Thread Jim Shu
HiFive Unmatched PDMA supports high/low 32-bit access of 64-bit register, but QEMU emulation support low part access now. Enhance QEMU emulation to support high 32-bit access. Also, permit 4/8-byte valid access in PDMA as we have verified 32/64-bit accesses of PDMA registers are supported. Jim

[PATCH 1/3] target/riscv: propagate PMP permission to TLB page

2021-02-21 Thread Jim Shu
Currently, PMP permission checking of TLB page is bypassed if TLB hits Fix it by propagating PMP permission to TLB page permission. PMP permission checking also use MMU-style API to change TLB permission and size. Signed-off-by: Jim Shu --- target/riscv/cpu_helper.c | 84

[PATCH 1/3] target/riscv: propagate PMP permission to TLB page

2021-02-21 Thread Jim Shu
Currently, PMP permission checking of TLB page is bypassed if TLB hits Fix it by propagating PMP permission to TLB page permission. PMP permission checking also use MMU-style API to change TLB permission and size. Signed-off-by: Jim Shu --- target/riscv/cpu_helper.c | 84

[PATCH 0/3] target/riscv: fix PMP permission checking when softmmu's TLB hits

2021-02-21 Thread Jim Shu
. To fix this issue, this patch set addes the feature to propagate PMP permission to the TLB page and flush TLB pages if PMP permission has been changed. The patch set is tested on Zephyr RTOS userspace testsuite on QEMU riscv32 virt machine. Jim Shu (3): target/riscv: propagate PMP permission

[PATCH 2/3] target/riscv: add log of PMP permission checking

2021-02-21 Thread Jim Shu
Like MMU translation, add qemu log of PMP permission checking for debugging. Signed-off-by: Jim Shu --- target/riscv/cpu_helper.c | 12 1 file changed, 12 insertions(+) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index f6ac63bf0e..c1ecb8a710 100644

[PATCH 2/3] target/riscv: add log of PMP permission checking

2021-02-21 Thread Jim Shu
Like MMU translation, add qemu log of PMP permission checking for debugging. Signed-off-by: Jim Shu --- target/riscv/cpu_helper.c | 12 1 file changed, 12 insertions(+) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index f6ac63bf0e..c1ecb8a710 100644

[PATCH 3/3] target/riscv: flush TLB pages if PMP permission has been changed

2021-02-21 Thread Jim Shu
If PMP permission of any address has been changed by updating PMP entry, flush all TLB pages to prevent from getting old permission. Signed-off-by: Jim Shu --- target/riscv/pmp.c | 4 1 file changed, 4 insertions(+) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index ebd874cde3

[PATCH 3/3] target/riscv: flush TLB pages if PMP permission has been changed

2021-02-21 Thread Jim Shu
If PMP permission of any address has been changed by updating PMP entry, flush all TLB pages to prevent from getting old permission. Signed-off-by: Jim Shu --- target/riscv/pmp.c | 4 1 file changed, 4 insertions(+) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index ebd874cde3