From patchwork Tue Aug 4 09:26:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11700099 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 BB1EE13B6 for ; Tue, 4 Aug 2020 09:28:22 +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 CA5432086A for ; Tue, 4 Aug 2020 09:28:22 +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="SPB5k+Bh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA5432086A 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 1k2tDP-0001sz-9l; Tue, 04 Aug 2020 09:26:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k2tDO-0001sq-72 for xen-devel@lists.xenproject.org; Tue, 04 Aug 2020 09:26:34 +0000 X-Inumbo-ID: 95bd8dc8-d634-11ea-913d-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 95bd8dc8-d634-11ea-913d-bc764e2007e4; Tue, 04 Aug 2020 09:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1596533193; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q3ReqT69K9XKGGN+e8ZybiqO+/keDcz0thRqBcGSR3M=; b=SPB5k+Bhaw6JKzIojmQekE7L76rVDNoAbAPHQ61jksNJlb3zAkfbEBtP WGtemK6cDprR+IK5/vZqYwGURx59fFougDPKqHewAGZY8a8W80GQTEUFC FgyJ7HFDiJxwH4xhlaQK7u+KT6U3GpUZXvnTHrsSh50LJ4DW83ZYru2iT I=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: Eq+gN6YFmS3ohlQqKPhOe2NcoL+vSDTiKtV8jXYqR+o7M3gFioVAeSG2I1hriVOiye0+/6X/8h OqfLandO1LO14rrROu8L9enqiFcL2gLkDkVY+0SVwQ6ouPLhjJ41HSoB/Qi0BogF5/OcytdetB mIxVAeP0V93Qzse3rdr+TlFOhU7KTCfEYYrsOz+4vM5iLXQmyRRmWkuGRVB86HgBJEBdrB0JOH +TH3asiD+AJ9QUYIWOd4nz/Tv3VItzy03bKZLluN7MhPuT0A74mPOv+nNCXvrOKAsNJs2wTgDE 6C4= X-SBRS: 3.7 X-MesageID: 24124488 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.75,433,1589256000"; d="scan'208";a="24124488" From: Anthony PERARD To: Subject: [PULL 1/1] accel/xen: Fix xen_enabled() behavior on target-agnostic objects Date: Tue, 4 Aug 2020 10:26:24 +0100 Message-ID: <20200804092624.1126013-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200804092624.1126013-1-anthony.perard@citrix.com> References: <20200804092624.1126013-1-anthony.perard@citrix.com> 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: Anthony PERARD , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , xen-devel@lists.xenproject.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Philippe Mathieu-Daudé CONFIG_XEN is generated by configure and stored in "config-target.h", which is (obviously) only include for target-specific objects. This is a problem for target-agnostic objects as CONFIG_XEN is never defined and xen_enabled() is always inlined as 'false'. Fix by following the KVM schema, defining CONFIG_XEN_IS_POSSIBLE when we don't know to force the call of the non-inlined function, returning the xen_allowed boolean. Fixes: da278d58a092 ("accel: Move Xen accelerator code under accel/xen/") Reported-by: Paul Durrant Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paul Durrant Reviewed-by: Anthony PERARD Message-Id: <20200804074930.13104-2-philmd@redhat.com> Signed-off-by: Anthony PERARD --- accel/stubs/xen-stub.c | 2 ++ accel/xen/xen-all.c | 7 +------ include/sysemu/xen.h | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/accel/stubs/xen-stub.c b/accel/stubs/xen-stub.c index dcca4e678a13..8ae658acff5f 100644 --- a/accel/stubs/xen-stub.c +++ b/accel/stubs/xen-stub.c @@ -9,6 +9,8 @@ #include "hw/xen/xen.h" #include "qapi/qapi-commands-misc.h" +bool xen_allowed; + void xenstore_store_pv_console_info(int i, Chardev *chr) { } diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c index 0c24d4b191a4..60b971d0a82f 100644 --- a/accel/xen/xen-all.c +++ b/accel/xen/xen-all.c @@ -32,12 +32,7 @@ do { } while (0) #endif -static bool xen_allowed; - -bool xen_enabled(void) -{ - return xen_allowed; -} +bool xen_allowed; xc_interface *xen_xc; xenforeignmemory_handle *xen_fmem; diff --git a/include/sysemu/xen.h b/include/sysemu/xen.h index 1ca292715e69..2c2c429ea8bf 100644 --- a/include/sysemu/xen.h +++ b/include/sysemu/xen.h @@ -8,9 +8,19 @@ #ifndef SYSEMU_XEN_H #define SYSEMU_XEN_H -#ifdef CONFIG_XEN +#ifdef NEED_CPU_H +# ifdef CONFIG_XEN +# define CONFIG_XEN_IS_POSSIBLE +# endif +#else +# define CONFIG_XEN_IS_POSSIBLE +#endif + +#ifdef CONFIG_XEN_IS_POSSIBLE + +extern bool xen_allowed; -bool xen_enabled(void); +#define xen_enabled() (xen_allowed) #ifndef CONFIG_USER_ONLY void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length); @@ -18,7 +28,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, struct MemoryRegion *mr, Error **errp); #endif -#else /* !CONFIG_XEN */ +#else /* !CONFIG_XEN_IS_POSSIBLE */ #define xen_enabled() 0 #ifndef CONFIG_USER_ONLY @@ -33,6 +43,6 @@ static inline void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, } #endif -#endif /* CONFIG_XEN */ +#endif /* CONFIG_XEN_IS_POSSIBLE */ #endif