From patchwork Mon Jan 8 17:32:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 123756 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3003373qgn; Mon, 8 Jan 2018 09:34:46 -0800 (PST) X-Google-Smtp-Source: ACJfBota09RRRdP0YkjXhnrf+Gkwy78lvpvMAhwfrHmFcOhNbXhcKA0rW7BheOiqipSge+Uw4ZAj X-Received: by 10.159.245.138 with SMTP id a10mr12786019pls.178.1515432886276; Mon, 08 Jan 2018 09:34:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515432886; cv=none; d=google.com; s=arc-20160816; b=DDmJHzso01ZsH44eoc19/qbemNHGzPQIUOeSwnIzaZGkIJ/jJaLpbBAgUKYb0WwNMU wG7DRcSrM1rc7XEoNwwn0SJ9CAL0SsqPpUaiH+FvrKeYRit3yrzl6H4PAeIQasOmgflL CCJ+3Qy2HJ9fkCoDt9mnrf0vokwGt7VdTVDRhFslweSJgRsmyql1HM521Dk0A/zyk81s DY38fPh2qEWDfI4iEbbN3kRLpA7d97gd1xF2+Z5+d58fTmZKilOZ2p+m4gVtGboosbx7 /7QA1mNBLcA9V5tQNVZmSCzLMYdW33d+mDls/0uRiNlIc27//BvQmSKCTQIbWwT//D66 KEPQ== 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=Tez517oV6OQI5T94xgXovwdvL2vW1YPcIAEvbREiwhvFLpQJ6O9AENHhhBxY4kvQYf BxIc7UDlVTdzXlhOHY7m7x9pOtSRbPHmafkJBxOMxdXhMJFb7e+YANqfCyuhA+7UgQIr ilb4O21cURZVf3U5lfaHD0p9t14CdBISd/oNrpIQAUvOKtU2LTZPFH7i6PYLfi/Kk6g/ 2wAGj8i8sCZw8JPecnXtE+OalbztQuAuQEUVVP6MbrSI7NCFt/4LWCutZr3rlb/rG3ZU UopsWiHGNgI1KjwmOiulVFDZCdiOSVvWrUp8zz9QhNZBBuiHdi2UKnvRldo3YGreFVR/ DxCQ== 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 t8si2669499plr.86.2018.01.08.09.34.45; Mon, 08 Jan 2018 09:34:46 -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 S1754606AbeAHRen (ORCPT + 28 others); Mon, 8 Jan 2018 12:34:43 -0500 Received: from foss.arm.com ([217.140.101.70]:42926 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754307AbeAHRck (ORCPT ); Mon, 8 Jan 2018 12:32:40 -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 3E30F16BA; Mon, 8 Jan 2018 09:32:40 -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 0F73F3F7C5; Mon, 8 Jan 2018 09:32:40 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 7989A1AE2FF7; Mon, 8 Jan 2018 17:32:41 +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, shankerd@codeaurora.org, jnair@caviumnetworks.com, Will Deacon Subject: [PATCH v3 09/13] arm64: KVM: Make PSCI_VERSION a fast path Date: Mon, 8 Jan 2018 17:32:34 +0000 Message-Id: <1515432758-26440-10-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1515432758-26440-1-git-send-email-will.deacon@arm.com> References: <1515432758-26440-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;