Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1209351pxu; Fri, 27 Nov 2020 02:16:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfBFiT4YMnk9Ue/XRcKbpOkcrPwN+uZmEEqn4eclYlgJ/l0LKwJU86VNnQZOIBOIYctdeh X-Received: by 2002:a17:906:80ca:: with SMTP id a10mr6857408ejx.351.1606472192574; Fri, 27 Nov 2020 02:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606472192; cv=none; d=google.com; s=arc-20160816; b=b6mtW65rDKLSnq1heRDqQxFavQjDlKJacMurZfNjZLCDPbTuOotMR9Eemgl3ASzbdh 30odUhJgQIhIn1wZJVm/OpTVSIlYKEQJI9hCORVwPTWPUe+GAkrte2N/EzsEW+04E9rO 4NVXIOJFgF6pHeDM7G/SXzBePx0PQJ/Np2lAA2VGSxEYTpp9eCxoFG6wLcIqgIxUJ4Ak 6/Sh/7MQNauscjaei7g78/jQxSCPKSy2Hy6ioA7DW5+/FKl4j6NEfXuWG56BxHVNlJ1P ma/FBEFVKmvPBMw8fHUQeHlR/cxVs6H9/hPAsTHm/3FP8zM77lpOQlLWIv08iBnE3esK z1VA== 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=Lsqfe3FLmSttsPHiyXUAo8CrvBCdbur3RipimSXiiCI=; b=EjkMj7c7OJ7ir3QggXfnG3zmscxvy0gz3sKKT+StfJPQ1ZBJfILwDGEIIPuP8us/zg +LJeQrScy7HCA1QHPN5rb57FIUGhyHsFmeYLt17T1n4VNQSpiOUeIl3+N59ktb1D0D2F t9em5FmKaYGlBcdV5xnIMM5IiDdvHpZ+uYpgiYayICtS6N1Gylrn5WDF2eqlSb4ozYMd sO4YueuMKSCSou9atJZy+RSYBaLpZKtWvOO0SsDqt5G/35RDgXIjSl+FAtiT97u4zgRD JZDV4JoQMEu0QcnMdoIgL9H//GsvEmecf/9K6yFQ2AGI9FH5sJZydeaoTZVr3P0/14Kd y5pw== 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 v5si4690314eda.107.2020.11.27.02.16.08; Fri, 27 Nov 2020 02:16:32 -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 S1726202AbgK0KOn (ORCPT + 99 others); Fri, 27 Nov 2020 05:14:43 -0500 Received: from foss.arm.com ([217.140.110.172]:36952 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725865AbgK0KOm (ORCPT ); Fri, 27 Nov 2020 05:14:42 -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 D965E1516; Fri, 27 Nov 2020 02:14:41 -0800 (PST) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A809E3F71F; Fri, 27 Nov 2020 02:14:39 -0800 (PST) Date: Fri, 27 Nov 2020 10:14:33 +0000 From: Lorenzo Pieralisi 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 , 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 16/23] kvm: arm64: Forward safe PSCI SMCs coming from host Message-ID: <20201127101433.GA1061@e121166-lin.cambridge.arm.com> 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: Mutt/1.9.4 (2018-02-28) 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 What about SYSTEM_SUSPEND ? Lorenzo > 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); > + else > + return PSCI_RET_NOT_SUPPORTED; > } > > static unsigned long psci_0_2_handler(u64 func_id, struct kvm_cpu_context *host_ctxt) > { > switch (func_id) { > + case PSCI_0_2_FN_PSCI_VERSION: > + case PSCI_0_2_FN_CPU_OFF: > + case PSCI_0_2_FN64_AFFINITY_INFO: > + case PSCI_0_2_FN64_MIGRATE: > + case PSCI_0_2_FN_MIGRATE_INFO_TYPE: > + case PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU: > + return psci_forward(host_ctxt); > + case PSCI_0_2_FN_SYSTEM_OFF: > + case PSCI_0_2_FN_SYSTEM_RESET: > + psci_forward_noreturn(host_ctxt); > + unreachable(); > default: > return PSCI_RET_NOT_SUPPORTED; > } > @@ -73,6 +110,10 @@ static unsigned long psci_0_2_handler(u64 func_id, struct kvm_cpu_context *host_ > static unsigned long psci_1_0_handler(u64 func_id, struct kvm_cpu_context *host_ctxt) > { > switch (func_id) { > + case PSCI_1_0_FN_PSCI_FEATURES: > + case PSCI_1_0_FN_SET_SUSPEND_MODE: > + case PSCI_1_1_FN64_SYSTEM_RESET2: > + return psci_forward(host_ctxt); > default: > return psci_0_2_handler(func_id, host_ctxt); > } > -- > 2.29.2.454.gaff20da3a2-goog >