From patchwork Fri Sep 6 17:13:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13794475 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 D768BE6FE33 for ; Fri, 6 Sep 2024 17:18: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=C2Awb8QHiwgK4hQKj8EI8RJlryPJ8iCefANxC9lVPtM=; b=Hh3hTFAxyNULNAfEqgSD3PM46X 4jAPkgcHsbfJRywIuSB/mssInyZ+Ei+Xb/IaSxFyTnKJQXi5+wrMetL84dDHNcb18mAGTYabqCH/M ML2UzzPAqlt9IciGxLGYEhUUNGErZ/wkTJFjHc00Fib3aCLSNrcXBVxQeUpdUpzmgNjRA37OnzgLR ddEB/oioOfOMDy5bxcEKecsdegMzkHXRcNyjsNY3J2dbROkfwEL/6ObB/ue3Y6xIFaXu9xsJI8kmM nJN508ZyTb95KzsXfyhoEAvrgVDTLChYbWrxrcc5sSmQPxXa71D1Uvix7m6s8fTJGowRSyhAZCD1S kCnECKxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smcbD-0000000D5hu-0ts6; Fri, 06 Sep 2024 17:18:19 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smcYT-0000000D5D7-1caO for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 17:15:30 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2d873dc644dso1722014a91.3 for ; Fri, 06 Sep 2024 10:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725642928; x=1726247728; 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=C2Awb8QHiwgK4hQKj8EI8RJlryPJ8iCefANxC9lVPtM=; b=iGbRZl9DwmRIUgA/ozLwHRMG9EMtC/oTbY7EvvPo11hlgE31e3zfd50N4mowpIdOcq xr06E83928t70inLXfzKm72/HtJ3G19IlrKJrHsA5NoLjbt0KdPgN4QeADVksI0EUU+j W43UhqISzBa5wEYXgG25/ycy2Q7/cIXi+qB95v2mZd9wwCjE6nOdvR2kP2GDF0MaVitD oe3EiKRqcoUWNL9JKRqC74P/DDVEAklcWdnV+FVBqyPIg6qBi98zsO+aokqo3AQwwhh4 c+3hN7EJVoNhXIrNTitPb2NXVrYd7ZgtquaCxRYJlMxzfTezI2KXJD7rhbQ3OzakhkO3 ThFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725642928; x=1726247728; 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=C2Awb8QHiwgK4hQKj8EI8RJlryPJ8iCefANxC9lVPtM=; b=m+6nUEHvYO721UN5lJXzikSXS9eOoNsUem9jfmkj889e5NhgW8YF0vVJXnihM2DMdZ XPhAwstpl0HLAQsALbZBc9WUqBQAM48SCqef7JSxKUHGxOeG9CWEVehjzYZkoLPVYRFX UQM8wHjuTq7d5bubEbC1gXh96r32aC/DZxP+GQ4N70xN4/8QF7TzhkHm5eARIKW59mTN 2rbDlJAYIe/Hxsbv7qWAHvQIktnpV+Bkw/C31NY7+CyC8bTbavCxV8fbW7tY9T2Y9nak 178p8ThJkn5BIlDTh4Y1l18+RkfE1YEk58T7LXUhfRQx1gI3WoC/c5PSdyOfbwfxz5aX 1g3Q== X-Forwarded-Encrypted: i=1; AJvYcCVXcThQPsXhZsV1olvgSteFngyirpdGGg0a0I/yGNaPFH91LffeIivLA5zf8hedrRq87/muUMLF7r4Ua3mORtbE@lists.infradead.org X-Gm-Message-State: AOJu0YynB3XuFkmaeD9xhExKClOK0UnMqvWigCoBt6z2IbLIUjevoy6Y qpn+gYP2lNj7k28D3mqFrYWwKwgosDeI+IYSR6QVNWJK6S+9YYOD X-Google-Smtp-Source: AGHT+IEitKjL9pf51BQRfyrnIhp+JSQo2gkjFGgr1MpgdrNgRy39LdtoUZno7Bc9XWCc1kIaXZP2HA== X-Received: by 2002:a17:90b:68a:b0:2da:6812:c1bd with SMTP id 98e67ed59e1d1-2dafcf1ac51mr112698a91.15.1725642928140; Fri, 06 Sep 2024 10:15:28 -0700 (PDT) Received: from localhost.localdomain ([59.188.211.160]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-2dadc10fa99sm1841519a91.39.2024.09.06.10.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:15:27 -0700 (PDT) From: Nick Chan To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: asahi@lists.linux.dev, ~postmarketos/upstreaming@lists.sr.ht, Nick Chan Subject: [PATCH RESEND 2/2] arm64: cpufeature: Pretend that Apple A10(X), T2 does not support 32-bit EL0 Date: Sat, 7 Sep 2024 01:13:26 +0800 Message-ID: <20240906171449.324354-4-towinchenmi@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240906171449.324354-1-towinchenmi@gmail.com> References: <20240906171449.324354-1-towinchenmi@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_101529_436502_3609E8C7 X-CRM114-Status: GOOD ( 14.41 ) 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 Apple A10(X), T2 consists of logical cores that can switch between P-mode and E-mode based on the frequency. However, only P-mode supported 32-bit EL0. Trying to support 32-bit EL0 on a CPU that can only execute it in certain states is a bad idea. The A10(X), T2 only supports 16KB page size anyway so many AArch32 executables won't run anyways. Pretend that it does not support 32-bit EL0 at all. Signed-off-by: Nick Chan --- arch/arm64/kernel/cpufeature.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 718728a85430..458bcbc4f328 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -3529,6 +3529,29 @@ void __init setup_boot_cpu_features(void) setup_boot_cpu_capabilities(); } +static void __init bad_aarch32_el0_fixup(void) +{ +#ifdef CONFIG_ARCH_APPLE + static const struct midr_range bad_aarch32_el0[] = { + MIDR_ALL_VERSIONS(MIDR_APPLE_A10_T2_HURRICANE_ZEPHYR), + MIDR_ALL_VERSIONS(MIDR_APPLE_A10X_HURRICANE_ZEPHYR), + {} + }; + + if (is_midr_in_range_list(read_cpuid_id(), bad_aarch32_el0)) { + struct arm64_ftr_reg *regp; + + regp = get_arm64_ftr_reg(SYS_ID_AA64PFR0_EL1); + if (!regp) + return; + u64 val = (regp->sys_val & ~ID_AA64PFR0_EL1_EL0_MASK) + | ID_AA64PFR0_EL1_EL0_IMP; + + update_cpu_ftr_reg(regp, val); + } +#endif +} + static void __init setup_system_capabilities(void) { /* @@ -3562,6 +3585,8 @@ static void __init setup_system_capabilities(void) void __init setup_system_features(void) { + bad_aarch32_el0_fixup(); + setup_system_capabilities(); kpti_install_ng_mappings();