Skip to contentSkip to conversation

mm: fix public declaration of struct xen_mem_acquire_resource

PATCH Superseded Roger Pau Monne 1 participant 2 messages Jun 25, 2020

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm: fix public declaration of struct xen_mem_acquire_resource

XENMEM_acquire_resource and it's related structure is currently inside a __XEN__ or __XEN_TOOLS__ guarded section to limit it's scope to the hypervisor or the toolstack only. This is wrong as the hypercall is already being used by the Linux kernel at least, and as such needs to be public.

Also switch the usage of uint64_aligned_t to plain uint64_t, as uint64_aligned_t is only to be used by the toolstack. Note that a padding field is added on 32bit x86, so that the size of the structure is the same.

No layout structure change. The structure doesn't need to be adjusted on 32bit Arm, because guest handlers are already expanded to 64bits.

Fixes 3f8f12281dd20 ('x86/mm: add HYPERVISOR_memory_op to acquire guest resources')

---
Should also be backported.
---
Changes since v1:
- Add padding on 32bits so structure size matches between arches and the previous layout is kept.

---
 xen/include/public/memory.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
xen/include/public/memory.h +7 -3
index dbd35305df..b6d3587cfa 100644
@@ -607,6 +607,8 @@ struct xen_reserved_device_memory_map {
 typedef struct xen_reserved_device_memory_map xen_reserved_device_memory_map_t;
 DEFINE_XEN_GUEST_HANDLE(xen_reserved_device_memory_map_t);
 
+#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
+
 /*
  * Get the pages for a particular guest resource, so that they can be
  * mapped directly by a tools domain.
@@ -645,7 +647,7 @@ struct xen_mem_acquire_resource {
      * IN - the index of the initial frame to be mapped. This parameter
      *      is ignored if nr_frames is 0.
      */
-    uint64_aligned_t frame;
+    uint64_t frame;
 
 #define XENMEM_resource_ioreq_server_frame_bufioreq 0
 #define XENMEM_resource_ioreq_server_frame_ioreq(n) (1 + (n))
@@ -662,12 +664,14 @@ struct xen_mem_acquire_resource {
      *          This parameter may be NULL if nr_frames is 0.
      */
     XEN_GUEST_HANDLE(xen_pfn_t) frame_list;
+
+#ifdef __i386__
+    uint32_t pad2;
+#endif
 };
 typedef struct xen_mem_acquire_resource xen_mem_acquire_resource_t;
 DEFINE_XEN_GUEST_HANDLE(xen_mem_acquire_resource_t);
 
-#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
-
 /*
  * XENMEM_get_vnumainfo used by guest to get
  * vNUMA topology from hypervisor.
Signature · 1 line
2.26.2
#1 lore raw
Quoted 14 lines · Roger Pau Monne

XENMEM_acquire_resource and it's related structure is currently inside a __XEN__ or __XEN_TOOLS__ guarded section to limit it's scope to the hypervisor or the toolstack only. This is wrong as the hypercall is already being used by the Linux kernel at least, and as such needs to be public.

Also switch the usage of uint64_aligned_t to plain uint64_t, as uint64_aligned_t is only to be used by the toolstack. Note that a padding field is added on 32bit x86, so that the size of the structure is the same.

No layout structure change. The structure doesn't need to be adjusted on 32bit Arm, because guest handlers are already expanded to 64bits.

Quoted 8 lines
Fixes 3f8f12281dd20 ('x86/mm: add HYPERVISOR_memory_op to acquire guest resources')

---
Should also be backported.
---
Changes since v1:
- Add padding on 32bits so structure size matches between arches and the previous layout is kept.

This is bogus, will send a proper version.

Sorry for the noise, Roger.