From patchwork Mon Nov 28 13:13:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 84398 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1128528qgi; Mon, 28 Nov 2016 05:15:51 -0800 (PST) X-Received: by 10.107.57.135 with SMTP id g129mr16758117ioa.178.1480338951722; Mon, 28 Nov 2016 05:15:51 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y191si40338727iod.125.2016.11.28.05.15.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 05:15:51 -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 1cBLkh-0002S3-1H; Mon, 28 Nov 2016 13:13:47 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBLkf-0002Rx-Mf for xen-devel@lists.xen.org; Mon, 28 Nov 2016 13:13:45 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 4A/A2-15390-98D2C385; Mon, 28 Nov 2016 13:13:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRWlGSWpSXmKPExsVysyfVTbdD1yb CYMYDKYslHxezODB6HN39mymAMYo1My8pvyKBNWPi88tsBTeUK/Ytlm9gPC3bxcjJISSwiVHi 0k6/LkYuIPs0o8TVDb1sIAk2AU2JO58/MYHYIgLSEtc+X2YEKWIWuMMo8Xv+BLCEsECExN1DV 8EaWARUJWafXwVm8wq4SDz9dIkdxJYQkJM4eWwy6wRGzgWMDKsYNYpTi8pSi3SNjfSSijLTM0 pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQL9xQAEOxhPrws8xCjJwaQkyhuiZRMhxJeUn1K ZkVicEV9UmpNafIhRhoNDSYL3qjZQTrAoNT21Ii0zBxg4MGkJDh4lEd5LOkBp3uKCxNzizHSI 1ClGXY43u14+YBJiycvPS5US5/UEKRIAKcoozYMbAQviS4yyUsK8jEBHCfEUpBblZpagyr9iF OdgVBLmtQaZwpOZVwK36RXQEUxAR7x9bQ1yREkiQkqqgbHp2vvLT34tLxWOf/nqy9qA5NCW+k lh21muCnBcczU/zdpxVmb6XC5Z61U8vb+u7G6/cF+4meeDabrz9Se1OW53Hvu4rih0zW56+NX Va3q4v4uXyhLHB3nZL3f2K8am2ka8+qp1bsF8lsMGgRl8KltqNF/uiJuVnf6TV3muaIooI6NY ufXxu0osxRmJhlrMRcWJALmtlL9dAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1480338823!72928225!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 2422 invoked from network); 28 Nov 2016 13:13:44 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-27.messagelabs.com with SMTP; 28 Nov 2016 13:13:44 -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 F35DAC14; Mon, 28 Nov 2016 05:13:42 -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 ADDE83F24D; Mon, 28 Nov 2016 05:13:41 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 28 Nov 2016 13:13:36 +0000 Message-Id: <1480338816-29434-1-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 Cc: sstabellini@kernel.org, wei.liu2@citrix.com, Andrew Cooper , ian.jackson@eu.citrix.com, Andrii Anisov , Julien Grall , jbeulich@suse.com Subject: [Xen-devel] [PATCH v2 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 Reviewed-by: Jan Beulich --- Changes in v2: - Use defined(CONFIG_*) rather than CONFIG_* - Use #if defined #elif defined construction - Directly use MKDSDT_CFLAGS-y - Add Andrew's reviewed-by 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 | 5 ++++- tools/libacpi/mk_dsdt.c | 14 +++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile index ccc32c9..6d8445d 100644 --- a/tools/libacpi/Makefile +++ b/tools/libacpi/Makefile @@ -27,6 +27,9 @@ 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 + # Suffix for temporary files. # # We will also use this suffix to workaround a bug in older iasl @@ -44,7 +47,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-y) $(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..760d81b 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__) +#if defined(CONFIG_X86) #include -#elif defined(__aarch64__) +#elif defined(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__) +#if defined(CONFIG_X86) max_cpus = HVM_MAX_VCPUS; -#elif defined(__aarch64__) +#elif defined(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();