Received: by 10.192.165.156 with SMTP id m28csp232690imm; Tue, 17 Apr 2018 09:13:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Hvps/zHojV9ov5RYJ0sOK0haqihrrM6R70T6H61sA2UlG/i0BQptRflIazKy5dtIwhM/I X-Received: by 10.101.93.140 with SMTP id f12mr2342295pgt.412.1523981601777; Tue, 17 Apr 2018 09:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523981601; cv=none; d=google.com; s=arc-20160816; b=zyH5qK6gBGxp5mXebuuZVJTZ9mwxHnUoxt8HHcu2J4sAiwSjJaxD/Jitca7Jk8Jrjo e0qbE91xJ9CV2Pe/zFVJjB+Bb2mSAyPaLQkLKkXJCrJS2wN3ep2QqPO03vgeH9/WezUc d2KdoWpZ1YXcdbrDddkg2in1G4idgxiASn1gxFZ58atDm7k3olyFeBwPIDM6vUu4e6Xa IsoEh0X6PDLbO5D5sC1GG9oCJ/wv/AMA0s9pjRtRfzuW4an+fiipZuVh0+50hp32Xv6H QmB1Y4TgdAJPcr06bLPrueElZO7xdmESEmMPmWWxVKqPfiixKUjPF3si5oxOxKZwoG+/ rS1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OkYavHGbqHZYwGyzJUOW8+IlqjtGHw3gEXYsyd9fOJ4=; b=gbw9dgbUEtvlV7ixDRDzKXKAKXxV0znPlxGSSgbaxbP3b7B5ZclR7gDpbw3K3TI8uv bu/4mgU+jbitO42GQvA+y8I5nM37HAvt3s/ARX+MmQwIRY/PLUQp53SlICjdCfnOkDUY C6U924ph7qSnet+SP5neNzy0eUlKCw6SBOtMMK2N1nmndH9524GfJuHIFFXikpqA6tpQ trxIIYHwHvYlSr2yks1wWw4P9dwUtwK2GrQZB4cUvjs0QiMLBnmUhDwh7piYGn2K8AC6 kFR6X/H8Z3TKM9jbWL30x1H3KEZT4la8hdRYCFjAQoHIh3TCOPjM8yQh+/3b5tEaoqVM UefA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 33-v6si14717620plk.37.2018.04.17.09.13.07; Tue, 17 Apr 2018 09:13:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756003AbeDQQLM (ORCPT + 99 others); Tue, 17 Apr 2018 12:11:12 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36630 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754580AbeDQQLH (ORCPT ); Tue, 17 Apr 2018 12:11:07 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 06CC4D6A; Tue, 17 Apr 2018 16:11:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Christoffer Dall , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Greg Hackmann , Mark Rutland Subject: [PATCH 4.9 39/66] arm/arm64: KVM: Implement PSCI 1.0 support Date: Tue, 17 Apr 2018 17:59:12 +0200 Message-Id: <20180417155647.562185014@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland 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] Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman --- arch/arm/kvm/psci.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- include/kvm/arm_psci.h | 3 +++ 2 files changed, 47 insertions(+), 1 deletion(-) --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -232,7 +232,7 @@ static void kvm_psci_system_reset(struct 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_ 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_ 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: --- 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);