Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1516396pxu; Fri, 27 Nov 2020 08:56:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGVCuqIiGdV71T1h5I4X0zcWbBBHP3PH5WDUA/MhtOtAktlVzNi/xkESBtkr1nu+nrxL1f X-Received: by 2002:a17:906:14d:: with SMTP id 13mr1036811ejh.516.1606496199688; Fri, 27 Nov 2020 08:56:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606496199; cv=none; d=google.com; s=arc-20160816; b=EadsHusMyUZkA7wvFBuxxbVgFyk3duZ8fq3+lJtuPaBvf5ch1u3P/LKmw3+LBQGSE/ mFI8+Um1mHKf+Nl4o+fa3a/yx8v07d6EsdXVKma+Dk3LR25e9IrghQ1pLYyOrk3Q7Kxo qX8i3SQvitQ2gAANkwncsjDI/kF3Pghpd3hcaYhS3tTVlzM7sCzJBBC9MOVWBvLRzlr2 AyVJ922WUhv2BSlRqqboxLFtqD9pZ034FFnp8I4M4gpXut1DtSGyz5OfMt1HVWD2TmCg oLkWw3zMp12nIR5k3ohG12PSHjXE43iXmyympcENye7U90chxHzMXlDgqPYlaL4iq+LH pC9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=xohEIkk2EhP52EhGu26GAOGmjr/UrAZsmZ1PxApvBw8=; b=Ml1OiMLMz4VCMiidtMExEfhJCTrGvXw2e+RhSQJGOYtbPHnM+6QzHNRJycLsqHZQtI KZvhLMZxxKXDKZPeoFUDvueJ4SFokICLMiGUtUU5IH3rvSTCRQhi5kJFiR1GX6jH/Kpj f2QiK85uYi9KQ69QGRXUn05q2yMBY8UoFsEgOZDpMdi/x7cPefjOk5SVSRB3mCwGldmG frU0zWsLo+Awb3CuKp6PBTaHWW8mT26XsZepRqhYMwvp1zHt1fwdn/cSA0+Oqmaa96oE 2MsXvdGHO8Ahx7JpvwQeRn7iW7MxhNmNZaPt09bjb8bQpAbKpgpKgwseZbPVDFyKh8Cy cCmQ== 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 3si5543395edv.202.2020.11.27.08.56.15; Fri, 27 Nov 2020 08:56:39 -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 S1732164AbgK0QwG (ORCPT + 99 others); Fri, 27 Nov 2020 11:52:06 -0500 Received: from foss.arm.com ([217.140.110.172]:46604 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732138AbgK0QwF (ORCPT ); Fri, 27 Nov 2020 11:52:05 -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 1848731B; Fri, 27 Nov 2020 08:52:05 -0800 (PST) Received: from bogus (unknown [10.57.59.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7EF3D3F71F; Fri, 27 Nov 2020 08:52:01 -0800 (PST) Date: Fri, 27 Nov 2020 16:51:59 +0000 From: Sudeep Holla 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 , Mark Rutland , Lorenzo Pieralisi , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com Subject: Re: [PATCH v3 16/23] kvm: arm64: Forward safe PSCI SMCs coming from host Message-ID: <20201127165159.3s7hob5tgjcrbz33@bogus> References: <20201126155421.14901-1-dbrazdil@google.com> <20201126155421.14901-17-dbrazdil@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126155421.14901-17-dbrazdil@google.com> User-Agent: NeoMutt/20171215 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 26, 2020 at 03:54:14PM +0000, David Brazdil wrote: > Forward the following PSCI SMCs issued by host to EL3 as they do not > require the hypervisor's intervention. This assumes that EL3 correctly > implements the PSCI specification. > > Only function IDs implemented in Linux are included. > > Where both 32-bit and 64-bit variants exist, it is assumed that the host > will always use the 64-bit variant. > > * SMCs that only return information about the system > * PSCI_VERSION - PSCI version implemented by EL3 > * PSCI_FEATURES - optional features supported by EL3 > * AFFINITY_INFO - power state of core/cluster > * MIGRATE_INFO_TYPE - whether Trusted OS can be migrated > * MIGRATE_INFO_UP_CPU - resident core of Trusted OS > * operations which do not affect the hypervisor > * MIGRATE - migrate Trusted OS to a different core > * SET_SUSPEND_MODE - toggle OS-initiated mode > * system shutdown/reset > * SYSTEM_OFF > * SYSTEM_RESET > * SYSTEM_RESET2 > > Signed-off-by: David Brazdil > --- > arch/arm64/kvm/hyp/nvhe/psci-relay.c | 43 +++++++++++++++++++++++++++- > 1 file changed, 42 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c > index e7091d89f0fc..7aa87ab7f5ce 100644 > --- a/arch/arm64/kvm/hyp/nvhe/psci-relay.c > +++ b/arch/arm64/kvm/hyp/nvhe/psci-relay.c > @@ -57,14 +57,51 @@ static bool is_psci_call(u64 func_id) > } > } > > +static unsigned long psci_call(unsigned long fn, unsigned long arg0, > + unsigned long arg1, unsigned long arg2) > +{ > + struct arm_smccc_res res; > + > + arm_smccc_1_1_smc(fn, arg0, arg1, arg2, &res); > + return res.a0; > +} > + > +static unsigned long psci_forward(struct kvm_cpu_context *host_ctxt) > +{ > + return psci_call(cpu_reg(host_ctxt, 0), cpu_reg(host_ctxt, 1), > + cpu_reg(host_ctxt, 2), cpu_reg(host_ctxt, 3)); > +} > + > +static __noreturn unsigned long psci_forward_noreturn(struct kvm_cpu_context *host_ctxt) > +{ > + psci_forward(host_ctxt); > + hyp_panic(); /* unreachable */ > +} > + > static unsigned long psci_0_1_handler(u64 func_id, struct kvm_cpu_context *host_ctxt) > { > - return PSCI_RET_NOT_SUPPORTED; > + if (func_id == kvm_host_psci_function_id[PSCI_FN_CPU_OFF]) > + return psci_forward(host_ctxt); > + else if (func_id == kvm_host_psci_function_id[PSCI_FN_MIGRATE]) > + return psci_forward(host_ctxt); Looks weird or I am not seeing something right ? Same action for both right ? Can't they be combined ? -- Regards, Sudeep