From patchwork Wed Feb 3 16:10:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 8204781 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6FA239F1C0 for ; Wed, 3 Feb 2016 16:13:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63A8720268 for ; Wed, 3 Feb 2016 16:13:52 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13CB82025B for ; Wed, 3 Feb 2016 16:13:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aR01Z-0007CS-PU; Wed, 03 Feb 2016 16:11:21 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aR01X-0007CB-AJ for xen-devel@lists.xen.org; Wed, 03 Feb 2016 16:11:19 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id 55/6C-28791-6A622B65; Wed, 03 Feb 2016 16:11:18 +0000 X-Env-Sender: prvs=8347a21d9=Ian.Campbell@citrix.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1454515875!21256050!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36624 invoked from network); 3 Feb 2016 16:11:17 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-7.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 3 Feb 2016 16:11:17 -0000 X-IronPort-AV: E=Sophos;i="5.22,391,1449532800"; d="scan'208";a="329443716" From: Ian Campbell To: , , Date: Wed, 3 Feb 2016 16:10:49 +0000 Message-ID: <1454515849-13886-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454515849-13886-1-git-send-email-ian.campbell@citrix.com> References: <1454515849-13886-1-git-send-email-ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell Subject: [Xen-devel] [PATCH v2 2/2] tools: Do not expose all builds to unstable hypercall APIs by default X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently __XEN_TOOLS__ is defined in the global CFLAGS used for tools builds, exposing them all to the various unstable hypercall interfaces. However there are places where we do not want this (in particular all the stable libraries now under tools/libs), and there is a risk of such uses slipping in unnoticed (currently there are none, but I tripped over the mixed nature of the HVMOPs just now in some new code I was putting together). Instead only define __XEN_TOOLS__ for things which explicitly want the unstable APIs. The vast majority of these are consumers of libxenctrl, which have opted into unstable interfaces by using libxenctrl already, so adding -D__XEN_TOOLS__ to CFLAGS_libxenctrl covers these without needing to patch the dozen or so tools manually. The libxc build itself, which doesn't use CFLAGS_libxenctrl, now needs the define too. As does gdbsx's own low level hypercall binding library xg. hvmloader no longer needs to undefine the symbol. The ocaml evtchn bindings don't actually need sysctl.h and therefore don't actually need __XEN_TOOLS__ either. qemu-xen-traditional doesn't use CFLAGS_libxenctrl and so we pass the define there (via --extra-cflags) too. Having removed __XEN_TOOLS__ replace it with __XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ so that in tree code is always using the latest APIs. Signed-off-by: Ian Campbell Acked-by: Ian Jackson Acked-by: Andrew Cooper for the x86 bits. --- v2: Define __XEN_INTERFACE_VERSION__ to be the latest for everyone. --- tools/Makefile | 2 +- tools/Rules.mk | 6 ++++-- tools/debugger/gdbsx/xg/Makefile | 1 + tools/firmware/hvmloader/Makefile | 2 +- tools/libxc/Makefile | 1 + tools/ocaml/libs/eventchn/xeneventchn_stubs.c | 1 - 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 3d3fd60..cb8652c 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -194,7 +194,7 @@ qemu-traditional-recurse = \ subdir-all-qemu-xen-traditional-dir: qemu-xen-traditional-dir-find $(call qemu-traditional-recurse,\ $(QEMU_ROOT)/xen-setup \ - --extra-cflags="$(EXTRA_CFLAGS_QEMU_TRADITIONAL)" \ + --extra-cflags="-D__XEN_TOOLS__ $(EXTRA_CFLAGS_QEMU_TRADITIONAL)" \ $(IOEMU_EXTRA_LDFLAGS) \ --cpu=$(IOEMU_CPU_ARCH) \ $(IOEMU_CONFIGURE_CROSS); \ diff --git a/tools/Rules.mk b/tools/Rules.mk index d47fa45..9ef0b47 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -108,7 +108,9 @@ CFLAGS_libxenforeignmemory = -I$(XEN_LIBXENFOREIGNMEMORY)/include $(CFLAGS_xenin LDLIBS_libxenforeignmemory = $(XEN_LIBXENFOREIGNMEMORY)/libxenforeignmemory$(libextension) SHLIB_libxenforeignmemory = -Wl,-rpath-link=$(XEN_LIBXENFOREIGNMEMORY) -CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude) +# code which compiles against libxenctrl get __XEN_TOOLS__ and +# therefore sees the unstable hypercall interfaces. +CFLAGS_libxenctrl = -I$(XEN_LIBXC)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxengntshr) $(SHLIB_libxencall) $(SHLIB_libxenforeignmemory) LDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_LIBXC)/libxenctrl$(libextension) SHLIB_libxenctrl = $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_LIBXC) @@ -159,7 +161,7 @@ SHDEPS_libxenlight = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libblktapc LDLIBS_libxenlight = $(SHDEPS_libxenlight) $(XEN_XENLIGHT)/libxenlight$(libextension) SHLIB_libxenlight = $(SHDEPS_libxenlight) -Wl,-rpath-link=$(XEN_XENLIGHT) -CFLAGS += -D__XEN_TOOLS__ +CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ # Get gcc to generate the dependencies for us. CFLAGS += -MMD -MF .$(if $(filter-out .,$(@D)),$(subst /,@,$(@D))@)$(@F).d diff --git a/tools/debugger/gdbsx/xg/Makefile b/tools/debugger/gdbsx/xg/Makefile index 78b4021..6a8937b 100644 --- a/tools/debugger/gdbsx/xg/Makefile +++ b/tools/debugger/gdbsx/xg/Makefile @@ -4,6 +4,7 @@ include ../Rules.mk XG_HDRS := xg_public.h XG_OBJS := xg_main.o +CFLAGS += -D__XEN_TOOLS__ CFLAGS += $(CFLAGS_xeninclude) diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile index 0560a7b..f2f4791 100644 --- a/tools/firmware/hvmloader/Makefile +++ b/tools/firmware/hvmloader/Makefile @@ -31,7 +31,7 @@ SMBIOS_REL_DATE ?= $(shell date +%m/%d/%Y) CFLAGS += $(CFLAGS_xeninclude) # We mustn't use tools-only public interfaces. -CFLAGS += -U__XEN_TOOLS__ -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ +CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ OBJS = hvmloader.o mp_tables.o util.o smbios.o OBJS += smp.o cacheattr.o xenbus.o vnuma.o diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index ca8bab7..0a8614c 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -105,6 +105,7 @@ endif CFLAGS += -Werror -Wmissing-prototypes CFLAGS += -I. -I./include $(CFLAGS_xeninclude) +CFLAGS += -D__XEN_TOOLS__ # Needed for posix_fadvise64() in xc_linux.c CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE diff --git a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c index c2d4737..9580396 100644 --- a/tools/ocaml/libs/eventchn/xeneventchn_stubs.c +++ b/tools/ocaml/libs/eventchn/xeneventchn_stubs.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include