All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <George.Dunlap@citrix.com>,
	Jan Beulich <JBeulich@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>
Subject: [PATCH 4/4] xen/public: Use -Wpadding for public headers
Date: Mon, 15 Apr 2024 16:41:55 +0100	[thread overview]
Message-ID: <20240415154155.2718064-5-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20240415154155.2718064-1-andrew.cooper3@citrix.com>

RFC.  In theory this is a great way to avoid some of the spiketraps involved
with C being the official representation.

However, this doesn't build.  gnttab_transfer has a layout that requires a
CONFIG_COMPAT if we want to satisfy -Wpadding for both forms of the structure.

Thoughts on whether this cross-check is worthwhile-enough to warrant the
ifdefary?

~Andrew
---
CC: George Dunlap <George.Dunlap@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien@xen.org>
---
 xen/common/Makefile              |  1 +
 xen/common/hdr-chk.c             | 13 +++++++++++++
 xen/include/public/grant_table.h |  7 +++++++
 3 files changed, 21 insertions(+)
 create mode 100644 xen/common/hdr-chk.c

diff --git a/xen/common/Makefile b/xen/common/Makefile
index d512cad5243f..dbbda70829f1 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -15,6 +15,7 @@ obj-y += event_fifo.o
 obj-$(CONFIG_GRANT_TABLE) += grant_table.o
 obj-y += guestcopy.o
 obj-y += gzip/
+obj-y += hdr-chk.o
 obj-$(CONFIG_HYPFS) += hypfs.o
 obj-$(CONFIG_IOREQ_SERVER) += ioreq.o
 obj-y += irq.o
diff --git a/xen/common/hdr-chk.c b/xen/common/hdr-chk.c
new file mode 100644
index 000000000000..1c7a509dcd06
--- /dev/null
+++ b/xen/common/hdr-chk.c
@@ -0,0 +1,13 @@
+#include <xen/stdint.h>
+
+#include <public/xen.h>
+
+#pragma GCC diagnostic error "-Wpadded"
+
+#include <public/grant_table.h>
+
+#ifdef CONFIG_COMPAT
+
+#include <compat/grant_table.h>
+
+#endif /* CONFIG_COMPAT */
diff --git a/xen/include/public/grant_table.h b/xen/include/public/grant_table.h
index 1dfa17a6d02a..a66c77d0166c 100644
--- a/xen/include/public/grant_table.h
+++ b/xen/include/public/grant_table.h
@@ -355,6 +355,7 @@ struct gnttab_unmap_grant_ref {
     grant_handle_t handle;
     /* OUT parameters. */
     int16_t  status;              /* => enum grant_status */
+    uint16_t _pad0;
 };
 typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t;
 DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
@@ -371,6 +372,7 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t);
 struct gnttab_setup_table {
     /* IN parameters. */
     domid_t  dom;
+    uint16_t _pad0;
     uint32_t nr_frames;
     /* OUT parameters. */
     int16_t  status;              /* => enum grant_status */
@@ -409,9 +411,12 @@ struct gnttab_transfer {
     /* IN parameters. */
     xen_pfn_t     mfn;
     domid_t       domid;
+    uint16_t      _pad0;
     grant_ref_t   ref;
     /* OUT parameters. */
     int16_t       status;
+    uint16_t      _pad1;
+    /* XXX compat-dependent padding. */
 };
 typedef struct gnttab_transfer gnttab_transfer_t;
 DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t);
@@ -468,10 +473,12 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t);
 struct gnttab_query_size {
     /* IN parameters. */
     domid_t  dom;
+    uint16_t _ign1;
     /* OUT parameters. */
     uint32_t nr_frames;
     uint32_t max_nr_frames;
     int16_t  status;              /* => enum grant_status */
+    uint16_t _ign2;
 };
 typedef struct gnttab_query_size gnttab_query_size_t;
 DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t);
-- 
2.30.2



  parent reply	other threads:[~2024-04-15 15:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 15:41 [PATCH 0/4] xen/xlat: Improvements to compat hypercall checking Andrew Cooper
2024-04-15 15:41 ` [PATCH 1/4] xen/xlat: Sort out whitespace Andrew Cooper
2024-04-15 21:49   ` Stefano Stabellini
2024-04-18 10:11     ` Andrew Cooper
2024-04-15 15:41 ` [PATCH 2/4] xen/xlat: Sort structs per file Andrew Cooper
2024-04-15 21:52   ` Stefano Stabellini
2024-04-18  9:00   ` Jan Beulich
2024-04-15 15:41 ` [PATCH 3/4] xen/gnttab: Perform compat/native gnttab_query_size check Andrew Cooper
2024-04-15 21:54   ` Stefano Stabellini
2024-04-18  9:03     ` Jan Beulich
2024-04-18  9:13   ` Jan Beulich
2024-04-15 15:41 ` Andrew Cooper [this message]
2024-04-15 22:15   ` [PATCH 4/4] xen/public: Use -Wpadding for public headers Stefano Stabellini
2024-04-18  9:21     ` Jan Beulich
2024-04-18  9:36   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240415154155.2718064-5-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.