All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] xen/arm: p2m: free 1GB static shared memory on domain destroy
@ 2026-11-30 16:43 Gabriel Quintáns Souto
  2026-11-30 16:43 ` [PATCH 1/3] xen/arm: p2m: add __p2m_free_entry() with a put argument Gabriel Quintáns Souto
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Gabriel Quintáns Souto @ 2026-11-30 16:43 UTC (permalink / raw)
  To: xen-devel
  Cc: Luca Fancellu, Gabriel Quintáns Souto, Stefano Stabellini,
	Julien Grall, Bertrand Marquis, Michal Orzel, Volodymyr Babchuk

Static shared memory can map a 1GB region into the borrower with a
single level 1 foreign entry, but level 1 puts were not implemented in
p2m_put_page(). When the borrower is destroyed, the extra reference it
holds on every page of the region is left behind, so the pages are never
freed and destroying the owner afterwards never completes.

Patch 2 is the main fix: relinquish_p2m_mapping() now splits the 1GB
mapping into 2MB blocks, so the puts go through the level 2 path and
can be preempted. Patch 3 adds level 1 puts for the case where the
split can't be done. Patch 1 fixes a separate issue in the split error
path, where references were put on the copied entries while the
superpage was still mapped, and the other two depend on it.

To reproduce it, I used a dom0less setup on QEMU virt (cortex-a72,
GICv3, -m 4G) with CONFIG_STATIC_SHM, where domU1 owns a 1GB region
allocated from the heap and domU2 borrows it, both at a 1GB aligned IPA:

    domU1 {
        ...
        shm-1g {
            compatible = "xen,domain-shared-memory-v1";
            role = "owner";
            xen,shm-id = "shm-1g";
            xen,shared-mem = <0x00 0x80000000 0x00 0x40000000>;
        };
    };

    domU2 {
        ...
        shm-1g {
            compatible = "xen,domain-shared-memory-v1";
            role = "borrower";
            xen,shm-id = "shm-1g";
            xen,shared-mem = <0x00 0x80000000 0x00 0x40000000>;
        };
    };

The 'q' debug key reports "1G mappings: 1" for both domains. Then, from
dom0, I destroyed domU2 followed by domU1:

  - Without the series, free_memory only went from 1982 to 2497 MB, and
    xl destroy of domU1 never returned. 'q' showed it stuck with
    dying=1 and nr_pages=262144.
  - With the series, both destroys completed and free_memory went from
    1982 to 3525 MB.

The -ENOMEM fallback was tested through a forced failure of
p2m_alloc_page() during relinquish.

An alternative would be to limit the foreign mappings of static shared
memory to 2MB, which avoids the issue without touching the level 1
path. I went with the split instead, since the TODO in p2m_put_page()
suggests level 1 superpages were meant to be supported.

Gabriel Quintáns Souto (3):
  xen/arm: p2m: add __p2m_free_entry() with a put argument
  xen/arm: p2m: split level 1 foreign superpages for preemption
  xen/arm: p2m: support level 1 puts if the superpage cannot be split

 xen/arch/arm/mmu/p2m.c | 68 +++++++++++++++++++++++++++++-------------
 1 file changed, 48 insertions(+), 20 deletions(-)

-- 
2.56.0



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-12-02 11:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 16:43 [PATCH 0/3] xen/arm: p2m: free 1GB static shared memory on domain destroy Gabriel Quintáns Souto
2026-11-30 16:43 ` [PATCH 1/3] xen/arm: p2m: add __p2m_free_entry() with a put argument Gabriel Quintáns Souto
2026-11-30 16:43 ` [PATCH 2/3] xen/arm: p2m: split level 1 foreign superpages for preemption Gabriel Quintáns Souto
2026-12-02 10:06   ` Grall, Julien
2026-12-02 11:08     ` Gabriel Quintáns Souto
2026-11-30 16:43 ` [PATCH 3/3] xen/arm: p2m: support level 1 puts if the superpage cannot be split Gabriel Quintáns Souto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.