From patchwork Tue Aug 16 10:25:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 74003 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1920683qga; Tue, 16 Aug 2016 03:34:35 -0700 (PDT) X-Received: by 10.107.62.4 with SMTP id l4mr4863993ioa.185.1471343675746; Tue, 16 Aug 2016 03:34:35 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 36si5330222iot.138.2016.08.16.03.34.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Aug 2016 03:34: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 1bZbfO-0003rM-8J; Tue, 16 Aug 2016 10:32:18 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZbfN-0003r6-3d for xen-devel@lists.xen.org; Tue, 16 Aug 2016 10:32:17 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id CA/71-24990-0BBE2B75; Tue, 16 Aug 2016 10:32:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSXf9603 hBoeWaVss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlPp05nLGiwqzi4eQFjA+MOwy5GLg4hgVOM Es++7mKEcPYwSixZcI29i5GTg01AV+LjxilgtoiArMTqrjnsIEXMAtcZJe6838YKkhAWcJF4s PkSWBGLgKrEkwPnmUBsXgEPiRs3p7OA2BICGhIreycA2RwcnAKeEtemsIGEhYBKTs9cyApRLi hxcuYTsHJmAQmJgy9eMEO0Kkq0rT/JBmFLShxccYMF5AYJkKtffDoBVWQqsffJGeYJjIKzkMy ahWTWAkamVYzqxalFZalFumZ6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTmJScV6yfm5mxiBAcoA BDsYpzY4H2KU5GBSEuWdOXFjuBBfUn5KZUZicUZ8UWlOavEhRhkODiUJXudXm8KFBItS01Mr0 jJzgLECk5bg4FES4Z0PkuYtLkjMLc5Mh0idYlSUEue1AUkIgCQySvPg2mDxeYlRVkqYlxHoEC GegtSi3MwSVPlXjOIcjErCvMtBpvBk5pXATX8FtJgJaLG+9AaQxSWJCCmpBsZ9Rm9X1lddUzq 0/O90jX0JRkwyrzY0Xph+NTQh+23TP8tz354LCTO6zTE8euJpx8ft6n+6Vxz+sczpz2ePuC7e DT/mHJOaZy7w4suqJmOPB1ZNJs+Md7bk23VHPLH3tJBQ2Pt76560sFnhZjJ20+xepsYVeYXU3 Pny7o6W3rzXPhv/zJx87tA9JZbijERDLeai4kQASHaSw8oCAAA= X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-16.tower-206.messagelabs.com!1471343532!38810731!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 3385 invoked from network); 16 Aug 2016 10:32:15 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-16.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 16 Aug 2016 10:32:15 -0000 Received: from 172.24.1.47 (EHLO szxeml434-hub.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CGJ21734; Tue, 16 Aug 2016 18:26:19 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml434-hub.china.huawei.com (10.82.67.225) with Microsoft SMTP Server id 14.3.235.1; Tue, 16 Aug 2016 18:25:34 +0800 From: Shannon Zhao To: Date: Tue, 16 Aug 2016 18:25:00 +0800 Message-ID: <1471343113-10652-4-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1471343113-10652-1-git-send-email-zhaoshenglong@huawei.com> References: <1471343113-10652-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.0A020201.57B2EA4D.0141, 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: 410fd80f7d36baea7c0d40b8c53eb8db 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 v4 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. Also only check iasl for aarch64 in configure since ACPI on ARM32 is not supported. Signed-off-by: Shannon Zhao --- tools/configure | 2 +- tools/libacpi/Makefile | 15 ++++++++++++- tools/libacpi/mk_dsdt.c | 51 ++++++++++++++++++++++++++++++++----------- tools/libxl/Makefile | 5 ++++- tools/libxl/libxl_arm_acpi.c | 5 +++++ xen/include/public/arch-arm.h | 3 +++ 6 files changed, 65 insertions(+), 16 deletions(-) diff --git a/tools/configure b/tools/configure index 5b5dcce..48239c0 100755 --- a/tools/configure +++ b/tools/configure @@ -7458,7 +7458,7 @@ then as_fn_error $? "Unable to find xgettext, please install xgettext" "$LINENO" 5 fi case "$host_cpu" in -i[3456]86|x86_64) +i[3456]86|x86_64|aarch64) # Extract the first word of "iasl", so it can be a program name with args. set dummy iasl; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile index d741ac5..7f50a33 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,18 @@ $(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, \"XenARM\", \"Xen DSDT\", 1)\n{" > $@ + $(MK_DSDT) --debug=$(debug) --arch arm >> $@ + +$(ACPI_BUILD_DIR)/dsdt_anycpu_arm.c: iasl $(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl + cd $(ACPI_BUILD_DIR) + iasl -vs -p $* -tc $(ACPI_BUILD_DIR)/$*.asl + sed -e 's/AmlCode/$*/g' $*.hex >$@ + echo "int $*_len=sizeof($*);" >>$@ + rm -f $*.aml $*.hex + cd $(CURDIR) + 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..f3ab28f 100644 --- a/tools/libacpi/mk_dsdt.c +++ b/tools/libacpi/mk_dsdt.c @@ -18,6 +18,7 @@ #include #include #include +#include static unsigned int indent_level; static bool debug = false; @@ -99,6 +100,7 @@ static struct option options[] = { { "dm-version", 1, 0, 'q' }, { "debug", 1, 0, 'd' }, { "no-dm", 0, 0, 'n' }, + { "arch", 1, 0, 'a' }, { 0, 0, 0, 0 } }; @@ -106,7 +108,7 @@ int main(int argc, char **argv) { unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS; dm_version dm_version = QEMU_XEN_TRADITIONAL; - bool no_dm = 0; + bool no_dm = 0, arch_is_arm = false; for ( ; ; ) { @@ -145,6 +147,10 @@ int main(int argc, char **argv) case 'n': no_dm = 1; break; + case 'a': + if (strcmp(optarg, "arm") == 0) + arch_is_arm = true; + break; case 'd': if (*optarg == 'y') debug = true; @@ -154,6 +160,9 @@ int main(int argc, char **argv) } } + if (arch_is_arm) + max_cpus = GUEST_MAX_VCPUS; + /**** DSDT DefinitionBlock start ****/ /* (we append to existing DSDT definition block) */ indent_level++; @@ -161,19 +170,21 @@ int main(int argc, char **argv) /**** Processor start ****/ push_block("Scope", "\\_SB"); - /* MADT checksum */ - stmt("OperationRegion", "MSUM, SystemMemory, \\_SB.MSUA, 1"); - push_block("Field", "MSUM, ByteAcc, NoLock, Preserve"); - indent(); printf("MSU, 8\n"); - pop_block(); + if (!arch_is_arm) { + /* MADT checksum */ + stmt("OperationRegion", "MSUM, SystemMemory, \\_SB.MSUA, 1"); + push_block("Field", "MSUM, ByteAcc, NoLock, Preserve"); + indent(); printf("MSU, 8\n"); + pop_block(); - /* Processor object helpers. */ - push_block("Method", "PMAT, 2"); - push_block("If", "LLess(Arg0, NCPU)"); - stmt("Return", "ToBuffer(Arg1)"); - pop_block(); - stmt("Return", "Buffer() {0, 8, 0xff, 0xff, 0, 0, 0, 0}"); - pop_block(); + /* Processor object helpers. */ + push_block("Method", "PMAT, 2"); + push_block("If", "LLess(Arg0, NCPU)"); + stmt("Return", "ToBuffer(Arg1)"); + pop_block(); + stmt("Return", "Buffer() {0, 8, 0xff, 0xff, 0, 0, 0, 0}"); + pop_block(); + } /* Define processor objects and control methods. */ for ( cpu = 0; cpu < max_cpus; cpu++) @@ -182,6 +193,12 @@ int main(int argc, char **argv) stmt("Name", "_HID, \"ACPI0007\""); + if (arch_is_arm) { + stmt("Name", "_UID, %d", cpu); + pop_block(); + continue; + } + /* 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 (arch_is_arm) { + pop_block(); + /**** Processor end ****/ + pop_block(); + /**** DSDT DefinitionBlock end ****/ + return 0; + } + /* 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 6139bed..ce356d0 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -90,7 +90,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 -LIBXL_OBJS-$(CONFIG_ARM_64) += libxl_arm_acpi.o +LIBXL_OBJS-$(CONFIG_ARM_64) += libxl_arm_acpi.o dsdt_anycpu_arm.o + +dsdt_anycpu_arm.c: + $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(shell pwd) libxl_arm_acpi.o: libxl_arm_acpi.c $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index ec6cf08..087d028 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -28,6 +28,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/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 0afd654..008a2a0 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