From patchwork Mon Feb 26 08:20:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10241663 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 104EB60208 for ; Mon, 26 Feb 2018 08:46:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03C7929D27 for ; Mon, 26 Feb 2018 08:46:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC44E29D2C; Mon, 26 Feb 2018 08:46:24 +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 6221029D27 for ; Mon, 26 Feb 2018 08:46:24 +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=7LdD83le0+K5UZ16VdAyXrcXFwG4PHBp6AeZV09e5cw=; b=EfNOMZ62uw6Bhf ZZOL34+6chDYUhX4nw2uWkzN5h2v2z35Ry1wxk0PKlp2dQesK+yDH3wgmoP8mMro7Lz7Ws8y3QpZz +h3rvjFUMxGSQEVkgV2bupJqiyiJ8S+7/Jf+6K9d1wAILqmrq127yAShcLwFnkKMccK2VPOqx81BU U2JXgycp19vX7A59MtPOemwwxLh9vpCjQwmPnDmDgmwy8Ffz6Kdnwne73yFNu5NlsgU7Zp4jjFZ3k LmvEusCNZJn+NU5wJRE2GcixCh3bJU8EldrsTytm1x12yOwU87LG0sUZoFY/Lwhzlo3QH55JCoYEJ kiL6wbI9bzF7Q4EPwTgA==; 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 1eqEQI-00047D-Uw; Mon, 26 Feb 2018 08:46:14 +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 1eqEJt-000574-Ay for linux-arm-kernel@bombadil.infradead.org; Mon, 26 Feb 2018 08:39:37 +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: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=ccWpB6B5MEm475gq8sjuImnJLMpKY94QLsRYdXyhfpw=; b=JO/hHFVoTvMVUh/YdHyNlk8Ax BmvZYkDqXGO+ID29D2NCJdANxZzlgr8Mg+0MHThSPeck+u5ARxy0V+YNDOkgkGfvXMMIjoT+V0eq1 Ti6q0t5GsfqtbrQKf2uirhI2EmibPib8b/QX6biqCv99iGo51nM1H9XN8yYORMii1JG1YSu2WKR00 RHP9mzF3KpD/gz3tM2QZxCeOGKCrYqqDIyXXJL5NNTTYKdQLTzFIIhGjDcyNMOw+v27ZGNyZk0EUh nWkhNf9w62iJ0y+sX5LNC+Yp9utYSzit0x6rr6QwCJXie67EWpiNGgGqnby0Ond6csYIBC7XiF/rb M++dV2Mcw==; Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqE6d-0006HP-Im for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2018 08:25:57 +0000 Received: by mail-pf0-x242.google.com with SMTP id 17so6215995pfw.11 for ; Mon, 26 Feb 2018 00:25:45 -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=ccWpB6B5MEm475gq8sjuImnJLMpKY94QLsRYdXyhfpw=; b=GMSh1cUzLcfYYCAjsxCGkkHOlpOgzYDYRr0AeSZcqTDL7AidefGBvuSZCvhK7rVp8R 7INieTcJI8C6FRncoiPVFIRmwm05Dv79AbD0SNdNLvmqSUI5Ec0I4dq1lzD9/t9Wxr1Q rwz+LMTWWjfuIhgCB4P7HEeg/pbSH8bb0pNuE= 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=ccWpB6B5MEm475gq8sjuImnJLMpKY94QLsRYdXyhfpw=; b=ehu7qHIrYupQcprg2pYfS9Kjw9ltCXaEjx0DWg36ndiwv/5qwgFWcLqBS5luGciiOU wixI7R/0eWLPWR6vhK+02UPc1J7jR+o/aTvglQGh9K2ytNcpviw6U7sxv8Etur3TNc3w VzS2yul16K9Y4Qx1qzdo/TeDedafXm3KRGqcOXKagEtALj5hp9Aq2dhamY5TnbSWIiuV hISnBUorvKS3eBKJE2xdFJNLL0sgc/Xo7qxSQmCO/2tUQrRPJ48a8WTKXEXatcFBwrEt 1HOxF/5DL+/V+b6LvyrCPkZS2UmuBkn3BbJwFPLV3SnEk+/8TfrP84jfUM/u4UrEhpYx 2PFw== X-Gm-Message-State: APf1xPDlD1kF2glZDZnETY21Vsh2mMdD0LO65XyPcBjMt4RTItJjd9jd tafTT5fOBpn54FYHx61X/Qqimg== X-Google-Smtp-Source: AG47ELui7C09Q6V4JPFdQRZwnJne7JL+Ej1ZEMKk9SFOx4Um2rssVJCuo50pUHmJp+i3yFNk+3atyA== X-Received: by 10.99.167.66 with SMTP id w2mr642864pgo.357.1519633543999; Mon, 26 Feb 2018 00:25:43 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:25:43 -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 , kvm@vger.kernel.org (open list:KERNEL VIRTUAL MACHINE (KVM)), linux-arm-kernel@lists.infradead.org (moderated list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)), kvmarm@lists.cs.columbia.edu (open list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 36/52] arm64: KVM: Make PSCI_VERSION a fast path Date: Mon, 26 Feb 2018 16:20:10 +0800 Message-Id: <1519633227-29832-37-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_082555_618970_7E01F11B X-CRM114-Status: GOOD ( 13.81 ) 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 90348689d500 upstream. For those CPUs that require PSCI to perform a BP invalidation, going all the way to the PSCI code for not much is a waste of precious cycles. Let's terminate that call as early as possible. Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Alex Shi --- arch/arm64/kvm/hyp/switch.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index cf6d962..3eab6ac 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -308,6 +309,18 @@ int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu) if (exit_code == ARM_EXCEPTION_TRAP && !__populate_fault_info(vcpu)) goto again; + if (exit_code == ARM_EXCEPTION_TRAP && + (kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_HVC64 || + kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_HVC32) && + vcpu_get_reg(vcpu, 0) == PSCI_0_2_FN_PSCI_VERSION) { + u64 val = PSCI_RET_NOT_SUPPORTED; + if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features)) + val = 2; + + vcpu_set_reg(vcpu, 0, val); + goto again; + } + if (static_branch_unlikely(&vgic_v2_cpuif_trap) && exit_code == ARM_EXCEPTION_TRAP) { bool valid;