Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753262AbdI1OLm (ORCPT ); Thu, 28 Sep 2017 10:11:42 -0400 Received: from g2t1383g.austin.hpe.com ([15.233.16.89]:35958 "EHLO g2t1383g.austin.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751138AbdI1OLh (ORCPT ); Thu, 28 Sep 2017 10:11:37 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=mike.travis@hpe.com; Subject: Re: [PATCH v2 RESEND 2/2] x86/mm/KASLR: Do not adapt the size of the direct mapping section for SGI UV system To: Ingo Molnar , Baoquan He CC: , , , , , , , , , , , References: <1504770150-25456-1-git-send-email-bhe@redhat.com> <1504770150-25456-3-git-send-email-bhe@redhat.com> <20170928075605.g74zm5xeglosmvct@gmail.com> <20170928083112.GN16025@x1> <20170928090143.m6sog2am2ccz5dm4@gmail.com> From: Mike Travis Message-ID: <25fc5345-3273-447e-de6a-2ac7c56d0f00@hpe.com> Date: Thu, 28 Sep 2017 07:10:53 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170928090143.m6sog2am2ccz5dm4@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [192.48.179.6] X-ClientProxiedBy: SN4PR0801CA0006.namprd08.prod.outlook.com (10.161.215.144) To CS1PR84MB0182.NAMPRD84.PROD.OUTLOOK.COM (10.162.190.141) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f494d92c-5de0-493e-5cce-08d5067ace52 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:CS1PR84MB0182; X-Microsoft-Exchange-Diagnostics: 1;CS1PR84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U89ODEI/vr1Zgb5JnOcZ4ZMv726URig13UdiEL5qsDKfPNzjVal1fe9ysBOog5Gm/OalFfN+jpOHABbzbMa/AWDVIVUm6c/F9EsOJWsT9L9w7ksxo7ZewBrfLSUgqRYHW4WrQ2Vc+6am3j5noQumSGYbusvMN5E1kOjv9n0gcLiggequeX07RhzcGpFvoFKH4zubaKVte4AZHlZNjlR274ZZCceL65lDP9W8sxmnQPCfU/JFtgqnOfWctX2XZfGCGh+fNLDMayLQZ4MgdSL5Jr9tjEnX6Cd/AROuLZxxsW77frD+8INRGOm55bqEDvJ86kLmXymQYedqqKJdR9NWTH5Va7TtJhjzRHsU0ZWvV;4:suBkLQ1jWtz/ZvzuMwi2ntcUXIZLX2LAyPYvLLJXid4k7sfmJiCQlmXiT5YF5oA92j+xTcvZ9aLBrzP/pbjDKnWOURPjsmsQIczTypXbruZtq6ms8GR/vAK3y8ujqNn8Uc4rnnqf/IyPVbVldmMVoiaME1JAjTQs8prlUFe6sZ4+3sNV/cj2kON5iq4BlwdG+zS+Ht1Xul04dooSqtsdUBECLyoXUKMSmtwnvOXJlMolQi1JTDJItnsmTCSzb9YcwhZYBKFM653dy/bhLSnfk44vaui0T2GGD6W8a3JZNUQ= X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123558100)(20161123555025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CS1PR84MB0182;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CS1PR84MB0182; X-Forefront-PRVS: 0444EB1997 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(6049001)(39860400002)(376002)(346002)(377454003)(199003)(24454002)(189002)(65956001)(53546010)(81166006)(8936002)(8676002)(2906002)(2950100002)(3260700006)(65826007)(101416001)(54356999)(81156014)(4326008)(50986999)(305945005)(7736002)(25786009)(50466002)(6666003)(33646002)(229853002)(68736007)(6246003)(76176999)(36756003)(53936002)(7416002)(58126008)(3846002)(6486002)(6116002)(106356001)(230700001)(93886005)(64126003)(189998001)(105586002)(66066001)(23746002)(5660300001)(478600001)(31696002)(16576012)(83506001)(316002)(47776003)(97736004)(31686004)(110136005)(65806001)(49976008)(86362001)(16526017)(78286006);DIR:OUT;SFP:1102;SCL:1;SRVR:CS1PR84MB0182;H:[134.15.0.136];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;CS1PR84MB0182;23:yuA4XNiToIJpW5V1PiSdR5aNqfhI1qsUacgMN?= =?Windows-1252?Q?mJsXegR94xru5bPsKbUZ/GfoWDcCUKO6DO7lXXf/M33Z2Y7ptk97hMAf?= =?Windows-1252?Q?IyOd3moUxmfgfVF6WxQtFeIjIrTLdIHsxiVcGZXS9ShN4F7985RuqtFs?= =?Windows-1252?Q?Z6IgQyuDq1xAJZ/4qV/sG7+TZZQuwukHiIay+T71XT9V32htD5bBkIDe?= =?Windows-1252?Q?8atBKOdzzRyLMHOTzStdYcIdemFrYrm95057VKx3ytS4us91IKusnPy6?= =?Windows-1252?Q?G2bGC61d2Q8zuNe9uUQzKf4FYsDQpcYADoadDF7hsLgygYzqB56dqbas?= =?Windows-1252?Q?XWTkG8I2pGcSp4HmBWHvAjQu0Yt2PyV0gDLNgD2Uhyp/DYAfY9w2fX5q?= =?Windows-1252?Q?vqy5NEDFHPkO+bS9NSaw1PqGILc2x1X96gJc+ahhu18TOvBU/8kwHriD?= =?Windows-1252?Q?mUEBXp5/ELrtF4oYHZ9OThCVSqTFIvcDU/kvP3evioSKLHAJMlSKM2rG?= =?Windows-1252?Q?sIlw2FbpVFCJQ8H7i+YIKsy4GrAqSb2VeqYwIXziG1RGeHbWsaFlLhaA?= =?Windows-1252?Q?2kZeYOY/a3opkNRRolTKcJY06/g9gpEqUa6JKhaMjib+td+dw1DwUCKT?= =?Windows-1252?Q?WtLS6QST95yVbPiuHKbkem9lEihzUW61Srfe5l5m4mAOK+x2PVrqIlsZ?= =?Windows-1252?Q?qGHWTHsbPVJd/dfY+GIg0VsUy5K9TdV7WBIFAhom0rILDJ4vBZhrh1zj?= =?Windows-1252?Q?g4UyEj7r76yh8wM4lx/yt9ZPGg/CiFnCsKPhFQo83IDPgNhKXI/4ZeZp?= =?Windows-1252?Q?3L7Rp82+/YplqvSEQdKVWkE16fisO2sN/eJ7esEhwq8Gg85LS7mg0miY?= =?Windows-1252?Q?YbVfHSavkug1YiKkQ54cPPKJ14/A1ejQQ2PmMEBEh3VW+u0iYN1siS3P?= =?Windows-1252?Q?6t40pbdf3yNl+kzj3ctulTdv007xlRyk5EWxl3JHN6KTPlm2GD1T/Vl1?= =?Windows-1252?Q?AeZJ6I91NgvtSabaAMcWy1UEJU7F5edTBj6s917bmmXm+tagSoDR4T5d?= =?Windows-1252?Q?I6hxQfesNAmyvCXJHSdQazPFo4LrLS4CxAESNOg3f6QdQYY15weTbmP5?= =?Windows-1252?Q?LRYUhWhqjxUOqmkC/uXeZyTLFQXBGzGJjsVN9p0g/4Ybha1xVMKV0qVh?= =?Windows-1252?Q?5tp0GwfkPBv+7LhEsAaNuYeJcTqonr90ox3LnudPzk/tLrP0A5SomBOA?= =?Windows-1252?Q?UVau2nUHHONB6wh5qwHMadNawaWol7AJ2oAvk7W8FaLZwoFFMfhfgZhI?= =?Windows-1252?Q?PGqyBVBA1oFLQB0y63zoaDbQx0kjkqy4XjrIrJAdzJKdR0RcKElD6DHv?= =?Windows-1252?Q?Oa77XS3PnUw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X4wMeWVp7Mc1KAb5KngXDJ2A8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2017 14:11:23.4135 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0182 X-OriginatorOrg: hpe.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3149 Lines: 85 On 9/28/2017 2:01 AM, Ingo Molnar wrote: > > * Baoquan He wrote: > >> Hi Ingo, >> >> On 09/28/17 at 09:56am, Ingo Molnar wrote: >>>> diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c >>>> index af599167fe3c..4d68c08df82d 100644 >>>> --- a/arch/x86/mm/kaslr.c >>>> +++ b/arch/x86/mm/kaslr.c >>>> @@ -27,6 +27,7 @@ >>>> #include >>>> #include >>>> #include >>>> +#include >>>> >>>> #include "mm_internal.h" >>>> >>>> @@ -123,7 +124,7 @@ void __init kernel_randomize_memory(void) >>>> CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING; >>>> >>>> /* Adapt phyiscal memory region size based on available memory */ >>>> - if (memory_tb < kaslr_regions[0].size_tb) >>>> + if (memory_tb < kaslr_regions[0].size_tb && !is_early_uv_system()) >>>> kaslr_regions[0].size_tb = memory_tb; >>> This is really an ugly hack. Is kaslr_regions[] incorrect? If so then it should be >>> corrected instead of uglifying the code that uses it... >> >> Thanks for looking into this! >> >> If on SGI UV system, the kaslr_regions[0].size_tb, namely the size of >> the direct mapping section, is incorrect. >> >> Its direct mapping size includes two parts: >> #1 RAM size of system >> #2 MMIOH region size which only SGI UV system has. >> >> However, the #2 can only be got till uv_system_init() is called in >> native_smp_prepare_cpus(). That is too late for mm KASLR calculation. >> That's why I made this hack. >> >> I checked uv_system_init() code, seems not easy to know the size of >> MMIOH region before or inside kernel_randomize_memory(). I have CCed UV >> devel experts, not sure if they have any idea about this. Otherwise, >> this patch could be the only way I can think of. >> >> Hi Mike and Russ, >> >> Is there any chance we can get the size of MMIOH region before mm KASLR >> code, namely before we call kernel_randomize_memory()? The sizes of the MMIOL and MMIOH areas are tied into the HUB design and how it is communicated to BIOS and the kernel. This is via some of the config MMR's found in the HUB and it would be impossible to provide any access to these registers as they change with each new UV architecture. The kernel does reserve the memory in the EFI memmap. I can send you a console log of the full startup that includes the MMIOH reservations. Note that it is dependent on what I/O devices are actually present as UV does not map empty slots unless forced (because we'd quickly run out of resources.) Also, the EFI memmap entries do not specify the exact usage of the contained areas. > > I don't mind system specific quirks to hardware enumeration details, as long as > they don't pollute generic code with such special hacks. > > I.e. in this case it's wrong to allow kaslr_regions[0].size_tb to be wrong. Any > other code that relies on it in the future will be wrong as well on UV systems. Which may come into play on other arches with the new upcoming memory technologies. > > The right quirk would be to fix that up where it gets introduced, or something > like that. Yes, does make sense. > > Thanks, > > Ingo >