From patchwork Sun Feb 25 20:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13571025 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 34456C54E41 for ; Sun, 25 Feb 2024 20:08:47 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l3jz1S/MUSlE2CzazwdkxUsAg5LqjXJL8ESRjmegLhA=; b=Jih82HdhprEwo0 vwsoWv93qqH7W8891nkXXWi34aKcoIvhbOMpraYh8u+yxl5wuiV3iOPjrquFCM+4KUHEwfZ/UFcRa GcQ21ewscFuBmof+lflaonbVyOHD+Rtf5TYZG8KVHPwIURLcI2cHL7ONcxomDNsbGTYpFOtGcyC+q P2z16foPShSf87II9rWMtkWbOxXvgv/NfVkFdiM70JJeRpnE2HyABe8WIJUGnb31EkpIPHTju+9lT eDAkM8V8vXnnkJ/OSbypKOctAiFbttQyTjR/bhLtNwdS6ZkGG2g0VYzv5m6Bih98vi4JBYzSmWQk2 at3F3Kevvv6R9YaFs00A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnc-0000000FcqK-3LMF; Sun, 25 Feb 2024 20:08:36 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reKnJ-0000000FcjV-2CRX for linux-arm-kernel@lists.infradead.org; Sun, 25 Feb 2024 20:08:19 +0000 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-56533e30887so2354194a12.1 for ; Sun, 25 Feb 2024 12:08:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708891695; x=1709496495; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=B30jBDh8l6oorNFVXLBM1TGNZMOeiKLndpCjpsCjwrU=; b=GC6etEk42mox4r44ey2zFKLjzWVe8OXOh5Lb3Vscy6XHMRYlCs5TJneO+tjesPSN22 vas+zlHEL5JLqV95zVuBaN+97gWI/4BLk7LWrTJ4NPZJCFNyHsEsBiEXFiVt7FXBFBUw XOU5vbEb3i7KqH3EzilgKj6W8zd7UQPnrxejTQiIls62Xq5ggP3dfHfXcQEeRZ21S4sf 0x1646/hvmbilNgUXj7+lWDw9FJ825zHsCnnViQ2/Q6xg+AxmpsLuLxTeNS0Q8B7753B 9MYqpI61pVYJV16B1nQSBBT4SGq86S2xirBwVUck9FhLs2/tgnTdo87+QouW70AguN5V ksqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708891695; x=1709496495; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B30jBDh8l6oorNFVXLBM1TGNZMOeiKLndpCjpsCjwrU=; b=gE53mDuoJQ2g8GD5gq1F+tINYTZnh3JvjPJRZce6sIp+N3NwTjk1lchkdOMai8NC0C TxjSDbN0EFQfgDh+rmpd5VQRLNjXdwBqH9Q+qY+pvHVJMiRCXXA9UdTTAp4pdLLPamVU ziSKjOgRicsfwuFxAXiLIIMr6c0jZQY4Qs9sFLNQuzeHHKS6wWOeXnsjANGsM9Y0Xw6z WBo11ALa7/Wh/colKz3ggLS07gGi5IhTXH408e2WIgk3kxlB2DvLBQgbJkE2yRdiy1LZ Q3QT3GpcQysPv9ohY+1CnwcnQ1xFN1eTl2Qvq84WkfI/vSpvBglXuJv2BwFsYULFCkMA 8ZqQ== X-Gm-Message-State: AOJu0YyvvwiWy+odEy4CdRnVc20v8LIE2mIDiQJbkT0ZkV6B9557hkg6 T7HeJEnsdpjBSCpiR5sM7vbvBOq5xAfQdUyhlXmzI+QybuAtGLQjbpWbBKPqcKE= X-Google-Smtp-Source: AGHT+IG2qoyuh4S+jfoRRx1zENZfd3lkef19UKCSeTtf/j2FkZhkfI+btWJuX2mCaASM5yFXpwUUiw== X-Received: by 2002:a17:906:c00b:b0:a43:292c:7c38 with SMTP id e11-20020a170906c00b00b00a43292c7c38mr1353402ejz.14.1708891694976; Sun, 25 Feb 2024 12:08:14 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id hu14-20020a170907a08e00b00a4340138ab5sm504621ejc.5.2024.02.25.12.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 12:08:14 -0800 (PST) From: Linus Walleij Date: Sun, 25 Feb 2024 21:08:12 +0100 Subject: [PATCH 3/7] ARM: bugs: Check in the vtable instead of defined aliases MIME-Version: 1.0 Message-Id: <20240225-arm32-cfi-v1-3-6943306f065b@linaro.org> References: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> In-Reply-To: <20240225-arm32-cfi-v1-0-6943306f065b@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240225_120817_602027_E914F9B7 X-CRM114-Status: GOOD ( 18.72 ) 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 Instead of checking if cpu_check_bugs() exist, check for this callback directly in the CPU vtable: this is better because the function is just a define to the vtable entry and this is why the code works. But we want to be able to specify a proper function for cpu_check_bugs() so look into the vtable instead. In bugs.c assign PROC_VTABLE(switch_mm) instead of assigning cpu_do_switch_mm where again this is just a define into the vtable: this makes it possible to make cpu_do_switch_mm() into a real function. Signed-off-by: Linus Walleij --- arch/arm/kernel/bugs.c | 2 +- arch/arm/mm/proc-v7-bugs.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/kernel/bugs.c b/arch/arm/kernel/bugs.c index 087bce6ec8e9..35d39efb51ed 100644 --- a/arch/arm/kernel/bugs.c +++ b/arch/arm/kernel/bugs.c @@ -7,7 +7,7 @@ void check_other_bugs(void) { #ifdef MULTI_CPU - if (cpu_check_bugs) + if (PROC_VTABLE(check_bugs)) cpu_check_bugs(); #endif } diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c index 8bc7a2d6d6c7..ea3ee2bd7b56 100644 --- a/arch/arm/mm/proc-v7-bugs.c +++ b/arch/arm/mm/proc-v7-bugs.c @@ -87,14 +87,14 @@ static unsigned int spectre_v2_install_workaround(unsigned int method) case SPECTRE_V2_METHOD_HVC: per_cpu(harden_branch_predictor_fn, cpu) = call_hvc_arch_workaround_1; - cpu_do_switch_mm = cpu_v7_hvc_switch_mm; + PROC_VTABLE(switch_mm) = cpu_v7_hvc_switch_mm; spectre_v2_method = "hypervisor"; break; case SPECTRE_V2_METHOD_SMC: per_cpu(harden_branch_predictor_fn, cpu) = call_smc_arch_workaround_1; - cpu_do_switch_mm = cpu_v7_smc_switch_mm; + PROC_VTABLE(switch_mm) = cpu_v7_smc_switch_mm; spectre_v2_method = "firmware"; break; }