From patchwork Thu May 11 12:58:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13237870 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 C5949C7EE23 for ; Thu, 11 May 2023 12:59:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 09F586B007D; Thu, 11 May 2023 08:59:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F1AD06B007E; Thu, 11 May 2023 08:59:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E09746B0080; Thu, 11 May 2023 08:59:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D33F56B007D for ; Thu, 11 May 2023 08:59:12 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A7A91160244 for ; Thu, 11 May 2023 12:59:12 +0000 (UTC) X-FDA: 80777979744.27.F37186E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf26.hostedemail.com (Postfix) with ESMTP id 0DDD114000D for ; Thu, 11 May 2023 12:59:09 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683809950; 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=WMthh2MmNYoWHSUFx6m/KjxMWz2qzKyAmiu+Y5xJg3M1DY4FITpfrFSzOMfGpz3fz4yiNE JkAU75Y1f9rCVE9MOpNStQryyxDLvhIZh4p4zEG39jnqIqgpmzXuNu+3WY4bfXoamFyWDN 2UbJJPYFKqeldx+GHIOwCubpMzMvVuc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683809950; a=rsa-sha256; cv=none; b=E2bKT3vUHAxc4veRWBScehtTDrdM0psZqOElICEW59RurlwHMWFKwN+pf/uVIT+NIrvxtd 1mvns1+hHXtr/WslwtYX5ERHt5he4RguF/QhnHPbQr+HSGvz/U6ZypvkTLDozY2YNNalTw utFmpshw7NuP4AURg2g8ceKEOdGgl78= 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 6908C165C; Thu, 11 May 2023 05:59:53 -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 C26083F5A1; Thu, 11 May 2023 05:59:07 -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: [PATCH v1 1/5] mm: vmalloc must set pte via arch code Date: Thu, 11 May 2023 13:58:44 +0100 Message-Id: <20230511125848.78621-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230511125848.78621-1-ryan.roberts@arm.com> References: <20230511125848.78621-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Stat-Signature: j7ymi59qug7aqbf4jj8c7azrzgcfoqyx X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0DDD114000D X-Rspam-User: X-HE-Tag: 1683809949-353723 X-HE-Meta: U2FsdGVkX1+YFuzIfiKPGU0D4RDEWQdifIVKsHLhK05u1QDpTdy26HeyEEF5LPDn3HQ/NR8i4AI/BLMKjlAn9xz3IIppUgL0TC8zmfxHBZtzcLMrQA48oP4/qSj6e9xMf4PY1YfBho2CjMYaezfCEtgfCtvdnBr76iznmTilPBtKOr0aDylHaVU0vo7HK2uYUD+wdZhC1f1riHozwboCwwZMvdZC7BCdb3mZudEyZCmNNu/zwqOECcq6tFJLY9OzpLV6tV6tBlo9CBqi8+hkzPEs/E7n/8aOfrtGMtiiCUtmMjryAYfI9v54DTFeXGa0lkQj0har2+7S0pJ7KDqWT6pIbWeS3N+mzB+/ZPq5ylUkKhRxecvgjC+GiQGb1QGpQcyHIi9cbzszWR8luioik7qsq140DKOzi2xBpwIpFliOBX5UyJmYqI4zL2ObHv30NJecJDjkUg/Yph1sEST2TqZGFW9nUbBBN9ZLwHYI2oNU/LO/V9dnWlBh0d2APwZUAb30JpHZOA2bwJm7FklttOcO5Jjj1nqRcchvJLX2KlvcGW0tsz6RPmjWwmGCY7aLJYO9oU3IimSQNS08jXlKih7ezRc/jA0tm7xIJcpTEJAxqHEAuXT9adHC7PJRuLWToYYvU0sWmb/w05AuKbIdxG0swzPK+g93e3RCsjL+xbL/I9YydHIw1cklbZKt51s6/bM1SY4aGafKOSedBPnyv9j60Oum12MED8qupQmpGAoLYKQh6lf00Tda+vx7Ya6y7PaHCxH9bj6y0O212AfsooleMO7eu8veyJDmHDiaiG1P8Sp3a26W/F+9xrGCzb4zPE8Ys7h2d41huveSj6sChXNUkwKm5U12I4n+Yp32opSnW0fn2nzrSO904B63NA4krm+pX4vKQYoDqJiPzD4Ij4f0QaQGCrIiWo5g/q0lykDIvcVQkKZvAPx60PNR3Ad9NFy80S8owMJ/20ixgem jJj5UPR4 dKT9XZ7UTflmCNsJGCKzoCkClSd5QYFwG2pji1J0eSboTtGjq54GIQeMPJrId54nptEEI+VVST1sIACPY8zskqRFkXaE3TR8J2WRdyRr4Jg8UVwqnwGAUf8u6bE46vEoD4QN2aem12Qbpqtz9NFf8pW2cQA== 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 --- mm/vmalloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; }