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=-11.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 77B04C64E7C for ; Wed, 2 Dec 2020 18:54:10 +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 0B9382173E for ; Wed, 2 Dec 2020 18:54:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B9382173E 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=3bYYg/cdeFsaRSDiNlK2X8pwB6zYV/DzxKCM161/4qA=; b=oxSjmMVcdz2YRgEqrcRBsw0vo hCHUKbKly9yNmQSQVWXLEb7/WsFZzj5UbzudQuU/kP9b14VUi/e+8ZbYPvHci0n35NDOXkECSM+OU V4KNelTYW8XanxIvcHEJzNh0FiZLUpPlvOLYH0Zq/ysRApw/4OZ8+NKgQTJH3nUahmBQso+oNBPL4 n0yEAgE1uTefo6PN9NO0gqlqXZhdyNO0CQt9yLS6u54+1a48Dk5xRTZtq3u3BhBd6x9oEaSkWBdIa YZCYtkOYzGbHeQgo+F7tM+Zk7JtUt7jWg65tXJ2twC2lBpAqh/jD0l+tOHnII9nvSbhNLM6yOZnKn J4Lzsdpmg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkXEh-0005DV-Uq; Wed, 02 Dec 2020 18:52:20 +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 1kkXDn-0004ny-QR for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2020 18:51:47 +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 EDAA8113E; Wed, 2 Dec 2020 10:51:18 -0800 (PST) Received: from [172.16.1.114] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 084433F575; Wed, 2 Dec 2020 10:51:17 -0800 (PST) Subject: Re: [PATCHv5 02/12] arm64: sdei: explicitly simulate PAN/UAO entry To: Mark Rutland References: <20201202131558.39270-1-mark.rutland@arm.com> <20201202131558.39270-3-mark.rutland@arm.com> From: James Morse Message-ID: <6621e562-675a-e265-b1c8-2ff830363162@arm.com> Date: Wed, 2 Dec 2020 18:51:11 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201202131558.39270-3-mark.rutland@arm.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201202_135124_052336_49F809FE X-CRM114-Status: GOOD ( 24.33 ) 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: catalin.marinas@arm.com, will@kernel.org, robin.murphy@arm.com, hch@lst.de, linux-arm-kernel@lists.infradead.org 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 Mark, On 02/12/2020 13:15, Mark Rutland wrote: > In preparation for removing addr_limit and set_fs() we must decouple the > SDEI PAN/UAO manipulation from the uaccess code, and explicitly > reinitialize these as required. > > SDEI enters the kernel with a non-architectural exception, and prior to > the most recent revision of the specification (ARM DEN 0054B), PSTATE > bits (e.g. PAN, UAO) are not manipulated in the same way as for > architectural exceptions. Notably, older versions of the spec can be > read ambiguously as to whether PSTATE bits are inherited unchanged from > the interrupted context or whether they are generated from scratch, with > TF-A doing the latter. > > We have three cases to consider: > > 1) The existing TF-A implementation of SDEI will clear PAN and clear UAO > (along with other bits in PSTATE) when delivering an SDEI exception. > > 2) In theory, implementations of SDEI prior to revision B could inherit > PAN and UAO (along with other bits in PSTATE) unchanged from the > interrupted context. However, in practice such implementations do not > exist. > > 3) Going forward, new implementations of SDEI must clear UAO, and > depending on SCTLR_ELx.SPAN must either inherit or set PAN. > > As we can ignore (2) we can assume that upon SDEI entry, UAO is always > clear, though PAN may be clear, inherited, or set per SCTLR_ELx.SPAN. > Therefore, we must explicitly initialize PAN, but do not need to do > anything for UAO. > > Considering what we need to do: > > * When set_fs() is removed, force_uaccess_begin() will have no HW > side-effects. As this only clears UAO, which we can assume has already > been cleared upon entry, this is not a problem. We do not need to add > code to manipulate UAOP explicitly. Typo? (Pretty sure UAOP isn't some other thing!) > * PAN may be cleared upon entry (in case 1 above), so where a kernel is > built to use PAN and this is supported by all CPUs, the kernel must > set PAN upon entry to ensure expected behaviour. > > * PAN may be inherited from the interrupted context (in case 3 above), > and so where a kernel is not built to use PAN or where PAN support is > not uniform across CPUs, the kernel must clear PAN to ensure expected > behaviour. > > This patch reworks the SDEI code accordingly, explicitly setting PAN to > the expected state in all cases. To cater for the cases where the kernel > does not use PAN or this is not uniformly supported by hardware we add a > new cpu_has_pan() helper which can be used regardless of whether the > kernel is built to use PAN. > > The existing system_uses_ttbr0_pan() is redefined in terms of > system_uses_hw_pan() both for clarity and as a minor optimization when > HW PAN is not selected. Still: Reviewed-by: James Morse Thanks, James _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel