From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smarthost01c.ixn.mail.zen.net.uk (smarthost01c.ixn.mail.zen.net.uk [212.23.1.22]) (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 A90523B8D42 for ; Wed, 21 Jan 2026 11:03:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.23.1.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768993422; cv=none; b=W8lvEq5yuqnOMx3l9ojtU3SSp+X6ONPCd9lQwEC/wa0MFL2AanSHRvmJcAMW5MtcUBzHKut5apbjfkZlyJRACuAbtmTt2gsiLyL+1Dr51Soe3fAFIN+ISgjTpOPqPTgZuT2UHG/ta8YWiNHWWqnQvisEEPr8gko3hcjoV0gQv08= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768993422; c=relaxed/simple; bh=sY2nyNBknwtDd6ux7sAOLa2lgDtHqay/dG7nG3jrXqw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pdlX1d4pSnstAJyUJpnVPKwcFauoCBlGfi9pqOhCITdXhNX+CpED7OYwARtjApct44GVokhaIy8J+0VozYOvaT4MQGrkdjLVGNdkMaPbrWAx9yKj6yVAUbaIYIPSt3YAlgcRKs4rFfKmMoWIYgUNg8UuRunlsjHrI/d7ebyOmUc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dingwall.me.uk; spf=pass smtp.mailfrom=dingwall.me.uk; arc=none smtp.client-ip=212.23.1.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dingwall.me.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dingwall.me.uk Received: from [217.155.64.189] (helo=mail0.xen.dingwall.me.uk) by smarthost01c.ixn.mail.zen.net.uk with esmtpsa (TLS1.0) tls TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (Exim 4.95) (envelope-from ) id 1viVzh-00DBO0-Dx; Wed, 21 Jan 2026 11:03:25 +0000 Received: from localhost (localhost [IPv6:::1]) by mail0.xen.dingwall.me.uk (Postfix) with ESMTP id E2887DF39CA; Wed, 21 Jan 2026 11:03:24 +0000 (GMT) X-Virus-Scanned: Debian amavis at dingwall.me.uk Received: from mail0.xen.dingwall.me.uk ([127.0.0.1]) by localhost (mail0.xen.dingwall.me.uk [127.0.0.1]) (amavis, port 10024) with ESMTP id LBUjXomlv6gY; Wed, 21 Jan 2026 11:03:24 +0000 (GMT) Received: from behemoth.dingwall.me.uk (behemoth.dingwall.me.uk [IPv6:2a02:8010:698e:302::c0a8:105]) by dingwall.me.uk (Postfix) with ESMTP id 90D7FDF39C7; Wed, 21 Jan 2026 11:03:24 +0000 (GMT) Received: by behemoth.dingwall.me.uk (Postfix, from userid 1000) id 5284E10CB0F3; Wed, 21 Jan 2026 11:03:23 +0000 (GMT) Date: Wed, 21 Jan 2026 11:03:23 +0000 From: James Dingwall To: Roger Pau Monne Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko Subject: Re: [PATCH] Partial revert "x86/xen: fix balloon target initialization for PVH dom0" Message-ID: References: <20260120140648.25977-1-roger.pau@citrix.com> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260120140648.25977-1-roger.pau@citrix.com> X-Originating-smarthost01c-IP: [217.155.64.189] Feedback-ID: 217.155.64.189 On Tue, Jan 20, 2026 at 03:06:47PM +0100, Roger Pau Monne wrote: > This partially reverts commit 87af633689ce16ddb166c80f32b120e50b1295de so > the current memory target for PV guests is still fetched from > start_info->nr_pages, which matches exactly what the toolstack sets the > initial memory target to. > > Using get_num_physpages() is possible on PV also, but needs adjusting to > take into account the ISA hole and the PFN at 0 not considered usable > memory depite being populated, and hence would need extra adjustments. > Instead of carrying those extra adjustments switch back to the previous > code. That leaves Linux with a difference in how current memory target is > obtained for HVM vs PV, but that's better than adding extra logic just for > PV. > > Also, for HVM the target is not (and has never been) accurately calculated, > as in that case part of what starts as guest memory is reused by hvmloader > and possibly other firmware to store ACPI tables and similar firmware > information, thus the memory is no longer being reported as RAM in the > memory map. > > Reported-by: James Dingwall > Signed-off-by: Roger Pau Monné > --- > drivers/xen/balloon.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c > index 49c3f9926394..e799650f6c8c 100644 > --- a/drivers/xen/balloon.c > +++ b/drivers/xen/balloon.c > @@ -724,6 +724,7 @@ static int __init balloon_add_regions(void) > static int __init balloon_init(void) > { > struct task_struct *task; > + unsigned long current_pages; > int rc; > > if (!xen_domain()) > @@ -731,12 +732,15 @@ static int __init balloon_init(void) > > pr_info("Initialising balloon driver\n"); > > - if (xen_released_pages >= get_num_physpages()) { > + current_pages = xen_pv_domain() ? min(xen_start_info->nr_pages, max_pfn) > + : get_num_physpages(); > + > + if (xen_released_pages >= current_pages) { > WARN(1, "Released pages underflow current target"); > return -ERANGE; > } > > - balloon_stats.current_pages = get_num_physpages() - xen_released_pages; > + balloon_stats.current_pages = current_pages - xen_released_pages; > balloon_stats.target_pages = balloon_stats.current_pages; > balloon_stats.balloon_low = 0; > balloon_stats.balloon_high = 0; > -- > 2.51.0 > Thank you Roger, I tested this patch on the system which originally showed the error and the pci passthrough now works as expected. Regards, James