From patchwork Fri Jun 24 03:13:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Chen X-Patchwork-Id: 9196477 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 9E73E60871 for ; Fri, 24 Jun 2016 03:16:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EFB228452 for ; Fri, 24 Jun 2016 03:16:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82E7828482; Fri, 24 Jun 2016 03:16:49 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04A8C28452 for ; Fri, 24 Jun 2016 03:16:48 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bGHa7-00018s-7e; Fri, 24 Jun 2016 03:14:59 +0000 Received: from eu-smtp-delivery-143.mimecast.com ([146.101.78.143]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bGHa4-00017S-6j for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2016 03:14:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=OspE7pdWsclafCm6+fvPPQMnJwaiYc5Kud0tPcGgzvs=; b=X/WspMSTMKWPX0OdaaVOpdVcBvMuQwFyopQkJQCodD5wrBt5l9V0j1SsIkWg3d4eUd6uacZgn94DdVZJlBskL5rWP41+oYV6GKPyDZLe5psFT8K8Yp5hxJBhSWlRt++gXmt6nJBvWAtKvusISsu7EVquRFYP5vXazFyFwcS6BdI= Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1lrp0015.outbound.protection.outlook.com [213.199.154.15]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-21-hKAxE0KkOe-uw4gB1TWp0g-1; Fri, 24 Jun 2016 04:14:32 +0100 Received: from AM3PR08CA0056.eurprd08.prod.outlook.com (10.163.23.152) by HE1PR0801MB1401.eurprd08.prod.outlook.com (10.167.248.21) with Microsoft SMTP Server (TLS) id 15.1.523.12; Fri, 24 Jun 2016 03:14:30 +0000 Received: from DB3FFO11FD035.protection.gbl (2a01:111:f400:7e04::175) by AM3PR08CA0056.outlook.office365.com (2a01:111:e400:8854::24) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Fri, 24 Jun 2016 03:14:30 +0000 Received: from nebula.arm.com (217.140.96.140) by DB3FFO11FD035.mail.protection.outlook.com (10.47.217.66) with Microsoft SMTP Server (TLS) id 15.1.517.7 via Frontend Transport; Fri, 24 Jun 2016 03:14:27 +0000 Received: from dennis-ws.asiapac.arm.com (10.1.2.79) by mail.arm.com (10.1.105.66) with Microsoft SMTP Server id 14.3.294.0; Fri, 24 Jun 2016 04:14:15 +0100 From: Dennis Chen To: Subject: [PATCH v2 1/2] mm: memblock Add some new functions to address the mem limit issue Date: Fri, 24 Jun 2016 11:13:46 +0800 Message-ID: <1466738027-15066-1-git-send-email-dennis.chen@arm.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(11100500001)(586003)(6806005)(104016004)(50986999)(48376002)(50226002)(26826002)(8676002)(246002)(50466002)(2906002)(4326007)(305945005)(110136002)(19580395003)(19580405001)(36756003)(92566002)(189998001)(86362001)(33646002)(2351001)(356003)(229853001)(47776003)(87936001)(7696003)(5003600100003)(7846002)(8936002)(5003940100001)(106466001)(77096005); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0801MB1401; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD035; 1:BEywHq+mowFqSz8PCWV5rXouMgn0cyn329mjouA/2f0JanslH2rvu5HYqdmdH+/h1HXhJWR0Cc3ZhDxjPqbgUtENVDuDVNW5e+BynRSplMrHMge1TF/eHbSmOKhJH7FAyswh74TrgAz14OAqfJIUjBjnAF79SBYgkklvqXr+TKNmnL98mAbL2vEaRadgzuWgW1yIaKjhRnqu0+2QFVdECCb6kLOOc32vhsgKTpZSIUav9syj+0dNVJGc3J3pYbhGuabvHyipCnfKGNcvFRXK7OCF0vTDAxBoZnXHbF2kuoNQqTFcReM4rfZL5E2r3SczdgHzzyhOMdZokTvkIkz4f2hVEnwiZsqbR3gx/5jhMukG+V18QPYFBh58vgFaDZJLZ7b6s3w24Yh6GFLdRfB+wleHXC17FGQKvu/ba0dZNsOshIuNDGdcuIP5ovFI+0zqpPdh45aookaJXzLKgP0SZ3VaZVjfAUu8X/y1Lma8DkT/5b1mw942DNVSxU+CfufteJ+Lxw/5HTPlja2/B4dcy8CSQ8vyejsWXtRyQPzcuPy/4aFalgLcglao8pkssiLvBKDICVNcBrduKs2EwhzaGG/1zt4yFrvdMShHEiHEMrU= X-MS-Office365-Filtering-Correlation-Id: 93b01d64-552c-44aa-1d1a-08d39bdda834 X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1401; 2:xEiIlOo7J9VmMXZRqXT+bpwy9j3YgijGCx8f76HCZTb+LxbpGgWSRRArF1a7IItMJZR86FpFyCNct8ERfz42lYVK5YbYN80TK62bjRVdFx6J40E82NV5wu6qLNRBhrs+RxF1wEwrcfiXrqESL5W5/UgDt3Lz7WrgTEQzVS3ixp7A67baYb4/zuXwV46HdXSb; 3:nuHwIGOFd3U1QIthXYARkAGUTjxHzOYBkID9JRcDkYcPGiqQXV3u5D7pCW9XSSzI2fnFPJ3RBvrGsgQio7+ON9J/Te0paBTziRa66P2akJmrPm+QemIrjbtfWOxmUYYjUz2sX0B3UQI07hcgCtpY9o8sRu3I2ZMOrFmJw9jPhA+VF7ojhvC1H59tx1PBjBlrrb5BJYfdW/j4jMzb8JcYHUHeVxUK9lBWqjONs/Cel6C4jdjebklFPVuuYhiO7qN859uEOcW/fYsVkSifw/NnnA==; 25:INzCV463hCV+7xsDjQE1n+YdTsm6k7VoftxjkVgF/1ewMj/zqX7twkmQUA0Xb2o5C79gYKg3qgVid/bUmV+VRhmAD1E7RCT1ZLujE+qz/ED9FZMbeS/V+kObHdCg06jaWtd1kPldOzT8ZqNHrZParApSgyClrYsR2z+CbZkw60wWr+C3Re11vGRF6MoV7ySlryraujGac0/lVKzkhcknFivjohavFP2pjGdWEUpG2kV5WkIzyMVtIsXdPho0COmr0S6qEEGWuhdeGjVxbKZcGpu/lCLC6OvIbSyooKZf0WNf1QsSr/14GeWTLguWXPAK6uefTIno7kD+5UC5PHShmBEkjqFNXYzjPVFhsSjHdPpOwKnPxMDkPHoC4K1WXprXGDPDIpMS/Iz6+SqEk04KsgSEo79NwHGUhVPVMKF7VMw= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:HE1PR0801MB1401; NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1401; 20:T/5WqCrDqEr3aymNR8tHzSJyl5QxCfhfffHt+H2/NvR9jsUeVs05qHarbaTxWiBemsERhxFb6w4iwZCwPQra6tlL8pq/dmAP0m5vCabM6QdIJiHM9fYofyxxDKNpL3UqyqaXmfd+AeRy2k5cGQCcJTDb0QDlbUH5qgPFyC/jdBF6K9wwJINl4KVFeVXaU4dQJEL8d/+bb2w0D3+U0KKOOdU+I6zFBGGCvrEHHwhqXjc2iOEA0bOCO1LwvOQHCUZE; 4:mbs9xM1pc5q2QvBMM3Vk/zmYeV2crjThDobN9Bc7pKbyusp/yiGZUjAWRKvGWEOSz56D7waKgMaXa/hHU/f4vv8Y4XWLj4A8aTP+yCxz7S45E1M2hJsK9c0yPHEoIMjOgXrJlPJ+JF//YfneqnX++AoOJPhDPFrGsI+ch9hwkZThsPq3JAeVJ5BDP4hCvZ4ElJ2jOj7biBmKf8fsiMZb6gCwiiqYgua0/Drt1pIldFiedx8KVjTywrxusQCtIeJa21Fk4G3y5T7n1P7DvSzotnZ78V/V84Ml5tAZzRYu/G6bT6DBpqb6GKFWVWr57t7hzjG/OUbWK8qs9zqsjwlnuecFoPYF92GbWRp/VPr0dcATpDzybymT2WViWmiRrtaQs+4Ry/P7XNr9aLuS2fMohGxNjS5wBvi5ymhnH1RskdGDpYQG8WAEV0K3jMRNd6OIK1Ou5iBen+herIDANe8eNHToqUiqqLwR4Fn5CcAZfTLj7EkVH8EqeYfnzur/gajhanZ8d/A3sraSstUtU7eERAdF041ct3HBkpJulafHlLBQ5NHm5rTm1E5vWnC02uB0 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(9452136761055)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(13024025)(13020025)(13013025)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:HE1PR0801MB1401; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0801MB1401; X-Forefront-PRVS: 0983EAD6B2 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0801MB1401; 23:OdtXQrfxJS/TMkCD1eqHS19Q1QAW8Wo96DFBkmM?= =?us-ascii?Q?ij3vJOxld4Si5957AcICPkoWfjqsc5LM44MlYVtrRP0V6Pat89yxbjanQLwx?= =?us-ascii?Q?j5wcr6l8BQq941uer/AkTzY2uqBUGUYGNXAoGeUlpZNcQdAZqBw8dj47lEF+?= =?us-ascii?Q?GABLKTc2qMjpD75M4XcMjxh33y2EK+9anN+IRYNi/21vaxOzXUmHQUwMIouh?= =?us-ascii?Q?eV0qDZd9wujC9GdEZ9OYlYSEmQDj9bLPmzq4s+AqGsi8b81AKwMjFXWx5xc0?= =?us-ascii?Q?h18L7/L3b+LJBx5KMCQ5lqPxM1qC8YNi3iBu2kh1a8eWoK8xisHWO3cJMPof?= =?us-ascii?Q?Xo9OPVDTE396kEGfnzlhSRQWElmowYuXIo3noGpprCRjHHMTFqjqq+8QPDQm?= =?us-ascii?Q?XtDYrNlyKT+FV+QlADugnMrzdeyBas+D9XOcYuBGYnDomaXJWV+kPvKMMUYu?= =?us-ascii?Q?s8285+MISpGc55K/5DFDsucQW81eAQ5/6MeZwFdE9YOdAyxbqyGfPau5vI/j?= =?us-ascii?Q?anx5tpZFDi0QE/mIdfw4/qDcDi4fEo7OHv0Fq4bLXqbG1qSn2/JRQLhBRTRC?= =?us-ascii?Q?PdGDQVbjF1DbDS07j50GXvbNZOn4yB8A1nTyaNzxOdnOLUXFy+YWt5RDoQGz?= =?us-ascii?Q?Hikb4Nltu+p9oh9z0N87VN9nM/CYvnne9LhgofCVbEXkQv2tiDTN8Km1lzvV?= =?us-ascii?Q?S3SQXBl4KMX8Jjo6h5PCvs3vPCP41A/VBa/HSWCI5Y1rkGFm5C+1XuE91pXQ?= =?us-ascii?Q?3DMwfbsQrHCieLOJHZ+47HoFszDH3CFnMzLOy4iNdH168/yki+99X0UN83pT?= =?us-ascii?Q?wuPsv8hd+WdIM5jDMsPGPijxMDUl6rNVM3rwS6yyFgRdkf5sZp2Ez6wmhc8V?= =?us-ascii?Q?Rds+EF/36aDMMfKVYgMXNmAXMy19SWtnkL82uUyaFDnk/QGGFFksWNYA9bLj?= =?us-ascii?Q?0/UFm7n3xsAyYu8NGPPGAMIxMzE5ia+qAoH8yvPZn77JidEuc8kN5VgjEYoL?= =?us-ascii?Q?eUE/twLHBpcxs/MrTGVeyRxpY?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1401; 6:qbhb+QllOrewTVKiOY90RzVkxgcg5fbmWyMdjTVfnDjFPP26Cazr/ULBSIaG5JGkxcwym7kmKZjMy0t2fwj3y/Pt7xwOcGuuuUm6e9s/tPDR4hdzV0eaPIZ71RZ9ohiDR57RMLcSpaSDWUu+rtun9N7PjsXbsGlbcOClO+r628zMJtV8/rC/wuPBK9PjfUrnGH5TXQ08B7tumHx5YJ0jHweRzqogiTiK1/oBKDjAKnQAHPu63yk/TmVyJuCKhB3nxwcxQSwuTXmwHYsmoeC3f4Q1eyawH6gzgBuuJ/B0ZvcqzonXNRpX//qJso6p/kFpVwXOYh9eGdX3ISdRl8NSJf/jj3qGIpAGW7ZH9063nmA=; 5:xw6Updon0/BT0tgKReTngfAOuUcuuJOodO9Eu/npNK8nAB+lvEHQ7TH5E5cdOthfp//5pm7cPIsvTtbtdO0xTlIgGHY5aNzi82LsP83+ELmsx0hIFkpy3Lejox5nZ90wY6oweNB3jP8csLSdvfAuug==; 24:srgNo3BloEWs3qbZZZG+bFImsPmeOiwhdgJ+m6N020dqzg6N1Odq/oPnsChrOHbTaZDq+BwhNy9CSXSuvcpSvBK0ldBvBCQ1sDLgaP0TJiA=; 7:n5jCbkQuCR/xvd7nou3BAZtGYnw3HTV9z2jqMUjariccn71sVe8TiPSloRfW99X4oeVXXZXc3xACZd9/0+HqURt48myVNNaDahLbUmVwTdWlH06KDe5CaZp3cQHZT0HIRvYfYR1I/Y4Dh4FaR5HWESIXZfum+YJbapYoI3AvXYTpp1f4ZQd9qhlFjEtDB4eUSwJ6YUWRNgg8fXie7GyP3FxJfdqsdg9hyPSPHU48fAAcfXPkL6UyT5v0fV08WM6oLtSCmESEX8T2nJ9KBJVHQw== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1401; 20:Z18WE/jQCDt2ZSQUKmCvb1Ij1xjZnVXX29x/Q6bacPyJ14HEEq9pX+nFrIOPU20WZSNnvSJMxlPTYYZBbdOg+/eJ2AShWDA77bcu7j8R4yJOs9IZuOMRMf0xs5krS3lvd47+DmvjOObY/EGuT4aptHgl8UVxtWbPA92nKvAPbjg= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2016 03:14:27.2109 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1401 X-MC-Unique: hKAxE0KkOe-uw4gB1TWp0g-1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160623_201456_526982_0541E3F4 X-CRM114-Status: GOOD ( 13.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "Rafael J . Wysocki" , linux-acpi@vger.kernel.org, Ard Biesheuvel , Matt Fleming , Catalin Marinas , Steve Capper , Will Deacon , linux-mm@kvack.org, linux-efi@vger.kernel.org, Dennis Chen , nd@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In some cases, memblock is queried to determine whether a physical address corresponds to memory present in a system even if unused by the OS for the linear mapping, highmem, etc. For example, the ACPI core needs this information to determine which attributes to use when mapping ACPI regions. Use of incorrect memory types can result in faults, data corruption, or other issues. Removing memory with memblock_enforce_memory_limit throws away this information, and so a kernel booted with 'mem=' may suffer from the issues described above. To avoid this, we can mark regions as nomap rather than removing them, which preserves the information we need while preventing other use of the regions. This patch adds new infrastructure to mark all memblock regions in an address range as nomap, to cater for this. Similarly we add infrastructure to clear the flag for an address range, which makes handling some overlap cases simpler. At last, we add 'size' and 'flag' debug output in the memblock debugfs for ease of the memblock debug effort. The '/sys/kernel/debug/memblock/memory' output looks like before: 0: 0x0000008000000000..0x0000008001e7ffff 1: 0x0000008001e80000..0x00000083ff184fff 2: 0x00000083ff185000..0x00000083ff1c2fff 3: 0x00000083ff1c3000..0x00000083ff222fff 4: 0x00000083ff223000..0x00000083ffe42fff 5: 0x00000083ffe43000..0x00000083ffffffff After applied: 0: 0x0000008000000000..0x0000008001e7ffff 0x0000000001e80000 0x4 1: 0x0000008001e80000..0x00000083ff184fff 0x00000003fd305000 0x0 2: 0x00000083ff185000..0x00000083ff1c2fff 0x000000000003e000 0x4 3: 0x00000083ff1c3000..0x00000083ff222fff 0x0000000000060000 0x0 4: 0x00000083ff223000..0x00000083ffe42fff 0x0000000000c20000 0x4 5: 0x00000083ffe43000..0x00000083ffffffff 0x00000000001bd000 0x0 Signed-off-by: Dennis Chen Cc: Catalin Marinas Cc: Steve Capper Cc: Ard Biesheuvel Cc: Will Deacon Cc: Mark Rutland Cc: Rafael J. Wysocki Cc: Matt Fleming Cc: linux-mm@kvack.org Cc: linux-acpi@vger.kernel.org Cc: linux-efi@vger.kernel.org --- Changes in v2: Update the commit message and add __init_memblock prefix to __find_max_addr() to avoid possible build warnning. include/linux/memblock.h | 2 ++ mm/memblock.c | 50 ++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 6c14b61..5e069c8 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -92,6 +92,7 @@ int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size); int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size); int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); int memblock_mark_nomap(phys_addr_t base, phys_addr_t size); +int memblock_clear_nomap(phys_addr_t base, phys_addr_t size); ulong choose_memblock_flags(void); /* Low level functions */ @@ -332,6 +333,7 @@ phys_addr_t memblock_mem_size(unsigned long limit_pfn); phys_addr_t memblock_start_of_DRAM(void); phys_addr_t memblock_end_of_DRAM(void); void memblock_enforce_memory_limit(phys_addr_t memory_limit); +void memblock_mem_limit_mark_nomap(phys_addr_t limit); bool memblock_is_memory(phys_addr_t addr); int memblock_is_map_memory(phys_addr_t addr); int memblock_is_region_memory(phys_addr_t base, phys_addr_t size); diff --git a/mm/memblock.c b/mm/memblock.c index ca09915..795596d 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -814,6 +814,18 @@ int __init_memblock memblock_mark_nomap(phys_addr_t base, phys_addr_t size) } /** + * memblock_clear_nomap - Clear flag MEMBLOCK_NOMAP for a specified region. + * @base: the base phys addr of the region + * @size: the size of the region + * + * Return 0 on success, -errno on failure. + */ +int __init_memblock memblock_clear_nomap(phys_addr_t base, phys_addr_t size) +{ + return memblock_setclr_flag(base, size, 0, MEMBLOCK_NOMAP); +} + +/** * __next_reserved_mem_region - next function for for_each_reserved_region() * @idx: pointer to u64 loop variable * @out_start: ptr to phys_addr_t for start address of the region, can be %NULL @@ -1465,14 +1477,11 @@ phys_addr_t __init_memblock memblock_end_of_DRAM(void) return (memblock.memory.regions[idx].base + memblock.memory.regions[idx].size); } -void __init memblock_enforce_memory_limit(phys_addr_t limit) +static phys_addr_t __init_memblock __find_max_addr(phys_addr_t limit) { phys_addr_t max_addr = (phys_addr_t)ULLONG_MAX; struct memblock_region *r; - if (!limit) - return; - /* find out max address */ for_each_memblock(memory, r) { if (limit <= r->size) { @@ -1482,6 +1491,18 @@ void __init memblock_enforce_memory_limit(phys_addr_t limit) limit -= r->size; } + return max_addr; +} + +void __init memblock_enforce_memory_limit(phys_addr_t limit) +{ + phys_addr_t max_addr; + + if (!limit) + return; + + max_addr = __find_max_addr(limit); + /* truncate both memory and reserved regions */ memblock_remove_range(&memblock.memory, max_addr, (phys_addr_t)ULLONG_MAX); @@ -1489,6 +1510,17 @@ void __init memblock_enforce_memory_limit(phys_addr_t limit) (phys_addr_t)ULLONG_MAX); } +void __init memblock_mem_limit_mark_nomap(phys_addr_t limit) +{ + phys_addr_t max_addr; + + if (!limit) + return; + + max_addr = __find_max_addr(limit); + memblock_mark_nomap(max_addr, (phys_addr_t)ULLONG_MAX); +} + static int __init_memblock memblock_search(struct memblock_type *type, phys_addr_t addr) { unsigned int left = 0, right = type->cnt; @@ -1677,13 +1709,15 @@ static int memblock_debug_show(struct seq_file *m, void *private) reg = &type->regions[i]; seq_printf(m, "%4d: ", i); if (sizeof(phys_addr_t) == 4) - seq_printf(m, "0x%08lx..0x%08lx\n", + seq_printf(m, "0x%08lx..0x%08lx 0x%08lx 0x%lx\n", (unsigned long)reg->base, - (unsigned long)(reg->base + reg->size - 1)); + (unsigned long)(reg->base + reg->size - 1), + (unsigned long)reg->size, reg->flags); else - seq_printf(m, "0x%016llx..0x%016llx\n", + seq_printf(m, "0x%016llx..0x%016llx 0x%016llx 0x%lx\n", (unsigned long long)reg->base, - (unsigned long long)(reg->base + reg->size - 1)); + (unsigned long long)(reg->base + reg->size - 1), + (unsigned long long)reg->size, reg->flags); } return 0;