Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6510059imu; Sun, 2 Dec 2018 20:20:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/X8hn++9FwLxXARkuWMJRH28jX9E6DxYdArcIgHRqT7awjGgXdO6KBYK7H1l/Q6VGLuotd/ X-Received: by 2002:a62:6799:: with SMTP id t25mr14390777pfj.139.1543810817721; Sun, 02 Dec 2018 20:20:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543810817; cv=none; d=google.com; s=arc-20160816; b=qltTNZUH7VB1EKf68CE9QjlJ6MYQoKdk4kTfH6s9wEz03uUp9zUlWnkZS/xPM6s1Ll SWnCyuHm9CKzrynKzBIue9w0CXudxb0zIDPBV3dWLV2hzMGFDvSxLHBqmstlaVrtpIbI pzfbqjV8odeuS+JUYsNS7RQlCdpnujSFPF9xB4mlRuI5ofvpTBq6swCCbmWCaWzSJeT2 eG1xnnqG6eyzspxoz+8ln2Dwkdzn8AGawhesX2GMKmCSpdlIb76qUTf86C3j1Iokpin4 /medJEqTcsHmb2Eu5St/Wl6iIBjHjnoHfFQ1BGABe+IwjgVqWEx9taZoJr1FAWI2lTgl OsaQ== 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=c+1do9fLXebSD/m8YrEEdQGwnqFZsyFb0dgi2Nfp7Q4=; b=njcRWKM3yidgsfHu0mkwOrWCqDnWpaM6wQ1Jcoln80LunV2dLjt/peOBqjlp+kEXGt Mnx341VfOfUUGlFjVtCese/pAYm8C5xaGX2xTqpiRga4tAlnpp1X73cE/8fx3c/q7fN6 2luzdzmuG0kM0CL8j//PeoK1CEU117lnmbC9BKf7rrMhFlwD+jTEdz81bdKUaK0I0PCx vZ52YVdCjRKN7hyFlvsCZPEA03wuu8VOtJmiBMZTnThVdDks1k0wGEvtmpEtOoIgStKe NHSxSKiR2HfkQD3aGA604psXn4SL2z0171Nq1tg5ZXbXP/yE6tVOx171WPkApjA3JYcZ rZ5w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si11253518pgl.340.2018.12.02.20.20.02; Sun, 02 Dec 2018 20:20:17 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725819AbeLCETc (ORCPT + 99 others); Sun, 2 Dec 2018 23:19:32 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:37090 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725806AbeLCETc (ORCPT ); Sun, 2 Dec 2018 23:19:32 -0500 X-IronPort-AV: E=Sophos;i="5.56,308,1539619200"; d="scan'208";a="48930142" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 03 Dec 2018 12:19:24 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id C0F204B6ED69; Mon, 3 Dec 2018 12:19:24 +0800 (CST) Received: from localhost.localdomain (10.167.225.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 3 Dec 2018 12:19:27 +0800 Date: Mon, 3 Dec 2018 12:19:10 +0800 From: Chao Fan To: Masayoshi Mizuma CC: , , , , , , , , , Subject: Re: [PATCH v12 4/5] x86/boot: Parse SRAT table from RSDP and store immovable memory Message-ID: <20181203041910.GE30941@localhost.localdomain> References: <20181129081631.11139-1-fanc.fnst@cn.fujitsu.com> <20181129081631.11139-5-fanc.fnst@cn.fujitsu.com> <20181129175520.xcmj3bv4yhdr7kk3@gabell> <20181130012454.GB1527@localhost.localdomain> <20181130145432.j2iwbglwrtj5xdus@gabell> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20181130145432.j2iwbglwrtj5xdus@gabell> User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [10.167.225.56] X-yoursite-MailScanner-ID: C0F204B6ED69.AD9D5 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: fanc.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 30, 2018 at 09:54:33AM -0500, Masayoshi Mizuma wrote: >On Fri, Nov 30, 2018 at 09:24:54AM +0800, Chao Fan wrote: >> >> /* acpitb.c */ >> >> +#ifdef CONFIG_RANDOMIZE_BASE >> >> +/* Store the amount of immovable memory regions */ >> >> +int num_immovable_mem; >> >> +#endif >> >> + >> >> +#ifdef CONFIG_EARLY_PARSE_RSDP >> >> +void get_immovable_mem(void); >> > >> >> +/* There are 72 kinds of ACPI_SIG in head file of ACPI. */ >> >> +#define MAX_ACPI_SIG 72 >> > >> >The 72 isn't the specification of ACPI, right? So the number >> >> Yes, it's from ACPI code, include/acpi/actbl*h. >> Boris said there should be a check for the num_entries, >> I didn't get a good idea, so I use the max number to check it. >> So do you have some advice? > >Ah, got it. How about adding the check for len to prevent the wrap? >Like as: > > len = header->length; > if (len <= sizeof(struct acpi_table_header)) > return NULL; > num_entries = (u32)((len - sizeof(struct acpi_table_header)) / size); Hi Masa, Your check is right, but not exactly the same. I think what Boris said is to prevent num_entries from getting too large and the loop getting too much. So the 'num_entries' or 'len' can't be more than a fixed value. Thanks, Chao Fan > >Thanks, >Masa > >