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: 10241793 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 5340160208 for ; Mon, 26 Feb 2018 09:44:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4097D29EB9 for ; Mon, 26 Feb 2018 09:44:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33CD829EBF; Mon, 26 Feb 2018 09:44:46 +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=unavailable 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 A057029EB9 for ; Mon, 26 Feb 2018 09:44:45 +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:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aL5MWT5GUiMg6F7uPr3H7Gv8ToHdMuE3FMjyrdwDsok=; b=E5Odc5uh0E9IZt IRO0w23a6pX0RNiC/RvaikplaMybfPVAzZdHHFcA6iBSnklDg32Og5SLXE8NEOOgJgxzMJLjlc5cc SjU4JB1hBwJ4ynFgNDUJLzwFVTkbao1/nt+BWGNk8XfIT0aK6G4Vzg/ehmIzV7BoKYtcsQ3kSX41C 84RVgT/SgGCydYTOsWEZo8R1VM/kK2l5yCVbY/EuVTFQmJMPzNN1dQAqRu7ZGXnQG51xq60yWi2ml XMAsLzDkjdpn5hDY/bf06zpaUmPt3FOWO2rs3bbgSLG4Y/iX4fLEy40pMYLzW3gy1KyxR5V0K85Z8 A8jL1r7jmSwhvSR0Y/cA==; 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 1eqFKj-00010o-In; Mon, 26 Feb 2018 09:44:33 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqFI3-0007sG-3g for linux-arm-kernel@bombadil.infradead.org; Mon, 26 Feb 2018 09:41:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:To:From:Sender:Reply-To:Cc: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=dkPnOZNxm9seQPfv5c9vz4+Yjf5n6fqYResagBKyW1s=; b=f8x2iiG42mSgES2+9IRBCaPkf QavRCY2pZ8WVJg7LLqAA4+cDIFoyqexSB0Vt8Ei5CFQUAX9Kg0Jxv1DfR2qNEfCR/pIwAARUAQ4tz e2rFNbyJqxjP7aI7yo7ELxDd3zf30xI1LKWTSwrbWUWzXzbGgO5YA0GWmNrDybWFZHhJf3FzOtzhO dChfUsnrkFR3fLhnHcrZGOqhw3r6h+Fa34GWr6Zkj8GgAfa26i9F6vP7Ww0P+G/4GnPLyWqXwbSgy qxZ1tgdbm4Ql9a2zoZHy86kvLG0UahO3nxcIjDRfyiIzO1PtY2o/wGjg/mAgx0XrX8/jn82UGPKRf 72qKsx0QQ==; Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqE6J-0003Z9-Rb for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2018 08:25:36 +0000 Received: by mail-pf0-x242.google.com with SMTP id y186so5539101pfb.2 for ; Mon, 26 Feb 2018 00:25:25 -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=ZeyFAxRT1zZD6i3k8HCrPIRX8C+/5CJeTqptESbBo6OylIbUWjOAlrjcIjUbMwg2UY phR+kKBDYbt5YQXe3rBJFAXqhZkh6AvF8Bpx8oLa3eXqNTlqZHuDOosdjAkQCqDOlGU7 H65Pu4jmi2nPHGR0d729zUa6KJrRqanII+lLhoSP+wEKZXKnMUSG76B6/Ns9P3GDWW8F IMSGp7wCXpO+BtXQ5sBWsf/fkd/AtMVCnB1ja6XGquhWrhqr5Zm0nqraeuKNOdZ7kBje 71qaXqzWQl8ZQxF9aUWymTjyIzLVDHWp2tAs7nPrd4ruRpcozF32968QytOzJGWLQjxB d5zw== X-Gm-Message-State: APf1xPB//kXNJu6zMAPhjV5oU1tigfsBSGmECJbvxokw6YTpV6Dz45ck L0NDwGNfB7TUf3g7ttlZAfcpGw== X-Google-Smtp-Source: AH8x227yiyS1nksBa+1ugCGnSJ4gUilbEQ4sSMNtaCUXI4dXr3Ii/Cdg+mghcOpHL3u9EJw+7H2rHw== 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?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180226_032535_932567_E31D522B X-CRM114-Status: GOOD ( 16.92 ) 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: , 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 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(-) 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);