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.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 2526BC433DB for ; Fri, 12 Feb 2021 11:02:23 +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 CD05464E77 for ; Fri, 12 Feb 2021 11:02:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD05464E77 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wXQREEIYjQsiApbHr+V65j85AcuuZf/Q2wP6Jmz6+Wo=; b=IOCLG2uEg7h2hIy/9MkapzNcu /Y3kK7DtyA0/PoGVnziseT1nqj7CghF0/X2952e+b1RkjIk09nZkTipRLFy0JQQBodjJvN1Ki0SI3 vOWOhbvPiCSQVgbY3RxVkRAMVGzgpycPkpAxyI8zjqoymlX2lMbGLdQk2Lys5Rg+x3m4OdXUDDx1V f55iz5vZBh3LEzjETZk+WCdV3azxmRfPEzKbAGgLQ16iW6SgGw+u5qeHHMmaZnBLTozXvMZe7S7ha 610jLUTjv6IWRMzIWm6XwRENJIbQFhDkO+SV52xnCNtDaEb91ilzDhK68VKj03NIl/zcVDd3+0MPX CRIftJhUQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lAWCI-0005cD-HE; Fri, 12 Feb 2021 11:01:14 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lAWCG-0005bU-E6 for linux-arm-kernel@lists.infradead.org; Fri, 12 Feb 2021 11:01:13 +0000 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 366CD113E; Fri, 12 Feb 2021 03:01:10 -0800 (PST) Received: from [192.168.0.14] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2D54B3F719; Fri, 12 Feb 2021 03:01:08 -0800 (PST) Subject: Re: [PATCH v6 3/3] arm64: pac: Optimize kernel entry/exit key installation code paths To: Peter Collingbourne , Will Deacon References: <20210126130947.GD29702@willie-the-truck> From: James Morse Message-ID: Date: Fri, 12 Feb 2021 11:01:06 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210212_060112_592249_82CFD716 X-CRM114-Status: GOOD ( 20.56 ) 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 , Andrey Konovalov , Kostya Serebryany , Florian Weimer , Evgenii Stepanov , Linux API , Vincenzo Frascino , Dave Martin , Linux ARM 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 Hi Peter, On 12/02/2021 05:01, Peter Collingbourne wrote: > On Tue, Jan 26, 2021 at 5:09 AM Will Deacon wrote: >> >> 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 > For GA I would expect it to be controlled by a hypothetical EnGA, not > by EnIA (and I'm a bit surprised that there isn't an EnGA; PACGA is undefined if the CPU doesn't implement PAC, whereas PACIASP is a NOP if the CPU doesn't implement PAC. I think the reason from the SCTLR_ELx controls is to make unaware systems transform the instructions that were hints back into hints. (e.g. the AddPACIA psuedo code). This is needed on mismatched big-little systems, otherwise processes can't be migrated between them. For the non-hint instructions, user-space needs to test the hwcap/id-register-emulation to know it can use these instructions, and the compiler shouldn't output them unconditionally. > doesn't it > mean that a userspace program running under an unaware kernel or > hypervisor may sign things using the GA from potentially another > hypervisor guest?) The hypervisor controls all this with HCR_EL2.API, which also traps PACGA et al. For the hypervisor its all or nothing. If the hypervisor is emulating a machine without PAC, it can emulate an undefined exception regardless of whether the CPU supports PAC or not. Does this match your reading? Thanks, James _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel