Re: [PATCH v9 8/8] x86/boot/KASLR: Limit kaslr to choosing the immovable memory

Chao Fan
2018-10-22T10:49:45Z

On Mon, Oct 22, 2018 at 06:24:55PM +0800, Baoquan He wrote:
>On 10/22/18 at 06:13pm, Chao Fan wrote:
>> >> +static bool process_mem_region(struct mem_vector *region,
>> >> + unsigned long long minimum,
>> >> + unsigned long long image_size)
>> >> +{
>> >> + int i;
>> >> + /*
>> >> + * If no immovable memory found, or MEMORY_HOTREMOVE disabled,
>> >> + * walk all the regions, so use region directely.
>> >> + */
>> >> + if (num_immovable_mem == 0) {
>> >> + slots_count(region, minimum, image_size);
>> >> +
>> >> + if (slot_area_index == MAX_SLOT_AREA) {
>> >> + debug_putstr("Aborted e820/efi memmap scan (slot_areas full)!\n");
>> >> + return 1;
>> >> + }
>> >> + return 0;
>> >> + }
>> >> +
>> >> +#ifdef CONFIG_MEMORY_HOTREMOVE
>> >> + /*
>> >> + * If immovable memory found, filter the intersection between
>> >> + * immovable memory and region to slots_count.
>> >> + * Otherwise, go on old code.
>> >
>> >Could you explain more about what is the old code in otherwise case you
>> >want to go on?
>>
>> Sure,
>> 1. 'movable_node' not specified in cmdline.
>> 2. CONFIG_HOT_REMOVE not difned.
>> 3. Just one node in this machine.
>
>So these cases are not covered by 'if (num_immovable_mem == 0)' code?
They are covered by 'if (num_immovable_mem == 0)' code.
>In thise ifdef code block, where do you handle above three cases?
"go on old code." means above:
+ if (num_immovable_mem == 0) {
+ slots_count(region, minimum, image_size);
+
+ if (slot_area_index == MAX_SLOT_AREA) {
+ debug_putstr("Aborted e820/efi memmap scan (slot_areas full)!\n");
+ return 1;
+ }
+ return 0;
+ }

Thanks,
Chao Fan

>
>Thanks
>Baoquan
>
>