Received: by 10.223.185.116 with SMTP id b49csp7395705wrg; Thu, 1 Mar 2018 05:01:22 -0800 (PST) X-Google-Smtp-Source: AG47ELuzK0ul9Hg5+ah0TXMyNBClbW8BYaq/+kNQOo8s3P2H0eYmIk5VF7qr8OHVskXr+JaeYVk7 X-Received: by 10.101.70.133 with SMTP id h5mr1533769pgr.166.1519909282680; Thu, 01 Mar 2018 05:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909282; cv=none; d=google.com; s=arc-20160816; b=PzA6bfn++kA0bKASFdtv2fCwNMXOIOQEyie3yDltrBHiHsmrXjO49Ua1FawPjsowfN GA3tcI0m2kNvxvWeaAiIVuxibQP8xIKeIgB52kAs2j5awPdQahbsSg+pwg9zKViZVT9v io+0lWKf0jBVprR8yAeSzjWxsSxxNPwMeL4xRzRylOjYVwp8I3iHKU0aJAtNDS7+hIYg nWPtq286BR3BtMqcYaMKHBRLnJ7McAuwACKAQYdA8C0uMrTR7pTog/ZYIOKqSm6qazA0 +Q6DmBSi1DzHCk8ZiPUESy9k/QMl9+Rt5Abko3kou7LVhbAM56zm1gaNJilRkGiUMb+b hQCg== 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:dkim-signature:arc-authentication-results; bh=J+5mFS5YG0Z6B4feNaUOGsgL/hJiqYMdZY2VyVL7BU0=; b=PQPFDC9MJEUa+9+eS0OjyeLbYYJKeegXR9E88OFh79JFltRl8lPUzPFaYQZV3sHBNN tvMwODSiBEPVJDxo69/KKoTje86qeqLTTlBnva1s9ubi4Udqf9uNs82Shd220t6QmjeP 7EUvgsoYvnaWQNRYGftpQdGbnTUrp+b4MEmyfc+/zs5t+3lUu/5JdZMJrOPEsrbv86Go CH8ru41UWFRccIKQIG6nLeUni/LpF+64ZIJNIcuBPo7L5GdzE+QbNrOH8Iz9ODfrglFN c8AdzOVlS3VPuyJUXYqGJUGr4WCZzIy0SiuDC9HcdspNH7uoX0XsuQ1cGdlHVcu0ql8I jJMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cNliJQE+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4-v6si2996348plw.297.2018.03.01.05.01.03; Thu, 01 Mar 2018 05:01:22 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=cNliJQE+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031063AbeCANAC (ORCPT + 99 others); Thu, 1 Mar 2018 08:00:02 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34475 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030735AbeCAM75 (ORCPT ); Thu, 1 Mar 2018 07:59:57 -0500 Received: by mail-pg0-f66.google.com with SMTP id m19so2279243pgn.1 for ; Thu, 01 Mar 2018 04:59:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=J+5mFS5YG0Z6B4feNaUOGsgL/hJiqYMdZY2VyVL7BU0=; b=cNliJQE+mVOBsVb8LMhpi351PjVm9gqEDlFXQWMMXNNaqbPBsy4oK/0vk9cVUXNkm2 I+ojSopeItSzHa2lqOac6u6cEXjJ5RXwip9bjvc1YILoj4Gfh/ernqEk7iOl0xYqUkDp 9ALGtgQxoadLu1NrtZs4AaZxjAlGW1urE2jNM= 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; bh=J+5mFS5YG0Z6B4feNaUOGsgL/hJiqYMdZY2VyVL7BU0=; b=Em4oHr9PqUlioEhoZBxcK2z6q7Xb/W+yaRtqspZXg5OSHxqDB71TBp1m8jc/5dHYKK zfWu67rN+tiOoowAyEzZFhlH8dNJZ9HpoFp21hbrIF6JNZQRGKTdl3GcLSt2WXzxanJ4 AqHFEVy1Vo/JumEV1KDV3Yx0+wMqx2VFck9h67Dz0MK+vOuwd3KoFxS+0il4ZcIWQt1R UPr9fw6VHCpeuqF2OdPvW7rOJuVkHa1RAbAA+8U5PFUtp09YwUgSKsQ0O6GqjpzKpMDj cZAc8VOcWQavpCVdqbgPHy0S54LFiZW1745iW+7qpf56iYMXltw10pKsvRzAb7DM7duD NtAg== X-Gm-Message-State: APf1xPAjtuIMevFcsqOCP0sTyHoHoTRWLlOAYd4IzJUHJfrtK5/pIwY6 FsvhvVOHuTnkhfpQFqCsu4H43A== X-Received: by 10.101.77.69 with SMTP id j5mr1494347pgt.352.1519909196927; Thu, 01 Mar 2018 04:59:56 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.04.59.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 04:59:56 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 34/45] arm/arm64: KVM: Implement PSCI 1.0 support Date: Thu, 1 Mar 2018 20:54:11 +0800 Message-Id: <1519908862-11425-35-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 58e0b2239a4d 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 Signed-off-by: Will Deacon Signed-off-by: Alex Shi --- arch/arm/kvm/psci.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- include/kvm/arm_psci.h | 3 +++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/psci.c b/arch/arm/kvm/psci.c index bc334d6..097632c 100644 --- a/arch/arm/kvm/psci.c +++ b/arch/arm/kvm/psci.c @@ -233,7 +233,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; } @@ -312,6 +312,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; @@ -354,6 +395,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 5659343..3236043 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); -- 2.7.4