From patchwork Mon Apr 15 13:43:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13630078 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 77C1FC4345F for ; Mon, 15 Apr 2024 13:43:52 +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=9r8MOC1yaITNU744pcXLuxkYGKtTtIuQP3zm/FYcSv8=; b=vBcnTNXpqX7nEX kRAGcjK6hY7bcMXtuYITjUOLq4AoSEDGwV+U3MFxVuXzbeNIxsjQsAbSXmoz4itJnBvNR3IIwZaVh E/qVCp6VVphBhZnB50tVG0lMbmNUHPxQbFCiBz/6DOOaZ0ZPSlaTBh6r8tYR/Xe/X8iip9wMCBf+d ivzZKY/xEOhGhfBtOimxO4HIIABbEIrSdequ8O+nsZc9jmsstsuCBKnYxYIjigO7rGnvoMud2HbjU Z1XDo333ChqS6BpT7KpQlL0QFblSj7izMMOek/WtYIt0ZDnerTJXXIb+5GpzlWwXxBx0OB87RWXM/ BPmgM4XxEyUyuMu7PbYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwMcW-00000008XPi-2RYX; Mon, 15 Apr 2024 13:43:40 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwMcS-00000008XNI-2nIT for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 13:43:38 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2d87450361fso43757941fa.2 for ; Mon, 15 Apr 2024 06:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713188613; x=1713793413; 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=XDN5FRmJQobK+MX9/UAQHb6uzGwTwVFq2SIWEuBGTZ8=; b=TYiktf6VPVzv0rjTGePrLAsNlPXv/VkLXMJoBbcHN49wvv6sV5wUCLWW1me+9mJRlW GasfhlftpmHJ8lyTEsza+TSUGAMiuAXGi+rNyApft2e2BAJYii1CarPWpvlwXYDzjj2+ A0/g6+4+74fp1+m+1snMCml8nvD1uUf4K9gXSqA9uTHH6U3nVFGwJoFJmUfnWR2Rx9cv 8TzFJ3E4d9sO2FVYYWTIqOXvHlIqFFYdbSarl3q1TqflGozux0ls/QSAvbQK88SDThG/ ZvKBZrgZtpAMkVxQXoykcM0MFesWWuOdisPaipzwiT6snVRNTzeLWNu8FyE2mudk8rL7 r8QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713188613; x=1713793413; 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=XDN5FRmJQobK+MX9/UAQHb6uzGwTwVFq2SIWEuBGTZ8=; b=rRmihV1zbxyRZwbzRsLNBjORiwp75f9noE9Wt7hRYuxggYUUMSHRIuXfh+b95hrU8s 6vF/hkjZwJ/R/m1sRWcn/kH8mw6J6Ch3pWpeNXlAYnoBojj96r7J9BuG3Ep7h4rcmddD RMTbJwnyQbBxa8jsaaxTpAj4xrhrdzKaf2ykqsv3r/1HdHLVjZwTCFStVqZpPgzR0R2e ueIARme9juHez5FA74tDBdQ3hG1v66JOVK8WI9cYvVOA/BZTETQFSxF0hp27BWjEsqzZ VlgpBESii1susjHGdfH2dIIyza7FVYidu/gWNlFp5g4m3/DyQE5dqgtN/2MFwceKFCYA h7uw== X-Gm-Message-State: AOJu0Yz/cthtuuYJaHzIZHXjHn0MvrbLN6YWJepUiQx0icvYu+FUhYcf bPKfrZhF/IkoLDIekead3ZKhKJxoUYwMSHHATwH4/iivg216zm798R2ZPLuLR5oZbjdkYrTb8ll v X-Google-Smtp-Source: AGHT+IENvq8G1LUSUr3osHrUpSD/2JG0PYRSNVB4/7/e2ibwfVimAbybaiBmt+OXtjMjSHOHdJ/NRg== X-Received: by 2002:a2e:a316:0:b0:2d8:2761:a90f with SMTP id l22-20020a2ea316000000b002d82761a90fmr6061460lje.33.1713188613154; Mon, 15 Apr 2024 06:43:33 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id p11-20020a2eb98b000000b002d43737e2d7sm1297988ljp.30.2024.04.15.06.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 06:43:32 -0700 (PDT) From: Linus Walleij Date: Mon, 15 Apr 2024 15:43:20 +0200 Subject: [PATCH v5 01/10] ARM: bugs: Check in the vtable instead of defined aliases MIME-Version: 1.0 Message-Id: <20240415-arm32-cfi-v5-1-ff11093eeccc@linaro.org> References: <20240415-arm32-cfi-v5-0-ff11093eeccc@linaro.org> In-Reply-To: <20240415-arm32-cfi-v5-0-ff11093eeccc@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.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_064336_770902_C91801FB X-CRM114-Status: GOOD ( 18.32 ) 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. Tested-by: Kees Cook 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; }