From patchwork Fri Feb 21 14:50:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 11396747 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BF2614E3 for ; Fri, 21 Feb 2020 14:50:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDD2120656 for ; Fri, 21 Feb 2020 14:50:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ayEsPLtV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDD2120656 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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: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:In-Reply-To: References:List-Owner; bh=M1H/zkU7imqrj7gBhGm8tto7j0jAPIf0PEHm7qy7Awg=; b=ayE sPLtV6ixOoBmNnKhmNfnLF2tjxVJy1QNaAVOEa7egZSISeWhdYBaja/OiuFVPXP1XrDfXFRZUHrlZ Eggu4NLW57r17bKoBYaCxYofvLlpUwXCHZzgkV3h4kMhGnijRh2F811HHJbIA0w6uNS0SKs8TrgQo VCeZQ+2Ec0Pjxz48mBGQ+JswwwNDzoPJGgPYpUZFRFHJDaJTaBUHj6rmddsJNs6oAwba3WvKL1+qE opbJu9OvTzfUWIY+Iex0E4F6D9c/uFitGLS7bTcrv6+0yFWiyWm3gewPoweEK0Yz+UHLt82e2R0xk Git9ALbX64jIrfyXvt8rg9xWqQay3iA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j59dS-0002L0-VV; Fri, 21 Feb 2020 14:50:34 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j59dQ-0002Jj-H9 for linux-arm-kernel@lists.infradead.org; Fri, 21 Feb 2020 14:50:34 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 200A11FB; Fri, 21 Feb 2020 06:50:30 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DE9FE3F703; Fri, 21 Feb 2020 06:50:28 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCHv2 0/2] arm64: add finalized cap helper Date: Fri, 21 Feb 2020 14:50:20 +0000 Message-Id: <20200221145022.27217-1-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200221_065032_616942_8A6294CF X-CRM114-Status: UNSURE ( 8.45 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [217.140.110.172 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, james.morse@arm.com, maz@kernel.org, will@kernel.org, kvmarm@lists.cs.columbia.edu, julien.thierry.kdev@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Across arm64 we use cpus_have_const_cap() to check for a capability without a runtime check. Prior to capabilities being finalized cpus_have_const_cap() falls back to a runtime check of the cpu_hwcaps array. In some cases we know that code is never invoked prior to the capabilities being finalized, and the fallback code is redundant (and unsound if ever executed in hyp context). So that we can avoid the redundant code and detect when the caps are unexpectedly checked too early, this series adds a new cpus_have_final_cap() helper, and migrates the KVM hyp code over to it. I'm hoping to use this as part of the entry.S -> entry-common.c conversion, and there are other places in arm64 that could potentially use this today. Since v1 [1] * Use system_capabilities_finalized() per Suzuki's comments * Remove extraneous whitespace * Add R-b tags from Marc and Suzuki [1] https://lore.kernel.org/linux-arm-kernel/20200210122708.38826-1-mark.rutland@arm.com/ Thanks, Mark. Mark Rutland (2): arm64: cpufeature: add cpus_have_final_cap() arm64: kvm: hyp: use cpus_have_final_cap() arch/arm64/include/asm/cpufeature.h | 58 ++++++++++++++++++++++++++++++------- arch/arm64/kvm/hyp/switch.c | 14 ++++----- arch/arm64/kvm/hyp/sysreg-sr.c | 8 ++--- arch/arm64/kvm/hyp/tlb.c | 8 ++--- 4 files changed, 62 insertions(+), 26 deletions(-)