Re: [PATCH for-8.1 v3 01/26] target/riscv/cpu.c: add riscv_cpu_validate_v()

2023-03-20 Thread LIU Zhiwei
-} else { -error_setg(errp, - "Unsupported vector spec version '%s'", - cpu->cfg.vext_spec); -return; -} -} else { -qemu_log("vector version is not specified, " - "use the default value v1.0\n"); -} -set_vext_version(env, vext_version); Reviewed-by: LIU Zhiwei Zhiwei } if (cpu->cfg.ext_j) { ext |= RVJ;

Re: Question about TCG liveness_pass_1

2023-03-18 Thread LIU Zhiwei
On 2023/3/17 22:02, Richard Henderson wrote: On 3/16/23 19:57, LIU Zhiwei wrote: Hi Richard, When I read the tcg code, I find a corner case which may be a bug in liveness_pass_1. I see all TEMP_TBs or global temps are set to TS_DEAD | TS_MEM when enter liveness_pass_1. Think about

Re: [PATCH v4] target/riscv: fix H extension TVM trap

2023-03-17 Thread LIU Zhiwei
(env->priv == PRV_U || get_field(env->hstatus, HSTATUS_VTVM))) { riscv_raise_exception(env, RISCV_EXCP_VIRT_INSTRUCTION_FAULT, GETPC()); } else { tlb_flush(cs); @@ -403,7 +403,7 @@ void helper_hyp_tlb_flush(CPURISCVState *env) { CPUState *cs = env_cpu(env); -if (env->priv == PRV_S && riscv_cpu_virt_enabled(env)) { +if (riscv_cpu_virt_enabled(env)) { riscv_raise_exception(env, RISCV_EXCP_VIRT_INSTRUCTION_FAULT, GETPC()); } Reviewed-by: LIU Zhiwei Zhiwei

Re: [PATCH qemu v2] linux-user: Emulate /proc/cpuinfo output for riscv

2023-03-17 Thread LIU Zhiwei
fer, "isa\t\t: rv64imafdc_zicsr_zifencei\n") == 0); +} else if (strstr(buffer, "mmu") != NULL) { +assert(strcmp(buffer, "mmu\t\t: sv48\n") == 0); +} else if (strstr(buffer, "uarch") != NULL) { +assert(strcmp(buffer, "uarch\t\t: qemu\n") == 0); +} +} + +fclose(fp); +return 0; +} Reviewed-by: LIU Zhiwei Zhiwei

Question about TCG liveness_pass_1

2023-03-16 Thread LIU Zhiwei
Hi Richard, When I read the tcg code, I find a corner case which may be a bug in liveness_pass_1. I see all TEMP_TBs or global temps are set to TS_DEAD | TS_MEM when enter liveness_pass_1. Think about the  sequence. 1)Write_global_temp_0 // 0->TS_DEAD, but not recorded in arg_life

Re: [PATCH] disas/riscv: Add support for XThead* instructions

2023-03-15 Thread LIU Zhiwei
for XTHEAD*. I once sent a multiple disassemble path patch set  for custom extensions. https://www.mail-archive.com/qemu-devel@nongnu.org/msg906222.html We may continue this work based on that patch set. Zhiwei Co-developed-by: LIU Zhiwei Signed-off-by: Christoph Müllner --- disas/riscv.c

Re: [PATCH v2 07/10] contrib/gitdm: add Alibaba to the domain-map

2023-03-12 Thread LIU Zhiwei
On 2023/3/11 2:03, Alex Bennée wrote: This replaces the previous attempt to add c-sky.com so I've dropped the review/ack tags. Group everything under Alibaba now. Added as requested by LIU Zhiwei. Signed-off-by: Alex Bennée Cc: LIU Zhiwei Cc: Xuan Zhuo Cc: Guo Ren --- contrib/gitdm

Re: [PATCH] target/riscv/csr.c: fix H extension TVM trap

2023-03-10 Thread LIU Zhiwei
On 2023/3/10 17:08, CHEN Yi wrote: -Original Messages- *From:*"LIU Zhiwei" *Sent Time:*2023-03-10 10:12:10 (Friday) *To:* chenyi2...@zju.edu.cn, qemu-devel@nongnu.org *Cc:* "Palmer Dabbelt" , "Alistair Francis" , "Bin Meng&qu

Re: [PATCH] target/riscv/csr.c: fix H extension TVM trap

2023-03-09 Thread LIU Zhiwei
On 2023/3/8 20:34, chenyi2...@zju.edu.cn wrote: From: Yi Chen Trap accesses to hgatp if MSTATUS_TVM is enabled. Don't trap accesses to vsatp even if MSTATUS_TVM is enabled. By the way, do you know why mstatus_tvm and hstatus_tvm are needed? The specification said, The TVM mechanism

Re: [PATCH for-8.1 17/17] target/riscv: rework write_misa()

2023-03-08 Thread LIU Zhiwei
On 2023/3/9 15:27, LIU Zhiwei wrote: On 2023/3/9 4:19, Daniel Henrique Barboza wrote: write_misa() must use as much common logic as possible, only specifying the bits that are exclusive to the CSR write operation and TCG internals. Rewrite write_misa() to work as follows: - supress RVC

Re: [PATCH for-8.1 04/17] target/riscv: add PRIV_VERSION_LATEST macro

2023-03-08 Thread LIU Zhiwei
On 2023/3/9 4:19, Daniel Henrique Barboza wrote: PRIV_VERSION_LATEST, at this moment assigned to PRIV_VERSION_1_12_0, is used in all generic CPUs: - riscv_any_cpu_init() - rv32_base_cpu_init() - rv64_base_cpu_init() - rv128_base_cpu_init() When a new PRIV version is made available we can

Re: [PATCH for-8.1 03/17] target/riscv/cpu.c: remove set_priv_version()

2023-03-08 Thread LIU Zhiwei
On 2023/3/9 4:19, Daniel Henrique Barboza wrote: The setter is doing nothing special. Just set env->priv_ver directly. IMHO, No better than the older implementation. Zhiwei Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 30 +- 1 file

Re: [PATCH for-8.1 02/17] target/riscv/cpu.c: remove set_vext_version()

2023-03-08 Thread LIU Zhiwei
On 2023/3/9 4:19, Daniel Henrique Barboza wrote: This setter is doing nothing else but setting env->vext_ver. Assign the value directly. IMHO, No better than the older implementation. Zhiwei Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 7 +-- 1 file changed, 1

Re: [PATCH for-8.1 17/17] target/riscv: rework write_misa()

2023-03-08 Thread LIU Zhiwei
On 2023/3/9 4:19, Daniel Henrique Barboza wrote: write_misa() must use as much common logic as possible, only specifying the bits that are exclusive to the CSR write operation and TCG internals. Rewrite write_misa() to work as follows: - supress RVC right after verifying that we're not

Re: [PATCH for-8.1 14/17] target/riscv/cpu.c: do not allow RVE to be set

2023-03-08 Thread LIU Zhiwei
On 2023/3/9 4:19, Daniel Henrique Barboza wrote: This restriction is found at the current implementation of write_misa() in csr.c. Add it in riscv_cpu_validate_set_extensions() as well, while also removing the checks we're doing considering that I or E can be enabled. Signed-off-by: Daniel

Re: [PATCH v7 03/10] target/riscv: allow MISA writes as experimental

2023-03-08 Thread LIU Zhiwei
On 2023/2/23 2:51, Daniel Henrique Barboza wrote: At this moment, and apparently since ever, we have no way of enabling RISCV_FEATURE_MISA. This means that all the code from write_misa(), all the nuts and bolts that handles how to properly write this CSR, has always been a no-op as well

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

2023-03-08 Thread LIU Zhiwei
On 2023/3/9 11:05, Jim Shu wrote: 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 support H-extension

Re: [PATCH qemu] linux-user: Emulate /proc/cpuinfo output for riscv

2023-03-06 Thread LIU Zhiwei
On 2023/3/5 22:34, ~abordado wrote: From: Afonso Bordado RISC-V does not expose all extensions via hwcaps, thus some userspace applications may want to query these via /proc/cpuinfo. Currently when querying this file the host's file is shown instead which is slightly confusing. Emulate a

Re: [PATCH 1/1] hw/riscv: Add signature dump function for spike to run ACT tests

2023-03-06 Thread LIU Zhiwei
On 2023/3/6 20:10, liweiwei wrote: On 2023/3/6 19:00, LIU Zhiwei wrote: On 2023/3/6 17:03, Weiwei Li wrote: Add signature and signature-granularity properties in spike to specify the target signatrue file and the line size for signature data. Recgonize the signature section between

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

2023-03-06 Thread LIU Zhiwei
rt = ldtul_p(mem_buf) & 0x1; +if ((cs->priv == PRV_M) && (virt == true)) { +/* M-mode only supports V=0. */ +virt = false; +} +riscv_cpu_set_virt_enabled(cs, virt); return sizeof(target_ulong); Same error here. Ot

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

2023-03-06 Thread LIU Zhiwei
ot;, 0); break; case MXL_RV64: case MXL_RV128: gdb_register_coprocessor(cs, riscv_gdb_get_virtual, riscv_gdb_set_virtual, - 1, "riscv-64bit-virtual.xml", 0); + 2, "

Re: [PATCH 1/1] hw/riscv: Add signature dump function for spike to run ACT tests

2023-03-06 Thread LIU Zhiwei
+if (i + j <= sig_len) { +fprintf(signature, "%02x", + sig_data[i + j - 1] & 0xff); Not sure about the order. Otherwise, Reviewe

Re: [PATCH v2 03/18] target/riscv: Use g_assert() for the predicate() NULL check

2023-03-01 Thread LIU Zhiwei
ate *env, * illegal instruction exception should be triggered instead of virtual * instruction exception. Hence this comes after the read / write check. */ +g_assert(csr_ops[csrno].predicate != NULL); Reviewed-by: LIU Zhiwei Zhiwei RISCVException ret = csr_ops[csrno].p

Re: [PATCH v2 02/18] target/riscv: Add some comments to clarify the priority policy of riscv_csrrw_check()

2023-03-01 Thread LIU Zhiwei
check. + */ Reviewed-by: LIU Zhiwei Zhiwei RISCVException ret = csr_ops[csrno].predicate(env, csrno); if (ret != RISCV_EXCP_NONE) { return ret;

Re: [PATCH v2 18/18] target/riscv: Group all predicate() routines together

2023-03-01 Thread LIU Zhiwei
riscv_set_csr_ops(int csrno, riscv_csr_operations *ops) csr_ops[csrno & (CSR_TABLE_SIZE - 1)] = *ops; } -/* Predicates */ Don't remove this comment. Otherwise, Reviewed-by: LIU Zhiwei Zhiwei -#if !defined(CONFIG_USER_ONLY) -static RISCVException smstateen_acc_ok(CPURISCVState *env,

Re: [PATCH v2 17/18] target/riscv: Drop priv level check in mseccfg predicate()

2023-03-01 Thread LIU Zhiwei
RISCVException pmp(CPURISCVState *env, int csrno) static RISCVException epmp(CPURISCVState *env, int csrno) { -if (env->priv == PRV_M && riscv_cpu_cfg(env)->epmp) { +if (riscv_cpu_cfg(env)->epmp) { Reviewed-by: LIU Zhiwei Zhiwei return RISCV_EXCP_NONE; }

Re: [PATCH v2 16/18] target/riscv: Allow debugger to access sstc CSRs

2023-03-01 Thread LIU Zhiwei
static RISCVException sstc(CPURISCVState *env, int csrno) } } -if ((csrno == CSR_VSTIMECMP) || (csrno == CSR_VSTIMECMPH)) { -hmode_check = true; -} - -return hmode_check ? hmode(env, csrno) : smode(env, csrno); +return RISCV_EXCP_NONE; Reviewed-by: LIU Zhiwei

Re: [PATCH v2 15/18] target/riscv: Allow debugger to access {h,s}stateen CSRs

2023-03-01 Thread LIU Zhiwei
n(CPURISCVState *env, int csrno) } } -return smode(env, csrno); +return RISCV_EXCP_NONE; Reviewed-by: LIU Zhiwei Zhiwei } /* Checks if PointerMasking registers could be accessed */

Re: [PATCH v2 05/18] target/riscv: gdbstub: Do not generate CSR XML if Zicsr is disabled

2023-03-01 Thread LIU Zhiwei
On 2023/3/2 8:30, Bin Meng wrote: On Thu, Mar 2, 2023 at 7:43 AM Palmer Dabbelt wrote: On Wed, 01 Mar 2023 01:55:34 PST (-0800), Bin Meng wrote: On Wed, Mar 1, 2023 at 5:52 PM LIU Zhiwei wrote: On 2023/2/28 18:40, Bin Meng wrote: There is no need to generate the CSR XML if the Zicsr

Re: [PATCH v2 05/18] target/riscv: gdbstub: Do not generate CSR XML if Zicsr is disabled

2023-03-01 Thread LIU Zhiwei
On 2023/2/28 18:40, Bin Meng wrote: There is no need to generate the CSR XML if the Zicsr extension is not enabled. Should we generate the FPU XML or Vector XML when Zicsr is not enabled? Zhiwei Signed-off-by: Bin Meng Reviewed-by: Weiwei Li Reviewed-by: LIU Zhiwei --- (no changes

Re: [PATCH v7 03/10] target/riscv: allow MISA writes as experimental

2023-02-28 Thread LIU Zhiwei
target_ulong val) { -if (!riscv_feature(env, RISCV_FEATURE_MISA)) { +if (!riscv_cpu_cfg(env)->misa_w) { Reviewed-by: LIU Zhiwei Zhiwei /* drop write to misa */ return RISCV_EXCP_NONE; }

Re: [PATCH v6 1/9] target/riscv: turn write_misa() into an official no-op

2023-02-22 Thread LIU Zhiwei
On 2023/2/22 2:22, Daniel Henrique Barboza wrote: On 2/21/23 14:06, Andrew Jones wrote: On Tue, Feb 21, 2023 at 12:49:11PM -0300, Daniel Henrique Barboza wrote: Hey, On 2/16/23 22:42, LIU Zhiwei wrote: On 2023/2/17 5:55, Daniel Henrique Barboza wrote: At this moment, and apparently

Question about input device

2023-02-20 Thread LIU Zhiwei
Hi folks, I am trying to do some tests on replay-input devices. One of input device is the PL050 keyboard. But I don't understand how to use the PL050 keyboard from a QEMU command line. Should I compile the arm into softmmu mode and enable the graphic display for using it? Can I see a graphic

Re: [PATCH] RISC-V: XTheadMemPair: Remove register restrictions for store-pair

2023-02-20 Thread LIU Zhiwei
;rs == a->rd1 || a->rs == a->rd2 || a->rd1 == a->rd2) { -return false; -} - Reviewed-by: LIU Zhiwei Zhiwei TCGv data1 = get_gpr(ctx, a->rd1, EXT_NONE); TCGv data2 = get_gpr(ctx, a->rd2, EXT_NONE); TCGv addr1 = tcg_temp_new();

Re: [PATCH 13/18] target/riscv: Allow debugger to access seed CSR

2023-02-16 Thread LIU Zhiwei
ONE; +} + Reviewed-by: LIU Zhiwei Zhiwei /* * With a CSR read-write instruction: * 1) The seed CSR is always available in machine mode as normal.

Re: [PATCH v6 2/9] target/riscv: introduce riscv_cpu_cfg()

2023-02-16 Thread LIU Zhiwei
On 2023/2/17 5:55, Daniel Henrique Barboza wrote: We're going to do changes that requires accessing the RISCVCPUConfig struct from the RISCVCPU, having access only to a CPURISCVState 'env' pointer. Add a helper to make the code easier to read. Signed-off-by: Daniel Henrique Barboza ---

Re: [PATCH 12/18] target/riscv: Allow debugger to access user timer and counter CSRs

2023-02-16 Thread LIU Zhiwei
urn RISCV_EXCP_NONE; +} + Reviewed-by: LIU Zhiwei Zhiwei if (env->priv < PRV_M && !get_field(env->mcounteren, ctr_mask)) { return RISCV_EXCP_ILLEGAL_INST; }

Re: [PATCH 11/18] target/riscv: gdbstub: Drop the vector CSRs in riscv-vector.xml

2023-02-16 Thread LIU Zhiwei
uot;, "vxrm", "vcsr", -"vl", "vtype", "vlenb" -}; - -for (i = 0; i < 7; i++) { -g_string_append_printf(s, - "", - vector_csrs[i], TARGET_LONG_BITS, base

Re: [PATCH 10/18] target/riscv: gdbstub: Turn on debugger mode before calling CSR predicate()

2023-02-16 Thread LIU Zhiwei
tring_free(s, false); + +#if !defined(CONFIG_USER_ONLY) +env->debugger = false; +#endif + Reviewed-by: LIU Zhiwei Zhiwei return CSR_TABLE_SIZE; }

Re: [PATCH 09/18] target/riscv: Avoid reporting odd-numbered pmpcfgX in the CSR XML for RV64

2023-02-16 Thread LIU Zhiwei
42,11 @@ static RISCVException write_mseccfg(CPURISCVState *env, int csrno, return RISCV_EXCP_NONE; } -static bool check_pmp_reg_index(CPURISCVState *env, uint32_t reg_index) -{ -/* TODO: RV128 restriction check */ Should keep this comment. Otherwise, Reviewed-by: LIU

Re: [PATCH 08/18] target/riscv: Simplify getting RISCVCPU pointer from env

2023-02-16 Thread LIU Zhiwei
nction. Otherwise, Reviewed-by: LIU Zhiwei Zhiwei if (env->misa_ext & RVV || cpu->cfg.ext_zve32f || cpu->cfg.ext_zve64f) { @@ -108,8 +106,7 @@ static RISCVException vs(CPURISCVState *env, int csrno) static RISCVException ctr(CPURISCVState *env, int csrno)

Re: [PATCH 07/18] target/riscv: Simplify {read,write}_pmpcfg() a little bit

2023-02-16 Thread LIU Zhiwei
; } -pmpcfg_csr_write(env, csrno - CSR_PMPCFG0, val); +pmpcfg_csr_write(env, reg_index, val); Reviewed-by: LIU Zhiwei Zhiwei return RISCV_EXCP_NONE; }

Re: [PATCH 06/18] target/riscv: Use 'bool' type for read_only

2023-02-16 Thread LIU Zhiwei
if check fails */ -int read_only = get_field(csrno, 0xC00) == 3; +bool read_only = get_field(csrno, 0xC00) == 3; Reviewed-by: LIU Zhiwei Zhiwei int csr_min_priv = csr_ops[csrno].min_priv_ver; /* ensure the CSR extension is enabled. */

Re: [PATCH 05/18] target/riscv: Coding style fixes in csr.c

2023-02-16 Thread LIU Zhiwei
7 +3340,7 @@ static RISCVException read_mseccfg(CPURISCVState *env, int csrno, } static RISCVException write_mseccfg(CPURISCVState *env, int csrno, - target_ulong val) +target_ulong val) Reviewed-by: LIU Zhiwei Zhiwei { mseccfg_csr_write(env, val); return RISCV_EXCP_NONE;

Re: [PATCH 04/18] target/riscv: gdbstub: Do not generate CSR XML if Zicsr is disabled

2023-02-16 Thread LIU Zhiwei
, riscv_gdb_set_csr, + riscv_gen_dynamic_csr_xml(cs, base_reg), + "riscv-csr.xml", 0); + } Reviewed-by: LIU Zhiwei Zhiwei }

Re: [PATCH 03/18] target/riscv: gdbstub: Minor change for better readability

2023-02-16 Thread LIU Zhiwei
n_dynamic_vector_xml(cs, - cs->gdb_num_regs), + ricsv_gen_dynamic_vector_xml(cs, base_reg), Reviewed-by: LIU Zhiwei Zhiwei "riscv-vector.xml", 0); } switch (env->misa_mxl_max) {

Re: [PATCH v6 2/9] target/riscv: introduce riscv_cpu_cfg()

2023-02-16 Thread LIU Zhiwei
On 2023/2/17 9:50, LIU Zhiwei wrote: On 2023/2/17 5:55, Daniel Henrique Barboza wrote: We're going to do changes that requires accessing the RISCVCPUConfig struct from the RISCVCPU, having access only to a CPURISCVState 'env' pointer. Add a helper to make the code easier to read. Signed-off

Re: [PATCH 02/18] target/riscv: Correct the priority policy of riscv_csrrw_check()

2023-02-16 Thread LIU Zhiwei
;& read_only) { +return RISCV_EXCP_ILLEGAL_INST; +} + Reviewed-by: LIU Zhiwei Zhiwei #if !defined(CONFIG_USER_ONLY) int csr_priv, effective_priv = env->priv;

Re: [PATCH 01/18] target/riscv: gdbstub: Check priv spec version before reporting CSR

2023-02-16 Thread LIU Zhiwei
+if (env->priv_ver < csr_ops[i].min_priv_ver) { +continue; +} Reviewed-by: LIU Zhiwei Zhiwei predicate = csr_ops[i].predicate; if (predicate && (predicate(env, i) == RISCV_EXCP_NONE)) { if (csr_ops[i].name) {

Re: [PATCH v6 9/9] target/riscv/cpu: remove CPUArchState::features and friends

2023-02-16 Thread LIU Zhiwei
INT32(env.misa_ext, RISCVCPU), VMSTATE_UINT32(env.misa_mxl_max, RISCVCPU), VMSTATE_UINT32(env.misa_ext_mask, RISCVCPU), -VMSTATE_UINT32(env.features, RISCVCPU), Reviewed-by: LIU Zhiwei Zhiwei VMSTATE_UINTTL(env.priv, RISCVCPU), VMSTATE_UINTTL(env

Re: [PATCH v6 8/9] target/riscv: remove RISCV_FEATURE_MMU

2023-02-16 Thread LIU Zhiwei
if (riscv_feature(env, RISCV_FEATURE_MMU)) { + if (riscv_cpu_cfg(env)->mmu) { Reviewed-by: LIU Zhiwei Zhiwei /* * If size is unknown (0), assume that all bytes * from addr to the end of the page will be accessed.

Re: [PATCH v6 7/9] hw/riscv/virt.c: do not use RISCV_FEATURE_MMU in create_fdt_socket_cpus()

2023-02-16 Thread LIU Zhiwei
(is_32_bit) ? "riscv,sv32" : "riscv,sv48"); } else { qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", "riscv,none"); } -name = riscv_isa_string(>soc[so

Re: [PATCH v6 6/9] target/riscv: remove RISCV_FEATURE_PMP

2023-02-16 Thread LIU Zhiwei
_hart_has_privs_default(CPURISCVState *env, target_ulong addr, } } -if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode == PRV_M)) { +if (!riscv_cpu_cfg(env)->pmp || (mode == PRV_M)) { Reviewed-by: LIU Zhiwei Zhiwei /* * Privileged spec v1.10 states if HW doesn't implement an

Re: [PATCH v6 5/9] target/riscv: remove RISCV_FEATURE_EPMP

2023-02-16 Thread LIU Zhiwei
ddr, { bool ret; -if (riscv_feature(env, RISCV_FEATURE_EPMP)) { +if (riscv_cpu_cfg(env)->epmp) { Reviewed-by: LIU Zhiwei Zhiwei if (MSECCFG_MMWP_ISSET(env)) { /* * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set

Re: [PATCH v6 4/9] target/riscv/cpu.c: error out if EPMP is enabled without PMP

2023-02-16 Thread LIU Zhiwei
TURE_EPMP); +if (!cpu->cfg.pmp) { +error_setg(errp, "Invalid configuration: EPMP requires PMP support"); +return; Reviewed-by: LIU Zhiwei Zhiwei } }

Re: [PATCH v6 3/9] target/riscv: remove RISCV_FEATURE_DEBUG

2023-02-16 Thread LIU Zhiwei
+ b/target/riscv/machine.c @@ -226,9 +226,8 @@ static const VMStateDescription vmstate_kvmtimer = { static bool debug_needed(void *opaque) { RISCVCPU *cpu = opaque; -CPURISCVState *env = >env; -return riscv_feature(env, RISCV_FEATURE_DEBUG); + return cpu->cfg.debug; }

Re: [PATCH v6 2/9] target/riscv: introduce riscv_cpu_cfg()

2023-02-16 Thread LIU Zhiwei
On 2023/2/17 5:55, Daniel Henrique Barboza wrote: We're going to do changes that requires accessing the RISCVCPUConfig struct from the RISCVCPU, having access only to a CPURISCVState 'env' pointer. Add a helper to make the code easier to read. Signed-off-by: Daniel Henrique Barboza ---

Re: [PATCH v6 2/9] target/riscv: introduce riscv_cpu_cfg()

2023-02-16 Thread LIU Zhiwei
riscv_cpu_mxl_bits(env) (1UL << (4 + riscv_cpu_mxl(env))) +static inline const RISCVCPUConfig *riscv_cpu_cfg(CPURISCVState *env) +{ +return _archcpu(env)->cfg; +} + #if defined(TARGET_RISCV32) #define cpu_recompute_xl(env) ((void)(env), MXL_RV32) #else Reviewed-by: LIU Zhiwei Zhiwei

Re: [PATCH v6 1/9] target/riscv: turn write_misa() into an official no-op

2023-02-16 Thread LIU Zhiwei
On 2023/2/17 5:55, Daniel Henrique Barboza wrote: At this moment, and apparently since ever, we have no way of enabling RISCV_FEATURE_MISA. This means that all the code from write_misa(), all the nuts and bolts that handles how to write this CSR, has always been a no-op as well because

Re: [PATCH v1 RFC Zisslpcfi 7/9] target/riscv: Tracking indirect branches (fcfi) using TCG

2023-02-15 Thread LIU Zhiwei
On 2023/2/16 8:02, Deepak Gupta wrote: On Wed, Feb 15, 2023 at 12:55 AM LIU Zhiwei wrote: On 2023/2/9 14:24, Deepak Gupta wrote: zisslpcfi protects forward control flow (if enabled) by enforcing all indirect call and jmp must land on a landing pad instruction `lpcll` short for landing pad

Re: [PATCH v1 RFC Zisslpcfi 6/9] target/riscv: MMU changes for back cfi's shadow stack

2023-02-15 Thread LIU Zhiwei
On 2023/2/16 7:57, Deepak Gupta wrote: `On Wed, Feb 15, 2023 at 12:43 AM LIU Zhiwei wrote: On 2023/2/9 14:24, Deepak Gupta wrote: zisslpcfi protects returns(back cfi) using shadow stack. If compiled with enabled compiler, function prologs will have `sspush ra` instruction to push return

Re: [PATCH v1 RFC Zisslpcfi 1/9] target/riscv: adding zimops and zisslpcfi extension to RISCV cpu config

2023-02-15 Thread LIU Zhiwei
On 2023/2/16 4:47, Deepak Gupta wrote: On Tue, Feb 14, 2023 at 6:52 PM LIU Zhiwei wrote: On 2023/2/9 14:23, Deepak Gupta wrote: Introducing riscv `zisslpcfi` extension to riscv target. `zisslpcfi` extension provides hardware assistance to riscv hart to enable control flow integrity (CFI

Re: [PATCH v1 RFC Zisslpcfi 8/9] target/riscv: Instructions encodings, implementation and handlers

2023-02-15 Thread LIU Zhiwei
On 2023/2/9 14:24, Deepak Gupta wrote: This patch implements instruction encodings for zisslpcfi instructions. Additionally this patch implements zimops encodings as well. If Zisslpcfi is supported by CPU but not enabled then all Zisslpcfi instructions default to Zimops instuction behavior

Re: [PATCH v1 RFC Zisslpcfi 7/9] target/riscv: Tracking indirect branches (fcfi) using TCG

2023-02-15 Thread LIU Zhiwei
On 2023/2/9 14:24, Deepak Gupta wrote: zisslpcfi protects forward control flow (if enabled) by enforcing all indirect call and jmp must land on a landing pad instruction `lpcll` short for landing pad and check lower label value. If target of an indirect call or jmp is not `lpcll` then cpu/hart

Re: [PATCH v1 RFC Zisslpcfi 6/9] target/riscv: MMU changes for back cfi's shadow stack

2023-02-15 Thread LIU Zhiwei
On 2023/2/9 14:24, Deepak Gupta wrote: zisslpcfi protects returns(back cfi) using shadow stack. If compiled with enabled compiler, function prologs will have `sspush ra` instruction to push return address on shadow stack and function epilogs will have `sspop t0; sschckra` instruction

Re: [PATCH v1 RFC Zisslpcfi 4/9] target/riscv: helper functions for forward and backward cfi

2023-02-14 Thread LIU Zhiwei
On 2023/2/9 14:23, Deepak Gupta wrote: Implementation for forward cfi and backward cfi needs helper function to determine if currently fcfi and bcfi are enabled. Enable depends on privilege mode and settings in sstatus/menvcfg/henvcfg/mseccfg CSRs. Signed-off-by: Deepak Gupta Signed-off-by:

Re: [PATCH v1 RFC Zisslpcfi 3/9] target/riscv: implements CSRs and new bits in existing CSRs in zisslpcfi

2023-02-14 Thread LIU Zhiwei
I don't find the modification for read_mstatus. Zhiwei On 2023/2/15 13:47, LIU Zhiwei wrote: On 2023/2/9 14:23, Deepak Gupta wrote: CSR_SSP and CSR_LPLR are new CSR additions to cpu/hart. This patch allows access to these CSRs. A predicate routine handles access to these CSR as per

Re: [PATCH v1 RFC Zisslpcfi 5/9] target/riscv: state save and restore of zisslppcfi state

2023-02-14 Thread LIU Zhiwei
can occur before target instruction is executed. In such a case this state must be preserved so that it can be restored later. zisslpcfi saves elp state in `sstatus` CSR. And mstatus CSR. Otherwise, Reviewed-by: LIU Zhiwei This patch saves elp state in sstatus CSR on trap delivery while

Re: [PATCH v1 RFC Zisslpcfi 3/9] target/riscv: implements CSRs and new bits in existing CSRs in zisslpcfi

2023-02-14 Thread LIU Zhiwei
On 2023/2/9 14:23, Deepak Gupta wrote: CSR_SSP and CSR_LPLR are new CSR additions to cpu/hart. This patch allows access to these CSRs. A predicate routine handles access to these CSR as per specification. This patch also implments new bit definitions in menvcfg/henvcfg/mstatus/ sstatus CSRs

Re: [PATCH v1 RFC Zisslpcfi 2/9] target/riscv: zisslpcfi CSR, bit positions and other definitions

2023-02-14 Thread LIU Zhiwei
On 2023/2/9 14:23, Deepak Gupta wrote: `zisslpcfi` extension adds two new CSRs. CSR_SSP and CSR_LPLR. - CSR_SSP: This CSR holds shadow stack pointer for current privilege mode CSR_SSP is accessible in all modes. Each mode must establish it's own CSR_SSP. - CSR_LPLR:

Re: [PATCH v1 RFC Zisslpcfi 1/9] target/riscv: adding zimops and zisslpcfi extension to RISCV cpu config

2023-02-14 Thread LIU Zhiwei
On 2023/2/9 14:23, Deepak Gupta wrote: Introducing riscv `zisslpcfi` extension to riscv target. `zisslpcfi` extension provides hardware assistance to riscv hart to enable control flow integrity (CFI) for software. `zisslpcfi` extension expects hart to implement `zimops`. `zimops` stands for

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

2023-02-13 Thread LIU Zhiwei
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 caught when run these instructions on qemu-riscv32. Signed-off-by: LIU Zhiwei --- target/riscv

Re: [PATCH] target/riscv: Smepmp: Skip applying default rules when address matches

2023-02-12 Thread LIU Zhiwei
On 2023/2/13 13:21, Himanshu Chauhan wrote: On 13/02/23 09:52, LIU Zhiwei wrote: On 2023/2/9 13:52, Himanshu Chauhan wrote: When MSECCFG.MML is set, after checking the address range in PMP if the asked permissions are not same as programmed in PMP, the default permissions are applied

Re: [PATCH] target/riscv: Smepmp: Skip applying default rules when address matches

2023-02-12 Thread LIU Zhiwei
On 2023/2/9 13:52, Himanshu Chauhan wrote: When MSECCFG.MML is set, after checking the address range in PMP if the asked permissions are not same as programmed in PMP, the default permissions are applied. This should only be the case when there is no matching address is found. This patch

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

2023-02-08 Thread LIU Zhiwei
96e25f62ac..847bc7f131 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -287,6 +287,9 @@ RISC-V TCG CPUs M: Palmer Dabbelt M: Alistair Francis M: Bin Meng +R: Weiwei Li +R: Daniel Henrique Barboza +R: Liu Zhiwei Acked-by: LIU Zhiwei Zhiwei L: qemu-ri...@nongnu.org S: Supported F

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

2023-02-07 Thread LIU Zhiwei
{ "vlenb",vs, read_vlenb }, /* User Timers and Counters */ [CSR_CYCLE]= { "cycle",ctr,read_hpmcounter }, [CSR_INSTRET] = { "instret", ctr,read_hpmcounter }, Reviewed-by: LIU Zhiwei Zhiwei

Re: [PATCH v3 08/14] RISC-V: Adding T-Head MemPair extension

2023-01-30 Thread LIU Zhiwei
On 2023/1/31 3:03, Richard Henderson wrote: On 1/29/23 22:41, LIU Zhiwei wrote: On 2023/1/30 13:43, Richard Henderson wrote: On 1/29/23 16:03, LIU Zhiwei wrote: Thanks. It's a bug. We should load all memory addresses to  local TCG temps first. Do you think we should probe all the memory

Re: [PATCH v3 12/14] RISC-V: Add initial support for T-Head C906

2023-01-30 Thread LIU Zhiwei
On 2023/1/25 5:26, Richard Henderson wrote: On 1/24/23 09:59, Christoph Muellner wrote: +++ b/target/riscv/cpu.h @@ -27,6 +27,7 @@   #include "qom/object.h"   #include "qemu/int128.h"   #include "cpu_bits.h" +#include "cpu_vendorid.h" I don't see that this ID is required for all users of

Re: [PATCH v3 09/14] RISC-V: Adding T-Head MemIdx extension

2023-01-30 Thread LIU Zhiwei
On 2023/1/25 5:21, Richard Henderson wrote: On 1/24/23 09:59, Christoph Muellner wrote: +/* XTheadMemIdx */ + +/* + * Load with memop from indexed address and add (imm5 << imm2) to rs1. + * If !preinc, then the load address is rs1. + * If  preinc, then the load address is rs1 + (imm5) <<

Re: [PATCH v3 08/14] RISC-V: Adding T-Head MemPair extension

2023-01-30 Thread LIU Zhiwei
On 2023/1/30 13:43, Richard Henderson wrote: On 1/29/23 16:03, LIU Zhiwei wrote: Thanks. It's a bug. We should load all memory addresses to  local TCG temps first. Do you think we should probe all the memory addresses for the store pair instructions? If so, can we avoid the use of a helper

Re: [PATCH v3 08/14] RISC-V: Adding T-Head MemPair extension

2023-01-29 Thread LIU Zhiwei
On 2023/1/25 4:44, Richard Henderson wrote: On 1/24/23 09:59, Christoph Muellner wrote: +static bool gen_loadpair_tl(DisasContext *ctx, arg_th_pair *a, MemOp memop, +    int shamt) +{ +    TCGv rd1 = dest_gpr(ctx, a->rd1); +    TCGv rd2 = dest_gpr(ctx, a->rd2); +   

Re: [PATCH 01/11] contrib/gitdm: add C-Sky to the domain map

2022-12-20 Thread LIU Zhiwei
On 2022/12/20 16:23, Alex Bennée wrote: LIU Zhiwei writes: The c-sky domain mail is no longer being used for Guo Ren and me. C-SKY company and C-SKY arch is still existing, but its website domain has been moved tohttps://www.t-head.cn/. Is this the new corporate entity for the C-SKY

Re: [PATCH 01/11] contrib/gitdm: add C-Sky to the domain map

2022-12-19 Thread LIU Zhiwei
The c-sky domain mail is no longer being used for Guo Ren and me. C-SKY company and C-SKY arch is still existing, but its website domain has been moved to https://www.t-head.cn/. Otherwise, Reviewed-by: LIU Zhiwei Thanks, Zhiwei On 2022/12/19 20:19, Alex Bennée wrote: Although

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

2022-12-15 Thread LIU Zhiwei
| cpu->cfg.vlen < 8) { +            if (cpu->cfg.elen > 64 || cpu->cfg.elen < 8) { Oops. You are right. Reviewed-by: LIU Zhiwei Zhiwei                  error_setg(errp,                          "Vector extension implementation only supports ELEN "                          "in the range [8, 64]"); -- 2.17.1

Re: [PATCH 03/11] RISC-V: Adding T-Head SYNC instructions

2022-12-12 Thread LIU Zhiwei
On 2022/9/8 15:29, Richard Henderson wrote: On 9/6/22 13:22, Christoph Muellner wrote: +NOP_PRIVCHECK(th_sfence_vmas, REQUIRE_PRIV_MHS) +NOP_PRIVCHECK(th_sync, REQUIRE_PRIV_MHSU) +NOP_PRIVCHECK(th_sync_i, REQUIRE_PRIV_MHSU) +NOP_PRIVCHECK(th_sync_is, REQUIRE_PRIV_MHSU)

Re: [PATCH 03/11] RISC-V: Adding T-Head SYNC instructions

2022-12-12 Thread LIU Zhiwei
On 2022/9/8 15:29, Richard Henderson wrote: On 9/6/22 13:22, Christoph Muellner wrote: +NOP_PRIVCHECK(th_sfence_vmas, REQUIRE_PRIV_MHS) +NOP_PRIVCHECK(th_sync, REQUIRE_PRIV_MHSU) +NOP_PRIVCHECK(th_sync_i, REQUIRE_PRIV_MHSU) +NOP_PRIVCHECK(th_sync_is, REQUIRE_PRIV_MHSU)

Re: [RFC PATCH] RISC-V: Save mmu_idx using FIELD_DP32 not OR

2022-12-08 Thread LIU Zhiwei
We may should rename cpu_mmu_index to cpu_mem_idx and TB_FLAGS_PRIV_MMU_MASK to TB_FLAGS_PRIV_MEM_MASK. We can also remove the TB_FLAGS_PRIV_MMU_MASK as the position of MEM_IDX in tb_flags may change in the future. Otherwise, this patch looks good to me, Reviewed-by: LIU Zhiwei

Re: [PATCH v1 4/4] target/riscv: Add itrigger_enabled field to CPURISCVState

2022-11-09 Thread LIU Zhiwei
On 2022/11/10 6:55, Alistair Francis wrote: On Thu, Oct 13, 2022 at 4:51 PM LIU Zhiwei wrote: Avoid calling riscv_itrigger_enabled() when calculate the tbflags. As the itrigger enable status can only be changed when write tdata1, migration load or itrigger fire, update env->itrigger_enab

Re: [PATCH v1 1/4] target/riscv: Add itrigger support when icount is not enabled

2022-11-07 Thread LIU Zhiwei
On 2022/11/7 23:58, Alex Bennée wrote: LIU Zhiwei writes: On 2022/11/7 9:37, Alistair Francis wrote: On Thu, Oct 13, 2022 at 4:32 PM LIU Zhiwei wrote: When icount is not enabled, there is no API in QEMU that can get the guest instruction number. Translate the guest code in a way

Re: [PATCH v1 1/4] target/riscv: Add itrigger support when icount is not enabled

2022-11-06 Thread LIU Zhiwei
On 2022/11/7 9:37, Alistair Francis wrote: On Thu, Oct 13, 2022 at 4:32 PM LIU Zhiwei wrote: When icount is not enabled, there is no API in QEMU that can get the guest instruction number. Translate the guest code in a way that each TB only has one instruction. I don't think this is a great

Re: [PATCH] tcg/riscv: Fix base register for user-only qemu_ld/st

2022-10-25 Thread LIU Zhiwei
-extend, and it keeps the register usage clear. Set base after each step of the address arithmetic instead of before. Return the base register used from tcg_out_tlb_load, so as to keep that register choice localized to that function. Reported-by: LIU Zhiwei Signed-off-by: Richard Henderson

[PATCH 1/1] tcg/riscv: Fix base regsiter for qemu_ld/st

2022-10-24 Thread LIU Zhiwei
When guest base is zero, we should use addr_regl as base regiser instead of the initial register TCG_REG_TMP0. Besides, we can remove the unnecessary use of base register. Signed-off-by: LIU Zhiwei --- tcg/riscv/tcg-target.c.inc | 20 1 file changed, 8 insertions(+), 12

Re: [PATCH] tcg/riscv: Fix range matched by TCG_CT_CONST_M12

2022-10-23 Thread LIU Zhiwei
On 2022/10/22 17:58, Richard Henderson wrote: We were matching a signed 13-bit range, not a 12-bit range. Expand the commentary within the function and be explicit about all of the ranges. Reported-by: LIU Zhiwei Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei --- tcg/riscv

Re: [RFC PATCH 2/3] tcg/riscv: Fix tcg_out_opc_imm when imm exceeds

2022-10-20 Thread LIU Zhiwei
On 2022/10/20 19:22, Richard Henderson wrote: On 10/20/22 20:41, LIU Zhiwei wrote: TYPE-I immediate can only represent a signed 12-bit value. If immediate exceed, mov it to an register. Signed-off-by: LIU Zhiwei ---   tcg/riscv/tcg-target.c.inc | 28 +++-   1 file

Re: [PATCH] target/riscv: Fix PMP propagation for tlb

2022-10-20 Thread LIU Zhiwei
ping On 2022/10/12 14:00, LIU Zhiwei wrote: Only the pmp index that be checked by pmp_hart_has_privs can be used by pmp_get_tlb_size to avoid an error pmp index. Before modification, we may use an error pmp index. For example, we check address 0x4fc, and the size 0x4 in pmp_hart_has_privs

Re: [RFC PATCH 3/3] tcg/riscv: Remove a wrong optimization for addsub2

2022-10-20 Thread LIU Zhiwei
On 2022/10/20 19:31, Richard Henderson wrote: On 10/20/22 20:41, LIU Zhiwei wrote: It's not clear what it is doing here. And it's wrong because bl and al are both register, so we can't add them by an ADDI instruction. Signed-off-by: LIU Zhiwei ---   tcg/riscv/tcg-target.c.inc | 3 ---   1

Re: [RFC PATCH 1/3] tcg/riscv: Fix base regsiter for qemu_ld/st

2022-10-20 Thread LIU Zhiwei
On 2022/10/20 19:18, Richard Henderson wrote: On 10/20/22 20:41, LIU Zhiwei wrote: When guest base is zero, we should use addr_regl as base regiser instead of the initial register TCG_REG_TMP0. Signed-off-by: LIU Zhiwei ---   tcg/riscv/tcg-target.c.inc | 4   1 file changed, 4

Re: [RFC PATCH 2/3] tcg/riscv: Fix tcg_out_opc_imm when imm exceeds

2022-10-20 Thread LIU Zhiwei
On 2022/10/20 19:22, Richard Henderson wrote: On 10/20/22 20:41, LIU Zhiwei wrote: TYPE-I immediate can only represent a signed 12-bit value. If immediate exceed, mov it to an register. Signed-off-by: LIU Zhiwei ---   tcg/riscv/tcg-target.c.inc | 28 +++-   1 file

Re: [RFC PATCH 1/3] tcg/riscv: Fix base regsiter for qemu_ld/st

2022-10-20 Thread LIU Zhiwei
On 2022/10/20 19:26, Philippe Mathieu-Daudé wrote: On 20/10/22 12:41, LIU Zhiwei wrote: When guest base is zero, we should use addr_regl as base regiser instead of Typo "register" here and in patch subject. the initial register TCG_REG_TMP0. Signed-off-by: LIU Zhiwei ---   tcg

[RFC PATCH 3/3] tcg/riscv: Remove a wrong optimization for addsub2

2022-10-20 Thread LIU Zhiwei
It's not clear what it is doing here. And it's wrong because bl and al are both register, so we can't add them by an ADDI instruction. Signed-off-by: LIU Zhiwei --- tcg/riscv/tcg-target.c.inc | 3 --- 1 file changed, 3 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg

<    1   2   3   4   5   6   7   8   9   10   >