[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH] xen/device-tree: Switch back to dt_unreserved_regions() in boot allocator


  • To: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Tue, 25 Mar 2025 09:46:20 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hjOTkbkYTS02rJHZrk7Jta3DippgZFvHnLCM2yf7V3o=; b=sA4f+CGf3sNs1sViHmrcLdWwMUhNzzltKU41b3s2EbRvBZvFpJl5tLnXyoFtVaCaycIL/dGFivPkWwdimAJ+JVd/YISMpsN6pVfEAIRlN5uK/EO7b71eP4z93gbVyU1bUxsLNAKm2i5SX3OYuXhOTgKv/0RLJyYwk0IRnuIGYYWfIN87JxpMQlPa6o4CYaKZUz4Wtmpy7Zd5WEs6nv8gKfQpD7WQcya2Vq+XMOLKOhyeWEsctFKtrIizr7p/BIJqd5hMr64UCK/bwrCRzwl4RLPYXEpW7XzElkFyeR9NYTwm7RHw9pR8hVvOGr4cuziC1U3VUZq1lVE2xKbtJ2ViLA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ijJHnegDJrCy38FQsozp91tpdnq1xvTaLc7Tn+d0VDLw8FsTwABAk2UOTp4A+9HzQFpEKuYWzv7KHsEGwk7NjS2jWvsvDymc5bCwI6XxSb43i/aVZFkFgI8GkCUR/aRWVHaQboYo5JpSYj3AGKa8+dZljf6esqYMh93LVkXPJShnmP5yk7N0wzSs3ye/XHd9W5v8uloQS4Pfvc29GoQRv3X0A/Eh5ggME7bzv08yEa2Xm22dHACCwrsqbZTwgSqGd+rXUZzvXN4paq7K6fq7x4IC5ojazkVJzpoBkmcf5ak5G8WFzxbvB/mWbrQSYU4lWOYWnQCpe+MpcXIvODGyLA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Tue, 25 Mar 2025 08:46:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 24/03/2025 22:27, Oleksandr Tyshchenko wrote:
> 
> 
> On the device-tree-based Arm64 system, if Xen is built with
> CONFIG_ACPI=y, CONFIG_STATIC_MEMORY=y, and the static memory range
> is provided in the host device tree, the BUG is triggered in
> common/page_alloc.c during Xen's early boot. The BUG occurs when
> the first page from the static range is fed to the domain
> sub-allocator and finally ends up in mark_page_free().
> The pg->count_info & PGC_state is not in the state that
> the code expects to see there.
> 
> The problem is that the static range gets mistakenly unreserved
> in populate_boot_allocator() and reaches init_boot_pages().
> This happens since by the time the populate_boot_allocator()
> is executed, the evaluated in fw_unreserved_regions()
> an acpi_disabled variable is still false (CONFIG_ACPI=y) and
> dt_unreserved_regions() which should simply skip that static range
> does not get called. The acpi_disabled will be set to the actual
> value later on in acpi_boot_table_init().
> 
> To avoid unreserving the whole region (including potential reserved
> memory ranges such as static memory) open code fw_unreserved_regions()
> and add a comment.
> 
> Another solution could be to call acpi_boot_table_init() before
> setup_mm() in Arm64's start_xen().
Interesting issue. However IMO the problem is located somewhere else. At the
moment, with CONFIG_ACPI=n, acpi_disabled is set to true. With CONFIG_ACPI=y,
it's set to false even though entire acpi_boot_table_init() is written with
assumption that ACPI is off by default at the start. That's why
acpi_boot_table_init() calls e.g. disable_acpi() if it finds that user specified
acpi=off on cmdline. Why would it do that if the assumption was that
acpi_disabled is false? There's even a comment:
https://xenbits.xenproject.org/gitweb/?p=xen.git;a=blob;f=xen/arch/arm/acpi/boot.c;hb=HEAD#l257
that clearly says that "at this point ACPI is disabled".

Therefore, I think the fix should look as follows:
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index ffcae900d72e..9e94f1a8c761 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -57,7 +57,7 @@
 struct cpuinfo_arm __read_mostly system_cpuinfo;

 #ifdef CONFIG_ACPI
-bool __read_mostly acpi_disabled;
+bool __read_mostly acpi_disabled = true;
 #endif

 domid_t __read_mostly max_init_domid;

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.