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

[PATCH v1 2/3] xen: introduce shared_info_to_gfn()


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <alejandro.garciavallejo@xxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Fri, 27 Mar 2026 15:50:24 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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=FNsX0tz7KlxvUQL2XaR7OMvrzRJaltI17tS9Ud2WDAA=; b=XnZ/PWz+cBLW9r1WryD3oMmzYX2IEDIKBHx+bEO+Ys5VyhWOHPjVrm64ZDf7/3lA5iTJnnUQaOyi7+Is5lsyc6na6fCHVB97A5XClKHzjjwk22oGGJHnRfVi9snrePBBQLEktfBPRjmGaI3PdpiHikTclwr5ChRHdQy7qfpwPQ6lOsDNIMdTq7vjbv/vfLDU4lf9e4uOLijV8bTBcsUzjCDd13ZolDxjIDMnHr9iptjzxFzjDWf+rLKWUZav2vdYLvaqsUe0cNxkbB6ygiHxeRsO4ORJ9DsorlxaHVxiesKx/x7Nmfasu/lgPxsJR5sFsgenKDnZx+d+NJiO08UlJQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zC7SEEq8vWMuIDXfUO6udV4HiArIfhki+36Log5uAKhImzKgYV90Ok3uj3zI4IUcPCAY56/taL4+zFkCLjRD2NYaqa3QM4jYmkIDvIhs8htOYZgUCAMn/qqNBHjqsK9GKqn1eSb+n7bYAVTeKzpyaE/NfIeHA6+L9h/8FiYKxouV17UXLhtzhVQKTceY7b60rMBs8mn8Jyt+eL0XTgui7pFVjV/xjT2O/fT0c3LZUJaCrD4kTXrlPz2ADW6qVmNwFv1kNezLu7UCDtjRwEK5lZwif7K8WUwmQ7x7TI3L3V9etKPTcMSEaL185K81M9SlqmxYykLm6SlmbmmtjeL7Tg==
  • 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: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>
  • Delivery-date: Fri, 27 Mar 2026 07:56:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On ARM, mfn_to_gfn() is a simple identity macro that actually does not return
the correct GFN for domains other than direct-map ones, so getdomaininfo() is
returning the wrong shared_info_frame on ARM.

Introduce a common shared_info_to_gfn(d) macro to output correct GFN for both
ARM and x86 in getdomaininfo():
- ARM: uses page_get_xenheap_gfn() to read the stored GFN
- x86: simply wraps the existing mfn_to_gfn() solution which consults the M2P
       table

Suggested-by: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
---
 xen/arch/arm/include/asm/mm.h  | 2 ++
 xen/arch/x86/include/asm/p2m.h | 3 +++
 xen/common/domctl.c            | 3 +--
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h
index d1873ec212..8d61b74e4f 100644
--- a/xen/arch/arm/include/asm/mm.h
+++ b/xen/arch/arm/include/asm/mm.h
@@ -308,6 +308,8 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t 
va,
 /* Xen always owns P2M on ARM */
 #define set_gpfn_from_mfn(mfn, pfn) do { (void) (mfn), (void)(pfn); } while (0)
 #define mfn_to_gfn(d, mfn) ((void)(d), _gfn(mfn_x(mfn)))
+#define shared_info_to_gfn(d) \
+    page_get_xenheap_gfn(virt_to_page((d)->shared_info))
 
 /* Arch-specific portion of memory_op hypercall. */
 long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg);
diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index 3a5a5fd43c..725403b28f 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -582,6 +582,9 @@ static inline gfn_t mfn_to_gfn(const struct domain *d, 
mfn_t mfn)
         return _gfn(mfn_x(mfn));
 }
 
+#define shared_info_to_gfn(d) \
+    mfn_to_gfn((d), _mfn(virt_to_mfn((d)->shared_info)))
+
 #ifdef CONFIG_ALTP2M
 #define AP2MGET_prepopulate true
 #define AP2MGET_query false
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 93738931c5..284926aa61 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -104,8 +104,7 @@ void getdomaininfo(struct domain *d, struct 
xen_domctl_getdomaininfo *info)
 #ifdef CONFIG_MEM_PAGING
     info->paged_pages       = atomic_read(&d->paged_pages);
 #endif
-    info->shared_info_frame =
-        gfn_x(mfn_to_gfn(d, _mfn(virt_to_mfn(d->shared_info))));
+    info->shared_info_frame = gfn_x(shared_info_to_gfn(d));
     BUG_ON(SHARED_M2P(info->shared_info_frame));
 
     info->cpupool = cpupool_get_id(d);
-- 
2.43.0




 


Rackspace

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