|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 2/3] xen: introduce shared_info_to_gfn()
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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |