Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp877819ybe; Thu, 5 Sep 2019 07:16:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwN+pKTfLVIdJJ4MKtBcPFCXM9AhN/ZC/7hIzX/bwIB4pIVsbq5yCKQsUWDGf5ATiN16R84 X-Received: by 2002:a63:cc14:: with SMTP id x20mr3436286pgf.142.1567692963445; Thu, 05 Sep 2019 07:16:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567692963; cv=none; d=google.com; s=arc-20160816; b=H3AwQAlrpLqHfdC3rbH2ItLxZxHjOsH49pv5loInbnQrI721JqUH3Mxo2gY24cgdhl sWtazYomzofMr3maPN9yR1CYLWuzxwZR0p+bGjyFamEJVhZnnkv5OefydP3DEhDPBun9 t4jO7U+p2CNKWVTPKHMT+zSXBriKU6hhYOY3YMR0tCsvrdNnRapubAhuUAibaYsRmHwJ LHArwqbDKglH3wOh9T9PFyZ+HTnVuaAP5hSMUQ3uaDfR7U4nWgqvOBUsNFBEexKTilNY yo5AbcucwyWxBzth4CCFdNY+ADTaefuspQH3moa57hvY5+7eO7ChDbW9cXenC8vZXDEg LmIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Rkq9+fRE5roldOHATlaaFTfefwfPDgcEPEGx16+rHCQ=; b=LoRke+siXD80XpjZTkOJ3/Z+sE6NSlrO+VFgYSarfT0Z/kApjJQ1OSo6smEFC26emK DD+thiVtfPC9iPf5QDd+Tt6/x+raYFy6676tuk4RrgKb9IOO2ngUkzbqj5nbZ79hYF6J jj3/Z6sfw+f/HH8w8nrpNEeHyT35tdOK79mesk+A9IKUR0mpcDOSnUKp3pgNvyTbTUdj 5or5puyOOLQNyWuQU+dC2rBaLx7Vs8SPBUg7pppHPQ4R68HFqDgp/LUFP4FfxBW0VpRY PtDr+Y9108mMmhjjsZAAiECtNb6zfstELRJWzL6Wp0oBvYa22/oUmVrdJlzPbOJ9Jdd5 I2dQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r11si2142230pls.183.2019.09.05.07.15.47; Thu, 05 Sep 2019 07:16:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732496AbfIENvu (ORCPT + 99 others); Thu, 5 Sep 2019 09:51:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55890 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729318AbfIENvu (ORCPT ); Thu, 5 Sep 2019 09:51:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D435318C4266; Thu, 5 Sep 2019 13:51:49 +0000 (UTC) Received: from localhost (ovpn-12-28.pek2.redhat.com [10.72.12.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB3B75D9E2; Thu, 5 Sep 2019 13:51:47 +0000 (UTC) Date: Thu, 5 Sep 2019 21:51:34 +0800 From: Baoquan He To: Masayoshi Mizuma Cc: Borislav Petkov , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/5] x86/boot: Get the max address from SRAT Message-ID: <20190905135134.GC20805@MiWiFi-R3L-srv> References: <20190830214707.1201-1-msys.mizuma@gmail.com> <20190830214707.1201-4-msys.mizuma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190830214707.1201-4-msys.mizuma@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Thu, 05 Sep 2019 13:51:49 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/30/19 at 05:47pm, Masayoshi Mizuma wrote: > From: Masayoshi Mizuma > > Get the max address from SRAT and write it into boot_params->max_addr. > > Signed-off-by: Masayoshi Mizuma > --- > arch/x86/boot/compressed/acpi.c | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c > index 908a1bfab..ba2bc5ab9 100644 > --- a/arch/x86/boot/compressed/acpi.c > +++ b/arch/x86/boot/compressed/acpi.c > @@ -362,16 +362,24 @@ static unsigned long get_acpi_srat_table(void) > return 0; > } > > -static void subtable_parse(struct acpi_subtable_header *sub_table, int *num) > +static void subtable_parse(struct acpi_subtable_header *sub_table, int *num, > + unsigned long *max_addr) > { > struct acpi_srat_mem_affinity *ma; > + unsigned long addr; > > ma = (struct acpi_srat_mem_affinity *)sub_table; > > - if (!(ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) && ma->length) { > - immovable_mem[*num].start = ma->base_address; > - immovable_mem[*num].size = ma->length; > - (*num)++; > + if (ma->length) { > + if (ma->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) { > + addr = ma->base_address + ma->length; > + if (addr > *max_addr) > + *max_addr = addr; Can we return max_addr or only pass out the max_addr, then let the max_addr compared and got outside of subtable_parse()? This can keep subtable_parse() really only doing parsing work. Personal opinion, see what maintainers and other reviewers will say. Thanks Baoquan > + } else { > + immovable_mem[*num].start = ma->base_address; > + immovable_mem[*num].size = ma->length; > + (*num)++; > + } > } > } > > @@ -391,6 +399,7 @@ int count_immovable_mem_regions(void) > struct acpi_subtable_header *sub_table; > struct acpi_table_header *table_header; > char arg[MAX_ACPI_ARG_LENGTH]; > + unsigned long max_addr = 0; > int num = 0; > > if (cmdline_find_option("acpi", arg, sizeof(arg)) == 3 && > @@ -409,7 +418,7 @@ int count_immovable_mem_regions(void) > sub_table = (struct acpi_subtable_header *)table; > if (sub_table->type == ACPI_SRAT_TYPE_MEMORY_AFFINITY) { > > - subtable_parse(sub_table, &num); > + subtable_parse(sub_table, &num, &max_addr); > > if (num >= MAX_NUMNODES*2) { > debug_putstr("Too many immovable memory regions, aborting.\n"); > @@ -418,6 +427,9 @@ int count_immovable_mem_regions(void) > } > table += sub_table->length; > } > + > + boot_params->max_addr = max_addr; > + > return num; > } > #endif /* CONFIG_RANDOMIZE_BASE && CONFIG_MEMORY_HOTREMOVE */ > -- > 2.18.1 >