From patchwork Thu Jan 4 15:08:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 123441 Delivered-To: patch@linaro.org Received: by 10.80.135.92 with SMTP id 28csp6823539edv; Thu, 4 Jan 2018 07:12:31 -0800 (PST) X-Google-Smtp-Source: ACJfBotP1a/qddA+c9H42djhihtw4YUhiv5nDOO6dBTg2EqLiDByKUleLcmxIWc+XV6jzRZaPrTc X-Received: by 10.98.171.12 with SMTP id p12mr5072022pff.201.1515078751643; Thu, 04 Jan 2018 07:12:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515078751; cv=none; d=google.com; s=arc-20160816; b=p5zk7UKbt2f38FYxnwHyv7bnuI2cFfHru7NYfXcjSuIGmwvzV0xrFuuAwEmAfh/Oww u5KeVPjTMoQEcVNP/nEPFWDCxbbE4JMVqImKkNE2eJGHyaeGnn+X9RFnsZeUAkfzihpT Sg+Xw33e31VNXyb4R4hbfN7akSyAALfY5uM/rAYJN8FEBhjoXP0a3+QWT8ro0OKT6Vta CRhuvRqNcfD+eApzsema/yXi5iz8J6i/7+wH+qxSOsTGAf49O6m15aKQBeR0ha5NpyaM tfnG9GdVHSvmx+iAk6PR6crYhHyI7A2VgLKgh/+QsoPhLstBjEhSgeD5NATcEgpXe6vc A40Q== 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:cc:to:from:arc-authentication-results; bh=aWAAohPCL/d8SZkGZOFj+DcqDFMfevwgGwnkpe8hBm8=; b=up/KcAlbgddJzDz+B/YNnyOWoB93SdXZzoBzKyiugF8ZdefXEYv/0ujuY+gXK9GMUa jm1ua8hzix/yPlQNIPDt1sCVyIxqVrcUJgKE3t+Lnmm/DJfL2fSdFK+2jXV3cqb6lwO0 9TvleQQt3IbDIyJhaEdhCJMQO3I4TkQlMNGmEmyUgpQWe6wFz4M1XPNN3+BA+tZML2rk +VmXGNtgzcvUS6Z4ikZNftkRO+yA7hvF2KykNxdRJkPkE5ZjaqM6mJimk4gYoqMYGDyz Nulfn2TbTiY8LfgOvfjc8DsKC0uZD/LDVhWVKM3oOjUlPz+msOOORjlXCtdSCV8ezEdJ +ROg== 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 f62si2399590plb.121.2018.01.04.07.12.31; Thu, 04 Jan 2018 07:12:31 -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 S1753462AbeADPK1 (ORCPT + 22 others); Thu, 4 Jan 2018 10:10:27 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33832 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753380AbeADPIm (ORCPT ); Thu, 4 Jan 2018 10:08:42 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8337A168F; Thu, 4 Jan 2018 07:08:41 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 53D8D3F7C5; Thu, 4 Jan 2018 07:08:41 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id ECF1F1AE1195; Thu, 4 Jan 2018 15:08:40 +0000 (GMT) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, ard.biesheuvel@linaro.org, marc.zyngier@arm.com, lorenzo.pieralisi@arm.com, christoffer.dall@linaro.org, linux-kernel@vger.kernel.org, Will Deacon Subject: [PATCH 09/11] arm64: KVM: Make PSCI_VERSION a fast path Date: Thu, 4 Jan 2018 15:08:33 +0000 Message-Id: <1515078515-13723-10-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1515078515-13723-1-git-send-email-will.deacon@arm.com> References: <1515078515-13723-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier 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 --- arch/arm64/kvm/hyp/switch.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.1.4 diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 8d4f3c9d6dc4..4d273f6d0e69 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -341,6 +342,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;