From patchwork Sun Apr 21 18:28:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13637478 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 AE5B9C4345F for ; Sun, 21 Apr 2024 18:28:48 +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=mjc0+9vcWt5LWk 9zjqcek5CUlEtcPD4L0Ob6FdHpxu5kfvraFf+0TL4byevLx8Wsv7LMXB/s9ppsld6RMEBvF14WSR0 jZHRjfYwGVUkhILamK2YArDYFHApI96vXK9Ay2em9kxR05WMqItplZSRqIUpiNF9NvuQdZi/pTN8g A1fOXqSLXRTUo626bIuE+1NraDwYbIxYSJ/s0DXFgEdlK+4VGUqGGrCRkKRXIiB0xNKC/6JZ+gDAh /gPtSjeRtgOSSnXF2ONGJp5Uh7rJiEwNIX5CJtHaJIvLoHB3D+EhjJx5JX4UbWx1Vm9mpuIsYWaG/ GsVigSnU+4wEG5XWqsaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rybvY-0000000B41p-3HO2; Sun, 21 Apr 2024 18:28:36 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rybvV-0000000B40I-0bSI for linux-arm-kernel@lists.infradead.org; Sun, 21 Apr 2024 18:28:34 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-516d4d80d00so4631935e87.0 for ; Sun, 21 Apr 2024 11:28:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713724110; x=1714328910; 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=qV2jQ57lFQybdt9nbsRQ0eEvVBGvD4G9s5Si1jkOqL27XUEUguzQvueDctDg/bAibV TgwoIRST4NBU0GrwG1gNw5QkrgY9GvecT4TlS+pFtUkVIiIKJ7HBhkng9sEG8zmxHrUv UAmsOevnWFhlOXXS5vbSBywvdStHccWBcbNTCgW01jZYzWUc4sUHP2rPywMuai/LuKF9 Jk0l5pXgbFD/W032vGZqj4lCMQVbMDbKBcQftiTkiBY0DI8MVkas2NmhllIeGGf3SrWO xj9BvdZy7HMH5zEa8SGtPaHaMHSzBBg1kK040Y0dv3uGZlxBJdLDDZzFwI8V705swZG/ IHXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713724110; x=1714328910; 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=IK+bNiouYEHTC6A1NRc2S1RJWAQq9/oURmoqiHXqLFLWbUMzMkmtNDYyOrxk/CjV38 fWOrrC4l6aGqJN2XhcuOSSfXEOxZLiNmSDSjI7A0eYoEPSVECxZpOFLcciAuxtHJrwuo mrnN05sgVTH3bmSOyS6hSH6kw2m0mdb3+Dv9eSGorw2NAl81N4q0r7kup0JGrdD1TlBm epXutZoN6+Mby2Do8OuWeCnfdrCyE9xxf6Ro2QuoVicO/24WnaAzNGtXWeX5+etwJw97 9Mmgwhx9EJ+yZyGwIZWWl7EJ9WHhlwevJ2augGAby2B9DvTyBMt1TUenOJ7f7fXR6A14 leQA== X-Gm-Message-State: AOJu0YygKswQWVnb3X/3UUxUiYEkiyzkkeaJsTbSmlN+UCSMzYe/4Zga +URGmGLQOwyT0qvQrhSw4F4/yUphVVq6Q0NFnhiwaTpbGW/ULnKSkIB450BQ4AI= X-Google-Smtp-Source: AGHT+IF1kFCvJZyBCCjnyY8onMy4sCEISbjCHyqmS3da1hYqvcFYcwFVkAZPOvSJ5O6gz/WKOXWcOQ== X-Received: by 2002:a05:6512:23a8:b0:51a:ca75:9ffe with SMTP id c40-20020a05651223a800b0051aca759ffemr6207388lfv.42.1713724110277; Sun, 21 Apr 2024 11:28:30 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id s14-20020a19770e000000b005188ea5d2b5sm1549641lfc.303.2024.04.21.11.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 11:28:29 -0700 (PDT) From: Linus Walleij Date: Sun, 21 Apr 2024 20:28:27 +0200 Subject: [PATCH v7 01/11] ARM: bugs: Check in the vtable instead of defined aliases MIME-Version: 1.0 Message-Id: <20240421-arm32-cfi-v7-1-6e132a948cc8@linaro.org> References: <20240421-arm32-cfi-v7-0-6e132a948cc8@linaro.org> In-Reply-To: <20240421-arm32-cfi-v7-0-6e132a948cc8@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-20240421_112833_208167_F7EA4027 X-CRM114-Status: GOOD ( 18.05 ) 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; }