Received: by 10.213.65.68 with SMTP id h4csp9655imn; Mon, 12 Mar 2018 05:05:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELthJ0+gh3jnN8c1O+OOVech51JGTqgGA5DPEgBcqpR+11+U09QuWBmn9NSI7oOnwKPYXZ4C X-Received: by 10.98.192.203 with SMTP id g72mr7822058pfk.27.1520856350225; Mon, 12 Mar 2018 05:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520856350; cv=none; d=google.com; s=arc-20160816; b=TkJmVx+PUVo3zwTaiwnBbQLdAVJhAMX612165pCdhGh4pRcaUC2PY/1t8tRrBAjtYy rpDqC7XXQISfG2odKyIL3hCweL77Lzg76RCRwc5QPb9QotUaXax6p6ikq5r1DUUB/koJ 5C2zf2Ibja/XCNgGis52/a7iYsxXXsImKRzwXYSnu2FYQ+3YlZdBbVg4lb2B9+pBE+W9 ZEBv8M+cxQ+ICrRfWXR2gvEO+msV+NyCQH1DpDBWwVlkhWcVtgB1LbVnjDN8tun2dvAi aDxeOqyBL7AxpNBiNhpf2ax4iPBW9uN6rPhJC8FnyvZbZ89DSdDZlaN597e0X74i7oXD 6T8g== 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=7ej2lcUcpySfFTspVC0qutvtY20sun1buRalL9TrKjg=; b=nar8gP8HPqxpd3GIb8w82J3byBf1jJZ0RIxsK/IWxBHB0w44iagGCYMlWdp+bW3veM GuEb74wZAycCESnzh4Nwg4iGYiEIMFWUz2DOXbqpVfjQy1a4ZxSStGFsnK1678I/IpZH ioPCIMvnXBOBZUSdXv0y6pD2n5KYMVtXu8zAl17dv815SfIM64OnjTJjbwMgwgoN4woL /On7sGmZPFXgpf7K4b9XEauL6Pm0XqOcTgJdaFVu4wPsExhkGo050rijUTTsLbI1aZTo 1cqeeCz4+XF80IMh2PnySH5wYaayN0GzdpXe4wJXFk6jM82gTo7C/74QnwQRLBNLaLOp TUKA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si5665626pff.68.2018.03.12.05.05.35; Mon, 12 Mar 2018 05:05:50 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751281AbeCLMEm (ORCPT + 99 others); Mon, 12 Mar 2018 08:04:42 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:33258 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750967AbeCLMEl (ORCPT ); Mon, 12 Mar 2018 08:04:41 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="37745850" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 12 Mar 2018 20:04:38 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id A78E74D0EFF1; Mon, 12 Mar 2018 20:04:36 +0800 (CST) Received: from localhost.localdomain (10.167.225.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Mon, 12 Mar 2018 20:04:39 +0800 Date: Mon, 12 Mar 2018 20:04:15 +0800 From: Chao Fan To: Ingo Molnar CC: Baoquan He , Andrew Morton , , , , , , , , , , Subject: Re: [PATCH v9 0/5] x86/KASLR: Add parameter kaslr_boot_mem=nn[KMG]@ss[KMG] Message-ID: <20180312120415.GC8547@localhost.localdomain> References: <20180228105105.11487-1-fanc.fnst@cn.fujitsu.com> <20180312093557.gxypr66vrbftz3v3@gmail.com> <20180312101031.GH18656@localhost.localdomain> <20180312105727.mzrtjvnyxgyz7jn7@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180312105727.mzrtjvnyxgyz7jn7@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-Originating-IP: [10.167.225.56] X-yoursite-MailScanner-ID: A78E74D0EFF1.AF0E3 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: fanc.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 12, 2018 at 11:57:27AM +0100, Ingo Molnar wrote: > >* Baoquan He wrote: > >> Hi Ingo, >> >> On 03/12/18 at 10:35am, Ingo Molnar wrote: >> > >> > * Chao Fan wrote: >> > >> > > Long time no reply, rebase the patchset, change the parameter name >> > > from 'kaslr_mem' to 'kaslr_boot_mem'. There's no more code change. >> > > >> > > ***Background: >> > > People reported that kaslr may randomly chooses some positions >> > > which are located in movable memory regions. This will break memory >> > > hotplug feature. >> > >> > [...] >> > >> > > ***Solutions: >> > > Introduce a new kernel parameter 'kaslr_boot_mem=nn@ss' to let users to >> > > specify the memory regions where kernel can be allowed to randomize >> > > safely. >> > >> > Manual solutions like that are pretty suboptimal to users, aren't they? >> > >> > In what way does memory hotplug feature 'break'? Does it crash or misbehave? Or >> > simply does it not allow the movement of the affected memory region, while still >> > allowing the rest to be moved? >> >> AFAIT, if kernel is randomized into the movable memory region, the >> affected memory region can not be hot added/removed since it has kernel >> data. Surely, the system can still work, the unaffected part still can >> be moved. Still it will cause regression on memory hotplug. >> >> Mainly we parse SRAT table to get the ranges of memory provided by >> hot-added memory devices in initmem_init(), that's very late. During boot, >> we don't know it. Chao ever posted patches to grab SRAT at decompressing >> stage, the code is very complicated and not elegant, ACPI maintainer >> NACKed that. Thanks for Ingo's suggestion and Baoquan's explaination. Yes, I did ever try to dig SRAT table in boot period in early RFC PATCH: https://lkml.org/lkml/2017/9/3/77 But the change is too huge so made this patchset to avoid this bug in a small change, which will not make the code looks messy. Thanks, Chao Fan > >So there's apparently a mis-design here: > > - KASLR needs to be done very early on during bootup: - it's not realistic to > expect KASLR to be done with a booted up kernel, because pointers to various > KASLR-ed objects are already widely spread out in memory. > > - But for some unfathomable reason the memory hotplug attribute of memory > regions is not part of the regular memory map but part of late-init ACPI data > structures. > >The right solution would be _not_ to fudge the KASLR location, but to provide the >memory hotplug information to early code, preferably via the primary memory map. >KASLR can then make use of it and avoid those regions, just like it avoids other >memory regions already. > >In addition to that hardware makers (including virtualized hardware) should also >fix their systems to provide memory hotplug information to early code. > >Thanks, > > Ingo > >