From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABC3E77F15 for ; Thu, 21 Dec 2023 22:03:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="cw8Y20B2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5AF6C433CB; Thu, 21 Dec 2023 22:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1703196181; bh=8FGnjhDRKc63x6ERnHGCSptOkrbsqPFpkkKFJyg21vQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cw8Y20B2iIadYSq+h5u2ueHu6JqUTjdciIgVa4yrnUfWDfZjoDo89/Tsuom2/ncZy H89QvIwHir1WNrmKBE1ixTnVNvptOSaNk0vZcOx0IBbS9iwG6BuZWvXt8Goj+h8vWD iJLrfWKHYPJiyfrzmHMcA45OYhJ64/NT4fBEqFbk= Date: Thu, 21 Dec 2023 14:03:00 -0800 From: Andrew Morton To: Yuntao Wang Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Baoquan He , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Simon Horman , Bjorn Helgaas Subject: Re: [PATCH] x86/kexec: fix incorrect end address passed to kernel_ident_mapping_init() Message-Id: <20231221140300.4fcfd4945eeb3b6c145a969c@linux-foundation.org> In-Reply-To: <20231221101702.20956-1-ytcoode@gmail.com> References: <20231221101702.20956-1-ytcoode@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 21 Dec 2023 18:17:02 +0800 Yuntao Wang wrote: > kernel_ident_mapping_init() takes an exclusive memory range [pstart, pend) > where pend is not included in the range, while res represents an inclusive > memory range [start, end] where end is considered part of the range. > > Therefore, passing res->end directly to kernel_ident_mapping_init() is > incorrect, the correct end address should be `res->end + 1`. > > ... > > --- a/arch/x86/kernel/machine_kexec_64.c > +++ b/arch/x86/kernel/machine_kexec_64.c > @@ -44,7 +44,7 @@ static int mem_region_callback(struct resource *res, void *arg) > struct init_pgtable_data *data = arg; > > return kernel_ident_mapping_init(data->info, data->level4p, > - res->start, res->end); > + res->start, res->end + 1); > } Thanks. When fixing a bug, please always full describe the userspace-visible effects of that bug. In this case I'm assuming "none", due to kernel_ident_mapping_init()'s upward rounding of the address?