From patchwork Thu Mar 21 15:57:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 1914524 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pY2ymEEs; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=h3tn/1yO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V0qqc0364z1yWs for ; Fri, 22 Mar 2024 02:58:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Wrd0BoOP5KmPS9NdMHu0BjO+y5U7W9cJn0b0Qq8yp1U=; b=pY2ymEEsn+VAPS LKInMXQwPnZpdwREkJxThexEX9Mn8EcZggghKJudG0vlKbOBQCz/fUVx6EcmQiWfPBQS59pqcVnxS TrFniHXNPPU0uAf0FRgFfRpA+PFQbNEvuB7at4BfxxKYh5M38f8ROznlbzQCvSf8lztDNTovw66BV UC/oNugnAfjLx8w1zfk1Qm8V5HV7E+3zU6MS5BNNkQPP2VhkPVHkW5YUZ/gOl3tZhdsfV5tN9CI5t GWI7i16IVP9vq0sOXTJ7KofRVcmKwQimX/PJT79/+i3mzHYJP6AUXybniQCc9s2qFLsiPh70oD+S9 yaZDVLJjJFNZdSEBg+ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnKnc-00000003fmF-1ScR; Thu, 21 Mar 2024 15:57:48 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rnKnY-00000003fkT-1dul for opensbi@lists.infradead.org; Thu, 21 Mar 2024 15:57:46 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-41401ebab9cso615635e9.0 for ; Thu, 21 Mar 2024 08:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1711036659; x=1711641459; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0eM+XjTIvLFlXJHAJNJ2CZisJGWygv5uVM7PdxvNAxM=; b=h3tn/1yOEBlyUQ+zJPuRGDEYW0vFuOJXQAjLyAPjeUOiRjhAFMmGD+0oY1OEHN+hX0 EE4sUCrHA0GLxechCOr5ShibIVE8fUM0IFc+wHSTOig5zibNAL4Gvspb8bfeP1UMnOcE zv6kcOSSpx8ZEnJ3OLZMNfDGT72cWIZ1UQQcO+7/coXar5HbyLK3kcQaQvIJLDV09DRT wdRmVR9qJEv/sbvj6ECIE/EG8udFR816JcAQB1iewBhM4II6+kCl84eNs+rGnhAI1c1T lJuwVFmE5+o2bg0SVdrMpRg7nsOuDfdIhvgRzuV8DukAqe3TM3Jfxb77KC3cwIilscvQ zYAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711036659; x=1711641459; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0eM+XjTIvLFlXJHAJNJ2CZisJGWygv5uVM7PdxvNAxM=; b=G6vieVcW4Sy3il15pE8ixD2EY8k4OFZboAXU7SyXygz+WIcTV4yTaWYNcXbhbxb2xy 8zIQNG2MmaZ+jPyMdtfVt2Ir8qxjA27CBElR/ale47AGhwA/x9KGi+wSs8S13d8vk3AX 1l783UyCIorR51zDdr4Y4diYK+ndHG8KHGSjWGVDZK/CLMPGdOPxzh8O9c0wAkkgyNmr 5Qq0PEe2feHJdJC9D2k5v5Il6DhzwwmBZstY4q0EmnZlrWMgQPjlfZ92MR3c/mg1D+n0 Rtvbv7BC3NQ88LgLzYUhY37oRDSzLfu6QYxKH3IjBjXrUaEtChKk9duV2lhI4zb+UPYK TLjQ== X-Gm-Message-State: AOJu0Yxct3TLM0/T/T0oWr5tn6mRKzG1G1OTnn0S46LqKPkKpIu1D5P0 VMaGq5EIkL9UFzMw1bzv6Ckvauv7qnHxP3+XGN5uTtG7FgeKK2CyaUoCTt4V8Tn+QZV0Eq53ZgP avSM= X-Google-Smtp-Source: AGHT+IEssMjdGyPjWi6AQAR8yHw7Pvq6/UbJKyTUaG9zbOq8GbZvxLQ3/Axh5852O21e4LjWWUVdyg== X-Received: by 2002:a05:600c:4f84:b0:414:64b3:186c with SMTP id n4-20020a05600c4f8400b0041464b3186cmr3848646wmq.1.1711036658631; Thu, 21 Mar 2024 08:57:38 -0700 (PDT) Received: from carbon-x1.. ([2a01:e0a:999:a3a0:9b98:41b4:ceda:8f9]) by smtp.gmail.com with ESMTPSA id n20-20020a05600c4f9400b004140e701884sm160981wmq.22.2024.03.21.08.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 08:57:38 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: opensbi@lists.infradead.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Atish Patra , Deepak Gupta , Anup Patel , Himanshu Chauhan , Xiang W , Jessica Clarke Subject: [PATCH v3 0/3] Add support for Supervisor Software Events extension Date: Thu, 21 Mar 2024 16:57:15 +0100 Message-ID: <20240321155720.1966860-1-cleger@rivosinc.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240321_085744_556236_A17AFE5A X-CRM114-Status: GOOD ( 12.31 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The SBI Supervisor Software Events (SSE) extensions provides a mechanism to inject software events from an SBI implementation to supervisor software such that it preempts all other supervisor level tr [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:330 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The SBI Supervisor Software Events (SSE) extensions provides a mechanism to inject software events from an SBI implementation to supervisor software such that it preempts all other supervisor level traps and interrupts [1]. This series implements the V3 version of the spec. Various events are defined and can be send asynchronously to supervisor software (RAS, PMU, DEBUG, Asynchronous page fault) from SBI as well as platform specific events. Events can be either local (per-hart) or global. Events can be nested on top of each other based on priority and can interrupt the supervisor mode at any time. This implementation can be tested using kvm-unit-tests [2] with the following commands: Build kvm-unit-tests: $ git clone https://github.com/clementleger/kvm-unit-tests.git $ cd kvm-unit-tests $ git switch dev/cleger/sse $ ./configure --arch=riscv64 --cross-prefix=$CROSS_COMPILE $ make Run using Qemu: $ ./qemu-system-riscv64 \ -smp 4 \ -M virt \ -cpu rv64 \ -nographic \ -serial mon:stdio \ -bios /build/platform/generic/firmware/fw_jump.bin \ -kernel /riscv/sbi_sse.flat An implementation of a SSE "client" in linux is available [3]. This series can be found on github [5]. Link: https://lists.riscv.org/g/tech-prs/message/798 [1] Link: https://github.com/clementleger/kvm-unit-tests/tree/dev/cleger/sse [2] Link: https://github.com/rivosinc/linux/tree/dev/cleger/sse [3] Link: http://lists.infradead.org/pipermail/opensbi/2024-March/006670.html [4] Link: https://github.com/rivosinc/opensbi/tree/dev/cleger/sse_v3 [5] Reviewed-by: Anup Patel --- Changes from v3: - Changes to follow v3 SSE specification - Use masks instead of struct with bitfields for status - Rework locking - SSE pending event processing is now done upon returning to previous mode v2: http://lists.infradead.org/pipermail/opensbi/2024-January/006223.html Changes from v2: - Move local/global event count initialization out of sse_global_init() - Remove PMU_IRQ_CLEAR SBI call and clear IRQ on SSE event completion - Change SBI_ERR_X to SBI_EXX defines - Add guards for invalid __riscv_xlen values - Update parameters passing (a6, a7) v1: http://lists.infradead.org/pipermail/opensbi/2023-November/006015.html Changes from v1: - Implemented SSE Spec v2 - Change event state checking (Xiang W) Clément Léger (3): lib: sbi: Add support for Supervisor Software Events extension lib: sbi: Implement SBI SSE extension lib: sbi: Add SSE support for PMU events include/sbi/sbi_ecall_interface.h | 79 +- include/sbi/sbi_error.h | 2 + include/sbi/sbi_pmu.h | 3 + include/sbi/sbi_sse.h | 94 +++ lib/sbi/Kconfig | 4 + lib/sbi/objects.mk | 4 + lib/sbi/sbi_ecall_sse.c | 57 ++ lib/sbi/sbi_init.c | 13 + lib/sbi/sbi_pmu.c | 51 ++ lib/sbi/sbi_sse.c | 1131 +++++++++++++++++++++++++++++ lib/sbi/sbi_trap.c | 11 + 11 files changed, 1448 insertions(+), 1 deletion(-) create mode 100644 include/sbi/sbi_sse.h create mode 100644 lib/sbi/sbi_ecall_sse.c create mode 100644 lib/sbi/sbi_sse.c