From patchwork Tue Jul 28 10:15:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11688867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 942351392 for ; Tue, 28 Jul 2020 10:16:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7062F20829 for ; Tue, 28 Jul 2020 10:16:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="D7ulHQGT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7062F20829 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k0MeT-0007Vm-G1; Tue, 28 Jul 2020 10:16:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k0MeS-0007Vg-L0 for xen-devel@lists.xenproject.org; Tue, 28 Jul 2020 10:16:04 +0000 X-Inumbo-ID: 571de7da-d0bb-11ea-8b26-bc764e2007e4 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 571de7da-d0bb-11ea-8b26-bc764e2007e4; Tue, 28 Jul 2020 10:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1595931363; h=from:to:cc:subject:date:message-id:mime-version; bh=eResLKENKrnBvZCEPNYPX+GbqgM/48vwzyRSj+mBaw8=; b=D7ulHQGTbCsO0jZGFZcVzJtrsQ0xtyQQo58EGu8tBqteqKK/O9o5Wgi2 eP2loA9WxmHkxgBzJmmbOxqIXcvC+tNGXrKTRJ1vEjmYw16NS9yphTf9q Xagk3ZV4xNBuaQe7RxV0e+fCa1QJ6AOw0yIrgY4K5B9oY+/7f602j/TpA o=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 4jNe9HkyjwpDKXp9aDdQaicuN+zhaneZt6IDT4vGSS6Cmm5gSPaOg2DU4IieG74IfRsJsoMo7+ dfDFv7uAHOBpd9gLh1Ql5WF96i95uKqYtscNhkuvppfR3jxX39ZH9YfYf6IXuF1tTVsoO37l2k 0GxlWl8LYZ8i7GgPsoWH2ovGhe8SnUFXtgfwebiYeo2JvgQMJuQevIRYd9PEZrk528A79EHNq2 kh4g68we4OUzBz6aujwRX4aIlDlEJGTekepNg3mdFY6iDlNzyGe5YAdR6ltYZaNA9MKbkPEQYm gWw= X-SBRS: 2.7 X-MesageID: 23344596 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,406,1589256000"; d="scan'208";a="23344596" From: Andrew Cooper To: Xen-devel Subject: [PATCH] public/domctl: Fix the struct xen_domctl ABI in 32bit builds Date: Tue, 28 Jul 2020 11:15:29 +0100 Message-ID: <20200728101529.13753-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Jan Beulich , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 --- CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall Further proof that C isn't an appropriate way to desribe an ABI... --- xen/common/domctl.c | 8 ++++++++ xen/include/public/domctl.h | 1 + 2 files changed, 9 insertions(+) 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;