From patchwork Mon Mar 11 09:15:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13588396 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 6B3D0C54E58 for ; Mon, 11 Mar 2024 09:16:16 +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=H7jO0iNrSl1M8U E5bZjAitsG4JYR8JOYoMpRPRuZ0rpAgjquhikV76zNdbDrWeyZj5Z5gginsqZsmvhrkrpP3FjcoDs 9l/JIqa3Oa6BwgVl5z1N4jt8ffQTHFmLIrqm8FeAXyRM4Jxaab6ARtN8gRENZOcKb35GXJ+JLbe6n wIqCCUOGoP/tJAIdsF+2+KnC1QEtgZVjD8dLAioTTW9WLYpLFVW02lzKcR3bXkDJrzlMPG+XONXv2 oEEE0yCk2oG50oTUiPfRJfzUbNZjj3CoyhZ/UjY+CiZsvlDzAboLHNqbgZ/1u/AjXv0w0TH0Pni11 /+mwQ80ezvwdu8hFrBYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjblG-00000000mYt-1dWR; Mon, 11 Mar 2024 09:15:58 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjbl5-00000000mPw-41Lr for linux-arm-kernel@lists.infradead.org; Mon, 11 Mar 2024 09:15:49 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a461c50deccso114174066b.0 for ; Mon, 11 Mar 2024 02:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710148545; x=1710753345; 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=AgbT3s6LxHkXbMR3mEhDy6vDP4eyNAOFIPbqSXqbSE5aLDH+c5nP0QhR7TGeHRxSrS B2H04d5VfEHY/8w/hqBUw24tCuKbB3oDOBrcA1qKsylXWqMMx0JFgc9aAcNgWk3jxrw8 you50MetCi/WmSaiupy7L2wI21E3+40k1CCLDeAvAKR18oWHvEWKjCfeWnL3vd/glCOV 8q1HzgeRjkG763Ingl3HdlqSsBb1BrFikqKpIWemtq03plLSeerXO3+NPBXZGNSjq3fI EKww3llUXppR3yNhFipYxDzWwWkPWm6cYg9m8zxdCPa08IctH3GqRLkZTazHZx/lpfw+ bifg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710148545; x=1710753345; 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=NUiTmuptxKKLZlE9mXT50uxnDHdZNikoy/BL0Bq7aSvLAu1QG+AlP6u3Gsn7Lu0n6T 5ueLyi33xpTwELe1i+ZvycgCixkxts734e8lfY292NXXOHUHnS1bvY2BHvL2M0Vn6rzv Z4Xy/T/CkmcNOaLZMJiv7mV5Rd1XxAruICGf3gOGjj51IZWqrqEsH5nFTLxJQjyGfpoj LMsO9jRkMVefYTylDiLWcbz4/ArJS5G6i+YzyrsHfbuRuDkKxJJHYpEhi0yon2FZ9+BU oDULd/KgKisrh/I5qPbjklrpofLWar8P39448l2W6kAeDJhHzuApioF05CFXpG1SQw9m 0aKQ== X-Gm-Message-State: AOJu0YzqA6lgRYv8M4uYYQ+wrDUOGnxfwon4yieTGCR0lyfakRiBFIk7 BSh1e5HrQYkDr54k+bsr25bvVxVv7TVIB0Fl31RwpncY/KmIyO6mjmyjYzTnyrG2FMlilfM7hny O X-Google-Smtp-Source: AGHT+IHDnM4IJaApY7pw00admaAa3JjS3BnAZhOMSFkbG2yLqgAL61ecbv6xbQrSNTpH89f8vOW9yw== X-Received: by 2002:a17:906:a287:b0:a44:7ad0:8069 with SMTP id i7-20020a170906a28700b00a447ad08069mr3668889ejz.72.1710148544581; Mon, 11 Mar 2024 02:15:44 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id js23-20020a170906ca9700b00a4617f1ccf3sm1601256ejb.169.2024.03.11.02.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 02:15:43 -0700 (PDT) From: Linus Walleij Date: Mon, 11 Mar 2024 10:15:40 +0100 Subject: [PATCH v3 3/9] ARM: bugs: Check in the vtable instead of defined aliases MIME-Version: 1.0 Message-Id: <20240311-arm32-cfi-v3-3-224a0f0a45c2@linaro.org> References: <20240311-arm32-cfi-v3-0-224a0f0a45c2@linaro.org> In-Reply-To: <20240311-arm32-cfi-v3-0-224a0f0a45c2@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-20240311_021548_135378_970F8F69 X-CRM114-Status: GOOD ( 18.61 ) 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; }