From patchwork Thu Oct 17 07:45:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 1998430 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=cYl7chbU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=ggYDVbah; 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 4XTfyw3f56z1xth for ; Thu, 17 Oct 2024 18:46:00 +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=qxaNYOGXUqD0rboGAHjQO7VDssI0cMl5pULv0OmIMGA=; b=cYl7chbUg1CLYM shp0iWULgILZRJklKKtf0u8s1du9Wf0Z8mF1N3SVci5XfhQ8dEniI1QJCcd4+2MDz0xj8jf7zc2up OdSUGejf7+3elxyBipXZ97v2pbRqN6gKUjtrp+lfQzQBwB36GvRfSypL4bWNFO1ddssPYpMxW16vR kNP6Ix0vpYeCMG/d0nC9bDOcKkrmAZy3P+PxBUc8V5eHWprBnqSWVYe9tis9SVFA1hXmegHVunJz4 ZKZ/is74CKCdjeiDSjwdCSXjhzJnYmVuxLZLBPI3GnzMa7ZxXiNj3R2M9pqWmtctULnZZ8TnDcgLw 3EEizh8rBWxtQSwzeCxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1LCp-0000000E1av-0zup; Thu, 17 Oct 2024 07:45:59 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1LCZ-0000000E1X2-0ppW for kvm-riscv@lists.infradead.org; Thu, 17 Oct 2024 07:45:49 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-430ee5c9570so8842205e9.3 for ; Thu, 17 Oct 2024 00:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1729151140; x=1729755940; 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=QnNqilJoD/E6XdDy/QOtp2E6wGYgJITTGhd82yqjJKw=; b=ggYDVbahr0/s/rM/CjBLdf29jjQEZoyJmDvMyX+gJbVlttxHhdmod9RWNm3kdmjNb9 o7iDC6Tn93kmimPyqEqmAoy2aMRhhvUidxeA60veVKhjBjeCHHwpaMQI31lPZPmG0IvA 2kFBwY2u0waDd/bHxyflCxMAliQBiG6NGJAQgrbmWKlQ+C9HQaIPPiOAtJkNr1weafnD kYFoQReJaq7hvq9exHhKzbut8lT6iFtxGZYQQ/lUZWdmP01ESS/V9KiLkLL5GhWv4zaI gP6jhEi5QrdtQwlR/Oh+dn31RVboT35TN3qeVzbYqj7bwotSnOgyH/s4RvfuTHlwzPU1 cYNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729151140; x=1729755940; 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=QnNqilJoD/E6XdDy/QOtp2E6wGYgJITTGhd82yqjJKw=; b=kGwtSsMnR1D93qPlwDJPQnSto1GH01V7ZH6N+woGCkUMtDX/0QFjvLtv7XCI58L4be S4YEp0U1RMsn+mgTc25k8fi8wOoKzP+zt6fPQTTz/lk8itIiuRB18rKr1QXCqfo6VRdf H3RnRWaGit47NLyRQojKtPBPLp9LIrJp4iETxOHuyvPnam7fHWSYdLRPME/2n42cjoum LvqGoVmzjomUp2PPNymjhdJmVi2XoOttUbm7t4OY+QdLa9G5ZPBli9ave7fSkcKialK7 s9Yzx5U3tMvk/qchu6ef1nzM+NUepuCknLgomSasoaiFkLEOF8PZYmb1aB8Je8jLP+Zc mSrA== X-Gm-Message-State: AOJu0Yw0OCFk961WZ9zdnlsZUB6PVT+Wv3lmSh5Jtc8AiRveNec9a632 BOLTEqRVNLW0hsps/IRQKgyBY5gWeqsL9MzxqmTpncCAlVzvqvFuNZGkwA9UcsDYBEQlImiA7Sc z X-Google-Smtp-Source: AGHT+IGHuU+j/D5Lt1wHDzHTexN8NI9bwGmoJ0Bbm4fY1yEX7V4GppW53QTQioIb0o7fWl+5wYLI9Q== X-Received: by 2002:a05:600c:5251:b0:42a:a6b8:f09f with SMTP id 5b1f17b1804b1-43125607846mr190261515e9.23.1729151140129; Thu, 17 Oct 2024 00:45:40 -0700 (PDT) Received: from localhost (cst2-173-13.cust.vodafone.cz. [31.30.173.13]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43158c61b20sm17121545e9.42.2024.10.17.00.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2024 00:45:39 -0700 (PDT) From: Andrew Jones To: kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org Cc: anup@brainfault.org, atishp@atishpatra.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu Subject: [PATCH 0/2] RISC-V: KVM: SBI system suspend support Date: Thu, 17 Oct 2024 09:45:39 +0200 Message-ID: <20241017074538.18867-4-ajones@ventanamicro.com> X-Mailer: git-send-email 2.46.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_004543_254060_BD9BE5E2 X-CRM114-Status: UNSURE ( 9.26 ) 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: The SBI spec provides a specification for system suspend to RAM and Linux already supports invoking the SBI call for suspend to RAM when CONFIG_SUSPEND is selected. Implement support for the SBI call [...] Content analysis details: (-2.1 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:32e 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_EF Message has a valid DKIM or DK signature from envelope-from domain -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 -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -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 The SBI spec provides a specification for system suspend to RAM and Linux already supports invoking the SBI call for suspend to RAM when CONFIG_SUSPEND is selected. Implement support for the SBI call in KVM so guests may initiate a system suspend. However, since what a "system suspend" means for a VM may differ between VM providers, leave it up to the VMM to decide what to do. KVM only needs to ensure the entry criteria for system suspend (per the spec) is met and prepare things for the resume for when the VMM triggers it. Tested with this kvmtool branch [1] [1] https://github.com/jones-drew/kvmtool/commits/riscv/sbi-sys-susp/ Andrew Jones (2): RISC-V: KVM: Add SBI system suspend support KVM: riscv: selftests: Add SBI SUSP to get-reg-list test arch/riscv/include/asm/kvm_vcpu_sbi.h | 1 + arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/Makefile | 1 + arch/riscv/kvm/vcpu_sbi.c | 4 + arch/riscv/kvm/vcpu_sbi_system.c | 73 +++++++++++++++++++ .../selftests/kvm/riscv/get-reg-list.c | 6 +- 6 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 arch/riscv/kvm/vcpu_sbi_system.c