From mboxrd@z Thu Jan 1 00:00:00 1970 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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC11C433FE for ; Sat, 26 Feb 2022 11:29:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 57D8D4B803; Sat, 26 Feb 2022 06:29:32 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5edBXSCafASq; Sat, 26 Feb 2022 06:29:30 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C4E454B809; Sat, 26 Feb 2022 06:29:30 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 57EF54966F for ; Sat, 26 Feb 2022 06:29:30 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7zRDoyh7SrIG for ; Sat, 26 Feb 2022 06:29:28 -0500 (EST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id A454C40CDE for ; Sat, 26 Feb 2022 06:29:28 -0500 (EST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4E74DB81C11; Sat, 26 Feb 2022 11:29:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9CF9C340F0; Sat, 26 Feb 2022 11:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645874966; bh=JuXM1IcwZ6ufdbQ1el8Jp2dut1va9ksUnfPsEgEfHDo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=HNeSTaJQTFB/513j1PexQUXeqMVZH6fVirVuZHzamyaheAvnHMWZa7b8ObQ0GpnHo kSwJO72NhZfmX0hn65kIbDyEWAqQLX2J+S8G1NPCw3xceqieyDW6OBDLQSLOzfcj6V QBsGnESxUuIMZuCmWgCl5lgktCiC9bsYL9EC8ZLzeCjvkBSyCwhq3UsaIVsAjAD2LH AjeNfqnW1csvufpARR/4pJ4YsMarzZhFKJPDj3/hnpuqCJkWCqdTmoYMMtCOjqXb8L 6+gKgbjvnSGJaSMrhWsNAsnDV4KmaE9LWoI3JjoV7GwSONRNda417qdHI5l5+bOfTP YmUnrpY0j30qw== Received: from sofa.misterjones.org ([185.219.108.64] helo=billy-the-mountain.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNvGN-00AjCy-KR; Sat, 26 Feb 2022 11:29:23 +0000 Date: Sat, 26 Feb 2022 11:29:22 +0000 Message-ID: <8735k57tnx.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Subject: Re: [PATCH v3 13/19] KVM: arm64: Add support KVM_SYSTEM_EVENT_SUSPEND to PSCI SYSTEM_SUSPEND In-Reply-To: References: <20220223041844.3984439-1-oupton@google.com> <20220223041844.3984439-14-oupton@google.com> <87sfs82rz4.wl-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oupton@google.com, kvmarm@lists.cs.columbia.edu, pbonzini@redhat.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, anup@brainfault.org, atishp@atishpatra.org, seanjc@google.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, pshier@google.com, reijiw@google.com, ricarkol@google.com, rananta@google.com, jingzhangos@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: Wanpeng Li , kvm@vger.kernel.org, Joerg Roedel , Peter Shier , kvm-riscv@lists.infradead.org, Atish Patra , Paolo Bonzini , Vitaly Kuznetsov , kvmarm@lists.cs.columbia.edu, Jim Mattson X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Thu, 24 Feb 2022 20:05:59 +0000, Oliver Upton wrote: > > On Thu, Feb 24, 2022 at 03:40:15PM +0000, Marc Zyngier wrote: > > > diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c > > > index 2bb8d047cde4..a7de84cec2e4 100644 > > > --- a/arch/arm64/kvm/psci.c > > > +++ b/arch/arm64/kvm/psci.c > > > @@ -245,6 +245,11 @@ static int kvm_psci_system_suspend(struct kvm_vcpu *vcpu) > > > return 1; > > > } > > > > > > + if (kvm->arch.system_suspend_exits) { > > > + kvm_vcpu_set_system_event_exit(vcpu, KVM_SYSTEM_EVENT_SUSPEND); > > > + return 0; > > > + } > > > + > > > > So there really is a difference in behaviour here. Userspace sees the > > WFI behaviour before reset (it implements it), while when not using > > the SUSPEND event, reset occurs before anything else. > > > > They really should behave in a similar way (WFI first, reset next). > > I mentioned this on the other patch, but I think the conversation should > continue here as UAPI context is in this one. > > If SUSPEND exits are disabled and SYSTEM_SUSPEND is implemented in the > kernel, userspace cannot observe any intermediate state. I think it is > necessary for migration, otherwise if userspace were to save the vCPU > post-WFI, pre-reset the pending reset would get lost along the way. > > As far as userspace is concerned, I think the WFI+reset operation is > atomic. SUSPEND exits just allow userspace to intervene before said > atomic operation. > > Perhaps I'm missing something: assuming SUSPEND exits are disabled, what > value is provided to userspace if it can see WFI behavior before the > reset? Signals get in the way, and break the notion of atomicity. Userspace *will* observe this. I agree that save/restore is an important point, and that snapshoting the guest at this stage should capture the reset value. But it is the asymmetry of the behaviours that I find jarring: - if you ask for userspace exit, no reset value is applied and you need to implement the reset in userspace - if you *don't* ask for a userspace exit, the reset values are applied, and a signal while in WFI will result in this reset being observed Why can't the userspace exit path also apply the reset values *before* exiting? After all, you can model this exit to userspace as reset+WFI+'spurious exit from WFI'. This would at least unify the two behaviours. I still dislike the reset state being applied early, but consistency (and save/restore) trumps taste here. I know I'm being pedantic here, but we've been burned with loosely defined semantics in the past, and I want to get this right. Or less wrong. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm