From patchwork Thu Feb 15 10:31:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 201378 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp319632dyb; Thu, 15 Feb 2024 03:08:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVcnHjJYCplfjqDUwSDSaJM0LmEdn8f+BkVKp83CGxfxpm0Oes7YaXu/x0YEczjis/HZx9R+dDx4D3PZK7SgylupSD3Pw== X-Google-Smtp-Source: AGHT+IFbEettBy5rv0hN/DRKaOwCIrwNkuBBIpFErdnrCQ9iXr8/UfMTN9tqK5j+5IhgzijNDktD X-Received: by 2002:a05:6a20:d043:b0:199:7628:286d with SMTP id hv3-20020a056a20d04300b001997628286dmr5726330pzb.30.1707995297069; Thu, 15 Feb 2024 03:08:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707995297; cv=pass; d=google.com; s=arc-20160816; b=trYYvyWvkXnouB6hl4ONfFSXknyoJxhLVUZf1I6X3ILcWe6rsnCP8Og7OTO0Fh7PXL laG+k6DTqHHe5whLcwE9ZxwHyQqz5HjXXnGYomvtdm5+5wJ2sgGBXXGqsjRl7LkACPQ2 LH/yao7VXyDhKpdNMYrJ6OUggyJVXNzafj/4vJnhwBmj4lJha0MKeBMDmbBI5s37WuoJ S+7r+1UoL8aGdzEC1Th9dGdSQZQtouFuvHBTO/gH68k/jqcMW2he/TYaIp3aduqAEpIJ lEAkIMmC9LnZ7a1lurIlj9UXqo2pIxE9O/lA3h0T06RCfl8lKqK6Tbb2BWi3rL+91LZv CCJw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=f6gb/nfiijie/R90uJlYvW3OmZJqXxR5XmD97JtGnxc=; fh=Heagowc1O8zVDXTyU76nJjOwDjz9r3Gi+0zmhF4ZELQ=; b=TVwwbVuiFUMM0m5r8zLbaJd0OoLg6BoINQBSjhR2SbsDYF5oxBO8s55Vkj2/A/fyTa nepfhyz3OT3DW842kPQ/mgaAE6zYb0ciE6jHT/ZqxRJUHFYnNsfILGXu9Y8g2NwpRCCZ zJbeUIU2WEY2+FcX1P3HyZuealmF5DRhYo4DThfLJiUscW7fBBsdV7LzdomL81l+SrfC NnkAamSi/l1OWHuzz7PeLVf9By0hsfWWzg2RJ4vAJsma05T5HcdICcbjvn0g6fQNrRtI gieJ1aJzzP7FcKa4E0iB5scMn7Z4Ma/rfHhp4oGC41sH4OvdtWQghmlqgARAo6s4jy2u rl8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-66635-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66635-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b11-20020a6567cb000000b005cdf9923679si906084pgs.727.2024.02.15.03.08.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 03:08:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66635-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-66635-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66635-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4FD51B25536 for ; Thu, 15 Feb 2024 10:33:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF6E712AAFF; Thu, 15 Feb 2024 10:32:28 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3808A129A75 for ; Thu, 15 Feb 2024 10:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993147; cv=none; b=l8EbcQD1oWPHXMUPIM4YLMV0QjuxrF/Ep8zmzpyu7wc1NJ+Y3RdcXu23+yHiEBZZwt6ea8oeADtkFQ8rChZtTyVhskn5Nqnc+3U/9Q+HSnVaPZLi2BY4/ZB8qFzbIoA4TBrxO4k5gs8Y1bsZvInXySKUVAZCvXLNI23i5iE2zfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993147; c=relaxed/simple; bh=s0t/hAahHKineLmcpNEMFwM7j20fOnG/CtX3vPG0uZE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MIsPXkSGwx5e3XbPRpAfCzskVkiuUbR75zlONVKBriroigK9RITjzk4KJiatJ03nLr7xUDXNHHxi7jJ5SaegVXYny1ACF1N4gSlLWeNSMRQ3kc6YJaZYTy1i2JqB9pr8M3yQ9C5P3MqLYsPXiCXm0/BVUtQeIRHeaEN3H7aZlMg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 40DFDDA7; Thu, 15 Feb 2024 02:33:04 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3722C3F7B4; Thu, 15 Feb 2024 02:32:20 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 01/18] mm: Clarify the spec for set_ptes() Date: Thu, 15 Feb 2024 10:31:48 +0000 Message-Id: <20240215103205.2607016-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240215103205.2607016-1-ryan.roberts@arm.com> References: <20240215103205.2607016-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790962876740109626 X-GMAIL-MSGID: 1790962876740109626 set_ptes() spec implies that it can only be used to set a present pte because it interprets the PFN field to increment it. However, set_pte_at() has been implemented on top of set_ptes() since set_ptes() was introduced, and set_pte_at() allows setting a pte to a not-present state. So clarify the spec to state that when nr==1, new state of pte may be present or not present. When nr>1, new state of all ptes must be present. While we are at it, tighten the spec to set requirements around the initial state of ptes; when nr==1 it may be either present or not-present. But when nr>1 all ptes must initially be not-present. All set_ptes() callsites already conform to this requirement. Stating it explicitly is useful because it allows for a simplification to the upcoming arm64 contpte implementation. Acked-by: David Hildenbrand Signed-off-by: Ryan Roberts --- include/linux/pgtable.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 49ab1f73b5c2..231370e1b80f 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -229,6 +229,10 @@ static inline pte_t pte_next_pfn(pte_t pte) * @pte: Page table entry for the first page. * @nr: Number of pages to map. * + * When nr==1, initial state of pte may be present or not present, and new state + * may be present or not present. When nr>1, initial state of all ptes must be + * not present, and new state must be present. + * * May be overridden by the architecture, or the architecture can define * set_pte() and PFN_PTE_SHIFT. *