From patchwork Sat Feb 28 00:53:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiakai Xu X-Patchwork-Id: 2202646 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=qM0TWHB9; 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=kvm-riscv-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 4fN6Cj6Qz5z1xxx for ; Sat, 28 Feb 2026 11:54:22 +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=vwTCan5O9jdRfjuxpyVyC3waWzHW1A/kIYNnrgLTF4I=; b=qM0TWHB9lB6f7l g0lRlcGx81Q9nxh7BS/DhqSZOjfPYfgtMtSXtWSNRNe5MKqEgYhkIyLrEIXP7MaNFzyD8EaQqmxVV tweFIF/qQgKPoOk+fLuwclrH9PSsolDwHtBzA2BnZtzE/wKyGuXOMmA5mMzK4dmlNpUwO0D6bafbn YQZn/vuzp2b+FB1uHBv1+j3Qe3FBQo+6MUFw07T4qCeGi4Sc8OWKm64QAdh+xEWfQpJ00zoRw/51N 8iUcc99vtcaI5gznTMpUEvHgIa6VXl7by9jhKECz1fvr4wfOYnbSmP2etWhWveskRrbGUIZIM9ldn ThOLts2Gbc7hWMsjHPTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vw8b2-00000009LDF-1Rsg; Sat, 28 Feb 2026 00:54:16 +0000 Received: from smtp81.cstnet.cn ([159.226.251.81] helo=cstnet.cn) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vw8ax-00000009LBD-2jvr; Sat, 28 Feb 2026 00:54:14 +0000 Received: from fric.. (unknown [210.73.43.101]) by APP-03 (Coremail) with SMTP id rQCowABXO+KkPKJpPMJ2CQ--.12049S2; Sat, 28 Feb 2026 08:53:57 +0800 (CST) From: Jiakai Xu To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org Cc: Alexandre Ghiti , Paolo Bonzini , Shuah Khan , Paul Walmsley , Palmer Dabbelt , Andrew Jones , Anup Patel , Atish Patra , Albert Ou , Jiakai Xu Subject: [PATCH v9 0/3] RISC-V: KVM: Validate SBI STA shmem alignment Date: Sat, 28 Feb 2026 00:53:52 +0000 Message-Id: <20260228005355.823048-1-xujiakai2025@iscas.ac.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CM-TRANSID: rQCowABXO+KkPKJpPMJ2CQ--.12049S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Gw4DZFW8ZFyDCr4UJFy5Jwb_yoW8Jr45pa 9xCa4FqFy8JayxA3Z3Aw4ktryfWw48CrsFyw17J342yay8KFy8tr47KFWUAasxGF1kXF1Y va4xK3WruF98ZaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBI14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr 1j6rxdM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVAC Y4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJV W8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI2 0VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04v7MxkF7I0En4kS14v26r1q6r43MxAIw28Icx kI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2Iq xVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42 IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY 6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aV CY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbQVy7UUUUU== X-Originating-IP: [210.73.43.101] X-CM-SenderInfo: 50xmxthndljiysv6x2xfdvhtffof0/1tbiBgoKCWmgYKJ+jgADs3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260227_165412_058422_5D861F4E X-CRM114-Status: UNSURE ( 4.70 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.1 (--) 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 fixes a missing validation in the RISC-V KVM SBI steal-time accounting (STA) register handling. Patch 1 validates the configured SBI STA shared memory GPA at KVM_SET_ONE_REG, enforcing the 64-byte alignment requirement defined by the SBI specification or allowing INVALID_GPA to explicitly disabl [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.226.251.81 listed in sa-accredit.habeas.com] 0.4 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.226.251.81 listed in bl.score.senderscore.com] 0.7 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [159.226.251.81 listed in sa-trusted.bondedsender.org] -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [159.226.251.81 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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 fixes a missing validation in the RISC-V KVM SBI steal-time accounting (STA) register handling. Patch 1 validates the configured SBI STA shared memory GPA at KVM_SET_ONE_REG, enforcing the 64-byte alignment requirement defined by the SBI specification or allowing INVALID_GPA to explicitly disable steal-time accounting. This prevents invalid userspace state from reaching runtime code paths and avoids WARN_ON() triggers during KVM_RUN. Patch 2 refactors existing UAPI tests from steal_time_init() into a dedicated check_steal_time_uapi() function for better code organization, and adds an empty stub for RISC-V. Patch 3 fills in the RISC-V stub with tests that verify KVM correctly enforces the STA alignment requirements. Jiakai Xu (3): RISC-V: KVM: Validate SBI STA shmem alignment in kvm_sbi_ext_sta_set_reg() KVM: selftests: Refactor UAPI tests into dedicated function RISC-V: KVM: selftests: Add RISC-V SBI STA shmem alignment tests arch/riscv/kvm/vcpu_sbi_sta.c | 16 ++- .../selftests/kvm/include/kvm_util_types.h | 2 + tools/testing/selftests/kvm/steal_time.c | 98 ++++++++++++++++--- 3 files changed, 95 insertions(+), 21 deletions(-)