From patchwork Thu Mar 28 08:19:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13608167 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 2EE64C54E64 for ; Thu, 28 Mar 2024 08:19:49 +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=k+ZfRLGYi9Q6kT7pBf89rlhUTWysYJpmEIGgbpQGxBQ=; b=Gf7NfgPTgc2uzK 8nXBaHY4ItBPYnJ3dr17H4GBGB2JwfQaYEqMefCPFfP/Krpdq/AgW+lz7oDodHR5OwQI6AaxM6Qkn iiV5RzPTyrXlDDc2V6a+MBYNbQqQL3ghNJf8E6PNx5M0QXeKZKY1bfjB5ikjfa/4FuhyB+qbv5Zux SAXioMcB990SXnsNybLaYAGWa/iu5qWGcHRco/UNOI/gu2pUzQ5qZMVdlLObG7sJyJCFcPL+Q7R67 DoT2nALpeQI2e4xK+0fQBSBgL0HMMJ4lgI9S2cHEx7wxCuMa06X6v1cUxauqXatbgPERq5kYSx8k1 qEB8xO9cjIoL3hxoMi0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpkz3-0000000D469-05bo; Thu, 28 Mar 2024 08:19:37 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpkyz-0000000D43d-2CEL for linux-arm-kernel@lists.infradead.org; Thu, 28 Mar 2024 08:19:34 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-56c08d1e900so746138a12.3 for ; Thu, 28 Mar 2024 01:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711613970; x=1712218770; 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=4CyZZb/q52ADG1Ns94g158QKzpX2+8bkeCd4yJ6fxkA=; b=oU6aomjttNtd2k0GQoLUG1H+hYBqcliYBYV9mmhBy67WB1TDavbLE3PlAXCRLkiKvG nvHIca9Aw2AGoE19qOx79lnRiClwd/jAd3acHH4GXtCSJeZAQp6tzilwTV4Q4QyC3Q5G Et+xWWN/6lvGpEd2vKPc5IoHMKSPLqf/STbLLzMLrdTVy89fakwtclF+fhNJDSUTq9yc +8lDYfYHruZGctp4/TSawI7T9Tn+RuCVFQCpn/jUiUywLogMQh7WH0nIw99lKNaHz7jM Ro+BF33Oz2kyjUUxZIdm/DjsnX+fhVgJMqMWCgqW4o4lV6zkz+A1/R2B1QKApqyCrgbn 6G6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711613970; x=1712218770; 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=4CyZZb/q52ADG1Ns94g158QKzpX2+8bkeCd4yJ6fxkA=; b=IVjhC3aTjoeOGnCClKUfg6kLD7WfSWSrs7vtpeU/JH/Qp9MfnJ8H0FAPBw6PGXwbTv ZgUkd6jS/Waw9cEnirDqvH4XlJXnthK0kjSXdxC4DyqHx2zWxOZbfLtvpxq3NKngHLp3 d0UwR0BWp+SFTGr5qLOIZ5XbGfRiGfhLKNh+JApJNUtczJVW2XGsf77ywAcnS7BCCb/V JFsPW6zkcjttI/bkTK87+QsXhZ9heVXhGoAQPXminjSUuhKO2SXLzRankTZZtFwcBCqP coE4RdlvpiFukJeJRMsdrQJzt54Z28D2GAN1y3KX5qo7q0Tyw+69NnZAlhPfjC/VXArM JArw== X-Gm-Message-State: AOJu0YyK+SFvurj5Y+UpfXXEfxkayJmcluUFh9T5p2Y5nIc/Rf97q3sb 0LBx3ZX5X0qspO6rrCCE/Tdj4N2eVRiZbESehqI9AP82qteQzhFCgX85RciEiQA= X-Google-Smtp-Source: AGHT+IHzEi20HXA9sEd3jUX1smrRmr0wS8k7O94mJZu3c52WLkHQoAoV3WTxSWf/Fh+PSLfieoktpA== X-Received: by 2002:a50:cc81:0:b0:56c:d33:7881 with SMTP id q1-20020a50cc81000000b0056c0d337881mr1468362edi.23.1711613970605; Thu, 28 Mar 2024 01:19:30 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id n7-20020a509347000000b0056c24df7a78sm566397eda.5.2024.03.28.01.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 01:19:30 -0700 (PDT) From: Linus Walleij Date: Thu, 28 Mar 2024 09:19:24 +0100 Subject: [PATCH v4 1/8] ARM: bugs: Check in the vtable instead of defined aliases MIME-Version: 1.0 Message-Id: <20240328-arm32-cfi-v4-1-a11046139125@linaro.org> References: <20240328-arm32-cfi-v4-0-a11046139125@linaro.org> In-Reply-To: <20240328-arm32-cfi-v4-0-a11046139125@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-20240328_011933_611407_3433ED71 X-CRM114-Status: GOOD ( 18.60 ) 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; }