From patchwork Thu May 11 13:21:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13237921 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 4EADEC77B7F for ; Thu, 11 May 2023 13:21:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C07A06B007D; Thu, 11 May 2023 09:21:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB82E6B007E; Thu, 11 May 2023 09:21:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A7E0B6B0080; Thu, 11 May 2023 09:21:27 -0400 (EDT) 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 9630D6B007D for ; Thu, 11 May 2023 09:21:27 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B64B0160C7D for ; Thu, 11 May 2023 13:21:26 +0000 (UTC) X-FDA: 80778035772.23.5C4D872 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id F1444C001C for ; Thu, 11 May 2023 13:21:24 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.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=1683811285; 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=iJTCpwM3C7wRT8X7CgIcIwNcs7Jix29ply3bIuZCJeE=; b=kfqPzYFJxRkeWSE57by08dMTAgjGOSkCRRsDrTh82GiIFbYEDp0fs7C4AV52l+Odc5HYUV afnTtJ2p/aCBYqaIa5ZHpfiKyb4OGmRa8evDpzrIBUTvsCfsTRINJsIsl0U21lq60XNsfO qoTEgrIiRG5eQtrKhL9MlEDDeP5Zdhs= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.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=1683811285; a=rsa-sha256; cv=none; b=r2iAeNrGuN8WpHTazsZxvQee6hZkN+/c62MQ+PI8QiOIb8Pi39P/SwFvTEcqSuFLJt9hpR 5Z//JwaAsevQLnIAxmnZW850qtQxmfeTd7KjMupBTDoJO1Cr2mLD6QSYteWvicBaXPmkn0 9UlXt3+hDCEuES/bOKe5rg31dST2oI4= 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 BA32B165C; Thu, 11 May 2023 06:22:08 -0700 (PDT) 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 1F4EA3F5A1; Thu, 11 May 2023 06:21:23 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , SeongJae Park Cc: Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: [RESEND PATCH v1 1/5] mm: vmalloc must set pte via arch code Date: Thu, 11 May 2023 14:21:09 +0100 Message-Id: <20230511132113.80196-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230511132113.80196-1-ryan.roberts@arm.com> References: <20230511132113.80196-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Stat-Signature: o8ckieh7s1pt8dejizomaqc34gt7ogho X-Rspam-User: X-Rspamd-Queue-Id: F1444C001C X-Rspamd-Server: rspam07 X-HE-Tag: 1683811284-60566 X-HE-Meta: U2FsdGVkX18GCQMxVDfWX1L1v7MhgCqvGhRmGoasVt8Pg2gX6r9oVDEmhYsH+0GQ76z4adtqXI+YDgYoEmTGzg90/gRjTcsI6u7yCvnTQaDmtJc+k9B2XP7hBRoozbz01rbeLkAG7pOmJWERyem76BCvptw/nArZ0VobAW22mZMnCfwmxy7DXRXwx0wE2KVDxZBGatwHg44Wonht/j2QKw+tuPJjMy4lLA+XoPYnxSuMN8KREAPAi/4S8Oc270fTQYQ6M1XiplhakoY5ai1zF0CyYM0A5YnHurr57+QaTax3Gtc1EI9dd3U2/RdeJ/qKbC8apZEab2BC3WH354EXcuHA93AMjlHyQw4BDe9lI8wAIC6GSApeR5rOOmZPoq6MGnBTlKgIiwnBOBq9I8hrkUOWOBGFuEA7fotLkUkMokEGduLrSFM9XiA+zOUvr8Gmk5t27sGiwjc/nWOOSci0K2NklFbIjwnBLwq5Nq/Qnz6l74XoLhAoIEYy5rm1GQwLnFS+45J7pByH/rIVSx3zwIPQJnU3mJNIfGAqyNX8fxpyDSIrBNg5bQiDqHVSKDBtX3vcVdjVPYoD28fQMhSc4bGMsxmswJwPrFDxRvmv5zfMOo1N8vlIZ3ydxKim08rd/o8+/5iUYJEKJzNQB3eyKn8jwJtp94+DNAHfgS/YJFh7IZwXwazgPFGCKDZo2KWoX6yL3rvp6U7WBNlB/oq2ZF1d/haghBSpLHpB2O+9oCxRCI9IrVBCxKOE65+99bLm5i6e59q79Fc46AhZGtbb0NmdVZhEtGAQKLzhFxD341vjtU9DxrALpOy2nncxE2fqH1EBDQmb7ULDq1W/vYYa09rt/uXwqANwFdlBEudXTUgH1tD3svZUYUyHYqzFDydnU8EZBIC5rZrb8WQdeMTst2PfyvabNN2fjBNpW9Ejs7Pqm/YZ1Ne7BKb8r0tu00FHR8DFPD2CRwCmEJvnbIf n2mmkY2F wbPaRDC7yF1zUKmKtbvA46qnJGvqdjFUT2MnlEZW/Cr8+BNXN7mdlwGavygxbBjGvCih49XmIECit7t8xwNSn5dLJGZWj0w7ZKYUtiNgIIis/R15vVbNnmdv+jhJnsM23t2MBnGJNzryQTEdwnlZw1ck7WQ== 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: It is bad practice to directly set pte entries within a pte table. Instead all modifications must go through arch-provided helpers such as set_pte_at() to give the arch code visibility and allow it to validate (and potentially modify) the operation. Fixes: 3e9a9e256b1e ("mm: add a vmap_pfn function") Signed-off-by: Ryan Roberts Reviewed-by: Christoph Hellwig Acked-by: Lorenzo Stoakes --- mm/vmalloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 9683573f1225..d8d2fe797c55 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2899,10 +2899,13 @@ struct vmap_pfn_data { static int vmap_pfn_apply(pte_t *pte, unsigned long addr, void *private) { struct vmap_pfn_data *data = private; + pte_t ptent; if (WARN_ON_ONCE(pfn_valid(data->pfns[data->idx]))) return -EINVAL; - *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot)); + + ptent = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot)); + set_pte_at(&init_mm, addr, pte, ptent); return 0; }