Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1136919lql; Tue, 12 Mar 2024 08:16:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVC965LWaetd8ehO3OtPbxCsSsXnK5/zKXDcmbySz+NtG8c9plXhNakE5pNPerhyUiz+V33lCKQJEzmrYD3VDDhAu45mgkmUjqC61D2hQ== X-Google-Smtp-Source: AGHT+IFkNnu8acLC/1JiH83mfE9Fj6ZtPYA9/4JVw29OAEP0NhSL8wTd/TOdbBEBO10l6eM9Q0qF X-Received: by 2002:a05:620a:2906:b0:788:3ed2:7da8 with SMTP id m6-20020a05620a290600b007883ed27da8mr985317qkp.3.1710256577755; Tue, 12 Mar 2024 08:16:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710256577; cv=pass; d=google.com; s=arc-20160816; b=bruonlJF3MQEjY7vpAXWZCCq3RRMS7RKrwqTf8WvnVflZSNniGGlWTJ9nWpynaoEsJ 8rurYVClqmgXn5K4V4DbD5iEwurFoqFzs4HH0p+M3LbeOP/vOt0VVs9L5Z+qsIKlVzsj ew0GTvm5NYvQHQOnj+6lN3wqLuIMgzG7RpWgq28XgkV5rJEt2K5aj0aGuZ5AIcp7YUPt FqaYXviMCm194N5WmT7xXdJlcymqOZdyhsLMBwzMZu1oDqKIBH2QFYtARskE4UNNhRdd SoWrD5ke8jAo1Ahaelf2oO1ILid6AswdYAo12vox4x4p1bK4FQVIOQmAZ5puf6qO9ZoS Urgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=jQe08bY6cMcC0sBvnFpiFQcBV697YeZ0n6MJqTOrObA=; fh=cGTiXEW680tjRkJBO0R8Z7uT0RUWfkbNFWDDGM1ZY2g=; b=TfvOeY3dTfkQ48vEYISjew/Q/U61T7Nv67WTVNqEUl2o0aSWTW7tqNC50KG/oDFDxE LfHyrGLdWlueXqNnuL9f9G2rMz/1ny5vDV8XTfma9RigzMZnZbSfaMNRs/WJN/J1IXR0 kMqg77dhud5X/OEcUY2wpbvN7P5AiUrc3KO3cduK0WjeKm+H95OM+cEQ3OV8FBfa4Q6g E4M/4ZskopO9w6dGLDWpVOtMznfI9fhDVJQW7NRNjSYFj8XQAxWGqGi93Gs7WL1a0Efg utUtYJT9IYUL/+yxWcf0FY3Jhdnnz+AndwVVXJiGYwXbJcKdKUE8Raq8syfvjerMPUHB Yxkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=OkBA9tac; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-100311-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100311-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vv20-20020a05620a563400b0078812fe97cfsi7507171qkn.409.2024.03.12.08.16.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 08:16:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100311-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=OkBA9tac; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-100311-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100311-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5ACDC1C21450 for ; Tue, 12 Mar 2024 14:00:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02C937B3C6; Tue, 12 Mar 2024 14:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="OkBA9tac" Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FC2F79B96; Tue, 12 Mar 2024 14:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710252012; cv=none; b=CG+OA/gCOk9Y4Lrgb41g6fFo6RW/MUHeyixZnx57h5mLWNo6Lnvpf6LpttZ7o2ZMrPanYGE5C3dGi7Gah8IyMokjDYTz/LgERlFoc3ZGYwejg7a8E5ruXmu6hgGznn4hcp/EIjSbARxEQqmCHhUYyVEfDrJcTCWTXKUOxhzw+AI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710252012; c=relaxed/simple; bh=3HWKckNpAQ8AY3aLQCp6UBNnYrtUMUkbdHYWXQt4TtY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EXKnbQkZdfDQa5Q+QosiooOvkBHHsaXk4gHObh88EjcaL63XAh+nf05iOrg82xJvumblJP+NexwHErHeRncRTOd4gCV4LzMRWhzQjO/YItMlwEpAnr5t2AaeHtLVBqL7/70nykPPmAm4+Ius6JID23wJLeW6xlZ251g8aiO+GT4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=desiato.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=OkBA9tac; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=desiato.srs.infradead.org 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html 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(-)