Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3771378rdg; Wed, 18 Oct 2023 05:52:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFiouaLuwOVtl85zQ73Cmjj4mD4pv4HzN7zwSxz6oYXTacmVuCNB3W3lOZAKP+KV7dlThl X-Received: by 2002:a05:6a21:a108:b0:154:a1e4:b676 with SMTP id aq8-20020a056a21a10800b00154a1e4b676mr4745377pzc.4.1697633549051; Wed, 18 Oct 2023 05:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697633549; cv=none; d=google.com; s=arc-20160816; b=CBk3l/SIRPRVqOdXFMc8yh2qmezVwJBJXGLz4fsGciQDFw23xjW76Z5e7lTyEY8VOU d+wEqd/DOs/JJCQ9X5wr1TRllN0eOVc/vd3DQotcPKODDeOpMdwUK4xAl07cBwi7WzTq Su5ZKvSJa4CDxap7CpQID5aB9DX4ntIaArAvVkxz/UP0DAOku7uCVKre1cogGmfo8cxc axSUa9Ldi9NFHsSUoH5A9v2XIZQw5ZB3nEy3URDYUl6ppUXzecXn6XDGaSuYGvWZTSVR Ao4ASoRTHbDtDzX3kvEmJlkV9ZO+V9sEhLlhF1nZ2n8AQwMmBMiZs4PZdlOBHBmrhtr5 5F2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=RVV/ZGHTmH9G86fAV9JqpAv8MSQsBP1UXRKvUsvL0cQ=; fh=hCPobr24DmA9maJD9j0iJQVs2bF3FJ0EU8dYUrAN60Y=; b=Ly71bdeCSZEYS80DZPbxLo2CO1KU/lMRdvQfTYH4eGBFARmaCiQZo2xjMCPleBAZ9n rrCkKXQdi4Wluvk1vVH2Q8R6K10mJdoLBewWEBdYCxz+ajQJWdEUHEE6mmLX3ZtavLba eIYxeWeh6S3wG+uJLoI8m0ZYYvry5Z61XRdKVkvK2Kk+NN/JUAfcPaiBGy4VjnAzCiVx Jotb5fCmJsD1sK2hN+Lh0CqpovFhGCxp8gO7tEsVmWhfv3RggBJBPb96BXtM8eeN2oOp jAmfyh2en/JnyWxDzap/Hif0LIVH11T4xiQ6K7aE/xQHD2IPoYdCr2VQfgY37HhpIOO1 sK1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id x6-20020a170902ec8600b001c3fa95ca18si4479722plg.333.2023.10.18.05.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 05:52:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BF1C580D7547; Wed, 18 Oct 2023 05:52:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbjJRMwR (ORCPT + 99 others); Wed, 18 Oct 2023 08:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbjJRMwQ (ORCPT ); Wed, 18 Oct 2023 08:52:16 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 61DAFA3 for ; Wed, 18 Oct 2023 05:52:13 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 289F92F4; Wed, 18 Oct 2023 05:52:54 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.31.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 272B63F762; Wed, 18 Oct 2023 05:52:12 -0700 (PDT) Date: Wed, 18 Oct 2023 13:52:06 +0100 From: Mark Rutland To: Andrea della Porta Cc: Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, nik.borisov@suse.com Subject: Re: [PATCH 0/4] arm64: Make Aarch32 compatibility enablement optional at boot Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 05:52:26 -0700 (PDT) On Wed, Oct 18, 2023 at 01:13:18PM +0200, Andrea della Porta wrote: > 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. Can you elaborate on *why* people want such a policy? > *** 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. Why does the compat syscall path need to do anything? On arm64 it's not possible to issue compat syscalls from a native 64-bit task. If you prevent the loading of AArch32 binaries, none of the compat syscalls will be reachable at all. That's the proper way to implement this, and we already have logic for that as part of the mismatched AArch32 support. > This of course results in a little performance loss, but has the following > advantages: A performance loss for what relative to what? How much of a performance loss? Mark. > * 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(-) > > -- > 2.35.3 >