From: Andrew Cooper Date: Mon, 27 Jul 2020 18:21:09 +0000 (+0100) Subject: public/domctl: Fix the struct xen_domctl ABI in 32bit builds X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~1821 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8899a280a493d6717afc7a709f7d1e842b4eb2d6;p=xen.git public/domctl: Fix the struct xen_domctl ABI in 32bit builds The Xen domctl ABI currently relies on the union containing a field with alignment of 8. 32bit projects which only copy the used subset of functionality end up with an ABI breakage if they don't have at least one uint64_aligned_t field copied. Insert explicit padding, and some build assertions to ensure it never changes moving forwards. Signed-off-by: Andrew Cooper Acked-by: Julien Grall --- diff --git a/xen/common/domctl.c b/xen/common/domctl.c index a69b3b59a8..20ef8399bd 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -959,6 +959,14 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) return ret; } +static void __init __maybe_unused build_assertions(void) +{ + struct xen_domctl d; + + BUILD_BUG_ON(sizeof(d) != 16 /* header */ + 128 /* union */); + BUILD_BUG_ON(offsetof(typeof(d), u) != 16); +} + /* * Local variables: * mode: C diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 59bdc28c89..9464a9058a 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -1222,6 +1222,7 @@ struct xen_domctl { #define XEN_DOMCTL_gdbsx_domstatus 1003 uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */ domid_t domain; + uint16_t _pad[3]; union { struct xen_domctl_createdomain createdomain; struct xen_domctl_getdomaininfo getdomaininfo;