Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1480931lqa; Mon, 29 Apr 2024 09:34:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUjivPfUOECdcRWMyVXcJLlX9oPVNw4Pqe6TJrKzJDay5pOZc+LK1EMy5bbqKBQ7EktQ/gF9B0d9SoGF/w9YPvDZKA8b4BOS8OIFBF1CA== X-Google-Smtp-Source: AGHT+IGWbsfDalNjv7wjPcv8/x7Nez9D6/2/6VQbOW2PdZUjg1U8VMxgrraeGyfA76PUC0xa+A7s X-Received: by 2002:a05:622a:115:b0:43a:cc86:568d with SMTP id u21-20020a05622a011500b0043acc86568dmr5212667qtw.23.1714408453333; Mon, 29 Apr 2024 09:34:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714408453; cv=pass; d=google.com; s=arc-20160816; b=TAa5Jd2XnnowahS/nUWp2UOx9ALUX9Un/q7KWDKWMriGSQrAlecL3cYk/NOb2ryJuX B9GaXsBEz8D554XycFGPvizBHRwCMKsUGKg7cGsDYtgLhKfbuN4GhvzbqQ6OBY7WXlbw CBT/BXSd+DFzWednRHnXChVUR/kXuYuwXFX6Rz0++dZTGFU5Lw2diS3iHaPE5R5z7e87 Qb8EmcPUZ1czKjgZv1ZLQaQzGygzjx7akVCUiHQlThM1NZadVqJAJE/45MTg4Os8Oaxr 5nwKUwI6r2sMXFZGz+CeA3vlXwuef3kpDqB6w1tK7TYNqgniVX92VBkK1sXkEMdPs0ul eyIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=EUsi88m7NZJm/HUD/VlNMr8gbhzBBzF9bk9U9sFEGeY=; fh=UVtjsaBbn01ImDVX1mAZD+I0m+voPm2rqO7vX9VHL6s=; b=ZGu0ogntJMx45re2dJ+zWem+v6eV/0RqciTuTaW2979sjGt7tSN8HzwebP0mKVMSGr Q9OQgkhPlhTXl/DRehjzddivv2lpucitHT1yRDAPECfKejMeBvZMpzhkHfyDvbQT2AP9 qn/7c4nd3x6itNCIiB+ibGbvfKIc2/4tMLyEFQOxwbzYv7xqL6PPvTr1ek5irB6NOJgV mGGqL+1rNJA278rGPMa+GyMRS7v1f9trmJQwEWl/f34jmESIS067h48G1b22wRp6ZyX2 m9ytb8b537VXeIk9L8DzdbZ1EmC2pMIwDAJUmtwAHfto8PA62BGcH38ySuUvzC59gbzI vbWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-162690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162690-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e17-20020ac85991000000b0043af50e9a04si2050162qte.240.2024.04.29.09.34.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 09:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-162690-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162690-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1128B1C21424 for ; Mon, 29 Apr 2024 16:34:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 715C985632; Mon, 29 Apr 2024 16:34:07 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F18EC1E4BE for ; Mon, 29 Apr 2024 16:34:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714408447; cv=none; b=CD75E/ikLs6cEScCy+GnOd7P9nF/oV1xiZxA9K9mO39tEN/uUJ08tttyUphFbAiGLckc5UfQSsPAseEF0KnDYtUkh9E5SUBYD2/YPaUjXL9shLh5D4jpe9v3mzldgHcVlDiLlVP5IVVHq25lCnPhga3KwrGFiQD/MwTiCDwvmWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714408447; c=relaxed/simple; bh=tp4gof1FQFgdvLtEsovWPTK7DBuxtwmZt9bB0FbK/eQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sX7KvWVLEW9J+PbcWachASGHBidz5762abWqNxQ+CloD6CPXfQe/4bIy1vnN62Mhu5NBnihmoRqAWYtoNZUGjTQgU1o/fzocdUffdHBJMyRl9hA3Q+MsWFOuwRd+Y6hJ399io5MWz6Cv6JgCzqKPofnuo3D1A9cRFzM2ckOhH7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D787C113CD; Mon, 29 Apr 2024 16:34:04 +0000 (UTC) Date: Mon, 29 Apr 2024 17:34:01 +0100 From: Catalin Marinas To: Ryan Roberts Cc: Will Deacon , Joey Gouly , Ard Biesheuvel , Mark Rutland , Anshuman Khandual , David Hildenbrand , Peter Xu , Mike Rapoport , Shivansh Vij , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] arm64/mm: Move PTE_INVALID to overlay PTE_NS Message-ID: References: <20240429140208.238056-1-ryan.roberts@arm.com> <20240429140208.238056-3-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240429140208.238056-3-ryan.roberts@arm.com> On Mon, Apr 29, 2024 at 03:02:06PM +0100, Ryan Roberts wrote: > PTE_INVALID was previously occupying bit 59, which when a PTE is valid > can either be IGNORED, PBHA[0] or AttrIndex[3], depending on the HW > configuration. In practice this is currently not a problem because > PTE_INVALID can only be 1 when PTE_VALID=0 and upstream Linux always > requires the bit set to 0 for a valid pte. > > However, if in future Linux wants to use the field (e.g. AttrIndex[3]) > then we could end up with confusion when PTE_INVALID comes along and > corrupts the field - we would ideally want to preserve it even for an > invalid (but present) pte. > > The other problem with bit 59 is that it prevents the offset field of a > swap entry within a swap pte from growing beyond 51 bits. By moving > PTE_INVALID to a low bit we can lay the swap pte out so that the > offset field could grow to 53 bits in future. > > So let's move PTE_INVALID to overlay PTE_NS (bit 5). PTE_NS is res0 for > SW outside of the secure state so Linux will never need to touch it. > > These are both marginal benefits, but make things a bit tidier in my > opinion. > > Signed-off-by: Ryan Roberts Reviewed-by: Catalin Marinas (subject to renaming PTE_INVALID to PTE_PRESENT_INVALID)