From nobody Wed May 15 07:37:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416282919761.6481370790775; Sun, 18 Dec 2022 18:18:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75iY-0008Ae-Qd; Sun, 18 Dec 2022 21:17:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iV-0008A2-Ub for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:24 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iS-00013m-FR for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:23 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:15 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:29:47 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:15 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Ht48Q5z1RvLy for ; Sun, 18 Dec 2022 18:17:14 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id qRq2WlPgodbt for ; Sun, 18 Dec 2022 18:17:13 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Hq6qs6z1RwqL; Sun, 18 Dec 2022 18:17:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416240; x=1702952240; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FRlSMP2b8zsVb4/ZDgFRZe/06W5GBU6yfCP7/T4rVJo=; b=GJMlai6IfNW0uUIEdWAqrAkKY5GzDU+4pzdtYg8dCXCEHMYTQQMOeR44 w5mqv1oiNfTLfPpO2ILTO4j0gUMuthb24piZ37OYDSlEfNxuicxcCr0B4 AWicHSmsH2bjBCn6tmidaeMU8gzhca0OrMnvp6k6gkiXNNPZCDQRcAQ52 jIVmHcy0KgbQkO4YKpLbK8Muy+nMwHDK4+K4d+f56yz5ssSyMEQLOfhKT XEIk+HW0v86Zrf5b4LPHEGz0Y6gEVV3fVdeQe+kcp5x55xmqk6rzHqUTh L+hsg94o1/CFqWciGrbWPkt3NmUccVWUbOcy4OEGqbxF9BlLnrUpClbgT A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199248" IronPort-SDR: ABwaewP53bgbKD4patGYomEUXiWtnjbpiBc9/spMW728nH5g0BCh8p0oo+wvtd5Bfe9BtmUeu5 aaiMVDzhFGlb23Xy5Hslw2nLkoFUOg92swFasteOId+wwSpDlCJUbvPDtxummaNcGbqyEhf4eT vGc5qsOxUZXosE58k5poZMt4sZaKOQhdUX+xSjbgSCm2ZVwHXPGFkspOHgDf4jDOUKhf0pLhk+ 83d315J6nY9KhN0J02p39hpMHijpfCq0MNf4h1aW7K10t4zE7B1849gbkdzrh3BSfxp8/bl1Fm XcM= IronPort-SDR: 6IhbvXvpvMW+HSHorCmcpYPuYv1Bjg5+Jrs38YIVtgBQX+WV5g8bAuXxT+9s+qcrMnkIczLMaB IbJMMC0fGrujkkI1Q3FoLFRzLvBUjoFUlL7EdMsRiN7SLLJs1dRADbXeDDTbgI0dGJj3EjxIR6 UpvvlBiytf9XxIx+m91cw5Z1cDMKdlJW5h3IbaVd3xZKN3QNgJndLIfAp13xxHtWGHxLirnhnL lqEseQbQ4PIz4H0u4nyvC3SHFYOIBqQ10p/jvVXfeFWpzGhH4PxzCMnHYL8zrUxjYjGPGqdUEm kzA= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416233; x=1674008234; bh=FRlSMP2b8zsVb4/ZDg FRZe/06W5GBU6yfCP7/T4rVJo=; b=qqIkSHR6CzB68bCXJ8gUFmTzGxzwoLP9Np Gf0Hr31Xdc9ID+Rk8BTJQE07avHpFRtlLo5L33q34EzYqHvWNsOSk4iw4w4nM35M +DNGnkTL4EIpjS77PtRm+CCq1coFfzsfz/1rZ9knQISlovAd9uLrTjkoBD4SplVY u3kawAVC70CP+TWhluUShLIoJed4HNQjyyXr1xdNLVBsH4N6MiZjPzNmmqpx6dvC jJqbuItpSQgJKEnLy2Jkmwpzd97KP2YV6Ob/V9PMZS/j6HaOacNKmi85NHoe8uI+ OLxjSRmfFsCFTVVPPYWMF0Um9vNAqtOXB3bKpo+rivHVmufkUAkQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Alistair Francis Subject: [PULL 01/45] target/riscv: Fix PMP propagation for tlb Date: Mon, 19 Dec 2022 12:16:19 +1000 Message-Id: <20221219021703.20473-2-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416284297100002 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei Only the pmp index that be checked by pmp_hart_has_privs can be used by pmp_get_tlb_size to avoid an error pmp index. Before modification, we may use an error pmp index. For example, we check address 0x4fc, and the size 0x4 in pmp_hart_has_privs. If there is an pmp rule, valid range is [0x4fc, 0x500), then pmp_hart_has_privs will return true; However, this checked pmp index is discarded as pmp_hart_has_privs return bool value. In pmp_is_range_in_tlb, it will traverse all pmp rules. The tlb_sa will be 0x0, and tlb_ea will be 0xfff. If there is a pmp rule [0x10, 0x14), it will be misused as it is legal in pmp_get_tlb_size. As we have already known the correct pmp index, just remove the remove the pmp_is_range_in_tlb and get tlb size directly from pmp_get_tlb_size. Signed-off-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-Id: <20221012060016.30856-1-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- target/riscv/pmp.h | 6 +-- target/riscv/cpu_helper.c | 16 ++++--- target/riscv/pmp.c | 90 +++++++++++++-------------------------- 3 files changed, 42 insertions(+), 70 deletions(-) diff --git a/target/riscv/pmp.h b/target/riscv/pmp.h index a8dd797476..da32c61c85 100644 --- a/target/riscv/pmp.h +++ b/target/riscv/pmp.h @@ -72,11 +72,11 @@ 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); -bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, +int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, target_ulong size, pmp_priv_t privs, pmp_priv_t *allowed_privs, target_ulong mode); -bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa, - target_ulong *tlb_size); +target_ulong pmp_get_tlb_size(CPURISCVState *env, int pmp_index, + target_ulong tlb_sa, target_ulong tlb_ea); void pmp_update_rule_addr(CPURISCVState *env, uint32_t pmp_index); void pmp_update_rule_nums(CPURISCVState *env); uint32_t pmp_get_num_rules(CPURISCVState *env); diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 278d163803..5d66246c2c 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -706,24 +706,26 @@ static int get_physical_address_pmp(CPURISCVState *en= v, int *prot, int mode) { pmp_priv_t pmp_priv; - target_ulong tlb_size_pmp =3D 0; + int pmp_index =3D -1; =20 if (!riscv_feature(env, RISCV_FEATURE_PMP)) { *prot =3D PAGE_READ | PAGE_WRITE | PAGE_EXEC; return TRANSLATE_SUCCESS; } =20 - if (!pmp_hart_has_privs(env, addr, size, 1 << access_type, &pmp_priv, - mode)) { + pmp_index =3D pmp_hart_has_privs(env, addr, size, 1 << access_type, + &pmp_priv, mode); + if (pmp_index < 0) { *prot =3D 0; return TRANSLATE_PMP_FAIL; } =20 *prot =3D pmp_priv_to_page_prot(pmp_priv); - if (tlb_size !=3D NULL) { - if (pmp_is_range_in_tlb(env, addr & ~(*tlb_size - 1), &tlb_size_pm= p)) { - *tlb_size =3D tlb_size_pmp; - } + if ((tlb_size !=3D NULL) && pmp_index !=3D MAX_RISCV_PMPS) { + target_ulong tlb_sa =3D addr & ~(TARGET_PAGE_SIZE - 1); + target_ulong tlb_ea =3D tlb_sa + TARGET_PAGE_SIZE - 1; + + *tlb_size =3D pmp_get_tlb_size(env, pmp_index, tlb_sa, tlb_ea); } =20 return TRANSLATE_SUCCESS; diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 2b43e399b8..d1126a6066 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -292,8 +292,11 @@ static bool pmp_hart_has_privs_default(CPURISCVState *= env, target_ulong addr, =20 /* * Check if the address has required RWX privs to complete desired operati= on + * Return PMP rule index if a pmp rule match + * Return MAX_RISCV_PMPS if default match + * Return negtive value if no match */ -bool pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, +int pmp_hart_has_privs(CPURISCVState *env, target_ulong addr, target_ulong size, pmp_priv_t privs, pmp_priv_t *allowed_privs, target_ulong mode) { @@ -305,8 +308,10 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulo= ng addr, =20 /* Short cut if no rules */ if (0 =3D=3D pmp_get_num_rules(env)) { - return pmp_hart_has_privs_default(env, addr, size, privs, - allowed_privs, mode); + if (pmp_hart_has_privs_default(env, addr, size, privs, + allowed_privs, mode)) { + ret =3D MAX_RISCV_PMPS; + } } =20 if (size =3D=3D 0) { @@ -333,7 +338,7 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ulon= g addr, if ((s + e) =3D=3D 1) { qemu_log_mask(LOG_GUEST_ERROR, "pmp violation - access is partially inside\n"); - ret =3D 0; + ret =3D -1; break; } =20 @@ -436,18 +441,22 @@ bool pmp_hart_has_privs(CPURISCVState *env, target_ul= ong addr, } } =20 - ret =3D ((privs & *allowed_privs) =3D=3D privs); + if ((privs & *allowed_privs) =3D=3D privs) { + ret =3D i; + } break; } } =20 /* No rule matched */ if (ret =3D=3D -1) { - return pmp_hart_has_privs_default(env, addr, size, privs, - allowed_privs, mode); + if (pmp_hart_has_privs_default(env, addr, size, privs, + allowed_privs, mode)) { + ret =3D MAX_RISCV_PMPS; + } } =20 - return ret =3D=3D 1 ? true : false; + return ret; } =20 /* @@ -586,64 +595,25 @@ target_ulong mseccfg_csr_read(CPURISCVState *env) * Calculate the TLB size if the start address or the end address of * PMP entry is presented in the TLB page. */ -static target_ulong pmp_get_tlb_size(CPURISCVState *env, int pmp_index, - target_ulong tlb_sa, target_ulong tlb= _ea) +target_ulong pmp_get_tlb_size(CPURISCVState *env, int pmp_index, + target_ulong tlb_sa, target_ulong tlb_ea) { target_ulong pmp_sa =3D env->pmp_state.addr[pmp_index].sa; target_ulong pmp_ea =3D env->pmp_state.addr[pmp_index].ea; =20 - if (pmp_sa >=3D tlb_sa && pmp_ea <=3D tlb_ea) { - return pmp_ea - pmp_sa + 1; - } - - if (pmp_sa >=3D tlb_sa && pmp_sa <=3D tlb_ea && pmp_ea >=3D tlb_ea) { - return tlb_ea - pmp_sa + 1; - } - - if (pmp_ea <=3D tlb_ea && pmp_ea >=3D tlb_sa && pmp_sa <=3D tlb_sa) { - return pmp_ea - tlb_sa + 1; - } - - return 0; -} - -/* - * Check is there a PMP entry which range covers this page. If so, - * try to find the minimum granularity for the TLB size. - */ -bool pmp_is_range_in_tlb(CPURISCVState *env, hwaddr tlb_sa, - target_ulong *tlb_size) -{ - int i; - target_ulong val; - target_ulong tlb_ea =3D (tlb_sa + TARGET_PAGE_SIZE - 1); - - for (i =3D 0; i < MAX_RISCV_PMPS; i++) { - val =3D pmp_get_tlb_size(env, i, tlb_sa, tlb_ea); - if (val) { - if (*tlb_size =3D=3D 0 || *tlb_size > val) { - *tlb_size =3D val; - } - } - } - - if (*tlb_size !=3D 0) { + if (pmp_sa <=3D tlb_sa && pmp_ea >=3D tlb_ea) { + return TARGET_PAGE_SIZE; + } else { /* - * At this point we have a tlb_size that is the smallest possible = size - * That fits within a TARGET_PAGE_SIZE and the PMP region. - * - * If the size is less then TARGET_PAGE_SIZE we drop the size to 1. - * This means the result isn't cached in the TLB and is only used = for - * a single translation. - */ - if (*tlb_size < TARGET_PAGE_SIZE) { - *tlb_size =3D 1; - } - - return true; + * At this point we have a tlb_size that is the smallest possible s= ize + * That fits within a TARGET_PAGE_SIZE and the PMP region. + * + * If the size is less then TARGET_PAGE_SIZE we drop the size to 1. + * This means the result isn't cached in the TLB and is only used f= or + * a single translation. + */ + return 1; } - - return false; } =20 /* --=20 2.38.1 From nobody Wed May 15 07:37:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416288824721.8990598548095; Sun, 18 Dec 2022 18:18:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75ia-0008Bl-Oa; Sun, 18 Dec 2022 21:17:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iW-0008AP-JI for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:24 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iU-00013w-Ex for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:23 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:17 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:29:50 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:17 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Hx3dRPz1RvLy for ; Sun, 18 Dec 2022 18:17:17 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id DDNW8Vf7Fxcu for ; Sun, 18 Dec 2022 18:17:17 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Ht4vLCz1Rwrq; Sun, 18 Dec 2022 18:17:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416242; x=1702952242; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CI5uErihF5w7ZBbRgK9Gg9eNSt3tdaxo7HSFvtv5odE=; b=qrgNKs2huN6YJ691dHgNyz/q8SpTxqymjOdutBAZwcG/8fwMssXPVb8M tE6i4veCIvtLE7uh00DmZSmYVYNjounjdMdZl78pUDjmioNFFHit2oAEG X2x85mClkmF3TlFVuA45xM84Z+vZhkiOEezHgazAAw/JIPGY3Tbx/qfXH hsfzPNnSAwxU1nhsknzXCCGAShL4cmMh0MO97PGGYQlU8bNfA4X/E4oo8 iL/IdUcwDmK755rnkx9n5/4kLKbtUDOpxNaKMJu/mA4f5m5vuuqWeBaEf 2zk16ur6Tr7nIVaIBaGnh8uTGZ6GTvC435t31aocyzzjvcrP2ah1HeQjz A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199259" IronPort-SDR: 1vnKhNL7y/jgzeyMyDjrTmK5OIWlaXZXPEsjtLVwLmjIqaEdGtPUiUyknCYWS0aq2tgJXTPwX3 8kOq2hmRcQ594eVSxb26V7EJku/ytOyNkjUQbgVYwp+sXWED4RhBinSaOoQF1Cki6eoFRguHRa Wsm+wifFPphM5Z+SagKT76cteeOvXKBw6WhSYvo4jqqboauT4JAaQ+qC58Bs4qNlpHym6YtM6P 2GSd1pFuDZCa8KZZxFfepzR3wFMlHwzqPBggSaS7vo2MJiG2zJo7+cc28VsR2kYhulBXBC7dMO /PY= IronPort-SDR: Y6v/X8AUxcuVyZKe/QOTgFH4DFv/JwtFYEA1tocK+Y4Y0tcsSsWSr5p9D9uqOlg9RoeUEAnZ70 v1vYN0X+Fj5mJvMQH1kLLhK5sv8vaKWXp4dY55hBlXjtprkqDDkUPHJ6d6gcEyARJ08e8StQLI My3u7Q5hIDmKk8QlkGbBoBbV6pJZav0KPr5YDJpF2NUxvjJvtq2Mhj0TFB00LND3lcFAmdE99j DEOeZFoFdOryLm5Lfb8Msh3DoZGvM+IXs+O7j9hgUIRQM4TaSjH2wddUsDGhcTmaWLCwmBXhbs wCo= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416237; x=1674008238; bh=CI5uErihF5w7ZBbRgK 9Gg9eNSt3tdaxo7HSFvtv5odE=; b=RQ055jm+OukAQA03iXgKw1L1QjOXnJNy1j x4ofbfSDPpIDEAzPsYRsiASkLdnpEG8z3PyPTLQkiNttXD/gKQOF/+NB5lZCZk0m TCeXHRUY05Ye1m5jCPUZ4HqvjrDrIlGr5erl/4LOFVzox0G/Ned4cOCl7J2S9LV6 2g1y1rdgdyY/WXRDBxBYI6s6mN+Uv4/mnVpjGKubaEru5DhIVU2xiMzHwZfwFAv2 DvxmcBJCZWnkdOj/FAqSd27WEkT8hMzhgWbGuKJIOoEB76N/DzIZO2Qr2jKf232K 4Vwj87JLeGa886omcAd6E1zkFK4ywpOBguF1Ejhle0/8//arp0Lw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Wilfred Mallawa , Alistair Francis Subject: [PULL 02/45] hw/registerfields: add `FIELDx_1CLEAR()` macro Date: Mon, 19 Dec 2022 12:16:20 +1000 Message-Id: <20221219021703.20473-3-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416290067100001 Content-Type: text/plain; charset="utf-8" From: Wilfred Mallawa Adds a helper macro that implements the register `w1c` functionality. Ex: uint32_t data =3D FIELD32_1CLEAR(val, REG, FIELD); If ANY bits of the specified `FIELD` is set then the respective field is cleared and returned to `data`. If the field is cleared (0), then no change and val is returned. Signed-off-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221017054950.317584-2-wilfred.mallawa@opensource.wdc.com> Signed-off-by: Alistair Francis --- include/hw/registerfields.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h index 1330ca77de..0b8404c2f7 100644 --- a/include/hw/registerfields.h +++ b/include/hw/registerfields.h @@ -115,6 +115,28 @@ R_ ## reg ## _ ## field ## _LENGTH, _v.v); \ _d; }) =20 +/* + * Clear the specified field in storage if + * any field bits are set, else no changes made. Implements + * single/multi-bit `w1c` + * + */ +#define FIELD8_1CLEAR(storage, reg, field) \ + (FIELD_EX8(storage, reg, field) ? \ + FIELD_DP8(storage, reg, field, 0x00) : storage) + +#define FIELD16_1CLEAR(storage, reg, field) \ + (FIELD_EX16(storage, reg, field) ? \ + FIELD_DP16(storage, reg, field, 0x00) : storage) + +#define FIELD32_1CLEAR(storage, reg, field) \ + (FIELD_EX32(storage, reg, field) ? \ + FIELD_DP32(storage, reg, field, 0x00) : storage) + +#define FIELD64_1CLEAR(storage, reg, field) \ + (FIELD_EX64(storage, reg, field) ? \ + FIELD_DP64(storage, reg, field, 0x00) : storage) + #define FIELD_SDP8(storage, reg, field, val) ({ \ struct { \ signed int v:R_ ## reg ## _ ## field ## _LENGTH; \ --=20 2.38.1 From nobody Wed May 15 07:37:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416846593223.09604030610512; Sun, 18 Dec 2022 18:27:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75ic-0008CM-J3; Sun, 18 Dec 2022 21:17:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iY-0008Ag-FJ for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:26 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iW-00013m-E9 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:25 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:21 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:29:53 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:21 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3J05ySMz1RvTr for ; Sun, 18 Dec 2022 18:17:20 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XqR75-9dbV8i for ; Sun, 18 Dec 2022 18:17:20 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Hy1LYjz1RvLy; Sun, 18 Dec 2022 18:17:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416244; x=1702952244; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R0UTDDb8qlNNbQTJDvqcP3kxtottUm1EerNxVeKk0so=; b=Pmd7sxl3JiSLyDPGYTXhMYTimVkn/IXy22lBFN88maqLebhndl+NmbNo mVgcbuUTUuqZGbwmmSgqnDz2+CwcuyB2MSS33G42LMvIzw46YoGZfh2ow CJuw2+zU4oiCZxa/MbBifNbSHANlEEoucZflClreNgHn8BT5cWbzZSJta /S5VqUt3X19TiDCUcST5/IKEG2dgCPIy4OqxZAed15cvqceuBHqPXNyx7 WLMs1KFOGq9DmiJnfdT+K5EZ0jXNXya7maKRlvqqnghy06bTm7DTYIgbm Tl38tADxnYQkzAVcJWm58v0Tux4dGQAe659s6R2b+Jc6DBoJ/+jjeixC2 g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199271" IronPort-SDR: wknXpZ5H9p8SXbejzJJ1ibWlCZ1yfb+HSvUAK5ST0rfIfjJAPjBvcVEauTILD9+qaDpZX5I2BA w45zru8gLF6FB7/4Yb1zXGfiPlJ2vUDvGQG2M9DPZsKWxW2L7guYhEwJNApBme5iDeQQg2wOby vSOZCaBFrmUdJQEPzip9d2kQWwVPcbL5sAk6+IItWeF2rGiZ67f9bsQyoPnbRSQC3XnX6gV8Qd sLmPeGk6fIihgSrIDRXVzANO46W2Eyz5rAdeSgPPDR5vefPFw5p0F2MX+I6gls2n6uXattfaAf 5BE= IronPort-SDR: 1iIhUNKUijMZJLZLEsZ0MNHvDsZxwSTvgn3RaZQp+9Tm41uGQneccOqII7FFwTMsHMWiSqcdVr D+1JM3PwLgEnpn4N0mqOQgEYQEDcOWk7hZLVx2qudIPmZcsFPH/lW80jjK4HicIlOfP2w4In/y JlmIfSHgMTimqV7rPhf6L/cUv9zyImbunq+sAX0z5HH30fhpY55L97mCiQuxMbJopdrPAHQTHC vZd3oA5EBZlcGFhtCK+C1J1VD89MW3xWanLbzJwY4vE66J5L+m+u4oNTtMYqZvOOh1fm45wPL/ yaI= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416240; x=1674008241; bh=R0UTDDb8qlNNbQTJDv qcP3kxtottUm1EerNxVeKk0so=; b=beK9Z3a6yXA+TKAea/21lac2bMAbFNNbRO t35tk/0K6mHZgWOk3ekNQKny54H6JKSQlgF2NfGR0cxKzKDnDmjFydPgGQxCKP8H GpECRw8PNBJZlBHnPpL1LUzNgEyh98l6f0PC94OMnAfLRxcDozgPJqNCpxh58qz0 wnE64FphgI4iN3A6KEehJx0VHymjOzXoSk+Pl9k6Gig/ZWowqY29xzzxcyqIxf+I CdMgzdFea5+289aMzAiOMVBzYz768Fw+an8Xr0QFZW9NT0cTw0nIFbQXxr1cLXGy RRNKvEXbIdBtw4ZO8RJq8k8WqrRldRPgADqGIKgT8X/Ig8p/KOPw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Wilfred Mallawa , Alistair Francis Subject: [PULL 03/45] hw/ssi/ibex_spi: implement `FIELD32_1CLEAR` macro Date: Mon, 19 Dec 2022 12:16:21 +1000 Message-Id: <20221219021703.20473-4-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416847562100003 Content-Type: text/plain; charset="utf-8" From: Wilfred Mallawa use the `FIELD32_1CLEAR` macro to implement register `rw1c` functionality to `ibex_spi`. This change was tested by running the `SPI_HOST` from TockOS. Signed-off-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221017054950.317584-3-wilfred.mallawa@opensource.wdc.com> Signed-off-by: Alistair Francis --- hw/ssi/ibex_spi_host.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/hw/ssi/ibex_spi_host.c b/hw/ssi/ibex_spi_host.c index 57df462e3c..0a456cd1ed 100644 --- a/hw/ssi/ibex_spi_host.c +++ b/hw/ssi/ibex_spi_host.c @@ -342,7 +342,7 @@ static void ibex_spi_host_write(void *opaque, hwaddr ad= dr, { IbexSPIHostState *s =3D opaque; uint32_t val32 =3D val64; - uint32_t shift_mask =3D 0xff, status =3D 0, data =3D 0; + uint32_t shift_mask =3D 0xff, status =3D 0; uint8_t txqd_len; =20 trace_ibex_spi_host_write(addr, size, val64); @@ -355,12 +355,11 @@ static void ibex_spi_host_write(void *opaque, hwaddr = addr, case IBEX_SPI_HOST_INTR_STATE: /* rw1c status register */ if (FIELD_EX32(val32, INTR_STATE, ERROR)) { - data =3D FIELD_DP32(data, INTR_STATE, ERROR, 0); + s->regs[addr] =3D FIELD32_1CLEAR(s->regs[addr], INTR_STATE, ER= ROR); } if (FIELD_EX32(val32, INTR_STATE, SPI_EVENT)) { - data =3D FIELD_DP32(data, INTR_STATE, SPI_EVENT, 0); + s->regs[addr] =3D FIELD32_1CLEAR(s->regs[addr], INTR_STATE, SP= I_EVENT); } - s->regs[addr] =3D data; break; case IBEX_SPI_HOST_INTR_ENABLE: s->regs[addr] =3D val32; @@ -505,27 +504,25 @@ static void ibex_spi_host_write(void *opaque, hwaddr = addr, * When an error occurs, the corresponding bit must be cleared * here before issuing any further commands */ - status =3D s->regs[addr]; /* rw1c status register */ if (FIELD_EX32(val32, ERROR_STATUS, CMDBUSY)) { - status =3D FIELD_DP32(status, ERROR_STATUS, CMDBUSY, 0); + s->regs[addr] =3D FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, = CMDBUSY); } if (FIELD_EX32(val32, ERROR_STATUS, OVERFLOW)) { - status =3D FIELD_DP32(status, ERROR_STATUS, OVERFLOW, 0); + s->regs[addr] =3D FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, = OVERFLOW); } if (FIELD_EX32(val32, ERROR_STATUS, UNDERFLOW)) { - status =3D FIELD_DP32(status, ERROR_STATUS, UNDERFLOW, 0); + s->regs[addr] =3D FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, = UNDERFLOW); } if (FIELD_EX32(val32, ERROR_STATUS, CMDINVAL)) { - status =3D FIELD_DP32(status, ERROR_STATUS, CMDINVAL, 0); + s->regs[addr] =3D FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, = CMDINVAL); } if (FIELD_EX32(val32, ERROR_STATUS, CSIDINVAL)) { - status =3D FIELD_DP32(status, ERROR_STATUS, CSIDINVAL, 0); + s->regs[addr] =3D FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, = CSIDINVAL); } if (FIELD_EX32(val32, ERROR_STATUS, ACCESSINVAL)) { - status =3D FIELD_DP32(status, ERROR_STATUS, ACCESSINVAL, 0); + s->regs[addr] =3D FIELD32_1CLEAR(s->regs[addr], ERROR_STATUS, = ACCESSINVAL); } - s->regs[addr] =3D status; break; case IBEX_SPI_HOST_EVENT_ENABLE: /* Controls which classes of SPI events raise an interrupt. */ --=20 2.38.1 From nobody Wed May 15 07:37:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416430539864.0293426705413; Sun, 18 Dec 2022 18:20:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75id-0008Cm-7R; Sun, 18 Dec 2022 21:17:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iY-0008Al-HN for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:26 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iW-00013w-TM for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:26 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:23 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:29:56 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:23 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3J31Q0qz1Rwt8 for ; Sun, 18 Dec 2022 18:17:23 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id gKkWB8GkCi8S for ; Sun, 18 Dec 2022 18:17:22 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3J06s8bz1RvLy; Sun, 18 Dec 2022 18:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416244; x=1702952244; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CA4KckVxC2yHEoq4Su2S93cY9ilRgoP8o3uZSJMhlOs=; b=Y+P8A1R6loFkuwgluFYLspe5bbiJd6Xc5+xZupUUs/hd0GjDo8lL5eni iEubvSrnIHIlk4wOtp49lRGoD/q5wb5pRTOplefsAuz8FASUNMl+2dTuo temMScee0bSUpOoq3fmpr/lRfGxtr4+1vTaJ7cmeIr9jTrQcNnFWaw/DY +xXsnbpTnc83411xQgH1k34PaxNBeuwEv79PQzbfpyHV7AZyhX+upFdh2 jl5iTIIAyoF/h4/z3Z/c7PykGM1CuMPT8P5yWElxg2ytCea+yC8GAEN8B WrcQdqaI7Sx42EbvCrwCJD1Z16ZQYzBQaGVvRGJGs237lmCDtnwlL/Msx w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199280" IronPort-SDR: aXCWQtB5DYbazHwkr3ewQhmQYwloKWHUOindeTycQ866u3QS3ALUUHZWPqTkaGrq6XldMGAzXj nMY8ATupFph4RHt0MWbe2KOj8Ma0hVLtcs3HxgoATeB5H0gc7W7kW+eQY+KTW1BA/ULI+v+laP MQ1MZ3Umio/O4OFuIMj7sOB8miw1FJ2lUQPB36Jp8+rEC0ab4XE4hG6s0i+vhS1vTRirYRQkFq fITYB9+Asa500eK3LG69gSjvTXdlO44hpqVzQ/bCLj5izNWOf9tRZan72dJ6h2iE8o9yZyZt3T geI= IronPort-SDR: jToedMe9jfg62Lw6DWbZH4zX8KERCRAWdZ9+N/+hj7DYQjgyU3WaZU4ThZfV2DhIzZagrR0gIM jHhViK5HZICoN/F9/0B6DbYka/tN00K+zuvP9anb6xA9HA2ySmrF0IUkxvBlNIje3iyKVwT76a myEJkuR0+SGmnxjR8E6O3Ln+FeSwa6r7ogsLzxUpSZP+Gd2gjzbKEFIDuRJ+E2yCzXUoHhqyxF JJPp4nrAgNJ7l27puPAYBToG/yYzAvh5i/2cVrm8eDGlpDEhfovuTpnj0hlbdDWOIVoLRhs4Fz Qvk= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416242; x=1674008243; bh=CA4KckVxC2yHEoq4Su 2S93cY9ilRgoP8o3uZSJMhlOs=; b=dmNSHIOhTtHVOcD4a/kEwLvgNGE68ddaXN fxuipKXPa9ejvXQ3tLpwQRMSukQ80H01mmEEDn0xbaNHctOeKYCIcqAvWxO9GJBb bWyjva63BcBVdhBSt0/BJQ2RGmU3OV2hrRQojEhiHB/yEGvpBSep8By4Q90m7ptk ZpEf+eQ5SxW52wDZoWmbD1rucvF1uwtIYh1cugAecQUjFGtH5RmJsvYhOJBMIwaq hBDcTpb1iMEbB0R3lrexHadnxej0+3vC4xBxyHMe/giG1/WOPyylyHgQDcK3Crvt HWJq7HAdrVXYyYM4ZpmZxqaEfFLRD+vuLZgBDGg/bGsBNbDCJI+g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 04/45] tcg/riscv: Fix range matched by TCG_CT_CONST_M12 Date: Mon, 19 Dec 2022 12:16:22 +1000 Message-Id: <20221219021703.20473-5-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416432364100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson We were matching a signed 13-bit range, not a 12-bit range. Expand the commentary within the function and be explicit about all of the ranges. Reported-by: LIU Zhiwei Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-Id: <20221022095821.2441874-1-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- tcg/riscv/tcg-target.c.inc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 81a83e45b1..191197853f 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -154,13 +154,26 @@ static bool tcg_target_const_match(int64_t val, TCGTy= pe type, int ct) if ((ct & TCG_CT_CONST_ZERO) && val =3D=3D 0) { return 1; } - if ((ct & TCG_CT_CONST_S12) && val =3D=3D sextreg(val, 0, 12)) { + /* + * Sign extended from 12 bits: [-0x800, 0x7ff]. + * Used for most arithmetic, as this is the isa field. + */ + if ((ct & TCG_CT_CONST_S12) && val >=3D -0x800 && val <=3D 0x7ff) { return 1; } - if ((ct & TCG_CT_CONST_N12) && -val =3D=3D sextreg(-val, 0, 12)) { + /* + * Sign extended from 12 bits, negated: [-0x7ff, 0x800]. + * Used for subtraction, where a constant must be handled by ADDI. + */ + if ((ct & TCG_CT_CONST_N12) && val >=3D -0x7ff && val <=3D 0x800) { return 1; } - if ((ct & TCG_CT_CONST_M12) && val >=3D -0xfff && val <=3D 0xfff) { + /* + * Sign extended from 12 bits, +/- matching: [-0x7ff, 0x7ff]. + * Used by addsub2, which may need the negative operation, + * and requires the modified constant to be representable. + */ + if ((ct & TCG_CT_CONST_M12) && val >=3D -0x7ff && val <=3D 0x7ff) { return 1; } return 0; --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167141700230964.1111932705478; Sun, 18 Dec 2022 18:30:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75ic-0008CL-DL; Sun, 18 Dec 2022 21:17:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iZ-0008BW-Oz for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:28 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iY-00013c-5v for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:27 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:25 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:29:58 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:25 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3J52TQvz1RwqL for ; Sun, 18 Dec 2022 18:17:25 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Cn0HROBpbPIw for ; Sun, 18 Dec 2022 18:17:24 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3J31PW3z1Rwrq; Sun, 18 Dec 2022 18:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416246; x=1702952246; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SPaspSsWq01oD2q07tmSbRBBdO5kaHAHyKb++qDpmvA=; b=gKgk5P8cujLoFicGG8Yml/TFUr5vYYdKLeZSy+qHYHOEy5+D11Ry0PUY WKOaverep5osuE7Sxf9Tdou6cKw5bM0LIwNoHvKWnPr9UBNkJx1cvx7rj 2af5/bnMgKMnStJFVcakm4us4dw2JrCzmPmjPNGW+5kwPjGm4BjpGqHMk fiNQgVW2fD1RFqNwPYMmHrihvFLki1YTGe8lMFaQeb3/Z+5DM3LQqcnh4 PNdim4gJnFGew9ohlI7uUiP2mHPkBdZhHzs+OpMhgLOTjjr2FpSOvj7ox JN+xuWjAYRCvti+/8GjlKZnVK5Duk6RvxMB+Fnr5mGZ4wm7WfcBdK1IOn Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199285" IronPort-SDR: L+WRbhLXu0bUfvAlxc3tgHZC7RSJZYqx1wb82d7+X3/Xp7g0YzdyQQ2sjuR4iuOOW1fxpQ9OdJ NFw5eBXnTMKQG04SvjaqKw/JiONndsp+uKk5/y2LP0VKPP/A1CdeHanvINsFxgT4PdoyVU/qft jydY8jTGwZ/A3oyE/QojP7J+an/GYltsJHNEhFyMj0L5ShqSnErEJ9L1MELAbPSMp6/8v5NbAW vSW9YCHNK5DaCdZtxV+zn5YCAuzxjfvJ7Ae/KYO6uI1US/vdcP9K5qkx+02mPPONWcZMdtG+le X28= IronPort-SDR: bgaF0dua5T4TqfCWoLbsRGqoPPS4hVBgERE12y6bDxH0T/JNyljor4P7LaJHG2+swvh0vXE7SG xRZKQWGsmL7o5lsN7/LknY2g+06fHVam3zzlF/GhRsycpO9fAHzbBoRHHvYriL/yXh6/mEt1RM wkjZyFnuzmRTZz7EU1lavhxReQGB8S6fvgMZxTw040TxePHcMBDo3p31ZhoP0FF5Lgy6iWNTYS JDUUl6k8a+8+OS0oLVPTybVfxGSWVYN1M7h6eW9CWvVEPjZiD5s+zqyyKpCUdDiwyDMyKvrdKD t6c= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416244; x=1674008245; bh=SPaspSsWq01oD2q07t mSbRBBdO5kaHAHyKb++qDpmvA=; b=hYcQMFqZSZmJi7Q8ElNuLmEQ7WngmTMEiJ 2VR1A2MSV8yCHMykL8l7HuRQSeubtDlzKJknXlyCE/FJ4MRehM1Rrs3fewkL4oGS caPLl2anRUzEqtHbO0lFR4SlW+0lYMbpffcTJSRtFb341t5Z//JP2jBHX03mGcgK bXVGvSLbSMAoyjjFlZU1CvlyFGHmbkqSRQdOZDwlbo3N9ZZGUL1ZE6VF7v7VrL2l Tuf60i7lcy5duHFHaJoUrdVAF4mKZ05SmyPQihfDSapc3iF4nd1Q71c9EFbyDtFC Yb6y/cbadXNIjB8gw2j/201JzkMo7N+Y2nePqZHqdDEkmchmAd0A== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 05/45] tcg/riscv: Fix reg overlap case in tcg_out_addsub2 Date: Mon, 19 Dec 2022 12:16:23 +1000 Message-Id: <20221219021703.20473-6-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671417004205100002 Content-Type: text/plain; charset="utf-8" From: Richard Henderson There was a typo using opc_addi instead of opc_add with the two registers. While we're at it, simplify the gating test to al =3D=3D bl to improve dynamic scheduling even when the output register does not overlap the inputs. Reported-by: LIU Zhiwei Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Message-Id: <20221020233836.2341671-1-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- tcg/riscv/tcg-target.c.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 191197853f..2a84c57bec 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -700,9 +700,15 @@ static void tcg_out_addsub2(TCGContext *s, if (cbl) { tcg_out_opc_imm(s, opc_addi, rl, al, bl); tcg_out_opc_imm(s, OPC_SLTIU, TCG_REG_TMP0, rl, bl); - } else if (rl =3D=3D al && rl =3D=3D bl) { + } else if (al =3D=3D bl) { + /* + * If the input regs overlap, this is a simple doubling + * and carry-out is the input msb. This special case is + * required when the output reg overlaps the input, + * but we might as well use it always. + */ tcg_out_opc_imm(s, OPC_SLTI, TCG_REG_TMP0, al, 0); - tcg_out_opc_reg(s, opc_addi, rl, al, bl); + tcg_out_opc_reg(s, opc_add, rl, al, al); } else { tcg_out_opc_reg(s, opc_add, rl, al, bl); tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_TMP0, --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416629774145.69491257820516; Sun, 18 Dec 2022 18:23:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75if-0008FU-Kl; Sun, 18 Dec 2022 21:17:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75ic-0008CO-LY for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:30 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75ia-00013c-Sf for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:30 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:28 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:00 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:28 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3J80Kntz1RwtC for ; Sun, 18 Dec 2022 18:17:28 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id bHyb_H29wSdE for ; Sun, 18 Dec 2022 18:17:27 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3J54rKyz1RvLy; Sun, 18 Dec 2022 18:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416248; x=1702952248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wLon510VHyvWrBnIFxTDZasif/XairXPaP+olplQ0og=; b=b6vtPHYrJ7xnMXChMfhWQih/SSpYJuwPIzhTxTZSWPi0YMp09mYkrU9q Qj4Y3nVNIh/LFLu2sQAvuQRz0977ELL7EYCRGRrzPotNbUHrCv+QWbSdb hBGOL4AhnkLsv1k9X1W1YmKnYD7gcImMhZXHZqpQCaeXrFHwE43ZEqs1B ksstIQXAlchZssEnnmQzMVYIX/e0V4vqSDkgic9V44CHS2AfNOJzVTD7t kvF6qvnqRQ8mIUp6DYF2wMhWlO2EIfSqBrVgV0WZ4ELnSWTr10eo09gKl FlfjKkARxCyd81DRvBuhaDLWyW5qQ5wj5W+yvMHxcXvY5fO3+gBiCv0Yn w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199291" IronPort-SDR: lqQtCCygyU1TrowuG2aK61OpvKEJ0c14667uQiUj8DcqZpW1z5CkGWlYPv1230IFjw+GP+Mwo8 aEPKSkvhCs1stjTSSOY1RvFyMvFqGfUfkLUlkj4DN8tBfSWiHuPZdKboqtkdSOJeK2NS0FOSl2 EuotbTo315wQXy/Ji64HBTJVBFup7NHoh+4lX56JtRTrjI5OzfdEjgKqmSP1idNqfiA5ZPYyva n1TqFnEJwIMrmbksAB8+gQXsVnwkdFVQFW1gSLXwfAQEeGP38RTj5twGbeZC/NLftfaT+SRLjp sSs= IronPort-SDR: h5Gh2fY42QsD/9jPnlf00PZkHRvV8vfaTdQ6AZdRiPyCW2p/O23GMLlWkgNunIO9uo1A+6Ouwj Iaizbfne+3uOB7WgnwwgFuwFXXrJ+FohMyC2tP3cNK94/VNyt/+5JhyCsrEhuYvxACydwwuRbD LWPv6xpmwqLncNEjCEnLu8gyKIvUkPuTnnqnXiKe4J4FEQ3KKxaGuiWA/mHCSrKWExvsg/Hr6j wtrIUjd0i3jBXL7wosZV9llgfTPX8/H8KB7ZNH/3qjQ8TFIlKgkIHm8A1c0wJHokFmJryOhECQ yZo= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416247; x=1674008248; bh=wLon510VHyvWrBnIFx TDZasif/XairXPaP+olplQ0og=; b=Wbqm/S6Pi0KryiYj2KO7j8Vph0uC/IuaS/ 91wGuXsqjezK/Ua1SyWs0xWbaegwil9x3xnIjWwLLkc3mPWAz+HXMDZa5tHOL5JO Xp9oCxpaklz648/nnky824eMK5cesb5cMdTnHMuLj/TOuQVKmR/5vfwHsPE/nFbr Gc0XRwBVJa3pt6IVg54Bvf9tCv6/eDxi4l6+oBLC0RAQLkHLIjM4JqG80/QI/Mky TCcSCWGITj6g5ScNZ9yeTCWXdOz+HHd9ASJhSwGsvthyxA+7g38tUHa1z7zJnWYQ hAG4XCYjAdB1Rx1A/3rvFoK4um1XNy7n7pXtiYueY43zkrHCptHA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , LIU Zhiwei , Alistair Francis Subject: [PULL 06/45] tcg/riscv: Fix base register for user-only qemu_ld/st Date: Mon, 19 Dec 2022 12:16:24 +1000 Message-Id: <20221219021703.20473-7-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416630403100001 Content-Type: text/plain; charset="utf-8" From: Richard Henderson When guest_base !=3D 0, we were not coordinating the usage of TCG_REG_TMP0 as base properly, leading to a previous zero-extend of the input address being discarded. Shuffle the alignment check to the front, because that does not depend on the zero-extend, and it keeps the register usage clear. Set base after each step of the address arithmetic instead of before. Return the base register used from tcg_out_tlb_load, so as to keep that register choice localized to that function. Reported-by: LIU Zhiwei Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-Id: <20221023233337.2846860-1-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- tcg/riscv/tcg-target.c.inc | 39 +++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index 2a84c57bec..e3b608034f 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -923,9 +923,9 @@ static void tcg_out_goto(TCGContext *s, const tcg_insn_= unit *target) tcg_debug_assert(ok); } =20 -static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, - TCGReg addrh, MemOpIdx oi, - tcg_insn_unit **label_ptr, bool is_load) +static TCGReg tcg_out_tlb_load(TCGContext *s, TCGReg addrl, + TCGReg addrh, MemOpIdx oi, + tcg_insn_unit **label_ptr, bool is_load) { MemOp opc =3D get_memop(oi); unsigned s_bits =3D opc & MO_SIZE; @@ -975,6 +975,7 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addr= l, addrl =3D TCG_REG_TMP0; } tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_REG_TMP2, addrl); + return TCG_REG_TMP0; } =20 static void add_qemu_ldst_label(TCGContext *s, int is_ld, MemOpIdx oi, @@ -1177,7 +1178,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGA= rg *args, bool is_64) #else unsigned a_bits; #endif - TCGReg base =3D TCG_REG_TMP0; + TCGReg base; =20 data_regl =3D *args++; data_regh =3D (TCG_TARGET_REG_BITS =3D=3D 32 && is_64 ? *args++ : 0); @@ -1187,23 +1188,25 @@ static void tcg_out_qemu_ld(TCGContext *s, const TC= GArg *args, bool is_64) opc =3D get_memop(oi); =20 #if defined(CONFIG_SOFTMMU) - tcg_out_tlb_load(s, addr_regl, addr_regh, oi, label_ptr, 1); + base =3D tcg_out_tlb_load(s, addr_regl, addr_regh, oi, label_ptr, 1); tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); add_qemu_ldst_label(s, 1, oi, (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), data_regl, data_regh, addr_regl, addr_regh, s->code_ptr, label_ptr); #else - if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { - tcg_out_ext32u(s, base, addr_regl); - addr_regl =3D base; - } a_bits =3D get_alignment_bits(opc); if (a_bits) { tcg_out_test_alignment(s, true, addr_regl, a_bits); } + base =3D addr_regl; + if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { + tcg_out_ext32u(s, TCG_REG_TMP0, base); + base =3D TCG_REG_TMP0; + } if (guest_base !=3D 0) { - tcg_out_opc_reg(s, OPC_ADD, base, TCG_GUEST_BASE_REG, addr_regl); + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_GUEST_BASE_REG, base= ); + base =3D TCG_REG_TMP0; } tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); #endif @@ -1249,7 +1252,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) #else unsigned a_bits; #endif - TCGReg base =3D TCG_REG_TMP0; + TCGReg base; =20 data_regl =3D *args++; data_regh =3D (TCG_TARGET_REG_BITS =3D=3D 32 && is_64 ? *args++ : 0); @@ -1259,23 +1262,25 @@ static void tcg_out_qemu_st(TCGContext *s, const TC= GArg *args, bool is_64) opc =3D get_memop(oi); =20 #if defined(CONFIG_SOFTMMU) - tcg_out_tlb_load(s, addr_regl, addr_regh, oi, label_ptr, 0); + base =3D tcg_out_tlb_load(s, addr_regl, addr_regh, oi, label_ptr, 0); tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); add_qemu_ldst_label(s, 0, oi, (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), data_regl, data_regh, addr_regl, addr_regh, s->code_ptr, label_ptr); #else - if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { - tcg_out_ext32u(s, base, addr_regl); - addr_regl =3D base; - } a_bits =3D get_alignment_bits(opc); if (a_bits) { tcg_out_test_alignment(s, false, addr_regl, a_bits); } + base =3D addr_regl; + if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { + tcg_out_ext32u(s, TCG_REG_TMP0, base); + base =3D TCG_REG_TMP0; + } if (guest_base !=3D 0) { - tcg_out_opc_reg(s, OPC_ADD, base, TCG_GUEST_BASE_REG, addr_regl); + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_GUEST_BASE_REG, base= ); + base =3D TCG_REG_TMP0; } tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); #endif --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416932930775.4734851226501; Sun, 18 Dec 2022 18:28:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75ig-0008Ff-Sq; Sun, 18 Dec 2022 21:17:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75if-0008FR-H5 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:33 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75id-00013c-Fp for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:33 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:30 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:03 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:31 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JB4q0gz1RwqL for ; Sun, 18 Dec 2022 18:17:30 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QeRqs0fSb8e3 for ; Sun, 18 Dec 2022 18:17:29 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3J75tHrz1RvTp; Sun, 18 Dec 2022 18:17:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416251; x=1702952251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nZrlKiAsAn7MNytGWr5N4/b3L8vVhvkGQkq8G2qzSWk=; b=SvTnNKBdpMHs/tJjFcjDvhSVdS0n2etS5H7bskrv0VeFZnVhlZkSSJA/ HuLIgQ3PnVSirSPrMHFC47K0Af8CpWcLUrwy0YDYwadMAhpO4czfYs32+ QapO1R2cdXqc2s+BU5Dl3UTsmgt0AC0MqTWFxPUsCbq6KyLOhViDJLym1 4WwIcpHgtxcdJe5hIy1kVAZmSqIMGTAB50nblP/dUm4hyHBOKGK/KFgjs YwDy/Bvt6N2rh0bqSguNDnLw+JDekJmJNYrzpdBk9Imh6kREEeRCaJ1+0 GtZ3GAiD66OABYsEqgna237uZ1HOK1qTf2jPUxef1SyxNioXCjL6ENt3p A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199298" IronPort-SDR: 23JvvBr7c2icftG9HHXSd6NStkpEYbTBTpGZ9PWf5zJf0wOyGGiHOqeCFXBz/gtNDFHiVF22KZ WCksdcKbdy/VZIkEL4/Mr49wRO2FgQfIaT/p88gLzOOlHtIwjxXbK+3FZBhJX/1uk8trPtm6Ya FDqRqU2XeU1uC2JMobYsBMIdAVMBhQFIekw98hMZsGvWcSnK/KfxDF0nxIR1e2K9iNnyxRwBYv mTi9iGS+lKP2YhYagYxPq78nWvBe6S19ZL/NJvi4Z8ipNSAbRybumVYWgZwcVnCldrsaGfD56R C9o= IronPort-SDR: ltBMjwqC41ZJ+FMo46v40dbQdkhbtDVvE5GGJSt/HswcChIBYnmKgy/ZeBWbmnyLaYvz8BSLL1 m53hRuTYI1vP4FyMA1A2IcegG47jI8C8Nko1gYkbjnVq7e1dmvRvNsF6GhJWN09t/denePimyb t7kVDTq7Y7GmlNjqbxKzaiUEoUG2YgiZKPzoWTJn7+YvrQ5S1pTrlfbDMX3Xgv6gXPebl28wnW zgGk8xicCyeqjHzM4tv5bhS5BBnK+YeT8WTGLgU3Oa4GTDvjsuQuTgPSUZVsjh5tf5E3Gg5Fwt 0Zs= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416249; x=1674008250; bh=nZrlKiAsAn7MNytGWr 5N4/b3L8vVhvkGQkq8G2qzSWk=; b=DWP5VD1ZCrl4UueR0aIG47gB6+kRB+Iz6u QG9RGxGOWHGMf3o+kwmhd9J5Z8A2mrpw/P6jcA7/TStMgONPgRsj7Dr/GZBPKAxx IctNvG2/Kt2ZE9s4k2qOq4Z0nOdEhhjpIFW95SgCbBaqXJyaLzwlzYPFl5uFRXmz x996CsGyLAg5hg3vafSzKgiLnMZrPyANLYQbfT9NgWptS9Lw0JaiV94Ktg+9sPnr 2/ado7ljvKyi80RpI/5Qsbry8of3E106rSsbKhhe709W3xMe68DcNQ3qvQLrJPqZ P+CqW2YHJwJ7C00g3RHAH8/9aZPY45UOCHkDgwaQRLvQ/o5ifAPw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Wilfred Mallawa , Alistair Francis , Bin Meng Subject: [PULL 07/45] hw/riscv/opentitan: bump opentitan Date: Mon, 19 Dec 2022 12:16:25 +1000 Message-Id: <20221219021703.20473-8-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416934322100003 Content-Type: text/plain; charset="utf-8" From: Wilfred Mallawa This patch updates the OpenTitan model to match the specified register layout as per [1]. Which is also the latest commit of OpenTitan supported by TockOS. Note: Pinmux and Padctrl has been merged into Pinmux [2][3], this patch rem= oves any references to Padctrl. Note: OpenTitan doc [2] has not yet specified much detail regarding this, except for a note that states `TODO: this section needs to be updated to reflect the pinmux/padctrl merger` [1] https://github.com/lowRISC/opentitan/blob/d072ac505f82152678d6e04be95c7= 2b728a347b8/hw/top_earlgrey/sw/autogen/top_earlgrey_memory.h [2] https://docs.opentitan.org/hw/top_earlgrey/doc/design/ [3] https://docs.opentitan.org/hw/ip/pinmux/doc/#overview Signed-off-by: Wilfred Mallawa Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Message-Id: <20221025043335.339815-2-wilfred.mallawa@opensource.wdc.com> Signed-off-by: Alistair Francis --- include/hw/riscv/opentitan.h | 9 ++++----- hw/riscv/opentitan.c | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h index 6665cd5794..1fc055cdff 100644 --- a/include/hw/riscv/opentitan.h +++ b/include/hw/riscv/opentitan.h @@ -81,7 +81,6 @@ enum { IBEX_DEV_RSTMGR, IBEX_DEV_CLKMGR, IBEX_DEV_PINMUX, - IBEX_DEV_PADCTRL, IBEX_DEV_USBDEV, IBEX_DEV_FLASH_CTRL, IBEX_DEV_PLIC, @@ -109,10 +108,10 @@ enum { IBEX_UART0_RX_TIMEOUT_IRQ =3D 7, IBEX_UART0_RX_PARITY_ERR_IRQ =3D 8, IBEX_TIMER_TIMEREXPIRED0_0 =3D 127, - IBEX_SPI_HOST0_ERR_IRQ =3D 151, - IBEX_SPI_HOST0_SPI_EVENT_IRQ =3D 152, - IBEX_SPI_HOST1_ERR_IRQ =3D 153, - IBEX_SPI_HOST1_SPI_EVENT_IRQ =3D 154, + IBEX_SPI_HOST0_ERR_IRQ =3D 134, + IBEX_SPI_HOST0_SPI_EVENT_IRQ =3D 135, + IBEX_SPI_HOST1_ERR_IRQ =3D 136, + IBEX_SPI_HOST1_SPI_EVENT_IRQ =3D 137, }; =20 #endif diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index be7ff1eea0..92493c629d 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -28,8 +28,16 @@ #include "qemu/units.h" #include "sysemu/sysemu.h" =20 +/* + * This version of the OpenTitan machine currently supports + * OpenTitan RTL version: + * + * + * MMIO mapping as per (specified commit): + * lowRISC/opentitan: hw/top_earlgrey/sw/autogen/top_earlgrey_memory.h + */ static const MemMapEntry ibex_memmap[] =3D { - [IBEX_DEV_ROM] =3D { 0x00008000, 0x8000 }, + [IBEX_DEV_ROM] =3D { 0x00008000, 0x8000 }, [IBEX_DEV_RAM] =3D { 0x10000000, 0x20000 }, [IBEX_DEV_FLASH] =3D { 0x20000000, 0x100000 }, [IBEX_DEV_UART] =3D { 0x40000000, 0x1000 }, @@ -38,17 +46,17 @@ static const MemMapEntry ibex_memmap[] =3D { [IBEX_DEV_I2C] =3D { 0x40080000, 0x1000 }, [IBEX_DEV_PATTGEN] =3D { 0x400e0000, 0x1000 }, [IBEX_DEV_TIMER] =3D { 0x40100000, 0x1000 }, - [IBEX_DEV_SENSOR_CTRL] =3D { 0x40110000, 0x1000 }, [IBEX_DEV_OTP_CTRL] =3D { 0x40130000, 0x4000 }, [IBEX_DEV_LC_CTRL] =3D { 0x40140000, 0x1000 }, - [IBEX_DEV_USBDEV] =3D { 0x40150000, 0x1000 }, + [IBEX_DEV_ALERT_HANDLER] =3D { 0x40150000, 0x1000 }, [IBEX_DEV_SPI_HOST0] =3D { 0x40300000, 0x1000 }, [IBEX_DEV_SPI_HOST1] =3D { 0x40310000, 0x1000 }, + [IBEX_DEV_USBDEV] =3D { 0x40320000, 0x1000 }, [IBEX_DEV_PWRMGR] =3D { 0x40400000, 0x1000 }, [IBEX_DEV_RSTMGR] =3D { 0x40410000, 0x1000 }, [IBEX_DEV_CLKMGR] =3D { 0x40420000, 0x1000 }, [IBEX_DEV_PINMUX] =3D { 0x40460000, 0x1000 }, - [IBEX_DEV_PADCTRL] =3D { 0x40470000, 0x1000 }, + [IBEX_DEV_SENSOR_CTRL] =3D { 0x40490000, 0x1000 }, [IBEX_DEV_FLASH_CTRL] =3D { 0x41000000, 0x1000 }, [IBEX_DEV_AES] =3D { 0x41100000, 0x1000 }, [IBEX_DEV_HMAC] =3D { 0x41110000, 0x1000 }, @@ -59,10 +67,9 @@ static const MemMapEntry ibex_memmap[] =3D { [IBEX_DEV_ENTROPY] =3D { 0x41160000, 0x1000 }, [IBEX_DEV_EDNO] =3D { 0x41170000, 0x1000 }, [IBEX_DEV_EDN1] =3D { 0x41180000, 0x1000 }, - [IBEX_DEV_ALERT_HANDLER] =3D { 0x411b0000, 0x1000 }, [IBEX_DEV_NMI_GEN] =3D { 0x411c0000, 0x1000 }, [IBEX_DEV_PERI] =3D { 0x411f0000, 0x10000 }, - [IBEX_DEV_PLIC] =3D { 0x48000000, 0x4005000 }, + [IBEX_DEV_PLIC] =3D { 0x48000000, 0x4005000 }, [IBEX_DEV_FLASH_VIRTUAL] =3D { 0x80000000, 0x80000 }, }; =20 @@ -265,8 +272,6 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_s= oc, Error **errp) memmap[IBEX_DEV_CLKMGR].base, memmap[IBEX_DEV_CLKMGR].size); create_unimplemented_device("riscv.lowrisc.ibex.pinmux", memmap[IBEX_DEV_PINMUX].base, memmap[IBEX_DEV_PINMUX].size); - create_unimplemented_device("riscv.lowrisc.ibex.padctrl", - memmap[IBEX_DEV_PADCTRL].base, memmap[IBEX_DEV_PADCTRL].size); create_unimplemented_device("riscv.lowrisc.ibex.usbdev", memmap[IBEX_DEV_USBDEV].base, memmap[IBEX_DEV_USBDEV].size); create_unimplemented_device("riscv.lowrisc.ibex.flash_ctrl", --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416995652883.5650915220334; Sun, 18 Dec 2022 18:29:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75ij-0008GY-5p; Sun, 18 Dec 2022 21:17:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75ih-0008Fx-CR for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:35 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75if-00013c-R1 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:35 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:32 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:05 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:33 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JD4X7Wz1RvTr for ; Sun, 18 Dec 2022 18:17:32 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UjSSxseeIZPc for ; Sun, 18 Dec 2022 18:17:32 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JB2jd6z1RvLy; Sun, 18 Dec 2022 18:17:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416253; x=1702952253; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SfKxA8G3IanL11OZNQXCiMwcclKpFSTH9ixHNUN8azY=; b=pQzCRDlXaDyo0XKgTRroqvsI7KjHIGD7rcwfewDNDMIrovyFhjCIKzMG vgzwFtXu8x/aZYeIogpVMX6Zmd1FrsNqPj+4NQWeuXU4X7OlxHABK9Wwc aza/ZLItXfKNzaoDiVbVO9DfPN3hKIc/iblmQSaoNnWELrFcddz6sLeJc RAF3vU6zeXWFSM2c8tn0+cQqDRj0s+VdKd3A5AU5X3e1hhzqF+xHYCPd+ x2gdYHeUNr1lq2B3RmKHLhJOAf4VpHXYlsmOkhG+qn2V5dbAuzDt8y8r5 uBpFI4/qI8IgVGe6vD1UWKHT7uy12gIQo4h9HyrlwUIT/L1/c+3YDzOUB Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199303" IronPort-SDR: RSdFX/Mxx8PG1iL8ctm5jbQlHJBcnt6m+TWlEwH09sjawJvSDD8aUYc4HoLjaT14F3MHDDo9V8 MkkHmqAPy1owIlx2KO2i+5aKXunwEkKlhwkwHdY+i9M+BYun3oECF4TmNMCMRGf5iP1lmoeBqQ G5fTfOaKr4Rxbc/zzjoyYc6ewVMnpbBav40wteYJBdGYTV9z2KsBTX6WJjkZ45o2UgoDtj07IM mNSS9MN+qUpjWTJZPBeg5rYRPlViXV2qiagtSCFKe+5qzYDSBQjqGflpK/5S4XM+KKDjn7M1Eh FI0= IronPort-SDR: YwMe8NaskFE1G6nIF5vIjcXsuBhEH5M7sIS4Jiqx3oaBsgP6gyIj3jISQ/+cMVkxeipqqSYvNF Pe27e44kQlhM4TFtA7Jeo6bPd5Fiz2SP4WXaJPZm11nkShfYBPLcsDC3gyh2U/40nVKFGis2AB enV+IW2iRLtTXgXvt/XVk4TYlu9DOsGh7puELHtF3lwoor5GIowB7QBOZsyDwQf+ZBtm5uAgIs J30bLMdgqhrp+OI+IOCFnns5fBCC8xb6MVkCMuzS975pnQWgeK+bccu1K0jgkz1Y7db3IYIDa+ +Zw= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416252; x=1674008253; bh=SfKxA8G3IanL11OZNQ XCiMwcclKpFSTH9ixHNUN8azY=; b=bcY6G62ZTlPda+kd9sFIUVzIy1zvOVNMSc IxVW8EV9axf2XlTWj3uftMOfxBmMQfEMLxuKbaSGYZapttYh42fhATIoS/kW5HaY JC/TfUMvEJIwJEr43PSHERnkJVgkpODnYzFw9Nkc9pRicZr/EJuFetlujci6ySNR 0yRrfiAAmdyPjFOQuSTztZdqMHaqKfO0I/8bgvCYafIuo9idn3/tsjaBL2aFnCXQ 3+hE6FtcSfD1Hj3M4ymOeq3ki7HoyFCYJDLR92/e6MdrGkrWRWgFClbKUGkfTHbH 8QA6DIDUkxiaXBEmsprYgFaI1Fq8kwExOUUaTzEgCFyGZsXiAJhw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Wilfred Mallawa , Bin Meng , Alistair Francis Subject: [PULL 08/45] hw/riscv/opentitan: add aon_timer base unimpl Date: Mon, 19 Dec 2022 12:16:26 +1000 Message-Id: <20221219021703.20473-9-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416996172100003 Content-Type: text/plain; charset="utf-8" From: Wilfred Mallawa Adds the updated `aon_timer` base as an unimplemented device. This is used by TockOS, patch ensures the guest doesn't hit load faults. Signed-off-by: Wilfred Mallawa Reviewed-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <20221025043335.339815-3-wilfred.mallawa@opensource.wdc.com> Signed-off-by: Alistair Francis --- include/hw/riscv/opentitan.h | 1 + hw/riscv/opentitan.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/hw/riscv/opentitan.h b/include/hw/riscv/opentitan.h index 1fc055cdff..7659d1bc5b 100644 --- a/include/hw/riscv/opentitan.h +++ b/include/hw/riscv/opentitan.h @@ -81,6 +81,7 @@ enum { IBEX_DEV_RSTMGR, IBEX_DEV_CLKMGR, IBEX_DEV_PINMUX, + IBEX_DEV_AON_TIMER, IBEX_DEV_USBDEV, IBEX_DEV_FLASH_CTRL, IBEX_DEV_PLIC, diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 92493c629d..78f895d773 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -56,6 +56,7 @@ static const MemMapEntry ibex_memmap[] =3D { [IBEX_DEV_RSTMGR] =3D { 0x40410000, 0x1000 }, [IBEX_DEV_CLKMGR] =3D { 0x40420000, 0x1000 }, [IBEX_DEV_PINMUX] =3D { 0x40460000, 0x1000 }, + [IBEX_DEV_AON_TIMER] =3D { 0x40470000, 0x1000 }, [IBEX_DEV_SENSOR_CTRL] =3D { 0x40490000, 0x1000 }, [IBEX_DEV_FLASH_CTRL] =3D { 0x41000000, 0x1000 }, [IBEX_DEV_AES] =3D { 0x41100000, 0x1000 }, @@ -272,6 +273,8 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_s= oc, Error **errp) memmap[IBEX_DEV_CLKMGR].base, memmap[IBEX_DEV_CLKMGR].size); create_unimplemented_device("riscv.lowrisc.ibex.pinmux", memmap[IBEX_DEV_PINMUX].base, memmap[IBEX_DEV_PINMUX].size); + create_unimplemented_device("riscv.lowrisc.ibex.aon_timer", + memmap[IBEX_DEV_AON_TIMER].base, memmap[IBEX_DEV_AON_TIMER].size); create_unimplemented_device("riscv.lowrisc.ibex.usbdev", memmap[IBEX_DEV_USBDEV].base, memmap[IBEX_DEV_USBDEV].size); create_unimplemented_device("riscv.lowrisc.ibex.flash_ctrl", --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416302238766.2305956359594; Sun, 18 Dec 2022 18:18:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75im-0008Gi-Po; Sun, 18 Dec 2022 21:17:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75il-0008Ga-Uv for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:39 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75ij-00015O-FR for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:39 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:36 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:09 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:36 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JJ18Tlz1RwtC for ; Sun, 18 Dec 2022 18:17:36 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QeTjoZ82nwsY for ; Sun, 18 Dec 2022 18:17:34 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JD5npdz1RvLy; Sun, 18 Dec 2022 18:17:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416257; x=1702952257; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v/tolp0FI5QSu95NYDTltjd9EctNgrO7SoOyyHZ4l80=; b=ZB/O3wVPbKJcqNSgGepyGJReibx9je68unFyJvSecJHX421RvcBBCpU/ nh8JWkXXY2ozZ3TLPy2vWJVTMfy/Bt00oy02ZFmGjvMcVY6VLqCumdxUD B+Fv1A0Ifk1ohBO2JdFiYT0RuzCGGXumMKFreqJJRJAud+ODzyahdd0qK jBSmjJVI8xczHwuvrksu2qH6RQNSJQUWqRkB7X3t4RPbEdgoHOrsVWVMK ADIApXZqZNB6cCNsJYP8tegamHTeqatFSFgwCAo4FfFWpPwUdL0wP10hC UkivHsYwvdIRUv1i8JAP2PXobo/iCq4i1cqTXnS/A4PWvq9/oc3/0FF3s A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199307" IronPort-SDR: jbGMuTOp1ZI9xfM3EKwe7RT73FMHiJdaAX8ZQo1AqEKNCH5GHFN4bVGB50ZHxIiSIB+tZda/S+ PrfhX5J/Jpl2zyH4OqS0rKshqCcOkUEGgarZ51vSwhi69+MmtRFIfNnVltHaWrqmF07QVs3kr6 HGnWexzQpS6Td4fgKRJQTEgPG//BkJcPihDiKexKOg/wUqwL6unVx/jLqUWzcH6qCzjqdGIzQG ei70LVcHRfGXRDU5a7TUtVueAkxhkj1XOY7O/u6nC2DvXAVmwYUSwqwj97c8tNkbZWM8JbZUq/ 5tY= IronPort-SDR: mH8Yd+3IuWre1mOZyS30AKbcK6SPB6yd02dPOH/xwC8RNbCRGhjzArWPThS8TY59V8RwZu2bFD Y6GspAFeF8MFZlIaUIPrDQA8kL6jC3BghRg53MsTLaQ0PRAxuW+IyOgB4bz8FwhYFQW5ZXD15S CuRPdWH640v0oWis6cu9M/UPtl3X35zQ6evIkpG28HLtoeBORnS9biX+mW6HgszeLAoi/JhK4q AtSY4fraMDFQj6sDlEk96wR8BNM4HDwsPxx2gCewWS5w4SHTF6zVZ4a658NmN/YWqq4Nl/2HpV a2g= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416254; x=1674008255; bh=v/tolp0FI5QSu95NYD Tltjd9EctNgrO7SoOyyHZ4l80=; b=D8TvEWD4XrLy9PIIBdZrUUFyFtm9XLBtQw 6kKPezNUN+sZ0OsiRGgM9sOpvi98JNowFSFi4LwxF39So8YV0f1/G+W7d3e26+Qp 6fjGjHayCbqvWG1Sp7wuT8O6CnEbXrsgf75f6T7DjlzqLrO882R+MEyttld8uRCm rs8nRckN8BZTglXiovdKEUlnk1AI+0mu9Ur/AwIkqNjJbj21ubu2wFKt5xidTqPB lbiUOuEkA7Xu3d1uRQ2iXxNyftMjgOR+UcsV7ayw4c+hTQ+kSnmGoOnq4jZ4LCtm tYKtWEkLhkQVcFxUw4ggWkEuvHQHbb34JSbK6qHVTdVLOQnW4COA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Mayuresh Chitale , Weiwei Li , Alistair Francis Subject: [PULL 09/45] target/riscv: Add smstateen support Date: Mon, 19 Dec 2022 12:16:27 +1000 Message-Id: <20221219021703.20473-10-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416304382100003 Content-Type: text/plain; charset="utf-8" From: Mayuresh Chitale Smstateen extension specifies a mechanism to close the potential covert channels that could cause security issues. This patch adds the CSRs defined in the specification and the corresponding predicates and read/write functions. Signed-off-by: Mayuresh Chitale Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Message-Id: <20221016124726.102129-2-mchitale@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 4 + target/riscv/cpu_bits.h | 37 +++++ target/riscv/csr.c | 316 ++++++++++++++++++++++++++++++++++++++++ target/riscv/machine.c | 21 +++ 4 files changed, 378 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 443d15a47c..5cac0c5eec 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -366,6 +366,9 @@ struct CPUArchState { =20 /* CSRs for execution enviornment configuration */ uint64_t menvcfg; + uint64_t mstateen[SMSTATEEN_MAX_COUNT]; + uint64_t hstateen[SMSTATEEN_MAX_COUNT]; + uint64_t sstateen[SMSTATEEN_MAX_COUNT]; target_ulong senvcfg; uint64_t henvcfg; #endif @@ -441,6 +444,7 @@ struct RISCVCPUConfig { bool ext_ifencei; bool ext_icsr; bool ext_zihintpause; + bool ext_smstateen; bool ext_sstc; bool ext_svinval; bool ext_svnapot; diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index d8f5f0abed..8b0d7e20ea 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -197,6 +197,12 @@ /* Supervisor Configuration CSRs */ #define CSR_SENVCFG 0x10A =20 +/* Supervisor state CSRs */ +#define CSR_SSTATEEN0 0x10C +#define CSR_SSTATEEN1 0x10D +#define CSR_SSTATEEN2 0x10E +#define CSR_SSTATEEN3 0x10F + /* Supervisor Trap Handling */ #define CSR_SSCRATCH 0x140 #define CSR_SEPC 0x141 @@ -244,6 +250,16 @@ #define CSR_HENVCFG 0x60A #define CSR_HENVCFGH 0x61A =20 +/* Hypervisor state CSRs */ +#define CSR_HSTATEEN0 0x60C +#define CSR_HSTATEEN0H 0x61C +#define CSR_HSTATEEN1 0x60D +#define CSR_HSTATEEN1H 0x61D +#define CSR_HSTATEEN2 0x60E +#define CSR_HSTATEEN2H 0x61E +#define CSR_HSTATEEN3 0x60F +#define CSR_HSTATEEN3H 0x61F + /* Virtual CSRs */ #define CSR_VSSTATUS 0x200 #define CSR_VSIE 0x204 @@ -289,6 +305,27 @@ #define CSR_MENVCFG 0x30A #define CSR_MENVCFGH 0x31A =20 +/* Machine state CSRs */ +#define CSR_MSTATEEN0 0x30C +#define CSR_MSTATEEN0H 0x31C +#define CSR_MSTATEEN1 0x30D +#define CSR_MSTATEEN1H 0x31D +#define CSR_MSTATEEN2 0x30E +#define CSR_MSTATEEN2H 0x31E +#define CSR_MSTATEEN3 0x30F +#define CSR_MSTATEEN3H 0x31F + +/* Common defines for all smstateen */ +#define SMSTATEEN_MAX_COUNT 4 +#define SMSTATEEN0_CS (1ULL << 0) +#define SMSTATEEN0_FCSR (1ULL << 1) +#define SMSTATEEN0_HSCONTXT (1ULL << 57) +#define SMSTATEEN0_IMSIC (1ULL << 58) +#define SMSTATEEN0_AIA (1ULL << 59) +#define SMSTATEEN0_SVSLCT (1ULL << 60) +#define SMSTATEEN0_HSENVCFG (1ULL << 62) +#define SMSTATEEN_STATEEN (1ULL << 63) + /* Enhanced Physical Memory Protection (ePMP) */ #define CSR_MSECCFG 0x747 #define CSR_MSECCFGH 0x757 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 5c9a7ee287..c861424e85 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -283,6 +283,72 @@ static RISCVException umode32(CPURISCVState *env, int = csrno) return umode(env, csrno); } =20 +static RISCVException mstateen(CPURISCVState *env, int csrno) +{ + CPUState *cs =3D env_cpu(env); + RISCVCPU *cpu =3D RISCV_CPU(cs); + + if (!cpu->cfg.ext_smstateen) { + return RISCV_EXCP_ILLEGAL_INST; + } + + return any(env, csrno); +} + +static RISCVException hstateen_pred(CPURISCVState *env, int csrno, int bas= e) +{ + CPUState *cs =3D env_cpu(env); + RISCVCPU *cpu =3D RISCV_CPU(cs); + + if (!cpu->cfg.ext_smstateen) { + return RISCV_EXCP_ILLEGAL_INST; + } + + if (env->priv < PRV_M) { + if (!(env->mstateen[csrno - base] & SMSTATEEN_STATEEN)) { + return RISCV_EXCP_ILLEGAL_INST; + } + } + + return hmode(env, csrno); +} + +static RISCVException hstateen(CPURISCVState *env, int csrno) +{ + return hstateen_pred(env, csrno, CSR_HSTATEEN0); +} + +static RISCVException hstateenh(CPURISCVState *env, int csrno) +{ + return hstateen_pred(env, csrno, CSR_HSTATEEN0H); +} + +static RISCVException sstateen(CPURISCVState *env, int csrno) +{ + bool virt =3D riscv_cpu_virt_enabled(env); + int index =3D csrno - CSR_SSTATEEN0; + CPUState *cs =3D env_cpu(env); + RISCVCPU *cpu =3D RISCV_CPU(cs); + + if (!cpu->cfg.ext_smstateen) { + return RISCV_EXCP_ILLEGAL_INST; + } + + if (env->priv < PRV_M) { + if (!(env->mstateen[index] & SMSTATEEN_STATEEN)) { + return RISCV_EXCP_ILLEGAL_INST; + } + + if (virt) { + if (!(env->hstateen[index] & SMSTATEEN_STATEEN)) { + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + } + } + } + + return smode(env, csrno); +} + /* Checks if PointerMasking registers could be accessed */ static RISCVException pointer_masking(CPURISCVState *env, int csrno) { @@ -1861,6 +1927,197 @@ static RISCVException write_henvcfgh(CPURISCVState = *env, int csrno, return RISCV_EXCP_NONE; } =20 +static RISCVException read_mstateen(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->mstateen[csrno - CSR_MSTATEEN0]; + + return RISCV_EXCP_NONE; +} + +static RISCVException write_mstateen(CPURISCVState *env, int csrno, + uint64_t wr_mask, target_ulong new_va= l) +{ + uint64_t *reg; + + reg =3D &env->mstateen[csrno - CSR_MSTATEEN0]; + *reg =3D (*reg & ~wr_mask) | (new_val & wr_mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException write_mstateen0(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + uint64_t wr_mask =3D SMSTATEEN_STATEEN; + + return write_mstateen(env, csrno, wr_mask, new_val); +} + +static RISCVException write_mstateen_1_3(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + return write_mstateen(env, csrno, SMSTATEEN_STATEEN, new_val); +} + +static RISCVException read_mstateenh(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val =3D env->mstateen[csrno - CSR_MSTATEEN0H] >> 32; + + return RISCV_EXCP_NONE; +} + +static RISCVException write_mstateenh(CPURISCVState *env, int csrno, + uint64_t wr_mask, target_ulong new_v= al) +{ + uint64_t *reg, val; + + reg =3D &env->mstateen[csrno - CSR_MSTATEEN0H]; + val =3D (uint64_t)new_val << 32; + val |=3D *reg & 0xFFFFFFFF; + *reg =3D (*reg & ~wr_mask) | (val & wr_mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException write_mstateen0h(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + uint64_t wr_mask =3D SMSTATEEN_STATEEN; + + return write_mstateenh(env, csrno, wr_mask, new_val); +} + +static RISCVException write_mstateenh_1_3(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + return write_mstateenh(env, csrno, SMSTATEEN_STATEEN, new_val); +} + +static RISCVException read_hstateen(CPURISCVState *env, int csrno, + target_ulong *val) +{ + int index =3D csrno - CSR_HSTATEEN0; + + *val =3D env->hstateen[index] & env->mstateen[index]; + + return RISCV_EXCP_NONE; +} + +static RISCVException write_hstateen(CPURISCVState *env, int csrno, + uint64_t mask, target_ulong new_val) +{ + int index =3D csrno - CSR_HSTATEEN0; + uint64_t *reg, wr_mask; + + reg =3D &env->hstateen[index]; + wr_mask =3D env->mstateen[index] & mask; + *reg =3D (*reg & ~wr_mask) | (new_val & wr_mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException write_hstateen0(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + uint64_t wr_mask =3D SMSTATEEN_STATEEN; + + return write_hstateen(env, csrno, wr_mask, new_val); +} + +static RISCVException write_hstateen_1_3(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + return write_hstateen(env, csrno, SMSTATEEN_STATEEN, new_val); +} + +static RISCVException read_hstateenh(CPURISCVState *env, int csrno, + target_ulong *val) +{ + int index =3D csrno - CSR_HSTATEEN0H; + + *val =3D (env->hstateen[index] >> 32) & (env->mstateen[index] >> 32); + + return RISCV_EXCP_NONE; +} + +static RISCVException write_hstateenh(CPURISCVState *env, int csrno, + uint64_t mask, target_ulong new_val) +{ + int index =3D csrno - CSR_HSTATEEN0H; + uint64_t *reg, wr_mask, val; + + reg =3D &env->hstateen[index]; + val =3D (uint64_t)new_val << 32; + val |=3D *reg & 0xFFFFFFFF; + wr_mask =3D env->mstateen[index] & mask; + *reg =3D (*reg & ~wr_mask) | (val & wr_mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException write_hstateen0h(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + uint64_t wr_mask =3D SMSTATEEN_STATEEN; + + return write_hstateenh(env, csrno, wr_mask, new_val); +} + +static RISCVException write_hstateenh_1_3(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + return write_hstateenh(env, csrno, SMSTATEEN_STATEEN, new_val); +} + +static RISCVException read_sstateen(CPURISCVState *env, int csrno, + target_ulong *val) +{ + bool virt =3D riscv_cpu_virt_enabled(env); + int index =3D csrno - CSR_SSTATEEN0; + + *val =3D env->sstateen[index] & env->mstateen[index]; + if (virt) { + *val &=3D env->hstateen[index]; + } + + return RISCV_EXCP_NONE; +} + +static RISCVException write_sstateen(CPURISCVState *env, int csrno, + uint64_t mask, target_ulong new_val) +{ + bool virt =3D riscv_cpu_virt_enabled(env); + int index =3D csrno - CSR_SSTATEEN0; + uint64_t wr_mask; + uint64_t *reg; + + wr_mask =3D env->mstateen[index] & mask; + if (virt) { + wr_mask &=3D env->hstateen[index]; + } + + reg =3D &env->sstateen[index]; + *reg =3D (*reg & ~wr_mask) | (new_val & wr_mask); + + return RISCV_EXCP_NONE; +} + +static RISCVException write_sstateen0(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + uint64_t wr_mask =3D SMSTATEEN_STATEEN; + + return write_sstateen(env, csrno, wr_mask, new_val); +} + +static RISCVException write_sstateen_1_3(CPURISCVState *env, int csrno, + target_ulong new_val) +{ + return write_sstateen(env, csrno, SMSTATEEN_STATEEN, new_val); +} + static RISCVException rmw_mip64(CPURISCVState *env, int csrno, uint64_t *ret_val, uint64_t new_val, uint64_t wr_mask) @@ -3744,6 +4001,65 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_HENVCFGH] =3D { "henvcfgh", hmode32, read_henvcfgh, write_henvcfg= h, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, =20 + /* Smstateen extension CSRs */ + [CSR_MSTATEEN0] =3D { "mstateen0", mstateen, read_mstateen, write_msta= teen0, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_MSTATEEN0H] =3D { "mstateen0h", mstateen, read_mstateenh, + write_mstateen0h, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_MSTATEEN1] =3D { "mstateen1", mstateen, read_mstateen, + write_mstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_MSTATEEN1H] =3D { "mstateen1h", mstateen, read_mstateenh, + write_mstateenh_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_MSTATEEN2] =3D { "mstateen2", mstateen, read_mstateen, + write_mstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_MSTATEEN2H] =3D { "mstateen2h", mstateen, read_mstateenh, + write_mstateenh_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_MSTATEEN3] =3D { "mstateen3", mstateen, read_mstateen, + write_mstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_MSTATEEN3H] =3D { "mstateen3h", mstateen, read_mstateenh, + write_mstateenh_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_HSTATEEN0] =3D { "hstateen0", hstateen, read_hstateen, write_hsta= teen0, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_HSTATEEN0H] =3D { "hstateen0h", hstateenh, read_hstateenh, + write_hstateen0h, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_HSTATEEN1] =3D { "hstateen1", hstateen, read_hstateen, + write_hstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_HSTATEEN1H] =3D { "hstateen1h", hstateenh, read_hstateenh, + write_hstateenh_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_HSTATEEN2] =3D { "hstateen2", hstateen, read_hstateen, + write_hstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_HSTATEEN2H] =3D { "hstateen2h", hstateenh, read_hstateenh, + write_hstateenh_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_HSTATEEN3] =3D { "hstateen3", hstateen, read_hstateen, + write_hstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_HSTATEEN3H] =3D { "hstateen3h", hstateenh, read_hstateenh, + write_hstateenh_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_SSTATEEN0] =3D { "sstateen0", sstateen, read_sstateen, write_ssta= teen0, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_SSTATEEN1] =3D { "sstateen1", sstateen, read_sstateen, + write_sstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_SSTATEEN2] =3D { "sstateen2", sstateen, read_sstateen, + write_sstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + [CSR_SSTATEEN3] =3D { "sstateen3", sstateen, read_sstateen, + write_sstateen_1_3, + .min_priv_ver =3D PRIV_VERSION_1_12_0 }, + /* Supervisor Trap Setup */ [CSR_SSTATUS] =3D { "sstatus", smode, read_sstatus, write_sst= atus, NULL, read_sstatus_i128 = }, diff --git a/target/riscv/machine.c b/target/riscv/machine.c index c2a94a82b3..e687f9fce0 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -253,6 +253,26 @@ static int riscv_cpu_post_load(void *opaque, int versi= on_id) return 0; } =20 +static bool smstateen_needed(void *opaque) +{ + RISCVCPU *cpu =3D opaque; + + return cpu->cfg.ext_smstateen; +} + +static const VMStateDescription vmstate_smstateen =3D { + .name =3D "cpu/smtateen", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D smstateen_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64_ARRAY(env.mstateen, RISCVCPU, 4), + VMSTATE_UINT64_ARRAY(env.hstateen, RISCVCPU, 4), + VMSTATE_UINT64_ARRAY(env.sstateen, RISCVCPU, 4), + VMSTATE_END_OF_LIST() + } +}; + static bool envcfg_needed(void *opaque) { RISCVCPU *cpu =3D opaque; @@ -364,6 +384,7 @@ const VMStateDescription vmstate_riscv_cpu =3D { &vmstate_kvmtimer, &vmstate_envcfg, &vmstate_debug, + &vmstate_smstateen, NULL } }; --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16714165958931021.6016437183415; Sun, 18 Dec 2022 18:23:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75is-0008HH-U2; Sun, 18 Dec 2022 21:17:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75in-0008H4-ML for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:41 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75il-00015X-QP for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:41 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:38 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:11 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:38 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JL36dKz1Rwrq for ; Sun, 18 Dec 2022 18:17:38 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id klR_TjocLbw7 for ; Sun, 18 Dec 2022 18:17:37 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JH4kgFz1RvTp; Sun, 18 Dec 2022 18:17:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416259; x=1702952259; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xbWWfWawTbSX2KmhEqxJ2DZscLJ5uVr1ICmRd7oSxqk=; b=oyOGI7FB/MXf0JWsnoUI9zEap7Vb5KYaDoqORpjbgwGLkXQA1DMuTDjY aMA7qqn/ns2f5swQsC1RcAct9e7vI3a8x8NgUbn7eb55o2iXvEZOGJuRg ur/vbEh18z4wm4LsTmzwM8DwRU9faLa9DzrK5T0CKf3vtqFHlZZA6ksH0 jA+nXYn4vlIs3t/AlhWJYBIetMn3nnnlszMLPjM393Gywcp6rrgWmtCrg 8Uvmw4JWC16qUssk8OEtKiydY6CK2L7RLUawczmWel/xdV/jtBPyMBq4G UONvUP1eAg93U9Jg3NQndxc6iegl5SZkvh0xkC907P9EnJD5H7Z3WJPzM Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199309" IronPort-SDR: VSvw72N2qtao1kaKi1j1/+N7tMP5jR8qXH7gVJuNeCdfW5n1gcUxixY7/eyWf7Lm4CA2pTgsj4 AoEbJNOomvfcjSk/lbSHRcHeDcVCcJsO0SSZdvGKHI8skZQd/DxjIKdLKWHpjcwqRJsvZoaSly Cps58xdZN+k0R7QOEye9C+fQSXDcJSLepkhD0j+bgvN7gFsJn5nU8WqasQFToVfHharANSf5/4 zbNRktbKzywlXJ5MEQUJzOQi3Q+MwAv8cu8kFc3sv4uwtnJ+oQjRVF97t6miNc9Q/LHi/iRtus j9U= IronPort-SDR: i5lqXMNCKnmpgM0EFlmHKDvncif5KpBaDGQAk5syAnFxyRwMFH3qDRolh2/+K4PV8ZNWOVhWt4 VwtRy4GkLOJwdS7YMV6BrGLBat0onSO94Cl4a1ytYZOAhZjBD1C/09/jmZy/8jl8CkCA8+8zpZ 3kakut+78BOe6k48mn0MYO+FyJyqikZM+F2iZdU9eRjgl6Gy/ZEkVwi3Onaxd60FlsVMR2XvLE NCUa49eHrK59qJHHsJDrjQcquSxdY0pIzEyGSasFyj6+h5wxKJx72sdUmNUSWoF3RhPGqW3mJ9 toU= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416257; x=1674008258; bh=xbWWfWawTbSX2KmhEq xJ2DZscLJ5uVr1ICmRd7oSxqk=; b=Zr0liNoT0JuGUmxuFbSaJYXnfJyfObu5or Zeok4shAb46V5KNpuA8E8kTc33QGWIYfz5wHQrAUFj/OMeLgCNfhsNG8MMu24KCY OxXPWcTCKRlpShwQRCKRsgpj4ZN4SlCGl6v3WFNn9yJPB0uvzsCbCiUaobAtNovc tttfdkwtGs2+1rUgXbLstuh9HlwX+HH2VicyFOwhHW/SdHZCwnMX8FQV/9dZawNz 3F5N/CLhKaCw8b71WmZ6UWbzY9k/P7vZ/Wl0I5ZZIoEMlqgl5HZn3oVPMncTSroM ZidgnW1OXIVnOe2bSzS91FXoiuksen629lS3rO4Gdhs+OXvMgU1Q== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Mayuresh Chitale , Weiwei Li , Alistair Francis Subject: [PULL 10/45] target/riscv: smstateen check for h/s/envcfg Date: Mon, 19 Dec 2022 12:16:28 +1000 Message-Id: <20221219021703.20473-11-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416596759100003 Content-Type: text/plain; charset="utf-8" From: Mayuresh Chitale Accesses to henvcfg, henvcfgh and senvcfg are allowed only if the correspon= ding bit in mstateen0/hstateen0 is enabled. Otherwise an illegal instruction tra= p is generated. Signed-off-by: Mayuresh Chitale Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Message-Id: <20221016124726.102129-3-mchitale@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 87 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 7 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index c861424e85..71236f2b5d 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -41,6 +41,42 @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *= ops) } =20 /* Predicates */ +#if !defined(CONFIG_USER_ONLY) +static RISCVException smstateen_acc_ok(CPURISCVState *env, int index, + uint64_t bit) +{ + bool virt =3D riscv_cpu_virt_enabled(env); + CPUState *cs =3D env_cpu(env); + RISCVCPU *cpu =3D RISCV_CPU(cs); + + if (env->priv =3D=3D PRV_M || !cpu->cfg.ext_smstateen) { + return RISCV_EXCP_NONE; + } + + if (!(env->mstateen[index] & bit)) { + return RISCV_EXCP_ILLEGAL_INST; + } + + if (virt) { + if (!(env->hstateen[index] & bit)) { + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + } + + if (env->priv =3D=3D PRV_U && !(env->sstateen[index] & bit)) { + return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; + } + } + + if (env->priv =3D=3D PRV_U && riscv_has_ext(env, RVS)) { + if (!(env->sstateen[index] & bit)) { + return RISCV_EXCP_ILLEGAL_INST; + } + } + + return RISCV_EXCP_NONE; +} +#endif + static RISCVException fs(CPURISCVState *env, int csrno) { #if !defined(CONFIG_USER_ONLY) @@ -1874,6 +1910,13 @@ static RISCVException write_menvcfgh(CPURISCVState *= env, int csrno, static RISCVException read_senvcfg(CPURISCVState *env, int csrno, target_ulong *val) { + RISCVException ret; + + ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } + *val =3D env->senvcfg; return RISCV_EXCP_NONE; } @@ -1882,15 +1925,27 @@ static RISCVException write_senvcfg(CPURISCVState *= env, int csrno, target_ulong val) { uint64_t mask =3D SENVCFG_FIOM | SENVCFG_CBIE | SENVCFG_CBCFE | SENVCF= G_CBZE; + RISCVException ret; =20 - env->senvcfg =3D (env->senvcfg & ~mask) | (val & mask); + ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } =20 + env->senvcfg =3D (env->senvcfg & ~mask) | (val & mask); return RISCV_EXCP_NONE; } =20 static RISCVException read_henvcfg(CPURISCVState *env, int csrno, target_ulong *val) { + RISCVException ret; + + ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } + *val =3D env->henvcfg; return RISCV_EXCP_NONE; } @@ -1899,6 +1954,12 @@ static RISCVException write_henvcfg(CPURISCVState *e= nv, int csrno, target_ulong val) { uint64_t mask =3D HENVCFG_FIOM | HENVCFG_CBIE | HENVCFG_CBCFE | HENVCF= G_CBZE; + RISCVException ret; + + ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } =20 if (riscv_cpu_mxl(env) =3D=3D MXL_RV64) { mask |=3D HENVCFG_PBMTE | HENVCFG_STCE; @@ -1912,6 +1973,13 @@ static RISCVException write_henvcfg(CPURISCVState *e= nv, int csrno, static RISCVException read_henvcfgh(CPURISCVState *env, int csrno, target_ulong *val) { + RISCVException ret; + + ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } + *val =3D env->henvcfg >> 32; return RISCV_EXCP_NONE; } @@ -1921,9 +1989,14 @@ static RISCVException write_henvcfgh(CPURISCVState *= env, int csrno, { uint64_t mask =3D HENVCFG_PBMTE | HENVCFG_STCE; uint64_t valh =3D (uint64_t)val << 32; + RISCVException ret; =20 - env->henvcfg =3D (env->henvcfg & ~mask) | (valh & mask); + ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_HSENVCFG); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } =20 + env->henvcfg =3D (env->henvcfg & ~mask) | (valh & mask); return RISCV_EXCP_NONE; } =20 @@ -1949,7 +2022,7 @@ static RISCVException write_mstateen(CPURISCVState *e= nv, int csrno, static RISCVException write_mstateen0(CPURISCVState *env, int csrno, target_ulong new_val) { - uint64_t wr_mask =3D SMSTATEEN_STATEEN; + uint64_t wr_mask =3D SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; =20 return write_mstateen(env, csrno, wr_mask, new_val); } @@ -1984,7 +2057,7 @@ static RISCVException write_mstateenh(CPURISCVState *= env, int csrno, static RISCVException write_mstateen0h(CPURISCVState *env, int csrno, target_ulong new_val) { - uint64_t wr_mask =3D SMSTATEEN_STATEEN; + uint64_t wr_mask =3D SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; =20 return write_mstateenh(env, csrno, wr_mask, new_val); } @@ -2021,7 +2094,7 @@ static RISCVException write_hstateen(CPURISCVState *e= nv, int csrno, static RISCVException write_hstateen0(CPURISCVState *env, int csrno, target_ulong new_val) { - uint64_t wr_mask =3D SMSTATEEN_STATEEN; + uint64_t wr_mask =3D SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; =20 return write_hstateen(env, csrno, wr_mask, new_val); } @@ -2060,7 +2133,7 @@ static RISCVException write_hstateenh(CPURISCVState *= env, int csrno, static RISCVException write_hstateen0h(CPURISCVState *env, int csrno, target_ulong new_val) { - uint64_t wr_mask =3D SMSTATEEN_STATEEN; + uint64_t wr_mask =3D SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; =20 return write_hstateenh(env, csrno, wr_mask, new_val); } @@ -2107,7 +2180,7 @@ static RISCVException write_sstateen(CPURISCVState *e= nv, int csrno, static RISCVException write_sstateen0(CPURISCVState *env, int csrno, target_ulong new_val) { - uint64_t wr_mask =3D SMSTATEEN_STATEEN; + uint64_t wr_mask =3D SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; =20 return write_sstateen(env, csrno, wr_mask, new_val); } --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671417108141841.1454912046905; Sun, 18 Dec 2022 18:31:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75iv-0008Ht-Kz; Sun, 18 Dec 2022 21:17:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iu-0008He-8h for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:48 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75ir-00015O-Jq for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:48 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:40 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:13 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:41 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JN697qz1RvTr for ; Sun, 18 Dec 2022 18:17:40 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kZLrCipQ1BVN for ; Sun, 18 Dec 2022 18:17:40 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JL250Mz1RvLy; Sun, 18 Dec 2022 18:17:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416265; x=1702952265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uKlkFUb7mBvR+Z9R4nsVPc0uLxuES5/f7RwMG/pjwv0=; b=UaEHi9dAHWUpykQYBQDl7NGHSI6OqGFAj/HxUkEpeLkjrk5kh/ylpb6y e+736rljhGvzCAJ/wx0faqFelbcGRKjP5L5+Jw1YQWKtwaMk5KHeyiwiX zXaeuz4ZZXouhdL8+X726x3hjtGmdu1eYuV4MPMO1rJWoXzPIL0uRE+21 s6PyaV9+21/zrL+Jo+YvBWrmt0mM2ouq6Et96+5bjq5Sqqyyyy81HZx9p r33f9LMpJ6WAjWP9TA14MvnMwye867LM38xUFeYIWzXZUcvhVd/USgW1T ZXaa9yx/IYtk7xJ/N0NfBo2yOeYi+GV5fFb3SOP8IWjHzwcIGqzmYAuSc A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199312" IronPort-SDR: RwL+bMELJDWi4SoOnAtu3zdtHLTTlbQC+wlSg8opMDJAeJ9D5JkIAiUct8icrK4h4z4VWXXMSV E+Gk7srWIV8sR9IniNF1UhxPaRB/q4C4sJcP9tZabxOPNHEFmTeO5/IVGpyoURbMxt5siv0XLa pI50n+KUsAwEd2AoxD8azaF/orPMS0hGTDemxrbuSgmqYFOFjuy3/6x+H9tsrlNZPJTOlnTgVo 547+ZwzKPa3T5Wn4ysYpopHMkhCo+IKlV71aYTLyLQciS2KcXFpbWlTIbLVqmhat+4RuLxrkBH IWg= IronPort-SDR: vuC1hRvxNykm1clYVkB20PUOJDx0oKAvGIufpPbo7/gDWDdFZZYQHEKE3pYiWQslCpsU4EeULy ryjE7Oc+gu3oibb2YUVRuVw/I8vTLwYGOetwYEKDoRYezCckghW+Ui+skb0zTrSgGSCIhpJ8pF +0yCpSSoCN9pIoXBslta/KrT6eYqp5yg7bBEGz8v9APePWNIISSaEbzH0Jt5o21RYrXlDemgL/ AUoqvJGprgecdm/53a2zuonP54wH98gPFvo6HWe1QwkQ3NEs0cqs924WWVPk1vFIq5d0t1vvoD izk= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416260; x=1674008261; bh=uKlkFUb7mBvR+Z9R4n sVPc0uLxuES5/f7RwMG/pjwv0=; b=Q7KRhaBrDz4WAUfc6c2FfDG05EtrUY3DMC trThifOcVrQeNqKc84vbDhkwTfIs+NatzeQoEsJePmomr2J4UqKnJpmzVcWKUzYq 02RY5FZskzHlibBe83F/IO+LDjpU7qrKWpD/+3NFDSNJideY9iHOo7ktzjFS4Qry 4Mj8zaBOnc5siYIorp+zAfBhBI/O1R6Ha6ZlaftMqY1re+Wd058ev314RwEB6miW j4vZrZEwicbIdg0UmjzmY7RnCd4phGHye0j7/QvgFPH4AwsjBN2yJzaLeUHT39HT b2R1hNUdo8/F3JlOkJMNKJFYdV7i4yANqe/vSnFQQpv+7+nVV3wg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Mayuresh Chitale , Weiwei Li , Alistair Francis Subject: [PULL 11/45] target/riscv: generate virtual instruction exception Date: Mon, 19 Dec 2022 12:16:29 +1000 Message-Id: <20221219021703.20473-12-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671417108649100001 Content-Type: text/plain; charset="utf-8" From: Mayuresh Chitale This patch adds a mechanism to generate a virtual instruction instruction exception instead of an illegal instruction exception during instruction decode when virt is enabled. Signed-off-by: Mayuresh Chitale Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Message-Id: <20221016124726.102129-4-mchitale@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/translate.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index db123da5ec..8b0bd38bb2 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -76,6 +76,7 @@ typedef struct DisasContext { to reset this known value. */ int frm; RISCVMXL ol; + bool virt_inst_excp; bool virt_enabled; const RISCVCPUConfig *cfg_ptr; bool hlsx; @@ -243,7 +244,11 @@ static void gen_exception_illegal(DisasContext *ctx) { tcg_gen_st_i32(tcg_constant_i32(ctx->opcode), cpu_env, offsetof(CPURISCVState, bins)); - generate_exception(ctx, RISCV_EXCP_ILLEGAL_INST); + if (ctx->virt_inst_excp) { + generate_exception(ctx, RISCV_EXCP_VIRT_INSTRUCTION_FAULT); + } else { + generate_exception(ctx, RISCV_EXCP_ILLEGAL_INST); + } } =20 static void gen_exception_inst_addr_mis(DisasContext *ctx) @@ -1062,6 +1067,7 @@ static void decode_opc(CPURISCVState *env, DisasConte= xt *ctx, uint16_t opcode) { has_XVentanaCondOps_p, decode_XVentanaCodeOps }, }; =20 + ctx->virt_inst_excp =3D false; /* Check for compressed insn */ if (insn_len(opcode) =3D=3D 2) { if (!has_ext(ctx, RVC)) { --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416315592187.437999215599; Sun, 18 Dec 2022 18:18:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75iw-0008IS-Cm; Sun, 18 Dec 2022 21:17:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75iv-0008Hm-51 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:49 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75ir-00015X-Jz for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:48 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:43 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:16 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:44 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JR58Mwz1Rwrq for ; Sun, 18 Dec 2022 18:17:43 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Sv9mg4TKH3vo for ; Sun, 18 Dec 2022 18:17:42 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JP0771z1RvLy; Sun, 18 Dec 2022 18:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416265; x=1702952265; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xFUlrf/rkP5FgRvdtWwqzmPs3jBEAWiKcaqXzib9gcg=; b=r8NaVd6UiNUZNIbS8FkugXAjk+YkAHVPUTs4DBoDy7NBdYTBwwwYFqQ1 Z5JDELBOOZdAV5vxtTArsXiX+U424K63yYdiEGxYAZZwbSrKIZhn9mCxB VEkOx5YFzoiDN0Lcx8jK3bhChpduuWI1vut8gnrXNZ6Bzy4q0SZIKsA53 2k/NeI78dt6dp5j/tJx0cNfTzihFaPpl4qnsVdzxgzkG0X+sNmyYHpchN WUPBxDsfG4ufJNLj5bSQT1ozLrk4sNXND5TYSL4yQOgwTIxnsrI5xc8kk UJFq2EPg2ot95iZ/E3MBitf0GEao7D8O3h9uauRiUfgkrmQwrIsT5/VUa g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199318" IronPort-SDR: 0ShUlF7CuwgCelL12oothcI5e0bNneQHt/DKLQ9faVQzOsqegusHAeseJCHNbxSR4hdhrn4hxA F6Q00+g4O7ObIi2jjD/XZar3499FihstywLrA6ZFaE5mC4OgxgdUllX6ZjJmXXpQQsw29P91qm arJhDYkLOYn6QpGgge1fceN+UUhqpym5el7pKXn/F3anDDmWk9lAZClPrgTLYYECUsWM0Zga6U cuZrvobFYpF8cc7TD+tIbWoSf6MfNh31ah4mYU0RHNJ4UQN390plaa4gQCSxtThOuln4id3Syt fGg= IronPort-SDR: vHk2sVHRygC0gPuFxwQKB8pNxgrSNl/TVkgc8Q7Il0cnqeH0GFbiUvv6MSY3ylePN9Y539hSIg QCuLrvtSJDIrN13SYz3S4Syk+pBnzGJwKS1o1pQH7WXUu3tdl9HH+yJCR4MwHDFWyIB6zBTnyo vqG32JhGXCiiItOz50k64GogNTqVIJHZidAOyOsibippCJfrJ3EEheFYTZTfcXCItHhFfP5HHO aE/QjT6FCkIEJo+hIYAhWGLNdGW4zEyta8YXHysITlCMp+zhSUdGWJxrmk7Z/+vEzYinAKJ1U3 eNQ= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416262; x=1674008263; bh=xFUlrf/rkP5FgRvdtW wqzmPs3jBEAWiKcaqXzib9gcg=; b=BGpcGz2upTwLn/6l4rXJiljP0fWnNPEJS7 d1hVUIaFVF1tAuRBHZ5kLI9mnJWkRCoqfZ+5zsIXQs/YZf0Fld+/dh2ZCxtLLEKm QK9KPg5vvmyq7+VfZr5beQyF8acgqIKcfDeUYjQ6bIeOUYR//t/8XovOhXPSB2Oz huZxsY67g1JlKvgnjB9T0mxcrG2rR8f7y4g4R1TAnENazGpF1SiWolb4or0R5ZoG TI3+G3E4SFWxUzTYNNepvIardM8HjqXssMx+mSnFkpXBdYKBEaLm2he44hHvcWSZ /aPQLBG2lAeowWhLNDA8xYbNWsM2UeUhRSd+sM8gXO66f7tmJTIg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Alistair Francis Subject: [PULL 12/45] target/riscv: Add itrigger support when icount is not enabled Date: Mon, 19 Dec 2022 12:16:30 +1000 Message-Id: <20221219021703.20473-13-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416316013100001 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei When icount is not enabled, there is no API in QEMU that can get the guest instruction number. Translate the guest code in a way that each TB only has one instruction. After executing the instruction, decrease the count by 1 until it reaches 0 where the itrigger fires. Note that only when priviledge matches the itrigger configuration, the count will decrease. Signed-off-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-Id: <20221013062946.7530-2-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 2 + target/riscv/debug.h | 12 ++++ target/riscv/helper.h | 2 + target/riscv/cpu_helper.c | 6 ++ target/riscv/debug.c | 71 +++++++++++++++++++ target/riscv/translate.c | 33 ++++++++- .../riscv/insn_trans/trans_privileged.c.inc | 4 +- target/riscv/insn_trans/trans_rvi.c.inc | 8 +-- target/riscv/insn_trans/trans_rvv.c.inc | 4 +- 9 files changed, 131 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 5cac0c5eec..c32e484c0b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -625,6 +625,8 @@ FIELD(TB_FLAGS, PM_MASK_ENABLED, 22, 1) FIELD(TB_FLAGS, PM_BASE_ENABLED, 23, 1) FIELD(TB_FLAGS, VTA, 24, 1) FIELD(TB_FLAGS, VMA, 25, 1) +/* Native debug itrigger */ +FIELD(TB_FLAGS, ITRIGGER, 26, 1) =20 #ifdef TARGET_RISCV32 #define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) diff --git a/target/riscv/debug.h b/target/riscv/debug.h index a1226b4d29..cc3358e69b 100644 --- a/target/riscv/debug.h +++ b/target/riscv/debug.h @@ -118,6 +118,17 @@ enum { SIZE_NUM =3D 16 }; =20 +/* itrigger filed masks */ +#define ITRIGGER_ACTION 0x3f +#define ITRIGGER_U BIT(6) +#define ITRIGGER_S BIT(7) +#define ITRIGGER_PENDING BIT(8) +#define ITRIGGER_M BIT(9) +#define ITRIGGER_COUNT (0x3fff << 10) +#define ITRIGGER_HIT BIT(24) +#define ITRIGGER_VU BIT(25) +#define ITRIGGER_VS BIT(26) + bool tdata_available(CPURISCVState *env, int tdata_index); =20 target_ulong tselect_csr_read(CPURISCVState *env); @@ -134,4 +145,5 @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPU= Watchpoint *wp); =20 void riscv_trigger_init(CPURISCVState *env); =20 +bool riscv_itrigger_enabled(CPURISCVState *env); #endif /* RISCV_DEBUG_H */ diff --git a/target/riscv/helper.h b/target/riscv/helper.h index a03014fe67..227c7122ef 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -109,6 +109,8 @@ DEF_HELPER_1(sret, tl, env) DEF_HELPER_1(mret, tl, env) DEF_HELPER_1(wfi, void, env) DEF_HELPER_1(tlb_flush, void, env) +/* Native Debug */ +DEF_HELPER_1(itrigger_match, void, env) #endif =20 /* Hypervisor functions */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 5d66246c2c..9d1d1bf9f1 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -27,7 +27,9 @@ #include "tcg/tcg-op.h" #include "trace.h" #include "semihosting/common-semi.h" +#include "sysemu/cpu-timers.h" #include "cpu_bits.h" +#include "debug.h" =20 int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch) { @@ -103,6 +105,10 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_u= long *pc, flags =3D FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_VS, get_field(env->mstatus_hs, MSTATUS_VS)); } + if (riscv_feature(env, RISCV_FEATURE_DEBUG) && !icount_enabled()) { + flags =3D FIELD_DP32(flags, TB_FLAGS, ITRIGGER, + riscv_itrigger_enabled(env)); + } #endif =20 flags =3D FIELD_DP32(flags, TB_FLAGS, XL, env->xl); diff --git a/target/riscv/debug.c b/target/riscv/debug.c index e44848d0d7..036161649f 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -29,6 +29,7 @@ #include "cpu.h" #include "trace.h" #include "exec/exec-all.h" +#include "exec/helper-proto.h" =20 /* * The following M-mode trigger CSRs are implemented: @@ -496,6 +497,76 @@ static void type6_reg_write(CPURISCVState *env, target= _ulong index, return; } =20 +/* icount trigger type */ +static inline int +itrigger_get_count(CPURISCVState *env, int index) +{ + return get_field(env->tdata1[index], ITRIGGER_COUNT); +} + +static inline void +itrigger_set_count(CPURISCVState *env, int index, int value) +{ + env->tdata1[index] =3D set_field(env->tdata1[index], + ITRIGGER_COUNT, value); +} + +static bool check_itrigger_priv(CPURISCVState *env, int index) +{ + target_ulong tdata1 =3D env->tdata1[index]; + if (riscv_cpu_virt_enabled(env)) { + /* check VU/VS bit against current privilege level */ + return (get_field(tdata1, ITRIGGER_VS) =3D=3D env->priv) || + (get_field(tdata1, ITRIGGER_VU) =3D=3D env->priv); + } else { + /* check U/S/M bit against current privilege level */ + return (get_field(tdata1, ITRIGGER_M) =3D=3D env->priv) || + (get_field(tdata1, ITRIGGER_S) =3D=3D env->priv) || + (get_field(tdata1, ITRIGGER_U) =3D=3D env->priv); + } +} + +bool riscv_itrigger_enabled(CPURISCVState *env) +{ + int count; + for (int i =3D 0; i < RV_MAX_TRIGGERS; i++) { + if (get_trigger_type(env, i) !=3D TRIGGER_TYPE_INST_CNT) { + continue; + } + if (check_itrigger_priv(env, i)) { + continue; + } + count =3D itrigger_get_count(env, i); + if (!count) { + continue; + } + return true; + } + + return false; +} + +void helper_itrigger_match(CPURISCVState *env) +{ + int count; + for (int i =3D 0; i < RV_MAX_TRIGGERS; i++) { + if (get_trigger_type(env, i) !=3D TRIGGER_TYPE_INST_CNT) { + continue; + } + if (check_itrigger_priv(env, i)) { + continue; + } + count =3D itrigger_get_count(env, i); + if (!count) { + continue; + } + itrigger_set_count(env, i, count--); + if (!count) { + do_trigger_action(env, i); + } + } +} + target_ulong tdata_csr_read(CPURISCVState *env, int tdata_index) { switch (tdata_index) { diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 8b0bd38bb2..cd5eb25ee8 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -112,6 +112,8 @@ typedef struct DisasContext { /* PointerMasking extension */ bool pm_mask_enabled; bool pm_base_enabled; + /* Use icount trigger for native debug */ + bool itrigger; /* TCG of the current insn_start */ TCGOp *insn_start; } DisasContext; @@ -257,15 +259,39 @@ static void gen_exception_inst_addr_mis(DisasContext = *ctx) generate_exception(ctx, RISCV_EXCP_INST_ADDR_MIS); } =20 +static void lookup_and_goto_ptr(DisasContext *ctx) +{ +#ifndef CONFIG_USER_ONLY + if (ctx->itrigger) { + gen_helper_itrigger_match(cpu_env); + } +#endif + tcg_gen_lookup_and_goto_ptr(); +} + +static void exit_tb(DisasContext *ctx) +{ +#ifndef CONFIG_USER_ONLY + if (ctx->itrigger) { + gen_helper_itrigger_match(cpu_env); + } +#endif + tcg_gen_exit_tb(NULL, 0); +} + static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) { - if (translator_use_goto_tb(&ctx->base, dest)) { + /* + * Under itrigger, instruction executes one by one like singlestep, + * direct block chain benefits will be small. + */ + if (translator_use_goto_tb(&ctx->base, dest) && !ctx->itrigger) { tcg_gen_goto_tb(n); gen_set_pc_imm(ctx, dest); tcg_gen_exit_tb(ctx->base.tb, n); } else { gen_set_pc_imm(ctx, dest); - tcg_gen_lookup_and_goto_ptr(); + lookup_and_goto_ptr(ctx); } } =20 @@ -1142,6 +1168,7 @@ static void riscv_tr_init_disas_context(DisasContextB= ase *dcbase, CPUState *cs) memset(ctx->ftemp, 0, sizeof(ctx->ftemp)); ctx->pm_mask_enabled =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_MASK_ENABLE= D); ctx->pm_base_enabled =3D FIELD_EX32(tb_flags, TB_FLAGS, PM_BASE_ENABLE= D); + ctx->itrigger =3D FIELD_EX32(tb_flags, TB_FLAGS, ITRIGGER); ctx->zero =3D tcg_constant_tl(0); } =20 @@ -1181,7 +1208,7 @@ static void riscv_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cpu) =20 /* Only the first insn within a TB is allowed to cross a page boundary= . */ if (ctx->base.is_jmp =3D=3D DISAS_NEXT) { - if (!is_same_page(&ctx->base, ctx->base.pc_next)) { + if (ctx->itrigger || !is_same_page(&ctx->base, ctx->base.pc_next))= { ctx->base.is_jmp =3D DISAS_TOO_MANY; } else { unsigned page_ofs =3D ctx->base.pc_next & ~TARGET_PAGE_MASK; diff --git a/target/riscv/insn_trans/trans_privileged.c.inc b/target/riscv/= insn_trans/trans_privileged.c.inc index 3281408a87..59501b2780 100644 --- a/target/riscv/insn_trans/trans_privileged.c.inc +++ b/target/riscv/insn_trans/trans_privileged.c.inc @@ -78,7 +78,7 @@ static bool trans_sret(DisasContext *ctx, arg_sret *a) if (has_ext(ctx, RVS)) { decode_save_opc(ctx); gen_helper_sret(cpu_pc, cpu_env); - tcg_gen_exit_tb(NULL, 0); /* no chaining */ + exit_tb(ctx); /* no chaining */ ctx->base.is_jmp =3D DISAS_NORETURN; } else { return false; @@ -94,7 +94,7 @@ static bool trans_mret(DisasContext *ctx, arg_mret *a) #ifndef CONFIG_USER_ONLY decode_save_opc(ctx); gen_helper_mret(cpu_pc, cpu_env); - tcg_gen_exit_tb(NULL, 0); /* no chaining */ + exit_tb(ctx); /* no chaining */ ctx->base.is_jmp =3D DISAS_NORETURN; return true; #else diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_tr= ans/trans_rvi.c.inc index c49dbec0eb..5c69b88d1e 100644 --- a/target/riscv/insn_trans/trans_rvi.c.inc +++ b/target/riscv/insn_trans/trans_rvi.c.inc @@ -66,7 +66,7 @@ static bool trans_jalr(DisasContext *ctx, arg_jalr *a) } =20 gen_set_gpri(ctx, a->rd, ctx->pc_succ_insn); - tcg_gen_lookup_and_goto_ptr(); + lookup_and_goto_ptr(ctx); =20 if (misaligned) { gen_set_label(misaligned); @@ -803,7 +803,7 @@ static bool trans_pause(DisasContext *ctx, arg_pause *a) * end the TB and return to main loop */ gen_set_pc_imm(ctx, ctx->pc_succ_insn); - tcg_gen_exit_tb(NULL, 0); + exit_tb(ctx); ctx->base.is_jmp =3D DISAS_NORETURN; =20 return true; @@ -827,7 +827,7 @@ static bool trans_fence_i(DisasContext *ctx, arg_fence_= i *a) * however we need to end the translation block */ gen_set_pc_imm(ctx, ctx->pc_succ_insn); - tcg_gen_exit_tb(NULL, 0); + exit_tb(ctx); ctx->base.is_jmp =3D DISAS_NORETURN; return true; } @@ -838,7 +838,7 @@ static bool do_csr_post(DisasContext *ctx) decode_save_opc(ctx); /* We may have changed important cpu state -- exit to main loop. */ gen_set_pc_imm(ctx, ctx->pc_succ_insn); - tcg_gen_exit_tb(NULL, 0); + exit_tb(ctx); ctx->base.is_jmp =3D DISAS_NORETURN; return true; } diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_tr= ans/trans_rvv.c.inc index 4dea4413ae..d455acedbf 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -196,7 +196,7 @@ static bool do_vsetvl(DisasContext *s, int rd, int rs1,= TCGv s2) mark_vs_dirty(s); =20 gen_set_pc_imm(s, s->pc_succ_insn); - tcg_gen_lookup_and_goto_ptr(); + lookup_and_goto_ptr(s); s->base.is_jmp =3D DISAS_NORETURN; =20 if (rd =3D=3D 0 && rs1 =3D=3D 0) { @@ -222,7 +222,7 @@ static bool do_vsetivli(DisasContext *s, int rd, TCGv s= 1, TCGv s2) gen_set_gpr(s, rd, dst); mark_vs_dirty(s); gen_set_pc_imm(s, s->pc_succ_insn); - tcg_gen_lookup_and_goto_ptr(); + lookup_and_goto_ptr(s); s->base.is_jmp =3D DISAS_NORETURN; =20 return true; --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416773536319.8671365659494; Sun, 18 Dec 2022 18:26:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75j6-0008JG-Hh; Sun, 18 Dec 2022 21:18:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75j5-0008J6-7M for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:59 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75j3-00017E-Ek for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:17:58 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:46 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:19 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:46 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JV0ykmz1RvTr for ; Sun, 18 Dec 2022 18:17:46 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 2E-4nKebeFW9 for ; Sun, 18 Dec 2022 18:17:45 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JR2Nwsz1RvTp; Sun, 18 Dec 2022 18:17:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416277; x=1702952277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WlzJNv7zAq+erG67OroIcaBLtHaWlexwDnpa6Hg6S1U=; b=LU4ENMxQ6ig9P2kvWQNF6Zo59xrNzZcD6w/oBnEKf9gaXRD7o70ixWcU IMqCS4QgmaKF/ZaeQ6W8TKTXJJgQatlnP1bx5paaiSLtGVnAx2aOF+fu0 963fq21AJQM9JJjqxJKaZH5BfK8AbCWNikCS2f+3nk07c1NcaD4G4A5W2 dHABXEnf9PrnEedmDPFEN+syB82BXf9aX+bMCt/tAXJ44fUMgK7Nhluo/ cRgmk2bHzhXYc3nMSz/hvLl9Am2VVgs/w5GXWHb6wU2c4qE9Qo6vUeNlb RgHsN/kbjeO1jJ2BBpEo8Q1AZnVXxTCCx+kGwy1iCQf9oNxOOnrA464ZB w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199319" IronPort-SDR: 1FIzvvN2PxiGdf1ZO2BEQyxNMP6hZXvnolFbUFy5JLf90E5Esd908dkbFIzOA8yC/ZuWYP1dmi jenT+5vu4epFFc8AddzRjcae3UZcZLDBo0nNdeJqNb4OmGuL7cpnBgqEGouIKO/nuqRkJ9gBw2 WX5w42AHb0pbD1BZWP07NIgjGW1r8VO0kiNcXSpJiEt2knwJIS7tYneO2fkm6/17Os24l0KDF3 1ExQe0Bpzg1DdUp85fMZnMTDDYE7v2tuTymj1c+48nWL61PQSsq0r1LmZnv13Ndc73FZJGoSJG /rg= IronPort-SDR: b/3n37oFtFKNF+l5+XpUe+4Xx0H9GC1cGZUmgc6VIPt5d9Z0mZo9R3jesDwVs8IiFb0Kvd+C5N +lYR+KBbZHJNO1HH+YANqiWY+7q5IVOnA8NDtkQwgVSBDJ6CocAeGaxQaj30KDEkBcTDjNF9LS nfmD3ajrUEPdaQifucxJ9xWpUBRYAi8fmy+DAzTGsD3MGAtyedJTznP6SmcQWZ1XFZ/4E5Ev3u QIrdxbi97KL2EXGPA2oIglbEDrw9yJJMpYIwn0La9kzJuZ07ACw3CaS2KfM5+fZVOCd14rUQ7r n8M= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416265; x=1674008266; bh=WlzJNv7zAq+erG67Or oIcaBLtHaWlexwDnpa6Hg6S1U=; b=e22KYXx84SRbOO6kmbsxVrfMVpFcEFofJA AoTV38BsSYG1zYV3hFrCH/c6ua6n3Lch32kaLmr4Ek5QrMMNGzVCcLr8pyCxW5jv n1dJDbps5DZ42/M2FuH8wADktuAOanHvkDDrQfrGjYzZqBFv5bf/ZzDh3dK8VVOv mmHB2J6+lQIhfAM9bg1s90K3t00CII7aE6wYy58lRme/zatSKhZl4tUzu5F36i5C wDfgWiI0Wj7YFoCXe1TMXWMokFqL5uVxojGDpTpKr6DaPQIM4h9rv4FULMuT51ig T3WEZMOQD6/nF0pFqSB4dVq7SrC9PaXI5lQi5FivZOApybHZb4Wg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Alistair Francis Subject: [PULL 13/45] target/riscv: Add itrigger support when icount is enabled Date: Mon, 19 Dec 2022 12:16:31 +1000 Message-Id: <20221219021703.20473-14-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416775138100003 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei The max count in itrigger can be 0x3FFF, which will cause a no trivial translation and execution overload. When icount is enabled, QEMU provides API that can fetch guest instruction number. Thus, we can set an timer for itrigger with the count as deadline. Only when timer expires or priviledge mode changes, do lazy update to count. Signed-off-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-Id: <20221013062946.7530-3-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 2 ++ target/riscv/debug.h | 1 + target/riscv/cpu_helper.c | 3 ++ target/riscv/debug.c | 59 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index c32e484c0b..b0b4048de9 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -329,6 +329,8 @@ struct CPUArchState { target_ulong tdata3[RV_MAX_TRIGGERS]; struct CPUBreakpoint *cpu_breakpoint[RV_MAX_TRIGGERS]; struct CPUWatchpoint *cpu_watchpoint[RV_MAX_TRIGGERS]; + QEMUTimer *itrigger_timer[RV_MAX_TRIGGERS]; + int64_t last_icount; =20 /* machine specific rdtime callback */ uint64_t (*rdtime_fn)(void *); diff --git a/target/riscv/debug.h b/target/riscv/debug.h index cc3358e69b..c471748d5a 100644 --- a/target/riscv/debug.h +++ b/target/riscv/debug.h @@ -146,4 +146,5 @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPU= Watchpoint *wp); void riscv_trigger_init(CPURISCVState *env); =20 bool riscv_itrigger_enabled(CPURISCVState *env); +void riscv_itrigger_update_priv(CPURISCVState *env); #endif /* RISCV_DEBUG_H */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 9d1d1bf9f1..6230f65f70 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -676,6 +676,9 @@ void riscv_cpu_set_mode(CPURISCVState *env, target_ulon= g newpriv) if (newpriv =3D=3D PRV_H) { newpriv =3D PRV_U; } + if (icount_enabled() && newpriv !=3D env->priv) { + riscv_itrigger_update_priv(env); + } /* tlb_flush is unnecessary as mode is contained in mmu_idx */ env->priv =3D newpriv; env->xl =3D cpu_recompute_xl(env); diff --git a/target/riscv/debug.c b/target/riscv/debug.c index 036161649f..371862cf38 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -30,6 +30,7 @@ #include "trace.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" +#include "sysemu/cpu-timers.h" =20 /* * The following M-mode trigger CSRs are implemented: @@ -567,6 +568,62 @@ void helper_itrigger_match(CPURISCVState *env) } } =20 +static void riscv_itrigger_update_count(CPURISCVState *env) +{ + int count, executed; + /* + * Record last icount, so that we can evaluate the executed instructio= ns + * since last priviledge mode change or timer expire. + */ + int64_t last_icount =3D env->last_icount, current_icount; + current_icount =3D env->last_icount =3D icount_get_raw(); + + for (int i =3D 0; i < RV_MAX_TRIGGERS; i++) { + if (get_trigger_type(env, i) !=3D TRIGGER_TYPE_INST_CNT) { + continue; + } + count =3D itrigger_get_count(env, i); + if (!count) { + continue; + } + /* + * Only when priviledge is changed or itrigger timer expires, + * the count field in itrigger tdata1 register is updated. + * And the count field in itrigger only contains remaining value. + */ + if (check_itrigger_priv(env, i)) { + /* + * If itrigger enabled in this priviledge mode, the number of + * executed instructions since last priviledge change + * should be reduced from current itrigger count. + */ + executed =3D current_icount - last_icount; + itrigger_set_count(env, i, count - executed); + if (count =3D=3D executed) { + do_trigger_action(env, i); + } + } else { + /* + * If itrigger is not enabled in this priviledge mode, + * the number of executed instructions will be discard and + * the count field in itrigger will not change. + */ + timer_mod(env->itrigger_timer[i], + current_icount + count); + } + } +} + +static void riscv_itrigger_timer_cb(void *opaque) +{ + riscv_itrigger_update_count((CPURISCVState *)opaque); +} + +void riscv_itrigger_update_priv(CPURISCVState *env) +{ + riscv_itrigger_update_count(env); +} + target_ulong tdata_csr_read(CPURISCVState *env, int tdata_index) { switch (tdata_index) { @@ -796,5 +853,7 @@ void riscv_trigger_init(CPURISCVState *env) env->tdata3[i] =3D 0; env->cpu_breakpoint[i] =3D NULL; env->cpu_watchpoint[i] =3D NULL; + env->itrigger_timer[i] =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, + riscv_itrigger_timer_cb, env= ); } } --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416546583948.4645066445721; Sun, 18 Dec 2022 18:22:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75j7-0008Ji-UJ; Sun, 18 Dec 2022 21:18:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75j6-0008JV-VV for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:00 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75j5-00015O-6D for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:00 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:48 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:21 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:48 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JX2dMFz1RvTp for ; Sun, 18 Dec 2022 18:17:48 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id CR_cMG_5W8_3 for ; Sun, 18 Dec 2022 18:17:47 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JV5gY8z1RvLy; Sun, 18 Dec 2022 18:17:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416279; x=1702952279; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6Q1etqXq6mt77HOH608vmTWlV47LCAy3tVEsE1U6I48=; b=A7T3vQDvSScLNiyalBrlXV2olTHz9OArJ1vvYw8tF5V2CDBBDoh6Nr3g D90k+0f5SNIIRz49vbKPj36NCxEr4ojtQjmPCUZ81wLgDUngNEc/k5FyR e0RUR+jXxlAOXBZqpZyurEo4NjE0/0R1BhcIA/HGN99K3gWcO4NCdOn7Q VOFt4QQ4z7Z/TSpBp1z4AuUZWfkPwWBleeegLatTdbVI+zAyxP+q4PA6r 00oii80rY4yIzZWKy9MPJs4fVsx6ruvpzSX3Gv3Q116vDOC7Z/88tQm5F BRw0RdAYmfxvfxxcEyA5bJZJHkgB6nJJ6kE9FsKB4a5de25W+OX8+3ASO A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199323" IronPort-SDR: Uy/RV5FAGaHnYTjWeRkTd6KRj2YaP2JWj9kLtTnbzdSo0dlUAdJfA/p44YpwmhPNl5qDMZm3wf 14/WLYvqnhFYayXg7D4DX0ZSk34mor5RxqqpJJ7IAjSB4MrFKPzUUSvBPw9D/X2jZinHtayHSt bJIsMKBdDNIS5h9BtR3KNdUnZ15hwQRp7XRmBI69w5aF96HD4u0ty4j9SUT5ETZQUWL0vAfNsm U/1Zz5hH3VXrtIjNWtVs7EW9yHwdzvNr5JdOjleBOFnVJ2lw9AIOF4QN9Fg3w6wLQIbx9H+8/Q bws= IronPort-SDR: 5DV74qRMteWXn5ZM9tztGAmALfL/xzbCRc+pdaZEhOdOmJhrAUyMs3wEPMo+koF1GVCKCedW4B oCHnX+mh8EakBJh1bVsnG0pKzWghAU4JYMwbx8anuL8G9Y1YojEMUPcbpWjTyOK6gKhtQN6S4D 1yZdF1dRj6Huj4JHh63EGDo9ovOJTOZmYEV7j37LyadF1wKYurHw/FFPdBU+KVLQ5CKUajgW9a 9kJR7o1lbPES7a9Uq82kQfC/lSEaxEQbvZWtcA0gntbTeCBAw09KlNon2BtBH5Vmx8laEAeCN8 ItY= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416267; x=1674008268; bh=6Q1etqXq6mt77HOH60 8vmTWlV47LCAy3tVEsE1U6I48=; b=RoC1D6ZM1d4VUVlUryv7+f0+L6qoLrLu1P 1bJb/2W5aWdg+ggL19A+x8thtpHknbGKew/4sKfjYRLOdyxPfMsZMqbJav/xKvNg CYQ/bk9jOr3UFeYJDd0Vxx/FEzElERznClnDFATUzZeHq2UjR09fdubCA+JcwuNk ayZiBlaEDzwpB/aYXD4rmmnssf7h1+ht7Ku1YPvWhDodHLPxbrxHK9sDgLlj7oDQ /7ySrzU3OBet1wd3NURo6zeKA4aNU4YQUar9bCGXOrfRF6jZoVSKXygBZxm2qRln vpcDVxOgnmLc1jhfy16qcmoUofmSFRdh0NrNKCT9TynXCdF8pPyQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Alistair Francis Subject: [PULL 14/45] target/riscv: Enable native debug itrigger Date: Mon, 19 Dec 2022 12:16:32 +1000 Message-Id: <20221219021703.20473-15-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416548074100003 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei When QEMU is not in icount mode, execute instruction one by one. The tdata1 can be read directly. When QEMU is in icount mode, use a timer to simulate the itrigger. The tdata1 may be not right because of lazy update of count in tdata1. Thus, We should pack the adjusted count into tdata1 before read it back. Signed-off-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-Id: <20221013062946.7530-4-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- target/riscv/debug.c | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/target/riscv/debug.c b/target/riscv/debug.c index 371862cf38..b3574b250f 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -624,10 +624,80 @@ void riscv_itrigger_update_priv(CPURISCVState *env) riscv_itrigger_update_count(env); } =20 +static target_ulong itrigger_validate(CPURISCVState *env, + target_ulong ctrl) +{ + target_ulong val; + + /* validate the generic part first */ + val =3D tdata1_validate(env, ctrl, TRIGGER_TYPE_INST_CNT); + + /* validate unimplemented (always zero) bits */ + warn_always_zero_bit(ctrl, ITRIGGER_ACTION, "action"); + warn_always_zero_bit(ctrl, ITRIGGER_HIT, "hit"); + warn_always_zero_bit(ctrl, ITRIGGER_PENDING, "pending"); + + /* keep the mode and attribute bits */ + val |=3D ctrl & (ITRIGGER_VU | ITRIGGER_VS | ITRIGGER_U | ITRIGGER_S | + ITRIGGER_M | ITRIGGER_COUNT); + + return val; +} + +static void itrigger_reg_write(CPURISCVState *env, target_ulong index, + int tdata_index, target_ulong val) +{ + target_ulong new_val; + + switch (tdata_index) { + case TDATA1: + /* set timer for icount */ + new_val =3D itrigger_validate(env, val); + if (new_val !=3D env->tdata1[index]) { + env->tdata1[index] =3D new_val; + if (icount_enabled()) { + env->last_icount =3D icount_get_raw(); + /* set the count to timer */ + timer_mod(env->itrigger_timer[index], + env->last_icount + itrigger_get_count(env, index= )); + } + } + break; + case TDATA2: + qemu_log_mask(LOG_UNIMP, + "tdata2 is not supported for icount trigger\n"); + break; + case TDATA3: + qemu_log_mask(LOG_UNIMP, + "tdata3 is not supported for icount trigger\n"); + break; + default: + g_assert_not_reached(); + } + + return; +} + +static int itrigger_get_adjust_count(CPURISCVState *env) +{ + int count =3D itrigger_get_count(env, env->trigger_cur), executed; + if ((count !=3D 0) && check_itrigger_priv(env, env->trigger_cur)) { + executed =3D icount_get_raw() - env->last_icount; + count +=3D executed; + } + return count; +} + target_ulong tdata_csr_read(CPURISCVState *env, int tdata_index) { + int trigger_type; switch (tdata_index) { case TDATA1: + trigger_type =3D extract_trigger_type(env, env->tdata1[env->trigge= r_cur]); + if ((trigger_type =3D=3D TRIGGER_TYPE_INST_CNT) && icount_enabled(= )) { + return deposit64(env->tdata1[env->trigger_cur], 10, 14, + itrigger_get_adjust_count(env)); + } return env->tdata1[env->trigger_cur]; case TDATA2: return env->tdata2[env->trigger_cur]; @@ -656,6 +726,8 @@ void tdata_csr_write(CPURISCVState *env, int tdata_inde= x, target_ulong val) type6_reg_write(env, env->trigger_cur, tdata_index, val); break; case TRIGGER_TYPE_INST_CNT: + itrigger_reg_write(env, env->trigger_cur, tdata_index, val); + break; case TRIGGER_TYPE_INT: case TRIGGER_TYPE_EXCP: case TRIGGER_TYPE_EXT_SRC: --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416581555397.1022325804664; Sun, 18 Dec 2022 18:23:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jE-0008Mq-05; Sun, 18 Dec 2022 21:18:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75j9-0008MN-2F for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:03 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75j7-00015X-5f for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:02 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:50 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:23 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:50 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3JZ1H5Fz1RvTr for ; Sun, 18 Dec 2022 18:17:50 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id GF-dSMv71UH3 for ; Sun, 18 Dec 2022 18:17:49 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JX2n5dz1RwqL; Sun, 18 Dec 2022 18:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416281; x=1702952281; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hA8GUt3QgaAt1ObukS0M+QptkQXfyXPsaUaQjv3/W5k=; b=Anz8NP9DCYqcxmLinE16m2nC+L3d90XVv30+UbRvxgTLwzce44bf6CY8 6wWad+3+ELxoFJoEE0Y7Nrv+EAiTNhg/FJ+gmfVkFcun92WhetYeVscYi LShg/Y/AtoHku6pecist1M/pWnVa6kN9lUJfmhbcatDtV1rZvACEjaeCB qfXSR+6A0prL+j8zMC+dlPIFJ1q4vTT6pTuiBw7xAUwoYGUtW4j93ovNM ssl9n0dhxW25WrV0rTz6O80BuDm3uEzPE/hPlUecNplD4hqTdS7W0IV2o bx9Zu2CHx7AM1ruLJH7r8VOSalifjJrlw3Geis4fSX3a/c74Gylr1bcED w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199329" IronPort-SDR: 3U2X2YKqBOTdQxikxdbau7286WUZJrLzfAc27kahtwbDZRErqrfFywv4KKVuwIRdtb2PprkHa5 hliP7vcPvyF/AXAkxujDrwPEWZzqJhzCUDBkLuWqU/w+wO/Dv6IhAjVeP7Oehfpqt3/efN5Fig VY2GxEtsY9NYmzvY/gaE+Qb/xXbgfXtcrD6VPdLyrj0L9/4lCZw6tft9HsigN81KOupdIZ1exW UDhDp1mZS/xVaYFNciBeuzw4ieThySxY/WHrpS1QLlBkJL3CcZNlp1TqGJyWIkkAgJxyLbXpbP fMo= IronPort-SDR: hzsLtE/eeH9kwU1WCyo0cDq0frrRdn0jedhxOuByrnVbISs86rNeVa7IdSqinCKDSbW5Ontlm8 HzKgR9qvR1eTNdflssD99U6sloJ0R4VyjdhzWX5y+u35+KsW1xErtJK6Nki1uJ5Vf2h+g9B/8I /5s+4j61eLdOTVNIBjenv7xE2kQEN8xFkaoDCI6fiwPb4KgaLm8q67zw/CIRzN/jup9vJHZMqE duQ1zN+IARdLe31Nsbgtww0mre/Y4BeLrHrPG0eFLLFJ0uVrDRCWLjr4d2Ka/NgnIgLS/SDqZy UT4= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416269; x=1674008270; bh=hA8GUt3QgaAt1ObukS 0M+QptkQXfyXPsaUaQjv3/W5k=; b=j1jzgfIZ0uD14T8y8irUu4KQ6+vidY1k7e ag/6g8pWs/YhHPVbQONKLsfeZoQVBzrAuCSkcT9/QeUeS0bmQTZ81zvX50XVKr/l vc+/AXHWldJV1OnkyCAHEuBkljuEzvA26kiJQugekk4gRWpWf302RC2kQxf3vdii mf9qiap7lyQgvbMD4z1IJTWZOnF+T+lfs8tu3VKeBL/60P+MykGFjVUidjNP2iLf 8LSxDFBkOm6kPa2EOSYWsyhiCxH2UmfNjZSFcT++Iyyo7nKhcWtdmbY3okG1mfTJ nSEcwx+tcovyTUWqOcwedX2dSyhtaUZs2/uTD6CnrSffGkSWS/8w== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Alistair Francis Subject: [PULL 15/45] target/riscv: Add itrigger_enabled field to CPURISCVState Date: Mon, 19 Dec 2022 12:16:33 +1000 Message-Id: <20221219021703.20473-16-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416582160100006 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei Avoid calling riscv_itrigger_enabled() when calculate the tbflags. As the itrigger enable status can only be changed when write tdata1, migration load or itrigger fire, update env->itrigger_enabled at these places. Signed-off-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-Id: <20221013062946.7530-5-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 1 + target/riscv/cpu_helper.c | 3 +-- target/riscv/debug.c | 3 +++ target/riscv/machine.c | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index b0b4048de9..37f9516941 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -331,6 +331,7 @@ struct CPUArchState { struct CPUWatchpoint *cpu_watchpoint[RV_MAX_TRIGGERS]; QEMUTimer *itrigger_timer[RV_MAX_TRIGGERS]; int64_t last_icount; + bool itrigger_enabled; =20 /* machine specific rdtime callback */ uint64_t (*rdtime_fn)(void *); diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 6230f65f70..427d4d4386 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -106,8 +106,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ul= ong *pc, get_field(env->mstatus_hs, MSTATUS_VS)); } if (riscv_feature(env, RISCV_FEATURE_DEBUG) && !icount_enabled()) { - flags =3D FIELD_DP32(flags, TB_FLAGS, ITRIGGER, - riscv_itrigger_enabled(env)); + flags =3D FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enab= led); } #endif =20 diff --git a/target/riscv/debug.c b/target/riscv/debug.c index b3574b250f..bf4840a6a3 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -563,6 +563,7 @@ void helper_itrigger_match(CPURISCVState *env) } itrigger_set_count(env, i, count--); if (!count) { + env->itrigger_enabled =3D riscv_itrigger_enabled(env); do_trigger_action(env, i); } } @@ -660,6 +661,8 @@ static void itrigger_reg_write(CPURISCVState *env, targ= et_ulong index, /* set the count to timer */ timer_mod(env->itrigger_timer[index], env->last_icount + itrigger_get_count(env, index= )); + } else { + env->itrigger_enabled =3D riscv_itrigger_enabled(env); } } break; diff --git a/target/riscv/machine.c b/target/riscv/machine.c index e687f9fce0..65a8549ec2 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -21,6 +21,8 @@ #include "qemu/error-report.h" #include "sysemu/kvm.h" #include "migration/cpu.h" +#include "sysemu/cpu-timers.h" +#include "debug.h" =20 static bool pmp_needed(void *opaque) { @@ -229,11 +231,24 @@ static bool debug_needed(void *opaque) return riscv_feature(env, RISCV_FEATURE_DEBUG); } =20 +static int debug_post_load(void *opaque, int version_id) +{ + RISCVCPU *cpu =3D opaque; + CPURISCVState *env =3D &cpu->env; + + if (icount_enabled()) { + env->itrigger_enabled =3D riscv_itrigger_enabled(env); + } + + return 0; +} + static const VMStateDescription vmstate_debug =3D { .name =3D "cpu/debug", .version_id =3D 2, .minimum_version_id =3D 2, .needed =3D debug_needed, + .post_load =3D debug_post_load, .fields =3D (VMStateField[]) { VMSTATE_UINTTL(env.trigger_cur, RISCVCPU), VMSTATE_UINTTL_ARRAY(env.tdata1, RISCVCPU, RV_MAX_TRIGGERS), --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416354796840.0668656710792; Sun, 18 Dec 2022 18:19:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jJ-0008Ri-9b; Sun, 18 Dec 2022 21:18:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jH-0008RE-8E for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:11 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jF-00017E-Ha for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:10 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:53 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:26 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:53 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jd2DSpz1RvLy for ; Sun, 18 Dec 2022 18:17:53 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id anBcRDukexnx for ; Sun, 18 Dec 2022 18:17:52 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3JZ1mpYz1RwqL; Sun, 18 Dec 2022 18:17:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416289; x=1702952289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KOmkdsaG2L/1f6aUZirO4FA9LnT3y2PXMdUmb+q6hDk=; b=X7SzGwESbVn1fUj0vEOcMUyr7+Ju+3pnZv8zfOdCV5T8Z9tTGfda3FxT HWCApJ4/Sgowk1dX3zF0XUhrlgqudKtefJul+pdMEEl4SNHot0uZCX3Xy G+tDJ3XKBpn0ER29AzFRcmweKzUjZ1R24X7mduIPI46hzCZtb5nu5/Q85 YxaVR9Qa/Xt1yV30PSq/5TeypPFoSJfIqoOxWq6rqLzhD4Bh1c1A/WgXX /+3q0uep7xATHlL3oP/+RvIcmU+c5ZVpnEn4YdlPyUvDgcJAEWkzb7U1H U2DDFLZvTp0pj8xY0O2IPNV/zaLEUa9PinKzMSmyointEiExZRJQrKyGu w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199333" IronPort-SDR: 7wuaqMJEdLofbsIwgjaRPmN150OTN+wZPKIpwOhLQwRB5m19TtVC7/kv63RcBBdQ/jnvSivcQE jmkW8ShsiQ8E+C3FXi8w3jtmAdBcS48Jmp3wqBrtMH8j1CU80z+gcCZc1Fc6lhuIeTRzlpSHuH 1ygDu/PKxCymkIGp/tRSp7YwU4LowmQggcSTMjnOThhBD6HNGNDfRRSEI4jnOpE+vDQGNNBaJU KlzNyG4B15jFf7oxm1TpvFGxh/Hr7Xt2+uZYmI8W6W2X9ykN4UijDcVk3WZsVmrbbm9uDcEqap HIc= IronPort-SDR: vS4upLhhZZX0jqXpLPM44+F+ixEnIbcXSwck95x2tEvDa1DFlahPp2Hq6Er3UPI3mf8zXKMEGI aIVbwaPuokUS76HLv3DwtZJPICci2QFMW6AgPiSRx6UrUTM2ojY1eBY/C3UijFBV0nyYt4w5x2 5bOzmYMWza0xCfpMt3W2CzIvzG6XPdD6tYTxy9sj8nb197Wqt4qaRtuyj4uTFaM4kxo5n7asEJ RLRSF2mR723zCQzOSMIz5tAX/ZNrVBl8QMeXvsII6v4mE4NABHlAFMZ9wCqziXKVFsiSzbHrX/ Bk4= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416272; x=1674008273; bh=KOmkdsa G2L/1f6aUZirO4FA9LnT3y2PXMdUmb+q6hDk=; b=qHj3wviRfEb5N4g1e424rIQ 2t3tSeAkPNTk/uWm3cJhwMBI2pOm3QYuiQGp8sbMcnzCnhjUY5Ms+aYpfg0034+G AM8v37Ib4Lf7u0QEFnBEE1v+5KLk0k3+g82Oq/MWiZpSFVlb9F/Ult4Ez9Otj4B2 8u9sCzNGleAk1HsjRNDA91JBCF2+pne9qjNQFPdlYL55x+TFWtPbdncgC2zJPJxZ VHQpElEyea5CzzZRy60VVCi/SWs7uggemTL8w7hKlPSMaW3o5FWzC6cOc1Vmij5W 3/ur26/aAA8FbGh3fUoFwPJj1Y6dC0w68H7V3AsurYyzX75o00uzbgXxjzo8n8Q= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9trot?= , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 16/45] hw/intc: sifive_plic: Renumber the S irqs for numa support Date: Mon, 19 Dec 2022 12:16:34 +1000 Message-Id: <20221219021703.20473-17-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416356237100003 Content-Type: text/plain; charset="utf-8" From: Fr=C3=A9d=C3=A9ric P=C3=A9trot Commit 40244040a7a changed the way the S irqs are numbered. This breaks when using numa configuration, e.g.: ./qemu-system-riscv64 -nographic -machine virt,dumpdtb=3Dnuma-tree.dtb \ -m 2G -smp cpus=3D16 \ -object memory-backend-ram,id=3Dmem0,size=3D512M \ -object memory-backend-ram,id=3Dmem1,size=3D512M \ -object memory-backend-ram,id=3Dmem2,size=3D512M \ -object memory-backend-ram,id=3Dmem3,size=3D512M \ -numa node,cpus=3D0-3,memdev=3Dmem0,nodeid=3D0 \ -numa node,cpus=3D4-7,memdev=3Dmem1,nodeid=3D1 \ -numa node,cpus=3D8-11,memdev=3Dmem2,nodeid=3D2 \ -numa node,cpus=3D12-15,memdev=3Dmem3,nodeid=3D3 leads to: Unexpected error in object_property_find_err() at ../qom/object.c:1304: qemu-system-riscv64: Property 'riscv.sifive.plic.unnamed-gpio-out[8]' not found This patch makes the nubering of the S irqs identical to what it was before. Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Fr=C3=A9d=C3=A9ric P=C3=A9trot Message-Id: <20221114135122.1668703-1-frederic.petrot@univ-grenoble-alpes.f= r> Signed-off-by: Alistair Francis --- hw/intc/sifive_plic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index c2dfacf028..b4949bef97 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -476,11 +476,11 @@ DeviceState *sifive_plic_create(hwaddr addr, char *ha= rt_config, CPUState *cpu =3D qemu_get_cpu(cpu_num); =20 if (plic->addr_config[i].mode =3D=3D PLICMode_M) { - qdev_connect_gpio_out(dev, num_harts - plic->hartid_base + cpu= _num, + qdev_connect_gpio_out(dev, cpu_num - hartid_base + num_harts, qdev_get_gpio_in(DEVICE(cpu), IRQ_M_EXT)= ); } if (plic->addr_config[i].mode =3D=3D PLICMode_S) { - qdev_connect_gpio_out(dev, cpu_num, + qdev_connect_gpio_out(dev, cpu_num - hartid_base, qdev_get_gpio_in(DEVICE(cpu), IRQ_S_EXT)= ); } } --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416581614299.1982190442326; Sun, 18 Dec 2022 18:23:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jK-0008Rn-0F; Sun, 18 Dec 2022 21:18:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jI-0008Ra-UO for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:12 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jH-00015O-CM for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:12 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:55 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:28 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:55 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jg2SVWz1RvTp for ; Sun, 18 Dec 2022 18:17:55 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nXwOmn1id2gU for ; Sun, 18 Dec 2022 18:17:55 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Jd2rmWz1Rwrq; Sun, 18 Dec 2022 18:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416291; x=1702952291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=icpZO5Thn7rLQmM9zLyvo4epmOEtTo4HPzPsWRyUaiM=; b=QohMPSvtQCBwNvtH/bWlsQynyliAmHU2Y15vuNLIQV4ospnc47d4RrmL G/B35JjP4J0hGoZknCRLQqbc1F5li8ohUefjzZ3sAmmR3IJs2R44ZJeB0 N/hxcrqKp3s9H+ayftgiiEMscuc/aE9IjfhyMA73rQZc+SDlWhkBNMce2 NWDqYsvQvNJ1zZYxupMMxlQ1GxIAwFwVtA97AunzrNR2Oo+NtwvIB9X4C vSRy3ycvxmfODSRrjaF3U2a9mSB6viCKsKNMVNatVyqIXMA+XfJvpdsQ4 oVZqMTF2GbMbkbL/DPLA7dpMQQJRK8hrje/sG5FbFY2UvxqklDbkqVnDh Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199338" IronPort-SDR: /vvWmAOOFrC5Gk1pSySYcbssTCCmET7vNXhqGokC+3ZvAY083NKPiehm2HsZP5IUcpYQwAMaji lQCiTbmCRyRl1/zAOLHT4xghADYXo2JtMp7tyM0Qsn7ZBRYYAQvd5n+mTxePDI841vjqkpauYG MnwnFCDxmZl7xZN2aKHInwFxixn3HD3M3HJ9XRZ5SBLRD9F6YNw3F/SHObahxvrQpszt2ynFOw ibOfiAF1GA8Jqk/gC0PyZBLOa9qfgQbLuAiKLwzDTeIJ/lAbfgT1D7oZT+73m2lgwobd+Ztify p5w= IronPort-SDR: 76bmp/qpuGaZxx/iZOY6WO3j9c6h5dIHujIWqwaUb8RAyhP/RL7Kxus8xQjRgFxcHGfB6x+umc E2HYbQb5DNf/F30KWpW/iiwaGnToE1O+hPgXWEK4kCWVAgvvMtknPcPeouY90s+nvvbbTM+bmX aYmq+yHPZAqxFWYREtJ6nJy159VNXwf5vGo2hyXBMmaJ9M12BieNF6J52sVnrD1X+YtEDa1Z8J Wn7aPt79z77HR8UR24U3Vh+yutjG/RVqGTDz66wLjxdq+7aQB4dH7IPG9Cg8tXrCkngwyR7VY9 RwI= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416275; x=1674008276; bh=icpZO5Thn7rLQmM9zL yvo4epmOEtTo4HPzPsWRyUaiM=; b=Ygjqv8T2SNROyiv/98kW6GWvX3Yl0I4UJt 06qdLWOwk/nVbmxVhUNUyachAKX7doGYebQ99b1EJMBv2AQwEL6rSHkoYyvQjZyK bsOuxORK1NxLkvzONjjUX15VRwNoVWpfXmR+Q1OOwBq+rdjSsD3jR0tHqsCIO5UP nN/U+wK1akyUfUsBwLGZwaXrJmMAoNUeP/G/1qYhF0Pc3TsNwYDIHqmI6kFqsPvv 1J0JNYzp3APRpP0pcm5Gg+8DY9KYnMVwNgTn77yCDnUsypjO/bgrECDy7Ldj5jyr i43nTLQrVe9UbmDxukuOKze87zcvTZMPnI2XCotLArWB/3zF0zgw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Anup Patel , Alistair Francis Subject: [PULL 17/45] target/riscv: Typo fix in sstc() predicate Date: Mon, 19 Dec 2022 12:16:35 +1000 Message-Id: <20221219021703.20473-18-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416582159100005 Content-Type: text/plain; charset="utf-8" From: Anup Patel We should use "&&" instead of "&" when checking hcounteren.TM and henvcfg.STCE bits. Fixes: 3ec0fe18a31f ("target/riscv: Add vstimecmp suppor") Signed-off-by: Anup Patel Reviewed-by: Alistair Francis Message-Id: <20221108125703.1463577-2-apatel@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 71236f2b5d..0db2c233e5 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -940,7 +940,7 @@ static RISCVException sstc(CPURISCVState *env, int csrn= o) } =20 if (riscv_cpu_virt_enabled(env)) { - if (!(get_field(env->hcounteren, COUNTEREN_TM) & + if (!(get_field(env->hcounteren, COUNTEREN_TM) && get_field(env->henvcfg, HENVCFG_STCE))) { return RISCV_EXCP_VIRT_INSTRUCTION_FAULT; } --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416475340976.6688923979636; Sun, 18 Dec 2022 18:21:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jM-0008V4-77; Sun, 18 Dec 2022 21:18:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jK-0008SM-Vf for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:14 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jJ-00015X-BQ for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:14 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:57 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:30 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:57 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jj1hnFz1RvTr for ; Sun, 18 Dec 2022 18:17:57 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id GrDNfnEAGTn8 for ; Sun, 18 Dec 2022 18:17:56 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Jg311Zz1Rwrq; Sun, 18 Dec 2022 18:17:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416293; x=1702952293; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+M7+37H0131qu5DnZvJJSIbui8Sp1KNr5DG3bv1IxMw=; b=guGkl3CE+ZehpUQeb/ywDCMYhr2kgu5Yq0wgzCGqnEif1U3mpJNSSdwb PXnVk1cekVGgT4kDOPvwqSOpckaH1IBMj24ukWRB1CtF5Etog5HuyenIV lKT3eVVaeeFIE5YlKe4O1TFwNk0D1kyQ+fq7FD9okifUXEQj6MrWuzotB N3jg+nRn5F8WMavNiax6WhyBKpbTrNDnK+WHLrpzP4IdPoABP8HI183D7 Fqbrby6RkJoxBbDO5vw7bsH4W2hLhM4zIEyjPe6ps9gX8N/wyJ9NTf6Kz Do6gD3ken8KXcoeCMrtAW82jqtcEpV8F/1YjHKCUCAh9gK/LaoCLtVvEK g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199342" IronPort-SDR: LjUy/7GsZlr1GPj90i1YS38Q2JEv0GgNmV56rwehuDvqqUVpFXe9SQIikc5R1SxJvqP3giRFME LTdaDafTJaCk2RL61tPohwPsZT3lK/pqDw0TUpOWGvUrooPwtkzeRm/vHCahLUaFqsRA2McN3r vtldAY2/r0I+FKKGkM4cUTOCMWlAmoIdKlovp/ZyKSrcN68J/fK+6luNQcpuymnc9Qvlx+Q9Ax CxAKhBApnFM7vaM5FRBLCzyO/2PnGdOzDzgZtf/iIXSgKH8TikinwNp3KU9kQBeVdqvui710Id +Xc= IronPort-SDR: URHj8SXh/Dq3Xn74dJxl6AdHt0SCHXMyE4RTL6OYq9DdBD6rZ9TsmFifDK90hrBgIPq4B86tpy XebkxUeAv/Vh+HGt8uUXctzwI4bZxnAM4dC1Kn+BsFNvacmJDwID5uWTRaRtrrGiky2tqRN37s O8ElRDsaUUCrwOPtRu/sxY76fMw1WoWOOnhCayAlKHcAM94HIIBB09eIHshLm286M998dYNTjw pzyNTilhOgshhHTRhAhRLLbTxnNR5Vg7xROk/x1YpSEurpNWBbFkJjfXz5BI9IoCL+qtv0/FlD av4= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416276; x=1674008277; bh=+M7+37H0131qu5DnZv JJSIbui8Sp1KNr5DG3bv1IxMw=; b=ZYm+xqghOTUQUDkRZmTAWcEW0QXt+OnYb2 W2KcbKsW2t5tJmgtjmY3WEE6z3cr8p2HgN31nB67Up+g8Glwb800lcnSyFaFDKA7 gArBgSz2bE1oGmSmutokd+xLG/5RVrTvYL0HlZEpzSsg5qZkNMdBeiKGsUfuH/xj WoTCPTwOxNQuEGwwuRiFHGdbsVDgtqo6jNiFmoVx4SwIUUTpU01fuWZtijRnw0Q1 EkgRVTh5dDdpV2hNTtsjRhE+V6vjDLXQ04xjGcdx+tD8lgxCJ2PLVfCqCsLnJJ0E RZwO4f1LayTkLRGeBOvw6brOvVcku3FdYze3895hz5psSIMTRD2g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Atish Patra , Alistair Francis Subject: [PULL 18/45] hw/riscv: virt: Remove the redundant ipi-id property Date: Mon, 19 Dec 2022 12:16:36 +1000 Message-Id: <20221219021703.20473-19-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416476539100002 Content-Type: text/plain; charset="utf-8" From: Atish Patra The imsic DT binding[1] has changed and no longer require an ipi-id. The latest IMSIC driver dynamically allocates ipi id if slow-ipi is not defined. Get rid of the unused dt property which may lead to confusion. [1] https://lore.kernel.org/lkml/20221111044207.1478350-5-apatel@ventanamic= ro.com/ Signed-off-by: Atish Patra Reviewed-by: Alistair Francis Message-Id: <20221122080529.1692533-1-atishp@rivosinc.com> Signed-off-by: Alistair Francis --- include/hw/riscv/virt.h | 1 - hw/riscv/virt.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index be4ab8fe7f..62513e075c 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -93,7 +93,6 @@ enum { =20 #define VIRT_PLATFORM_BUS_NUM_IRQS 32 =20 -#define VIRT_IRQCHIP_IPI_MSI 1 #define VIRT_IRQCHIP_NUM_MSIS 255 #define VIRT_IRQCHIP_NUM_SOURCES VIRTIO_NDEV #define VIRT_IRQCHIP_NUM_PRIO_BITS 3 diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index a5bc7353b4..6cf9355b99 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -546,8 +546,6 @@ static void create_fdt_imsic(RISCVVirtState *s, const M= emMapEntry *memmap, riscv_socket_count(mc) * sizeof(uint32_t) * 4); qemu_fdt_setprop_cell(mc->fdt, imsic_name, "riscv,num-ids", VIRT_IRQCHIP_NUM_MSIS); - qemu_fdt_setprop_cells(mc->fdt, imsic_name, "riscv,ipi-id", - VIRT_IRQCHIP_IPI_MSI); if (riscv_socket_count(mc) > 1) { qemu_fdt_setprop_cell(mc->fdt, imsic_name, "riscv,hart-index-bits", imsic_num_bits(imsic_max_hart_per_socket)); @@ -597,8 +595,6 @@ static void create_fdt_imsic(RISCVVirtState *s, const M= emMapEntry *memmap, riscv_socket_count(mc) * sizeof(uint32_t) * 4); qemu_fdt_setprop_cell(mc->fdt, imsic_name, "riscv,num-ids", VIRT_IRQCHIP_NUM_MSIS); - qemu_fdt_setprop_cells(mc->fdt, imsic_name, "riscv,ipi-id", - VIRT_IRQCHIP_IPI_MSI); if (imsic_guest_bits) { qemu_fdt_setprop_cell(mc->fdt, imsic_name, "riscv,guest-index-bits= ", imsic_guest_bits); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416517302980.8775674015579; Sun, 18 Dec 2022 18:21:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jU-0000Pq-S9; Sun, 18 Dec 2022 21:18:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jT-0000LU-7l for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:23 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jR-00017E-IK for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:23 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:17:59 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:31 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:17:59 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jk734Hz1Rwt8 for ; Sun, 18 Dec 2022 18:17:58 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id RE_ln3QTMSTU for ; Sun, 18 Dec 2022 18:17:58 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Jj1hZjz1RvTp; Sun, 18 Dec 2022 18:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416301; x=1702952301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X5pPuQ/7QbzlG3f/0UBJxpkHOFrd2/Xcw9qJolUpEC0=; b=oZ/BohvabFrvBSMLxwHz3784+kFOMQT5/wOX6mq26+E+wDD6+VTFuuKF VgQoJystHzN3axI3MhPoKLA0IYgQB3XG0UvD0P/RdB+uXdwA+h/N4XTMi Ua1IOCHeoJSgfN/WDrHd8zM4BQLF+52y+NPosMciAuoR3VeDjZ50U8LNg Uqs1gw0mYl/WCbRwIEzaO9I/Vtv8ZIvUZfRm2fo6c85bgyISrajUV7lMK eUsrWsceGxoyv9bjQSwJJCA4EPCfHWCnPB0JAmE7prQvqR2ZP/JSpzW3J qfmadAn0g4/Y44J9dWTka6ypt+JuHpKH+e9h+VdMDDenqbMcp/7Len15r A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199346" IronPort-SDR: 8XihbuEPnSa3Hz8u3YYF+fqLuSOjZLu8yo6SgAzytRTx1V4agEwCgrzqQk4KC02zs02hnt5IGM gMnbewf6e7Vk453ihHo4HluA3Ja5tCOZep59Hx2nAYUSFTOQ+/dhWfmQyMGr5MSwe+SLQEB9Tw 3l4p1SF3yI6bdaZPKWs+HB8ZnNc8+11iCCbSKjMbV3SdXhn+P7ymgPlm1ZRHFn0ZGOHLu6Btim d+9CxH8MUau7v7MUUh9nUS9LcLq8hz60pZPgZTb2dDhVYxVsUewKYW0GaSTVatlDrsrt6n7rOY QJo= IronPort-SDR: rOWCq+xQgUGdl4Ybgm0R6mPNAtHgNtPhS0LTaBhcpUrWuZfZZaspp7I19AgUiahzUAXhMC9DcH oQGNKdAVTUiDVlTMmJN5GgugTZxnyUD8prUdOZZqXaygFtd328C1uBBVBVr4ajDoZFnEH5wUrT G1o5wMeLUR4BAqvDl7mcmWmpPwqTYxB7QAb6LaTZUJjEHPY3GLFQjGJNtRk4BlaB2fgzyQCqNr GS+svyMCVtd78blOiiTbReYBPUIDhsV4UPpRBWSz3N9upGaA9+e8oZSiRXQcoKtjc3FPTGtUFa XFI= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416278; x=1674008279; bh=X5pPuQ/7QbzlG3f/0U BJxpkHOFrd2/Xcw9qJolUpEC0=; b=QR7NbzoOptI2jrduYWNRHuD5IFr4SeaVxq ezByUXbZtyD/1VQGyVKZGqR5GqzFU7RoTPy5o42MtR6QOsi0mSjM+4Kod9gaTBWM nhnSDIozFpHH+DSE9Ge65aHssR5IrRCSlXN+RbtlWxzFUbaPmwKVV4A3m/xyeKJH v7czCgctZJ1j0UlWA2Xly1cB6cI3f/0Xn0pIII8YfEKdNtVPqFFsvRi0o7k+k6JG 4UrSVG+1HgwT0rYxvPFjn72yft8R8I6pp7XGrTjEaa5mU3fGXzWzcBsE41JBASPu 2VbO4Bu0be5x6Q8QxM6rMZth9rfMntdxG6jd+JcPCSXb7qmDS/nw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jim Shu , Alistair Francis Subject: [PULL 19/45] target/riscv: support cache-related PMU events in virtual mode Date: Mon, 19 Dec 2022 12:16:37 +1000 Message-Id: <20221219021703.20473-20-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416517943100001 Content-Type: text/plain; charset="utf-8" From: Jim Shu let tlb_fill() function also increments PMU counter when it is from two-stage translation, so QEMU could also monitor these PMU events when CPU runs in VS/VU mode (like running guest OS). Signed-off-by: Jim Shu Reviewed-by: Alistair Francis Message-Id: <20221123090635.6574-1-jim.shu@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 427d4d4386..1ff6ab5746 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -1258,6 +1258,7 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, = int size, } } =20 + pmu_tlb_fill_incr_ctr(cpu, access_type); if (riscv_cpu_virt_enabled(env) || ((riscv_cpu_two_stage_lookup(mmu_idx) || two_stage_lookup) && access_type !=3D MMU_INST_FETCH)) { @@ -1321,7 +1322,6 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, = int size, } } } else { - pmu_tlb_fill_incr_ctr(cpu, access_type); /* Single stage lookup */ ret =3D get_physical_address(env, &pa, &prot, address, NULL, access_type, mmu_idx, true, false, fals= e); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167141715515022.4225346864863; Sun, 18 Dec 2022 18:32:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jZ-0000Ud-K7; Sun, 18 Dec 2022 21:18:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jU-0000Pk-Om for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:24 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jT-00015O-70 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:24 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:01 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:34 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:01 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jn1HQRz1RwqL for ; Sun, 18 Dec 2022 18:18:01 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ZPvzMFn47NZD for ; Sun, 18 Dec 2022 18:18:00 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Jk71jDz1Rwrq; Sun, 18 Dec 2022 18:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416303; x=1702952303; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o8dl9X7n0QpbDK6OlU8v1kgM0gsCxofq6AuWFPs0GJo=; b=O7YbFG4jSVE0KUwoYkxVLSBaYf1n3U7FU4+QL8jroKlI43uz/Qk7jYAc Lr3hbE3CeJkMal9/bNNBh+qwawm6/n+ldHD2i0IQe8mjuz5ULxcgrA5O7 7/s1NiQw4oZbfyQm+zdOTu725YtQzKBRbxI0nh/xg2TxEUVaMRucb1bA1 jKwSUef7L7L5roRaQC1npnilab3Fpt09MKTnB2uJegMfWpZgZkucWTM66 0AqTyH2/HNbo+s5DxfIx8ce3GtXfsZg51MOPM2z7DrMNdF6Clzw0srX3J ylQjF1rMtR19HWsy0TbLah4ZNWh/OuBGc0U9Agpum3045x1he2XKzGG3x w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199351" IronPort-SDR: Gs/RhNibEKnDJLHoNjIp+RWeJkiK2Wrh7DtwEAb1jGc7EkXtOkJ5EmgvWSWK3I1WV7iHk3hZXq GeOepuXE8P+nBRvvRlXfeNgIIFPq6TgH2PuT4TQuwG+Nb6WMoXP3FjdmpcN3yhzSJVLr3GuFIR FoaUwGNjtr4LekBC3zfKV/WhpJFZCDcEb0ihTVJNE0Etgwim8/Yy9kkmrZ9XWkfhqQcyCojDTt AQ+ORgHF/fKmPVFoQnCkxa2vtzN7KSNBWPLD38YIdDjCrxJc9PvNiYxGa3tEUGy9G2vvsd7Tny /Rc= IronPort-SDR: /JdMds7DJLRpaKQyNMywU3vzj3drmoUWSWIb3XaGrok0vw8q4g5VQeG3M7FcQ4MGd0+Vo2nRQN cWlqVC0nT/yL4klLLfc5ZG95tDLp3m1iFTPijIv+3C0s/F+1dsqpaWDV0Vf+qna/uzVgISDHlO E46QHwbEl5TWuBcmguxAJYJi7yobErfbP3mPfC4FgTyxwfsG3quAhGTyR+78GknrLxSdtXQodg S+mJrqdyEE/pulVniXPdEeoCzTjOn8Edd6f1dplaTFVzUGhbbijey308OAAH+yQS86FXtFzBQp BUU= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416280; x=1674008281; bh=o8dl9X7n0QpbDK6OlU 8v1kgM0gsCxofq6AuWFPs0GJo=; b=hP+GYVBZ3+TMb/a+yo2sUmwEPioo7RjpvH Tjj+FK0ZMP1kw3D+7y76D7i+0kKgLgY21gMK0svc7785OB7EUqlmQMx7Nc5IEU2Y HgGfHS1dKpXGZ4Z46sSYm/vKP6RSGPYINxESX0J7uKz8/eZaT0J/+x6OZbTE7S+D PRQO5BdTqt6W46An7leq+oF8jOP6jNFHKFZP44XJhq9c1zdqNoUv5che/PgfRAyG OJV1MfXbtDd7XIrOXFtahAhNGrk98gjwHSL3AunHwirP9GH/drFln13/iZMEmrVU 8MQK2CttUIkVW4togpsZ9US6GHm0O0nQakS7UE8ovv2Ey0kEs27g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis Subject: [PULL 20/45] target/riscv: Add some comments for sstatus CSR in riscv_cpu_dump_state() Date: Mon, 19 Dec 2022 12:16:38 +1000 Message-Id: <20221219021703.20473-21-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671417157006100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng sstatus register dump is currently missing in riscv_cpu_dump_state(). As sstatus is a copy of mstatus, which is described in the priv spec, it seems redundant to print the same information twice. Add some comments for this to let people know this is intentional. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <20221125050354.3166023-1-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6fe176e483..b2c132e269 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -382,6 +382,10 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f= , int flags) CSR_MHARTID, CSR_MSTATUS, CSR_MSTATUSH, + /* + * CSR_SSTATUS is intentionally omitted here as its value + * can be figured out by looking at CSR_MSTATUS + */ CSR_HSTATUS, CSR_VSSTATUS, CSR_MIP, --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416423489669.8578545473448; Sun, 18 Dec 2022 18:20:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jd-0000t3-NL; Sun, 18 Dec 2022 21:18:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jb-0000fY-FO for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:31 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jV-00015X-96 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:30 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:03 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:36 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:03 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jq1Qh0z1RvLy for ; Sun, 18 Dec 2022 18:18:03 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 989F7dvUaX6M for ; Sun, 18 Dec 2022 18:18:02 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Jn1RhRz1Rwrq; Sun, 18 Dec 2022 18:18:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416305; x=1702952305; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FIMAReO8fXe+YRY+QgOavq1HmVvfN04k2FyBaT0sflE=; b=c7g8fyJKp38i8o8t7GABCi/cD9NjTPfPVmgUVbYgm7YPk11DVPps7/fF 21BUkid2sp4JOtlDXxWRLQZx/7dL/Pg8TTsBZY8yPthHIiprfRyQH66/O pk+ZbQ7EC0Qeknx5P87jZjh2xEr5ZGC10M1XOkUdpYfROEbdMk9DH0tmg fVS0qdPNsE4admC2vjcY8vo3Un6exs5Xkuud2R0w65ksZJXtLUdnoYZ+U 68G0egE5tnQbh4VztZhj0G41b93mOvgcPd3w4+46W6SLU6IyBF0mJwfSp 1WupRCaGLeWf0FZN1ctaym/O0NRPXqPo6epNmc+BrxX91kuZrJWboln3i g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199355" IronPort-SDR: sIgUWzC3gkD3gaYOoK7HLC1BAZYvy+Oq0Nd5yycCP7J8E/55x2QmvXrhVQImASFd9wDyiELl5A oLPr902TTjp0qD/Rw4JOmk+pofA28kO1ftfrk6d+e95Eet+mMXJjYN3CdjdT6U5QGeVPkcnvA5 8lDXWNWRCQtPce0JumIC06NrHFALDjbDV2HLMa8V6lL3F45cs7S34tRB94ljlue3UBn+GcKokh aSz9pSQ89sAnJhPSPtVqtdkhUErlmEZUrOLtbllo/4EX9lVM6nY7OdzfrrA3KXeSUOZWbyMl13 Ytw= IronPort-SDR: KDStNa1RuOHxlJEWpNHlcr3WNIH+Nmf1oxTDjHk6vAtFYsCTkSXoS9YGaJOhnYMZ9aRVoinbwl d22picJDwfiQ4hxqx+EUE4Xd207/LvhUWVyKMCpWt/OzzN3gbe/sPWyPciQND0DlOvU208qnEi joXcA/jtau9vwdv7/r/wI5W46+mn6YbAib4mk2HWzSnsVrOTrJSCepWAgejDrbo3oBeoSysXBS JkvDZMYhuNdw9HGxqlqSHf2A7ypxm2X7oxLVobvWb3lHbZHvlBkIQ/C5h6IO465GdLhp0b8I9E 5ag= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416282; x=1674008283; bh=FIMAReO8fXe+YRY+Qg Oavq1HmVvfN04k2FyBaT0sflE=; b=DVbk5bfsDEIk8JyKcUhdQx4EJfVKlxpBK/ 2A4DDXOXIUtOe8D1kKmUNnkFxRPW+s2zInOzfGi7wnMrUh78gHLMyKFnROcRdTDe +hjimfbE+eA9DoMXyvFV20VncMMx5e5LABUs2rmsJNxHv19JbD5vL9Zb9XGX4rEj bLtQ0UWX6Fikbxrq4sLjaK1tXGfPPLM05nvilVKe4ofdi9yBe+ElE8E9w6lOucjs 60czyHTK60C6C+02ku9OkRYlU7JcRkHoL/NPibUih7GBT/NMgCRfJysemtPYjfC7 5gg+3IKqy8+uIPj3flCVcPVEa/2KhWYS2tOo/yueeE2ytvB7ychQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Conor Dooley , Alistair Francis Subject: [PULL 21/45] hw/misc: pfsoc: add fabric clocks to ioscb Date: Mon, 19 Dec 2022 12:16:39 +1000 Message-Id: <20221219021703.20473-22-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416424321100001 Content-Type: text/plain; charset="utf-8" From: Conor Dooley On PolarFire SoC, some peripherals (eg the PCI root port) are clocked by "Clock Conditioning Circuitry" in the FPGA. The specific clock depends on the FPGA bitstream & can be locked to one particular {D,P}LL - in the Icicle Kit Reference Design v2022.09 or later this is/will be the case. Linux v6.1+ will have a driver for this peripheral and devicetrees that previously relied on "fixed-frequency" clock nodes have been switched over to clock-controller nodes. The IOSCB region is represented in QEMU, but the specific region of it that the CCCs occupy has not so v6.1-rcN kernels fail to boot in QEMU. Add the regions as unimplemented so that the status-quo in terms of boot is maintained. Acked-by: Alistair Francis Signed-off-by: Conor Dooley Message-Id: <20221117225518.4102575-2-conor@kernel.org> Signed-off-by: Alistair Francis --- include/hw/misc/mchp_pfsoc_ioscb.h | 1 + hw/misc/mchp_pfsoc_ioscb.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfso= c_ioscb.h index 9235523e33..687b213742 100644 --- a/include/hw/misc/mchp_pfsoc_ioscb.h +++ b/include/hw/misc/mchp_pfsoc_ioscb.h @@ -30,6 +30,7 @@ typedef struct MchpPfSoCIoscbState { MemoryRegion lane23; MemoryRegion ctrl; MemoryRegion cfg; + MemoryRegion ccc; MemoryRegion pll_mss; MemoryRegion cfm_mss; MemoryRegion pll_ddr; diff --git a/hw/misc/mchp_pfsoc_ioscb.c b/hw/misc/mchp_pfsoc_ioscb.c index f4fd55a0e5..f976e42f72 100644 --- a/hw/misc/mchp_pfsoc_ioscb.c +++ b/hw/misc/mchp_pfsoc_ioscb.c @@ -33,6 +33,7 @@ */ #define IOSCB_WHOLE_REG_SIZE 0x10000000 #define IOSCB_SUBMOD_REG_SIZE 0x1000 +#define IOSCB_CCC_REG_SIZE 0x2000000 =20 /* * There are many sub-modules in the IOSCB module. @@ -45,6 +46,7 @@ #define IOSCB_LANE23_BASE 0x06510000 #define IOSCB_CTRL_BASE 0x07020000 #define IOSCB_CFG_BASE 0x07080000 +#define IOSCB_CCC_BASE 0x08000000 #define IOSCB_PLL_MSS_BASE 0x0E001000 #define IOSCB_CFM_MSS_BASE 0x0E002000 #define IOSCB_PLL_DDR_BASE 0x0E010000 @@ -168,6 +170,10 @@ static void mchp_pfsoc_ioscb_realize(DeviceState *dev,= Error **errp) "mchp.pfsoc.ioscb.cfg", IOSCB_SUBMOD_REG_SIZE); memory_region_add_subregion(&s->container, IOSCB_CFG_BASE, &s->cfg); =20 + memory_region_init_io(&s->ccc, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.ccc", IOSCB_CCC_REG_SIZE); + memory_region_add_subregion(&s->container, IOSCB_CCC_BASE, &s->ccc); + memory_region_init_io(&s->pll_mss, OBJECT(s), &mchp_pfsoc_pll_ops, s, "mchp.pfsoc.ioscb.pll_mss", IOSCB_SUBMOD_REG_SIZ= E); memory_region_add_subregion(&s->container, IOSCB_PLL_MSS_BASE, &s->pll= _mss); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671417005345838.7686572501112; Sun, 18 Dec 2022 18:30:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75ji-00017V-5R; Sun, 18 Dec 2022 21:18:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jf-0000yh-M8 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:35 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jd-00017E-IF for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:35 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:06 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:38 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:06 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jt0Ctsz1RwqL for ; Sun, 18 Dec 2022 18:18:06 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HkrK9yZrzCL2 for ; Sun, 18 Dec 2022 18:18:05 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Jq29f1z1Rwt8; Sun, 18 Dec 2022 18:18:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416313; x=1702952313; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RobOMoHC8AMiNjPZ0P2MpRetfpGMHTgISeyeurg1D18=; b=LA8qz6GmtLc3b8ubuc5QLbTWTytGX65VwfCOkHVyKi9yMeki0h3j81Pv ZZdZgb7V1mJF8YYvY6/gLNAVn+Y56tYyPh4Tgfwi8qc7JoYeDXQOIbS4l fobF+BLsKSUAQrFhKqy+ABMUHOZl2qRDOrewF26BXuHysloJq85x3/M57 Swlmx6PwuVanvN4UUMgCWRo6F7E4qVWKvf+8vF/z/rxiXvXGxvlAnH+Ll IcYHHd9bh/quO5hhuROJCWI19arOOE7z29QSiZ8RLnTt9XUsq2ycwMHfa ItviaeVc7Fw96d6IlNFFKM7oqZJ1C0pr+Uy69sPT0Aojr4ih4lP+Cvk1o g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199359" IronPort-SDR: du/dOmR+0T6t6CbZ07TK9OzqevBy6a/ImQ2vCFnP5k/+Om1PBHrBBfBr2mGJp9eUDpirTakEFJ tiFN219gWZVy5/oBpaBO8DCRl4bRfn5+NhiDCgMOuh4qIt0yecuHZQjSmkJ/oc7C7Y924vhB5G QCxSqonIq8xv9RNoTIuOi3yoKjUKEsIxZRl1by9Yu6wGNEhA9X6L1XsRhCxEbCfl2IkBZ+P7p1 t3o10VsSICNjac6fxXAb0PTjyUT3a0t6mrXSEYCiWG9C+IoN5umARmG31Iv4hH0e0mZQ4wqhw1 Fns= IronPort-SDR: MVSKbXQ0fHOQfCY5MJa3vlH8ofaSq/w1DYML9MErN4OtvAtKw4Xz8VZzSW69fpKubQKF0udnYm xejtdiI5RQ0PU6d+Fcd2vS5A0+GrsbxULbu8ZGcu1PiDyLO7YRtMnuZGJuhl6cwEnFwQgzBDZZ 4wnvpQervc7re4lHB1JWWcFWQjovjvvw9ByF3c+GUAAX3Q93WQiXLDXDpwVUPCvj3ZzT5avn8i EFZcTdY7zVrzF6MWksiU4Bufz56kgboziP+NVfs/jP1ja1ZTajFEjJ78gYrXEVnnUjAJ9hiALs EYs= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416285; x=1674008286; bh=RobOMoHC8AMiNjPZ0P 2MpRetfpGMHTgISeyeurg1D18=; b=gKg+n7Imu1FPId86OZZ5lVKzpwwkXX5uOj N91tnaqSC0VsAftzBewa7YTDyJp5KVCF/3bFQHClxJox8SNzFHam9CYcqOqzKqU5 s7jSa/iZ/An4BZyOiAZTT69pcMbErd8JxcrB/dB2LsT5mmuDlHzGljW87plhz1Ge C2qt/lVrMEGiWUcxoCc4EwmCUDLLH3we6bsRxzKOjFUmsUFIgIroFpNA4q3WNlUz e2UPEVo/zSaObsk6TMsepQhMsyJNgTDMEIq/gGapXT4g5uVw0L0NJBWyoLUWeK8M GeFo4+4YoNO2C0CMMKqKM3bHwRLcchXoloLNNJ0aU1v+J40PkHlw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Conor Dooley , Alistair Francis Subject: [PULL 22/45] hw/riscv: pfsoc: add missing FICs as unimplemented Date: Mon, 19 Dec 2022 12:16:40 +1000 Message-Id: <20221219021703.20473-23-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671417006249100006 Content-Type: text/plain; charset="utf-8" From: Conor Dooley The Fabric Interconnect Controllers provide interfaces between the FPGA fabric and the core complex. There are 5 FICs on PolarFire SoC, numbered 0 through 4. FIC2 is an AXI4 slave interface from the FPGA fabric and does not show up on the MSS memory map. FIC4 is dedicated to the User Crypto Processor and does not show up on the MSS memory map either. FIC 0, 1 & 3 do show up in the MSS memory map and neither FICs 0 or 1 are represented in QEMU, leading to load access violations while booting Linux for Icicle if PCIe is enabled as the root port is connected via either FIC 0 or 1. Acked-by: Alistair Francis Signed-off-by: Conor Dooley Message-Id: <20221117225518.4102575-3-conor@kernel.org> Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 2 + hw/riscv/microchip_pfsoc.c | 115 ++++++++++++++++------------- 2 files changed, 65 insertions(+), 52 deletions(-) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchi= p_pfsoc.h index a757b240e0..7e7950dd36 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -121,6 +121,8 @@ enum { MICROCHIP_PFSOC_USB, MICROCHIP_PFSOC_QSPI_XIP, MICROCHIP_PFSOC_IOSCB, + MICROCHIP_PFSOC_FABRIC_FIC0, + MICROCHIP_PFSOC_FABRIC_FIC1, MICROCHIP_PFSOC_FABRIC_FIC3, MICROCHIP_PFSOC_DRAM_LO, MICROCHIP_PFSOC_DRAM_LO_ALIAS, diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index a821263d4f..2a24e3437a 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -86,58 +86,61 @@ * describes the complete IOSCB modules memory maps */ static const MemMapEntry microchip_pfsoc_memmap[] =3D { - [MICROCHIP_PFSOC_RSVD0] =3D { 0x0, 0x100 }, - [MICROCHIP_PFSOC_DEBUG] =3D { 0x100, 0xf00 }, - [MICROCHIP_PFSOC_E51_DTIM] =3D { 0x1000000, 0x2000 }, - [MICROCHIP_PFSOC_BUSERR_UNIT0] =3D { 0x1700000, 0x1000 }, - [MICROCHIP_PFSOC_BUSERR_UNIT1] =3D { 0x1701000, 0x1000 }, - [MICROCHIP_PFSOC_BUSERR_UNIT2] =3D { 0x1702000, 0x1000 }, - [MICROCHIP_PFSOC_BUSERR_UNIT3] =3D { 0x1703000, 0x1000 }, - [MICROCHIP_PFSOC_BUSERR_UNIT4] =3D { 0x1704000, 0x1000 }, - [MICROCHIP_PFSOC_CLINT] =3D { 0x2000000, 0x10000 }, - [MICROCHIP_PFSOC_L2CC] =3D { 0x2010000, 0x1000 }, - [MICROCHIP_PFSOC_DMA] =3D { 0x3000000, 0x100000 }, - [MICROCHIP_PFSOC_L2LIM] =3D { 0x8000000, 0x2000000 }, - [MICROCHIP_PFSOC_PLIC] =3D { 0xc000000, 0x4000000 }, - [MICROCHIP_PFSOC_MMUART0] =3D { 0x20000000, 0x1000 }, - [MICROCHIP_PFSOC_WDOG0] =3D { 0x20001000, 0x1000 }, - [MICROCHIP_PFSOC_SYSREG] =3D { 0x20002000, 0x2000 }, - [MICROCHIP_PFSOC_AXISW] =3D { 0x20004000, 0x1000 }, - [MICROCHIP_PFSOC_MPUCFG] =3D { 0x20005000, 0x1000 }, - [MICROCHIP_PFSOC_FMETER] =3D { 0x20006000, 0x1000 }, - [MICROCHIP_PFSOC_DDR_SGMII_PHY] =3D { 0x20007000, 0x1000 }, - [MICROCHIP_PFSOC_EMMC_SD] =3D { 0x20008000, 0x1000 }, - [MICROCHIP_PFSOC_DDR_CFG] =3D { 0x20080000, 0x40000 }, - [MICROCHIP_PFSOC_MMUART1] =3D { 0x20100000, 0x1000 }, - [MICROCHIP_PFSOC_MMUART2] =3D { 0x20102000, 0x1000 }, - [MICROCHIP_PFSOC_MMUART3] =3D { 0x20104000, 0x1000 }, - [MICROCHIP_PFSOC_MMUART4] =3D { 0x20106000, 0x1000 }, - [MICROCHIP_PFSOC_WDOG1] =3D { 0x20101000, 0x1000 }, - [MICROCHIP_PFSOC_WDOG2] =3D { 0x20103000, 0x1000 }, - [MICROCHIP_PFSOC_WDOG3] =3D { 0x20105000, 0x1000 }, - [MICROCHIP_PFSOC_WDOG4] =3D { 0x20106000, 0x1000 }, - [MICROCHIP_PFSOC_SPI0] =3D { 0x20108000, 0x1000 }, - [MICROCHIP_PFSOC_SPI1] =3D { 0x20109000, 0x1000 }, - [MICROCHIP_PFSOC_I2C0] =3D { 0x2010a000, 0x1000 }, - [MICROCHIP_PFSOC_I2C1] =3D { 0x2010b000, 0x1000 }, - [MICROCHIP_PFSOC_CAN0] =3D { 0x2010c000, 0x1000 }, - [MICROCHIP_PFSOC_CAN1] =3D { 0x2010d000, 0x1000 }, - [MICROCHIP_PFSOC_GEM0] =3D { 0x20110000, 0x2000 }, - [MICROCHIP_PFSOC_GEM1] =3D { 0x20112000, 0x2000 }, - [MICROCHIP_PFSOC_GPIO0] =3D { 0x20120000, 0x1000 }, - [MICROCHIP_PFSOC_GPIO1] =3D { 0x20121000, 0x1000 }, - [MICROCHIP_PFSOC_GPIO2] =3D { 0x20122000, 0x1000 }, - [MICROCHIP_PFSOC_RTC] =3D { 0x20124000, 0x1000 }, - [MICROCHIP_PFSOC_ENVM_CFG] =3D { 0x20200000, 0x1000 }, - [MICROCHIP_PFSOC_ENVM_DATA] =3D { 0x20220000, 0x20000 }, - [MICROCHIP_PFSOC_USB] =3D { 0x20201000, 0x1000 }, - [MICROCHIP_PFSOC_QSPI_XIP] =3D { 0x21000000, 0x1000000 }, - [MICROCHIP_PFSOC_IOSCB] =3D { 0x30000000, 0x10000000 }, - [MICROCHIP_PFSOC_FABRIC_FIC3] =3D { 0x40000000, 0x20000000 }, - [MICROCHIP_PFSOC_DRAM_LO] =3D { 0x80000000, 0x40000000 }, - [MICROCHIP_PFSOC_DRAM_LO_ALIAS] =3D { 0xc0000000, 0x40000000 }, - [MICROCHIP_PFSOC_DRAM_HI] =3D { 0x1000000000, 0x0 }, - [MICROCHIP_PFSOC_DRAM_HI_ALIAS] =3D { 0x1400000000, 0x0 }, + [MICROCHIP_PFSOC_RSVD0] =3D { 0x0, 0x100 }, + [MICROCHIP_PFSOC_DEBUG] =3D { 0x100, 0xf00 }, + [MICROCHIP_PFSOC_E51_DTIM] =3D { 0x1000000, 0x2000 }, + [MICROCHIP_PFSOC_BUSERR_UNIT0] =3D { 0x1700000, 0x1000 }, + [MICROCHIP_PFSOC_BUSERR_UNIT1] =3D { 0x1701000, 0x1000 }, + [MICROCHIP_PFSOC_BUSERR_UNIT2] =3D { 0x1702000, 0x1000 }, + [MICROCHIP_PFSOC_BUSERR_UNIT3] =3D { 0x1703000, 0x1000 }, + [MICROCHIP_PFSOC_BUSERR_UNIT4] =3D { 0x1704000, 0x1000 }, + [MICROCHIP_PFSOC_CLINT] =3D { 0x2000000, 0x10000 }, + [MICROCHIP_PFSOC_L2CC] =3D { 0x2010000, 0x1000 }, + [MICROCHIP_PFSOC_DMA] =3D { 0x3000000, 0x100000 }, + [MICROCHIP_PFSOC_L2LIM] =3D { 0x8000000, 0x2000000 }, + [MICROCHIP_PFSOC_PLIC] =3D { 0xc000000, 0x4000000 }, + [MICROCHIP_PFSOC_MMUART0] =3D { 0x20000000, 0x1000 }, + [MICROCHIP_PFSOC_WDOG0] =3D { 0x20001000, 0x1000 }, + [MICROCHIP_PFSOC_SYSREG] =3D { 0x20002000, 0x2000 }, + [MICROCHIP_PFSOC_AXISW] =3D { 0x20004000, 0x1000 }, + [MICROCHIP_PFSOC_MPUCFG] =3D { 0x20005000, 0x1000 }, + [MICROCHIP_PFSOC_FMETER] =3D { 0x20006000, 0x1000 }, + [MICROCHIP_PFSOC_DDR_SGMII_PHY] =3D { 0x20007000, 0x1000 }, + [MICROCHIP_PFSOC_EMMC_SD] =3D { 0x20008000, 0x1000 }, + [MICROCHIP_PFSOC_DDR_CFG] =3D { 0x20080000, 0x40000 }, + [MICROCHIP_PFSOC_MMUART1] =3D { 0x20100000, 0x1000 }, + [MICROCHIP_PFSOC_MMUART2] =3D { 0x20102000, 0x1000 }, + [MICROCHIP_PFSOC_MMUART3] =3D { 0x20104000, 0x1000 }, + [MICROCHIP_PFSOC_MMUART4] =3D { 0x20106000, 0x1000 }, + [MICROCHIP_PFSOC_WDOG1] =3D { 0x20101000, 0x1000 }, + [MICROCHIP_PFSOC_WDOG2] =3D { 0x20103000, 0x1000 }, + [MICROCHIP_PFSOC_WDOG3] =3D { 0x20105000, 0x1000 }, + [MICROCHIP_PFSOC_WDOG4] =3D { 0x20106000, 0x1000 }, + [MICROCHIP_PFSOC_SPI0] =3D { 0x20108000, 0x1000 }, + [MICROCHIP_PFSOC_SPI1] =3D { 0x20109000, 0x1000 }, + [MICROCHIP_PFSOC_I2C0] =3D { 0x2010a000, 0x1000 }, + [MICROCHIP_PFSOC_I2C1] =3D { 0x2010b000, 0x1000 }, + [MICROCHIP_PFSOC_CAN0] =3D { 0x2010c000, 0x1000 }, + [MICROCHIP_PFSOC_CAN1] =3D { 0x2010d000, 0x1000 }, + [MICROCHIP_PFSOC_GEM0] =3D { 0x20110000, 0x2000 }, + [MICROCHIP_PFSOC_GEM1] =3D { 0x20112000, 0x2000 }, + [MICROCHIP_PFSOC_GPIO0] =3D { 0x20120000, 0x1000 }, + [MICROCHIP_PFSOC_GPIO1] =3D { 0x20121000, 0x1000 }, + [MICROCHIP_PFSOC_GPIO2] =3D { 0x20122000, 0x1000 }, + [MICROCHIP_PFSOC_RTC] =3D { 0x20124000, 0x1000 }, + [MICROCHIP_PFSOC_ENVM_CFG] =3D { 0x20200000, 0x1000 }, + [MICROCHIP_PFSOC_ENVM_DATA] =3D { 0x20220000, 0x20000 }, + [MICROCHIP_PFSOC_USB] =3D { 0x20201000, 0x1000 }, + [MICROCHIP_PFSOC_QSPI_XIP] =3D { 0x21000000, 0x1000000 }, + [MICROCHIP_PFSOC_IOSCB] =3D { 0x30000000, 0x10000000 }, + [MICROCHIP_PFSOC_FABRIC_FIC0] =3D { 0x2000000000, 0x1000000000 }, + [MICROCHIP_PFSOC_FABRIC_FIC1] =3D { 0x3000000000, 0x1000000000 }, + [MICROCHIP_PFSOC_FABRIC_FIC3] =3D { 0x40000000, 0x20000000 }, + [MICROCHIP_PFSOC_DRAM_LO] =3D { 0x80000000, 0x40000000 }, + [MICROCHIP_PFSOC_DRAM_LO_ALIAS] =3D { 0xc0000000, 0x40000000 }, + [MICROCHIP_PFSOC_DRAM_HI] =3D { 0x1000000000, 0x0 }, + [MICROCHIP_PFSOC_DRAM_HI_ALIAS] =3D { 0x1400000000, 0x0 }, + }; =20 static void microchip_pfsoc_soc_instance_init(Object *obj) @@ -461,6 +464,14 @@ static void microchip_pfsoc_soc_realize(DeviceState *d= ev, Error **errp) create_unimplemented_device("microchip.pfsoc.fabricfic3", memmap[MICROCHIP_PFSOC_FABRIC_FIC3].base, memmap[MICROCHIP_PFSOC_FABRIC_FIC3].size); + /* FPGA Fabric */ + create_unimplemented_device("microchip.pfsoc.fabricfic0", + memmap[MICROCHIP_PFSOC_FABRIC_FIC0].base, + memmap[MICROCHIP_PFSOC_FABRIC_FIC0].size); + /* FPGA Fabric */ + create_unimplemented_device("microchip.pfsoc.fabricfic1", + memmap[MICROCHIP_PFSOC_FABRIC_FIC1].base, + memmap[MICROCHIP_PFSOC_FABRIC_FIC1].size); =20 /* QSPI Flash */ memory_region_init_rom(qspi_xip_mem, OBJECT(dev), --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416778718297.7986085641867; Sun, 18 Dec 2022 18:26:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jj-00019Q-Bp; Sun, 18 Dec 2022 21:18:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jh-00016T-FZ for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:37 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jf-00015O-2J for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:37 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:08 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:40 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:08 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jw0HQRz1Rwt8 for ; Sun, 18 Dec 2022 18:18:08 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id RJmianavWH-t for ; Sun, 18 Dec 2022 18:18:07 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Js6MmNz1RvLy; Sun, 18 Dec 2022 18:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416314; x=1702952314; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QjIke9qrZ9cvn5GeMe573On+qIo4TLWOFmWcJlPWex8=; b=L3KmY5SXDSYx+LPbOBcoK+v3c2oO7n94kv1gcmLXiXXsN6fxp/gx1Ftj X14cBY/K4zEg3erGFFJpuE/KzYi/QdU1ATjaVNVedH7JOxgIBxOFgdZro U3IHPqCl1bCdscfghYNZCc7nyS0NSP/GsH5/6iTrlhehTIIZOn3MpMcIH +n15FVJtqDlC6e9OnVnPY8RYeb6bkPtBYssg4ajoEe83pqNy9+zMT7mE0 pgebudhxwKLO5v9b9GL/rsDy8+G3rQ8okyPjkTxVP6wpYVPJBGYfCa4Cj 9XuUcSkp7w90WrSDLB0l9w0sF30w+CrRKqUyLIkGDoH1LqkRONLMuBS+d g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199364" IronPort-SDR: 3+reDhwVXm1p/pjvLDR+IeI5bez639d12i8yHEL0c6+2yEw0KMIeD7a/bIkxUAd+n27ziY1qSc y7S0IIvhptKPpxqs3Tc9+utvoEULYvtuaaY0G+b+eaLnsNX+qmSiVjNBrP6x0lSLYLXm3Hs+RU z8RAa/6pb/TVzO+pqx68pn7GDQQ0bV0Rksw8l6i0R8eT1XjMmWa6I9k8WGdxeszPL8YuBF82TJ 29KmF92y7f5LTKJrjX6mQW4EX0ngYtDN+GJJVKmpbJOS1C367OgmIvXZmxGVOGGQyWAi9lcspx ZWk= IronPort-SDR: qAtPDe24XbXNHOtuHBy2rknIfYw9mt/57DWRdBRenjna+k0hBOEhuPQ7PsnaT2j4TQMLfY626T CZ6umG7bw3PEiDRC46UeQm7vFoQIPuBj7hBfnxsO24VPD075neYSxAUgbu8M4ywKmsq77LxzGZ OBgC+0sETnMQZdUqAGskB/60qVL1A4QzZhj41ptotWe1ACLgT9mAm4iGn4xCoOb/iIz9wcdcts 9nsbmehm7PEHEfkqpTuzdaS/Cp1rOB1CBmnxMxnI65dFva0RJqxmQW6Ilm3B3iemwp3x5oAjLE 1f0= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416287; x=1674008288; bh=QjIke9q rZ9cvn5GeMe573On+qIo4TLWOFmWcJlPWex8=; b=WrgRD7PyZ3UP2o/FbgUq2on Lk1bLZv7dcuQ7/9kE0rUkkrQyV/mnP44jnHEFoMCM01DVxbQ7vOOEM17PwEdBjRs ETgEIQ+nWNYQjDClKT2WAtzpKlZnv2MsUoYu70Xhml0ClQ4xHiWTTxzZeHFquaQx 1pbviEc1WKwof0S+DLCjOqSO5lzaLGrnKGNSdrkqWjbtnlxIoSgK/uBYtEe+ubZp BA5LBFluktYuzwR7VOT+oPMdLbpCMTQfDalTfgleMY2l7wYkxnWhkBNJjnE6ojKZ Xcxq2pZrEQcBPYT+HRi7YPYjzzyfjJwNfM+izO7SGg69m0uhNyCsbEm24slxGqA= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Conor Dooley , Alistair Francis Subject: [PULL 23/45] hw/{misc, riscv}: pfsoc: add system controller as unimplemented Date: Mon, 19 Dec 2022 12:16:41 +1000 Message-Id: <20221219021703.20473-24-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416779191100001 Content-Type: text/plain; charset="utf-8" From: Conor Dooley The system controller on PolarFire SoC is access via a mailbox. The control registers for this mailbox lie in the "IOSCB" region & the interrupt is cleared via write to the "SYSREG" region. It also has a QSPI controller, usually connected to a flash chip, that is used for storing FPGA bitstreams and used for In-Application Programming (IAP). Linux has an implementation of the system controller, through which the hwrng is accessed, leading to load/store access faults. Add the QSPI as unimplemented and a very basic (effectively unimplemented) version of the system controller's mailbox. Rather than purely marking the regions as unimplemented, service the mailbox requests by reporting failures and raising the interrupt so a guest can better handle the lack of support. Signed-off-by: Conor Dooley Acked-by: Alistair Francis Message-Id: <20221117225518.4102575-4-conor@kernel.org> Signed-off-by: Alistair Francis --- include/hw/misc/mchp_pfsoc_ioscb.h | 3 ++ include/hw/misc/mchp_pfsoc_sysreg.h | 1 + include/hw/riscv/microchip_pfsoc.h | 1 + hw/misc/mchp_pfsoc_ioscb.c | 72 ++++++++++++++++++++++++++++- hw/misc/mchp_pfsoc_sysreg.c | 18 ++++++-- hw/riscv/microchip_pfsoc.c | 6 +++ 6 files changed, 95 insertions(+), 6 deletions(-) diff --git a/include/hw/misc/mchp_pfsoc_ioscb.h b/include/hw/misc/mchp_pfso= c_ioscb.h index 687b213742..a1104862c8 100644 --- a/include/hw/misc/mchp_pfsoc_ioscb.h +++ b/include/hw/misc/mchp_pfsoc_ioscb.h @@ -29,6 +29,8 @@ typedef struct MchpPfSoCIoscbState { MemoryRegion lane01; MemoryRegion lane23; MemoryRegion ctrl; + MemoryRegion qspixip; + MemoryRegion mailbox; MemoryRegion cfg; MemoryRegion ccc; MemoryRegion pll_mss; @@ -41,6 +43,7 @@ typedef struct MchpPfSoCIoscbState { MemoryRegion cfm_sgmii; MemoryRegion bc_sgmii; MemoryRegion io_calib_sgmii; + qemu_irq irq; } MchpPfSoCIoscbState; =20 #define TYPE_MCHP_PFSOC_IOSCB "mchp.pfsoc.ioscb" diff --git a/include/hw/misc/mchp_pfsoc_sysreg.h b/include/hw/misc/mchp_pfs= oc_sysreg.h index 546ba68f6a..3cebe40ea9 100644 --- a/include/hw/misc/mchp_pfsoc_sysreg.h +++ b/include/hw/misc/mchp_pfsoc_sysreg.h @@ -28,6 +28,7 @@ typedef struct MchpPfSoCSysregState { SysBusDevice parent; MemoryRegion sysreg; + qemu_irq irq; } MchpPfSoCSysregState; =20 #define TYPE_MCHP_PFSOC_SYSREG "mchp.pfsoc.sysreg" diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchi= p_pfsoc.h index 7e7950dd36..69a686b54a 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -147,6 +147,7 @@ enum { MICROCHIP_PFSOC_MMUART2_IRQ =3D 92, MICROCHIP_PFSOC_MMUART3_IRQ =3D 93, MICROCHIP_PFSOC_MMUART4_IRQ =3D 94, + MICROCHIP_PFSOC_MAILBOX_IRQ =3D 96, }; =20 #define MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT 1 diff --git a/hw/misc/mchp_pfsoc_ioscb.c b/hw/misc/mchp_pfsoc_ioscb.c index f976e42f72..a71d134295 100644 --- a/hw/misc/mchp_pfsoc_ioscb.c +++ b/hw/misc/mchp_pfsoc_ioscb.c @@ -24,6 +24,7 @@ #include "qemu/bitops.h" #include "qemu/log.h" #include "qapi/error.h" +#include "hw/irq.h" #include "hw/sysbus.h" #include "hw/misc/mchp_pfsoc_ioscb.h" =20 @@ -34,6 +35,9 @@ #define IOSCB_WHOLE_REG_SIZE 0x10000000 #define IOSCB_SUBMOD_REG_SIZE 0x1000 #define IOSCB_CCC_REG_SIZE 0x2000000 +#define IOSCB_CTRL_REG_SIZE 0x800 +#define IOSCB_QSPIXIP_REG_SIZE 0x200 + =20 /* * There are many sub-modules in the IOSCB module. @@ -45,6 +49,8 @@ #define IOSCB_LANE01_BASE 0x06500000 #define IOSCB_LANE23_BASE 0x06510000 #define IOSCB_CTRL_BASE 0x07020000 +#define IOSCB_QSPIXIP_BASE 0x07020100 +#define IOSCB_MAILBOX_BASE 0x07020800 #define IOSCB_CFG_BASE 0x07080000 #define IOSCB_CCC_BASE 0x08000000 #define IOSCB_PLL_MSS_BASE 0x0E001000 @@ -143,6 +149,58 @@ static const MemoryRegionOps mchp_pfsoc_io_calib_ddr_o= ps =3D { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 +#define SERVICES_CR 0x50 +#define SERVICES_SR 0x54 +#define SERVICES_STATUS_SHIFT 16 + +static uint64_t mchp_pfsoc_ctrl_read(void *opaque, hwaddr offset, + unsigned size) +{ + uint32_t val =3D 0; + + switch (offset) { + case SERVICES_SR: + /* + * Although some services have no error codes, most do. All servic= es + * that do implement errors, begin their error codes at 1. Treat a= ll + * service requests as failures & return 1. + * See the "PolarFire=C2=AE FPGA and PolarFire SoC FPGA System Ser= vices" + * user guide for more information on service error codes. + */ + val =3D 1u << SERVICES_STATUS_SHIFT; + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read " + "(size %d, offset 0x%" HWADDR_PRIx ")\n", + __func__, size, offset); + } + + return val; +} + +static void mchp_pfsoc_ctrl_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ + MchpPfSoCIoscbState *s =3D opaque; + + switch (offset) { + case SERVICES_CR: + qemu_irq_raise(s->irq); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " + "(size %d, value 0x%" PRIx64 + ", offset 0x%" HWADDR_PRIx ")\n", + __func__, size, value, offset); + } +} + +static const MemoryRegionOps mchp_pfsoc_ctrl_ops =3D { + .read =3D mchp_pfsoc_ctrl_read, + .write =3D mchp_pfsoc_ctrl_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, +}; + static void mchp_pfsoc_ioscb_realize(DeviceState *dev, Error **errp) { MchpPfSoCIoscbState *s =3D MCHP_PFSOC_IOSCB(dev); @@ -162,10 +220,18 @@ static void mchp_pfsoc_ioscb_realize(DeviceState *dev= , Error **errp) "mchp.pfsoc.ioscb.lane23", IOSCB_SUBMOD_REG_SIZE= ); memory_region_add_subregion(&s->container, IOSCB_LANE23_BASE, &s->lane= 23); =20 - memory_region_init_io(&s->ctrl, OBJECT(s), &mchp_pfsoc_dummy_ops, s, - "mchp.pfsoc.ioscb.ctrl", IOSCB_SUBMOD_REG_SIZE); + memory_region_init_io(&s->ctrl, OBJECT(s), &mchp_pfsoc_ctrl_ops, s, + "mchp.pfsoc.ioscb.ctrl", IOSCB_CTRL_REG_SIZE); memory_region_add_subregion(&s->container, IOSCB_CTRL_BASE, &s->ctrl); =20 + memory_region_init_io(&s->qspixip, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.qspixip", IOSCB_QSPIXIP_REG_SI= ZE); + memory_region_add_subregion(&s->container, IOSCB_QSPIXIP_BASE, &s->qsp= ixip); + + memory_region_init_io(&s->mailbox, OBJECT(s), &mchp_pfsoc_dummy_ops, s, + "mchp.pfsoc.ioscb.mailbox", IOSCB_SUBMOD_REG_SIZ= E); + memory_region_add_subregion(&s->container, IOSCB_MAILBOX_BASE, &s->mai= lbox); + memory_region_init_io(&s->cfg, OBJECT(s), &mchp_pfsoc_dummy_ops, s, "mchp.pfsoc.ioscb.cfg", IOSCB_SUBMOD_REG_SIZE); memory_region_add_subregion(&s->container, IOSCB_CFG_BASE, &s->cfg); @@ -222,6 +288,8 @@ static void mchp_pfsoc_ioscb_realize(DeviceState *dev, = Error **errp) IOSCB_SUBMOD_REG_SIZE); memory_region_add_subregion(&s->container, IOSCB_IO_CALIB_SGMII_BASE, &s->io_calib_sgmii); + + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); } =20 static void mchp_pfsoc_ioscb_class_init(ObjectClass *klass, void *data) diff --git a/hw/misc/mchp_pfsoc_sysreg.c b/hw/misc/mchp_pfsoc_sysreg.c index 89571eded5..7876fe0c5b 100644 --- a/hw/misc/mchp_pfsoc_sysreg.c +++ b/hw/misc/mchp_pfsoc_sysreg.c @@ -24,10 +24,12 @@ #include "qemu/bitops.h" #include "qemu/log.h" #include "qapi/error.h" +#include "hw/irq.h" #include "hw/sysbus.h" #include "hw/misc/mchp_pfsoc_sysreg.h" =20 #define ENVM_CR 0xb8 +#define MESSAGE_INT 0x118c =20 static uint64_t mchp_pfsoc_sysreg_read(void *opaque, hwaddr offset, unsigned size) @@ -52,10 +54,17 @@ static uint64_t mchp_pfsoc_sysreg_read(void *opaque, hw= addr offset, static void mchp_pfsoc_sysreg_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { - qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " - "(size %d, value 0x%" PRIx64 - ", offset 0x%" HWADDR_PRIx ")\n", - __func__, size, value, offset); + MchpPfSoCSysregState *s =3D opaque; + switch (offset) { + case MESSAGE_INT: + qemu_irq_lower(s->irq); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write " + "(size %d, value 0x%" PRIx64 + ", offset 0x%" HWADDR_PRIx ")\n", + __func__, size, value, offset); + } } =20 static const MemoryRegionOps mchp_pfsoc_sysreg_ops =3D { @@ -73,6 +82,7 @@ static void mchp_pfsoc_sysreg_realize(DeviceState *dev, E= rror **errp) "mchp.pfsoc.sysreg", MCHP_PFSOC_SYSREG_REG_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->sysreg); + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); } =20 static void mchp_pfsoc_sysreg_class_init(ObjectClass *klass, void *data) diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 2a24e3437a..b10321b564 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -306,6 +306,9 @@ static void microchip_pfsoc_soc_realize(DeviceState *de= v, Error **errp) sysbus_realize(SYS_BUS_DEVICE(&s->sysreg), errp); sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysreg), 0, memmap[MICROCHIP_PFSOC_SYSREG].base); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->sysreg), 0, + qdev_get_gpio_in(DEVICE(s->plic), + MICROCHIP_PFSOC_MAILBOX_IRQ)); =20 /* AXISW */ create_unimplemented_device("microchip.pfsoc.axisw", @@ -459,6 +462,9 @@ static void microchip_pfsoc_soc_realize(DeviceState *de= v, Error **errp) sysbus_realize(SYS_BUS_DEVICE(&s->ioscb), errp); sysbus_mmio_map(SYS_BUS_DEVICE(&s->ioscb), 0, memmap[MICROCHIP_PFSOC_IOSCB].base); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->ioscb), 0, + qdev_get_gpio_in(DEVICE(s->plic), + MICROCHIP_PFSOC_MAILBOX_IRQ)); =20 /* FPGA Fabric */ create_unimplemented_device("microchip.pfsoc.fabricfic3", --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416340096793.7527421062745; Sun, 18 Dec 2022 18:19:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jo-0001KV-S7; Sun, 18 Dec 2022 21:18:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jn-0001Hn-45 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:43 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jl-00015X-Bo for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:42 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:10 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:42 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:10 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Jx6tFNz1RwqL for ; Sun, 18 Dec 2022 18:18:09 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pMTwTUpGWKvD for ; Sun, 18 Dec 2022 18:18:09 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Jv5JKsz1RvTp; Sun, 18 Dec 2022 18:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416321; x=1702952321; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lkr40dqOmoRlHb4uKWd/0UnkaNvhnwtWV+0/s7TpnTE=; b=aK3Nyub/Q3PVHzxLrhj/Qf/f+Dn2HUgr44kEITMty0U725qrBDwZaqSo LmxjhMozt805Cj4sQ+RVZe3IcyxFlWRm5uVrmYvBMR9gQLcFEm+c349qa +VxqVQ3D0GuH11/n7mHg1C/cc6/Xw5rkT2eyiHS1wZTnaBD0OyjPkB0SS Oor42u7vLs90CIRGoRZ94b6Gv94oqS/M7vlFDHV2ColdbusU3dhFI2Pw7 G/CmKcdn5CVfyz1MPD6wtE0AbiI5SjI9PJE40H2kRZD1iUL1lWayb7fn+ eY7RPasd1s6UAd9M5N3JQ69EsJTGRDISgG9+FaIJDTAvwQLxTUKneFhqU A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199367" IronPort-SDR: AaKvkI3gGAVPwL3Jm6/88E+9+N6uIQn3hEHiaFju56kNp1xdpcpkp3mgtzUDdMvKSXKrB/duay 8vACgDX6ZH189/WQTDTFBtAwtvjCtl2xe3OCHEvqyv8qtfX35iOwvzlLRlmck2onjlMPoNxWRl 9N6vLMVzbFgG4D2OnlW5pfwhzEAfiH1ZfY6jLjgdabn9GehiUYlmo/Q2jjSt5wagrQ4BZMyS6w s+yl19D1juqDF88E7bRLCDRv2cZfgXsFVnUJ4RaB3ELAjDOnLI4REkcvMo0de3HV/SfuE4qOSY kvw= IronPort-SDR: zY8UsQj28fNKyRIaIwsPI5gv/jxhriDwsZXfvXzuB7Fwg9bDEgzjIONd3oh3ok84K4BbOjRe76 +k7btxPIlb1lTF38Spvi+mNVYY1HyEVT1KtxMYKQyJ4vNMtnrasZ1tev1aUWETPhjETK4FElmM Rjkty2iWvzUW7xwHRJ8VNvtv4TTDGXxtfdaQXBR77FLYY+6M8oXTpX67rRneUz21k9boY+zSE0 DnmCzpUrjWvqP/flQQYt2B9VA1vqcBD4q3hLikKn8Z1L5il23Y7fHqTMmhKB0YJ9LbfIwrCNoc Vl8= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416289; x=1674008290; bh=lkr40dqOmoRlHb4uKW d/0UnkaNvhnwtWV+0/s7TpnTE=; b=Jx+9OJ3EYcHw0vlVR27hHzgLwV+hDbJOEH pm14Ed4ycp26tY9ZsXNTShlZlj125E5q+Ua9DeJX5sSfnd4rYYZ1IZB1/KmX3uNJ 7X0r6ykYugzAwxsvJD9l9W1z4EIQsMQEEidC8VwYBIwnEWiYvJPB/Q62vm47MMGB 3HvJsU3CTD+0cnevgO+/ZYtix9YPQAmMfBAeSqswZUFi0umnzwupaXCx+N2RT8bo 89qypD46sz5Y1V67GToqmav8LGIEyfc4W4CnsEOWyTJj6PmJTe+DUzLauYwGvRGE B9BNzFQLfrXwOiOvPz2doDngbA2gQ57XKlODyupAk3kPuuvNPCuA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jim Shu , Bin Meng , Alistair Francis Subject: [PULL 24/45] hw/intc: sifive_plic: fix out-of-bound access of source_priority array Date: Mon, 19 Dec 2022 12:16:42 +1000 Message-Id: <20221219021703.20473-25-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416342050100007 Content-Type: text/plain; charset="utf-8" From: Jim Shu If the number of interrupt is not multiple of 32, PLIC will have out-of-bound access to source_priority array. Compute the number of interrupt in the last word to avoid this out-of-bound access of array. Signed-off-by: Jim Shu Reviewed-by: Bin Meng Message-Id: <20221127165753.30533-1-jim.shu@sifive.com> Signed-off-by: Alistair Francis --- hw/intc/sifive_plic.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index b4949bef97..0c7696520d 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -78,6 +78,7 @@ static uint32_t sifive_plic_claimed(SiFivePLICState *plic= , uint32_t addrid) uint32_t max_irq =3D 0; uint32_t max_prio =3D plic->target_priority[addrid]; int i, j; + int num_irq_in_word =3D 32; =20 for (i =3D 0; i < plic->bitfield_words; i++) { uint32_t pending_enabled_not_claimed =3D @@ -88,7 +89,16 @@ static uint32_t sifive_plic_claimed(SiFivePLICState *pli= c, uint32_t addrid) continue; } =20 - for (j =3D 0; j < 32; j++) { + if (i =3D=3D (plic->bitfield_words - 1)) { + /* + * If plic->num_sources is not multiple of 32, num-of-irq in l= ast + * word is not 32. Compute the num-of-irq of last word to avoid + * out-of-bound access of source_priority array. + */ + num_irq_in_word =3D plic->num_sources - ((plic->bitfield_words= - 1) << 5); + } + + for (j =3D 0; j < num_irq_in_word; j++) { int irq =3D (i << 5) + j; uint32_t prio =3D plic->source_priority[irq]; int enabled =3D pending_enabled_not_claimed & (1 << j); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167141682977347.35844331467922; Sun, 18 Dec 2022 18:27:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75js-0001Vm-RX; Sun, 18 Dec 2022 21:18:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jr-0001TY-Qf for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:47 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jp-00017E-WF for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:47 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:12 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:45 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:12 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3K02Yb2z1Rwrq for ; Sun, 18 Dec 2022 18:18:12 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 073jZ2Nuh2SW for ; Sun, 18 Dec 2022 18:18:11 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Jy0WB0z1RvTp; Sun, 18 Dec 2022 18:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416325; x=1702952325; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CAdCSxJeKKq8tYmIBqs3LqQExUqaPNsJrRGHQLOgr7o=; b=fCNiqm+csuNE2iJWrLrSM8bgqIFTNEwpOe4yMa77nKOaVPSZCQ4N9slP cnBLG43VRqsolouPviToNFmcnsmc2sDPt4GzKRg6EG8ZWFCnpBL5hyj3k T4oovFu5yUDLzTqSXOKoChxEUvXBKkqSXSFOEQvehQunQdwkpy9s3HVV0 MsGzmYEwqS5Q1usAjXN+WRsJmQy0nr5tDkY2GozxuJchxxA92C6iPP6gJ y5yNZEeunxE0AYpQyVpT2unCrPRez+wDWCnvsOMg1a/vLKqc3oZEjxl2I rDhTwTMPmYprnqatKa99dxI0bvzlfcOe+ss/pt+eFY14UQHWmcg6pHIFz Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199379" IronPort-SDR: nJ1nLkowLbEyfzOxZOT6hjC9g/ZtyJkQkj3UShS8XdrrYN9feKI/fuNBxiqykiE/aHfQBIncVO S6ej1KrODpGwarpz/hO7QGhuhu7aWEIqQvLgm2IwTLPzSqRlNebFb258HxIbfx7XyuzuYh6ddV kFEq+URbxW7Hyul90pFMnFk2EUwv90vwevlpBkWYLXufpf2TR6Pkwij9o2sLB4D/sn2GsPhUVF t9QTZ5f2d0wG9S96ddHED8Fo5GznzkWOEe3SJL46viiBSzhPD0nKV0hi6c6h3svsfwuJ+1gA48 20k= IronPort-SDR: XiIq7EiJMov6FA6qd8vT1L/pVy9cHjcy7X5DPBMItdPz05ylaoTYWJOvBCR3JCBpM+nzDDTNPM Vl5zJQYYfk4zoT0Ri1DGcKGOlDjVjOPpXjWBkNmFTooLkdrdncFniJSCbNStxoJZwdjhBKvNNP sGN+cnz/DDFqrcFAhmAVvQnpKaULAv6z4v8mRpCwNjkpyDyyyD0Ih59aMGPLvfFgSCmmDCxW6A GJNuJF8bl+sNJdfhH1Kt+McrCddaYBlWwv+gcWAddvaERc5x7APWVsPVrXxRwBIe7dS4eCT9BM sNw= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416291; x=1674008292; bh=CAdCSxJeKKq8tYmIBq s3LqQExUqaPNsJrRGHQLOgr7o=; b=IIK20VZ0h8Oe+E3fJlXgbSTUMeowfOrmTD pmGo/0crOdfrSaeQrMLT6lP+x7+0eLbnlXQDQxLdTXugIdpNmNkIpWHEZbc/zWcd BsiT0wMnCXx1UkOGK4EvUqOSHWiASgSz2mkEqAL86JnPFSvBVzsmgblzI9yyECtQ EB1IINDPC9yaZiQU6Th6K3Y7FS4w1NCz8fkIUS7zOgm2jBFyG5uKQUR9/rKZ688s LYxOWDLflTI26ubKSG6vWb9KJ7F/WE0vFuklRM1sLJqv6Lp+4VyLaLjyoUfEUBp0 B1CfSG13LUJvYP2qQKcq2BdfEWP6JS6ICEInK9S+eomVpP+4l/Bw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Wilfred Mallawa , Alistair Francis Subject: [PULL 25/45] target/riscv: Fix mret exception cause when no pmp rule is configured Date: Mon, 19 Dec 2022 12:16:43 +1000 Message-Id: <20221219021703.20473-26-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416831434100003 Content-Type: text/plain; charset="utf-8" From: Bin Meng The priv spec v1.12 says: If no PMP entry matches an M-mode access, the access succeeds. If no PMP entry matches an S-mode or U-mode access, but at least one PMP entry is implemented, the access fails. Failed accesses generate an instruction, load, or store access-fault exception. At present the exception cause is set to 'illegal instruction' but should have been 'instruction access fault'. Fixes: d102f19a2085 ("target/riscv/pmp: Raise exception if no PMP entry is = configured") Signed-off-by: Bin Meng Reviewed-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221205065303.204095-1-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- target/riscv/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index 09f1f5185d..d7af7f056b 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -202,7 +202,7 @@ target_ulong helper_mret(CPURISCVState *env) =20 if (riscv_feature(env, RISCV_FEATURE_PMP) && !pmp_get_num_rules(env) && (prev_priv !=3D PRV_M)) { - riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC()); + riscv_raise_exception(env, RISCV_EXCP_INST_ACCESS_FAULT, GETPC()); } =20 target_ulong prev_virt =3D get_field(env->mstatus, MSTATUS_MPV); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416752903528.2014791119315; Sun, 18 Dec 2022 18:25:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75k0-0001cl-KX; Sun, 18 Dec 2022 21:18:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jt-0001Yw-Hm for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:54 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jr-00015O-PP for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:49 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:15 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:47 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:15 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3K271hvz1RwqL for ; Sun, 18 Dec 2022 18:18:14 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id L8KYwHybRHj6 for ; Sun, 18 Dec 2022 18:18:14 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3K036bgz1RvTp; Sun, 18 Dec 2022 18:18:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416327; x=1702952327; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jzu4w1v0TJpnBmXkZe8wqb1VN0yzrvZdJQ4Z2Lx9Dzs=; b=Z9LhlBR+YKhobnQzErt8/iaFtaVw5Qyog3BbO/JuSWNUd7EOIlWsdMq6 McMMRpW40Hh4djTXjuz2B159YPKPjWahuSGBXN5OJ1KtmWL/rYTG+sCxf ADfP1v0duHV/Pmp8uzbm6B/ImPuE6c7xGawB4LvlY3ioHU9isCsdt/2Fo VJSpIjofB69ElMDhRipLgkLJQmcERLMKO1t3SbaxhAd/dbS4khm1c1f/L ffn9K1GrZkyE9e2aB3oLUPhMw4EDmPRMrnma0q9yKJ0yq7mysv6z61ZXy 8rmDkWdkwWCvQ3gmUG+34+wg5wmuAVqcdZXHkByiz8eEEwkf+CuEe8Njj g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199386" IronPort-SDR: kRAwKT/4j+lJYrzgWhbN6jCRW+P925NxAEhcMjK+L/Y1n/8CVF8NKbKajHzNkjh7n0RtkXl2Xs I4v4OlviFVgaGMjdwsvbNMdQB6cYQnyN2mGmF2RWUXzNnD7BLZC358Tgk20dXeStNh3hoE7QOz cFLmoHhHFe35Ils1BFd3QjCEsfKxZYHF+Eas8YWj99L51K06v+cnXPSiowP7lyomXNIk1wBV1H HKIOPIBU3G1sx3Nv1QDUz74w5//g5SfPV4CHCrLiR9Wv23SezyadcaBPFIB+V02w+I47crx2Yy r1g= IronPort-SDR: j++HBdJz6mdCOC+GuJ2cUL4OsbvJGIWMFdoWrgrPUruT4ZoMcmgI4rxf7IHjSMFXSB+yGWM5ua QT0GVBnN4iqRjViGIgegLL9hUJ3uOzdqkk4qxSxmsb5/Q5ffkmypfDVyhw5nQXaZCX32Zl0xqe oz69V1yFd3wPCYcZkdopMiV86NcpJren8slW3J9EFhKUmE6KTOdj5jKRdpnp3/QCm2vWLs6QBS oMsX1H0L7ibFNXD7LJHWcdTcEwc9DKRRAP+Tmkj9GcIeS53W/e1l6iLns5wPBhZv9AditV1oOs mxk= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416294; x=1674008295; bh=Jzu4w1v 0TJpnBmXkZe8wqb1VN0yzrvZdJQ4Z2Lx9Dzs=; b=K4mvxcppjCK9Yl0hs/emQ5C qZo3AZAd4h7CtafXVRroqhKHLcHG+Cgqt6X47SsALGhKyl8TMEH++XaWLPH3BbyC rsJ3AY5rr15B+PSdpeW+JR/FZD0ipx/PTzHqIwAe77KByLkSMlmKsLPsKEDWkQTj 6vciSLRVI+ofpRIObah8Ec6M20My4lLTWoS/yJUuAbPAkOBFuBr1YvfPa6mEDU+p +zZfyWS75K9QYUlME5wj4dswWJp7rpBxYH4WEy3Cq9QLlbhGygPFBMK0Q+voaeCG rp9zmJ6ts98YNKVxrYY6ZLIlw0vwLg1PspBXi7y5G65cxeJsxiQeBbmRL1E4TBw= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , qemu-stable@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 26/45] target/riscv: Set pc_succ_insn for !rvc illegal insn Date: Mon, 19 Dec 2022 12:16:44 +1000 Message-Id: <20221219021703.20473-27-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416754995100006 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Failure to set pc_succ_insn may result in a TB covering zero bytes, which triggers an assert within the code generator. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1224 Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20221203175744.151365-1-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/translate.c | 12 ++++-------- tests/tcg/Makefile.target | 2 ++ tests/tcg/riscv64/Makefile.target | 5 +++++ tests/tcg/riscv64/test-noc.S | 32 +++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 tests/tcg/riscv64/test-noc.S diff --git a/target/riscv/translate.c b/target/riscv/translate.c index cd5eb25ee8..160aefc3df 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1096,14 +1096,10 @@ static void decode_opc(CPURISCVState *env, DisasCon= text *ctx, uint16_t opcode) ctx->virt_inst_excp =3D false; /* Check for compressed insn */ if (insn_len(opcode) =3D=3D 2) { - if (!has_ext(ctx, RVC)) { - gen_exception_illegal(ctx); - } else { - ctx->opcode =3D opcode; - ctx->pc_succ_insn =3D ctx->base.pc_next + 2; - if (decode_insn16(ctx, opcode)) { - return; - } + ctx->opcode =3D opcode; + ctx->pc_succ_insn =3D ctx->base.pc_next + 2; + if (has_ext(ctx, RVC) && decode_insn16(ctx, opcode)) { + return; } } else { uint32_t opcode32 =3D opcode; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 75257f2b29..14bc013181 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -117,6 +117,8 @@ endif =20 %: %.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) +%: %.S + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) else # For softmmu targets we include a different Makefile fragement as the # build options for bare programs are usually pretty different. They diff --git a/tests/tcg/riscv64/Makefile.target b/tests/tcg/riscv64/Makefile= .target index b5b89dfb0e..9973ba3b5f 100644 --- a/tests/tcg/riscv64/Makefile.target +++ b/tests/tcg/riscv64/Makefile.target @@ -4,3 +4,8 @@ VPATH +=3D $(SRC_PATH)/tests/tcg/riscv64 TESTS +=3D test-div TESTS +=3D noexec + +# Disable compressed instructions for test-noc +TESTS +=3D test-noc +test-noc: LDFLAGS =3D -nostdlib -static +run-test-noc: QEMU_OPTS +=3D -cpu rv64,c=3Dfalse diff --git a/tests/tcg/riscv64/test-noc.S b/tests/tcg/riscv64/test-noc.S new file mode 100644 index 0000000000..e29d60c8b3 --- /dev/null +++ b/tests/tcg/riscv64/test-noc.S @@ -0,0 +1,32 @@ +#include + + .text + .globl _start +_start: + .option norvc + li a0, 4 /* SIGILL */ + la a1, sa + li a2, 0 + li a3, 8 + li a7, __NR_rt_sigaction + scall + + .option rvc + li a0, 1 + j exit + .option norvc + +pass: + li a0, 0 +exit: + li a7, __NR_exit + scall + + .data + /* struct kernel_sigaction sa =3D { .sa_handler =3D pass }; */ + .type sa, @object + .size sa, 32 +sa: + .dword pass + .zero 24 + --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416330146372.95492344729496; Sun, 18 Dec 2022 18:18:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jT-0000MY-Nx; Sun, 18 Dec 2022 21:18:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jS-0000Jw-Ou for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:22 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jQ-00019F-NM for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:22 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:16 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:33 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:17 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3K46Sddz1RvTr for ; Sun, 18 Dec 2022 18:18:16 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id jRVtmDC6ODMx for ; Sun, 18 Dec 2022 18:18:16 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3K26zmMz1RvLy; Sun, 18 Dec 2022 18:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416300; x=1702952300; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SvE69aK7bAVRqVg7LOCIAVD1/g2aMYl/gyVgZLYkuxo=; b=QuvuhqWM0c9s5JLGeOaoHyW/+H/GJ3dYgZvEEPJPVfbmrfl49vggkEEM ByNpdl3IgWfhsoywEDbmtuWTwEyGfWNilk4xI3B3RflsxGxbZqujrYQ18 Ai2t4GEg/RfMFycr7iXanI/i7GXgA3JvDvR+Ft0piPJ0w1sJzrIhjKavW x2e195NKFtZsj4+L5VVNAHQRailPM7nEEiscVgs0jynl7qM+WSNrJQWre +F9ogpWMfm7BBXrklemgyvplOQN0Hy8e/opHBl9e/AK6GSHu/v2Q1p2NS pvVC9yI2vRyBvfxtV8CF4Ljb83UztnnRmXK944xLirG1Voj3DZzFDKq+n A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056793" IronPort-SDR: 2B8lmyRm2swy49srkEG9RVQfpy5KlKCGh6+ZrzEan8/lGTPPaMo1FBvqnQ0ZQ37L1ueJUPBjaa ZdvxQki2sgCX1i91mObfDWvNU4AG5MbWs+YbIjnKl/OrZwcmxmAkUPeNbq7sfEynhPCaRqDnLa 52Ior/8ptf7cchEIOTtMamrONIuOl8zptVKv86O4M//Nt3Kha08DuofL4uEpRHpnXC6x9Yd9Vj GsUXGbYyrE5NAIGmmwRIrGvYfA6KVuIcPec5f57lUWBpLSIXYI0JwofXMDP043G/wKfR4IjL2D kos= IronPort-SDR: rGh2VywX4y/N6+w118sUGRNX585T4caY8P1PziB6fbOhBi5hjTTnHAj2Dmidq6A4ATV1YK1+5z 5/D8ZVdVwFrlIM3oLTWWjnOO2mxp/gntxCY6uA5yT4+XBfBhEpOIjrZv3Gc+RFa/qVhFes+sZJ 9QeNa2TMsV6fufSpBAsq55TNTcr5yg7HF9sy544j9sMul7m6kWEUy+M/RHaFHaZDze2Wc5q5ry xCvURZKt4jjuuvfJUum/TdBl8YbtjpM5hBrhfdD7LQdBDoBzUN1a/ugexAfLgGb3AzsCqHXEz/ b+s= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416296; x=1674008297; bh=SvE69aK7bAVRqVg7LO CIAVD1/g2aMYl/gyVgZLYkuxo=; b=C+MoE9qJP96rPt8pvmNvlEETmd658lTPbS ovSK4YJlGV3NwIqiPoO+Aedz8481FX0UIDqqNXss5ppkDxaCZH/L7FDVp8gG3J4O aqztmMQQFIEz0OAvbuCf5vMeAVIA0El9FGZ5MfdX6toSPpCvlWFT5s7qNis8uu4T MmVfSXKmcfCHAKrlbzHUxkPby6PYAz+Oi1KaHivuLR+nCywHTvWc7pvBR2d/hT1u Jpo20WqizQLIClJVFdlJRZWVyhG1/CI7/8EmAen/i/I9EoZzDJUTzdp8whoDabyi EiqYURtFTtg3RDYpki2KJW+1Ie4KCFPBJYBcYwrDL6gNowbEjAww== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis Subject: [PULL 27/45] target/riscv: Simplify helper_sret() a little bit Date: Mon, 19 Dec 2022 12:16:45 +1000 Message-Id: <20221219021703.20473-28-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416332452100002 Content-Type: text/plain; charset="utf-8" From: Bin Meng There are 2 paths in helper_sret() and the same mstatus update codes are replicated. Extract the common parts to simplify it a little bit. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <20221207090037.281452-1-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- target/riscv/op_helper.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index d7af7f056b..a047d38152 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -149,21 +149,21 @@ target_ulong helper_sret(CPURISCVState *env) } =20 mstatus =3D env->mstatus; + prev_priv =3D get_field(mstatus, MSTATUS_SPP); + mstatus =3D set_field(mstatus, MSTATUS_SIE, + get_field(mstatus, MSTATUS_SPIE)); + mstatus =3D set_field(mstatus, MSTATUS_SPIE, 1); + mstatus =3D set_field(mstatus, MSTATUS_SPP, PRV_U); + env->mstatus =3D mstatus; =20 if (riscv_has_ext(env, RVH) && !riscv_cpu_virt_enabled(env)) { /* We support Hypervisor extensions and virtulisation is disabled = */ target_ulong hstatus =3D env->hstatus; =20 - prev_priv =3D get_field(mstatus, MSTATUS_SPP); prev_virt =3D get_field(hstatus, HSTATUS_SPV); =20 hstatus =3D set_field(hstatus, HSTATUS_SPV, 0); - mstatus =3D set_field(mstatus, MSTATUS_SPP, 0); - mstatus =3D set_field(mstatus, SSTATUS_SIE, - get_field(mstatus, SSTATUS_SPIE)); - mstatus =3D set_field(mstatus, SSTATUS_SPIE, 1); =20 - env->mstatus =3D mstatus; env->hstatus =3D hstatus; =20 if (prev_virt) { @@ -171,14 +171,6 @@ target_ulong helper_sret(CPURISCVState *env) } =20 riscv_cpu_set_virt_enabled(env, prev_virt); - } else { - prev_priv =3D get_field(mstatus, MSTATUS_SPP); - - mstatus =3D set_field(mstatus, MSTATUS_SIE, - get_field(mstatus, MSTATUS_SPIE)); - mstatus =3D set_field(mstatus, MSTATUS_SPIE, 1); - mstatus =3D set_field(mstatus, MSTATUS_SPP, PRV_U); - env->mstatus =3D mstatus; } =20 riscv_cpu_set_mode(env, prev_priv); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416902737813.3243909496202; Sun, 18 Dec 2022 18:28:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jV-0000R2-E6; Sun, 18 Dec 2022 21:18:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jT-0000MR-KN for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:23 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jR-000190-T0 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:23 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:19 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:35 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:19 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3K70cVQz1Rwrq for ; Sun, 18 Dec 2022 18:18:19 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 2owNuqpFpkIa for ; Sun, 18 Dec 2022 18:18:18 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3K51Nx3z1RvLy; Sun, 18 Dec 2022 18:18:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416301; x=1702952301; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DKKYFsAWy3mQQVNV1VM5SmTNOYbIwJL0N/VaovONcxU=; b=FD+gs3BGTNNDS5kZM6PBpd+kDx8YYQXXCSnyJQbPA/HtvexhbXUOzYRZ SKGQKQOWXn1mbuHfNJmnpb7N5omUkMwxP4ta7jZOHFDLmM2SlwNf/rsjA 0pX4ebrB3D69HbEjjalBTkksrhByXW5MA96S8TqPxJLyWYoDScu4/GVIl yp/oIU4/SXTTWCuoqaC+Dype+n26LZwOCvNcLzo131aDyVj95NYuVfPqE TUlcMs+gab2c1LU6feM4Cvl7g+Pd8cr1pC4AT0A4+6ugIEkYdCLA1rsSx KSq3IOsfNlctvNCnxpzAwweBrwFW03NieSt71x4OyIn9YUMFIpRiC6dNI Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056794" IronPort-SDR: jviNUASFz2HAF9K7yaIg1ajmh1QS8Wy+dZVyYFMlxnIV/EHRE9IfqMRlqhQkiaIzma5VueJhzD Auz3D3l0quc/eEqk6smDh6FVJJasi+rT8p6Vt1b4YEsEXjFKVIIq22cnW9PJONViM33fYZQmAv HBwQy5wRblUqzscZC+XMoBgu0YWhxybge3gEizALkgwAPFquCV45HZLr3r+a7cr8IAclwGe58O jLi7M64wa1AMyVg/hkNOYbFAHjMPQWZlCq8RUqYvcgIVCt9S5S/iLC9ip1Owy+OY9fi9elDRhw U1U= IronPort-SDR: OavyPQ/FkitX36T8zL5xD+P0yqinEEn9YQ3iU9Oap0r0Te6PfC3/R/b1CJ4WaRMVOfzzlLEbnf N4sJU5hVKJuXqJPFCdS9uSqqWZfEsCLNQdf+ODjFZiQrXSLlwcdHZigdQ0t6ADF/LVEaOqVze/ gaqFpLnOGZnwZCwNImg94LNhq6YsmTkV3H+0eZL6SXNCcr1U2fKy2TspgKykgnE0T9g8seNENB lR1WAltjgu1kgEOYTuj++64/8+MsgczATSPIC0bQN575wimBW8BAJoJl5HVPFaGPJM6Cxepcmh PIA= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416298; x=1674008299; bh=DKKYFsAWy3mQQVNV1V M5SmTNOYbIwJL0N/VaovONcxU=; b=N5LuElXHgKiMdGpiKcYe5en4NN6iwT+7p5 O7nCyrVSfPjGnLOIKBzu200WJorwHicuKCE/mtb7GVg1B6SyQdoButM5od6OP5mZ nKu6cBl0ewDm1LgqjmQuuX+4tNMToexLUgW2ftdlKlM0KVWYVAs9omCeikLZcbvf ur0+YBwanlVOUwsaWR3/pXo4wt4LVFXDViF3dbxaq0gobuGs+Bv8bv8oeUq0WRkJ 4Lj3XLKlTT/twDTyCx+YmVerLz7Yw0T2+EzDMbjRVq3ll3x6499haTYtbEm/jrHz nReYIvz5BMQAMrNKLnO/X6Lfjiwb5M5VgNMBehF4nM1zRCkaRccQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis Subject: [PULL 28/45] target/riscv: Clear mstatus.MPRV when leaving M-mode for priv spec 1.12+ Date: Mon, 19 Dec 2022 12:16:46 +1000 Message-Id: <20221219021703.20473-29-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416903950100005 Content-Type: text/plain; charset="utf-8" From: Bin Meng Since priv spec v1.12, MRET and SRET now clear mstatus.MPRV when leaving M-mode. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <20221207090037.281452-2-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- target/riscv/op_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index a047d38152..878bcb03b8 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -154,6 +154,9 @@ target_ulong helper_sret(CPURISCVState *env) get_field(mstatus, MSTATUS_SPIE)); mstatus =3D set_field(mstatus, MSTATUS_SPIE, 1); mstatus =3D set_field(mstatus, MSTATUS_SPP, PRV_U); + if (env->priv_ver >=3D PRIV_VERSION_1_12_0) { + mstatus =3D set_field(mstatus, MSTATUS_MPRV, 0); + } env->mstatus =3D mstatus; =20 if (riscv_has_ext(env, RVH) && !riscv_cpu_virt_enabled(env)) { @@ -203,6 +206,9 @@ target_ulong helper_mret(CPURISCVState *env) mstatus =3D set_field(mstatus, MSTATUS_MPIE, 1); mstatus =3D set_field(mstatus, MSTATUS_MPP, PRV_U); mstatus =3D set_field(mstatus, MSTATUS_MPV, 0); + if ((env->priv_ver >=3D PRIV_VERSION_1_12_0) && (prev_priv !=3D PRV_M)= ) { + mstatus =3D set_field(mstatus, MSTATUS_MPRV, 0); + } env->mstatus =3D mstatus; riscv_cpu_set_mode(env, prev_priv); =20 --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671417106851164.98610195768174; Sun, 18 Dec 2022 18:31:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jZ-0000RR-Gu; Sun, 18 Dec 2022 21:18:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jV-0000QP-2g for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:25 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jT-00019F-2M for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:24 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:21 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:38 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:22 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3K95SgLz1Rwrq for ; Sun, 18 Dec 2022 18:18:21 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wY0k28OUQyCQ for ; Sun, 18 Dec 2022 18:18:20 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3K71qDvz1RvLy; Sun, 18 Dec 2022 18:18:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416302; x=1702952302; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TZ8ZSQ/6EJPt3aV5ej9Xbmbe3XTCl5tkWbAwM/q28aQ=; b=au5RXVeHnwuqtAZkSE/cPuiA7Uv9q+D2F6aZ6Y7s4+rdhp0ibGrgLumA p8RssDX72HgfLjkQuHMACu4IdAJj3idwK/Ar0qv4dC0RvEux19RuH7N+U 8Ixfm0eL8/Y3MwN5TvTDtx2NuQQGfjMJWZil/oMS4TxyQeqKZxXbCgyFP ETK9GToJnsEOIPr9fFAVug/ZeqPp6VXLCo9aJfjg+Tcrklq95UW4szE0j Tnb9sUT9wQQLTUYsTZgy6lE5euQadb+TYyJxc1E/edvvdonnJ24CD6k5h e24QzBSaw8fIWFqSWyZqPuoX5Pz4z4IK5a2N3UGbMnsISAGjZGRJbrrZD g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056798" IronPort-SDR: H5G9/SFTacBBbk/Qf55dmS8AhUn98Yzem7pK8A/s7DO9HydsJrc7F3k1n4ZODu4bwhwFjiw38I 0aTmk70dKJWBjBzqESn3Xc8YcF7I+oGX0wSkK+FycDczVaVAXz5mIjg54ytxtkp0E42VRtVk+P a4x+xSx8k/b+xv+1sVeNbMZnqRwS2HJBop/2zqPdhGfIWETQbk8jkDJhb/lXNxWFAzP/wM94cc jKsGfPzNvziNebYK/0M0DlubZ71iXd0g2H6o/Lo5QRW4t/OtwiPreF9QO8l/jYj89rInEOe2XW eQY= IronPort-SDR: OnCPZDvpcXQJasB6ZIRpwWtbSuH0iPLt5U5mPiwaTnynuciD4TTxoNNamq8rC/6mCsHJa1BYsV vrMdaMdQN9n5ox2dJcvaIknkk71ok1WjQkbjKOymhpbF2doh+OeFhDW5pev/xg+Aa781YcaK+i fX0Ad2NlMmvBKbxNRHNLmsu9Uom170Oh42ICpcncjVyMydlQ9EP3Ei1yhY7pUFR2H4n4rw28X0 7eKmSUhz3LellKcgpfg+/qAbuWRIc1o8T7RO94hOQpSPnPl3WdoGeVyFPQAzaB78DYv8eSmTEt hKM= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416300; x=1674008301; bh=TZ8ZSQ/ 6EJPt3aV5ej9Xbmbe3XTCl5tkWbAwM/q28aQ=; b=Rz9AOWJW0wbVt0uahfnOpjV cTj9WAOIqgVBbhqO/qF6Rg32mprh2nFdSYbFubyRJUF0aNm96OIY0mt64Kc0Vvyn BN3pbhBlBQcvUswKa++BtoNECSDAFPKH095Q41MhifGcaAHD7GVPPQdEKUmwb0GI 6rsSAbpckVblXVhPXYOvmo4AbNOl/awPHjVI/fOtJh3uiMMIDdTaYCpCqnweNYpp Og4vym9zulaWxGyg+R1W65SZqXYsLUS8r497A9mKz4Cj3XV1DWBTJaxtLUJP1eLT 9prrjmukXbWV2Ncz5rmR4rasl6nE8t/9M8In6rArBLqu3jbENgDS7DUGrhKdYvg= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Christoph Muellner , Alistair Francis Subject: [PULL 29/45] RISC-V: Add Zawrs ISA extension support Date: Mon, 19 Dec 2022 12:16:47 +1000 Message-Id: <20221219021703.20473-30-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671417108667100002 Content-Type: text/plain; charset="utf-8" From: Christoph Muellner This patch adds support for the Zawrs ISA extension. Given the current (incomplete) implementation of reservation sets there seems to be no way to provide a full emulation of the WRS instruction (wake on reservation set invalidation or timeout or interrupt). Therefore, we just exit the TB and return to the main loop. The specification can be found here: https://github.com/riscv/riscv-zawrs/blob/main/zawrs.adoc Note, that the Zawrs extension is frozen, but not ratified yet. Changes since v3: * Remove "RFC" since the extension is frozen * Rebase on master and fix integration issues * Fix entry ordering in extension list Changes since v2: * Rebase on master and resolve conflicts * Adjustments according to a specification change * Inline REQUIRE_ZAWRS() since it has only one user Changes since v1: * Adding zawrs to the ISA string that is passed to the kernel Signed-off-by: Christoph M=C3=BCllner Reviewed-by: Alistair Francis Message-Id: <20221005144948.3421504-1-christoph.muellner@vrull.eu> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 1 + target/riscv/insn32.decode | 4 ++ target/riscv/cpu.c | 7 +++ target/riscv/translate.c | 1 + target/riscv/insn_trans/trans_rvzawrs.c.inc | 51 +++++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 target/riscv/insn_trans/trans_rvzawrs.c.inc diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 37f9516941..f5609b62a2 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -453,6 +453,7 @@ struct RISCVCPUConfig { bool ext_svnapot; bool ext_svpbmt; bool ext_zdinx; + bool ext_zawrs; bool ext_zfh; bool ext_zfhmin; bool ext_zfinx; diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index d0253b8104..b7e7613ea2 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -718,6 +718,10 @@ vsetvli 0 ........... ..... 111 ..... 1010111 = @r2_zimm11 vsetivli 11 .......... ..... 111 ..... 1010111 @r2_zimm10 vsetvl 1000000 ..... ..... 111 ..... 1010111 @r =20 +# *** Zawrs Standard Extension *** +wrs_nto 000000001101 00000 000 00000 1110011 +wrs_sto 000000011101 00000 000 00000 1110011 + # *** RV32 Zba Standard Extension *** sh1add 0010000 .......... 010 ..... 0110011 @r sh2add 0010000 .......... 100 ..... 0110011 @r diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b2c132e269..cc75ca7667 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -76,6 +76,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zicsr, true, PRIV_VERSION_1_10_0, ext_icsr), ISA_EXT_DATA_ENTRY(zifencei, true, PRIV_VERSION_1_10_0, ext_ifencei), ISA_EXT_DATA_ENTRY(zihintpause, true, PRIV_VERSION_1_10_0, ext_zihintp= ause), + ISA_EXT_DATA_ENTRY(zawrs, true, PRIV_VERSION_1_12_0, ext_zawrs), ISA_EXT_DATA_ENTRY(zfh, true, PRIV_VERSION_1_12_0, ext_zfh), ISA_EXT_DATA_ENTRY(zfhmin, true, PRIV_VERSION_1_12_0, ext_zfhmin), ISA_EXT_DATA_ENTRY(zfinx, true, PRIV_VERSION_1_12_0, ext_zfinx), @@ -766,6 +767,11 @@ static void riscv_cpu_realize(DeviceState *dev, Error = **errp) return; } =20 + if ((cpu->cfg.ext_zawrs) && !cpu->cfg.ext_a) { + error_setg(errp, "Zawrs extension requires A extension"); + return; + } + if ((cpu->cfg.ext_zfh || cpu->cfg.ext_zfhmin) && !cpu->cfg.ext_f) { error_setg(errp, "Zfh/Zfhmin extensions require F extension"); return; @@ -1021,6 +1027,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), DEFINE_PROP_BOOL("Zihintpause", RISCVCPU, cfg.ext_zihintpause, true), + DEFINE_PROP_BOOL("Zawrs", RISCVCPU, cfg.ext_zawrs, true), DEFINE_PROP_BOOL("Zfh", RISCVCPU, cfg.ext_zfh, false), DEFINE_PROP_BOOL("Zfhmin", RISCVCPU, cfg.ext_zfhmin, false), DEFINE_PROP_BOOL("Zve32f", RISCVCPU, cfg.ext_zve32f, false), diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 160aefc3df..df38db7553 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1060,6 +1060,7 @@ static uint32_t opcode_at(DisasContextBase *dcbase, t= arget_ulong pc) #include "insn_trans/trans_rvh.c.inc" #include "insn_trans/trans_rvv.c.inc" #include "insn_trans/trans_rvb.c.inc" +#include "insn_trans/trans_rvzawrs.c.inc" #include "insn_trans/trans_rvzfh.c.inc" #include "insn_trans/trans_rvk.c.inc" #include "insn_trans/trans_privileged.c.inc" diff --git a/target/riscv/insn_trans/trans_rvzawrs.c.inc b/target/riscv/ins= n_trans/trans_rvzawrs.c.inc new file mode 100644 index 0000000000..8254e7dfe2 --- /dev/null +++ b/target/riscv/insn_trans/trans_rvzawrs.c.inc @@ -0,0 +1,51 @@ +/* + * RISC-V translation routines for the RISC-V Zawrs Extension. + * + * Copyright (c) 2022 Christoph Muellner, christoph.muellner@vrull.io + * + * 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 f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +static bool trans_wrs(DisasContext *ctx) +{ + if (!ctx->cfg_ptr->ext_zawrs) { + return false; + } + + /* + * The specification says: + * While stalled, an implementation is permitted to occasionally + * terminate the stall and complete execution for any reason. + * + * So let's just exit TB and return to the main loop. + */ + + /* Clear the load reservation (if any). */ + tcg_gen_movi_tl(load_res, -1); + + gen_set_pc_imm(ctx, ctx->pc_succ_insn); + tcg_gen_exit_tb(NULL, 0); + ctx->base.is_jmp =3D DISAS_NORETURN; + + return true; +} + +#define GEN_TRANS_WRS(insn) \ +static bool trans_ ## insn(DisasContext *ctx, arg_ ## insn *a) \ +{ \ + (void)a; \ + return trans_wrs(ctx); \ +} + +GEN_TRANS_WRS(wrs_nto) +GEN_TRANS_WRS(wrs_sto) --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416824889939.8439667634624; Sun, 18 Dec 2022 18:27:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jb-0000fP-3p; Sun, 18 Dec 2022 21:18:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jZ-0000V2-Kv for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:29 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jU-000190-UY for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:26 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:23 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:40 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:24 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3KD0Ps2z1RwtC for ; Sun, 18 Dec 2022 18:18:24 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id r14earm-hI4C for ; Sun, 18 Dec 2022 18:18:23 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3K95RJBz1RwqL; Sun, 18 Dec 2022 18:18:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416304; x=1702952304; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZCE7CztmzSZYcLhiaCvb74bOC6OBI6o+zLLsd/7OGTk=; b=VzxF6xVQZD5Qj0p7nBdvrk7yoCEsrILcKbU0VAQRCHDFMh0Oi3eUUB9R k0Ipq+mxDGsYwvjrqlnWbQQ1DE6QHB79Ao9F6H1CzvvILzlkyXETx2Ge1 jf6CrXWBoMuZhlCyT/VojX5Mb9GrzYHPe8X60rs5VqhLbJvpwsEtedWd+ Yx0AbCLXlCfO87RdwMkg4UuC5RrgSVnisT0G1jZIMGzvr7UBrPRbOb88b jbvQbQgY9vL+Hmflm2ttFZk3kBxoRWmqfGApkbCrkKmJSWjNTsiwkCjVp EwY3fYsy8ccwknVkcjoD4kRnEE4PfogqsMUuCDox7LH6OgCYjWG/kOuVO g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056799" IronPort-SDR: kJEFg2k9ln8bnQlac60uNgrOE9f2Oyoqk7ouFJrIlX/IK3nOJRkMpBFG+rTLXnRgy88gs4av0C j8p3X2Z4JVHQXFgmRfjAXAOm+NRbFJGCdHwgpcMllO3jqd27qitHX9U1PcKeOeuqJUGPHYqBSg YuWl+fgpP3eNKRcCn0brRgVX5Fqi3ncqFPGCbZh0CEIyy39T4oFN626JJzHwIxDeIxKyc/+DJd uBiugZ25SEMKd1tJBkn/XAinb4D6EYClH7k8mr5fPfFCIEOszRIYDzTUxNjtP9XNz3+k0ZL3ft x1I= IronPort-SDR: grasaSiLmguwAEfKCcBxC2Uqa0Gip4m4L4Yh7DoH4owbkTPeUq8rR12J6cv9p7+Nf5k2HWBRd4 ALUSsJXhuUPlg7hv46d6G8GDZj9POc61Pfz7VwgoNfSqBWAnyFMaH0a66ieDMyWtmAXcfgPdE0 5LrbyoYwNEy6Bvibv89gjr3JK1/zO/jqFe4q0oQcDITlaRazfN/ea5+9CaZK4yWkOxtOC+OJEa MRGoXyeCXH/3Wdb27eoBbPdBE8Jl4R4LoDKQUdirJPZYIc+4t6ce4k5+NVTW/Iq8bIpbvMit7r I3o= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416303; x=1674008304; bh=ZCE7Czt mzSZYcLhiaCvb74bOC6OBI6o+zLLsd/7OGTk=; b=orP3e9ICffQQAWXsAu1L7x8 etI1YKdtRr3nX6/kHqSYPcFbiLciY50rQzduFD3GAuzeVh5/9f3PMePZG1XlWKIx BYAS8rJeb3TvyhfFsS79SvFEsIhorXErfbG9PJ0xE23IIB90mbPPSuzg5r8O4tmY T+eYx9uiDlN6JVx5VbZgRaBIHpQDJcMwgNAjXIKM5mFtijcHzH5lLtpU3DKekUC3 wJpWdXoCmwtrOar8CtWzzKbf+RWzr2dGeCyqGcA7+Nfk8iDoHpLtAIIaSMHI7Gcm pJwb8TPe6zFzP8qXq4La8Hb5WauKkA+dzxiBtVN4uKink2pEUskdnDFtKnDePEQ= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wilfred Mallawa Subject: [PULL 30/45] hw/riscv: Select MSI_NONBROKEN in SIFIVE_PLIC Date: Mon, 19 Dec 2022 12:16:48 +1000 Message-Id: <20221219021703.20473-31-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416825428100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng hw/pci/Kconfig says MSI_NONBROKEN should be selected by interrupt controllers regardless of how MSI is implemented. msi_nonbroken is initialized to true in sifive_plic_realize(). Let SIFIVE_PLIC select MSI_NONBROKEN and drop the selection from RISC-V machines. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Wilfred Mallawa Message-Id: <20221211030829.802437-1-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/intc/Kconfig | 1 + hw/riscv/Kconfig | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index ecd2883ceb..1d4573e803 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -78,6 +78,7 @@ config RISCV_IMSIC =20 config SIFIVE_PLIC bool + select MSI_NONBROKEN =20 config GOLDFISH_PIC bool diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 79ff61c464..167dc4cca6 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -11,7 +11,6 @@ config MICROCHIP_PFSOC select MCHP_PFSOC_IOSCB select MCHP_PFSOC_MMUART select MCHP_PFSOC_SYSREG - select MSI_NONBROKEN select RISCV_ACLINT select SIFIVE_PDMA select SIFIVE_PLIC @@ -37,7 +36,6 @@ config RISCV_VIRT imply TPM_TIS_SYSBUS select RISCV_NUMA select GOLDFISH_RTC - select MSI_NONBROKEN select PCI select PCI_EXPRESS_GENERIC_BRIDGE select PFLASH_CFI01 @@ -53,7 +51,6 @@ config RISCV_VIRT =20 config SIFIVE_E bool - select MSI_NONBROKEN select RISCV_ACLINT select SIFIVE_GPIO select SIFIVE_PLIC @@ -64,7 +61,6 @@ config SIFIVE_E config SIFIVE_U bool select CADENCE - select MSI_NONBROKEN select RISCV_ACLINT select SIFIVE_GPIO select SIFIVE_PDMA @@ -82,6 +78,5 @@ config SPIKE bool select RISCV_NUMA select HTIF - select MSI_NONBROKEN select RISCV_ACLINT select SIFIVE_PLIC --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167141633969898.1976524795814; Sun, 18 Dec 2022 18:18:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jd-0000t1-LO; Sun, 18 Dec 2022 21:18:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jb-0000fu-QL for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:31 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jZ-00019F-FB for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:30 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:26 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:43 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:26 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3KG3tlHz1RvLy for ; Sun, 18 Dec 2022 18:18:26 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 2bq3Vi-Oqikj for ; Sun, 18 Dec 2022 18:18:26 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3KC6vNQz1RvTr; Sun, 18 Dec 2022 18:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416309; x=1702952309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wy8uMlexCTLFy7zcIJSicrjiNVPO7dvX3ZUqTF3gE+Y=; b=Q5M48X6hyvAPZWT6XNwodYSXIykng1ochtuoSbKKY3SQJyrTEW6HoMJr FTGFgU2UjbqYAyV0+niz8St2iXfiPJqbdZMWP1Ho/dp1QSVKGZLsp1Z77 MZBZY7qG0dOVhngLSegrzWmwixTmsd1UXmYH5oaqO9ynTZiru9hCqU+r9 VErAxfgvaNoGFbEXC9wJR7nuYAbziKd3z1XQRYpMuhynsD+4NHsamGcYq 6uSK/zQqRHbhXighan4w0DG9r+/NorYnykB/bEAzbvDJiZ5VBM6+bmRgs ypvxKQelIIJnJmCxPmI/stBm5w1Bi4iRDgWzVPTID33Cc6E89n7KRqz1R w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056800" IronPort-SDR: BFlNLF4Sw6uu2LozxrQhbHYIzycL1rLQTWy/wqaf/pi+MbV2VWzETjrOTUGRrmkLTV95GLvZGM CxhUF0/zjptq8jb5emcVqiFPlpmNtXcNKfCEsAB62FtvSYhb0lArNOveMVSMdd2W0JD21rZEON 79QEXk+K1hGXBuqCpHGK0OLWsJ9NGGGa/m0Rf8vGzPkHnpVlv0UzzNHOTNqW5eKoLHUJN3caoM 0NQuIsKh+jc6nEHMwubjkFKHSfvPtIp6vn1ErJxgbAIBAAJJ9E4dbZLIIpwjhjf33+FelKRyiq Pp8= IronPort-SDR: Ut+R0Jp8Ut/If4W3ro7X8qL0fnx1lSBRRXi2n/CO0OdHPb/9vhzbDTU+qkZRWkmn5jQJOE3dcz Vn3mLVtqnOMpRJM6bxyeaSM70pMYzxHiWbl48xhRFlfjk2TDCwblE5ClebgGWsvhR29RXkb4Be GPMWS80xN5P6n15bfLcWxavYaEs2KEoAaMhO46eEPlrpZFtZeB1eSX9cUgqgGmT6ISjR2IuUwa oKRyjcQqEJj9KhT/tJd7QwciEM5Ju+cNN2Vr207KHLhhPiN7aBkfIO6XkdoKDihW1ZgnoLyI9T xko= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416306; x=1674008307; bh=wy8uMle xCTLFy7zcIJSicrjiNVPO7dvX3ZUqTF3gE+Y=; b=W5jo00qFJEYULtpC5lRnBiw TaCHN+3UJtq1/L0k55Q0vZDkW5SSDv9Q2I+pyDhb2o8YKzxqy3BnIbd+tI/iQzIT 5QmIauW/ZPva8ihduw2jaI9pgl18nuB+WFl6UwRHr/ZaVCcePay57w6XE8o95Sfc xl2r/tmgeqD8siGjCHQtzstobSWYZoix4W3yA+gAIRBnu4x+sj3M/7KPFIESZo11 lxVspVMfCWcUSkaV2u/r76La37IrlMRSZoeFzgtC9Ln97gFMF0L/cMKqj4j/a5Cx p+fw/XVlhNcWge9fiQjG4Kndzb4N1C+MpQP6GGFTX03iRf5MPYvlOKlXx7FhY8g= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 31/45] hw/intc: Select MSI_NONBROKEN in RISC-V AIA interrupt controllers Date: Mon, 19 Dec 2022 12:16:49 +1000 Message-Id: <20221219021703.20473-32-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416340275100002 Content-Type: text/plain; charset="utf-8" From: Bin Meng hw/pci/Kconfig says MSI_NONBROKEN should be selected by interrupt controllers regardless of how MSI is implemented. msi_nonbroken is initialized to true in both riscv_aplic_realize() and riscv_imsic_realize(). Select MSI_NONBROKEN in RISCV_APLIC and RISCV_IMSIC. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20221211030829.802437-2-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/intc/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index 1d4573e803..21441d0a0c 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -72,9 +72,11 @@ config RISCV_ACLINT =20 config RISCV_APLIC bool + select MSI_NONBROKEN =20 config RISCV_IMSIC bool + select MSI_NONBROKEN =20 config SIFIVE_PLIC bool --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167141665479165.91140178790806; Sun, 18 Dec 2022 18:24:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jf-0000xi-Ha; Sun, 18 Dec 2022 21:18:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jc-0000ms-EC for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:32 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75ja-000190-Cp for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:32 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:29 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:46 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:29 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3KK3YKrz1RvTp for ; Sun, 18 Dec 2022 18:18:29 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FfvkEGl3uANX for ; Sun, 18 Dec 2022 18:18:29 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3KG5nyCz1RvLy; Sun, 18 Dec 2022 18:18:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416310; x=1702952310; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QikRAc9jhPx+8qjwv2aF1TI8bV2sm7YwxCfz1ApfiCc=; b=N9QQjxUGQ6ESDN6eaU1e0zjeBeueJqROuCbHodDDj9rdaoy0k86eeIxm 3a6GJfdjI1XrzzOFj8OScn1qFmuxJcv1Ny7ssEWSLLF6B8maQIhXOL9Yn uWcGwfQBr3hhnBdODFowkLBr1+/mm9Zh+pbGwiS5h33FFAKLp2jzSI0nB 2kGhJpnxeTAX87+6rTpiIo6+UZpay8NUczqvvCVoRYDhbJnM0c/hZ4TrS okHOQSoHK1n/1kl8guWlwuv2yHtzzFXoaqGt9Gu1jccuKgDZj9lstw5vv pZhs5xC4WWoZRu4nB+fSn3NSWfbOAFT4WJ+8irBo0W4IdMWzom7oInAVG w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056801" IronPort-SDR: YerPDXKT+cGqwpbaIT/KMmdwAT1lbG8TGG8H4HRmZbbMvQKfPC5DHR9LoYngIeNpLceQvSkw9L /9S47HZnpuQsEGcVEwb4ANxO/NsqHzhvu1y5K4v6+yHNaEpOijosl28qT8UDfKN7DpxaiPWZfm tjRCB7OKcSCSuXXAqwcYoeL7S1GvESs3MDshcNLgvAoZcoNQ2AJnzKvwE68y4w1k7s9zUuKrVp /ol09WUa2H8GvJEWXcpDiV0QzJHV69AOvcYZCn8UtxWEgO2OYabxBcrvw5Z/gytWiz6LVloxls VuQ= IronPort-SDR: ndFl+cplJQd5wOljUvCqxzlHUgn0rVK04j2S22xiQJZc3bChl3rr88+KssprHbuZNT4ZtiO/D+ G15lrP++hmQHSx5/3zjI5VpvOv3wn/aqNSiOzgkiR8DUn6GT4snsYHkWTcMIxZhSxBsmzcIRxv 1KPyyR3o5NU0P6p9NV/lIhIhFjHWDfGw79IP/pjThG94TA+gVPicod44w61BBe2EVGZ32uvkwW s0bL8Z1VESmuys8U22jzlP6yOmpqci5o/U2rJ1LiYyvm1DH8pOU5Yi8hqFORNhOqb3wnxOul/F QXU= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416309; x=1674008310; bh=QikRAc9jhPx+8qjwv2 aF1TI8bV2sm7YwxCfz1ApfiCc=; b=PAY1B7rH7suSzO3N2BAoXZcPIuaCCC2Rwe UUoF/sVZ6OETkl0AL5CNy4lfr/6JZGLOvigdKNt3ncF7/KTUgYxROijqa6Hmg+sX wk9JfH3wK5q3asN3w23eeDf8J2GFBH9RIYfHZpsqvdDxt61iQrx7rqzrhepxjnUo Ir/RIIO4lPM4qN6aGgQ20QH1MgDbcJXV1EzA+IVKTsV3YUeZUzdIlq0chxTcFLDj JwqiQo40JCesVkY8+ufOJmkiHArlkeTUZ0Z/rLblgwro4lddCLnMxtnLpoe6YlbS zX00ECBwQI3j0LC+jdWNB/OnrsUjuTYTBzBpkOaFu4Tfz8wJKgWQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Wilfred Mallawa , Alistair Francis Subject: [PULL 32/45] hw/riscv: Fix opentitan dependency to SIFIVE_PLIC Date: Mon, 19 Dec 2022 12:16:50 +1000 Message-Id: <20221219021703.20473-33-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416656446100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng Since commit ef6310064820 ("hw/riscv: opentitan: Update to the latest build= ") the IBEX PLIC model was replaced with the SiFive PLIC model in the 'opentitan' machine but we forgot the add the dependency there. Signed-off-by: Bin Meng Reviewed-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-3-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 167dc4cca6..1e4b58024f 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -19,6 +19,7 @@ config MICROCHIP_PFSOC config OPENTITAN bool select IBEX + select SIFIVE_PLIC select UNIMP =20 config SHAKTI_C --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416903310425.12873876129663; Sun, 18 Dec 2022 18:28:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jg-00015U-Ig; Sun, 18 Dec 2022 21:18:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jf-0000yN-Lj for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:35 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jd-0001BQ-V5 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:35 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:32 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:49 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:32 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3KN32x4z1Rwrq for ; Sun, 18 Dec 2022 18:18:32 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ocnYBAsO5SPI for ; Sun, 18 Dec 2022 18:18:31 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3KK4L18z1RvLy; Sun, 18 Dec 2022 18:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416313; x=1702952313; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Xc5MYHOMGVFtrxdnb2BOI0WjdZAtZsCNEVi1/TetPEQ=; b=Lsw0o/INu34tl/Skowq3WBHQ4rxsV5neqE9fskf2Z67SqxeJ7VAglaHU pBHbj0BOmavglQ1on8+PU2OFp7qyiEABDdDec3GBJ0K1JYMGNZ5paNV6W OSiRPSvUz0WMctujLuaZLUV3tIKSN3vyqDR+0UH+z82bBTEvl2Fe5tgbU COtP7YUrRm566Qj9azm8ZzelfcTpEgERHc1kw+c9N2fHnxM2QQ/vdR/oO DaFEEVKIQbiXARIP11JDNKnCUXK2e0tw43yuHhKFihtfoHxNK7xE6IufE 78ES8Y7cC3i3yuvPE6haKxSC0rBTt/JYUXlbAV2sjc05Kc+n5H+Uqjp1J Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056807" IronPort-SDR: a6+jC57RpnI09GxVy/7MVL+nOltr8AQZWv8/QXQndV1gkL3M6hHZz+IDqm7HLVMR0wduhnaAUr crS7Z8PoIphTvmMDkCvpFi6ttSxgAzqpTO4RAosM6DEy7KcgZbvN6KH+nY265jubCVFqSdy2o5 UUamk5vOJqk61sstG9Dkr3Ns5lw1y8Ue6r9vzTisropzt5s5qzp///03FyxfqDPnsAfB3/8DyG JmX7GxvK8KV0TEDCf6SgSTB7oG/UvXX1XlW/GGqc4qd+8iW18FY3g/8v3WECLgOo8D7q45a3LO zvQ= IronPort-SDR: AnHGAS+CGy/Xtv3mnPZCWTGRMt8SPdKOmr/irtZ/9jZApCpuUubvvdjBIh4FqlT9wKcnyV4osa 4kEXkionNAqyrwmpj1Ixuhbm5hRGzrkPYXmh5fr0PLwiE6eKPeQtEQ06To/jUtiCbx5Td+DK3C tubRIKlBmAg5t9JvT6sSeD3XhnxCmfkmaYmF4m8BUvrhBZ6n95CSjT2qGN7x4XRslJrrYArnGN yGqZWHGX0GiSliy0Lj6WP/I3ORJyRnz4nOLINdz017dJXBHf27XptOQToZcevVRMAHQFdVIKhe gqc= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416311; x=1674008312; bh=Xc5MYHO MGVFtrxdnb2BOI0WjdZAtZsCNEVi1/TetPEQ=; b=TE80D90aVkuKNQ8i5nnVoe3 2SF9lT+R0+XDtJwtQHNfR3S51dO6wEDLLOrdEKeA/GyQ2EVAXJnhuY8yvc/sBCxg oFJgZRVx+dldavRW1+YN8vFFoBc+Z4W6XdDAN1tDR2+gnO/XQWmlos8c2oOnIf2m zqrgjYcXSN3j6niPrIKhD4Z181cCY7+7bFMBJh2mmjETEXOupDe0q7KGp6qG6cNm EM68gMit9ilwV+g44uTXvw7LWIgnj8AwvYdHgoYAYz9x+t3/BGo475t06Us1TL8s LOtYF/XlZtjNtWuD2+joffZtgY3f8Xw8h0DuIabKkRPgxnCyPbLrDkVeNTflYEw= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wilfred Mallawa Subject: [PULL 33/45] hw/riscv: Sort machines Kconfig options in alphabetical order Date: Mon, 19 Dec 2022 12:16:51 +1000 Message-Id: <20221219021703.20473-34-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416903953100006 Content-Type: text/plain; charset="utf-8" From: Bin Meng SHAKTI_C machine Kconfig option was inserted in disorder. Fix it. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Wilfred Mallawa Message-Id: <20221211030829.802437-4-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/riscv/Kconfig | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 1e4b58024f..4550b3b938 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -4,6 +4,8 @@ config RISCV_NUMA config IBEX bool =20 +# RISC-V machines in alphabetical order + config MICROCHIP_PFSOC bool select CADENCE_SDHCI @@ -22,13 +24,6 @@ config OPENTITAN select SIFIVE_PLIC select UNIMP =20 -config SHAKTI_C - bool - select UNIMP - select SHAKTI_UART - select RISCV_ACLINT - select SIFIVE_PLIC - config RISCV_VIRT bool imply PCI_DEVICES @@ -50,6 +45,13 @@ config RISCV_VIRT select FW_CFG_DMA select PLATFORM_BUS =20 +config SHAKTI_C + bool + select RISCV_ACLINT + select SHAKTI_UART + select SIFIVE_PLIC + select UNIMP + config SIFIVE_E bool select RISCV_ACLINT --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416474592863.4079023719738; Sun, 18 Dec 2022 18:21:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jl-0001G9-Vt; Sun, 18 Dec 2022 21:18:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jh-00016f-L5 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:37 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jf-0001BQ-Ui for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:37 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:34 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:51 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:35 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3KQ6xsxz1RwqL for ; Sun, 18 Dec 2022 18:18:34 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id iTIbZNXOGgSg for ; Sun, 18 Dec 2022 18:18:34 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3KN3CHlz1Rwtl; Sun, 18 Dec 2022 18:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416315; x=1702952315; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WRx6Vvid93Q1T1mtyE/QThVhuj/pNvv5e8rHnvs+X88=; b=M5ewo9Tlz8xu4K4T0pzYBKgPiQvugIC4Cf88Y2+CbuR/n7Qh5rULHtYl YhczEjVNGZ4VIGrQY+b+hlifZLGSQf0gdMu4hi3+eu9fYU3eA9oWX21t4 W5RJDxMVVakc5gwp39QAOSa6+m7vlt/EGTvz+eB8EtiT3gk1Qz+SnDaUV 2dc9Oo5tnKeQ1pymEW88eaBN+1X+AjpM8GC+Bl7Mh4HcioljMm6bxyUW8 6fxHVLeWlpvEu6zfZHwPMPRzTnmb5ZN+K48+7vC3MpbC3YxkCn24Me3kn DuX78CkruWBmm+q13jg2UwWm4QsRIvUCIEv5Z4zq70l6sJbx8dNHS9MRW g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056810" IronPort-SDR: 7rNUoEBH8yZBCVsq0ymuZuUvVv0Q9Rzix67rnrx7N9lIyWEslgA6ufyDlOyzWZgU8oHpI5LoMX whsdzDLVDTa+n7wl34q758wc2r4s7hzWLoln5hbd/ZZx/nsC3kcAjfmozkQ7oV9DJrZfbgMPIC pBssQ722FKmPBsFqBW03bGWekrLc+vK1QtXK+U7aJEQQBmtgDiciNNnptqJV3h5CCTI9FNEHik tcxVm1UCfo2cMWfvIi5cz68SK6ompavEBUwQfZN4yIn4v8nR9TNcY0Gz2v4Q8Zrz2zvecVOsNL eY8= IronPort-SDR: GqWpCtM1wSvb+AGJ7RX4OEv6bSqJ7LXQOu3BLKUbpFJX+vVm3KL/I84ths/mKvQ9Fa8mK+0gko UsOPLrbCZ3MPYwU2t+2foFT69KXQo7kdsdQRf1rgm6e1ZeZXxCrR38DGgPPsLsPUhgxmCsnv2g 2dc6desWbcCr4kXmoxGlZ4A8xl/nFCN8/tBuXg08+LCrIxq1SjSgFLzXtNV0RSuX91+bPh/Jfc V7lHs1/qTMyXFFa1/VpzyPikE3xmw0/Bq1KjAaEvy3/gShnoKJoSWTHAEZYfM+zpP47+RLvc59 VpA= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416314; x=1674008315; bh=WRx6Vvid93Q1T1mtyE /QThVhuj/pNvv5e8rHnvs+X88=; b=dgo/YE+dMPTG3Yl2DHKai08c+VpT0vY3ER myvp3pVJqNxgu/R42U8M1MiXcLX7UlOoAR5+QkC4rcvgO/zSgqKkkENjWykB7uKm 7+d3mQqnFYPD5eltpwLruVfP8V772pE46oELmvIgaDGoh066zjEXxQh+Z4AQG+t2 Elxtb7x/srV9fKU2+A1foF/v3Fzrnn+W3U5AHtN9DKdh1ZvOya5XPIjyo9xVHS9J 8+pNfH6qwIew5r/3gAghlnqXhj0OfPNKWdx9LIYU5RoYPSJORJSIqvV451fGvwU5 vAQ4BgDr4Xsq14vXgQC6M8oR4npUdYTdUU+2MSqSCD4RO0odWibw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Wilfred Mallawa , Alistair Francis Subject: [PULL 34/45] hw/riscv: spike: Remove misleading comments Date: Mon, 19 Dec 2022 12:16:52 +1000 Message-Id: <20221219021703.20473-35-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416476536100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng PLIC is not included in the 'spike' machine. Signed-off-by: Bin Meng Reviewed-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-5-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/riscv/spike.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 1e1d752c00..13946acf0d 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -8,7 +8,6 @@ * * 0) HTIF Console and Poweroff * 1) CLINT (Timer and IPI) - * 2) PLIC (Platform Level Interrupt Controller) * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416611669943.2077916471287; Sun, 18 Dec 2022 18:23:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jp-0001MH-J2; Sun, 18 Dec 2022 21:18:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jn-0001Hy-8F for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:43 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jl-0001CC-LG for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:43 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:37 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:54 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:38 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3KT4N1Zz1RwqL for ; Sun, 18 Dec 2022 18:18:37 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3xX0VN_mxk8A for ; Sun, 18 Dec 2022 18:18:37 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3KR1073z1RvLy; Sun, 18 Dec 2022 18:18:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416321; x=1702952321; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=390eeG4V0e1ilBaF3agJQhKFOgqHLzF2xG/939DvkZw=; b=odPMAN/5oBU4/sqpPVVCcjw0IWBfuemc78RKFGNk2u2IWrddRNBX5qGt 9QEuEUloOR6Pbs1SGJ6kLkEcQO4ix0g1srqyHXfTWJKQvy4YNY3e+2wX7 ur5QXi+yrZ7i+NDgI6s5tjR5jAP3LynGA8e2HyIT32t4H3m9WP4AZnesd ANS4yRpj5AxgXQzesQTaRm5rxpHLbPbSEH6N+l6Pub0rmDDZdlxq1shwm 4FmbnG5dE9+1BI4CPttIzdxfLggdvptrlfnGHyp+7zL8398zGhFZN6+z0 ak+J7DX4BiB/xZJ+13acEPNUPtHKjaQI1doXoxwM5SUcOAmCppaFJXTbD A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056812" IronPort-SDR: C2To00yx7CS5/0V81QghxIQIHbSVFP1+hNlaVWYAUHGvqNKmV6ypE0/SRSWaYi9HclVZlzPNbh FzXtRYTcULI28XucjBoUtMrSr9VWqn612kaiQLT8uob94DcN+FEShLOT87PGkEzWrsWgRh+xSt 06cT2RR1yUu5A1sj0DH2T53J+tnhNs26hG1zlkAJYuWxi+JJfG52w0Vv4NXO2/1+GjLxO4SaCW i0LjwPH59Zexil6MTOwz2NbRfGM/YiCLeDLz3v1HW40y6CqnnbVD9y1HW0cIG+/5UlSy5hfqlP LE4= IronPort-SDR: 32ae0zao2o8lqoHMpkcmc0PC/sKM4Mb6tjhNyijHBcgHLW7YZR3MloTYooh698fDY2p+3EH7G+ jbi3lRfAvSU6iIUp5gu5RgP0U45Ff+SB/+MjM3SkOT54C3WKgYi7P3wOVns6rNEgxkVbFM6pOo nO22lDOq/2hF+eoNRz4ZWMxj81qRNHX21EM4Qi+qCKLm1x5sal7m4EBND0g6L+f82nlr2UV5Fq kl76DECP+d6lHgUWNK9C4PVwibrr9wpYBFZFpzbsli01B41rhr06mXbD95ZKw5iKEOK4yJRu56 P/g= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416317; x=1674008318; bh=390eeG4V0e1ilBaF3a gJQhKFOgqHLzF2xG/939DvkZw=; b=uKwkGFOAl2tH8TQw8r70JTqMcUAOS77Tzx 6TcBreaCSsDxA5YkV9ooyZD+3WwGg7Bz20U2kCBAylq8RaDlRGsiC1xZlHhUgKrZ Zmz2p8tswNdR8eD97pVfMrwMplVXLM8SffR8aR+PZlxDq/kPxBXQrPvdswQu8Bu+ DAiRrWDX8W2tloesqmxNZ3KA1VdeGDAU/L7E9E8Uyk+LirULdjycL6E8cMhGJjJS mDXjYICiQlqrCtwel4/qMTM3HRdS6U1EAqDpoyU7s7BdFD0BSCGgXaOvJzHUdamm 6JvlJW304mWaa5CH8BYuIosq4WfoQszM8N8NP4w9Tntsr72NNgdA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Wilfred Mallawa , Alistair Francis Subject: [PULL 35/45] hw/intc: sifive_plic: Drop PLICMode_H Date: Mon, 19 Dec 2022 12:16:53 +1000 Message-Id: <20221219021703.20473-36-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416612276100002 Content-Type: text/plain; charset="utf-8" From: Bin Meng H-mode has been removed since priv spec 1.10. Drop it. Signed-off-by: Bin Meng Reviewed-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-6-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- include/hw/intc/sifive_plic.h | 1 - hw/intc/sifive_plic.c | 1 - 2 files changed, 2 deletions(-) diff --git a/include/hw/intc/sifive_plic.h b/include/hw/intc/sifive_plic.h index 134cf39a96..d3f45ec248 100644 --- a/include/hw/intc/sifive_plic.h +++ b/include/hw/intc/sifive_plic.h @@ -33,7 +33,6 @@ DECLARE_INSTANCE_CHECKER(SiFivePLICState, SIFIVE_PLIC, typedef enum PLICMode { PLICMode_U, PLICMode_S, - PLICMode_H, PLICMode_M } PLICMode; =20 diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index 0c7696520d..936dcf74bc 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -42,7 +42,6 @@ static PLICMode char_to_mode(char c) switch (c) { case 'U': return PLICMode_U; case 'S': return PLICMode_S; - case 'H': return PLICMode_H; case 'M': return PLICMode_M; default: error_report("plic: invalid mode '%c'", c); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167141691086783.4389599524012; Sun, 18 Dec 2022 18:28:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jp-0001Mj-VF; Sun, 18 Dec 2022 21:18:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jo-0001Ja-9J for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:44 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jl-0001CG-OK for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:44 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:39 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:56 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:40 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3KW5dNNz1RvLy for ; Sun, 18 Dec 2022 18:18:39 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id gUh26rFpdbTD for ; Sun, 18 Dec 2022 18:18:39 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3KT4d43z1RwtC; Sun, 18 Dec 2022 18:18:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416321; x=1702952321; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FTpM9wSisWlcMO9trrZZ4PMyQatiOo+GCvuYX47JsM8=; b=PjohIRUfWE/m739Vn2FsCTdCkmpZ2tNQBZTl5RWRTNkHn2CaNqgxIur/ vgsmu69+2odwJfsXPlVA1Jqldo3Ccbmc9b8iBZNApYEcSyjsGC2IY8ctU OnujlpHGOZeHWd3moxyCK8sFNq9jS3bMXHqIhelLkRJ+Kq0s3k8L6YFrQ +HcIo8GClg05fAPZLa4EdfY9lJmVFN6J04ANYdEgckQbRKuP/SOdzXbTC c7DXdCnimr3GjBvttS8SQ2/yBAW1y6O6sSTgL7oLSq25f++msIQ51PYuX FM3fTe5Y2sKzbWtwlxxBs8QEm1P/khDMV+Q950DD0RKCM6UtjsXPGJ5hQ g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056813" IronPort-SDR: jKhYm1P2VpALGoAfnT4oqxjnmhg5mtQJSwgkteSkf5QnSsDXuuPASUy1PSRT7FVe1qIIvvcvdV x0nuvOwMOSg1K6i0WyW9umXeWAvqIX8+hsEl3sMckYh0ehkeMjoFHetoW15j4xSdZn1tGrtHyx q0+2HniFix4Sq1pNZDTwInKh6MsFReWzhiLaI4DUoLCQYwfV7D2AD5IS9B7Kg7TtIESB0ozJBb VUsVve7Uplme3igtYrdyiqOT5Ad4LpTZUGWoOE38WuwUyZFSZBy/r68G1cUsFM2EweyY6O9JF1 kXM= IronPort-SDR: wb/TyGuyCCPxEIeDox7ECx0kWhapbHpeB2r3wL+g945x0UAoeU75xoEDCsJXh0AEo5ZsUa3iuU 64W85acT1qDgR1sxW+LNyXG5muXtou02FtiKm4g189ZVC4DXdXFQx9PvFX2QwDX7Ole1YYbaUs bHnj1/s/AikYoaFw3+XHKYhDdk6esyLMaHiUFOuLvie6Tyn6p9UGdUmqgRKWci54L2Y5Z88HfG nTl/6xFOgUFsi1OuKy005MzEQtqEN9hckdxJTzPCakprxBIWKd32n/klYP7CwVFkMsr8RyZqs+ buo= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416319; x=1674008320; bh=FTpM9wSisWlcMO9trr ZZ4PMyQatiOo+GCvuYX47JsM8=; b=dG84+zZs87ozdbDHnhTZBsLZp5yRem7+xY BBMA8XaKxbm/OyZGWcLz8L4v8ZVm4c5wqH6hFWAOIvRTzNGhNPqa3DV/4jo8vBnL mgk7ZNLqBKFUEyGHGZ0Ti9k3NCb/uv9pT/dd/PtEUwBXBR5JgEwh19vnbvWHT7mS e7VgKbz0Y+lNaRuWEtdDuj/zcev9uPGZaAZv9vpHbfZjgZvcS457E2HFIlSDoRvj jYvUfiMF2mWsUP87F/PUuCR6eRgH4yungqizHgxr6UDpZzkc7YV6y9BADvECkWtm d042hlrMuqLEPXpSJxzRmmm9DU77VNO0D3YRprMEuY8McI5spVGw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis Subject: [PULL 36/45] hw/intc: sifive_plic: Improve robustness of the PLIC config parser Date: Mon, 19 Dec 2022 12:16:54 +1000 Message-Id: <20221219021703.20473-37-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416911858100003 Content-Type: text/plain; charset="utf-8" From: Bin Meng At present the PLIC config parser can only handle legal config string like "MS,MS". However if a config string like ",MS,MS,,MS,MS,," is given the parser won't get the correct configuration. This commit improves the config parser to make it more robust. Signed-off-by: Bin Meng Acked-by: Alistair Francis Message-Id: <20221211030829.802437-7-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/intc/sifive_plic.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index 936dcf74bc..c9af94a888 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -290,7 +290,7 @@ static void sifive_plic_reset(DeviceState *dev) */ static void parse_hart_config(SiFivePLICState *plic) { - int addrid, hartid, modes; + int addrid, hartid, modes, m; const char *p; char c; =20 @@ -299,11 +299,13 @@ static void parse_hart_config(SiFivePLICState *plic) p =3D plic->hart_config; while ((c =3D *p++)) { if (c =3D=3D ',') { - addrid +=3D ctpop8(modes); - modes =3D 0; - hartid++; + if (modes) { + addrid +=3D ctpop8(modes); + hartid++; + modes =3D 0; + } } else { - int m =3D 1 << char_to_mode(c); + m =3D 1 << char_to_mode(c); if (modes =3D=3D (modes | m)) { error_report("plic: duplicate mode '%c' in config: %s", c, plic->hart_config); @@ -314,8 +316,9 @@ static void parse_hart_config(SiFivePLICState *plic) } if (modes) { addrid +=3D ctpop8(modes); + hartid++; + modes =3D 0; } - hartid++; =20 plic->num_addrs =3D addrid; plic->num_harts =3D hartid; @@ -326,11 +329,16 @@ static void parse_hart_config(SiFivePLICState *plic) p =3D plic->hart_config; while ((c =3D *p++)) { if (c =3D=3D ',') { - hartid++; + if (modes) { + hartid++; + modes =3D 0; + } } else { + m =3D char_to_mode(c); plic->addr_config[addrid].addrid =3D addrid; plic->addr_config[addrid].hartid =3D hartid; - plic->addr_config[addrid].mode =3D char_to_mode(c); + plic->addr_config[addrid].mode =3D m; + modes |=3D (1 << m); addrid++; } } --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416568330307.16320232071746; Sun, 18 Dec 2022 18:22:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75jq-0001RT-V2; Sun, 18 Dec 2022 21:18:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jp-0001L6-2k for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:45 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jn-0001CM-Hw for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:44 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:42 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:36:58 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:42 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3KZ0p3rz1RvTp for ; Sun, 18 Dec 2022 18:18:42 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id nmN13YVq1Ndt for ; Sun, 18 Dec 2022 18:18:41 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3KW73Pjz1Rwrq; Sun, 18 Dec 2022 18:18:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416323; x=1702952323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nlKcnGFnnezn/uyVuR1UsLHc6jl6EbJxpvVfxGJcUTE=; b=a8QWhtd/W2AmulYRSbcXa/VQWuTIU+z9HXc6N6lhKEqKj9/tgzdPXuMO +9kgyB5hp+OGOIYr7vl1fOrZHx1qY1v6pCi7yw6JplFajYdWkRl9satIo sy8kppotNAY/F2Rn8O8OW2O7PYU2y/SIRTVcNOc6Oi35rMNDzLpXL9hLJ fe5Hiv1+90wGKAI7Pw73Pkkss8L05/qlGh4YnNU3+M3NvuuzMkACSZ3n/ g+8KBnYsl1fQhJoLl8pNGJJ1OXvDZDWs5MQrUxBu2Xfu5PhhCW8VL2tJj S11L7+acUqUEaM5WQkZ0bOm/ePpau7xWYaO0rnMaA3X6XoA1tbVnHNIWF g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056817" IronPort-SDR: mUmhO3HKGOseiAemGny0EGf1eWrl2dQj2959IoEbaZ4xIIwWMUabdCT3B1YQjE7Bg+rNtC8rK6 60wACv1SG4JT9GTl1fT12qU3QkZAAcEXMg+Qx93aQ1rYuF3YgUPztGj3UlBXruS8k6woeAIcJg H/WpQZ42ULqTw4rWoZMSqVASHvH/gIgnjEa4TCv9V8kQlEhn+YZzzQXklRCSWSt/DRTMxJreCZ OgIUy3nEwW551sSvoBzq9JrwuuwGlSgWvIZSJK9aDm/cSiQT2Lce23HZdVSqRbrUB263PCnlhN ZkQ= IronPort-SDR: 5crEQua0m7srMhGaY2TJ6mjBYEHlAw2kwJc6YVRJCw6XQ5DQn+CfasbPqxhZKBXoFEBGMwG0et fPB0e3LL4uEiX8KKPA32R3wPmxqIleDsT3DaPgVYdxKt3OSPE5F2eqbErkG0iRu/x30fbem0cj uCwUrDvjbFRTjaQZBuF79fjQtzaav+fQmQtu22Bm8SaKv/b7A0nBsQwRcuKLBFzWuEzlrR6Rmz Lv1Frg8jnpbCSnLML2tb2BO3znnwFQagY5TeyGqxn1+b7FgMk8GTUIYOyMXwX09JTYUwY5COHj Iuk= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416321; x=1674008322; bh=nlKcnGF nnezn/uyVuR1UsLHc6jl6EbJxpvVfxGJcUTE=; b=kt+M1IzW/wLjrpCSsrkHhS4 K9cBJFa0fLGtCbeCCJGSyShml4mK6GduxZxzb+A/psISx2Hbz+YdDtQYuS/65Drc A7XIszoCY/APGZGy/HvGKSNapN4xJt5RiyAYEBPsnii0gSzLUZqXKNaO37/q8x+8 n3RzTD+WEFML0VihStdBob2lzEv7wVyyNuhOVnuYB4QoL3j9pdhjiHTAURrbPgXh TKtDXIXTOrBwvg+XnVUJFWWOzkp3p6KOaHFRXVUAEOyftWR4lhl0iyyX4qsZWZli BZD9AlEdV+GzKFrQsZcR/z2DVd/gNAzx4Q1Qonxa8GUT0iMEZSBukPSONORiyeQ= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 37/45] hw/intc: sifive_plic: Use error_setg() to propagate the error up via errp in sifive_plic_realize() Date: Mon, 19 Dec 2022 12:16:55 +1000 Message-Id: <20221219021703.20473-38-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416570113100003 Content-Type: text/plain; charset="utf-8" From: Bin Meng The realize() callback has an errp for us to propagate the error up. While we are here, correct the wrong multi-line comment format. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20221211030829.802437-8-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/intc/sifive_plic.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index c9af94a888..9cb4c6d6d4 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -379,7 +379,8 @@ static void sifive_plic_realize(DeviceState *dev, Error= **errp) s->m_external_irqs =3D g_malloc(sizeof(qemu_irq) * s->num_harts); qdev_init_gpio_out(dev, s->m_external_irqs, s->num_harts); =20 - /* We can't allow the supervisor to control SEIP as this would allow t= he + /* + * We can't allow the supervisor to control SEIP as this would allow t= he * supervisor to clear a pending external interrupt which will result = in * lost a interrupt in the case a PLIC is attached. The SEIP bit must = be * hardware controlled when a PLIC is attached. @@ -387,8 +388,8 @@ static void sifive_plic_realize(DeviceState *dev, Error= **errp) for (i =3D 0; i < s->num_harts; i++) { RISCVCPU *cpu =3D RISCV_CPU(qemu_get_cpu(s->hartid_base + i)); if (riscv_cpu_claim_interrupts(cpu, MIP_SEIP) < 0) { - error_report("SEIP already claimed"); - exit(1); + error_setg(errp, "SEIP already claimed"); + return; } } =20 --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416624972206.15368546827642; Sun, 18 Dec 2022 18:23:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75kD-0001oB-4s; Sun, 18 Dec 2022 21:19:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75k1-0001e0-K2 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:59 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jz-0001Ck-EA for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:57 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:43 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:37:00 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:44 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Kb6LmXz1RvLy for ; Sun, 18 Dec 2022 18:18:43 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UkpOZr8_sOPW for ; Sun, 18 Dec 2022 18:18:43 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3KZ1848z1RwtC; Sun, 18 Dec 2022 18:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416335; x=1702952335; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sj/y8vrFJBlbuclXKhQf/IHAdoHqQPxC6w+uEVXB90w=; b=fbO1GueTa6C8x2PxxkJrJgW8b5gQ5WcWVBs7m3sVrL5apfbBiVGnnI0w dLBMcae5iHeea4nRkYvoJWZ/1XoD1I63tR8GpgObR7EPbhiMD1Aqd5z5C xo9RAD+vQnDj9vArEGbHbeCdRo+YnDWgZDlYnbdEO4PDnSgvKXPyy2zh/ srdOzclI+OgoyaCjiV5jk2lv6YxflB2iDWF53EBqiWKLqV09+zLwFqrgg q7KXU0ml8wkDE3SxtDOVB1QbdWIBxm5LYgmLoz0JpgEQG7wIZvTxPcjBW d4IBWJqK+gfEje4A+2rCxHEi0AVtpRPsgWudbVdAW3qaEsYWcmgjIuOtz w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056822" IronPort-SDR: o1fGOZV3ywSmyrpEpReLEWCEzxsIL9pJGp6AFgMU8q3fM6K6VO+xR9QVb3gtLt3NlXX1sggY4q R/TAjKaTWOsTH34lRCwBVBK5JdZXL1y/4XBIJ1R8m6V5cjWzSjIOKj7nW/Gptnb5Mi1+Jon5bc tHY1REq4A6p3frGgEflJkUzt3W0YLLTB6fy0dT70MoY/kJOCNWf9Bs+vSmdNcoSQQzJZVhd/HL 3a6vlZesewSHfJh91HWbGi80JfJWy23A5q24yDVUuDgkCyVv2uv7oqV/PRnvO/nvcYWxCu3U+Z 6KE= IronPort-SDR: Tpn14YfXmXTsyWW39jVHgSUm6WakT23XG2Ob3dFzNImNBIt5HzyB0iy2/WPDjXflKkNVKnOOF7 T/ZSIVffo/DXFAo4gTauOY/l46Hui66IiO7wd4fHL/0B23UIE37aGMOVmP9s1gXh2+KnCltFSF KKvXSIIYNe0XKxovTkhC+gdxYCpebwuUINABSmdKMNdNdrAY+le+aFV6P7yqRFJvar4LH3SRxF OLIOak+7diSan/2xN8W852c+/Wtcj5kyX9VtQjFWE4QjaWfJO6FOikA0BEL58+F20bSCBsewE/ xe4= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416323; x=1674008324; bh=sj/y8vrFJBlbuclXKh Qf/IHAdoHqQPxC6w+uEVXB90w=; b=GK2pIjwZt4cezlkozgYkyLxHrA0xuFjNYi bLguZ5rOrdTNvCmSbWOKJlUcY6Zxh+wstCgeI4GEADFPbZhMApcCCCuufxdO3D9Y ttemQLsGRh0vUQuPvOEr+xQmUcl7pvMNorVSe5qCNX84TX2KNZBdGypkCaZfPas9 Is/Eo8EMPqh7mQeTOU0ksUWpBFOT4enpWaQzc45NbNERhc36PbydNkvFLJU8vt3T vNzVg7hkdRCrY9ES6zX02hmz2Pi82eSb/9H2lhdGCyIw0Jg7/9Ox1f1C3S9TaXhi F0vTa45OOoz2O+yse0KpKTWGDWEcVh9ucPbzuHO3fXanKQL5Z8xQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis Subject: [PULL 38/45] hw/intc: sifive_plic: Update "num-sources" property default value Date: Mon, 19 Dec 2022 12:16:56 +1000 Message-Id: <20221219021703.20473-39-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416626356100002 Content-Type: text/plain; charset="utf-8" From: Bin Meng At present the default value of "num-sources" property is zero, which does not make a lot of sense, as in sifive_plic_realize() we see s->bitfield_words is calculated by: s->bitfield_words =3D (s->num_sources + 31) >> 5; if the we don't configure "num-sources" property its default value zero makes s->bitfield_words zero too, which isn't true because interrupt source 0 still occupies one word. Let's change the default value to 1 meaning that only interrupt source 0 is supported by default and a sanity check in realize(). While we are here, add a comment to describe the exact meaning of this property that the number should include interrupt source 0. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-9-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/intc/sifive_plic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index 9cb4c6d6d4..1edeb1e1ed 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -363,6 +363,11 @@ static void sifive_plic_realize(DeviceState *dev, Erro= r **errp) =20 parse_hart_config(s); =20 + if (!s->num_sources) { + error_setg(errp, "plic: invalid number of interrupt sources"); + return; + } + s->bitfield_words =3D (s->num_sources + 31) >> 5; s->num_enables =3D s->bitfield_words * s->num_addrs; s->source_priority =3D g_new0(uint32_t, s->num_sources); @@ -420,7 +425,8 @@ static const VMStateDescription vmstate_sifive_plic =3D= { static Property sifive_plic_properties[] =3D { DEFINE_PROP_STRING("hart-config", SiFivePLICState, hart_config), DEFINE_PROP_UINT32("hartid-base", SiFivePLICState, hartid_base, 0), - DEFINE_PROP_UINT32("num-sources", SiFivePLICState, num_sources, 0), + /* number of interrupt sources including interrupt source 0 */ + DEFINE_PROP_UINT32("num-sources", SiFivePLICState, num_sources, 1), DEFINE_PROP_UINT32("num-priorities", SiFivePLICState, num_priorities, = 0), DEFINE_PROP_UINT32("priority-base", SiFivePLICState, priority_base, 0), DEFINE_PROP_UINT32("pending-base", SiFivePLICState, pending_base, 0), --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167141675427832.91957678591132; Sun, 18 Dec 2022 18:25:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75kD-0001pA-QE; Sun, 18 Dec 2022 21:19:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75k3-0001hn-P1 for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:00 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75k1-0001CM-VC for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:59 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:46 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:37:03 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:47 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Kg0PHKz1RwqL for ; Sun, 18 Dec 2022 18:18:47 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TS9uURvHeteC for ; Sun, 18 Dec 2022 18:18:46 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Kc2kW0z1RvLy; Sun, 18 Dec 2022 18:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416337; x=1702952337; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3esrjL+0ACOe7jvODgUx8nE+o14tGGAQ9W+P0DFAYvY=; b=Ulk505pvnsuq2v5qyR19PAsPDXNbzbM5n1ZruxaIWMA034KEt0JtCgZH JH2rt66NzOOWl1lagRZOIwk4oJCqYv9bjOO9taz83OR0wU1+cNaX1VkOL cDs56qfCXCY1MDiJ3myTc9z8fmAEkQPhKJ0Ct+RRJDFlO1DLQtb3g6sWj Ug1JhJPI9eLpiVSzhUTpH6Cl9404pgK/k0Krs9B5aQAdC8vLDDDm3EjLi a8rlgAYMVZ7YwCgZ0iyKjxuScbkPrtzJ65ParpQEWxFryWgAdbizgh0U1 3LTFKqW9vNI2LDRrG9vuLqDcTQKQGLn1imXfMuFZYFEp1bGW6t7+s33T0 w==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056823" IronPort-SDR: tkO1a9CFfVTrhXng3gCCmfM+yOnyjXXhg/gSZVx+UB8J+jGSQ+7cRzZEYQkfUbwY5qUX0JtdFo ugodTL+Gss0jwytS88nUo6+jJ+obVOpF6vTWJ9i0lCkFe9eoWb7kQrffdgVJmAoB5LvCLl//J+ 7HdnFQ466wZAAfXgm/jPYhRuY914WFCV4oslyQo9NO1jJJRVNPe7OqKtTUcYVMma3dVtqN5XSH BBa5llAM29KI7OSwdi5NNWkLeYX1y28mGE0ZqHmKCltwjAlGjd2x6Z9cXKhKj4FYhNTTcmGDVm 3m0= IronPort-SDR: G2t0Bu/hR6k9OwYoneUfy/jnJekoOmX+5+Dj09R9Dhefebbb/dnTtCgIwEnVgNbmSgoUZqoLX0 l62Ueu4sOs6RrnLnkWOwG1eLk7uboN/3qLUquunyeV+xu+wFlVPoiremcxIYbbWeBb7VE1I+6d gxZ2rlJL2iZI0Pg5d5K/uxC2+trMjZKe1wNYisrE+u2UG+j44O/9bwGHnATI2MrrBiaz8gaYQG NdcmVqhIjTKVYiaLRB8S1qGZXfwDcFMrIjvMgjWaI62WzuuSg2V1kNdaGLqG11Gy51o/THooz/ xZU= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416326; x=1674008327; bh=3esrjL+0ACOe7jvODg Ux8nE+o14tGGAQ9W+P0DFAYvY=; b=gwLdqsleSu4AsS7IUBaE6GMb+L6AH7osH3 YoLF/jRByV/7xkR+vvoBtGi/WuGisXk64dlQuTJbxslLv4CV+le2Yi9F3BrH7HU1 BO7sKwCxc4SDpxEpwWY3EacGqa787HSyTJcEf0Q756MOSQlwVnq63pXiqVhJKeIh c9/Ibm/b4OM8aQVhijD5GvRSwXIAtfHT5tJTjnjZLuzMb8JbjC0gEK4NOw4PhsnV gnVP/bOAS48RHaGRwryeUtu8p3y3H0wUMZ+jLfrMFYwgcMDa/MIT0FXO6JXmHOwg Iu6auIV8ibuhlnUGxBsirSxXvKBTTwUm/UZm3kt07e5txh95sD3g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Wilfred Mallawa , Alistair Francis , Conor Dooley Subject: [PULL 39/45] hw/riscv: microchip_pfsoc: Fix the number of interrupt sources of PLIC Date: Mon, 19 Dec 2022 12:16:57 +1000 Message-Id: <20221219021703.20473-40-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416754987100005 Content-Type: text/plain; charset="utf-8" From: Bin Meng Per chapter 6.5.2 in [1], the number of interupt sources including interrupt source 0 should be 187. [1] PolarFire SoC MSS TRM: https://ww1.microchip.com/downloads/aemDocuments/documents/FPGA/ProductDocu= ments/ReferenceManuals/PolarFire_SoC_FPGA_MSS_Technical_Reference_Manual_VC= .pdf Fixes: 56f6e31e7b7e ("hw/riscv: Initial support for Microchip PolarFire SoC= Icicle Kit board") Signed-off-by: Bin Meng Reviewed-by: Wilfred Mallawa Reviewed-by: Alistair Francis Reviewed-by: Conor Dooley Message-Id: <20221211030829.802437-10-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchi= p_pfsoc.h index 69a686b54a..577efad0c4 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -153,7 +153,7 @@ enum { #define MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT 1 #define MICROCHIP_PFSOC_COMPUTE_CPU_COUNT 4 =20 -#define MICROCHIP_PFSOC_PLIC_NUM_SOURCES 185 +#define MICROCHIP_PFSOC_PLIC_NUM_SOURCES 187 #define MICROCHIP_PFSOC_PLIC_NUM_PRIORITIES 7 #define MICROCHIP_PFSOC_PLIC_PRIORITY_BASE 0x04 #define MICROCHIP_PFSOC_PLIC_PENDING_BASE 0x1000 --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16714163646421000.1327429753308; Sun, 18 Dec 2022 18:19:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75kF-0001qx-1H; Sun, 18 Dec 2022 21:19:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75k7-0001iQ-3u for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:06 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75k5-0001Ed-3s for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:02 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:49 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:37:06 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:50 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Kj4Yz2z1Rwt8 for ; Sun, 18 Dec 2022 18:18:49 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id apQe3xcL83fh for ; Sun, 18 Dec 2022 18:18:48 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Kf5xKWz1RvTp; Sun, 18 Dec 2022 18:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416340; x=1702952340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RignxIYbKCPHxUnIhIqB+bDCTC2InNMQAhk2vcktKns=; b=BT0cGAUYt4gghnDYc5Yj+CP0N1ErSi9T0+g40fg5IsbBnqUvVNgDN7qy X82s8QhKkCblSHvYuFoCI26Vfte5VHgh/PofYFr/7W/kPuR/XUFcqP21D tEUz9qz14aXsT3c406/Gsyzg7imQajlf2v1v3hxFYz/hgBBpBwMCea57X 6VyiWGUIfi9WbrJgwLIMp2jkGIVRMKNb6UNmkrhWjh+zVKrxl/Mb+Qh1C 2spr5cXio2XQtMl8tpg1gHM4Cl5yoJ2whL4notgSwz9rTIOLpAi3NhoAO JJ1KMeoB5c/GfY2klPrBkSuGttkdhLD0wQda9N9/NF3fTAJxHA+GHlbe2 Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056826" IronPort-SDR: Gltl9f+SfyfNKuQZuTC0DQCTcJ8/Gw9bt/8NJjAQRHFQOLFy6pI3jReJRWQ5AIQ0eLeU0VYJUH IZhTzwVXtJYOpMvcJjXmbFsils3P3TdDvZXxL5+PgAZWx17c6vjaHeOzAopIk236yi+qpbQ+dL /90eNnJM+j4gxbtRr7Y8TJslTod7JnER2dxn0i9h+lSqvQtHdhqUwaFdp4zMtkgFyvBIrI/zJt eHwf9RKwPdodXpTS5FP/Reb1p3lCbOYHa1M43W7rJTD5dIvMDRPJutMlZW3Jt63uveDiYvnadk 10I= IronPort-SDR: eAa8oui0tWLmTtUlr7HhJb9C9o8Sp1upsUL7AbA7itW4z97O6AlSM4gi4aC0e43yX/ZD9rNqF8 3kCPgr+YdohPpiezQQkk/LTNQTJ9clMJmPnT5vdaEZph0u7SaeEemSsBM9gGs3VmCVni8jzoaw bq/zFHB8ojKiN5KEnQeIqiVXq80oTS6jK4RaxLMByWNCUdTyVhDTqn8Y0noW66+wdTBCpQ9r/o q0VBWbciz9YkpK2MLqGvKc6MxycNCq7YwZ1sebbXb5caaue/6qQqvOk9V6tKjvrtraP11KB7Ur 2Do= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416328; x=1674008329; bh=RignxIYbKCPHxUnIhI qB+bDCTC2InNMQAhk2vcktKns=; b=PYDJjHjNLC1rQdCKSVMqpDaBmtKXMv5VCU FzsIMHg91WUgbZ6ZWWv2dnozHgGAiWzoWOsv/2LuZmOZ+hrOUcjj0TE0ZF7HYS5s QARuHAm27tgrZz+QueiM9wk/7xKE3olmTMWJ6uBcsDTOXU3iNZdXvv8E0fiu5dIh qa6MyAqqp2j2mvTJgzwOZ7+4VwvnlhpUDEnAdm+HlK9Usp6gDeKkoQLRUd1shsJx pp/xiiazyfYY4yc4sAkR7N/44sa5wC7KYzpAD2sXv7x0dxWAPNqMLqjBlAtuNwHh Zfk2BjG81PJ7fvDxE0sef3MVy7kAvkxoaqCwA6QmYk7GnTXm0wQw== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Wilfred Mallawa , Alistair Francis Subject: [PULL 40/45] hw/riscv: sifive_e: Fix the number of interrupt sources of PLIC Date: Mon, 19 Dec 2022 12:16:58 +1000 Message-Id: <20221219021703.20473-41-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416366112100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng Per chapter 10 in Freedom E310 manuals [1][2][3], E310 G002 and G003 supports 52 interrupt sources while G000 supports 51 interrupt sources. We use the value of G002 and G003, so it is 53 (including source 0). [1] G000 manual: https://sifive.cdn.prismic.io/sifive/4faf3e34-4a42-4c2f-be9e-c77baa4928c7_f= e310-g000-manual-v3p2.pdf [2] G002 manual: https://sifive.cdn.prismic.io/sifive/034760b5-ac6a-4b1c-911c-f4148bb2c4a5_f= e310-g002-v1p5.pdf [3] G003 manual: https://sifive.cdn.prismic.io/sifive/3af39c59-6498-471e-9dab-5355a0d539eb_f= e310-g003-manual.pdf Fixes: eb637edb1241 ("SiFive Freedom E Series RISC-V Machine") Signed-off-by: Bin Meng Reviewed-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-11-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_e.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h index d738745925..9e58247fd8 100644 --- a/include/hw/riscv/sifive_e.h +++ b/include/hw/riscv/sifive_e.h @@ -82,7 +82,12 @@ enum { }; =20 #define SIFIVE_E_PLIC_HART_CONFIG "M" -#define SIFIVE_E_PLIC_NUM_SOURCES 127 +/* + * Freedom E310 G002 and G003 supports 52 interrupt sources while + * Freedom E310 G000 supports 51 interrupt sources. We use the value + * of G002 and G003, so it is 53 (including interrupt source 0). + */ +#define SIFIVE_E_PLIC_NUM_SOURCES 53 #define SIFIVE_E_PLIC_NUM_PRIORITIES 7 #define SIFIVE_E_PLIC_PRIORITY_BASE 0x04 #define SIFIVE_E_PLIC_PENDING_BASE 0x1000 --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416449197609.0168752944792; Sun, 18 Dec 2022 18:20:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75kG-0001u9-Bf; Sun, 18 Dec 2022 21:19:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kE-0001pm-DT for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:10 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kB-0001Ck-UJ for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:09 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:53 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:37:09 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:53 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Kn0wPHz1RvTr for ; Sun, 18 Dec 2022 18:18:53 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wltj8jmAZ8Hb for ; Sun, 18 Dec 2022 18:18:52 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Kj5jw2z1RvLy; Sun, 18 Dec 2022 18:18:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416347; x=1702952347; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=B4bsb7C+WvHwOgjHhyitFcg8hTn062ir9rkIHz/V44c=; b=PeeFdTyKe3o5R/8U5HD4sF6JQkF5du0cU3Fce1tLg1bOkLNCL4ZalS5h 4voByKdz6HpGaE6hmGtNrh5qko87IkqnmNgLYo2ldC6ZUmmHK8qm5VMJ/ mRa0vtzS6eZ0AH+4Y+Yu00xiuXSFicGz5916VC8+Rg8Sn+/N1pDnJWfmU u05/F0HX7E1aizXxg0I/K9zOd/oaq2khpvUHQQXSyQ1aLZlz1Isb0Vv5T 1jq1vBENVPmogVseyv5ljqDo7swmFYl5BWetz4PkZycVKtHN/66nvwxPO NIg64avfwaWig0UhUfruXGOMw/UGs0bqrIyygI/Drpzq7JhjJRMJR0dIB g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056831" IronPort-SDR: GoxfrGOvGBA2pya5U2lERwbllpaz9/z1jAvxfjDGY2vzS/gcodNc0vgFuLWrwOGYSddVfeB7iJ 8jkLJm+jPh52ShlAmTOkgGIMv0hATVZBVhDFKLnHPk2w8O4XBRK3zaclBwGilZlMcbFLAKi6++ wYOqjnixi2+cOEp5cZQB4SHeHOXdb8i3sPj/aTgpkXushOF3gdL2H+NDbIqd3vVZhp1wa5ZW8Q Jmwd+B+n3/Riz/eExz6Cc187FsOJIxkxR2Ipv+VogRLo1bU8Qq7VPGE5Q1E0LEliBh6nXXbGGZ pQI= IronPort-SDR: lNJ55/bD4Mn+GpG2tS2Th8WpxVfZKi3aK/E6KZenQ9+maFVsHvf8tjuQ6kD70RqYLDKdqOtzg3 Nraqh8Da5xTyu0qjZ6vG25OhEb/hhoDClilNnPXitqW1+a8lnJn9YkuVZS84JyqCkZ3mmJn6tO doBUwRpgCxnCm0t/jafj9Pg2L0o5u4O2JSiYCTVvAtWWy1HnfsIgNZcpzAJNBJkvKsqGgDxP7I xJCfeT/r3a+vaAUEtC5zHz5BN6WIfyN9ZMp3QVebygMNUqSyuFudf6goI+dB7p6m9fk4xLDLU+ NBs= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416332; x=1674008333; bh=B4bsb7C+WvHwOgjHhy itFcg8hTn062ir9rkIHz/V44c=; b=ItIXg9jwX/CRg+59scZc+8TLFY/PC3FFIH i5xE6+ezLFrzcfpmranFT/+7Y4PXYbCBhacbNeZ5lKUuSRbx58f4zyY/IKnaTKg8 VGVDfjl5uE519gfTx1j51T8LcbY162qzJYSyUIYXg5CKAc5ytU8DF1p+8q+NguiK xLdEAt/WnrCGwglSRpNsHTe5C/aqhfbGlukCks6/4JNjjYHBo9bZ821Fk09NGjVm yDD1p/2XObXWVQzum7YZDqSif4zquW71lJORHaRFfj8vLy4MP+iR7ZGdDTvpUG0b Y/guazc5OZYtl+ZdKakx2EaT/H6NC+l3mYdMWWEa0bV8jToxKWQA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Wilfred Mallawa , Alistair Francis Subject: [PULL 41/45] hw/riscv: sifive_u: Avoid using magic number for "riscv, ndev" Date: Mon, 19 Dec 2022 12:16:59 +1000 Message-Id: <20221219021703.20473-42-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416450637100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng At present magic number is used to create "riscv,ndev" property in the dtb. Let's use the macro SIFIVE_U_PLIC_NUM_SOURCES that is used to instantiate the PLIC model instead. Signed-off-by: Bin Meng Reviewed-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-12-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/riscv/sifive_u.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index b139824aab..b40a4767e2 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -287,7 +287,8 @@ static void create_fdt(SiFiveUState *s, const MemMapEnt= ry *memmap, qemu_fdt_setprop_cells(fdt, nodename, "reg", 0x0, memmap[SIFIVE_U_DEV_PLIC].base, 0x0, memmap[SIFIVE_U_DEV_PLIC].size); - qemu_fdt_setprop_cell(fdt, nodename, "riscv,ndev", 0x35); + qemu_fdt_setprop_cell(fdt, nodename, "riscv,ndev", + SIFIVE_U_PLIC_NUM_SOURCES - 1); qemu_fdt_setprop_cell(fdt, nodename, "phandle", plic_phandle); plic_phandle =3D qemu_fdt_get_phandle(fdt, nodename); g_free(cells); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671417071997378.6204829595781; Sun, 18 Dec 2022 18:31:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75kH-0001y1-Dc; Sun, 18 Dec 2022 21:19:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kF-0001tA-Rm for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:11 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kE-0001CM-3J for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:11 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:55 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:37:12 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:55 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Kq2QnGz1RvTp for ; Sun, 18 Dec 2022 18:18:55 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id OvI2MUiCvIeZ for ; Sun, 18 Dec 2022 18:18:55 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Kn4bGCz1RvLy; Sun, 18 Dec 2022 18:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416349; x=1702952349; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qqZZTilR5d2pq+JF0832DzXY6m5V2ZSxxMPDsmHeovY=; b=mM7ut7md9oyYB5vSaQOzBWGjth3Qvx1olcxoYdh0WBIE8KokW5wcVWWI 5PeQO9nn/yFFhJml0XsXW0p0RXDeJclF2FaS4hyuUXfq5IEKUaM0vpuHd /a1NtmS5tLcqcxtNqjek5p8Ov0VLZQAB5ygBBCZbTE+uPdZbmBUYX4ucR qJH+uMbTFqmAseYu4YMMlqoJ1PTVuiNA+CkQBoIKTynvLa1zzced+QtRp COHbEEU89++A0pUwIqGS3ryNrbltLy8BQbVVloBT3hVz0EqgmDjHSYidg INV86SLY+jcu3oEi0gLf7oIjouq0k+XGCx9k5xjNx4+JE1hQnoV9UsQu8 A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056838" IronPort-SDR: XWK0dS4EMxaddPrDJTTCDJdldVD60JcVzmSXthrf62nzDlzMhzBnrekjHa9mlF48RpWy8WQkLG tgDAW27/+PKgZl09WSnxSS8KKiweyQQqZcTZ3eTg9hBapgxyX3F8/JRgbrBeDMtAKu01Vqew6H 6y82vwUrLHCOCuTnQJZUcfmML/sC848uNcjjq1WJU9oKF9jTdvnmG/QASu/1OGWZ5R3e7TV3Ci 6PuARp7U6wrU2Y5gVTwvxFtmzMxCbN+XEluGLh65uYaoP4gD6F71NHCFfZv8AqDyGZdihFwtQN ZOA= IronPort-SDR: y3qfqLMQE19AAUvxRUMCZfWZgz8tM9uZuA+S6yD7K5PfYk3AnXICJh7nZnT8oWshhq3Ww5U/Sz qsZRk9KXwo+NmiiWkbrkJpczdpFjhrc2ZPsOOeOoP3Z6htffzD61cfTHj3oDY+R+je8+hAqSJ8 Fasw+eUMayN9UoWWc43WL3LmNqNE2rQyV9v/HaM8jBLqD45xcZJPSMctqDNiss/EBqbC5RjFuE 1bL62pH+LzHV5/jQq5jY9EoM5HQKCUOUdDyZxNHhLHxsaffPAhVe2zIuoOahfs6WJVlitnMnkV uNA= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416335; x=1674008336; bh=qqZZTilR5d2pq+JF08 32DzXY6m5V2ZSxxMPDsmHeovY=; b=YKxdRAXsw36lwrpyrS9qKLYRY0H+p3vB4b nP7O2DhyjA9LjttC2reP/sJoOAJu8uUoemciP/qufSqnbfOg0l1AE8B2kycXUh1R 1ijgw+fisaV/itp3mxuLXCeDa4vzLZbI1TXTjVwwkFK5miyfi8Wh2SxtwQmfxNvr GkRs9Q4bYUVkjdMPTFflp6/6/OP/VSRMMr4GMiAS0bKmRFBtrLpLTirgyomiZRao 7B0AeOU4DtPpvFfcXn5DefUo/N4pKh5yM5vQ4+9OH6rlpJKVWdgb5SQ4rp8zgk7A anqv0bMCEcSjinK/woxH9Gt7Zlw0xrjFoZOqF8ex/NyusOtAfZ5A== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis Subject: [PULL 42/45] hw/riscv: virt: Fix the value of "riscv, ndev" in the dtb Date: Mon, 19 Dec 2022 12:17:00 +1000 Message-Id: <20221219021703.20473-43-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671417072500100001 Content-Type: text/plain; charset="utf-8" From: Bin Meng Commit 28d8c281200f ("hw/riscv: virt: Add optional AIA IMSIC support to vir= t machine") changed the value of VIRT_IRQCHIP_NUM_SOURCES from 127 to 53, which is VIRTIO_NDEV and also used as the value of "riscv,ndev" property in the dtb. Unfortunately this is wrong as VIRT_IRQCHIP_NUM_SOURCES should include interrupt source 0 but "riscv,ndev" does not. While we are here, we also fix the comments of platform bus irq range which is now "64 to 96", but should be "64 to 95", introduced since commit 1832b7cb3f64 ("hw/riscv: virt: Create a platform bus"). Fixes: 28d8c281200f ("hw/riscv: virt: Add optional AIA IMSIC support to vir= t machine") Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-13-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- include/hw/riscv/virt.h | 5 ++--- hw/riscv/virt.c | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 62513e075c..e1ce0048af 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -87,14 +87,13 @@ enum { VIRTIO_IRQ =3D 1, /* 1 to 8 */ VIRTIO_COUNT =3D 8, PCIE_IRQ =3D 0x20, /* 32 to 35 */ - VIRT_PLATFORM_BUS_IRQ =3D 64, /* 64 to 96 */ - VIRTIO_NDEV =3D 96 /* Arbitrary maximum number of interrupts */ + VIRT_PLATFORM_BUS_IRQ =3D 64, /* 64 to 95 */ }; =20 #define VIRT_PLATFORM_BUS_NUM_IRQS 32 =20 #define VIRT_IRQCHIP_NUM_MSIS 255 -#define VIRT_IRQCHIP_NUM_SOURCES VIRTIO_NDEV +#define VIRT_IRQCHIP_NUM_SOURCES 96 #define VIRT_IRQCHIP_NUM_PRIO_BITS 3 #define VIRT_IRQCHIP_MAX_GUESTS_BITS 3 #define VIRT_IRQCHIP_MAX_GUESTS ((1U << VIRT_IRQCHIP_MAX_GUESTS_BITS) - 1U) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 6cf9355b99..94ff2a1584 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -468,7 +468,8 @@ static void create_fdt_socket_plic(RISCVVirtState *s, plic_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 4); qemu_fdt_setprop_cells(mc->fdt, plic_name, "reg", 0x0, plic_addr, 0x0, memmap[VIRT_PLIC].size); - qemu_fdt_setprop_cell(mc->fdt, plic_name, "riscv,ndev", VIRTIO_NDEV); + qemu_fdt_setprop_cell(mc->fdt, plic_name, "riscv,ndev", + VIRT_IRQCHIP_NUM_SOURCES - 1); riscv_socket_fdt_write_id(mc, mc->fdt, plic_name, socket); qemu_fdt_setprop_cell(mc->fdt, plic_name, "phandle", plic_phandles[socket]); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416612759722.8535334778207; Sun, 18 Dec 2022 18:23:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75kO-00026U-2U; Sun, 18 Dec 2022 21:19:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kJ-00022D-Jy for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:18 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kH-0001Ed-EM for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:15 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:57 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:37:14 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:58 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Ks67Mkz1RvTr for ; Sun, 18 Dec 2022 18:18:57 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MP-iGhhglPi2 for ; Sun, 18 Dec 2022 18:18:57 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Kq606Sz1RvLy; Sun, 18 Dec 2022 18:18:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416353; x=1702952353; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=33ydBuzuBnZFvlbDBH6+hF4mtGaD+zrqRMjuDlazzLE=; b=OZgcVOU6dnU5gOLtc2jMH5Wvq6H0b32CWjA5QcBh7difonzjPqNy3fxP hlo9QVDVCjriMv7TJfdqtw/dwR7WwFMw7pv8vPWz5K6DuKDCi3IBUJ5FL 1c1NURUtHxvS2kHgqPL2Wryo+RJfyCLQx69QOB7wvLXua/fHDTdxNrQwa MfHE0PedMdvg2eGbMfJjHKwRkyx/yRx4XU1jIoTXWdeVKgbCS0U5sQidS RL1yy1riTWqJfrQz8UdIrAGrNFLjUf/zazeUMThxgbGeDq9bJTIn+f4Tf gIMFCRo6Ctx7dNP1wdXF9UTdMw4JOIRvrN0qYeNM4ttMdhZfEUGlttYkO Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056841" IronPort-SDR: eLGblgbur4Q1LoW+/IBS1KdE9BkuvP57fzUCcQlyEAm7TWRorCwhW3Ocy4tRlofiYZf/IbtVSn /m1CbIPaGYSjAq2p/Q0LUdsRiA5viczDcA+rzq+8omqh9xeGQs8t4yGM1oBnCa8MX01QghMN1o HnyK00WnHPXxlRJIViUUTx/CNdcGAbSKrVvheenry1peHiySedM8VdLlm/wKv32PA5W0xt+MGD 2FtaSmH1tFHq8xNxYOz1kKzjyvMroX4dsPGymSYHvFxf6Map7etuBGdjW7Cb3/940yLI+5R8a8 Lag= IronPort-SDR: w8MJ650R+gdzzZzRE3Bx+VbVvpMepO8sWCfHwttjU37AmHc8RgOZ435ePQPd4D9kWM2ElffqKQ pPyGNm9R1YivljcHjkDkLgLB+Uhgmnh27mcmtbt3/JJ0qx5Qg1ujg7M5FrTP/OYiBFRc+K45xL ngYUO1xDPuntyDo0LE5LYRRMmqZs+GYCE78+BQESM0iNisWmbtMP2XDgNGkI53JRxnvvu8+PAj CwfyahZNbwkVOPrwBBOL7rcm6aOyq37oNZWCaupZVu+Uejh2M1ChOwsDFKtE0ML0c3ixZA7tw2 q08= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416337; x=1674008338; bh=33ydBuzuBnZFvlbDBH 6+hF4mtGaD+zrqRMjuDlazzLE=; b=C6I5OiEII5WEu/vDcZ70Osc+DMyQLeKBov /prYcM4VgEh6jjywoChAlE0KqgLdo44WPgsGSmepfreIwez3YT5iLiYS93g7e+Wd tWqCokieFAlkTwr6nxDZAeZzLoKooMU/AtxLlac/bsB2/VoYEqAoeZ/WAPunhtp2 suSeRhrQR8NXlUVeuMaTK8Nv2q5lIYI89mgBrIADJXhJaxnginjR+B0U9/mBuzre PMnyymrdu6pcAi7EHurIV7v3cPWaOWXGlmUCsrWlpjrSRUDBJ6ctO78cJ+1/3ftW eA6Kn/1Qs4uU4slMQZzqKptuHz5t1Iy6MmY8LeDOfIfs6S62bE6A== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis , Wilfred Mallawa Subject: [PULL 43/45] hw/intc: sifive_plic: Change "priority-base" to start from interrupt source 0 Date: Mon, 19 Dec 2022 12:17:01 +1000 Message-Id: <20221219021703.20473-44-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416614304100007 Content-Type: text/plain; charset="utf-8" From: Bin Meng At present the SiFive PLIC model "priority-base" expects interrupt priority register base starting from source 1 instead source 0, that's why on most platforms "priority-base" is set to 0x04 except 'opentitan' machine. 'opentitan' should have set "priority-base" to 0x04 too. Note the irq number calculation in sifive_plic_{read,write} is correct as the codes make up for the irq number by adding 1. Let's simply update "priority-base" to start from interrupt source 0 and add a comment to make it crystal clear. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Reviewed-by: Wilfred Mallawa Message-Id: <20221211030829.802437-14-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- include/hw/riscv/microchip_pfsoc.h | 2 +- include/hw/riscv/shakti_c.h | 2 +- include/hw/riscv/sifive_e.h | 2 +- include/hw/riscv/sifive_u.h | 2 +- include/hw/riscv/virt.h | 2 +- hw/intc/sifive_plic.c | 5 +++-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchi= p_pfsoc.h index 577efad0c4..e65ffeb02d 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -155,7 +155,7 @@ enum { =20 #define MICROCHIP_PFSOC_PLIC_NUM_SOURCES 187 #define MICROCHIP_PFSOC_PLIC_NUM_PRIORITIES 7 -#define MICROCHIP_PFSOC_PLIC_PRIORITY_BASE 0x04 +#define MICROCHIP_PFSOC_PLIC_PRIORITY_BASE 0x00 #define MICROCHIP_PFSOC_PLIC_PENDING_BASE 0x1000 #define MICROCHIP_PFSOC_PLIC_ENABLE_BASE 0x2000 #define MICROCHIP_PFSOC_PLIC_ENABLE_STRIDE 0x80 diff --git a/include/hw/riscv/shakti_c.h b/include/hw/riscv/shakti_c.h index daf0aae13f..539fe1156d 100644 --- a/include/hw/riscv/shakti_c.h +++ b/include/hw/riscv/shakti_c.h @@ -65,7 +65,7 @@ enum { #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_PRIORITY_BASE 0x00 #define SHAKTI_C_PLIC_PENDING_BASE 0x1000 #define SHAKTI_C_PLIC_ENABLE_BASE 0x2000 #define SHAKTI_C_PLIC_ENABLE_STRIDE 0x80 diff --git a/include/hw/riscv/sifive_e.h b/include/hw/riscv/sifive_e.h index 9e58247fd8..b824a79e2d 100644 --- a/include/hw/riscv/sifive_e.h +++ b/include/hw/riscv/sifive_e.h @@ -89,7 +89,7 @@ enum { */ #define SIFIVE_E_PLIC_NUM_SOURCES 53 #define SIFIVE_E_PLIC_NUM_PRIORITIES 7 -#define SIFIVE_E_PLIC_PRIORITY_BASE 0x04 +#define SIFIVE_E_PLIC_PRIORITY_BASE 0x00 #define SIFIVE_E_PLIC_PENDING_BASE 0x1000 #define SIFIVE_E_PLIC_ENABLE_BASE 0x2000 #define SIFIVE_E_PLIC_ENABLE_STRIDE 0x80 diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index 8f63a183c4..e680d61ece 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -158,7 +158,7 @@ enum { =20 #define SIFIVE_U_PLIC_NUM_SOURCES 54 #define SIFIVE_U_PLIC_NUM_PRIORITIES 7 -#define SIFIVE_U_PLIC_PRIORITY_BASE 0x04 +#define SIFIVE_U_PLIC_PRIORITY_BASE 0x00 #define SIFIVE_U_PLIC_PENDING_BASE 0x1000 #define SIFIVE_U_PLIC_ENABLE_BASE 0x2000 #define SIFIVE_U_PLIC_ENABLE_STRIDE 0x80 diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index e1ce0048af..3407c9e8dd 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -98,7 +98,7 @@ enum { #define VIRT_IRQCHIP_MAX_GUESTS_BITS 3 #define VIRT_IRQCHIP_MAX_GUESTS ((1U << VIRT_IRQCHIP_MAX_GUESTS_BITS) - 1U) =20 -#define VIRT_PLIC_PRIORITY_BASE 0x04 +#define VIRT_PLIC_PRIORITY_BASE 0x00 #define VIRT_PLIC_PENDING_BASE 0x1000 #define VIRT_PLIC_ENABLE_BASE 0x2000 #define VIRT_PLIC_ENABLE_STRIDE 0x80 diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index 1edeb1e1ed..1a792cc3f5 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -140,7 +140,7 @@ static uint64_t sifive_plic_read(void *opaque, hwaddr a= ddr, unsigned size) SiFivePLICState *plic =3D opaque; =20 if (addr_between(addr, plic->priority_base, plic->num_sources << 2)) { - uint32_t irq =3D ((addr - plic->priority_base) >> 2) + 1; + uint32_t irq =3D (addr - plic->priority_base) >> 2; =20 return plic->source_priority[irq]; } else if (addr_between(addr, plic->pending_base, plic->num_sources >>= 3)) { @@ -187,7 +187,7 @@ static void sifive_plic_write(void *opaque, hwaddr addr= , uint64_t value, SiFivePLICState *plic =3D opaque; =20 if (addr_between(addr, plic->priority_base, plic->num_sources << 2)) { - uint32_t irq =3D ((addr - plic->priority_base) >> 2) + 1; + uint32_t irq =3D (addr - plic->priority_base) >> 2; =20 if (((plic->num_priorities + 1) & plic->num_priorities) =3D=3D 0) { /* @@ -428,6 +428,7 @@ static Property sifive_plic_properties[] =3D { /* number of interrupt sources including interrupt source 0 */ DEFINE_PROP_UINT32("num-sources", SiFivePLICState, num_sources, 1), DEFINE_PROP_UINT32("num-priorities", SiFivePLICState, num_priorities, = 0), + /* interrupt priority register base starting from source 0 */ DEFINE_PROP_UINT32("priority-base", SiFivePLICState, priority_base, 0), DEFINE_PROP_UINT32("pending-base", SiFivePLICState, pending_base, 0), DEFINE_PROP_UINT32("enable-base", SiFivePLICState, enable_base, 0), --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416870328984.206809926126; Sun, 18 Dec 2022 18:27:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75kT-0002DK-8O; Sun, 18 Dec 2022 21:19:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kQ-0002An-6A for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:22 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kO-0001Ck-Im for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:21 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:59 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:37:16 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:19:00 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Kv75Qgz1RwqL for ; Sun, 18 Dec 2022 18:18:59 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QyrHHTsb-mmL for ; Sun, 18 Dec 2022 18:18:59 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Ks5fmkz1RvTp; Sun, 18 Dec 2022 18:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416360; x=1702952360; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FyJflZSfGCFJuxVWGryLkKV05Gzhy7oKc/Efd3wNjjA=; b=le1en8ffEN5Kaxd3FWq4frMFTVU/n7r/DIgJV7aAmzJUiMQSozCCBd1U AlD33296+oKAiEs3/rJIe9UWdDyqqJRWE0cQJ8sW5ZxpjMZe0uUg0B4G1 YA14Ag0aITkLa9nvnw4OGl28gAgpbnRvIqtE3BKlMqW8OqLeC/03lF/gM FCTNUagIgOC+CScxRdFP7R48vnVQP8C07ZiorP7UjC6U9me3xTAIckE/M 74RY/Z+ASR2AhVwvHoiDzEeR6tb9q1cCEl/wJs1WPzny8zq2jZmLwVSiG 55wfU6f9PHZDXxnqiI4vgPLKFA7qR9UxFWBBcOLIgOZ/R6k6JDU/xYKAV A==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056843" IronPort-SDR: nWFokBQDrmyidz9j0ruvGWeVC2q2NXv+N7cief6FgZknkrQtcdWCO1kXyY4mSrBnea0FR7aVAf r7z5210KX2Q5FraCTkDZohwoiGjFv1S4gBSlVAfXrfSIvT1Zjx+HKuUydTRqqNoo2z2MDAUWk9 Ozc/2biBs8UoIQpHnpxx6SAT1u6wobt1KdzVgp0SLSggGhhLGMKbhB8JdlY4Ab4aaEJ/bbf04g fASM/uL6LZ4EPY/TB8hrEgsrxyrbGeOoE5wZC1uP3U+FWAB5QCG+tnFesKc7Cex+tP7b66rnS1 Oqw= IronPort-SDR: SppTiwNc5nUwKIXME8IgQ6ktCTh6nw4SVHYxidtBZEOJdgJ4ytQ158imaO5l9WQHf6fmV35ao3 3MaqNE34YB8TW4GNzVzsacu1V5a2OFv3GuwZQ3ilFcXJV5XDa+HPyWt0Tg+g72c1GGimDaA135 JjjV0Fr3CZrBWV0fmaIYHFYRX+oHBM/2h+Y3ZFZMRTMeqEj6q7sD5G++1BjmNDRw9J/K4cK78a 4CO5IQZHg7nVsnifCKDV/XSVic6Qrq0Cj6wVoEx4Ks7tXEbm5YqPcoZqvqxdKlP+ERLGUcDTCu gGk= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416339; x=1674008340; bh=FyJflZSfGCFJuxVWGr yLkKV05Gzhy7oKc/Efd3wNjjA=; b=hgKSQ6w1YD4woPX14IL9zCWdW6Ex84HyEg NipmoQ8cA4WOltqutv59SP2YIm+ASC1XEYfeh24sU/XBD6SJfaxowsQjyGmGy70C ByW1xGPuIcMqEEmPm0y4G/3GtIqgdK1aMSCWZe5FT0UXD/7ScFKRzzKEpCV22G7Q 8WV8EcLQ/PMEs95zKFv4zjA8iRjKFXbQCX27WXUWQIVbvjjx2G7R7EeWlhac/skt qTA/4Y5ZZKla3iP9/LlfWfmDNDeZEFFa79m+Li2NTGuQxqUx0Tc/wKldv1lmW9v5 jSwwQDDfGJqMjJ6a3T1DsxGlw0NRXgJSKkTjhRYhLeWIKXjcy5UQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Wilfred Mallawa , Alistair Francis Subject: [PULL 44/45] hw/riscv: opentitan: Drop "hartid-base" and "priority-base" initialization Date: Mon, 19 Dec 2022 12:17:02 +1000 Message-Id: <20221219021703.20473-45-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416871643100003 Content-Type: text/plain; charset="utf-8" From: Bin Meng "hartid-base" and "priority-base" are zero by default. There is no need to initialize them to zero again. Signed-off-by: Bin Meng Reviewed-by: Wilfred Mallawa Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-15-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/riscv/opentitan.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 78f895d773..85ffdac5be 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -173,10 +173,8 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_= soc, Error **errp) =20 /* PLIC */ qdev_prop_set_string(DEVICE(&s->plic), "hart-config", "M"); - qdev_prop_set_uint32(DEVICE(&s->plic), "hartid-base", 0); qdev_prop_set_uint32(DEVICE(&s->plic), "num-sources", 180); qdev_prop_set_uint32(DEVICE(&s->plic), "num-priorities", 3); - qdev_prop_set_uint32(DEVICE(&s->plic), "priority-base", 0x00); qdev_prop_set_uint32(DEVICE(&s->plic), "pending-base", 0x1000); qdev_prop_set_uint32(DEVICE(&s->plic), "enable-base", 0x2000); qdev_prop_set_uint32(DEVICE(&s->plic), "enable-stride", 32); --=20 2.38.1 From nobody Wed May 15 07:37:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=quarantine dis=quarantine) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1671416797232762.583990930496; Sun, 18 Dec 2022 18:26:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75kb-0002PY-DA; Sun, 18 Dec 2022 21:19:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kT-0002H6-0A for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:25 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75kQ-0001CM-7U for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:19:23 -0500 Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:19:02 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:37:19 -0800 Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:19:03 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3Ky4XKzz1Rwrq for ; Sun, 18 Dec 2022 18:19:02 -0800 (PST) Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QpTspKkyIJ1X for ; Sun, 18 Dec 2022 18:19:02 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3Kw1Zkyz1RvLy; Sun, 18 Dec 2022 18:18:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416361; x=1702952361; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VhJier8Sfagp/2bmB4q0y6I9QpcKcN4XDbRExd/aw3w=; b=lWnXc1QzKt3RhXFCiE8NMGSkT24kQ92u0wNnBIKNXFLGlDrXNesghjUT iG967RBKU0+INkYaOYwKWYPJFkpi8xs/TJLbAQ5jvf2kh5hOkDDvFg7wi k5RnYFar6v3FDQkx76BwuUaRHV8jicR4MF/a8BP40g9M13bXG2452Fdz/ W7bKp6NYYe3CQfssPnnvhuKseNDEstXxftol8A3NTLz4DD+KxucCQffmD uZaEZYdyh4JBRq36pSHkjNT/Rt0drhl0oraVv8WDr5Yt0voUYLFbtEG9U XL5SRbfSaml9aNJSEB92ekDe/Ot6Etw+o4aacRklU2n6Kb86H6NVAlVSX Q==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="331056846" IronPort-SDR: KTh9JM8Q3zg4bESiRCwCTB2Vpi2Mu3CRDpHpzoV/QxeT0Lm9AFv2CZa1Qp9f5PmInLPj/cjsWp p6VQLvhr+5a24vSAHITPHMWpiGVhi+3NLDpFIsJtiXyv7t4qtZvwr4BM6rITeAVrpgrxRMAGg3 hF3k1a363AjRVSaGDo7raTAUm8EAggSf/UvMeX4Pq3BtnwRV3KOqdM60TLaShXqLe1ge9TScs+ HazjpZTwLb0K7MdiE0PIdr8MSGA8wb25sN6kTLKvxH+FoyH31xl0UdgunWWibRA4Gc/1aIiGVN Py4= IronPort-SDR: uk4EelR0yHWKsJirojzjU3MBlwCUknZk5sRPLOIQiyMr6UmG4TsHnKSCjMO3Ev6qfZeop0LIpm xPHWFJUCLonfvDrQNPqGKHTtSp5Wc6K4arDCyrbWwiGZrf2nsqWSeSj5K7jy6uA7ZfXEqMvdbI gYO6MfkDtc32yvCLN1hlTJa8MtOMHdcJeLbeFTobxaTyiJ7yGYVu9CTFdcycM88Ckoos5JakPV 9K0wUbPbTujxPfoFrd1RKFSpBt4V1BYEm2Qg13D/HKlg/lOmniOqtKbZiPsdR1+Uuay7Zx7gzF 6NA= WDCIronportException: Internal Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1671416342; x=1674008343; bh=VhJier8Sfagp/2bmB4 q0y6I9QpcKcN4XDbRExd/aw3w=; b=pXwB46a0Ajr/LdermCz2+dYUl3fRy4/TC8 A5efY5spvx+VDoMW7KYjynpK7pMhz3CTHGpGPL6/obwxY9FmZNhhq2A0XQqGZGfP WFkBpryp9QV0mY5vcYCfZdX7Ex4niVBtG6ItlSy1UdfcnmWr4jwOwVUDtjKZ0lv7 3VVU2Go1WawlKBUCdbnJE2lDmbebEF1L/M3iXMq7U7iciKR9v1bgT9/BXiF7vAQn WJGcITkEwXhD2Rm199Sh2VXFUJJMK5g2dTPaZutd5rUMRRtKuyeQGkLY0ZYoFLrP CmslU1uIye2GV7kqCjQzzEfpnSMD4lfaRowkTWrsmQmMUoqniMgA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Bin Meng , Alistair Francis Subject: [PULL 45/45] hw/intc: sifive_plic: Fix the pending register range check Date: Mon, 19 Dec 2022 12:17:03 +1000 Message-Id: <20221219021703.20473-46-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa1.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1671416799280100003 Content-Type: text/plain; charset="utf-8" From: Bin Meng The pending register upper limit is currently set to plic->num_sources >> 3, which is wrong, e.g.: considering plic->num_sources is 7, the upper limit becomes 0 which fails the range check if reading the pending register at pending_base. Fixes: 1e24429e40df ("SiFive RISC-V PLIC Block") Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <20221211030829.802437-16-bmeng@tinylab.org> Signed-off-by: Alistair Francis --- hw/intc/sifive_plic.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index 1a792cc3f5..5522ede2cf 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -143,7 +143,8 @@ static uint64_t sifive_plic_read(void *opaque, hwaddr a= ddr, unsigned size) uint32_t irq =3D (addr - plic->priority_base) >> 2; =20 return plic->source_priority[irq]; - } else if (addr_between(addr, plic->pending_base, plic->num_sources >>= 3)) { + } else if (addr_between(addr, plic->pending_base, + (plic->num_sources + 31) >> 3)) { uint32_t word =3D (addr - plic->pending_base) >> 2; =20 return plic->pending[word]; @@ -202,7 +203,7 @@ static void sifive_plic_write(void *opaque, hwaddr addr= , uint64_t value, sifive_plic_update(plic); } } else if (addr_between(addr, plic->pending_base, - plic->num_sources >> 3)) { + (plic->num_sources + 31) >> 3)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid pending write: 0x%" HWADDR_PRIx "", __func__, addr); --=20 2.38.1