From patchwork Mon Oct 23 14:42:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 156925 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1345092vqx; Mon, 23 Oct 2023 07:44:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuzbsuNWSvZ4WsyPxKilHMddl/lelnwLyEs0NgRrjW+khQA4LF7+OAYwto9CQJ1s1VQhD7 X-Received: by 2002:a05:6a00:1a09:b0:6bd:7cbd:15ae with SMTP id g9-20020a056a001a0900b006bd7cbd15aemr9986374pfv.26.1698072262969; Mon, 23 Oct 2023 07:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698072262; cv=none; d=google.com; s=arc-20160816; b=sqByTWNtiiwMLA/SM1RWhbtAGsw5g1kies+RTiM3n5f/yl24IEDn+5eJuj9Z339Wmb sJy5mFfWQN6P7yPRGPhWUIEJKt5YFJZmdDdJocm8EmY9YjSXtE46gyqo5Rqik2+YBR4Q UH+6Ub3Jq1sEDR1LFqO7ovp4iFLYNC4nRkjwQEnrO0v+ae7X2mgxZDtR8cyFUBaxHbHk tf28L/dJH9+YFNLJ0uxTFUoZ6S0mud0tvD+T06flQv9blyevWYaVoKuY40YULyV/70Mv ilpndwxgdOuyS9ollA6uE+wNfsg4JHK/NL0oKHFnt79qd8EKxe9/0qFwCDhGrgEc2OTA Hdew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IgkfPdLL0JOTUwZlB8Z82NlYikR+ETv1lCssxJ5dRNw=; fh=Mt283RDXEoutdgZ0ioYgkrGAUpbBAwJ7lRTaJXIGXS8=; b=UGgY2QZPeoVR34PiAaFiBPLi3JKJQZgsEJjMSlEalJig3F+P7JpbBKcYW1bueC4IMy uTEZ2j1KZuoJeV1BqLAZJBkvaaRMntfHBqGTE2rS/ZXIdR5yOCLU/qrEayd1iiFqyB5z rnhdWA4vmLHZRy1d2FnF+3h03iITg4Gqj+CK5DdYkbctstwWu4CAakK3hF+mkzGwtdrt UBjBUJtijb+cEBcX+5pYN6IPoD4ggM+TOcZlO6neXiZv+1VaazCQO4L4Vu9idwNeG61g QcDigVNLbIK6YClS7w7PMPexIuY4FrLvZICX4fQRUO0lOAjSal3glGkXXi/u78zdlxox uskw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=T4ANELya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id g28-20020a63375c000000b00585a454179fsi6395800pgn.162.2023.10.23.07.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:44:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=T4ANELya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 77FCE809C665; Mon, 23 Oct 2023 07:44:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230398AbjJWOoC (ORCPT + 27 others); Mon, 23 Oct 2023 10:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233748AbjJWOnp (ORCPT ); Mon, 23 Oct 2023 10:43:45 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82C7C1FC6 for ; Mon, 23 Oct 2023 07:42:27 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CEC842188E; Mon, 23 Oct 2023 14:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698072145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IgkfPdLL0JOTUwZlB8Z82NlYikR+ETv1lCssxJ5dRNw=; b=T4ANELya+7eZzKSrlrTqXHdbhHz9Q7GsrHbdikW7vFTLnq1CfFy0SF0z+7K2F8+Mpp9kG7 Kl73rR2m2g0NHJ+8Oq4BsDeZEZaXxTmmNXSo0+LiD20kd7xG30J2N1jEHs8EEdje2G9C91 LjNnETkVoyhH+3EPXwA8YMGp32MN7Vk= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B673F139C2; Mon, 23 Oct 2023 14:42:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GMlnK1GGNmW9dgAAMHmgww (envelope-from ); Mon, 23 Oct 2023 14:42:25 +0000 From: Andrea della Porta To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: nik.borisov@suse.com, arnd@arndb.de, mark.rutland@arm.com, Andrea della Porta Subject: [PATCH v2 1/4] arm64: Introduce aarch32_enabled() Date: Mon, 23 Oct 2023 16:42:20 +0200 Message-ID: <1dec05cc8f54d0b85acffce69d929f13e6d81313.1698069331.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -3.72 X-Spamd-Result: default: False [-3.72 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_HAM(-1.02)[87.38%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FORGED_SENDER(0.30)[andrea.porta@suse.com,aporta@suse.de]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_NEQ_ENVFROM(0.10)[andrea.porta@suse.com,aporta@suse.de]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 23 Oct 2023 07:44:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780557821267335319 X-GMAIL-MSGID: 1780557821267335319 Aarch32 bit support on 64bit kernels depends on whether CONFIG_COMPAT is selected or not. As it is a compile time option it doesn't provide the flexibility to have distributions set their own policy for Aarch32 support and give the user the flexibility to override it. As a first step introduce aarch32_enabled() which abstracts whether 32 bit compat is turned on or off. Upcoming patches will implement the ability to set Aarch32 compat state at boot time. Signed-off-by: Andrea della Porta --- arch/arm64/include/asm/cpufeature.h | 15 +++++++++++++++ arch/arm64/kernel/entry-common.c | 2 ++ 2 files changed, 17 insertions(+) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 396af9b9c857..1180d68daaff 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -657,6 +657,21 @@ static inline bool supports_clearbhb(int scope) ID_AA64ISAR2_EL1_CLRBHB_SHIFT); } +#ifdef CONFIG_COMPAT +extern bool __aarch32_enabled; + +static inline bool aarch32_enabled(void) +{ + return __aarch32_enabled; +} +#else /* !CONFIG_COMPAT */ + +static inline bool aarch32_enabled(void) +{ + return false; +} +#endif + const struct cpumask *system_32bit_el0_cpumask(void); DECLARE_STATIC_KEY_FALSE(arm64_mismatched_32bit_el0); diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index 0fc94207e69a..69ff9b8c0bde 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -877,6 +877,8 @@ asmlinkage void noinstr el0t_32_error_handler(struct pt_regs *regs) { __el0_error_handler_common(regs); } + +bool __aarch32_enabled __ro_after_init = true; #else /* CONFIG_COMPAT */ UNHANDLED(el0t, 32, sync) UNHANDLED(el0t, 32, irq) From patchwork Mon Oct 23 14:42:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 156923 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1345044vqx; Mon, 23 Oct 2023 07:44:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFX43QbOUwWb7T8EsB+imZyATmPyAsMS2EZ+gNWiWZAPew5bPbNs6dw/RGJ1gwYUEtfyvib X-Received: by 2002:a05:6358:7295:b0:168:cdee:155e with SMTP id w21-20020a056358729500b00168cdee155emr6322227rwf.3.1698072257908; Mon, 23 Oct 2023 07:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698072257; cv=none; d=google.com; s=arc-20160816; b=dGhaZ39TYlrcLCLBO7vl7UA/OWYQ2AFXv+EttydGZXLUBImicUQ5YxE9d35Eu4LS7C ABabz6qFRHlGGg2/GqSyh7uRCaUBdBFG7MVeA6XFTqzn6DgWSNiIYkBR6DVOMSkY4J+r nKvuaOFJYc/nbikt6jjXLhRS8Zh+ZwaPV1Ogg+KQS/2UZ5ktqfJ0pvqvz3izD0ez2YYN o9hhWVc/sTXRGQ5Y69V5qU9JQ5dXV9kKLT06EQaXTHr7HWkXUH+oRrPZdln3wTOaW0mp MjS5BlaSy9o+AKAzXzYEljHTzPz9qMamf/TKIhCAIBNUOMqZkjFCk01gupH+21OjUs7o kFqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ptLMqv6iaACOOpI3/GceNmmJmtBYsEsFiVZhrERtJcU=; fh=Mt283RDXEoutdgZ0ioYgkrGAUpbBAwJ7lRTaJXIGXS8=; b=atA9N/Ox2cOgcaBEFHRrCOd38eyI46v6cgx8I2uoSqnwvcqG3VBCMmKfjB7qPZL3J0 AG+hUGM5IQSKAHpiRitgtmIg+sEW33KUvXgJkUKNhfsKiP7wmrvItzGXnwFocMZlsr9O dhpBH4LnwyW4goqR6ORH2PqYwQLSqCshHl4MEi9XTWoVeXAow8BjBkFPizkH0dgpFsJn /SkhL+Kbvfvj/H29JVxJeGk00rlQP4R4BO77m4NNby/+QChhmioOpfBpnRtOozi68dG1 7AggOiep3a8gVSB1tt9b+eL7M8dItvp0JeoY4Gfp+Jt6uO80ocaEH+8thmpnUIDMVF6L Ozzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=HpFvhsGR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id cb21-20020a056a02071500b0057777451a91si7019047pgb.581.2023.10.23.07.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=HpFvhsGR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D94548061B45; Mon, 23 Oct 2023 07:44:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233746AbjJWOoH (ORCPT + 27 others); Mon, 23 Oct 2023 10:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233807AbjJWOnq (ORCPT ); Mon, 23 Oct 2023 10:43:46 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C7CA1FD3 for ; Mon, 23 Oct 2023 07:42:28 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9011B2188F; Mon, 23 Oct 2023 14:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698072146; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ptLMqv6iaACOOpI3/GceNmmJmtBYsEsFiVZhrERtJcU=; b=HpFvhsGRqrkWuoKHGLQpCHaNEeX0hCZU8Ns5O630i2hGaSX8F5c1wRpCrav8t6nLksfcoJ 6UwowYxJJBXRuTNz7bgCFJuvAzm8bfwtOP5kEueXj2qutCxLwiu8lLt+JXWoyQv5JNT7nd +UVGsPwwPFbHAXjdujBBcGqmrw6XfvY= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 73BD2139C2; Mon, 23 Oct 2023 14:42:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WPj+GVKGNmXBdgAAMHmgww (envelope-from ); Mon, 23 Oct 2023 14:42:26 +0000 From: Andrea della Porta To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: nik.borisov@suse.com, arnd@arndb.de, mark.rutland@arm.com, Andrea della Porta Subject: [PATCH v2 2/4] arm64/process: Make loading of 32bit processes depend on aarch32_enabled() Date: Mon, 23 Oct 2023 16:42:21 +0200 Message-ID: <2d105c9d8184686fe5aadf646bea7f46ec68ff8b.1698069331.git.andrea.porta@suse.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -2.70 X-Spamd-Result: default: False [-2.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FORGED_SENDER(0.30)[andrea.porta@suse.com,aporta@suse.de]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_NEQ_ENVFROM(0.10)[andrea.porta@suse.com,aporta@suse.de]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 23 Oct 2023 07:44:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780557815526868527 X-GMAIL-MSGID: 1780557815526868527 Major aspect of Aarch32 support is the ability to load 32bit processes. That's currently decided (among others) by compat_elf_check_arch() and system_supports_32bit_el0(). Make the macro use aarch32_enabled() to decide if Aarch32 compat is enabled before loading a 32bit process. Signed-off-by: Andrea della Porta --- arch/arm64/include/asm/cpufeature.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 1180d68daaff..778f2f3b2c7d 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -679,8 +679,9 @@ static inline bool system_supports_32bit_el0(void) { u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1); - return static_branch_unlikely(&arm64_mismatched_32bit_el0) || - id_aa64pfr0_32bit_el0(pfr0); + return (static_branch_unlikely(&arm64_mismatched_32bit_el0) || + id_aa64pfr0_32bit_el0(pfr0)) && + aarch32_enabled(); } static inline bool system_supports_4kb_granule(void) From patchwork Mon Oct 23 14:42:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 156926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1345110vqx; Mon, 23 Oct 2023 07:44:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtNWEIPrrUR5njPWV8GM8XhByLadjUmuIKAp2VOYlgY0GGm2TZ7pyKTuxQXNBR4uJXraJ7 X-Received: by 2002:a05:6a20:3cab:b0:152:4615:cb9d with SMTP id b43-20020a056a203cab00b001524615cb9dmr16599679pzj.12.1698072265457; Mon, 23 Oct 2023 07:44:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698072265; cv=none; d=google.com; s=arc-20160816; b=lnKiI9d+CfaRjvw9fcBUEBxTkF+VkxK9AUs1SnBdidznhTCoUk+se/ZQY6tgttKG45 Ue4j9R2XqUKa2PWJZl+dJQqgy6QrHtmlPX2p4T1UPZgf7gscBVmx61p9EdBGckSoRQy6 dBvVSBWtOApPXNoQugYJ6to2Jy/a+G9z6TBF310ZSHiRX082Hr0jn/rnRd/KMRtQ7zMx cTTHcOwXKsIt9pQSzwgM7OM2aWkBhFOhADLsszg2S2RAeKUUFNf43dl7Sqw5Cwa8QDGV T9mDXyooPfcrlXBdAwiOBapLrDsKjWudDORerR7pHY6iHHWFsrBNaZkV1wvxJgnQBz7V x6pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+I9ud1Xuz1QVsjjSIfjL5lCnrVLHZ6fU43dq2sdHnMY=; fh=Mt283RDXEoutdgZ0ioYgkrGAUpbBAwJ7lRTaJXIGXS8=; b=sMhlMwL1spkkGSDduq3mNpaePUoqS7g4x/VUymTwDOlVL8LUF7QtaXwK+nTsBF5HPb GGZdSnmad1GXZqfpenBbxipbUxX2WmDG9cYykf3Ykc3zl7OWFTWul86093v4y2tNns/b Z+14NeX3C9xpeGIuAuIMjYNQEqWrsKA6uKjO4UBdTWz5BkoZXHA8sL5q4Hgj/fIoDsK7 umHq/g7pdxMHbV4c2TumegndYFeWPKoTXpKYnIjZRk7dnRJglj4VcBvcviu22jb+dJdb 646c2nc3GgyJfJDoMf+PW6tlUYM2mlbZhy/MTwkSUwmiI5x095ZGxRsC/KYNd2zBo2xl vglg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ZnpY4uBk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o5-20020a656a45000000b00578af609d05si6758946pgu.244.2023.10.23.07.44.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:44:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ZnpY4uBk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 392CD80AA251; Mon, 23 Oct 2023 07:44:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233731AbjJWOoF (ORCPT + 27 others); Mon, 23 Oct 2023 10:44:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233693AbjJWOnq (ORCPT ); Mon, 23 Oct 2023 10:43:46 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 067721FD4 for ; Mon, 23 Oct 2023 07:42:28 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 548FD1FE25; Mon, 23 Oct 2023 14:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698072147; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+I9ud1Xuz1QVsjjSIfjL5lCnrVLHZ6fU43dq2sdHnMY=; b=ZnpY4uBkNksiRZIcuaIZLNFna9sII/TYaINRsWSXNc6OdlfhvABzLZ16+G+q94Tzm7blpJ PMeCt0I7PQHC2/G80z3PJUEFkVOvR8qTtss5N2SydDmRGdI871w6Ja15+iK+hQjWSXzKJn h+cGzSpnfJzOfDwOp68ksqiZVoAEzZo= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 39BE5139C2; Mon, 23 Oct 2023 14:42:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id zHHgC1OGNmXFdgAAMHmgww (envelope-from ); Mon, 23 Oct 2023 14:42:27 +0000 From: Andrea della Porta To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: nik.borisov@suse.com, arnd@arndb.de, mark.rutland@arm.com, Andrea della Porta Subject: [PATCH v2 3/4] arm64/entry-common: Make Aarch32 exceptions' availability depend on aarch32_enabled() Date: Mon, 23 Oct 2023 16:42:22 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -5.70 X-Spamd-Result: default: False [-5.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_HAM(-3.00)[100.00%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FORGED_SENDER(0.30)[andrea.porta@suse.com,aporta@suse.de]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_NEQ_ENVFROM(0.10)[andrea.porta@suse.com,aporta@suse.de]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 23 Oct 2023 07:44:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780557823816913098 X-GMAIL-MSGID: 1780557823816913098 Another major aspect of supporting running of 32bit processes is the ability to access 32bit syscalls and exceptions. Syscalls, in particular, can be invoked by using the svc instruction. If Aarch32 support is disabled ensure that calling svc (or any exceptions) from 32bit context results in the same behavior as if CONFIG_COMPAT has not been enabled (i.e. a kernel panic). Signed-off-by: Andrea della Porta --- arch/arm64/include/asm/exception.h | 7 +++++++ arch/arm64/kernel/entry-common.c | 25 ++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/exception.h b/arch/arm64/include/asm/exception.h index ad688e157c9b..ccb41ba8d86c 100644 --- a/arch/arm64/include/asm/exception.h +++ b/arch/arm64/include/asm/exception.h @@ -48,6 +48,13 @@ asmlinkage void el0t_32_irq_handler(struct pt_regs *regs); asmlinkage void el0t_32_fiq_handler(struct pt_regs *regs); asmlinkage void el0t_32_error_handler(struct pt_regs *regs); +#ifdef CONFIG_COMPAT +asmlinkage void el0t_32_sync_ni_handler(struct pt_regs *regs); +asmlinkage void el0t_32_irq_ni_handler(struct pt_regs *regs); +asmlinkage void el0t_32_fiq_ni_handler(struct pt_regs *regs); +asmlinkage void el0t_32_error_ni_handler(struct pt_regs *regs); +#endif + asmlinkage void call_on_irq_stack(struct pt_regs *regs, void (*func)(struct pt_regs *)); asmlinkage void asm_exit_to_user_mode(struct pt_regs *regs); diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index 69ff9b8c0bde..32761760d9dd 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -802,6 +802,11 @@ asmlinkage void noinstr el0t_64_error_handler(struct pt_regs *regs) } #ifdef CONFIG_COMPAT +UNHANDLED(el0t, 32, sync_ni) +UNHANDLED(el0t, 32, irq_ni) +UNHANDLED(el0t, 32, fiq_ni) +UNHANDLED(el0t, 32, error_ni) + static void noinstr el0_cp15(struct pt_regs *regs, unsigned long esr) { enter_from_user_mode(regs); @@ -821,6 +826,11 @@ static void noinstr el0_svc_compat(struct pt_regs *regs) asmlinkage void noinstr el0t_32_sync_handler(struct pt_regs *regs) { + if (!aarch32_enabled()) { + el0t_32_sync_ni_handler(regs); + return; + } + unsigned long esr = read_sysreg(esr_el1); switch (ESR_ELx_EC(esr)) { @@ -865,17 +875,26 @@ asmlinkage void noinstr el0t_32_sync_handler(struct pt_regs *regs) asmlinkage void noinstr el0t_32_irq_handler(struct pt_regs *regs) { - __el0_irq_handler_common(regs); + if (!aarch32_enabled()) + el0t_32_irq_ni_handler(regs); + else + __el0_irq_handler_common(regs); } asmlinkage void noinstr el0t_32_fiq_handler(struct pt_regs *regs) { - __el0_fiq_handler_common(regs); + if (!aarch32_enabled()) + el0t_32_fiq_ni_handler(regs); + else + __el0_fiq_handler_common(regs); } asmlinkage void noinstr el0t_32_error_handler(struct pt_regs *regs) { - __el0_error_handler_common(regs); + if (!aarch32_enabled()) + el0t_32_error_ni_handler(regs); + else + __el0_error_handler_common(regs); } bool __aarch32_enabled __ro_after_init = true; From patchwork Mon Oct 23 14:42:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea della Porta X-Patchwork-Id: 156924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1345053vqx; Mon, 23 Oct 2023 07:44:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5AuiP3nxjWOY7lM/nPrMHD3hfYOlvLZQv2m4FckhiiDyYh/Nb4rEUtejUuYI6URr3PDUI X-Received: by 2002:a05:6a00:238b:b0:6be:314c:16cb with SMTP id f11-20020a056a00238b00b006be314c16cbmr11462103pfc.10.1698072258745; Mon, 23 Oct 2023 07:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698072258; cv=none; d=google.com; s=arc-20160816; b=hXxNSWXoWSda9VU6lOTkkze72T2UE4xIfpi7oOG3xdepNKsi/bsIoeK+OR6EU9P7Di rnREyrSxam3DdIH3xSZJhN95glN9GPqtQHodUMAsxcUNrJaC/sJiOKtoEPs5uHIa+pdF ZMPUeWvsN7CLlJQ0n4RlqwlGV98oPpb8HfmmGlVF/8ZlmbMABjcfwLOL3ooMfUi6+1hq qIXdBLdqwHIE/59q+b+5GhHhCQYputcOGnyzzXaJBgmxYeP2n4Btv4tkqq3wUkdGKOa1 hhvWu/On0w4WfjeLq/NAeQdTmkKHL6P8GjA+JGndoLBg9xYjd07xpCjn+s3P74Ithtnn AyxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iKEUG9SHB6x+trsiRcHBTizDjwB2rC51Fj16Z+SAh18=; fh=Mt283RDXEoutdgZ0ioYgkrGAUpbBAwJ7lRTaJXIGXS8=; b=VPuVwf5RjEtIeHNfe6Ya4xy1aS2tmJlwHzRWI5muSHajFXqTAa3+oQjAyLUta1NV7m ejoA4hNiZFMFyXr2ySKWfwLf9Ib5YLD602fPn/8vd+h5r7CpYPIU91knWHGoe/Mlmya6 bp7OUcvyWmxTcR/nBaMK9Wefs1jGbqilX27GLg8TtS49Jjq5rNSnzmmRNW9dBW0q1pWP RGPr0Dy/Ii6yFdHIp55/GdF4TDZDdIUqw1w8z1f1U0Zj13kZBaAubjWIPjknrEL08rQr vBnxT9Xr7ufNVb4PE/XzU9QVhECW7W53o5yzA5rfMo/PdWu4ffYcCxeW+nRkhH/N2Cnn FmuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ZiOCAb8t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y1-20020a056a001c8100b006bf2e5f0841si5435792pfw.393.2023.10.23.07.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 07:44:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ZiOCAb8t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0D5278061B59; Mon, 23 Oct 2023 07:44:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233782AbjJWOoM (ORCPT + 27 others); Mon, 23 Oct 2023 10:44:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233698AbjJWOnt (ORCPT ); Mon, 23 Oct 2023 10:43:49 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BC1426A4 for ; Mon, 23 Oct 2023 07:42:29 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 17B541FE26; Mon, 23 Oct 2023 14:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1698072148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iKEUG9SHB6x+trsiRcHBTizDjwB2rC51Fj16Z+SAh18=; b=ZiOCAb8terQeWFu0Gp5FoprPiJsiQ3xSPzR2zvqOyloHHkz2+BgO9CTMpDQIG8xptvpcl6 AUUi8sw6p9HMOn+Szbj2g/ggFZcMNFQ+9rqo6xDw69lSkJ4N7zQDTF0IrZs0Es9DXdDyBN hIO56oQg5WXvA4kFIATudttPc18+x+Y= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E62B5139C2; Mon, 23 Oct 2023 14:42:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mLeKNlOGNmXLdgAAMHmgww (envelope-from ); Mon, 23 Oct 2023 14:42:27 +0000 From: Andrea della Porta To: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: nik.borisov@suse.com, arnd@arndb.de, mark.rutland@arm.com, Andrea della Porta Subject: [PATCH v2 4/4] arm64: Make Aarch32 support boot time configurable Date: Mon, 23 Oct 2023 16:42:23 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -5.70 X-Spamd-Result: default: False [-5.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_HAM(-3.00)[100.00%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; FORGED_SENDER(0.30)[andrea.porta@suse.com,aporta@suse.de]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_NEQ_ENVFROM(0.10)[andrea.porta@suse.com,aporta@suse.de]; RCVD_TLS_ALL(0.00)[] X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 23 Oct 2023 07:44:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780557817111556568 X-GMAIL-MSGID: 1780557817111556568 Distributions would like to reduce their attack surface as much as possible but at the same time they'd want to retain flexibility to cater to a variety of legacy software. This stems from the conjecture that compat layer is likely rarely tested and could have latent security bugs. Ideally distributions will set their default policy and also give users the ability to override it as appropriate. To enable this use case, introduce CONFIG_AARCH32_SUPPORT_DEFAULT_DISABLED compile time option, which controls whether 32bit processes/exceptions should be allowed or not. This option is aimed mainly at distributions to set their preferred default behavior in their kernels. To allow users to override the distro's policy, introduce the 'allow_32bit_el0' parameter which allows overriding CONFIG_AARCH32_SUPPORT_DEFAULT_DISABLED state at boot time. Signed-off-by: Andrea della Porta --- Documentation/admin-guide/kernel-parameters.txt | 7 +++++++ arch/arm64/Kconfig | 9 +++++++++ arch/arm64/kernel/entry-common.c | 8 +++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 0a1731a0f0ef..9752c4640bd7 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1,3 +1,10 @@ + allow_32bit_el0= [ARM64] + Format: + When true, allows loading 32-bit programs and executing + 32-bit syscalls and exceptions, essentially overriding + AARCH32_SUPPORT_DEFAULT_DISABLED at boot time. when false, + unconditionally disables AARCH32 support. + acpi= [HW,ACPI,X86,ARM64,RISCV64] Advanced Configuration and Power Interface Format: { force | on | off | strict | noirq | rsdt | diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b10515c0200b..c8e1b3535018 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1725,6 +1725,15 @@ config SETEND_EMULATION If unsure, say Y endif # ARMV8_DEPRECATED +config AARCH32_SUPPORT_DEFAULT_DISABLED + bool "Aarch32 support disabled by default" + default n + depends on COMPAT + help + Make Aarch32 support disabled by default. This prevents loading 32-bit + processes and access to 32-bit syscalls and exceptions. + + If unsure, leave it to its default value. endif # COMPAT menu "ARMv8.1 architectural features" diff --git a/arch/arm64/kernel/entry-common.c b/arch/arm64/kernel/entry-common.c index 32761760d9dd..7698057ef4ce 100644 --- a/arch/arm64/kernel/entry-common.c +++ b/arch/arm64/kernel/entry-common.c @@ -897,7 +897,13 @@ asmlinkage void noinstr el0t_32_error_handler(struct pt_regs *regs) __el0_error_handler_common(regs); } -bool __aarch32_enabled __ro_after_init = true; +bool __aarch32_enabled __ro_after_init = !IS_ENABLED(CONFIG_AARCH32_SUPPORT_DEFAULT_DISABLED); + +static int aarch32_support_override_cmdline(char *arg) +{ + return kstrtobool(arg, &__aarch32_enabled); +} +early_param("allow_32bit_el0", aarch32_support_override_cmdline); #else /* CONFIG_COMPAT */ UNHANDLED(el0t, 32, sync) UNHANDLED(el0t, 32, irq)