Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1667709pxb; Thu, 16 Sep 2021 12:28:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi08q9s87YE/+o/tBplWcVWsU4TD5kIr/4WAs8JUwrBgdYuNo3bgzeCMz2PlfXqhTybxLf X-Received: by 2002:a17:907:75ed:: with SMTP id jz13mr7891387ejc.506.1631820523002; Thu, 16 Sep 2021 12:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631820522; cv=none; d=google.com; s=arc-20160816; b=DbL2o3ormVh0XV6O2MCVd2sdAUlZV5krYlix7NjRrUqS6p3Qjp7U84CyWHbN7hEIho 0Lwaq6bbVqRnG0ikE++9r7YTqWgDsdtz+LeWtkhfsyA9EEgqKvpSFGuq1oARNQ8QN4Me S8dRTDsIS7y1gBjSBEx6aCvtDTB6jzu9PFfLTKqEp7AkhBnnZ/c4Yyqn0wL/5s+wxMSx tmSaIMF5ATziSFdcqVWE0Yqhunjeby/fE6anMJF0OwFV8niI8a4wfrdRfU3jUzNOfYN9 0yywqAgjQ5BnSh/SzlwUx70p5Yi5pSMRqTW3CpldLSLn6YVt9nXskKCAGZGohmK+MO2Q Vttw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oswHMZclWh5+tHy0mj/TWL2ce+cy+5wcy3muWwqWdhA=; b=0nuWu4wCGXONTW1SCtINkgYam5ZNQ4/MRbqDqdbG4fawOkyxiKvYllB+Gtzt+wfA2l GBw64PffLMgIiCGOwVUHLMd7TS7ct2D3XHiYPAOYKiLFZsAunc4c0ZfkzXCFrNQNJ6JQ mJUHQz9rJNYyh0fr6zbeCkhLpg+e9JLKvJkZ6gGqboEjP32PcA93B9K/iMtQYAkrVajm 0mX1Ieik3I7XU1AhbY/XZKVUoP2qKtQzH9dot8KIO1rIPjM7oRjCY1V87W8FQbMdJUfz gY87uTgbnD81Air7hUZmPeI1tiHrOVz8jd0W/9lxTMcZmZJxVA/go7Bk07DxvlLvta8n l4ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="sV/7AJPY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id og11si3862308ejc.487.2021.09.16.12.28.19; Thu, 16 Sep 2021 12:28:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="sV/7AJPY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240537AbhIPQFc (ORCPT + 99 others); Thu, 16 Sep 2021 12:05:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:44480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240528AbhIPQFW (ORCPT ); Thu, 16 Sep 2021 12:05:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AD1361246; Thu, 16 Sep 2021 16:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808241; bh=c4V6EWY3Wn/cNSs1oKxOGg3WnslcDrOHs2+AwiRU454=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sV/7AJPYduBD5fNxL604T1/+D/5Pma6eae6B5KQcw97j/2/RIQmQ5DACw8ewepJWL 919MQJwp/CGEm5sukbLGa8cxz4Tvaalfz9rdirr0+nuiDYVQXfVjq9BdSYwtnBNrlb KHrBG5l9K7IWw/jXQcGhbvBJ4DLAYmmbGce/DrMM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Jan Beulich Subject: [PATCH 5.10 013/306] xen: fix setting of max_pfn in shared_info Date: Thu, 16 Sep 2021 17:55:58 +0200 Message-Id: <20210916155754.371235087@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross commit 4b511d5bfa74b1926daefd1694205c7f1bcf677f upstream. Xen PV guests are specifying the highest used PFN via the max_pfn field in shared_info. This value is used by the Xen tools when saving or migrating the guest. Unfortunately this field is misnamed, as in reality it is specifying the number of pages (including any memory holes) of the guest, so it is the highest used PFN + 1. Renaming isn't possible, as this is a public Xen hypervisor interface which needs to be kept stable. The kernel will set the value correctly initially at boot time, but when adding more pages (e.g. due to memory hotplug or ballooning) a real PFN number is stored in max_pfn. This is done when expanding the p2m array, and the PFN stored there is even possibly wrong, as it should be the last possible PFN of the just added P2M frame, and not one which led to the P2M expansion. Fix that by setting shared_info->max_pfn to the last possible PFN + 1. Fixes: 98dd166ea3a3c3 ("x86/xen/p2m: hint at the last populated P2M entry") Cc: stable@vger.kernel.org Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Link: https://lore.kernel.org/r/20210730092622.9973-2-jgross@suse.com Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- arch/x86/xen/p2m.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/xen/p2m.c +++ b/arch/x86/xen/p2m.c @@ -618,8 +618,8 @@ int xen_alloc_p2m_entry(unsigned long pf } /* Expanded the p2m? */ - if (pfn > xen_p2m_last_pfn) { - xen_p2m_last_pfn = pfn; + if (pfn >= xen_p2m_last_pfn) { + xen_p2m_last_pfn = ALIGN(pfn + 1, P2M_PER_PAGE); HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn; }