From patchwork Tue Jan 7 20:05:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 13929573 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 410D7E77198 for ; Tue, 7 Jan 2025 20:10:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0KrxwWdw54K0Yj+RKR+q5UWCVF10MxJgob7ZMKnFuvw=; b=4Av5Vo6/1So3HZmYIIHOSQpApE HwjKQTqkh/m7qoy7w9Zb2jrHJS90WAtxysBk5MKdJBEPUjnW+jrQoWX6Lxq4kfEl4qFrpxU4jCHKN qSfUbSTyUQAsPZVedH/J0NeG8uBKdO3oUQ/RD51XLRiH1ohw9EP4lm08x8bkU4pLXV8LX1nOBuIog yRNfWNnXnlNWRRIM9VruiEuf/3O0LkIofFc61HS/ArfaDIj8d45sjO3/fPNnW+WuW1rEBFfg7ackp LjKIMubT4K2E+FN2ayLoV9JpP8NSoTDbmSsBk3DSpDSRXSCppw3tAN/3hYna5HwwScdGxLd9DRhTr UQinPlxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVFuS-00000006D43-2E0k; Tue, 07 Jan 2025 20:10:40 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVFs3-00000006CQs-08HS for linux-arm-kernel@lists.infradead.org; Tue, 07 Jan 2025 20:08:16 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-216728b1836so215819035ad.0 for ; Tue, 07 Jan 2025 12:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736280490; x=1736885290; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0KrxwWdw54K0Yj+RKR+q5UWCVF10MxJgob7ZMKnFuvw=; b=X2vdvdZI4As24Zf+ALaWAQSefA3HY9tnfkF+3ItpeqKG5J0oV1vloypLvYND99IfFU BDNJhoiaX9O6pRIhpS4K//5EHRclwqpBc41ZEZqUDYH+0vqVbi+YxtxxMdl9XwpwCZh1 fTqO8qCdhQzauNihNeqNGQU3X7TcmLBzcKZA4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736280490; x=1736885290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0KrxwWdw54K0Yj+RKR+q5UWCVF10MxJgob7ZMKnFuvw=; b=EPGxRd8OSnC3b1zjIDjM/LHZmkIYEbcGj7nrb6zIHSpTngCZ6Lz5E8PmwCWijvcbxl iWrWmANfQ/jlBPLV2WEwXTZOtgpEDRtUXPTMkxiil2bZBwI8JXxnW4CuucYgt6CP2n9r 2Rkz/UOhSSyZ8Gady/etoMLKPvU7v1k1dBQhpCsSSpvwwem4bsfj2s3kBXjqn0fn/vsS JMCrUA6rZ5yJ++15MNJEpl1DhSzqkbR3eN/ujIA4gJ2TPohJ0xwmEELY7HshMcBc/u5q w35AAkgLcfjiZxHvzAqLvXXJpnLfZnDt62sRyYGbEBS9R+A0RihT57OMqmYhn5b74gdZ C/HQ== X-Forwarded-Encrypted: i=1; AJvYcCVGxGGmRl1LcUtd2m+s7xk+IfJIc3kxJDK9poUQWvswFjQUMvMFnUmZZaIcfeOqTvFhCGp0tt9MWU298UgTvYV+@lists.infradead.org X-Gm-Message-State: AOJu0Yy6XHSm11R6mptycXA0JckpGonx6fug59RWRwGo+GyzNfD5X/rP ewI+XbQMV8+sHypqgO1UybUM1MC5DjIgKu9pSyNeIj6tsHaoG7jEJYVornN88g== X-Gm-Gg: ASbGnctEEqjBCLgLBBaJ74w7YAYdbTexl1WH+MxgrLPzyzmQBG6UzmK8e51l1Qu0xa3 bzrvgHk9EOm99a4wo/rmO9yPHiVOedUNlRMEtwje6uPKalyGttFX1ybcRbCrxSv1L3rBSZrbvAG w2IKOw2VuQT/IYFQBFK/8rP8EV8iT8yuHVKJUrveNysmrD255iq0vzsIxKFQGYH+rUTol8trPNZ KIAMrFZiygazSx2xfnv2kz1PURN/7wZqH1xrCGLMn1o+5U8t+2UKzYHxX6A2I8l3E9AT2HlTkxx X-Google-Smtp-Source: AGHT+IGlYlv+o4b4M4lfyay2yfIQhWPrIig5AxGmXyZ7/rDfeJh96vHrE9iSzFs341VZqJN1Vu/LmA== X-Received: by 2002:a17:902:d48b:b0:216:2bd7:1c2f with SMTP id d9443c01a7336-21a83f5510emr4528055ad.18.1736280489913; Tue, 07 Jan 2025 12:08:09 -0800 (PST) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2961:4bbc:5703:5820]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc962d47sm314263425ad.55.2025.01.07.12.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 12:08:09 -0800 (PST) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Mark Rutland Cc: Roxana Bradescu , Julius Werner , bjorn.andersson@oss.qualcomm.com, Trilok Soni , linux-arm-msm@vger.kernel.org, Florian Fainelli , linux-arm-kernel@lists.infradead.org, Jeffrey Hugo , Scott Bauer , Douglas Anderson , stable@vger.kernel.org, James Morse , linux-kernel@vger.kernel.org Subject: [PATCH v4 1/5] arm64: errata: Add QCOM_KRYO_4XX_GOLD to the spectre_bhb_k24_list Date: Tue, 7 Jan 2025 12:05:58 -0800 Message-ID: <20250107120555.v4.1.Ie4ef54abe02e7eb0eee50f830575719bf23bda48@changeid> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20250107200715.422172-1-dianders@chromium.org> References: <20250107200715.422172-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250107_120811_067147_42212DF2 X-CRM114-Status: GOOD ( 10.89 ) 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 Qualcomm Kryo 400-series Gold cores have a derivative of an ARM Cortex A76 in them. Since A76 needs Spectre mitigation via looping then the Kyro 400-series Gold cores also need Spectre mitigation via looping. Qualcomm has confirmed that the proper "k" value for Kryo 400-series Gold cores is 24. Fixes: 558c303c9734 ("arm64: Mitigate spectre style branch history side channels") Cc: stable@vger.kernel.org Cc: Scott Bauer Signed-off-by: Douglas Anderson --- Changes in v4: - Re-added QCOM_KRYO_4XX_GOLD k24 patch after Qualcomm confirmed. Changes in v3: - Removed QCOM_KRYO_4XX_GOLD k24 patch. Changes in v2: - Slight change to wording and notes of KRYO_4XX_GOLD patch arch/arm64/kernel/proton-pack.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c index da53722f95d4..e149efadff20 100644 --- a/arch/arm64/kernel/proton-pack.c +++ b/arch/arm64/kernel/proton-pack.c @@ -866,6 +866,7 @@ u8 spectre_bhb_loop_affected(int scope) MIDR_ALL_VERSIONS(MIDR_CORTEX_A76), MIDR_ALL_VERSIONS(MIDR_CORTEX_A77), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), + MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD), {}, }; static const struct midr_range spectre_bhb_k11_list[] = { From patchwork Tue Jan 7 20:05:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 13929574 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 905ECE77197 for ; Tue, 7 Jan 2025 20:12:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VyuPoGoas0FXrrfma5oME99Ny+q0qNNG5nUGFTCnZN8=; b=HMQxqe19KJVf0TRTmr/IXg9uQ6 YuXolBx09pVRfq5NFu8FjvZVn9+pl131M1xMxbqbfzoJ4oXq7wbPF8mt1EV3aiZo/JnYLE2bg1pHE GKyFxQWM3n3LaFZPoHTkeLhrCfj8JRn+HHQfoSKXamltVA+HpPqGJ0JMcSdrvF/m8Qo2rT4XyZcSu NXIeqrKddXpqJX2P6Rg4eyruWPyRiMg+IxI/L47v46RdFrD2uE3KuN3twO9w9jEQiMfilK58rQNHc Vp5MTZvNokI5BkqEfqdQUS15NyvyvlrLrDtAQe5MVa/k7AfBnJIl7H3oEnFWN3e+/WvF6sJ3TLtWH dsAV7LMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVFvd-00000006DCv-0tWD; Tue, 07 Jan 2025 20:11:53 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVFs5-00000006CRq-1LYO for linux-arm-kernel@lists.infradead.org; Tue, 07 Jan 2025 20:08:18 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2166f1e589cso18267045ad.3 for ; Tue, 07 Jan 2025 12:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736280492; x=1736885292; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VyuPoGoas0FXrrfma5oME99Ny+q0qNNG5nUGFTCnZN8=; b=H086kfDwVupbkyrE6Lm0OibreduQq5GaZ6M2C2yKQ3bmn9DfbRpu3TFCeXQyHgwDj6 LMoIBF+83vuncSREOLaVotiROJOjN/luH7OKDaFEJDl068/pVq3HWGf1ySXTdf6KjJ2W gBVA4ND67DVxFoI16iDhmTQYIq64S2l8Wxi/U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736280492; x=1736885292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VyuPoGoas0FXrrfma5oME99Ny+q0qNNG5nUGFTCnZN8=; b=ENiuv31SSwtTlBD5R2jRfFcCsgfQB99DpDb+IyniK+eNMKqCjqlXybnvA96ddt0r3o bRlbUWbWWLmo+CAsiBqM6ZqPpIZ7QA4A9WK1NTTfuYc/sGmFzfyl4f4mSmjF4WeimmlS iMLZ4fhOwvGUjeszTiqTi3l2GBCT2Jm1CoAvxQH68Bimycn7exrRWJr8W/STtyECX0Mh PcjeldLn4k/Fx20h0cNp05NQMSO7eaGN2Lg1v66MJ60PxV/Vosoh+aunWcrQb7JjEZzS 30fluBPMY6ONOIVpfuweYwqvLM/QpTtL9XmDFmlQW+pSnh8KE9wm2UduHENqMKGBMK4h xF1g== X-Forwarded-Encrypted: i=1; AJvYcCXUGbDbfgEj+o7AwuwIgjTzJUaIJGNQvz+KJceJr/LM8/SEoDF5ZSUB0E72Zq0xqQwvsKURrYcGywJkmtT5Or8W@lists.infradead.org X-Gm-Message-State: AOJu0YzwMS/dCqrHtNrRZoJg9SkoVb9x0M3OQ1+c7mbIZ3wHMUIws3zr 9L7k5RCf42BZNmHsZZNH8GpqR5DcYNY3wDmHcqDAZhA78dFQweoeNrSPFfCsTA== X-Gm-Gg: ASbGncvLD2xnjmVB3DjtMgjhnGcx6DOJM/B3stT7HewDQnJ809cy5GxL1yTaUI/9+Qe Ip+JdWfLoAIX2Y8qhPsq4o9sbI+t1PTcU64C/QL2kKqt5DniINaVE/WdmAS1K/ERaH3qik05MXM Z9JyW8zEfOPA946knSiM/BvGR7QfuabkK6w1F6AGryGAeaH4TsLDxCB8T48v9xE2D4qlvuVsO35 aJETiMlSXbLH0Ge9LZOk6LQOwcnNCXLFnWWmevdcdQbfakMUo0z/Fw5ies4VmWCBVn8b4X2s7gU X-Google-Smtp-Source: AGHT+IH9SDkWGRhHf89AC8Lyy6Me9FNM2MneEbrONqwNlFgWCin4uJi7+v53aHD2Xs3q0+CE3HhNxg== X-Received: by 2002:a17:903:32cf:b0:216:644f:bc0e with SMTP id d9443c01a7336-21a83f502aemr4816215ad.24.1736280492102; Tue, 07 Jan 2025 12:08:12 -0800 (PST) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2961:4bbc:5703:5820]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc962d47sm314263425ad.55.2025.01.07.12.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 12:08:11 -0800 (PST) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Mark Rutland Cc: Roxana Bradescu , Julius Werner , bjorn.andersson@oss.qualcomm.com, Trilok Soni , linux-arm-msm@vger.kernel.org, Florian Fainelli , linux-arm-kernel@lists.infradead.org, Jeffrey Hugo , Scott Bauer , Douglas Anderson , stable@vger.kernel.org, James Morse , linux-kernel@vger.kernel.org Subject: [PATCH v4 2/5] arm64: errata: Assume that unknown CPUs _are_ vulnerable to Spectre BHB Date: Tue, 7 Jan 2025 12:05:59 -0800 Message-ID: <20250107120555.v4.2.I2040fa004dafe196243f67ebcc647cbedbb516e6@changeid> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20250107200715.422172-1-dianders@chromium.org> References: <20250107200715.422172-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250107_120813_361982_F71EF115 X-CRM114-Status: GOOD ( 27.11 ) 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 The code for detecting CPUs that are vulnerable to Spectre BHB was based on a hardcoded list of CPU IDs that were known to be affected. Unfortunately, the list mostly only contained the IDs of standard ARM cores. The IDs for many cores that are minor variants of the standard ARM cores (like many Qualcomm Kyro CPUs) weren't listed. This led the code to assume that those variants were not affected. Flip the code on its head and instead assume that a core is vulnerable if it doesn't have CSV2_3 but is unrecognized as being safe. This involves creating a "Spectre BHB safe" list. As of right now, the only CPU IDs added to the "Spectre BHB safe" list are ARM Cortex A35, A53, A55, A510, and A520. This list was created by looking for cores that weren't listed in ARM's list [1] as per review feedback on v2 of this patch [2]. Additionally Brahma A53 is added as per mailing list feedback [3]. NOTE: this patch will not actually _mitigate_ anyone, it will simply cause them to report themselves as vulnerable. If any cores in the system are reported as vulnerable but not mitigated then the whole system will be reported as vulnerable though the system will attempt to mitigate with the information it has about the known cores. [1] https://developer.arm.com/Arm%20Security%20Center/Spectre-BHB [2] https://lore.kernel.org/r/20241219175128.GA25477@willie-the-truck [3] https://lore.kernel.org/r/18dbd7d1-a46c-4112-a425-320c99f67a8d@broadcom.com Fixes: 558c303c9734 ("arm64: Mitigate spectre style branch history side channels") Cc: stable@vger.kernel.org Reviewed-by: Julius Werner Signed-off-by: Douglas Anderson --- Changes in v4: - Add MIDR_BRAHMA_B53 as safe. - Get rid of `spectre_bhb_firmware_mitigated_list`. Changes in v3: - Don't guess the mitigation; just report unknown cores as vulnerable. - Restructure the code since is_spectre_bhb_affected() defaults to true Changes in v2: - New arch/arm64/include/asm/spectre.h | 1 - arch/arm64/kernel/proton-pack.c | 203 ++++++++++++++++--------------- 2 files changed, 102 insertions(+), 102 deletions(-) diff --git a/arch/arm64/include/asm/spectre.h b/arch/arm64/include/asm/spectre.h index 0c4d9045c31f..f1524cdeacf1 100644 --- a/arch/arm64/include/asm/spectre.h +++ b/arch/arm64/include/asm/spectre.h @@ -97,7 +97,6 @@ enum mitigation_state arm64_get_meltdown_state(void); enum mitigation_state arm64_get_spectre_bhb_state(void); bool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry, int scope); -u8 spectre_bhb_loop_affected(int scope); void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *__unused); bool try_emulate_el1_ssbs(struct pt_regs *regs, u32 instr); diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c index e149efadff20..17aa836fe46d 100644 --- a/arch/arm64/kernel/proton-pack.c +++ b/arch/arm64/kernel/proton-pack.c @@ -845,53 +845,70 @@ static unsigned long system_bhb_mitigations; * This must be called with SCOPE_LOCAL_CPU for each type of CPU, before any * SCOPE_SYSTEM call will give the right answer. */ -u8 spectre_bhb_loop_affected(int scope) +static bool is_spectre_bhb_safe(int scope) +{ + static const struct midr_range spectre_bhb_safe_list[] = { + MIDR_ALL_VERSIONS(MIDR_CORTEX_A35), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A53), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A55), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A510), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A520), + MIDR_ALL_VERSIONS(MIDR_BRAHMA_B53), + {}, + }; + static bool all_safe = true; + + if (scope != SCOPE_LOCAL_CPU) + return all_safe; + + if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_safe_list)) + return true; + + all_safe = false; + + return false; +} + +static u8 spectre_bhb_loop_affected(void) { u8 k = 0; - static u8 max_bhb_k; - - if (scope == SCOPE_LOCAL_CPU) { - static const struct midr_range spectre_bhb_k32_list[] = { - MIDR_ALL_VERSIONS(MIDR_CORTEX_A78), - MIDR_ALL_VERSIONS(MIDR_CORTEX_A78AE), - MIDR_ALL_VERSIONS(MIDR_CORTEX_A78C), - MIDR_ALL_VERSIONS(MIDR_CORTEX_X1), - MIDR_ALL_VERSIONS(MIDR_CORTEX_A710), - MIDR_ALL_VERSIONS(MIDR_CORTEX_X2), - MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2), - MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1), - {}, - }; - static const struct midr_range spectre_bhb_k24_list[] = { - MIDR_ALL_VERSIONS(MIDR_CORTEX_A76), - MIDR_ALL_VERSIONS(MIDR_CORTEX_A77), - MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), - MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD), - {}, - }; - static const struct midr_range spectre_bhb_k11_list[] = { - MIDR_ALL_VERSIONS(MIDR_AMPERE1), - {}, - }; - static const struct midr_range spectre_bhb_k8_list[] = { - MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), - MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), - {}, - }; - - if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k32_list)) - k = 32; - else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k24_list)) - k = 24; - else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k11_list)) - k = 11; - else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k8_list)) - k = 8; - - max_bhb_k = max(max_bhb_k, k); - } else { - k = max_bhb_k; - } + + static const struct midr_range spectre_bhb_k32_list[] = { + MIDR_ALL_VERSIONS(MIDR_CORTEX_A78), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A78AE), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A78C), + MIDR_ALL_VERSIONS(MIDR_CORTEX_X1), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A710), + MIDR_ALL_VERSIONS(MIDR_CORTEX_X2), + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2), + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V1), + {}, + }; + static const struct midr_range spectre_bhb_k24_list[] = { + MIDR_ALL_VERSIONS(MIDR_CORTEX_A76), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A77), + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), + MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD), + {}, + }; + static const struct midr_range spectre_bhb_k11_list[] = { + MIDR_ALL_VERSIONS(MIDR_AMPERE1), + {}, + }; + static const struct midr_range spectre_bhb_k8_list[] = { + MIDR_ALL_VERSIONS(MIDR_CORTEX_A72), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A57), + {}, + }; + + if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k32_list)) + k = 32; + else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k24_list)) + k = 24; + else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k11_list)) + k = 11; + else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k8_list)) + k = 8; return k; } @@ -917,29 +934,13 @@ static enum mitigation_state spectre_bhb_get_cpu_fw_mitigation_state(void) } } -static bool is_spectre_bhb_fw_affected(int scope) +static bool has_spectre_bhb_fw_mitigation(void) { - static bool system_affected; enum mitigation_state fw_state; bool has_smccc = arm_smccc_1_1_get_conduit() != SMCCC_CONDUIT_NONE; - static const struct midr_range spectre_bhb_firmware_mitigated_list[] = { - MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), - MIDR_ALL_VERSIONS(MIDR_CORTEX_A75), - {}, - }; - bool cpu_in_list = is_midr_in_range_list(read_cpuid_id(), - spectre_bhb_firmware_mitigated_list); - - if (scope != SCOPE_LOCAL_CPU) - return system_affected; fw_state = spectre_bhb_get_cpu_fw_mitigation_state(); - if (cpu_in_list || (has_smccc && fw_state == SPECTRE_MITIGATED)) { - system_affected = true; - return true; - } - - return false; + return has_smccc && fw_state == SPECTRE_MITIGATED; } static bool supports_ecbhb(int scope) @@ -955,6 +956,8 @@ static bool supports_ecbhb(int scope) ID_AA64MMFR1_EL1_ECBHB_SHIFT); } +static u8 max_bhb_k; + bool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry, int scope) { @@ -963,16 +966,18 @@ bool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry, if (supports_csv2p3(scope)) return false; - if (supports_clearbhb(scope)) - return true; - - if (spectre_bhb_loop_affected(scope)) - return true; + if (is_spectre_bhb_safe(scope)) + return false; - if (is_spectre_bhb_fw_affected(scope)) - return true; + /* + * At this point the core isn't known to be "safe" so we're going to + * assume it's vulnerable. We still need to update `max_bhb_k` though, + * but only if we aren't mitigating with clearbhb though. + */ + if (scope == SCOPE_LOCAL_CPU && !supports_clearbhb(SCOPE_LOCAL_CPU)) + max_bhb_k = max(max_bhb_k, spectre_bhb_loop_affected()); - return false; + return true; } static void this_cpu_set_vectors(enum arm64_bp_harden_el1_vectors slot) @@ -1003,7 +1008,7 @@ early_param("nospectre_bhb", parse_spectre_bhb_param); void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry) { bp_hardening_cb_t cpu_cb; - enum mitigation_state fw_state, state = SPECTRE_VULNERABLE; + enum mitigation_state state = SPECTRE_VULNERABLE; struct bp_hardening_data *data = this_cpu_ptr(&bp_hardening_data); if (!is_spectre_bhb_affected(entry, SCOPE_LOCAL_CPU)) @@ -1029,7 +1034,7 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry) this_cpu_set_vectors(EL1_VECTOR_BHB_CLEAR_INSN); state = SPECTRE_MITIGATED; set_bit(BHB_INSN, &system_bhb_mitigations); - } else if (spectre_bhb_loop_affected(SCOPE_LOCAL_CPU)) { + } else if (spectre_bhb_loop_affected()) { /* * Ensure KVM uses the indirect vector which will have the * branchy-loop added. A57/A72-r0 will already have selected @@ -1042,32 +1047,29 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry) this_cpu_set_vectors(EL1_VECTOR_BHB_LOOP); state = SPECTRE_MITIGATED; set_bit(BHB_LOOP, &system_bhb_mitigations); - } else if (is_spectre_bhb_fw_affected(SCOPE_LOCAL_CPU)) { - fw_state = spectre_bhb_get_cpu_fw_mitigation_state(); - if (fw_state == SPECTRE_MITIGATED) { - /* - * Ensure KVM uses one of the spectre bp_hardening - * vectors. The indirect vector doesn't include the EL3 - * call, so needs upgrading to - * HYP_VECTOR_SPECTRE_INDIRECT. - */ - if (!data->slot || data->slot == HYP_VECTOR_INDIRECT) - data->slot += 1; - - this_cpu_set_vectors(EL1_VECTOR_BHB_FW); - - /* - * The WA3 call in the vectors supersedes the WA1 call - * made during context-switch. Uninstall any firmware - * bp_hardening callback. - */ - cpu_cb = spectre_v2_get_sw_mitigation_cb(); - if (__this_cpu_read(bp_hardening_data.fn) != cpu_cb) - __this_cpu_write(bp_hardening_data.fn, NULL); - - state = SPECTRE_MITIGATED; - set_bit(BHB_FW, &system_bhb_mitigations); - } + } else if (has_spectre_bhb_fw_mitigation()) { + /* + * Ensure KVM uses one of the spectre bp_hardening + * vectors. The indirect vector doesn't include the EL3 + * call, so needs upgrading to + * HYP_VECTOR_SPECTRE_INDIRECT. + */ + if (!data->slot || data->slot == HYP_VECTOR_INDIRECT) + data->slot += 1; + + this_cpu_set_vectors(EL1_VECTOR_BHB_FW); + + /* + * The WA3 call in the vectors supersedes the WA1 call + * made during context-switch. Uninstall any firmware + * bp_hardening callback. + */ + cpu_cb = spectre_v2_get_sw_mitigation_cb(); + if (__this_cpu_read(bp_hardening_data.fn) != cpu_cb) + __this_cpu_write(bp_hardening_data.fn, NULL); + + state = SPECTRE_MITIGATED; + set_bit(BHB_FW, &system_bhb_mitigations); } update_mitigation_state(&spectre_bhb_state, state); @@ -1101,7 +1103,6 @@ void noinstr spectre_bhb_patch_loop_iter(struct alt_instr *alt, { u8 rd; u32 insn; - u16 loop_count = spectre_bhb_loop_affected(SCOPE_SYSTEM); BUG_ON(nr_inst != 1); /* MOV -> MOV */ @@ -1110,7 +1111,7 @@ void noinstr spectre_bhb_patch_loop_iter(struct alt_instr *alt, insn = le32_to_cpu(*origptr); rd = aarch64_insn_decode_register(AARCH64_INSN_REGTYPE_RD, insn); - insn = aarch64_insn_gen_movewide(rd, loop_count, 0, + insn = aarch64_insn_gen_movewide(rd, max_bhb_k, 0, AARCH64_INSN_VARIANT_64BIT, AARCH64_INSN_MOVEWIDE_ZERO); *updptr++ = cpu_to_le32(insn); From patchwork Tue Jan 7 20:06:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 13929575 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 E7C6AE77199 for ; Tue, 7 Jan 2025 20:13:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=B7JIcKoOn+aj6A6FGmZdKgBjeiVX3ZBuDhppF1K0+s8=; b=wz2iHm8CpE4iFQDQg2TjftaMfC ccUusIvOKwcaKcYtCvuXp9oYfN+IwjyHLoP/ogsZjjp1QW/jkU3SqTm7AY77J7XVqnKPkTKamRbM1 ycWF4ZGxRJ2leGm5pHfwTaBOMUGwN/DlsF5AcmnFSL9OuWjBNvuioUuV/hDtJ1IKglkH4UIN3e63U 2EG0cSGqAj8jLpPWhEEvOYD7jOLVuPhmneZDgQqtFd1JMjqijNb/5DoDjKdQR7YXOU6822aHPfuDJ SE4IHxFxnXPFw9XN/Wm2tsPItprt2bjYqxCZszMBPO8Kb2Jaq/j3ANvUFmzEjwsi72jO1G9n4MFFw z1OaYjGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVFwm-00000006DLr-3ShQ; Tue, 07 Jan 2025 20:13:04 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVFs7-00000006CSe-0cza for linux-arm-kernel@lists.infradead.org; Tue, 07 Jan 2025 20:08:20 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-2167141dfa1so2658175ad.1 for ; Tue, 07 Jan 2025 12:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736280494; x=1736885294; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B7JIcKoOn+aj6A6FGmZdKgBjeiVX3ZBuDhppF1K0+s8=; b=L3F7onW08RhT7drv/Mrs/vVemHwV0PpXpTYjGGFWmDx6XwPQmS1PgQUc6nh4BMOOT1 4VfbWqDcWG3LkGMbehi1qifKwQ4iYdPR+cJq2wU7HB9vWUzEGUQv8reofZtT4iTHHzwN D2dRO8Dvr061t4gElpKarAnoQKmCmSBtopoak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736280494; x=1736885294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B7JIcKoOn+aj6A6FGmZdKgBjeiVX3ZBuDhppF1K0+s8=; b=a+4cQGMKeWXCBTiErdcYw88zwyJYsD4b0uqIJ9p7d6VTdwa0Jc4TLuytTGxFWw1oAb 7fi3I50LcDIlhHu/Q8KsJz4NH/uEvFE8ye+0960vFLzJrPacpc8v8M2lTFHPNvSSUezX +I1h4RdKOo93HheNEbOn8m3nCwBIEopxPU2aPSRfPa7VoNJ3U6I1/IYc7Gbgkn2OjmQ4 vSeY2gyS62DAQFE2zrgu6wzMLH2+wVrqlkBZ+fbavF3Wd/hP+ds4K57Sj379KZc6VZ/H PhBuwSdlnlufiepFOUKMzkxcsx+61LOVGcPvISXg8s9PV/tMPICnRiuhpHSb8OI78FMB fyKg== X-Forwarded-Encrypted: i=1; AJvYcCUIqzwzJ+OdTYvAR/vmh60DJp9Sisqo7t/WbWRKJ1Omglt4rhxv96LTk0NkRUcU40uFUMx/OO0mYIVjXSB/j+tW@lists.infradead.org X-Gm-Message-State: AOJu0YySG9J9NRtMU+fMwRWaaxsc+/WqUYjZZo0H/TQi17xTpGWsniWv GXZQS8r+DamR0qaO/zQY7vdH34R71c1YFJxh+8E9HeC/oO7KDyWyJEJzb9nOew== X-Gm-Gg: ASbGncs7OttsYq6Vicuu6j9yg6gDmGEirAhYowWVgXSlQYIhg4dANHy2xFf+YIYZ+iY xkwa03qjCa5D5GeOSe7UeVR92OZOy4/B38S74OhWHMXUK09bF0hOC1tD0DgImvK9BKdDP9v29dg pZgeSrci90nNHd5wmyQvC81tGOI4r3w6wF4yK31SaogO3C0m1QwL0OaBZvvfw5DIa618Egz1dCm +sZRzekfbk6NdUiATaGHxFhCUXg3VThDubXgj5fXBsB0DE3v6Fn4CRO1kwH/4uek9655nMPj79S X-Google-Smtp-Source: AGHT+IFYwu/b5vkXAi4S+EzyiEJNxnfulDMZqRNb7srUjlr5I3jIs0W0BPEczm+Ttsn4js6vyxWAkQ== X-Received: by 2002:a17:903:41c6:b0:215:758c:52e8 with SMTP id d9443c01a7336-21a83c148abmr5723375ad.12.1736280494447; Tue, 07 Jan 2025 12:08:14 -0800 (PST) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2961:4bbc:5703:5820]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc962d47sm314263425ad.55.2025.01.07.12.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 12:08:13 -0800 (PST) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Mark Rutland Cc: Roxana Bradescu , Julius Werner , bjorn.andersson@oss.qualcomm.com, Trilok Soni , linux-arm-msm@vger.kernel.org, Florian Fainelli , linux-arm-kernel@lists.infradead.org, Jeffrey Hugo , Scott Bauer , Douglas Anderson , stable@vger.kernel.org, James Morse , linux-kernel@vger.kernel.org Subject: [PATCH v4 3/5] arm64: errata: Add KRYO 2XX/3XX/4XX silver cores to Spectre BHB safe list Date: Tue, 7 Jan 2025 12:06:00 -0800 Message-ID: <20250107120555.v4.3.Iab8dbfb5c9b1e143e7a29f410bce5f9525a0ba32@changeid> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20250107200715.422172-1-dianders@chromium.org> References: <20250107200715.422172-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250107_120815_189960_3DF4CB20 X-CRM114-Status: UNSURE ( 9.33 ) X-CRM114-Notice: Please train this message. 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 Qualcomm has confirmed that, much like Cortex A53 and A55, KRYO 2XX/3XX/4XX silver cores are unaffected by Spectre BHB. Add them to the safe list. Fixes: 558c303c9734 ("arm64: Mitigate spectre style branch history side channels") Cc: stable@vger.kernel.org Cc: Scott Bauer Signed-off-by: Douglas Anderson --- Changes in v4: - Re-added KRYO 2XX/3XX/4XX silver patch after Qualcomm confirmed. Changes in v3: - Removed KRYO 2XX/3XX/4XX silver patch. Changes in v2: - New arch/arm64/kernel/proton-pack.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c index 17aa836fe46d..89405be53d8f 100644 --- a/arch/arm64/kernel/proton-pack.c +++ b/arch/arm64/kernel/proton-pack.c @@ -854,6 +854,9 @@ static bool is_spectre_bhb_safe(int scope) MIDR_ALL_VERSIONS(MIDR_CORTEX_A510), MIDR_ALL_VERSIONS(MIDR_CORTEX_A520), MIDR_ALL_VERSIONS(MIDR_BRAHMA_B53), + MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_2XX_SILVER), + MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_3XX_SILVER), + MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_SILVER), {}, }; static bool all_safe = true; From patchwork Tue Jan 7 20:06:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 13929587 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 24C3BE77197 for ; Tue, 7 Jan 2025 20:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+J3uEvrodRrvpIjWWGDgko7jtoYydXF7C2qPRbL5eTY=; b=4H+HUySOxzP2z9AsPXPebJzlJT a2xbtbEj9t31anyrS2kgKeKKkPW6IE7WdjcmIkmBclJ+os4vc2UUjjHN9dXILoxYJEY8ZgEmSFCSJ Cb+R+oxUC4d708Kj89ih57Tdb20MjA255BYP6J49eQlTs3nihWyK1l+B3vxD88ZWNXzR8Lxuffts8 mt3+DvqBRScU/TwRdETuGtLN8emh79NhjnaqdbDceRPIDSbZ/QZUt8sMzjHKuCOfSzO1ubUkV8/36 y/RzuDwrjDUKS+a/qSqN6JWahl1FfY4nooHyONlH1PKzbMZpKIdjpk6HIGM/YmPMuDMl/gCEz/jsz 6tGTZybw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVFxx-00000006DcI-1rfb; Tue, 07 Jan 2025 20:14:17 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVFs9-00000006CTJ-2B6Q for linux-arm-kernel@lists.infradead.org; Tue, 07 Jan 2025 20:08:20 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-2167141dfa1so2658825ad.1 for ; Tue, 07 Jan 2025 12:08:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736280497; x=1736885297; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+J3uEvrodRrvpIjWWGDgko7jtoYydXF7C2qPRbL5eTY=; b=guVQSlKjeE1WjDhS4VGzYTzqohgmdXlGKwodziW+IQoetdvt0lOR4dwPRR+Zl5aK7F 3Cm+tELKXvrtuV/5MyyKR+WBpMwSB6PmJDPHpzsdwQ47Y7YRmhZT7wFPUERfqu9mznFw j41IDoozbYNOPBJNZkjmEg4gnkBldfaY6w7Uo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736280497; x=1736885297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+J3uEvrodRrvpIjWWGDgko7jtoYydXF7C2qPRbL5eTY=; b=kiK6W46iOa7c2qu6rH2Ip/0PLtG95veRZTYKEM58RDyweCx0jWLVnHTf+/Fm/y7jEw PJCQok7AIspeUsknBYxtiov6qKJkg7U3f1zoygH4k4N4/RawLRrlSFljA6VYdD//Udxj dgQ3ZMHEA5+5nMwsxqUXqZ5ZWE01073LUmm/UunQzpdWGWYoWjHXkJYpdyJtYhr49AiE zfIFF6XyKQXM0vgMP8mGc0QDpaCgUE0MaRBgHRa2fbmYAOY7PzAwmLfQwyAFZaqgFcRc SfsMH9sPHgxK1xLAeeDdvaaOPzCvR2NZ/CA4OkeXILeeW4QZxnMVqfeuSVDyKftC95WI nasA== X-Forwarded-Encrypted: i=1; AJvYcCUUo3dbscAQWJzxzQHy3VFI3hUSCWkjXbYgnCln2UyZOGfceFd8zLwzzcZI4FL8Lde8JF9y2GdPhnrs7BMXZTjN@lists.infradead.org X-Gm-Message-State: AOJu0Yxq1ppatcvib36ycAc0JxjjZOYWGz0WRhvM97EBxPcyb4RFoL3m XJxIeq9v7zDKlu8F8qiCIrGZCvixIDkBm2zLfILmjdgFOPM0WJMK16IY8d+AhA== X-Gm-Gg: ASbGnctjZtfOsAhEzoxv4erby8N6caPTfJhzoxqUWYLtFiOI4qLjkFFbjDCwEbakNpZ QRRdNLT3ybVhtYxMt0V9r5tRi30hhV96J9NQUqH8SRuo9bTAccuok1KuTtc55wbbTXWsb+kHuvP gv7YU7q+oYMEXXqAVwcfBbgwtK19tNyBrgxyRJLoB+MO+X9Nt+F3yHyPuGULIRn+E//BuleEB+b kJ6RQ/GC/kKIkdWf0I8WIEwyW3w0jcdR1aLq3e11AOuGfs/ptAXbTAfv6ggs5rMRa3P0Gg1zm0a X-Google-Smtp-Source: AGHT+IERsInGKvMTJwDEekT7zUQ/SqNr1OWxECv7WnReZ50o5l0ZIy479qmOPxldyGbLGh45fTS6jg== X-Received: by 2002:a17:902:da85:b0:216:4676:dfb5 with SMTP id d9443c01a7336-21a83c721c1mr6200665ad.21.1736280496985; Tue, 07 Jan 2025 12:08:16 -0800 (PST) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2961:4bbc:5703:5820]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc962d47sm314263425ad.55.2025.01.07.12.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 12:08:16 -0800 (PST) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Mark Rutland Cc: Roxana Bradescu , Julius Werner , bjorn.andersson@oss.qualcomm.com, Trilok Soni , linux-arm-msm@vger.kernel.org, Florian Fainelli , linux-arm-kernel@lists.infradead.org, Jeffrey Hugo , Scott Bauer , Douglas Anderson , stable@vger.kernel.org, Anshuman Khandual , Besar Wicaksono , D Scott Phillips , Easwar Hariharan , Oliver Upton , linux-kernel@vger.kernel.org Subject: [PATCH v4 4/5] arm64: cputype: Add MIDR_CORTEX_A76AE Date: Tue, 7 Jan 2025 12:06:01 -0800 Message-ID: <20250107120555.v4.4.I151f3b7ee323bcc3082179b8c60c3cd03308aa94@changeid> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20250107200715.422172-1-dianders@chromium.org> References: <20250107200715.422172-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250107_120817_554174_E8AB7B07 X-CRM114-Status: GOOD ( 11.21 ) 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 From the TRM, MIDR_CORTEX_A76AE has a partnum of 0xDOE and an implementor of 0x41 (ARM). Add the values. Cc: stable@vger.kernel.org # dependency of the next fix in the series Signed-off-by: Douglas Anderson --- (no changes since v3) Changes in v3: - New arch/arm64/include/asm/cputype.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h index 488f8e751349..a345628fce51 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -75,6 +75,7 @@ #define ARM_CPU_PART_CORTEX_A76 0xD0B #define ARM_CPU_PART_NEOVERSE_N1 0xD0C #define ARM_CPU_PART_CORTEX_A77 0xD0D +#define ARM_CPU_PART_CORTEX_A76AE 0xD0E #define ARM_CPU_PART_NEOVERSE_V1 0xD40 #define ARM_CPU_PART_CORTEX_A78 0xD41 #define ARM_CPU_PART_CORTEX_A78AE 0xD42 @@ -158,6 +159,7 @@ #define MIDR_CORTEX_A76 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76) #define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N1) #define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77) +#define MIDR_CORTEX_A76AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76AE) #define MIDR_NEOVERSE_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V1) #define MIDR_CORTEX_A78 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78) #define MIDR_CORTEX_A78AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78AE) From patchwork Tue Jan 7 20:06:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Anderson X-Patchwork-Id: 13929588 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 526D7E77197 for ; Tue, 7 Jan 2025 20:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OfHdG1ANNWPpZE2kjiBnSExD56hP6zWfFTzaWahyQ5I=; b=ifQS7ZdL0A5ay/0pjyfshQvckE U+dkqrCTcSz9mkJkyvS7IteqHz02HvYQPALhuSmL5Ptg+txHhCaZR9E1UV70WGeGRuo63yh7XE4Ij tNh3yOxLG3wTQLsMMpEFj6hcVjIBWvg0elYssDyn5RRpTv0lpZvisjTu3OXB2qeLOc4/R3s1VugVU baM7jEpMtinv7QG7JUZ81+EkLX5Ua9a1WjgBSVrrRUhV7N7qCvfzwbj8rBhZfksBJBr3Jw/hefXwS 5P/kPJCB0cM26Ye2fj4vvLfBUmzWn+uIarx9IS6BRSDv4EbIKWF8lq+nrCoPuUgxgn4Ez0vQbuIar r55VrOvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVFz8-00000006Dk8-0iJY; Tue, 07 Jan 2025 20:15:30 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVFsC-00000006CUj-0WIu for linux-arm-kernel@lists.infradead.org; Tue, 07 Jan 2025 20:08:24 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-21680814d42so200112175ad.2 for ; Tue, 07 Jan 2025 12:08:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1736280499; x=1736885299; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OfHdG1ANNWPpZE2kjiBnSExD56hP6zWfFTzaWahyQ5I=; b=Qb+/XSrFqqjxvhxlscBdEbgesN/1ygfqAxQ57DWWWgiPPrNb7ynyvSa9AYoca+PLlc l2WBw2eQW+a7CYYtDZHBYu9qd1QxRsVRz6+ZtAuHZ0PzNbw+MM4+MyQX4+VWotEOlG6k YVt7twarP+N6wY5258dB2UAjRTXZsPGuT9a0Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736280499; x=1736885299; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OfHdG1ANNWPpZE2kjiBnSExD56hP6zWfFTzaWahyQ5I=; b=mFKZYnvtbL722OE+mwu6uf1d3e59tG6zbGDGUdq0OFjdUgx/bZMX5WDSWaMVmg0jDf 9hBr+MB81I8VTFJiWjOyTmJTxW4Zj1QSx53hn/ujVAZOSc2Ik6xWO+zbQIpqcbJwN4J9 uAqYsEI6OB69Q7N9tFEnHgBr0XKdNoMANW6t3Isa0xcD1IePgvv9245DQzePDrPa3afX utftou+itL8c7Y9UJ+prwg76Ww3Va5S1mBIlbnM4/niObL7H0nc/V2TWyprkcSZQotrv Wze+44GoSxDxk4jk7DIU4+8ErQ0Tbbv9Un6yDhaH11I1Xs3CCPO9RqzxAaN2EVp53mmb L62Q== X-Forwarded-Encrypted: i=1; AJvYcCWo/HUyS9nCv2lAnSVZqRsLilSIzSZkcguuqIrBahhTFu3GyC4Bz+5T3BZLxtsY1kdmECJoxAA8+GDcsskQKdiv@lists.infradead.org X-Gm-Message-State: AOJu0YyoTLAwI0r37D7Ip1Osp/3soN/HC88a6Tu2PYR8Z0mBbaUxpCLe 6WgXb6mPHj0zKO5EDURkwMcTgLIUNGNYX22n9rTxp9x8xoGjQmsl1+KUncDD3Q== X-Gm-Gg: ASbGncs5480/xEqBsQpluj+DskudQBoTSBu1Pb65ymd8+4xDkQu4IeXVpTrUr8D/n5l BPDcilwywc9IviTgT89W3RvN4BV5zmB7qjAFONFBh5zu2YzgQbk2xuy7UCCupqPU/YHFw6QEL3X +mRmMahmYcB9ZHBMvEXdlSven0vX1ddkANrR12FDZZzIOm/289u6i4Ps2IBjLAk6kwi6trwAjRK 86a3b68s6NFNIsWPcNqXIdbOdng6rA5fdAIfKNKPeDfOmC1UX/ou5wwy3otGo1LQ4izYTcEE7BA X-Google-Smtp-Source: AGHT+IFu7otqKCCIAbXozs9Yi25BzurouHYPRUn+yFnfSXfUKFQHp3WyFH7S4/kldp390+NNufFNOg== X-Received: by 2002:a17:902:ccc2:b0:216:4165:c05e with SMTP id d9443c01a7336-21a83f67982mr5749945ad.24.1736280499600; Tue, 07 Jan 2025 12:08:19 -0800 (PST) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:2961:4bbc:5703:5820]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc962d47sm314263425ad.55.2025.01.07.12.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 12:08:18 -0800 (PST) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Mark Rutland Cc: Roxana Bradescu , Julius Werner , bjorn.andersson@oss.qualcomm.com, Trilok Soni , linux-arm-msm@vger.kernel.org, Florian Fainelli , linux-arm-kernel@lists.infradead.org, Jeffrey Hugo , Scott Bauer , Douglas Anderson , stable@vger.kernel.org, James Morse , linux-kernel@vger.kernel.org Subject: [PATCH v4 5/5] arm64: errata: Add newer ARM cores to the spectre_bhb_loop_affected() lists Date: Tue, 7 Jan 2025 12:06:02 -0800 Message-ID: <20250107120555.v4.5.I4a9a527e03f663040721c5401c41de587d015c82@changeid> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog In-Reply-To: <20250107200715.422172-1-dianders@chromium.org> References: <20250107200715.422172-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250107_120820_159572_0696AA08 X-CRM114-Status: GOOD ( 14.36 ) 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 When comparing to the ARM list [1], it appears that several ARM cores were missing from the lists in spectre_bhb_loop_affected(). Add them. NOTE: for some of these cores it may not matter since other ways of clearing the BHB may be used (like the CLRBHB instruction or ECBHB), but it still seems good to have all the info from ARM's whitepaper included. [1] https://developer.arm.com/Arm%20Security%20Center/Spectre-BHB Fixes: 558c303c9734 ("arm64: Mitigate spectre style branch history side channels") Cc: stable@vger.kernel.org Signed-off-by: Douglas Anderson --- (no changes since v3) Changes in v3: - New arch/arm64/kernel/proton-pack.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/proton-pack.c b/arch/arm64/kernel/proton-pack.c index 89405be53d8f..0f51fd10b4b0 100644 --- a/arch/arm64/kernel/proton-pack.c +++ b/arch/arm64/kernel/proton-pack.c @@ -876,6 +876,14 @@ static u8 spectre_bhb_loop_affected(void) { u8 k = 0; + static const struct midr_range spectre_bhb_k132_list[] = { + MIDR_ALL_VERSIONS(MIDR_CORTEX_X3), + MIDR_ALL_VERSIONS(MIDR_NEOVERSE_V2), + }; + static const struct midr_range spectre_bhb_k38_list[] = { + MIDR_ALL_VERSIONS(MIDR_CORTEX_A715), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A720), + }; static const struct midr_range spectre_bhb_k32_list[] = { MIDR_ALL_VERSIONS(MIDR_CORTEX_A78), MIDR_ALL_VERSIONS(MIDR_CORTEX_A78AE), @@ -889,6 +897,7 @@ static u8 spectre_bhb_loop_affected(void) }; static const struct midr_range spectre_bhb_k24_list[] = { MIDR_ALL_VERSIONS(MIDR_CORTEX_A76), + MIDR_ALL_VERSIONS(MIDR_CORTEX_A76AE), MIDR_ALL_VERSIONS(MIDR_CORTEX_A77), MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N1), MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD), @@ -904,7 +913,11 @@ static u8 spectre_bhb_loop_affected(void) {}, }; - if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k32_list)) + if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k132_list)) + k = 132; + else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k38_list)) + k = 38; + else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k32_list)) k = 32; else if (is_midr_in_range_list(read_cpuid_id(), spectre_bhb_k24_list)) k = 24;