From patchwork Thu Apr 12 11:11:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 133226 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1572439ljb; Thu, 12 Apr 2018 04:13:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Tnl2KEjRdx+iPrlyqNdY9LZkCDsRSlVLebaivAJkjVcKpnocNVVWIQGaFFe4TcM6+NOIt X-Received: by 2002:a17:902:d88a:: with SMTP id b10-v6mr559963plz.172.1523531611916; Thu, 12 Apr 2018 04:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531611; cv=none; d=google.com; s=arc-20160816; b=kENnt/xPBUUelyqhKgB60+O4awEPjND72+worlWOTsM/Ml4WDgEB3bQG0wsbSXjoKv MbGbRPIyCh3f3SXhBAVowptLJ6dcVvgnFOt3HyGs8G9YknF11LcTuudFQB8yrT/CsgQz VhTTnyOEgX4An8ggCICaxSVBRvU9akIYYx094l4lx3dyB2zQ5TtmD0NCWmV5DxeVyjky EZD5Dioz9KMMX6hOzSYUeezmDE1NyRBBBWlvEserFscHOdt3+Tuh8WE9dSC7aefu/Bu7 bQgHO0ka9GPf76HWNUvB5VggoLenhzt9eXKCdOz/WrPabbb1VrwuDqRYLalMb1mrjBTE 4n7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=u0q0Hsr64XxPjdEAim7Mp/p7JHdAVhc7y6YbjeBxVdI=; b=AZbp66xog29/CG8aSnMhvdRnImeXvteoy7mA+3otMsjCsc0Deb145GOPiczGIn8U8q dNnJyHv0fj1MDICgX6Pc7hZIKPH/4MfuFppDnIbAtAUEJ9/dfhWOr1D8dybpvBAA+Xbp QTg+gWOC/ATeiGwBTeVGR8w5J1LLb8//O6l74L8PkldlDa6KDlgjzNA2AFckGh4CMmAQ Phv6kJ3D6DkqvXAfbnIA/gb8r3mIJq4Fv54gRWPEfFKoEorLF0sEBl/Vnme+cBTo+2hx OokBy4+nQJPBAfbPaKpxr+QNPulZz9qcSkWS2McCCpwSKsQmFzzJ7OXvLxFZLnVhcuIu zG/g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v23si2494850pfk.116.2018.04.12.04.13.31; Thu, 12 Apr 2018 04:13:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752953AbeDLLNb (ORCPT + 11 others); Thu, 12 Apr 2018 07:13:31 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59596 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752925AbeDLLNa (ORCPT ); Thu, 12 Apr 2018 07:13:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8A63580D; Thu, 12 Apr 2018 04:13:30 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DED493F24A; Thu, 12 Apr 2018 04:13:28 -0700 (PDT) From: Mark Rutland To: stable@vger.kernel.org Cc: mark.brown@linaro.org, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, ghackmann@google.com, shankerd@codeaurora.org Subject: [PATCH v4.9.y 31/42] arm/arm64: KVM: Implement PSCI 1.0 support Date: Thu, 12 Apr 2018 12:11:27 +0100 Message-Id: <20180412111138.40990-32-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180412111138.40990-1-mark.rutland@arm.com> References: <20180412111138.40990-1-mark.rutland@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 58e0b2239a4d997094ba63986ef4de29ddc91d87 upstream. PSCI 1.0 can be trivially implemented by providing the FEATURES call on top of PSCI 0.2 and returning 1.0 as the PSCI version. We happily ignore everything else, as they are either optional or are clarifications that do not require any additional change. PSCI 1.0 is now the default until we decide to add a userspace selection API. Reviewed-by: Christoffer Dall Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas [v4.9: account for files moved to virt/ upstream] Signed-off-by: Mark Rutland [v4.9 backport] --- arch/arm/kvm/psci.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- include/kvm/arm_psci.h | 3 +++ 2 files changed, 47 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index f579ed9d279b..220eaa04b1c4 100644 --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -232,7 +232,7 @@ static void kvm_psci_system_reset(struct kvm_vcpu *vcpu) int kvm_psci_version(struct kvm_vcpu *vcpu) { if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features)) - return KVM_ARM_PSCI_0_2; + return KVM_ARM_PSCI_LATEST; return KVM_ARM_PSCI_0_1; } @@ -311,6 +311,47 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) return ret; } +static int kvm_psci_1_0_call(struct kvm_vcpu *vcpu) +{ + u32 psci_fn = smccc_get_function(vcpu); + u32 feature; + unsigned long val; + int ret = 1; + + switch(psci_fn) { + case PSCI_0_2_FN_PSCI_VERSION: + val = KVM_ARM_PSCI_1_0; + break; + case PSCI_1_0_FN_PSCI_FEATURES: + feature = smccc_get_arg1(vcpu); + switch(feature) { + case PSCI_0_2_FN_PSCI_VERSION: + case PSCI_0_2_FN_CPU_SUSPEND: + case PSCI_0_2_FN64_CPU_SUSPEND: + case PSCI_0_2_FN_CPU_OFF: + case PSCI_0_2_FN_CPU_ON: + case PSCI_0_2_FN64_CPU_ON: + case PSCI_0_2_FN_AFFINITY_INFO: + case PSCI_0_2_FN64_AFFINITY_INFO: + case PSCI_0_2_FN_MIGRATE_INFO_TYPE: + case PSCI_0_2_FN_SYSTEM_OFF: + case PSCI_0_2_FN_SYSTEM_RESET: + case PSCI_1_0_FN_PSCI_FEATURES: + val = 0; + break; + default: + val = PSCI_RET_NOT_SUPPORTED; + break; + } + break; + default: + return kvm_psci_0_2_call(vcpu); + } + + smccc_set_retval(vcpu, val, 0, 0, 0); + return ret; +} + static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) { struct kvm *kvm = vcpu->kvm; @@ -353,6 +394,8 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) int kvm_psci_call(struct kvm_vcpu *vcpu) { switch (kvm_psci_version(vcpu)) { + case KVM_ARM_PSCI_1_0: + return kvm_psci_1_0_call(vcpu); case KVM_ARM_PSCI_0_2: return kvm_psci_0_2_call(vcpu); case KVM_ARM_PSCI_0_1: diff --git a/include/kvm/arm_psci.h b/include/kvm/arm_psci.h index 5659343580a3..32360432cff5 100644 --- a/include/kvm/arm_psci.h +++ b/include/kvm/arm_psci.h @@ -22,6 +22,9 @@ #define KVM_ARM_PSCI_0_1 PSCI_VERSION(0, 1) #define KVM_ARM_PSCI_0_2 PSCI_VERSION(0, 2) +#define KVM_ARM_PSCI_1_0 PSCI_VERSION(1, 0) + +#define KVM_ARM_PSCI_LATEST KVM_ARM_PSCI_1_0 int kvm_psci_version(struct kvm_vcpu *vcpu); int kvm_psci_call(struct kvm_vcpu *vcpu);