Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2725993imm; Mon, 10 Sep 2018 05:42:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdabUtdFV9sWRkbjgOCx2cWqjl2x8qQYLMnxLJ1HUJXE0BM3MrVo/T4ZJQWfct4YDO0YzWl4 X-Received: by 2002:a62:c8d2:: with SMTP id i79-v6mr23388834pfk.35.1536583360307; Mon, 10 Sep 2018 05:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536583360; cv=none; d=google.com; s=arc-20160816; b=rdpw4g4MDqtzDsohvsYSRDukqvqxcW3F/bZlNzquBueVo/6yUxPhzMcfOQQVjqxbL7 T50PbQyNASoccFPUzRo2l/M7FM1SrTmgpanaWfLE3lAfKIUk8s4YOAFpVCpJR2IHvx4M Y5ZpgiAmDiSbGAHyLWzKLhJnTds92MPLVP0utCT9ZBsMmRZB/Rxb5hqoCtqfKf/iIq+z TUOhbAATbUMTLqF8SO/8d/wxgRQBN3Rah24mp03TFRifH9J0f69lSBW4goj1ht9t1F6q oBjAWfEuxtCMspiWSipvxX35m3ouD1RTnDYFNg0Tyf9751/Kgs2Em3fLvigdh0cQo++q 6KsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ywvh9rNPy0IR4DkSp5nJ5h94xXkGUhLpIQHdoge1sU0=; b=L4RKkI8UcqWBJPGd5DPuop9MnkI6SP6qn7bmNDKIVIclNje3mOn8HC1sI8rkY0froU 9kvjyf+aFI39CWYPqRiidCGFOeJxzlwzRjRQ4+uz7/MKELhTCYxdKO4jM+3/L5CYnp/T xPw1UtMLoZVVQ9dGfF4y/3JK6kzlR/BSH9HuO6FogiVUHnUnyPRay8pUN37ep4e1xg9s GQ3crgeqi8a2ndrVokZ1MX8lEe1M9KRoa8IRneRLeFfbdRd8fmFT2E0vTLin18thUnpk PUYbXxpVri8W1YVBHhu6t4YkYfQ44nbIAcGNG/6WIx/gLvjQdG1i4kVRs2pepngSfmHy o+pA== 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 j64-v6si15114096pgd.199.2018.09.10.05.42.25; Mon, 10 Sep 2018 05:42:40 -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 S1728665AbeIJRem (ORCPT + 99 others); Mon, 10 Sep 2018 13:34:42 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:52644 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727649AbeIJRel (ORCPT ); Mon, 10 Sep 2018 13:34:41 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="44733320" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 10 Sep 2018 20:40:41 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 5B41B4B6AE18; Mon, 10 Sep 2018 20:40:38 +0800 (CST) Received: from localhost (10.167.225.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.408.0; Mon, 10 Sep 2018 20:40:41 +0800 From: Chao Fan To: , , , , , , CC: , , , Chao Fan Subject: [PATCH v6 2/3] x86/boot/KASLR: Walk srat tables to filter immovable memory Date: Mon, 10 Sep 2018 20:40:14 +0800 Message-ID: <20180910124015.18073-3-fanc.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180910124015.18073-1-fanc.fnst@cn.fujitsu.com> References: <20180910124015.18073-1-fanc.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-yoursite-MailScanner-ID: 5B41B4B6AE18.AAD3F 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 If CONFIG_MEMORY_HOTREMOVE enabled, walk through the acpi srat memory tables and store those immovable memory regions so that kaslr can get where to choose for randomization. Signed-off-by: Chao Fan --- arch/x86/boot/compressed/kaslr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index d1e19f358b6e..3d839040cc7f 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -101,6 +101,11 @@ static bool memmap_too_large; /* Store memory limit specified by "mem=nn[KMG]" or "memmap=nn[KMG]" */ static unsigned long long mem_limit = ULLONG_MAX; +#ifdef CONFIG_MEMORY_HOTREMOVE +/* Store the immovable memory regions */ +extern struct mem_vector immovable_mem[MAX_NUMNODES*2]; +#endif + enum mem_avoid_index { MEM_AVOID_ZO_RANGE = 0, @@ -418,6 +423,11 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size, /* Mark the memmap regions we need to avoid */ handle_mem_options(); +#ifdef CONFIG_MEMORY_HOTREMOVE + /* Mark the immovable regions we need to choose */ + get_immovable_mem(); +#endif + #ifdef CONFIG_X86_VERBOSE_BOOTUP /* Make sure video RAM can be used. */ add_identity_map(0, PMD_SIZE); -- 2.17.1