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=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 E4055C433B4 for ; Fri, 30 Apr 2021 15:06:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 6BE02613E1 for ; Fri, 30 Apr 2021 15:06:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BE02613E1 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc: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=Ki73Uz51K4paJcF/kThZNEGXa+G60qycWvr36SPw5xM=; b=Uaxy12yKHcimUdsmz5Sj4Bd71 fCywqWf3Ln3FRP9u9D2J12hKMh7B9X7IVfRE0ldc2g+afyVf+m2i3eEOx4Lm5g7zWFSA/JPLNxSdl V/6jevbOoS7niZDg5zfYk/ZoscY531zXwdPi6v6Bg8H0IwHYW2PVF1+cdtEw+BQ/k4w9aUSUbUq4s fYKCrXmiFmLo2mCBxz42iUmtUQVSylIZKvDwdjhxQ1YaLMv9A+A6Y1J68euLRoI3WDu4sL4RUTXfr q94B2sf5sjlD72VfIcJcFVtam9yIl90snzAy3pg32LTnMyskTORICeYkerl2kWER0mDRtvFp5b9Ja 9kQU5hv0Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lcUhN-0080kC-JV; Fri, 30 Apr 2021 15:04:57 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lcUhJ-0080jl-G8 for linux-arm-kernel@desiato.infradead.org; Fri, 30 Apr 2021 15:04:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HVZYIkKqX9Kq7DFQX63/BM3dyNtpDb4zBVlGak7aYxM=; b=KN3GMl8Rhs63fvR8EBQlkQcjtc yYpwmKy+NNvmQHlC/Rs+vLRKfa9aywMzUL9yi5n2+XNpT+aXIfaV1nGBqu0SfLzd7hL256nu9b4f3 BwfMkcGKnfx5ZIEuWXYNclD74Amjd4Zsmc0Px6+Gjv8bACQK8uWkb73KMjeBV++b9boVobb/tK2sL Tzw4RcYrk+Sc6IiBQnLbfWQdCFa2zp0WW+jxuOxcFs9SaNQrmKIi0haRNiMT/kybRXoFv8MxsV+2Q madCNm44FMHQn8SndyHz66JO7pLz3QQ7d+MYFbPOtWzOqUQWRsg052vo/LwUsXsrPQfbdpvgGM/IM bqWa3MYQ==; Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lcUhG-001TC3-71 for linux-arm-kernel@lists.infradead.org; Fri, 30 Apr 2021 15:04:52 +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 8F1ED1063; Fri, 30 Apr 2021 08:04:45 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.5.252]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 927973F70D; Fri, 30 Apr 2021 08:04:43 -0700 (PDT) Date: Fri, 30 Apr 2021 16:04:38 +0100 From: Mark Rutland To: Derrick McKee Cc: Yianni Giannaris , Linux ARM , suzuki.poulose@arm.com, Catalin Marinas , james.morse@arm.com, amit.kachhap@arm.com, will@kernel.org Subject: Re: PAC key changes when kernel code is preempted Message-ID: <20210430150438.GA57205@C02TD0UTHF1T.local> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210430_080450_344237_DE1D466D X-CRM114-Status: GOOD ( 18.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Fri, Apr 30, 2021 at 10:40:04AM -0400, Derrick McKee wrote: > Hi, > > I am noticing that when kernel code is preempted, PAC keys seem to > change when resuming execution. For instance, when I read > APDAKeyHi_EL1 and APDAKeyLo_EL1, sleep, and read them again, the > values are different. Is this the intended behavior? This is expected; kernel-side we only use the IA keys (which should stay the same from a kernel task's PoV), and the other keys (IB, DA, DB, GA) are not supposed to be used within the kernel. Up to and including v5.12, the other keys are switched at entry to/from userspace, and so may change from the PoV of a kernel thread across preemption. With the patches merged for v5.13, the other keys will be switched with the task, but userspace can reset these at any time, and they are still not supposed to be used within the kernel. > If so, how can I ensure that the keys do not change? The different > keys are causing PAC authentication to fail on pointers signed using > the stale key. Thanks. I take it this is non-mainline code? We shouldn't be using the other keys today. If you want to use the other keys, you'll need to alter the context-switch and userspace entry/exit logic to have kernel versions of the other keys, and switch them at the same points we switch the IA keys. For reference, see commit: b90e483938ce387c ("arm64: pac: Optimize kernel entry/exit key installation code paths") Thank, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel