From patchwork Wed Oct 18 11:13:18 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: 15539 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4712983vqb; Wed, 18 Oct 2023 04:13:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhY41cmrKrOvvLbPaD2muUM35cv0uDa+Vp1k9THmAR+zo4NEHYeA/Mqg2nlS+rZAwxyx2m X-Received: by 2002:a17:90b:38cf:b0:27d:32d8:5f23 with SMTP id nn15-20020a17090b38cf00b0027d32d85f23mr5215327pjb.2.1697627637347; Wed, 18 Oct 2023 04:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697627637; cv=none; d=google.com; s=arc-20160816; b=zE0uclNlbxQDh0UiuGcpoauqzWD8vnJCmEt20G72hovY3ckKV/LZaA81yTqB7VgV6m mKzBB3xCs9BLpRmL/Z1CXxMDIs0hXhjUURhttEXfFyw64qfFRqofYW7zf+d+psfAXmF+ /Rv22oU9VTSUKH4mIhlGHgtS49xnrTTrDXQQ/qJLefBh02cPfIC4xqO3D2W4rOiTza/N tPG+U00yi1VprCeH0gBycxbV4pI1crf0LuygtlFVBulZCSndcJ/u2wqav9cJgTfSdMgJ uPjgMPmP0cfCXnDn8fYdmK0jwhFrt6OTjiG47cCq6gFkSzUvmg0qDASol9qCuO11/q/i /yoQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=WWOeIhCQpfkoB9v4pU6ssMo6xZ7yBOXJ0schrwa2slA=; fh=Fmfa0t6QgnUIyzgsSgnN1cYWfnFwLN+1Ba+VDm5h09M=; b=Ag0azrz9EQAFZFEVS74T+EyXvRfMgPFTnD/Ztwz+ep7lVXzcbHgUtxmD3e9XoJS17S KpG5VEWVEK8KXB1JR6tban4Ha7d23LzxfjznSxBh1oC0RQWH4SB66kakSbPEn8JygKk0 ncsPe9/s8T9gr8DblLhDpkP28VtcLj5/lWKth0GJBQsO5e8VfuLCU4g3eHtVhlKZutJB DlJoVyUxQ73FGFIwaZhsFKcrpWeC1zwZZPDj6QK/PBDzrBdpMFkGHe7/8yiB4FWcMvLa csrUHlaiz28klt4CwZVD4Vtqh6cDPkCgEpnN1MzFmHYvdr98eLcPrT8/KANUDsl0AQ2m Yeng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rqsvqGS0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bs191-20020a6328c8000000b005b3b8896199si1842387pgb.591.2023.10.18.04.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 04:13:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rqsvqGS0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 117908114EE8; Wed, 18 Oct 2023 04:13:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230121AbjJRLNc (ORCPT + 24 others); Wed, 18 Oct 2023 07:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbjJRLNa (ORCPT ); Wed, 18 Oct 2023 07:13:30 -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 4530E112 for ; Wed, 18 Oct 2023 04:13: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 7E67E1F383; Wed, 18 Oct 2023 11:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1697627606; 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; bh=WWOeIhCQpfkoB9v4pU6ssMo6xZ7yBOXJ0schrwa2slA=; b=rqsvqGS0pplX1TMVXx3jtnoyflVVfjwHTHeEozpvg2BKUFgH/CbqvfwPoKYX6824ddK+7w RhX8j53M0c7g4pXZIkarww1+OSi2lNQGPVmL5awBufgdFZ1omg4JTUSkmRxCIhwP5QA+Tl zRLEwkbzK7cGaQvPPWalwslb1yVv73Q= 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 61D9F13915; Wed, 18 Oct 2023 11:13:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id BAJvFda9L2VDZwAAMHmgww (envelope-from ); Wed, 18 Oct 2023 11:13: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, Andrea della Porta Subject: [PATCH 0/4] arm64: Make Aarch32 compatibility enablement optional at boot Date: Wed, 18 Oct 2023 13:13:18 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -1.70 X-Spamd-Result: default: False [-1.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)[]; RCPT_COUNT_FIVE(0.00)[6]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-1.00)[-1.000]; 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 fry.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 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 04:13:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780091597627190026 X-GMAIL-MSGID: 1780091597627190026 Aarch32 compatibility mode is enabled at compile time through CONFIG_COMPAT Kconfig option. This patchset lets 32-bit support (for both processes and syscalls) be enabled at boot time using a kernel parameter. Also, it provides a mean for distributions to set their own default without sacrificing compatibility support, that is users can override default behaviour through the kernel parameter. *** Notes about syscall management *** VBAR_EL1 register, which holds the exception table address, is setup very early in the boot process, before parse_early_param(). This means that it's not possible to access boot parameter before setting the register. Also, setting the aforementioned register for secondary cpus is done later in the boot flow. Several ways to work around this has been considered, among which: * resetting VBAR_EL1 to point to one of two vector tables (the former with 32-bit exceptions handler enabled and the latter pointing to unhandled stub, just as if CONFIG_COMPAT is enabled) depending on the proposed boot parameter. This has the disadvantage to produce a somewhat messy patchset involving several lines, has higher cognitive load since there are at least three places where the register is getting changed (not near to each other), and have implications on other code segments (namely kpti, kvm and vdso), requiring special care. * patching the vector table contents once the early param is available. This has most of the implications of the previous option (except maybe not impacting other code segments), plus it sounds a little 'hackish'. The chosen approach involves conditional executing 32-bit syscalls depending on the parameter value. This of course results in a little performance loss, but has the following advantages: * all the cons from previously explained alternatives are solved * users of 32-bit apps on 64-bit kernel are already suffering from performance losses due to 32-bit apps not fully leveraging the 64-bit processor, so they are already aware of this * users of 32-bit apps on 64-bit kernel are believed to be a minority and most of the time there are sources available to be recompiled for 64-bit as a workaround for better performance It worth mentioning that users of 64-bit apps are, of course, unaffected. Based on the work from Nikolay Borisov, see: Link: https://lkml.org/lkml/2023/6/23/387 Andrea della Porta (4): arm64: Introduce aarch32_enabled() arm64/process: Make loading of 32bit processes depend on aarch32_enabled() arm64/entry-common: Make Aarch32 syscalls' availability depend on aarch32_enabled() arm64: Make Aarch32 emulation boot time configurable .../admin-guide/kernel-parameters.txt | 7 ++++ arch/arm64/Kconfig | 9 +++++ arch/arm64/include/asm/compat.h | 12 +++++++ arch/arm64/kernel/entry-common.c | 33 +++++++++++++++++-- arch/arm64/kernel/process.c | 2 +- 5 files changed, 59 insertions(+), 4 deletions(-)