From patchwork Fri Mar 9 09:07:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10270201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EBE3A602BD for ; Fri, 9 Mar 2018 09:29:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E719029D7C for ; Fri, 9 Mar 2018 09:29:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA33829D9B; Fri, 9 Mar 2018 09:29:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4CA4429D7C for ; Fri, 9 Mar 2018 09:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hTtzv/XSDvIefiUo7Xs4ePEJ9YKgN7aY1IEQjnoQ78w=; b=cPgSMq8GEWbRsQ+Xhq76TIHbF+ c6F9S8J8kZDTZE9egN7LKQYH1DeEnJeWJErcRxDAcZsVNPsIJ3XMK9UEpMu2X9j5yI9GOta34Imty CVjpyxZZa1h0m5262Hkxk7NaIo/KHl+c5ACUiQiPUH2bLxPX2/NQdjGF0QNtd9tmKhzdLim6/vcQo QgfYw5WMr7PAVKAK+Dp92AMibXgHrubBCu9Gr1mZO8weF0a68+xaWK83Q85CIvH1wQu7q85zhuGzN Cka9fF7KTMnVfJpYVfXjHVjMRNH0BcA5M9NUXx/1qLjcgYanjijWLs4aaERdmZ9Bw7skJ/VvVsHXi oIfVuVNw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euEKb-0001aX-N7; Fri, 09 Mar 2018 09:28:53 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euEHt-0006YZ-SE for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Mar 2018 09:26:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GQCCFAoDneCg5YSwBIbsWFXYhex8E5BRYcp1hoZYgyc=; b=AAZv3tfBSKey3fRXBuM4RTm2p lOwByfiRayxt29saAxxbz5+KclzLwO004pzcyHbuVgsiSRBxxsPt6QdfM2KlifQHm3AEW8JQ6bfa8 Y5mygXOOv3sHx2qef6lf3BtFUX+iKQZnR0C9yzwXagX4dYRz2O6e8T1wFkQLHHSY6NRKg18MZRvcE vFMKqPITabsZ0DZFynGEo5WFkLf1tM1oymwaBiUm/32nVelD8Qv+j9i0SHbQEKTYcT2i6fAdgIbrM /jzKDUH9ipDvSYAm9cndXX9xCVZ5XBL/A6o1vhwygP03sLtWbuWJOvp++7/sk6DRdRNueIiro9/Mk 02jldwDRA==; Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euE3V-0001hG-4Y for linux-arm-kernel@lists.infradead.org; Fri, 09 Mar 2018 09:11:15 +0000 Received: by mail-pg0-x243.google.com with SMTP id r26so3324330pgv.13 for ; Fri, 09 Mar 2018 01:11:03 -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=GQCCFAoDneCg5YSwBIbsWFXYhex8E5BRYcp1hoZYgyc=; b=CJEHmqRm48d46Blf3KNKlek4x4ZZIYcKVCbTdIhdHAVrZT58KCZa7kelXBOIV91vzf Uo6IRTUyIq0v2msB0TQuAWnMFu76h6RYqT3ykG8lj2fLtFuFfICN1aMgHonfGM7sVprU ROZnncmh0zuAsr9ErfBUL42uMVZrtBK6ZfCDo= 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=GQCCFAoDneCg5YSwBIbsWFXYhex8E5BRYcp1hoZYgyc=; b=DQIkpC5M+528/5SVZOtQCdkMMW7aAdkJdwJQfqY6mgtF/5kQ92EO6nVuaveNjH72nD 4OUpwa968P4GB97eQO4HQFWJD2b4kFlfZK7YUK5Z2CpNdOHqlcikmJnf7uXrXeAm+YZb tiwn1+67CzHl0Dl2xuPPVAwi06CMFjw3BFCweBsItskXqEKkMfGuestnvqblD7wWLLA4 HB5QPC+r3D6yRrrlBDIE+ul8JJ12OFeUO30P0ptLVAypfQgaBoaHyXw58F7HOM3B3upR EPD7bisap/uwu7AKQBzFoaYlPp3dfzCJ1tRnKvBkixp2xfrQxKHu0ytMWlRm3QZOWWFs bx9w== X-Gm-Message-State: AElRT7ETHqzixfEtW334PsW4GgnBZsfVXPOWUTeevvnSyCLDX45K/JrN ZGi/fS7wDKvUXnM3AiNAcM2oig== X-Google-Smtp-Source: AG47ELuwYmUODXpWCAp/mHs+48KHIQgDuJ56oZNL+jS20hyYTd3KLuxdoY5r04oOSzgzegrn4qcpbA== X-Received: by 10.99.119.130 with SMTP id s124mr14047927pgc.64.1520586661560; Fri, 09 Mar 2018 01:11:01 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id c7sm1961752pfg.36.2018.03.09.01.10.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 01:11:00 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , broonie@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 26/39] arm/arm64: KVM: Implement PSCI 1.0 support Date: Fri, 9 Mar 2018 17:07:09 +0800 Message-Id: <20180309090722.26279-27-alex.shi@linaro.org> X-Mailer: git-send-email 2.16.2.440.gc6284da In-Reply-To: <20180309090722.26279-1-alex.shi@linaro.org> References: <20180309090722.26279-1-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_091113_189143_3E3B9534 X-CRM114-Status: GOOD ( 17.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 946acf69a021..84027927986b 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 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);