Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2565892lkm; Mon, 20 Sep 2021 18:52:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN02KOhdekPyUGlFoT8faLSzY1UiJ3Xg1tZ68HzcoLW4YZJJqf6b4hwfn0b0Qk+nIVtdoR X-Received: by 2002:a05:6602:4a:: with SMTP id z10mr10747153ioz.16.1632189026771; Mon, 20 Sep 2021 18:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189026; cv=none; d=google.com; s=arc-20160816; b=nTQOjwHd/mYMGGZ8Bz2ektz6t6szxT5aPD1o0zvArziBFz84TLLGBKSjP6q5TLAEdE ZIxLF/b5HStlgiDXT0tXABYxTMyQUON84ppgYtJSCavlzBNr+U030EeeQa3/kos5k8qD pbwoQpmmAO/yEw6i3jwjeJBnr6fpVVUEMmPuYYx/nf5h3qmc09xx/XP6noFgZMbby1Wo K070QAi/sNezjyV1X++chiMXfL3jQOqYLP7AfuV71s8pbuKj8pxFgYruVWercE/gdkHE W9dF2m33FuO5LfWtBAl5RzUV4ET3x3zD100Y39YUnnwC61Xprbe3pHcnX8ATbYghzcvC godg== 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=FjDvBdZdMHP7HBT4UbPk85AzwVrFZX55AMtMU0wxVdU=; b=E3Km3x62kJl4Svlm8mM7FMcE5GlEoNwVz78fIKc9NCyRD8gr0GtaCafJojvbFWyD9y j43ibYSbjU1h6JzTNgcU1UCvDtbtQSEI6FZPkot01hkbWWLSgSAePfMRNzfpO42Dkp9D OhozlzQ+T/8avIfdXxzn7twGDZUrLtnE9RnMz3eM6XrrlgZ6sszsLGasaLqDkNCv29S6 kX4JmUR/KWMjdUbKXT9imYbLBzswzzTPAPScFeC94Z+RbIN3n70TjPE+dDP7FRl+zKcO TRQbG0OBNUOiDm+yVYlMKinbvkeM9qQlD5A3LhKmmwgdR2dYr81cYaLuYZVkBAM2SUdb fFiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T4P9cfP0; 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 e17si15813840iot.109.2021.09.20.18.50.15; Mon, 20 Sep 2021 18:50:26 -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=T4P9cfP0; 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 S1350471AbhITSFx (ORCPT + 99 others); Mon, 20 Sep 2021 14:05:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:57648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356431AbhITR7z (ORCPT ); Mon, 20 Sep 2021 13:59:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 32EF663222; Mon, 20 Sep 2021 17:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158134; bh=fkpJmItxZAh1VTg2jjoL2N7YC7WgQwXD95DqcrK7egA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4P9cfP0bFZFL2O2kYJcm+dNLsKtL2nf0QKzNaDe4l+eEpVvFinjoiHuArNd4400M 70AnzI0rRLFpM868WLY47Wz9U56s51FyiQGkfTMGSZHW1ijqSvwW4idr+0NPBbgc2l Y7Vs8TMJkRRhUwPr3K2ec8bXIIylzevAd68AS3RM= 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.4 008/260] xen: fix setting of max_pfn in shared_info Date: Mon, 20 Sep 2021 18:40:26 +0200 Message-Id: <20210920163931.414630351@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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 @@ -622,8 +622,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; }