Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp411241pxu; Tue, 1 Dec 2020 14:36:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQQAhZ8QsOqTfZu86OM6ir4sxGuRgn3uV7as9sJJoR62D5kfQXoYckjuvoLUw6z7Ti1mpF X-Received: by 2002:a05:6402:1c1c:: with SMTP id ck28mr5463089edb.336.1606862211323; Tue, 01 Dec 2020 14:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606862211; cv=none; d=google.com; s=arc-20160816; b=qiBykOw6e5QyxdhprHTvpp7yaSHRstgt6bioouo2qZvhz/Zw/lQtNFw1UKHzLLf8V/ 6YtVWVMcV0PRKaL7zgg2zBSJam9h7v8NOF0vNAlV8cnJPWlcqu8SgdBY2/YCG/lC6rwi dEdsB4A665QtuRTUETheTQ5ySelwzBTxW+qSFUL6D42B4iccs4TH4/hqL5F3gJQYZvIf 00Nst3mGRavlRH1zFevneCD/NK4ZF4DWaV9SHHTmid1svB/9Qci/vCu/z6xmXtYGEBsX +9c/W4vzsVIzlPVc+6GZGnnOKNong6H9r8RdOeoVXOLNLOtTOeVlLZXmUcCim/abefGg Wd7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Fn+GsNbHXoSK7RO1vbfNSiE3l/EjdCIvdHaPsftpZm4=; b=vVJHVtLQi03WrE8mBfBFlpgjebFJ8rHqzcM6CDCeTlK4MC6N+iOBuRo590xfFOSkpn Dq3VQPqQAXDTeW2rpsYp28AaSpUxiBjJqPeI3cKckO4g1cthCWfPK7Z8NZijIF9FVjkv PdRSyrlGNdOG3+Xxj8xoZN6eFjnQ8fZzVrQOA5HD19uzyiKqqajzaWsu45k/Q3zfKdkf sG21k0BKInA/G69rgUBKY0vTZV72uqjsCVLruxILLz+D+x2UmwdazPcCeR0L24zKogYX 3Oi7DzLvAibgiIZdGL/SymGD0ehaqkZmKviTg6T8ffV57E6gDnawSTkUm9EsFzHu/ph0 xtBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si905594eje.368.2020.12.01.14.36.29; Tue, 01 Dec 2020 14:36:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389920AbgLAO6S (ORCPT + 99 others); Tue, 1 Dec 2020 09:58:18 -0500 Received: from foss.arm.com ([217.140.110.172]:44382 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389268AbgLAO6S (ORCPT ); Tue, 1 Dec 2020 09:58:18 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 72E9C30E; Tue, 1 Dec 2020 06:57:32 -0800 (PST) Received: from C02TD0UTHF1T.local (unknown [10.57.30.155]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 073823F575; Tue, 1 Dec 2020 06:57:23 -0800 (PST) Date: Tue, 1 Dec 2020 14:57:20 +0000 From: Mark Rutland To: David Brazdil Cc: kvmarm@lists.cs.columbia.edu, Jonathan Corbet , Catalin Marinas , Will Deacon , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Dennis Zhou , Tejun Heo , Christoph Lameter , Lorenzo Pieralisi , Sudeep Holla , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com Subject: Re: [PATCH v3 20/23] kvm: arm64: Intercept host's CPU_SUSPEND PSCI SMCs Message-ID: <20201201145720.GB86881@C02TD0UTHF1T.local> References: <20201126155421.14901-1-dbrazdil@google.com> <20201126155421.14901-21-dbrazdil@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126155421.14901-21-dbrazdil@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 26, 2020 at 03:54:18PM +0000, David Brazdil wrote: > Add a handler of CPU_SUSPEND host PSCI SMCs. The SMC can either enter > a sleep state indistinguishable from a WFI or a deeper sleep state that > behaves like a CPU_OFF+CPU_ON except that the core is still considered > online when asleep. > > The handler saves r0,pc of the host and makes the same call to EL3 with > the hyp CPU entry point. It either returns back to the handler and then > back to the host, or wakes up into the entry point and initializes EL2 > state before dropping back to EL1. For those CPU_SUSPEND calls which lose context, is there no EL2 state that you need to save/restore, or is that all saved elsewhere already? The usual suspects are PMU, debug, and timers, so maybe not. It'd be nice to have a statement in the commit message if we're certain there's no state that we need to save. > A core can only suspend itself but other cores can concurrently invoke > CPU_ON with this core as target. To avoid racing them for the same > boot args struct, CPU_SUSPEND uses a different struct instance and entry > point. Each entry point selects the corresponding struct to restore host > boot args from. This avoids the need for locking in CPU_SUSPEND. I found this a bit confusing since the first sentence can be read to mean that CPU_ON is expected to compose with CPU_SUSPEND, whereas what this is actually saying is the implementation ensures they don't interact. How about: | CPU_ON and CPU_SUSPEND are both implemented using struct cpu_boot_args | to store the state upon powerup, with each CPU having separate structs | for CPU_ON and CPU_SUSPEND so that CPU_SUSPEND can operate locklessly | and so that a CPU_ON xall targetting a CPU cannot interfere with a | concurrent CPU_SUSPEND call on that CPU. The patch itself looks fine to me. Thanks, Mark.