Received: by 10.223.176.5 with SMTP id f5csp949534wra; Tue, 6 Feb 2018 09:59:00 -0800 (PST) X-Google-Smtp-Source: AH8x2243GpKUo42lDeJ0NC2PatggIYCgmiPAol+cvVvMMp56M77CT5MubU2ZGl4xvJBz/pIOZ3kW X-Received: by 10.101.101.149 with SMTP id u21mr2671491pgv.251.1517939940840; Tue, 06 Feb 2018 09:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517939940; cv=none; d=google.com; s=arc-20160816; b=Wkia9g2YtQKxlph73c1K7DtnK22bunF7OxOTcG6r0erYCO4nYVvrTTlKVIyHWuIicE LI/Rq3DHbD1GAgcRot1hjowmNoy+QWQprQYUNy4FunYdbtG7n2lWIybdLHdysD4zfgah aO1q9hL1L1G4Gmyca0ra6+WjInIVN+YOGk+AJgM9+TTtkfOkR9CS2VP3LYYbocQesoSv e0V7ebqGXEo8fRWa1Bb9SkrimAfkJSIfRa9Nv1uDtaXD/93zQrgeRq6XDg2KvUaKaMjr ld1fIRlyFNMRB3dbl5A8QnTmJtdUiqXLEfIu4/HCgrTSFADFTqjYIMhVtGKkEMvSMWpU HHAw== 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=coJysfTO3riy48G2lxBqPu4UBNenl2qEEEmpgrZE5xw=; b=Xy5aO7Z0jsRBIJhvpkNuXSnfUGgXL7Nd42ezghUmKByLBCuXfy6nEa1+aw5zdtIALj dlnLHRndnmg3UeEE+DMyAAn33tvXamI755Ka6VNdKLmijIjkXyHMlOEdkG08r1bMO0M3 iabCSk4lUCOEmYRr1nkkyQuJ4DSwfHxYdtQ/T++STIXhnrt3T5qJI2nseekwz2BWkHzV nlPvCc4+T+r9T/JpA5CTjOSilFEpPoAyhQ16Ll7cyppLK4/TRwJrx1DXMk7PjWSGoAF5 vH7RgknrIQx5ktLdY5sQ+mdj917Vfg7ZrrqO7fj4Q7v4UdPcp8yhruF+AzaXU+NAyajo ReOQ== 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 x10-v6si4809587pln.30.2018.02.06.09.58.47; Tue, 06 Feb 2018 09:59:00 -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; 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 S1752905AbeBFR5q (ORCPT + 99 others); Tue, 6 Feb 2018 12:57:46 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:41048 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752599AbeBFR5H (ORCPT ); Tue, 6 Feb 2018 12:57:07 -0500 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 19D2D1596; Tue, 6 Feb 2018 09:57:07 -0800 (PST) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.207.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6CB9F3F25C; Tue, 6 Feb 2018 09:57:04 -0800 (PST) From: Marc Zyngier To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Cc: Catalin Marinas , Will Deacon , Peter Maydell , Christoffer Dall , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux Subject: [PATCH v4 07/17] arm/arm64: KVM: Implement PSCI 1.0 support Date: Tue, 6 Feb 2018 17:56:11 +0000 Message-Id: <20180206175621.929-8-marc.zyngier@arm.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180206175621.929-1-marc.zyngier@arm.com> References: <20180206175621.929-1-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- include/kvm/arm_psci.h | 3 +++ virt/kvm/arm/psci.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) 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); diff --git a/virt/kvm/arm/psci.c b/virt/kvm/arm/psci.c index c41553d35110..3e7c63e15f04 100644 --- a/virt/kvm/arm/psci.c +++ b/virt/kvm/arm/psci.c @@ -234,7 +234,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; } @@ -313,6 +313,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; @@ -355,6 +396,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: -- 2.14.2