linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG]
@ 2017-11-01 11:31 Chao Fan
  2017-11-01 11:32 ` [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG] Chao Fan
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Chao Fan @ 2017-11-01 11:31 UTC (permalink / raw)
  To: linux-kernel, x86, hpa, tglx, mingo, bhe, keescook, yasu.isimatu
  Cc: indou.takao, caoj.fnst, douly.fnst, Chao Fan

Here is a problem:
Here is a machine with several NUMA nodes and some of them are
hot-pluggable. It's not good for kernel to be extracted in the memory
region of movable node. But in current code, I print the address chosen by
kaslr and found it may be placed in movable node sometimes.
To solve this problem, it's better to limit the memory region chosen by
kaslr to immovable node in kaslr.c. But the memory information about if
it's hot-pluggable is stored in ACPI SRAT table, which is parsed after
kernel is extracted. So we can't get the detail memory information
before extracting kernel.

So extend the movable_node to movable_node=nn@ss, in which nn means
the size of memory in *immovable* node, and ss means the start position of
this memory region. Then limit kaslr choose memory in these regions.

There are two policies:
1. Specify the memory region in *movable* node to avoid:
   Then we can use the existing mem_avoid to handle. But if the memory
   on movable node was separated by memory hole or different movable nodes
   are discontinuous, we don't know how many regions need to avoid.
   OTOH, we must avoid all of the movable memory, otherwise, kaslr may
   choose the wrong place.
2. Specify the memory region in *immovable* node to select:
   Only support 4 regions in this parameter. Then user can use two nodes
   at least for kaslr to choose, it's enough for the kernel to extract.
   At the same time, because we need only 4 new mem_vector, the usage
   of memory here is not too big. So I think this way is better, and this 
   patchset is based on this policy.

PATCH 1/4 parse the extended movable_node=nn[KMG]@ss[KMG], then
          store the memory regions.
PATCH 2/4 select the memory region in immovable node when process
          memmap.
PATCH 3/4 add document.
PATCH 4/4 cleans up some little problems.

v1->v2:
Follow Dou's suggestion:
 - Add the parse for movable_node=nn[KMG] without @ss[KMG]
 - Fix the bug for more than one "movable_node=" specified
 - Drop useless variables and use mem_vector region directely
 - Add more comments.

Chao Fan (4):
  kaslr: parse the extended movable_node=nn[KMG]@ss[KMG]
  kaslr: select the memory region in immovable node to process
  document: change the document for the extended movable_node
  kaslr: clean up a useless variable and some usless space

 Documentation/admin-guide/kernel-parameters.txt |   9 ++
 arch/x86/boot/compressed/kaslr.c                | 141 ++++++++++++++++++++++--
 2 files changed, 138 insertions(+), 12 deletions(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG]
  2017-11-01 11:31 [PATCH v2 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG] Chao Fan
@ 2017-11-01 11:32 ` Chao Fan
  2017-11-13  8:10   ` Baoquan He
  2017-11-01 11:32 ` [PATCH v2 2/4] kaslr: select the memory region in immovable node to process Chao Fan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 20+ messages in thread
From: Chao Fan @ 2017-11-01 11:32 UTC (permalink / raw)
  To: linux-kernel, x86, hpa, tglx, mingo, bhe, keescook, yasu.isimatu
  Cc: indou.takao, caoj.fnst, douly.fnst, Chao Fan

Extend the movable_node to movable_node=nn[KMG]@ss[KMG].

Since in current code, kaslr may choose the memory region in movable
nodes to extract kernel, which will make the nodes can't be hot-removed.
To solve it, we can specify the region in immovable node. Create
immovable_mem to store the regions in immovable_mem, where should be
chosen by kaslr.

Multiple regions can be specified, comma delimited.
Considering the usage of memory, only support for 4 regions.
4 regions contains 2 nodes at least, enough for kernel to extract.

Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
---
 arch/x86/boot/compressed/kaslr.c | 76 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 75 insertions(+), 1 deletion(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 17818ba6906f..0a591c0023f1 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -107,6 +107,15 @@ enum mem_avoid_index {
 
 static struct mem_vector mem_avoid[MEM_AVOID_MAX];
 
+/* Only supporting at most 4 immovable memory regions with kaslr */
+#define MAX_IMMOVABLE_MEM	4
+
+/* Store the memory regions in immovable node */
+static struct mem_vector immovable_mem[MAX_IMMOVABLE_MEM];
+
+/* The immovable regions user specify, not more than 4 */
+static int num_immovable_region;
+
 static bool mem_overlaps(struct mem_vector *one, struct mem_vector *two)
 {
 	/* Item one is entirely before item two. */
@@ -167,6 +176,38 @@ parse_memmap(char *p, unsigned long long *start, unsigned long long *size)
 	return -EINVAL;
 }
 
+static int parse_immovable_mem(char *p,
+			       unsigned long long *start,
+			       unsigned long long *size)
+{
+	char *oldp;
+
+	if (!p)
+		return -EINVAL;
+
+	oldp = p;
+	*size = memparse(p, &p);
+	if (p == oldp)
+		return -EINVAL;
+
+	/* We support nn[KMG]@ss[KMG] and nn[KMG]. */
+	switch (*p) {
+	case '@':
+		*start = memparse(p + 1, &p);
+		return 0;
+	default:
+		/*
+		 * If w/o offset, only size specified, movable_node=nn[KMG]
+		 * has the same behaviour as movable_node=nn[KMG]@0. It means
+		 * the region starts from 0.
+		 */
+		*start = 0;
+		return 0;
+	}
+
+	return -EINVAL;
+}
+
 static void mem_avoid_memmap(char *str)
 {
 	static int i;
@@ -206,6 +247,36 @@ static void mem_avoid_memmap(char *str)
 		memmap_too_large = true;
 }
 
+#ifdef CONFIG_MEMORY_HOTPLUG
+static void mem_mark_immovable(char *str)
+{
+	static int i;
+
+	while (str && (i < MAX_IMMOVABLE_MEM)) {
+		int rc;
+		unsigned long long start, size;
+		char *k = strchr(str, ',');
+
+		if (k)
+			*k++ = 0;
+
+		rc = parse_immovable_mem(str, &start, &size);
+		if (rc < 0)
+			break;
+		str = k;
+
+		immovable_mem[i].start = start;
+		immovable_mem[i].size = size;
+		i++;
+	}
+	num_immovable_region = i;
+}
+#else
+static inline void mem_mark_immovable(char *str)
+{
+}
+#endif
+
 static int handle_mem_memmap(void)
 {
 	char *args = (char *)get_cmd_line_ptr();
@@ -214,7 +285,8 @@ static int handle_mem_memmap(void)
 	char *param, *val;
 	u64 mem_size;
 
-	if (!strstr(args, "memmap=") && !strstr(args, "mem="))
+	if (!strstr(args, "memmap=") && !strstr(args, "mem=") &&
+	    !strstr(args, "movable_node="))
 		return 0;
 
 	tmp_cmdline = malloc(len + 1);
@@ -239,6 +311,8 @@ static int handle_mem_memmap(void)
 
 		if (!strcmp(param, "memmap")) {
 			mem_avoid_memmap(val);
+		} else if (!strcmp(param, "movable_node")) {
+			mem_mark_immovable(val);
 		} else if (!strcmp(param, "mem")) {
 			char *p = val;
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-01 11:31 [PATCH v2 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG] Chao Fan
  2017-11-01 11:32 ` [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG] Chao Fan
@ 2017-11-01 11:32 ` Chao Fan
  2017-11-09  8:21   ` Baoquan He
  2017-11-13  8:31   ` Baoquan He
  2017-11-01 11:32 ` [PATCH v2 3/4] document: change the document for the extended movable_node Chao Fan
  2017-11-01 11:32 ` [PATCH v2 4/4] kaslr: clean up a useless variable and some usless space Chao Fan
  3 siblings, 2 replies; 20+ messages in thread
From: Chao Fan @ 2017-11-01 11:32 UTC (permalink / raw)
  To: linux-kernel, x86, hpa, tglx, mingo, bhe, keescook, yasu.isimatu
  Cc: indou.takao, caoj.fnst, douly.fnst, Chao Fan

Compare the region of memmap entry and immovable_mem, then choose the
intersection to process_mem_region.

Since the interrelationship between e820 or efi entries and memory
region in immovable_mem is different:
One memory region in one node may contain several entries of e820 or
efi sometimes, and one entry of e820 or efi may contain the memory in
different nodes sometimes.
It may split one node or one entry to several regions.

Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
---
 arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
 1 file changed, 52 insertions(+), 8 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 0a591c0023f1..fcd640fdeaed 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
 	}
 }
 
+static bool select_immovable_node(struct mem_vector region,
+				  unsigned long long minimum,
+				  unsigned long long image_size)
+{
+	int i;
+
+	/* If no immovable_mem stored, use region directly */
+	if (num_immovable_region == 0) {
+		process_mem_region(&region, minimum, image_size);
+
+		if (slot_area_index == MAX_SLOT_AREA) {
+			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
+			return 1;
+		}
+	} else {
+		/*
+		 * Walk all immovable regions, and filter the intersection
+		 * to process_mem_region.
+		 */
+		for (i = 0; i < num_immovable_region; i++) {
+			struct mem_vector entry;
+			unsigned long long start, end, select_end, region_end;
+
+			region_end = region.start + region.size - 1;
+			start = immovable_mem[i].start;
+			end = start + immovable_mem[i].size - 1;
+
+			if (region_end < start || region.start > end)
+				continue;
+
+			/* May split one region to several entries. */
+			entry.start = start > region.start ?
+				      start : region.start;
+			select_end = end > region_end ? region_end : end;
+
+			entry.size = select_end - entry.start + 1;
+
+			process_mem_region(&entry, minimum, image_size);
+
+			if (slot_area_index == MAX_SLOT_AREA) {
+				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
+				return 1;
+			}
+		}
+	}
+	return 0;
+}
+
 #ifdef CONFIG_EFI
 /*
  * Returns true if mirror region found (and must have been processed
@@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
 
 		region.start = md->phys_addr;
 		region.size = md->num_pages << EFI_PAGE_SHIFT;
-		process_mem_region(&region, minimum, image_size);
-		if (slot_area_index == MAX_SLOT_AREA) {
-			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
+
+		if (select_immovable_node(region, minimum, image_size))
 			break;
-		}
 	}
 	return true;
 }
@@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
 			continue;
 		region.start = entry->addr;
 		region.size = entry->size;
-		process_mem_region(&region, minimum, image_size);
-		if (slot_area_index == MAX_SLOT_AREA) {
-			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
+
+		if (select_immovable_node(region, minimum, image_size))
 			break;
-		}
 	}
 }
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 3/4] document: change the document for the extended movable_node
  2017-11-01 11:31 [PATCH v2 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG] Chao Fan
  2017-11-01 11:32 ` [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG] Chao Fan
  2017-11-01 11:32 ` [PATCH v2 2/4] kaslr: select the memory region in immovable node to process Chao Fan
@ 2017-11-01 11:32 ` Chao Fan
  2017-11-01 11:32 ` [PATCH v2 4/4] kaslr: clean up a useless variable and some usless space Chao Fan
  3 siblings, 0 replies; 20+ messages in thread
From: Chao Fan @ 2017-11-01 11:32 UTC (permalink / raw)
  To: linux-kernel, x86, hpa, tglx, mingo, bhe, keescook, yasu.isimatu
  Cc: indou.takao, caoj.fnst, douly.fnst, Chao Fan, Jonathan Corbet, linux-doc

Add the document for the change of extended movable_node=nn[KMG]@ss[KMG].

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org
Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index f16f7cf58c18..22ae1baf4bbd 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2335,6 +2335,15 @@
 			allocations which rules out almost all kernel
 			allocations. Use with caution!
 
+	movable_node=nn[KMG]@ss[KMG]
+			[KNL] Force usage of a specific region of memory.
+			Extend movable_node to work well with KASLR.
+			Region of memory in immovable node is from ss to ss+nn.
+			Multiple regions can be specified, comma delimited.
+			Notice: we support 4 regions at most now.
+			Example:
+			movable_node=1G,100M@2G,1G@4G
+
 	MTD_Partition=	[MTD]
 			Format: <name>,<region-number>,<size>,<offset>
 
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 4/4] kaslr: clean up a useless variable and some usless space
  2017-11-01 11:31 [PATCH v2 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG] Chao Fan
                   ` (2 preceding siblings ...)
  2017-11-01 11:32 ` [PATCH v2 3/4] document: change the document for the extended movable_node Chao Fan
@ 2017-11-01 11:32 ` Chao Fan
  2017-11-13  8:32   ` Baoquan He
  3 siblings, 1 reply; 20+ messages in thread
From: Chao Fan @ 2017-11-01 11:32 UTC (permalink / raw)
  To: linux-kernel, x86, hpa, tglx, mingo, bhe, keescook, yasu.isimatu
  Cc: indou.takao, caoj.fnst, douly.fnst, Chao Fan

There are two same variable "rc" in this function. One is in the
circulation, the other is out of the circulation. The one out will never
be used, so drop it.

Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
---
 arch/x86/boot/compressed/kaslr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index fcd640fdeaed..aff184e19270 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -211,7 +211,6 @@ static int parse_immovable_mem(char *p,
 static void mem_avoid_memmap(char *str)
 {
 	static int i;
-	int rc;
 
 	if (i >= MAX_MEMMAP_REGIONS)
 		return;
@@ -290,7 +289,7 @@ static int handle_mem_memmap(void)
 		return 0;
 
 	tmp_cmdline = malloc(len + 1);
-	if (!tmp_cmdline )
+	if (!tmp_cmdline)
 		error("Failed to allocate space for tmp_cmdline");
 
 	memcpy(tmp_cmdline, args, len);
@@ -436,7 +435,7 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
 	cmd_line |= boot_params->hdr.cmd_line_ptr;
 	/* Calculate size of cmd_line. */
 	ptr = (char *)(unsigned long)cmd_line;
-	for (cmd_line_size = 0; ptr[cmd_line_size++]; )
+	for (cmd_line_size = 0; ptr[cmd_line_size++];)
 		;
 	mem_avoid[MEM_AVOID_CMDLINE].start = cmd_line;
 	mem_avoid[MEM_AVOID_CMDLINE].size = cmd_line_size;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-01 11:32 ` [PATCH v2 2/4] kaslr: select the memory region in immovable node to process Chao Fan
@ 2017-11-09  8:21   ` Baoquan He
  2017-11-10  1:14     ` Chao Fan
  2017-11-10  3:03     ` Chao Fan
  2017-11-13  8:31   ` Baoquan He
  1 sibling, 2 replies; 20+ messages in thread
From: Baoquan He @ 2017-11-09  8:21 UTC (permalink / raw)
  To: Chao Fan
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

Hi Chao,

On 11/01/17 at 07:32pm, Chao Fan wrote:
> Compare the region of memmap entry and immovable_mem, then choose the
> intersection to process_mem_region.
> 
> Since the interrelationship between e820 or efi entries and memory
> region in immovable_mem is different:

Could you paste a bootlog with efi=debug specified in cmdline on the
system you tested? I want to check what kind of intersection between
them. The adding makes code pretty ugly, want to make sure if we have
to do like this.

Thanks
Baoquan

> One memory region in one node may contain several entries of e820 or
> efi sometimes, and one entry of e820 or efi may contain the memory in
> different nodes sometimes.
> It may split one node or one entry to several regions.
> 
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> ---
>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
>  1 file changed, 52 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> index 0a591c0023f1..fcd640fdeaed 100644
> --- a/arch/x86/boot/compressed/kaslr.c
> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
>  	}
>  }
>  
> +static bool select_immovable_node(struct mem_vector region,
> +				  unsigned long long minimum,
> +				  unsigned long long image_size)
> +{
> +	int i;
> +
> +	/* If no immovable_mem stored, use region directly */
> +	if (num_immovable_region == 0) {
> +		process_mem_region(&region, minimum, image_size);
> +
> +		if (slot_area_index == MAX_SLOT_AREA) {
> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> +			return 1;
> +		}
> +	} else {
> +		/*
> +		 * Walk all immovable regions, and filter the intersection
> +		 * to process_mem_region.
> +		 */
> +		for (i = 0; i < num_immovable_region; i++) {
> +			struct mem_vector entry;
> +			unsigned long long start, end, select_end, region_end;
> +
> +			region_end = region.start + region.size - 1;
> +			start = immovable_mem[i].start;
> +			end = start + immovable_mem[i].size - 1;
> +
> +			if (region_end < start || region.start > end)
> +				continue;
> +
> +			/* May split one region to several entries. */
> +			entry.start = start > region.start ?
> +				      start : region.start;
> +			select_end = end > region_end ? region_end : end;
> +
> +			entry.size = select_end - entry.start + 1;
> +
> +			process_mem_region(&entry, minimum, image_size);
> +
> +			if (slot_area_index == MAX_SLOT_AREA) {
> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> +				return 1;
> +			}
> +		}
> +	}
> +	return 0;
> +}
> +
>  #ifdef CONFIG_EFI
>  /*
>   * Returns true if mirror region found (and must have been processed
> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>  
>  		region.start = md->phys_addr;
>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
> -		process_mem_region(&region, minimum, image_size);
> -		if (slot_area_index == MAX_SLOT_AREA) {
> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
> +
> +		if (select_immovable_node(region, minimum, image_size))
>  			break;
> -		}
>  	}
>  	return true;
>  }
> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
>  			continue;
>  		region.start = entry->addr;
>  		region.size = entry->size;
> -		process_mem_region(&region, minimum, image_size);
> -		if (slot_area_index == MAX_SLOT_AREA) {
> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
> +
> +		if (select_immovable_node(region, minimum, image_size))
>  			break;
> -		}
>  	}
>  }
>  
> -- 
> 2.13.6
> 
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-09  8:21   ` Baoquan He
@ 2017-11-10  1:14     ` Chao Fan
  2017-11-10  3:03     ` Chao Fan
  1 sibling, 0 replies; 20+ messages in thread
From: Chao Fan @ 2017-11-10  1:14 UTC (permalink / raw)
  To: Baoquan He
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On Thu, Nov 09, 2017 at 04:21:32PM +0800, Baoquan He wrote:
>Hi Chao,
>
>On 11/01/17 at 07:32pm, Chao Fan wrote:
>> Compare the region of memmap entry and immovable_mem, then choose the
>> intersection to process_mem_region.
>> 
>> Since the interrelationship between e820 or efi entries and memory
>> region in immovable_mem is different:
>
>Could you paste a bootlog with efi=debug specified in cmdline on the
>system you tested? I want to check what kind of intersection between

Sure, I will.

Thanks,
Chao Fan

>them. The adding makes code pretty ugly, want to make sure if we have
>to do like this.
>
>Thanks
>Baoquan
>
>> One memory region in one node may contain several entries of e820 or
>> efi sometimes, and one entry of e820 or efi may contain the memory in
>> different nodes sometimes.
>> It may split one node or one entry to several regions.
>> 
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> ---
>>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
>>  1 file changed, 52 insertions(+), 8 deletions(-)
>> 
>> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> index 0a591c0023f1..fcd640fdeaed 100644
>> --- a/arch/x86/boot/compressed/kaslr.c
>> +++ b/arch/x86/boot/compressed/kaslr.c
>> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
>>  	}
>>  }
>>  
>> +static bool select_immovable_node(struct mem_vector region,
>> +				  unsigned long long minimum,
>> +				  unsigned long long image_size)
>> +{
>> +	int i;
>> +
>> +	/* If no immovable_mem stored, use region directly */
>> +	if (num_immovable_region == 0) {
>> +		process_mem_region(&region, minimum, image_size);
>> +
>> +		if (slot_area_index == MAX_SLOT_AREA) {
>> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> +			return 1;
>> +		}
>> +	} else {
>> +		/*
>> +		 * Walk all immovable regions, and filter the intersection
>> +		 * to process_mem_region.
>> +		 */
>> +		for (i = 0; i < num_immovable_region; i++) {
>> +			struct mem_vector entry;
>> +			unsigned long long start, end, select_end, region_end;
>> +
>> +			region_end = region.start + region.size - 1;
>> +			start = immovable_mem[i].start;
>> +			end = start + immovable_mem[i].size - 1;
>> +
>> +			if (region_end < start || region.start > end)
>> +				continue;
>> +
>> +			/* May split one region to several entries. */
>> +			entry.start = start > region.start ?
>> +				      start : region.start;
>> +			select_end = end > region_end ? region_end : end;
>> +
>> +			entry.size = select_end - entry.start + 1;
>> +
>> +			process_mem_region(&entry, minimum, image_size);
>> +
>> +			if (slot_area_index == MAX_SLOT_AREA) {
>> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> +				return 1;
>> +			}
>> +		}
>> +	}
>> +	return 0;
>> +}
>> +
>>  #ifdef CONFIG_EFI
>>  /*
>>   * Returns true if mirror region found (and must have been processed
>> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>>  
>>  		region.start = md->phys_addr;
>>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
>> -		process_mem_region(&region, minimum, image_size);
>> -		if (slot_area_index == MAX_SLOT_AREA) {
>> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
>> +
>> +		if (select_immovable_node(region, minimum, image_size))
>>  			break;
>> -		}
>>  	}
>>  	return true;
>>  }
>> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
>>  			continue;
>>  		region.start = entry->addr;
>>  		region.size = entry->size;
>> -		process_mem_region(&region, minimum, image_size);
>> -		if (slot_area_index == MAX_SLOT_AREA) {
>> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
>> +
>> +		if (select_immovable_node(region, minimum, image_size))
>>  			break;
>> -		}
>>  	}
>>  }
>>  
>> -- 
>> 2.13.6
>> 
>> 
>> 
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-09  8:21   ` Baoquan He
  2017-11-10  1:14     ` Chao Fan
@ 2017-11-10  3:03     ` Chao Fan
  2017-11-10  3:14       ` Baoquan He
  1 sibling, 1 reply; 20+ messages in thread
From: Chao Fan @ 2017-11-10  3:03 UTC (permalink / raw)
  To: Baoquan He
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On Thu, Nov 09, 2017 at 04:21:32PM +0800, Baoquan He wrote:
>Hi Chao,
>
>On 11/01/17 at 07:32pm, Chao Fan wrote:
>> Compare the region of memmap entry and immovable_mem, then choose the
>> intersection to process_mem_region.
>> 
>> Since the interrelationship between e820 or efi entries and memory
>> region in immovable_mem is different:
>
>Could you paste a bootlog with efi=debug specified in cmdline on the
>system you tested? I want to check what kind of intersection between
>them. The adding makes code pretty ugly, want to make sure if we have
>to do like this.
Hi Baoquan,

Here is a machine with efi.

The memory information in SRAT from dmesg:
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00000000-0x0009ffff]
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00100000-0x1f3fffff]
[    0.000000] ACPI: SRAT: Node 1 PXM 1 [mem 0x1f400000-0x3e7fffff]
[    0.000000] ACPI: SRAT: Node 2 PXM 2 [mem 0x3e800000-0x5dbfffff]
[    0.000000] ACPI: SRAT: Node 3 PXM 3 [mem 0x5dc00000-0x7cffffff]
[    0.000000] ACPI: SRAT: Node 4 PXM 4 [mem 0x7d000000-0x9c3fffff]
[    0.000000] ACPI: SRAT: Node 5 PXM 5 [mem 0x9c400000-0xbb7fffff]
[    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0xbb800000-0xbfffffff]
[    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0x100000000-0x11abfffff]
[    0.000000] ACPI: SRAT: Node 7 PXM 7 [mem 0x11ac00000-0x139ffffff]
[    0.000000] ACPI: SRAT: Node 8 PXM 8 [mem 0x13a000000-0x1593fffff]
[    0.000000] ACPI: SRAT: Node 9 PXM 9 [mem 0x159400000-0x1787fffff]

There are 10 nodes, and 500M memory in every node.
And node0 and node 6 has two parts.


Here is the efi mem:
[    0.000000] efi: mem00: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000000000-0x0000000000000fff] (0MB)
[    0.000000] efi: mem01: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000001000-0x0000000000001fff] (0MB)
[    0.000000] efi: mem02: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000002000-0x000000000009ffff] (0MB)
[    0.000000] efi: mem03: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000100000-0x0000000000805fff] (7MB)
[    0.000000] efi: mem04: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000806000-0x0000000000806fff] (0MB)
[    0.000000] efi: mem05: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000807000-0x000000000081ffff] (0MB)
[    0.000000] efi: mem06: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000820000-0x00000000012fffff] (10MB)
[    0.000000] efi: mem07: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000001300000-0x0000000001ffffff] (13MB)
[    0.000000] efi: mem08: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000002000000-0x00000000036e3fff] (22MB)
(From mem00 to mem08, belongs to node0)
[    0.000000] efi: mem09: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000036e4000-0x000000003d626fff] (927MB)
(mem09 has part of node0 and part of node1, but not the whole of node0 and node1)
[    0.000000] efi: mem10: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000003d627000-0x000000003fffffff] (41MB)
(part of node1 and part of node2)
[    0.000000] efi: mem11: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000040000000-0x000000008c92dfff] (1225MB)
[    0.000000] efi: mem12: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000008c92e000-0x00000000bbfbdfff] (758MB)
[    0.000000] efi: mem13: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfbe000-0x00000000bbfddfff] (0MB)
[    0.000000] efi: mem14: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfde000-0x00000000be350fff] (35MB)
[    0.000000] efi: mem15: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be351000-0x00000000be579fff] (2MB)
[    0.000000] efi: mem16: [Loader Code        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be57a000-0x00000000be6a0fff] (1MB)
[    0.000000] efi: mem17: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be6a1000-0x00000000beb21fff] (4MB)
[    0.000000] efi: mem18: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beb22000-0x00000000bed95fff] (2MB)
[    0.000000] efi: mem19: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed96000-0x00000000bed9afff] (0MB)
[    0.000000] efi: mem20: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed9b000-0x00000000beda1fff] (0MB)
[    0.000000] efi: mem21: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda2000-0x00000000beda6fff] (0MB)
[    0.000000] efi: mem22: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda7000-0x00000000bedacfff] (0MB)
[    0.000000] efi: mem23: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedad000-0x00000000bedb1fff] (0MB)
[    0.000000] efi: mem24: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedb2000-0x00000000bedbafff] (0MB)
[    0.000000] efi: mem25: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedbb000-0x00000000bedbffff] (0MB)
[    0.000000] efi: mem26: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc0000-0x00000000bedc6fff] (0MB)
[    0.000000] efi: mem27: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc7000-0x00000000bede6fff] (0MB)
[    0.000000] efi: mem28: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bede7000-0x00000000bf07efff] (2MB)
[    0.000000] efi: mem29: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf07f000-0x00000000bf3c3fff] (3MB)
[    0.000000] efi: mem30: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3c4000-0x00000000bf3cdfff] (0MB)
[    0.000000] efi: mem31: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3ce000-0x00000000bfce6fff] (9MB)
[    0.000000] efi: mem32: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce7000-0x00000000bfce8fff] (0MB)
[    0.000000] efi: mem33: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce9000-0x00000000bfe66fff] (1MB)
[    0.000000] efi: mem34: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe67000-0x00000000bfe96fff] (0MB)
[    0.000000] efi: mem35: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe97000-0x00000000bfebafff] (0MB)
[    0.000000] efi: mem36: [Reserved           |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebb000-0x00000000bfebefff] (0MB)
[    0.000000] efi: mem37: [ACPI Reclaim Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebf000-0x00000000bfec6fff] (0MB)
[    0.000000] efi: mem38: [ACPI Memory NVS    |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfec7000-0x00000000bfecafff] (0MB)
[    0.000000] efi: mem39: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfecb000-0x00000000bffcffff] (1MB)
[    0.000000] efi: mem40: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bffd0000-0x00000000bffeffff] (0MB)
[    0.000000] efi: mem41: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfff0000-0x00000000bfffffff] (0MB)
[    0.000000] efi: mem42: [Runtime Data       |RUN|  |  |  |  |  |  |   |  |  |  |UC] range=[0x00000000ffe00000-0x00000000ffffffff] (2MB)
[    0.000000] efi: mem43: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000100000000-0x00000001787fffff] (1928MB)


If the information is not enough, I can add more.

Thanks,
Chao Fan

>
>Thanks
>Baoquan
>
>> One memory region in one node may contain several entries of e820 or
>> efi sometimes, and one entry of e820 or efi may contain the memory in
>> different nodes sometimes.
>> It may split one node or one entry to several regions.
>> 
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> ---
>>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
>>  1 file changed, 52 insertions(+), 8 deletions(-)
>> 
>> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> index 0a591c0023f1..fcd640fdeaed 100644
>> --- a/arch/x86/boot/compressed/kaslr.c
>> +++ b/arch/x86/boot/compressed/kaslr.c
>> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
>>  	}
>>  }
>>  
>> +static bool select_immovable_node(struct mem_vector region,
>> +				  unsigned long long minimum,
>> +				  unsigned long long image_size)
>> +{
>> +	int i;
>> +
>> +	/* If no immovable_mem stored, use region directly */
>> +	if (num_immovable_region == 0) {
>> +		process_mem_region(&region, minimum, image_size);
>> +
>> +		if (slot_area_index == MAX_SLOT_AREA) {
>> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> +			return 1;
>> +		}
>> +	} else {
>> +		/*
>> +		 * Walk all immovable regions, and filter the intersection
>> +		 * to process_mem_region.
>> +		 */
>> +		for (i = 0; i < num_immovable_region; i++) {
>> +			struct mem_vector entry;
>> +			unsigned long long start, end, select_end, region_end;
>> +
>> +			region_end = region.start + region.size - 1;
>> +			start = immovable_mem[i].start;
>> +			end = start + immovable_mem[i].size - 1;
>> +
>> +			if (region_end < start || region.start > end)
>> +				continue;
>> +
>> +			/* May split one region to several entries. */
>> +			entry.start = start > region.start ?
>> +				      start : region.start;
>> +			select_end = end > region_end ? region_end : end;
>> +
>> +			entry.size = select_end - entry.start + 1;
>> +
>> +			process_mem_region(&entry, minimum, image_size);
>> +
>> +			if (slot_area_index == MAX_SLOT_AREA) {
>> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> +				return 1;
>> +			}
>> +		}
>> +	}
>> +	return 0;
>> +}
>> +
>>  #ifdef CONFIG_EFI
>>  /*
>>   * Returns true if mirror region found (and must have been processed
>> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>>  
>>  		region.start = md->phys_addr;
>>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
>> -		process_mem_region(&region, minimum, image_size);
>> -		if (slot_area_index == MAX_SLOT_AREA) {
>> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
>> +
>> +		if (select_immovable_node(region, minimum, image_size))
>>  			break;
>> -		}
>>  	}
>>  	return true;
>>  }
>> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
>>  			continue;
>>  		region.start = entry->addr;
>>  		region.size = entry->size;
>> -		process_mem_region(&region, minimum, image_size);
>> -		if (slot_area_index == MAX_SLOT_AREA) {
>> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
>> +
>> +		if (select_immovable_node(region, minimum, image_size))
>>  			break;
>> -		}
>>  	}
>>  }
>>  
>> -- 
>> 2.13.6
>> 
>> 
>> 
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-10  3:03     ` Chao Fan
@ 2017-11-10  3:14       ` Baoquan He
  2017-11-10  4:20         ` Chao Fan
  2017-11-10  6:02         ` Chao Fan
  0 siblings, 2 replies; 20+ messages in thread
From: Baoquan He @ 2017-11-10  3:14 UTC (permalink / raw)
  To: Chao Fan
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On 11/10/17 at 11:03am, Chao Fan wrote:
> On Thu, Nov 09, 2017 at 04:21:32PM +0800, Baoquan He wrote:
> >Hi Chao,
> >
> >On 11/01/17 at 07:32pm, Chao Fan wrote:
> >> Compare the region of memmap entry and immovable_mem, then choose the
> >> intersection to process_mem_region.
> >> 
> >> Since the interrelationship between e820 or efi entries and memory
> >> region in immovable_mem is different:
> >
> >Could you paste a bootlog with efi=debug specified in cmdline on the
> >system you tested? I want to check what kind of intersection between
> >them. The adding makes code pretty ugly, want to make sure if we have
> >to do like this.
> Hi Baoquan,
> 
> Here is a machine with efi.

Thanks, do you have the whole boot log? I want to have a look at e820.
And this is a special system, or a customized system? I mean you just
customize the firmware for better testing to cover kinds of cases.

If it's too big, please attach it and send to me privately.

Anyway, seems your considering about the intersection is right.

Thanks
Baoquan
> 
> The memory information in SRAT from dmesg:
> [    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00000000-0x0009ffff]
> [    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00100000-0x1f3fffff]
> [    0.000000] ACPI: SRAT: Node 1 PXM 1 [mem 0x1f400000-0x3e7fffff]
> [    0.000000] ACPI: SRAT: Node 2 PXM 2 [mem 0x3e800000-0x5dbfffff]
> [    0.000000] ACPI: SRAT: Node 3 PXM 3 [mem 0x5dc00000-0x7cffffff]
> [    0.000000] ACPI: SRAT: Node 4 PXM 4 [mem 0x7d000000-0x9c3fffff]
> [    0.000000] ACPI: SRAT: Node 5 PXM 5 [mem 0x9c400000-0xbb7fffff]
> [    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0xbb800000-0xbfffffff]
> [    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0x100000000-0x11abfffff]
> [    0.000000] ACPI: SRAT: Node 7 PXM 7 [mem 0x11ac00000-0x139ffffff]
> [    0.000000] ACPI: SRAT: Node 8 PXM 8 [mem 0x13a000000-0x1593fffff]
> [    0.000000] ACPI: SRAT: Node 9 PXM 9 [mem 0x159400000-0x1787fffff]
> 
> There are 10 nodes, and 500M memory in every node.
> And node0 and node 6 has two parts.
> 
> 
> Here is the efi mem:
> [    0.000000] efi: mem00: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000000000-0x0000000000000fff] (0MB)
> [    0.000000] efi: mem01: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000001000-0x0000000000001fff] (0MB)
> [    0.000000] efi: mem02: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000002000-0x000000000009ffff] (0MB)
> [    0.000000] efi: mem03: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000100000-0x0000000000805fff] (7MB)
> [    0.000000] efi: mem04: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000806000-0x0000000000806fff] (0MB)
> [    0.000000] efi: mem05: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000807000-0x000000000081ffff] (0MB)
> [    0.000000] efi: mem06: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000820000-0x00000000012fffff] (10MB)
> [    0.000000] efi: mem07: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000001300000-0x0000000001ffffff] (13MB)
> [    0.000000] efi: mem08: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000002000000-0x00000000036e3fff] (22MB)
> (From mem00 to mem08, belongs to node0)
> [    0.000000] efi: mem09: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000036e4000-0x000000003d626fff] (927MB)
> (mem09 has part of node0 and part of node1, but not the whole of node0 and node1)
> [    0.000000] efi: mem10: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000003d627000-0x000000003fffffff] (41MB)
> (part of node1 and part of node2)
> [    0.000000] efi: mem11: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000040000000-0x000000008c92dfff] (1225MB)
> [    0.000000] efi: mem12: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000008c92e000-0x00000000bbfbdfff] (758MB)
> [    0.000000] efi: mem13: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfbe000-0x00000000bbfddfff] (0MB)
> [    0.000000] efi: mem14: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfde000-0x00000000be350fff] (35MB)
> [    0.000000] efi: mem15: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be351000-0x00000000be579fff] (2MB)
> [    0.000000] efi: mem16: [Loader Code        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be57a000-0x00000000be6a0fff] (1MB)
> [    0.000000] efi: mem17: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be6a1000-0x00000000beb21fff] (4MB)
> [    0.000000] efi: mem18: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beb22000-0x00000000bed95fff] (2MB)
> [    0.000000] efi: mem19: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed96000-0x00000000bed9afff] (0MB)
> [    0.000000] efi: mem20: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed9b000-0x00000000beda1fff] (0MB)
> [    0.000000] efi: mem21: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda2000-0x00000000beda6fff] (0MB)
> [    0.000000] efi: mem22: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda7000-0x00000000bedacfff] (0MB)
> [    0.000000] efi: mem23: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedad000-0x00000000bedb1fff] (0MB)
> [    0.000000] efi: mem24: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedb2000-0x00000000bedbafff] (0MB)
> [    0.000000] efi: mem25: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedbb000-0x00000000bedbffff] (0MB)
> [    0.000000] efi: mem26: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc0000-0x00000000bedc6fff] (0MB)
> [    0.000000] efi: mem27: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc7000-0x00000000bede6fff] (0MB)
> [    0.000000] efi: mem28: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bede7000-0x00000000bf07efff] (2MB)
> [    0.000000] efi: mem29: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf07f000-0x00000000bf3c3fff] (3MB)
> [    0.000000] efi: mem30: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3c4000-0x00000000bf3cdfff] (0MB)
> [    0.000000] efi: mem31: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3ce000-0x00000000bfce6fff] (9MB)
> [    0.000000] efi: mem32: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce7000-0x00000000bfce8fff] (0MB)
> [    0.000000] efi: mem33: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce9000-0x00000000bfe66fff] (1MB)
> [    0.000000] efi: mem34: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe67000-0x00000000bfe96fff] (0MB)
> [    0.000000] efi: mem35: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe97000-0x00000000bfebafff] (0MB)
> [    0.000000] efi: mem36: [Reserved           |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebb000-0x00000000bfebefff] (0MB)
> [    0.000000] efi: mem37: [ACPI Reclaim Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebf000-0x00000000bfec6fff] (0MB)
> [    0.000000] efi: mem38: [ACPI Memory NVS    |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfec7000-0x00000000bfecafff] (0MB)
> [    0.000000] efi: mem39: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfecb000-0x00000000bffcffff] (1MB)
> [    0.000000] efi: mem40: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bffd0000-0x00000000bffeffff] (0MB)
> [    0.000000] efi: mem41: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfff0000-0x00000000bfffffff] (0MB)
> [    0.000000] efi: mem42: [Runtime Data       |RUN|  |  |  |  |  |  |   |  |  |  |UC] range=[0x00000000ffe00000-0x00000000ffffffff] (2MB)
> [    0.000000] efi: mem43: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000100000000-0x00000001787fffff] (1928MB)
> 
> 
> If the information is not enough, I can add more.
> 
> Thanks,
> Chao Fan
> 
> >
> >Thanks
> >Baoquan
> >
> >> One memory region in one node may contain several entries of e820 or
> >> efi sometimes, and one entry of e820 or efi may contain the memory in
> >> different nodes sometimes.
> >> It may split one node or one entry to several regions.
> >> 
> >> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> >> ---
> >>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
> >>  1 file changed, 52 insertions(+), 8 deletions(-)
> >> 
> >> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> >> index 0a591c0023f1..fcd640fdeaed 100644
> >> --- a/arch/x86/boot/compressed/kaslr.c
> >> +++ b/arch/x86/boot/compressed/kaslr.c
> >> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
> >>  	}
> >>  }
> >>  
> >> +static bool select_immovable_node(struct mem_vector region,
> >> +				  unsigned long long minimum,
> >> +				  unsigned long long image_size)
> >> +{
> >> +	int i;
> >> +
> >> +	/* If no immovable_mem stored, use region directly */
> >> +	if (num_immovable_region == 0) {
> >> +		process_mem_region(&region, minimum, image_size);
> >> +
> >> +		if (slot_area_index == MAX_SLOT_AREA) {
> >> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> >> +			return 1;
> >> +		}
> >> +	} else {
> >> +		/*
> >> +		 * Walk all immovable regions, and filter the intersection
> >> +		 * to process_mem_region.
> >> +		 */
> >> +		for (i = 0; i < num_immovable_region; i++) {
> >> +			struct mem_vector entry;
> >> +			unsigned long long start, end, select_end, region_end;
> >> +
> >> +			region_end = region.start + region.size - 1;
> >> +			start = immovable_mem[i].start;
> >> +			end = start + immovable_mem[i].size - 1;
> >> +
> >> +			if (region_end < start || region.start > end)
> >> +				continue;
> >> +
> >> +			/* May split one region to several entries. */
> >> +			entry.start = start > region.start ?
> >> +				      start : region.start;
> >> +			select_end = end > region_end ? region_end : end;
> >> +
> >> +			entry.size = select_end - entry.start + 1;
> >> +
> >> +			process_mem_region(&entry, minimum, image_size);
> >> +
> >> +			if (slot_area_index == MAX_SLOT_AREA) {
> >> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> >> +				return 1;
> >> +			}
> >> +		}
> >> +	}
> >> +	return 0;
> >> +}
> >> +
> >>  #ifdef CONFIG_EFI
> >>  /*
> >>   * Returns true if mirror region found (and must have been processed
> >> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
> >>  
> >>  		region.start = md->phys_addr;
> >>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
> >> -		process_mem_region(&region, minimum, image_size);
> >> -		if (slot_area_index == MAX_SLOT_AREA) {
> >> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
> >> +
> >> +		if (select_immovable_node(region, minimum, image_size))
> >>  			break;
> >> -		}
> >>  	}
> >>  	return true;
> >>  }
> >> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
> >>  			continue;
> >>  		region.start = entry->addr;
> >>  		region.size = entry->size;
> >> -		process_mem_region(&region, minimum, image_size);
> >> -		if (slot_area_index == MAX_SLOT_AREA) {
> >> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
> >> +
> >> +		if (select_immovable_node(region, minimum, image_size))
> >>  			break;
> >> -		}
> >>  	}
> >>  }
> >>  
> >> -- 
> >> 2.13.6
> >> 
> >> 
> >> 
> >
> >
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-10  3:14       ` Baoquan He
@ 2017-11-10  4:20         ` Chao Fan
  2017-11-10  6:02         ` Chao Fan
  1 sibling, 0 replies; 20+ messages in thread
From: Chao Fan @ 2017-11-10  4:20 UTC (permalink / raw)
  To: Baoquan He
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

[-- Attachment #1: Type: text/plain, Size: 12682 bytes --]

On Fri, Nov 10, 2017 at 11:14:37AM +0800, Baoquan He wrote:
>On 11/10/17 at 11:03am, Chao Fan wrote:
>> On Thu, Nov 09, 2017 at 04:21:32PM +0800, Baoquan He wrote:
>> >Hi Chao,
>> >
>> >On 11/01/17 at 07:32pm, Chao Fan wrote:
>> >> Compare the region of memmap entry and immovable_mem, then choose the
>> >> intersection to process_mem_region.
>> >> 
>> >> Since the interrelationship between e820 or efi entries and memory
>> >> region in immovable_mem is different:
>> >
>> >Could you paste a bootlog with efi=debug specified in cmdline on the
>> >system you tested? I want to check what kind of intersection between
>> >them. The adding makes code pretty ugly, want to make sure if we have
>> >to do like this.
>> Hi Baoquan,
>> 
>> Here is a machine with efi.
>
>Thanks, do you have the whole boot log? I want to have a look at e820.

No problem, I will paste the whole in attach file.

>And this is a special system, or a customized system? I mean you just

It's a qemu machine, in which I can make more nodes to test.
I have no suitable host machine available in my hand.

>customize the firmware for better testing to cover kinds of cases.

Although the code may be a little ugly, after comparing the
different memory regions, this method and logic are better to
cover more cases.
If you have some ideas to improve the code. Thank you very much!

Thanks,
Chao Fan

>
>If it's too big, please attach it and send to me privately.
>
>Anyway, seems your considering about the intersection is right.
>
>Thanks
>Baoquan
>> 
>> The memory information in SRAT from dmesg:
>> [    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00000000-0x0009ffff]
>> [    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00100000-0x1f3fffff]
>> [    0.000000] ACPI: SRAT: Node 1 PXM 1 [mem 0x1f400000-0x3e7fffff]
>> [    0.000000] ACPI: SRAT: Node 2 PXM 2 [mem 0x3e800000-0x5dbfffff]
>> [    0.000000] ACPI: SRAT: Node 3 PXM 3 [mem 0x5dc00000-0x7cffffff]
>> [    0.000000] ACPI: SRAT: Node 4 PXM 4 [mem 0x7d000000-0x9c3fffff]
>> [    0.000000] ACPI: SRAT: Node 5 PXM 5 [mem 0x9c400000-0xbb7fffff]
>> [    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0xbb800000-0xbfffffff]
>> [    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0x100000000-0x11abfffff]
>> [    0.000000] ACPI: SRAT: Node 7 PXM 7 [mem 0x11ac00000-0x139ffffff]
>> [    0.000000] ACPI: SRAT: Node 8 PXM 8 [mem 0x13a000000-0x1593fffff]
>> [    0.000000] ACPI: SRAT: Node 9 PXM 9 [mem 0x159400000-0x1787fffff]
>> 
>> There are 10 nodes, and 500M memory in every node.
>> And node0 and node 6 has two parts.
>> 
>> 
>> Here is the efi mem:
>> [    0.000000] efi: mem00: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000000000-0x0000000000000fff] (0MB)
>> [    0.000000] efi: mem01: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000001000-0x0000000000001fff] (0MB)
>> [    0.000000] efi: mem02: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000002000-0x000000000009ffff] (0MB)
>> [    0.000000] efi: mem03: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000100000-0x0000000000805fff] (7MB)
>> [    0.000000] efi: mem04: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000806000-0x0000000000806fff] (0MB)
>> [    0.000000] efi: mem05: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000807000-0x000000000081ffff] (0MB)
>> [    0.000000] efi: mem06: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000820000-0x00000000012fffff] (10MB)
>> [    0.000000] efi: mem07: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000001300000-0x0000000001ffffff] (13MB)
>> [    0.000000] efi: mem08: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000002000000-0x00000000036e3fff] (22MB)
>> (From mem00 to mem08, belongs to node0)
>> [    0.000000] efi: mem09: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000036e4000-0x000000003d626fff] (927MB)
>> (mem09 has part of node0 and part of node1, but not the whole of node0 and node1)
>> [    0.000000] efi: mem10: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000003d627000-0x000000003fffffff] (41MB)
>> (part of node1 and part of node2)
>> [    0.000000] efi: mem11: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000040000000-0x000000008c92dfff] (1225MB)
>> [    0.000000] efi: mem12: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000008c92e000-0x00000000bbfbdfff] (758MB)
>> [    0.000000] efi: mem13: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfbe000-0x00000000bbfddfff] (0MB)
>> [    0.000000] efi: mem14: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfde000-0x00000000be350fff] (35MB)
>> [    0.000000] efi: mem15: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be351000-0x00000000be579fff] (2MB)
>> [    0.000000] efi: mem16: [Loader Code        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be57a000-0x00000000be6a0fff] (1MB)
>> [    0.000000] efi: mem17: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be6a1000-0x00000000beb21fff] (4MB)
>> [    0.000000] efi: mem18: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beb22000-0x00000000bed95fff] (2MB)
>> [    0.000000] efi: mem19: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed96000-0x00000000bed9afff] (0MB)
>> [    0.000000] efi: mem20: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed9b000-0x00000000beda1fff] (0MB)
>> [    0.000000] efi: mem21: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda2000-0x00000000beda6fff] (0MB)
>> [    0.000000] efi: mem22: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda7000-0x00000000bedacfff] (0MB)
>> [    0.000000] efi: mem23: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedad000-0x00000000bedb1fff] (0MB)
>> [    0.000000] efi: mem24: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedb2000-0x00000000bedbafff] (0MB)
>> [    0.000000] efi: mem25: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedbb000-0x00000000bedbffff] (0MB)
>> [    0.000000] efi: mem26: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc0000-0x00000000bedc6fff] (0MB)
>> [    0.000000] efi: mem27: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc7000-0x00000000bede6fff] (0MB)
>> [    0.000000] efi: mem28: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bede7000-0x00000000bf07efff] (2MB)
>> [    0.000000] efi: mem29: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf07f000-0x00000000bf3c3fff] (3MB)
>> [    0.000000] efi: mem30: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3c4000-0x00000000bf3cdfff] (0MB)
>> [    0.000000] efi: mem31: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3ce000-0x00000000bfce6fff] (9MB)
>> [    0.000000] efi: mem32: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce7000-0x00000000bfce8fff] (0MB)
>> [    0.000000] efi: mem33: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce9000-0x00000000bfe66fff] (1MB)
>> [    0.000000] efi: mem34: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe67000-0x00000000bfe96fff] (0MB)
>> [    0.000000] efi: mem35: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe97000-0x00000000bfebafff] (0MB)
>> [    0.000000] efi: mem36: [Reserved           |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebb000-0x00000000bfebefff] (0MB)
>> [    0.000000] efi: mem37: [ACPI Reclaim Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebf000-0x00000000bfec6fff] (0MB)
>> [    0.000000] efi: mem38: [ACPI Memory NVS    |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfec7000-0x00000000bfecafff] (0MB)
>> [    0.000000] efi: mem39: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfecb000-0x00000000bffcffff] (1MB)
>> [    0.000000] efi: mem40: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bffd0000-0x00000000bffeffff] (0MB)
>> [    0.000000] efi: mem41: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfff0000-0x00000000bfffffff] (0MB)
>> [    0.000000] efi: mem42: [Runtime Data       |RUN|  |  |  |  |  |  |   |  |  |  |UC] range=[0x00000000ffe00000-0x00000000ffffffff] (2MB)
>> [    0.000000] efi: mem43: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000100000000-0x00000001787fffff] (1928MB)
>> 
>> 
>> If the information is not enough, I can add more.
>> 
>> Thanks,
>> Chao Fan
>> 
>> >
>> >Thanks
>> >Baoquan
>> >
>> >> One memory region in one node may contain several entries of e820 or
>> >> efi sometimes, and one entry of e820 or efi may contain the memory in
>> >> different nodes sometimes.
>> >> It may split one node or one entry to several regions.
>> >> 
>> >> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> >> ---
>> >>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
>> >>  1 file changed, 52 insertions(+), 8 deletions(-)
>> >> 
>> >> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> >> index 0a591c0023f1..fcd640fdeaed 100644
>> >> --- a/arch/x86/boot/compressed/kaslr.c
>> >> +++ b/arch/x86/boot/compressed/kaslr.c
>> >> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
>> >>  	}
>> >>  }
>> >>  
>> >> +static bool select_immovable_node(struct mem_vector region,
>> >> +				  unsigned long long minimum,
>> >> +				  unsigned long long image_size)
>> >> +{
>> >> +	int i;
>> >> +
>> >> +	/* If no immovable_mem stored, use region directly */
>> >> +	if (num_immovable_region == 0) {
>> >> +		process_mem_region(&region, minimum, image_size);
>> >> +
>> >> +		if (slot_area_index == MAX_SLOT_AREA) {
>> >> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> >> +			return 1;
>> >> +		}
>> >> +	} else {
>> >> +		/*
>> >> +		 * Walk all immovable regions, and filter the intersection
>> >> +		 * to process_mem_region.
>> >> +		 */
>> >> +		for (i = 0; i < num_immovable_region; i++) {
>> >> +			struct mem_vector entry;
>> >> +			unsigned long long start, end, select_end, region_end;
>> >> +
>> >> +			region_end = region.start + region.size - 1;
>> >> +			start = immovable_mem[i].start;
>> >> +			end = start + immovable_mem[i].size - 1;
>> >> +
>> >> +			if (region_end < start || region.start > end)
>> >> +				continue;
>> >> +
>> >> +			/* May split one region to several entries. */
>> >> +			entry.start = start > region.start ?
>> >> +				      start : region.start;
>> >> +			select_end = end > region_end ? region_end : end;
>> >> +
>> >> +			entry.size = select_end - entry.start + 1;
>> >> +
>> >> +			process_mem_region(&entry, minimum, image_size);
>> >> +
>> >> +			if (slot_area_index == MAX_SLOT_AREA) {
>> >> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> >> +				return 1;
>> >> +			}
>> >> +		}
>> >> +	}
>> >> +	return 0;
>> >> +}
>> >> +
>> >>  #ifdef CONFIG_EFI
>> >>  /*
>> >>   * Returns true if mirror region found (and must have been processed
>> >> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>> >>  
>> >>  		region.start = md->phys_addr;
>> >>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
>> >> -		process_mem_region(&region, minimum, image_size);
>> >> -		if (slot_area_index == MAX_SLOT_AREA) {
>> >> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
>> >> +
>> >> +		if (select_immovable_node(region, minimum, image_size))
>> >>  			break;
>> >> -		}
>> >>  	}
>> >>  	return true;
>> >>  }
>> >> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
>> >>  			continue;
>> >>  		region.start = entry->addr;
>> >>  		region.size = entry->size;
>> >> -		process_mem_region(&region, minimum, image_size);
>> >> -		if (slot_area_index == MAX_SLOT_AREA) {
>> >> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
>> >> +
>> >> +		if (select_immovable_node(region, minimum, image_size))
>> >>  			break;
>> >> -		}
>> >>  	}
>> >>  }
>> >>  
>> >> -- 
>> >> 2.13.6
>> >> 
>> >> 
>> >> 
>> >
>> >
>> 
>> 
>
>



[-- Attachment #2: efi.log --]
[-- Type: text/plain, Size: 45321 bytes --]

[    0.000000] Linux version 4.11.8-300.fc26.x86_64 (mockbuild@bkernel02.phx2.fedoraproject.org) (gcc version 7.1.1 20170622 (Red Hat 7.1.1-3) (GCC) ) #1 SMP Thu Jun 29 20:09:48 UTC 2017
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-4.11.8-300.fc26.x86_64 root=UUID=68a4bf5c-b573-4bba-9da5-f997480d5d23 ro console=ttyS0 efi=debug
[    0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[    0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[    0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009ffff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000bed95fff] usable
[    0.000000] BIOS-e820: [mem 0x00000000bed96000-0x00000000bede6fff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000bede7000-0x00000000bfe66fff] usable
[    0.000000] BIOS-e820: [mem 0x00000000bfe67000-0x00000000bfebefff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000bfebf000-0x00000000bfec6fff] ACPI data
[    0.000000] BIOS-e820: [mem 0x00000000bfec7000-0x00000000bfecafff] ACPI NVS
[    0.000000] BIOS-e820: [mem 0x00000000bfecb000-0x00000000bffcffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000bffd0000-0x00000000bffeffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000bfff0000-0x00000000bfffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000ffe00000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000001787fffff] usable
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] extended physical RAM map:
[    0.000000] reserve setup_data: [mem 0x0000000000000000-0x000000000009ffff] usable
[    0.000000] reserve setup_data: [mem 0x0000000000100000-0x00000000be352017] usable
[    0.000000] reserve setup_data: [mem 0x00000000be352018-0x00000000be389c57] usable
[    0.000000] reserve setup_data: [mem 0x00000000be389c58-0x00000000be38a017] usable
[    0.000000] reserve setup_data: [mem 0x00000000be38a018-0x00000000be393857] usable
[    0.000000] reserve setup_data: [mem 0x00000000be393858-0x00000000bed95fff] usable
[    0.000000] reserve setup_data: [mem 0x00000000bed96000-0x00000000bede6fff] reserved
[    0.000000] reserve setup_data: [mem 0x00000000bede7000-0x00000000bfe66fff] usable
[    0.000000] reserve setup_data: [mem 0x00000000bfe67000-0x00000000bfebefff] reserved
[    0.000000] reserve setup_data: [mem 0x00000000bfebf000-0x00000000bfec6fff] ACPI data
[    0.000000] reserve setup_data: [mem 0x00000000bfec7000-0x00000000bfecafff] ACPI NVS
[    0.000000] reserve setup_data: [mem 0x00000000bfecb000-0x00000000bffcffff] usable
[    0.000000] reserve setup_data: [mem 0x00000000bffd0000-0x00000000bffeffff] reserved
[    0.000000] reserve setup_data: [mem 0x00000000bfff0000-0x00000000bfffffff] usable
[    0.000000] reserve setup_data: [mem 0x00000000ffe00000-0x00000000ffffffff] reserved
[    0.000000] reserve setup_data: [mem 0x0000000100000000-0x00000001787fffff] usable
[    0.000000] efi: EFI v2.60 by EDK II
[    0.000000] efi:  SMBIOS=0xbfe98000  ACPI=0xbfec6000  ACPI 2.0=0xbfec6014  MEMATTR=0xbf1b1698 
[    0.000000] efi: mem00: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000000000-0x0000000000000fff] (0MB)
[    0.000000] efi: mem01: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000001000-0x0000000000001fff] (0MB)
[    0.000000] efi: mem02: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000002000-0x000000000009ffff] (0MB)
[    0.000000] efi: mem03: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000100000-0x0000000000805fff] (7MB)
[    0.000000] efi: mem04: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000806000-0x0000000000806fff] (0MB)
[    0.000000] efi: mem05: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000807000-0x000000000081ffff] (0MB)
[    0.000000] efi: mem06: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000820000-0x00000000012fffff] (10MB)
[    0.000000] efi: mem07: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000001300000-0x0000000001ffffff] (13MB)
[    0.000000] efi: mem08: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000002000000-0x00000000036e3fff] (22MB)
[    0.000000] efi: mem09: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000036e4000-0x000000003d626fff] (927MB)
[    0.000000] efi: mem10: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000003d627000-0x000000003fffffff] (41MB)
[    0.000000] efi: mem11: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000040000000-0x000000008c92dfff] (1225MB)
[    0.000000] efi: mem12: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000008c92e000-0x00000000bbfbdfff] (758MB)
[    0.000000] efi: mem13: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfbe000-0x00000000bbfddfff] (0MB)
[    0.000000] efi: mem14: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfde000-0x00000000be350fff] (35MB)
[    0.000000] efi: mem15: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be351000-0x00000000be579fff] (2MB)
[    0.000000] efi: mem16: [Loader Code        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be57a000-0x00000000be6a0fff] (1MB)
[    0.000000] efi: mem17: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be6a1000-0x00000000beb21fff] (4MB)
[    0.000000] efi: mem18: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beb22000-0x00000000bed95fff] (2MB)
[    0.000000] efi: mem19: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed96000-0x00000000bed9afff] (0MB)
[    0.000000] efi: mem20: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed9b000-0x00000000beda1fff] (0MB)
[    0.000000] efi: mem21: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda2000-0x00000000beda6fff] (0MB)
[    0.000000] efi: mem22: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda7000-0x00000000bedacfff] (0MB)
[    0.000000] efi: mem23: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedad000-0x00000000bedb1fff] (0MB)
[    0.000000] efi: mem24: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedb2000-0x00000000bedbafff] (0MB)
[    0.000000] efi: mem25: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedbb000-0x00000000bedbffff] (0MB)
[    0.000000] efi: mem26: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc0000-0x00000000bedc6fff] (0MB)
[    0.000000] efi: mem27: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc7000-0x00000000bede6fff] (0MB)
[    0.000000] efi: mem28: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bede7000-0x00000000bf07efff] (2MB)
[    0.000000] efi: mem29: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf07f000-0x00000000bf3c3fff] (3MB)
[    0.000000] efi: mem30: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3c4000-0x00000000bf3cdfff] (0MB)
[    0.000000] efi: mem31: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3ce000-0x00000000bfce6fff] (9MB)
[    0.000000] efi: mem32: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce7000-0x00000000bfce8fff] (0MB)
[    0.000000] efi: mem33: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce9000-0x00000000bfe66fff] (1MB)
[    0.000000] efi: mem34: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe67000-0x00000000bfe96fff] (0MB)
[    0.000000] efi: mem35: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe97000-0x00000000bfebafff] (0MB)
[    0.000000] efi: mem36: [Reserved           |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebb000-0x00000000bfebefff] (0MB)
[    0.000000] efi: mem37: [ACPI Reclaim Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebf000-0x00000000bfec6fff] (0MB)
[    0.000000] efi: mem38: [ACPI Memory NVS    |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfec7000-0x00000000bfecafff] (0MB)
[    0.000000] efi: mem39: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfecb000-0x00000000bffcffff] (1MB)
[    0.000000] efi: mem40: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bffd0000-0x00000000bffeffff] (0MB)
[    0.000000] efi: mem41: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfff0000-0x00000000bfffffff] (0MB)
[    0.000000] efi: mem42: [Runtime Data       |RUN|  |  |  |  |  |  |   |  |  |  |UC] range=[0x00000000ffe00000-0x00000000ffffffff] (2MB)
[    0.000000] efi: mem43: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000100000000-0x00000001787fffff] (1928MB)
[    0.000000] SMBIOS 2.8 present.
[    0.000000] DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
[    0.000000] Hypervisor detected: KVM
[    0.000000] e820: last_pfn = 0x178800 max_arch_pfn = 0x400000000
[    0.000000] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WC  UC- WT  
[    0.000000] e820: last_pfn = 0xc0000 max_arch_pfn = 0x400000000
[    0.000000] Secure boot disabled
[    0.000000] RAMDISK: [mem 0x3d627000-0x3e919fff]
[    0.000000] ACPI: Early table checksum verification disabled
[    0.000000] ACPI: RSDP 0x00000000BFEC6014 000024 (v02 BOCHS )
[    0.000000] ACPI: XSDT 0x00000000BFEC50E8 000044 (v01 BOCHS  BXPCFACP 00000001      01000013)
[    0.000000] ACPI: FACP 0x00000000BFEC2000 000074 (v01 BOCHS  BXPCFACP 00000001 BXPC 00000001)
[    0.000000] ACPI: DSDT 0x00000000BFEC3000 0016EC (v01 BOCHS  BXPCDSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: FACS 0x00000000BFEC9000 000040
[    0.000000] ACPI: APIC 0x00000000BFEC1000 0000C0 (v01 BOCHS  BXPCAPIC 00000001 BXPC 00000001)
[    0.000000] ACPI: SRAT 0x00000000BFEC0000 0002B0 (v01 BOCHS  BXPCSRAT 00000001 BXPC 00000001)
[    0.000000] ACPI: BGRT 0x00000000BFEBF000 000038 (v01 INTEL  EDK2     00000002      01000013)
[    0.000000] SRAT: PXM 0 -> APIC 0x00 -> Node 0
[    0.000000] SRAT: PXM 1 -> APIC 0x01 -> Node 1
[    0.000000] SRAT: PXM 2 -> APIC 0x02 -> Node 2
[    0.000000] SRAT: PXM 3 -> APIC 0x03 -> Node 3
[    0.000000] SRAT: PXM 4 -> APIC 0x04 -> Node 4
[    0.000000] SRAT: PXM 5 -> APIC 0x05 -> Node 5
[    0.000000] SRAT: PXM 6 -> APIC 0x06 -> Node 6
[    0.000000] SRAT: PXM 7 -> APIC 0x07 -> Node 7
[    0.000000] SRAT: PXM 8 -> APIC 0x08 -> Node 8
[    0.000000] SRAT: PXM 9 -> APIC 0x09 -> Node 9
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00000000-0x0009ffff]
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00100000-0x1f3fffff]
[    0.000000] ACPI: SRAT: Node 1 PXM 1 [mem 0x1f400000-0x3e7fffff]
[    0.000000] ACPI: SRAT: Node 2 PXM 2 [mem 0x3e800000-0x5dbfffff]
[    0.000000] ACPI: SRAT: Node 3 PXM 3 [mem 0x5dc00000-0x7cffffff]
[    0.000000] ACPI: SRAT: Node 4 PXM 4 [mem 0x7d000000-0x9c3fffff]
[    0.000000] ACPI: SRAT: Node 5 PXM 5 [mem 0x9c400000-0xbb7fffff]
[    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0xbb800000-0xbfffffff]
[    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0x100000000-0x11abfffff]
[    0.000000] ACPI: SRAT: Node 7 PXM 7 [mem 0x11ac00000-0x139ffffff]
[    0.000000] ACPI: SRAT: Node 8 PXM 8 [mem 0x13a000000-0x1593fffff]
[    0.000000] ACPI: SRAT: Node 9 PXM 9 [mem 0x159400000-0x1787fffff]
[    0.000000] NUMA: Node 0 [mem 0x00000000-0x0009ffff] + [mem 0x00100000-0x1f3fffff] -> [mem 0x00000000-0x1f3fffff]
[    0.000000] NUMA: Node 6 [mem 0xbb800000-0xbfffffff] + [mem 0x100000000-0x11abfffff] -> [mem 0xbb800000-0x11abfffff]
[    0.000000] NODE_DATA(0) allocated [mem 0x1f3d5000-0x1f3fffff]
[    0.000000] NODE_DATA(1) allocated [mem 0x3d5fc000-0x3d626fff]
[    0.000000] NODE_DATA(2) allocated [mem 0x5dbd5000-0x5dbfffff]
[    0.000000] NODE_DATA(3) allocated [mem 0x7cfd5000-0x7cffffff]
[    0.000000] NODE_DATA(4) allocated [mem 0x9c3d5000-0x9c3fffff]
[    0.000000] NODE_DATA(5) allocated [mem 0xbb7d5000-0xbb7fffff]
[    0.000000] NODE_DATA(6) allocated [mem 0x11abd5000-0x11abfffff]
[    0.000000] NODE_DATA(7) allocated [mem 0x139fd5000-0x139ffffff]
[    0.000000] NODE_DATA(8) allocated [mem 0x1593d5000-0x1593fffff]
[    0.000000] NODE_DATA(9) allocated [mem 0x1787d2000-0x1787fcfff]
[    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
[    0.000000] kvm-clock: cpu 0, msr 1:78752001, primary cpu clock
[    0.000000] kvm-clock: using sched offset of 374535107118 cycles
[    0.000000] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000001000-0x0000000000ffffff]
[    0.000000]   DMA32    [mem 0x0000000001000000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x00000001787fffff]
[    0.000000]   Device   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000001000-0x000000000009ffff]
[    0.000000]   node   0: [mem 0x0000000000100000-0x000000001f3fffff]
[    0.000000]   node   1: [mem 0x000000001f400000-0x000000003e7fffff]
[    0.000000]   node   2: [mem 0x000000003e800000-0x000000005dbfffff]
[    0.000000]   node   3: [mem 0x000000005dc00000-0x000000007cffffff]
[    0.000000]   node   4: [mem 0x000000007d000000-0x000000009c3fffff]
[    0.000000]   node   5: [mem 0x000000009c400000-0x00000000bb7fffff]
[    0.000000]   node   6: [mem 0x00000000bb800000-0x00000000bed95fff]
[    0.000000]   node   6: [mem 0x00000000bede7000-0x00000000bfe66fff]
[    0.000000]   node   6: [mem 0x00000000bfecb000-0x00000000bffcffff]
[    0.000000]   node   6: [mem 0x00000000bfff0000-0x00000000bfffffff]
[    0.000000]   node   6: [mem 0x0000000100000000-0x000000011abfffff]
[    0.000000]   node   7: [mem 0x000000011ac00000-0x0000000139ffffff]
[    0.000000]   node   8: [mem 0x000000013a000000-0x00000001593fffff]
[    0.000000]   node   9: [mem 0x0000000159400000-0x00000001787fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000001000-0x000000001f3fffff]
[    0.000000] Initmem setup node 1 [mem 0x000000001f400000-0x000000003e7fffff]
[    0.000000] Initmem setup node 2 [mem 0x000000003e800000-0x000000005dbfffff]
[    0.000000] Initmem setup node 3 [mem 0x000000005dc00000-0x000000007cffffff]
[    0.000000] Initmem setup node 4 [mem 0x000000007d000000-0x000000009c3fffff]
[    0.000000] Initmem setup node 5 [mem 0x000000009c400000-0x00000000bb7fffff]
[    0.000000] Initmem setup node 6 [mem 0x00000000bb800000-0x000000011abfffff]
[    0.000000] Initmem setup node 7 [mem 0x000000011ac00000-0x0000000139ffffff]
[    0.000000] Initmem setup node 8 [mem 0x000000013a000000-0x00000001593fffff]
[    0.000000] Initmem setup node 9 [mem 0x0000000159400000-0x00000001787fffff]
[    0.000000] ACPI: PM-Timer IO Port: 0xb008
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[    0.000000] IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] smpboot: Allowing 10 CPUs, 0 hotplug CPUs
[    0.000000] PM: Registered nosave memory: [mem 0x00000000-0x00000fff]
[    0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000fffff]
[    0.000000] PM: Registered nosave memory: [mem 0xbe352000-0xbe352fff]
[    0.000000] PM: Registered nosave memory: [mem 0xbe389000-0xbe389fff]
[    0.000000] PM: Registered nosave memory: [mem 0xbe38a000-0xbe38afff]
[    0.000000] PM: Registered nosave memory: [mem 0xbe393000-0xbe393fff]
[    0.000000] PM: Registered nosave memory: [mem 0xbed96000-0xbede6fff]
[    0.000000] PM: Registered nosave memory: [mem 0xbfe67000-0xbfebefff]
[    0.000000] PM: Registered nosave memory: [mem 0xbfebf000-0xbfec6fff]
[    0.000000] PM: Registered nosave memory: [mem 0xbfec7000-0xbfecafff]
[    0.000000] PM: Registered nosave memory: [mem 0xbffd0000-0xbffeffff]
[    0.000000] PM: Registered nosave memory: [mem 0xc0000000-0xffdfffff]
[    0.000000] PM: Registered nosave memory: [mem 0xffe00000-0xffffffff]
[    0.000000] e820: [mem 0xc0000000-0xffdfffff] available for PCI devices
[    0.000000] Booting paravirtualized kernel on KVM
[    0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1910969940391419 ns
[    0.000000] setup_percpu: NR_CPUS:8192 nr_cpumask_bits:10 nr_cpu_ids:10 nr_node_ids:10
[    0.000000] percpu: Embedded 36 pages/cpu @ffff9cd89e800000 s108888 r8192 d30376 u2097152
[    0.000000] KVM setup async PF for cpu 0
[    0.000000] kvm-stealtime: cpu 0, msr 1e80d900
[    0.000000] Built 10 zonelists in Node order, mobility grouping on.  Total pages: 1257654
[    0.000000] Policy zone: Normal
[    0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-4.11.8-300.fc26.x86_64 root=UUID=68a4bf5c-b573-4bba-9da5-f997480d5d23 ro console=ttyS0 efi=debug
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Memory: 4896992K/5118760K available (8688K kernel code, 1668K rwdata, 3604K rodata, 2120K init, 1816K bss, 221768K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=10, Nodes=10
[    0.001000] Hierarchical RCU implementation.
[    0.001000]  Build-time adjustment of leaf fanout to 64.
[    0.001000]  RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=10.
[    0.001000] RCU: Adjusting geometry for rcu_fanout_leaf=64, nr_cpu_ids=10
[    0.001000] NR_IRQS:524544 nr_irqs:504 16
[    0.001000]  Offload RCU callbacks from all CPUs
[    0.001000]  Offload RCU callbacks from CPUs: 0-9.
[    0.001000] Console: colour dummy device 80x25
[    0.001000] console [ttyS0] enabled
[    0.001000] mempolicy: Enabling automatic NUMA balancing. Configure with numa_balancing= or the kernel.numa_balancing sysctl
[    0.001006] tsc: Detected 3192.616 MHz processor
[    0.002005] Calibrating delay loop (skipped) preset value.. 6385.23 BogoMIPS (lpj=3192616)
[    0.004004] pid_max: default: 32768 minimum: 301
[    0.006049] ACPI: Core revision 20170119
[    0.008085] ACPI: 1 ACPI AML tables successfully acquired and loaded
[    0.010078] efi: EFI runtime memory map:
[    0.011006] efi: mem00: [Runtime Data       |RUN|  |  |  |  |  |  |   |  |  |  |UC] range=[0x00000000ffe00000-0x00000000ffffffff] (2MB)
[    0.013005] efi: mem01: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bffd0000-0x00000000bffeffff] (0MB)
[    0.015008] efi: mem02: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfecb000-0x00000000bffcffff] (1MB)
[    0.017008] efi: mem03: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe97000-0x00000000bfebafff] (0MB)
[    0.019006] efi: mem04: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe67000-0x00000000bfe96fff] (0MB)
[    0.021006] efi: mem05: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce9000-0x00000000bfe66fff] (1MB)
[    0.023005] efi: mem06: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3ce000-0x00000000bfce6fff] (9MB)
[    0.025006] efi: mem07: [Boot Data          |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf07f000-0x00000000bf3c3fff] (3MB)
[    0.026008] efi: mem08: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc7000-0x00000000bede6fff] (0MB)
[    0.027015] efi: mem09: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc0000-0x00000000bedc6fff] (0MB)
[    0.029006] efi: mem10: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedbb000-0x00000000bedbffff] (0MB)
[    0.031009] efi: mem11: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedb2000-0x00000000bedbafff] (0MB)
[    0.033007] efi: mem12: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedad000-0x00000000bedb1fff] (0MB)
[    0.035006] efi: mem13: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda7000-0x00000000bedacfff] (0MB)
[    0.037004] efi: mem14: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda2000-0x00000000beda6fff] (0MB)
[    0.039003] efi: mem15: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed9b000-0x00000000beda1fff] (0MB)
[    0.041006] efi: mem16: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed96000-0x00000000bed9afff] (0MB)
[    0.043005] efi: mem17: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beb22000-0x00000000bed95fff] (2MB)
[    0.045005] efi: mem18: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be6a1000-0x00000000beb21fff] (4MB)
[    0.047009] efi: mem19: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfbe000-0x00000000bbfddfff] (0MB)
[    0.049008] efi: mem20: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000820000-0x00000000012fffff] (10MB)
[    0.051005] efi: mem21: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000806000-0x0000000000806fff] (0MB)
[    0.053006] efi: mem22: [Boot Code          |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000000000-0x0000000000000fff] (0MB)
[    0.055092] efi: memattr: Processing EFI Memory Attributes table:
[    0.057005] efi: memattr:  0x0000bed96000-0x0000bed9afff [Runtime Data       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.059010] efi: memattr:  0x0000bed9b000-0x0000bed9bfff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.061005] efi: memattr:  0x0000bed9c000-0x0000bed9ffff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.063005] efi: memattr:  0x0000beda0000-0x0000beda1fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.065006] efi: memattr:  0x0000beda2000-0x0000beda6fff [Runtime Data       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.067005] efi: memattr:  0x0000beda7000-0x0000beda7fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.069011] efi: memattr:  0x0000beda8000-0x0000bedaafff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.071010] efi: memattr:  0x0000bedab000-0x0000bedacfff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.073008] efi: memattr:  0x0000bedad000-0x0000bedb1fff [Runtime Data       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.075007] efi: memattr:  0x0000bedb2000-0x0000bedb2fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.077005] efi: memattr:  0x0000bedb3000-0x0000bedb8fff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.079006] efi: memattr:  0x0000bedb9000-0x0000bedbafff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.081007] efi: memattr:  0x0000bedbb000-0x0000bedbffff [Runtime Data       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.083005] efi: memattr:  0x0000bedc0000-0x0000bedc0fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.085007] efi: memattr:  0x0000bedc1000-0x0000bedc4fff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.087007] efi: memattr:  0x0000bedc5000-0x0000bedc6fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.089006] efi: memattr:  0x0000bedc7000-0x0000bede6fff [Runtime Data       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.091014] efi: memattr:  0x0000bfe67000-0x0000bfe69fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.093010] efi: memattr:  0x0000bfe6a000-0x0000bfe76fff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.095010] efi: memattr:  0x0000bfe77000-0x0000bfe79fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.097006] efi: memattr:  0x0000bfe7a000-0x0000bfe7dfff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.099009] efi: memattr:  0x0000bfe7e000-0x0000bfe80fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.101008] efi: memattr:  0x0000bfe81000-0x0000bfe84fff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.103008] efi: memattr:  0x0000bfe85000-0x0000bfe87fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.105006] efi: memattr:  0x0000bfe88000-0x0000bfe8cfff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.107006] efi: memattr:  0x0000bfe8d000-0x0000bfe8ffff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.109005] efi: memattr:  0x0000bfe90000-0x0000bfe94fff [Runtime Code       |RUN|  |  |  |  |  |RO|   |  |  |  |  ]
[    0.111005] efi: memattr:  0x0000bfe95000-0x0000bfe96fff [Runtime Code       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.113013] efi: memattr:  0x0000bfe97000-0x0000bfebafff [Runtime Data       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.115013] efi: memattr:  0x0000bffd0000-0x0000bffeffff [Runtime Data       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.117010] efi: memattr:  0x0000ffe00000-0x0000ffffffff [Runtime Data       |RUN|  |  |XP|  |  |  |   |  |  |  |  ]
[    0.119136] Security Framework initialized
[    0.121004] Yama: becoming mindful.
[    0.122007] SELinux:  Initializing.
[    0.123346] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes)
[    0.127040] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes)
[    0.129298] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes)
[    0.131016] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes)
[    0.133172] CPU: Physical Processor ID: 0
[    0.134022] mce: CPU supports 10 MCE banks
[    0.136046] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.137003] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0
[    0.139102] Freeing SMP alternatives memory: 32K
[    0.141940] ftrace: allocating 31978 entries in 125 pages
[    0.149096] smpboot: Max logical packages: 10
[    0.150314] x2apic enabled
[    0.151004] Switched APIC routing to physical x2apic.
[    0.154805] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.155000] smpboot: CPU0: Intel Core Processor (Haswell, no TSX) (family: 0x6, model: 0x3c, stepping: 0x1)
[    0.155190] Performance Events: unsupported p6 CPU model 60 no PMU driver, software events only.
[    0.156619] smp: Bringing up secondary CPUs ...
[    0.157109] x86: Booting SMP configuration:
[    0.158006] .... node   #1, CPUs:        #1
[    0.001000] kvm-clock: cpu 1, msr 1:78752041, secondary cpu clock
[    0.161073] KVM setup async PF for cpu 1
[    0.162000] kvm-stealtime: cpu 1, msr 3ca0d900
[    0.164129] .... node   #2, CPUs:    #2
[    0.001000] kvm-clock: cpu 2, msr 1:78752081, secondary cpu clock
[    0.167069] KVM setup async PF for cpu 2
[    0.168000] kvm-stealtime: cpu 2, msr 5d00d900
[    0.170130] .... node   #3, CPUs:    #3
[    0.001000] kvm-clock: cpu 3, msr 1:787520c1, secondary cpu clock
[    0.173092] KVM setup async PF for cpu 3
[    0.173930] kvm-stealtime: cpu 3, msr 7c40d900
[    0.175158] .... node   #4, CPUs:    #4
[    0.001000] kvm-clock: cpu 4, msr 1:78752101, secondary cpu clock
[    0.178070] KVM setup async PF for cpu 4
[    0.179000] kvm-stealtime: cpu 4, msr 9b80d900
[    0.181005] .... node   #5, CPUs:    #5
[    0.001000] kvm-clock: cpu 5, msr 1:78752141, secondary cpu clock
[    0.188057] KVM setup async PF for cpu 5
[    0.189000] kvm-stealtime: cpu 5, msr bac0d900
[    0.191134] .... node   #6, CPUs:    #6
[    0.001000] kvm-clock: cpu 6, msr 1:78752181, secondary cpu clock
[    0.195122] KVM setup async PF for cpu 6
[    0.196000] kvm-stealtime: cpu 6, msr 11a00d900
[    0.198041] .... node   #7, CPUs:    #7
[    0.001000] kvm-clock: cpu 7, msr 1:787521c1, secondary cpu clock
[    0.206061] KVM setup async PF for cpu 7
[    0.207000] kvm-stealtime: cpu 7, msr 13940d900
[    0.210142] .... node   #8, CPUs:    #8
[    0.001000] kvm-clock: cpu 8, msr 1:78752201, secondary cpu clock
[    0.216070] KVM setup async PF for cpu 8
[    0.217000] kvm-stealtime: cpu 8, msr 15880d900
[    0.218150] .... node   #9, CPUs:    #9
[    0.001000] kvm-clock: cpu 9, msr 1:78752241, secondary cpu clock
[    0.221078] KVM setup async PF for cpu 9
[    0.221804] kvm-stealtime: cpu 9, msr 17840d900
[    0.222017] smp: Brought up 10 nodes, 10 CPUs
[    0.223008] smpboot: Total of 10 processors activated (63852.32 BogoMIPS)
[    0.228720] sched_clock: Marking stable (228000000, 0)->(1003503098, -775503098)
[    0.232781] devtmpfs: initialized
[    0.233628] x86/mm: Memory block size: 128MB
[    0.237432] PM: Registering ACPI NVS region [mem 0xbfec7000-0xbfecafff] (16384 bytes)
[    0.239382] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275000 ns
[    0.241706] futex hash table entries: 4096 (order: 6, 262144 bytes)
[    0.243267] pinctrl core: initialized pinctrl subsystem
[    0.245372] RTC time:  2:32:11, date: 11/10/17
[    0.246765] NET: Registered protocol family 16
[    0.248267] cpuidle: using governor menu
[    0.249116] PCCT header not found.
[    0.251860] ACPI: bus type PCI registered
[    0.253015] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
[    0.254819] PCI: Using configuration type 1 for base access
[    0.263009] HugeTLB registered 2 MB page size, pre-allocated 0 pages
[    0.279366] ACPI: Added _OSI(Module Device)
[    0.280464] ACPI: Added _OSI(Processor Device)
[    0.281644] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.282891] ACPI: Added _OSI(Processor Aggregator Device)
[    0.285156] ACPI: Interpreter enabled
[    0.286178] ACPI: (supports S0 S5)
[    0.287110] ACPI: Using IOAPIC for interrupt routing
[    0.288585] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.293918] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[    0.296808] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI]
[    0.298538] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
[    0.301228] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
[    0.304197] acpiphp: Slot [3] registered
[    0.305225] acpiphp: Slot [4] registered
[    0.306135] acpiphp: Slot [6] registered
[    0.307582] acpiphp: Slot [7] registered
[    0.308613] acpiphp: Slot [8] registered
[    0.309628] acpiphp: Slot [9] registered
[    0.310529] acpiphp: Slot [10] registered
[    0.311457] acpiphp: Slot [11] registered
[    0.312378] acpiphp: Slot [12] registered
[    0.313293] acpiphp: Slot [13] registered
[    0.314116] acpiphp: Slot [14] registered
[    0.314961] acpiphp: Slot [15] registered
[    0.316409] acpiphp: Slot [16] registered
[    0.317339] acpiphp: Slot [17] registered
[    0.318232] acpiphp: Slot [18] registered
[    0.319162] acpiphp: Slot [19] registered
[    0.321299] acpiphp: Slot [20] registered
[    0.322350] acpiphp: Slot [21] registered
[    0.323258] acpiphp: Slot [22] registered
[    0.324217] acpiphp: Slot [23] registered
[    0.325741] acpiphp: Slot [24] registered
[    0.326804] acpiphp: Slot [25] registered
[    0.327836] acpiphp: Slot [26] registered
[    0.329783] acpiphp: Slot [27] registered
[    0.330713] acpiphp: Slot [28] registered
[    0.331653] acpiphp: Slot [29] registered
[    0.332600] acpiphp: Slot [30] registered
[    0.333619] acpiphp: Slot [31] registered
[    0.335546] PCI host bridge to bus 0000:00
[    0.336309] pci_bus 0000:00: root bus resource [io  0x0000-0x0cf7 window]
[    0.337778] pci_bus 0000:00: root bus resource [io  0x0d00-0xffff window]
[    0.339317] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff window]
[    0.341348] pci_bus 0000:00: root bus resource [mem 0xc0000000-0xfebfffff window]
[    0.342748] pci_bus 0000:00: root bus resource [mem 0x800000000-0x800013fff window]
[    0.344444] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.365086] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io  0x01f0-0x01f7]
[    0.366893] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io  0x03f6]
[    0.370561] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io  0x0170-0x0177]
[    0.372904] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io  0x0376]
[    0.375174] pci 0000:00:01.3: quirk: [io  0xb000-0xb03f] claimed by PIIX4 ACPI
[    0.376888] pci 0000:00:01.3: quirk: [io  0xb100-0xb10f] claimed by PIIX4 SMB
[    0.727527] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 10 *11)
[    0.730378] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 10 *11)
[    0.732006] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 *10 11)
[    0.733529] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 *10 11)
[    0.734831] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
[    0.736505] ACPI: Enabled 2 GPEs in block 00 to 0F
[    0.739320] pci 0000:00:02.0: vgaarb: setting as boot VGA device
[    0.740547] pci 0000:00:02.0: vgaarb: VGA device added: decodes=io+mem,owns=io+mem,locks=none
[    0.742539] pci 0000:00:02.0: vgaarb: bridge control possible
[    0.743834] vgaarb: loaded
[    0.744642] SCSI subsystem initialized
[    0.745690] ACPI: bus type USB registered
[    0.746643] usbcore: registered new interface driver usbfs
[    0.748028] usbcore: registered new interface driver hub
[    0.749507] usbcore: registered new device driver usb
[    0.750872] Registered efivars operations
[    0.752235] PCI: Using ACPI for IRQ routing
[    0.753697] NetLabel: Initializing
[    0.754659] NetLabel:  domain hash size = 128
[    0.755896] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    0.757532] NetLabel:  unlabeled traffic allowed by default
[    0.771726] clocksource: Switched to clocksource kvm-clock
[    0.781386] VFS: Disk quotas dquot_6.6.0
[    0.782595] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.784487] pnp: PnP ACPI init
[    0.785613] pnp: PnP ACPI: found 5 devices
[    0.796851] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns
[    0.799283] pci 0000:00:02.0: can't claim BAR 6 [mem 0xffff0000-0xffffffff pref]: no compatible bridge window
[    0.801789] pci 0000:00:03.0: can't claim BAR 6 [mem 0xfffc0000-0xffffffff pref]: no compatible bridge window
[    0.804400] pci 0000:00:03.0: BAR 6: assigned [mem 0xc8040000-0xc807ffff pref]
[    0.806516] pci 0000:00:02.0: BAR 6: assigned [mem 0xc8010000-0xc801ffff pref]
[    0.808793] NET: Registered protocol family 2
[    0.809985] TCP established hash table entries: 65536 (order: 7, 524288 bytes)
[    0.811931] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
[    0.813680] TCP: Hash tables configured (established 65536 bind 65536)
[    0.815437] UDP hash table entries: 4096 (order: 5, 131072 bytes)
[    0.816968] UDP-Lite hash table entries: 4096 (order: 5, 131072 bytes)
[    0.818802] NET: Registered protocol family 1
[    0.819971] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
[    0.821661] pci 0000:00:01.0: PIIX3: Enabling Passive Release
[    0.823293] pci 0000:00:01.0: Activating ISA DMA hang workarounds
[    0.825024] pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
[    0.842915] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 11
[    0.877301] ACPI: PCI Interrupt Link [LNKB] enabled at IRQ 10
[    0.911267] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 10
[    0.945029] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 11
[    0.963686] Unpacking initramfs...
[    1.174796] Freeing initrd memory: 19404K
[    1.175950] PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
[    1.177696] software IO TLB [mem 0xb6c00000-0xbac00000] (64MB) mapped at [ffff9cd936c00000-ffff9cd93abfffff]
[    1.183521] audit: initializing netlink subsys (disabled)
[    1.185153] audit: type=2000 audit(1510281132.335:1): state=initialized audit_enabled=0 res=1
[    1.185324] Initialise system trusted keyrings
[    1.199048] workingset: timestamp_bits=36 max_order=21 bucket_order=0
[    1.201241] zbud: loaded
[    1.257620] NET: Registered protocol family 38
[    1.258777] Key type asymmetric registered
[    1.259946] Asymmetric key parser 'x509' registered
[    1.261414] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    1.273346] io scheduler noop registered
[    1.274377] io scheduler deadline registered
[    1.275457] io scheduler cfq registered (default)
[    1.276705] io scheduler mq-deadline registered
[    1.278026] atomic64_test: passed for x86-64 platform with CX8 and with SSE
[    1.279829] efifb: probing for efifb
[    1.280871] efifb: framebuffer at 0xc4000000, using 1876k, total 1875k
[    1.282792] efifb: mode is 800x600x32, linelength=3200, pages=1
[    1.284502] efifb: scrolling: redraw
[    1.285558] efifb: Truecolor: size=8:8:8:8, shift=24:16:8:0
[    1.288853] Console: switching to colour frame buffer device 100x37
[    1.291359] fb0: EFI VGA frame buffer device
[    1.293756] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
[    1.295994] ACPI: Power Button [PWRF]
[    1.297558] GHES: HEST is not enabled!
[    1.298598] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled
[    1.327673] 00:04: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    1.331042] Non-volatile memory driver v1.3
[    1.332309] Linux agpgart interface v0.103
[    1.335295] scsi host0: ata_piix
[    1.336372] scsi host1: ata_piix
[    1.337031] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc160 irq 14
[    1.338673] ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc168 irq 15
[    1.340755] libphy: Fixed MDIO Bus: probed
[    1.342394] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.344352] ehci-pci: EHCI PCI platform driver
[    1.361881] ehci-pci 0000:00:05.7: EHCI Host Controller
[    1.363584] ehci-pci 0000:00:05.7: new USB bus registered, assigned bus number 1
[    1.366029] ehci-pci 0000:00:05.7: irq 11, io mem 0xc8008000
[    1.373703] ehci-pci 0000:00:05.7: USB 2.0 started, EHCI 1.00
[    1.375975] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.377799] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.379415] usb usb1: Product: EHCI Host Controller
[    1.380519] usb usb1: Manufacturer: Linux 4.11.8-300.fc26.x86_64 ehci_hcd
[    1.382042] usb usb1: SerialNumber: 0000:00:05.7
[    1.383261] hub 1-0:1.0: USB hub found
[    1.384207] hub 1-0:1.0: 6 ports detected
[    1.385369] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.386936] ohci-pci: OHCI PCI platform driver
[    1.388046] uhci_hcd: USB Universal Host Controller Interface driver
[    1.407930] uhci_hcd 0000:00:05.0: UHCI Host Controller
[    1.409792] uhci_hcd 0000:00:05.0: new USB bus registered, assigned bus number 2
[    1.411779] uhci_hcd 0000:00:05.0: detected 2 ports
[    1.414452] uhci_hcd 0000:00:05.0: irq 11, io base 0x0000c100
[    1.416906] usb usb2: New USB device found, idVendor=1d6b, idProduct=0001
[    1.418569] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.420510] usb usb2: Product: UHCI Host Controller
[    1.421569] usb usb2: Manufacturer: Linux 4.11.8-300.fc26.x86_64 uhci_hcd
[    1.423835] usb usb2: SerialNumber: 0000:00:05.0
[    1.425353] hub 2-0:1.0: USB hub found
[    1.426436] hub 2-0:1.0: 2 ports detected
[    1.444199] uhci_hcd 0000:00:05.1: UHCI Host Controller
[    1.445880] uhci_hcd 0000:00:05.1: new USB bus registered, assigned bus number 3
[    1.448244] uhci_hcd 0000:00:05.1: detected 2 ports
[    1.449837] uhci_hcd 0000:00:05.1: irq 10, io base 0x0000c0e0
[    1.451263] usb usb3: New USB device found, idVendor=1d6b, idProduct=0001
[    1.453185] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.456175] usb usb3: Product: UHCI Host Controller
[    1.457969] usb usb3: Manufacturer: Linux 4.11.8-300.fc26.x86_64 uhci_hcd
[    1.460215] usb usb3: SerialNumber: 0000:00:05.1
[    1.461589] hub 3-0:1.0: USB hub found
[    1.462551] hub 3-0:1.0: 2 ports detected
[    1.480484] uhci_hcd 0000:00:05.2: UHCI Host Controller
[    1.482194] uhci_hcd 0000:00:05.2: new USB bus registered, assigned bus number 4
[    1.484167] uhci_hcd 0000:00:05.2: detected 2 ports
[    1.485626] uhci_hcd 0000:00:05.2: irq 10, io base 0x0000c0c0
[    1.488211] usb usb4: New USB device found, idVendor=1d6b, idProduct=0001
[    1.489983] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.491866] usb usb4: Product: UHCI Host Controller
[    1.493931] usb usb4: Manufacturer: Linux 4.11.8-300.fc26.x86_64 uhci_hcd
[    1.494877] ata1.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
[    1.498128] ata1.00: configured for MWDMA2
[    1.499699] usb usb4: SerialNumber: 0000:00:05.2
[    1.506603] hub 4-0:1.0: USB hub found
[    1.507749] scsi 0:0:0:0: CD-ROM            QEMU     QEMU DVD-ROM     2.5+ PQ: 0 ANSI: 5
[    1.510271] hub 4-0:1.0: 2 ports detected
[    1.513258] usbcore: registered new interface driver usbserial
[    1.519622] usbcore: registered new interface driver usbserial_generic
[    1.521457] usbserial: USB Serial support registered for generic
[    1.522773] i8042: PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
[    1.525530] serio: i8042 KBD port at 0x60,0x64 irq 1
[    1.526715] serio: i8042 AUX port at 0x60,0x64 irq 12
[    1.528221] mousedev: PS/2 mouse device common for all mice
[    1.529756] rtc_cmos 00:00: RTC can wake from S4
[    1.531081] sr 0:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[    1.531816] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input1
[    1.531865] rtc_cmos 00:00: rtc core: registered rtc_cmos as rtc0
[    1.535336] rtc_cmos 00:00: alarms up to one day, y3k, 114 bytes nvram
[    1.536241] device-mapper: uevent: version 1.0.3
[    1.536984] device-mapper: ioctl: 4.35.0-ioctl (2016-06-23) initialised: dm-devel@redhat.com
[    1.537957] hidraw: raw HID events driver (C) Jiri Kosina
[    1.538407] usbcore: registered new interface driver usbhid
[    1.538410] usbhid: USB HID core driver
[    1.538646] drop_monitor: Initializing network drop monitor service
[    1.540586] ip_tables: (C) 2000-2006 Netfilter Core Team
[    1.554470] Initializing XFRM netlink socket
[    1.558601] NET: Registered protocol family 10
[    1.563027] Segment Routing with IPv6
[    1.563039] mip6: Mobile IPv6
[    1.563040] NET: Registered protocol family 17
[    1.569449] cdrom: Uniform CD-ROM driver Revision: 3.20
[    1.571735] AVX2 version of gcm_enc/dec engaged.
[    1.572771] AES CTR mode by8 optimization enabled
[    1.573304] sr 0:0:0:0: Attached scsi generic sg0 type 5
[    1.588219] registered taskstats version 1
[    1.589316] Loading compiled-in X.509 certificates
[    1.591808] alg: No test for pkcs1pad(rsa,sha256) (pkcs1pad(rsa-generic,sha256))
[    1.594635] Loaded X.509 cert 'Fedora kernel signing key: a97d6306ae6a6507bdc5a7857746bd9b5938a8b2'
[    1.597559] zswap: loaded using pool lzo/zbud
[    1.610322] Key type big_key registered
[    1.612801] Key type encrypted registered
[    1.614801]   Magic number: 9:468:510
[    1.616195] rtc_cmos 00:00: setting system clock to 2017-11-10 02:32:12 UTC (1510281132)
[    1.619848] Freeing unused kernel memory: 2120K
[    1.620905] Write protecting the kernel read-only data: 14336k
[    1.623755] Freeing unused kernel memory: 1536K
[    1.626149] Freeing unused kernel memory: 492K
[    1.628518] x86/mm: Checked W+X mappings: passed, no W+X pages found.
[    1.630269] rodata_test: all tests were successful
[    1.636067] random: systemd: uninitialized urandom read (16 bytes read)
[    1.637943] random: systemd: uninitialized urandom read (16 bytes read)
[    1.639882] random: systemd: uninitialized urandom read (16 bytes read)
[    1.685627] systemd[1]: systemd 233 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN default-hierarchy=hybrid)
[    1.690867] systemd[1]: Detected virtualization kvm.
[    1.693337] systemd[1]: Detected architecture x86-64.
[    1.694809] usb 1-1: new high-speed USB device number 2 using ehci-pci
[    1.696675] systemd[1]: Running in initial RAM disk.

Welcome to Fedora 26 (Workstation Edition) dracut-044-183.fc26 (Initramfs)!


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-10  3:14       ` Baoquan He
  2017-11-10  4:20         ` Chao Fan
@ 2017-11-10  6:02         ` Chao Fan
  1 sibling, 0 replies; 20+ messages in thread
From: Chao Fan @ 2017-11-10  6:02 UTC (permalink / raw)
  To: Baoquan He
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

[-- Attachment #1: Type: text/plain, Size: 12362 bytes --]

On Fri, Nov 10, 2017 at 11:14:37AM +0800, Baoquan He wrote:
>On 11/10/17 at 11:03am, Chao Fan wrote:
>> On Thu, Nov 09, 2017 at 04:21:32PM +0800, Baoquan He wrote:
>> >Hi Chao,
>> >
>> >On 11/01/17 at 07:32pm, Chao Fan wrote:
>> >> Compare the region of memmap entry and immovable_mem, then choose the
>> >> intersection to process_mem_region.
>> >> 
>> >> Since the interrelationship between e820 or efi entries and memory
>> >> region in immovable_mem is different:
>> >
>> >Could you paste a bootlog with efi=debug specified in cmdline on the
>> >system you tested? I want to check what kind of intersection between
>> >them. The adding makes code pretty ugly, want to make sure if we have
>> >to do like this.
>> Hi Baoquan,
>> 
>> Here is a machine with efi.
>

Here is a log for e820, also 10 nodes in this machine.

Thanks,
Chao Fan

>Thanks, do you have the whole boot log? I want to have a look at e820.
>And this is a special system, or a customized system? I mean you just
>customize the firmware for better testing to cover kinds of cases.
>
>If it's too big, please attach it and send to me privately.
>
>Anyway, seems your considering about the intersection is right.
>
>Thanks
>Baoquan
>> 
>> The memory information in SRAT from dmesg:
>> [    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00000000-0x0009ffff]
>> [    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00100000-0x1f3fffff]
>> [    0.000000] ACPI: SRAT: Node 1 PXM 1 [mem 0x1f400000-0x3e7fffff]
>> [    0.000000] ACPI: SRAT: Node 2 PXM 2 [mem 0x3e800000-0x5dbfffff]
>> [    0.000000] ACPI: SRAT: Node 3 PXM 3 [mem 0x5dc00000-0x7cffffff]
>> [    0.000000] ACPI: SRAT: Node 4 PXM 4 [mem 0x7d000000-0x9c3fffff]
>> [    0.000000] ACPI: SRAT: Node 5 PXM 5 [mem 0x9c400000-0xbb7fffff]
>> [    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0xbb800000-0xbfffffff]
>> [    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0x100000000-0x11abfffff]
>> [    0.000000] ACPI: SRAT: Node 7 PXM 7 [mem 0x11ac00000-0x139ffffff]
>> [    0.000000] ACPI: SRAT: Node 8 PXM 8 [mem 0x13a000000-0x1593fffff]
>> [    0.000000] ACPI: SRAT: Node 9 PXM 9 [mem 0x159400000-0x1787fffff]
>> 
>> There are 10 nodes, and 500M memory in every node.
>> And node0 and node 6 has two parts.
>> 
>> 
>> Here is the efi mem:
>> [    0.000000] efi: mem00: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000000000-0x0000000000000fff] (0MB)
>> [    0.000000] efi: mem01: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000001000-0x0000000000001fff] (0MB)
>> [    0.000000] efi: mem02: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000002000-0x000000000009ffff] (0MB)
>> [    0.000000] efi: mem03: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000100000-0x0000000000805fff] (7MB)
>> [    0.000000] efi: mem04: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000806000-0x0000000000806fff] (0MB)
>> [    0.000000] efi: mem05: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000807000-0x000000000081ffff] (0MB)
>> [    0.000000] efi: mem06: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000000820000-0x00000000012fffff] (10MB)
>> [    0.000000] efi: mem07: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000001300000-0x0000000001ffffff] (13MB)
>> [    0.000000] efi: mem08: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000002000000-0x00000000036e3fff] (22MB)
>> (From mem00 to mem08, belongs to node0)
>> [    0.000000] efi: mem09: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000036e4000-0x000000003d626fff] (927MB)
>> (mem09 has part of node0 and part of node1, but not the whole of node0 and node1)
>> [    0.000000] efi: mem10: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000003d627000-0x000000003fffffff] (41MB)
>> (part of node1 and part of node2)
>> [    0.000000] efi: mem11: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000040000000-0x000000008c92dfff] (1225MB)
>> [    0.000000] efi: mem12: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x000000008c92e000-0x00000000bbfbdfff] (758MB)
>> [    0.000000] efi: mem13: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfbe000-0x00000000bbfddfff] (0MB)
>> [    0.000000] efi: mem14: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bbfde000-0x00000000be350fff] (35MB)
>> [    0.000000] efi: mem15: [Loader Data        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be351000-0x00000000be579fff] (2MB)
>> [    0.000000] efi: mem16: [Loader Code        |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be57a000-0x00000000be6a0fff] (1MB)
>> [    0.000000] efi: mem17: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000be6a1000-0x00000000beb21fff] (4MB)
>> [    0.000000] efi: mem18: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beb22000-0x00000000bed95fff] (2MB)
>> [    0.000000] efi: mem19: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed96000-0x00000000bed9afff] (0MB)
>> [    0.000000] efi: mem20: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bed9b000-0x00000000beda1fff] (0MB)
>> [    0.000000] efi: mem21: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda2000-0x00000000beda6fff] (0MB)
>> [    0.000000] efi: mem22: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000beda7000-0x00000000bedacfff] (0MB)
>> [    0.000000] efi: mem23: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedad000-0x00000000bedb1fff] (0MB)
>> [    0.000000] efi: mem24: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedb2000-0x00000000bedbafff] (0MB)
>> [    0.000000] efi: mem25: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedbb000-0x00000000bedbffff] (0MB)
>> [    0.000000] efi: mem26: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc0000-0x00000000bedc6fff] (0MB)
>> [    0.000000] efi: mem27: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bedc7000-0x00000000bede6fff] (0MB)
>> [    0.000000] efi: mem28: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bede7000-0x00000000bf07efff] (2MB)
>> [    0.000000] efi: mem29: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf07f000-0x00000000bf3c3fff] (3MB)
>> [    0.000000] efi: mem30: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3c4000-0x00000000bf3cdfff] (0MB)
>> [    0.000000] efi: mem31: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bf3ce000-0x00000000bfce6fff] (9MB)
>> [    0.000000] efi: mem32: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce7000-0x00000000bfce8fff] (0MB)
>> [    0.000000] efi: mem33: [Boot Code          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfce9000-0x00000000bfe66fff] (1MB)
>> [    0.000000] efi: mem34: [Runtime Code       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe67000-0x00000000bfe96fff] (0MB)
>> [    0.000000] efi: mem35: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfe97000-0x00000000bfebafff] (0MB)
>> [    0.000000] efi: mem36: [Reserved           |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebb000-0x00000000bfebefff] (0MB)
>> [    0.000000] efi: mem37: [ACPI Reclaim Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfebf000-0x00000000bfec6fff] (0MB)
>> [    0.000000] efi: mem38: [ACPI Memory NVS    |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfec7000-0x00000000bfecafff] (0MB)
>> [    0.000000] efi: mem39: [Boot Data          |   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfecb000-0x00000000bffcffff] (1MB)
>> [    0.000000] efi: mem40: [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bffd0000-0x00000000bffeffff] (0MB)
>> [    0.000000] efi: mem41: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x00000000bfff0000-0x00000000bfffffff] (0MB)
>> [    0.000000] efi: mem42: [Runtime Data       |RUN|  |  |  |  |  |  |   |  |  |  |UC] range=[0x00000000ffe00000-0x00000000ffffffff] (2MB)
>> [    0.000000] efi: mem43: [Conventional Memory|   |  |  |  |  |  |  |   |WB|WT|WC|UC] range=[0x0000000100000000-0x00000001787fffff] (1928MB)
>> 
>> 
>> If the information is not enough, I can add more.
>> 
>> Thanks,
>> Chao Fan
>> 
>> >
>> >Thanks
>> >Baoquan
>> >
>> >> One memory region in one node may contain several entries of e820 or
>> >> efi sometimes, and one entry of e820 or efi may contain the memory in
>> >> different nodes sometimes.
>> >> It may split one node or one entry to several regions.
>> >> 
>> >> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> >> ---
>> >>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
>> >>  1 file changed, 52 insertions(+), 8 deletions(-)
>> >> 
>> >> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> >> index 0a591c0023f1..fcd640fdeaed 100644
>> >> --- a/arch/x86/boot/compressed/kaslr.c
>> >> +++ b/arch/x86/boot/compressed/kaslr.c
>> >> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
>> >>  	}
>> >>  }
>> >>  
>> >> +static bool select_immovable_node(struct mem_vector region,
>> >> +				  unsigned long long minimum,
>> >> +				  unsigned long long image_size)
>> >> +{
>> >> +	int i;
>> >> +
>> >> +	/* If no immovable_mem stored, use region directly */
>> >> +	if (num_immovable_region == 0) {
>> >> +		process_mem_region(&region, minimum, image_size);
>> >> +
>> >> +		if (slot_area_index == MAX_SLOT_AREA) {
>> >> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> >> +			return 1;
>> >> +		}
>> >> +	} else {
>> >> +		/*
>> >> +		 * Walk all immovable regions, and filter the intersection
>> >> +		 * to process_mem_region.
>> >> +		 */
>> >> +		for (i = 0; i < num_immovable_region; i++) {
>> >> +			struct mem_vector entry;
>> >> +			unsigned long long start, end, select_end, region_end;
>> >> +
>> >> +			region_end = region.start + region.size - 1;
>> >> +			start = immovable_mem[i].start;
>> >> +			end = start + immovable_mem[i].size - 1;
>> >> +
>> >> +			if (region_end < start || region.start > end)
>> >> +				continue;
>> >> +
>> >> +			/* May split one region to several entries. */
>> >> +			entry.start = start > region.start ?
>> >> +				      start : region.start;
>> >> +			select_end = end > region_end ? region_end : end;
>> >> +
>> >> +			entry.size = select_end - entry.start + 1;
>> >> +
>> >> +			process_mem_region(&entry, minimum, image_size);
>> >> +
>> >> +			if (slot_area_index == MAX_SLOT_AREA) {
>> >> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> >> +				return 1;
>> >> +			}
>> >> +		}
>> >> +	}
>> >> +	return 0;
>> >> +}
>> >> +
>> >>  #ifdef CONFIG_EFI
>> >>  /*
>> >>   * Returns true if mirror region found (and must have been processed
>> >> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>> >>  
>> >>  		region.start = md->phys_addr;
>> >>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
>> >> -		process_mem_region(&region, minimum, image_size);
>> >> -		if (slot_area_index == MAX_SLOT_AREA) {
>> >> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
>> >> +
>> >> +		if (select_immovable_node(region, minimum, image_size))
>> >>  			break;
>> >> -		}
>> >>  	}
>> >>  	return true;
>> >>  }
>> >> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
>> >>  			continue;
>> >>  		region.start = entry->addr;
>> >>  		region.size = entry->size;
>> >> -		process_mem_region(&region, minimum, image_size);
>> >> -		if (slot_area_index == MAX_SLOT_AREA) {
>> >> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
>> >> +
>> >> +		if (select_immovable_node(region, minimum, image_size))
>> >>  			break;
>> >> -		}
>> >>  	}
>> >>  }
>> >>  
>> >> -- 
>> >> 2.13.6
>> >> 
>> >> 
>> >> 
>> >
>> >
>> 
>> 
>
>



[-- Attachment #2: e820.log --]
[-- Type: text/plain, Size: 30118 bytes --]

early console in extract_kernel
input_data: 0x00000000023763b4
input_len: 0x0000000000757590
output: 0x0000000001000000
output_len: 0x0000000001aa1d24
kernel_total_size: 0x00000000017cd000
booted via startup_32()
bios_entry: 0x0000000000000000
entry->addr: 0x0000000000000000
entry->size: 0x000000000009fc00
-----------------
bios_entry: 0x0000000000000001
entry->addr: 0x000000000009fc00
entry->size: 0x0000000000000400
-----------------
bios_entry: 0x0000000000000002
entry->addr: 0x00000000000f0000
entry->size: 0x0000000000010000
-----------------
bios_entry: 0x0000000000000003
entry->addr: 0x0000000000100000
entry->size: 0x00000000bfed9000
-----------------
bios_entry: 0x0000000000000004
entry->addr: 0x00000000bffd9000
entry->size: 0x0000000000027000
-----------------
bios_entry: 0x0000000000000005
entry->addr: 0x00000000feffc000
entry->size: 0x0000000000004000
-----------------
bios_entry: 0x0000000000000006
entry->addr: 0x00000000fffc0000
entry->size: 0x0000000000040000
-----------------
bios_entry: 0x0000000000000007
entry->addr: 0x0000000100000000
entry->size: 0x0000000078800000
-----------------
Physical KASLR using RDRAND RDTSC...
Virtual KASLR using RDRAND RDTSC...

Decompressing Linux... Parsing ELF... Performing relocations... done.
Booting the kernel.
[    0.000000] Linux version 4.14.0-rc8+ (root@localhost.localdomain) (gcc version 7.1.1 20170622 (Red Hat 7.1.1-3) (GCC)) #8 SMP Fri Nov 10 13:50:25 CST 2017
[    0.000000] Command line: BOOT_IMAGE=/vmlinuz-4.14.0-rc8+ root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap console=ttyS0 earlyprintk=serial,0x3f8,115200 movable_node=2G movable_node=1G@4G LANG=en_US.UTF-8
[    0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[    0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[    0.000000] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256
[    0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000bffd8fff] usable
[    0.000000] BIOS-e820: [mem 0x00000000bffd9000-0x00000000bfffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000feffc000-0x00000000feffffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000001787fffff] usable
[    0.000000] bootconsole [earlyser0] enabled
[    0.000000] NX (Execute Disable) protection: active
[    0.000000] random: fast init done
[    0.000000] SMBIOS 2.8 present.
[    0.000000] DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1.fc26 04/01/2014
[    0.000000] Hypervisor detected: KVM
[    0.000000] e820: last_pfn = 0x178800 max_arch_pfn = 0x400000000
[    0.000000] x86/PAT: Configuration [0-7]: WB  WC  UC- UC  WB  WP  UC- WT  
Memory KASLR using RDRAND RDTSC...
[    0.000000] e820: last_pfn = 0xbffd9 max_arch_pfn = 0x400000000
[    0.000000] found SMP MP-table at [mem 0x000f6b10-0x000f6b1f] mapped at [fffffffffd200b10]
[    0.000000] RAMDISK: [mem 0x3273c000-0x35395fff]
[    0.000000] ACPI: Early table checksum verification disabled
[    0.000000] ACPI: RSDP 0x00000000000F6AC0 000014 (v00 BOCHS )
[    0.000000] ACPI: RSDT 0x00000000BFFE16E2 000030 (v01 BOCHS  BXPCRSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: FACP 0x00000000BFFE12FE 000074 (v01 BOCHS  BXPCFACP 00000001 BXPC 00000001)
[    0.000000] ACPI: DSDT 0x00000000BFFDFC40 0016BE (v01 BOCHS  BXPCDSDT 00000001 BXPC 00000001)
[    0.000000] ACPI: FACS 0x00000000BFFDFC00 000040
[    0.000000] ACPI: APIC 0x00000000BFFE1372 0000C0 (v01 BOCHS  BXPCAPIC 00000001 BXPC 00000001)
[    0.000000] ACPI: SRAT 0x00000000BFFE1432 0002B0 (v01 BOCHS  BXPCSRAT 00000001 BXPC 00000001)
[    0.000000] SRAT: PXM 0 -> APIC 0x00 -> Node 0
[    0.000000] SRAT: PXM 1 -> APIC 0x01 -> Node 1
[    0.000000] SRAT: PXM 2 -> APIC 0x02 -> Node 2
[    0.000000] SRAT: PXM 3 -> APIC 0x03 -> Node 3
[    0.000000] SRAT: PXM 4 -> APIC 0x04 -> Node 4
[    0.000000] SRAT: PXM 5 -> APIC 0x05 -> Node 5
[    0.000000] SRAT: PXM 6 -> APIC 0x06 -> Node 6
[    0.000000] SRAT: PXM 7 -> APIC 0x07 -> Node 7
[    0.000000] SRAT: PXM 8 -> APIC 0x08 -> Node 8
[    0.000000] SRAT: PXM 9 -> APIC 0x09 -> Node 9
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00000000-0x0009ffff]
[    0.000000] ACPI: SRAT: Node 0 PXM 0 [mem 0x00100000-0x1f3fffff]
[    0.000000] ACPI: SRAT: Node 1 PXM 1 [mem 0x1f400000-0x3e7fffff]
[    0.000000] ACPI: SRAT: Node 2 PXM 2 [mem 0x3e800000-0x5dbfffff]
[    0.000000] ACPI: SRAT: Node 3 PXM 3 [mem 0x5dc00000-0x7cffffff]
[    0.000000] ACPI: SRAT: Node 4 PXM 4 [mem 0x7d000000-0x9c3fffff]
[    0.000000] ACPI: SRAT: Node 5 PXM 5 [mem 0x9c400000-0xbb7fffff]
[    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0xbb800000-0xbfffffff]
[    0.000000] ACPI: SRAT: Node 6 PXM 6 [mem 0x100000000-0x11abfffff]
[    0.000000] ACPI: SRAT: Node 7 PXM 7 [mem 0x11ac00000-0x139ffffff]
[    0.000000] ACPI: SRAT: Node 8 PXM 8 [mem 0x13a000000-0x1593fffff]
[    0.000000] ACPI: SRAT: Node 9 PXM 9 [mem 0x159400000-0x1787fffff]
[    0.000000] NUMA: Node 0 [mem 0x00000000-0x0009ffff] + [mem 0x00100000-0x1f3fffff] -> [mem 0x00000000-0x1f3fffff]
[    0.000000] NUMA: Node 6 [mem 0xbb800000-0xbfffffff] + [mem 0x100000000-0x11abfffff] -> [mem 0xbb800000-0x11abfffff]
[    0.000000] NODE_DATA(0) allocated [mem 0x1f3d5000-0x1f3fffff]
[    0.000000] NODE_DATA(1) allocated [mem 0x3e7d5000-0x3e7fffff]
[    0.000000] NODE_DATA(2) allocated [mem 0x5dbd5000-0x5dbfffff]
[    0.000000] NODE_DATA(3) allocated [mem 0x7cfd5000-0x7cffffff]
[    0.000000] NODE_DATA(4) allocated [mem 0x9c3d5000-0x9c3fffff]
[    0.000000] NODE_DATA(5) allocated [mem 0xbb7d5000-0xbb7fffff]
[    0.000000] NODE_DATA(6) allocated [mem 0x11abd5000-0x11abfffff]
[    0.000000] NODE_DATA(7) allocated [mem 0x139fd5000-0x139ffffff]
[    0.000000] NODE_DATA(8) allocated [mem 0x1593d5000-0x1593fffff]
[    0.000000] NODE_DATA(9) allocated [mem 0x1787d5000-0x1787fffff]
[    0.000000] kvm-clock: cpu 0, msr 1:78754001, primary cpu clock
[    0.000000] kvm-clock: Using msrs 4b564d01 and 4b564d00
[    0.000000] kvm-clock: using sched offset of 8703897114962 cycles
[    0.000000] clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000000001000-0x0000000000ffffff]
[    0.000000]   DMA32    [mem 0x0000000001000000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x00000001787fffff]
[    0.000000]   Device   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000001000-0x000000000009efff]
[    0.000000]   node   0: [mem 0x0000000000100000-0x000000001f3fffff]
[    0.000000]   node   1: [mem 0x000000001f400000-0x000000003e7fffff]
[    0.000000]   node   2: [mem 0x000000003e800000-0x000000005dbfffff]
[    0.000000]   node   3: [mem 0x000000005dc00000-0x000000007cffffff]
[    0.000000]   node   4: [mem 0x000000007d000000-0x000000009c3fffff]
[    0.000000]   node   5: [mem 0x000000009c400000-0x00000000bb7fffff]
[    0.000000]   node   6: [mem 0x00000000bb800000-0x00000000bffd8fff]
[    0.000000]   node   6: [mem 0x0000000100000000-0x000000011abfffff]
[    0.000000]   node   7: [mem 0x000000011ac00000-0x0000000139ffffff]
[    0.000000]   node   8: [mem 0x000000013a000000-0x00000001593fffff]
[    0.000000]   node   9: [mem 0x0000000159400000-0x00000001787fffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000001000-0x000000001f3fffff]
[    0.000000] Initmem setup node 1 [mem 0x000000001f400000-0x000000003e7fffff]
[    0.000000] Initmem setup node 2 [mem 0x000000003e800000-0x000000005dbfffff]
[    0.000000] Initmem setup node 3 [mem 0x000000005dc00000-0x000000007cffffff]
[    0.000000] Initmem setup node 4 [mem 0x000000007d000000-0x000000009c3fffff]
[    0.000000] Initmem setup node 5 [mem 0x000000009c400000-0x00000000bb7fffff]
[    0.000000] Initmem setup node 6 [mem 0x00000000bb800000-0x000000011abfffff]
[    0.000000] Initmem setup node 7 [mem 0x000000011ac00000-0x0000000139ffffff]
[    0.000000] Initmem setup node 8 [mem 0x000000013a000000-0x00000001593fffff]
[    0.000000] Initmem setup node 9 [mem 0x0000000159400000-0x00000001787fffff]
[    0.000000] ACPI: PM-Timer IO Port: 0x608
[    0.000000] ACPI: LAPIC_NMI (acpi_id[0xff] dfl dfl lint[0x1])
[    0.000000] IOAPIC[0]: apic_id 0, version 17, address 0xfec00000, GSI 0-23
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high level)
[    0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq 11 high level)
[    0.000000] Using ACPI (MADT) for SMP configuration information
[    0.000000] smpboot: Allowing 10 CPUs, 0 hotplug CPUs
[    0.000000] PM: Registered nosave memory: [mem 0x00000000-0x00000fff]
[    0.000000] PM: Registered nosave memory: [mem 0x0009f000-0x0009ffff]
[    0.000000] PM: Registered nosave memory: [mem 0x000a0000-0x000effff]
[    0.000000] PM: Registered nosave memory: [mem 0x000f0000-0x000fffff]
[    0.000000] PM: Registered nosave memory: [mem 0xbffd9000-0xbfffffff]
[    0.000000] PM: Registered nosave memory: [mem 0xc0000000-0xfeffbfff]
[    0.000000] PM: Registered nosave memory: [mem 0xfeffc000-0xfeffffff]
[    0.000000] PM: Registered nosave memory: [mem 0xff000000-0xfffbffff]
[    0.000000] PM: Registered nosave memory: [mem 0xfffc0000-0xffffffff]
[    0.000000] e820: [mem 0xc0000000-0xfeffbfff] available for PCI devices
[    0.000000] Booting paravirtualized kernel on KVM
[    0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1910969940391419 ns
[    0.000000] setup_percpu: NR_CPUS:8192 nr_cpumask_bits:10 nr_cpu_ids:10 nr_node_ids:10
[    0.000000] percpu: Embedded 37 pages/cpu @ffffa0d41e800000 s112088 r8192 d31272 u2097152
[    0.000000] KVM setup async PF for cpu 0
[    0.000000] kvm-stealtime: cpu 0, msr 1e80d940
[    0.000000] Built 10 zonelists, mobility grouping on.  Total pages: 1259842
[    0.000000] Policy zone: Normal
[    0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-4.14.0-rc8+ root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap console=ttyS0 earlyprintk=serial,0x3f8,115200 movable_node=2G movable_node=1G@4G LANG=en_US.UTF-8
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] Memory: 4897984K/5119452K available (8536K kernel code, 2294K rwdata, 3772K rodata, 2196K init, 1952K bss, 221468K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=10, Nodes=10
[    0.000000] ftrace: allocating 34899 entries in 137 pages
[    0.001000] Hierarchical RCU implementation.
[    0.001000] 	RCU restricting CPUs from NR_CPUS=8192 to nr_cpu_ids=10.
[    0.001000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=10
[    0.001000] NR_IRQS: 524544, nr_irqs: 504, preallocated irqs: 16
[    0.001000] 	Offload RCU callbacks from CPUs: .
[    0.001000] Console: colour VGA+ 80x25
[    0.001000] console [ttyS0] enabled
[    0.001000] console [ttyS0] enabled
[    0.001000] bootconsole [earlyser0] disabled
[    0.001000] bootconsole [earlyser0] disabled
[    0.001000] mempolicy: Enabling automatic NUMA balancing. Configure with numa_balancing= or the kernel.numa_balancing sysctl
[    0.001000] ACPI: Core revision 20170728
[    0.001000] ACPI: 1 ACPI AML tables successfully acquired and loaded
[    0.001014] APIC: Switch to symmetric I/O mode setup
[    0.002298] x2apic enabled
[    0.003005] Switched APIC routing to physical x2apic.
[    0.006399] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1
[    0.007000] tsc: Detected 3192.616 MHz processor
[    0.007006] Calibrating delay loop (skipped) preset value.. 6385.23 BogoMIPS (lpj=3192616)
[    0.010002] pid_max: default: 32768 minimum: 301
[    0.011111] Security Framework initialized
[    0.012002] Yama: becoming mindful.
[    0.013004] SELinux:  Initializing.
[    0.015268] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes)
[    0.017583] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes)
[    0.019042] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes)
[    0.021017] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes)
[    0.022249] CPU: Physical Processor ID: 0
[    0.023023] mce: CPU supports 10 MCE banks
[    0.024036] Last level iTLB entries: 4KB 0, 2MB 0, 4MB 0
[    0.025001] Last level dTLB entries: 4KB 0, 2MB 0, 4MB 0, 1GB 0
[    0.027075] Freeing SMP alternatives memory: 32K
[    0.029152] smpboot: Max logical packages: 10
[    0.030023] smpboot: CPU0: Intel Core Processor (Haswell, no TSX) (family: 0x6, model: 0x3c, stepping: 0x1)
[    0.031213] Performance Events: unsupported p6 CPU model 60 no PMU driver, software events only.
[    0.032048] Hierarchical SRCU implementation.
[    0.033506] NMI watchdog: Perf event create on CPU 0 failed with -2
[    0.034004] NMI watchdog: Perf NMI watchdog permanently disabled
[    0.035133] smp: Bringing up secondary CPUs ...
[    0.036083] x86: Booting SMP configuration:
[    0.037004] .... node   #1, CPUs:        #1
[    0.001000] kvm-clock: cpu 1, msr 1:78754041, secondary cpu clock
[    0.040101] KVM setup async PF for cpu 1
[    0.040941] kvm-stealtime: cpu 1, msr 3dc0d940
[    0.042127] .... node   #2, CPUs:    #2
[    0.001000] kvm-clock: cpu 2, msr 1:78754081, secondary cpu clock
[    0.045049] KVM setup async PF for cpu 2
[    0.045838] kvm-stealtime: cpu 2, msr 5d00d940
[    0.047104] .... node   #3, CPUs:    #3
[    0.001000] kvm-clock: cpu 3, msr 1:787540c1, secondary cpu clock
[    0.050051] KVM setup async PF for cpu 3
[    0.050802] kvm-stealtime: cpu 3, msr 7c40d940
[    0.052092] .... node   #4, CPUs:    #4
[    0.001000] kvm-clock: cpu 4, msr 1:78754101, secondary cpu clock
[    0.055045] KVM setup async PF for cpu 4
[    0.055806] kvm-stealtime: cpu 4, msr 9b80d940
[    0.056113] .... node   #5, CPUs:    #5
[    0.001000] kvm-clock: cpu 5, msr 1:78754141, secondary cpu clock
[    0.059060] KVM setup async PF for cpu 5
[    0.059811] kvm-stealtime: cpu 5, msr bac0d940
[    0.061005] .... node   #6, CPUs:    #6
[    0.001000] kvm-clock: cpu 6, msr 1:78754181, secondary cpu clock
[    0.064043] KVM setup async PF for cpu 6
[    0.064844] kvm-stealtime: cpu 6, msr 11a00d940
[    0.066105] .... node   #7, CPUs:    #7
[    0.001000] kvm-clock: cpu 7, msr 1:787541c1, secondary cpu clock
[    0.069057] KVM setup async PF for cpu 7
[    0.069933] kvm-stealtime: cpu 7, msr 13940d940
[    0.071105] .... node   #8, CPUs:    #8
[    0.001000] kvm-clock: cpu 8, msr 1:78754201, secondary cpu clock
[    0.074048] KVM setup async PF for cpu 8
[    0.074836] kvm-stealtime: cpu 8, msr 15880d940
[    0.076109] .... node   #9, CPUs:    #9
[    0.001000] kvm-clock: cpu 9, msr 1:78754241, secondary cpu clock
[    0.078082] KVM setup async PF for cpu 9
[    0.078880] kvm-stealtime: cpu 9, msr 17840d940
[    0.080018] smp: Brought up 10 nodes, 10 CPUs
[    0.081005] smpboot: Total of 10 processors activated (63852.32 BogoMIPS)
[    0.088771] devtmpfs: initialized
[    0.089038] x86/mm: Memory block size: 128MB
[    0.091073] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275000 ns
[    0.092027] futex hash table entries: 4096 (order: 6, 262144 bytes)
[    0.093153] pinctrl core: initialized pinctrl subsystem
[    0.094113] RTC time:  5:59:08, date: 11/10/17
[    0.095283] NET: Registered protocol family 16
[    0.096138] cpuidle: using governor menu
[    0.098970] ACPI: bus type PCI registered
[    0.099005] acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5
[    0.100150] PCI: Using configuration type 1 for base access
[    0.104021] HugeTLB registered 2.00 MiB page size, pre-allocated 0 pages
[    0.108115] ACPI: Added _OSI(Module Device)
[    0.109005] ACPI: Added _OSI(Processor Device)
[    0.110003] ACPI: Added _OSI(3.0 _SCP Extensions)
[    0.111003] ACPI: Added _OSI(Processor Aggregator Device)
[    0.112761] ACPI: Interpreter enabled
[    0.113011] ACPI: (supports S0 S5)
[    0.113854] ACPI: Using IOAPIC for interrupt routing
[    0.114013] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
[    0.115126] ACPI: Enabled 2 GPEs in block 00 to 0F
[    0.118021] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
[    0.119011] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI]
[    0.120013] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
[    0.121010] acpi PNP0A03:00: fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.
[    0.122219] acpiphp: Slot [3] registered
[    0.123023] acpiphp: Slot [4] registered
[    0.124010] acpiphp: Slot [6] registered
[    0.124953] acpiphp: Slot [7] registered
[    0.125022] acpiphp: Slot [8] registered
[    0.125935] acpiphp: Slot [9] registered
[    0.126022] acpiphp: Slot [10] registered
[    0.126944] acpiphp: Slot [11] registered
[    0.127023] acpiphp: Slot [12] registered
[    0.127967] acpiphp: Slot [13] registered
[    0.128022] acpiphp: Slot [14] registered
[    0.128956] acpiphp: Slot [15] registered
[    0.129021] acpiphp: Slot [16] registered
[    0.129939] acpiphp: Slot [17] registered
[    0.130023] acpiphp: Slot [18] registered
[    0.131021] acpiphp: Slot [19] registered
[    0.132022] acpiphp: Slot [20] registered
[    0.133022] acpiphp: Slot [21] registered
[    0.134022] acpiphp: Slot [22] registered
[    0.134953] acpiphp: Slot [23] registered
[    0.135024] acpiphp: Slot [24] registered
[    0.136024] acpiphp: Slot [25] registered
[    0.137029] acpiphp: Slot [26] registered
[    0.138029] acpiphp: Slot [27] registered
[    0.139033] acpiphp: Slot [28] registered
[    0.140039] acpiphp: Slot [29] registered
[    0.140946] acpiphp: Slot [30] registered
[    0.140946] acpiphp: Slot [31] registered
[    0.142023] PCI host bridge to bus 0000:00
[    0.142928] pci_bus 0000:00: root bus resource [io  0x0000-0x0cf7 window]
[    0.144004] pci_bus 0000:00: root bus resource [io  0x0d00-0xffff window]
[    0.146004] pci_bus 0000:00: root bus resource [mem 0x000a0000-0x000bffff window]
[    0.148004] pci_bus 0000:00: root bus resource [mem 0xc0000000-0xfebfffff window]
[    0.149004] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.158035] pci 0000:00:01.1: legacy IDE quirk: reg 0x10: [io  0x01f0-0x01f7]
[    0.160005] pci 0000:00:01.1: legacy IDE quirk: reg 0x14: [io  0x03f6]
[    0.161003] pci 0000:00:01.1: legacy IDE quirk: reg 0x18: [io  0x0170-0x0177]
[    0.163005] pci 0000:00:01.1: legacy IDE quirk: reg 0x1c: [io  0x0376]
[    0.165793] pci 0000:00:01.3: quirk: [io  0x0600-0x063f] claimed by PIIX4 ACPI
[    0.167018] pci 0000:00:01.3: quirk: [io  0x0700-0x070f] claimed by PIIX4 SMB
[    0.316104] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10 11)
[    0.317112] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 *10 11)
[    0.319111] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10 *11)
[    0.321113] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
[    0.323065] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
[    0.331026] pci 0000:00:02.0: vgaarb: setting as boot VGA device
[    0.332000] pci 0000:00:02.0: vgaarb: VGA device added: decodes=io+mem,owns=io+mem,locks=none
[    0.334006] pci 0000:00:02.0: vgaarb: bridge control possible
[    0.335003] vgaarb: loaded
[    0.335772] SCSI subsystem initialized
[    0.344120] ACPI: bus type USB registered
[    0.345031] usbcore: registered new interface driver usbfs
[    0.346016] usbcore: registered new interface driver hub
[    0.347042] usbcore: registered new device driver usb
[    0.357010] EDAC MC: Ver: 3.0.0
[    0.359025] PCI: Using ACPI for IRQ routing
[    0.360385] NetLabel: Initializing
[    0.361004] NetLabel:  domain hash size = 128
[    0.361959] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    0.363014] NetLabel:  unlabeled traffic allowed by default
[    0.388812] clocksource: Switched to clocksource kvm-clock
[    0.401277] VFS: Disk quotas dquot_6.6.0
[    0.402453] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.404303] pnp: PnP ACPI init
[    0.405401] pnp: PnP ACPI: found 5 devices
[    0.412581] clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns
[    0.415145] NET: Registered protocol family 2
[    0.416505] TCP established hash table entries: 65536 (order: 7, 524288 bytes)
[    0.418619] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
[    0.420370] TCP: Hash tables configured (established 65536 bind 65536)
[    0.422115] UDP hash table entries: 4096 (order: 5, 131072 bytes)
[    0.423760] UDP-Lite hash table entries: 4096 (order: 5, 131072 bytes)
[    0.425565] NET: Registered protocol family 1
[    0.426735] pci 0000:00:00.0: Limiting direct PCI/PCI transfers
[    0.428559] pci 0000:00:01.0: PIIX3: Enabling Passive Release
[    0.430208] pci 0000:00:01.0: Activating ISA DMA hang workarounds
[    0.431677] pci 0000:00:02.0: Video device with shadowed ROM at [mem 0x000c0000-0x000dffff]
[    0.447108] ACPI: PCI Interrupt Link [LNKA] enabled at IRQ 10
[    0.475172] ACPI: PCI Interrupt Link [LNKB] enabled at IRQ 11
[    0.502595] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
[    0.529722] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 10
[    0.544544] Unpacking initramfs...
[    1.093855] Freeing initrd memory: 45416K
[    1.094888] PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
[    1.096312] software IO TLB [mem 0xbbfd9000-0xbffd9000] (64MB) mapped at [ffffa0d4bbfd9000-ffffa0d4bffd8fff]
[    1.100405] audit: initializing netlink subsys (disabled)
[    1.101766] audit: type=2000 audit(1510293550.024:1): state=initialized audit_enabled=0 res=1
[    1.101930] Initialise system trusted keyrings
[    1.101936] Key type blacklist registered
[    1.107740] workingset: timestamp_bits=36 max_order=21 bucket_order=0
[    1.109819] zbud: loaded
[    1.242766] NET: Registered protocol family 38
[    1.243829] Key type asymmetric registered
[    1.244870] Asymmetric key parser 'x509' registered
[    1.246166] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 248)
[    1.254351] io scheduler noop registered
[    1.255616] io scheduler deadline registered
[    1.256805] io scheduler cfq registered (default)
[    1.258171] io scheduler mq-deadline registered
[    1.259793] atomic64_test: passed for x86-64 platform with CX8 and with SSE
[    1.262411] input: Power Button as /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0
[    1.264478] ACPI: Power Button [PWRF]
[    1.265954] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled
[    1.291926] 00:04: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    1.295323] Non-volatile memory driver v1.3
[    1.296532] Linux agpgart interface v0.103
[    1.299187] scsi host0: ata_piix
[    1.300141] scsi host1: ata_piix
[    1.300846] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6 bmdma 0xc160 irq 14
[    1.302397] ata2: PATA max MWDMA2 cmd 0x170 ctl 0x376 bmdma 0xc168 irq 15
[    1.308335] libphy: Fixed MDIO Bus: probed
[    1.309567] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.311318] ehci-pci: EHCI PCI platform driver
[    1.325827] ehci-pci 0000:00:05.7: EHCI Host Controller
[    1.327315] ehci-pci 0000:00:05.7: new USB bus registered, assigned bus number 1
[    1.329618] ehci-pci 0000:00:05.7: irq 10, io mem 0xfc057000
[    1.338135] ehci-pci 0000:00:05.7: USB 2.0 started, EHCI 1.00
[    1.340118] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.342186] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.344541] usb usb1: Product: EHCI Host Controller
[    1.345920] usb usb1: Manufacturer: Linux 4.14.0-rc8+ ehci_hcd
[    1.347666] usb usb1: SerialNumber: 0000:00:05.7
[    1.348892] hub 1-0:1.0: USB hub found
[    1.349883] hub 1-0:1.0: 6 ports detected
[    1.350990] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.352454] ohci-pci: OHCI PCI platform driver
[    1.353671] uhci_hcd: USB Universal Host Controller Interface driver
[    1.369365] uhci_hcd 0000:00:05.0: UHCI Host Controller
[    1.370896] uhci_hcd 0000:00:05.0: new USB bus registered, assigned bus number 2
[    1.372646] uhci_hcd 0000:00:05.0: detected 2 ports
[    1.374064] uhci_hcd 0000:00:05.0: irq 10, io base 0x0000c0c0
[    1.375719] usb usb2: New USB device found, idVendor=1d6b, idProduct=0001
[    1.377485] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.379488] usb usb2: Product: UHCI Host Controller
[    1.380647] usb usb2: Manufacturer: Linux 4.14.0-rc8+ uhci_hcd
[    1.382082] usb usb2: SerialNumber: 0000:00:05.0
[    1.383452] hub 2-0:1.0: USB hub found
[    1.384363] hub 2-0:1.0: 2 ports detected
[    1.399520] uhci_hcd 0000:00:05.1: UHCI Host Controller
[    1.401088] uhci_hcd 0000:00:05.1: new USB bus registered, assigned bus number 3
[    1.403208] uhci_hcd 0000:00:05.1: detected 2 ports
[    1.404723] uhci_hcd 0000:00:05.1: irq 11, io base 0x0000c0e0
[    1.406177] usb usb3: New USB device found, idVendor=1d6b, idProduct=0001
[    1.408010] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.409997] usb usb3: Product: UHCI Host Controller
[    1.411487] usb usb3: Manufacturer: Linux 4.14.0-rc8+ uhci_hcd
[    1.412815] usb usb3: SerialNumber: 0000:00:05.1
[    1.414041] hub 3-0:1.0: USB hub found
[    1.415019] hub 3-0:1.0: 2 ports detected
[    1.429704] uhci_hcd 0000:00:05.2: UHCI Host Controller
[    1.431091] uhci_hcd 0000:00:05.2: new USB bus registered, assigned bus number 4
[    1.432834] uhci_hcd 0000:00:05.2: detected 2 ports
[    1.434199] uhci_hcd 0000:00:05.2: irq 11, io base 0x0000c100
[    1.435704] usb usb4: New USB device found, idVendor=1d6b, idProduct=0001
[    1.437307] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.439127] usb usb4: Product: UHCI Host Controller
[    1.440345] usb usb4: Manufacturer: Linux 4.14.0-rc8+ uhci_hcd
[    1.441746] usb usb4: SerialNumber: 0000:00:05.2
[    1.442969] hub 4-0:1.0: USB hub found
[    1.443950] hub 4-0:1.0: 2 ports detected
[    1.445099] usbcore: registered new interface driver usbserial
[    1.446556] usbcore: registered new interface driver usbserial_generic
[    1.448152] usbserial: USB Serial support registered for generic
[    1.449549] i8042: PNP: PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12
[    1.452824] serio: i8042 KBD port at 0x60,0x64 irq 1
[    1.454111] serio: i8042 AUX port at 0x60,0x64 irq 12
[    1.455532] mousedev: PS/2 mouse device common for all mice
[    1.457119] rtc_cmos 00:00: RTC can wake from S4
[    1.458748] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input1
[    1.460775] rtc_cmos 00:00: rtc core: registered rtc_cmos as rtc0
[    1.462398] rtc_cmos 00:00: alarms up to one day, y3k, 114 bytes nvram
[    1.467052] ata1.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
[    1.467690] ata1.00: configured for MWDMA2
[    1.470876] device-mapper: uevent: version 1.0.3
[    1.471981] scsi 0:0:0:0: CD-ROM            QEMU     QEMU DVD-ROM     2.5+ PQ: 0 ANSI: 5
[    1.474567] device-mapper: ioctl: 4.37.0-ioctl (2017-09-20) initialised: dm-devel@redhat.com
[    1.482569] hidraw: raw HID events driver (C) Jiri Kosina
[    1.484172] usbcore: registered new interface driver usbhid
[    1.485633] usbhid: USB HID core driver
[    1.488621] drop_monitor: Initializing network drop monitor service
[    1.491422] sr 0:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[    1.493113] cdrom: Uniform CD-ROM driver Revision: 3.20
[    1.494415] ip_tables: (C) 2000-2006 Netfilter Core Team
[    1.504355] sr 0:0:0:0: Attached scsi generic sg0 type 5
[    1.506429] Initializing XFRM netlink socket
[    1.513058] NET: Registered protocol family 10
[    1.516265] Segment Routing with IPv6
[    1.517187] mip6: Mobile IPv6
[    1.517903] NET: Registered protocol family 17
[    1.519557] RAS: Correctable Errors collector initialized.
[    1.521335] AVX2 version of gcm_enc/dec engaged.
[    1.522387] AES CTR mode by8 optimization enabled
[    1.530835] sched_clock: Marking stable (1530829912, 0)->(2009906160, -479076248)
[    1.534486] registered taskstats version 1
[    1.535818] Loading compiled-in X.509 certificates
[    1.566243] Loaded X.509 cert 'Build time autogenerated kernel key: ad6e544ea32cba64d1c880561b8d0c19096b586d'
[    1.568888] zswap: loaded using pool lzo/zbud
[    1.573814] Key type big_key registered
[    1.576034] Key type encrypted registered
[    1.577756]   Magic number: 9:751:971
[    1.578909] rtc_cmos 00:00: setting system clock to 2017-11-10 05:59:09 UTC (1510293549)
[    1.583277] Freeing unused kernel memory: 2196K
[    1.584541] Write protecting the kernel read-only data: 14336k
[    1.586539] Freeing unused kernel memory: 1680K
[    1.588277] Freeing unused kernel memory: 324K
[    1.593033] x86/mm: Checked W+X mappings: passed, no W+X pages found.
[    1.594621] rodata_test: all tests were successful
[    1.618845] systemd[1]: systemd 233 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN default-hierarchy=hybrid)
[    1.623765] systemd[1]: Detected virtualization kvm.
[    1.624907] systemd[1]: Detected architecture x86-64.
[    1.626106] systemd[1]: Running in initial RAM disk.


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG]
  2017-11-01 11:32 ` [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG] Chao Fan
@ 2017-11-13  8:10   ` Baoquan He
  2017-11-13  8:42     ` Chao Fan
  0 siblings, 1 reply; 20+ messages in thread
From: Baoquan He @ 2017-11-13  8:10 UTC (permalink / raw)
  To: Chao Fan
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

Hi Chao,

Please think more on your patches, better to discuss with your
colleagues and ask them to help review before your post.

On 11/01/17 at 07:32pm, Chao Fan wrote:
> Extend the movable_node to movable_node=nn[KMG]@ss[KMG].

Firstly, apparently we can't make use of movable_node kernel parameter
and extend it to pass in the immovable_nodes. In fact we are passing in
the memory ranges which can be used for kernel data, not sure if
kernelcore= is OK, or we can make a new one.

Think more about this, or consult your colleagues, FJ has many experts
on mem hotplugging. Choose an proper one or create a new one.

> 
> Since in current code, kaslr may choose the memory region in movable
> nodes to extract kernel, which will make the nodes can't be hot-removed.
> To solve it, we can specify the region in immovable node. Create
> immovable_mem to store the regions in immovable_mem, where should be
> chosen by kaslr.
> 
> Multiple regions can be specified, comma delimited.
> Considering the usage of memory, only support for 4 regions.
> 4 regions contains 2 nodes at least, enough for kernel to extract.
> 
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> ---
>  arch/x86/boot/compressed/kaslr.c | 76 +++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 75 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> index 17818ba6906f..0a591c0023f1 100644
> --- a/arch/x86/boot/compressed/kaslr.c
> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -107,6 +107,15 @@ enum mem_avoid_index {
>  
>  static struct mem_vector mem_avoid[MEM_AVOID_MAX];
>  
> +/* Only supporting at most 4 immovable memory regions with kaslr */
> +#define MAX_IMMOVABLE_MEM	4
> +
> +/* Store the memory regions in immovable node */
> +static struct mem_vector immovable_mem[MAX_IMMOVABLE_MEM];
> +
> +/* The immovable regions user specify, not more than 4 */
> +static int num_immovable_region;

I am fine we support 4 immvoable_mem for now. Please discuss with yor
colleagues, make sure if 4 is OK.

> +
>  static bool mem_overlaps(struct mem_vector *one, struct mem_vector *two)
>  {
>  	/* Item one is entirely before item two. */
> @@ -167,6 +176,38 @@ parse_memmap(char *p, unsigned long long *start, unsigned long long *size)
>  	return -EINVAL;
>  }
>  
> +static int parse_immovable_mem(char *p,
> +			       unsigned long long *start,
> +			       unsigned long long *size)
> +{
> +	char *oldp;
> +
> +	if (!p)
> +		return -EINVAL;
> +
> +	oldp = p;
> +	*size = memparse(p, &p);
> +	if (p == oldp)
> +		return -EINVAL;
> +
> +	/* We support nn[KMG]@ss[KMG] and nn[KMG]. */
> +	switch (*p) {
> +	case '@':
> +		*start = memparse(p + 1, &p);
> +		return 0;
> +	default:
> +		/*
> +		 * If w/o offset, only size specified, movable_node=nn[KMG]
> +		 * has the same behaviour as movable_node=nn[KMG]@0. It means
> +		 * the region starts from 0.
> +		 */
> +		*start = 0;
> +		return 0;
> +	}
> +
> +	return -EINVAL;
> +}
> +
>  static void mem_avoid_memmap(char *str)
>  {
>  	static int i;
> @@ -206,6 +247,36 @@ static void mem_avoid_memmap(char *str)
>  		memmap_too_large = true;
>  }
>  
> +#ifdef CONFIG_MEMORY_HOTPLUG
> +static void mem_mark_immovable(char *str)

I know you try to imitate the function memblock_mark_hotplug(), but do
you really think you are marking the immovable mem regions? In below
code?

Even if use parse_immovable_mem_regions(), please do not use
mem_mark_immovable.

> +{
> +	static int i;
> +
> +	while (str && (i < MAX_IMMOVABLE_MEM)) {
> +		int rc;
> +		unsigned long long start, size;
> +		char *k = strchr(str, ',');
> +
> +		if (k)
> +			*k++ = 0;
> +
> +		rc = parse_immovable_mem(str, &start, &size);
> +		if (rc < 0)
> +			break;
> +		str = k;
> +
> +		immovable_mem[i].start = start;
> +		immovable_mem[i].size = size;
> +		i++;
> +	}
> +	num_immovable_region = i;
> +}
> +#else
> +static inline void mem_mark_immovable(char *str)
> +{
> +}
> +#endif
> +
>  static int handle_mem_memmap(void)

Please think of a better function name when you add immovable memory
regions parsing in. Clearly it's not a right name now.

>  {
>  	char *args = (char *)get_cmd_line_ptr();
> @@ -214,7 +285,8 @@ static int handle_mem_memmap(void)
>  	char *param, *val;
>  	u64 mem_size;
>  
> -	if (!strstr(args, "memmap=") && !strstr(args, "mem="))
> +	if (!strstr(args, "memmap=") && !strstr(args, "mem=") &&
> +	    !strstr(args, "movable_node="))
>  		return 0;
>  
>  	tmp_cmdline = malloc(len + 1);
> @@ -239,6 +311,8 @@ static int handle_mem_memmap(void)
>  
>  		if (!strcmp(param, "memmap")) {
>  			mem_avoid_memmap(val);
> +		} else if (!strcmp(param, "movable_node")) {
> +			mem_mark_immovable(val);
>  		} else if (!strcmp(param, "mem")) {
>  			char *p = val;
>  
> -- 
> 2.13.6
> 
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-01 11:32 ` [PATCH v2 2/4] kaslr: select the memory region in immovable node to process Chao Fan
  2017-11-09  8:21   ` Baoquan He
@ 2017-11-13  8:31   ` Baoquan He
  2017-11-13  9:18     ` Chao Fan
  1 sibling, 1 reply; 20+ messages in thread
From: Baoquan He @ 2017-11-13  8:31 UTC (permalink / raw)
  To: Chao Fan
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On 11/01/17 at 07:32pm, Chao Fan wrote:
> Compare the region of memmap entry and immovable_mem, then choose the
> intersection to process_mem_region.
> 
> Since the interrelationship between e820 or efi entries and memory
> region in immovable_mem is different:
> One memory region in one node may contain several entries of e820 or
> efi sometimes, and one entry of e820 or efi may contain the memory in
> different nodes sometimes.
> It may split one node or one entry to several regions.
> 
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> ---
>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
>  1 file changed, 52 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> index 0a591c0023f1..fcd640fdeaed 100644
> --- a/arch/x86/boot/compressed/kaslr.c
> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
>  	}
>  }
>  
> +static bool select_immovable_node(struct mem_vector region,
> +				  unsigned long long minimum,
> +				  unsigned long long image_size)
> +{

About this patch, I just want to notice two things:
1) From the current code, 'movable_node' kernel parameter is exclusive.
In find_zone_movable_pfns_for_nodes(), you can see that 'kernelcore' and
'movablecore' will be ignored as long as 'movable_node' is specified.
Please also consider this in your code here. If 'movable_node' has to be
specified too, and need skip the kernel mirror handling.

2)process_mem_region() is a key function to process the available memory
regions. Please don't make another process_mem_region() like below. You
can write a small helper function to find the immovable_mem[] which is
intersecting with the passed in memory region and use clamp() to get
the real available region. You 'REALLY' don't need to split the region
in your so called 'select_immovable_node()' function here.

PLEASE elaborate more on these details before post.

Thanks
Baoquan

> +	int i;
> +
> +	/* If no immovable_mem stored, use region directly */
> +	if (num_immovable_region == 0) {
> +		process_mem_region(&region, minimum, image_size);
> +
> +		if (slot_area_index == MAX_SLOT_AREA) {
> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> +			return 1;
> +		}
> +	} else {
> +		/*
> +		 * Walk all immovable regions, and filter the intersection
> +		 * to process_mem_region.
> +		 */
> +		for (i = 0; i < num_immovable_region; i++) {
> +			struct mem_vector entry;
> +			unsigned long long start, end, select_end, region_end;
> +
> +			region_end = region.start + region.size - 1;
> +			start = immovable_mem[i].start;
> +			end = start + immovable_mem[i].size - 1;
> +
> +			if (region_end < start || region.start > end)
> +				continue;
> +
> +			/* May split one region to several entries. */
> +			entry.start = start > region.start ?
> +				      start : region.start;
> +			select_end = end > region_end ? region_end : end;
> +
> +			entry.size = select_end - entry.start + 1;
> +
> +			process_mem_region(&entry, minimum, image_size);
> +
> +			if (slot_area_index == MAX_SLOT_AREA) {
> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> +				return 1;
> +			}
> +		}
> +	}
> +	return 0;
> +}
> +
>  #ifdef CONFIG_EFI
>  /*
>   * Returns true if mirror region found (and must have been processed
> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>  
>  		region.start = md->phys_addr;
>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
> -		process_mem_region(&region, minimum, image_size);
> -		if (slot_area_index == MAX_SLOT_AREA) {
> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
> +
> +		if (select_immovable_node(region, minimum, image_size))
>  			break;
> -		}
>  	}
>  	return true;
>  }
> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
>  			continue;
>  		region.start = entry->addr;
>  		region.size = entry->size;
> -		process_mem_region(&region, minimum, image_size);
> -		if (slot_area_index == MAX_SLOT_AREA) {
> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
> +
> +		if (select_immovable_node(region, minimum, image_size))
>  			break;
> -		}
>  	}
>  }
>  
> -- 
> 2.13.6
> 
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/4] kaslr: clean up a useless variable and some usless space
  2017-11-01 11:32 ` [PATCH v2 4/4] kaslr: clean up a useless variable and some usless space Chao Fan
@ 2017-11-13  8:32   ` Baoquan He
  2017-11-13  9:19     ` Chao Fan
  0 siblings, 1 reply; 20+ messages in thread
From: Baoquan He @ 2017-11-13  8:32 UTC (permalink / raw)
  To: Chao Fan
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On 11/01/17 at 07:32pm, Chao Fan wrote:
> There are two same variable "rc" in this function. One is in the
> circulation, the other is out of the circulation. The one out will never
> be used, so drop it.

You can send this clean up patch alone.

> 
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> ---
>  arch/x86/boot/compressed/kaslr.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> index fcd640fdeaed..aff184e19270 100644
> --- a/arch/x86/boot/compressed/kaslr.c
> +++ b/arch/x86/boot/compressed/kaslr.c
> @@ -211,7 +211,6 @@ static int parse_immovable_mem(char *p,
>  static void mem_avoid_memmap(char *str)
>  {
>  	static int i;
> -	int rc;
>  
>  	if (i >= MAX_MEMMAP_REGIONS)
>  		return;
> @@ -290,7 +289,7 @@ static int handle_mem_memmap(void)
>  		return 0;
>  
>  	tmp_cmdline = malloc(len + 1);
> -	if (!tmp_cmdline )
> +	if (!tmp_cmdline)
>  		error("Failed to allocate space for tmp_cmdline");
>  
>  	memcpy(tmp_cmdline, args, len);
> @@ -436,7 +435,7 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
>  	cmd_line |= boot_params->hdr.cmd_line_ptr;
>  	/* Calculate size of cmd_line. */
>  	ptr = (char *)(unsigned long)cmd_line;
> -	for (cmd_line_size = 0; ptr[cmd_line_size++]; )
> +	for (cmd_line_size = 0; ptr[cmd_line_size++];)
>  		;
>  	mem_avoid[MEM_AVOID_CMDLINE].start = cmd_line;
>  	mem_avoid[MEM_AVOID_CMDLINE].size = cmd_line_size;
> -- 
> 2.13.6
> 
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG]
  2017-11-13  8:10   ` Baoquan He
@ 2017-11-13  8:42     ` Chao Fan
  0 siblings, 0 replies; 20+ messages in thread
From: Chao Fan @ 2017-11-13  8:42 UTC (permalink / raw)
  To: Baoquan He
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On Mon, Nov 13, 2017 at 04:10:41PM +0800, Baoquan He wrote:
>Hi Chao,
Hi Baoquan,

Thanks for your reply.
>
>Please think more on your patches, better to discuss with your
>colleagues and ask them to help review before your post.
>
>On 11/01/17 at 07:32pm, Chao Fan wrote:
>> Extend the movable_node to movable_node=nn[KMG]@ss[KMG].
>
>Firstly, apparently we can't make use of movable_node kernel parameter
>and extend it to pass in the immovable_nodes. In fact we are passing in
>the memory ranges which can be used for kernel data, not sure if
>kernelcore= is OK, or we can make a new one.

OK, I will think more about this.

>
>Think more about this, or consult your colleagues, FJ has many experts
>on mem hotplugging. Choose an proper one or create a new one.
>
>> 
>> Since in current code, kaslr may choose the memory region in movable
>> nodes to extract kernel, which will make the nodes can't be hot-removed.
>> To solve it, we can specify the region in immovable node. Create
>> immovable_mem to store the regions in immovable_mem, where should be
>> chosen by kaslr.
>> 
>> Multiple regions can be specified, comma delimited.
>> Considering the usage of memory, only support for 4 regions.
>> 4 regions contains 2 nodes at least, enough for kernel to extract.
>> 
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> ---
>>  arch/x86/boot/compressed/kaslr.c | 76 +++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 75 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> index 17818ba6906f..0a591c0023f1 100644
>> --- a/arch/x86/boot/compressed/kaslr.c
>> +++ b/arch/x86/boot/compressed/kaslr.c
>> @@ -107,6 +107,15 @@ enum mem_avoid_index {
>>  
>>  static struct mem_vector mem_avoid[MEM_AVOID_MAX];
>>  
>> +/* Only supporting at most 4 immovable memory regions with kaslr */
>> +#define MAX_IMMOVABLE_MEM	4
>> +
>> +/* Store the memory regions in immovable node */
>> +static struct mem_vector immovable_mem[MAX_IMMOVABLE_MEM];
>> +
>> +/* The immovable regions user specify, not more than 4 */
>> +static int num_immovable_region;
>
>I am fine we support 4 immvoable_mem for now. Please discuss with yor
>colleagues, make sure if 4 is OK.

OK. I will ask more colleagues to decide this.
In my opinion, 4 can contain 2 nodes at least.
The memory region will be enough.
Thanks for your advice.

>
>> +
>>  static bool mem_overlaps(struct mem_vector *one, struct mem_vector *two)
>>  {
>>  	/* Item one is entirely before item two. */
>> @@ -167,6 +176,38 @@ parse_memmap(char *p, unsigned long long *start, unsigned long long *size)
>>  	return -EINVAL;
>>  }
>>  
>> +static int parse_immovable_mem(char *p,
>> +			       unsigned long long *start,
>> +			       unsigned long long *size)
>> +{
>> +	char *oldp;
>> +
>> +	if (!p)
>> +		return -EINVAL;
>> +
>> +	oldp = p;
>> +	*size = memparse(p, &p);
>> +	if (p == oldp)
>> +		return -EINVAL;
>> +
>> +	/* We support nn[KMG]@ss[KMG] and nn[KMG]. */
>> +	switch (*p) {
>> +	case '@':
>> +		*start = memparse(p + 1, &p);
>> +		return 0;
>> +	default:
>> +		/*
>> +		 * If w/o offset, only size specified, movable_node=nn[KMG]
>> +		 * has the same behaviour as movable_node=nn[KMG]@0. It means
>> +		 * the region starts from 0.
>> +		 */
>> +		*start = 0;
>> +		return 0;
>> +	}
>> +
>> +	return -EINVAL;
>> +}
>> +
>>  static void mem_avoid_memmap(char *str)
>>  {
>>  	static int i;
>> @@ -206,6 +247,36 @@ static void mem_avoid_memmap(char *str)
>>  		memmap_too_large = true;
>>  }
>>  
>> +#ifdef CONFIG_MEMORY_HOTPLUG
>> +static void mem_mark_immovable(char *str)
>
>I know you try to imitate the function memblock_mark_hotplug(), but do
>you really think you are marking the immovable mem regions? In below

Well, this depends to what the users specify.
If users specify the immovable mem regions, the stored data will be
immovable.
If users specify the movable mem regions, it will be movable regions.

If this puzzle users, I will make a new name.

>code?
>
>Even if use parse_immovable_mem_regions(), please do not use
>mem_mark_immovable.

Thanks for your advice, I will think about it.
>
>> +{
>> +	static int i;
>> +
>> +	while (str && (i < MAX_IMMOVABLE_MEM)) {
>> +		int rc;
>> +		unsigned long long start, size;
>> +		char *k = strchr(str, ',');
>> +
>> +		if (k)
>> +			*k++ = 0;
>> +
>> +		rc = parse_immovable_mem(str, &start, &size);
>> +		if (rc < 0)
>> +			break;
>> +		str = k;
>> +
>> +		immovable_mem[i].start = start;
>> +		immovable_mem[i].size = size;
>> +		i++;
>> +	}
>> +	num_immovable_region = i;
>> +}
>> +#else
>> +static inline void mem_mark_immovable(char *str)
>> +{
>> +}
>> +#endif
>> +
>>  static int handle_mem_memmap(void)
>
>Please think of a better function name when you add immovable memory
>regions parsing in. Clearly it's not a right name now.

OK, I will try to make a new one and change the code.
Thank you so much for the advice.

Thanks,
Chao Fan

>
>>  {
>>  	char *args = (char *)get_cmd_line_ptr();
>> @@ -214,7 +285,8 @@ static int handle_mem_memmap(void)
>>  	char *param, *val;
>>  	u64 mem_size;
>>  
>> -	if (!strstr(args, "memmap=") && !strstr(args, "mem="))
>> +	if (!strstr(args, "memmap=") && !strstr(args, "mem=") &&
>> +	    !strstr(args, "movable_node="))
>>  		return 0;
>>  
>>  	tmp_cmdline = malloc(len + 1);
>> @@ -239,6 +311,8 @@ static int handle_mem_memmap(void)
>>  
>>  		if (!strcmp(param, "memmap")) {
>>  			mem_avoid_memmap(val);
>> +		} else if (!strcmp(param, "movable_node")) {
>> +			mem_mark_immovable(val);
>>  		} else if (!strcmp(param, "mem")) {
>>  			char *p = val;
>>  
>> -- 
>> 2.13.6
>> 
>> 
>> 
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-13  8:31   ` Baoquan He
@ 2017-11-13  9:18     ` Chao Fan
  2017-11-13  9:26       ` Baoquan He
  0 siblings, 1 reply; 20+ messages in thread
From: Chao Fan @ 2017-11-13  9:18 UTC (permalink / raw)
  To: Baoquan He
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On Mon, Nov 13, 2017 at 04:31:31PM +0800, Baoquan He wrote:
>On 11/01/17 at 07:32pm, Chao Fan wrote:
>> Compare the region of memmap entry and immovable_mem, then choose the
>> intersection to process_mem_region.
>> 
>> Since the interrelationship between e820 or efi entries and memory
>> region in immovable_mem is different:
>> One memory region in one node may contain several entries of e820 or
>> efi sometimes, and one entry of e820 or efi may contain the memory in
>> different nodes sometimes.
>> It may split one node or one entry to several regions.
>> 
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> ---
>>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
>>  1 file changed, 52 insertions(+), 8 deletions(-)
>> 
>> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> index 0a591c0023f1..fcd640fdeaed 100644
>> --- a/arch/x86/boot/compressed/kaslr.c
>> +++ b/arch/x86/boot/compressed/kaslr.c
>> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
>>  	}
>>  }
>>  
>> +static bool select_immovable_node(struct mem_vector region,
>> +				  unsigned long long minimum,
>> +				  unsigned long long image_size)
>> +{
>
>About this patch, I just want to notice two things:
>1) From the current code, 'movable_node' kernel parameter is exclusive.
>In find_zone_movable_pfns_for_nodes(), you can see that 'kernelcore' and
>'movablecore' will be ignored as long as 'movable_node' is specified.
>Please also consider this in your code here. If 'movable_node' has to be
>specified too, and need skip the kernel mirror handling.
>

Thanks for the notice, I will add the similar operation.

>2)process_mem_region() is a key function to process the available memory
>regions. Please don't make another process_mem_region() like below. You
>can write a small helper function to find the immovable_mem[] which is
>intersecting with the passed in memory region and use clamp() to get
>the real available region. You 'REALLY' don't need to split the region
>in your so called 'select_immovable_node()' function here.
>

OK, I will try to make a new method, which is smaller and better to
filter the regions.

Thanks,
Chao Fan

>PLEASE elaborate more on these details before post.
>
>Thanks
>Baoquan
>
>> +	int i;
>> +
>> +	/* If no immovable_mem stored, use region directly */
>> +	if (num_immovable_region == 0) {
>> +		process_mem_region(&region, minimum, image_size);
>> +
>> +		if (slot_area_index == MAX_SLOT_AREA) {
>> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> +			return 1;
>> +		}
>> +	} else {
>> +		/*
>> +		 * Walk all immovable regions, and filter the intersection
>> +		 * to process_mem_region.
>> +		 */
>> +		for (i = 0; i < num_immovable_region; i++) {
>> +			struct mem_vector entry;
>> +			unsigned long long start, end, select_end, region_end;
>> +
>> +			region_end = region.start + region.size - 1;
>> +			start = immovable_mem[i].start;
>> +			end = start + immovable_mem[i].size - 1;
>> +
>> +			if (region_end < start || region.start > end)
>> +				continue;
>> +
>> +			/* May split one region to several entries. */
>> +			entry.start = start > region.start ?
>> +				      start : region.start;
>> +			select_end = end > region_end ? region_end : end;
>> +
>> +			entry.size = select_end - entry.start + 1;
>> +
>> +			process_mem_region(&entry, minimum, image_size);
>> +
>> +			if (slot_area_index == MAX_SLOT_AREA) {
>> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> +				return 1;
>> +			}
>> +		}
>> +	}
>> +	return 0;
>> +}
>> +
>>  #ifdef CONFIG_EFI
>>  /*
>>   * Returns true if mirror region found (and must have been processed
>> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>>  
>>  		region.start = md->phys_addr;
>>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
>> -		process_mem_region(&region, minimum, image_size);
>> -		if (slot_area_index == MAX_SLOT_AREA) {
>> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
>> +
>> +		if (select_immovable_node(region, minimum, image_size))
>>  			break;
>> -		}
>>  	}
>>  	return true;
>>  }
>> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
>>  			continue;
>>  		region.start = entry->addr;
>>  		region.size = entry->size;
>> -		process_mem_region(&region, minimum, image_size);
>> -		if (slot_area_index == MAX_SLOT_AREA) {
>> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
>> +
>> +		if (select_immovable_node(region, minimum, image_size))
>>  			break;
>> -		}
>>  	}
>>  }
>>  
>> -- 
>> 2.13.6
>> 
>> 
>> 
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/4] kaslr: clean up a useless variable and some usless space
  2017-11-13  8:32   ` Baoquan He
@ 2017-11-13  9:19     ` Chao Fan
  0 siblings, 0 replies; 20+ messages in thread
From: Chao Fan @ 2017-11-13  9:19 UTC (permalink / raw)
  To: Baoquan He
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On Mon, Nov 13, 2017 at 04:32:33PM +0800, Baoquan He wrote:
>On 11/01/17 at 07:32pm, Chao Fan wrote:
>> There are two same variable "rc" in this function. One is in the
>> circulation, the other is out of the circulation. The one out will never
>> be used, so drop it.
>
>You can send this clean up patch alone.
>
OK, I will send it as a new patch.

Thanks,
Chao Fan

>> 
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> ---
>>  arch/x86/boot/compressed/kaslr.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>> 
>> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> index fcd640fdeaed..aff184e19270 100644
>> --- a/arch/x86/boot/compressed/kaslr.c
>> +++ b/arch/x86/boot/compressed/kaslr.c
>> @@ -211,7 +211,6 @@ static int parse_immovable_mem(char *p,
>>  static void mem_avoid_memmap(char *str)
>>  {
>>  	static int i;
>> -	int rc;
>>  
>>  	if (i >= MAX_MEMMAP_REGIONS)
>>  		return;
>> @@ -290,7 +289,7 @@ static int handle_mem_memmap(void)
>>  		return 0;
>>  
>>  	tmp_cmdline = malloc(len + 1);
>> -	if (!tmp_cmdline )
>> +	if (!tmp_cmdline)
>>  		error("Failed to allocate space for tmp_cmdline");
>>  
>>  	memcpy(tmp_cmdline, args, len);
>> @@ -436,7 +435,7 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
>>  	cmd_line |= boot_params->hdr.cmd_line_ptr;
>>  	/* Calculate size of cmd_line. */
>>  	ptr = (char *)(unsigned long)cmd_line;
>> -	for (cmd_line_size = 0; ptr[cmd_line_size++]; )
>> +	for (cmd_line_size = 0; ptr[cmd_line_size++];)
>>  		;
>>  	mem_avoid[MEM_AVOID_CMDLINE].start = cmd_line;
>>  	mem_avoid[MEM_AVOID_CMDLINE].size = cmd_line_size;
>> -- 
>> 2.13.6
>> 
>> 
>> 
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-13  9:18     ` Chao Fan
@ 2017-11-13  9:26       ` Baoquan He
  2017-11-13  9:50         ` Chao Fan
  0 siblings, 1 reply; 20+ messages in thread
From: Baoquan He @ 2017-11-13  9:26 UTC (permalink / raw)
  To: Chao Fan
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On 11/13/17 at 05:18pm, Chao Fan wrote:
> On Mon, Nov 13, 2017 at 04:31:31PM +0800, Baoquan He wrote:
> >On 11/01/17 at 07:32pm, Chao Fan wrote:
> >> Compare the region of memmap entry and immovable_mem, then choose the
> >> intersection to process_mem_region.
> >> 
> >> Since the interrelationship between e820 or efi entries and memory
> >> region in immovable_mem is different:
> >> One memory region in one node may contain several entries of e820 or
> >> efi sometimes, and one entry of e820 or efi may contain the memory in
> >> different nodes sometimes.
> >> It may split one node or one entry to several regions.
> >> 
> >> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> >> ---
> >>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
> >>  1 file changed, 52 insertions(+), 8 deletions(-)
> >> 
> >> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
> >> index 0a591c0023f1..fcd640fdeaed 100644
> >> --- a/arch/x86/boot/compressed/kaslr.c
> >> +++ b/arch/x86/boot/compressed/kaslr.c
> >> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
> >>  	}
> >>  }
> >>  
> >> +static bool select_immovable_node(struct mem_vector region,
> >> +				  unsigned long long minimum,
> >> +				  unsigned long long image_size)
> >> +{
> >
> >About this patch, I just want to notice two things:
> >1) From the current code, 'movable_node' kernel parameter is exclusive.
> >In find_zone_movable_pfns_for_nodes(), you can see that 'kernelcore' and
> >'movablecore' will be ignored as long as 'movable_node' is specified.
> >Please also consider this in your code here. If 'movable_node' has to be
> >specified too, and need skip the kernel mirror handling.
> >
> 
> Thanks for the notice, I will add the similar operation.

No, I meant if movable_node is specified, we have to ignore
'kernelcore=', then we may need skip the kernel mirror handling. Since
kernel mirror is enabled by 'kernelcore=mirror'.


> 
> >2)process_mem_region() is a key function to process the available memory
> >regions. Please don't make another process_mem_region() like below. You
> >can write a small helper function to find the immovable_mem[] which is
> >intersecting with the passed in memory region and use clamp() to get
> >the real available region. You 'REALLY' don't need to split the region
> >in your so called 'select_immovable_node()' function here.
> >
> 
> OK, I will try to make a new method, which is smaller and better to
> filter the regions.
> 
> Thanks,
> Chao Fan
> 
> >PLEASE elaborate more on these details before post.
> >
> >Thanks
> >Baoquan
> >
> >> +	int i;
> >> +
> >> +	/* If no immovable_mem stored, use region directly */
> >> +	if (num_immovable_region == 0) {
> >> +		process_mem_region(&region, minimum, image_size);
> >> +
> >> +		if (slot_area_index == MAX_SLOT_AREA) {
> >> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> >> +			return 1;
> >> +		}
> >> +	} else {
> >> +		/*
> >> +		 * Walk all immovable regions, and filter the intersection
> >> +		 * to process_mem_region.
> >> +		 */
> >> +		for (i = 0; i < num_immovable_region; i++) {
> >> +			struct mem_vector entry;
> >> +			unsigned long long start, end, select_end, region_end;
> >> +
> >> +			region_end = region.start + region.size - 1;
> >> +			start = immovable_mem[i].start;
> >> +			end = start + immovable_mem[i].size - 1;
> >> +
> >> +			if (region_end < start || region.start > end)
> >> +				continue;
> >> +
> >> +			/* May split one region to several entries. */
> >> +			entry.start = start > region.start ?
> >> +				      start : region.start;
> >> +			select_end = end > region_end ? region_end : end;
> >> +
> >> +			entry.size = select_end - entry.start + 1;
> >> +
> >> +			process_mem_region(&entry, minimum, image_size);
> >> +
> >> +			if (slot_area_index == MAX_SLOT_AREA) {
> >> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> >> +				return 1;
> >> +			}
> >> +		}
> >> +	}
> >> +	return 0;
> >> +}
> >> +
> >>  #ifdef CONFIG_EFI
> >>  /*
> >>   * Returns true if mirror region found (and must have been processed
> >> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
> >>  
> >>  		region.start = md->phys_addr;
> >>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
> >> -		process_mem_region(&region, minimum, image_size);
> >> -		if (slot_area_index == MAX_SLOT_AREA) {
> >> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
> >> +
> >> +		if (select_immovable_node(region, minimum, image_size))
> >>  			break;
> >> -		}
> >>  	}
> >>  	return true;
> >>  }
> >> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
> >>  			continue;
> >>  		region.start = entry->addr;
> >>  		region.size = entry->size;
> >> -		process_mem_region(&region, minimum, image_size);
> >> -		if (slot_area_index == MAX_SLOT_AREA) {
> >> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
> >> +
> >> +		if (select_immovable_node(region, minimum, image_size))
> >>  			break;
> >> -		}
> >>  	}
> >>  }
> >>  
> >> -- 
> >> 2.13.6
> >> 
> >> 
> >> 
> >
> >
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-13  9:26       ` Baoquan He
@ 2017-11-13  9:50         ` Chao Fan
  2017-11-13 11:02           ` Baoquan He
  0 siblings, 1 reply; 20+ messages in thread
From: Chao Fan @ 2017-11-13  9:50 UTC (permalink / raw)
  To: Baoquan He
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On Mon, Nov 13, 2017 at 05:26:24PM +0800, Baoquan He wrote:
>On 11/13/17 at 05:18pm, Chao Fan wrote:
>> On Mon, Nov 13, 2017 at 04:31:31PM +0800, Baoquan He wrote:
>> >On 11/01/17 at 07:32pm, Chao Fan wrote:
>> >> Compare the region of memmap entry and immovable_mem, then choose the
>> >> intersection to process_mem_region.
>> >> 
>> >> Since the interrelationship between e820 or efi entries and memory
>> >> region in immovable_mem is different:
>> >> One memory region in one node may contain several entries of e820 or
>> >> efi sometimes, and one entry of e820 or efi may contain the memory in
>> >> different nodes sometimes.
>> >> It may split one node or one entry to several regions.
>> >> 
>> >> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> >> ---
>> >>  arch/x86/boot/compressed/kaslr.c | 60 ++++++++++++++++++++++++++++++++++------
>> >>  1 file changed, 52 insertions(+), 8 deletions(-)
>> >> 
>> >> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> >> index 0a591c0023f1..fcd640fdeaed 100644
>> >> --- a/arch/x86/boot/compressed/kaslr.c
>> >> +++ b/arch/x86/boot/compressed/kaslr.c
>> >> @@ -634,6 +634,54 @@ static void process_mem_region(struct mem_vector *entry,
>> >>  	}
>> >>  }
>> >>  
>> >> +static bool select_immovable_node(struct mem_vector region,
>> >> +				  unsigned long long minimum,
>> >> +				  unsigned long long image_size)
>> >> +{
>> >
>> >About this patch, I just want to notice two things:
>> >1) From the current code, 'movable_node' kernel parameter is exclusive.
>> >In find_zone_movable_pfns_for_nodes(), you can see that 'kernelcore' and
>> >'movablecore' will be ignored as long as 'movable_node' is specified.
>> >Please also consider this in your code here. If 'movable_node' has to be
>> >specified too, and need skip the kernel mirror handling.
>> >
>> 
>> Thanks for the notice, I will add the similar operation.
>
>No, I meant if movable_node is specified, we have to ignore
>'kernelcore=', then we may need skip the kernel mirror handling. Since
>kernel mirror is enabled by 'kernelcore=mirror'.
>

Yes, the two parameters are conflict.
Then if "movable_node" specified, we shoul not consider mirror region.
I think there can be one another patch to handle this, but not in this
serials. I will add the change.

Thanks,
Chao Fan

>
>> 
>> >2)process_mem_region() is a key function to process the available memory
>> >regions. Please don't make another process_mem_region() like below. You
>> >can write a small helper function to find the immovable_mem[] which is
>> >intersecting with the passed in memory region and use clamp() to get
>> >the real available region. You 'REALLY' don't need to split the region
>> >in your so called 'select_immovable_node()' function here.
>> >
>> 
>> OK, I will try to make a new method, which is smaller and better to
>> filter the regions.
>> 
>> Thanks,
>> Chao Fan
>> 
>> >PLEASE elaborate more on these details before post.
>> >
>> >Thanks
>> >Baoquan
>> >
>> >> +	int i;
>> >> +
>> >> +	/* If no immovable_mem stored, use region directly */
>> >> +	if (num_immovable_region == 0) {
>> >> +		process_mem_region(&region, minimum, image_size);
>> >> +
>> >> +		if (slot_area_index == MAX_SLOT_AREA) {
>> >> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> >> +			return 1;
>> >> +		}
>> >> +	} else {
>> >> +		/*
>> >> +		 * Walk all immovable regions, and filter the intersection
>> >> +		 * to process_mem_region.
>> >> +		 */
>> >> +		for (i = 0; i < num_immovable_region; i++) {
>> >> +			struct mem_vector entry;
>> >> +			unsigned long long start, end, select_end, region_end;
>> >> +
>> >> +			region_end = region.start + region.size - 1;
>> >> +			start = immovable_mem[i].start;
>> >> +			end = start + immovable_mem[i].size - 1;
>> >> +
>> >> +			if (region_end < start || region.start > end)
>> >> +				continue;
>> >> +
>> >> +			/* May split one region to several entries. */
>> >> +			entry.start = start > region.start ?
>> >> +				      start : region.start;
>> >> +			select_end = end > region_end ? region_end : end;
>> >> +
>> >> +			entry.size = select_end - entry.start + 1;
>> >> +
>> >> +			process_mem_region(&entry, minimum, image_size);
>> >> +
>> >> +			if (slot_area_index == MAX_SLOT_AREA) {
>> >> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
>> >> +				return 1;
>> >> +			}
>> >> +		}
>> >> +	}
>> >> +	return 0;
>> >> +}
>> >> +
>> >>  #ifdef CONFIG_EFI
>> >>  /*
>> >>   * Returns true if mirror region found (and must have been processed
>> >> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>> >>  
>> >>  		region.start = md->phys_addr;
>> >>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
>> >> -		process_mem_region(&region, minimum, image_size);
>> >> -		if (slot_area_index == MAX_SLOT_AREA) {
>> >> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
>> >> +
>> >> +		if (select_immovable_node(region, minimum, image_size))
>> >>  			break;
>> >> -		}
>> >>  	}
>> >>  	return true;
>> >>  }
>> >> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
>> >>  			continue;
>> >>  		region.start = entry->addr;
>> >>  		region.size = entry->size;
>> >> -		process_mem_region(&region, minimum, image_size);
>> >> -		if (slot_area_index == MAX_SLOT_AREA) {
>> >> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
>> >> +
>> >> +		if (select_immovable_node(region, minimum, image_size))
>> >>  			break;
>> >> -		}
>> >>  	}
>> >>  }
>> >>  
>> >> -- 
>> >> 2.13.6
>> >> 
>> >> 
>> >> 
>> >
>> >
>> 
>> 
>
>

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process
  2017-11-13  9:50         ` Chao Fan
@ 2017-11-13 11:02           ` Baoquan He
  0 siblings, 0 replies; 20+ messages in thread
From: Baoquan He @ 2017-11-13 11:02 UTC (permalink / raw)
  To: Chao Fan
  Cc: linux-kernel, x86, hpa, tglx, mingo, keescook, yasu.isimatu,
	indou.takao, caoj.fnst, douly.fnst

On 11/13/17 at 05:50pm, Chao Fan wrote:
> On Mon, Nov 13, 2017 at 05:26:24PM +0800, Baoquan He wrote:
  
> >> >> +static bool select_immovable_node(struct mem_vector region,
> >> >> +				  unsigned long long minimum,
> >> >> +				  unsigned long long image_size)
> >> >> +{
> >> >
> >> >About this patch, I just want to notice two things:
> >> >1) From the current code, 'movable_node' kernel parameter is exclusive.
> >> >In find_zone_movable_pfns_for_nodes(), you can see that 'kernelcore' and
> >> >'movablecore' will be ignored as long as 'movable_node' is specified.
> >> >Please also consider this in your code here. If 'movable_node' has to be
> >> >specified too, and need skip the kernel mirror handling.
> >> >
> >> 
> >> Thanks for the notice, I will add the similar operation.
> >
> >No, I meant if movable_node is specified, we have to ignore
> >'kernelcore=', then we may need skip the kernel mirror handling. Since
> >kernel mirror is enabled by 'kernelcore=mirror'.
> >
> 
> Yes, the two parameters are conflict.
> Then if "movable_node" specified, we shoul not consider mirror region.
> I think there can be one another patch to handle this, but not in this
> serials. I will add the change.

Well, no.

You didn't get what I said. In process_efi_entries() mirrorred
regions are picked. If movable_node specified, mirror feature will be
ignored. That has been handled in find_zone_movable_pfns_for_nodes()
very well. So you need make it be consistent. 

And if you add a new kernel para, like immovable_mem=xx@xx, movable_node
will be expected. Anyway, please read find_zone_movable_pfns_for_nodes()
carefully.

Thanks
Baoquan
> 
> >
> >> 
> >> >2)process_mem_region() is a key function to process the available memory
> >> >regions. Please don't make another process_mem_region() like below. You
> >> >can write a small helper function to find the immovable_mem[] which is
> >> >intersecting with the passed in memory region and use clamp() to get
> >> >the real available region. You 'REALLY' don't need to split the region
> >> >in your so called 'select_immovable_node()' function here.
> >> >
> >> 
> >> OK, I will try to make a new method, which is smaller and better to
> >> filter the regions.
> >> 
> >> Thanks,
> >> Chao Fan
> >> 
> >> >PLEASE elaborate more on these details before post.
> >> >
> >> >Thanks
> >> >Baoquan
> >> >
> >> >> +	int i;
> >> >> +
> >> >> +	/* If no immovable_mem stored, use region directly */
> >> >> +	if (num_immovable_region == 0) {
> >> >> +		process_mem_region(&region, minimum, image_size);
> >> >> +
> >> >> +		if (slot_area_index == MAX_SLOT_AREA) {
> >> >> +			debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> >> >> +			return 1;
> >> >> +		}
> >> >> +	} else {
> >> >> +		/*
> >> >> +		 * Walk all immovable regions, and filter the intersection
> >> >> +		 * to process_mem_region.
> >> >> +		 */
> >> >> +		for (i = 0; i < num_immovable_region; i++) {
> >> >> +			struct mem_vector entry;
> >> >> +			unsigned long long start, end, select_end, region_end;
> >> >> +
> >> >> +			region_end = region.start + region.size - 1;
> >> >> +			start = immovable_mem[i].start;
> >> >> +			end = start + immovable_mem[i].size - 1;
> >> >> +
> >> >> +			if (region_end < start || region.start > end)
> >> >> +				continue;
> >> >> +
> >> >> +			/* May split one region to several entries. */
> >> >> +			entry.start = start > region.start ?
> >> >> +				      start : region.start;
> >> >> +			select_end = end > region_end ? region_end : end;
> >> >> +
> >> >> +			entry.size = select_end - entry.start + 1;
> >> >> +
> >> >> +			process_mem_region(&entry, minimum, image_size);
> >> >> +
> >> >> +			if (slot_area_index == MAX_SLOT_AREA) {
> >> >> +				debug_putstr("Aborted memmap scan (slot_areas full)!\n");
> >> >> +				return 1;
> >> >> +			}
> >> >> +		}
> >> >> +	}
> >> >> +	return 0;
> >> >> +}
> >> >> +
> >> >>  #ifdef CONFIG_EFI
> >> >>  /*
> >> >>   * Returns true if mirror region found (and must have been processed
> >> >> @@ -699,11 +747,9 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
> >> >>  
> >> >>  		region.start = md->phys_addr;
> >> >>  		region.size = md->num_pages << EFI_PAGE_SHIFT;
> >> >> -		process_mem_region(&region, minimum, image_size);
> >> >> -		if (slot_area_index == MAX_SLOT_AREA) {
> >> >> -			debug_putstr("Aborted EFI scan (slot_areas full)!\n");
> >> >> +
> >> >> +		if (select_immovable_node(region, minimum, image_size))
> >> >>  			break;
> >> >> -		}
> >> >>  	}
> >> >>  	return true;
> >> >>  }
> >> >> @@ -730,11 +776,9 @@ static void process_e820_entries(unsigned long minimum,
> >> >>  			continue;
> >> >>  		region.start = entry->addr;
> >> >>  		region.size = entry->size;
> >> >> -		process_mem_region(&region, minimum, image_size);
> >> >> -		if (slot_area_index == MAX_SLOT_AREA) {
> >> >> -			debug_putstr("Aborted e820 scan (slot_areas full)!\n");
> >> >> +
> >> >> +		if (select_immovable_node(region, minimum, image_size))
> >> >>  			break;
> >> >> -		}
> >> >>  	}
> >> >>  }
> >> >>  
> >> >> -- 
> >> >> 2.13.6
> >> >> 
> >> >> 
> >> >> 
> >> >
> >> >
> >> 
> >> 
> >
> >
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-11-13 11:02 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-01 11:31 [PATCH v2 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG] Chao Fan
2017-11-01 11:32 ` [PATCH v2 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG] Chao Fan
2017-11-13  8:10   ` Baoquan He
2017-11-13  8:42     ` Chao Fan
2017-11-01 11:32 ` [PATCH v2 2/4] kaslr: select the memory region in immovable node to process Chao Fan
2017-11-09  8:21   ` Baoquan He
2017-11-10  1:14     ` Chao Fan
2017-11-10  3:03     ` Chao Fan
2017-11-10  3:14       ` Baoquan He
2017-11-10  4:20         ` Chao Fan
2017-11-10  6:02         ` Chao Fan
2017-11-13  8:31   ` Baoquan He
2017-11-13  9:18     ` Chao Fan
2017-11-13  9:26       ` Baoquan He
2017-11-13  9:50         ` Chao Fan
2017-11-13 11:02           ` Baoquan He
2017-11-01 11:32 ` [PATCH v2 3/4] document: change the document for the extended movable_node Chao Fan
2017-11-01 11:32 ` [PATCH v2 4/4] kaslr: clean up a useless variable and some usless space Chao Fan
2017-11-13  8:32   ` Baoquan He
2017-11-13  9:19     ` Chao Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).