From patchwork Thu May 18 11:07:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13246483 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 94FEDC7EE23 for ; Thu, 18 May 2023 11:07:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27BD6900006; Thu, 18 May 2023 07:07:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 205F3900003; Thu, 18 May 2023 07:07:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A5CA900006; Thu, 18 May 2023 07:07:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id F02FB900003 for ; Thu, 18 May 2023 07:07:43 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CDD921C7337 for ; Thu, 18 May 2023 11:07:43 +0000 (UTC) X-FDA: 80803100406.08.9E82A37 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 14E0D1C0013 for ; Thu, 18 May 2023 11:07:40 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.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=1684408061; a=rsa-sha256; cv=none; b=IoYfljWVSISCLa8W0LdYY8a6HalbftUU84dvd/Xd2LtytmCPC0o9RxMdPAMZ1yCkn5td81 poJAqaeGXriwU3hUspgkw5E4bA0jFCsoOs/tFg7azw4HYBP4C4nvNGG8q8aGtKQ7XuCCcp iudfBs11ZfuHhGPjXzrKWnWC7FtS1go= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.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=1684408061; 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=NEW0x3p/iFg/JUm9c2rErOqCzOzNE0TGsXEgs7dca+s=; b=2y/7IC2BNCV+lwpKuGLnc3RzTQAvzUTFFOSY4Om4Vl6mVKdiN8kfZS1ItiT2ExvVbMUrHf xXXsTSLO1r1Y/pmBpOvzCc4G7uXBYUoSG04PnUfgRTn4xVsWu+0nKI0gkL+eEktzerbOKH gonLCaEqtKUm9rh7G16gs35eSisCVFc= 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 D08C52F4; Thu, 18 May 2023 04:08:24 -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 5D0033F793; Thu, 18 May 2023 04:07:38 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , SeongJae Park , Christoph Hellwig Cc: Ryan Roberts , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Lorenzo Stoakes , Uladzislau Rezki , Zi Yan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev, Christoph Hellwig Subject: [PATCH v2 1/5] mm: vmalloc must set pte via arch code Date: Thu, 18 May 2023 12:07:23 +0100 Message-Id: <20230518110727.2106156-2-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518110727.2106156-1-ryan.roberts@arm.com> References: <20230518110727.2106156-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 14E0D1C0013 X-Stat-Signature: u5aijqa54ms6tbd8aa4etz7tcmq8triw X-HE-Tag: 1684408060-391790 X-HE-Meta: U2FsdGVkX18VEK9TCDhMLg3JcwU5cILf1ezH0pr7VMWCYygEQSgqb+W7xVclc8D8iiXHpeWcSIkxD5r7kqRfn+mfCwWGOicWwlW51eQ6og00uy2QhLsme9vHTMJv/L8mZp2iKBUxhMa/IAzEng9h1MyqnW1MBxY04B91ySIecTinfY9HnlzYllsmYF7kK8VyzMThn98XmtWzJirt/0hauv8WzlXdBEwLpgoyN62Rb58rmZSeIL/SvGTM13E1zF6/zFzU80pYM8r8eH5bKIIFMXG9liXsE0XgmR1WLjL9c+ty1mgkvaq+zPgFCx96pI+W4sk7zQQiTEpewUGsDYzQrIHtR3KzFreEuWZW/8nGw9QfIzGtWyOl5Eemct8gXXpZNkby/f9t1dZ+/YpYdSazJMFHqzxjypcBRDKr+7Z8oGKjaOsfLdeFJL/mZfcU7PHXwoovYOSwegqBuq0NrdU0uuIjWp3e0KoWtVFSI4C1bTJV2cHIe+Jz9GZ6KPbj+IVV+DMsBDRVzbL+6w9qcTI5HWlkJaOXQAAvZs1itnw8B4GKHe8SICrnhweEceokq00dnRJct79pgs4EeUsglFoj/2qyrybOJL4ypvyNv2ijF2xmcIajDxJ8zFQuzdp1dHB55ZqVIzi99TCfQXkGxLk9HLi2sJ6JDwTTbf2XqXloqxKL/F/NUAn4Yto+rL5cTonQ4HuFyn/j+XkkaI9XTEvn2emuimU/Q2h7VNtTVrsNplPvlea1e1UCfhwUhvWhpVEzJNabi4NZTsg9fT9j/bpoGx9CuQ1IWth/xYzAn5PejFhXG49NfhKZP+hIEk6wD/m9N0Tpicnq245pm3HdWG7/2nDh5wGLgFmpxUKs9T7zDKjdVVxRXJrCVCFZVSxzFCc9sL6lpl02xxSkUDj/BbtUs+lIihVV4dXPjHxhdVEySGWTicJGmsTdlLABQ3Sj4U0MFmoVGnY9QhT0C8i4FUA 7y5xyyty g71BHp2us6ui8WzxJhAoK+GIvU4fHznavPNUYFxe9MZqoWamc4zicacXNJ6ayOkdDC/4Prrd+/HqkPOuZCqXHfUo6z5Qk3CZTsAPr9OPnO2kyMsxXx+4fXNJ8NBPf0gvOtgNmuxaMzNJFnNGbWCp1iOBlqEBVzug0Loa5KlCPRg6fRJbRyJzwDoQ0kVF6LUGcvdDrJRsfhbZXi5w= 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 check (and potentially modify) the operation. Fixes: 3e9a9e256b1e ("mm: add a vmap_pfn function") Signed-off-by: Ryan Roberts Reviewed-by: Zi Yan Acked-by: Lorenzo Stoakes Reviewed-by: Christoph Hellwig Reviewed-by: Uladzislau Rezki (Sony) Reviewed-by: Mike Rapoport (IBM) --- mm/vmalloc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 9683573f1225..48202ec5f79a 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2899,10 +2899,16 @@ struct vmap_pfn_data { static int vmap_pfn_apply(pte_t *pte, unsigned long addr, void *private) { struct vmap_pfn_data *data = private; + unsigned long pfn = data->pfns[data->idx]; + pte_t ptent; - if (WARN_ON_ONCE(pfn_valid(data->pfns[data->idx]))) + if (WARN_ON_ONCE(pfn_valid(pfn))) return -EINVAL; - *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot)); + + ptent = pte_mkspecial(pfn_pte(pfn, data->prot)); + set_pte_at(&init_mm, addr, pte, ptent); + + data->idx++; return 0; }