From patchwork Tue May 11 10:19:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=KmfMBAq/; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfYxf6MW3z9t0T for ; Tue, 11 May 2021 20:26:46 +1000 (AEST) Received: from localhost ([::1]:44800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPbA-0001sk-Qh for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:26:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPUu-0008Jp-LR for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:21 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPUn-0006V6-8z for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728407; x=1652264407; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BdYYVeUYgq1mi3A8UHIIcrCtropB7TiiKZWRQSAagxg=; b=KmfMBAq/+/gYJvq9BKqOUL4ycGEtqwEZY2rQ3TZ496fz3mjw1ICPU7l9 SLis5aWnNUwQEG99RjFBz41Rd4aU61BlnxctpGs1BJKYaapTnY8LQc0tJ 9yDX9Hje6wgm5TZeUN9ubnoLzELZR7eN3BdcPtNgjX3sa0yGM6XA3pJfB Ho9KMG6v/zAkPcGhOxmhP+MuzO7s9bB7m/8HMc+hNXQza6beEDNhcW48Z nFe+kLGzWFKbVHDnfQPPMpw0XLnk4UJmHz4aUxpQ4aXU7Rjc8hubB8f+j bG8/U8n1mnt30k5DOco4C2oLKC/U0IaWtf3tWXnyTG0HWp/KmnWx2iERE w==; IronPort-SDR: DRurbCGvTwk5yELL0a8Jg2aqfCWdSgKRgVJl8MlPEV3P7eFdAmKAl1FBUfSgS7o4G9YXxE2kKm LPZLrJnDdSSYKfasGcS2U9pWrEYDFWXiUVjAZfzqOakHM9+PPggvJvAO9kbwccLjbeyvRNaOOT xAXG4ceBw0u3s9FC+dBPm+386PCc/u9l3cQrcl41/AOIsQJNM7QQbM82OoKr/3B3AMm77oGIbb +tPoGjCLx6QIr0pA4z9OGbhZ+7ldN+4Qff8QUohsP09+4XCsGPgX6a8B1D55XF/4wLFap7osIW GcM= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735325" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:05 +0800 IronPort-SDR: f14K/L3Qh8hlUHQL0rf9qTZM0jP8Fz+g4vAzcStNy8ifCYSkvKCwsafmZalmHwP242uKSInPvG /yvrqPF/ZTZl55URwFS3Bct9LmR6QNpGodfwhj/JZXKZUpAhooGS2y+dYc+vJiyJgoNlqU0oyx 8eonMrGCsHxHo8NgNFJ2Tp3BiPSq3XiBNybuSf25bX1IMFtcqU/VD4HMTFpdztfFT8oeRQS1SY pDovQiCnVGGMhLaJ0b6GjCinrEwCNttxZVQXCmebMdqknwcS1QYOAXM1980dFtECHwLzHmnqtV +bXLUpAV4Yp/t44YB1r5rHo9 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:04 -0700 IronPort-SDR: vTjTenOGJk2HKyjCn5yko6iy+rqdjCmUXV4TlsKSyLtDHnoqPP84yOfj416t5RtpE7O3fvwgQ9 3amaSOvbR6qpEvJrdhOkrwJDHy4hWA7xar2XxRCOPrvQ6RKlGpykeR5gQo6lLYKJP7z1LdZTRK rnUgp8478TeOwrUIW6CsFPGrV2W0TJb2MLXpjOnf+5m6+H0JCU5r5ekknr9/SjhZvxheqCYhwZ QSoU65pjUotUhJk1BIoqVc+GKRIswoWEUZu0EYqvh+b3i2zXi6pTn3k5GEe9lJVJiWYdwjryB7 9rU= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:03 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 01/42] target/riscv: Remove privilege v1.9 specific CSR related code Date: Tue, 11 May 2021 20:19:10 +1000 Message-Id: <20210511101951.165287-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org, Atish Patra Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Atish Patra Qemu doesn't support RISC-V privilege specification v1.9. Remove the remaining v1.9 specific references from the implementation. Signed-off-by: Atish Patra Reviewed-by: Alistair Francis Message-Id: <20210319194534.2082397-2-atish.patra@wdc.com> [Changes by AF: - Rebase on latest patches - Bump the vmstate_riscv_cpu version_id and minimum_version_id ] Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 4 +--- target/riscv/cpu_bits.h | 23 --------------------- target/riscv/cpu.c | 2 +- target/riscv/cpu_helper.c | 12 +++++------ target/riscv/csr.c | 42 ++++++++++----------------------------- target/riscv/machine.c | 8 +++----- target/riscv/translate.c | 4 ++-- 7 files changed, 23 insertions(+), 72 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 0a33d387ba..311b1db875 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -163,10 +163,8 @@ struct CPURISCVState { target_ulong mie; target_ulong mideleg; - target_ulong sptbr; /* until: priv-1.9.1 */ target_ulong satp; /* since: priv-1.10.0 */ - target_ulong sbadaddr; - target_ulong mbadaddr; + target_ulong stval; target_ulong medeleg; target_ulong stvec; diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index caf4599207..b42dd4f8d8 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -153,12 +153,6 @@ /* 32-bit only */ #define CSR_MSTATUSH 0x310 -/* Legacy Counter Setup (priv v1.9.1) */ -/* Update to #define CSR_MCOUNTINHIBIT 0x320 for 1.11.0 */ -#define CSR_MUCOUNTEREN 0x320 -#define CSR_MSCOUNTEREN 0x321 -#define CSR_MHCOUNTEREN 0x322 - /* Machine Trap Handling */ #define CSR_MSCRATCH 0x340 #define CSR_MEPC 0x341 @@ -166,9 +160,6 @@ #define CSR_MTVAL 0x343 #define CSR_MIP 0x344 -/* Legacy Machine Trap Handling (priv v1.9.1) */ -#define CSR_MBADADDR 0x343 - /* Supervisor Trap Setup */ #define CSR_SSTATUS 0x100 #define CSR_SEDELEG 0x102 @@ -184,9 +175,6 @@ #define CSR_STVAL 0x143 #define CSR_SIP 0x144 -/* Legacy Supervisor Trap Handling (priv v1.9.1) */ -#define CSR_SBADADDR 0x143 - /* Supervisor Protection and Translation */ #define CSR_SPTBR 0x180 #define CSR_SATP 0x180 @@ -354,14 +342,6 @@ #define CSR_MHPMCOUNTER30H 0xb9e #define CSR_MHPMCOUNTER31H 0xb9f -/* Legacy Machine Protection and Translation (priv v1.9.1) */ -#define CSR_MBASE 0x380 -#define CSR_MBOUND 0x381 -#define CSR_MIBASE 0x382 -#define CSR_MIBOUND 0x383 -#define CSR_MDBASE 0x384 -#define CSR_MDBOUND 0x385 - /* mstatus CSR bits */ #define MSTATUS_UIE 0x00000001 #define MSTATUS_SIE 0x00000002 @@ -375,10 +355,8 @@ #define MSTATUS_FS 0x00006000 #define MSTATUS_XS 0x00018000 #define MSTATUS_MPRV 0x00020000 -#define MSTATUS_PUM 0x00040000 /* until: priv-1.9.1 */ #define MSTATUS_SUM 0x00040000 /* since: priv-1.10 */ #define MSTATUS_MXR 0x00080000 -#define MSTATUS_VM 0x1F000000 /* until: priv-1.9.1 */ #define MSTATUS_TVM 0x00100000 /* since: priv-1.10 */ #define MSTATUS_TW 0x00200000 /* since: priv-1.10 */ #define MSTATUS_TSR 0x00400000 /* since: priv-1.10 */ @@ -416,7 +394,6 @@ #define SSTATUS_SPP 0x00000100 #define SSTATUS_FS 0x00006000 #define SSTATUS_XS 0x00018000 -#define SSTATUS_PUM 0x00040000 /* until: priv-1.9.1 */ #define SSTATUS_SUM 0x00040000 /* since: priv-1.10 */ #define SSTATUS_MXR 0x00080000 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 7d6ed80f6b..86e7dbeb20 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -282,7 +282,7 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vscause ", env->vscause); } qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->sbadaddr); + qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval); if (riscv_has_ext(env, RVH)) { qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval); qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2); diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 21c54ef561..503c2559f8 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -136,8 +136,8 @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) env->vscause = env->scause; env->scause = env->scause_hs; - env->vstval = env->sbadaddr; - env->sbadaddr = env->stval_hs; + env->vstval = env->stval; + env->stval = env->stval_hs; env->vsatp = env->satp; env->satp = env->satp_hs; @@ -159,8 +159,8 @@ void riscv_cpu_swap_hypervisor_regs(CPURISCVState *env) env->scause_hs = env->scause; env->scause = env->vscause; - env->stval_hs = env->sbadaddr; - env->sbadaddr = env->vstval; + env->stval_hs = env->stval; + env->stval = env->vstval; env->satp_hs = env->satp; env->satp = env->vsatp; @@ -1023,7 +1023,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) env->mstatus = s; env->scause = cause | ((target_ulong)async << (TARGET_LONG_BITS - 1)); env->sepc = env->pc; - env->sbadaddr = tval; + env->stval = tval; env->htval = htval; env->pc = (env->stvec >> 2 << 2) + ((async && (env->stvec & 3) == 1) ? cause * 4 : 0); @@ -1054,7 +1054,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) env->mstatus = s; env->mcause = cause | ~(((target_ulong)-1) >> async); env->mepc = env->pc; - env->mbadaddr = tval; + env->mtval = tval; env->mtval2 = mtval2; env->pc = (env->mtvec >> 2 << 2) + ((async && (env->mtvec & 3) == 1) ? cause * 4 : 0); diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d2585395bf..de7427d8f8 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -644,26 +644,6 @@ static int write_mcounteren(CPURISCVState *env, int csrno, target_ulong val) return 0; } -/* This regiser is replaced with CSR_MCOUNTINHIBIT in 1.11.0 */ -static int read_mscounteren(CPURISCVState *env, int csrno, target_ulong *val) -{ - if (env->priv_ver < PRIV_VERSION_1_11_0) { - return -RISCV_EXCP_ILLEGAL_INST; - } - *val = env->mcounteren; - return 0; -} - -/* This regiser is replaced with CSR_MCOUNTINHIBIT in 1.11.0 */ -static int write_mscounteren(CPURISCVState *env, int csrno, target_ulong val) -{ - if (env->priv_ver < PRIV_VERSION_1_11_0) { - return -RISCV_EXCP_ILLEGAL_INST; - } - env->mcounteren = val; - return 0; -} - /* Machine Trap Handling */ static int read_mscratch(CPURISCVState *env, int csrno, target_ulong *val) { @@ -701,15 +681,15 @@ static int write_mcause(CPURISCVState *env, int csrno, target_ulong val) return 0; } -static int read_mbadaddr(CPURISCVState *env, int csrno, target_ulong *val) +static int read_mtval(CPURISCVState *env, int csrno, target_ulong *val) { - *val = env->mbadaddr; + *val = env->mtval; return 0; } -static int write_mbadaddr(CPURISCVState *env, int csrno, target_ulong val) +static int write_mtval(CPURISCVState *env, int csrno, target_ulong val) { - env->mbadaddr = val; + env->mtval = val; return 0; } @@ -853,15 +833,15 @@ static int write_scause(CPURISCVState *env, int csrno, target_ulong val) return 0; } -static int read_sbadaddr(CPURISCVState *env, int csrno, target_ulong *val) +static int read_stval(CPURISCVState *env, int csrno, target_ulong *val) { - *val = env->sbadaddr; + *val = env->stval; return 0; } -static int write_sbadaddr(CPURISCVState *env, int csrno, target_ulong val) +static int write_stval(CPURISCVState *env, int csrno, target_ulong val) { - env->sbadaddr = val; + env->stval = val; return 0; } @@ -1419,13 +1399,11 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_MSTATUSH] = { "mstatush", any32, read_mstatush, write_mstatush }, - [CSR_MSCOUNTEREN] = { "msounteren", any, read_mscounteren, write_mscounteren }, - /* Machine Trap Handling */ [CSR_MSCRATCH] = { "mscratch", any, read_mscratch, write_mscratch }, [CSR_MEPC] = { "mepc", any, read_mepc, write_mepc }, [CSR_MCAUSE] = { "mcause", any, read_mcause, write_mcause }, - [CSR_MBADADDR] = { "mbadaddr", any, read_mbadaddr, write_mbadaddr }, + [CSR_MTVAL] = { "mtval", any, read_mtval, write_mtval }, [CSR_MIP] = { "mip", any, NULL, NULL, rmw_mip }, /* Supervisor Trap Setup */ @@ -1438,7 +1416,7 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_SSCRATCH] = { "sscratch", smode, read_sscratch, write_sscratch }, [CSR_SEPC] = { "sepc", smode, read_sepc, write_sepc }, [CSR_SCAUSE] = { "scause", smode, read_scause, write_scause }, - [CSR_SBADADDR] = { "sbadaddr", smode, read_sbadaddr, write_sbadaddr }, + [CSR_STVAL] = { "stval", smode, read_stval, write_stval }, [CSR_SIP] = { "sip", smode, NULL, NULL, rmw_sip }, /* Supervisor Protection and Translation */ diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 44d4015bd6..16a08302da 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -140,8 +140,8 @@ static const VMStateDescription vmstate_hyper = { const VMStateDescription vmstate_riscv_cpu = { .name = "cpu", - .version_id = 1, - .minimum_version_id = 1, + .version_id = 2, + .minimum_version_id = 2, .fields = (VMStateField[]) { VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), VMSTATE_UINT64_ARRAY(env.fpr, RISCVCPU, 32), @@ -165,10 +165,8 @@ const VMStateDescription vmstate_riscv_cpu = { VMSTATE_UINT32(env.miclaim, RISCVCPU), VMSTATE_UINTTL(env.mie, RISCVCPU), VMSTATE_UINTTL(env.mideleg, RISCVCPU), - VMSTATE_UINTTL(env.sptbr, RISCVCPU), VMSTATE_UINTTL(env.satp, RISCVCPU), - VMSTATE_UINTTL(env.sbadaddr, RISCVCPU), - VMSTATE_UINTTL(env.mbadaddr, RISCVCPU), + VMSTATE_UINTTL(env.stval, RISCVCPU), VMSTATE_UINTTL(env.medeleg, RISCVCPU), VMSTATE_UINTTL(env.stvec, RISCVCPU), VMSTATE_UINTTL(env.sepc, RISCVCPU), diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 2f9f5ccc62..26eccc5eb1 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -116,7 +116,7 @@ static void generate_exception(DisasContext *ctx, int excp) ctx->base.is_jmp = DISAS_NORETURN; } -static void generate_exception_mbadaddr(DisasContext *ctx, int excp) +static void generate_exception_mtval(DisasContext *ctx, int excp) { tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); tcg_gen_st_tl(cpu_pc, cpu_env, offsetof(CPURISCVState, badaddr)); @@ -160,7 +160,7 @@ static void gen_exception_illegal(DisasContext *ctx) static void gen_exception_inst_addr_mis(DisasContext *ctx) { - generate_exception_mbadaddr(ctx, RISCV_EXCP_INST_ADDR_MIS); + generate_exception_mtval(ctx, RISCV_EXCP_INST_ADDR_MIS); } static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest) From patchwork Tue May 11 10:19:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Uf04chUW; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfYrH2vCCz9t0k for ; Tue, 11 May 2021 20:22:07 +1000 (AEST) Received: from localhost ([::1]:58734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPWf-0008NQ-2s for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:22:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPUz-0008KY-Qg for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:25 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPUo-0006X1-Dq for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728408; x=1652264408; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v9dngNOlYI6M8UvqCNI7Vz66vBQPm9MreWEGG7vUnp8=; b=Uf04chUWvkmjksBxB+nIHd4m6Z4y37FHi7eZfprdcCw0T+qEfBGB0dm/ pTQN0HBMkkdiDIktp/cfi5LCvlBLL5jlMR8NGVB6L8xLvHRwVUe1yET1F cR9QQWCZVyPPTT26hRNeX1/DjRsoiZTTZEAx/xDnUnY/xzYacTNaySu38 /kXUFSHZ5+cpqqFsw6/mS9JijXjHC8xvmC80urlAvMwhHG4L+PoGDVfpK woGgT7ts9XHh87S9AlSptwJNLp2a1FynHOR3lC7tMaSSzcngfgICbn6/u SkVl9GVKk/0At2356aTYYGexlN01zxKrkZ5NxUijuQg0VFiZDmc9pQyyc g==; IronPort-SDR: 44DMAVm1h501+jIBjTGvqSJsFYH2GPMNzH9oXRjcZUaCRzh29WB86GuZVDdOTerHM79akcYhOR xdMIY0vQdmkz3juE+4xMax3cbJEwCTatlR9XCJXvZbka4gf4mPItsNGBo7ZP0PCF64OJHNmq1a qQEAfFqKFDo31Wlhg0wOcBgA+2BA8mGJzXYVYRvEkwR9btG3qnrTxJ5dcdoPzMw0UBfzCcBqhS z04/kH/8HmsR2grhDP74s/oveeXX/fOH2g9PXU6MdvyqUbebJClKy6Fv4mfUgCAaTBy9AZftrA raw= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735332" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:07 +0800 IronPort-SDR: L7SEp58l/EKQUw25i2DppGrZaJMYbejB860DekGayh6PhRy2C+ctAt1p/xmhHp90q82g9CP7DV MwM/ZYiVJwC7DZDT/FM1GXYN27S0BxhKra8q1lyalR4K/9H3wNoVtDl2CmVfNl84PNTsrTVcCf eifjzPLmqKuCeFf5xSN1qKFM6qIt67sHCPIEmeLy+BOdVrherP0n5tIVtbEN28+al4EomqWOXk GS/wkvsO7ti5g1kHfIHjUNQkoUWuqxGI3naygrP1I7vWFWLGHSqWX09q5yx//XTL0Bdj4yMTF2 VgSGImLiqDR/1L/MjiQjEPp3 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:07 -0700 IronPort-SDR: ZevJqMrygcFvOLjI9TB2YNeKXhYImqbdhv3j1Qzl5l/T6+l6pK8rSIv5bv59xX8ZVU/Ik15Fhg BDqeZRmUIAYwlx+zh1JPLsqfHqc7BwGxYRguCMCM89Tp8UP0HwjAgSeOwV6RcdzlgYRwWi5Bea mlpXLe4MKH9UkhO1dGlWCKaNzaKEwEIKVsZBYbQPgYwIAhi7btBseA7AjAb1i1jbs5OKk2wrF6 t/QRmwPs65FbE7MCpbphF9rsc0GCFZV6cmnoi0Xzdgh1k0GgDZxW4QJ0BbSU0jvs6B8DvfOmDJ g6M= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:06 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 02/42] docs/system/generic-loader.rst: Fix style Date: Tue, 11 May 2021 20:19:11 +1000 Message-Id: <20210511101951.165287-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Axel Heider , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Axel Heider Fix style to have a proper description of the parameter 'force-raw'. Signed-off-by: Axel Heider Reviewed-by: Alistair Francis Message-id: a7e50a64-1c7c-2d41-96d3-d8a417a659ac@gmx.de Signed-off-by: Alistair Francis --- docs/system/generic-loader.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/system/generic-loader.rst b/docs/system/generic-loader.rst index 6bf8a4eb48..531ddbc8e3 100644 --- a/docs/system/generic-loader.rst +++ b/docs/system/generic-loader.rst @@ -92,9 +92,12 @@ shown below: specified in the executable format header. This option should only be used for the boot image. This will also cause the image to be written to the specified CPU's address space. If not specified, the - default is CPU 0. - Setting force-raw=on forces the file - to be treated as a raw image. This can be used to load supported - executable formats as if they were raw. + default is CPU 0. + +```` + Setting 'force-raw=on' forces the file to be treated as a raw image. + This can be used to load supported executable formats as if they + were raw. All values are parsed using the standard QemuOpts parsing. This allows the user to specify any values in any format supported. By default the values From patchwork Tue May 11 10:19:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=NV/zKNhM; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfYtK0pSMz9t0T for ; Tue, 11 May 2021 20:23:53 +1000 (AEST) Received: from localhost ([::1]:34896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPYN-0003Eq-3B for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:23:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVB-0008MO-Dg for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:36 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPUz-0006V6-8D for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728419; x=1652264419; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a4yEU+4TjBk6Oe2/N0wvc5JGnBHXRW0rnny396yYmb0=; b=NV/zKNhMS0peoJCjgo5ysSUEM8DE/+f/WiggbxMwvSDq3kSidlnGivRR wDG8CIvWNaw0BdzzStkcCjVDwsNqULahqFFG5VlBNNyF4UCOhJwSkDY58 tA/YQu0/bfIqaQyyPymImK/hV42mzQgc9TgwUQN1pC2lIjJPiLFTygntC UIvd83hT+WBy7GthWwjmeAvNZ6GVeie8y/BxwV0yHrcNGCGhahUCRXxAw a7+sKMzSaZ7VWQWtUUG7Hw1glQnwqgA70Gx8E3NAyJLHoV7/wjabPmu58 UvzsJLiwOvko9Bl0YL0/3kBTZpaTA9WjCm4BTS+NU4kQPAfQvWWT0vKJh Q==; IronPort-SDR: KFM7E6+qOX//7v0AV3QK212Hm4wUbvyaCy72/cmWG6c9XV1KjJof1nXrJiRfhu0dJKZYza/86Q tY/w4Zn2oRzGpdWKtTuvOYJ5BDqCI01dzu82tQ+/TBT+lJWQnACNqtl7dwSbRyGREz+T4rVdkE XKtdheC4Nr7a/k2qEZpS2wOXKO6nsmXTGJWtirEqZNPwcVY3ABiCT2WLEnb1qm8UXwJvm4nNEm hTA2oCJx7OuyNJ9r+uN8czonlTQXTtsijBA6t9P3ijqqxB3m2lNzgBh0exmBDe2CtnWovajRwj v0w= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735349" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:11 +0800 IronPort-SDR: r7jlDX/sPDeD77lDx2HWQSs01vvnsJ5+gUTzK0SGqoqLV+ieLtyx/GMAXg/9AOTlyIYlUUZAsj Uk4jGiaKckipR4+/yHqOhdNuclSs8pjBtp4jka5G4WrCss13bMKyvlyEqmi1rurhHI67laYksL fVZJ2yyxZlwdSQ/aCdC9CXYRJ/Qd0nX3iz8fcV44+Lb1cq1pboXmkcxdhV2C3L5uXHGtDMmifU 1YI9BBYNg1NP0En06sktv8p7b7WsHaOyXsA584XCUK4JD4spBaGU67Mx/ERmVGHHYQkxZKFS3o 298clPrBEy+TOcCIl2mu6CWp Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:11 -0700 IronPort-SDR: RDBRjENb0YHgeu+gnKeLfPrcTuo/wJ1ZhDe7ddC+SJc9KUAe0zCefCEUDxo3kNcARlpmLki4Ap yGC2PYfgFbZB0/5i+9caCY2d9r04d2uMcqe6/OBRwuC5lAw+hXS3ramPuwWXfSd6kApLz114ln djimbuYJGdSVKH6i3lRc2BEKL1cy/6fegsSazlvbkWN5hCTqLZtOBAesuV3tPllnAqCKY770SM J1XzgoxJf+QDdMOCHDfmr1830gRiCQ4gR7/LkT6uUxQns/ciiPZvXOenm9SaXVbEnZcYsu1SAk dUw= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:09 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 03/42] target/riscv: Align the data type of reset vector address Date: Tue, 11 May 2021 20:19:12 +1000 Message-Id: <20210511101951.165287-4-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dylan Jhong , qemu-devel@nongnu.org, Alistair Francis , Ruinland ChuanTzu Tsai , alistair23@gmail.com, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Dylan Jhong Use target_ulong to instead of uint64_t on reset vector address to adapt on both 32/64 machine. Signed-off-by: Dylan Jhong Signed-off-by: Ruinland ChuanTzu Tsai Reviewed-by: Bin Meng Reviewed-by: Alistair Francis Message-id: 20210329034801.22667-1-dylan@andestech.com Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 86e7dbeb20..047d6344fe 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -137,7 +137,7 @@ static void set_feature(CPURISCVState *env, int feature) env->features |= (1ULL << feature); } -static void set_resetvec(CPURISCVState *env, int resetvec) +static void set_resetvec(CPURISCVState *env, target_ulong resetvec) { #ifndef CONFIG_USER_ONLY env->resetvec = resetvec; From patchwork Tue May 11 10:19:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=XPAjvXyK; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfYv75Hkzz9t0T for ; Tue, 11 May 2021 20:24:35 +1000 (AEST) Received: from localhost ([::1]:38998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPZ3-0006Gc-M7 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:24:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVE-0008MP-Sw for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:36 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPV0-0006TG-BN for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728421; x=1652264421; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NQcnq47NunDV4WKlnP2K9I0LwZt5ImuM/NUAvOuKrLw=; b=XPAjvXyKL2hckDcxBbiC3pt9NoisOosdxWVC0Nvgw1Zz26ReelJz8Cxo WucRNxdfkmT/npI1Nxn8K+FFGVKBlg7OXPAD1pqHHaOrn0xTG9R7h8ijn A6gPmUVpNHpVWoXjT+kFuwjcddAClh8c9GAzl0hDmNBa4qLqKDG3nMRzV e6cwrlEHukd5DfZ+UK5pLDh7D4pzgbB9ljqexLXxEMSQB4oIvro00JS6T 48djvu7efnQHFG8HUpmR6qE+fdoK4NPsRsNmkQbu33gQN0CnEeMKJayma EysBgE4OwNAVxBOzPwb0OcuSEv+S15MuWS9tzHF8CSeovw++LgASbdPIc A==; IronPort-SDR: tmvvUCKPNfJSikrhRSR02J6r5TpCXz2unfCcqcZwF0sx8yWZK7QBgtvVuTxGh2UfwWImy5ogYG AJVAKx9STF7GRAonKuCNRv42Ch9I51S6HqmSNB1qgvjsFrsZyUq5WxVXN2cQglDG4ElhntAvsl DqSspoAyhLwh7UKS9M2W1wq795KqirgiHt90Yx7tHU2tpwTX3dbpx6QWnZDzPlp2EIYeQLf/Xw MjkCNnTHqkgZL2vGS1nfOB8o+Bbzq11qFJZtZVbGVGKK5gxImptn5ZMR5xR47smfj2pMO80k9g 0NU= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735352" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:15 +0800 IronPort-SDR: IgjYJ3obNL1a9Ddjlw1ZBUIRa45viY+ZzVKvJoBJzizMMzt9uk7FAUpI7+a8rTIAZThxQDmm1w 7mvczgUhKlXbtcKRvoa4+Gka+xCs+dPntuT9e/oLI5vjVHzkk5vUShJlMu1RYA1mefxKa5iOFn qggg6RPyQLj6LU1jiinb8Ok9xWyFEkTexz2TTJO7rphtmPSAeP4HGthGL//prNO5zRgTjv7Ny6 R3zQyMJ1kvp4RNncWVXMgu/OkN/W6bXp8rtNZDSjEnGiDiKrExmjCh16y+2rQJamzRGcLaHVRq aVg4JVxxqfuunlLD/2EPCtBo Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:14 -0700 IronPort-SDR: cYmOPwZYIQJcEpbmXs4MssrZB4QgYbjLOCi1hXLgHV8aoB6jWHzEywtRSfdEZq5KiFBsai/GaB 1Fg/7pTrS4nCmxAcHe7YcSjQpw6pEaBtPE0r0z/tUgr4QExSA3Wor7APofNtyMSsQaYbrlmfEM ozjy0MwXTf+NLI3ZBdFiSGYcwJ1z/gJ3HoUvSwk/WVg19la6o9pQTJrWsaIJpt7gkbxRQolWz8 LlLk3fAuvuR8yTXlfdfmoG70Sq4QNjJt0RoYyii5tT+6DXzcRDPItmF6OorxU3U2PoTqfACNcp GnE= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:13 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 04/42] hw/riscv: sifive_e: Add 'const' to sifive_e_memmap[] Date: Tue, 11 May 2021 20:19:13 +1000 Message-Id: <20210511101951.165287-5-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emmanuel Blot , qemu-devel@nongnu.org, =?utf-8?q?Phi?= =?utf-8?q?lippe_Mathieu-Daud=C3=A9?= , Alistair Francis , alistair23@gmail.com, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This was accidentally dropped before. Add it back. Fixes: 732612856a8 ("hw/riscv: Drop 'struct MemmapEntry'") Reported-by: Emmanuel Blot Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis Message-id: 20210331103612.654261-1-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/riscv/sifive_e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 3e8b44b2c0..ddc658c8d6 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -48,7 +48,7 @@ #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" -static MemMapEntry sifive_e_memmap[] = { +static const MemMapEntry sifive_e_memmap[] = { [SIFIVE_E_DEV_DEBUG] = { 0x0, 0x1000 }, [SIFIVE_E_DEV_MROM] = { 0x1000, 0x2000 }, [SIFIVE_E_DEV_OTP] = { 0x20000, 0x2000 }, From patchwork Tue May 11 10:19:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=oucN2XWP; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfYxK7306z9t0T for ; Tue, 11 May 2021 20:26:29 +1000 (AEST) Received: from localhost ([::1]:43264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPat-0000kl-Ql for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:26:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVF-0008Oi-OO for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:38 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPV0-0006X1-BX for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728421; x=1652264421; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qPCk4g3W8fX2UrYqx8Ha0jhj3mJEcwbKzn0C8s8q6fI=; b=oucN2XWPcy2mxLi1q3oBgP07ckU/klG2fa0+UQNDGFPL2Ak1vJkJ6dy9 NbrLZl7hYO7MKMKAz9O/YV/iYRCkRobg+dnrnmn7B4lOB/3aGBiEhBjqS 4ihDBZUgag81N1V2DMjBMkPOHXW9UrWM5d6CFaZAD4DsPEh68idUb0XxZ 4BkwFUcFt5IfxXM0aIbe4A6z8FNhZszH/2BE+nKKDi8hmXnAqFcUlnr0x K1mtzj5mz38d/dOLWuBGypzMnub4Fw++vlgdfF43Cpv7lhKbTxfmm5q+U dPlfkjdk0NwKgnOLlVPAfwe5EzjJul+VlahZgztUfJDo07dqubEOM5eMb Q==; IronPort-SDR: WN7CcicTR0CLIbcPUFEsE3MyEgSq45zJ3FtwYb3UrZzHmj/Xfqjfw6q5VqtbJjclnUBABzNsO5 SzqiSmpC2EDdowO4AGpJV1cWoXoeeNewGnuc96CYvvm05/bWe1xN8P35PdV+QVWrEmLIxypGfj Lf/5NvvGFnIRuVWLnwcmWhveKrB22jcTbshSlokM+UOQTIRN+T33s0j8Jjhnc0FYlYQMT4TZ7Z 035pe4J818TxJxsZPeH0l8feZvkQ1WWLNZJx6phAQYyLTKzzMsg9XQyqL0uUI8UwTaum/XHQrF uGc= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735356" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:18 +0800 IronPort-SDR: LLCOLY+5mvGnK4hcPqrLolHfLpDOtJ3/PFgQIMhv7uTLkNEOTXe8u8sLs88hIrX/tE6SsWzuYA ENSnZEuUkMYh9+/ENo46cmh5lhzUS8R4hwwfYHnwyRTjFKVlgjuHr5guxmoFkfedj3zWDWTQDN WrslTPHp0SFXGoRmej7S/+c3g2MjpAUSC96XKv4PbnSDiT6psw2KfZ3wdIGPwrgM8525q5cpIY sUyy0tYqgqAjrRytGIu8X1bY1Sp071vjiPxRPu5HlwspThTWgiwQ9FNc5eG7y1BfdRhWNKXOxt 4Pev1Zq/WHmEFrKF3nhofbmt Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:17 -0700 IronPort-SDR: HNgN7+MuSBShX5Oo/q/Qf09Hg4k2pAuSMHug0m1rkByavrbmHIZMA/CeLq2I4Kgfs1l72XypY2 VVXI91e9QcxyE/ESEPMnt4lUxH/Q+wJyySrkIa6c5vLFQ/gBzKsqpZEE9ZzOlNjAnoVmW3tkM3 PmGCaZ33C7uZyh9wV7MmQE8jlvOtDif+GO0KGIleETVWM4defo5z2DwR6dG8PcUfVikDKGleCt 7xsdt+gE3PjIrjWKugrgf/jf7IaagDMjk3ZfGCOdrOnHSUnhOj0ZB1Brr25fHSS1ksTtpJdgoj NYA= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:17 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 05/42] target/riscv: Add Shakti C class CPU Date: Tue, 11 May 2021 20:19:14 +1000 Message-Id: <20210511101951.165287-6-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vijai Kumar K , alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vijai Kumar K C-Class is a member of the SHAKTI family of processors from IIT-M. It is an extremely configurable and commercial-grade 5-stage in-order core supporting the standard RV64GCSUN ISA extensions. Signed-off-by: Vijai Kumar K Reviewed-by: Alistair Francis Message-id: 20210401181457.73039-2-vijai@behindbytes.com Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 1 + target/riscv/cpu.c | 1 + 2 files changed, 2 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 311b1db875..8079da8fa8 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -38,6 +38,7 @@ #define TYPE_RISCV_CPU_BASE32 RISCV_CPU_TYPE_NAME("rv32") #define TYPE_RISCV_CPU_BASE64 RISCV_CPU_TYPE_NAME("rv64") #define TYPE_RISCV_CPU_IBEX RISCV_CPU_TYPE_NAME("lowrisc-ibex") +#define TYPE_RISCV_CPU_SHAKTI_C RISCV_CPU_TYPE_NAME("shakti-c") #define TYPE_RISCV_CPU_SIFIVE_E31 RISCV_CPU_TYPE_NAME("sifive-e31") #define TYPE_RISCV_CPU_SIFIVE_E34 RISCV_CPU_TYPE_NAME("sifive-e34") #define TYPE_RISCV_CPU_SIFIVE_E51 RISCV_CPU_TYPE_NAME("sifive-e51") diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 047d6344fe..6842626c69 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -708,6 +708,7 @@ static const TypeInfo riscv_cpu_type_infos[] = { DEFINE_CPU(TYPE_RISCV_CPU_BASE64, rv64_base_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_E51, rv64_sifive_e_cpu_init), DEFINE_CPU(TYPE_RISCV_CPU_SIFIVE_U54, rv64_sifive_u_cpu_init), + DEFINE_CPU(TYPE_RISCV_CPU_SHAKTI_C, rv64_sifive_u_cpu_init), #endif }; From patchwork Tue May 11 10:19:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=O7nXXKOI; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfYyF3ky7z9sSn for ; Tue, 11 May 2021 20:27:17 +1000 (AEST) Received: from localhost ([::1]:47486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPbf-0003g9-5m for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:27:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVI-0008R2-Nw for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:40 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVE-0006V6-On for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728436; x=1652264436; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mjdkWuclpIuP5rkbnzonvrRc+N/FtfDgg5P/Dv0CCqA=; b=O7nXXKOIS7QR7NlJzP8UV1x9yh7N8Ukoyi970Mz4GUUsMSFaGAElCWA5 qjpmJLj6x5jIpTjwexvT9IkszESNDNTclYpYrYc7JQBI8A913/kpU/tKG I+0fsr3dsXpgdzJjpztXi50bMHbjsGmZFbjcYhPF78/h38ppUT6NJjZET 7WghKVWz2u8dxoVFAzM19DcL/KkjTuBjaymbBYl+IQsIYQuCQvscFONBn RV+iiSb/I4TzxMWFMlMg4GovwiJWnXdd74UBZt/SoWnqzm5IucNt3IyR+ s/Nz0+iZ2HPSpaiQ6tCWrTt3b5OIER4mjs8Hk0Pa5WFTdyWi7mwNAaF7F A==; IronPort-SDR: pQHVB1nRpLRE6kwwfcwb3xPiTtjptYmAbHkitHRI/nxLRVQTyGGx97DH7bS8aW4CiBISNQS9PV iv5t9Sil4eLlu028rRwJNLXdxMhnw7+VM7a/u7eDz6dOPZxbWQVQ3/FJ5hl/S4E8y1xz3XvVk8 kwlDw9kf3yWKiQW74w6jabdNEd4RAKz78HHj8FmG4JBhQTvkHBZERDdfM/t8DCwgy3KMqSV2zU Gcp/5paog7F7LbMYBtsK67M/74Hfcgow9dNMrO7JRS2FiNBUYyj4g2fpxRyI/wtnR0Dn+ndSBE eYE= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735361" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:20 +0800 IronPort-SDR: AQyf9KFO5/04bRTroL4145npI0KKVo/j+8aI6xPOjS8DaqBb0kEvztPAmh+isCAYnnF4ny/VBV o6KsPKPIo3vFC9hqO51KkSUNsbR8YSL25Q2EluwH0YGEdGHxqBYVZv2OAHxHAB4IDqysZhAx/L 21pFW+C5RFTN1RfC7l+rln8DXxgpC41UrLjAb1gn2il1IJ+e7djQcw7w/qi2aexSXwo/Eoaayq Of5r4eNun8GsIibTdYj7aFPIk4etNtl9lKGvY3kfrlXXzGbHiaYhgYhnSzXV/UERv/ssYKjTVp tRJFC7XLoL63mFQaquyBBmpg Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:20 -0700 IronPort-SDR: FbUtmILhlVa2sSt2IAyQNHFhqIu/QW0UrZqw/9KOO9qLIrpNA2mxNwHkcIofZ5uU1bcwWbMrkx lk1GbBRS0oNmk4AxclCqIOLvQC4cvuCMtH++WzTZ62XEF3BC78zZKu5QUeX/sz4JdV0a3mCBSB DzOoxudHGNGx8ycgt/AJPr0SMvyQh6vXe4ZAZBfH8HUjOowwZyVKMSwKNLkiC8ckFZWKaxuuxP EjcZvfhMXsEn0bz48degOTY87ZGMql2HWlCT3a0ys4BvZVpQcYYE6ZHX0R/EhO1VmDVkaUMuYs eeo= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:20 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 06/42] riscv: Add initial support for Shakti C machine Date: Tue, 11 May 2021 20:19:15 +1000 Message-Id: <20210511101951.165287-7-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vijai Kumar K , alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vijai Kumar K Add support for emulating Shakti reference platform based on C-class running on arty-100T board. https://gitlab.com/shaktiproject/cores/shakti-soc/-/blob/master/README.rst Signed-off-by: Vijai Kumar K Reviewed-by: Alistair Francis Message-id: 20210401181457.73039-3-vijai@behindbytes.com [Changes by AF: - Check for mstate->firmware before loading it ] Signed-off-by: Alistair Francis --- default-configs/devices/riscv64-softmmu.mak | 1 + include/hw/riscv/shakti_c.h | 73 +++++++++ hw/riscv/shakti_c.c | 173 ++++++++++++++++++++ MAINTAINERS | 7 + hw/riscv/Kconfig | 10 ++ hw/riscv/meson.build | 1 + 6 files changed, 265 insertions(+) create mode 100644 include/hw/riscv/shakti_c.h create mode 100644 hw/riscv/shakti_c.c diff --git a/default-configs/devices/riscv64-softmmu.mak b/default-configs/devices/riscv64-softmmu.mak index d5eec75f05..bc69301fa4 100644 --- a/default-configs/devices/riscv64-softmmu.mak +++ b/default-configs/devices/riscv64-softmmu.mak @@ -13,3 +13,4 @@ CONFIG_SIFIVE_E=y CONFIG_SIFIVE_U=y CONFIG_RISCV_VIRT=y CONFIG_MICROCHIP_PFSOC=y +CONFIG_SHAKTI_C=y diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h new file mode 100644 index 0000000000..8ffc2b0213 --- /dev/null +++ b/include/hw/riscv/shakti_c.h @@ -0,0 +1,73 @@ +/* + * Shakti C-class SoC emulation + * + * Copyright (c) 2021 Vijai Kumar K + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef HW_SHAKTI_H +#define HW_SHAKTI_H + +#include "hw/riscv/riscv_hart.h" +#include "hw/boards.h" + +#define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc" +#define RISCV_SHAKTI_SOC(obj) \ + OBJECT_CHECK(ShaktiCSoCState, (obj), TYPE_RISCV_SHAKTI_SOC) + +typedef struct ShaktiCSoCState { + /*< private >*/ + DeviceState parent_obj; + + /*< public >*/ + RISCVHartArrayState cpus; + DeviceState *plic; + MemoryRegion rom; + +} ShaktiCSoCState; + +#define TYPE_RISCV_SHAKTI_MACHINE MACHINE_TYPE_NAME("shakti_c") +#define RISCV_SHAKTI_MACHINE(obj) \ + OBJECT_CHECK(ShaktiCMachineState, (obj), TYPE_RISCV_SHAKTI_MACHINE) +typedef struct ShaktiCMachineState { + /*< private >*/ + MachineState parent_obj; + + /*< public >*/ + ShaktiCSoCState soc; +} ShaktiCMachineState; + +enum { + SHAKTI_C_ROM, + SHAKTI_C_RAM, + SHAKTI_C_UART, + SHAKTI_C_GPIO, + SHAKTI_C_PLIC, + SHAKTI_C_CLINT, + SHAKTI_C_I2C, +}; + +#define SHAKTI_C_PLIC_HART_CONFIG "MS" +/* Including Interrupt ID 0 (no interrupt)*/ +#define SHAKTI_C_PLIC_NUM_SOURCES 28 +/* Excluding Priority 0 */ +#define SHAKTI_C_PLIC_NUM_PRIORITIES 2 +#define SHAKTI_C_PLIC_PRIORITY_BASE 0x04 +#define SHAKTI_C_PLIC_PENDING_BASE 0x1000 +#define SHAKTI_C_PLIC_ENABLE_BASE 0x2000 +#define SHAKTI_C_PLIC_ENABLE_STRIDE 0x80 +#define SHAKTI_C_PLIC_CONTEXT_BASE 0x200000 +#define SHAKTI_C_PLIC_CONTEXT_STRIDE 0x1000 + +#endif diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c new file mode 100644 index 0000000000..6e6e63d153 --- /dev/null +++ b/hw/riscv/shakti_c.c @@ -0,0 +1,173 @@ +/* + * Shakti C-class SoC emulation + * + * Copyright (c) 2021 Vijai Kumar K + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "hw/boards.h" +#include "hw/riscv/shakti_c.h" +#include "qapi/error.h" +#include "hw/intc/sifive_plic.h" +#include "hw/intc/sifive_clint.h" +#include "sysemu/sysemu.h" +#include "hw/qdev-properties.h" +#include "exec/address-spaces.h" +#include "hw/riscv/boot.h" + + +static const struct MemmapEntry { + hwaddr base; + hwaddr size; +} shakti_c_memmap[] = { + [SHAKTI_C_ROM] = { 0x00001000, 0x2000 }, + [SHAKTI_C_RAM] = { 0x80000000, 0x0 }, + [SHAKTI_C_UART] = { 0x00011300, 0x00040 }, + [SHAKTI_C_GPIO] = { 0x020d0000, 0x00100 }, + [SHAKTI_C_PLIC] = { 0x0c000000, 0x20000 }, + [SHAKTI_C_CLINT] = { 0x02000000, 0xc0000 }, + [SHAKTI_C_I2C] = { 0x20c00000, 0x00100 }, +}; + +static void shakti_c_machine_state_init(MachineState *mstate) +{ + ShaktiCMachineState *sms = RISCV_SHAKTI_MACHINE(mstate); + MemoryRegion *system_memory = get_system_memory(); + MemoryRegion *main_mem = g_new(MemoryRegion, 1); + + /* Allow only Shakti C CPU for this platform */ + if (strcmp(mstate->cpu_type, TYPE_RISCV_CPU_SHAKTI_C) != 0) { + error_report("This board can only be used with Shakti C CPU"); + exit(1); + } + + /* Initialize SoC */ + object_initialize_child(OBJECT(mstate), "soc", &sms->soc, + TYPE_RISCV_SHAKTI_SOC); + qdev_realize(DEVICE(&sms->soc), NULL, &error_abort); + + /* register RAM */ + memory_region_init_ram(main_mem, NULL, "riscv.shakti.c.ram", + mstate->ram_size, &error_fatal); + memory_region_add_subregion(system_memory, + shakti_c_memmap[SHAKTI_C_RAM].base, + main_mem); + + /* ROM reset vector */ + riscv_setup_rom_reset_vec(mstate, &sms->soc.cpus, + shakti_c_memmap[SHAKTI_C_RAM].base, + shakti_c_memmap[SHAKTI_C_ROM].base, + shakti_c_memmap[SHAKTI_C_ROM].size, 0, 0, + NULL); + if (mstate->firmware) { + riscv_load_firmware(mstate->firmware, + shakti_c_memmap[SHAKTI_C_RAM].base, + NULL); + } +} + +static void shakti_c_machine_instance_init(Object *obj) +{ +} + +static void shakti_c_machine_class_init(ObjectClass *klass, void *data) +{ + MachineClass *mc = MACHINE_CLASS(klass); + mc->desc = "RISC-V Board compatible with Shakti SDK"; + mc->init = shakti_c_machine_state_init; + mc->default_cpu_type = TYPE_RISCV_CPU_SHAKTI_C; +} + +static const TypeInfo shakti_c_machine_type_info = { + .name = TYPE_RISCV_SHAKTI_MACHINE, + .parent = TYPE_MACHINE, + .class_init = shakti_c_machine_class_init, + .instance_init = shakti_c_machine_instance_init, + .instance_size = sizeof(ShaktiCMachineState), +}; + +static void shakti_c_machine_type_info_register(void) +{ + type_register_static(&shakti_c_machine_type_info); +} +type_init(shakti_c_machine_type_info_register) + +static void shakti_c_soc_state_realize(DeviceState *dev, Error **errp) +{ + ShaktiCSoCState *sss = RISCV_SHAKTI_SOC(dev); + MemoryRegion *system_memory = get_system_memory(); + + sysbus_realize(SYS_BUS_DEVICE(&sss->cpus), &error_abort); + + sss->plic = sifive_plic_create(shakti_c_memmap[SHAKTI_C_PLIC].base, + (char *)SHAKTI_C_PLIC_HART_CONFIG, 0, + SHAKTI_C_PLIC_NUM_SOURCES, + SHAKTI_C_PLIC_NUM_PRIORITIES, + SHAKTI_C_PLIC_PRIORITY_BASE, + SHAKTI_C_PLIC_PENDING_BASE, + SHAKTI_C_PLIC_ENABLE_BASE, + SHAKTI_C_PLIC_ENABLE_STRIDE, + SHAKTI_C_PLIC_CONTEXT_BASE, + SHAKTI_C_PLIC_CONTEXT_STRIDE, + shakti_c_memmap[SHAKTI_C_PLIC].size); + + sifive_clint_create(shakti_c_memmap[SHAKTI_C_CLINT].base, + shakti_c_memmap[SHAKTI_C_CLINT].size, 0, 1, + SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, + SIFIVE_CLINT_TIMEBASE_FREQ, false); + + /* ROM */ + memory_region_init_rom(&sss->rom, OBJECT(dev), "riscv.shakti.c.rom", + shakti_c_memmap[SHAKTI_C_ROM].size, &error_fatal); + memory_region_add_subregion(system_memory, + shakti_c_memmap[SHAKTI_C_ROM].base, &sss->rom); +} + +static void shakti_c_soc_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + dc->realize = shakti_c_soc_state_realize; +} + +static void shakti_c_soc_instance_init(Object *obj) +{ + ShaktiCSoCState *sss = RISCV_SHAKTI_SOC(obj); + + object_initialize_child(obj, "cpus", &sss->cpus, TYPE_RISCV_HART_ARRAY); + + /* + * CPU type is fixed and we are not supporting passing from commandline yet. + * So let it be in instance_init. When supported should use ms->cpu_type + * instead of TYPE_RISCV_CPU_SHAKTI_C + */ + object_property_set_str(OBJECT(&sss->cpus), "cpu-type", + TYPE_RISCV_CPU_SHAKTI_C, &error_abort); + object_property_set_int(OBJECT(&sss->cpus), "num-harts", 1, + &error_abort); +} + +static const TypeInfo shakti_c_type_info = { + .name = TYPE_RISCV_SHAKTI_SOC, + .parent = TYPE_DEVICE, + .class_init = shakti_c_soc_class_init, + .instance_init = shakti_c_soc_instance_init, + .instance_size = sizeof(ShaktiCSoCState), +}; + +static void shakti_c_type_info_register(void) +{ + type_register_static(&shakti_c_type_info); +} +type_init(shakti_c_type_info_register) diff --git a/MAINTAINERS b/MAINTAINERS index 06642d9799..bfa5adcb1a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1415,6 +1415,13 @@ F: include/hw/misc/mchp_pfsoc_dmc.h F: include/hw/misc/mchp_pfsoc_ioscb.h F: include/hw/misc/mchp_pfsoc_sysreg.h +Shakti C class SoC +M: Vijai Kumar K +L: qemu-riscv@nongnu.org +S: Supported +F: hw/riscv/shakti_c.c +F: include/hw/riscv/shakti_c.h + SiFive Machines M: Alistair Francis M: Bin Meng diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 1de18cdcf1..a0225716b5 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -19,6 +19,16 @@ config OPENTITAN select IBEX select UNIMP +config SHAKTI + bool + +config SHAKTI_C + bool + select UNIMP + select SHAKTI + select SIFIVE_CLINT + select SIFIVE_PLIC + config RISCV_VIRT bool imply PCI_DEVICES diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build index 275c0f7eb7..a97454661c 100644 --- a/hw/riscv/meson.build +++ b/hw/riscv/meson.build @@ -4,6 +4,7 @@ riscv_ss.add(files('numa.c')) riscv_ss.add(files('riscv_hart.c')) riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c')) riscv_ss.add(when: 'CONFIG_RISCV_VIRT', if_true: files('virt.c')) +riscv_ss.add(when: 'CONFIG_SHAKTI_C', if_true: files('shakti_c.c')) riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c')) riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c')) riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c')) From patchwork Tue May 11 10:19:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=dzH3MpAw; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZ213M67z9t10 for ; Tue, 11 May 2021 20:30:33 +1000 (AEST) Received: from localhost ([::1]:56046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPep-00013e-FM for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:30:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVJ-0008SI-9q for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:41 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVF-0006TG-A9 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728436; x=1652264436; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tEjik2EaIsz78QagD2WjSx1mPC83CHoABEsbbOdo1mY=; b=dzH3MpAwaigP/YJzSX7XLK7SSKp92dznrO3Szif7YtYHjeNzkeTJMCE7 BdWaGh3tGM3NVKlzGf1H0XnZ8HLNjXn5NLsKoQwKaZoin9gZRdclXmK+M UCfJbMcjspaAli7zOB8Yj8M5W0BeYrqvIcWa7peDqhIxs+2NqHrPSFDW9 nn/3b1wUHsX8zfn3bIxKwfz4dD8v8J/9crY2x2n7LUWTTcZO0tTd82kAp fL1EtXqiy5l9wXDuhfxGpxseQhzmT7lZpUzKWVKlqxweR/UvL4rqf/Nrw t9ouLvlMbtC4zYiRU8fSsqt2vGAJFiRiO+ljuWFTK1pfGjYJMFsrtCWS6 g==; IronPort-SDR: qfXns9Ij67bh9w7xAMxqmPhUAyxMj6RxdUWaZdt2gcvjlVdSTHZg+oOEXRK4eQu6BxSD5vbVzj u86sUIH2DQNwT4aTUwErrDL3orRFUwANiSqiqdZRZzTUv0DTRHOT71YExiF/ySUNq0c3s+yVqs iyHDSe+UDa4GNmQpKmVsC0gL/3n8eEUQ+S+ds1cU24gFPPL7yptvlVj0RgI6IAf/r3CtV6uX4s JQ1xrkE5EYrMbcJUdChgEEx42swrCoCiCXW+OY2XhIx4424x/D3b3Jxl3Q32umhO8CVVWIPePe jlk= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735367" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:24 +0800 IronPort-SDR: ot8cSxQBMnxJu4+MIe/HSXddCMrNtmEAneDCdE/ENduhIUjYCocZYi0wqhEQonaMygUnz5iHjU CJzoGwvRnjq98qoKjjHXae9GFYViVGLtlDCQXBUKPNV73zl1MH8nmMtxViyu8rytmrWI7cTd4L YcGeUrt1n2bo9PwADdU8sVPKXeRRdKIfhPIWGJvKlk5L+Z/q6xXCVhhSxFRyrVQzcs1adWTKAM rM4Fm9cp+ZWwEoaCaoBXZjzCR1jQMBPlD1Tbpd3H5zLemnpqHm0KwCmZ8KXtQW6aHZG1GPNiCC vn8+ZaxGbc2qflmj2ace8wqe Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:23 -0700 IronPort-SDR: VQ6qAxYdTfVEvWvFiNnP4jd335ReK7zBTEYgqopaan9E1/ZAXgc8HneuYcgebeVJ5BrrFft0jq ccEKtLIT+3p7CYSuRCALNjAmtL+3UGAccRFJ0FenSOGuKZEmkBWprMfmKgSlYG8Pa1WUaubaeK QphYy12zUoU3TM6WMwht1KzM6nf5SBkOZJ7xnTDhPPZldTmVdiISVaZUDqt/zPAU6jSqBTq698 2E6mn5bOcZJstRtSlhSlK3+lZh6nzIW5tGbqfRbUW1AUkmm4cixrcAXdTvjozjfJiJ1YT1qN6B 5HI= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:23 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 07/42] hw/char: Add Shakti UART emulation Date: Tue, 11 May 2021 20:19:16 +1000 Message-Id: <20210511101951.165287-8-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vijai Kumar K , alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vijai Kumar K This is the initial implementation of Shakti UART. Signed-off-by: Vijai Kumar K Reviewed-by: Alistair Francis Message-id: 20210401181457.73039-4-vijai@behindbytes.com Signed-off-by: Alistair Francis --- include/hw/char/shakti_uart.h | 74 ++++++++++++++ hw/char/shakti_uart.c | 185 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 + hw/char/meson.build | 1 + hw/char/trace-events | 4 + 5 files changed, 266 insertions(+) create mode 100644 include/hw/char/shakti_uart.h create mode 100644 hw/char/shakti_uart.c diff --git a/include/hw/char/shakti_uart.h b/include/hw/char/shakti_uart.h new file mode 100644 index 0000000000..526c408233 --- /dev/null +++ b/include/hw/char/shakti_uart.h @@ -0,0 +1,74 @@ +/* + * SHAKTI UART + * + * Copyright (c) 2021 Vijai Kumar K + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef HW_SHAKTI_UART_H +#define HW_SHAKTI_UART_H + +#include "hw/sysbus.h" +#include "chardev/char-fe.h" + +#define SHAKTI_UART_BAUD 0x00 +#define SHAKTI_UART_TX 0x04 +#define SHAKTI_UART_RX 0x08 +#define SHAKTI_UART_STATUS 0x0C +#define SHAKTI_UART_DELAY 0x10 +#define SHAKTI_UART_CONTROL 0x14 +#define SHAKTI_UART_INT_EN 0x18 +#define SHAKTI_UART_IQ_CYCLES 0x1C +#define SHAKTI_UART_RX_THRES 0x20 + +#define SHAKTI_UART_STATUS_TX_EMPTY (1 << 0) +#define SHAKTI_UART_STATUS_TX_FULL (1 << 1) +#define SHAKTI_UART_STATUS_RX_NOT_EMPTY (1 << 2) +#define SHAKTI_UART_STATUS_RX_FULL (1 << 3) +/* 9600 8N1 is the default setting */ +/* Reg value = (50000000 Hz)/(16 * 9600)*/ +#define SHAKTI_UART_BAUD_DEFAULT 0x0145 +#define SHAKTI_UART_CONTROL_DEFAULT 0x0100 + +#define TYPE_SHAKTI_UART "shakti-uart" +#define SHAKTI_UART(obj) \ + OBJECT_CHECK(ShaktiUartState, (obj), TYPE_SHAKTI_UART) + +typedef struct { + /* */ + SysBusDevice parent_obj; + + /* */ + MemoryRegion mmio; + + uint32_t uart_baud; + uint32_t uart_tx; + uint32_t uart_rx; + uint32_t uart_status; + uint32_t uart_delay; + uint32_t uart_control; + uint32_t uart_interrupt; + uint32_t uart_iq_cycles; + uint32_t uart_rx_threshold; + + CharBackend chr; +} ShaktiUartState; + +#endif /* HW_SHAKTI_UART_H */ diff --git a/hw/char/shakti_uart.c b/hw/char/shakti_uart.c new file mode 100644 index 0000000000..6870821325 --- /dev/null +++ b/hw/char/shakti_uart.c @@ -0,0 +1,185 @@ +/* + * SHAKTI UART + * + * Copyright (c) 2021 Vijai Kumar K + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "hw/char/shakti_uart.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" +#include "qemu/log.h" + +static uint64_t shakti_uart_read(void *opaque, hwaddr addr, unsigned size) +{ + ShaktiUartState *s = opaque; + + switch (addr) { + case SHAKTI_UART_BAUD: + return s->uart_baud; + case SHAKTI_UART_RX: + qemu_chr_fe_accept_input(&s->chr); + s->uart_status &= ~SHAKTI_UART_STATUS_RX_NOT_EMPTY; + return s->uart_rx; + case SHAKTI_UART_STATUS: + return s->uart_status; + case SHAKTI_UART_DELAY: + return s->uart_delay; + case SHAKTI_UART_CONTROL: + return s->uart_control; + case SHAKTI_UART_INT_EN: + return s->uart_interrupt; + case SHAKTI_UART_IQ_CYCLES: + return s->uart_iq_cycles; + case SHAKTI_UART_RX_THRES: + return s->uart_rx_threshold; + default: + /* Also handles TX REG which is write only */ + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); + } + + return 0; +} + +static void shakti_uart_write(void *opaque, hwaddr addr, + uint64_t data, unsigned size) +{ + ShaktiUartState *s = opaque; + uint32_t value = data; + uint8_t ch; + + switch (addr) { + case SHAKTI_UART_BAUD: + s->uart_baud = value; + break; + case SHAKTI_UART_TX: + ch = value; + qemu_chr_fe_write_all(&s->chr, &ch, 1); + s->uart_status &= ~SHAKTI_UART_STATUS_TX_FULL; + break; + case SHAKTI_UART_STATUS: + s->uart_status = value; + break; + case SHAKTI_UART_DELAY: + s->uart_delay = value; + break; + case SHAKTI_UART_CONTROL: + s->uart_control = value; + break; + case SHAKTI_UART_INT_EN: + s->uart_interrupt = value; + break; + case SHAKTI_UART_IQ_CYCLES: + s->uart_iq_cycles = value; + break; + case SHAKTI_UART_RX_THRES: + s->uart_rx_threshold = value; + break; + default: + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); + } +} + +static const MemoryRegionOps shakti_uart_ops = { + .read = shakti_uart_read, + .write = shakti_uart_write, + .endianness = DEVICE_NATIVE_ENDIAN, + .impl = {.min_access_size = 1, .max_access_size = 4}, + .valid = {.min_access_size = 1, .max_access_size = 4}, +}; + +static void shakti_uart_reset(DeviceState *dev) +{ + ShaktiUartState *s = SHAKTI_UART(dev); + + s->uart_baud = SHAKTI_UART_BAUD_DEFAULT; + s->uart_tx = 0x0; + s->uart_rx = 0x0; + s->uart_status = 0x0000; + s->uart_delay = 0x0000; + s->uart_control = SHAKTI_UART_CONTROL_DEFAULT; + s->uart_interrupt = 0x0000; + s->uart_iq_cycles = 0x00; + s->uart_rx_threshold = 0x00; +} + +static int shakti_uart_can_receive(void *opaque) +{ + ShaktiUartState *s = opaque; + + return !(s->uart_status & SHAKTI_UART_STATUS_RX_NOT_EMPTY); +} + +static void shakti_uart_receive(void *opaque, const uint8_t *buf, int size) +{ + ShaktiUartState *s = opaque; + + s->uart_rx = *buf; + s->uart_status |= SHAKTI_UART_STATUS_RX_NOT_EMPTY; +} + +static void shakti_uart_realize(DeviceState *dev, Error **errp) +{ + ShaktiUartState *sus = SHAKTI_UART(dev); + qemu_chr_fe_set_handlers(&sus->chr, shakti_uart_can_receive, + shakti_uart_receive, NULL, NULL, sus, NULL, true); +} + +static void shakti_uart_instance_init(Object *obj) +{ + ShaktiUartState *sus = SHAKTI_UART(obj); + memory_region_init_io(&sus->mmio, + obj, + &shakti_uart_ops, + sus, + TYPE_SHAKTI_UART, + 0x1000); + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &sus->mmio); +} + +static Property shakti_uart_properties[] = { + DEFINE_PROP_CHR("chardev", ShaktiUartState, chr), + DEFINE_PROP_END_OF_LIST(), +}; + +static void shakti_uart_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + dc->reset = shakti_uart_reset; + dc->realize = shakti_uart_realize; + device_class_set_props(dc, shakti_uart_properties); +} + +static const TypeInfo shakti_uart_info = { + .name = TYPE_SHAKTI_UART, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(ShaktiUartState), + .class_init = shakti_uart_class_init, + .instance_init = shakti_uart_instance_init, +}; + +static void shakti_uart_register_types(void) +{ + type_register_static(&shakti_uart_info); +} +type_init(shakti_uart_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index bfa5adcb1a..7aaa304b1e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1420,7 +1420,9 @@ M: Vijai Kumar K L: qemu-riscv@nongnu.org S: Supported F: hw/riscv/shakti_c.c +F: hw/char/shakti_uart.c F: include/hw/riscv/shakti_c.h +F: include/hw/char/shakti_uart.h SiFive Machines M: Alistair Francis diff --git a/hw/char/meson.build b/hw/char/meson.build index da5bb8b762..014833dded 100644 --- a/hw/char/meson.build +++ b/hw/char/meson.build @@ -19,6 +19,7 @@ softmmu_ss.add(when: 'CONFIG_SERIAL', if_true: files('serial.c')) softmmu_ss.add(when: 'CONFIG_SERIAL_ISA', if_true: files('serial-isa.c')) softmmu_ss.add(when: 'CONFIG_SERIAL_PCI', if_true: files('serial-pci.c')) softmmu_ss.add(when: 'CONFIG_SERIAL_PCI_MULTI', if_true: files('serial-pci-multi.c')) +softmmu_ss.add(when: 'CONFIG_SHAKTI', if_true: files('shakti_uart.c')) softmmu_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true: files('virtio-console.c')) softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen_console.c')) softmmu_ss.add(when: 'CONFIG_XILINX', if_true: files('xilinx_uartlite.c')) diff --git a/hw/char/trace-events b/hw/char/trace-events index 76d52938ea..c8dcade104 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -90,6 +90,10 @@ cmsdk_apb_uart_set_params(int speed) "CMSDK APB UART: params set to %d 8N1" nrf51_uart_read(uint64_t addr, uint64_t r, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx64 " size %u" nrf51_uart_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx64 " size %u" +# shakti_uart.c +shakti_uart_read(uint64_t addr, uint16_t r, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx16 " size %u" +shakti_uart_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx64 " size %u" + # exynos4210_uart.c exynos_uart_dmabusy(uint32_t channel) "UART%d: DMA busy (Rx buffer empty)" exynos_uart_dmaready(uint32_t channel) "UART%d: DMA ready" From patchwork Tue May 11 10:19:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477029 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=FiseQIvs; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfYzW455wz9sSn for ; Tue, 11 May 2021 20:28:23 +1000 (AEST) Received: from localhost ([::1]:51734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPcj-0006WA-Ck for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:28:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVK-0008TF-4L for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:48 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVG-0006X1-2t for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728437; x=1652264437; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DnxGqkqryW4nT1B8CpFaIJuKOwmq2qmaWP3zHuKVDz0=; b=FiseQIvsW/peAfo+q8GMVpnkBMkjUg4P0/E056mQTR19pL1dLeykFzWB rcZfMpv3j0xz0MLfYzXX/QhnhL7eGernp96P0dT95MS7ElNfleTPlOEXq jnlmQPqNd78bVYIihp6I6Q6A5WwghnQ3UIqxs5fb0Ug9RzCOpikss1Z0N bJ7t/uV/4rQ6qCr23NkzLcRyRCPe2oj7aqwypL3/9ZqAJL2mEgx3qJPiU 5LyEUJRSq3QxnjbF52Ya37h/LGuXJ9vVjs+CBQKOavUjIIEf+bxgnSHLY TdcbvGMaM3ck4AHBUqZqqhbGmhj0SJF0whHBowdicZWEUrPjtXv6XdGZH g==; IronPort-SDR: awQFzsygtpFHz+49AL/JNC7+D0gPrgD8pTmVL6Xys6zseCdsszYOWPgCyd5Yfzuc5se46Xmwvl jtnJC6tiBxreoggsDAgJS+7JbgN9ddIKdy2DL/LoJYHdJWI6jSoypvL8RJPHjGD23iWSvUuKzG goZ0RJqrWfrXfO8/6ulq6tGIWaYabcJdpYdfs2r4RuJWm9plmeywO3bF96Sauz/gs8UrqzhhPt aoN5pWXyobqTzRWI7OTZSwBR7kXi7ckIsH3LU6/gOvQ1P23YiWeWrT6stVxu78nBHCRPrRGeuc +7s= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735369" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:27 +0800 IronPort-SDR: DAupdVK0ZTEJ1xJCfNhr8DNLyi0cRISPZi5ESeN1rngevVvUG9eWKmoC2ctoqyAd3SQWbtH3GH yuNIiGf0vW9aarYwzdLQLRMrBsYq9f5xXsZcG9AoXwhMwE8ayu/6mMgLLRhx43ARLsCBgt+Bki vmB8uDN3buzpdYR4GxC7cDMUjFQIXUlhYTYyDmRmu23f3RUJUmyRGIyq3lmfGuggEDfaeZNvOB CNtV23AYdZ3Ag8nz0GFX7XOyxfikh9T80gd/1ybuMLC7QW9DFMWoJyvVeImJAMrypEvdA3RdFP TvQeNPy+lzfWyYinv4TZaLoJ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:26 -0700 IronPort-SDR: XqTf3haPtZ9pokFci2GTKlQXZE0cg1aT7NonH2PMA2V82ECdCUBzKjvHC8XwxieeFbXCE9+lh1 u8JslvGQtZXpM5cRKbYmocq1AqXpv606D8sWJhtgYPRcsmlpL7se0/y5VijcWNyad/0Si928Bn Yka0uITmyhZrxcndQqUj/6Hp58Vs46XJYjoNkz4uN3qa5DQ7VoBQXRzeBPwL6quqiN6vSCssGJ Son+XzKUzCkxNtN+ncxaGh7vGzZmWcnizMMiyslRxUzJMx4gA9xq8rwxG/3SCj7CQUhXywYsks TMI= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:26 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 08/42] hw/riscv: Connect Shakti UART to Shakti platform Date: Tue, 11 May 2021 20:19:17 +1000 Message-Id: <20210511101951.165287-9-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vijai Kumar K , alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vijai Kumar K Connect one shakti uart to the shakti_c machine. Signed-off-by: Vijai Kumar K Reviewed-by: Alistair Francis Message-id: 20210401181457.73039-5-vijai@behindbytes.com Signed-off-by: Alistair Francis --- include/hw/riscv/shakti_c.h | 2 ++ hw/riscv/shakti_c.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h index 8ffc2b0213..50a2b79086 100644 --- a/include/hw/riscv/shakti_c.h +++ b/include/hw/riscv/shakti_c.h @@ -21,6 +21,7 @@ #include "hw/riscv/riscv_hart.h" #include "hw/boards.h" +#include "hw/char/shakti_uart.h" #define TYPE_RISCV_SHAKTI_SOC "riscv.shakti.cclass.soc" #define RISCV_SHAKTI_SOC(obj) \ @@ -33,6 +34,7 @@ typedef struct ShaktiCSoCState { /*< public >*/ RISCVHartArrayState cpus; DeviceState *plic; + ShaktiUartState uart; MemoryRegion rom; } ShaktiCSoCState; diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c index 6e6e63d153..18f70fadaa 100644 --- a/hw/riscv/shakti_c.c +++ b/hw/riscv/shakti_c.c @@ -128,6 +128,13 @@ static void shakti_c_soc_state_realize(DeviceState *dev, Error **errp) SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE, SIFIVE_CLINT_TIMEBASE_FREQ, false); + qdev_prop_set_chr(DEVICE(&(sss->uart)), "chardev", serial_hd(0)); + if (!sysbus_realize(SYS_BUS_DEVICE(&sss->uart), errp)) { + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&sss->uart), 0, + shakti_c_memmap[SHAKTI_C_UART].base); + /* ROM */ memory_region_init_rom(&sss->rom, OBJECT(dev), "riscv.shakti.c.rom", shakti_c_memmap[SHAKTI_C_ROM].size, &error_fatal); @@ -146,6 +153,7 @@ static void shakti_c_soc_instance_init(Object *obj) ShaktiCSoCState *sss = RISCV_SHAKTI_SOC(obj); object_initialize_child(obj, "cpus", &sss->cpus, TYPE_RISCV_HART_ARRAY); + object_initialize_child(obj, "uart", &sss->uart, TYPE_SHAKTI_UART); /* * CPU type is fixed and we are not supporting passing from commandline yet. From patchwork Tue May 11 10:19:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=po6cv9/U; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZ2D6kHNz9t0k for ; Tue, 11 May 2021 20:30:44 +1000 (AEST) Received: from localhost ([::1]:57036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPf0-0001kT-RB for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:30:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVU-00005Q-HQ for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:52 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVJ-0006V6-4M for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728439; x=1652264439; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cQ+E7bgIWZyDSwMRwwYYu9Yg/pKRgf4qLqVbRNdF+II=; b=po6cv9/ULFElrHOqujyoZlxSafss+CdRvNTIVhhIhhRbcL2hq3bOTUtU ert4NRLheCaPtmrApZeiXDJu8rVX2JmlzGd1jMr9VcIRBkgzynt9oOnlO loAINIKun2Ova0SYKMzv2ZIGos6FcZ3va6b4Zqyr6Hfb3G5ofUf2U8HXY sOXf7uuacIw3u7sPyFKZSnGMgktvqwyJTwb8zZ0TQ4scUyLBUUA/OTZp6 A2BrxCP0A9GmjbYJBvWQDOLu/K9Mw2xlBiRdbtlF50H94baV/viaoxaaN S+5ifqprfDzxhRbt1FrhZMaukB3wKWK+ZiOL0foCss47CTczzmc7EqPQB A==; IronPort-SDR: 8U31g+AgRgAlCIGJupivwN/jt8YGMAb0FpgRggwGEvGOvTsSj6387dicbE/nyIbtxZpXDFiO8d CKyf6MWKHXA6ud3djo3yQ/qOEdSF8WAEox6UvE78/OWr+ab67T0oCVvBGRYesmawATh1ZP3TZA KX8u/kJGt4JNqeOW4MkDoHzr2PQuMp1iZS8g+7IA+vAij5zzK2FBgu+7SatOVYqIXI/jrprt5w /a4mxhBmJ43ym5ffige3QGtZF8YM8Z1FX+MKf9TSxHlQ8iTmXkiW1Rodxt7hjiJTU6cqRe6iuE ado= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735372" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:30 +0800 IronPort-SDR: 5T38LmXGifw2lS5djXyxzYVlV0m+Utk8j+slHRVAfdRQhmQmLmQ1bR2I8FEy+hmyMNy2rG5625 BnadKcdlaBuLhBdVTkrEZfFcwvdiarYSb0KL2gK5dRy9Dz5FIciksn6h4yGrOLyWR+4jvsIaV/ CMulnjpe8mWoXR79mZuJ2qLICV2ELm5yp7cbMLJ9QKb6imnZ4plBvz6TJsrGNfqgNR0lddaiiF ojJoe8fGjDP1hVDUJ4lG9+t9Je0XmgSN3DmtBE9+ZteHdzaJGWS7VTPQ1rK7kEFKKmz6T7PjFq YuFVoVc4hIWrl5qEkBA4I0uo Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:29 -0700 IronPort-SDR: 6m8ADwUoM+s4LrAnbgMGiRxY6jzWBZleEzeT7PGNsqGym0bKD1yI9qgB/6zgxeMhkxqBslc6Yj gs76gJJsY63leDi5ttAQWCd4pyuIvyy2BzBoMnaxCibZTaJvx16OhsEFQbcV1QoLGMM2v30jYk ZxW2LeN1az+IzlDRJ7ylgI2vWR71unaJoSiYICUjyHxQZZlHrbzN4vncQFPuL5M4OmZECpdung DoK5GudXBhGJDOPOVEt4qyt0r+cRGq0vL+xPzoArbKImquZjd2pDrUb5v2x1IeuggXx/m3aESb BiY= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:29 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 09/42] target/riscv: Convert the RISC-V exceptions to an enum Date: Tue, 11 May 2021 20:19:18 +1000 Message-Id: <20210511101951.165287-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Bin Meng , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Reviewed-by: Richard Henderson Message-id: f191dcf08bf413a822e743a7c7f824d68879a527.1617290165.git.alistair.francis@wdc.com --- target/riscv/cpu_bits.h | 44 ++++++++++++++++++++------------------- target/riscv/cpu.c | 2 +- target/riscv/cpu_helper.c | 4 ++-- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index b42dd4f8d8..8549d77b4f 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -504,27 +504,29 @@ #define DEFAULT_RSTVEC 0x1000 /* Exception causes */ -#define EXCP_NONE -1 /* sentinel value */ -#define RISCV_EXCP_INST_ADDR_MIS 0x0 -#define RISCV_EXCP_INST_ACCESS_FAULT 0x1 -#define RISCV_EXCP_ILLEGAL_INST 0x2 -#define RISCV_EXCP_BREAKPOINT 0x3 -#define RISCV_EXCP_LOAD_ADDR_MIS 0x4 -#define RISCV_EXCP_LOAD_ACCESS_FAULT 0x5 -#define RISCV_EXCP_STORE_AMO_ADDR_MIS 0x6 -#define RISCV_EXCP_STORE_AMO_ACCESS_FAULT 0x7 -#define RISCV_EXCP_U_ECALL 0x8 -#define RISCV_EXCP_S_ECALL 0x9 -#define RISCV_EXCP_VS_ECALL 0xa -#define RISCV_EXCP_M_ECALL 0xb -#define RISCV_EXCP_INST_PAGE_FAULT 0xc /* since: priv-1.10.0 */ -#define RISCV_EXCP_LOAD_PAGE_FAULT 0xd /* since: priv-1.10.0 */ -#define RISCV_EXCP_STORE_PAGE_FAULT 0xf /* since: priv-1.10.0 */ -#define RISCV_EXCP_SEMIHOST 0x10 -#define RISCV_EXCP_INST_GUEST_PAGE_FAULT 0x14 -#define RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT 0x15 -#define RISCV_EXCP_VIRT_INSTRUCTION_FAULT 0x16 -#define RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT 0x17 +typedef enum RISCVException { + RISCV_EXCP_NONE = -1, /* sentinel value */ + RISCV_EXCP_INST_ADDR_MIS = 0x0, + RISCV_EXCP_INST_ACCESS_FAULT = 0x1, + RISCV_EXCP_ILLEGAL_INST = 0x2, + RISCV_EXCP_BREAKPOINT = 0x3, + RISCV_EXCP_LOAD_ADDR_MIS = 0x4, + RISCV_EXCP_LOAD_ACCESS_FAULT = 0x5, + RISCV_EXCP_STORE_AMO_ADDR_MIS = 0x6, + RISCV_EXCP_STORE_AMO_ACCESS_FAULT = 0x7, + RISCV_EXCP_U_ECALL = 0x8, + RISCV_EXCP_S_ECALL = 0x9, + RISCV_EXCP_VS_ECALL = 0xa, + RISCV_EXCP_M_ECALL = 0xb, + RISCV_EXCP_INST_PAGE_FAULT = 0xc, /* since: priv-1.10.0 */ + RISCV_EXCP_LOAD_PAGE_FAULT = 0xd, /* since: priv-1.10.0 */ + RISCV_EXCP_STORE_PAGE_FAULT = 0xf, /* since: priv-1.10.0 */ + RISCV_EXCP_SEMIHOST = 0x10, + RISCV_EXCP_INST_GUEST_PAGE_FAULT = 0x14, + RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT = 0x15, + RISCV_EXCP_VIRT_INSTRUCTION_FAULT = 0x16, + RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT = 0x17, +} RISCVException; #define RISCV_EXCP_INT_FLAG 0x80000000 #define RISCV_EXCP_INT_MASK 0x7fffffff diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6842626c69..e530df9385 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -358,7 +358,7 @@ static void riscv_cpu_reset(DeviceState *dev) env->pc = env->resetvec; env->two_stage_lookup = false; #endif - cs->exception_index = EXCP_NONE; + cs->exception_index = RISCV_EXCP_NONE; env->load_res = -1; set_default_nan_mode(1, &env->fp_status); } diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 503c2559f8..99cc388db9 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -72,7 +72,7 @@ static int riscv_cpu_local_irq_pending(CPURISCVState *env) if (irqs) { return ctz64(irqs); /* since non-zero */ } else { - return EXCP_NONE; /* indicates no pending interrupt */ + return RISCV_EXCP_NONE; /* indicates no pending interrupt */ } } #endif @@ -1069,5 +1069,5 @@ void riscv_cpu_do_interrupt(CPUState *cs) env->two_stage_lookup = false; #endif - cs->exception_index = EXCP_NONE; /* mark handled to qemu */ + cs->exception_index = RISCV_EXCP_NONE; /* mark handled to qemu */ } From patchwork Tue May 11 10:19:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477026 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=ehZZRPFo; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfYyV0CHWz9sSn for ; Tue, 11 May 2021 20:27:30 +1000 (AEST) Received: from localhost ([::1]:48578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPbr-0004OO-Vo for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:27:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVR-0008Ua-0H for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:49 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVJ-0006TG-K5 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728440; x=1652264440; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DVBFNXfYUcIYw0n/vuetOzN6NP8PIXn4wpMgfPrqrDM=; b=ehZZRPFoZqlSnk0UWLEYU/iBHq3Q56FQ+7ZOl7QObhz75OFPFnugI3sD cj+donM9cHtLZje6Ri9nj7mJ9gN8ilsoxgbFqF3KjYANnaOlqWso6lsWo PpkMIe0MLErubIxIif8jsMJqUXH/Hx4l7Iuw5V/YTib2nkNbAYvL4rvuC Jg9Oq8mAWF32pZQxvBH5Pf3Bx0fR48H+LvE2cIy6rJ1c8nNp2lYQBl4p9 4H3NBOUFcBtScgd/EYODhFTbF2kfxjp1X3Rec7SY2N22FdfBa/9nH2QOU v2cky6n9bwloM9pSBbhPKHX3R/h7BPCwI64qo/LojZrogzs4Y7M+0a0eh A==; IronPort-SDR: ClB3hsgneX+5BfXP0esQHM+Umjhqz5O/bqIaMQqNlp/mI5OO8ALWLYA+Tb80NXqOrcOz+Syi6o Xr4hfYkYDZyyv0NzT+YuaNxQYQ9N+hwuOgU6Sg1k7tUG+MrC+Z4Gz44ZThMnfLLqEe0hUIFMz3 NuDUnVc9rs5cLH1YKayQAtxnHFfLw2WAcaNnKLbq869SVsDtiwmFhl6O0ErMhwLxLcFVMYAi9q 41u66+OfqxjNiBhQrUzkMBLdT0N45MwEmxcRKv6yv+rq5yZAH07idJF4yq1hi4xscaYS3QPDau yrs= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735375" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:34 +0800 IronPort-SDR: 7wFhbIgbVvpxlA0EptMBokU3GnKX9frQvYeyb/NhRBV67SrWxGHMLIPkQoTV8SL9mdqRI4y37I R+6A+wiTlO6wxLEaVojQlHxfVVlZdoiO8FZ8LYtJIvOvyo4iOzRCL3Tn/vXLtA/q/2IIlnuxjP IfBmetqk1Xb3kkwXGzOIv+F7BtRO/gbHaufcGes11c6MD0vkzZxvKMG69VHCaO+CVAn320LJLc mYHzz6Xo/Bkqsd0R4w6YMd7UZDz31LykQmhhMerBJ6tI8ZZPzGjWb6Jz9PyzMPLKs/zafVz6hA aPqVoVaLNfSZMZH+n+08eCD+ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:33 -0700 IronPort-SDR: Ftq63d/U2s5E5t0JervPCRONJbji46Qy/PstcoXif+6V0xGQu2KPv28ptpyFAzUkpzq0xzcjVI oJ0sWHxtn1GITVTMLzY1yRev8DujIdHHeQug4lvtLWZLg8W90OMr8WAMdyg7CVQ2pmJphWt9F4 jTH1loPUQBuw6GDCtIph9miiWRc7kldqewepYR0VRzU7yrU92WcSId0D5u3HdE95vh31KQPHrI 6pRioB4UXCpDizzFFo4Jl61q6o0JY5GK0ltX9rJUGs7a5DPE+1Drv47cPB2ZSPLDD3mouWw8Cm ltE= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:32 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 10/42] target/riscv: Use the RISCVException enum for CSR predicates Date: Tue, 11 May 2021 20:19:19 +1000 Message-Id: <20210511101951.165287-11-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: 187261fa671c3a77cf5aa482adb2a558c02a7cad.1617290165.git.alistair.francis@wdc.com --- target/riscv/cpu.h | 3 +- target/riscv/csr.c | 80 +++++++++++++++++++++++++--------------------- 2 files changed, 46 insertions(+), 37 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 8079da8fa8..1dd42a6bc1 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -472,7 +472,8 @@ static inline target_ulong riscv_csr_read(CPURISCVState *env, int csrno) return val; } -typedef int (*riscv_csr_predicate_fn)(CPURISCVState *env, int csrno); +typedef RISCVException (*riscv_csr_predicate_fn)(CPURISCVState *env, + int csrno); typedef int (*riscv_csr_read_fn)(CPURISCVState *env, int csrno, target_ulong *ret_value); typedef int (*riscv_csr_write_fn)(CPURISCVState *env, int csrno, diff --git a/target/riscv/csr.c b/target/riscv/csr.c index de7427d8f8..1938bdca7d 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -35,29 +35,29 @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops) } /* Predicates */ -static int fs(CPURISCVState *env, int csrno) +static RISCVException fs(CPURISCVState *env, int csrno) { #if !defined(CONFIG_USER_ONLY) /* loose check condition for fcsr in vector extension */ if ((csrno == CSR_FCSR) && (env->misa & RVV)) { - return 0; + return RISCV_EXCP_NONE; } if (!env->debugger && !riscv_cpu_fp_enabled(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } #endif - return 0; + return RISCV_EXCP_NONE; } -static int vs(CPURISCVState *env, int csrno) +static RISCVException vs(CPURISCVState *env, int csrno) { if (env->misa & RVV) { - return 0; + return RISCV_EXCP_NONE; } - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } -static int ctr(CPURISCVState *env, int csrno) +static RISCVException ctr(CPURISCVState *env, int csrno) { #if !defined(CONFIG_USER_ONLY) CPUState *cs = env_cpu(env); @@ -65,7 +65,7 @@ static int ctr(CPURISCVState *env, int csrno) if (!cpu->cfg.ext_counters) { /* The Counters extensions is not enabled */ - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } if (riscv_cpu_virt_enabled(env)) { @@ -73,25 +73,25 @@ static int ctr(CPURISCVState *env, int csrno) case CSR_CYCLE: if (!get_field(env->hcounteren, HCOUNTEREN_CY) && get_field(env->mcounteren, HCOUNTEREN_CY)) { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } break; case CSR_TIME: if (!get_field(env->hcounteren, HCOUNTEREN_TM) && get_field(env->mcounteren, HCOUNTEREN_TM)) { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } break; case CSR_INSTRET: if (!get_field(env->hcounteren, HCOUNTEREN_IR) && get_field(env->mcounteren, HCOUNTEREN_IR)) { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } break; case CSR_HPMCOUNTER3...CSR_HPMCOUNTER31: if (!get_field(env->hcounteren, 1 << (csrno - CSR_HPMCOUNTER3)) && get_field(env->mcounteren, 1 << (csrno - CSR_HPMCOUNTER3))) { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } break; } @@ -100,93 +100,101 @@ static int ctr(CPURISCVState *env, int csrno) case CSR_CYCLEH: if (!get_field(env->hcounteren, HCOUNTEREN_CY) && get_field(env->mcounteren, HCOUNTEREN_CY)) { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } break; case CSR_TIMEH: if (!get_field(env->hcounteren, HCOUNTEREN_TM) && get_field(env->mcounteren, HCOUNTEREN_TM)) { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } break; case CSR_INSTRETH: if (!get_field(env->hcounteren, HCOUNTEREN_IR) && get_field(env->mcounteren, HCOUNTEREN_IR)) { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } break; case CSR_HPMCOUNTER3H...CSR_HPMCOUNTER31H: if (!get_field(env->hcounteren, 1 << (csrno - CSR_HPMCOUNTER3H)) && get_field(env->mcounteren, 1 << (csrno - CSR_HPMCOUNTER3H))) { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } break; } } } #endif - return 0; + return RISCV_EXCP_NONE; } -static int ctr32(CPURISCVState *env, int csrno) +static RISCVException ctr32(CPURISCVState *env, int csrno) { if (!riscv_cpu_is_32bit(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } return ctr(env, csrno); } #if !defined(CONFIG_USER_ONLY) -static int any(CPURISCVState *env, int csrno) +static RISCVException any(CPURISCVState *env, int csrno) { - return 0; + return RISCV_EXCP_NONE; } -static int any32(CPURISCVState *env, int csrno) +static RISCVException any32(CPURISCVState *env, int csrno) { if (!riscv_cpu_is_32bit(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } return any(env, csrno); } -static int smode(CPURISCVState *env, int csrno) +static RISCVException smode(CPURISCVState *env, int csrno) { - return -!riscv_has_ext(env, RVS); + if (riscv_has_ext(env, RVS)) { + return RISCV_EXCP_NONE; + } + + return RISCV_EXCP_ILLEGAL_INST; } -static int hmode(CPURISCVState *env, int csrno) +static RISCVException hmode(CPURISCVState *env, int csrno) { if (riscv_has_ext(env, RVS) && riscv_has_ext(env, RVH)) { /* Hypervisor extension is supported */ if ((env->priv == PRV_S && !riscv_cpu_virt_enabled(env)) || env->priv == PRV_M) { - return 0; + return RISCV_EXCP_NONE; } else { - return -RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } } - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } -static int hmode32(CPURISCVState *env, int csrno) +static RISCVException hmode32(CPURISCVState *env, int csrno) { if (!riscv_cpu_is_32bit(env)) { - return 0; + return RISCV_EXCP_NONE; } return hmode(env, csrno); } -static int pmp(CPURISCVState *env, int csrno) +static RISCVException pmp(CPURISCVState *env, int csrno) { - return -!riscv_feature(env, RISCV_FEATURE_PMP); + if (riscv_feature(env, RISCV_FEATURE_PMP)) { + return RISCV_EXCP_NONE; + } + + return RISCV_EXCP_ILLEGAL_INST; } #endif @@ -1293,8 +1301,8 @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, return -RISCV_EXCP_ILLEGAL_INST; } ret = csr_ops[csrno].predicate(env, csrno); - if (ret < 0) { - return ret; + if (ret != RISCV_EXCP_NONE) { + return -ret; } /* execute combined read/write operation if it exists */ From patchwork Tue May 11 10:19:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=o80IkdQ9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZ0J0Vx2z9t0k for ; Tue, 11 May 2021 20:29:04 +1000 (AEST) Received: from localhost ([::1]:53432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPdO-0007gW-24 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:29:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVU-00005Z-KH for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:52 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVO-0006X1-9Y for qemu-devel@nongnu.org; Tue, 11 May 2021 06:20:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728444; x=1652264444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bxuh/HYpFG5/VX0DQF6fAKC2S1UYsYT0FobkIKhBegY=; b=o80IkdQ9MPyD8rl2rA0GUoAfhfqJ5lvpMcbeHmEgHc30vevTH5igFtd6 7iFdSyu92mRfxM0vDqb6m0H4VZEm6b08YxJ93SWrAEFrF+Vw+d3iKV/vW 8HtLjew+eWXGZimwpVo8N9hxNGEcGSqsEI5DLea9mVE/2k+WbkQW5TxFD sQ4okQh/KhqXrx2zk02BAIXxigKvFQDr1sq7f5UafEyIIP+/6/lj5IPEo GdEm8vvqKLBkgtm4S7XVLCCFL/HXwbcy/yAB/nT88Mg7uRcK4udA11Q2O J0XKdpQqDf0fUbFCa1OaEumfDU4YuNLgRgBVvOiXw4/8RCK4CwaLAO+cE w==; IronPort-SDR: 16MHsPKVBgprYnAT1fA8gp2JMPPxhkIC2gcPyyCoCK7HB2Dms6Ep4AyEamLh5p5dTes//Nym2k HjOxIWbiLDsSVMpFxx/7MVL7jCFyWJi6W4LKFUbbdVgkA6y+QEJmAjHDqAggJlbskWM+CsDyw0 X0OUMpgfrz6gL6w2cTmbCMwfJcncijQykUZ6sjBFEImORO7j2ad6lN5p+9DZa/L8xq++mQhIgn p9nVMBCdqAQTmx5+k7QLbNwkzd2iYjk91P6hGSmz7u5972X05ifAK837ZED5FbZ09R1r/TURDT YpY= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735377" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:37 +0800 IronPort-SDR: lFxkTi9LjqTJCLcPRJN4ysDPGU2sSfcPTs0JIYoASTWSvBcsfa25V03h/HoMOEqu0RvMz7tnBZ SgCNlkV8/ci6OWAoA+mf37ubW4KX1NHIVydc/8jGYZI2trgUXOs4CvX4picm0EFAqVERquh5ce jWmYwIQ7cnKNo+rdgyw3/9OXYtwncTR++14HYOif8aVNxFbWS9W0JibILE33NiwLKpi0TTdZyg 0cfXOFdT28QaeC8kDL5pLwvOlEBtQXD0onRVcyznfkxeySk8cBtuX+qvKAxHvjuFur7BGmQKid +FfWMz2zq1s2ky9d4izkP0dg Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:36 -0700 IronPort-SDR: wogQaDCvVa6nanJCjlmZHuoEUGNuu6ce4UDjFBya6MxN/QkkmqO4ZLQmlw/D6NEttknbqb5jHM FOZhdxDW43cDxige6UmXuuq6nvQE0mmYi57jTf957y4z8qJV7gc4sWEpyJ6CanaHuh699XPCC/ VdLfEyLm0nDS5QxtDAVOKbmFKvXYYjmhpSK2SSxYwUq2dGduRvRYHCFaHk4KLmyNyy6qm2nDNZ pL/e4LQnzq+V3km5QnKtaSEWXjW0AvogeqvRCNdZGk+8IHiQDsAT6RNUwDVAu9/K5ti5ZCU0Ii Pvs= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:35 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 11/42] target/riscv: Fix 32-bit HS mode access permissions Date: Tue, 11 May 2021 20:19:20 +1000 Message-Id: <20210511101951.165287-12-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: cb1ef2061547dc9028ce3cf4f6622588f9c09149.1617290165.git.alistair.francis@wdc.com --- target/riscv/csr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 1938bdca7d..6a39c4aa96 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -181,7 +181,11 @@ static RISCVException hmode(CPURISCVState *env, int csrno) static RISCVException hmode32(CPURISCVState *env, int csrno) { if (!riscv_cpu_is_32bit(env)) { - return RISCV_EXCP_NONE; + if (riscv_cpu_virt_enabled(env)) { + return RISCV_EXCP_ILLEGAL_INST; + } else { + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + } } return hmode(env, csrno); From patchwork Tue May 11 10:19:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=g84GhHPS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZ4f4g4zz9t0k for ; Tue, 11 May 2021 20:32:50 +1000 (AEST) Received: from localhost ([::1]:34828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPh2-0005wD-6L for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:32:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVd-0000C7-Fb for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:03 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVS-0006TG-MT for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728449; x=1652264449; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e0YzdJesqAIbUxCt8y8Vw5TYLDaNlmu3rc5rIc1NNq0=; b=g84GhHPSeePAB9jr6wKRA0nVwJfSEul5vT1uMO6Zk37ipMqe7joJuOeb afct+8U+gShqJzd214ybJoruc7Am5DXgd0UVPlHiXkxbwZA4+0BgcAp6B eYALIgfLsLkTQYf4Ts7eIqBoMooGsPkZ/rBkTqKVeWIEAErZ7KdrumP9W O7ciuEtsP3PgOx2S4GscltD3FwCH1LHCyZyOZC6HLz4ONljehQ2EOqZwJ nLuCRwlgTG0DCSL/LmPWnL3/O0XCR79cMMmvJkq7iJov2UAwl5f3J57AO OEzRF1fcVlszb3yFtLHJsyjyhHVSJrE7+aK+X+9Zt49ibt7EunYdG2r4M w==; IronPort-SDR: trYMVWd0DZafShuIPsKhy468duND/GiX/Zl6+MHhYBrpWYxPWw0c+7rL4lxunkX1ZD9WugVlse 1Crl3ys4oxRh6rjKmLJWwRu6QKaVh6fmST4tbns9oi8/bmofTYY9LNcDjKsEBbW8F1e9CBeuAT +CtJfE9pwRd2fHK47SPx2fzZCKdU6qnTDtXY4zTeGmgwJi6TdSQtEISDCcOD6wQp+Hh60QK9IW m0LRQppPV9tvSviZtHvp6bHQ1gFw9URdaZI4E4G9aJ85ApZzxI99w7jv58Q/XTbJ2ISVo+SfN0 xyk= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735382" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:40 +0800 IronPort-SDR: 8Mh8FmV66/jr3wy2xTc0yyGMtTPn8TrEtllzFYQ1IkxUiJ6s8Q6FlVSExv48FxH20+uXh8A78y d/gw4/B7eCHaoW0U0fkXOeYSrGSPzlE3CKOiH1fYvFr2nGZ8vEVZXp3+YuX+k+pjSmlx3duIMr UMS3tzYrffdFTq1m6V34u0QpzxGtDakUTSz/xRVuI7Ymj0gM8ylHg6RGOtqpF86fbeak+qESL6 2NQGWXgp81XwJmKHrTeS3G9SBp/z1O4Md15kddGWjvsJfAH8TDaMg/pLfodm7B03VJlqOkRXwy 8UivQWnFPT0OgY8CqdX6abuv Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:40 -0700 IronPort-SDR: QMABttJDDPhxszBXRGoecyq//fTaQCQTltKdjUvqxS4wYLF+GgngiZC0aHHVVr3LYbbxGYmiCM 76glvCJBtv1Lx9hwbm5QarXEad5XwagJl6iawOlHkUnLZ8fTk2zxDnN8CVx+ITMKujd+sXV7Fv EyZdPJEtAhBSXHZ+3zdfsaksLm98brDCWh8QLbLV5OYBwIMUlIVxmgIyF0O6WRWZ3KaACLbArp SmRXeZrAmHuSAkhPrfQZkDrns99CNhAJglrujbmFaLwkefBUfl6lY14xDAlZ/7hcoH2rZQDYgA Kko= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:38 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 12/42] target/riscv: Use the RISCVException enum for CSR operations Date: Tue, 11 May 2021 20:19:21 +1000 Message-Id: <20210511101951.165287-13-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: 8566c4c271723f27f3ae8fc2429f906a459f17ce.1617290165.git.alistair.francis@wdc.com --- target/riscv/cpu.h | 14 +- target/riscv/csr.c | 629 +++++++++++++++++++++++++++------------------ 2 files changed, 382 insertions(+), 261 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 1dd42a6bc1..a7b8876ea0 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -474,12 +474,14 @@ static inline target_ulong riscv_csr_read(CPURISCVState *env, int csrno) typedef RISCVException (*riscv_csr_predicate_fn)(CPURISCVState *env, int csrno); -typedef int (*riscv_csr_read_fn)(CPURISCVState *env, int csrno, - target_ulong *ret_value); -typedef int (*riscv_csr_write_fn)(CPURISCVState *env, int csrno, - target_ulong new_value); -typedef int (*riscv_csr_op_fn)(CPURISCVState *env, int csrno, - target_ulong *ret_value, target_ulong new_value, target_ulong write_mask); +typedef RISCVException (*riscv_csr_read_fn)(CPURISCVState *env, int csrno, + target_ulong *ret_value); +typedef RISCVException (*riscv_csr_write_fn)(CPURISCVState *env, int csrno, + target_ulong new_value); +typedef RISCVException (*riscv_csr_op_fn)(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, + target_ulong write_mask); typedef struct { const char *name; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 6a39c4aa96..f67eaf4042 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -203,57 +203,62 @@ static RISCVException pmp(CPURISCVState *env, int csrno) #endif /* User Floating-Point CSRs */ -static int read_fflags(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_fflags(CPURISCVState *env, int csrno, + target_ulong *val) { #if !defined(CONFIG_USER_ONLY) if (!env->debugger && !riscv_cpu_fp_enabled(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } #endif *val = riscv_cpu_get_fflags(env); - return 0; + return RISCV_EXCP_NONE; } -static int write_fflags(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_fflags(CPURISCVState *env, int csrno, + target_ulong val) { #if !defined(CONFIG_USER_ONLY) if (!env->debugger && !riscv_cpu_fp_enabled(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } env->mstatus |= MSTATUS_FS; #endif riscv_cpu_set_fflags(env, val & (FSR_AEXC >> FSR_AEXC_SHIFT)); - return 0; + return RISCV_EXCP_NONE; } -static int read_frm(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_frm(CPURISCVState *env, int csrno, + target_ulong *val) { #if !defined(CONFIG_USER_ONLY) if (!env->debugger && !riscv_cpu_fp_enabled(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } #endif *val = env->frm; - return 0; + return RISCV_EXCP_NONE; } -static int write_frm(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_frm(CPURISCVState *env, int csrno, + target_ulong val) { #if !defined(CONFIG_USER_ONLY) if (!env->debugger && !riscv_cpu_fp_enabled(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } env->mstatus |= MSTATUS_FS; #endif env->frm = val & (FSR_RD >> FSR_RD_SHIFT); - return 0; + return RISCV_EXCP_NONE; } -static int read_fcsr(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_fcsr(CPURISCVState *env, int csrno, + target_ulong *val) { #if !defined(CONFIG_USER_ONLY) if (!env->debugger && !riscv_cpu_fp_enabled(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } #endif *val = (riscv_cpu_get_fflags(env) << FSR_AEXC_SHIFT) @@ -262,14 +267,15 @@ static int read_fcsr(CPURISCVState *env, int csrno, target_ulong *val) *val |= (env->vxrm << FSR_VXRM_SHIFT) | (env->vxsat << FSR_VXSAT_SHIFT); } - return 0; + return RISCV_EXCP_NONE; } -static int write_fcsr(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_fcsr(CPURISCVState *env, int csrno, + target_ulong val) { #if !defined(CONFIG_USER_ONLY) if (!env->debugger && !riscv_cpu_fp_enabled(env)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } env->mstatus |= MSTATUS_FS; #endif @@ -279,59 +285,68 @@ static int write_fcsr(CPURISCVState *env, int csrno, target_ulong val) env->vxsat = (val & FSR_VXSAT) >> FSR_VXSAT_SHIFT; } riscv_cpu_set_fflags(env, (val & FSR_AEXC) >> FSR_AEXC_SHIFT); - return 0; + return RISCV_EXCP_NONE; } -static int read_vtype(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vtype(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vtype; - return 0; + return RISCV_EXCP_NONE; } -static int read_vl(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vl(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vl; - return 0; + return RISCV_EXCP_NONE; } -static int read_vxrm(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vxrm(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vxrm; - return 0; + return RISCV_EXCP_NONE; } -static int write_vxrm(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vxrm(CPURISCVState *env, int csrno, + target_ulong val) { env->vxrm = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_vxsat(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vxsat(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vxsat; - return 0; + return RISCV_EXCP_NONE; } -static int write_vxsat(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vxsat(CPURISCVState *env, int csrno, + target_ulong val) { env->vxsat = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_vstart(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vstart(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vstart; - return 0; + return RISCV_EXCP_NONE; } -static int write_vstart(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vstart(CPURISCVState *env, int csrno, + target_ulong val) { env->vstart = val; - return 0; + return RISCV_EXCP_NONE; } /* User Timers and Counters */ -static int read_instret(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_instret(CPURISCVState *env, int csrno, + target_ulong *val) { #if !defined(CONFIG_USER_ONLY) if (icount_enabled()) { @@ -342,10 +357,11 @@ static int read_instret(CPURISCVState *env, int csrno, target_ulong *val) #else *val = cpu_get_host_ticks(); #endif - return 0; + return RISCV_EXCP_NONE; } -static int read_instreth(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_instreth(CPURISCVState *env, int csrno, + target_ulong *val) { #if !defined(CONFIG_USER_ONLY) if (icount_enabled()) { @@ -356,46 +372,50 @@ static int read_instreth(CPURISCVState *env, int csrno, target_ulong *val) #else *val = cpu_get_host_ticks() >> 32; #endif - return 0; + return RISCV_EXCP_NONE; } #if defined(CONFIG_USER_ONLY) -static int read_time(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_time(CPURISCVState *env, int csrno, + target_ulong *val) { *val = cpu_get_host_ticks(); - return 0; + return RISCV_EXCP_NONE; } -static int read_timeh(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_timeh(CPURISCVState *env, int csrno, + target_ulong *val) { *val = cpu_get_host_ticks() >> 32; - return 0; + return RISCV_EXCP_NONE; } #else /* CONFIG_USER_ONLY */ -static int read_time(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_time(CPURISCVState *env, int csrno, + target_ulong *val) { uint64_t delta = riscv_cpu_virt_enabled(env) ? env->htimedelta : 0; if (!env->rdtime_fn) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } *val = env->rdtime_fn(env->rdtime_fn_arg) + delta; - return 0; + return RISCV_EXCP_NONE; } -static int read_timeh(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_timeh(CPURISCVState *env, int csrno, + target_ulong *val) { uint64_t delta = riscv_cpu_virt_enabled(env) ? env->htimedelta : 0; if (!env->rdtime_fn) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } *val = (env->rdtime_fn(env->rdtime_fn_arg) + delta) >> 32; - return 0; + return RISCV_EXCP_NONE; } /* Machine constants */ @@ -449,22 +469,26 @@ static const char valid_vm_1_10_64[16] = { }; /* Machine Information Registers */ -static int read_zero(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_zero(CPURISCVState *env, int csrno, + target_ulong *val) { - return *val = 0; + *val = 0; + return RISCV_EXCP_NONE; } -static int read_mhartid(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mhartid(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mhartid; - return 0; + return RISCV_EXCP_NONE; } /* Machine Trap Setup */ -static int read_mstatus(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mstatus(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mstatus; - return 0; + return RISCV_EXCP_NONE; } static int validate_vm(CPURISCVState *env, target_ulong vm) @@ -476,7 +500,8 @@ static int validate_vm(CPURISCVState *env, target_ulong vm) } } -static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mstatus(CPURISCVState *env, int csrno, + target_ulong val) { uint64_t mstatus = env->mstatus; uint64_t mask = 0; @@ -507,16 +532,18 @@ static int write_mstatus(CPURISCVState *env, int csrno, target_ulong val) mstatus = set_field(mstatus, MSTATUS_SD, dirty); env->mstatus = mstatus; - return 0; + return RISCV_EXCP_NONE; } -static int read_mstatush(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mstatush(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mstatus >> 32; - return 0; + return RISCV_EXCP_NONE; } -static int write_mstatush(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mstatush(CPURISCVState *env, int csrno, + target_ulong val) { uint64_t valh = (uint64_t)val << 32; uint64_t mask = MSTATUS_MPV | MSTATUS_GVA; @@ -527,26 +554,28 @@ static int write_mstatush(CPURISCVState *env, int csrno, target_ulong val) env->mstatus = (env->mstatus & ~mask) | (valh & mask); - return 0; + return RISCV_EXCP_NONE; } -static int read_misa(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_misa(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->misa; - return 0; + return RISCV_EXCP_NONE; } -static int write_misa(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_misa(CPURISCVState *env, int csrno, + target_ulong val) { if (!riscv_feature(env, RISCV_FEATURE_MISA)) { /* drop write to misa */ - return 0; + return RISCV_EXCP_NONE; } /* 'I' or 'E' must be present */ if (!(val & (RVI | RVE))) { /* It is not, drop write to misa */ - return 0; + return RISCV_EXCP_NONE; } /* 'E' excludes all other extensions */ @@ -554,7 +583,7 @@ static int write_misa(CPURISCVState *env, int csrno, target_ulong val) /* when we support 'E' we can do "val = RVE;" however * for now we just drop writes if 'E' is present. */ - return 0; + return RISCV_EXCP_NONE; } /* Mask extensions that are not supported by this hart */ @@ -585,55 +614,63 @@ static int write_misa(CPURISCVState *env, int csrno, target_ulong val) env->misa = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_medeleg(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_medeleg(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->medeleg; - return 0; + return RISCV_EXCP_NONE; } -static int write_medeleg(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_medeleg(CPURISCVState *env, int csrno, + target_ulong val) { env->medeleg = (env->medeleg & ~delegable_excps) | (val & delegable_excps); - return 0; + return RISCV_EXCP_NONE; } -static int read_mideleg(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mideleg(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mideleg; - return 0; + return RISCV_EXCP_NONE; } -static int write_mideleg(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mideleg(CPURISCVState *env, int csrno, + target_ulong val) { env->mideleg = (env->mideleg & ~delegable_ints) | (val & delegable_ints); if (riscv_has_ext(env, RVH)) { env->mideleg |= VS_MODE_INTERRUPTS; } - return 0; + return RISCV_EXCP_NONE; } -static int read_mie(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mie(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mie; - return 0; + return RISCV_EXCP_NONE; } -static int write_mie(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mie(CPURISCVState *env, int csrno, + target_ulong val) { env->mie = (env->mie & ~all_ints) | (val & all_ints); - return 0; + return RISCV_EXCP_NONE; } -static int read_mtvec(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mtvec(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mtvec; - return 0; + return RISCV_EXCP_NONE; } -static int write_mtvec(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mtvec(CPURISCVState *env, int csrno, + target_ulong val) { /* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ if ((val & 3) < 2) { @@ -641,72 +678,83 @@ static int write_mtvec(CPURISCVState *env, int csrno, target_ulong val) } else { qemu_log_mask(LOG_UNIMP, "CSR_MTVEC: reserved mode not supported\n"); } - return 0; + return RISCV_EXCP_NONE; } -static int read_mcounteren(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mcounteren(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mcounteren; - return 0; + return RISCV_EXCP_NONE; } -static int write_mcounteren(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mcounteren(CPURISCVState *env, int csrno, + target_ulong val) { env->mcounteren = val; - return 0; + return RISCV_EXCP_NONE; } /* Machine Trap Handling */ -static int read_mscratch(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mscratch(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mscratch; - return 0; + return RISCV_EXCP_NONE; } -static int write_mscratch(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mscratch(CPURISCVState *env, int csrno, + target_ulong val) { env->mscratch = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_mepc(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mepc(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mepc; - return 0; + return RISCV_EXCP_NONE; } -static int write_mepc(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mepc(CPURISCVState *env, int csrno, + target_ulong val) { env->mepc = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_mcause(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mcause(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mcause; - return 0; + return RISCV_EXCP_NONE; } -static int write_mcause(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mcause(CPURISCVState *env, int csrno, + target_ulong val) { env->mcause = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_mtval(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mtval(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mtval; - return 0; + return RISCV_EXCP_NONE; } -static int write_mtval(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mtval(CPURISCVState *env, int csrno, + target_ulong val) { env->mtval = val; - return 0; + return RISCV_EXCP_NONE; } -static int rmw_mip(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask) +static RISCVException rmw_mip(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, target_ulong write_mask) { RISCVCPU *cpu = env_archcpu(env); /* Allow software control of delegable interrupts not claimed by hardware */ @@ -723,42 +771,47 @@ static int rmw_mip(CPURISCVState *env, int csrno, target_ulong *ret_value, *ret_value = old_mip; } - return 0; + return RISCV_EXCP_NONE; } /* Supervisor Trap Setup */ -static int read_sstatus(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_sstatus(CPURISCVState *env, int csrno, + target_ulong *val) { target_ulong mask = (sstatus_v1_10_mask); *val = env->mstatus & mask; - return 0; + return RISCV_EXCP_NONE; } -static int write_sstatus(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_sstatus(CPURISCVState *env, int csrno, + target_ulong val) { target_ulong mask = (sstatus_v1_10_mask); target_ulong newval = (env->mstatus & ~mask) | (val & mask); return write_mstatus(env, CSR_MSTATUS, newval); } -static int read_vsie(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vsie(CPURISCVState *env, int csrno, + target_ulong *val) { /* Shift the VS bits to their S bit location in vsie */ *val = (env->mie & env->hideleg & VS_MODE_INTERRUPTS) >> 1; - return 0; + return RISCV_EXCP_NONE; } -static int read_sie(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_sie(CPURISCVState *env, int csrno, + target_ulong *val) { if (riscv_cpu_virt_enabled(env)) { read_vsie(env, CSR_VSIE, val); } else { *val = env->mie & env->mideleg; } - return 0; + return RISCV_EXCP_NONE; } -static int write_vsie(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vsie(CPURISCVState *env, int csrno, + target_ulong val) { /* Shift the S bits to their VS bit location in mie */ target_ulong newval = (env->mie & ~VS_MODE_INTERRUPTS) | @@ -776,16 +829,18 @@ static int write_sie(CPURISCVState *env, int csrno, target_ulong val) write_mie(env, CSR_MIE, newval); } - return 0; + return RISCV_EXCP_NONE; } -static int read_stvec(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_stvec(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->stvec; - return 0; + return RISCV_EXCP_NONE; } -static int write_stvec(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_stvec(CPURISCVState *env, int csrno, + target_ulong val) { /* bits [1:0] encode mode; 0 = direct, 1 = vectored, 2 >= reserved */ if ((val & 3) < 2) { @@ -793,72 +848,83 @@ static int write_stvec(CPURISCVState *env, int csrno, target_ulong val) } else { qemu_log_mask(LOG_UNIMP, "CSR_STVEC: reserved mode not supported\n"); } - return 0; + return RISCV_EXCP_NONE; } -static int read_scounteren(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_scounteren(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->scounteren; - return 0; + return RISCV_EXCP_NONE; } -static int write_scounteren(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_scounteren(CPURISCVState *env, int csrno, + target_ulong val) { env->scounteren = val; - return 0; + return RISCV_EXCP_NONE; } /* Supervisor Trap Handling */ -static int read_sscratch(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_sscratch(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->sscratch; - return 0; + return RISCV_EXCP_NONE; } -static int write_sscratch(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_sscratch(CPURISCVState *env, int csrno, + target_ulong val) { env->sscratch = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_sepc(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_sepc(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->sepc; - return 0; + return RISCV_EXCP_NONE; } -static int write_sepc(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_sepc(CPURISCVState *env, int csrno, + target_ulong val) { env->sepc = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_scause(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_scause(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->scause; - return 0; + return RISCV_EXCP_NONE; } -static int write_scause(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_scause(CPURISCVState *env, int csrno, + target_ulong val) { env->scause = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_stval(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_stval(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->stval; - return 0; + return RISCV_EXCP_NONE; } -static int write_stval(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_stval(CPURISCVState *env, int csrno, + target_ulong val) { env->stval = val; - return 0; + return RISCV_EXCP_NONE; } -static int rmw_vsip(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask) +static RISCVException rmw_vsip(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, target_ulong write_mask) { /* Shift the S bits to their VS bit location in mip */ int ret = rmw_mip(env, 0, ret_value, new_value << 1, @@ -869,8 +935,9 @@ static int rmw_vsip(CPURISCVState *env, int csrno, target_ulong *ret_value, return ret; } -static int rmw_sip(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask) +static RISCVException rmw_sip(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, target_ulong write_mask) { int ret; @@ -886,32 +953,34 @@ static int rmw_sip(CPURISCVState *env, int csrno, target_ulong *ret_value, } /* Supervisor Protection and Translation */ -static int read_satp(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_satp(CPURISCVState *env, int csrno, + target_ulong *val) { if (!riscv_feature(env, RISCV_FEATURE_MMU)) { *val = 0; - return 0; + return RISCV_EXCP_NONE; } if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } else { *val = env->satp; } - return 0; + return RISCV_EXCP_NONE; } -static int write_satp(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_satp(CPURISCVState *env, int csrno, + target_ulong val) { if (!riscv_feature(env, RISCV_FEATURE_MMU)) { - return 0; + return RISCV_EXCP_NONE; } if (validate_vm(env, get_field(val, SATP_MODE)) && ((val ^ env->satp) & (SATP_MODE | SATP_ASID | SATP_PPN))) { if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } else { if ((val ^ env->satp) & SATP_ASID) { tlb_flush(env_cpu(env)); @@ -919,11 +988,12 @@ static int write_satp(CPURISCVState *env, int csrno, target_ulong val) env->satp = val; } } - return 0; + return RISCV_EXCP_NONE; } /* Hypervisor Extensions */ -static int read_hstatus(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_hstatus(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->hstatus; if (!riscv_cpu_is_32bit(env)) { @@ -932,10 +1002,11 @@ static int read_hstatus(CPURISCVState *env, int csrno, target_ulong *val) } /* We only support little endian */ *val = set_field(*val, HSTATUS_VSBE, 0); - return 0; + return RISCV_EXCP_NONE; } -static int write_hstatus(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_hstatus(CPURISCVState *env, int csrno, + target_ulong val) { env->hstatus = val; if (!riscv_cpu_is_32bit(env) && get_field(val, HSTATUS_VSXL) != 2) { @@ -944,35 +1015,40 @@ static int write_hstatus(CPURISCVState *env, int csrno, target_ulong val) if (get_field(val, HSTATUS_VSBE) != 0) { qemu_log_mask(LOG_UNIMP, "QEMU does not support big endian guests."); } - return 0; + return RISCV_EXCP_NONE; } -static int read_hedeleg(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_hedeleg(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->hedeleg; - return 0; + return RISCV_EXCP_NONE; } -static int write_hedeleg(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_hedeleg(CPURISCVState *env, int csrno, + target_ulong val) { env->hedeleg = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_hideleg(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_hideleg(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->hideleg; - return 0; + return RISCV_EXCP_NONE; } -static int write_hideleg(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_hideleg(CPURISCVState *env, int csrno, + target_ulong val) { env->hideleg = val; - return 0; + return RISCV_EXCP_NONE; } -static int rmw_hvip(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask) +static RISCVException rmw_hvip(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, target_ulong write_mask) { int ret = rmw_mip(env, 0, ret_value, new_value, write_mask & hvip_writable_mask); @@ -982,8 +1058,9 @@ static int rmw_hvip(CPURISCVState *env, int csrno, target_ulong *ret_value, return ret; } -static int rmw_hip(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask) +static RISCVException rmw_hip(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, target_ulong write_mask) { int ret = rmw_mip(env, 0, ret_value, new_value, write_mask & hip_writable_mask); @@ -993,103 +1070,119 @@ static int rmw_hip(CPURISCVState *env, int csrno, target_ulong *ret_value, return ret; } -static int read_hie(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_hie(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mie & VS_MODE_INTERRUPTS; - return 0; + return RISCV_EXCP_NONE; } -static int write_hie(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_hie(CPURISCVState *env, int csrno, + target_ulong val) { target_ulong newval = (env->mie & ~VS_MODE_INTERRUPTS) | (val & VS_MODE_INTERRUPTS); return write_mie(env, CSR_MIE, newval); } -static int read_hcounteren(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_hcounteren(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->hcounteren; - return 0; + return RISCV_EXCP_NONE; } -static int write_hcounteren(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_hcounteren(CPURISCVState *env, int csrno, + target_ulong val) { env->hcounteren = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_hgeie(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_hgeie(CPURISCVState *env, int csrno, + target_ulong *val) { qemu_log_mask(LOG_UNIMP, "No support for a non-zero GEILEN."); - return 0; + return RISCV_EXCP_NONE; } -static int write_hgeie(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_hgeie(CPURISCVState *env, int csrno, + target_ulong val) { qemu_log_mask(LOG_UNIMP, "No support for a non-zero GEILEN."); - return 0; + return RISCV_EXCP_NONE; } -static int read_htval(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_htval(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->htval; - return 0; + return RISCV_EXCP_NONE; } -static int write_htval(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_htval(CPURISCVState *env, int csrno, + target_ulong val) { env->htval = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_htinst(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_htinst(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->htinst; - return 0; + return RISCV_EXCP_NONE; } -static int write_htinst(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_htinst(CPURISCVState *env, int csrno, + target_ulong val) { - return 0; + return RISCV_EXCP_NONE; } -static int read_hgeip(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_hgeip(CPURISCVState *env, int csrno, + target_ulong *val) { qemu_log_mask(LOG_UNIMP, "No support for a non-zero GEILEN."); - return 0; + return RISCV_EXCP_NONE; } -static int write_hgeip(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_hgeip(CPURISCVState *env, int csrno, + target_ulong val) { qemu_log_mask(LOG_UNIMP, "No support for a non-zero GEILEN."); - return 0; + return RISCV_EXCP_NONE; } -static int read_hgatp(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_hgatp(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->hgatp; - return 0; + return RISCV_EXCP_NONE; } -static int write_hgatp(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_hgatp(CPURISCVState *env, int csrno, + target_ulong val) { env->hgatp = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_htimedelta(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_htimedelta(CPURISCVState *env, int csrno, + target_ulong *val) { if (!env->rdtime_fn) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } *val = env->htimedelta; - return 0; + return RISCV_EXCP_NONE; } -static int write_htimedelta(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_htimedelta(CPURISCVState *env, int csrno, + target_ulong val) { if (!env->rdtime_fn) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } if (riscv_cpu_is_32bit(env)) { @@ -1097,162 +1190,185 @@ static int write_htimedelta(CPURISCVState *env, int csrno, target_ulong val) } else { env->htimedelta = val; } - return 0; + return RISCV_EXCP_NONE; } -static int read_htimedeltah(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_htimedeltah(CPURISCVState *env, int csrno, + target_ulong *val) { if (!env->rdtime_fn) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } *val = env->htimedelta >> 32; - return 0; + return RISCV_EXCP_NONE; } -static int write_htimedeltah(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_htimedeltah(CPURISCVState *env, int csrno, + target_ulong val) { if (!env->rdtime_fn) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } env->htimedelta = deposit64(env->htimedelta, 32, 32, (uint64_t)val); - return 0; + return RISCV_EXCP_NONE; } /* Virtual CSR Registers */ -static int read_vsstatus(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vsstatus(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vsstatus; - return 0; + return RISCV_EXCP_NONE; } -static int write_vsstatus(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vsstatus(CPURISCVState *env, int csrno, + target_ulong val) { uint64_t mask = (target_ulong)-1; env->vsstatus = (env->vsstatus & ~mask) | (uint64_t)val; - return 0; + return RISCV_EXCP_NONE; } static int read_vstvec(CPURISCVState *env, int csrno, target_ulong *val) { *val = env->vstvec; - return 0; + return RISCV_EXCP_NONE; } -static int write_vstvec(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vstvec(CPURISCVState *env, int csrno, + target_ulong val) { env->vstvec = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_vsscratch(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vsscratch(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vsscratch; - return 0; + return RISCV_EXCP_NONE; } -static int write_vsscratch(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vsscratch(CPURISCVState *env, int csrno, + target_ulong val) { env->vsscratch = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_vsepc(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vsepc(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vsepc; - return 0; + return RISCV_EXCP_NONE; } -static int write_vsepc(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vsepc(CPURISCVState *env, int csrno, + target_ulong val) { env->vsepc = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_vscause(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vscause(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vscause; - return 0; + return RISCV_EXCP_NONE; } -static int write_vscause(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vscause(CPURISCVState *env, int csrno, + target_ulong val) { env->vscause = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_vstval(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vstval(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vstval; - return 0; + return RISCV_EXCP_NONE; } -static int write_vstval(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vstval(CPURISCVState *env, int csrno, + target_ulong val) { env->vstval = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_vsatp(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_vsatp(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->vsatp; - return 0; + return RISCV_EXCP_NONE; } -static int write_vsatp(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_vsatp(CPURISCVState *env, int csrno, + target_ulong val) { env->vsatp = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_mtval2(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mtval2(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mtval2; - return 0; + return RISCV_EXCP_NONE; } -static int write_mtval2(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mtval2(CPURISCVState *env, int csrno, + target_ulong val) { env->mtval2 = val; - return 0; + return RISCV_EXCP_NONE; } -static int read_mtinst(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_mtinst(CPURISCVState *env, int csrno, + target_ulong *val) { *val = env->mtinst; - return 0; + return RISCV_EXCP_NONE; } -static int write_mtinst(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_mtinst(CPURISCVState *env, int csrno, + target_ulong val) { env->mtinst = val; - return 0; + return RISCV_EXCP_NONE; } /* Physical Memory Protection */ -static int read_pmpcfg(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_pmpcfg(CPURISCVState *env, int csrno, + target_ulong *val) { *val = pmpcfg_csr_read(env, csrno - CSR_PMPCFG0); - return 0; + return RISCV_EXCP_NONE; } -static int write_pmpcfg(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_pmpcfg(CPURISCVState *env, int csrno, + target_ulong val) { pmpcfg_csr_write(env, csrno - CSR_PMPCFG0, val); - return 0; + return RISCV_EXCP_NONE; } -static int read_pmpaddr(CPURISCVState *env, int csrno, target_ulong *val) +static RISCVException read_pmpaddr(CPURISCVState *env, int csrno, + target_ulong *val) { *val = pmpaddr_csr_read(env, csrno - CSR_PMPADDR0); - return 0; + return RISCV_EXCP_NONE; } -static int write_pmpaddr(CPURISCVState *env, int csrno, target_ulong val) +static RISCVException write_pmpaddr(CPURISCVState *env, int csrno, + target_ulong val) { pmpaddr_csr_write(env, csrno - CSR_PMPADDR0, val); - return 0; + return RISCV_EXCP_NONE; } #endif @@ -1311,18 +1427,21 @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, /* execute combined read/write operation if it exists */ if (csr_ops[csrno].op) { - return csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask); + ret = csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask); + if (ret != RISCV_EXCP_NONE) { + return -ret; + } + return 0; } /* if no accessor exists then return failure */ if (!csr_ops[csrno].read) { return -RISCV_EXCP_ILLEGAL_INST; } - /* read old value */ ret = csr_ops[csrno].read(env, csrno, &old_value); - if (ret < 0) { - return ret; + if (ret != RISCV_EXCP_NONE) { + return -ret; } /* write value if writable and write mask set, otherwise drop writes */ @@ -1330,8 +1449,8 @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, new_value = (old_value & ~write_mask) | (new_value & write_mask); if (csr_ops[csrno].write) { ret = csr_ops[csrno].write(env, csrno, new_value); - if (ret < 0) { - return ret; + if (ret != RISCV_EXCP_NONE) { + return -ret; } } } From patchwork Tue May 11 10:19:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=fzqrnPl7; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZ5W3293z9sWl for ; Tue, 11 May 2021 20:33:35 +1000 (AEST) Received: from localhost ([::1]:36324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPhl-0006wt-De for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:33:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVh-0000Fh-BO for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:05 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVV-0006V6-Fi for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728453; x=1652264453; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lTWmHLSJ/1zeLY+vPzxAeYV0kg5U5ryvxxKuI70GuU4=; b=fzqrnPl7KWmkn420hD5Lgu8mmmAVoju0mrYCpvGWiLpW9/WaHW4DaY3O TrXp1yKjMrSMjgPK6IhoX6TsxVmdwjWPMxlr6JV69N2+ZXuJeMeD61ETj fSR8K3AzRHLE0xfFE5Y4kWhfcpXlwJGcjPkmfuxcYQskafriw9QE8dEEP gAZjzEUp6h6jlE+Gc+3xCCw5J7RqabJ1mHFYcYnOQ7BaGnPPIvBNOeAis TLgzq6n27avf9HQQwhpnwHBCOPu2OMKNjicV6tRFTkIM3Sq0YmTeve4Yu 3uAvA0+deQAfa7TH/MevpEUQWkAaw1ruPyhM7DViZ46P6gaNj+M6vQU/4 w==; IronPort-SDR: 0ct/gPSCei1CLSjbacEGUMrz/zOgjQ0A4Pd8cOboBF1JbXRpdQmODp7Qn1sZCUdEaiYq823Gm6 6ClmsFaQP4p0vM1GtK1WsUkUUeTBIrXgoypRRZ8xY8TfXV+CQ7zn107fc9PP4AX2doGY8TskBn WPWPy2ehzcyyISzC59BFfqwFxSLwhjcNkCfXFfrLaBektSXoHe7AuIfzgHlu5fytsf3pDExvmY dshHHw084DmHaY8Igj8UhUI5sD8iCagPS7XQ7ikTjgud1somH8UOG4K/nEQB6342XSEbuMoKru Z/8= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735386" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:43 +0800 IronPort-SDR: LyUyb7y2XvuPvvzP2BIZRwBUx6R8JdJ8GbvHw0WFbUhYp0jLJEBum2YMEqMRamfSIRo4K6Z3Fu H6rkCLItaG6pV0FmepabS6mdZKRV5lKPwJDqs49wInKbPXIPK5Be0E9fcF3dpfkHzJyQJS+07O atGCpitIxftSVJz9UsXcgdiIpvjYrXFkyFv7aditoEFKUxYaH8EQY6ixbvfki/BbeY4vMhBj+U QrZ9yh93DCdlp+4KfrCySSB9lKjf1z5G3AIr75KSDiMQ+JIfMF6Nwl19AEtZDt34zvccnLCUhz sWrv+KzqaqvygTuRyjqzFvwe Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:43 -0700 IronPort-SDR: KrdjlYgkwjpxZUmi0ZA4E7gkvwgGixTvHxFgTR1XoCo6fy8wwLdubl2BawhdMpmPWeBORUurhm 0AdDvRRZw+FDNGcqDf5NhJPoQSMj07kFo8yaHBBGxuwbq6VmfB89E/CBb1FQVddrZzignMSdJl YNALZJWTCmEW2n/44Ixgri2BTiVqLlMYzFyjTxDKCsBc0ADYajHNG318vBZptJ1u42RGmiRrpR qFqN0pPUJV5CDh8FQ2qbYI9/k+dsVHL2EPUxEUCp0QMVMBoXEaJzKOpQCy6BxmZ7jskUeW83Ym Y7I= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:42 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 13/42] target/riscv: Use RISCVException enum for CSR access Date: Tue, 11 May 2021 20:19:22 +1000 Message-Id: <20210511101951.165287-14-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: 302b208f40373557fa11b351b5c9f43039ca8ea3.1617290165.git.alistair.francis@wdc.com --- target/riscv/cpu.h | 11 +++++++---- target/riscv/csr.c | 37 ++++++++++++++++++------------------- target/riscv/gdbstub.c | 8 ++++---- target/riscv/op_helper.c | 18 +++++++++--------- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index a7b8876ea0..842d3ab810 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -454,10 +454,13 @@ static inline void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, *pflags = flags; } -int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask); -int riscv_csrrw_debug(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask); +RISCVException riscv_csrrw(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, target_ulong write_mask); +RISCVException riscv_csrrw_debug(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, + target_ulong write_mask); static inline void riscv_csr_write(CPURISCVState *env, int csrno, target_ulong val) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index f67eaf4042..f0a74f0eb8 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1382,10 +1382,11 @@ static RISCVException write_pmpaddr(CPURISCVState *env, int csrno, * csrrc <-> riscv_csrrw(env, csrno, ret_value, 0, value); */ -int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask) +RISCVException riscv_csrrw(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, target_ulong write_mask) { - int ret; + RISCVException ret; target_ulong old_value; RISCVCPU *cpu = env_archcpu(env); @@ -1407,41 +1408,37 @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, if ((write_mask && read_only) || (!env->debugger && (effective_priv < get_field(csrno, 0x300)))) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } #endif /* ensure the CSR extension is enabled. */ if (!cpu->cfg.ext_icsr) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } /* check predicate */ if (!csr_ops[csrno].predicate) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } ret = csr_ops[csrno].predicate(env, csrno); if (ret != RISCV_EXCP_NONE) { - return -ret; + return ret; } /* execute combined read/write operation if it exists */ if (csr_ops[csrno].op) { - ret = csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask); - if (ret != RISCV_EXCP_NONE) { - return -ret; - } - return 0; + return csr_ops[csrno].op(env, csrno, ret_value, new_value, write_mask); } /* if no accessor exists then return failure */ if (!csr_ops[csrno].read) { - return -RISCV_EXCP_ILLEGAL_INST; + return RISCV_EXCP_ILLEGAL_INST; } /* read old value */ ret = csr_ops[csrno].read(env, csrno, &old_value); if (ret != RISCV_EXCP_NONE) { - return -ret; + return ret; } /* write value if writable and write mask set, otherwise drop writes */ @@ -1450,7 +1447,7 @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, if (csr_ops[csrno].write) { ret = csr_ops[csrno].write(env, csrno, new_value); if (ret != RISCV_EXCP_NONE) { - return -ret; + return ret; } } } @@ -1460,17 +1457,19 @@ int riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, *ret_value = old_value; } - return 0; + return RISCV_EXCP_NONE; } /* * Debugger support. If not in user mode, set env->debugger before the * riscv_csrrw call and clear it after the call. */ -int riscv_csrrw_debug(CPURISCVState *env, int csrno, target_ulong *ret_value, - target_ulong new_value, target_ulong write_mask) +RISCVException riscv_csrrw_debug(CPURISCVState *env, int csrno, + target_ulong *ret_value, + target_ulong new_value, + target_ulong write_mask) { - int ret; + RISCVException ret; #if !defined(CONFIG_USER_ONLY) env->debugger = true; #endif diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 5f96b7ea2a..ca78682cf4 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -71,7 +71,7 @@ static int riscv_gdb_get_fpu(CPURISCVState *env, GByteArray *buf, int n) */ result = riscv_csrrw_debug(env, n - 32, &val, 0, 0); - if (result == 0) { + if (result == RISCV_EXCP_NONE) { return gdb_get_regl(buf, val); } } @@ -94,7 +94,7 @@ static int riscv_gdb_set_fpu(CPURISCVState *env, uint8_t *mem_buf, int n) */ result = riscv_csrrw_debug(env, n - 32, NULL, val, -1); - if (result == 0) { + if (result == RISCV_EXCP_NONE) { return sizeof(target_ulong); } } @@ -108,7 +108,7 @@ static int riscv_gdb_get_csr(CPURISCVState *env, GByteArray *buf, int n) int result; result = riscv_csrrw_debug(env, n, &val, 0, 0); - if (result == 0) { + if (result == RISCV_EXCP_NONE) { return gdb_get_regl(buf, val); } } @@ -122,7 +122,7 @@ static int riscv_gdb_set_csr(CPURISCVState *env, uint8_t *mem_buf, int n) int result; result = riscv_csrrw_debug(env, n, NULL, val, -1); - if (result == 0) { + if (result == RISCV_EXCP_NONE) { return sizeof(target_ulong); } } diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index f0bbd73ca5..170b494227 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -41,10 +41,10 @@ target_ulong helper_csrrw(CPURISCVState *env, target_ulong src, target_ulong csr) { target_ulong val = 0; - int ret = riscv_csrrw(env, csr, &val, src, -1); + RISCVException ret = riscv_csrrw(env, csr, &val, src, -1); - if (ret < 0) { - riscv_raise_exception(env, -ret, GETPC()); + if (ret != RISCV_EXCP_NONE) { + riscv_raise_exception(env, ret, GETPC()); } return val; } @@ -53,10 +53,10 @@ target_ulong helper_csrrs(CPURISCVState *env, target_ulong src, target_ulong csr, target_ulong rs1_pass) { target_ulong val = 0; - int ret = riscv_csrrw(env, csr, &val, -1, rs1_pass ? src : 0); + RISCVException ret = riscv_csrrw(env, csr, &val, -1, rs1_pass ? src : 0); - if (ret < 0) { - riscv_raise_exception(env, -ret, GETPC()); + if (ret != RISCV_EXCP_NONE) { + riscv_raise_exception(env, ret, GETPC()); } return val; } @@ -65,10 +65,10 @@ target_ulong helper_csrrc(CPURISCVState *env, target_ulong src, target_ulong csr, target_ulong rs1_pass) { target_ulong val = 0; - int ret = riscv_csrrw(env, csr, &val, 0, rs1_pass ? src : 0); + RISCVException ret = riscv_csrrw(env, csr, &val, 0, rs1_pass ? src : 0); - if (ret < 0) { - riscv_raise_exception(env, -ret, GETPC()); + if (ret != RISCV_EXCP_NONE) { + riscv_raise_exception(env, ret, GETPC()); } return val; } From patchwork Tue May 11 10:19:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=mljbZxKR; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZ5g25LLz9sWl for ; Tue, 11 May 2021 20:33:43 +1000 (AEST) Received: from localhost ([::1]:37094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPht-0007WT-6j for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:33:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVj-0000Jm-Lc for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:11 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVf-0006X1-G6 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728462; x=1652264462; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YgQJw7SjjqySGEU0p7K3VL1nspJ4011lufPoQdJ7iF0=; b=mljbZxKRh+/93BSZ0CmEsI9mf6ZCv5xjXRI5riP+mltvSYsii2E7rCg1 vJSkHM7CKUQJHLHF3xZ/d+DycToE+f0HgNsAs9ZS/Xlk//SmSsFRlHkHk iprW4+wOGd0MWAcGx74d7us3QARPxIfgBMY1cLXhpn/ESMjYJSgYZBqH/ vryw2ORhEj40PoDyeGa/JFZxhsBI/lmckm1NBBBsiCKFconWeUGcXYBSf 0DDq1T06lFzluuzPZ4DSDMtZTMHLLqKqp/CSpxhjm08mzRUO9ZAVRs2Xe pwBI0ZaJ+FKK7kCK60Umd2cDa217qFvgLaKbHjFeXymhgwiRZVrwR/23u w==; IronPort-SDR: HF9grLUzryuz3n5lz8Zuor6rjL6Wei0ZJk0ppm+0DtzFXLZxW8UPI/sFtB0Z/dSkLAi7i0yYHd RdCClAul+0MMbr+M1wb5NoOSJD25MFiDCdVVVcUXLJ7jmwjR5tMGaAoT/aWu8VNLlCA3SyV6C/ AubSmAMeLSOZqDBzaBxnI+KL36bupmgCOInORcIm3KT9KSNHU+f3ompfEBM46+zJ6Q9IsljWWx J4Szmofg0bJ3NUC0TZs7g1keqDmcoE5WPzfYSZ3+4FoAtHxtk6RMfM/YM95rD0idmXOJRjbuMm HIA= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735389" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:47 +0800 IronPort-SDR: XAnVxEF5C3+pUudpYDgPj7q/enVmp6bc71mc0VX2vomzZ40vpzAZZpPXHdWIzkleTg55v7F50s Zo76C3lG/Y3/BvuRiNYFG0EyUKc2Ilobw6EA6qk3wUv8DIUeEBlezzInX5kwx1G6tgwe+QktMS OZa/WOLcwtrTfbDHxDSlpVErjggNF7Lf5zVVBrdry8bP98fkqPv3Jj1IO8zTKbCc1+wdR2iRjp zsFp5wnHe3NfT5P4N1Ik0JMUdbtT4IYJo8oS/fpWaSDT8ij1SiOthYSphvZOB9tpAYR/e+PsnV ZQIlq4gVo7pwjdATxuF5TMTV Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:47 -0700 IronPort-SDR: g46sVhfQqGDgqq+vPEBe2vTi9r3tKoAxNh6VODK9qsIiFX/9rhiMFucJSx1uvQEWomdeOuBB3z 01t0vSgyDOmJeI1+Vyj+IyOJ5m5Bsa7Y8Pck1lKjDADdpVE4vJM/s2kauKK3fCRLWDYv13pZF7 cnxg5+nosmytC5Haybrsfsfyp9JfmBgSR0QhniV9R9B6a0j9MhsE9qNkW+xyrLDwRoEs5xvLAO 6KV1Kdwg3keYWliBxIbkeo/13MgijzXfG+9avKUcYktJRqpKw72D2QahNu3XbgIDgF36a0Pid6 +Bg= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:46 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 14/42] MAINTAINERS: Update the RISC-V CPU Maintainers Date: Tue, 11 May 2021 20:19:23 +1000 Message-Id: <20210511101951.165287-15-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bastian Koppelmann , Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, Alistair Francis , alistair23@gmail.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Update the RISC-V maintainers by removing Sagar and Bastian who haven't been involved recently. Also add Bin who has been helping with reviews. Signed-off-by: Alistair Francis Acked-by: Bin Meng Acked-by: Bastian Koppelmann Reviewed-by: Philippe Mathieu-Daudé Message-id: 6564ba829c40ad9aa7d28f43be69d8eb5cf4b56b.1617749142.git.alistair.francis@wdc.com --- MAINTAINERS | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 7aaa304b1e..3ace764d29 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -295,9 +295,8 @@ F: tests/acceptance/machine_ppc.py RISC-V TCG CPUs M: Palmer Dabbelt -M: Alistair Francis -M: Sagar Karandikar -M: Bastian Koppelmann +M: Alistair Francis +M: Bin Meng L: qemu-riscv@nongnu.org S: Supported F: target/riscv/ From patchwork Tue May 11 10:19:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=BMZ0DY93; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZBR0KBfz9rx6 for ; Tue, 11 May 2021 20:37:51 +1000 (AEST) Received: from localhost ([::1]:44718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPlt-0004So-1h for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:37:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVs-0000bX-SG for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:16 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVp-0006TG-7g for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728471; x=1652264471; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CCgwUukf0mol48E+b6OjDya1sHpuv6iWQ9PgPgArBlM=; b=BMZ0DY93+XW3tJtTjIgVXNEXkkuSaKC5YQZfPOJ8EFqwxAyOXXcVpL5s y3gsYnDtT+XnPV6uB8oEnkGydDIsNUU9PubHDA/M7KWf6h6W+dH1fqph4 +5WODTXvjSSeuMamQSLeMO2gN3QivG1FFbLUwHRxiotd6J7wchNjVYIIq jHb3WAuLJvW0KsxqUMpRoYaKN7rD9r1a+TOniMuyXEipeGZewWs+TV84a B1TcVCVZoQt2hgNrhmpsfeuetrUApPQkBN8n9psJhjb9okO9JGmoQRMMQ J3I4+yL9r86nphaEuq3OiIuy/aqMs2Yy/di9oTOUvVdKI/bMEX3gfwK2k w==; IronPort-SDR: jiSxbDcKxRJIKOX1yhObLjGDcQKUl6Dd1XfGBJsPkD0y1p/oPd/fONSo/Ord1Dt+vD+kIhtylg pixsoern8lFHqZTZOjZx6gO8lnGtDch0DO/5crDMYWPEZHAoWjGY4kJqYLQ43bVVjieH/sj7AS iezQHQ/hJH+LPU3USFf3txxEppXGnAQefqEa7xGtH8fE4piPfFmVlwwSLpfO20widm4hChFIPn b5ADPSBC8UAcm3JazVUObjzf3VGZZwL9KsEWIsVk7OY+joqN1UeI6EJwYlg6vQYkjanaIVDQRw VbU= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735391" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:51 +0800 IronPort-SDR: EmWgKZbXIzRUpXldkuIk9bgKMKCyVX3YkH/MwcGJyEHtcOnyHl1SCr3rGLot1XCtkgdhGbk+fX LamhhuY8/fGUwpGHMWD9UBuj2CiZOqygSOpgtEgEfGLoDBRUnPxDP451RTWtuo0/J2or6iaHoc NvbgJ/x4okfzIgrov32KJboYJO0WOx8Z+3ZByVbpNyP3uqN6cpV6GpWOryCgZtP3yVQFOxrI2C tGJNEhANW1NgjU0dXRB1ASds6XFeIf1tygxWVxobxWE0Z84zrhb18k4YWwRDaEjkBWzPafN7ZJ UBCKwKOAAvs/M8skb+WEnK6h Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:50 -0700 IronPort-SDR: xOpD93eXPHWFqOOtioJlAYWyaaB1ItWKj0OISja7oWhkGw3y2DLD53wCw5lREmI7tGC7ukLTZi Pqk+9v4gu1X0ajTdfFxOF/uX33uKVYMqrQH2sTlwJNRSa8A8b70+pEQYnjvhIJsv4W46Rqkgi1 qEc4C1ZZ51dguLzT0OZdPsd0Zxxd4JqNELvQY0n5aKeD5DwPfRs4dCFbtZNz9NTY0XUAMjWa1x 0VqLPkQIgETtAUVKJSZCmyHsRT1QTMWeDT+VovekAja9b8BSTnHw5xHyohZWT15amIh6/CymJV 5Bk= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:49 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 15/42] hw/opentitan: Update the interrupt layout Date: Tue, 11 May 2021 20:19:24 +1000 Message-Id: <20210511101951.165287-16-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Update the OpenTitan interrupt layout to match the latest OpenTitan bitstreams. This involves changing the Ibex PLIC memory layout and the UART interrupts. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: e92b696f1809c9fa4410da2e9f23c414db5a6960.1617202791.git.alistair.francis@wdc.com --- include/hw/riscv/opentitan.h | 16 ++++++++-------- hw/intc/ibex_plic.c | 20 ++++++++++---------- hw/riscv/opentitan.c | 8 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h index a5ea3a5e4e..aab9bc9245 100644 --- a/include/hw/riscv/opentitan.h +++ b/include/hw/riscv/opentitan.h @@ -82,14 +82,14 @@ enum { }; enum { - IBEX_UART_RX_PARITY_ERR_IRQ = 0x28, - IBEX_UART_RX_TIMEOUT_IRQ = 0x27, - IBEX_UART_RX_BREAK_ERR_IRQ = 0x26, - IBEX_UART_RX_FRAME_ERR_IRQ = 0x25, - IBEX_UART_RX_OVERFLOW_IRQ = 0x24, - IBEX_UART_TX_EMPTY_IRQ = 0x23, - IBEX_UART_RX_WATERMARK_IRQ = 0x22, - IBEX_UART_TX_WATERMARK_IRQ = 0x21, + IBEX_UART0_RX_PARITY_ERR_IRQ = 8, + IBEX_UART0_RX_TIMEOUT_IRQ = 7, + IBEX_UART0_RX_BREAK_ERR_IRQ = 6, + IBEX_UART0_RX_FRAME_ERR_IRQ = 5, + IBEX_UART0_RX_OVERFLOW_IRQ = 4, + IBEX_UART0_TX_EMPTY_IRQ = 3, + IBEX_UART0_RX_WATERMARK_IRQ = 2, + IBEX_UART0_TX_WATERMARK_IRQ = 1, }; #endif diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c index c1b72fcab0..edf76e4f61 100644 --- a/hw/intc/ibex_plic.c +++ b/hw/intc/ibex_plic.c @@ -225,23 +225,23 @@ static void ibex_plic_irq_request(void *opaque, int irq, int level) static Property ibex_plic_properties[] = { DEFINE_PROP_UINT32("num-cpus", IbexPlicState, num_cpus, 1), - DEFINE_PROP_UINT32("num-sources", IbexPlicState, num_sources, 80), + DEFINE_PROP_UINT32("num-sources", IbexPlicState, num_sources, 176), DEFINE_PROP_UINT32("pending-base", IbexPlicState, pending_base, 0), - DEFINE_PROP_UINT32("pending-num", IbexPlicState, pending_num, 3), + DEFINE_PROP_UINT32("pending-num", IbexPlicState, pending_num, 6), - DEFINE_PROP_UINT32("source-base", IbexPlicState, source_base, 0x0c), - DEFINE_PROP_UINT32("source-num", IbexPlicState, source_num, 3), + DEFINE_PROP_UINT32("source-base", IbexPlicState, source_base, 0x18), + DEFINE_PROP_UINT32("source-num", IbexPlicState, source_num, 6), - DEFINE_PROP_UINT32("priority-base", IbexPlicState, priority_base, 0x18), - DEFINE_PROP_UINT32("priority-num", IbexPlicState, priority_num, 80), + DEFINE_PROP_UINT32("priority-base", IbexPlicState, priority_base, 0x30), + DEFINE_PROP_UINT32("priority-num", IbexPlicState, priority_num, 177), - DEFINE_PROP_UINT32("enable-base", IbexPlicState, enable_base, 0x200), - DEFINE_PROP_UINT32("enable-num", IbexPlicState, enable_num, 3), + DEFINE_PROP_UINT32("enable-base", IbexPlicState, enable_base, 0x300), + DEFINE_PROP_UINT32("enable-num", IbexPlicState, enable_num, 6), - DEFINE_PROP_UINT32("threshold-base", IbexPlicState, threshold_base, 0x20c), + DEFINE_PROP_UINT32("threshold-base", IbexPlicState, threshold_base, 0x318), - DEFINE_PROP_UINT32("claim-base", IbexPlicState, claim_base, 0x210), + DEFINE_PROP_UINT32("claim-base", IbexPlicState, claim_base, 0x31c), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index dc9dea117e..557d73726b 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -148,16 +148,16 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart), 0, memmap[IBEX_DEV_UART].base); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), 0, qdev_get_gpio_in(DEVICE(&s->plic), - IBEX_UART_TX_WATERMARK_IRQ)); + IBEX_UART0_TX_WATERMARK_IRQ)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), 1, qdev_get_gpio_in(DEVICE(&s->plic), - IBEX_UART_RX_WATERMARK_IRQ)); + IBEX_UART0_RX_WATERMARK_IRQ)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), 2, qdev_get_gpio_in(DEVICE(&s->plic), - IBEX_UART_TX_EMPTY_IRQ)); + IBEX_UART0_TX_EMPTY_IRQ)); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), 3, qdev_get_gpio_in(DEVICE(&s->plic), - IBEX_UART_RX_OVERFLOW_IRQ)); + IBEX_UART0_RX_OVERFLOW_IRQ)); create_unimplemented_device("riscv.lowrisc.ibex.gpio", memmap[IBEX_DEV_GPIO].base, memmap[IBEX_DEV_GPIO].size); From patchwork Tue May 11 10:19:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=jQJvsyzQ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZ3c1g7pz9sSn for ; Tue, 11 May 2021 20:31:56 +1000 (AEST) Received: from localhost ([::1]:33454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPgA-0004z0-6G for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:31:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVu-0000j0-TI for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:19 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVt-0006V6-7O for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728476; x=1652264476; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=otQOSwcYVr7RAj/nWvFHEWoMMJh10b7Yi4YNSpL0/3M=; b=jQJvsyzQdkOEhBfV64Qkr7LaymZ8IajNoBfmFef8pb/uQ4KA+Aijpyzg T9o3WY8ZUCdGTf3do6d1/iaxQdALVQluMA0x38dRTYCYWVXGv86oqwTBq 4jMma9oWdAZc9e0MEesUMrJ1y/yJ/CTZH7FxXYdaQebs70N3SnHsyupmD qj2g5nIhqHRg3U/guU2s32UpA4pWE6sC3SJwCD4XTKI63WSfY1rTQqWMN GXInL6LBOy3Kq1FBrnwU6N9ioATG0BlLnrLc0hhlCwF5ICBA0olDF1JWZ qMqonWuZvl5z7mqwY+cHw6OhrXcVl9ukVqGmm+tz6UfY4WRKvIyR84sv0 Q==; IronPort-SDR: u2aI8KtZdjQ7K/OgRhXkwqKPNc4m0Xu93zwgutUou5OUi72I01oNwCFQmt7s0Fipppgqyre352 xsXuOhHucLCmHE8gYDljc+TIzkWt346yaQb6azO+BKek9Pu6CXLE5NwZGC3Fo2duN4JqnZJ9PM S0HR9cEwTG0TMDSNzL5mf8RxrTb/aLvc6gsWsAP1ADOMEi/nyOSc/vLtNQnwboH3zpBzqF5W3B nk0A7rQP4CEUSadq9E4xCbr5Vgq0odjvcg+wF3QnBlWzdUT7qeqwudih8KARXyt47A62r+NyGN pWA= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735393" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:54 +0800 IronPort-SDR: efO8vcwkrs8SNk8uWXk0H9hjVku1htzBL3hfK6A7DfcRVKDqFpOsCyE2nCzVXUQO5GwlJuR+SW 5s4rR58T9q3DbzJnyIrobpst2g3PtlA2MXJzAmStwHkryP0wuua128wrUIN7Awd2jsGLeOI9Dv i7HVQ3BeJcyEDrX0AtIZFdp9ctMC8YD6bdMyfWT0ihbsJ0ToytzLqMYnWYPG1peK7Whc/VZp5d eaUMpruUxrp4JyadwKmsi4qTJh5CaVh3rt+ARziU7bEr139cMOCjDdFR7ZMypDwjS3HUcPaS7N bZEVhIvYCpoQMWT8+MVXLcrV Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:53 -0700 IronPort-SDR: 3JFu3rzpO7lEo4R9wKNRsHVXYPewsY1YzFdn5fPi8WUGXTsDsL+AgCwj3MiynF+j271bBIYmqB e9KfLJVIrRR4f+KpJ3sRuozxBLbZpz0Rr27DsFVo1SeiWvw6b9j1apkuPsrohjbPcV7YIdPMYB Vv58MQOWpFbpVHniBGwTIpuYi3jyf8ANszIrKGv2Rl+xFO1NWX+D58ganTKbEUDc384Zma+EB4 yK+CfegCwVE9KybhQTXqpbEhbXpPulBRxoIIG9TV84Kupjjx/DhIz6MLSlRJcJalzUgsGxttbJ iB8= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:52 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 16/42] hw/riscv: Enable VIRTIO_VGA for RISC-V virt machine Date: Tue, 11 May 2021 20:19:25 +1000 Message-Id: <20210511101951.165287-17-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" imply VIRTIO_VGA for the virt machine, this fixes the following error when specifying `-vga virtio` as a command line argument: qemu-system-riscv64: Virtio VGA not available Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 7ac26fafee8bd59d2a0640f3233f8ad1ab270e1e.1617367317.git.alistair.francis@wdc.com --- hw/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index a0225716b5..86957ec7b0 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -32,6 +32,7 @@ config SHAKTI_C config RISCV_VIRT bool imply PCI_DEVICES + imply VIRTIO_VGA imply TEST_DEVICES select GOLDFISH_RTC select MSI_NONBROKEN From patchwork Tue May 11 10:19:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477047 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=GT+Ewpel; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZF45rznz9sW5 for ; Tue, 11 May 2021 20:40:08 +1000 (AEST) Received: from localhost ([::1]:51678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPo6-0000mc-Qu for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:40:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPW5-0000xI-PN for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:31 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPVx-0006X1-JG for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728480; x=1652264480; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yFRLTCdAcyqhfcygvlqGQ7lXNGX9GsANpwxchwLWEg0=; b=GT+EwpeloRar5M1I171SsdVPrumbVSEvYA9EeEgl6EElhJp+FaH93oIC aIkKp2fPIiodNRqz66AFjJIvKK57TG4mwELN4mXM8kXHjpY41mpScqJBl TWRBD3nBzr5U2Tik59Q2ffJf/ACwJb2+2I2Rk1U4yDoG3jSgNx+TWSUaM 7yb84nqmpqyZ0WQZITO7JZjFIo9X5VQFy/1BBjtfBMJWZfftYeh9yfK1P Hk1cs8OkJGflcHk8gF6RPo/q8EnQ/RkSGFSxSKvG6JoLEkRC5n34NYflC yTGh1rGzifEtDCyfyTbdlaOtkhTYISX/1avNjGnpgyDxeoj0WAdxmH5xZ A==; IronPort-SDR: cMussp7QcIrC8TrHS7BQzB/ebDuGpYxMTK/hS8zQ22xmV1jjJXQeOHnmlTbVAbONxde8uiD2s8 clOHHNSkk5rf4iy1Le76S99gP6gLjMjZ3HqGFB0sSQIcFX4rA4tL72Ieiny0z/44T17U4rlttV Z7RxMNMIgvYuZjScEtTu+hZSZ71A6LqBZSFYG+Ss7PGQk6A1l9qjVMdZNexAw2P5KyeFgZ5aXu j/ZJNjfapAzWU+odmqf7KSTOP/HqtpAhqxAHHDrsFTl2DGcHisv4lQM5cgceu2EhSyqUsmjJoX 4aI= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735397" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:57 +0800 IronPort-SDR: DC780OlySbHWSXkTpjB23bcdJlxEyxm70klgabuVbXdk7yHr6ansnc3wPIzy5RR+AHHYZaHZ3Q uisFroCQWlfyCKnzvJWMctK1/CPh5QdiaQKqqAI7I3NRMQJIWL4P2I7zIUC85I9TWVB5nzBwkI GESekVQXx9Xmd0Fxt1ETNTjxf69LGmQMv6O8TUBqq4wt+mZsyQw1bEJJPo3KsixjZ/Aehi/c5R mZ0Wnox3AujJU0ft9CK7hC+JMKyggBP3IDRq2zGcktcR/VHCgunFvNS4VI3Rc+p1FcyxREoEJV zeixoWYM+Xx1v808MZUn+AIU Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:56 -0700 IronPort-SDR: VT4lCKtvdGENIOMUB2rBl4Tbu5V000ZhYkryxaeowS3/vnmhFfGT9OntpeasnFsQ0InLywOF1d HupOaxM1Ge3m6I6wPswQ3Aod31nII1r6oFP8TldZLYxfXUTXNBC7/TSlvy29P1ug9w4J4kgsMM mhIPU4/2qJb82Tqw6a1/L/0uFoIADOcwwnCySymk0PY1fJnO2kpbiuQGo3ezvHeI2mq3rTgCgr ovRfp9O57QDKYlMJ5n/Pb5pbMM205AHSPAbgzIAkesh3t2DQlDdEUz7eQL5gOnEJXcn3Ch4z36 sRM= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:55 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 17/42] riscv: don't look at SUM when accessing memory from a debugger context Date: Tue, 11 May 2021 20:19:26 +1000 Message-Id: <20210511101951.165287-18-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org, Jade Fink Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jade Fink Previously the qemu monitor and gdbstub looked at SUM and refused to perform accesses to user memory if it is off, which was an impediment to debugging. Signed-off-by: Jade Fink Reviewed-by: Alistair Francis Message-id: 20210406113109.1031033-1-qemu@jade.fyi Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 99cc388db9..659ca8a173 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -342,12 +342,14 @@ static int get_physical_address_pmp(CPURISCVState *env, int *prot, * @first_stage: Are we in first stage translation? * Second stage is used for hypervisor guest translation * @two_stage: Are we going to perform two stage translation + * @is_debug: Is this access from a debugger or the monitor? */ static int get_physical_address(CPURISCVState *env, hwaddr *physical, int *prot, target_ulong addr, target_ulong *fault_pte_addr, int access_type, int mmu_idx, - bool first_stage, bool two_stage) + bool first_stage, bool two_stage, + bool is_debug) { /* NOTE: the env->pc value visible here will not be * correct, but the value visible to the exception handler @@ -416,7 +418,7 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, widened = 2; } /* status.SUM will be ignored if execute on background */ - sum = get_field(env->mstatus, MSTATUS_SUM) || use_background; + sum = get_field(env->mstatus, MSTATUS_SUM) || use_background || is_debug; switch (vm) { case VM_1_10_SV32: levels = 2; ptidxbits = 10; ptesize = 4; break; @@ -475,7 +477,8 @@ restart: /* Do the second stage translation on the base PTE address. */ int vbase_ret = get_physical_address(env, &vbase, &vbase_prot, base, NULL, MMU_DATA_LOAD, - mmu_idx, false, true); + mmu_idx, false, true, + is_debug); if (vbase_ret != TRANSLATE_SUCCESS) { if (fault_pte_addr) { @@ -666,13 +669,13 @@ hwaddr riscv_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) int mmu_idx = cpu_mmu_index(&cpu->env, false); if (get_physical_address(env, &phys_addr, &prot, addr, NULL, 0, mmu_idx, - true, riscv_cpu_virt_enabled(env))) { + true, riscv_cpu_virt_enabled(env), true)) { return -1; } if (riscv_cpu_virt_enabled(env)) { if (get_physical_address(env, &phys_addr, &prot, phys_addr, NULL, - 0, mmu_idx, false, true)) { + 0, mmu_idx, false, true, true)) { return -1; } } @@ -768,7 +771,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, /* Two stage lookup */ ret = get_physical_address(env, &pa, &prot, address, &env->guest_phys_fault_addr, access_type, - mmu_idx, true, true); + mmu_idx, true, true, false); /* * A G-stage exception may be triggered during two state lookup. @@ -790,7 +793,8 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, im_address = pa; ret = get_physical_address(env, &pa, &prot2, im_address, NULL, - access_type, mmu_idx, false, true); + access_type, mmu_idx, false, true, + false); qemu_log_mask(CPU_LOG_MMU, "%s 2nd-stage address=%" VADDR_PRIx " ret %d physical " @@ -825,7 +829,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, } else { /* Single stage lookup */ ret = get_physical_address(env, &pa, &prot, address, NULL, - access_type, mmu_idx, true, false); + access_type, mmu_idx, true, false, false); qemu_log_mask(CPU_LOG_MMU, "%s address=%" VADDR_PRIx " ret %d physical " From patchwork Tue May 11 10:19:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=DEd2RiKO; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZ9y5X1Nz9sW5 for ; Tue, 11 May 2021 20:37:26 +1000 (AEST) Received: from localhost ([::1]:43272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPlU-0003TA-Fz for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:37:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWC-0000yx-4r for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:36 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPW3-0006TG-H5 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728485; x=1652264485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eBNCyqtOfzNeogyxUlf2PGSAY8yQsrhavKYqjK6n7uE=; b=DEd2RiKOq0ZSy0DHgRQidfRoLKWsdxeqZkjaPFMB0C/IcC+Z5hGgUSwC T5xPgquqUC1bte5gGOpADfCPxv3CFd4hqdkhEnkx7/3Mo6WI1WnjKyNHM Bcup2Z/wcUVDuEN//lbYQfnszm3O4wVEmX6D/4hzGVUcX0GGiWCydcpA8 ibKQVvpFkHJz5rwqqQSTP4DltW9vtJRaiUBpmhxZnlSxfBaYPMjmC1NH0 JBC4Zxm5RhhgtCnTi3o7i40rwaPdjqma36Al6CbeBvRJaMSDGJXWCNv1y W6HJ9dwjb0cH+3fnIIMk3ABjiOBwvz/jOkPIfFW+sYrcg7nkZWmSJQRS3 w==; IronPort-SDR: JfGFTOijgSX9aBqlopLj5DsLUJ0yS5VWjLrxJz3b7CmSwkHWMfRs2ztvtGa/+x8T68ajKEfIVl bS7sHpqosbXoOlrSxsfaresnJPhu5IS/kFVHIYUiqZYvF6w5/dXKiP0EDTqI/OWzpgceVb1BNH yr/EJ7lwqVlxe4PRoCh0vBXVsJrxCSl/8bTFkgXu3zySwr8/616TFeccmrHmjaPUUfy0veG5ig kYq3ChZaDNuhK4xzmrKaBpwm7a0DnIyqQ9UMI9RcNAOt8i60kCfL8IhVYsiyZuEYXCKThk+Ji5 2EU= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735402" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:20:59 +0800 IronPort-SDR: 9m1BuC717QO7QIsy3ZTRVRbshUM3Bw+5e+ldxFR8hEM8Gqen04NX9xaK7aZT4mmps65PngXCb7 bYKyKSCAXUqpmiRzQSkb3F+Qb7IIfIeDxKzW0ETFCieTe6QFAz1nupv+Om+roxTo/qL2Fwb4p0 y/aF1TBjMFd5r8XazkKwNgHc27Vx4HkLFwENr6lzmMnOHKOhBayWf0P+K9WxxV/WE8fgxcsByL ORbVWpG72USHzxl4PSNY6Pjjfw/zp6ElpS1Po2wu9eMPHfZa0aQb61fT5uT7cK2vaLGHhrZcd8 s68ipQAzaL/DKsecsozGRAR+ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:00:59 -0700 IronPort-SDR: kui9oBkgCzOZVHXy/ensks9+ME4FPk+Dd03eXRbifl0x6wVGxWFmsn4W5NM4F2JFBIB9HiVtbg Sd8i1C9ofmqpFR63fm916qX+ANyGy3cDirlr4MHZhxzfJgVkBWK/JqXU87QXXVz3F5fIciN5yx GWk2wlp70cnQNJmhab/z4vGPIbJpRxYdvc280NCl83EzOGJjRi6ksIo+xz/5vbaO3TCdL7TNCL IGPYU+ZiI0frCliTJY/3RxFJUicREeWSQuTgFnMDskjeTns1SK6OHokaSTikjg3aFhBesxH/wv AoQ= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:20:58 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 18/42] target/riscv: Fixup saturate subtract function Date: Tue, 11 May 2021 20:19:27 +1000 Message-Id: <20210511101951.165287-19-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Alistair Francis , Richard Henderson , qemu-devel@nongnu.org, LIU Zhiwei Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: LIU Zhiwei The overflow predication ((a - b) ^ a) & (a ^ b) & INT64_MIN is right. However, when the predication is ture and a is 0, it should return maximum. Signed-off-by: LIU Zhiwei Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Message-id: 20210212150256.885-4-zhiwei_liu@c-sky.com Signed-off-by: Alistair Francis --- target/riscv/vector_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index a156573d28..356cef8a09 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -2451,7 +2451,7 @@ static inline int8_t ssub8(CPURISCVState *env, int vxrm, int8_t a, int8_t b) { int8_t res = a - b; if ((res ^ a) & (a ^ b) & INT8_MIN) { - res = a > 0 ? INT8_MAX : INT8_MIN; + res = a >= 0 ? INT8_MAX : INT8_MIN; env->vxsat = 0x1; } return res; @@ -2461,7 +2461,7 @@ static inline int16_t ssub16(CPURISCVState *env, int vxrm, int16_t a, int16_t b) { int16_t res = a - b; if ((res ^ a) & (a ^ b) & INT16_MIN) { - res = a > 0 ? INT16_MAX : INT16_MIN; + res = a >= 0 ? INT16_MAX : INT16_MIN; env->vxsat = 0x1; } return res; @@ -2471,7 +2471,7 @@ static inline int32_t ssub32(CPURISCVState *env, int vxrm, int32_t a, int32_t b) { int32_t res = a - b; if ((res ^ a) & (a ^ b) & INT32_MIN) { - res = a > 0 ? INT32_MAX : INT32_MIN; + res = a >= 0 ? INT32_MAX : INT32_MIN; env->vxsat = 0x1; } return res; @@ -2481,7 +2481,7 @@ static inline int64_t ssub64(CPURISCVState *env, int vxrm, int64_t a, int64_t b) { int64_t res = a - b; if ((res ^ a) & (a ^ b) & INT64_MIN) { - res = a > 0 ? INT64_MAX : INT64_MIN; + res = a >= 0 ? INT64_MAX : INT64_MIN; env->vxsat = 0x1; } return res; From patchwork Tue May 11 10:19:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=UnX+Jeyx; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZJ45P4Wz9sW5 for ; Tue, 11 May 2021 20:42:44 +1000 (AEST) Received: from localhost ([::1]:58600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPqc-0005YV-4O for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:42:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPW8-0000xw-3C for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:32 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPW5-0006V6-BV for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728488; x=1652264488; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wAdLscB027NRqcQ0ba/KeWpvwnrXo8RKVmBCua1qbhw=; b=UnX+JeyxI18nEzAyh6YluSkHh443lmzUSILPZw4TsEd4ROotyDu8kWYL drJS+ge9DfBzyGbCl6zJ0hR7loIPWsTKvsCQeekyXYCFb6IaKPHcs5IaA 79CmuqYWayy9wAVT+sVYa6vdflOeWENHuqTpPjSuTESWwMc5QstlfQxGL mFFpysZXrVYniWtANjnWUqmFiNxxoytD5yTEQVhSV0/4inC28qnGE4oOw 98NCfdYrUmXkmZ0tR6rt+hdDGAYloj0SYn0Q4mDOGkUxqSH9X9y2rLjX7 nV/0UBCQZKre0tr88m2W/gJhwRJRAdJGX3cdkFafNQ0Tq/bnVO6cye+il Q==; IronPort-SDR: 88W68D1BtFr4wcFOAbc5Dr/2mjP0BHjWJNoeH1616qe2+sRxzJdReA6HCJxDjeKLorFxroV+R8 joOYQQ/hPoudI61n1RTbuaxHL1niaWQoxPDbQpi5/F5M3URCVcYDjvk5R3qIvGE9Zo3wv+8Jdr 0NJ4TuxpxMd1Tu4DQQq9EdVSRQjl5ZgQdP23HrlSCkJjaPkcCN2MjxGNMt/scXfcaAuVtMtUJB 0wr5T23h3is7euacDOAqK+ffwBfh/tGqBL5sLrVkrC0TsP8ywbXkfv+HA69ILEGyihSR3eZ1MK X9Y= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735406" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:02 +0800 IronPort-SDR: Vp0DvXhLuZyGtghWltTHxKS6pfxzFXasRWPGET5rxEgbzMx6za9zj/6/1leQ/L5QruV8fGYqH0 KzDLwSURaeO9xmAymX7SWCPVo3C1uOchIPiXV7g76+r6FTw3BYCFA/4PXbe18PxHxSkrnc9mIY HQeYmoPtmfMdB05kWcLNk20gRed/wNOWaqt4zgTQQRc+rRug93WmYoGgurr07ZsG91LgHlnrFg Gwi37qlkYM+vC1+bWn6BfGE7jpKvWoBUFV7uilcPj2hAeIvhJwks0dEo9UiJ1kpSWxTycCJgGP lW8/3tjIIWpf8sSVd5Oqi3z2 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:02 -0700 IronPort-SDR: MjSh96011M9ZMz8TVvDL9h/BnUbeQjMyiNVFjioaKaHpU5p4MhRebIBAv2YnK3vt/N1PJvUIL0 U/0gFRF8WEIs+u8JTWEgOJDyf8Djza6kssUtIKTAUxOBde8OifcnzFz9cVADmgdOdjLpc/WEAO NOluKwZT+Y/bxqS6RA86TVpaIaBRsyLgix8utxk7u5fel4cKkVEDGTMHVkd5pMx3UGtiNQWu2j DF9rpIT1m1bwFKLiopl2IQgg0+0tCie2Yttmc09HKM6kRikO8f+t3xE9nNAvrFmREb3W93LC9T Gfg= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:01 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 19/42] docs: Add documentation for shakti_c machine Date: Tue, 11 May 2021 20:19:28 +1000 Message-Id: <20210511101951.165287-20-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vijai Kumar K , alistair23@gmail.com, Bin Meng , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Vijai Kumar K Add documentation for Shakti C reference platform. Signed-off-by: Vijai Kumar K Reviewed-by: Alistair Francis Message-id: 20210412174248.8668-1-vijai@behindbytes.com Signed-off-by: Bin Meng [ Changes from Bin Meng: - Add missing TOC Message-id: 20210430070534.1487242-1-bmeng.cn@gmail.com ] Signed-off-by: Alistair Francis --- docs/system/riscv/shakti-c.rst | 82 ++++++++++++++++++++++++++++++++++ docs/system/target-riscv.rst | 1 + 2 files changed, 83 insertions(+) create mode 100644 docs/system/riscv/shakti-c.rst diff --git a/docs/system/riscv/shakti-c.rst b/docs/system/riscv/shakti-c.rst new file mode 100644 index 0000000000..a6035d42b0 --- /dev/null +++ b/docs/system/riscv/shakti-c.rst @@ -0,0 +1,82 @@ +Shakti C Reference Platform (``shakti_c``) +========================================== + +Shakti C Reference Platform is a reference platform based on arty a7 100t +for the Shakti SoC. + +Shakti SoC is a SoC based on the Shakti C-class processor core. Shakti C +is a 64bit RV64GCSUN processor core. + +For more details on Shakti SoC, please see: +https://gitlab.com/shaktiproject/cores/shakti-soc/-/blob/master/fpga/boards/artya7-100t/c-class/README.rst + +For more info on the Shakti C-class core, please see: +https://c-class.readthedocs.io/en/latest/ + +Supported devices +----------------- + +The ``shakti_c`` machine supports the following devices: + + * 1 C-class core + * Core Level Interruptor (CLINT) + * Platform-Level Interrupt Controller (PLIC) + * 1 UART + +Boot options +------------ + +The ``shakti_c`` machine can start using the standard -bios +functionality for loading the baremetal application or opensbi. + +Boot the machine +---------------- + +Shakti SDK +~~~~~~~~~~ +Shakti SDK can be used to generate the baremetal example UART applications. + +.. code-block:: bash + + $ git clone https://gitlab.com/behindbytes/shakti-sdk.git + $ cd shakti-sdk + $ make software PROGRAM=loopback TARGET=artix7_100t + +Binary would be generated in: + software/examples/uart_applns/loopback/output/loopback.shakti + +You could also download the precompiled example applicatons using below +commands. + +.. code-block:: bash + + $ wget -c https://gitlab.com/behindbytes/shakti-binaries/-/raw/master/sdk/shakti_sdk_qemu.zip + $ unzip shakti_sdk_qemu.zip + +Then we can run the UART example using: + +.. code-block:: bash + + $ qemu-system-riscv64 -M shakti_c -nographic \ + -bios path/to/shakti_sdk_qemu/loopback.shakti + +OpenSBI +~~~~~~~ +We can also run OpenSBI with Test Payload. + +.. code-block:: bash + + $ git clone https://github.com/riscv/opensbi.git -b v0.9 + $ cd opensbi + $ wget -c https://gitlab.com/behindbytes/shakti-binaries/-/raw/master/dts/shakti.dtb + $ export CROSS_COMPILE=riscv64-unknown-elf- + $ export FW_FDT_PATH=./shakti.dtb + $ make PLATFORM=generic + +fw_payload.elf would be generated in build/platform/generic/firmware/fw_payload.elf. +Boot it using the below qemu command. + +.. code-block:: bash + + $ qemu-system-riscv64 -M shakti_c -nographic \ + -bios path/to/fw_payload.elf diff --git a/docs/system/target-riscv.rst b/docs/system/target-riscv.rst index 8d5946fbbb..4b3c78382c 100644 --- a/docs/system/target-riscv.rst +++ b/docs/system/target-riscv.rst @@ -67,6 +67,7 @@ undocumented; you can get a complete list by running :maxdepth: 1 riscv/microchip-icicle-kit + riscv/shakti-c riscv/sifive_u RISC-V CPU features From patchwork Tue May 11 10:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=WaDEUtaH; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZLn2HdGz9sWl for ; Tue, 11 May 2021 20:45:05 +1000 (AEST) Received: from localhost ([::1]:38054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPst-0002Kb-77 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:45:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWL-00016m-E5 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:45 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWG-0006X1-Gp for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728499; x=1652264499; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d+NPft2RyN4RxgurmCoyTVD5EaivC4NQIQYrLmDjJmk=; b=WaDEUtaHz0aAVnar1UCGGnUZD663mELnukEcozW52KJXvZHqbzZYVnRe MQ6Xc//3G7K9lrERqJ/vQNK11439rmCCepQHm6yEHSJagc9Q4ypEQ10ru KGZJY1FWxqtK0L9Z2AbftnQnSlk7hNQe9O6uh9UWCCBIegctxr185IWM8 co4vRk7fOhEfhC6ZElF10WOCEt4RZ4DyF7OoGBzpFKMVXvcjS35fmY+yv J5b79XpTD+Ind44nfpf5j4XMV+t7F/Q6JMLhW2p15D019XLkerdJr1z7E rATFHoovqkSxEsnOnloKK6vM33opPYuFPuFYx1xGhc/rlR9OkXULC//Fj w==; IronPort-SDR: AZxSc/UWlG6E9NatSM+0xMkQ/QtkMt4ssgGjjybjmy0gtg1DDkXETZcTaTYW7pyubIsxKf+cI3 sCy6YeHeMPGiXZg3srAABALKhbGbPVKpQsutpZz69FIYQpX0dZsE7yRUa3EeAMdCwzWAzTutt8 xuEFG+3TMOKZ48H4kmUC1HFtfWhB8CuhWymWQK4hbr8XcqmdBqM/nLMQCLW4JGAtrKeGx9lXhw 9RMjAFNRB+GKEZEI0K4puWXDpdl0if/Qw3kAZkjgFKld+9MWGV9VQTd/1swyREL2ixf6lDGUkB tuM= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735413" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:05 +0800 IronPort-SDR: 4xYaoSmSvCM5kwU59IAh2kMWKDj/Hat6EWSOdYtx11jGVVuHwNZvNt5p7AqljDXupP856UAkhP A1Is9OkQJpYAqVU58vlSRRx2STQIL8hVRMFuw9o9S8E4Y4KnuW2EYqyMHOkRh0gCOxas+n509A 9HD3g64S9in66QpKEzpu3a9nLF3cnBfE7/qfz+RK0eZ2bHSUEZkS6oMuSJoaf3rHGp1RvMreEg rJq4L0CJi5Ylj56kWJHXLDsQVR78aVnFr5sMcmJzUFGLowt0WW+rZXadzeYygwLMZ4ZvBei4+V kJ5fIlyJmqBaV3h7LWGTmyUW Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:05 -0700 IronPort-SDR: 9V6CReCCR+GUdSTBCl5zTBnj+Jw2AZJkZiNx6OL1SHTxqnJSw2KMIFFsDWBvq0xj7DpDaz2K+w kMzQ2AbwbDs9QNQ0Qmmxu8m6N263tujOiGU9ucIi3jqHLHzR5lDXsqJ7gtt8zB4wrx4SpRHSD0 VWLHl1c+bnOqKFNmKq8JMTrTNI1K/AFmO4LkLv7AGQc+rl4i0P1Se4uC4756YVi2K+h96IsxZx E2mK2Hh1IUsZAwuvwANFM7rVwRSUL6sSUgpeA/uAovWdAiOwp4Fr0yDX24m/Y9dadSokXzXIY4 q/w= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:04 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 20/42] target/riscv: Fix the PMP is locked check when using TOR Date: Tue, 11 May 2021 20:19:29 +1000 Message-Id: <20210511101951.165287-21-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The RISC-V spec says: if PMP entry i is locked and pmpicfg.A is set to TOR, writes to pmpaddri-1 are ignored. The current QEMU code ignores accesses to pmpaddri-1 and pmpcfgi-1 which is incorrect. Update the pmp_is_locked() function to not check the supporting fields and instead enforce the lock functionality in the pmpaddr write operation. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 2831241458163f445a89bd59c59990247265b0c6.1618812899.git.alistair.francis@wdc.com --- target/riscv/pmp.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index cff020122a..a3b253bb15 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -59,16 +59,6 @@ static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index) return 0; } - /* In TOR mode, need to check the lock bit of the next pmp - * (if there is a next) - */ - const uint8_t a_field = - pmp_get_a_field(env->pmp_state.pmp[pmp_index + 1].cfg_reg); - if ((env->pmp_state.pmp[pmp_index + 1u].cfg_reg & PMP_LOCK) && - (PMP_AMATCH_TOR == a_field)) { - return 1; - } - return 0; } @@ -380,7 +370,23 @@ void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index, target_ulong val) { trace_pmpaddr_csr_write(env->mhartid, addr_index, val); + if (addr_index < MAX_RISCV_PMPS) { + /* + * In TOR mode, need to check the lock bit of the next pmp + * (if there is a next). + */ + if (addr_index + 1 < MAX_RISCV_PMPS) { + uint8_t pmp_cfg = env->pmp_state.pmp[addr_index + 1].cfg_reg; + + if (pmp_cfg & PMP_LOCK && + PMP_AMATCH_TOR == pmp_get_a_field(pmp_cfg)) { + qemu_log_mask(LOG_GUEST_ERROR, + "ignoring pmpaddr write - pmpcfg + 1 locked\n"); + return; + } + } + if (!pmp_is_locked(env, addr_index)) { env->pmp_state.pmp[addr_index].addr_reg = val; pmp_update_rule(env, addr_index); From patchwork Tue May 11 10:19:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=bL5vzlkC; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZKy6wCnz9rx6 for ; Tue, 11 May 2021 20:44:22 +1000 (AEST) Received: from localhost ([::1]:35092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPsC-0000LV-TR for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:44:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWM-0001C0-Ur for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:46 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWJ-0006V6-OI for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728501; x=1652264501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8y3Un5Hxd2E2PcjnIHIP4w4G78fYCc51KoJUltBBqoo=; b=bL5vzlkCpUD/28lb+LTsBa6kgJfP/RXBis5AGy7TQtDSJOGpAYwkifli QyDEMpVIjnc8imVqsZGSYXDxdY/aPKo4tD28v5ZF/9a3UxBtQcz6G9STZ pTXevWARPTXnbfMkchpLtkRsU9MylJfSQ/2ssFVdAkrfT3Dwmhk83mk83 TMHZvE6e1bYsFLg1yGkLNIz8SDPVSEJwy2D1Xo8GtpsbMHbfyolFRAfw3 25+2K08Q8+E3K4cZVcU92zX3ZlgOkzIMsbKsWt72o0dQl+RniQW1CIuLa I1O7DkA7hGnQIabzVJuYWYtaErE9Ktave1Wr45PYqclP/aNu5TAIcHkGz g==; IronPort-SDR: Cpb5avGWA8CL0ra/s0uYRaYYKba3dbhlrEb3+xYcMhb3uEK7kugEQKlSFl9e3V1EPvkFiY2wkF lDm8pYTwlEBUhhMWkSFSiA9oYVrUcB0C/odaxE9vVBruXZguCwEFFNXhOWZDcNSU6jefB34JGo XSwY+/Y/BwLsNUWCY9f00RgxktW+dnBe8J9XCTsT6o+3yLBYX/cb7U2lkbMec77nCFGWqiGCcG WzuudwG+hAQjDDBe3dp5qLIFzuPQAKMmkcmptamTAJfFmpMFsaL3YVdWg/sBQ5VI80zi8z7fM4 XQo= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735420" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:09 +0800 IronPort-SDR: IP6txWdVLsjpLZUugHBBHeoJ2KqwdY9EL6Y7SeDKx92erPfiYQMk+ks740rsIcA1p2BmbM/xcl gR5qF26g5GAOjfi49jd2a578zGdTRqkRTkoCiJX50Pw86AALr2JwcKMoAptEjEMp7EyXvKsH2Q udoNatyW8zcj0RM4SlRWfGMFhm5SXMdJmpddN+pVEDQS+AoDKzM5wVfdSvj4gwnXgSQ0o2xj5o D1NzrtWfMD3vN0zhQOKkX98ta9mTd8h3mJ8dCbb+6h/9EeOaHKqhmzcvhakOzNU5fKcxHu9SJQ f0/YtxXTUh1s6Sl06u+WQtmi Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:09 -0700 IronPort-SDR: OTXSz9DRtHP+OTrAhTweZ/FTzgTack0JDq2oln19/xPl77PR51vom7yzgvJApr2JzKT9HUXIAl Ol3NlqR7Z8Uc7SqepYF/FrIdJ6z6QwbA68+V6429LmI2kuKRvnnvCf8oxyp2hlG2rwtfpwC/Yh feOhs/OCexUz5P9Cui2c7F/hCm69r4oxHwvyzjuQ2DB0/XTSOCnnSE8mOsBpnoxLPxAarLZk2W hhQ2uIWzrCCX//STNA0DcAKR9TB8LaXkVWAAvEtu9YSE6VtaUDunfwCjTclTLmkWU0DG3mkLEy Th8= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:07 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 21/42] target/riscv: Define ePMP mseccfg Date: Tue, 11 May 2021 20:19:30 +1000 Message-Id: <20210511101951.165287-22-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hou Weiying , qemu-devel@nongnu.org, Hongzheng-Li , Alistair Francis , alistair23@gmail.com, Bin Meng , Myriad-Dreamin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying Use address 0x390 and 0x391 for the ePMP CSRs. Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Reviewed-by: Alistair Francis Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 63245b559f477a9ce6d4f930136d2d7fd7f99c78.1618812899.git.alistair.francis@wdc.com [ Changes by AF: - Tidy up commit message ] Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu_bits.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 8549d77b4f..24d89939a0 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -220,6 +220,9 @@ #define CSR_MTINST 0x34a #define CSR_MTVAL2 0x34b +/* Enhanced Physical Memory Protection (ePMP) */ +#define CSR_MSECCFG 0x390 +#define CSR_MSECCFGH 0x391 /* Physical Memory Protection */ #define CSR_PMPCFG0 0x3a0 #define CSR_PMPCFG1 0x3a1 From patchwork Tue May 11 10:19:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=aZKsW0pY; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZBF1Km5z9rx6 for ; Tue, 11 May 2021 20:37:41 +1000 (AEST) Received: from localhost ([::1]:44142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPlj-000438-4f for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:37:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWP-0001Km-7u for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:49 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWM-0006TG-GU for qemu-devel@nongnu.org; Tue, 11 May 2021 06:21:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728504; x=1652264504; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NHvDFXBaWN2j3izad2FF3XGWNvtRcgbhcimmn8MDmLE=; b=aZKsW0pYaHhMLMzzsx7X8x/+X5c84CyQY1j1pMikuUGKVjuYTTdgLxz7 l//JtSuAxyG7BwfrpGHTVB7FTtaQQJUM6r521xoAAlk6eme+HVGzJh2KA PbFP3yLSvDak9TDxPKnOBW/DuYVLZSGybpFM7If8+YPhtNfOjVLny20JP UDy22ZIRGsBgjJVdDyYNYBQuEEKs7Dahxuut7+89UlYVvL1fFA5tc0uV9 izq1D1lpyHC0AGSz81zyVcVOJW4+pIBTJ6NBFb16cqf6OvgS11j/udg8K qVzaoYCuhNxzwy/V6N4qEYu0Eltde8gX3TNsJFpL31m0w7iSbzEXJsoqO w==; IronPort-SDR: Uz03infTEH7d+q7hUb2bOsA7QH52c2dJDjMcx0ys24sBsXGdlvTmzf8yw6kMzGHiAQz+qRn1Sy R294y2/9L/ojg4SnS9FOXCOfbjksB3yJcDiaNy0BVnFiVNhsJbcmM4PQ2f2ls3U8EMPkzsVYH2 p1RiQNXn1JbTohcAtLFiX4oQrmj9LwOT0S6EuNouNaA6HD7dkEXj31JC3Hbpq41wuJJson/vEl 89GucrTBz/Gvv622AHIsD+3iUvZ26P5kcrFJMemW05yVNT4e6kGDR5uws89VKqTcuXIQC0decx 3CU= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735425" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:12 +0800 IronPort-SDR: omvQBZP49R2lCyrFpqwz9VVBNIZ7trnr5yRXsHKRKQUK+vAK1LN9L2OzCW5rw3NnTUtl4YgM8G KFu/O42cX89gZCXyV6PqBqIW7PIa3qCJjBEfoNWMXG2tR+1rHFswC7WeKwpENmxONNG9o17MHM f9aqAb1d5jRWnMNrVAh0Fs6FxwI7aesuvlkWcr7l9Y8AGcwsJ5mT2JOvs8xZ81MA3vCH5LvTIg ZLHEEITisQiKt2mzvsYvZmby4l1qib66BeAnnQPVqNrxRSXkNZMYLXQKAuujPr4wisrP2rSih7 CCqbY1fwI6v07KtkyY6395eB Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:12 -0700 IronPort-SDR: dfIDZSZnQRYssruxUL15OCgCJD/kw/PgSU5AxPUa2Ry0/0KZW5HZAUvdZ2Ibdzvwik1qkzpgR5 u4PoGiVM7qs6qWytgCWZhMPNFshvE8viHhRvSsUQta51nk2b1IJVDLrEhJ1SXQg6WRO0jonR7U X6G88DaalBmD0vDJZ1O+VPyQCZQVtVf+UZOyJvq9O47NG+5fnOfm1ENnPSvayiPtQQcRAoRBZ4 ZYmfMw2dX4VDhvgqqaoHQvdnU88wcgTTJflAeoExz+dFi88Yv9Q1woiomrT2i4mqQ3GcOlWQQ/ rro= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:11 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 22/42] target/riscv: Add the ePMP feature Date: Tue, 11 May 2021 20:19:31 +1000 Message-Id: <20210511101951.165287-23-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The spec is avaliable at: https://docs.google.com/document/d/1Mh_aiHYxemL0umN3GTTw8vsbmzHZ_nxZXgjgOUzbvc8 Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 28c8855c80b0388a08c3ae009f5467e2b3960ce0.1618812899.git.alistair.francis@wdc.com --- target/riscv/cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 842d3ab810..13a08b86f6 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -81,6 +81,7 @@ enum { RISCV_FEATURE_MMU, RISCV_FEATURE_PMP, + RISCV_FEATURE_EPMP, RISCV_FEATURE_MISA }; From patchwork Tue May 11 10:19:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=TRs6QRgH; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZQT70ymz9sWq for ; Tue, 11 May 2021 20:48:17 +1000 (AEST) Received: from localhost ([::1]:46514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPvz-00083B-VB for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:48:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWb-0001Ze-AO for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:01 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWV-0006X1-PA for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728514; x=1652264514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U7W9/97cV7S0MeqIjKSK1ip9SWpr6IUZRTVpdh1xCzQ=; b=TRs6QRgHfp9buzaiQppXCIhiZOL5oyPYEmWrsaW11LrxnycEx6WcojGF yHd8K5sKDcYaSFzQBZf5xoUW749KLUOHNrb0U4ljT2GJIwX3HLGNd4RdI 4Q2/E8Db4+g2S/DY0qQTIBKixPzItNUPNeso5gzBtXFMMsUMry3+/TLN+ y+aZhIl75segxRZV8Pao8jm5L6EvBIDFc9kGCPU+3zSDoY50AAbAi0iNT pkYd5jAdCvgUqqn8r0Ot3cgvul+wLtishfKJLzoTp936VXRh6WIryU3+E dJ8/rHlAwQZ6cnr5VG3krW15LZDPw0UCEggbF+zOpV4eXVlZJgfy+4z+Q A==; IronPort-SDR: ILl/erqFiLfvQUv1rKJji6LkR+DE+mdlqdcv4LTbx0B+x/GqY/+R4JVJOXWPE780Uo/7g0m6+o DmK4LfmvCGsNSVP9ZPU0ZJ977MCYnqwv6PH2tT6aN3B1wfNedOmFGYxoinOrBNiVkLMoLluTBp WgHD1uMBF8aMLaV0EXWK8V8qYwNw7jh51fnRwvMS00M9LCSqdYn7csjoCSm1DlBrW5+HWZGMIw 7ctSxFcdaxjlBFzT2SRukwAUE3y8c+uUHg1A3sr1NZaqmA6vNT9Y++p7aGSmDiCjPck44zF8lv zAI= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735433" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:16 +0800 IronPort-SDR: nI6tFoZ1YyaoGBhlMYNtvi+1O/AWIsyNC7gXyTK5u6Cz5TYHGVzk2Ayp+j5bX2v8kHOCDCqDfK BAQRJUNIszLqPvUkn2NjMBg00sbH3AHtmp0hDtpF/sosiErhOURvM0313fhJp3gpm0iasODwqp dDwZoLPN6qDIvb54sDDmRlZpL0JC2DhEE8x6In8dYfivqs6qUURFtIJ+MceYsIO29E9d1EOlu+ SQjDJ2rKjVd/8UwtOygotmxIPu6zoikkUgqO2iinxYuA3LxjBOXI2S5Kg6J0tgDB7HLBFe4Qf4 gFTCt6UoctI5Ow9AP8pkiXDo Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:16 -0700 IronPort-SDR: a4XpmkfakKpsSXPd1CgqWRhnI38+kT3US+VelVtyb6w2M4EvoUhQR4LDnSqkaQHlEs43uDWtdx OM51Rq2Q1t1JlJjXWCzTn6lSEKMYDqAWHYLgEyk3mfKxLcSFDD5CRLr3/Oo2iPsdWuJUMCpHKF hqCeT4x0GBLOk8I0FMmpTi2qV5Liw/C7e73COh37ddte1idNvQo/7MnXoS8TJnAwaYDgsPqNAv p9I391PrqnMi0IVn4XlYVxUvZRTFzQP7p4WF73a+kzfDYNloMtyHUR9orgIAvQNEtU7/IRzuue M4g= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:14 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 23/42] target/riscv: Add ePMP CSR access functions Date: Tue, 11 May 2021 20:19:32 +1000 Message-Id: <20210511101951.165287-24-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hou Weiying , qemu-devel@nongnu.org, Hongzheng-Li , Alistair Francis , alistair23@gmail.com, Bin Meng , Myriad-Dreamin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 270762cb2507fba6a9eeb99a774cf49f7da9cc32.1618812899.git.alistair.francis@wdc.com [ Changes by AF: - Rebase on master - Fix build errors - Fix some style issues ] Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu.h | 1 + target/riscv/pmp.h | 14 ++++++++++++++ target/riscv/csr.c | 24 ++++++++++++++++++++++++ target/riscv/pmp.c | 34 ++++++++++++++++++++++++++++++++++ target/riscv/trace-events | 3 +++ 5 files changed, 76 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 13a08b86f6..83b315e0b2 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -230,6 +230,7 @@ struct CPURISCVState { /* physical memory protection */ pmp_table_t pmp_state; + target_ulong mseccfg; /* machine specific rdtime callback */ uint64_t (*rdtime_fn)(uint32_t); diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h index b82a30f0d5..a9a0b363a7 100644 --- a/target/riscv/pmp.h +++ b/target/riscv/pmp.h @@ -36,6 +36,12 @@ typedef enum { PMP_AMATCH_NAPOT /* Naturally aligned power-of-two region */ } pmp_am_t; +typedef enum { + MSECCFG_MML = 1 << 0, + MSECCFG_MMWP = 1 << 1, + MSECCFG_RLB = 1 << 2 +} mseccfg_field_t; + typedef struct { target_ulong addr_reg; uint8_t cfg_reg; @@ -55,6 +61,10 @@ typedef struct { void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index, target_ulong val); target_ulong pmpcfg_csr_read(CPURISCVState *env, uint32_t reg_index); + +void mseccfg_csr_write(CPURISCVState *env, target_ulong val); +target_ulong mseccfg_csr_read(CPURISCVState *env); + void pmpaddr_csr_write(CPURISCVState *env, uint32_t addr_index, target_ulong val); target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t addr_index); @@ -68,4 +78,8 @@ void pmp_update_rule_nums(CPURISCVState *env); uint32_t pmp_get_num_rules(CPURISCVState *env); int pmp_priv_to_page_prot(pmp_priv_t pmp_priv); +#define MSECCFG_MML_ISSET(env) get_field(env->mseccfg, MSECCFG_MML) +#define MSECCFG_MMWP_ISSET(env) get_field(env->mseccfg, MSECCFG_MMWP) +#define MSECCFG_RLB_ISSET(env) get_field(env->mseccfg, MSECCFG_RLB) + #endif diff --git a/target/riscv/csr.c b/target/riscv/csr.c index f0a74f0eb8..97ceff718f 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -200,6 +200,15 @@ static RISCVException pmp(CPURISCVState *env, int csrno) return RISCV_EXCP_ILLEGAL_INST; } + +static RISCVException epmp(CPURISCVState *env, int csrno) +{ + if (env->priv == PRV_M && riscv_feature(env, RISCV_FEATURE_EPMP)) { + return RISCV_EXCP_NONE; + } + + return RISCV_EXCP_ILLEGAL_INST; +} #endif /* User Floating-Point CSRs */ @@ -1343,6 +1352,20 @@ static RISCVException write_mtinst(CPURISCVState *env, int csrno, } /* Physical Memory Protection */ +static RISCVException read_mseccfg(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = mseccfg_csr_read(env); + return RISCV_EXCP_NONE; +} + +static RISCVException write_mseccfg(CPURISCVState *env, int csrno, + target_ulong val) +{ + mseccfg_csr_write(env, val); + return RISCV_EXCP_NONE; +} + static RISCVException read_pmpcfg(CPURISCVState *env, int csrno, target_ulong *val) { @@ -1581,6 +1604,7 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_MTINST] = { "mtinst", hmode, read_mtinst, write_mtinst }, /* Physical Memory Protection */ + [CSR_MSECCFG] = { "mseccfg", epmp, read_mseccfg, write_mseccfg }, [CSR_PMPCFG0] = { "pmpcfg0", pmp, read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG1] = { "pmpcfg1", pmp, read_pmpcfg, write_pmpcfg }, [CSR_PMPCFG2] = { "pmpcfg2", pmp, read_pmpcfg, write_pmpcfg }, diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index a3b253bb15..e35988eec2 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -419,6 +419,40 @@ target_ulong pmpaddr_csr_read(CPURISCVState *env, uint32_t addr_index) return val; } +/* + * Handle a write to a mseccfg CSR + */ +void mseccfg_csr_write(CPURISCVState *env, target_ulong val) +{ + int i; + + trace_mseccfg_csr_write(env->mhartid, val); + + /* RLB cannot be enabled if it's already 0 and if any regions are locked */ + if (!MSECCFG_RLB_ISSET(env)) { + for (i = 0; i < MAX_RISCV_PMPS; i++) { + if (pmp_is_locked(env, i)) { + val &= ~MSECCFG_RLB; + break; + } + } + } + + /* Sticky bits */ + val |= (env->mseccfg & (MSECCFG_MMWP | MSECCFG_MML)); + + env->mseccfg = val; +} + +/* + * Handle a read from a mseccfg CSR + */ +target_ulong mseccfg_csr_read(CPURISCVState *env) +{ + trace_mseccfg_csr_read(env->mhartid, env->mseccfg); + return env->mseccfg; +} + /* * Calculate the TLB size if the start address or the end address of * PMP entry is presented in thie TLB page. diff --git a/target/riscv/trace-events b/target/riscv/trace-events index b7e371ee97..49ec4d3b7d 100644 --- a/target/riscv/trace-events +++ b/target/riscv/trace-events @@ -6,3 +6,6 @@ pmpcfg_csr_read(uint64_t mhartid, uint32_t reg_index, uint64_t val) "hart %" PRI pmpcfg_csr_write(uint64_t mhartid, uint32_t reg_index, uint64_t val) "hart %" PRIu64 ": write reg%" PRIu32", val: 0x%" PRIx64 pmpaddr_csr_read(uint64_t mhartid, uint32_t addr_index, uint64_t val) "hart %" PRIu64 ": read addr%" PRIu32", val: 0x%" PRIx64 pmpaddr_csr_write(uint64_t mhartid, uint32_t addr_index, uint64_t val) "hart %" PRIu64 ": write addr%" PRIu32", val: 0x%" PRIx64 + +mseccfg_csr_read(uint64_t mhartid, uint64_t val) "hart %" PRIu64 ": read mseccfg, val: 0x%" PRIx64 +mseccfg_csr_write(uint64_t mhartid, uint64_t val) "hart %" PRIu64 ": write mseccfg, val: 0x%" PRIx64 From patchwork Tue May 11 10:19:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=qITCLzJy; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZDl0hsvz9rx6 for ; Tue, 11 May 2021 20:39:49 +1000 (AEST) Received: from localhost ([::1]:50222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPnl-0008DH-G4 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:39:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWb-0001ax-Ij for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:01 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWX-0006V6-9d for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728516; x=1652264516; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pBBAC61+EEfqzPyFG9Ss2AtmUcGJb3aUIYDnVeOutq0=; b=qITCLzJyJlf1ZM6QP9+7eTeFIkvW66KIbCMGZX4hpwJ9uRXisHORj2Vz NuNFt1kAcs+yQ8vow3lfpfYChf5lw0l/eFlGU1Zf1uEWw4aEbND8pihqI eakiYRyGtZlhg20scW905hFqe/bfrh5CIziS/OiSb0rmh36dXpvsj0ZcB GtXy26cV/mn1uWiICwWyk+p/S7Qrliwg42WxYC3lFG/4r6/RFvFYqw+oJ DX3qtzFFolaDTAzTxOfCT57L8huLboWt6p+tWHAhPJQYzFPYfkYQfQm2s 6tlhOkXDFaWOEtpP7vdQPZc7uQX7nP7HmL3yFEuc6SZMhOcZomXT/BVkK A==; IronPort-SDR: gx2HZEvBV/V7bAw+lBf8CHKrAJZleckvkhMvaHe5/EQ4ymXpzPbknzg/PXJkRAXHxZGDCDpK0G DOAiGBEb5eJ0qaKYZbyWjhvMEyjBik0tubiVGWdOn6+S9oyZgBQK/jaNLjlDeY6rH99SrgM6UK AXmew6JngYqCufbxNbKHK4JSathE3HYX84ZgFnF0pcgXfdGend6RQYAeZcwjTgVAoZ8FK9OFbc p3Z7EpyiKgcM2gLYhBwlC7Yaiv8mngGC7oMtQFurytoF0v46rH0BG4QE+1bP+V7v9qXaHghC22 ncA= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735438" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:20 +0800 IronPort-SDR: G39gwkAA74R+izZcUba8x9tLdI2V0/C0yVY9CuYl+TwYl2hzmpIwsqjQJmw70TXb+7zSY9ZjIX B/omDzZwSJHfx1I60XxY9a43h4HOLDG8BSnMrFSAPBeuWcaGeikN//4EBQs94Ew8MiN90MnKl1 HL77nemfyEQMk/qS2d4OM9qIHKbYWhLHeCQ20x6CvambR/3IJUmO6AslLwJEMk3PrAvWS0RcVP DOBByzU31c6Kxsjv9amOedquXHP3Xpey0iIocDZKSQtUU0TlxcxU3v9d3UnwKOdtNgK3Zh/dt5 R2ad/GF8oLkHMRiCrs01KL/R Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:20 -0700 IronPort-SDR: KcmOYzf+mCc6s6S8BUF2MJbPpaGkchKhgQI2gQT0m8ZK7VGb80KxLkwo7swUuJd3VIxNcSZBab 4cVImVG49Q56FxnVlLQhF6ElEZhSncCsjB5zfbWBN8wUvespZKjj3iuLSoR9T5Zbosm8Ja3lS2 8gpU8IWcGSsO/KT4lbAAU+PuVfZnO6jjHOMNat2Gf3KkJpa+Ud2Ms+/F1h/T9Pvb6+8rRYlvBO dFYDujpzkUX0GRQf9SyEaSkTVNM4LtU5nvY2odMliyVNB7KB1nKfUA+8vrgzscMoZUahCvq6yE NxY= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:18 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 24/42] target/riscv: Implementation of enhanced PMP (ePMP) Date: Tue, 11 May 2021 20:19:33 +1000 Message-Id: <20210511101951.165287-25-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hou Weiying , qemu-devel@nongnu.org, Hongzheng-Li , Alistair Francis , alistair23@gmail.com, Bin Meng , Myriad-Dreamin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying This commit adds support for ePMP v0.9.1. The ePMP spec can be found in: https://docs.google.com/document/d/1Mh_aiHYxemL0umN3GTTw8vsbmzHZ_nxZXgjgOUzbvc8 Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: fef23b885f9649a4d54e7c98b168bdec5d297bb1.1618812899.git.alistair.francis@wdc.com [ Changes by AF: - Rebase on master - Update to latest spec - Use a switch case to handle ePMP MML permissions - Fix a few bugs ] Signed-off-by: Alistair Francis --- target/riscv/pmp.c | 154 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 146 insertions(+), 8 deletions(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index e35988eec2..e1f5776316 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -90,11 +90,42 @@ static inline uint8_t pmp_read_cfg(CPURISCVState *env, uint32_t pmp_index) static void pmp_write_cfg(CPURISCVState *env, uint32_t pmp_index, uint8_t val) { if (pmp_index < MAX_RISCV_PMPS) { - if (!pmp_is_locked(env, pmp_index)) { - env->pmp_state.pmp[pmp_index].cfg_reg = val; - pmp_update_rule(env, pmp_index); + bool locked = true; + + if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + /* mseccfg.RLB is set */ + if (MSECCFG_RLB_ISSET(env)) { + locked = false; + } + + /* mseccfg.MML is not set */ + if (!MSECCFG_MML_ISSET(env) && !pmp_is_locked(env, pmp_index)) { + locked = false; + } + + /* mseccfg.MML is set */ + if (MSECCFG_MML_ISSET(env)) { + /* not adding execute bit */ + if ((val & PMP_LOCK) != 0 && (val & PMP_EXEC) != PMP_EXEC) { + locked = false; + } + /* shared region and not adding X bit */ + if ((val & PMP_LOCK) != PMP_LOCK && + (val & 0x7) != (PMP_WRITE | PMP_EXEC)) { + locked = false; + } + } } else { + if (!pmp_is_locked(env, pmp_index)) { + locked = false; + } + } + + if (locked) { qemu_log_mask(LOG_GUEST_ERROR, "ignoring pmpcfg write - locked\n"); + } else { + env->pmp_state.pmp[pmp_index].cfg_reg = val; + pmp_update_rule(env, pmp_index); } } else { qemu_log_mask(LOG_GUEST_ERROR, @@ -217,6 +248,32 @@ static bool pmp_hart_has_privs_default(CPURISCVState *env, target_ulong addr, { bool ret; + if (riscv_feature(env, RISCV_FEATURE_EPMP)) { + if (MSECCFG_MMWP_ISSET(env)) { + /* + * The Machine Mode Whitelist Policy (mseccfg.MMWP) is set + * so we default to deny all, even for M-mode. + */ + *allowed_privs = 0; + return false; + } else if (MSECCFG_MML_ISSET(env)) { + /* + * The Machine Mode Lockdown (mseccfg.MML) bit is set + * so we can only execute code in M-mode with an applicable + * rule. Other modes are disabled. + */ + if (mode == PRV_M && !(privs & PMP_EXEC)) { + ret = true; + *allowed_privs = PMP_READ | PMP_WRITE; + } else { + ret = false; + *allowed_privs = 0; + } + + return ret; + } + } + if ((!riscv_feature(env, RISCV_FEATURE_PMP)) || (mode == PRV_M)) { /* * Privileged spec v1.10 states if HW doesn't implement any PMP entry @@ -294,13 +351,94 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, pmp_get_a_field(env->pmp_state.pmp[i].cfg_reg); /* - * If the PMP entry is not off and the address is in range, do the priv - * check + * Convert the PMP permissions to match the truth table in the + * ePMP spec. */ + const uint8_t epmp_operation = + ((env->pmp_state.pmp[i].cfg_reg & PMP_LOCK) >> 4) | + ((env->pmp_state.pmp[i].cfg_reg & PMP_READ) << 2) | + (env->pmp_state.pmp[i].cfg_reg & PMP_WRITE) | + ((env->pmp_state.pmp[i].cfg_reg & PMP_EXEC) >> 2); + if (((s + e) == 2) && (PMP_AMATCH_OFF != a_field)) { - *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; - if ((mode != PRV_M) || pmp_is_locked(env, i)) { - *allowed_privs &= env->pmp_state.pmp[i].cfg_reg; + /* + * If the PMP entry is not off and the address is in range, + * do the priv check + */ + if (!MSECCFG_MML_ISSET(env)) { + /* + * If mseccfg.MML Bit is not set, do pmp priv check + * This will always apply to regular PMP. + */ + *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; + if ((mode != PRV_M) || pmp_is_locked(env, i)) { + *allowed_privs &= env->pmp_state.pmp[i].cfg_reg; + } + } else { + /* + * If mseccfg.MML Bit set, do the enhanced pmp priv check + */ + if (mode == PRV_M) { + switch (epmp_operation) { + case 0: + case 1: + case 4: + case 5: + case 6: + case 7: + case 8: + *allowed_privs = 0; + break; + case 2: + case 3: + case 14: + *allowed_privs = PMP_READ | PMP_WRITE; + break; + case 9: + case 10: + *allowed_privs = PMP_EXEC; + break; + case 11: + case 13: + *allowed_privs = PMP_READ | PMP_EXEC; + break; + case 12: + case 15: + *allowed_privs = PMP_READ; + break; + } + } else { + switch (epmp_operation) { + case 0: + case 8: + case 9: + case 12: + case 13: + case 14: + *allowed_privs = 0; + break; + case 1: + case 10: + case 11: + *allowed_privs = PMP_EXEC; + break; + case 2: + case 4: + case 15: + *allowed_privs = PMP_READ; + break; + case 3: + case 6: + *allowed_privs = PMP_READ | PMP_WRITE; + break; + case 5: + *allowed_privs = PMP_READ | PMP_EXEC; + break; + case 7: + *allowed_privs = PMP_READ | PMP_WRITE | PMP_EXEC; + break; + } + } } ret = ((privs & *allowed_privs) == privs); From patchwork Tue May 11 10:19:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477063 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=rDheA8St; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZVJ31lFz9t1Q for ; Tue, 11 May 2021 20:51:36 +1000 (AEST) Received: from localhost ([::1]:55286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPzC-0005Xj-Cv for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:51:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWd-0001iN-Gi for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:03 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWZ-0006TG-Hp for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728518; x=1652264518; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eY64W9JB7jnGvaakjv5BADNjhl2X/P3bfdlkpxmil/8=; b=rDheA8St3yi5MHWPTIHSd7y/np43F0AeL6lwY3LQq/t5bsGe3lg0GtO4 3oefXXNMLzbQLHqFjDfUeGKXsKlQb7urxe/yBC+i8IGtl/zAIV9258XUo urPe33bNVauclE0tIyP3wjqgoYBTLeE5SAFLF7KugSyWoz9rMJIh0VKoA iJXy+MIxgTY8E3NH60LYGtyJMGZ3R7Gp9H8PJ3IS2oGo/mUp95aAOqF5f GzUDqATEgsVPNuRBaDDd6Vu826iMm39A8k3UbM7Tng7w1fLJJ+RkEfjXp QwShS0LE4k0GoFmvp/XpzyIylA4w7jr80OoCt9s3qI88MRqkWwL7NJEQS g==; IronPort-SDR: XokblxMn8TX098q3+Y0m+HCQYE43yp9TtyBHw5ipw3xr0wjcHbjBLdCMiRPmdVLOryPrGyvjMN zMttsyXViRQM3Y4J7PcOHkOhL0+VvfrJfE5NkzH07L5PWRdozt5kph3EpUYbXB/wPXz/vQUFKt BZGOhUCd6o87mR12BuRUwAowH7yTa4HBnbfP+pHY5DfDKV0apOd3lcvgsy0C982GBCbTcVhuF+ FDRUdujBXD1jBVZWY+PKO8RTDjG1wQ7W/rfoeT0k7TjIFom+NaFnkTHMdmPanmZQOIUFbq+pdZ vKg= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735443" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:24 +0800 IronPort-SDR: WkTJQlaIVVVMnOGb20f1vf0wqEmbVMMW10jcB3wzGx0N5c8pBognO4iGaa0oKFc5k22QuScfBg ivJm7ytYAACzGZqRTQymOEuItn1L6qAmEGr1ER5boyr1g/tnEvrjKHeDwDRV+MVLQNB3uAxVt/ WHww4q45y1/1ahaznCF1IFtOfQXDlBQW6SD9VJDs78L0b5tt463IysbUMtxdNTaKhwBBFmgUo2 g6t87X/IN+LDDvOr+dyOg1ME8udrMG/xIjK34fYtqsAEJM5S4vDtNvSjoRnVt/3dAVzoAwtweM FlnJfgW9Y1czqjAZMiDpbnSd Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:24 -0700 IronPort-SDR: m6qPRz/GwDRerIH9IML6ayzdwOW40GztvQvcH5J8+XaNb7aB/aa3FK03cAPMp8Q95eIYF0gT5b x4hOMlifGzNHDTbLjgB2Pb9d1OiNsrd4S3lBHTRKR9Ya+yriie5O8raz2moS3ES4B6oxvYYGs2 YXfON/95Va2W0OTLGvPlGu4pNNTrRJLormP6tzwi0QWfxGvxghayJJMcmo1dbYQtFugMRlIpNc Eq4P3jp/y5JxixP1kxrka54+jYLf1Yg39E8jkpQozUdA3La8VfO+7FQEN6QlWU45cIa4k8G4ly TMk= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:22 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 25/42] target/riscv: Add a config option for ePMP Date: Tue, 11 May 2021 20:19:34 +1000 Message-Id: <20210511101951.165287-26-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hou Weiying , qemu-devel@nongnu.org, Hongzheng-Li , Alistair Francis , alistair23@gmail.com, Bin Meng , Myriad-Dreamin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying Add a config option to enable experimental support for ePMP. This is disabled by default and can be enabled with 'x-epmp=true'. Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: a22ccdaf9314078bc735d3b323f966623f8af020.1618812899.git.alistair.francis@wdc.com Signed-off-by: Alistair Francis Reviewed-by: Bin Meng --- target/riscv/cpu.h | 1 + target/riscv/cpu.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 83b315e0b2..add734bbbd 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -304,6 +304,7 @@ struct RISCVCPU { uint16_t elen; bool mmu; bool pmp; + bool epmp; uint64_t resetvec; } cfg; }; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index e530df9385..66787d019c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -412,6 +412,14 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) if (cpu->cfg.pmp) { set_feature(env, RISCV_FEATURE_PMP); + + /* + * Enhanced PMP should only be available + * on harts with PMP support + */ + if (cpu->cfg.epmp) { + set_feature(env, RISCV_FEATURE_EPMP); + } } set_resetvec(env, cpu->cfg.resetvec); @@ -554,6 +562,8 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), + DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), + DEFINE_PROP_UINT64("resetvec", RISCVCPU, cfg.resetvec, DEFAULT_RSTVEC), DEFINE_PROP_END_OF_LIST(), }; From patchwork Tue May 11 10:19:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=kexH6Th3; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZPC1Nxnz9rx6 for ; Tue, 11 May 2021 20:47:11 +1000 (AEST) Received: from localhost ([::1]:43600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPuv-00065N-7L for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:47:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWs-00028c-Dn for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:18 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWl-0006X1-Lw for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728529; x=1652264529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WzI8U0Vh2iFMSVxjJhHwv+fox5ZJja+nCtlrHq7wrso=; b=kexH6Th3DSsJbGStBiirdBLteZDDBmIAAqsmBsIZcXNebkkYfg/wHQFt cfP/4QRDtF47ITvciJ8kqflcQC+AwYHjitQ2gRLzBCjSWIMZW4od++pDk mfPZyBAe1AeG/TnpZDjtnFxP/HhYuewnjyGHAXD9WqwDMrJnNgrV+fC8z jOD7DT36GOL4r/UcAQBPf0fHp1s7/cE0otUdN8YBPtuwCXAj6oQY59LP2 CnJuwVwAo/gTB8e1qQQTbjVKDwdvTDZ2lKBW+iNQapNo9IcsXx31MoFjD w/EBes8KBl91lXsSbwvc3QcdE6XEvDBim4tJ1m/fAzolRHmnzes+NEF2u Q==; IronPort-SDR: 6GIBU/gItMgzDDq+JHaM4D97uQ2sy+SsX3F3eqL3LBwx03+FLL3EGqmVnBcynIUOLGfwQoFiI/ p8G3tolMs41ENviRHtldRCH5ov/II88QZcxMGJBc0PClzfcYBBVnurX805SPHHiFdKxUSZoqsG 7YOz2QLDUjyH9loxOELCxC9L7hnpWona/Zwq/BZlA4Mdyz4XXY6CotFYwJVOEuzCOJTcDsd8vG p5Q3987RLmGTOBGFou88VxWnZZ6gurhB13CSMMKGEvYRq+52UOlX0yUphgSC8ZYwPgUaH41hLw mzM= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735451" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:28 +0800 IronPort-SDR: jMAWb8rnr5RV2+PfMY4p853Ss47Qm0Feh5gDBXTflCk6/4VBW6fR/KyxD79SaoDHKqv156OUUK 8OHOlRlXGFtWkHVGd8FD+P5Aessrrjx81usYHpRtY83Hl+vY8FfPRXFtxMvdD69XB2cgSQH3ZB s2IZTim+uy4OCI0VJAxgxjg3gdu04Vye4vck4i49NtkkFFRlHFyLHr9KjlJ2/kaP5VaOa/OOBn Zt7+N3MV9k8qo1XcXcCGkhkKIWj9exFk4GMeH6RrHkzQalcQOtS/xnJtSSFd7rT5u1Uk9bCrKh NHxEBKH796UUuHuLnzSWjLTY Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:27 -0700 IronPort-SDR: fDhiO2DbrHPbSVQ0c3HBZ/JieYu0XzUHQl+XCmve8ZFhsw65G0M3d8G2eJN6Rtm1iCENfa5V5T 1eSGhnS6BKF2ZynkkUAJYIszs7kDpLA+QXt1hZFezk92DIkAmTNDKWef3uExXHAJsDC6c4V1cd fVegSkcVkw2kbFfWqVRpgc/8Yc2fZQBHtxx8RQkgu/e3O4UYgYWvNyrWUz1MhB9SCkuJubrf/Y d77Rz6wOWJbJi2AMNlwcd5RHxyUUoxKPWV76q7JC/lf5XywpY36/tDDQf7Jjip+MWgX/m/AEpa l/s= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:26 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 26/42] target/riscv/pmp: Remove outdated comment Date: Tue, 11 May 2021 20:19:35 +1000 Message-Id: <20210511101951.165287-27-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 10387eec21d2f17c499a78fdba85280cab4dd27f.1618812899.git.alistair.francis@wdc.com --- target/riscv/pmp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index e1f5776316..78203291de 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -19,10 +19,6 @@ * this program. If not, see . */ -/* - * PMP (Physical Memory Protection) is as-of-yet unused and needs testing. - */ - #include "qemu/osdep.h" #include "qemu/log.h" #include "qapi/error.h" From patchwork Tue May 11 10:19:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477049 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Ze+1IbgZ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZHS6q12z9rx6 for ; Tue, 11 May 2021 20:42:12 +1000 (AEST) Received: from localhost ([::1]:57218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPq6-0004bx-TI for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:42:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWr-00028b-P2 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:18 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWl-0006V6-Tw for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728529; x=1652264529; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=F35Wlg7ThlZkm1vRHn1Yuy4izpGJ5nEtQpXZGyOoRmY=; b=Ze+1IbgZjp9ljrIJCby+1QDxclBwGBFVBJoZRFwDZwtIJQ1nptmC19nb TsuJBsX7lKUrPCKisUfLOuz3egsvec67GGqSgzopoO6XU8f+loKBaw6I1 wga3RJi3SWzQHTEx+zv/5DFG9mv2tgej75zS/0SeeAXhXZTtV0zBI7at6 7mlHofGGp+GYc6ZbdHotQ7d1CpldeNq1S8hlb4uO42pCvysTurrKflmK/ Vp4v6Xu5Rs94oVR+g9B5C05aJoNeS0KWq3YVVNmpRldtccsSfLA0XA52j PGG7db2iV7FVCi8slj+QFsRZlg9ZCVZJeBJHdtRoqsYCaYAPGuZoaSlEm Q==; IronPort-SDR: Pb/FFiHv3qGd6+CilncN59oVDr6hSd6WLv9/4r9CVmAe/r8/00T39uZPlyTvPN9I92Da3vsMYJ lBtwBVsCJXdLRUMYOedhUB8cp8ILsQ+lOs5GxMrFn9vD/QBIsKd2rB0lD1XNTbnuSPYjvgOCDH U+Y2SKIYgSs3Qrod7WSb9FhVXWhrNLoFevHrMGWN728Ina727b7qnFRc81AblyUdFwcaCjd6cb qu5FtdeN8YR6jsSmCm/OwZk+Pf+31IGoWaru6KoDlQ/AczDiDe7lrrJY7mPEnwsnRMeY2uvqCu 9Sg= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735458" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:31 +0800 IronPort-SDR: XCTANfp8H6SFimSowxLvJemXatdxBk8H23VeoxOsWBuIH8d5FMFQWWVAfCvq3rTGxlAyWhAZGB s9DcBhQnd647aq7Nt5TmuJE8X5hbH57soV5cfdWHBwPo/6Tq/1JWoHffbyBk+3FhPTlB1wqN95 cpY5HWT8PhVPNsIdKVIlFdVW1BOjjTiEf5KJGDgsqVU6F+Z2g5VPezllE39USvt0iNus+DtuCN BK6jyZdBEA01zYLwEACjj6e7yUnk0fzbzcId1JNB/pf2d9FMCfh9aRI6NVWDbM0y6xL5XaQSxI vfcbQktZifhCN26fU8KxSDKY Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:30 -0700 IronPort-SDR: 63A/ddUPBuQfptyNrUXr4j5D/anK080GobMfL3sTV51yHKyi0MoMXzp5FWOPVT6ivsPeg9TtC1 wRh5BiaGZxvVr4r7+OKXUwnHpDHvnzDnCTN5iJMfQBEWFjyM4/eJ6WCgAaNfX0+AZ0Dt/lc2Th w+yU2RwRBiPSbg39Kj7WNn8gmIjvzFye3BEvQVuXhsCllaGUPB5Jh9kO6yIYTli7lEzFscKmGs e80vyAszK4rkzyJtjrvHqGYOqXiCNhDadcV5JUBhnFY5qEC5SVhUek9EeM2WdhDWdAOTUB7KY4 WeE= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:30 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 27/42] target/riscv: Add ePMP support for the Ibex CPU Date: Tue, 11 May 2021 20:19:36 +1000 Message-Id: <20210511101951.165287-28-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The physical Ibex CPU has ePMP support and it's enabled for the OpenTitan machine so let's enable ePMP support for the Ibex CPU in QEMU. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: d426baabab0c9361ed2e989dbe416e417a551fd1.1618812899.git.alistair.francis@wdc.com --- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 66787d019c..4bf6a00636 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -202,6 +202,7 @@ static void rv32_ibex_cpu_init(Object *obj) set_misa(env, RV32 | RVI | RVM | RVC | RVU); set_priv_version(env, PRIV_VERSION_1_10_0); qdev_prop_set_bit(DEVICE(obj), "mmu", false); + qdev_prop_set_bit(DEVICE(obj), "x-epmp", true); } static void rv32_imafcu_nommu_cpu_init(Object *obj) From patchwork Tue May 11 10:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Q8PZTEqP; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZZH1ctYz9t18 for ; Tue, 11 May 2021 20:55:02 +1000 (AEST) Received: from localhost ([::1]:35690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQ2W-0002wR-J3 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:55:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWr-00028a-Jg for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:18 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPWn-0006TG-S1 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728532; x=1652264532; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HRFnRKpT6eIKGkJmmSWcNkwahgPJ7f2r03ru00s2A0o=; b=Q8PZTEqP0DWVxfrvxBuYPLD3lcxKrixZBBTxAZN17dwSpd0iGIPIRTr4 +sOVUtjLGJ1q6yUo9twVfXs4VZ8osCMbbGyT50mfplSlHiTvAu0dCV3f+ CWyVnHdIUViy+WVU1DbPHHZwqY4IEh79Hg58cPA6Qblb+EC7Me3/iyMDg gYCWTyoUcVKhpIoYGjS497E7tv7k/ASyVQKCCYKrlbeWmSZA186KBU8kl rnvT6SJjd04bcvM2zPyIwshCcH3DQa0G2zk1KjGK+4Q4LZVP+NN1CA99J U/lFrHmwnhr7ZL3Na87eAk6vKg+820TEJPe4+Nh3gP/IHdHh6uApvgzXr g==; IronPort-SDR: C6e4Y52y3jZuoHhOut4HlqGpfXglS9VlmaM7SuyHdrXrXvhc9YfOZtaCQ3iDTju3QyuMlteC3F VJi41M1ZHYscLmInEVkY0GndvAwrejY6d2Fyn3LguDnhufX1ne3zi9VwWKU8bAsxTgHNAzrgaB XqVR3euClcrBOI1ZNuwFUETKMHxvRi09ZnBCqX/V0zeNgB2DdX121e/MVIVrDhjMtLF1uiz+pD Qn9Qwa340dr0tC6bJLphtKpOIA3iuoKngCeADwvWxc8I3eAkcmS1jTQwrwNThTnjXprOkQIDZ3 P8s= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735465" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:34 +0800 IronPort-SDR: obC5hgSJrKQrs4SpJjpQi2pzkX4wAPBnXQXv7LjNki95rj1zeDwHPv/ZVUn14X6sPrPsXfGfeG 8b7VaW3ZuUXJLxbq3NvDej0p4CL2+huk/hUuyXZWE/XglGUvrJzW35AJPsmVPW6uR8os7L7Vf/ wTOW/6BNtvjlz6ugEwzv0lby1ShYulvZTerJG2ly3MbflrQNj/KQYt+xgzIfdItQXb9KZKJ5PH 4Zc9eyxrtuEdBLxqYNCVFcaGajMjV+IIYmN/qSfgXbEpS+2MJ17f0JdoO1CYj1k24GY7rrQeBH J0dxMugPgvs9x3AE6jzzd1Yq Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:34 -0700 IronPort-SDR: KSrScgw1pJ94opK/R7DkGNihmFrBDAWgt7Pjl9faDJ6neChGlVXT7aVbUXfoBR5Cu77FAreiEh zT95h3L/tIEZYtquN8R/ZHw+48DQQMrUBmKxCp52XxyzxV/vVH4YZGAt16+35Q70pqdAHYpoI3 zQNxRhy170EaKGEY9mmbMN6LsPymdzzuKTVVPZK4KZoyOJSoAaosTvMfsspFx9dpy2dDOnT2YQ 4G78PHSayYlKzwnShgl+ZgcoeQZIe1TEKmR1shkisKCOcQC0KtRCaMLycArDodfu3ddfi73HzW k20= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:33 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 28/42] target/riscv: fix vrgather macro index variable type bug Date: Tue, 11 May 2021 20:19:37 +1000 Message-Id: <20210511101951.165287-29-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frank Chang , alistair23@gmail.com, Alistair Francis , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Frank Chang ETYPE may be type of uint64_t, thus index variable has to be declared as type of uint64_t, too. Otherwise the value read from vs1 register may be truncated to type of uint32_t. Signed-off-by: Frank Chang Reviewed-by: Richard Henderson Message-id: 20210419060302.14075-1-frank.chang@sifive.com Signed-off-by: Alistair Francis --- target/riscv/vector_helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 356cef8a09..4651a1e224 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -4796,7 +4796,8 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \ uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ uint32_t vm = vext_vm(desc); \ uint32_t vl = env->vl; \ - uint32_t index, i; \ + uint64_t index; \ + uint32_t i; \ \ for (i = 0; i < vl; i++) { \ if (!vm && !vext_elem_mask(v0, mlen, i)) { \ @@ -4826,7 +4827,8 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \ uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \ uint32_t vm = vext_vm(desc); \ uint32_t vl = env->vl; \ - uint32_t index = s1, i; \ + uint64_t index = s1; \ + uint32_t i; \ \ for (i = 0; i < vl; i++) { \ if (!vm && !vext_elem_mask(v0, mlen, i)) { \ From patchwork Tue May 11 10:19:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=cCK6MSIs; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZqG04Zhz9sV5 for ; Tue, 11 May 2021 21:06:16 +1000 (AEST) Received: from localhost ([::1]:56518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQDN-0001Vw-5r for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 07:06:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXD-0002gw-G8 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:39 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPX2-0006TG-5h for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728546; x=1652264546; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XfXgYxiYX5i1x54fnTk0QzFVD6VSA4CU3S+I1f1IWWg=; b=cCK6MSIs1Dm2fbs3tVS6tEGWRj6J7NLQEndb9ZsbUxl/WYFs3W09cLFW 2zsS3+nnotrMsXmTBRmfSVA1UZtQHEnnbiOyJwtRvMrXRFWoy58n4yByP deB1ysYtzDovBMeMN78MYGGl5aDh7fkm2zvhU8I+UNXJJm7z8/OEchClL edCP+IKNmxd5UKiFMm3ayvY22lCdxITlCvM6xQnLM5DwdMvqJXzPLCrlX p+hHyPxyhNpoBXty+w/0oM/yibieVW4+QpUX54IynOFgwQdBafyy6fNIb 8/K4gMJcrdtAAN8C6/1JY/y40PI01fC3k/MFsfpvHge5ihzNrWkuoT8Vg w==; IronPort-SDR: CpqrA0gWL6sx7/TW36kPTFZAxwtkdF7xYsW3X7vuKGhPe2ACETOsnj7yaB5OJEpibFtEmARjtV 1w2wLeZNR4gIVSbb+sJckR5L2FluBy87QnWbRCbdYK7bSRRiFQXeLMVMuP47uZmdYJnNRoKo9k 1thwIn2BoNiRMuEy8MAcRMXTdEnH8lmkk20dQXwA/HgHWUlIIyDuC+u4m3eW5fajbRBfGHRyQu 3cGvbK37v4QRviyX5P5pBqn3hB7BwNatAmjgJDxFt9KFzpZJXO9gdt1EJgwOWQ4DbFBk8wHpbV R+w= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735470" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:37 +0800 IronPort-SDR: y/pRBR1xwoipKG2Zf0s/unhxdT+wlb6dMH+G3F5v98Jyk/UJjI2BTVpHJPKqGZjWp0qbg6mYBu kfJ8+/CExPumdL10ccCxoX3pkcv0R78ZG6ppAhMlRjOWr8rLfmqelPIGtZ6jIGPOnT280F9rwq lgL5x+q207xJ6aOR2US0trXn+FP74kSUka4vkwbTRAA7sg0OEL3Ijc4bQ4b3eNVihPbdmEvyDJ 6QLyu7AMtJjMvUWWB+1BnIV74CbI7od8f/+KyK2lUapWCmP7ttDti6H+mZqwv2LFh9b773u+bR cIKvPkR4AG7S27cpLVV5v/Qm Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:37 -0700 IronPort-SDR: 4fw3k+Lirku+C/1xsyfww02JxzE71pIgTm+Y1ayxcNcfwl1VFtbyti4n1McbmZzqEa2gn8/ln5 XZpo2n1zHjNHyQzkRBDN0DQtDkech8W3942NGaqouusGTysm2qgBsYFb2VaS3O1Hj516U3Wsm3 4PB2058pVTDiH0bAFiUgantN2UrSqW68DQlVR19keZlBCfoGGczcAb8riX19K6j5264+c06LyD wKiLAE0ZPmDi6JZh83nxTgRXpm91L5tvfzCHtzuXDk/63rcxIgAliOHzt0KDG4HD7DNUMQaWJq Zjg= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:36 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 29/42] target/riscv: fix exception index on instruction access fault Date: Tue, 11 May 2021 20:19:38 +1000 Message-Id: <20210511101951.165287-30-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org, Emmanuel Blot Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Emmanuel Blot When no MMU is used and the guest code attempts to fetch an instruction from an invalid memory location, the exception index defaults to a data load access fault, rather an instruction access fault. Signed-off-by: Emmanuel Blot Reviewed-by: Alistair Francis Message-id: FB9EA197-B018-4879-AB0F-922C2047A08B@sifive.com Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 659ca8a173..1018c0036d 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -694,8 +694,10 @@ void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, if (access_type == MMU_DATA_STORE) { cs->exception_index = RISCV_EXCP_STORE_AMO_ACCESS_FAULT; - } else { + } else if (access_type == MMU_DATA_LOAD) { cs->exception_index = RISCV_EXCP_LOAD_ACCESS_FAULT; + } else { + cs->exception_index = RISCV_EXCP_INST_ACCESS_FAULT; } env->badaddr = addr; From patchwork Tue May 11 10:19:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=fcF5jath; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZdc1Ts3z9sWp for ; Tue, 11 May 2021 20:57:56 +1000 (AEST) Received: from localhost ([::1]:43250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQ5K-0000hB-74 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:57:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXB-0002ZQ-Nz for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:37 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPX2-0006V6-7g for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728546; x=1652264546; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wh2ave+DSkoE9jb+Ncy1LkaCoi2qwdskqhXQshjT/NI=; b=fcF5jathcN2EhPFQl9UZM0zHjnHF2aL2IjDTZJROV0TaLontdDzLYXZs /xDruK6A3kYniwQFXANMxADrJgOf1YbbCLjI1px0v4rHrmQ5tTVCQlqQV 9emj52F0K7IFqdbb7fgoBIPDBzIGTBIVrVa4wCGeW815iKvxDM7MY2Hrg XxFW9qaCeTyK+Ytwz1IbCQXXD2K6rxoNxoLsKhVks2jglfqOrhyYpp4Yk 0Sqd8wO89i+U2l5oShYMoUqsEYEwB3QcskBnb+aIvMZn2zMgGa1DxwbFn PmfeiCvoZNpUqF2g6V7R/ZVnLnwCLtOPFWSZP3MzgNuPnfpyWaM2EdBde A==; IronPort-SDR: A23HbeZUSxClf+T/SbnfA3GXDAlt+SMIi73vmuwaq4YQef/GtuScxh5e21kzBXTX9sT3VA5slp vHCSgWc+swnMu9iZ/RuZ167AY34lA8t4lZm4xmKqMqZr0dEi17kADH7jCYc3HbgUDfQTj7u3HO EOWonrU7hxnvQ7/G5L1ZWU6U4zaoQVPb4ekiJslDAZIdnFlR7Orc9C2qluoXMMxHcB4AO2bXCu jzBxkYU8cLQEZqWQh3c5Hhii0F4Z8XXJq9+/d+eb3RPOf/z++PMupC7SqOkvLLsv09DAyOEkJ4 iZY= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735477" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:39 +0800 IronPort-SDR: BNvU/vQJLBveFF0bsa7u4mmE81QjCDVDQlEy134zRYnEniCfmwUvEqfByWikadMiee6NlriC5U jhYeSDzUpUvXGHuP2B0vFvWihyglA/Af/k7WGAiDt/ZRtucswPey6SMO2C223KEcfQlgG42Oy9 ZSGaOp+cn9mzpnFutOczbVrZrpmGDTViE1KI6hI+7+3S/lT4FYkRdBVNBY+Z7UycvegeOlPoPe nipnDMjPfGGNnpUhkLEMHYu0R2xbhwZT8bTKP6w6k5Z0onhzkR+cqd+eAACvAkitloHXM9cwKv SkaBHy6FJI+bnirm+X448JFm Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:39 -0700 IronPort-SDR: xK3PCtQQ1XJI3nNP2dbH41eRuwzSO0TW3j/WVJFHg4mZW7yO8k1Q8UUG6ZoRGl119VxzZE9i9l OWgHgPzrRsFMce+ner/jdLrJOlWLzwxEzMhbif+n9rT20G77x00GE6sAnmj6pa+vloZkY2PT5I fWh0ALua6Ck4Jay377mFdl6+ifrqLKm2RIXbCI4lB+L5ij5i5vpx5ien+ixZY89gPT4TsyIsA+ Tv0FGgTlprbvMiSUWfqo5ITqmFDRgFWFCqB56TREW1+P7cvF/PlUuY8GaJPgOEZSQAC9+m6z2F tLw= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:39 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 30/42] hw/riscv: Fix OT IBEX reset vector Date: Tue, 11 May 2021 20:19:39 +1000 Message-Id: <20210511101951.165287-31-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org, Alexander Wagner Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexander Wagner The IBEX documentation [1] specifies the reset vector to be "the most significant 3 bytes of the boot address and the reset value (0x80) as the least significant byte". [1] https://github.com/lowRISC/ibex/blob/master/doc/03_reference/exception_interrupts.rst Signed-off-by: Alexander Wagner Reviewed-by: Alistair Francis Message-id: 20210420080008.119798-1-alexander.wagner@ulal.de Signed-off-by: Alistair Francis --- hw/riscv/opentitan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 557d73726b..7545dcda9c 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -119,7 +119,7 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) &error_abort); object_property_set_int(OBJECT(&s->cpus), "num-harts", ms->smp.cpus, &error_abort); - object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x8090, &error_abort); + object_property_set_int(OBJECT(&s->cpus), "resetvec", 0x8080, &error_abort); sysbus_realize(SYS_BUS_DEVICE(&s->cpus), &error_abort); /* Boot ROM */ From patchwork Tue May 11 10:19:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=LZxMRbb0; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZjk5w0Tz9sV5 for ; Tue, 11 May 2021 21:01:30 +1000 (AEST) Received: from localhost ([::1]:49626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQ8m-00053x-Qp for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 07:01:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXC-0002cY-BG for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:38 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPX2-0006X1-Pc for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728546; x=1652264546; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AqdonLUuZyYbToc+r7mOqmQfOKiL5G8dfgQnAVG1UWQ=; b=LZxMRbb09tROEzyUijtNZLYuu1IZGljPr0gTcPyPgbVkUhJ+rRia5fSH A/bFUguTAk4Eatq72i3bKgbYIQXu37GyAuHNwqaKpKxcG8cCruhqehG3A fYJ+yLETxFNeu0QtI6B56BXC272GUwcki9KXfijdaWA16vGZgH++qlHNb IGwpN2PlBCThth0gQ8zLH+CzArpqa9ksjjhNqktYNE4+on2KuQERA5eZB VLbGhIws0/GRwq1nAAcAhiFfqMfWPObAEWffFJDXkDArIldrUyuHIK7ws 3MQyc1jro2PlldIS/CuWrnWK+SmtUlevf/ollrZjVxAcXqqG4k2UA4Ybp Q==; IronPort-SDR: 5T198sX1/wjDlWZO5AF29uA31sxUincAdmqTulDaWRjfkNVYNdw3x5G8LFf1wsvQND2DeKIF9w 1SlDTjLd9e5YD9jvzKZQqwlIG9a6yoeHaM7WDz6lC6dopXfUXVkWVcPd87B5FMbQfmJqYP4Lvk GR5FH3YS+8EnekG4iGtfopoMgWQkf1p1ZVYQvXT+QeWh8nFhAE6i/LK1vPSw1XRKXFV633/N1h JhPdP+h2So1a0ke7XQcCNfSOTJbPUFYqhrJVhXiZnI+vo2EsvICQIUhe05aLW3Bl6DyLeowGiy 1no= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735482" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:42 +0800 IronPort-SDR: zSHzThHs/0WWY+TJ4S6NBPWjputc37JI6CD9E9uQxD0JmEXUY2JW865OUhQDZj3nsMV3YdbnWF zjmN9IbkS4KJybqZ07Dr7AIBPn2bWFwBIoE9es1YKg+w7Z+NCTDF3QBvn3aAV81AtyvSDliWTw dN9gTj8N2nsPdKXGrVaHRqhgeFR+2pz7DZBkciodLPnrngdM0MtS2cT3TyaRK7CbbcvyQMZgmR Dv2/oTMDVeFMhJzzZ0Cv/BDXcyK0sfX3+qa3pDmODsw6fyeDA/EYi0QirZLtAaOpPIVxEmwyei 4pwH/3AX3km+UUQgHdv7xY75 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:43 -0700 IronPort-SDR: gfoA+7xRFjMs41qasJfwx5sdXdy2t7alYJHX2uZN+vUB9BuDoPl/cNRRxXovs94Pqp/zAnKTpE mbcRk2VCkYYiZZvvJFDVzyt0s8OnB35FSlEJpWryno8nX72nhAXfk/TqC6j//jPPT7/ywWRKnj twAj7ESLc/nXgM2DLExtiW8pFqn52SDmMPahpQ7ZVQOJvHiL+OniQ2FM/NqLFdXGhD/NXnYqAH w624GjuD7E7JwS1K7I/+1v7Dvac3NUhGlcpYQ6fwiXa6JtCAUaqCKqE24WvuIFJ0Br/49xNsgq Uq8= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:42 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 31/42] fpu/softfloat: set invalid excp flag for RISC-V muladd instructions Date: Tue, 11 May 2021 20:19:40 +1000 Message-Id: <20210511101951.165287-32-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frank Chang , alistair23@gmail.com, Alistair Francis , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Frank Chang In IEEE 754-2008 spec: Invalid operation exception is signaled when doing: fusedMultiplyAdd(0, Inf, c) or fusedMultiplyAdd(Inf, 0, c) unless c is a quiet NaN; if c is a quiet NaN then it is implementation defined whether the invalid operation exception is signaled. In RISC-V Unprivileged ISA spec: The fused multiply-add instructions must set the invalid operation exception flag when the multiplicands are Inf and zero, even when the addend is a quiet NaN. This commit set invalid operation execption flag for RISC-V when multiplicands of muladd instructions are Inf and zero. Signed-off-by: Frank Chang Reviewed-by: Richard Henderson Message-id: 20210420013150.21992-1-frank.chang@sifive.com Signed-off-by: Alistair Francis --- fpu/softfloat-specialize.c.inc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index 9ea318f3e2..78f699d6f8 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -627,6 +627,12 @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, } else { return 1; } +#elif defined(TARGET_RISCV) + /* For RISC-V, InvalidOp is set when multiplicands are Inf and zero */ + if (infzero) { + float_raise(float_flag_invalid, status); + } + return 3; /* default NaN */ #elif defined(TARGET_XTENSA) /* * For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns From patchwork Tue May 11 10:19:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477048 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=I97vRjWN; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZG621cNz9sW5 for ; Tue, 11 May 2021 20:41:02 +1000 (AEST) Received: from localhost ([::1]:53602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPoy-000245-8M for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:41:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXO-0002v1-OZ for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:50 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXC-0006V6-2t for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728557; x=1652264557; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BXqWpLcc7+g4pGC4+WkIHTkL2rsoYwibHzP3HV8BwNI=; b=I97vRjWNxF7DRgmuKBsNt9WeDd5XpENdraCkHePkmPl/84wzqr2DMDUK 51NK/L+BlFai+rAGc/Ew3iB6KrKHXNmrmdPosfzViD6bblMWHlADA0cnH dR9tK7gjjihCT1lhlC3YTeQxls5IbybKrfDvFAXuxbtGREQu1cfqt79TX QHXFzTsEL2QtZ6PWf8WKtLWQpwILOz2tOMzgyzuOsxF8mkNqcBRo9Ys24 8HPXbSoGd6fjIL1WbraE7Cjzkwct7D4po+/vFK2oUFoWxJf1mV40JvYPa 0gg2EvPE0A36LBPdy+DJcFZ8H6/vhfn55kudLNY4mza4Jf6Jn7cL0CxVD A==; IronPort-SDR: rHOeiRA1r4DngoasLF1NfbQrWzEeDME9qUcmQ7efsCfDAx2KHilfgm/trITpzlOBAMGTdcFFw+ zmsvG1Nvi2uEFNDMQXlYfZAoefggI0F4mKNra2kgLqBG3LX+86x1sMkKIwBvJWMrabU0TqPqmS waY7q2edaL5cMjQzLSAWmvfnjbW6ejQcGT/6FLgoRn/RW/ZBp6WXFw2eKWjbs5j38jKY1gqr+y BEOEk3rKfPKugnWIpzaQExiW3ol8Lrvg/GN0QbyRMhRP3zYmgTl5CpiBZMQxLKQpBOLB6hamAs cXc= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735488" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:46 +0800 IronPort-SDR: 6KeNZG5oAkD2FEdUcbpyJaxOFE/lTkkRxvj6sfM4nOEGltey6hgl/+AsAO2uBS5yGzYKoHEj5W i2fJWjBNPOzwSsZQfH2PaY9jt+OVCaFRzQ/t8tr5B9EzzPVLrazJ9OFYEF5NENiBeKVhmuGQXu 9o3ITJ0gmDSTthkhxsgCFWceGDYUSum+BySqGgfoutGfNuTf4YzE9A0N8kHf93ofsTXdNXYB4I K12ajWMiedSpH1bHGdhs0YMy3+awTWl9W7Vs7xKbO4IGwz+Vg/oLiD11PmS01KTg5bUnxR86Ru 9FhQP0m0ijC9g+YilShKqDJy Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:46 -0700 IronPort-SDR: hCdulifEmpLkYiWlYasedUcLJX4NZu37oaIw9ORlTbJxhku5N0EGBJ5Ubef9b8TuD62LtbyqD/ CwNL/36UufPN4STnTByCQNyb42xyquRcGkSXZPg8Z0j6Ipm4wR58ZpH6Hl10IN5OliKeW16UvB 1g/7670TST7rX0XcPV66iBBdwMwX/FjSUP94xsubrcrMfimJinSVoUCG3MmLPVAzb9k2a+trQC XIJTcRX/cAYh/OmICUd8D4m0j0a/4xFtXEkNg2y0z9/DrM3ncktBmSmJtZNVazxAWWE86f87Tp eiI= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:45 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 32/42] target/riscv: fix a typo with interrupt names Date: Tue, 11 May 2021 20:19:41 +1000 Message-Id: <20210511101951.165287-33-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Alistair Francis , qemu-devel@nongnu.org, Emmanuel Blot Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Emmanuel Blot Interrupt names have been swapped in 205377f8 and do not follow IRQ_*_EXT definition order. Signed-off-by: Emmanuel Blot Reviewed-by: Alistair Francis Message-id: 20210421133236.11323-1-emmanuel.blot@sifive.com Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 4bf6a00636..04ac03f8c9 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -88,8 +88,8 @@ const char * const riscv_intr_names[] = { "vs_timer", "m_timer", "u_external", + "s_external", "vs_external", - "h_external", "m_external", "reserved", "reserved", From patchwork Tue May 11 10:19:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=m2eVkVnp; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZvt71LRz9sVt for ; Tue, 11 May 2021 21:10:18 +1000 (AEST) Received: from localhost ([::1]:35150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQHI-0006Ir-N7 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 07:10:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXZ-00033H-2v for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:03 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXM-0006X1-P3 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728568; x=1652264568; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JgM/gLIjni+dyO7wx31lSD4YXhtJoi1y1oqkheC/Erk=; b=m2eVkVnpIHhAczxT26Pxs6t7OUhtP9QkovAFSv25bPOxZk6iUplRBKmI L7Yut2Ea4bCtkMZBMdgR0Q0j+V9ngeWdAWcKqdKvKKeJ0nBqs01XJbjh+ RNIAmsoF68BciB++S3AKGAlWDF9sHisy1sFhKBF6GuqSnGQdOzhRzd+PH U5IAEQUdtj/25fJ1ZLf+MRjveL67mVdge4uboDQqmimj+NjNBSv0Voy/H 5zyt81rm336pBs/rGRB34j6qDS6dwxUuTx8RP7FJFFycJqys+PAPlryNK XAXW3G+xPfcC+DU4XD50CqbX9XmDIY6kyPUB78F4PuM9fXU65gntrmP4L A==; IronPort-SDR: UhaeL/ZnndQv8qErUJaU/ULt1QuEioCXT0LSrQio1Fx7HrPt3Rpmsuy57reDr6GEDhvGh9aBIN E0MVnlkAXApHNEAWZOXMlPiJCWgWmD+NljghSFMEbhmOSiJkikbUNcAa/cWrtiC/+oAxaIj8kM qMiyaeuqKN70aybyddpQnvU2KDfSlkFMOokbADReF8jAGJC7BFEHgp8HpXJmAUwXt7IXlwOWQ3 wC8h3iydBa3RSwKDzPG4vqTY/jtOHs0zQDmobkJwfiPpYWLOMVti6pf4vXJAcSqd7k95Jnl/gn L1o= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735492" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:50 +0800 IronPort-SDR: 6nWf2jd4T7sKb6tpviMMf9uxujdE+v3322OoABuzzoj/TuP559wgNWHasHnDKSNWNMGcrtaAR3 MhUH5Utpfhin6P996Vx5c9vh2mjtekVFk8/+EQchkgEme9zEZhep3LOkRSJeOxJ1ZKEqfaU0Rb cUrJWYSyvzz6i7Rnz4ZUVuRQxBS//m+EPZKkLP7V0OwloaXDHsKdS6TiImfjN+OUit+uSyUdiP fyrxu1HPBHW8O0AqSxbdSdAh3ZBMozgVc8XyT5Ud9ix5ynxvGTEy+yL3vDZlnIemjqtUah1rtG YDVvjG/gn+1wL1Yx6cBmRFBa Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:49 -0700 IronPort-SDR: Z9KgeFdRYIColcrMZjxWZh+fdwvT5jtFAkxyZwI/2GxU4QURm3MrC/0EfT7wrLuPHILip5QiZS /LHTYq0U3ghAx7dY30OkN7BrwbSSyymp/EP20FBZcCU2Vfn4NArZLi+fdNx50YwbMObYJT/Q1k NddW6Yr9tJwtMJ9Hu6WDWOj6X1ELcDuN/bxHG3yC1Az4rLSDnpqUdVp3CLgVZKyKqE7py1n5qE xZHHXejWJGtkHLy4lIERAqQZeMCkMvmCxeNCrm4zrPByWcqQu4kxoA96PsskSd92nzXX+/B8YA sh0= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:48 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 33/42] target/riscv: Remove the hardcoded RVXLEN macro Date: Tue, 11 May 2021 20:19:42 +1000 Message-Id: <20210511101951.165287-34-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: a07bc0c6dc4958681b4f93cbc5d0acc31ed3344a.1619234854.git.alistair.francis@wdc.com --- target/riscv/cpu.h | 6 ------ target/riscv/cpu.c | 6 +++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index add734bbbd..7e879fb9ca 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -54,12 +54,6 @@ #define RV32 ((target_ulong)1 << (TARGET_LONG_BITS - 2)) #define RV64 ((target_ulong)2 << (TARGET_LONG_BITS - 2)) -#if defined(TARGET_RISCV32) -#define RVXLEN RV32 -#elif defined(TARGET_RISCV64) -#define RVXLEN RV64 -#endif - #define RV(x) ((target_ulong)1 << (x - 'A')) #define RVI RV('I') diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 04ac03f8c9..3191fd0082 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -147,7 +147,11 @@ static void set_resetvec(CPURISCVState *env, target_ulong resetvec) static void riscv_any_cpu_init(Object *obj) { CPURISCVState *env = &RISCV_CPU(obj)->env; - set_misa(env, RVXLEN | RVI | RVM | RVA | RVF | RVD | RVC | RVU); +#if defined(TARGET_RISCV32) + set_misa(env, RV32 | RVI | RVM | RVA | RVF | RVD | RVC | RVU); +#elif defined(TARGET_RISCV64) + set_misa(env, RV64 | RVI | RVM | RVA | RVF | RVD | RVC | RVU); +#endif set_priv_version(env, PRIV_VERSION_1_11_0); } From patchwork Tue May 11 10:19:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=OQU3vT9D; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZK12rxGz9sW5 for ; Tue, 11 May 2021 20:43:33 +1000 (AEST) Received: from localhost ([::1]:60600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPrP-0006wg-D3 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:43:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXR-00031z-J3 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:55 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXN-0006TG-Q5 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:22:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728569; x=1652264569; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kX2Xv9V0jg3JpeHNNRl1F4kvINea/oqMxr6h/7opXw8=; b=OQU3vT9D4YQ2A3OrEpjGSwOBIncsB10PiudLZ6HOnJw4gKQdDadRn1+e iAejfood//9mLiTaBk2z3Iz7KlfcIZ1OQ2UlrTG+atsmHVPcIPEey+E25 oZG5wHRoQpmiEHZVbY2SCMW53YB4PmHth5fiVvGse4OiIOXtfeP0YvhIc MO5P7exXfdhH7q8WweR0Slt/QvDbJ+BNWpRAhVOkhw3hzhh5fvaMMPTmR XCPsDYE6bTfmG6ib6759MyG6X/UVojJVwcYUlnu/Um+yLldnbH9ztIa3U bJL/ANUbHIgNL3J7QWDrig4zcVCrbTBm6MzS4iShtUfBdjffapXLEF/RT g==; IronPort-SDR: Cop+ns6xH8gpF4rfLhExvBCjQcIOP+L1PanbZBfCi00fKB+DdTX2ulw5sbz8nhZzDixLZUzH8j v+qrR/uSgAuME3P+rvFlXiTEPlt1P/Bb4fmY1OGW4qkeVhlrBqlF5ETAuAjP/n9X3TjA6hrPek ZiEfqwk4AG8d6ftwcHCz+uc+EuI3+xT2gsyZsSPYiQpK8TnCmAleF2ckZX1UkrRwHRoH+gqlsM dmnWNRneaRng7WgtcMvaaeLv+X6RtW92jV1DUaCmnsJt0c4F/E9vVZgRtu8nZv47RSOC2GvDu7 pRc= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735495" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:53 +0800 IronPort-SDR: PZ840mW7fUrg+t0Iu0MlbI0I80+iFnn8ZOlCZNdfsJh1OsJtdZKc3u+AMgM5oCd+munGOz4U+C SnyqebfD1ou686PaQJeagz7H/RhSZJtYi/qu75XhsM3pXOuPJmiApaJiBmhrlv+cTj6iC1N+hE hUBbjopGkG0UTiQ8vfvkwfa1jxh5wVHETiGVwmyt1SIcBOto95IP3lxMu9+eJdtLzLmluc3HNO 4zfo7io8ALfxuRgHyDzeLQcxgW6pC37qv2mmsqxgw0DXs8uED/ac7lRWKpI1DuxSAoiWy52+fz /6p/RnD+6XKW954yTwQebTZe Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:52 -0700 IronPort-SDR: ICLNxL9tr9M0RlkL958AJiTS2agnMnwWwD+7SEWLPE+IqEw93WpuIsaaLzzeZlEReA8A5DrrOf SDGewpg33d4gVTvk9QemcO1M3Ov09eIBiFUHSydSgtzUsIv7/8bxX1Aphr0OdYnJqDymaOxMPP RLFhVGNoNbY0YlJDhCIPk3ru8a4LLKwMK/bB6f+1rxdMOkbTYOSK8dAkRzlVOhwUY0uyf+7CDo 5rtNtk6QU1wTvFs/X/KdLz2ijb+ES+NuIMSHQtnggJtMYNzBQSvfaWP0uAj6Lk1ZwKCLm7XBHo pnU= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:51 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 34/42] target/riscv: Remove the hardcoded SSTATUS_SD macro Date: Tue, 11 May 2021 20:19:43 +1000 Message-Id: <20210511101951.165287-35-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This also ensures that the SD bit is not writable. Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: 9ea842309f0fd7adff172790f5b5fc058b40f2f1.1619234854.git.alistair.francis@wdc.com --- target/riscv/cpu_bits.h | 6 ------ target/riscv/csr.c | 9 ++++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 24d89939a0..3a0e79e545 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -403,12 +403,6 @@ #define SSTATUS32_SD 0x80000000 #define SSTATUS64_SD 0x8000000000000000ULL -#if defined(TARGET_RISCV32) -#define SSTATUS_SD SSTATUS32_SD -#elif defined(TARGET_RISCV64) -#define SSTATUS_SD SSTATUS64_SD -#endif - /* hstatus CSR bits */ #define HSTATUS_VSBE 0x00000020 #define HSTATUS_GVA 0x00000040 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 97ceff718f..41951a0a84 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -459,7 +459,7 @@ static const target_ulong delegable_excps = (1ULL << (RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT)); static const target_ulong sstatus_v1_10_mask = SSTATUS_SIE | SSTATUS_SPIE | SSTATUS_UIE | SSTATUS_UPIE | SSTATUS_SPP | SSTATUS_FS | SSTATUS_XS | - SSTATUS_SUM | SSTATUS_MXR | SSTATUS_SD; + SSTATUS_SUM | SSTATUS_MXR; static const target_ulong sip_writable_mask = SIP_SSIP | MIP_USIP | MIP_UEIP; static const target_ulong hip_writable_mask = MIP_VSSIP; static const target_ulong hvip_writable_mask = MIP_VSSIP | MIP_VSTIP | MIP_VSEIP; @@ -788,6 +788,13 @@ static RISCVException read_sstatus(CPURISCVState *env, int csrno, target_ulong *val) { target_ulong mask = (sstatus_v1_10_mask); + + if (riscv_cpu_is_32bit(env)) { + mask |= SSTATUS32_SD; + } else { + mask |= SSTATUS64_SD; + } + *val = env->mstatus & mask; return RISCV_EXCP_NONE; } From patchwork Tue May 11 10:19:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=ApZW1oVH; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZLS0gLJz9rx6 for ; Tue, 11 May 2021 20:44:47 +1000 (AEST) Received: from localhost ([::1]:36262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPsb-00017U-KA for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:44:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXf-00038u-TW for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:07 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXZ-0006V6-3R for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728580; x=1652264580; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WQcSS1oSxULsvx3rcazGUleTjavqMGxioohI8At+Ha4=; b=ApZW1oVHV7YJ2mN3DelI9/mkvO9sptnVfjfyK8k/h3sMEcZjwyyq7B8Z ujmTzcmcRcoeIjGl7VBsAVMrPgBK0OmzE2XlxwZ5U1K+etiLNCAgejdfl sYBEnAq3WAF5c2Hg2IAnbqZoMJ+t5wF/ngXeKsVZs8A0KjjnwJrX2mGRe SkBAHt9jACvwAOfJKHTWIfXG2Tz3cygRDw//bJVGTtqgoHmTLnbtxNZJf pWtTBqb34f5oCETtv6W9CY/lQTPH+mdHrn7pnkeadAyy5fhucyIWav4eK QjzOLyvtSmOCvt0+25629gkk0g+8K0zfwFGZL6FDNJ8LsRxlwbxUXPW+9 A==; IronPort-SDR: inYaC1VYrM4fJzMvRjQhh3pmuRIY4uqbm0SJbgs0nRy7zUYLeUt72ifDRWv+mt7skLwl90D2BS lJ7b2RKwsGgEueuzMzo9wJNoClN93a2Zq1bF6OU7qyX2nCR/w8MFAUusvrfmUO1RUWM1JgV4e4 sy7FHiepZYZ+ftf8AA1yYGm/O9JBHgomBdxtPZw27/halghfzilRQPUjlf5hCed0JggCZuKC8T JIxMqeuSaKqKJc8y5Lzt/8oZzGZ4Ruzy4gC+0XigGPoS+RgfhzYC751yXHxXA/cuV93pBFxD7l 3Co= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735499" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:56 +0800 IronPort-SDR: b+LmsIBPBaaJ10CS1U+dlI5UKhT29QIW6hEY9dSERZ13+xZyhwbLfhQeffwxbB1qesZ79U2cRX pCUm/NnambXml2j6gOzdus8LE+i6H3zEBGVJ9CzEBpl1AhygJOCXf9H43jDgDZGVnsZAJqG/fy wbw7Ln95JigyE/0/J/w9XTG/M5IrWAukzXh4MLLoGRTgMumOm4MyL0qr+rsAdmClxA6dFv/CUI 7F7C6EXo7e3uyett3jw7KZOzvGJuH45vNZOwt76uPFiXvwW/3vBohYnsXhNYZ4Fd66/Hu22GAo AjpL1KQ+vsSLwufvOIiZayqE Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:56 -0700 IronPort-SDR: /deeAPNDNxMPf7NPp07z+L1uXv9dt1UqHYfjkBL1skS9cNEbVYmm7rtzUhaBoOuR9VUBFqsgxC q9vTixAvtFwE2laKaVVMfmcCUUHaTG1XLbV37+hmWYwwFQp5/0nuRg0t0FZHsx7Zq0ak1w0aC9 EBN8VjC2zJ5mxrK7bgBf4NDVo/18up7rbenW4WttXNnNRvTXoqQObyspyVCLR/gyrN278zSw0/ V5IIbSroRdQRccXul3LHEH2TML4PubiX5+984hifF358UmUOXSZHkcxDlbNCwTmWC/yG7omQbl YbE= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:55 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 35/42] target/riscv: Remove the hardcoded HGATP_MODE macro Date: Tue, 11 May 2021 20:19:44 +1000 Message-Id: <20210511101951.165287-36-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: 665f624bfdc2e3ca64265004b07de7489c77a766.1619234854.git.alistair.francis@wdc.com --- target/riscv/cpu_bits.h | 11 ----------- target/riscv/cpu_helper.c | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 3a0e79e545..d738e2fdbd 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -195,17 +195,6 @@ #define CSR_HTIMEDELTA 0x605 #define CSR_HTIMEDELTAH 0x615 -#if defined(TARGET_RISCV32) -#define HGATP_MODE SATP32_MODE -#define HGATP_VMID SATP32_ASID -#define HGATP_PPN SATP32_PPN -#endif -#if defined(TARGET_RISCV64) -#define HGATP_MODE SATP64_MODE -#define HGATP_VMID SATP64_ASID -#define HGATP_PPN SATP64_PPN -#endif - /* Virtual CSRs */ #define CSR_VSSTATUS 0x200 #define CSR_VSIE 0x204 diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 1018c0036d..d9defbdd34 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -413,8 +413,13 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, } widened = 0; } else { - base = (hwaddr)get_field(env->hgatp, HGATP_PPN) << PGSHIFT; - vm = get_field(env->hgatp, HGATP_MODE); + if (riscv_cpu_is_32bit(env)) { + base = (hwaddr)get_field(env->hgatp, SATP32_PPN) << PGSHIFT; + vm = get_field(env->hgatp, SATP32_MODE); + } else { + base = (hwaddr)get_field(env->hgatp, SATP64_PPN) << PGSHIFT; + vm = get_field(env->hgatp, SATP64_MODE); + } widened = 2; } /* status.SUM will be ignored if execute on background */ @@ -618,16 +623,17 @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, bool first_stage, bool two_stage) { CPUState *cs = env_cpu(env); - int page_fault_exceptions; + int page_fault_exceptions, vm; + if (first_stage) { - page_fault_exceptions = - get_field(env->satp, SATP_MODE) != VM_1_10_MBARE && - !pmp_violation; + vm = get_field(env->satp, SATP_MODE); + } else if (riscv_cpu_is_32bit(env)) { + vm = get_field(env->hgatp, SATP32_MODE); } else { - page_fault_exceptions = - get_field(env->hgatp, HGATP_MODE) != VM_1_10_MBARE && - !pmp_violation; + vm = get_field(env->hgatp, SATP64_MODE); } + page_fault_exceptions = vm != VM_1_10_MBARE && !pmp_violation; + switch (access_type) { case MMU_INST_FETCH: if (riscv_cpu_virt_enabled(env) && !first_stage) { From patchwork Tue May 11 10:19:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=LDvgIF42; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZxW2Zhsz9sVt for ; Tue, 11 May 2021 21:11:41 +1000 (AEST) Received: from localhost ([::1]:40036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQIc-0001Eh-Vj for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 07:11:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXl-0003Dl-GU for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:13 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXb-0006TG-UG for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728583; x=1652264583; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T4xfBUHTz99KeO4XUesDnPxK/SiUu00qLVoeeLc7XQY=; b=LDvgIF425dGpYBhwaWwnt9HobO/8c1zzrzEnMyK0WNCcPMqDASXMRSG0 sa6widk0OXRZYRYcqIpELrwCvWrHJENpuxgEvKAbUQ9mQY2CNEaO4//5r eV3tImJWYf33mzC4S8O4wUiaiFlglgIFWcdZuLXiCaXgk99EH5W+Lec2E JsFLeOujq87892nYUymzELuWyHhiAuGNZG9qjuNzokmEnnqI1FMxwiHj8 3Oe+d9Sha8kTsdhhNZIeLiZFTX/NSgS9aaOmWJOMG0lGQe8CLUmL3m03b wDf3tEsPHZAeRTChwi6+0r+akG2bwuvFh7vATUL9ZFGbFkS0y4IbMQjSX g==; IronPort-SDR: +oPTLSX78Vo70YPQvPGEp/oqd6jxDNr3RMhOj1btKwffaOP4N8WGPUaYA2ETKksWIMYPXgnQMA mb4M4hWMx4n7ce0FYJolhaq8QPbLE1XHnBcTqjbcdvsmnjTp0PkEwFrDOTuf4fZYkm2k2dG8sR Tlw+eojgdwVBkLoS1UZf67bENLM8hLOFp4gyLbQfLsTfDBZ4txKzxbZ+x4tApLtZF9qMErr4vR nCHes3r7fctjIAX2SAKR9iQHTXZn7DA9FoWYZwyIGFYYvDuoQ5II+G2Qn5Oq23ATpcDMVl6RB9 QKg= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735502" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:21:59 +0800 IronPort-SDR: PwrKDVW8rNhmHLoQvqw2jurJIe3x5XtAquKR6Wr7N2DEkYrp7VlaHP3J3+YQfoMbAoaR1IeXmz 4RpkqLAs80Qo2rv0FV9nPkHcV0pJUEWWGCptixEyX5PPWSo9GiuuEg0Cgu1fJPthTaVtZzGcs3 ifWqn86AtC7psfvguawJZ1+WjQyTl9b4Ws00Gs9gYjgt7RwGNpx8ui7+0ICx72XVSpR4wPEMmd yJ8zVaKds9V4osIvi284TC4J0pWAqN4CmbnpGOhUdZmrH2hbRDLSOq2Do0NlLEc8aFmE9gIldX LQ1SD2yDqYR2xq/jPiOjkkJT Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:01:59 -0700 IronPort-SDR: m3XlLOAlJm2ouuzOn2dNGSfhLfWbLLGu8LSwmx5d/oI3wziFTZSdurwWllcHm2iHA0j8B7e/XX ldp4xldqbZXJOMKqAu0xlgD3wpF0wWct2PdQacnq5opb6UILqkU22O11wD5JjM/w+W5WFnAXq3 GgSth6bqA4bBBguY9waiKVf4aPLnyj0Kmu34omhqMf6HLxlbXxmV6eq8JiJzO4YV8acdED1Zo+ oIzhRfZxGdfKUMeBmYRO6jvC83F3CJ0fjlHyb5WLwxOWtzuMlMGPCi7LM7pLCKS1cGC4PxA7PS ABk= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:21:58 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 36/42] target/riscv: Remove the hardcoded MSTATUS_SD macro Date: Tue, 11 May 2021 20:19:45 +1000 Message-Id: <20210511101951.165287-37-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Message-id: fcc125d96da941b56c817c9dd6068dc36478fc53.1619234854.git.alistair.francis@wdc.com --- target/riscv/cpu_bits.h | 10 ---------- target/riscv/csr.c | 12 ++++++++++-- target/riscv/translate.c | 19 +++++++++++++++++-- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index d738e2fdbd..6e30b312f0 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -368,16 +368,6 @@ #define MXL_RV64 2 #define MXL_RV128 3 -#if defined(TARGET_RISCV32) -#define MSTATUS_SD MSTATUS32_SD -#define MISA_MXL MISA32_MXL -#define MXL_VAL MXL_RV32 -#elif defined(TARGET_RISCV64) -#define MSTATUS_SD MSTATUS64_SD -#define MISA_MXL MISA64_MXL -#define MXL_VAL MXL_RV64 -#endif - /* sstatus CSR bits */ #define SSTATUS_UIE 0x00000001 #define SSTATUS_SIE 0x00000002 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 41951a0a84..e955753441 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -538,7 +538,11 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, dirty = ((mstatus & MSTATUS_FS) == MSTATUS_FS) | ((mstatus & MSTATUS_XS) == MSTATUS_XS); - mstatus = set_field(mstatus, MSTATUS_SD, dirty); + if (riscv_cpu_is_32bit(env)) { + mstatus = set_field(mstatus, MSTATUS32_SD, dirty); + } else { + mstatus = set_field(mstatus, MSTATUS64_SD, dirty); + } env->mstatus = mstatus; return RISCV_EXCP_NONE; @@ -614,7 +618,11 @@ static RISCVException write_misa(CPURISCVState *env, int csrno, } /* misa.MXL writes are not supported by QEMU */ - val = (env->misa & MISA_MXL) | (val & ~MISA_MXL); + if (riscv_cpu_is_32bit(env)) { + val = (env->misa & MISA32_MXL) | (val & ~MISA32_MXL); + } else { + val = (env->misa & MISA64_MXL) | (val & ~MISA64_MXL); + } /* flush translation cache */ if (val != env->misa) { diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 26eccc5eb1..a596f80f20 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -78,6 +78,17 @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext) return ctx->misa & ext; } +#ifdef TARGET_RISCV32 +# define is_32bit(ctx) true +#elif defined(CONFIG_USER_ONLY) +# define is_32bit(ctx) false +#else +static inline bool is_32bit(DisasContext *ctx) +{ + return (ctx->misa & RV32) == RV32; +} +#endif + /* * RISC-V requires NaN-boxing of narrower width floating point values. * This applies when a 32-bit value is assigned to a 64-bit FP register. @@ -369,6 +380,8 @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) static void mark_fs_dirty(DisasContext *ctx) { TCGv tmp; + target_ulong sd; + if (ctx->mstatus_fs == MSTATUS_FS) { return; } @@ -376,13 +389,15 @@ static void mark_fs_dirty(DisasContext *ctx) ctx->mstatus_fs = MSTATUS_FS; tmp = tcg_temp_new(); + sd = is_32bit(ctx) ? MSTATUS32_SD : MSTATUS64_SD; + tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus)); - tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | MSTATUS_SD); + tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd); tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus)); if (ctx->virt_enabled) { tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs)); - tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | MSTATUS_SD); + tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd); tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs)); } tcg_temp_free(tmp); From patchwork Tue May 11 10:19:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=hlqv1rat; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZPb4RZmz9s1l for ; Tue, 11 May 2021 20:47:31 +1000 (AEST) Received: from localhost ([::1]:44838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPvF-0006vO-Bi for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:47:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXo-0003QM-8X for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:16 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXk-0006X1-Jt for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728592; x=1652264592; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w0SdTRmqXHH5oPpVmfVR5fdaYUPfuZPdbmGEgavaDUo=; b=hlqv1ratYd/L7UKcq4jKbRojfssXomvwx+uWvB7N/5UNc03q5doCFzXg fmaDUw3aIdhU9/AbZAUFcAgGqVxPC2sCMah8QHwJpvMVlj0NOWjqBz+JF 9EZ82cyQx2bfrYeA9eHZtrCnechaA8r+Mn1MwpVy8VSRzMC1rI6g70MYC y428XuuNyBSXzH5XoAKUsOjL7U0u6dUaf63uZybAo2FWyPkQBwvEBabCE fk19R7+bGC5SoL1iowSk6330MRX3ZwG7ym4ohzUzpqYmS0ef99OeJL43u xXPRUM0qwFKPNwdPLwVhcOJgaxpCRDBrB6QjzmOVegeKnryOCgKX6pVIy Q==; IronPort-SDR: JRXGJdWD41tgW2eOlsGfQBJARe7THvBXF7RY9PpdmTXGSJKH22UAYrQs9Bc/6MdaLhhs0ntYFj sx04orYDtQViw8bPEm2ZYnj7aeFXLGv/fOMi+s2a5krHwJ2hUnOlxei+Twv/PNOm4Axl4EaUxY D9C5hYKj4mpAM7QENVQSJyzEI6COsxavaYN+B35/VAJtTdErdv7q7QCu1z2nslGKQF42B2bO2D 849A0NlLDNRKnIa04i93PGD0iKvg06yGzduBSY5QO5TGQavRdAZVBxrlJEw4AY03E/viJJy0cR +Ys= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735504" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:22:02 +0800 IronPort-SDR: /TlkvjNJhKel8cxtja0eJcOndf/iH0VC9xlOgF56eRttgnfdYrxDXwKuYvEeUsZDHz6DTbQw0S DmwHBsMtalqcVGqy14XCJqfq0MIhwoencoLDCQPbJ7CWZ35JprYUZ3XdrSnTYrYBNr575hyMdS AzzCyXBrAfR2vEgRV+EcW4gteRbNPw7UAvsBe7GMOehMez+n/8TX58wryt1oCpe1xnCJW3fkF/ sNGo/IFy0GDAS423mKX0PMzxopKp1uqWVQku9ImsJooxi8Uztt5BOEbtc1n4NEosNbYTU6VjJW BSW0/6d+HgjV+8Ejr6xQNnSh Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:02:02 -0700 IronPort-SDR: PtVPIyVCCm0/CZGbwQ5xMzEw6I1GSayoeVCbUNa4Oiy+fu3sBhaBtd/245DoLg3HEAD3oR1xvR WJg6oYOjNzAH0cMixXPQo5iiKA90t4O0EESBqef3CcUu8kP7yHO3XQ9/pDzEThrn4mWuscHHQL 3c+FMbxJ7ToJDBKIhUqoIW+UD4yQaglSvi0lEd/+bkZJk+2VafARhFEmxVicNre4/UYjZWbGjw ktLamphswUqdo5eQzc3KQCACn1+Xpjc69/Wv7iPg9C4dbtWjcO9mc/I87RXnLCEAWqnXqNpxqs LZM= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:22:01 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 37/42] target/riscv: Remove the hardcoded SATP_MODE macro Date: Tue, 11 May 2021 20:19:46 +1000 Message-Id: <20210511101951.165287-38-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Message-id: 6b701769d6621f45ba1739334198e36a64fe04df.1619234854.git.alistair.francis@wdc.com --- target/riscv/cpu_bits.h | 11 ----------- target/riscv/cpu_helper.c | 32 ++++++++++++++++++++++++-------- target/riscv/csr.c | 19 +++++++++++++++---- target/riscv/monitor.c | 22 +++++++++++++++++----- 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 6e30b312f0..d98f3bc8bc 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -432,17 +432,6 @@ #define SATP64_ASID 0x0FFFF00000000000ULL #define SATP64_PPN 0x00000FFFFFFFFFFFULL -#if defined(TARGET_RISCV32) -#define SATP_MODE SATP32_MODE -#define SATP_ASID SATP32_ASID -#define SATP_PPN SATP32_PPN -#endif -#if defined(TARGET_RISCV64) -#define SATP_MODE SATP64_MODE -#define SATP_ASID SATP64_ASID -#define SATP_PPN SATP64_PPN -#endif - /* VM modes (mstatus.vm) privileged ISA 1.9.1 */ #define VM_1_09_MBARE 0 #define VM_1_09_MBB 1 diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index d9defbdd34..968cb8046f 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -405,11 +405,21 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, if (first_stage == true) { if (use_background) { - base = (hwaddr)get_field(env->vsatp, SATP_PPN) << PGSHIFT; - vm = get_field(env->vsatp, SATP_MODE); + if (riscv_cpu_is_32bit(env)) { + base = (hwaddr)get_field(env->vsatp, SATP32_PPN) << PGSHIFT; + vm = get_field(env->vsatp, SATP32_MODE); + } else { + base = (hwaddr)get_field(env->vsatp, SATP64_PPN) << PGSHIFT; + vm = get_field(env->vsatp, SATP64_MODE); + } } else { - base = (hwaddr)get_field(env->satp, SATP_PPN) << PGSHIFT; - vm = get_field(env->satp, SATP_MODE); + if (riscv_cpu_is_32bit(env)) { + base = (hwaddr)get_field(env->satp, SATP32_PPN) << PGSHIFT; + vm = get_field(env->satp, SATP32_MODE); + } else { + base = (hwaddr)get_field(env->satp, SATP64_PPN) << PGSHIFT; + vm = get_field(env->satp, SATP64_MODE); + } } widened = 0; } else { @@ -624,14 +634,20 @@ static void raise_mmu_exception(CPURISCVState *env, target_ulong address, { CPUState *cs = env_cpu(env); int page_fault_exceptions, vm; + uint64_t stap_mode; + + if (riscv_cpu_is_32bit(env)) { + stap_mode = SATP32_MODE; + } else { + stap_mode = SATP64_MODE; + } if (first_stage) { - vm = get_field(env->satp, SATP_MODE); - } else if (riscv_cpu_is_32bit(env)) { - vm = get_field(env->hgatp, SATP32_MODE); + vm = get_field(env->satp, stap_mode); } else { - vm = get_field(env->hgatp, SATP64_MODE); + vm = get_field(env->hgatp, stap_mode); } + page_fault_exceptions = vm != VM_1_10_MBARE && !pmp_violation; switch (access_type) { diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e955753441..fe5628fea6 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -997,16 +997,27 @@ static RISCVException read_satp(CPURISCVState *env, int csrno, static RISCVException write_satp(CPURISCVState *env, int csrno, target_ulong val) { + int vm, mask, asid; + if (!riscv_feature(env, RISCV_FEATURE_MMU)) { return RISCV_EXCP_NONE; } - if (validate_vm(env, get_field(val, SATP_MODE)) && - ((val ^ env->satp) & (SATP_MODE | SATP_ASID | SATP_PPN))) - { + + if (riscv_cpu_is_32bit(env)) { + vm = validate_vm(env, get_field(val, SATP32_MODE)); + mask = (val ^ env->satp) & (SATP32_MODE | SATP32_ASID | SATP32_PPN); + asid = (val ^ env->satp) & SATP32_ASID; + } else { + vm = validate_vm(env, get_field(val, SATP64_MODE)); + mask = (val ^ env->satp) & (SATP64_MODE | SATP64_ASID | SATP64_PPN); + asid = (val ^ env->satp) & SATP64_ASID; + } + + if (vm && mask) { if (env->priv == PRV_S && get_field(env->mstatus, MSTATUS_TVM)) { return RISCV_EXCP_ILLEGAL_INST; } else { - if ((val ^ env->satp) & SATP_ASID) { + if (asid) { tlb_flush(env_cpu(env)); } env->satp = val; diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c index e51188f919..f7e6ea72b3 100644 --- a/target/riscv/monitor.c +++ b/target/riscv/monitor.c @@ -150,9 +150,14 @@ static void mem_info_svxx(Monitor *mon, CPUArchState *env) target_ulong last_size; int last_attr; - base = (hwaddr)get_field(env->satp, SATP_PPN) << PGSHIFT; + if (riscv_cpu_is_32bit(env)) { + base = (hwaddr)get_field(env->satp, SATP32_PPN) << PGSHIFT; + vm = get_field(env->satp, SATP32_MODE); + } else { + base = (hwaddr)get_field(env->satp, SATP64_PPN) << PGSHIFT; + vm = get_field(env->satp, SATP64_MODE); + } - vm = get_field(env->satp, SATP_MODE); switch (vm) { case VM_1_10_SV32: levels = 2; @@ -215,9 +220,16 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict) return; } - if (!(env->satp & SATP_MODE)) { - monitor_printf(mon, "No translation or protection\n"); - return; + if (riscv_cpu_is_32bit(env)) { + if (!(env->satp & SATP32_MODE)) { + monitor_printf(mon, "No translation or protection\n"); + return; + } + } else { + if (!(env->satp & SATP64_MODE)) { + monitor_printf(mon, "No translation or protection\n"); + return; + } } mem_info_svxx(mon, env); From patchwork Tue May 11 10:19:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=DT1BeY1l; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZzW6W9cz9sWl for ; Tue, 11 May 2021 21:13:27 +1000 (AEST) Received: from localhost ([::1]:42760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQKL-00033Z-UF for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 07:13:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXw-00044w-RK for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:24 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXu-0006V6-KP for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728602; x=1652264602; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k8AB1GhaTYWteYEraUA7OHerw//cTNnk2vKdIJFK9EI=; b=DT1BeY1le7FTQszRkfyOQ2Fgg9sixD3OD+XlY4igGiq0SPMk40RtkLiz SsrxTSPlYrdgZCO8T0GNLdHfpH/TsaNG+uoC084qWG2e+s59Z+HtGQC5O Wqm2qdOOh8l8IwakTUwTBiV7Wr7i3kTSvzsr5sinCw5sdZON3Z2afGcrd 2LBOVd7VZCD1Q5IWWCDn4euNYC2rdr23lS8PEW4jr7852P1oxeqntHJbr x9ffkDby1uzfvhPoh5P3B2qBt1+KHPK2R59T68WWTRNbLb2HcbkeZyBul oeHENEBq9ZFGIrkY6biwrmpfjTrrKyk982rJGx6Qwwh4OMH+qZXnc+H00 g==; IronPort-SDR: x+p5tjWMQVwBIaITL8oogR00oh6BfNw1vVpZhX154qoj6X2pweaPZc8+yMmRbEo5hJ+Q+MNP24 8apnxxYM+Mboz/QVwOftSHhBEW3pA1GikMYU8i0CxgeJblfbYSgMZCOZKFac06blqAIc7fOMFb E18LZga4tHlHUBBA56TEc6u0pvYourTA8dNFdtDFha3R+jw37Tp4GNcXwbtn694ADzFCd9/BOo YIWRPMc0vo1qqzVnR9d73MwlSejxgypCVxoNYqcUFoKfXpURCnXhiJr4iRie61eoPfZV+JUlCO ga4= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735510" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:22:05 +0800 IronPort-SDR: 9gjyxXfZ1hrvV09bTrp8C0Yd+bbfYNYYp8RFSJyIHzxnrnDVyI+HfbyXepG3Vo/C7LYbWsCrq8 QHRw7r44/zeEEdj6SdMX6kw2IKQjhCJbzAohOSIfOxV8AYnDHSojt7beZt3hRx7n3UiJj4Znwe 9glLJ6W2tW/m0ge/1nJ+dspZ+uJVfHmENNkNDY70ZU2xBiJ3RYEJKug0mcSAbG/XPn1o0ZF5ED Y0PtGbfTvFybrx0oP5B8CxFQpLm8XvDE9DrbyeUdXU5DP5oFfXSfMdHF9LveqZIEj5HSdlGmYX N45JViaNCzYnNvCYjF4orA1N Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:02:05 -0700 IronPort-SDR: 8WPVtrn6suEBiLsN1Uz9ewX43QQz5xR/FdjtedJHz94nUGRiGk4hNCwyD83+qhY7CiAJwDHjeN jI2I/bBY+kiSDm5ajbeaoXnb1695ipaZCBXWSenyFx4vs68JUEbUwYw52X4pehpRfHkt9M4B6w RH8zadGdNV+Kl9yTAlt77aMnGbJbYib/HuUQyI8hHwcaWocP4gAufxDprH5rvsEB1wtLLrIq5Z 3YBmnpAOx+bWEeRnntW4nqnGQhe88Yjohdak3n4GPSb43NLzTD08/yBhyDrM0exY6/3lfrPH9U oGE= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:22:04 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 38/42] target/riscv: Remove the unused HSTATUS_WPRI macro Date: Tue, 11 May 2021 20:19:47 +1000 Message-Id: <20210511101951.165287-39-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: e095b57af0d419c8ed822958f04dfc732d7beb7e.1619234854.git.alistair.francis@wdc.com --- target/riscv/cpu_bits.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index d98f3bc8bc..52640e6856 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -396,12 +396,6 @@ #define HSTATUS32_WPRI 0xFF8FF87E #define HSTATUS64_WPRI 0xFFFFFFFFFF8FF87EULL -#if defined(TARGET_RISCV32) -#define HSTATUS_WPRI HSTATUS32_WPRI -#elif defined(TARGET_RISCV64) -#define HSTATUS_WPRI HSTATUS64_WPRI -#endif - #define HCOUNTEREN_CY (1 << 0) #define HCOUNTEREN_TM (1 << 1) #define HCOUNTEREN_IR (1 << 2) From patchwork Tue May 11 10:19:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=O2YfnKnG; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZYP5vRvz9srX for ; Tue, 11 May 2021 20:54:17 +1000 (AEST) Received: from localhost ([::1]:60914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQ1n-0000w6-QA for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:54:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXx-000494-K6 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:25 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXv-0006TG-Uy for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728603; x=1652264603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PH9mV72E9bXrh9R0MkptPiiHh1DAnrn6j54hAeX+lmw=; b=O2YfnKnGJKVt87AKspCX5im/lp7OBvWKvJTTUe//AbAzkDwC1rO8Jt/+ k8kZuO3Lm2EsUDfknYv2jx317H59ntyGPvvn95k62PmsRuFpkZ98s5Oi3 /w6kvMZMhHIWmOr8AKon88JUxvHFbfNv7vIinUv9atjV1bfN8v85v/A98 8W4Bvc7y/7QFJzrLJPqj3eeboY6xpzHPIekz62DZfqqFYxlp+2buJRdFf tJPOcahyiE0ekc7Tjh8JGodiGYRU7rvSGcG0sprW5XHRD2wzMuPjYVbwu b93JazHzoFZuEXoQ0fMoiMQRGzUf4b/P38lYAtHxT1atImhSrLsIWTOqE A==; IronPort-SDR: pKVK8XGVZBEx6IjN6ah/nI9kQkgDgABRHtPG6eZvJ/iBIh5nze4nF+wd/VWWvpip4eE5fwtHaB SkvjYmWZ5d6gKBbAS+gsQtMcmDPtzT1xL7pBpFJnvnB+60MAW8JjncX2mgkDl1q6+wqi3OP2/I ezaVnIQKhehX/HXhZKN2HPP5JVPg0HQO3JqGHTuUi+P7anDFwc+E9jVqbeArGtaserRRwduKyI BEjwKeC1Q5R30x2CHzDp/0RThu/isaRXGnnAN5OKtynLb792poJN+WcdM3xcBqOuBWLhLZ3amh MWk= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735514" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:22:08 +0800 IronPort-SDR: JiU5tRkkn2gYwAhUyz615w477WEIg9zUqLb5Xj+pj1FBfJ+I/f/g2cr+2qoPZlvV9q7IzLt5sx 5xpOxjdqCdKp7uL7droNfW7dhDOJmrhaEDMFW+wK9NEnSwXOV2hluquGQiRO+AMY2JNSyxXTzL 8MqLue2u1PxOKkqhojFfKPCzmiSuEdJKwKEBPsm1rIljH0chk+mMLtfOa4K2uDAxnXgwuYERlE YEGJXfMi9ZqC3xJeaSBLxdXPF0z1d5YINUauZF6x7FJqZMdS0vtb+KZ2+8tVuZH2CiCcZnPQ5P rNnFLSyf4Dt2XjkhbdQEBnR5 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:02:09 -0700 IronPort-SDR: r8cK6OnipqcsPX0cx8V65YXGqgh5mTHRdvcJAQK6cc/wwryChrC3OPd8HhKCn02olVbUSyUZgr 2indBXQI7s93GYBbWmkZUtFkHWkfNn2MiH9x0Ha1I13AsbMdsIE/agzePFumhXUdYMegiZDLg/ 0IlXBI40GEepHZKHFmmCI7ZF2+r0ZxX8bJEDAFSgxgTCXlePdFiTn4gTc92VdUoXIOvAJs09Za GTwqJ09HUZpzIrL5idHSz94z3WpA61+U8D3JeFV2WCii594eiyBijj6DjPetrmekUUavDiZclq Xxc= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:22:07 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 39/42] target/riscv: Remove an unused CASE_OP_32_64 macro Date: Tue, 11 May 2021 20:19:48 +1000 Message-Id: <20210511101951.165287-40-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org, Bin Meng Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Reviewed-by: Bin Meng Message-id: 4853459564af35a6690120c74ad892f60cec35ff.1619234854.git.alistair.francis@wdc.com --- target/riscv/translate.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index a596f80f20..a1f794ffda 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -67,12 +67,6 @@ typedef struct DisasContext { CPUState *cs; } DisasContext; -#ifdef TARGET_RISCV64 -#define CASE_OP_32_64(X) case X: case glue(X, W) -#else -#define CASE_OP_32_64(X) case X -#endif - static inline bool has_ext(DisasContext *ctx, uint32_t ext) { return ctx->misa & ext; From patchwork Tue May 11 10:19:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=RG5NXTry; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FfZN54zVHz9rx6 for ; Tue, 11 May 2021 20:46:13 +1000 (AEST) Received: from localhost ([::1]:41106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgPtz-0004Ks-HN for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 06:46:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPY6-0004Vp-G7 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:34 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPXy-0006X1-L4 for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728606; x=1652264606; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=se8lfUOqpnCd33IAE3PZjy5dFjxaV2X6rgujV44CGDs=; b=RG5NXTryd0PotkUa2dgrMU7LG1E3awsB6txmxX/uypvLLE1idXKNNKhA VvaUryA53fR+rXBBEt6QcOsngN7T+ybfVe+p1NyL2vCnXKE3jgA8j9Cvi KcuXaIymVVAvdFq8Kh7CrAudKrtGBWFpP1RUssuVCqrMV73pho9PtV+zM Ki/P7B0I9OpCJj4FsG9vTHyHEVvSbYDkCz/tefSRqETEjTD+EGsFHc+dd 71JoV9c0sTInyMO6tMX8aFKf+e+Dx+9er57G9ajj0UUyf3pOnX6oiWNBW q0sP9GUMa7fETt0r2ACds7eiszz9GbPgDvvh+8m7RqKjTSqP6xFv9yskg A==; IronPort-SDR: kqBaiRMBIo31jH9yYDk91rW5l5Rfnfhtau8BaS9wGCetyOfEOX4OYznTb0jkKvZdeBCfIpZyL0 6pSm5HXX0s1rzBpJSnV6CPr7bMDwuGut6S3uZ9dj9oFL+ME104P8n0TGksDBVgX+BiqiC6vlrU UaKG/04+9D6CSxZJLpY0MT8gwXBEDYObUmDmpkfeuoIFRyX1rD96KUGE13Y+suMEABKtDiudGh oFiBkCAj/FcL/pA2zDagH6FlUwFIhNAIRnteXH6++1wPxL0IWZ+INK/8r3hxBz7pQUbWQZux04 bKg= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735519" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:22:12 +0800 IronPort-SDR: +AjY4fo6EnhyqHowAWwff3ELjy85ziHZKiP0/TDWB4V/vTdnPbSgmpBaveeR0ULle/PubJkxWV Gfjxsst+6qJd0gpuUupX48Pr36g2hRSIlbZZA37J8DLpidAo5vfpznnkWHFKwGT1Q2jpEhj4bO 4al8eI/pbI18Dxh17+n1BBfJUVYe8wmkzhpz92AO7ccelDTu+4n5s5U5CmWv2/5v3S2Nq4d6xm MemzYIbOa/gM7JRUs+auWYMVc4jAbaIGIQbcykfCfPsonrsJPzS4OAQ2j7EcWgJI4Zxl5CfY2M McaJdt1pdRIOwMv9Qxhmu0OU Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:02:12 -0700 IronPort-SDR: Y8gF+vxbiZLWwqyokgZmgbCdk3cwJkVE+MGEGuBNI8VKSa7PDtP3Z+h0685Uv/qdIPWBKuyptD L8YMvuQQhpCvXcT+ddXXs3ber7jOBGsfSFzG8jP4awI5lfUI4RbGY7ac1k9n6mca4JCJdOfI3C txghVjAHFyQM2Vus5Opn3chNipkUI5nLpmfBqwt5RR70awkz474Skmix1KU17s240JG14IcK74 3DlVFrNhjNBB3rTnhIxbEKR/4NjlwKprc62kVstE/27hcx7Jeu/4mGW7UWJW7dg8TX47NlLnpc yUg= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:22:11 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 40/42] target/riscv: Consolidate RV32/64 32-bit instructions Date: Tue, 11 May 2021 20:19:49 +1000 Message-Id: <20210511101951.165287-41-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch removes the insn32-64.decode decode file and consolidates the instructions into the general RISC-V insn32.decode decode tree. This means that all of the instructions are avaliable in both the 32-bit and 64-bit builds. This also means that we run a check to ensure we are running a 64-bit softmmu before we execute the 64-bit only instructions. This allows us to include the 32-bit instructions in the 64-bit build, while also ensuring that 32-bit only software can not execute the instructions. Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Message-id: db709360e2be47d2f9c6483ab973fe4791aefa77.1619234854.git.alistair.francis@wdc.com --- target/riscv/helper.h | 18 +++-- target/riscv/insn32-64.decode | 88 ------------------------- target/riscv/insn32.decode | 67 ++++++++++++++++++- target/riscv/fpu_helper.c | 16 ++--- target/riscv/translate.c | 9 ++- target/riscv/vector_helper.c | 4 -- target/riscv/insn_trans/trans_rva.c.inc | 14 +++- target/riscv/insn_trans/trans_rvd.c.inc | 17 ++++- target/riscv/insn_trans/trans_rvf.c.inc | 6 +- target/riscv/insn_trans/trans_rvh.c.inc | 8 ++- target/riscv/insn_trans/trans_rvi.c.inc | 16 +++-- target/riscv/insn_trans/trans_rvm.c.inc | 12 +++- target/riscv/insn_trans/trans_rvv.c.inc | 39 +++++------ target/riscv/meson.build | 2 +- 14 files changed, 166 insertions(+), 150 deletions(-) delete mode 100644 target/riscv/insn32-64.decode diff --git a/target/riscv/helper.h b/target/riscv/helper.h index e3f3f41e89..c7267593c3 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -27,12 +27,12 @@ DEF_HELPER_FLAGS_3(flt_s, TCG_CALL_NO_RWG, tl, env, i64, i64) DEF_HELPER_FLAGS_3(feq_s, TCG_CALL_NO_RWG, tl, env, i64, i64) DEF_HELPER_FLAGS_2(fcvt_w_s, TCG_CALL_NO_RWG, tl, env, i64) DEF_HELPER_FLAGS_2(fcvt_wu_s, TCG_CALL_NO_RWG, tl, env, i64) -DEF_HELPER_FLAGS_2(fcvt_l_s, TCG_CALL_NO_RWG, i64, env, i64) -DEF_HELPER_FLAGS_2(fcvt_lu_s, TCG_CALL_NO_RWG, i64, env, i64) +DEF_HELPER_FLAGS_2(fcvt_l_s, TCG_CALL_NO_RWG, tl, env, i64) +DEF_HELPER_FLAGS_2(fcvt_lu_s, TCG_CALL_NO_RWG, tl, env, i64) DEF_HELPER_FLAGS_2(fcvt_s_w, TCG_CALL_NO_RWG, i64, env, tl) DEF_HELPER_FLAGS_2(fcvt_s_wu, TCG_CALL_NO_RWG, i64, env, tl) -DEF_HELPER_FLAGS_2(fcvt_s_l, TCG_CALL_NO_RWG, i64, env, i64) -DEF_HELPER_FLAGS_2(fcvt_s_lu, TCG_CALL_NO_RWG, i64, env, i64) +DEF_HELPER_FLAGS_2(fcvt_s_l, TCG_CALL_NO_RWG, i64, env, tl) +DEF_HELPER_FLAGS_2(fcvt_s_lu, TCG_CALL_NO_RWG, i64, env, tl) DEF_HELPER_FLAGS_1(fclass_s, TCG_CALL_NO_RWG_SE, tl, i64) /* Floating Point - Double Precision */ @@ -50,12 +50,12 @@ DEF_HELPER_FLAGS_3(flt_d, TCG_CALL_NO_RWG, tl, env, i64, i64) DEF_HELPER_FLAGS_3(feq_d, TCG_CALL_NO_RWG, tl, env, i64, i64) DEF_HELPER_FLAGS_2(fcvt_w_d, TCG_CALL_NO_RWG, tl, env, i64) DEF_HELPER_FLAGS_2(fcvt_wu_d, TCG_CALL_NO_RWG, tl, env, i64) -DEF_HELPER_FLAGS_2(fcvt_l_d, TCG_CALL_NO_RWG, i64, env, i64) -DEF_HELPER_FLAGS_2(fcvt_lu_d, TCG_CALL_NO_RWG, i64, env, i64) +DEF_HELPER_FLAGS_2(fcvt_l_d, TCG_CALL_NO_RWG, tl, env, i64) +DEF_HELPER_FLAGS_2(fcvt_lu_d, TCG_CALL_NO_RWG, tl, env, i64) DEF_HELPER_FLAGS_2(fcvt_d_w, TCG_CALL_NO_RWG, i64, env, tl) DEF_HELPER_FLAGS_2(fcvt_d_wu, TCG_CALL_NO_RWG, i64, env, tl) -DEF_HELPER_FLAGS_2(fcvt_d_l, TCG_CALL_NO_RWG, i64, env, i64) -DEF_HELPER_FLAGS_2(fcvt_d_lu, TCG_CALL_NO_RWG, i64, env, i64) +DEF_HELPER_FLAGS_2(fcvt_d_l, TCG_CALL_NO_RWG, i64, env, tl) +DEF_HELPER_FLAGS_2(fcvt_d_lu, TCG_CALL_NO_RWG, i64, env, tl) DEF_HELPER_FLAGS_1(fclass_d, TCG_CALL_NO_RWG_SE, tl, i64) /* Special functions */ @@ -241,7 +241,6 @@ DEF_HELPER_5(vlhuff_v_w, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vlhuff_v_d, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vlwuff_v_w, void, ptr, ptr, tl, env, i32) DEF_HELPER_5(vlwuff_v_d, void, ptr, ptr, tl, env, i32) -#ifdef TARGET_RISCV64 DEF_HELPER_6(vamoswapw_v_d, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vamoswapd_v_d, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vamoaddw_v_d, void, ptr, ptr, tl, ptr, env, i32) @@ -260,7 +259,6 @@ DEF_HELPER_6(vamominuw_v_d, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vamominud_v_d, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vamomaxuw_v_d, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vamomaxud_v_d, void, ptr, ptr, tl, ptr, env, i32) -#endif DEF_HELPER_6(vamoswapw_v_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vamoaddw_v_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vamoxorw_v_w, void, ptr, ptr, tl, ptr, env, i32) diff --git a/target/riscv/insn32-64.decode b/target/riscv/insn32-64.decode deleted file mode 100644 index 8157dee8b7..0000000000 --- a/target/riscv/insn32-64.decode +++ /dev/null @@ -1,88 +0,0 @@ -# -# RISC-V translation routines for the RV Instruction Set. -# -# Copyright (c) 2018 Peer Adelt, peer.adelt@hni.uni-paderborn.de -# Bastian Koppelmann, kbastian@mail.uni-paderborn.de -# -# This program is free software; you can redistribute it and/or modify it -# under the terms and conditions of the GNU General Public License, -# version 2 or later, as published by the Free Software Foundation. -# -# This program is distributed in the hope it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program. If not, see . - -# This is concatenated with insn32.decode for risc64 targets. -# Most of the fields and formats are there. - -%sh5 20:5 - -@sh5 ....... ..... ..... ... ..... ....... &shift shamt=%sh5 %rs1 %rd - -# *** RV64I Base Instruction Set (in addition to RV32I) *** -lwu ............ ..... 110 ..... 0000011 @i -ld ............ ..... 011 ..... 0000011 @i -sd ....... ..... ..... 011 ..... 0100011 @s -addiw ............ ..... 000 ..... 0011011 @i -slliw 0000000 ..... ..... 001 ..... 0011011 @sh5 -srliw 0000000 ..... ..... 101 ..... 0011011 @sh5 -sraiw 0100000 ..... ..... 101 ..... 0011011 @sh5 -addw 0000000 ..... ..... 000 ..... 0111011 @r -subw 0100000 ..... ..... 000 ..... 0111011 @r -sllw 0000000 ..... ..... 001 ..... 0111011 @r -srlw 0000000 ..... ..... 101 ..... 0111011 @r -sraw 0100000 ..... ..... 101 ..... 0111011 @r - -# *** RV64M Standard Extension (in addition to RV32M) *** -mulw 0000001 ..... ..... 000 ..... 0111011 @r -divw 0000001 ..... ..... 100 ..... 0111011 @r -divuw 0000001 ..... ..... 101 ..... 0111011 @r -remw 0000001 ..... ..... 110 ..... 0111011 @r -remuw 0000001 ..... ..... 111 ..... 0111011 @r - -# *** RV64A Standard Extension (in addition to RV32A) *** -lr_d 00010 . . 00000 ..... 011 ..... 0101111 @atom_ld -sc_d 00011 . . ..... ..... 011 ..... 0101111 @atom_st -amoswap_d 00001 . . ..... ..... 011 ..... 0101111 @atom_st -amoadd_d 00000 . . ..... ..... 011 ..... 0101111 @atom_st -amoxor_d 00100 . . ..... ..... 011 ..... 0101111 @atom_st -amoand_d 01100 . . ..... ..... 011 ..... 0101111 @atom_st -amoor_d 01000 . . ..... ..... 011 ..... 0101111 @atom_st -amomin_d 10000 . . ..... ..... 011 ..... 0101111 @atom_st -amomax_d 10100 . . ..... ..... 011 ..... 0101111 @atom_st -amominu_d 11000 . . ..... ..... 011 ..... 0101111 @atom_st -amomaxu_d 11100 . . ..... ..... 011 ..... 0101111 @atom_st - -#*** Vector AMO operations (in addition to Zvamo) *** -vamoswapd_v 00001 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamoaddd_v 00000 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamoxord_v 00100 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamoandd_v 01100 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamoord_v 01000 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamomind_v 10000 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamomaxd_v 10100 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamominud_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm -vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm - -# *** RV64F Standard Extension (in addition to RV32F) *** -fcvt_l_s 1100000 00010 ..... ... ..... 1010011 @r2_rm -fcvt_lu_s 1100000 00011 ..... ... ..... 1010011 @r2_rm -fcvt_s_l 1101000 00010 ..... ... ..... 1010011 @r2_rm -fcvt_s_lu 1101000 00011 ..... ... ..... 1010011 @r2_rm - -# *** RV64D Standard Extension (in addition to RV32D) *** -fcvt_l_d 1100001 00010 ..... ... ..... 1010011 @r2_rm -fcvt_lu_d 1100001 00011 ..... ... ..... 1010011 @r2_rm -fmv_x_d 1110001 00000 ..... 000 ..... 1010011 @r2 -fcvt_d_l 1101001 00010 ..... ... ..... 1010011 @r2_rm -fcvt_d_lu 1101001 00011 ..... ... ..... 1010011 @r2_rm -fmv_d_x 1111001 00000 ..... 000 ..... 1010011 @r2 - -# *** RV32H Base Instruction Set *** -hlv_wu 0110100 00001 ..... 100 ..... 1110011 @r2 -hlv_d 0110110 00000 ..... 100 ..... 1110011 @r2 -hsv_d 0110111 ..... ..... 100 00000 1110011 @r2_s diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 84080dd18c..fecf0f15d5 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -21,6 +21,7 @@ %rs2 20:5 %rs1 15:5 %rd 7:5 +%sh5 20:5 %sh10 20:10 %csr 20:12 @@ -86,6 +87,8 @@ @sfence_vma ....... ..... ..... ... ..... ....... %rs2 %rs1 @sfence_vm ....... ..... ..... ... ..... ....... %rs1 +# Formats 64: +@sh5 ....... ..... ..... ... ..... ....... &shift shamt=%sh5 %rs1 %rd # *** Privileged Instructions *** ecall 000000000000 00000 000 00000 1110011 @@ -144,6 +147,20 @@ csrrwi ............ ..... 101 ..... 1110011 @csr csrrsi ............ ..... 110 ..... 1110011 @csr csrrci ............ ..... 111 ..... 1110011 @csr +# *** RV64I Base Instruction Set (in addition to RV32I) *** +lwu ............ ..... 110 ..... 0000011 @i +ld ............ ..... 011 ..... 0000011 @i +sd ....... ..... ..... 011 ..... 0100011 @s +addiw ............ ..... 000 ..... 0011011 @i +slliw 0000000 ..... ..... 001 ..... 0011011 @sh5 +srliw 0000000 ..... ..... 101 ..... 0011011 @sh5 +sraiw 0100000 ..... ..... 101 ..... 0011011 @sh5 +addw 0000000 ..... ..... 000 ..... 0111011 @r +subw 0100000 ..... ..... 000 ..... 0111011 @r +sllw 0000000 ..... ..... 001 ..... 0111011 @r +srlw 0000000 ..... ..... 101 ..... 0111011 @r +sraw 0100000 ..... ..... 101 ..... 0111011 @r + # *** RV32M Standard Extension *** mul 0000001 ..... ..... 000 ..... 0110011 @r mulh 0000001 ..... ..... 001 ..... 0110011 @r @@ -154,6 +171,13 @@ divu 0000001 ..... ..... 101 ..... 0110011 @r rem 0000001 ..... ..... 110 ..... 0110011 @r remu 0000001 ..... ..... 111 ..... 0110011 @r +# *** RV64M Standard Extension (in addition to RV32M) *** +mulw 0000001 ..... ..... 000 ..... 0111011 @r +divw 0000001 ..... ..... 100 ..... 0111011 @r +divuw 0000001 ..... ..... 101 ..... 0111011 @r +remw 0000001 ..... ..... 110 ..... 0111011 @r +remuw 0000001 ..... ..... 111 ..... 0111011 @r + # *** RV32A Standard Extension *** lr_w 00010 . . 00000 ..... 010 ..... 0101111 @atom_ld sc_w 00011 . . ..... ..... 010 ..... 0101111 @atom_st @@ -167,6 +191,19 @@ amomax_w 10100 . . ..... ..... 010 ..... 0101111 @atom_st amominu_w 11000 . . ..... ..... 010 ..... 0101111 @atom_st amomaxu_w 11100 . . ..... ..... 010 ..... 0101111 @atom_st +# *** RV64A Standard Extension (in addition to RV32A) *** +lr_d 00010 . . 00000 ..... 011 ..... 0101111 @atom_ld +sc_d 00011 . . ..... ..... 011 ..... 0101111 @atom_st +amoswap_d 00001 . . ..... ..... 011 ..... 0101111 @atom_st +amoadd_d 00000 . . ..... ..... 011 ..... 0101111 @atom_st +amoxor_d 00100 . . ..... ..... 011 ..... 0101111 @atom_st +amoand_d 01100 . . ..... ..... 011 ..... 0101111 @atom_st +amoor_d 01000 . . ..... ..... 011 ..... 0101111 @atom_st +amomin_d 10000 . . ..... ..... 011 ..... 0101111 @atom_st +amomax_d 10100 . . ..... ..... 011 ..... 0101111 @atom_st +amominu_d 11000 . . ..... ..... 011 ..... 0101111 @atom_st +amomaxu_d 11100 . . ..... ..... 011 ..... 0101111 @atom_st + # *** RV32F Standard Extension *** flw ............ ..... 010 ..... 0000111 @i fsw ....... ..... ..... 010 ..... 0100111 @s @@ -195,6 +232,12 @@ fcvt_s_w 1101000 00000 ..... ... ..... 1010011 @r2_rm fcvt_s_wu 1101000 00001 ..... ... ..... 1010011 @r2_rm fmv_w_x 1111000 00000 ..... 000 ..... 1010011 @r2 +# *** RV64F Standard Extension (in addition to RV32F) *** +fcvt_l_s 1100000 00010 ..... ... ..... 1010011 @r2_rm +fcvt_lu_s 1100000 00011 ..... ... ..... 1010011 @r2_rm +fcvt_s_l 1101000 00010 ..... ... ..... 1010011 @r2_rm +fcvt_s_lu 1101000 00011 ..... ... ..... 1010011 @r2_rm + # *** RV32D Standard Extension *** fld ............ ..... 011 ..... 0000111 @i fsd ....... ..... ..... 011 ..... 0100111 @s @@ -223,6 +266,14 @@ fcvt_wu_d 1100001 00001 ..... ... ..... 1010011 @r2_rm fcvt_d_w 1101001 00000 ..... ... ..... 1010011 @r2_rm fcvt_d_wu 1101001 00001 ..... ... ..... 1010011 @r2_rm +# *** RV64D Standard Extension (in addition to RV32D) *** +fcvt_l_d 1100001 00010 ..... ... ..... 1010011 @r2_rm +fcvt_lu_d 1100001 00011 ..... ... ..... 1010011 @r2_rm +fmv_x_d 1110001 00000 ..... 000 ..... 1010011 @r2 +fcvt_d_l 1101001 00010 ..... ... ..... 1010011 @r2_rm +fcvt_d_lu 1101001 00011 ..... ... ..... 1010011 @r2_rm +fmv_d_x 1111001 00000 ..... 000 ..... 1010011 @r2 + # *** RV32H Base Instruction Set *** hlv_b 0110000 00000 ..... 100 ..... 1110011 @r2 hlv_bu 0110000 00001 ..... 100 ..... 1110011 @r2 @@ -237,7 +288,10 @@ hsv_w 0110101 ..... ..... 100 00000 1110011 @r2_s hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma -# *** RV32V Extension *** +# *** RV32H Base Instruction Set *** +hlv_wu 0110100 00001 ..... 100 ..... 1110011 @r2 +hlv_d 0110110 00000 ..... 100 ..... 1110011 @r2 +hsv_d 0110111 ..... ..... 100 00000 1110011 @r2_s # *** Vector loads and stores are encoded within LOADFP/STORE-FP *** vlb_v ... 100 . 00000 ..... 000 ..... 0000111 @r2_nfvm @@ -592,3 +646,14 @@ vcompress_vm 010111 - ..... ..... 010 ..... 1010111 @r vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm vsetvl 1000000 ..... ..... 111 ..... 1010111 @r + +#*** Vector AMO operations (in addition to Zvamo) *** +vamoswapd_v 00001 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoaddd_v 00000 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoxord_v 00100 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoandd_v 01100 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamoord_v 01000 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamomind_v 10000 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamomaxd_v 10100 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamominud_v 11000 . . ..... ..... 111 ..... 0101111 @r_wdvm +vamomaxud_v 11100 . . ..... ..... 111 ..... 0101111 @r_wdvm diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index 7c4ab92ecb..8700516a14 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -223,13 +223,13 @@ target_ulong helper_fcvt_wu_s(CPURISCVState *env, uint64_t rs1) return (int32_t)float32_to_uint32(frs1, &env->fp_status); } -uint64_t helper_fcvt_l_s(CPURISCVState *env, uint64_t rs1) +target_ulong helper_fcvt_l_s(CPURISCVState *env, uint64_t rs1) { float32 frs1 = check_nanbox_s(rs1); return float32_to_int64(frs1, &env->fp_status); } -uint64_t helper_fcvt_lu_s(CPURISCVState *env, uint64_t rs1) +target_ulong helper_fcvt_lu_s(CPURISCVState *env, uint64_t rs1) { float32 frs1 = check_nanbox_s(rs1); return float32_to_uint64(frs1, &env->fp_status); @@ -245,12 +245,12 @@ uint64_t helper_fcvt_s_wu(CPURISCVState *env, target_ulong rs1) return nanbox_s(uint32_to_float32((uint32_t)rs1, &env->fp_status)); } -uint64_t helper_fcvt_s_l(CPURISCVState *env, uint64_t rs1) +uint64_t helper_fcvt_s_l(CPURISCVState *env, target_ulong rs1) { return nanbox_s(int64_to_float32(rs1, &env->fp_status)); } -uint64_t helper_fcvt_s_lu(CPURISCVState *env, uint64_t rs1) +uint64_t helper_fcvt_s_lu(CPURISCVState *env, target_ulong rs1) { return nanbox_s(uint64_to_float32(rs1, &env->fp_status)); } @@ -332,12 +332,12 @@ target_ulong helper_fcvt_wu_d(CPURISCVState *env, uint64_t frs1) return (int32_t)float64_to_uint32(frs1, &env->fp_status); } -uint64_t helper_fcvt_l_d(CPURISCVState *env, uint64_t frs1) +target_ulong helper_fcvt_l_d(CPURISCVState *env, uint64_t frs1) { return float64_to_int64(frs1, &env->fp_status); } -uint64_t helper_fcvt_lu_d(CPURISCVState *env, uint64_t frs1) +target_ulong helper_fcvt_lu_d(CPURISCVState *env, uint64_t frs1) { return float64_to_uint64(frs1, &env->fp_status); } @@ -352,12 +352,12 @@ uint64_t helper_fcvt_d_wu(CPURISCVState *env, target_ulong rs1) return uint32_to_float64((uint32_t)rs1, &env->fp_status); } -uint64_t helper_fcvt_d_l(CPURISCVState *env, uint64_t rs1) +uint64_t helper_fcvt_d_l(CPURISCVState *env, target_ulong rs1) { return int64_to_float64(rs1, &env->fp_status); } -uint64_t helper_fcvt_d_lu(CPURISCVState *env, uint64_t rs1) +uint64_t helper_fcvt_d_lu(CPURISCVState *env, target_ulong rs1) { return uint64_to_float64(rs1, &env->fp_status); } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index a1f794ffda..e945352bca 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -435,6 +435,12 @@ EX_SH(12) } \ } while (0) +#define REQUIRE_64BIT(ctx) do { \ + if (is_32bit(ctx)) { \ + return false; \ + } \ +} while (0) + static int ex_rvc_register(DisasContext *ctx, int reg) { return 8 + reg; @@ -482,7 +488,6 @@ static bool gen_arith_imm_tl(DisasContext *ctx, arg_i *a, return true; } -#ifdef TARGET_RISCV64 static void gen_addw(TCGv ret, TCGv arg1, TCGv arg2) { tcg_gen_add_tl(ret, arg1, arg2); @@ -543,8 +548,6 @@ static bool gen_arith_div_uw(DisasContext *ctx, arg_r *a, return true; } -#endif - static bool gen_arith(DisasContext *ctx, arg_r *a, void(*func)(TCGv, TCGv, TCGv)) { diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 4651a1e224..12c31aa4b4 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -751,7 +751,6 @@ GEN_VEXT_AMO_NOATOMIC_OP(vamominw_v_w, 32, 32, H4, DO_MIN, l) GEN_VEXT_AMO_NOATOMIC_OP(vamomaxw_v_w, 32, 32, H4, DO_MAX, l) GEN_VEXT_AMO_NOATOMIC_OP(vamominuw_v_w, 32, 32, H4, DO_MINU, l) GEN_VEXT_AMO_NOATOMIC_OP(vamomaxuw_v_w, 32, 32, H4, DO_MAXU, l) -#ifdef TARGET_RISCV64 GEN_VEXT_AMO_NOATOMIC_OP(vamoswapw_v_d, 64, 32, H8, DO_SWAP, l) GEN_VEXT_AMO_NOATOMIC_OP(vamoswapd_v_d, 64, 64, H8, DO_SWAP, q) GEN_VEXT_AMO_NOATOMIC_OP(vamoaddw_v_d, 64, 32, H8, DO_ADD, l) @@ -770,7 +769,6 @@ GEN_VEXT_AMO_NOATOMIC_OP(vamominuw_v_d, 64, 32, H8, DO_MINU, l) GEN_VEXT_AMO_NOATOMIC_OP(vamominud_v_d, 64, 64, H8, DO_MINU, q) GEN_VEXT_AMO_NOATOMIC_OP(vamomaxuw_v_d, 64, 32, H8, DO_MAXU, l) GEN_VEXT_AMO_NOATOMIC_OP(vamomaxud_v_d, 64, 64, H8, DO_MAXU, q) -#endif static inline void vext_amo_noatomic(void *vs3, void *v0, target_ulong base, @@ -814,7 +812,6 @@ void HELPER(NAME)(void *vs3, void *v0, target_ulong base, \ GETPC()); \ } -#ifdef TARGET_RISCV64 GEN_VEXT_AMO(vamoswapw_v_d, int32_t, int64_t, idx_d, clearq) GEN_VEXT_AMO(vamoswapd_v_d, int64_t, int64_t, idx_d, clearq) GEN_VEXT_AMO(vamoaddw_v_d, int32_t, int64_t, idx_d, clearq) @@ -833,7 +830,6 @@ GEN_VEXT_AMO(vamominuw_v_d, uint32_t, uint64_t, idx_d, clearq) GEN_VEXT_AMO(vamominud_v_d, uint64_t, uint64_t, idx_d, clearq) GEN_VEXT_AMO(vamomaxuw_v_d, uint32_t, uint64_t, idx_d, clearq) GEN_VEXT_AMO(vamomaxud_v_d, uint64_t, uint64_t, idx_d, clearq) -#endif GEN_VEXT_AMO(vamoswapw_v_w, int32_t, int32_t, idx_w, clearl) GEN_VEXT_AMO(vamoaddw_v_w, int32_t, int32_t, idx_w, clearl) GEN_VEXT_AMO(vamoxorw_v_w, int32_t, int32_t, idx_w, clearl) diff --git a/target/riscv/insn_trans/trans_rva.c.inc b/target/riscv/insn_trans/trans_rva.c.inc index be8a9f06dd..ab2ec4f0a5 100644 --- a/target/riscv/insn_trans/trans_rva.c.inc +++ b/target/riscv/insn_trans/trans_rva.c.inc @@ -165,60 +165,68 @@ static bool trans_amomaxu_w(DisasContext *ctx, arg_amomaxu_w *a) return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umax_tl, (MO_ALIGN | MO_TESL)); } -#ifdef TARGET_RISCV64 - static bool trans_lr_d(DisasContext *ctx, arg_lr_d *a) { + REQUIRE_64BIT(ctx); return gen_lr(ctx, a, MO_ALIGN | MO_TEQ); } static bool trans_sc_d(DisasContext *ctx, arg_sc_d *a) { + REQUIRE_64BIT(ctx); return gen_sc(ctx, a, (MO_ALIGN | MO_TEQ)); } static bool trans_amoswap_d(DisasContext *ctx, arg_amoswap_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_xchg_tl, (MO_ALIGN | MO_TEQ)); } static bool trans_amoadd_d(DisasContext *ctx, arg_amoadd_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_add_tl, (MO_ALIGN | MO_TEQ)); } static bool trans_amoxor_d(DisasContext *ctx, arg_amoxor_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_xor_tl, (MO_ALIGN | MO_TEQ)); } static bool trans_amoand_d(DisasContext *ctx, arg_amoand_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_and_tl, (MO_ALIGN | MO_TEQ)); } static bool trans_amoor_d(DisasContext *ctx, arg_amoor_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_or_tl, (MO_ALIGN | MO_TEQ)); } static bool trans_amomin_d(DisasContext *ctx, arg_amomin_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_smin_tl, (MO_ALIGN | MO_TEQ)); } static bool trans_amomax_d(DisasContext *ctx, arg_amomax_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_smax_tl, (MO_ALIGN | MO_TEQ)); } static bool trans_amominu_d(DisasContext *ctx, arg_amominu_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umin_tl, (MO_ALIGN | MO_TEQ)); } static bool trans_amomaxu_d(DisasContext *ctx, arg_amomaxu_d *a) { + REQUIRE_64BIT(ctx); return gen_amo(ctx, a, &tcg_gen_atomic_fetch_umax_tl, (MO_ALIGN | MO_TEQ)); } -#endif diff --git a/target/riscv/insn_trans/trans_rvd.c.inc b/target/riscv/insn_trans/trans_rvd.c.inc index 4f832637fa..7e45538ae0 100644 --- a/target/riscv/insn_trans/trans_rvd.c.inc +++ b/target/riscv/insn_trans/trans_rvd.c.inc @@ -358,10 +358,9 @@ static bool trans_fcvt_d_wu(DisasContext *ctx, arg_fcvt_d_wu *a) return true; } -#ifdef TARGET_RISCV64 - static bool trans_fcvt_l_d(DisasContext *ctx, arg_fcvt_l_d *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); @@ -375,6 +374,7 @@ static bool trans_fcvt_l_d(DisasContext *ctx, arg_fcvt_l_d *a) static bool trans_fcvt_lu_d(DisasContext *ctx, arg_fcvt_lu_d *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); @@ -388,15 +388,21 @@ static bool trans_fcvt_lu_d(DisasContext *ctx, arg_fcvt_lu_d *a) static bool trans_fmv_x_d(DisasContext *ctx, arg_fmv_x_d *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); +#ifdef TARGET_RISCV64 gen_set_gpr(a->rd, cpu_fpr[a->rs1]); return true; +#else + qemu_build_not_reached(); +#endif } static bool trans_fcvt_d_l(DisasContext *ctx, arg_fcvt_d_l *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); @@ -412,6 +418,7 @@ static bool trans_fcvt_d_l(DisasContext *ctx, arg_fcvt_d_l *a) static bool trans_fcvt_d_lu(DisasContext *ctx, arg_fcvt_d_lu *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); @@ -427,9 +434,11 @@ static bool trans_fcvt_d_lu(DisasContext *ctx, arg_fcvt_d_lu *a) static bool trans_fmv_d_x(DisasContext *ctx, arg_fmv_d_x *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); +#ifdef TARGET_RISCV64 TCGv t0 = tcg_temp_new(); gen_get_gpr(t0, a->rs1); @@ -437,5 +446,7 @@ static bool trans_fmv_d_x(DisasContext *ctx, arg_fmv_d_x *a) tcg_temp_free(t0); mark_fs_dirty(ctx); return true; -} +#else + qemu_build_not_reached(); #endif +} diff --git a/target/riscv/insn_trans/trans_rvf.c.inc b/target/riscv/insn_trans/trans_rvf.c.inc index 3dfec8211d..db1c0c9974 100644 --- a/target/riscv/insn_trans/trans_rvf.c.inc +++ b/target/riscv/insn_trans/trans_rvf.c.inc @@ -415,9 +415,9 @@ static bool trans_fmv_w_x(DisasContext *ctx, arg_fmv_w_x *a) return true; } -#ifdef TARGET_RISCV64 static bool trans_fcvt_l_s(DisasContext *ctx, arg_fcvt_l_s *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); @@ -431,6 +431,7 @@ static bool trans_fcvt_l_s(DisasContext *ctx, arg_fcvt_l_s *a) static bool trans_fcvt_lu_s(DisasContext *ctx, arg_fcvt_lu_s *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); @@ -444,6 +445,7 @@ static bool trans_fcvt_lu_s(DisasContext *ctx, arg_fcvt_lu_s *a) static bool trans_fcvt_s_l(DisasContext *ctx, arg_fcvt_s_l *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); @@ -460,6 +462,7 @@ static bool trans_fcvt_s_l(DisasContext *ctx, arg_fcvt_s_l *a) static bool trans_fcvt_s_lu(DisasContext *ctx, arg_fcvt_s_lu *a) { + REQUIRE_64BIT(ctx); REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); @@ -473,4 +476,3 @@ static bool trans_fcvt_s_lu(DisasContext *ctx, arg_fcvt_s_lu *a) tcg_temp_free(t0); return true; } -#endif diff --git a/target/riscv/insn_trans/trans_rvh.c.inc b/target/riscv/insn_trans/trans_rvh.c.inc index ce7ed5affb..6b5edf82b7 100644 --- a/target/riscv/insn_trans/trans_rvh.c.inc +++ b/target/riscv/insn_trans/trans_rvh.c.inc @@ -203,10 +203,11 @@ static bool trans_hsv_w(DisasContext *ctx, arg_hsv_w *a) #endif } -#ifdef TARGET_RISCV64 static bool trans_hlv_wu(DisasContext *ctx, arg_hlv_wu *a) { + REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVH); + #ifndef CONFIG_USER_ONLY TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); @@ -228,7 +229,9 @@ static bool trans_hlv_wu(DisasContext *ctx, arg_hlv_wu *a) static bool trans_hlv_d(DisasContext *ctx, arg_hlv_d *a) { + REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVH); + #ifndef CONFIG_USER_ONLY TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); @@ -250,7 +253,9 @@ static bool trans_hlv_d(DisasContext *ctx, arg_hlv_d *a) static bool trans_hsv_d(DisasContext *ctx, arg_hsv_d *a) { + REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVH); + #ifndef CONFIG_USER_ONLY TCGv t0 = tcg_temp_new(); TCGv dat = tcg_temp_new(); @@ -269,7 +274,6 @@ static bool trans_hsv_d(DisasContext *ctx, arg_hsv_d *a) return false; #endif } -#endif static bool trans_hlvx_hu(DisasContext *ctx, arg_hlvx_hu *a) { diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc index d04ca0394c..1340676209 100644 --- a/target/riscv/insn_trans/trans_rvi.c.inc +++ b/target/riscv/insn_trans/trans_rvi.c.inc @@ -204,22 +204,23 @@ static bool trans_sw(DisasContext *ctx, arg_sw *a) return gen_store(ctx, a, MO_TESL); } -#ifdef TARGET_RISCV64 static bool trans_lwu(DisasContext *ctx, arg_lwu *a) { + REQUIRE_64BIT(ctx); return gen_load(ctx, a, MO_TEUL); } static bool trans_ld(DisasContext *ctx, arg_ld *a) { + REQUIRE_64BIT(ctx); return gen_load(ctx, a, MO_TEQ); } static bool trans_sd(DisasContext *ctx, arg_sd *a) { + REQUIRE_64BIT(ctx); return gen_store(ctx, a, MO_TEQ); } -#endif static bool trans_addi(DisasContext *ctx, arg_addi *a) { @@ -361,14 +362,15 @@ static bool trans_and(DisasContext *ctx, arg_and *a) return gen_arith(ctx, a, &tcg_gen_and_tl); } -#ifdef TARGET_RISCV64 static bool trans_addiw(DisasContext *ctx, arg_addiw *a) { + REQUIRE_64BIT(ctx); return gen_arith_imm_tl(ctx, a, &gen_addw); } static bool trans_slliw(DisasContext *ctx, arg_slliw *a) { + REQUIRE_64BIT(ctx); TCGv source1; source1 = tcg_temp_new(); gen_get_gpr(source1, a->rs1); @@ -383,6 +385,7 @@ static bool trans_slliw(DisasContext *ctx, arg_slliw *a) static bool trans_srliw(DisasContext *ctx, arg_srliw *a) { + REQUIRE_64BIT(ctx); TCGv t = tcg_temp_new(); gen_get_gpr(t, a->rs1); tcg_gen_extract_tl(t, t, a->shamt, 32 - a->shamt); @@ -395,6 +398,7 @@ static bool trans_srliw(DisasContext *ctx, arg_srliw *a) static bool trans_sraiw(DisasContext *ctx, arg_sraiw *a) { + REQUIRE_64BIT(ctx); TCGv t = tcg_temp_new(); gen_get_gpr(t, a->rs1); tcg_gen_sextract_tl(t, t, a->shamt, 32 - a->shamt); @@ -405,16 +409,19 @@ static bool trans_sraiw(DisasContext *ctx, arg_sraiw *a) static bool trans_addw(DisasContext *ctx, arg_addw *a) { + REQUIRE_64BIT(ctx); return gen_arith(ctx, a, &gen_addw); } static bool trans_subw(DisasContext *ctx, arg_subw *a) { + REQUIRE_64BIT(ctx); return gen_arith(ctx, a, &gen_subw); } static bool trans_sllw(DisasContext *ctx, arg_sllw *a) { + REQUIRE_64BIT(ctx); TCGv source1 = tcg_temp_new(); TCGv source2 = tcg_temp_new(); @@ -433,6 +440,7 @@ static bool trans_sllw(DisasContext *ctx, arg_sllw *a) static bool trans_srlw(DisasContext *ctx, arg_srlw *a) { + REQUIRE_64BIT(ctx); TCGv source1 = tcg_temp_new(); TCGv source2 = tcg_temp_new(); @@ -453,6 +461,7 @@ static bool trans_srlw(DisasContext *ctx, arg_srlw *a) static bool trans_sraw(DisasContext *ctx, arg_sraw *a) { + REQUIRE_64BIT(ctx); TCGv source1 = tcg_temp_new(); TCGv source2 = tcg_temp_new(); @@ -473,7 +482,6 @@ static bool trans_sraw(DisasContext *ctx, arg_sraw *a) return true; } -#endif static bool trans_fence(DisasContext *ctx, arg_fence *a) { diff --git a/target/riscv/insn_trans/trans_rvm.c.inc b/target/riscv/insn_trans/trans_rvm.c.inc index 47cd6edc72..10ecc456fc 100644 --- a/target/riscv/insn_trans/trans_rvm.c.inc +++ b/target/riscv/insn_trans/trans_rvm.c.inc @@ -87,34 +87,42 @@ static bool trans_remu(DisasContext *ctx, arg_remu *a) return gen_arith(ctx, a, &gen_remu); } -#ifdef TARGET_RISCV64 static bool trans_mulw(DisasContext *ctx, arg_mulw *a) { + REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); + return gen_arith(ctx, a, &gen_mulw); } static bool trans_divw(DisasContext *ctx, arg_divw *a) { + REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); + return gen_arith_div_w(ctx, a, &gen_div); } static bool trans_divuw(DisasContext *ctx, arg_divuw *a) { + REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); + return gen_arith_div_uw(ctx, a, &gen_divu); } static bool trans_remw(DisasContext *ctx, arg_remw *a) { + REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); + return gen_arith_div_w(ctx, a, &gen_rem); } static bool trans_remuw(DisasContext *ctx, arg_remuw *a) { + REQUIRE_64BIT(ctx); REQUIRE_EXT(ctx, RVM); + return gen_arith_div_uw(ctx, a, &gen_remu); } -#endif diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index 887c6b8883..47914a3b69 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -705,7 +705,6 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) gen_helper_vamominuw_v_w, gen_helper_vamomaxuw_v_w }; -#ifdef TARGET_RISCV64 static gen_helper_amo *const fnsd[18] = { gen_helper_vamoswapw_v_d, gen_helper_vamoaddw_v_d, @@ -726,7 +725,6 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) gen_helper_vamominud_v_d, gen_helper_vamomaxud_v_d }; -#endif if (tb_cflags(s->base.tb) & CF_PARALLEL) { gen_helper_exit_atomic(cpu_env); @@ -734,12 +732,12 @@ static bool amo_op(DisasContext *s, arg_rwdvm *a, uint8_t seq) return true; } else { if (s->sew == 3) { -#ifdef TARGET_RISCV64 - fn = fnsd[seq]; -#else - /* Check done in amo_check(). */ - g_assert_not_reached(); -#endif + if (!is_32bit(s)) { + fn = fnsd[seq]; + } else { + /* Check done in amo_check(). */ + g_assert_not_reached(); + } } else { assert(seq < ARRAY_SIZE(fnsw)); fn = fnsw[seq]; @@ -769,6 +767,11 @@ static bool amo_check(DisasContext *s, arg_rwdvm* a) ((1 << s->sew) >= 4)); } +static bool amo_check64(DisasContext *s, arg_rwdvm* a) +{ + return !is_32bit(s) && amo_check(s, a); +} + GEN_VEXT_TRANS(vamoswapw_v, 0, rwdvm, amo_op, amo_check) GEN_VEXT_TRANS(vamoaddw_v, 1, rwdvm, amo_op, amo_check) GEN_VEXT_TRANS(vamoxorw_v, 2, rwdvm, amo_op, amo_check) @@ -778,17 +781,15 @@ GEN_VEXT_TRANS(vamominw_v, 5, rwdvm, amo_op, amo_check) GEN_VEXT_TRANS(vamomaxw_v, 6, rwdvm, amo_op, amo_check) GEN_VEXT_TRANS(vamominuw_v, 7, rwdvm, amo_op, amo_check) GEN_VEXT_TRANS(vamomaxuw_v, 8, rwdvm, amo_op, amo_check) -#ifdef TARGET_RISCV64 -GEN_VEXT_TRANS(vamoswapd_v, 9, rwdvm, amo_op, amo_check) -GEN_VEXT_TRANS(vamoaddd_v, 10, rwdvm, amo_op, amo_check) -GEN_VEXT_TRANS(vamoxord_v, 11, rwdvm, amo_op, amo_check) -GEN_VEXT_TRANS(vamoandd_v, 12, rwdvm, amo_op, amo_check) -GEN_VEXT_TRANS(vamoord_v, 13, rwdvm, amo_op, amo_check) -GEN_VEXT_TRANS(vamomind_v, 14, rwdvm, amo_op, amo_check) -GEN_VEXT_TRANS(vamomaxd_v, 15, rwdvm, amo_op, amo_check) -GEN_VEXT_TRANS(vamominud_v, 16, rwdvm, amo_op, amo_check) -GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check) -#endif +GEN_VEXT_TRANS(vamoswapd_v, 9, rwdvm, amo_op, amo_check64) +GEN_VEXT_TRANS(vamoaddd_v, 10, rwdvm, amo_op, amo_check64) +GEN_VEXT_TRANS(vamoxord_v, 11, rwdvm, amo_op, amo_check64) +GEN_VEXT_TRANS(vamoandd_v, 12, rwdvm, amo_op, amo_check64) +GEN_VEXT_TRANS(vamoord_v, 13, rwdvm, amo_op, amo_check64) +GEN_VEXT_TRANS(vamomind_v, 14, rwdvm, amo_op, amo_check64) +GEN_VEXT_TRANS(vamomaxd_v, 15, rwdvm, amo_op, amo_check64) +GEN_VEXT_TRANS(vamominud_v, 16, rwdvm, amo_op, amo_check64) +GEN_VEXT_TRANS(vamomaxud_v, 17, rwdvm, amo_op, amo_check64) /* *** Vector Integer Arithmetic Instructions diff --git a/target/riscv/meson.build b/target/riscv/meson.build index 88ab850682..24bf049164 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -7,7 +7,7 @@ gen32 = [ gen64 = [ decodetree.process('insn16.decode', extra_args: [dir / 'insn16-64.decode', '--static-decode=decode_insn16', '--insnwidth=16']), - decodetree.process('insn32.decode', extra_args: [dir / 'insn32-64.decode', '--static-decode=decode_insn32']), + decodetree.process('insn32.decode', extra_args: '--static-decode=decode_insn32'), ] riscv_ss = ss.source_set() From patchwork Tue May 11 10:19:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=dCnkVQ9o; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Ffb2V5gZpz9sVt for ; Tue, 11 May 2021 21:16:02 +1000 (AEST) Received: from localhost ([::1]:46498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQMq-0005an-Q5 for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 07:16:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPY9-0004Zq-Kr for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:38 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41098) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPY7-0006V6-5n for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728614; x=1652264614; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HhXS6Fd5kQIv7sJJfl/l66LLxPEJxvVRkO3qUYKWd2Q=; b=dCnkVQ9oBWFI5rxxMmDHOQU8RHRNYBC+APkqenxofTnHkJdSE+dpAtfq gnkxcxtZa5JZ4BJKhsX4jmBB9Sn2OSj9VwpBUEwteqskOsBIvDm/S6asY 3vceN9ksRiKvviMsareCkUvWeHiVZLhaWxVh3t3QVkNywg4d6d4kyOut9 YS6AqtYRSukMihcZFn1akTFRy06E8KsjtFHaqcgXkY160oW048DEGiCCV iUTU2dEr2m18DZKbr44QcOiZcGUiEMvfQFAuYPElYsyq2OGF4BCFeknqm NJsnsR2TeQjOfu8JcSHLDyyKJ6lvMYXRteajJAbB+BkafN4CLiN4iBHH+ w==; IronPort-SDR: 6mLGUSuzrLKX8oeQqDRRLhyvh4m82Ti5FBa4nO93yL98m2RO2OwZmtCJhNHAw7jgD3wsVxfnH/ R3OdPglP/CF5oxRx7NtwYtYutR+02lfzqDQWv4ovD5ZDibW7ZfC8IV+ab6tK/NzO+8Ra74/CcD HteyDP4Dbx5kcXIZAh42wEFv8TOdWoHE78bobewXEaIaCGoBCC44ooPnVRy9uYGfyF6wPTe7Rq HUBOyFbMkGKTnufrjKN3n/34RQPNEsVB9ZFAGZBQLjq7o0zo9D5ySj3P856A/vskE95lfU7AJP ccI= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735522" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:22:15 +0800 IronPort-SDR: DDvoQdtIWpWSsheCPzhrFQMo2cinm3Xo8NddllGog9SkYAiq8y+vOVYhMw7ocpJjSJVR6LCk8a wy5lr+JDrOvehSTBM9goAf+OyL4isfyINDqCE4CiP1to9EFYX6Gn5A8b6tMiYk0BcaL7BIeBOJ nXvvIgH55IY8Uj3YXTuCzbRSCVlvUXstLW2refp9zgEE79z3eb4LnJEXpn505m1/rfVG3ogX82 ngIStUaYJC+QRTucp+R8uVWm4HqbD8nthXc30LVOQsVwhTQ/SNWEZYeUCNA1qGCddUxczwyhAG 6FEFAnxr9J3Pb5bQRitn+jfE Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:02:15 -0700 IronPort-SDR: txN3JFAwqfpYShDNVsz53c/Uk48Dj9IqU7+9Id6K3hmQfqcRF74zb1KBcQ/WjuLhVCREXDNTuD 8o0Cic1UedINxSIHD8wcKs98TbvuPxvyc2LvYICu4lxbpO+mAi4ZuKdfjk1KURFyDQG1mFEaLD lwD2uv/1pgmkZvtpUbUeqjIXLaFRkYCURTm3A1Hd1E3hQRXiK/nAVPRFXMeapiiH/KQ2GYgc/N iwGq3qV2qQen1cMxitsZmqq8j/6aFRkQ60BMrvGFvJUM0FhtW0ry1eUaBwzFSingtxjWAgLzsT kxI= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:22:14 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 41/42] target/riscv: Consolidate RV32/64 16-bit instructions Date: Tue, 11 May 2021 20:19:50 +1000 Message-Id: <20210511101951.165287-42-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch removes the insn16-32.decode and insn16-64.decode decode files and consolidates the instructions into the general RISC-V insn16.decode decode tree. This means that all of the instructions are avaliable in both the 32-bit and 64-bit builds. This also means that we run a check to ensure we are running a 64-bit softmmu before we execute the 64-bit only instructions. This allows us to include the 32-bit instructions in the 64-bit build, while also ensuring that 32-bit only software can not execute the instructions. Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Message-id: 01e2b0efeae311adc7ebf133c2cde6a7a37224d7.1619234854.git.alistair.francis@wdc.com --- target/riscv/insn16-32.decode | 28 ------------------- target/riscv/insn16-64.decode | 36 ------------------------- target/riscv/insn16.decode | 30 +++++++++++++++++++++ target/riscv/insn_trans/trans_rvi.c.inc | 6 +++++ target/riscv/meson.build | 11 +++----- 5 files changed, 39 insertions(+), 72 deletions(-) delete mode 100644 target/riscv/insn16-32.decode delete mode 100644 target/riscv/insn16-64.decode diff --git a/target/riscv/insn16-32.decode b/target/riscv/insn16-32.decode deleted file mode 100644 index 0819b17028..0000000000 --- a/target/riscv/insn16-32.decode +++ /dev/null @@ -1,28 +0,0 @@ -# -# RISC-V translation routines for the RVXI Base Integer Instruction Set. -# -# Copyright (c) 2018 Peer Adelt, peer.adelt@hni.uni-paderborn.de -# Bastian Koppelmann, kbastian@mail.uni-paderborn.de -# -# This program is free software; you can redistribute it and/or modify it -# under the terms and conditions of the GNU General Public License, -# version 2 or later, as published by the Free Software Foundation. -# -# This program is distributed in the hope it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program. If not, see . - -# *** RV32C Standard Extension (Quadrant 0) *** -flw 011 ... ... .. ... 00 @cl_w -fsw 111 ... ... .. ... 00 @cs_w - -# *** RV32C Standard Extension (Quadrant 1) *** -jal 001 ........... 01 @cj rd=1 # C.JAL - -# *** RV32C Standard Extension (Quadrant 2) *** -flw 011 . ..... ..... 10 @c_lwsp -fsw 111 . ..... ..... 10 @c_swsp diff --git a/target/riscv/insn16-64.decode b/target/riscv/insn16-64.decode deleted file mode 100644 index 672e1e916f..0000000000 --- a/target/riscv/insn16-64.decode +++ /dev/null @@ -1,36 +0,0 @@ -# -# RISC-V translation routines for the RVXI Base Integer Instruction Set. -# -# Copyright (c) 2018 Peer Adelt, peer.adelt@hni.uni-paderborn.de -# Bastian Koppelmann, kbastian@mail.uni-paderborn.de -# -# This program is free software; you can redistribute it and/or modify it -# under the terms and conditions of the GNU General Public License, -# version 2 or later, as published by the Free Software Foundation. -# -# This program is distributed in the hope it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along with -# this program. If not, see . - -# *** RV64C Standard Extension (Quadrant 0) *** -ld 011 ... ... .. ... 00 @cl_d -sd 111 ... ... .. ... 00 @cs_d - -# *** RV64C Standard Extension (Quadrant 1) *** -{ - illegal 001 - 00000 ----- 01 # c.addiw, RES rd=0 - addiw 001 . ..... ..... 01 @ci -} -subw 100 1 11 ... 00 ... 01 @cs_2 -addw 100 1 11 ... 01 ... 01 @cs_2 - -# *** RV64C Standard Extension (Quadrant 2) *** -{ - illegal 011 - 00000 ----- 10 # c.ldsp, RES rd=0 - ld 011 . ..... ..... 10 @c_ldsp -} -sd 111 . ..... ..... 10 @c_sdsp diff --git a/target/riscv/insn16.decode b/target/riscv/insn16.decode index 1cb93876fe..2e9212663c 100644 --- a/target/riscv/insn16.decode +++ b/target/riscv/insn16.decode @@ -92,6 +92,16 @@ lw 010 ... ... .. ... 00 @cl_w fsd 101 ... ... .. ... 00 @cs_d sw 110 ... ... .. ... 00 @cs_w +# *** RV32C and RV64C specific Standard Extension (Quadrant 0) *** +{ + ld 011 ... ... .. ... 00 @cl_d + flw 011 ... ... .. ... 00 @cl_w +} +{ + sd 111 ... ... .. ... 00 @cs_d + fsw 111 ... ... .. ... 00 @cs_w +} + # *** RV32/64C Standard Extension (Quadrant 1) *** addi 000 . ..... ..... 01 @ci addi 010 . ..... ..... 01 @c_li @@ -111,6 +121,15 @@ jal 101 ........... 01 @cj rd=0 # C.J beq 110 ... ... ..... 01 @cb_z bne 111 ... ... ..... 01 @cb_z +# *** RV64C and RV32C specific Standard Extension (Quadrant 1) *** +{ + c64_illegal 001 - 00000 ----- 01 # c.addiw, RES rd=0 + addiw 001 . ..... ..... 01 @ci + jal 001 ........... 01 @cj rd=1 # C.JAL +} +subw 100 1 11 ... 00 ... 01 @cs_2 +addw 100 1 11 ... 01 ... 01 @cs_2 + # *** RV32/64C Standard Extension (Quadrant 2) *** slli 000 . ..... ..... 10 @c_shift2 fld 001 . ..... ..... 10 @c_ldsp @@ -130,3 +149,14 @@ fld 001 . ..... ..... 10 @c_ldsp } fsd 101 ...... ..... 10 @c_sdsp sw 110 . ..... ..... 10 @c_swsp + +# *** RV32C and RV64C specific Standard Extension (Quadrant 2) *** +{ + c64_illegal 011 - 00000 ----- 10 # c.ldsp, RES rd=0 + ld 011 . ..... ..... 10 @c_ldsp + flw 011 . ..... ..... 10 @c_lwsp +} +{ + sd 111 . ..... ..... 10 @c_sdsp + fsw 111 . ..... ..... 10 @c_swsp +} diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc index 1340676209..bd93f634cf 100644 --- a/target/riscv/insn_trans/trans_rvi.c.inc +++ b/target/riscv/insn_trans/trans_rvi.c.inc @@ -24,6 +24,12 @@ static bool trans_illegal(DisasContext *ctx, arg_empty *a) return true; } +static bool trans_c64_illegal(DisasContext *ctx, arg_empty *a) +{ + REQUIRE_64BIT(ctx); + return trans_illegal(ctx, a); +} + static bool trans_lui(DisasContext *ctx, arg_lui *a) { if (a->rd != 0) { diff --git a/target/riscv/meson.build b/target/riscv/meson.build index 24bf049164..af6c3416b7 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -1,18 +1,13 @@ # FIXME extra_args should accept files() dir = meson.current_source_dir() -gen32 = [ - decodetree.process('insn16.decode', extra_args: [dir / 'insn16-32.decode', '--static-decode=decode_insn16', '--insnwidth=16']), - decodetree.process('insn32.decode', extra_args: '--static-decode=decode_insn32'), -] -gen64 = [ - decodetree.process('insn16.decode', extra_args: [dir / 'insn16-64.decode', '--static-decode=decode_insn16', '--insnwidth=16']), +gen = [ + decodetree.process('insn16.decode', extra_args: ['--static-decode=decode_insn16', '--insnwidth=16']), decodetree.process('insn32.decode', extra_args: '--static-decode=decode_insn32'), ] riscv_ss = ss.source_set() -riscv_ss.add(when: 'TARGET_RISCV32', if_true: gen32) -riscv_ss.add(when: 'TARGET_RISCV64', if_true: gen64) +riscv_ss.add(gen) riscv_ss.add(files( 'cpu.c', 'cpu_helper.c', From patchwork Tue May 11 10:19:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1477089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=iB1JMC7O; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Ffb5R6vx6z9sWD for ; Tue, 11 May 2021 21:18:35 +1000 (AEST) Received: from localhost ([::1]:49594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgQPJ-0007p6-VU for incoming@patchwork.ozlabs.org; Tue, 11 May 2021 07:18:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPY9-0004aV-Nx for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:38 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:41095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgPY7-0006TG-Uz for qemu-devel@nongnu.org; Tue, 11 May 2021 06:23:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1620728615; x=1652264615; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Hm1PZz5zTe2h985zHWYZPUO7Ex1Xb0pRXXDGBKNcQMc=; b=iB1JMC7O0CEvCuD5Wyl8NpsLwUHwREA9lbmPX4Dh7IpNFSno7l4H7dMF 41eKndIy6mDleGnTGkxkTTmw37FwgknphDrTt2W0DtVfXen/pg8pzCq5n bJRC1yPMWEeCWFy1eC9cDrHVRoA+Q3CuwAs2ap0DdPuOBc/S9FFcrp5bU WAeZC0YM4cd5VM3olEFk2uUSXZ6IQs8yTbh3phYgeSp0vGZBTrR0LO0kK u3QNEk156gWS5wzfskGz0r1DxF2ftUNKcVaOv6WfnRYeEA24P1lfCT71r 18irauS8U5SoS67XgVGREDL/tTGPb7EH4ehxfpqdk6z2WzzWwoCvOdoq5 A==; IronPort-SDR: Bqk4oZEe8M8ok184uOt97z6r6ynpGIV9K9QVOM6gwI7kiFzBxjPth2GPjZxTo5MgifVUPUXuQ8 nykTmyNNSIXJFFcLt3tKfHeMV77lr+tL/EsITcS8Q6vXemHpiyfEgbgZV3zv8POkyuFYVstXmr LC+etDe63HFor1PbBP1izDV4Qmc38hyGn6cJ62jH2NraNSgWqpgvAFxq6wht1jlJZdkS1qQ9aw 3Tagaz719vXLM4sJTZQzrLzMjWY0UYGzyWbLdFsjuV/VbfFlzOxNrVRjjwP62ZbIHi7C1T7x4+ eS0= X-IronPort-AV: E=Sophos;i="5.82,290,1613404800"; d="scan'208";a="167735527" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 May 2021 18:22:19 +0800 IronPort-SDR: nQRTfTcM29Og3lgT6lBsEM3GGoLSIIuErIHQweNRPXniSYJTUyUWT5SxDBVuRhz95Xc+2PpAwD gRx0GCX/sPfBh09T0NLjgs5MjoyWQhHX9aWBo2U7uP8k8tXYHH/+zNfIoUwg3rW31ZOmgp2Kvo 6TWFo9NcMD/tQKM8aKoRPk7NkU8ORXajGOasfTMlyIs2pBiWiRTK5x8FfPeRCnE24hG1c3uCme leaaib4GhzMyj/1UPKypGTOLQ+FWkXEdK9uCQxWXROPfQmXLv7UiNnSpP152uxDGPP7jInUJtj KAgsC7UBIYlzdYktzZ7w0wvD Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2021 03:02:18 -0700 IronPort-SDR: zMKZSO+fHpfohjH/kuuvG3upQoSZMUE0mtUqQrP+A2zgJQAxWsQ7h2sDgrI8Y58fio/Iv6szkb Xv8Fr2qKOPrKtUFsBHuMzXqTB4T6CYrSekmO9qcrgF4/+P75RMwQLjJzHGXh3fNk6lazJuznGS Ioah6lctruNl37nGUooaN9yWCJ3C9KMqkyh5Q7n9v0gfgSnRdlKl4DlIl4PllEJ8dH3KowY5rP LBK836tMQPc+QMn3a8UcHZCKC4fD7mCOgrjFyHwMDU/TP0pkjf8GMEyeTt/qthy1JN5FEFu6t8 GS8= WDCIronportException: Internal Received: from unknown (HELO alistair-risc6-laptop.wdc.com) ([10.225.165.48]) by uls-op-cesaip01.wdc.com with ESMTP; 11 May 2021 03:22:17 -0700 From: Alistair Francis To: peter.maydell@linaro.org Subject: [PULL v3 42/42] target/riscv: Fix the RV64H decode comment Date: Tue, 11 May 2021 20:19:51 +1000 Message-Id: <20210511101951.165287-43-alistair.francis@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511101951.165287-1-alistair.francis@wdc.com> References: <20210511101951.165287-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=7584e029c=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Richard Henderson , Alistair Francis , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" BugLink: https://gitlab.com/qemu-project/qemu/-/issues/47 Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson Message-id: 024ce841221c1d15c74b253512428c4baca7e4ba.1619234854.git.alistair.francis@wdc.com --- target/riscv/insn32.decode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index fecf0f15d5..8901ba1e1b 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -288,7 +288,7 @@ hsv_w 0110101 ..... ..... 100 00000 1110011 @r2_s hfence_gvma 0110001 ..... ..... 000 00000 1110011 @hfence_gvma hfence_vvma 0010001 ..... ..... 000 00000 1110011 @hfence_vvma -# *** RV32H Base Instruction Set *** +# *** RV64H Base Instruction Set *** hlv_wu 0110100 00001 ..... 100 ..... 1110011 @r2 hlv_d 0110110 00000 ..... 100 ..... 1110011 @r2 hsv_d 0110111 ..... ..... 100 00000 1110011 @r2_s