Received: by 10.223.176.5 with SMTP id f5csp3171272wra; Mon, 29 Jan 2018 09:49:03 -0800 (PST) X-Google-Smtp-Source: AH8x225xV08JUCtltqCccj89OYqHO4AjeSnnO8r1nNbFbsV0rmbR1ix9ZKZnge64lkKchAAgMdiF X-Received: by 10.98.61.22 with SMTP id k22mr27414066pfa.133.1517248143605; Mon, 29 Jan 2018 09:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517248143; cv=none; d=google.com; s=arc-20160816; b=HJQxVxM+HrR7pbBlFmqEdesPc5Xa6vmx9i9tveOr3uRgPvvrRVKNggNRxQCGe9as3z Bnki6uBGzZ5txOrKxh1aETpsvIz6QRBbczDvt5McLrnfNOqhkhuBc/cKQeyI1QVXet/A yMuPQrnux5oAijQsB7F/LPtulWePIa/5TGEdNoPGg32bQRi8r8DX3Ej6Uh94t+xydho1 S117VwtBF27XSF9I+vrfIQbwwmWGezBHGyQ99EXXNTZ5tdhQ5xOZtJZSWEeMlO9/7mJV DtcLRd5oyGusIflmqRME5ny5U9jgKWviUNkCkhGucpbTgo+0GLotJIZdSLlaZvDVPARb tDXA== 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=kQmCszeD1oz9Rgf4ADrB+8J6LoMf0sSxzh0YDkmIgqs=; b=xkoJz9rkPm6gjRWUKueqbkkVM67GOTBUsJy395pqkTmMiimao2ShY4zvxrwNiqNHRX LSxvfXrf4N8HyUbIhWAnCc8lp2JHxpEFvJGhFAJib4Ss7y/AnWiUlCOJ8muNvXX4Wwh2 0TGaqvTuiTcVLM50qDVrl1KDK3zC7iOqG/H+dPclq/mrygYr4H3zIM8xetsoKixYadVy ZtaAOsmIjbr+coiW44zHm32/rQ3fsiSSIDgACx79OyYcZMyHZHFh8iHQYgZV0EMY2aMZ 5FtsbkE7JENuxDOC1caad+rC3QCenxtxdmoCYK26k1oy7LT/A2T+XNX+Y+i+CCBjupt8 6A/g== 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 u26si3810297pge.210.2018.01.29.09.48.49; Mon, 29 Jan 2018 09:49:03 -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 S1751894AbeA2RrS (ORCPT + 99 others); Mon, 29 Jan 2018 12:47:18 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:43518 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666AbeA2Rq2 (ORCPT ); Mon, 29 Jan 2018 12:46:28 -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 D79FF1435; Mon, 29 Jan 2018 09:46:27 -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 C45653F487; Mon, 29 Jan 2018 09:46:25 -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 , Jon Masters Subject: [PATCH v2 06/16] arm/arm64: KVM: Implement PSCI 1.0 support Date: Mon, 29 Jan 2018 17:45:49 +0000 Message-Id: <20180129174559.1866-7-marc.zyngier@arm.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180129174559.1866-1-marc.zyngier@arm.com> References: <20180129174559.1866-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 having PSCI 0.2 and the FEATURES call. Of, and returning 1.0 as the PSCI version. We happily ignore everything else, as it is optional. Signed-off-by: Marc Zyngier --- include/kvm/arm_psci.h | 1 + virt/kvm/arm/psci.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/kvm/arm_psci.h b/include/kvm/arm_psci.h index 3a408c846c09..e7f69c0dc249 100644 --- a/include/kvm/arm_psci.h +++ b/include/kvm/arm_psci.h @@ -21,6 +21,7 @@ #define PSCI_VERSION(x,y) ((((x) & 0x7fff) << 16) | ((y) & 0xffff)) #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) 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 053654082bd4..6299501f7664 100644 --- a/virt/kvm/arm/psci.c +++ b/virt/kvm/arm/psci.c @@ -315,6 +315,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; @@ -357,6 +398,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