From patchwork Fri Sep 2 02:55:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 75270 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp623817qga; Thu, 1 Sep 2016 19:58:58 -0700 (PDT) X-Received: by 10.157.17.233 with SMTP id y38mr478489oty.40.1472785132306; Thu, 01 Sep 2016 19:58:52 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 42si10184402otm.29.2016.09.01.19.58.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 19:58:52 -0700 (PDT) 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 1bfeeq-0006r3-Ht; Fri, 02 Sep 2016 02:56:44 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfeep-0006qD-1e for xen-devel@lists.xen.org; Fri, 02 Sep 2016 02:56:43 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id A1/B3-05361-A6AE8C75; Fri, 02 Sep 2016 02:56:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVi9XuGg27mqxP hBj83qlgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBkrT5xnKXhhVTF7yznmBsbphl2MXBxCAqcY JeZuuM4G4exmlPjcMoexi5GTg01AV+LjxinsILaIgKzE6q457CBFzALXGSXuvN/GCpIQFnCRu LL2NQuIzSKgInH0TBsbiM0r4CHRfHgSWI2EgIbEyt4JYDWcAp4Sb1d9AhsqBFTz+NUjJoh6QY mTM5+A1TALSEgcfPGCGaJXUaJt/Uk2CFtS4uCKGywgR0iAnP1w3y5GiISpxMnzG1gmMArOQjJ rFpJZCxiZVjGqF6cWlaUW6ZroJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEhigD EOxg7L7sf4hRkoNJSZQ3/8mJcCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvEYvgXKCRanpqRVpm TnAaIFJS3DwKInwmoGkeYsLEnOLM9MhUqcYFaXEeV+8AEoIgCQySvPg2mAReolRVkqYlxHoEC GegtSi3MwSVPlXjOIcjErCvAEg43ky80rgpr8CWswEtLjk2nGQxSWJCCmpBsa1MnZzlf/6nHg sUbZb/vjBCxG7V7+TYBXn4+rn+qy3W6Ovx2J96zLmE4+MXdf7FN2cbKma6lS1xihTy31FzAan L9VVK6rl+4vnH+3xjuFfdEnl/gxJnp+OT5gXT5zXKfTG9IrjRdUInprDLw68l/e/ef3UQuGbJ 28aKQvY1i2+19q6wmrHQl0lluKMREMt5qLiRAAr21nXywIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1472784996!56747903!1 X-Originating-IP: [58.251.152.64] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 55606 invoked from network); 2 Sep 2016 02:56:40 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-16.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 2 Sep 2016 02:56:40 -0000 Received: from 172.24.1.60 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.60]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DQM36289; Fri, 02 Sep 2016 10:56:13 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Fri, 2 Sep 2016 10:56:01 +0800 From: Shannon Zhao To: Date: Fri, 2 Sep 2016 10:55:26 +0800 Message-ID: <1472784939-14404-4-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1472784939-14404-1-git-send-email-zhaoshenglong@huawei.com> References: <1472784939-14404-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0207.57C8EA4F.0019, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 68f7b8114070d023ddcbb0f6159174ad Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v5 03/16] libxl/arm: Generate static ACPI DSDT table 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" From: Shannon Zhao It uses static DSDT table like the way x86 uses. Currently the DSDT table only contains processor device objects and it generates the maximal objects which so far is 128. While the GUEST_MAX_VCPUS is defined under __XEN__ or __XEN_TOOLS__, it needs to add -D__XEN_TOOLS__ to compile mk_dsdt.c. Also only check iasl for aarch64 in configure since ACPI on ARM32 is not supported. Signed-off-by: Shannon Zhao Acked-by: Julien Grall --- Note: this patch needs to be rebased on Boris's v3 patchset for only generating dsdt_anycpu_arm.c for ARM64. --- tools/configure.ac | 2 +- tools/libacpi/Makefile | 13 ++++++++++++- tools/libacpi/mk_dsdt.c | 27 ++++++++++++++++++++++++++- tools/libxl/Makefile | 5 ++++- tools/libxl/libxl_arm_acpi.c | 5 +++++ xen/arch/arm/domain.c | 1 + xen/include/public/arch-arm.h | 3 +++ 7 files changed, 52 insertions(+), 4 deletions(-) diff --git a/tools/configure.ac b/tools/configure.ac index 0229d44..b4e0c80 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -335,7 +335,7 @@ dnl "host" here means the platform on which the hypervisor and tools is dnl going to run, not the platform on which we are building (known as dnl "build" in gnu speak). case "$host_cpu" in -i[[3456]]86|x86_64) +i[[3456]]86|x86_64|aarch64) AX_PATH_PROG_OR_FAIL([IASL], [iasl]) ;; esac diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile index d741ac5..b1965cc 100644 --- a/tools/libacpi/Makefile +++ b/tools/libacpi/Makefile @@ -19,6 +19,7 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt # Sources to be generated C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c dsdt_pvh.c) +C_SRC += $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h) vpath iasl $(PATH) @@ -32,7 +33,7 @@ $(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl cd $(CURDIR) $(MK_DSDT): mk_dsdt.c - $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c + $(HOSTCC) $(HOSTCFLAGS) $(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) awk 'NR > 1 {print s} {s=$$0}' $< > $@ @@ -62,6 +63,16 @@ $(ACPI_BUILD_DIR)/dsdt_pvh.c: iasl $(ACPI_BUILD_DIR)/dsdt_pvh.asl echo "int dsdt_pvh_len=sizeof(dsdt_pvh);" >>$@ rm -f $(ACPI_BUILD_DIR)/$*.aml $(ACPI_BUILD_DIR)/$*.hex +$(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl: $(MK_DSDT) + printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 3, \"Xen\", \"ARM\", 1)\n{" > $@ + $(MK_DSDT) --debug=$(debug) >> $@ + +$(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c: iasl $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl + iasl -vs -p $(ACPI_BUILD_DIR)/$* -tc $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl + sed -e 's/AmlCode/dsdt_anycpu_arm/g' $(ACPI_BUILD_DIR)/$*.hex >$@ + echo "int dsdt_anycpu_arm_len=sizeof(dsdt_anycpu_arm);" >>$@ + rm -f $(ACPI_BUILD_DIR)/$*.aml $(ACPI_BUILD_DIR)/$*.hex + iasl: @echo @echo "ACPI ASL compiler (iasl) is needed" diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c index 7d76784..a56e0f0 100644 --- a/tools/libacpi/mk_dsdt.c +++ b/tools/libacpi/mk_dsdt.c @@ -17,7 +17,11 @@ #include #include #include +#if defined(__i386__) || defined(__x86_64__) #include +#elif defined(__aarch64__) +#include +#endif static unsigned int indent_level; static bool debug = false; @@ -104,10 +108,16 @@ static struct option options[] = { int main(int argc, char **argv) { - unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS; + unsigned int slot, dev, intx, link, cpu, max_cpus; dm_version dm_version = QEMU_XEN_TRADITIONAL; bool no_dm = 0; +#if defined(__i386__) || defined(__x86_64__) + max_cpus = HVM_MAX_VCPUS; +#elif defined(__aarch64__) + max_cpus = GUEST_MAX_VCPUS; +#endif + for ( ; ; ) { int opt = getopt_long(argc, argv, "", options, NULL); @@ -161,6 +171,7 @@ int main(int argc, char **argv) /**** Processor start ****/ push_block("Scope", "\\_SB"); +#if defined(__i386__) || defined(__x86_64__) /* MADT checksum */ stmt("OperationRegion", "MSUM, SystemMemory, \\_SB.MSUA, 1"); push_block("Field", "MSUM, ByteAcc, NoLock, Preserve"); @@ -174,6 +185,7 @@ int main(int argc, char **argv) pop_block(); stmt("Return", "Buffer() {0, 8, 0xff, 0xff, 0, 0, 0, 0}"); pop_block(); +#endif /* Define processor objects and control methods. */ for ( cpu = 0; cpu < max_cpus; cpu++) @@ -182,6 +194,11 @@ int main(int argc, char **argv) stmt("Name", "_HID, \"ACPI0007\""); + stmt("Name", "_UID, %d", cpu); +#if defined(__aarch64__) + pop_block(); + continue; +#endif /* Name this processor's MADT LAPIC descriptor. */ stmt("OperationRegion", "MATR, SystemMemory, Add(\\_SB.MAPA, %d), 8", cpu*8); @@ -220,6 +237,14 @@ int main(int argc, char **argv) pop_block(); } +#if defined(__aarch64__) + pop_block(); + /**** Processor end ****/ + pop_block(); + /**** DSDT DefinitionBlock end ****/ + return 0; +#endif + /* Operation Region 'PRST': bitmask of online CPUs. */ stmt("OperationRegion", "PRST, SystemIO, 0xaf00, 32"); push_block("Field", "PRST, ByteAcc, NoLock, Preserve"); diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index afd93de..15a9046 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -91,7 +91,10 @@ acpi: LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o ifeq ($(CONFIG_ARM_64),y) -LIBXL_OBJS-y += libxl_arm_acpi.o +LIBXL_OBJS-y += libxl_arm_acpi.o dsdt_anycpu_arm.o +dsdt_anycpu_arm.c: + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) + libxl_arm_acpi.o: libxl_arm_acpi.c $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c else diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index 810aed8..0851411 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -29,6 +29,11 @@ typedef uint64_t u64; #include #include +_hidden +extern const unsigned char dsdt_anycpu_arm[]; +_hidden +extern const int dsdt_anycpu_arm_len; + int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 61fc08e..234d994 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -548,6 +548,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, { int rc; + BUILD_BUG_ON(GUEST_MAX_VCPUS < MAX_VIRT_CPUS); d->arch.relmem = RELMEM_not_started; /* Idle domains do not need this setup */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 4b4c959..1bef2ee 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -435,6 +435,9 @@ typedef uint64_t xen_callback_t; #define GUEST_RAM_BANK_BASES { GUEST_RAM0_BASE, GUEST_RAM1_BASE } #define GUEST_RAM_BANK_SIZES { GUEST_RAM0_SIZE, GUEST_RAM1_SIZE } +/* Current supported guest VCPUs */ +#define GUEST_MAX_VCPUS 128 + /* Interrupts */ #define GUEST_TIMER_VIRT_PPI 27 #define GUEST_TIMER_PHYS_S_PPI 29