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

Re: [PATCH for-4.22 v2] xen/x86: Change stub page allocation/free


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Thu, 11 Jun 2026 13:26:07 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=citrix.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=u8o3963NWYw7wPzD0qV1mgDhdlJGqg9Gy/ZYe9bblvg=; b=bgQldTb0k7QX6mjad0kQDYLaoc4RL1q6mBue2M//XV4Uf6BvoJcmLkA5If4BKULJIbafaG6XcKo8biIj38PtTw62bxJnPDpUKRDDyLNyHckWoGZGrvsRvyDuIctGR59O6WD8MCH0FwGY4ITXxXKGmz5jMTBuHKnXVkig33IIRWg7CjxBlIO3kzecSh85v233xBEZw9+uQEsUGvbkc0SAlEtMMw87Xg8v1Gx7m5re7D8JaLTADZDaxkF0pF6RQGYFKkcnbX2dgdIZTIO1d/agTdadapmVWiHrqfiwtnfGYrQN1awuFgq8AlCYHlY4oIlhjosyzYJfTAIR93e3Jna3xQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ExtNQ8AU7l/lOwY5MtMquu7RK6X0c2+xvQETbMMDmr+IJPYl6+Dyun3WmeRpYla/7T1kLPT0ZZbILsJ936011j0lYOYbQ4bnRgm+e+QAIj9wAn/P/kW2aNkmS0VIG+rEfCjLRpg9OADqZ1JOcSj0wIajhKf1080h48PztKxmxKvpIOlpZu+70H+6Z/Tu3v2tX16IVsTrYa7AccGmdek9PY3Gn0SqGxGavQg04rngGyXwW1TYNeImAWkcYy0D6XV6F45vj5ZmthU6DFtD+FaQ/yvCDDTJpt8+HNrNeF+6oo/GEadJWy1/5SpRpH9x4ooY5f/nAVxtIraLtnTYjbfdkw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Thu, 11 Jun 2026 17:26:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2026-06-11 10:21, Roger Pau Monne wrote:
From: Jason Andryuk <jason.andryuk@xxxxxxx>

Today the inline tracking of the stub page is problematic.  0xcc is used to
indicate unused, but it is also a "clear value."  A !CONFIG_PV build with
smt=0 will bring up CPU0, bring up CPU1, bring down CPU1, and free the
in-use stub page.  CPU0 or subsequent onlined CPUs can write to the re-used
page.

The new approach uses a global, CPU-indexed dynamically allocated array of
stub addresses.  However, to handle NUMA aware allocations, we cannot
allocate all the memory in advance because of the NUMA dependency.  Take
advantage of the fact that Xen will attempt to contiguously pack CPUs on
the same NUMA node (see normalise_cpu_order()), and on CPU bringup use the
same stubs page the previous CPU did if suitable.  Note the code would
still function properly even if CPUs from NUMA nodes are not contiguously
packed, it just consumes more memory.

stub pages are no longer freed.  They remain referenced in the global
CPU-indexed array and are re-used if the CPU is re-onlined.

The stubs array doesn't have an explicit lock.  During boot it's accessed
single threaded.  During runtime, &cpu_add_remove_lock serializes access.

Fixes: 7a66ac8d1633 ("x86: move syscall trampolines off the stack")
Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks, Roger.


-        nodeid_t node = cpu_to_node(cpu);
-        unsigned int memflags = node != NUMA_NO_NODE ? MEMF_node(node) : 0;
+        nodeid_t nid = cpu_to_node(cpu);

...

+            struct page_info *pg = alloc_domheap_page(NULL, MEMF_node(nid));

I agree that MEMF_node(NUMA_NO_NODE) -> 0, so this is okay. I looked around, and there is a mix of places that special case NUMA_NO_NODE or don't, which makes it a little confusing.

- unmap_domain_page(memset(__map_domain_page(pg), 0xcc, PAGE_SIZE));
+            if ( !pg )
+                return false;

Newline here?

+            unmap_domain_page(memset(__map_domain_page(pg), 0xcc, PAGE_SIZE));
+            addr = page_to_maddr(pg);
+        }
+        stubs[cpu] = addr;

!CONFIG_PV && smt=0 boots (doesn't blow up).

Tested-by: Jason Andryuk <jason.andryuk@xxxxxxx>
Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx>

Thanks,
Jason



 


Rackspace

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