Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp443446rdb; Thu, 21 Dec 2023 14:03:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNTv91k6Uq1eLyyF2o8AlfKqXb19MAQK/HsIqKywi17m8qLgJYAvp1aRXz33r0UYD3kV0B X-Received: by 2002:a05:620a:1923:b0:77e:fbba:6466 with SMTP id bj35-20020a05620a192300b0077efbba6466mr2472228qkb.69.1703196201230; Thu, 21 Dec 2023 14:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703196201; cv=none; d=google.com; s=arc-20160816; b=jbSUd49ml/LoWWD8T+vblJbvKKgPzYkxDKw/GeIb6eubnc0Capz4GX2Kus778kpFEd Qqh/05eyzxjw5vZvw/My/wy/zgpWidHm7B7U8LOdTA8DlnuO4iBwSuhMI+iSqJyawLqN bFZwwcmPoBn+E1MdvsLNW+g/2MNmIvSemls75afk7IGx7iSxuZZE8xdz1JyvbT75bF2g UfCcPdOQAIO7lWc5zU6S4jRVvS6wRovbWE3NM8Q8uxe4cKu5H5GpbzJ1yh46SGllxgYl qu6QnPhfp1UxuwZB+OtLYLQ9THbWOX2NrOAhQqKG6eMKmLjDFqRPeoGxnilcfajMx507 sQug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Zl5WZ9D4SM1BDmn1imNHX5/rJLiVKCxiTuNKjEpqAU0=; fh=oXW2EsnSf5CW+td2WR1Z+22S3rFULHnzj+06fj92Yjc=; b=uLvW2A57YY0azGUhDBEJABpyM1zdeJozrABhEHP7kCMquF59bJ69qjU6RdEhG7O7VO jtHuVvWkrskMY+4WfaYHXGpeQUinV8y9NtAgHPWjMimrcySzI3ic3JJb400NlmMRGnp6 6DaE9/4ix7Oe3xQgvv7FhSEUKe+EhVfeBumX7nF9t9ZqXdVJ5hgs5ijzkP2TE6v07g/a vAc3fCRcygcCccgHdM/cqm1W7F5vtTtp2j7CWq/ApbvGSQhcogZeiUBWekleCSOQV9hA YTqGGr9B91qeV3kNvTcqEfRISa3yyD3IFZFUIhqPdN79zMUQl/+ex2ctj4os/drI5Rar MfNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=cw8Y20B2; spf=pass (google.com: domain of linux-kernel+bounces-9110-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9110-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d12-20020ac85acc000000b004277c3be900si3116310qtd.457.2023.12.21.14.03.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 14:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9110-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=cw8Y20B2; spf=pass (google.com: domain of linux-kernel+bounces-9110-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9110-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 94F221C23F2C for ; Thu, 21 Dec 2023 22:03:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7989F77F2D; Thu, 21 Dec 2023 22:03:03 +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" X-Original-To: linux-kernel@vger.kernel.org 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) 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?