From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19798C433DB for ; Tue, 26 Jan 2021 13:11:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C859623109 for ; Tue, 26 Jan 2021 13:11:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C859623109 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R6HcZZ1DRk8XY0nRKJlZoQo8Z+JgZbOu7Gt9RH/3t3Q=; b=d+5ic5ey3BDknBUjI2vml3n0X YQGXNHQfHh6IqoHReaNsLDgVa0g6Ei85fRNEHQNYHSHxKFJkndscMrAv4o5WBpVBDY6kRQ5zgOmlt m0MDtQ90m09UtswbJ0avEcBbwk7+2l9gV8nhv6Dj143acQIjbX4FSSpWjplL/OnplSfkON1ZmEm/4 HIWYJi+MIgz0KYQbF8g5uVd3thGdc7sJLAT7KrRY3x+MH3lob1NulHTsubMFHTMCra9IwG/KAGIoW xDX32SCRTKrBMCWeA8fE9WUbpdsX3Y6ajvEM6lFgjqa6EusDLufX9k4rJB4cQeHQ+6M+346TRhgih S2dcvkZKg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4O6b-0006Uv-LH; Tue, 26 Jan 2021 13:10:01 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4O6V-0006UU-9j for linux-arm-kernel@lists.infradead.org; Tue, 26 Jan 2021 13:09:59 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 785A723109; Tue, 26 Jan 2021 13:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611666593; bh=ZKqmv5ySAEdjIw8FQQCkv9GpFgvu0//r1rv3d/WP07o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XTwlDzUR5YnyO9yclmVZGRKNMQnC/Y5iBHSiUXF2z8IIhUPq583aX9r6OwMzkpbX5 o3m4zSy4UjoHO7dUZhaFv5Fz07m5oabjWYcYVN0uOJTvp6HMbyf92qLhTU9UzTERmd 9Yr8Ibex5JHDcvkAtg8OMfi7UAbog7H4AWb/vMZCCXiXhWH6gEI97ZgURl7dXHa73e QFhzuOcD3RnPc66wMTEPYDFFK39QjBzZzHu7szCNPH6C/txKWZjw9fJLodry88kcyz EGFxt5qUH88psBifxTkZgXSkEV80Wcw05yaprXWLBIY48/TL53GNPmDQKpXJ6/ckfT 6dJEsmygC9zsg== Date: Tue, 26 Jan 2021 13:09:48 +0000 From: Will Deacon To: Peter Collingbourne Subject: Re: [PATCH v6 3/3] arm64: pac: Optimize kernel entry/exit key installation code paths Message-ID: <20210126130947.GD29702@willie-the-truck> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210126_080955_422509_A462C822 X-CRM114-Status: GOOD ( 15.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libc-alpha@sourceware.org, Szabolcs Nagy , Catalin Marinas , Kevin Brodsky , linux-api@vger.kernel.org, Kostya Serebryany , Florian Weimer , Linux ARM , Andrey Konovalov , Vincenzo Frascino , Dave Martin , Evgenii Stepanov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Dec 29, 2020 at 10:59:15PM -0800, Peter Collingbourne wrote: > The kernel does not use any keys besides IA so we don't need to > install IB/DA/DB/GA on kernel exit if we arrange to install them > on task switch instead, which we can expect to happen an order of > magnitude less often. > > Furthermore we can avoid installing the user IA in the case where the > user task has IA disabled and just leave the kernel IA installed. This > also lets us avoid needing to install IA on kernel entry. I've got to be honest, this makes me nervous in case there is a way for userspace to recover the kernel key even though EnIA is clear. Currently, EnIA doesn't affect XPAC* and PACGA instructions, and the architecture clearly expects us to be switching these things: | Note | Keys are not banked by Exception level. Arm expects software to switch the | keys between Exception levels, typically by swapping the values with zero | so that the current key values are not present in memo But then: > On an Apple M1 under a hypervisor, the overhead of kernel entry/exit > has been measured to be reduced by 15.6ns in the case where IA is > enabled, and 31.9ns in the case where IA is disabled. That's a good improvement, so this feels like its worth doing. I suppose all we can do is keep an eye on the architecture in case any future extensions mean the approach taken here is dangerous. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel