Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966334AbcKXPJp (ORCPT ); Thu, 24 Nov 2016 10:09:45 -0500 Received: from mail-by2nam01on0078.outbound.protection.outlook.com ([104.47.34.78]:36963 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965958AbcKXPJk (ORCPT ); Thu, 24 Nov 2016 10:09:40 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Robert.Richter@cavium.com; Date: Thu, 24 Nov 2016 16:09:18 +0100 From: Robert Richter To: Ard Biesheuvel CC: Will Deacon , Robert Richter , Mark Rutland , Catalin Marinas , David Daney , Hanjun Guo , "linux-arm-kernel@lists.infradead.org" , "linux-efi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] arm64: mm: Fix memmap to be initialized for the entire section Message-ID: <20161124150918.GF2213@rric.localdomain> References: <20161117151805.GJ2151@rric.localdomain> <20161123211538.GH10776@rric.localdomain> <20161124134238.GI10776@rric.localdomain> <20161124135151.GJ10776@rric.localdomain> <20161124141149.GE2213@rric.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [92.229.88.216] X-ClientProxiedBy: HE1P192CA0015.EURP192.PROD.OUTLOOK.COM (10.171.121.153) To BY2PR07MB2342.namprd07.prod.outlook.com (10.166.114.144) X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2342;2:AprZJTAKXM7PEGKM9XU4ApUZy5Yluwpt61s0dUOnd2I1Jzjo3dRUykhax16qA2CI2TZSQGuTwJMTSxtbiCW41BmTdJ413KC4Ti4muXpvcMHUaTjE3WjCJ4w7nsOcQ+RG0OOXJ8ntVGPAlIh+63cCw6FXHwsSTCKplnuWx3BA/BA=;3:l6oUJuiPM4RUxnbW/ZgI4cgsQeNulC3przvDuqsThuLuBtbZvwPn9vcut1KCTA3g+6HdUlx+shBg1DVammkkcLCqY+DxF+lPdGiTJ9XOHhbH09AULJNR0Lml2YwipDPnBmbSpfV2/hjNWf5F8OXJ5feI1/GgexJraQYf0aLpxwU=;25:2zZ/SEAhnF47VGgWED5Q/p0pS/yNIo2xva5vgtvxdFRAkD+6vt52W1ckFquLgv/lzTMJnxdWyti9gArhkRYQZtkPe461poVBinCjd/NxrSOxaVxiJrFGsTl64zgcZ+qHbhBO8yJrWsMQ7GIbKw7mu1RBfQ2OAPn8fQMOiVKi9IISXPq01EO6SNwWkY8sOTtTJcRKttxQmg9+9iN1h43Gh+7gnXoFlCWZZlGiMF9lPEkACRNv7VuItVnfOEXsJwWUgfyNRFIPLzjHdYOSYo13tcrdEmmzhFdcO3DGy5chJflG1kB/2l3juMqq3kgOnODoyTs5FY/5bTSQ9kdFNsq4zZCsf2XiHufY3t8QdQs+eFYhF/Dk5v/JN7FXRqIKqw+R8JlNrHXKvfR4uYrSbx4HkWmJFLIj2d/4H6ZJgS0IXp+xag29ziZdrIz70K8wGjno593YB1v2VVnL0mOFuTd/zQ== X-MS-Office365-Filtering-Correlation-Id: fda0873a-28d8-4617-f41d-08d4147be805 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BY2PR07MB2342; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2342;31:PugGbRU+8PSSZPWGYGsp9xzT6JMuZ5a8itbmwTx9FEF3xRs8nofeFz2xKb+I3ySKhiZI+2YrWx7K6KZa+KVxy/sGZMaJM8IbLN3UlER6WGQBdQ7NyTZxk1zsUNWnGCa9fchNWI8kj1bWgbEY0b8pUcFtiWBlRciILhHrU+rLSBGZr14AEYnNyLCC4OeSbM0F0bEBr6CM9kq00+UDKVyOn3SuSrPuBPQ0sTlHiGXUY7qq6MlubeI8cfl5C5YoGkaQwcScTwwkOqym55twxCyERw==;20:qddOOUzzImqQ8U8PUWCyE2BLJxdx3GLfm0WlwbIEm6I3UuVYW4Rc6XXAYHeT/rZgVJoQ8kMK6PwDPrVbi7FD6c9rM2MH4E0ur6V6HCeQljlnEkvjnOzYJSw8fWiYtRRxrQsTM1ehSSfZ3WVw6HsQm/A6yeTB26FYbgyHrBk6gIEdLBrLaaiTEnwp9XdbGa38l82adycSn9pZbkegfNJgZLjgk/wDr5/KVWj4z8x+HsGngXDZz+Uh8MjOc6hl5rlZh43o+1xXKRMV88J8MId/pS26gF+MocqbuNs0uXi3Egq8ceJyXv9mnZ+O2emf/2Q6ybLRI6rdDD5B5B72aTLOQKhvCndRG8nYzYhVJT33QU84mJGj6NICHFrAdevFRVeJly51EmafJJIxNrff7wxmhj5DHcGVqWULc5wUMaP/tIZo3Awie6Pp7bK+ZCTDsJiMUY+lMzZvfgCuzNetdqeJv4nh4ltkuSMAOw/NV81jV1JfYLQdSkSFv7bHZ74FhfFw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6060326)(6045199)(6040361)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(6061324)(20161123555025)(20161123564025)(20161123560025)(20161123562025);SRVR:BY2PR07MB2342;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB2342; X-Microsoft-Exchange-Diagnostics: 1;BY2PR07MB2342;4:XRLroZ31/AggHNhutpuyDjRHw06xwi7Vn7yKeyTowI1LavaE/0eaq27kRHSnF0xwJfDqqap5/h39gL53lvEJRCxf/iIQNyQF4yfrADbliuHJR5y/FvrTNjYByY8XqDyL0xaV3oDTqXVWh7JoE/FoNIuXVfCfkprpULOl2iE+DRUTaW+0jHWgpR6f+C3gI6O0jnAHUP6JEocbiXt2x5dPbxB2gm52F6E3XEqhDufrLFciMFZbV39tVftaapPvz8T/s9+mAYX4zJFMTFSwJlk45gP7Q1K/QDiOQ08Vs1eisTcGwpuej3u/nqcNj6WEXRuokOS/DdPldJLkBL2sufA2Q6jd8D/xdLSpBrSdv70e0lc+9rc4A3CgXvKj+HT05CNjtYOR+sNLsMVMxThvFo3PDXTxhjcKiZ+TQN5NGzGVExx3T4nJ/iGKTC1ERNrFjATypt6+YJioBtQvgeZrNzMgymCF5TYAuIo6eJroduvCPN+ZsHBgs/7296wH4cedg6ltFbbxZWe9JAsvSbScNb45x1i5v/C+tHSa/raUnjVz0tMcWQBX7RE/C4HtLfDKXZ6glOvzTxBMC6OUqMmuM4h+12TCvpVTK6yxauxmAerI5nQ= X-Forefront-PRVS: 0136C1DDA4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(24454002)(189002)(105586002)(47776003)(4326007)(93886004)(83506001)(50466002)(77096005)(2950100002)(2906002)(39400400001)(229853002)(5660300001)(38730400001)(86362001)(6916009)(66066001)(110136003)(6666003)(4001350100001)(3846002)(106356001)(97736004)(76176999)(50986999)(1076002)(101416001)(54356999)(46406003)(39380400001)(39410400001)(7736002)(189998001)(6116002)(23726003)(81156014)(8676002)(7846002)(33656002)(92566002)(305945005)(81166006)(42186005)(68736007)(9686002)(97756001)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR07MB2342;H:rric.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR07MB2342;23:WqgzNpM0k17UuSH6ntVP1L6ResDzXakRCiBUNlFM6?= =?us-ascii?Q?czYQQAz5uxePE0RoKTJ6QAK+64FU3N0eoXk8JeT251tCphozbyadmUmcQsW3?= =?us-ascii?Q?ZfVWeoEb4OxFHu//TOpSyh76CKQiBiX6qd1RIanK1Ji8HydyRtqKrbrlynlu?= =?us-ascii?Q?+q9ie2ZjgaYXUpTUjhLX4K2NJaXYMxKQMLu5QEcHuMxLlpuKGYSxwxt3loZC?= =?us-ascii?Q?p5oGASDGAhMqfDrWsOKThx4sJpx8wk/8tP7xcMZuYcU3Xz47sd1ajy7skioN?=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sHLe2Rbges7+cjDm+jRgl7Q9PphHUIkGpEjoW7k6kZcpXT5bEzVV7dBenZVFBOwQylw+MfamvDmsAoow4eL87d4YlLlZKiVQt3Q9SH2BAOp8rMdzpd27aLxxoJA5a/0k/YbH45jVLZ0tQv6nurPdJE1kWBUeMDcpmLFBTFWQsLgrb9xftmp2CbDiJW0Nf/FsGhi2sTWasR4Z1YqbvSMGPMPJJSI= X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2016 15:09:34.4206 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB2342 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2659 Lines: 63 On 24.11.16 14:23:16, Ard Biesheuvel wrote: > On 24 November 2016 at 14:11, Robert Richter wrote: > > On 24.11.16 13:58:30, Ard Biesheuvel wrote: > >> On 24 November 2016 at 13:51, Robert Richter wrote: > >> > On 24.11.16 13:44:31, Ard Biesheuvel wrote: > >> >> On 24 November 2016 at 13:42, Robert Richter wrote: > >> >> > On 23.11.16 21:25:06, Ard Biesheuvel wrote: > >> >> >> Why? MEMREMAP_WB is used often, among other things for mapping > >> >> >> firmware tables, which are marked as NOMAP, so in these cases, the > >> >> >> linear address is not mapped. > >> >> > > >> >> > If fw tables are mapped wb, that is wrong and needs a separate fix. > >> >> > > >> >> > >> >> Why is that wrong? > >> > > >> > The whole issue with mapping acpi tables is not marking them cachable, > >> > what wb does. > >> > >> What 'issue'? > >> > >> > Otherwise we could just use linear mapping for those mem > >> > ranges. > >> > > >> > >> Regions containing firmware tables are owned by the firmware, and it > >> is the firmware that tells us which memory attributes we are allowed > >> to use. If those attributes include WB, it is perfectly legal to use a > >> cacheable mapping. That does *not* mean they should be covered by the > >> linear mapping. The linear mapping is read-write-non-exec, for > >> instance, and we may prefer to use a read-only mapping and/or > >> executable mapping. > > > > Ok, I am going to fix try_ram_remap(). > > > > Thanks. Could you also add an arm64 version of page_is_ram() that uses > memblock_is_memory() while you're at it? I think using memblock > directly in try_ram_remap() may not be the best approach Sure. I also want to mark the patches as stable. > > Are there other concerns with this patch? > > > > I think we all agree that pfn_valid() should return whether a pfn has > a struct page associated with it, the debate is about whether it makes > sense to allocate struct pages for memory that the kernel does not > own. But given that it does not really hurt to do so for small holes, > I think your suggestion makes sense. Thanks for your comments and the review. > Should we be doing anything more to ensure that those pages are not > dereferenced inadvertently? Is there a page flag we should be setting? I don't think so. Boot mem is initialized in free_low_memory_core_ early(). The PageReserved flag is set for pages from reserved memory ranges, and memory ranges not marked NOMAP is just freed. Since pages are either reservered or in the free_list of pages, pages from other memory ranges (NOMAP) is not visible to mm. -Robert