Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1091902pxu; Wed, 2 Dec 2020 10:47:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8NN7MGVKwlWaOhv+aGAmbuXDWVXPQpJtbgfnORjkZ2j6qZMjOVMwgL0ABUQDtOoPLoM7/ X-Received: by 2002:a17:907:3da3:: with SMTP id he35mr1140310ejc.9.1606934857637; Wed, 02 Dec 2020 10:47:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606934857; cv=none; d=google.com; s=arc-20160816; b=K9tDD2uLQf73jk1EZn6zjNRnkQOB06jzoeIGamlgOJr5KxGS1E9axE5e8KhvxElzZ0 en7bcfqFLG+5Ndfm0bcc+Hijc2hGpngJBRP7fLBIauFCV6Ou9HDNWG3hmK11Niv/hDCX Y/rhn6z/ncG2cpC05L4AMlFt2o4G4GkzuUBFpgZwW97eMARv0CEDk+KskM66h9PGSNg7 eZqAfUnWsl/5rJymCuSu3n4ZnPS0Tm6QdWoR2NKb0L5smf/9kjQsZoNmJ2OCIb8oOsal uUGeLqoj0EOwS6Lba++Gyx9utq0c5v18z1sr68IcSbO1Xao3uPUwICb4Lx7YuOcpxlIi HSMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FBH6HEW5NPUtTsYV4IlYky2BDGVGm12SrN30lN4PkFY=; b=xL3nV52xoNuggAAJwe0X3ajvWSkm1fAqdRX1EPhHmV0zFvDpu7Ti6crJEWIm/3f0eK uu4nio37tL5W+3I6rb25Hq65ivi0B4ijO0NA4U7ItZvaJ59I/9vJlSoOuM/N0GmlYzFG kxLfvWXFne0KEB6osv9oZm32Nue6IiAfWfwhCLgNKuWCF4h62DMPj+0Td6AUkSWeEvQl CI0WIaPqDvAdfswKkKOAfYvdZqgrKC3oaPwME2NQKLzPNAzlV4tD9UkP37reCDz5Ia6K x7Pxgiwv23pjjnR0Kt7zCVLrDy3xeD5mfKHAndVZOQwV+NYPEnBL+daqNWyDUZ9hsm5p kBqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GwirdQYp; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si569779ejt.583.2020.12.02.10.47.14; Wed, 02 Dec 2020 10:47:37 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=GwirdQYp; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389594AbgLBSng (ORCPT + 99 others); Wed, 2 Dec 2020 13:43:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389587AbgLBSne (ORCPT ); Wed, 2 Dec 2020 13:43:34 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9003C0617A7 for ; Wed, 2 Dec 2020 10:42:20 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id e25so11135561wme.0 for ; Wed, 02 Dec 2020 10:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FBH6HEW5NPUtTsYV4IlYky2BDGVGm12SrN30lN4PkFY=; b=GwirdQYpnGgq1EVsJzAuWcQcbP11n6x036yOyPPx1vuGLdUpAEBFHj+LcFwdzYyxw+ T8lnqGlHicu8lC1OG+9o9owM1KpTEfxKieiZO+v648VwSXWHshhhM5L5mcoUnNJoGpgP JF9LDYFE971ZkAyI4UJiC9Wj2Xc8p3fiDo1tCV+m8q7oGRHw7LI+kmLYVPoNtx23niwN DKnFEZdky5kwe4pgwVbOEWZKaUBtyvs+ZR+1j/PIZVxPLVLSf3X2PlsluY9qutX26LPO CoDv2JHfB182QCETZ+fYEDp3BzS+9YTS+Cpc2qSLa7FqP4K3kA3VJYq5HemX3PVOurbw WfCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FBH6HEW5NPUtTsYV4IlYky2BDGVGm12SrN30lN4PkFY=; b=s0y0WJg/t8LYOdqR/gPmhUS8DZWsQjFJxCGWReU/z2aq5s5XQ044YIpHDPSR7HeEpi 5tHuG7UQHehPSDw9rdsP1oa00cWJ7mpnzcvEVM2dD35kuD/VofAUYzKtliWYJSDiUHc3 pKzBcX6zkWlYfXjxKoYKzkAcQ7adwo42/pLqxaTl3Wp1WUoCTGHxMg+fLLmfWXdMcfCz Emfy+SNiTjRr57dT3lPUXpGptM1fFgMxspxwFXArbpie04eb6A6+y7mmuukJSVk4tjiE KfV+qUbXsPSRuYxEd61UBz0cAXkAyytnD+VFx3ZbOQqxsanhgEUjKrNVjS57Dlf7hTGz Z9Lw== X-Gm-Message-State: AOAM532BqOfSX0L36pK0adLqzXplQ1wz22FeF6uS3G/dP1AYdD+2THHk QpsgoRcpJ7UIZQW/bqnrCoBJ5Q== X-Received: by 2002:a1c:a402:: with SMTP id n2mr4626696wme.185.1606934539318; Wed, 02 Dec 2020 10:42:19 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:5ddd:b7c5:e3c9:e87a]) by smtp.gmail.com with ESMTPSA id x9sm3176873wru.55.2020.12.02.10.42.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Dec 2020 10:42:18 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: 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 , Sudeep Holla , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-team@android.com, David Brazdil Subject: [PATCH v4 23/26] kvm: arm64: Intercept host's SYSTEM_SUSPEND PSCI SMCs Date: Wed, 2 Dec 2020 18:41:19 +0000 Message-Id: <20201202184122.26046-24-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201202184122.26046-1-dbrazdil@google.com> References: <20201202184122.26046-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a handler of SYSTEM_SUSPEND host PSCI SMCs. The semantics are equivalent to CPU_SUSPEND, typically called on the last online CPU. Reuse the same entry point and boot args struct as CPU_SUSPEND. Signed-off-by: David Brazdil --- arch/arm64/kvm/hyp/nvhe/hyp-init.S | 2 +- arch/arm64/kvm/hyp/nvhe/psci-relay.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-init.S b/arch/arm64/kvm/hyp/nvhe/hyp-init.S index 0853f62b052b..a2e251547625 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-init.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp-init.S @@ -151,7 +151,7 @@ SYM_CODE_START(kvm_hyp_cpu_entry) SYM_CODE_END(kvm_hyp_cpu_entry) /* - * PSCI CPU_SUSPEND entry point + * PSCI CPU_SUSPEND / SYSTEM_SUSPEND entry point * * x0: struct kvm_nvhe_init_params PA */ diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c index 688cf7f40d42..08dc9de69314 100644 --- a/arch/arm64/kvm/hyp/nvhe/psci-relay.c +++ b/arch/arm64/kvm/hyp/nvhe/psci-relay.c @@ -201,6 +201,30 @@ static int psci_cpu_suspend(u64 func_id, struct kvm_cpu_context *host_ctxt) __hyp_pa(init_params)); } +static int psci_system_suspend(u64 func_id, struct kvm_cpu_context *host_ctxt) +{ + DECLARE_REG(unsigned long, pc, host_ctxt, 1); + DECLARE_REG(unsigned long, r0, host_ctxt, 2); + + struct psci_boot_args *boot_args; + struct kvm_nvhe_init_params *init_params; + + boot_args = this_cpu_ptr(hyp_symbol_addr(suspend_args)); + init_params = this_cpu_ptr(hyp_symbol_addr(kvm_init_params)); + + /* + * No need to acquire a lock before writing to boot_args because a core + * can only suspend itself. Racy CPU_ON calls use a separate struct. + */ + boot_args->pc = pc; + boot_args->r0 = r0; + + /* Will only return on error. */ + return psci_call(func_id, + __hyp_pa(hyp_symbol_addr(kvm_hyp_cpu_resume)), + __hyp_pa(init_params), 0); +} + asmlinkage void __noreturn kvm_host_psci_cpu_entry(bool is_cpu_on) { struct psci_boot_args *boot_args; @@ -265,6 +289,8 @@ static unsigned long psci_1_0_handler(u64 func_id, struct kvm_cpu_context *host_ case PSCI_1_0_FN_SET_SUSPEND_MODE: case PSCI_1_1_FN64_SYSTEM_RESET2: return psci_forward(host_ctxt); + case PSCI_1_0_FN64_SYSTEM_SUSPEND: + return psci_system_suspend(func_id, host_ctxt); default: return psci_0_2_handler(func_id, host_ctxt); } -- 2.29.2.454.gaff20da3a2-goog