From patchwork Thu Sep 22 12:52:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 76782 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp14843qgf; Thu, 22 Sep 2016 05:55:35 -0700 (PDT) X-Received: by 10.107.173.105 with SMTP id w102mr2512027ioe.186.1474548935152; Thu, 22 Sep 2016 05:55:35 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o84si1532653itd.64.2016.09.22.05.55.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 05:55:35 -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 1bn3VW-0004BO-KQ; Thu, 22 Sep 2016 12:53:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bn3VV-0004A2-5o for xen-devel@lists.xen.org; Thu, 22 Sep 2016 12:53:41 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id AA/F3-04595-454D3E75; Thu, 22 Sep 2016 12:53:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSTf4yuN wgycfbSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyO1l3MBT2WFX+P7WJuYHys38XIySEkcIpR 4tAzmS5GLiB7D6PEjzXzGUESbAJaEuen/2AHsUUEZCVWd81hByliFrjOKHHn/TZWkISwgIvEk 9NH2EBsFgFVib4Ph8FsXgEPiT+9s1hAbAkBDYmVvRPAbE4BT4kJR9azQmz2kFh5ZSErRL2gxM mZT8BqmAUkJA6+eMEM0aso0bb+JBuELSlxcMUNFpAjJECuvn10KVSRqcSNlk/MExgFZyGZNQv JrAWMTKsY1YtTi8pSi3Qt9ZKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAgOUAQh2 MN7dFHCIUZKDSUmU90L/43AhvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErwJl4FygkWp6akVaZk5w FiBSUtw8CiJ8BaDpHmLCxJzizPTIVKnGBWlxHnrQBICIImM0jy4Nlh8XmKUlRLmZQQ6RIinIL UoN7MEVf4VozgHo5IwbxDIFJ7MvBK46a+AFjMBLd7y8wHI4pJEhJRUA+PE1IvKMRMTPjfsOD6 F6/CDxf9lNqw/dyV9r3mMGW+Hla/PLdbTsr/i9gtq1k1I0zu6iE1aYeuh50u+CJuc8pNvkLXk zZtq/nlJ7oo5PusWlNxxL2JO+/bKRed5QGwS8ysp6/D7OtKn5lQxyE1OT3v0b3YhV8nCkKTYz Tf+dbnW11eIFRv9NldiKc5INNRiLipOBABCFNJRygIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1474548816!12017043!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 38642 invoked from network); 22 Sep 2016 12:53:39 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-6.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 22 Sep 2016 12:53:39 -0000 Received: from 172.24.1.47 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CIG48119; Thu, 22 Sep 2016 20:53:00 +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; Thu, 22 Sep 2016 20:52:51 +0800 From: z00226004 To: Date: Thu, 22 Sep 2016 20:52:20 +0800 Message-ID: <1474548753-12596-4-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1474548753-12596-1-git-send-email-zhaoshenglong@huawei.com> References: <1474548753-12596-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.0A020204.57E3D42E.0283, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f66d70d38945bed7f71e4a26a1b59aa0 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 v6 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 Acked-by: Wei Liu --- tools/configure.ac | 2 +- tools/libacpi/Makefile | 8 +++++++- 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, 47 insertions(+), 4 deletions(-) diff --git a/tools/configure.ac b/tools/configure.ac index f010d72..dba7c7a 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -340,7 +340,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 68351c7..ee3f071 100644 --- a/tools/libacpi/Makefile +++ b/tools/libacpi/Makefile @@ -24,6 +24,7 @@ MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt C_SRC-$(GPL) = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, dsdt_pvh.c $(C_SRC-y)) +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) @@ -35,7 +36,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) -o $@ mk_dsdt.c + $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c ifeq ($(GPL),y) $(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: gpl/dsdt.asl $(MK_DSDT) @@ -58,6 +59,11 @@ $(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT) $(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@.$(TMP_SUFFIX) mv -f $@.$(TMP_SUFFIX) $@ +$(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl: $(MK_DSDT) + printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 3, \"Xen\", \"ARM\", 1)\n{" > $@.$(TMP_SUFFIX) + $(MK_DSDT) --debug=$(debug) >> $@.$(TMP_SUFFIX) + mv -f $@.$(TMP_SUFFIX) $@ + $(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@.$(TMP_SUFFIX) diff --git a/tools/libacpi/mk_dsdt.c b/tools/libacpi/mk_dsdt.c index 8130cbd..4ae68bc 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,9 +108,15 @@ static struct option options[] = { int main(int argc, char **argv) { - unsigned int slot, cpu, max_cpus = HVM_MAX_VCPUS; + unsigned int slot, cpu, max_cpus; dm_version dm_version = QEMU_XEN_TRADITIONAL; +#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); @@ -159,6 +169,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"); @@ -172,6 +183,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++) @@ -180,6 +192,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); @@ -218,6 +235,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 94ab743..95f6a33 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -92,7 +92,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 20bb2ba..e237f61 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, count = 0; + 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