From patchwork Tue Mar 12 13:51:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 13590039 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 F3336C54E5D for ; Tue, 12 Mar 2024 14:00:44 +0000 (UTC) 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=Uyb2eOGIvLHZeDA5mG4+uPOFKdlXPOfJ/dbQxzxWnVo=; b=TwuDM1pH8bKjO3 dPI6UQfc3wzyEQ3pt2oojcMj8CV1W5S7HXtM+GIxdwkm9WaiT24BYfLQfo1SJKaL/2gxDvr7vlIu8 jXpUuboTBIglTkcq1rk4/ky+7JqPytUi7CAjDGr1fT2peVsnmw1RzbGdofqAk1ycmmH6dVq1+YmZp j9l7jGK7xqlDiiBXc/v/ZT/XMDg11qjSD/dXXyIb48nuQfavjJCATiZsKs1IAvRRtWyA9LG9hPjXB eOLRP/Nbw37QJ2eJq6Bo0J6Q/zF+HpyEPNW4TUxAQUOcDvCMpNDvfJMPqdX6gsx7YGStXI7r3AdMZ hiZXSexd/oPjF3Bt3XjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk2fr-000000060Rd-0b05; Tue, 12 Mar 2024 14:00:11 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk2fp-000000060RB-34z5 for linux-arm-kernel@bombadil.infradead.org; Tue, 12 Mar 2024 14:00:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=jQe08bY6cMcC0sBvnFpiFQcBV697YeZ0n6MJqTOrObA=; b=OkBA9tacW41yqQUpfP1Hzcplt8 xtAww7kN00Sx5K7o7fgoszyFLXs+91r6SQIcCn/Jv7GQY566BTvYHRHPtNF2MhyqQwf3NwcdyXnof 1kiFoNaj9RN1c8qgyvTRK0GfX1iOqV7ATqTE1fcfzWHm4XpEVQW3OgYVZs1sDw4eEr5hj5JY5ePht Ag8x2K6WMsl29tDBbHuPrqFnyqhcmv7vIHk74dqsDUPYbiBvQifpSoh098LUkq+al5F5TLrJTjdk9 mA81FeGfnVhdKHCOfllPPrMnySBa6SwGeF1e+mDU4w+TbV12/54iDj1Vncdv5ZiSJ9HlIvmEGeo2a hyB9wd0A==; Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by desiato.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk2fh-00000009V5K-3oqy; Tue, 12 Mar 2024 14:00:02 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk2fg-000000033N2-2oJe; Tue, 12 Mar 2024 14:00:00 +0000 From: David Woodhouse To: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: Paolo Bonzini , Jonathan Corbet , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Lorenzo Pieralisi , "Rafael J. Wysocki" , Len Brown , Pavel Machek , David Woodhouse , Mostafa Saleh , Jean-Philippe Brucker , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-pm@vger.kernel.org Subject: [RFC PATCH 0/2] Add PSCI v1.3 SYSTEM_OFF2 support for hibernation Date: Tue, 12 Mar 2024 13:51:27 +0000 Message-ID: <20240312135958.727765-1-dwmw2@infradead.org> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The upcoming PSCI v1.3 specification adds support for a SYSTEM_OFF2 function which is analogous to ACPI S4 state. This will allow hosting environments to determine that a guest is hibernated rather than just powered off, and ensure that they preserve the virtual environment appropriately to allow the guest to resume safely (or bump the hardware_signature in the FACS to trigger a clean reboot instead). This adds support for it to KVM, and to the guest hibernate code. Strictly, we should perhaps also allow the guest to detect PSCI v1.3, but when v1.1 was added in commit 512865d83fd9 it was done unconditionally, which seems wrong. Shouldn't we have a way for userspace to control what gets exposed, rather than silently changing the guest behaviour with newer host kernels? Should I add a KVM_CAP_ARM_PSCI_VERSION? For the guest side, this adds a new SYS_OFF_MODE_POWER_OFF with higher priority than the EFI one, but which *only* triggers when there's a hibernation in progress. That seemed like the simplest option, but see the commit message for alternative possilities. I told Rafael I'd post a straw man for bikeshedding, and here it is. Documentation/virt/kvm/api.rst | 11 +++++++++++ arch/arm64/include/asm/kvm_host.h | 2 ++ arch/arm64/include/uapi/asm/kvm.h | 6 ++++++ arch/arm64/kvm/arm.c | 5 +++++ arch/arm64/kvm/hyp/nvhe/psci-relay.c | 2 ++ arch/arm64/kvm/psci.c | 37 ++++++++++++++++++++++++++++++++++++ drivers/firmware/psci/psci.c | 35 ++++++++++++++++++++++++++++++++++ include/uapi/linux/kvm.h | 1 + include/uapi/linux/psci.h | 5 +++++ kernel/power/hibernate.c | 5 ++++- 10 files changed, 108 insertions(+), 1 deletion(-)