From patchwork Tue Apr 18 21:17:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 9686447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AFCF602C2 for ; Tue, 18 Apr 2017 21:27:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B3732094F for ; Tue, 18 Apr 2017 21:27:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F30D252D5; Tue, 18 Apr 2017 21:27:10 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D62882094F for ; Tue, 18 Apr 2017 21:27:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757888AbdDRVSG (ORCPT ); Tue, 18 Apr 2017 17:18:06 -0400 Received: from mail-co1nam03on0058.outbound.protection.outlook.com ([104.47.40.58]:37136 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757949AbdDRVRv (ORCPT ); Tue, 18 Apr 2017 17:17:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=597RoEYgjj06agbCTXmzbIgwr8lsX3jteyY+lLlTNZk=; b=2scfhQUW9cJ5ztJXj77bt7VenCzeYs0f5fnMGACKisEEaeumuH7pVkJ0dmRgW11wsU6iJjBwL2EYiafCS7xNQ8xUOPseOoKEObwI69QgSMw+hM3cxTRR0bEAU/498osFz58HnmWjgjRcECDZEttNoCftt7HbEDj7bxDUCJ7JtoI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by CY4PR12MB1141.namprd12.prod.outlook.com (10.168.163.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Tue, 18 Apr 2017 21:17:48 +0000 From: Tom Lendacky Subject: [PATCH v5 08/32] x86/mm: Simplify p[g4um]d_page() macros To: , , , , , , , , , CC: Rik van Riel , Radim =?utf-8?b?S3LEjW3DocWZ?= , Toshimitsu Kani , Arnd Bergmann , Jonathan Corbet , Matt Fleming , "Michael S. Tsirkin" , Joerg Roedel , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Brijesh Singh , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dave Young , Thomas Gleixner , Dmitry Vyukov Date: Tue, 18 Apr 2017 16:17:46 -0500 Message-ID: <20170418211746.10190.25735.stgit@tlendack-t1.amdoffice.net> In-Reply-To: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> References: <20170418211612.10190.82788.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR12CA0044.namprd12.prod.outlook.com (10.175.82.158) To CY4PR12MB1141.namprd12.prod.outlook.com (10.168.163.149) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7dcf3108-bb81-4a6d-b09a-08d486a05e24 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1141; 3:yRkCjkrAdbwZ9L8xIpxg5VLqQphmt4uB4mvXIWM07IHHD9PwjyEIe1HlAjYy6CE4tEifoB/q8myATNGtSclep4K5l6JgrCGEOGRI+yBLBiIFkRyO78OE3a0P1O23vThN9ycfJxrJt2R/J3QIVZpvwRvq32h306isgilqgVUMCrlMauh8uaEL3sYwQas2IFmsGXiPtP6qkqRKit21t+6R5LtoZkBdhbW+6d8pAiFw4XsollZFr3pZPkLJ4WsTytzRrxpVicwnMc8Tu34C/vNNU7oq5WdemSs/hxqzGR8sX8YKfY4k4BbjmZ4KhTBpZ7Od6Zr1XLZimfd09nbo0ptLCfNuHFN2NHdcBSTTGGd/lec=; 25:5T67JdLkeGoMKAq6U2gzGx6ySR9pOkgDVo0ZF3l4nmyvT4XlmyX+QKx+G+0tTmFXeLbhckxRlGbgYOZg2b8fMFa01F+cpNi4QNXtmYyMBtjtmfSV8iSG+rPLf8wfUUHkvadfn6My75LPqivWU7h9fUc4yzepevOBO6AMbNhn1b03FKRyAnaKfEY+G2ZqpNZnkLmZShZZbiJUOiJ5Z+7rP+OReomPODiuUY4ybQ9qzLHfq42sdf38+mNN+Bua9XX1qgNurEKJGh+HclPxOiLJ8hafDouZH6IFxun+8cmQpREsMnbZvDsep0dbC2fJyITLLr5TZ3veeAjJpw7ewLpmEQdXQKTLZfL+dz0FwMLGcSfAdSRfKe6Y1SIkiCZCJqGkA1Zq5iMgi45mntro4PGkbDS5Bf93RyMfntf3rPHbrhOOW9wwEQSFxzTOmyxyQtzFosrAbhbYSCVqGLeBiIOEYA== X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1141; 31:4DmMN3f3X/qmadVj5GZUR8LP8kSaQ+2I4u40Yn8V0A5L2k26eCBcA/EO9y8z52x6HzUZLXBbJWS970tW85y5SbEHrCXCcIifzRYhmFKRo9ccrCjOjSC0qPHOP5NE1tS6o8aF0QqtZ5pYIyH+6ZXwMmXx4XhO+N4uZW1uKjhe0DLm0RDhCsMuYE4A/BPyVsEN0LYvHVTbDPpQXXu4T2+9Ilu8KlijnR0bawls79QHGGsmQhRrAhEpoqBe5aQPA603SS/zGWRUxlAYkpBm5jLwLQ==; 20:jbvQ2v+smpHOFe7EDcVQ/GrKMW3oXn/v+6idOfnzLc/8UwrBQyYOP2ORxdb6mMyIGWVUaU609p53Eg7atpSVVOwSpHvlDavc+Auv4uqDF4K0YMG1ER3gzIngWRulimCHrqOq6jxioHMh7yW9571Qa1UAvZDpM57533ai5ifjp4y7SmJM3zBBJNEjOdtGJoF8BF8XUw6YVNQSZ+CTcIDD8UU3quq019D2gs99a+a1xhzlGUyt4sGvH1EpC7XXBliLMw2ZxCKVkMFt8IBwT6Fwu3hftZ7UARzq6YjmDX1dFf5dzDFMA5wyBlkEKqlDZcx2RIZZDARCIu1KuQa5o1mrZUP7FS2yrIx9N4vEMLszqVdLpRiLfUC2gbR0BJCc2WGMWRnjvbdXDYKffLxf96T5h25WKgCjAPJzf1mD44eTwu9l1Z2arynHw3PDbvvIZmgncxRgW7FIcsHTJe2RdoE1AvXf1MUm+WqGQEu6HxeDPfeOtUjblvaQvNGc/C1ImKkV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123562025)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(20161123555025)(6072148); SRVR:CY4PR12MB1141; BCL:0; PCL:0; RULEID:; SRVR:CY4PR12MB1141; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1141; 4:I6ZkQbFzEsesOI+jph4gzJMROICtX6NuV4VCaA0NLsxs/nGfyiuI5uuIeG/vN3yOaZN9ZLw59+/7U5CyFpMap8xSSl+FnnLwr72whvh4z5SXuBPXdBsWhGRk3CFneZFDOWeH40sD043vAUI58JntKW0BTLW6DLDJlrJyWmLKzIm+XUbz33iLRv0RxRgNS6872tIJ/U8ndDVXUhb+7LY9tWjbdqC67sWv/LLl8uDb4UIakcWbGr5KyxDHQ8G3Wuwc2XqO3LyRbVJ4U3I6lQuFCzg0T1qXWGOBObZaIKXHcsj9J5shxyKSGiUjohJCLUlORGM32c59QwOdLQ9CK4xKIXRWGbcbGN78C33IPzeHsaSuzh6BN1AGi0GFQrdE9jm907pNw5uuS3OuSEyeowB/gTKEBo1ISg/hWR8zcz/Es1Uw41VoIRb/RHW0eAmWcTNnlXkMDMFZtwEPLHr+uV7Z4IP6bUzbcOLeKHim9eL4YTPVY5PeQtnbooNp/YJx0wEyaIHzlmMCBCrkJynU7F59ZicSn81QEv1wTxSjd8mgj/TjVECnd+MKb8qC+D0dYLF3MXCkzqfcin37waWgIhx/+LvAjgNoTyNqKxUUAZaTpj7rZMtQshyk0Qip1u3OgkVlXKGTqh9y/jZgQp2wwE1yxvGU3KdoidtS+IDOsE/YlbKF8QpM2wP7cuMBikLhLyAK0ba9qK+rmqPJpHJq4rU3sjTFJ2ZLtrMOVi+3XJ0A4tR1JFs3E4eqmZ1fzB5EYc4RE1WHi0wTmo6Qdad7et+xXw== X-Forefront-PRVS: 028166BF91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39860400002)(39850400002)(39840400002)(39400400002)(39410400002)(42186005)(3846002)(305945005)(25786009)(7406005)(50466002)(7736002)(38730400002)(2906002)(4001350100001)(230700001)(53416004)(86362001)(2950100002)(5660300001)(103116003)(23676002)(6116002)(7416002)(2201001)(33646002)(1076002)(50986999)(54356999)(81166006)(55016002)(76176999)(97746001)(83506001)(66066001)(189998001)(9686003)(4326008)(6506006)(47776003)(53936002)(54906002)(8676002)(921003)(71626007)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1141; H:tlendack-t1.amdoffice.net; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxMTQxOzIzOjhOU1pwTmNVNkhNS3c4SVJCZ3lOd0FadkhM?= =?utf-8?B?a2xWa3ZYRENPVExJcjM0U0FreUNaZmxuam90cTN4SUdCVEZrZUxLcTNnOXNF?= =?utf-8?B?TVUyVFdJcXFCbmxkNm5WQ0NhVzM0MHdOR0k2UEJDSkxWNDBSemVObGF5Wkth?= =?utf-8?B?SHp2S2tidU9HM2tMTGI5bW5HTmsxcDJSUitVYVhOTVZWQVdxY0lHWkthbG9N?= =?utf-8?B?VHprakZmem1WYUYvWENsT0h6K1ZOaEllWER2b2NxR3htelc0QW9sUWhqaVJO?= =?utf-8?B?M1hzSW8reC9FOUVhWGU5YzlzdkEvdTZDSU1zazhXb3VZUHdqZ0loTTNCUVZG?= =?utf-8?B?STRpc0Nac1Y2UUk2dGdSUmJvRTJDSU9lUzFpZGZZTElscnpyQmVzQWdLeis0?= =?utf-8?B?czV0RkJDUXE2d0JOUkcxUGRvUjhSTnltZTlFTndYbHdxRDB4b01hYUVwVWkz?= =?utf-8?B?Z1R1bEFjcjVZeHJkd1JhK3g3ZkYyVVZqNm96b2gwMThRTnl4QzZ6MGlkcng5?= =?utf-8?B?bElKemtwZkFwRk51bmlTejNuRFF6Z3RJMERCejFxcENGUHNUc2xoS1RCR3ZG?= =?utf-8?B?SU1sWTVyblJPbFMxS24vRDQxTkZzWEhPbTFuSit3NmZQOFVWaUVxM3R5VDVu?= =?utf-8?B?NGNyZ214c25rUjFpK3dCZ2JCOVVHelBydzA0aG1WVjV2WWR2ZXJBRTBqWDNs?= =?utf-8?B?QW1SRWZlTDRUdDJiSFlSMGpHOE1PcDRxUjhnWlRWV0VUR3ZFM2x5Wnd2bDVn?= =?utf-8?B?OXl5SzVwRm95NGN4VEo1VGFaRk9DREluNk1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pS8HMT9SdWXNIW2gWcS/f9BCY2jJ6W/jgk/RM/XILm83jGl+7E6da+3F0yh+/nJP6LPDBQ==; 20:GpYN0zrzeoQeNRaw4zLA9xR9HHqNDNs5+b+8XBttX+wEQmRvwBHpH4ica/2vASrF5x9QLY/DKfA497MPlao7pcK7lPix+RQMA66j0feW3QNuH0JDJ62uL4y3etUPx/MdO+BN4NhIJWY4eRVXOhEZ70HE75ZgkwdaCKgdepB+/27D53RvuWgUDjHC4Lnvz2snixKEFPcoaoyEQzjzAaBxzp7Gh/1v3xhwezKYr6KYcaCEOaOul2saMmv4Nz68BxX8 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2017 21:17:48.5043 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1141 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create a pgd_pfn() and p4d_pfn() macro similar to the p[um]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 --- arch/x86/include/asm/pgtable.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 942482a..42b7193 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -195,6 +195,11 @@ static inline unsigned long p4d_pfn(p4d_t p4d) return (p4d_val(p4d) & p4d_pfn_mask(p4d)) >> PAGE_SHIFT; } +static inline unsigned long pgd_pfn(pgd_t pgd) +{ + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT; +} + static inline int p4d_large(p4d_t p4d) { /* No 512 GiB pages yet */ @@ -704,8 +709,7 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) * 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] @@ -773,8 +777,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud) * 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) @@ -824,8 +827,7 @@ static inline unsigned long p4d_page_vaddr(p4d_t p4d) * Currently stuck as a macro due to indirect forward reference to * linux/mmzone.h's __section_mem_map_addr() definition: */ -#define p4d_page(p4d) \ - pfn_to_page((p4d_val(p4d) & p4d_pfn_mask(p4d)) >> PAGE_SHIFT) +#define p4d_page(p4d) pfn_to_page(p4d_pfn(p4d)) /* Find an entry in the third-level page table.. */ static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address) @@ -859,7 +861,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd) * 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 p4d_t *p4d_offset(pgd_t *pgd, unsigned long address)