From patchwork Mon Feb 12 17:11:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Irina Ryapolova X-Patchwork-Id: 13553768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 491D7C48297 for ; Mon, 12 Feb 2024 17:13:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZZrB-00067Z-A2; Mon, 12 Feb 2024 12:12: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 1rZZr9-00066o-7i; Mon, 12 Feb 2024 12:12:35 -0500 Received: from mta-04.yadro.com ([89.207.88.248]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZZr7-0004S8-Hj; Mon, 12 Feb 2024 12:12:34 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com 05990C0003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1707757944; bh=s/XN3CO0iJeMqY5zI5HVlTnKgwEGUPwXTodK87ckfDQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=IqUwrcu9F95LkOvhuAd3Gb/B33RKr4V+8YUlAamO3kKIIB5ktz5HKE9Jl3PAY70BM w1WeMCLu//ByqaWa9iYZ/Q05ASrUmUziE9Q++r/akML0Zkfx+yrDf+8YDgxpEkXDz0 01Jshw9LsLbPrLSoE8Z0kogrbHzsGH+XcB3cg3kWMAt9OAzVk+WrFzfuLJcIbM+Qz2 eKp00VJ4Pvb8DIbkusrZu85DR7v6RyUtXPgAIbYSV1GTpJf5kVSrBcJRRy78YE6zc5 kcNPUj1KesLjqFP2jyE2sY9NKAAYST0Mieky7RB4AyfgDSygHjbqTuRyBWcoz2qKjp OE7Q68vF5ilHQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1707757944; bh=s/XN3CO0iJeMqY5zI5HVlTnKgwEGUPwXTodK87ckfDQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=HBNP5jkwVCECcVWgUHgH6WYPAwn4XG0fuGQ2lS19BYDfPE6oaLJgiitAH2L1T12LQ 4oEnX/EGOcdFl9Nsp8Ip+dCDHera12aqfHRUlpmL+GDrghFDC0cPJKWVkZZaA2tsFI 0QF6UrA/hxVWRIepdNZeouOeDRA71PlRRiIckvMqrZDphDMk9rmjKNHbI3PI35RGiI rEmUzxURgnec4ChRsuzWdtQSMc6if14+CIJ6lmky1jcNE/zmfilQE20DLFsutez1HX MkUM+lcVHMv56Lzux0gbpMkrEApx2R2h/mvpM11PywHxMrvu3fZtgNEqlO7qgG0oX7 6Ts3D1FwZmV7g== From: Irina Ryapolova To: CC: , , , , , , , Irina Ryapolova Subject: [PATCH 1/2] target/riscv/csr.c: Add functional of hvictl CSR Date: Mon, 12 Feb 2024 20:11:55 +0300 Message-ID: <20240212171156.47293-1-irina.ryapolova@syntacore.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-ClientProxiedBy: T-Exch-05.corp.yadro.com (172.17.10.109) To S-Exch-01.corp.yadro.com (10.78.5.241) Received-SPF: permerror client-ip=89.207.88.248; envelope-from=irina.ryapolova@syntacore.com; helo=mta-04.yadro.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_PERMERROR=0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org CSR hvictl (Hypervisor Virtual Interrupt Control) provides further flexibility for injecting interrupts into VS level in situations not fully supported by the facilities described thus far, but only with more active involvement of the hypervisor. (See riscv-interrupts-1.0: Interrupts at VS level) Signed-off-by: Irina Ryapolova --- target/riscv/csr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 674ea075a4..0c21145eaf 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3585,6 +3585,21 @@ static int read_hvictl(CPURISCVState *env, int csrno, target_ulong *val) static int write_hvictl(CPURISCVState *env, int csrno, target_ulong val) { env->hvictl = val & HVICTL_VALID_MASK; + if (env->hvictl & HVICTL_VTI) + { + uint32_t hviid = get_field(env->hvictl, HVICTL_IID); + uint32_t hviprio = get_field(env->hvictl, HVICTL_IPRIO); + /* the pair IID = 9, IPRIO = 0 generally to represent no interrupt in hvictl. */ + if (!(hviid == IRQ_S_EXT && hviprio == 0)) { + uint64_t new_val = BIT(hviid) ; + if (new_val & S_MODE_INTERRUPTS) { + rmw_hvip64(env, csrno, NULL, new_val << 1, new_val << 1); + } else if (new_val & LOCAL_INTERRUPTS) { + rmw_hvip64(env, csrno, NULL, new_val, new_val); + } + } + } + return RISCV_EXCP_NONE; } From patchwork Mon Feb 12 17:11:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Irina Ryapolova X-Patchwork-Id: 13553767 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36492C4829C for ; Mon, 12 Feb 2024 17:13:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZZrA-00067J-JO; Mon, 12 Feb 2024 12:12: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 1rZZr8-00066n-Pl; Mon, 12 Feb 2024 12:12:35 -0500 Received: from mta-04.yadro.com ([89.207.88.248]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rZZr6-0004SY-Lx; Mon, 12 Feb 2024 12:12:34 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com 87BA1C0003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1707757946; bh=p2He24Co5aJs3M9K5ZmUnK0CvHWqfjQF8RaDer3mx0Q=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=XerkAYSzxjKv/a4zIGwt3qKmOGGLCqYAkMtUZbrOvOZRR7N64G6Y8cnqahX9MH7K5 QNjPHRYeIqhZ8ZHuT5Kjf/t/Qs1S50GCdPWXGlnBHMZDdoUIK54Pn0PIcWU3Z4R/Hk 0vwc1RVU1qQ6tYIjQ9t05SwwzVXEJRQWjETytqN1tl2sW0NyXVNj4g+lkjYtE2ZVZ+ wsITPZQ+LaOtECGOsh4ryduo46lk02EGxNIoI51veQwvcqtD5NwGzaaeJuh1CPu49Q 2LQVRPCHqufVaqPXS8fiVLth318BjvXyUd1oPS/H6JSemw+54iV9Hhp3Hr7Sasrvz3 ZMOUmdGIUsRXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1707757946; bh=p2He24Co5aJs3M9K5ZmUnK0CvHWqfjQF8RaDer3mx0Q=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=gnCbbG9Om2Snb73XMt83IVwoYHnUlg2vDWijlBYk/DZb5Ywj89KyYU9tt86SXc+Ij 5FFZIGmzB4K0BeFOBF++CtApNC0ANqIswqOy6KKXy3UcjhEAf6hY320A3QyU9RpzKk PAxHNTX1DjOSuzlCBN3m6ElbS/xiIatC/rFTr8Ios8mmjZ8QsRif18nfVY+nARUUbs wmF1wjSWd3LPatGqAQfbXkvKSC/ztEAxM92RovcaujKMQQT0QJc9WEXcsg+07eE8Yi MNslPfbufwnQrdXiY5f81eye/d11gEE3cKj3+c7+zh7fzuG8+7xKJTSI2r+g9tZHvQ I5E9Tmgn7oy8A== From: Irina Ryapolova To: CC: , , , , , , , Vadim Shakirov Subject: [PATCH 2/2] target/riscv/csr: Added the ability to delegate LCOFI to VS Date: Mon, 12 Feb 2024 20:11:56 +0300 Message-ID: <20240212171156.47293-2-irina.ryapolova@syntacore.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240212171156.47293-1-irina.ryapolova@syntacore.com> References: <20240212171156.47293-1-irina.ryapolova@syntacore.com> MIME-Version: 1.0 X-ClientProxiedBy: T-Exch-05.corp.yadro.com (172.17.10.109) To S-Exch-01.corp.yadro.com (10.78.5.241) Received-SPF: permerror client-ip=89.207.88.248; envelope-from=irina.ryapolova@syntacore.com; helo=mta-04.yadro.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_PERMERROR=0.01 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Vadim Shakirov In the AIA specification in the paragraph "Virtual interrupts for VS level" it is indicated for interrupts 13-63: if the bit in hideleg is enabled, then the corresponding vsip and vsie bits are aliases to sip and sie Signed-off-by: Vadim Shakirov Reviewed-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 0c21145eaf..51b1099e10 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1136,7 +1136,7 @@ static RISCVException write_stimecmph(CPURISCVState *env, int csrno, static const uint64_t delegable_ints = S_MODE_INTERRUPTS | VS_MODE_INTERRUPTS | MIP_LCOFIP; static const uint64_t vs_delegable_ints = - (VS_MODE_INTERRUPTS | LOCAL_INTERRUPTS) & ~MIP_LCOFIP; + VS_MODE_INTERRUPTS | LOCAL_INTERRUPTS; static const uint64_t all_ints = M_MODE_INTERRUPTS | S_MODE_INTERRUPTS | HS_MODE_INTERRUPTS | LOCAL_INTERRUPTS; #define DELEGABLE_EXCPS ((1ULL << (RISCV_EXCP_INST_ADDR_MIS)) | \