From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FB63606A697 for ; Mon, 30 Nov 2026 16:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=N+kPwzh9 Received: from list by lists.xenproject.org with outflank-mailman.1508031.1701048 (Exim 4.92) (envelope-from ) id 1xY4Uw-0008Jm-CT; Mon, 30 Nov 2026 16:45:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1508031.1701048; Mon, 30 Nov 2026 16:45:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xY4Uw-0008JQ-7U; Mon, 30 Nov 2026 16:45:02 +0000 Received: by outflank-mailman (input) for mailman id 1508031; Mon, 30 Nov 2026 16:45:00 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xY4Uu-0008JK-85 for xen-devel@lists.xenproject.org; Mon, 30 Nov 2026 16:45:00 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xY4Ut-001flg-JA for xen-devel@lists.xenproject.org; Mon, 30 Nov 2026 17:44:59 +0100 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6b0da7f9-2eae-0a2a0a5409dd-0a2a45019e56-20 for ; Mon, 30 Nov 2026 17:44:59 +0100 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6b0da80b-5bcc-0a2a45010019-d155802ab1e0-3 for ; Mon, 30 Nov 2026 17:44:59 +0100 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4a2153c8525so87522675e9.3 for ; Mon, 30 Nov 2026 08:44:59 -0800 (PST) Received: from ws-fedora.tail006fee.ts.net (cm-93-156-219-234.telecable.es. [93.156.219.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6a67fe75sm75312283f8f.24.2026.11.30.08.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 08:44:58 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Post: List-Help: List-Subscribe: , Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796057099; x=1796661899; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=dywRxM/ozfNwueSh6WSTObuHaOo9h8tQ/RZ3GAusqYA=; b=N+kPwzh9AS27w72c2NUJlPlMIM3XPFklTgplNCgT/GsSiyPGckLgVBqDG4qAtZ1omt a1KXK1ZWFN8gb12U9atyOLsu345kII5FhkhwGxLn1UJzIbiwjWAYD6Zr3WypG7cuWoUF yk+iZE+0javTJt3blFwHuevIf2JlaOUxwXPXes/ZN5EuaC8IlxUqicgDVqOHZKI1InrQ QtZeb7g62FreszCWDztKEIDzyBGu+lgDK43B0XGeY0oCCvbdQM644lT3jv1bEhEAmtAB l9qzEFCg40xi2zWiAp66IwB1M9xIgWA2WBrWInSg1SHpETXDfPVmZtaq+wUBG1URCVng XyUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796057099; x=1796661899; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=dywRxM/ozfNwueSh6WSTObuHaOo9h8tQ/RZ3GAusqYA=; b=ZIKS5w64ZySQALOfNLXuS31TUxbb22r3Z30amFAsDD4SijH0PRolTfNjJuJxTVrEBh HRMe3AjWmhyMaIlryvQ1SJ0q55DQ1UN0VruKYoBRGuCF0U3PwMEwZZBHM8xppV9RsMMJ aUS3wRTIu+WkuISDVlmiyxBEPXyNmzUiM5D7QbKJCbzfNg/bJ3iGfP1pcGpwTUhzApiJ H4k+me9nDgcj9t7YOYQr+9veeyWV/VuHD+GVJvqQGZLOs+YvmUdJZfQRtqjv2F3TnQZp 4AtHNP3jkL/YzU06FDDlUKLENDB1VagwdKY/idZdQpziCsVP4718eqIbpoqEoAelW+wc u8Ww== X-Gm-Message-State: APuU4Z+1HwLNmHlO6tiXWTIjygQjEZuy58RUPGkEPZXvyTaT9Xp8xr1O EyH9M++QNeKmRP9opvM5slihQXThRtwFGZiM6qtj/t4StKeJuVJyPuw5Ni5j3T8J X-Gm-Gg: AZFdTZe/Z1BQt5MQy7LGzhmJsIF25emYIfn2fkUapkMjMnZHo7ckdz1j46lXm7imUM7 wyd7jRiBcWSQfdzAZB8654vU8TRTjOBtyj9ricZcrz/0f3YMbHw/G5+pKWLvgyILm9x3G5A1pxH jnyotk5JJagg40t4asnXvZvDQJ9bJ+i8B6BFbzOAAg7nTeFtOpF7taLhJSnez1oxMjd7LysFEpe 7SvXP78rZXSvDSh59YX6sEj/4N1cc1cvmaXd5+HDG7tD+FGQcV9lLGe+O6kiXUMgJu7fJlBYo47 lNMBnmKRTeTKMQHGuwOuOUKn0TlMJ+UexHc9jW95AuUtuM1wyLsl1Xk8XNXYXZnbuDMoSl1g6Lt mWpkVRP/XRZHfhNhU2Nu0jRGfYrWZNdyMMIHi5H/FZ9jkaoFAE3IcjSzOpdV6vArzLfQbgvgJyw nZhNYgpu3IDc5NcAALtJOxAYltQjY+7vsGuZrU64e1LmJLwmpkxwrrIYm3Exe5GND4sm1OyP1cW KRmu/AjlDIq8KO6KskY5NWLlUAUjOM70189IKR1qW07E+ii1wNgey6lBI+xBeRzbgFvyZqbz6m1 MCFsgGC8ENd5KJGXv+63u5C2yOYSvqcJAlGq9e6DVyUHsZaI3cBCW43wY31hKIeAUUucKiQcjDN 1j+DbB859yw== X-Received: by 2002:a05:600d:6512:20b0:4bb:be79:27 with SMTP id 5b1f17b1804b1-4bbbe79013bmr106588575e9.29.1796057098840; Mon, 30 Nov 2026 08:44:58 -0800 (PST) From: =?UTF-8?q?Gabriel=20Quint=C3=A1ns=20Souto?= To: xen-devel@lists.xenproject.org Cc: Luca Fancellu , =?UTF-8?q?Gabriel=20Quint=C3=A1ns=20Souto?= , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH 0/3] xen/arm: p2m: free 1GB static shared memory on domain destroy Date: Mon, 30 Nov 2026 17:43:21 +0100 Message-ID: <20261130164324.47726-1-gabi.qs.mail@gmail.com> X-Mailer: git-send-email 2.56.0 X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-d62444/1796057099-4ED415FD-3997FBED/0/0 X-purgate-type: clean X-purgate-size: 2606 X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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