[PATCH for-4.14 v2] mm: fix public declaration of struct xen_mem_acquire_resource

Roger Pau Monne posted 1 patch 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/xen tags/patchew/20200625141643.82822-1-roger.pau@citrix.com
xen/include/public/memory.h | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

[PATCH for-4.14 v2] mm: fix public declaration of struct xen_mem_acquire_resource

Posted by Roger Pau Monne 2 weeks ago
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')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
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(-)

diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
index dbd35305df..b6d3587cfa 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -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.
-- 
2.26.2


Re: [PATCH for-4.14 v2] mm: fix public declaration of struct xen_mem_acquire_resource

Posted by Roger Pau Monné 2 weeks ago
On Thu, Jun 25, 2020 at 04:16:43PM +0200, Roger Pau Monne wrote:
> 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')
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> 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.