From patchwork Fri Sep 6 16:59:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Chan X-Patchwork-Id: 13794468 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 9C0F4E6FE33 for ; Fri, 6 Sep 2024 17:10:18 +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=m+lS6eOfUGQL/2MMHNxNF6i+Qz ciIVFZfWk7BuD0iKCBO4b6kSs3/bGv5MqTrpJyzzUdjAhu8beZv5jmTfbbllJsVl64nfXoAW8Z+SI mg7XqZ8cBTDj44aa9DUhevQ9puFEkBensIPN6ernn5GhlUQGLocorQqle2R51KPR+op/532e0gwb0 aZMuKk24dCTZvO30JbYD2ABLhOdsssb4zi90r/7GnEmyOkO0RQ0go7ZyE4kw7IybW/8JOiYHQbVgO ESORY1n6v6VzUk1EFsKwep2blL2yzEZHAvDB7JeF6hHoJNU1eJspulMhROW6p1OhdqtZ/8IUPDVOU bTQ7DSgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smcTI-0000000D4Ra-0Qln; Fri, 06 Sep 2024 17:10:08 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smcQS-0000000D3lo-3Iyn for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 17:07:14 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-20551e2f1f8so22832465ad.2 for ; Fri, 06 Sep 2024 10:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725642432; x=1726247232; 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=jc2q3rJ2yzweAHxBTKJhUb5xJIBXDYmDXCoQPoHPhb5O8AR+880AZ6L3J9DpvxnaC0 zF/qrrs4M5agsH14lsz4X04ybRQgu0gf3jMNVSmrTX7G+gfhz5JTfEFELIj29BFHddi0 27p/zOWG4Nq/U2ZmWBrsGbdCBYYXDDlz/1vpmyVGTRsKljGh10fKNOXPKt/vl4Nk9/f8 F41xnDH5tb5fxAwB0kDR/1Qz+wk2JEX3j1vnGSU9/un2hteQaOlBYUw7qynKizPayW0e mhoLjzC81Em7KCcOQOkAGrJGBNrBO+63enXUAmItkw4C/luH1FlGkvejIJnZ6PmEmFF3 SmAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725642432; x=1726247232; 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=IBOyMVBz0swZ/hUazvgAGjYXgQUZCfZpy2Hw1yBVqpO/le7mxwmqic6etH+y+znTH5 kA6/6UVKPsiTx1YK0pyqyDELigNLeXLcre+C9DrfqiXPAAbhICRFxBo6ioXoIY2lmFAq +B+aQ1hzxmS0vFo7ueeIK6Bbk7GnsQ1inGb0AZYeFVIJa+4ChZP0LrZ2Lr9OC1TTzIax Yd2v6VgzOVoON7l1hiFOBisiyh8EaKt26FQaT8BpgVpp6IDjrpIuvNSoKfwE6JEidXQ6 7rrpmHn2c8f8mBfRtAa/fwbLl9B4mygFaYFnAhhjJjD4lgxzvGl+s/NGTz+jQE6u19im 9mPg== X-Forwarded-Encrypted: i=1; AJvYcCW3F7us8RViw84pU+3pm6yq/YK9RYaywJpg460SCVTQKnaGepbdj2179kQ2u9RDUCNcCNbgvXwSQBt4/cC4rILm@lists.infradead.org X-Gm-Message-State: AOJu0YyEdq6Z8c5oAWMohkF26EkjRVSI+TGs/zq97yt8WpZH7+DlmUYL pXACM30ieo6dXbgiNS65KIB5ptSulbPh48rnEjxIboKM1Qo6TaRT X-Google-Smtp-Source: AGHT+IFzWBC72QoGzj8kbBobKI6Ww4r0XzwjrJiOcmr9ev3ZyRUXQKrGkjvpbp2VTVfHowtN+JDMZQ== X-Received: by 2002:a17:902:da92:b0:205:6c5f:e3ca with SMTP id d9443c01a7336-206f05faf58mr27842755ad.53.1725642431812; Fri, 06 Sep 2024 10:07:11 -0700 (PDT) Received: from localhost.localdomain ([59.188.211.160]) by smtp.googlemail.com with ESMTPSA id d9443c01a7336-206ae965b58sm45317185ad.118.2024.09.06.10.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 10:07:11 -0700 (PDT) From: Nick Chan To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: asahi@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht, Nick Chan Subject: [PATCH 2/2] arm64: cpufeature: Pretend that Apple A10(X), T2 does not support 32-bit EL0 Date: Sat, 7 Sep 2024 00:59:39 +0800 Message-ID: <20240906170648.323759-3-towinchenmi@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240906170648.323759-1-towinchenmi@gmail.com> References: <20240906170648.323759-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_100712_904510_9069989D X-CRM114-Status: GOOD ( 14.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 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();