From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752554AbdI1IbT (ORCPT ); Thu, 28 Sep 2017 04:31:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42082 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752134AbdI1IbQ (ORCPT ); Thu, 28 Sep 2017 04:31:16 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 68719B30A7 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=bhe@redhat.com Date: Thu, 28 Sep 2017 16:31:12 +0800 From: Baoquan He To: Ingo Molnar , rja@hpe.com, frank.ramsay@hpe.com Cc: 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 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: <20170928083112.GN16025@x1> References: <1504770150-25456-1-git-send-email-bhe@redhat.com> <1504770150-25456-3-git-send-email-bhe@redhat.com> <20170928075605.g74zm5xeglosmvct@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170928075605.g74zm5xeglosmvct@gmail.com> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 28 Sep 2017 08:31:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()? Thanks Baoquan