From patchwork Tue Dec 12 17:09:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13489692 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D57FCC4332F for ; Tue, 12 Dec 2023 17:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :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=p/DCfIMzqBrLvEoHW+BdRYVKoQbav6YqPyzb3LhZ5K8=; b=jJoHBZeVl4zPAS vYk10/yy38Z2L3fVl6L87ZD9DKE62vqHwZVonSmIOvxEyWBiVC+07sVNIF4WKFrfLQQ0dCR8ts30q hLG8wAA+7z+iOWWzqSZ2d8NMnSUXL1kELUEqQfqFDM/jlJLzYFoTq7sEPTthxRZToVUyMcvrbmN5a /8pHU0Puwa4+xyJn0unPeABHnr1UvVzZuh+9E/6woOFRVp+Uxh6X7H1VRu01E/tgJgNVScQsWcZ0f EjQgvv9rxdyZ1z3UvS3NkcHR0ZsTQ5tdJ6dMYa56uXTiL97sKIQSZy2M0q0wpzxP6HOPgTjdwNQot l1pk02Wbky4k2kOnO35A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rD6G1-00CKnx-1o; Tue, 12 Dec 2023 17:09:21 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rD6Fy-00CKmn-0l for linux-arm-kernel@lists.infradead.org; Tue, 12 Dec 2023 17:09:19 +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 F0B6BFEC; Tue, 12 Dec 2023 09:10:01 -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 D6B253F762; Tue, 12 Dec 2023 09:09:14 -0800 (PST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, Will Deacon Cc: ardb@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com Subject: [PATCH 0/2] arm64: cpucap handling cleanups Date: Tue, 12 Dec 2023 17:09:08 +0000 Message-Id: <20231212170910.3745497-1-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231212_090918_340497_40A79542 X-CRM114-Status: UNSURE ( 9.11 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The recent changes to remove cpus_have_const_cap() left a period between detecting cpucaps and patching alternatives where it is necessary to use cpus_have_cap() to check that a cpucap has been detected. During this period we do a few things, and there's a risk that code using a mixture of cpus_have_cap() and alternative_has_cap_*() sees an inconsistent state. These patches rework the cpucap code to minimize the period between detecting cpucaps and patching the relevant alternatives, deferring other work until after the alternatives have been patched. This removes the need for some code to use cpus_have_cap(), and allows them to use common helper functions that may use alternative_has_cap_*() internally, making them consistent with other kernel code. This cleanup was requested by Will across: https://lore.kernel.org/linux-arm-kernel/20231127154818.GA8453@willie-the-truck/ https://lore.kernel.org/linux-arm-kernel/20231127163103.GA8627@willie-the-truck/ https://lore.kernel.org/linux-arm-kernel/20231127164127.GB8627@willie-the-truck/ https://lore.kernel.org/linux-arm-kernel/20231128110339.GA9717@willie-the-truck/ The patches are based on the arm64 for-next/fixes branch, whose HEAD commit is currently: f5259997f3e8d6ed ("arm64: Avoid enabling KPTI unnecessarily") ... which patch 1 is partially a cleanup for. I've given both patches some testing in a few configurations (e.g. with and without nVHE forced on the command line) to check that detection and patching works as expected. Mark. Mark Rutland (2): arm64: Cleanup system cpucap handling arm64: Align boot cpucap handling with system cpucap handling arch/arm64/include/asm/cpufeature.h | 1 + arch/arm64/kernel/cpufeature.c | 105 +++++++++++++++------------- arch/arm64/kernel/fpsimd.c | 4 +- arch/arm64/kernel/smp.c | 12 +--- 4 files changed, 64 insertions(+), 58 deletions(-)