From patchwork Mon Feb 28 09:42:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 1598578 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=TFTHC+Pv; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20210112.gappssmtp.com header.i=@rivosinc-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=TscrhBaD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K6b5m2KPhz9sGS for ; Mon, 28 Feb 2022 20:42:52 +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=uCeWyjUutfXNtKJpmDNnt7iAZJIq1ubpEqV08kuMl4o=; b=TFTHC+Pv3B6CjE 6hIddNxJws3T+uHezPipHpVvuw4vegCwAHlD/5XNfjrVj/tpqZpL4a9Nm+F9aS/riuREuVWOovh3N UJZjSO2TZdKUlG9oJ3T/05pr3GoRB5ofvQ+RXVEhZJ6nvLdcWyP60R1hBEmrynBwlVJ84+KVHN6IR wmRv0PYQf8KuTtuu8EM6HH5ijIq5h6sSa8CpM5cpW+4RtDRrfG9SdTCn8GFt/CzVK08DA4dD+r+CE tyltTULzke1uhVBnixo+ipjQXTiMqOZF0TB2DhCfb279CEH2IMUW0jmPTS5g3EUuZfDgQ6tdGcEuT DGBASahvR2nptA+lrbnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOcYL-00BIL8-VQ; Mon, 28 Feb 2022 09:42:49 +0000 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOcYF-00BIGi-0u for kvm-riscv@lists.infradead.org; Mon, 28 Feb 2022 09:42:45 +0000 Received: by mail-oi1-x231.google.com with SMTP id y7so12660503oih.5 for ; Mon, 28 Feb 2022 01:42:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Lqd+uM0+AsEqEUkgyYxAHY0Z5jtxbH0DOOxZpRbhWVk=; b=TscrhBaDAEepfdz5Z2ltBnhHnUV1g+rV3nLy4t44yc41fnNwqn0MmQhy7DT7B2Bk0E ZrjZXsjxfT3EFYOMxdq3t7n+Xlq9hVZwgJeC6KSd6RjMuT5m4rvuwS+cmQSvbw3mw3hO ZbntkGKhK2um4h+a2Mu71f3CQxokfd5GOyyKd9yfivfNnfaBHG1vuoewiJsA2D5tcHa4 bfcO1OAsYYoeKqg35HK6i10PhwLPII6uhFR4vVsOWcyKUcvWQLRBceRiHLbckDoUpgsK W4oFhtbAZdO8XecA/Kdjgp/QqkpWzu/RYdrKqXTMbj4dyTQUPDeRlEF60V1huvRiL/VU xQ+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Lqd+uM0+AsEqEUkgyYxAHY0Z5jtxbH0DOOxZpRbhWVk=; b=j9JfUycetOoATBDncfFfiDAbi4f9vMeiPFQyoRKI3TaiHxaT/QUhh+M62Rw1J2vpYv ncOXtmaX6BHPeoOXZs4RPDpy3dwPXrnSn4u3zTmFaYc3pS/AfbrCxdqTu/dqI3jfrEPZ 7SaHjF8JmdpjKt/563oN02s88qfeXs8VbINNfW0/veTLF2Z3wcgHhXl96SFbND+iu34R S4cTf8KxiGd9fIA+7zikL03oDHE65ng3vjzW/SsEajHicoZUfQfvrc0YPsgchA8Cy9/8 tInjmWcsV4r16StqWoUP6RqGpMX4wOiyguuPSWaDA2v2Gs7QX4EuAzf2gjNRxLUaDPNh DwcA== X-Gm-Message-State: AOAM532kc5C2voZTEwsCWlUwOvxCDRCoDPGjH76QWPqRlcHEtAsmu+9K 7Gc0HqAHcUkFTFKktE15C2VetA== X-Google-Smtp-Source: ABdhPJzGVSYPURjxwKVMmt98ELmUV/vmpESUrllO+pnCtr9uHHmokFZxrEV/7bQfqVedP7L9vtOWdQ== X-Received: by 2002:a05:6808:56b:b0:2d4:5f04:f2fa with SMTP id j11-20020a056808056b00b002d45f04f2famr9813151oig.96.1646041362018; Mon, 28 Feb 2022 01:42:42 -0800 (PST) Received: from rivos-atish.. (adsl-70-228-75-190.dsl.akrnoh.ameritech.net. [70.228.75.190]) by smtp.gmail.com with ESMTPSA id bx10-20020a0568081b0a00b002d70da1ac54sm5936852oib.19.2022.02.28.01.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 01:42:41 -0800 (PST) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Albert Ou , Atish Patra , kvm-riscv@lists.infradead.org, Anup Patel , Damien Le Moal , devicetree@vger.kernel.org, Jisheng Zhang , Krzysztof Kozlowski , linux-riscv@lists.infradead.org, Palmer Dabbelt , Paul Walmsley , Rob Herring Subject: [RFC PATCH 0/6] Add Sstc extension support Date: Mon, 28 Feb 2022 01:42:27 -0800 Message-Id: <20220228094234.3773153-1-atishp@rivosinc.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220228_014243_131132_7160BC40 X-CRM114-Status: GOOD ( 12.62 ) 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: This series implements Sstc extension support which was ratified recently. Before the Sstc extension, an SBI call is necessary to generate timer interrupts as only M-mode have access to the timecompar [...] 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 [2607:f8b0:4864:20:0:0:0:231 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This series implements Sstc extension support which was ratified recently. Before the Sstc extension, an SBI call is necessary to generate timer interrupts as only M-mode have access to the timecompare registers. Thus, there is significant latency to generate timer interrupts at kernel. For virtualized enviornments, its even worse as the KVM handles the SBI call and uses a software timer to emulate the timecomapre register. Sstc extension solves both these problems by defining a stimecmp/vstimecmp at supervisor (host/guest) level. It allows kernel to program a timer and recieve interrupt without supervisor execution enviornment (M-mode/HS mode) intervention. To maintain backward compatibility, KVM directly updates the vstimecmp if older kernel without sstc support is running in guest. Similary, the M-mode firmware(OpenSBI) uses stimecmp for older kernel without sstc support. The PATCH 1 & 2 enables the basic infrastructure around Sstc extension while PATCH 3 lets kernel use the Sstc extension if it is available in hardware. PATCH 4 & 5 adds the infrastructure for KVM to use sstc while PATCH 6 actually uses the Sstc extension if available. This series has been tested on Qemu(RV32 & RV64) with additional patches in OpenSBI[2] and Qemu[3]. This series can also be found at [4]. [1] https://drive.google.com/file/d/1m84Re2yK8m_vbW7TspvevCDR82MOBaSX/view [2] https://github.com/atishp04/opensbi/tree/sstc_v1 [3] https://github.com/atishp04/qemu/tree/sstc_v1 [3] https://github.com/atishp04/linux/tree/sstc_v1 Atish Patra (6): RISC-V: Add SSTC extension CSR details RISC-V: Enable sstc extension parsing from DT RISC-V: Prefer sstc extension if available RISC-V: Restrict the isa field in config register to base extensions RISC-V: KVM: Introduce ISA extension register RISC-V: KVM: Support sstc extension arch/riscv/include/asm/csr.h | 11 ++ arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/include/asm/kvm_host.h | 4 + arch/riscv/include/asm/kvm_vcpu_timer.h | 3 +- arch/riscv/include/asm/timex.h | 2 + arch/riscv/include/uapi/asm/kvm.h | 22 ++++ arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 4 +- arch/riscv/kvm/main.c | 8 ++ arch/riscv/kvm/vcpu.c | 111 ++++++++++++++++++- arch/riscv/kvm/vcpu_sbi_replace.c | 10 +- arch/riscv/kvm/vcpu_timer.c | 136 +++++++++++++++++++++++- drivers/clocksource/timer-riscv.c | 22 +++- 13 files changed, 323 insertions(+), 12 deletions(-) --- 2.30.2