From patchwork Fri Feb 2 08:07:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13542336 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D71E4C47258 for ; Fri, 2 Feb 2024 08:08:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6379F6B0071; Fri, 2 Feb 2024 03:08:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E8936B0072; Fri, 2 Feb 2024 03:08:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AF9D6B0074; Fri, 2 Feb 2024 03:08:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3A7136B0071 for ; Fri, 2 Feb 2024 03:08:23 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D20FEC0EA0 for ; Fri, 2 Feb 2024 08:08:22 +0000 (UTC) X-FDA: 81746136444.15.FEEA911 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf02.hostedemail.com (Postfix) with ESMTP id 2AB3F80023 for ; Fri, 2 Feb 2024 08:08:20 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706861301; a=rsa-sha256; cv=none; b=QWLyw+2M5R3pHTugch1jQFkde2V9Jx2awFYMQ8CP+evYbwpXsgPm9aGS1bRxjyhHT+zf3G aDTwOB14RWbn3DfUmNyUQM+GMPSyu/E8y91H+KIz04rwFThZFJAX/Kc+ty9W9C9JJNKkxS zqmTBMTt0JZ/kVczYfhfXGVOrrCwBa0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf02.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706861301; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dr+JmlJli2R+rlUtzp9TTxxnomA8MeE7u4eqm10nX+k=; b=8jb8/G6sPmP98CJji0+aFA4Rw8Q0SfBTZ9xRSFwgX8qeZWqz/0TIHF2gQeZ19TwB0CpK27 PaXX8Ve1CkjzbH7w/Kip2KJS+fBG1CNGxu9psAU9fdmvbTZhthf1vGLM2IdOLG3GgWxgJY BmnI39DPWnHtV5vNINZP2JIMhwDkPWY= 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 85221FEC; Fri, 2 Feb 2024 00:09:02 -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 99B143F5A1; Fri, 2 Feb 2024 00:08:16 -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 , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , 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 v5 01/25] mm: Clarify the spec for set_ptes() Date: Fri, 2 Feb 2024 08:07:32 +0000 Message-Id: <20240202080756.1453939-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240202080756.1453939-1-ryan.roberts@arm.com> References: <20240202080756.1453939-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 2AB3F80023 X-Stat-Signature: p135zfub1wsyrhupzffaby7efxn1wgfa X-Rspam-User: X-HE-Tag: 1706861300-537968 X-HE-Meta: U2FsdGVkX19z1mKVJ8FIZuUeFTge1DAusbfoH5bW1NbdHody0bPeqE3NB1UDDNs+QLGWgEtUV2LVi9ASzaXaBJ6JjWxWfMUlaZ9YvgZ5DA3E2WgdEN/c56CwJLdL5IL3QEWEVdmgsclA+tTAgWCIXereayXFgWktCNYaOlFCPEq3zlSpq2YvgVrmofnXqIGedAdA+oIdRaDhKXEKRjrjYCFJTY+sPY6KWfOKDWHQvW9qKkDNc4RXh4oLQK4IiB+g/EteVXgBVgD1iLNUI1LOu6ft4jcJ6H5SxilQWnZdFFTh3I3EGXVjDUyHb2zAHvymiZ6GyPlZGuKHs8FUM5CatIvSqV5JhHpUyP/7tmQvl1mXAIt3Mrwnlam+P/j5NxhBmD3iqmXyAmh+3oheCPTZFhpkvecdeQDlSTDGvFOvxkMbC+nK2Z/NV6eqRQxHyIQwxU4Q7z0HMfkBkbvN/ri3SnCraRRhQP5+wHu9H5s4A38oXKmZ77zVC9Ji5Mg/HcM7gnzYMsnL0zhAT0gWZM13qv9bwdQCbzyqts0G4Tibiwuqs6junmpCzP1m8q1RbqxfLHXdD/SfLc2wupQ5TM7FeR7MTBYk4BfVyiHU25yWlAS7tzq+K/c3eeZtnIWEVLJyyQE9Q4v/iYyzL9fQSz1bZR6PBGwqyDzmDtpvKaU+G/R8sVNzMPqxv2Noyuj1gReBX4+Mr06Jx5cRcq91gqXLCYKDZTmC2Yse4ZYkQlgCDZz2H1pNHMnjOp501HrgWnZPWwKcu9BjJpNNL61WW/sDhsnR9Co6jczG7pNcrdmAoVCNnyd2q5BmR/f8AnExDp6bF2nuTcPUOKhqnh54S1ayBNx+ylRrGT6XbkSmuf2xU9l4YTfhoT6OTr7vejjri+oRhW1L9ibCfsWen6yroEGLjM6qoV0T6Ktf+tvslWEtwQznDCCQO2FykLe3/5kyl72sKH3Cj1wkQ7o9sCYSMIw 5UnL7Uw3 yNPaMzOJn4R9aqryqOxe8/d5jueqcI0VPRLJJBqwTW48Ass+uvoawbLePLqCi4xvWQkUpNrZ53VOuZskhnSWjt5WAbBEd8b+TboeOBVMm9YvfnzsOgY2UQiYbVDGRcH6G6tPE0UWqE1gaBlrvRmlr9f5WqK16raLug+NHdZdoO4jCEvqVPYfkrTY9FbOYawtJOJTeo90fDuQb7W62wY+YKi7zs+MkCRXcCMEjZXOY78iONXiAMgyYLrKuQNiJIQRW3kUvSinefuZKag0vA5hyK2jACZPKfaElHE5CAlGgNYa6L0rT/L2Tfhs/8FA2DcjxHzES X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. Signed-off-by: Ryan Roberts Acked-by: David Hildenbrand --- include/linux/pgtable.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index f0feae7f89fb..5e7eaf8f2b97 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. *