From patchwork Tue Aug 21 06:21:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 10571061 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 A1A99921 for ; Tue, 21 Aug 2018 06:33:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9174A29A0E for ; Tue, 21 Aug 2018 06:33:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8370829A16; Tue, 21 Aug 2018 06:33:27 +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 093B229A0E for ; Tue, 21 Aug 2018 06:33:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D59576B1D4E; Tue, 21 Aug 2018 02:33:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D09726B1D4F; Tue, 21 Aug 2018 02:33:24 -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 BF8536B1D50; Tue, 21 Aug 2018 02:33:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 800BD6B1D4E for ; Tue, 21 Aug 2018 02:33:24 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id q21-v6so9182118pff.21 for ; Mon, 20 Aug 2018 23:33:24 -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=Wc75zFlQomkuMLIZO75F4E2ev+RWmnhiUJZbC9XfrhQ=; b=cT2WZdMpjzL6XReFpd3TMa3HnV3058vjbMpW4Ahlwhf1PugL1Lewv7ubb7GkT/S52S qsKV1Xg/9F5+5Qku971NanWdokz+FoOEGGMApGBSNF87i+STyO8+4Y0GsWEHYWwKuo2L wCSGNStDLfBqfVm73Tq1qCDF61HbCnapxcwKP+ug6ZoGymEMlGcNlcDP996s/9Tq2ni3 g43tNwKdPTJVF84YYvTKTgTQsvivz3fry5dh6Wp9FdS+LPjFPYZhsBTVmBB1Tduq2ScA 92UEkL8rIGPS4XkInEqQoTgCd6u8vCWP9eT36EzTVaQxHngknMWQh95KrujtImo3f8qi ZMFw== 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: AOUpUlF0MyKcCJIeMC/UydFY1f2DUqcvI7uzYFomCTzRznD6qH5QrAQT DwWY4qdg2nEBczl7HIHwlMRk9Q0FD1vJ8BpwQTDxJemTg01Hwcm0C7KX1LUz9UbcesUDJHeDblG 24T9f+AKuHgwCQNgCDHiu2qLxS1gRbvatmDoS3eAi/vB1tuzUl0O+uLve4H/PkWxsaQ== X-Received: by 2002:a17:902:b688:: with SMTP id c8-v6mr11612965pls.114.1534833204201; Mon, 20 Aug 2018 23:33:24 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwahqs3SLP4ZlANxWj65pWGdulYcVQch61ojBVNLGpEUQJY1lbymhYH4fnsdZpiJRx1OfoM X-Received: by 2002:a17:902:b688:: with SMTP id c8-v6mr11612929pls.114.1534833203423; Mon, 20 Aug 2018 23:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534833203; cv=none; d=google.com; s=arc-20160816; b=yWPvigS/AQmireUmG+cslxYpIzafx1qN2El5dWSDElrPH2gzzU2Ep1qXWhYuDjr5rV 9Oqd7Nkt3MXmAtPi+5LTmpL8sniWuUnaEj8IrBNQApdGCEGesK/KXpbcPHXJMOcKTLPX uUrYl3rxWTI9UV3CyNw4n1eJr4Hp/nVKcWeYuCW+r0uKMsyZYyBYXCfUn2mHTJE5oNG1 zQuYi6YBSqEx9KE0OYnnU8lLGJKDt95ft+20uZcuKpDwT9zs70Rzc4JptZ53wU/Z4wUd OkV2jK+G1Np3N7gIvh52Tb2yWRRU5aQ4h8vuYffcj4p5iMCdej+Mz4rflKkozJUbF9f5 Pygg== 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=Wc75zFlQomkuMLIZO75F4E2ev+RWmnhiUJZbC9XfrhQ=; b=wZadJMJ42HCfCutkmAV92lFgziKl/82NNDYZzXiojSwL0TI2WiQNb/04mRWoUF9xO5 6E9aVZ9YCVSZvPfL2R3xUvJw1P62WKtMsTJy5kyBxUgXpphGonUvdoMIw12kG8vjf7Qs TZxnj5ow55Bi9Re7x4fHM9sNdBE8HwC7Mj9b1qy6HWWEkiMj3PcomjyBv/Z2uIDinVcI /Gu7y1M8KqN4WTIGGm7neBcfLoGwHq/rKbONcKl37/o1//jedLv4/uyink7XiaktM84P eE8jVdKqpK38gJyoi5CL/AGYbcahNBuuIHD+zSUw1IIEESQ8M0kqjd4ER+iND38EvqyG Kpsw== 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 w19-v6si11819753pfn.160.2018.08.20.23.33.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 23:33:23 -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 78F5B7F6; Tue, 21 Aug 2018 06:33:22 +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.9 24/25] x86/mm: Simplify p[g4um]d_page() macros Date: Tue, 21 Aug 2018 08:21:38 +0200 Message-Id: <20180821055126.128924982@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180821055124.909865464@linuxfoundation.org> References: <20180821055124.909865464@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.9-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 @@ -190,6 +190,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) @@ -621,8 +626,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] @@ -690,8 +694,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) @@ -731,7 +734,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)