mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Fan <fanc.fnst@cn.fujitsu.com>
To: Dou Liyang <douly.fnst@cn.fujitsu.com>
Cc: <linux-kernel@vger.kernel.org>, <x86@kernel.org>, <hpa@zytor.com>,
	<tglx@linutronix.de>, <mingo@redhat.com>, <bhe@redhat.com>,
	<keescook@chromium.org>, <indou.takao@jp.fujitsu.com>,
	<caoj.fnst@cn.fujitsu.com>
Subject: Re: [PATCH 2/4] kaslr: select the memory region in immovable node to process
Date: Fri, 20 Oct 2017 11:41:19 +0800	[thread overview]
Message-ID: <20171020034117.GB5635@localhost.localdomain> (raw)
In-Reply-To: <a84faa15-df1c-7da5-4f8a-57054c4cf583@cn.fujitsu.com>

On Fri, Oct 20, 2017 at 11:17:26AM +0800, Dou Liyang wrote:
>Hi Chao
>
Hi Dou-san,

>At 10/19/2017 06:02 PM, Chao Fan wrote:
>> 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. So select the intersection as a region to
>> process_mem_region. 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 | 72 ++++++++++++++++++++++++++++++++--------
>>  1 file changed, 58 insertions(+), 14 deletions(-)
>> 
>> diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
>> index 3c1f5204693b..22330cbe8515 100644
>> --- a/arch/x86/boot/compressed/kaslr.c
>> +++ b/arch/x86/boot/compressed/kaslr.c
>> @@ -563,6 +563,7 @@ static void process_mem_region(struct mem_vector *entry,
>>  	end = min(entry->size + entry->start, mem_limit);
>>  	if (entry->start >= end)
>>  		return;
>> +
>>  	cur_entry.start = entry->start;
>>  	cur_entry.size = end - entry->start;
>
>Above code has nothing to do with this patch. remove it.
>
>> 
>> @@ -621,6 +622,52 @@ static void process_mem_region(struct mem_vector *entry,
>>  	}
>>  }
>> 
>> +static bool select_immovable_node(unsigned long long start,
>> +				  unsigned long long size,
>> +				  unsigned long long minimum,
>> +				  unsigned long long image_size)
>> +{
>> +	struct mem_vector region;
>> +	int i;
>> +
>> +	if (num_immovable_region == 0) {
>
>Seems it more better:
>
>#ifdef CONFIG_MEMORY_HOTPLUG
>for (i = 0; i < num_immovable_region; i++) {
>  ...
>}
>#else
>...
>process_mem_region(&region, minimum, image_size);
>...
>#endif

No, if we set CONFIG_MEMORY_HOTPLUG=y(the default is y in fedora), but we do not
use movable_node, we should go to process_mem_region straight, right?
But in your change, we still go to the for(...), even if
num_immovable_region == 0.
So if num_immovable_region is 0, it includes the situation of
CONFIG_MEMORY_HOTPLUG=n

>
>> +		region.start = start;
>> +		region.size = size;
>> +		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 {
>> +		for (i = 0; i < num_immovable_region; i++) {
>> +			unsigned long long end, select_end;
>> +			unsigned long long region_start, region_end;
>> +
>> +			end = start + size - 1;
>> +			region_start = immovable_mem[i].start;
>> +			region_end = region_start + immovable_mem[i].size - 1;
>> +
>> +			if (end < region_start || start > region_end)
>> +				continue;
>> +
>> +			region.start = start > region_start ?
>> +				       start : region_start;
>> +			select_end = end > region_end ? region_end : end;
>> +
>> +			region.size = select_end - region.start + 1;
>> +
>> +			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;
>> +			}
>> +		}
>> +	}
>> +	return 0;
>> +}
>> +
>>  #ifdef CONFIG_EFI
>>  /*
>>   * Returns true if mirror region found (and must have been processed
>> @@ -631,7 +678,6 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>>  {
>>  	struct efi_info *e = &boot_params->efi_info;
>>  	bool efi_mirror_found = false;
>> -	struct mem_vector region;
>>  	efi_memory_desc_t *md;
>>  	unsigned long pmap;
>>  	char *signature;
>> @@ -664,6 +710,8 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>>  	}
>> 
>>  	for (i = 0; i < nr_desc; i++) {
>> +		unsigned long long start, size;
>> +
>>  		md = efi_early_memdesc_ptr(pmap, e->efi_memdesc_size, i);
>> 
>>  		/*
>> @@ -684,13 +732,11 @@ process_efi_entries(unsigned long minimum, unsigned long image_size)
>>  		    !(md->attribute & EFI_MEMORY_MORE_RELIABLE))
>>  			continue;
>> 
>> -		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");
>> +		start = md->phys_addr;
>> +		size = md->num_pages << EFI_PAGE_SHIFT;
>> +
>> +		if (select_immovable_node(start, size, minimum, image_size))
>
>Why you replace the region with two parameters? Just use region.
>

You can see the commit message, we may splite one entry to more regions,
so there will be region.start compared with memory region in
immovable_mem and then fill more new regions if we use region here.
The code will look strange.

Start and size will be more clear.

Thanks,
Chao Fan

>>  			break;
>> -		}
>>  	}
>>  	return true;
>>  }
>> @@ -706,22 +752,20 @@ static void process_e820_entries(unsigned long minimum,
>>  				 unsigned long image_size)
>>  {
>>  	int i;
>> -	struct mem_vector region;
>>  	struct boot_e820_entry *entry;
>> 
>>  	/* Verify potential e820 positions, appending to slots list. */
>>  	for (i = 0; i < boot_params->e820_entries; i++) {
>> +		unsigned long long start, size;
>>  		entry = &boot_params->e820_table[i];
>>  		/* Skip non-RAM entries. */
>>  		if (entry->type != E820_TYPE_RAM)
>>  			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");
>> +		start = entry->addr;
>> +		size = entry->size;
>> +
>> +		if (select_immovable_node(start, size, minimum, image_size))
>ditto
>
>Thanks,
>	dou.
>>  			break;
>> -		}
>>  	}
>>  }
>> 
>> 

  reply	other threads:[~2017-10-20  3:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19 10:02 [PATCH 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG] Chao Fan
2017-10-19 10:02 ` [PATCH 1/4] kaslr: parse the extended movable_node=nn[KMG]@ss[KMG] Chao Fan
2017-10-20  3:04   ` Dou Liyang
2017-10-20  3:22     ` Chao Fan
2017-10-20  3:41       ` Dou Liyang
2017-10-20  3:44         ` Chao Fan
2017-10-20  5:33           ` Dou Liyang
2017-10-20  9:34             ` Chao Fan
2017-10-19 10:02 ` [PATCH 2/4] kaslr: select the memory region in immovable node to process Chao Fan
2017-10-20  3:17   ` Dou Liyang
2017-10-20  3:41     ` Chao Fan [this message]
2017-10-20  6:05       ` Dou Liyang
2017-10-19 10:02 ` [PATCH 3/4] document: change the document for the extended movable_node Chao Fan
2017-10-19 10:02 ` [PATCH 4/4] kaslr: clean up a useless variable and some usless space Chao Fan
2017-10-20  3:19   ` Dou Liyang
2017-10-20  4:10     ` Chao Fan
2017-10-20  2:37 ` [PATCH 0/4] kaslr: extend movable_node to movable_node=nn[KMG]@ss[KMG] Dou Liyang
2017-10-20  2:53   ` Chao Fan
2017-10-20  3:37     ` Dou Liyang
2017-10-20  3:46       ` Chao Fan
2017-10-20  6:41         ` Dou Liyang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171020034117.GB5635@localhost.localdomain \
    --to=fanc.fnst@cn.fujitsu.com \
    --cc=bhe@redhat.com \
    --cc=caoj.fnst@cn.fujitsu.com \
    --cc=douly.fnst@cn.fujitsu.com \
    --cc=hpa@zytor.com \
    --cc=indou.takao@jp.fujitsu.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome