All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@amd.com>
To: <xen-devel@lists.xenproject.org>
Cc: <sstabellini@kernel.org>, <andrew.cooper3@citrix.com>,
	<bertrand.marquis@arm.com>, <george.dunlap@citrix.com>,
	<jbeulich@suse.com>, <julien@xen.org>, <michal.orzel@amd.com>,
	<roger.pau@citrix.com>,
	"Stefano Stabellini" <stefano.stabellini@amd.com>
Subject: [PATCH v2 3/4] xen/public: s/unsigned long/xen_ulong_t
Date: Wed, 10 Apr 2024 16:47:39 -0700	[thread overview]
Message-ID: <20240410234740.994001-3-stefano.stabellini@amd.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2404101644130.976094@ubuntu-linux-20-04-desktop>

The goal is to use only fixed-size integers in public headers, such as
uint32_t and uint64_t.

However, there are cases where the ABI changes depending on the
architecture. In those cases, adding #ifdefs might be the clearest
solution but it is also cumbersome. We already define a xen_ulong_t type
which is widely used in public headers and it is defined differently by
architecture.

Instead of unsigned long, use xen_ulong_t in public headers:
- it makes it clearer that size might change by arch
- it gets us closer to the goal of no unfixed-size integers in public
headers

Note that unsigned long and xen_ulong_t are the same thing on x86 (both
32-bit and 64-bit) but they differ on all other arches. However, all
the interfaces with xen_ulong_t or unsigned long are x86-only interfaces
today. Thus, this patch doesn't introduce any ABI or semantic changes.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
 xen/include/public/kexec.h   | 10 +++++-----
 xen/include/public/nmi.h     |  4 ++--
 xen/include/public/physdev.h |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/include/public/kexec.h b/xen/include/public/kexec.h
index 8d2a0ef697..89164094d9 100644
--- a/xen/include/public/kexec.h
+++ b/xen/include/public/kexec.h
@@ -78,10 +78,10 @@
 
 typedef struct xen_kexec_image {
 #if defined(__i386__) || defined(__x86_64__)
-    unsigned long page_list[KEXEC_XEN_NO_PAGES];
+    xen_ulong_t page_list[KEXEC_XEN_NO_PAGES];
 #endif
-    unsigned long indirection_page;
-    unsigned long start_address;
+    xen_ulong_t indirection_page;
+    xen_ulong_t start_address;
 } xen_kexec_image_t;
 
 /*
@@ -145,8 +145,8 @@ typedef struct xen_kexec_load_v1 {
 typedef struct xen_kexec_range {
     int32_t range;
     int32_t nr;
-    unsigned long size;
-    unsigned long start;
+    xen_ulong_t size;
+    xen_ulong_t start;
 } xen_kexec_range_t;
 
 #if __XEN_INTERFACE_VERSION__ >= 0x00040400
diff --git a/xen/include/public/nmi.h b/xen/include/public/nmi.h
index 5900703f5f..c8c0ddafc2 100644
--- a/xen/include/public/nmi.h
+++ b/xen/include/public/nmi.h
@@ -43,8 +43,8 @@
  */
 #define XENNMI_register_callback   0
 struct xennmi_callback {
-    unsigned long handler_address;
-    unsigned long pad;
+    xen_ulong_t handler_address;
+    xen_ulong_t pad;
 };
 typedef struct xennmi_callback xennmi_callback_t;
 DEFINE_XEN_GUEST_HANDLE(xennmi_callback_t);
diff --git a/xen/include/public/physdev.h b/xen/include/public/physdev.h
index 03ccf86618..5bbb809fae 100644
--- a/xen/include/public/physdev.h
+++ b/xen/include/public/physdev.h
@@ -109,7 +109,7 @@ DEFINE_XEN_GUEST_HANDLE(physdev_set_iobitmap_t);
 #define PHYSDEVOP_apic_write             9
 struct physdev_apic {
     /* IN */
-    unsigned long apic_physbase;
+    xen_ulong_t apic_physbase;
     uint32_t reg;
     /* IN or OUT */
     uint32_t value;
-- 
2.25.1



  parent reply	other threads:[~2024-04-10 23:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10 23:46 [PATCH v2 0/4] xen/public: use fixed-size integers Stefano Stabellini
2024-04-10 23:47 ` [PATCH v2 1/4] docs: add xen_ulong_t to the documented integers sizes/alignments Stefano Stabellini
2024-04-10 23:50   ` Julien Grall
2024-04-11 22:08     ` Stefano Stabellini
2024-04-12 13:53       ` Julien Grall
2024-04-12 15:30         ` Bertrand Marquis
2024-04-12 17:01           ` Julien Grall
2024-04-15  7:48             ` Bertrand Marquis
2024-04-15 10:08               ` Julien Grall
2024-04-15 11:28                 ` Bertrand Marquis
2024-04-10 23:47 ` [PATCH v2 2/4] public: s/int/int32_t Stefano Stabellini
2024-04-18  6:40   ` Jan Beulich
2024-04-10 23:47 ` Stefano Stabellini [this message]
2024-04-18  6:49   ` [PATCH v2 3/4] xen/public: s/unsigned long/xen_ulong_t Jan Beulich
2024-04-10 23:47 ` [PATCH v2 4/4] xen/public: replace remaining int and long Stefano Stabellini
2024-04-18  7:04   ` 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=20240410234740.994001-3-stefano.stabellini@amd.com \
    --to=stefano.stabellini@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.com \
    --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.