Re: [PATCH v2 00/15] riscv: QEMU RISC-V IOMMU Support

2024-05-10 Thread Frank Chang
Hi Daniel, Thanks for the upstream work. Sorry that it took a while for me to review the patchset. Please let me know if you need any help from us to update the IOMMU model. We would like to see it merged for QEMU 9.1.0. Regards, Frank Chang Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:04寫道

Re: [PATCH v2 02/15] hw/riscv: add riscv-iommu-bits.h

2024-05-10 Thread Frank Chang
Reviewed-by: Frank Chang Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:07寫道: > > From: Tomasz Jeznach > > This header will be used by the RISC-V IOMMU emulation to be added > in the next patch. Due to its size it's being sent in separate for > an easier review. >

Re: [PATCH v2 11/15] hw/riscv/riscv-iommu: add DBG support

2024-05-10 Thread Frank Chang
Hi Daniel, Daniel Henrique Barboza 於 2024年5月6日 週一 下午9:06寫道: > > Hi Frank, > > On 5/6/24 01:09, Frank Chang wrote: > > Hi Daniel, > > > > Daniel Henrique Barboza 於 2024年3月8日 週五 > > 上午12:05寫道: > >> > >> From: Tomasz Jeznach > >>

Re: [PATCH v2 03/15] hw/riscv: add RISC-V IOMMU base emulation

2024-05-10 Thread Frank Chang
Hi Daniel, Daniel Henrique Barboza 於 2024年5月8日 週三 下午7:16寫道: > > Hi Frank, > > I'll reply with that I've done so far. Still missing some stuff: > > On 5/2/24 08:37, Frank Chang wrote: > > Hi Daniel, > > > > Daniel Henrique Barboza 於 2024年3月8日 週五 > >

Re: [RFC PATCH 0/1] pci: allocate a PCI ID for RISC-V IOMMU

2024-05-10 Thread Frank Chang
e went to Red Hat, and they were > kind enough > to give us a PCI ID for the RISC-V IOMMU reference device. That's great. Thanks to Red Hat. I'm wondering do we have the plan to document the new PCI ID to the IOMMU spec or somewhere else that's publicly accessible? Regards, Frank Chang &

Re: [PATCH v2 09/15] hw/riscv/riscv-iommu: add s-stage and g-stage support

2024-05-10 Thread Frank Chang
c = RISCV_IOMMU_DC_TC_V; > ctx->ta = 0; > ctx->msiptp = 0; > @@ -424,6 +649,8 @@ static int riscv_iommu_ctx_fetch(RISCVIOMMUState *s, > RISCVIOMMUContext *ctx) > > /* Set translation context. */ > ctx->tc =

Re: [PATCH v2 08/15] hw/riscv/riscv-iommu: add Address Translation Cache (IOATC)

2024-05-08 Thread Frank Chang
_iot_inval_pscid_iova(gpointer key, gpointer value, gpointer > data) > +{ > +RISCVIOMMUEntry *iot = (RISCVIOMMUEntry *) value; > +RISCVIOMMUEntry *arg = (RISCVIOMMUEntry *) data; > +if (iot->gscid == arg->gscid && > +iot->pscid == arg->pscid &&

Re: [PATCH v2 10/15] hw/riscv/riscv-iommu: add ATS support

2024-05-07 Thread Frank Chang
s perm = resp_code ? IOMMU_NONE : IOMMU_RW; > +return riscv_iommu_ats(s, cmd, IOMMU_NOTIFIER_MAP, perm, > + trace_riscv_iommu_ats_prgr); > +} > + > static void riscv_iommu_process_ddtp(RISCVIOMMUState *s) > { > uint64_t old_ddtp = s->ddtp; > @

Re: [RFC PATCH 0/1] pci: allocate a PCI ID for RISC-V IOMMU

2024-05-07 Thread Frank Chang
Hi Daniel, Daniel Henrique Barboza 於 2024年5月3日 週五 下午8:43寫道: > > Hi, > > In this RFC I want to check with Gerd and others if it's ok to add a PCI > id for the RISC-V IOMMU device. It's currently under review in [1]. The Is the link [1] missing? Regards, Frank Chang > idea is

Re: [RFC PATCH 1/1] pci-ids.rst: add Red Hat pci-id for generic IOMMU device

2024-05-07 Thread Frank Chang
Hi Daniel, It's glad to see that we have the dedicate PCIe device ID for RISC-V IOMMU. Reviewed-by: Frank Chang Daniel Henrique Barboza 於 2024年5月3日 週五 下午8:44寫道: > > Reserve an id to be used by the RISC-V IOMMU PCI device. > > Cc: Gerd Hoffmann > Signed-off-by: Daniel H

Re: [PATCH v2 15/15] hw/misc: EDU: add ATS/PRI capability

2024-05-07 Thread Frank Chang
> @@ -390,9 +603,28 @@ static void pci_edu_realize(PCIDevice *pdev, Error > **errp) > pos = PCI_CONFIG_SPACE_SIZE; > if (edu->enable_pasid) { > /* PCIe Spec 7.8.9 PASID Extended Capability Structure */ > -pcie_add_capability(pdev,

Re: [PATCH v2 14/15] hw/misc: EDU: added PASID support

2024-05-07 Thread Frank Chang
, TRUE), > +DEFINE_PROP_END_OF_LIST(), > +}; > + > static void edu_class_init(ObjectClass *class, void *data) > { > DeviceClass *dc = DEVICE_CLASS(class); > PCIDeviceClass *k = PCI_DEVICE_CLASS(class); > > +device_class_set_props(dc, edu_properties); > k->realize = pci_edu_realize; > k->exit = pci_edu_uninit; > k->vendor_id = PCI_VENDOR_ID_QEMU; > @@ -430,7 +461,7 @@ static void edu_class_init(ObjectClass *class, void *data) > static void pci_edu_register_types(void) > { > static InterfaceInfo interfaces[] = { > -{ INTERFACE_CONVENTIONAL_PCI_DEVICE }, > +{ INTERFACE_PCIE_DEVICE }, > { }, > }; > static const TypeInfo edu_info = { > -- > 2.43.2 > > This commit introduces a new command for PASID (PV, bitwise OR of: 0x08; PASID, cmds[27:8]). We should also update the EDU spec: docs/specs/edu.rst to address the changes. Regards, Frank Chang

Re: [PATCH v2 13/15] qtest/riscv-iommu-test: add init queues test

2024-05-07 Thread Frank Chang
Reviewed-by: Frank Chang Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:06寫道: > > Add an additional test to further exercise the IOMMU where we attempt to > initialize the command, fault and page-request queues. > > These steps are taken from chapter 6.2 of the RISC-V IOMMU spec

Re: [PATCH v2 12/15] hw/riscv/riscv-iommu: Add another irq for mrif notifications

2024-05-06 Thread Frank Chang
Reviewed-by: Frank Chang Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:06寫道: > > From: Andrew Jones > > And add mrif notification trace. > > Signed-off-by: Andrew Jones > Reviewed-by: Daniel Henrique Barboza > --- > hw/riscv/riscv-iommu-pci.c | 2 +- > hw/riscv

Re: [PATCH v2 11/15] hw/riscv/riscv-iommu: add DBG support

2024-05-05 Thread Frank Chang
anslate(s, ctx, , false); > +if (fault) { > +iova = RISCV_IOMMU_TR_RESPONSE_FAULT | (((uint64_t) fault) << > 10); > +} else { > +iova = ((iotlb.translated_addr & ~iotlb.addr_mask) >> 2) & For 4-KB page, we should right-shift 12 bits. >

Re: [PATCH v2 03/15] hw/riscv: add RISC-V IOMMU base emulation

2024-05-02 Thread Frank Chang
Hi Daniel, Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:04寫道: > > From: Tomasz Jeznach > > The RISC-V IOMMU specification is now ratified as-per the RISC-V > international process. The latest frozen specifcation can be found > at: > >

Re: [PATCH v2 07/15] test/qtest: add riscv-iommu-pci tests

2024-04-29 Thread Frank Chang
Reviewed-by: Frank Chang Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:05寫道: > > To test the RISC-V IOMMU emulation we'll use its PCI representation. > Create a new 'riscv-iommu-pci' libqos device that will be present with > CONFIG_RISCV_IOMMU. This config is only available fo

Re: [PATCH v2 06/15] hw/riscv/virt.c: support for RISC-V IOMMU PCIDevice hotplug

2024-04-29 Thread Frank Chang
Reviewed-by: Frank Chang Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:06寫道: > > From: Tomasz Jeznach > > Generate device tree entry for riscv-iommu PCI device, along with > mapping all PCI device identifiers to the single IOMMU device instance. > > Signed-off-by: Tomasz

Re: [PATCH v2 05/15] hw/riscv: add riscv-iommu-sys platform device

2024-04-29 Thread Frank Chang
Reviewed-by: Frank Chang Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:05寫道: > > From: Tomasz Jeznach > > This device models the RISC-V IOMMU as a sysbus device. > > Signed-off-by: Tomasz Jeznach > Signed-off-by: Daniel Henrique Barboza > --- > hw/riscv/meson.buil

Re: [PATCH v2 04/15] hw/riscv: add riscv-iommu-pci device

2024-04-29 Thread Frank Chang
Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:04寫道: > > From: Tomasz Jeznach > > The RISC-V IOMMU can be modelled as a PCIe device following the > guidelines of the RISC-V IOMMU spec, chapter 7.1, "Integrating an IOMMU > as a PCIe device". > > Signed-off-by: Tomasz Jeznach > Signed-off-by: Daniel

Re: [PATCH v2 01/15] exec/memtxattr: add process identifier to the transaction attributes

2024-04-23 Thread Frank Chang
Reviewed-by: Frank Chang Daniel Henrique Barboza 於 2024年3月8日 週五 上午12:04寫道: > > From: Tomasz Jeznach > > Extend memory transaction attributes with process identifier to allow > per-request address translation logic to use requester_id / process_id > to identify memory mapp

[PATCH] hw/intc: Update APLIC IDC after claiming iforce register

2024-03-21 Thread frank . chang
From: Frank Chang Currently, QEMU only sets the iforce register to 0 and returns early when claiming the iforce register. However, this may leave mip.meip remains at 1 if a spurious external interrupt triggered by iforce register is the only pending interrupt to be claimed, and the interrupt

[PATCH] target/riscv: Add missing include guard in pmu.h

2024-02-20 Thread frank . chang
From: Frank Chang Add missing include guard in pmu.h to avoid the problem of double inclusion. Signed-off-by: Frank Chang --- target/riscv/pmu.h | 5 + 1 file changed, 5 insertions(+) diff --git a/target/riscv/pmu.h b/target/riscv/pmu.h index 505fc850d3..7c0ad661e0 100644 --- a/target

Re: [PATCH] target/riscv: Update $pc after linking to $ra in trans_cm_jalt()

2024-02-06 Thread Frank Chang
Reviewed-by: Frank Chang On Tue, Feb 6, 2024 at 9:19 PM Jason Chien wrote: > The original implementation sets $pc to the address read from the jump > vector table first and links $ra with the address of the next instruction > after the updated $pc. After jumping to the up

Re: [PATCH] hw/pci-host: Allow extended config space access for Designware PCIe host

2023-08-11 Thread Frank Chang
Reviewed-by: Frank Chang On Wed, Aug 9, 2023 at 6:23 PM Jason Chien wrote: > In pcie_bus_realize(), a root bus is realized as a PCIe bus and a non-root > bus is realized as a PCIe bus if its parent bus is a PCIe bus. However, > the child bus "dw-pcie" is realized before t

Re: [PATCH] target/riscv: Add Zihintntl extension ISA string to DTS

2023-07-04 Thread Frank Chang
Reviewed-by: Frank Chang On Tue, Jul 4, 2023 at 4:41 PM Jason Chien wrote: > RVA23 Profiles states: > The RVA23 profiles are intended to be used for 64-bit application > processors that will run rich OS stacks from standard binary OS > distributions and with a substantial number of

Re: [PATCH] hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop.

2023-05-20 Thread Frank Chang
Reviewed-by: Frank Chang On Fri, May 19, 2023 at 2:23 PM Tommy Wu wrote: > When we receive a packet from the xilinx_axienet and then try to s2mem > through the xilinx_axidma, if the descriptor ring buffer is full in the > xilinx axidma driver, we’ll assert the DMASR.HALTED in the &

Re: [PATCH] target/riscv: Add support for Zicond extension

2023-02-23 Thread Frank Chang
Reviewed-by: Frank Chang On Tue, Feb 21, 2023 at 5:10 PM Weiwei Li wrote: > The spec can be found in https://github.com/riscv/riscv-zicond. > Two instructions are added: > - czero.eqz: Moves zero to a register rd, if the condition rs2 is >equal to zero, otherwise mov

Re: [PATCH] target/riscv/vector_helper.c: create vext_set_tail_elems_1s()

2023-02-23 Thread Frank Chang
Reviewed-by: Frank Chang On Wed, Feb 22, 2023 at 2:46 AM Daniel Henrique Barboza < dbarb...@ventanamicro.com> wrote: > Commit 752614cab8e6 ("target/riscv: rvv: Add tail agnostic for vector > load / store instructions") added code to set the tail elements to 1 in > th

Re: [PATCH] target/riscv: Fix vslide1up.vf and vslide1down.vf

2023-02-13 Thread Frank Chang
Reviewed-by: Frank Chang On Mon, Feb 13, 2023 at 5:45 PM LIU Zhiwei wrote: > vslide1up_##BITWIDTH is used by the vslide1up.vx and vslide1up.vf. So its > scalar input should be uint64_t to hold the 64 bits float register.And the > same for vslide1down_##BITWIDTH. > > This bug is

Re: [PATCH] MAINTAINERS: Add some RISC-V reviewers

2023-02-09 Thread Frank Chang
Reviewed-by: Frank Chang On Thu, Feb 9, 2023 at 8:34 AM Alistair Francis < alistair.fran...@opensource.wdc.com> wrote: > From: Alistair Francis > > This patch adds some active RISC-V members as reviewers to the > MAINTAINERS file. > > Signed-off-by: Alistair Francis

[PATCH v2] target/riscv: Remove privileged spec version restriction for RVV

2023-02-07 Thread frank . chang
From: Frank Chang The RVV specification does not require that the core needs to support the privileged specification v1.12.0 to support RVV, and there is no dependency from ISA level. This commit removes the restriction from both RVV CSRs and extension CPU ISA string. Signed-off-by: Frank

Re: [PATCH] target/riscv: Remove .min_priv_ver restriction from RVV CSRs

2023-02-07 Thread Frank Chang
I realized that I should also remove the privileged version check in isa_edata_arr[], too. I will send out v2 patch to fix it. Regards, Frank Chang On Tue, Feb 7, 2023 at 4:43 PM wrote: > From: Frank Chang > > The RVV specification does not require that the core needs t

[PATCH] target/riscv: Remove .min_priv_ver restriction from RVV CSRs

2023-02-07 Thread frank . chang
From: Frank Chang The RVV specification does not require that the core needs to support the privileged specification v1.12.0 to support RVV, and there is no dependency from ISA level. This commit removes the restriction. Signed-off-by: Frank Chang --- target/riscv/csr.c | 21

Re: [PATCH v10 3/5] riscv: Allow user to set the satp mode

2023-02-03 Thread Frank Chang
ot;sv39"; > +case VM_1_10_MBARE: > +return "none"; > +} > +} > + > +g_assert_not_reached(); > +} > + > +/* Sets the satp mode to the max supported */ > +static void set_satp_mode_default_map(RISCVCPU *cpu) > +{ &g

Re: [PATCH v10 4/5] riscv: Introduce satp mode hw capabilities

2023-02-03 Thread Frank Chang
Reviewed-by: Frank Chang On Fri, Feb 3, 2023 at 2:02 PM Alexandre Ghiti wrote: > Currently, the max satp mode is set with the only constraint that it must > be > implemented in QEMU, i.e. set in valid_vm_1_10_[32|64]. > > But we actually need to add another level of constrai

Re: [PATCH v9 4/5] riscv: Introduce satp mode hw capabilities

2023-02-02 Thread Frank Chang
On Thu, Feb 2, 2023 at 9:01 PM Alexandre Ghiti wrote: > Hi Frank, > > On Wed, Feb 1, 2023 at 4:49 PM Frank Chang wrote: > > > > On Tue, Jan 31, 2023 at 10:36 PM Alexandre Ghiti > wrote: > >> > >> Currently, the max satp mode is set with the only con

Re: [PATCH v9 4/5] riscv: Introduce satp mode hw capabilities

2023-02-01 Thread Frank Chang
lid_vm_1_10_32 and valid_vm_1_10_64 are defined in !CONFIG_USER_ONLY section. This issue also exists in patch 3. You have to move valid_vm_1_10_32 and valid_vm_1_10_64 out from !CONFIG_USER_ONLY. Regards, Frank Chang > -if (riscv_feature(>env, RISCV_FEATURE_MMU)) { > -

Re: [PATCH v9 5/5] riscv: Correctly set the device-tree entry 'mmu-type'

2023-02-01 Thread Frank Chang
Reviewed-by: Frank Chang On Tue, Jan 31, 2023 at 10:36 PM Alexandre Ghiti wrote: > The 'mmu-type' should reflect what the hardware is capable of so use the > new satp_mode field in RISCVCPUConfig to do that. > > Signed-off-by: Alexandre Ghiti > Reviewed-by: Andrew Jo

Re: [PATCH v9 2/5] riscv: Change type of valid_vm_1_10_[32|64] to bool

2023-02-01 Thread Frank Chang
Reviewed-by: Frank Chang On Tue, Jan 31, 2023 at 10:29 PM Alexandre Ghiti wrote: > This array is actually used as a boolean so swap its current char type > to a boolean and at the same time, change the type of validate_vm to > bool since it returns valid_vm_1_10_[32|64]. >

Re: [PATCH v5 1/2] riscv: Pass Object to register_cpu_props instead of DeviceState

2023-01-16 Thread Frank Chang
Reviewed-by: Frank Chang On Fri, Jan 13, 2023 at 6:35 PM Alexandre Ghiti wrote: > One can extract the DeviceState pointer from the Object pointer, so pass > the Object for future commits to access other fields of Object. > > No functional changes intended. > > Signed-off-b

Re: [PATCH v4] riscv: Allow user to set the satp mode

2022-12-16 Thread Frank Chang
e add another helper function to wrap this for the "named" CPUs? Regards, Frank Chang On Mon, Dec 12, 2022 at 6:23 PM Alexandre Ghiti wrote: > RISC-V specifies multiple sizes for addressable memory and Linux probes for > the machine's support at startup via the satp CSR regis

Re: [PATCH] target/riscv/cpu.c: Fix elen check

2022-12-15 Thread Frank Chang
Reviewed-by: Frank Chang On Thu, Dec 15, 2022 at 11:09 PM Elta <503386...@qq.com> wrote: > Should be cpu->cfg.elen in range [8, 64]. > > Signed-off-by: Dongxue Zhang > --- > target/riscv/cpu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --

Re: [PATCH 1/3] target/riscv: Set the CPU resetvec directly

2022-09-27 Thread Frank Chang
Reviewed-by: Frank Chang On Wed, Sep 14, 2022 at 6:12 PM Alistair Francis via wrote: > Instead of using our properties to set a config value which then might > be used to set the resetvec (depending on your timing), let's instead > just set the resetvec directly in the e

Re: [PATCH 2/3] hw/riscv: sifive_e: Support the watchdog timer of HiFive 1 rev b.

2022-09-27 Thread Frank Chang
Reviewed-by: Frank Chang On Thu, Sep 22, 2022 at 4:41 PM Tommy Wu wrote: > Create the AON device when we realize the sifive_e machine. > This patch only implemented the functionality of the watchdog timer, > not all the functionality of the AON device. > > Signed-off-by: Tommy

Re: [PATCH 1/3] hw/misc: sifive_e_aon: Support the watchdog timer of HiFive 1 rev b.

2022-09-27 Thread Frank Chang
Reviewed-by: Frank Chang On Thu, Sep 22, 2022 at 4:41 PM Tommy Wu wrote: > The watchdog timer is in the always-on domain device of HiFive 1 rev b, > so this patch added the AON device to the sifive_e machine. This patch > only implemented the functionality of the watchdog timer. >

Re: [PATCH 3/3] tests/qtest: sifive-e-aon-watchdog-test.c : Add QTest of watchdog of sifive_e

2022-09-27 Thread Frank Chang
Reviewed-by: Frank Chang On Thu, Sep 22, 2022 at 4:42 PM Tommy Wu wrote: > Add some simple tests of the watchdog timer in the always-on domain device > of HiFive 1 rev b. > > Signed-off-by: Tommy Wu > --- > tests/qtest/meson.build | 3 + > tests/qtest/

Re: [PATCH 2/2] target/riscv: rvv-1.0: vf[w]redsum distinguish between ordered/unordered

2022-09-25 Thread Frank Chang
Reviewed-by: Frank Chang On Wed, Aug 17, 2022 at 11:45 PM Yang Liu wrote: > Starting with RVV1.0, the original vf[w]redsum_vs instruction was renamed > to vf[w]redusum_vs. The distinction between ordered and unordered is also > more consistent with other instructions,

Re: [PATCH 1/2] target/riscv: rvv-1.0: Simplify vfwredsum code

2022-09-25 Thread Frank Chang
Reviewed-by: Frank Chang On Wed, Aug 17, 2022 at 11:32 PM Yang Liu wrote: > Remove duplicate code by wrapping vfwredsum_vs's OP function. > > Signed-off-by: Yang Liu > --- > target/riscv/vector_helper.c | 56 +++- > 1 file changed, 10

Re: [PATCH] hw/riscv/sifive_e: Fix inheritance of SiFiveEState

2022-09-22 Thread Frank Chang
Hi Bernhard, I think there's already a similar patch for this bug fix: https://www.mail-archive.com/qemu-devel@nongnu.org/msg905424.html Regards, Frank Chang On Thu, Sep 22, 2022 at 3:53 PM Bernhard Beschow wrote: > SiFiveEState inherits from SysBusDevice while it's TypeInfo cla

[PATCH] target/riscv: Check the correct exception cause in vector GDB stub

2022-09-18 Thread frank . chang
From: Frank Chang After RISCVException enum is introduced, riscv_csrrw_debug() returns RISCV_EXCP_NONE to indicate there's no error. RISC-V vector GDB stub should check the result against RISCV_EXCP_NONE instead of value 0. Otherwise, 'E14' packet would be incorrectly reported for vector CSRs

Re: [PATCH 1/2] util/log: Add vu to dump content of vector unit

2022-07-11 Thread Frank Chang
ot;, "output from TCG plugins\n"}, > #endif > +{ CPU_LOG_TB_VU, "vu", > + "include vector unit registers in the 'cpu' logging" }, > { LOG_STRACE, "strace", >"log every user-mode syscall, its input, and its result" }, > { LOG_PER_THREAD, "tid", > -- > 2.34.0 > > Reviewed-by: Frank Chang

Re: [PATCH 2/2] target/riscv: Auto set elen from vector extension by default

2022-07-11 Thread Frank Chang
gt; + cpu->cfg.elen < 8)) { > error_setg(errp, > "Vector extension implementation only supports > ELEN " > "in the range [8, 64]"); >

[PATCH 8/9] target/riscv: debug: Return 0 if previous value written to tselect >= number of triggers

2022-06-09 Thread frank . chang
From: Frank Chang If the value written to tselect is greater than or equal to the number of supported triggers, then the following reads of tselect would return value 0. Signed-off-by: Frank Chang --- target/riscv/cpu.h | 1 + target/riscv/debug.c | 6 ++ 2 files changed, 7 insertions

[PATCH 9/9] target/riscv: debug: Add initial support of type 6 trigger

2022-06-09 Thread frank . chang
From: Frank Chang Type 6 trigger is similar to a type 2 trigger, but provides additional functionality and should be used instead of type 2 in newer implementations. Signed-off-by: Frank Chang --- target/riscv/debug.c | 174 ++- target/riscv/debug.h

[PATCH 7/9] target/riscv: debug: Check VU/VS modes for type 2 trigger

2022-06-09 Thread frank . chang
From: Frank Chang Type 2 trigger cannot be fired in VU/VS modes. Signed-off-by: Frank Chang --- target/riscv/debug.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/target/riscv/debug.c b/target/riscv/debug.c index ab23566113..ce9ff15d75 100644 --- a/target/riscv/debug.c +++ b

[PATCH 6/9] target/riscv: debug: Create common trigger actions function

2022-06-09 Thread frank . chang
From: Frank Chang Trigger actions are shared among all triggers. Extract to a common function. Signed-off-by: Frank Chang --- target/riscv/debug.c | 55 ++-- target/riscv/debug.h | 13 +++ 2 files changed, 66 insertions(+), 2 deletions(-) diff

[PATCH 1/9] target/riscv: debug: Determine the trigger type from tdata1.type

2022-06-09 Thread frank . chang
From: Frank Chang Current RISC-V debug assumes that only type 2 trigger is supported. To allow more types of triggers to be supported in the future (e.g. type 6 trigger, which is similar to type 2 trigger with additional functionality), we should determine the trigger type from tdata1.type

[PATCH 5/9] target/riscv: debug: Introduce tinfo CSR

2022-06-09 Thread frank . chang
From: Frank Chang tinfo.info: One bit for each possible type enumerated in tdata1. If the bit is set, then that type is supported by the currently selected trigger. Signed-off-by: Frank Chang --- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 8 target/riscv/debug.c

[PATCH 2/9] target/riscv: debug: Introduce build_tdata1() to build tdata1 register content

2022-06-09 Thread frank . chang
From: Frank Chang Introduce build_tdata1() to build tdata1 register content, which can be shared among all types of triggers. Signed-off-by: Frank Chang --- target/riscv/debug.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/target/riscv/debug.c b/target

[PATCH 4/9] target/riscv: debug: Restrict the range of tselect value can be written

2022-06-09 Thread frank . chang
From: Frank Chang The value of tselect CSR can be written should be limited within the range of supported triggers number. Signed-off-by: Frank Chang --- target/riscv/debug.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/target/riscv/debug.c b/target/riscv

[PATCH 0/9] Improve RISC-V Debug support

2022-06-09 Thread frank . chang
From: Frank Chang This patchset refactors RISC-V Debug support to allow more types of triggers to be extended. The initial support of type 6 trigger, which is similar to type 2 trigger with additional functionality, is also introduced in this patchset. Frank Chang (9): target/riscv: debug

[PATCH 3/9] target/riscv: debug: Introduce tdata1, tdata2, and tdata3 CSRs

2022-06-09 Thread frank . chang
From: Frank Chang Replace type2_trigger_t with the real tdata1, tdata2, and tdata3 CSRs, which allows us to support more types of triggers in the future. Signed-off-by: Frank Chang --- target/riscv/cpu.h | 6 ++- target/riscv/debug.c | 101

Re: [PATCH v9 09/12] target/riscv: Simplify counter predicate function

2022-05-25 Thread Frank Chang
ak; > -case CSR_INSTRETH: > -if (!get_field(env->mcounteren, COUNTEREN_IR)) { > -return RISCV_EXCP_ILLEGAL_INST; > -} > -break; > -case CSR_HPMCOUNTER3H...CSR_HPMCOUNTER31H: > -

Re: [PATCH v9 08/12] target/riscv: Add sscofpmf extension support

2022-05-25 Thread Frank Chang
VMSTATE_UINTTL(mhpmcounterh_prev, PMUCTRState), > +VMSTATE_UINT8(write_done, PMUCTRState), > VMSTATE_BOOL(started, PMUCTRState), > VMSTATE_END_OF_LIST() > } > @@ -355,6 +356,9 @@ const VMStateDescription vmstate_riscv_cpu = { >

[RESEND PATCH v2] target/riscv: Fix typo of mimpid cpu option

2022-05-23 Thread frank . chang
From: Frank Chang "mimpid" cpu option was mistyped to "mipid". Fixes: 9951ba94 ("target/riscv: Support configuarable marchid, mvendorid, mipid CSR values") Signed-off-by: Frank Chang Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 4 ++-- target/riscv/cp

[PATCH v2] target/riscv: Fix typo of mimpid cpu option

2022-05-23 Thread frank . chang
From: Frank Chang "mimpid" cpu option was mistyped to "mipid". Fixes: 9951ba94 ("target/riscv: Support configuarable marchid, mvendorid, mipid CSR values") Signed-off-by: Frank Chang --- target/riscv/cpu.c | 4 ++-- target/riscv/cpu.h | 2 +- target/riscv/csr.c

[PATCH] target/riscv: Fix typo of mimpid cpu option

2022-05-20 Thread frank . chang
From: Frank Chang "mimpid" cpu option was mistyped to "mipid". Fixes commit: 9951ba94 Signed-off-by: Frank Chang --- target/riscv/cpu.c | 4 ++-- target/riscv/cpu.h | 2 +- target/riscv/csr.c | 8 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/

Re: [PATCH v8 07/12] target/riscv: Support mcycle/minstret write operation

2022-05-14 Thread Frank Chang
On Fri, May 13, 2022 at 11:58 PM Atish Kumar Patra wrote: > On Thu, May 12, 2022 at 11:29 PM Frank Chang > wrote: > > > > On Thu, May 12, 2022 at 6:01 AM Atish Patra wrote: > >> > >> From: Atish Patra > >> > >> mcycle/minstret are actually

Re: [PATCH] hw/intc: Pass correct hartid while updating mtimecmp

2022-05-13 Thread Frank Chang
Reviewed-by: Frank Chang On Sat, May 14, 2022 at 6:15 AM Atish Patra wrote: > timecmp update function should be invoked with hartid for which > timecmp is being updated. The following patch passes the incorrect > hartid to the update function. > > Fixes: e2f01f3c2e13 ("

Re: [PATCH v8 07/12] target/riscv: Support mcycle/minstret write operation

2022-05-13 Thread Frank Chang
} > > return RISCV_EXCP_NONE; > } > > static int read_hpmcounter(CPURISCVState *env, int csrno, target_ulong > *val) > { > -int ctr_index; > +uint16_t ctr_index; > > if (env->priv == PRV_M) { > -ctr_index = csrno - CSR_MHP

Re: [PATCH] hw/dma: Add Xilinx AXI CDMA

2022-05-04 Thread Frank Chang
On Thu, May 5, 2022 at 4:50 AM Edgar E. Iglesias wrote: > > On Tue, May 3, 2022 at 7:12 PM Edgar E. Iglesias > wrote: > >> On Tue, May 3, 2022 at 5:06 PM Frank Chang >> wrote: >> >>> On Tue, May 3, 2022 at 5:35 PM Edgar E. Iglesias < >>> edga

Re: [PATCH 2/3] target/riscv: Add dummy mcountinhibit CSR for priv spec v1.11 or higher

2022-05-04 Thread Frank Chang
Hi Anup, I found that Atish has already submitted a patch to implement the mcountinhibit CSR: https://www.mail-archive.com/qemu-devel@nongnu.org/msg879349.html Regards, Frank Chang On Fri, Apr 29, 2022 at 11:44 PM Anup Patel wrote: > The mcountinhibit CSR is mandatory for priv spec v1

Re: [PATCH] hw/dma: Add Xilinx AXI CDMA

2022-05-03 Thread Frank Chang
On Tue, May 3, 2022 at 5:35 PM Edgar E. Iglesias wrote: > On Tue, May 3, 2022 at 3:16 AM Frank Chang wrote: > >> On Mon, May 2, 2022 at 6:29 PM Edgar E. Iglesias < >> edgar.igles...@gmail.com> wrote: >> >>> On Thu, Apr 28, 2022 at 5:43 PM wrote: >>&

Re: [PATCH] hw/dma: Add Xilinx AXI CDMA

2022-05-02 Thread Frank Chang
On Mon, May 2, 2022 at 6:29 PM Edgar E. Iglesias wrote: > On Thu, Apr 28, 2022 at 5:43 PM wrote: > >> From: Frank Chang >> >> Add Xilinx AXI CDMA model, which follows >> AXI Central Direct Memory Access v4.1 spec: >> https://docs.xilinx.com/v/u/en-US/pg034

Re: [PATCH 3/3] target/riscv: Consider priv spec version when generating ISA string

2022-04-29 Thread Frank Chang
On Sat, Apr 30, 2022 at 12:30 PM Anup Patel wrote: > On Sat, Apr 30, 2022 at 8:39 AM Frank Chang > wrote: > > > > Hi Anup, > > > > If we want to limit the generated ISA string to/after a specific > privilege spec version. > > Shouldn't we als

Re: [PATCH 1/4] target/riscv: Fix csr number based privilege checking

2022-04-29 Thread Frank Chang
Reviewed-by: Frank Chang On Fri, Apr 29, 2022 at 11:34 AM Anup Patel wrote: > When hypervisor and VS CSRs are accessed from VS-mode or VU-mode, > the riscv_csrrw_check() function should generate virtual instruction > trap instead illegal instruction trap. > > Fixes: 533c91e8f22c

Re: [PATCH 3/4] target/riscv: Set [m|s]tval for both illegal and virtual instruction traps

2022-04-29 Thread Frank Chang
Reviewed-by: Frank Chang On Fri, Apr 29, 2022 at 11:36 AM Anup Patel wrote: > Currently, the [m|s]tval CSRs are set with trapping instruction encoding > only for illegal instruction traps taken at the time of instruction > decoding. > > In RISC-V world, a valid instructions

Re: [PATCH 2/3] target/riscv: Add dummy mcountinhibit CSR for priv spec v1.11 or higher

2022-04-29 Thread Frank Chang
Reviewed-by: Frank Chang On Fri, Apr 29, 2022 at 11:44 PM Anup Patel wrote: > The mcountinhibit CSR is mandatory for priv spec v1.11 or higher. For > implementation that don't want to implement can simply have a dummy > mcountinhibit which always zero. > > Fixes: a4b2fa433125

Re: [PATCH 3/3] target/riscv: Consider priv spec version when generating ISA string

2022-04-29 Thread Frank Chang
in which the extension is supported. (This is possible if user specifies the privileged spec version through the command line.) The ISA string therefore won't include the enabled extension. Regards, Frank Chang On Fri, Apr 29, 2022 at 11:49 PM Anup Patel wrote: > Most of the multi-let

Re: [PATCH 1/3] target/riscv: Don't force update priv spec version to latest

2022-04-29 Thread Frank Chang
Reviewed-by: Frank Chang On Fri, Apr 29, 2022 at 11:41 PM Anup Patel wrote: > The riscv_cpu_realize() sets priv spec verion to v1.12 when it is > when "env->priv_ver == 0" (i.e. default v1.10) because the enum > value of priv spec v1.10 is zero. > > Due to above

[PATCH] hw/dma: Add Xilinx AXI CDMA

2022-04-28 Thread frank . chang
From: Frank Chang Add Xilinx AXI CDMA model, which follows AXI Central Direct Memory Access v4.1 spec: https://docs.xilinx.com/v/u/en-US/pg034-axi-cdma Supports both Simple DMA and Scatter Gather modes. Signed-off-by: Frank Chang Reviewed-by: Jim Shu --- hw/dma/meson.build

[PATCH v3] target/riscv: Support configuarable marchid, mvendorid, mipid CSR values

2022-04-21 Thread frank . chang
From: Frank Chang Allow user to set core's marchid, mvendorid, mipid CSRs through -cpu command line option. The default values of marchid and mipid are built with QEMU's version numbers. Signed-off-by: Frank Chang Reviewed-by: Jim Shu Reviewed-by: Alistair Francis Reviewed-by: Bin Meng

Re: [PATCH v2] target/riscv: Support configuarable marchid, mvendorid, mipid CSR values

2022-04-21 Thread Frank Chang
On Fri, Apr 22, 2022 at 8:48 AM Alistair Francis wrote: > On Thu, Apr 21, 2022 at 12:17 PM Bin Meng wrote: > > > > On Wed, Apr 20, 2022 at 5:57 PM wrote: > > > > > > From: Frank Chang > > > > > > Allow user to set core's marchid, mvendorid

[PATCH v2] target/riscv: Support configuarable marchid, mvendorid, mipid CSR values

2022-04-20 Thread frank . chang
From: Frank Chang Allow user to set core's marchid, mvendorid, mipid CSRs through -cpu command line option. The default values of marchid and mipid are built with QEMU's version numbers. Signed-off-by: Frank Chang Reviewed-by: Jim Shu Reviewed-by: Alistair Francis --- target/riscv/cpu.c

Re: [PATCH] target/riscv: Support configuarable marchid, mvendorid, mipid CSR values

2022-04-20 Thread Frank Chang
On Tue, Apr 19, 2022 at 2:00 PM Frank Chang wrote: > On Tue, Apr 19, 2022 at 1:27 PM Anup Patel > wrote: > >> On Tue, Apr 19, 2022 at 10:52 AM Alistair Francis >> wrote: >> > >> > On Fri, Apr 15, 2022 at 7:37 PM wrote: >> > > >> >

[PATCH v4 3/4] hw/intc: Make RISC-V ACLINT mtime MMIO register writable

2022-04-20 Thread frank . chang
From: Frank Chang RISC-V privilege spec defines that mtime is exposed as a memory-mapped machine-mode read-write register. However, as QEMU uses host monotonic timer as timer source, this makes mtime to be read-only in RISC-V ACLINT. This patch makes mtime to be writable by recording the time

[PATCH v4 4/4] hw/intc: riscv_aclint: Add reset function of ACLINT devices

2022-04-20 Thread frank . chang
From: Jim Shu This commit implements reset function of all ACLINT devices. ACLINT device reset will clear MTIME and MSIP register to 0. Depend on RISC-V ACLINT spec v1.0-rc4: https://github.com/riscv/riscv-aclint/blob/v1.0-rc4/riscv-aclint.adoc Signed-off-by: Jim Shu Reviewed-by: Frank Chang

[PATCH v4 2/4] hw/intc: Support 32/64-bit mtimecmp and mtime accesses in RISC-V ACLINT

2022-04-20 Thread frank . chang
From: Frank Chang RISC-V privilege spec defines that: * In RV32, memory-mapped writes to mtimecmp modify only one 32-bit part of the register. * For RV64, naturally aligned 64-bit memory accesses to the mtime and mtimecmp registers are additionally supported and are atomic. It's possible

[PATCH v4 1/4] hw/intc: Add .impl.[min|max]_access_size declaration in RISC-V ACLINT

2022-04-20 Thread frank . chang
From: Frank Chang If device's MemoryRegion doesn't have .impl.[min|max]_access_size declaration, the default access_size_min would be 1 byte and access_size_max would be 4 bytes (see: softmmu/memory.c). This will cause a 64-bit memory access to ACLINT to be splitted into two 32-bit memory

[PATCH v4 0/4] Support ACLINT 32/64-bit mtimecmp/mtime read/write accesses

2022-04-20 Thread frank . chang
From: Frank Chang This patchset makes ACLINT mtime to be writable as RISC-V privilege spec defines that mtime is exposed as a memory-mapped machine-mode read-write register. Also, mtimecmp and mtime should be 32/64-bit memory accessible registers. ACLINT reset function is also added, which

Re: [PATCH] target/riscv: Support configuarable marchid, mvendorid, mipid CSR values

2022-04-20 Thread Frank Chang
On Wed, Apr 20, 2022 at 3:47 PM Alistair Francis wrote: > On Tue, Apr 19, 2022 at 5:04 PM Frank Chang > wrote: > > > > On Tue, Apr 19, 2022 at 2:00 PM Frank Chang > wrote: > >> > >> On Tue, Apr 19, 2022 at 1:27 PM Anup Patel > wrote: > >&g

Re: [PATCH v3 3/4] hw/intc: Make RISC-V ACLINT mtime MMIO register writable

2022-04-20 Thread Frank Chang
On Wed, Apr 20, 2022 at 3:42 PM Alistair Francis wrote: > On Tue, Apr 19, 2022 at 7:10 PM wrote: > > > > From: Frank Chang > > > > RISC-V privilege spec defines that mtime is exposed as a memory-mapped > > machine-mode read-write register. However, as Q

[PATCH v3 4/4] hw/intc: riscv_aclint: Add reset function of ACLINT devices

2022-04-19 Thread frank . chang
From: Jim Shu This commit implements reset function of all ACLINT devices. ACLINT device reset will clear MTIME and MSIP register to 0. Depend on RISC-V ACLINT spec v1.0-rc4: https://github.com/riscv/riscv-aclint/blob/v1.0-rc4/riscv-aclint.adoc Signed-off-by: Jim Shu Reviewed-by: Frank Chang

[PATCH v3 0/4] Support ACLINT 32/64-bit mtimecmp/mtime read/write accesses

2022-04-19 Thread frank . chang
From: Frank Chang This patchset makes ACLINT mtime to be writable as RISC-V privilege spec defines that mtime is exposed as a memory-mapped machine-mode read-write register. Also, mtimecmp and mtime should be 32/64-bit memory accessible registers. ACLINT reset function is also added, which

[PATCH v3 2/4] hw/intc: Support 32/64-bit mtimecmp and mtime accesses in RISC-V ACLINT

2022-04-19 Thread frank . chang
From: Frank Chang RISC-V privilege spec defines that: * In RV32, memory-mapped writes to mtimecmp modify only one 32-bit part of the register. * For RV64, naturally aligned 64-bit memory accesses to the mtime and mtimecmp registers are additionally supported and are atomic. It's possible

[PATCH v3 3/4] hw/intc: Make RISC-V ACLINT mtime MMIO register writable

2022-04-19 Thread frank . chang
From: Frank Chang RISC-V privilege spec defines that mtime is exposed as a memory-mapped machine-mode read-write register. However, as QEMU uses host monotonic timer as timer source, this makes mtime to be read-only in RISC-V ACLINT. This patch makes mtime to be writable by recording the time

[PATCH v3 1/4] hw/intc: Add .impl.[min|max]_access_size declaration in RISC-V ACLINT

2022-04-19 Thread frank . chang
From: Frank Chang If device's MemoryRegion doesn't have .impl.[min|max]_access_size declaration, the default access_size_min would be 1 byte and access_size_max would be 4 bytes (see: softmmu/memory.c). This will cause a 64-bit memory access to ACLINT to be splitted into two 32-bit memory

Re: [PATCH] target/riscv: Support configuarable marchid, mvendorid, mipid CSR values

2022-04-19 Thread Frank Chang
On Tue, Apr 19, 2022 at 2:00 PM Frank Chang wrote: > On Tue, Apr 19, 2022 at 1:27 PM Anup Patel > wrote: > >> On Tue, Apr 19, 2022 at 10:52 AM Alistair Francis >> wrote: >> > >> > On Fri, Apr 15, 2022 at 7:37 PM wrote: >> > > >> >

Re: [PATCH] target/riscv: Support configuarable marchid, mvendorid, mipid CSR values

2022-04-19 Thread Frank Chang
On Tue, Apr 19, 2022 at 1:27 PM Anup Patel wrote: > On Tue, Apr 19, 2022 at 10:52 AM Alistair Francis > wrote: > > > > On Fri, Apr 15, 2022 at 7:37 PM wrote: > > > > > > From: Frank Chang > > > > > > Allow user to set core's marchid,

  1   2   3   4   5   6   7   8   9   10   >