Received: by 10.223.185.116 with SMTP id b49csp513573wrg; Fri, 16 Feb 2018 02:47:00 -0800 (PST) X-Google-Smtp-Source: AH8x226YMAV8uA/oVTJBchMpoOa9crT73+PFSguP3li/jkVITlgSnWEMMWegfFJkTa9lJ/RRW6Ga X-Received: by 2002:a17:902:402:: with SMTP id 2-v6mr5394823ple.353.1518778020694; Fri, 16 Feb 2018 02:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518778020; cv=none; d=google.com; s=arc-20160816; b=TmU5Aw8WeXl40GPShWATHlMEV04Fu31crDlS33LecjP+a4AUBH6NzzmCNioEloSNOS J7GYUoYWBIzPzweitfmH/qBqqNsYkxpI08kPtTFiATDWheaa6a7d5VaeA2QuWrY6JxWe zpcyiYvkmOatmJu1Ni+9/TH9LJiaAScY6PITXJVl8BVG5ojK7DopzqfuGElcNIp452LX Lw+/VPRaHM8xVE1IH8LXVjPMxQmhCRzOi9FCQVik8IuScp/V0v+BCBZMAUVUpzgm8CPh Iep9IXj/dEsp/1Sq4OljPcSykfVsE94EqB06Nj8pMd6O0pozRgPW4tPT0juD83h4P8ui khJA== 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=3fEbLEkoNZCk5ujMyexC+Tb4AQSlEnzFjzeEBiT9zR4=; b=OVTGbg+16nreP4g2YYeh2khU2AA7i8T1RHxVxbQxuDFLGRcn1v1sBtKH9bYh6M4amp dFnTff3V+ehfxlCPYXdxBEsYjLtm0SwHRg+Ex1UJW19zhHdhr0SLE5XSI9Pyv7tv9Uc+ QaakoXSAAuSvBZwNXr5Rhk13FpX+rBx7veDwQxwaPts5UOF/eRNBHZm4RiCA9Rnsjb92 FLmdjNUhskK7QUu3oxIKy4QbTVgveF4e8+b6hnOkYlFEm54o5m8q3DQ244aNsOGAWcAK 36UVIGURHvCsQl0DMtZdT7xcV5BLWMbAXXs0F5HnV+XguMHBdn19mCb2nP0cERIKAO2h 2Yyw== 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 94-v6si2984911ple.298.2018.02.16.02.46.46; Fri, 16 Feb 2018 02:47: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 S1427137AbeBORd2 (ORCPT + 99 others); Thu, 15 Feb 2018 12:33:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56694 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164820AbeBOPdS (ORCPT ); Thu, 15 Feb 2018 10:33:18 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7B6F0F97; Thu, 15 Feb 2018 15:33:17 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoffer Dall , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Will Deacon Subject: [PATCH 4.14 083/195] [Variant 2/Spectre-v2] arm/arm64: KVM: Implement PSCI 1.0 support Date: Thu, 15 Feb 2018 16:16:14 +0100 Message-Id: <20180215151709.855940567@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- include/kvm/arm_psci.h | 3 +++ virt/kvm/arm/psci.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) --- 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); --- a/virt/kvm/arm/psci.c +++ b/virt/kvm/arm/psci.c @@ -234,7 +234,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; } @@ -313,6 +313,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; @@ -355,6 +396,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: