From patchwork Mon Feb 26 08:20:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 129587 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3358175lja; Mon, 26 Feb 2018 00:25:32 -0800 (PST) X-Google-Smtp-Source: AH8x226dZoabfi3bPBz36HdSkrubJIcVag0P/EnKFzAzzCqpaFj/J0iYL9ysxYTGEkEDoq0cCHNx X-Received: by 10.98.106.10 with SMTP id f10mr9804192pfc.222.1519633531969; Mon, 26 Feb 2018 00:25:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633531; cv=none; d=google.com; s=arc-20160816; b=XkoD3Y/JUAHs5Ep+9vzU37TR4QC/P8w3k5RXPzCxgDktM9jiPbWNMBC7Ch03wUy4GH Q+o2/fKLKgRgXCZV/rTAfLpQ03B9SU+P3yQKqZ7PG5lGLAy4J6wMPZVwX1v/U8qfKMvC lOPJvxNxGzbbpuK0ZQH4mGuDAD8PRysWDop4K9/YO9eEAHKXUpPy1BnYVQJpYPLngxsm 386SVISuAfnlIBaSOB8m8Qs+/E8j64xpoqkGd+CB4b74jzgTS2BFyFO5kOEry3EiDpZa Dg7Rhf0CWdRjW8R97ulFKYsZPt8hoYkRzUqOZw03CMHCPRk1w7LsR2zH9JT+hB/NTH5F Ku7A== 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:to:from:dkim-signature:arc-authentication-results; bh=dkPnOZNxm9seQPfv5c9vz4+Yjf5n6fqYResagBKyW1s=; b=itbh4XiuDlK7jwG+Ci+SLoCtW+vM/fl/fuqKuYZmU9X5t9LwaOnHs4X8kRV5LO9yWz BLoQ7Ull4/JoKPpDY+ma7AFrONL08u//9kh53S9E5eTgaXDferw5HijFeqMwOQGbRlhf p/Ixl7oqlNzmSB1PwBnQeClHu15NkCeCaG0AzYCdMm5pV3XxYOwY4Rlz18scBOtt4mpQ uVo3pX/qJGqlaS0FoN4w/BlM2LRs2kFCIYYoAwrbbsZXnFHbf75HapMAg0vW8sZ3c23E /JhKoWlaVXybZulPq6sns62RQrWXF/1VrNW0zQg8qOKTz3iy81JCx5WD2Q/Zz/MGAj41 S5cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z4Ilq6+W; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 r26si6430932pfi.378.2018.02.26.00.25.31; Mon, 26 Feb 2018 00:25:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=Z4Ilq6+W; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1752537AbeBZIZa (ORCPT + 10 others); Mon, 26 Feb 2018 03:25:30 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33382 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752420AbeBZIZY (ORCPT ); Mon, 26 Feb 2018 03:25:24 -0500 Received: by mail-pf0-f196.google.com with SMTP id q13so6224557pff.0 for ; Mon, 26 Feb 2018 00:25:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=dkPnOZNxm9seQPfv5c9vz4+Yjf5n6fqYResagBKyW1s=; b=Z4Ilq6+Wx3MQYchI6CMGFV4WmySMREfNZejZ5nSzez8eBD9pw806Mmx4t436Qyu0Ma FhEbLlngN7+DGr24QJe/4YMPLywi0DZYCZZVOeNYAa/Ru8x1iNplG3ZcGAsBuQl6m/aU wCarkFKmL+/KSNmWgLTAhrIIXvXsGOUqNgO5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=dkPnOZNxm9seQPfv5c9vz4+Yjf5n6fqYResagBKyW1s=; b=Yb/VR0gUM7+opV5U8csp+jb7siSXVeUiM0qKprlPixQgekweynHYDoleC5NmlB+6lq E61c5dEf8pUvlsUmrGeUSgSWj/ntAqPCl4qPxwRdhTWLzfCwPh2WHNM7xjQDF0W+hVs/ YB3ZfZOvIEwdwrCXyu1D/TYZ1EDq/JReatY564s/FTEn0yOQaFeiytaBCPn2H7WcG9so HCRkVYroqQKAHPKpF/JvqJ8FfP5NK5MFo9MFZrZpaE6GzS818f0nSiqP9dy67AXslQTW 7jeRaCwpr9nXMda/RTCNr0453DXJVcqOHY6NdKzvsOckctNMjdg5UbSL8jaEOcymHK/4 DpWQ== X-Gm-Message-State: APf1xPA3bobAik7AyADH3voJSfNeQhXj/CRwHez1K0f2Rk8dgy9QzAul 7Hw3FIlZ74ZXl7hY3htOSONazW8s2vU= X-Received: by 10.99.5.197 with SMTP id 188mr7799923pgf.196.1519633523556; Mon, 26 Feb 2018 00:25:23 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.25.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:25:23 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Christoffer Dall , Russell King , kvm@vger.kernel.org (open list:KERNEL VIRTUAL MACHINE (KVM)), linux-arm-kernel@lists.infradead.org (moderated list:KERNEL VIRTUAL MACHINE (KVM) FOR ARM), kvmarm@lists.cs.columbia.edu (open list:KERNEL VIRTUAL MACHINE (KVM) FOR ARM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 34/52] arm/arm64: KVM: Implement PSCI 1.0 support Date: Mon, 26 Feb 2018 16:20:08 +0800 Message-Id: <1519633227-29832-35-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 Conflicts: mv chagnes from virt/kvm/arm/psci.c to arch/arm/kvm/psci.c --- arch/arm/kvm/psci.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- include/kvm/arm_psci.h | 3 +++ 2 files changed, 47 insertions(+), 1 deletion(-) -- 2.7.4 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);