From patchwork Fri Nov 25 19:06:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 84197 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp334742obn; Fri, 25 Nov 2016 11:08:23 -0800 (PST) X-Received: by 10.107.36.74 with SMTP id k71mr8178673iok.157.1480100903826; Fri, 25 Nov 2016 11:08:23 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v123si33739805ioe.252.2016.11.25.11.08.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 11:08:23 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cALpQ-0003G3-6j; Fri, 25 Nov 2016 19:06:32 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cALpP-0003Fv-4j for xen-devel@lists.xen.org; Fri, 25 Nov 2016 19:06:31 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 5E/B9-28490-6BB88385; Fri, 25 Nov 2016 19:06:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRWlGSWpSXmKPExsVysyfVTXdrt0W Ewe/jxhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a3qU9ZCx4pVmx7q9nAOEmmi5GLQ0hgE6PE 89UdjBDOaUaJrU//MXcxcnKwCWhK3Pn8iQnEFhGQlrj2+TJYEbPABkaJUy3TgBIcHMICoRLvG uRAalgEVCUmXb4JVs8r4Cyx/GsnO4gtISAncfLYZNYJjJwLGBlWMWoUpxaVpRbpGhnqJRVlpm eU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIE+osBCHYw/lkWcIhRkoNJSZS3sc0iQogvKT+ lMiOxOCO+qDQntfgQowwHh5IEb0gXUE6wKDU9tSItMwcYODBpCQ4eJRFe1U6gNG9xQWJucWY6 ROoUoy7Hm10vHzAJseTl56VKifOqgMwQACnKKM2DGwEL4kuMslLCvIxARwnxFKQW5WaWoMq/Y hTnYFQS5p0KMoUnM68EbtMroCOYgI5w/mEOckRJIkJKqoHRhuXCzYVnLQX5mncI9RgL+PwO6u PrOPMudOXdhTuTLARtj6g0nFreGxLulntqbeBstfeH9vvZv1FfFLHMvPGMSG3FO72IfptF22Z ujZOOZfhf7RewziQsu6NJyDnZQmxZzt4fq9dGLJmRNPX/63+qTxTvqp9SmnM+4FXCB8eGf8vF OHTeredRYinOSDTUYi4qTgQAcRZ9Zl0CAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1480100789!39084446!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37267 invoked from network); 25 Nov 2016 19:06:29 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-21.messagelabs.com with SMTP; 25 Nov 2016 19:06:29 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7E76AC14; Fri, 25 Nov 2016 11:06:28 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 56CAB3F318; Fri, 25 Nov 2016 11:06:27 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 25 Nov 2016 19:06:21 +0000 Message-Id: <1480100781-2915-1-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, Andrii Anisov , Julien Grall , jbeulich@suse.com Subject: [Xen-devel] [PATCH for-4.8] tools/libacpi: Fix compilation when cross building the tools X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The tools (such as mk_dsdt) can be cross-built when it may not be desirable to build them on the target. The commit c4ac1077 "libxl/arm: Generate static ACPI DSDT table" introduced support of ARM64 in mk_dsdt but also break cross-building tools because the ACPI tables are not correct. While mk_dsdt should generate ACPI table for the target architecture, it currently generates the one for the host. This is because the source code contains reference to the host architecture (__aarch64__, __x86_64__, __i386__) when it should be the target architecture. Replace all __aarch64__, __x86_64__, __i386__ by the corresponding CONFIG_*. Also expose the CONFIG_* to the source code as the currently only exposed to the Makefile. Reported-by: Andrii Anisov Suggested-by: Wei Liu Signed-off-by: Julien Grall Reviewed-by: Andrew Cooper , with one tweak, --- This was reported on the ML recently (see [1]) and affects only Xen 4.8. Without this patch, cross-building the tools will not work. I think this patch is quite important for embedded users where they tend to cross-build the rootfs (for instance using yocto). The patch is fairly simple, exposing CONFIG_* to the source code and replacing all reference to the host architecture to the corresponding target architecture. It could be easy to test all the configuration. I diffed the generated dsdt and it is the same before and after the patches when built natively. I did try cross-build, Andrii could you give a try? [1] https://lists.xenproject.org/archives/html/xen-devel/2016-11/msg01903.html --- tools/libacpi/Makefile | 7 ++++++- tools/libacpi/mk_dsdt.c | 14 +++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile index ccc32c9..4560c0e 100644 --- a/tools/libacpi/Makefile +++ b/tools/libacpi/Makefile @@ -27,6 +27,11 @@ DSDT_FILES ?= $(C_SRC-y) C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, $(DSDT_FILES)) H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h) +MKDSDT_CFLAGS-$(CONFIG_ARM_64) = -DCONFIG_ARM_64 +MKDSDT_CFLAGS-$(CONFIG_X86) = -DCONFIG_X86 + +MKDSDT_CFLAGS = $(MKDSDT_CFLAGS-y) + # Suffix for temporary files. # # We will also use this suffix to workaround a bug in older iasl @@ -44,7 +49,7 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex) $(MK_DSDT): mk_dsdt.c - $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c + $(HOSTCC) $(HOSTCFLAGS) $(MKDSDT_CFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT) # Remove last bracket diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c index 16320a9..fa3c1e9 100644 --- a/tools/libacpi/mk_dsdt.c +++ b/tools/libacpi/mk_dsdt.c @@ -17,9 +17,9 @@ #include #include #include -#if defined(__i386__) || defined(__x86_64__) +#ifdef CONFIG_X86 #include -#elif defined(__aarch64__) +#elif CONFIG_ARM_64 #include #endif @@ -111,9 +111,9 @@ int main(int argc, char **argv) unsigned int slot, dev, intx, link, cpu, max_cpus; dm_version dm_version = QEMU_XEN_TRADITIONAL; -#if defined(__i386__) || defined(__x86_64__) +#ifdef CONFIG_X86 max_cpus = HVM_MAX_VCPUS; -#elif defined(__aarch64__) +#elif CONFIG_ARM_64 max_cpus = GUEST_MAX_VCPUS; #endif @@ -169,7 +169,7 @@ int main(int argc, char **argv) /**** Processor start ****/ push_block("Scope", "\\_SB"); -#if defined(__i386__) || defined(__x86_64__) +#ifdef CONFIG_X86 /* MADT checksum */ stmt("OperationRegion", "MSUM, SystemMemory, \\_SB.MSUA, 1"); push_block("Field", "MSUM, ByteAcc, NoLock, Preserve"); @@ -193,7 +193,7 @@ int main(int argc, char **argv) stmt("Name", "_HID, \"ACPI0007\""); stmt("Name", "_UID, %d", cpu); -#if defined(__aarch64__) +#ifdef CONFIG_ARM_64 pop_block(); continue; #endif @@ -235,7 +235,7 @@ int main(int argc, char **argv) pop_block(); } -#if defined(__aarch64__) +#ifdef CONFIG_ARM_64 pop_block(); /**** Processor end ****/ pop_block();