From patchwork Wed Aug 14 15:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13763656 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 B9A3DC52D7B for ; Wed, 14 Aug 2024 15:44:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB05A6B007B; Wed, 14 Aug 2024 11:44:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D49DA6B008C; Wed, 14 Aug 2024 11:44:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 938D16B007B; Wed, 14 Aug 2024 11:44:38 -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 5169B6B0088 for ; Wed, 14 Aug 2024 11:44:38 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EA87440C33 for ; Wed, 14 Aug 2024 15:44:37 +0000 (UTC) X-FDA: 82451273394.21.789A5A7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id AC3FBC000B for ; Wed, 14 Aug 2024 15:44:35 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dIsNq+CQ; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723650240; 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:dkim-signature; bh=33UCl0Co8i3PNxF7TNO2g0opNXJUnYgo70pV3HV1tcI=; b=tfrd+/olryHVDrPhbsrSg7dJzgszjQzz9CWKCedooUmEyV/mlCuPGq9S/Wasgxl7e1G2QQ 7zoN2CCyJxviRqXlz3Cfl+bVvhGoYGWFKrdn3VA0NyyyXPN76P+xfnFhDnA3b1sZof+95E RnDfyTh1rWPsLsK826qjyrhwkW41hvs= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dIsNq+CQ; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723650240; a=rsa-sha256; cv=none; b=aMC9i0wdQ0wLRyjGJfYfQcfIEQfagtMVmf1f/tATRypfoo2aCNNmHX0jqluC7AZCQxdtZQ EJTJqSvzxRSd788IPUfPZNxGWIobP2AEydG9/Q1fPDCdiMZE3Pm84R9nrTffWeSRcbt/Xr olXBhhxLPiZtDQuFe1uVlyGfPPEg+J4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=33UCl0Co8i3PNxF7TNO2g0opNXJUnYgo70pV3HV1tcI=; b=dIsNq+CQflIlXtOXmQTqb8pXRY oZqzwxIWI5YvxpP4/j2cyaUs/F+SRrHagsggKoL0vGKsexxHrjHORIlOlRnWyWreUtLEU384QLk7G 9xy/Kq44WGvy3tBpQggevSL4bfHSCSHK+R+SUs/YM7Nq45lxf5DNRTk/qNcXE+6Z4ZtOpYtr7rcUD /NZqx1otFZnfV8ukq8ni6hn+tG1lztLatVpBF+aeWCIRciarfr/XjIMiMWU7tm+LCY2pCLlsCstZF 6gTHeQMb7xlQmbogxzWyxViBZBTk2F5stHLfKgnMSLhKKvWud5/XOuKxAevKTe+B0jdBaHDVIDD/c JGh0gQFA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1seGAs-00000000gHM-11f1; Wed, 14 Aug 2024 15:44:34 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org, linux-arch@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" , linux-s390@vger.kernel.org, linux-um@lists.infradead.org, x86@kernel.org Subject: [PATCH 3/5] um: Remove custom definition of mk_pte() Date: Wed, 14 Aug 2024 16:44:23 +0100 Message-ID: <20240814154427.162475-4-willy@infradead.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240814154427.162475-1-willy@infradead.org> References: <20240814154427.162475-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: AC3FBC000B X-Stat-Signature: t7npis811yze1xpa3eccugr97e749pja X-HE-Tag: 1723650275-168382 X-HE-Meta: U2FsdGVkX19giCp1E/QtQN39M+ZGUECLgk4YD3n9yyHzA+qAVjPDTnpTtUgSeE+uuS53fpJSwCDgnLbn3i6j2yfCkJAZ7CVdABim676CdBXOdyyQudLrIhw9GsIazp0gK8LQfaEKsEdlSiqRv2mW/+163O7P+i1Ch+mY+YEcF5aCyka1OgTGUq7uxwhpwnMPS4i2pZAtYhMzCzqEq0gtEKlUH5y4zabCamgkD92iJ/5qm01xsHXTveg+e28d1dfcGLqc+BmZ/vQ0GuwMzieP3NiROY8aUiiOp9eSxux9CWi/zxC+0yUKRU5vPM4PtiX1Lq2HiQrJPP1/b1Ctr6dWwT6j1hxGWODIs/ydoUDHuFKdhMENDK3J+vlo6yr0dGJmQ55WgGDnm9F8nmSwV5Mwu/r04irk6WZFQ4dKPmq1X436R0L6Dcf0Vd5KkTEIgSMkXZj+/TmlSgm0e0DDog4PPjyrDAucO2QPmurswT33nl9PDTUxlCP0bMihRbNINbMHG8FnrERhMsiF2ZmiteEjF2jItUaCRTrNB3/5n284ZBX3+xcQ0Yj5vxxUvO4kVC+FzSYmBUfVhk6QJzpsJsxrCk5TZfpL3U1M24fdUiIS8CouvXbb6l9hrp1ILsxCNqNFatNw+GTZNUTr4X4UcDUazFXaDMwgCsCXkdu8ZNO+yP7WMs4jz8VfuhBdWAhOr5HB/eRSQz8qP88HZ0TmbjPaZqIEXXoGkD4utaunV/cjQ0uZNhE7VXxOx0p4CgmAzcb0RUHFrv+ByY5yPBpaX/axi7TJCygHIUbIJo7j8LhT2U6x61qekZdlW79seX9rQIht1jGOhRwgGHMg9K9gH7E3cPIUHNFQH7fLsX3bBiYxZ6evO05OfMVtAWjqHkhqVJxxdaX+uct+hTZ80wrGvwAxN6BtUHAMpzbvuO5nlmIy2PQScCyOSIXQEj9UZrguhBA+ZPcFWxRYtVNPAb5AXsl 4qBEFqS0 qLYr8Nb/79oq3Isjh9kOF8cuFYabeydeJSyaslVAUFAP8TPlM7oBcEqSJXW1Wt8sJ/Pa1LJ37skWW85XKHjxf9cLVFLkTF4wEHYdWRk6iMHMJeaRy2j4shbfjis/eCd1wiTZQhBwLD5Qm5peB6jBeizvuNmSw3u4zHMqcueS/qEpz47+kWYvJBc6IJd5RfZzOf86PadSmv4lT+J0WJfys7UYzPquYiAKN02tq4qvnQSNbKcBQEtvRnJbspk/bjf12zQna2cDYvwndV4g= 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: Move the pfn_pte() definitions from the 2level and 3level files to the generic pgtable.h, move the setting of newprot and newpage bits into pfn_pte() and delete the custom definition of mk_pte() so that we use the central definition. Signed-off-by: Matthew Wilcox (Oracle) --- arch/um/include/asm/pgtable-2level.h | 1 - arch/um/include/asm/pgtable-3level.h | 9 --------- arch/um/include/asm/pgtable.h | 17 ++++++++++------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/arch/um/include/asm/pgtable-2level.h b/arch/um/include/asm/pgtable-2level.h index 8256ecc5b919..2be7ba470abb 100644 --- a/arch/um/include/asm/pgtable-2level.h +++ b/arch/um/include/asm/pgtable-2level.h @@ -37,7 +37,6 @@ static inline void pgd_mkuptodate(pgd_t pgd) { } #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval)) #define pte_pfn(x) phys_to_pfn(pte_val(x)) -#define pfn_pte(pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot)) #define pfn_pmd(pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot)) #endif diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h index 8a5032ec231f..20870be83cfa 100644 --- a/arch/um/include/asm/pgtable-3level.h +++ b/arch/um/include/asm/pgtable-3level.h @@ -82,15 +82,6 @@ static inline unsigned long pte_pfn(pte_t pte) return phys_to_pfn(pte_val(pte)); } -static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) -{ - pte_t pte; - phys_t phys = pfn_to_phys(page_nr); - - pte_set_val(pte, phys, pgprot); - return pte; -} - static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) { return __pmd((page_nr << PAGE_SHIFT) | pgprot_val(pgprot)); diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h index 5bb397b65efb..6ecc4c4ffeab 100644 --- a/arch/um/include/asm/pgtable.h +++ b/arch/um/include/asm/pgtable.h @@ -292,13 +292,16 @@ static inline int pte_same(pte_t pte_a, pte_t pte_b) #define page_to_phys(page) pfn_to_phys(page_to_pfn(page)) #define virt_to_page(addr) __virt_to_page((const unsigned long) addr) -#define mk_pte(page, pgprot) \ - ({ pte_t pte; \ - \ - pte_set_val(pte, page_to_phys(page), (pgprot)); \ - if (pte_present(pte)) \ - pte_mknewprot(pte_mknewpage(pte)); \ - pte;}) +static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot) +{ + pte_t pte; + + pte_set_val(pte, pfn * PAGE_SIZE, pgprot); + if (pte_present(pte)) + pte_mknewprot(pte_mknewpage(pte)); + + return pte; +} static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) {