mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Miguel Luis <miguel.luis@oracle.com>
Cc: Souvik Chakravarty <Souvik.Chakravarty@arm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>, Marc Zyngier <maz@kernel.org>,
	Oliver Upton <oliver.upton@linux.dev>,
	James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
	Shuah Khan <shuah@kernel.org>,
	 "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
	 "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	 "linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>
Subject: Re: [PATCH v4 1/6] firmware/psci: Add definitions for PSCI v1.3 specification
Date: Fri, 27 Sep 2024 15:24:45 +0100	[thread overview]
Message-ID: <378d3797a94df5df655d47b3bd733da8853cc2e4.camel@infradead.org> (raw)
In-Reply-To: <CB344CC7-E6E2-4325-9669-9BE7EA47C56B@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]

On Fri, 2024-09-27 at 12:43 +0000, Miguel Luis wrote:
> 
> The common factor being the bit offset in the bitmap for SYSTEM_OFF2 discovery
> and argument to call SYSTEM_OFF2 as well. Would it be clearer something like:
> 
> #define  PSCI_1_3_HIBERNATE_TYPE_OFF BIT(0)

I've updated the tree at
https://git.infradead.org/users/dwmw2/linux.git/shortlog/refs/heads/psci-hibernate
to do it that way.

As I did so, I realised that KVM *does* care about the argument to
SYSTEM_OFF2. This is a straight copy of the SYSTEM_RESET2 handling.
Although it doesn't pass the argument up to userspace (presumably
userspace is expected to look at the registers if it cares), it *does*
check it's within the range of permitted values and return
PSCI_RET_INVALID_PARAMS if not.

I've changed that check to:

		arg = smccc_get_arg1(vcpu);
		/*
		 * Permit zero to mean HIBERNATE_OFF as well as the bitmap
		 * form which was introduced in PSCI v1.3 beta.
		 */
		if (arg && arg != PSCI_1_3_HIBERNATE_TYPE_OFF) {
			val = PSCI_RET_INVALID_PARAMS;
			break;
		}
		kvm_psci_system_off2(vcpu);


On the guest side, I've changed the invocation to:

static int psci_sys_hibernate(struct sys_off_data *data)
{
	/*
	 * Zero is an acceptable alternative to PSCI_1_3_HIBERNATE_TYPE_OFF
	 * and is supported by hypervisors implementing an earlier version
	 * of the pSCI v1.3 spec.
	 */
	if (system_entering_hibernation())
		invoke_psci_fn(PSCI_FN_NATIVE(1_3, SYSTEM_OFF2),
			       0 /*PSCI_1_3_HIBERNATE_TYPE_OFF*/, 0, 0);
	return NOTIFY_DONE;
}

I'm going to do some careful interop testing with existing and new
hypervisors before reposting this version.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

      parent reply	other threads:[~2024-09-27 14:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 16:05 David Woodhouse
2024-09-24 16:05 ` [PATCH v4 2/6] KVM: arm64: Add PSCI v1.3 SYSTEM_OFF2 function for hibernation David Woodhouse
2024-09-26  9:14   ` Francesco Lavra
2024-09-24 16:05 ` [PATCH v4 3/6] KVM: arm64: Add support for PSCI v1.2 and v1.3 David Woodhouse
2024-09-24 16:05 ` [PATCH v4 4/6] KVM: selftests: Add test for PSCI SYSTEM_OFF2 David Woodhouse
2024-09-24 16:05 ` [PATCH v4 5/6] KVM: arm64: nvhe: Pass through PSCI v1.3 SYSTEM_OFF2 call David Woodhouse
2024-09-24 16:05 ` [PATCH v4 6/6] arm64: Use SYSTEM_OFF2 PSCI call to power off for hibernate David Woodhouse
2024-09-26  9:18   ` Francesco Lavra
2024-09-24 16:13 ` [PATCH v4 0/6] Add PSCI v1.3 SYSTEM_OFF2 support for hibernation David Woodhouse
2024-09-26  8:55 ` [PATCH v4 1/6] firmware/psci: Add definitions for PSCI v1.3 specification Francesco Lavra
2024-09-26  9:59   ` David Woodhouse
2024-09-26  9:56 ` Miguel Luis
2024-09-26 16:30   ` David Woodhouse
2024-09-27 12:43     ` Miguel Luis
2024-09-27 13:20       ` David Woodhouse
2024-09-27 14:24       ` David Woodhouse [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=378d3797a94df5df655d47b3bd733da8853cc2e4.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=Souvik.Chakravarty@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=james.morse@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=miguel.luis@oracle.com \
    --cc=oliver.upton@linux.dev \
    --cc=pavel@ucw.cz \
    --cc=pbonzini@redhat.com \
    --cc=rafael@kernel.org \
    --cc=shuah@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®