From patchwork Tue Aug 21 06:21:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10571063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 634B7921 for ; Tue, 21 Aug 2018 06:34:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE0A29A0E for ; Tue, 21 Aug 2018 06:34:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40C8429A16; Tue, 21 Aug 2018 06:34:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9724729A0E for ; Tue, 21 Aug 2018 06:34:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B35606B1D51; Tue, 21 Aug 2018 02:34:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AE4E66B1D52; Tue, 21 Aug 2018 02:34:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AE816B1D53; Tue, 21 Aug 2018 02:34:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 5CFA06B1D51 for ; Tue, 21 Aug 2018 02:34:38 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id 186-v6so586406pgc.12 for ; Mon, 20 Aug 2018 23:34:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:user-agent :mime-version; bh=t/965/MYzWrSpK8t5qMC8h3uK7gel0YahkjXSFSUb6Q=; b=LmKoye4bqJ4FXYyZqyP97zdbZ/RTwdDJeotNuAY9h8yEWyQDNVDqg1FDRxNaq2iCdz gOoT+Z+YKRBzUCiW4adiGeOHdHnUyUTTapSmOezzTPKm7C0Ek1q2/fgbDO+z0rlqxFNW +5ER25DNAqFWPJEVsUtiAqy6/xEuR2mICKqpMGBoPcu2Uu72oWdz9CDYzh+NlOe5ClBT CIfxGg8ltyhkUgFe9Uvay7TLMIc8oJBZfPFdK5Jr+39pPLA/2wSKShkHhls8uj5YLpVa crQBm8B6kBRmTvIUGjk547Vtaoy7d+MC14oCPntWKPJdy/L2mHjIb2/00MmOZnLsGk+v Xwnw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Gm-Message-State: AOUpUlHtgM5ns5vPJerq5OCeTqBNsPIcm0A7H+hX2rPvE8ZwJ/dlZsQ9 za8pRa9rxzZ/xYC9NQ9JiHP9h0a9C9PBLVF5LT3RqsyAH9/PeGeUS/+fcBSlEaiUPJMMoNp9zFA RkaBE6jKmwffdajoeAR4Ld1u3PpJh8jWogiTu7b7aFNTIKYmLAXTo9n1g1BHKtW7qXg== X-Received: by 2002:a17:902:724c:: with SMTP id c12-v6mr47871081pll.326.1534833278055; Mon, 20 Aug 2018 23:34:38 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwlBvO3l2vBBthxQd8HY8mU+Oo8iVJrBZH05Atsm/uDjVFgb87JRwYpGTeq3huQy7QOYDg8 X-Received: by 2002:a17:902:724c:: with SMTP id c12-v6mr47871038pll.326.1534833277266; Mon, 20 Aug 2018 23:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534833277; cv=none; d=google.com; s=arc-20160816; b=BRnjIYb0FcDsVbwg+9wzmzXL6O1xQp+bLfi6d6MNswlByN+lcm7ZgN6OJ6AuVBU6Lh 4tTJxK50NmfqsYfK0rXjS4GYpojsZM0M93p3TWxHZuWcA+X8pdsYQSK8WBIfnX8zVVhR OMgPWgakFfl114TDaoS6NAGsWa0bFOA/Y+HjoPNPFqqgztUtab0yIpjfZMqkonmME8yz rizsQQv4364cTBZ4cDI1dn+X4NjkllkkGcxDHvtTH1DI1X2KrkYUYGC37wabJ+4xqZGU CKOkPUZZryUJ9dRj7sKlMo/1G+v7MeOjWDJCjHeZL8V+T1Lvt6qCOZI23p60n+taDj93 bHyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=t/965/MYzWrSpK8t5qMC8h3uK7gel0YahkjXSFSUb6Q=; b=EfbQGM2qPqObDZn0aPwxG5eLTD+Q41a7tfXdNo8fQzF1NNX+wLu2zCzlpko18mCqsF Kmk7N9dODHA1vlBK9gwi4khSpatpN8fX+1FHmummA3fIIy0ijV5Mi6m/d17HTT9bw7au Iob5laVoqWhCN5Pn2yUbdzA3RkQsp/mcBkxuyPuRWgg++I3nuLT+HtLmcWJHXUxatinp sZcglIQ9aZRtYj2n0ygzcZy1IrydAw5rlOInF7HMqRqS0AMEOCHxzzZA4ayH23jEvO84 az0KnBSC6aISxFC7/yu5iLhxRSilW6zU0WcORGgKgGO5it2xLL1l9dqQhpyWx1XSRU7P PP+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org. [140.211.169.12]) by mx.google.com with ESMTPS id cb14-v6si4271433plb.178.2018.08.20.23.34.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 23:34:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) client-ip=140.211.169.12; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gregkh@linuxfoundation.org designates 140.211.169.12 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Received: from localhost (5355525A.cm-6-6b.dynamic.ziggo.nl [83.85.82.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3B47A9D7; Tue, 21 Aug 2018 06:34:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Lendacky , Thomas Gleixner , Borislav Petkov , Alexander Potapenko , Andrey Ryabinin , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Brijesh Singh , Dave Young , Dmitry Vyukov , Jonathan Corbet , Konrad Rzeszutek Wilk , Larry Woodman , Linus Torvalds , Matt Fleming , "Michael S. Tsirkin" , Paolo Bonzini , Peter Zijlstra , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Rik van Riel , Toshimitsu Kani , kasan-dev@googlegroups.com, kvm@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-efi@vger.kernel.org, linux-mm@kvack.org, Ingo Molnar , Andi Kleen Subject: [PATCH 4.4 20/22] x86/mm: Simplify p[g4um]d_page() macros Date: Tue, 21 Aug 2018 08:21:46 +0200 Message-Id: <20180821055140.512503507@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180821055139.462620042@linuxfoundation.org> References: <20180821055139.462620042@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tom Lendacky commit fd7e315988b784509ba3f1b42f539bd0b1fca9bb upstream. Create a pgd_pfn() macro similar to the p[4um]d_pfn() macros and then use the p[g4um]d_pfn() macros in the p[g4um]d_page() macros instead of duplicating the code. Signed-off-by: Tom Lendacky Reviewed-by: Thomas Gleixner Reviewed-by: Borislav Petkov Cc: Alexander Potapenko Cc: Andrey Ryabinin Cc: Andy Lutomirski Cc: Arnd Bergmann Cc: Borislav Petkov Cc: Brijesh Singh Cc: Dave Young Cc: Dmitry Vyukov Cc: Jonathan Corbet Cc: Konrad Rzeszutek Wilk Cc: Larry Woodman Cc: Linus Torvalds Cc: Matt Fleming Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Peter Zijlstra Cc: Radim Krčmář Cc: Rik van Riel Cc: Toshimitsu Kani Cc: kasan-dev@googlegroups.com Cc: kvm@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-efi@vger.kernel.org Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/e61eb533a6d0aac941db2723d8aa63ef6b882dee.1500319216.git.thomas.lendacky@amd.com Signed-off-by: Ingo Molnar [Backported to 4.9 stable by AK, suggested by Michael Hocko] Signed-off-by: Andi Kleen Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/pgtable.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -173,6 +173,11 @@ static inline unsigned long pud_pfn(pud_ return (pfn & pud_pfn_mask(pud)) >> PAGE_SHIFT; } +static inline unsigned long pgd_pfn(pgd_t pgd) +{ + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT; +} + #define pte_page(pte) pfn_to_page(pte_pfn(pte)) static inline int pmd_large(pmd_t pte) @@ -578,8 +583,7 @@ static inline unsigned long pmd_page_vad * Currently stuck as a macro due to indirect forward reference to * linux/mmzone.h's __section_mem_map_addr() definition: */ -#define pmd_page(pmd) \ - pfn_to_page((pmd_val(pmd) & pmd_pfn_mask(pmd)) >> PAGE_SHIFT) +#define pmd_page(pmd) pfn_to_page(pmd_pfn(pmd)) /* * the pmd page can be thought of an array like this: pmd_t[PTRS_PER_PMD] @@ -647,8 +651,7 @@ static inline unsigned long pud_page_vad * Currently stuck as a macro due to indirect forward reference to * linux/mmzone.h's __section_mem_map_addr() definition: */ -#define pud_page(pud) \ - pfn_to_page((pud_val(pud) & pud_pfn_mask(pud)) >> PAGE_SHIFT) +#define pud_page(pud) pfn_to_page(pud_pfn(pud)) /* Find an entry in the second-level page table.. */ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address) @@ -688,7 +691,7 @@ static inline unsigned long pgd_page_vad * Currently stuck as a macro due to indirect forward reference to * linux/mmzone.h's __section_mem_map_addr() definition: */ -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT) +#define pgd_page(pgd) pfn_to_page(pgd_pfn(pgd)) /* to find an entry in a page-table-directory. */ static inline unsigned long pud_index(unsigned long address)