From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755459AbdKJBO0 (ORCPT ); Thu, 9 Nov 2017 20:14:26 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:6937 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755255AbdKJBOZ (ORCPT ); Thu, 9 Nov 2017 20:14:25 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="30065425" Date: Fri, 10 Nov 2017 09:14:17 +0800 From: Chao Fan To: Baoquan He CC: , , , , , , , , , Subject: Re: [PATCH v2 2/4] kaslr: select the memory region in immovable node to process Message-ID: <20171110011416.GA15416@localhost.localdomain> References: <20171101113203.27741-1-fanc.fnst@cn.fujitsu.com> <20171101113203.27741-3-fanc.fnst@cn.fujitsu.com> <20171109082132.GJ22644@x1> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20171109082132.GJ22644@x1> User-Agent: Mutt/1.9.1 (2017-09-22) X-Originating-IP: [10.167.225.56] X-yoursite-MailScanner-ID: 5C9BE48089FB.ACD1F X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: fanc.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> 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(®ion, 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(®ion, 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(®ion, 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 >> >> >> > >