Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2782236imm; Wed, 16 May 2018 20:18:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpTgW+lZrQ2CJhlnNtd/NY5LPW/h4d7GS7hlF/mM8iyO6IcxkooSCl1Wh+W4fxtpF6s5oP0 X-Received: by 2002:a17:902:680c:: with SMTP id h12-v6mr3583996plk.113.1526527121818; Wed, 16 May 2018 20:18:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526527121; cv=none; d=google.com; s=arc-20160816; b=jNjviRxLi7ayvmezJ393wLh/gc8ILRAX0zNBAsTz6S1pJXBNMlmZ1JxBJL/NXdWGhB bC5pPMrFbzEOhwLKsdc3vhO8OCPwiId66oKyU9FpLh0GXnhhQJTX8coz7w2fNKaEFs8h terNORuBYZq8ijANkWLKfLqnwEsPaKLHAtji5/C9iUHF60mnQcdOqt0Jh2kaSHe14X64 lnMlJ1ADtIuQsGySSMOXyP3NWSMjlGfrqG6aBuaqP9xoI/4xNHSqUwEgPYT5nMHGReZv v7edEmJlyvpQBiQMZSdURLuy9Uyf9dikCWbth/Auc9COE2gref0qj9Cc0gX5G/evoIZm C1+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=4LHy72p2HKD90wOqiBPcyCC7LFDAMY7OM97xnW/+B7w=; b=iaARIPEHSxM9zL8Thjuc3RuPQyCMYzGjieHyKUqBlbe0UPVs7z9AzLNFz36zHpCpdA l/lSlkSZto0gXhhyJcVvhHGWpWdNGCC3y7IRpyPQN8E11gi436xEUO/NNkwCcoR0ck1E 6VYdIio9J5TbHX4Tw3iXTWoCbSQ7TRdbWaE12xd6q7fUFD69q0aZng4OuWNCd8ioHgof +QnKMLMNH98dCO43ij6sXWDcD2fxjmROegX9MpXLQuTEycUxjCUbIbGHS0J6Way0x97H aMJ/twOpFs7Aq5rgDCunOQcN8z030GNRG9MYB/RqS7kUf6IRMjBn0IkS+2+aIVnAAi/8 AWqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e3-v6si4021515pld.229.2018.05.16.20.18.16; Wed, 16 May 2018 20:18:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751695AbeEQDSI (ORCPT + 99 others); Wed, 16 May 2018 23:18:08 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59146 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751395AbeEQDSH (ORCPT ); Wed, 16 May 2018 23:18:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 95EA081FE16A; Thu, 17 May 2018 03:18:06 +0000 (UTC) Received: from localhost (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 59906202660C; Thu, 17 May 2018 03:18:05 +0000 (UTC) Date: Thu, 17 May 2018 11:18:02 +0800 From: Baoquan He To: Mike Travis , rja@hpe.com, frank.ramsay@hpe.com Cc: Ingo Molnar , linux-kernel@vger.kernel.org, x86@kernel.org, mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, thgarnie@google.com, keescook@chromium.org, akpm@linux-foundation.org, yamada.masahiro@socionext.com, sivanich@hpe.com, dyoung@redhat.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 Message-ID: <20180517031802.GK24627@MiWiFi-R3L-srv> 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> <25fc5345-3273-447e-de6a-2ac7c56d0f00@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25fc5345-3273-447e-de6a-2ac7c56d0f00@hpe.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 17 May 2018 03:18:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 17 May 2018 03:18:06 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mike, Russ and Frank, On 09/28/17 at 07:10am, Mike Travis wrote: > > > On 9/28/2017 2:01 AM, Ingo Molnar wrote: > > > > * Baoquan He wrote: > > > > > > > @@ -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. This one is still a regression bug in our newer rhel since I just fixed them with rhel-only patch. Now I still need the console log which includes the MMIOH reservations. Could you help provide a console log with MMIOH info, or I need request one from redhat's lab? Or expert from HPE UV team can make a patch based on the finding and analysis? Thanks Baoquan > > > > > 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 > >