From patchwork Thu Sep 22 12:52:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 76773 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp14678qgf; Thu, 22 Sep 2016 05:55:14 -0700 (PDT) X-Received: by 10.36.163.8 with SMTP id p8mr2565333ite.101.1474548914068; Thu, 22 Sep 2016 05:55:14 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id l200si1934290iol.86.2016.09.22.05.55.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 05:55:14 -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 1bn3VO-00043q-PD; Thu, 22 Sep 2016 12:53:34 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bn3VN-00042c-1i for xen-devel@lists.xen.org; Thu, 22 Sep 2016 12:53:33 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 3C/E2-11175-C44D3E75; Thu, 22 Sep 2016 12:53:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSdf7yuN wg5drLS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozNBzazFkwQrfj3cDZzA+NXgS5GLg4hgTOM Eu/+zWaHcPYwSnw/foWxi5GTg01AS+L89B/sILaIgKzE6q45YEXMAtcZJe6838baxcjBISxgJ 3GtzwSkhkVAVeJN3w8mEJtXwEPi5Ok3zCC2hICGxMreCSwgNqeAp8SEI+tZQWwhoJqVVxayQt QLSpyc+QSshllAQuLgixdQvYoSbetPskHYkhIHV9xgAblBQuAUo8S6e+sYQW6QEDCV6GyQncA oOAvJqFlIRi1gZFrFqFGcWlSWWqRrZKyXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7 iREYoAxAsIPxz/zAQ4ySHExKorwX+h+HC/El5adUZiQWZ8QXleakFh9ilOHgUJLgfXwJKCdYl JqeWpGWmQOMFZi0BAePkghv8WWgNG9xQWJucWY6ROoUo6KUOO9vkD4BkERGaR5cGyw+LzHKSg nzMgIdIsRTkFqUm1mCKv+KUZyDUUmYNwhkPE9mXgnc9FdAi5mAFm/5+QBkcUkiQkqqgdHpzzS dk5vbJt/48G/XuYNnfI8lHTIpzuF50vDDxWgq7+r3GvU3VQ/wLmxw6O06uGDrd737xamlyi8f nDgw49FV7vjX3z/Lfou4bV6a1lD2Tu382ZZte7bOZM7caBiRXbvM8BR30tnwKMM34ueOTv27v +teUcv+HUffb16/9Moe/9Drf9QDKr8aKbEUZyQaajEXFScCAEwsFUbKAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1474548807!34585189!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 63880 invoked from network); 22 Sep 2016 12:53:31 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-7.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 22 Sep 2016 12:53:31 -0000 Received: from 172.24.1.137 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CIG48131; Thu, 22 Sep 2016 20:53:04 +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:54 +0800 From: z00226004 To: Date: Thu, 22 Sep 2016 20:52:24 +0800 Message-ID: <1474548753-12596-8-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.0A020205.57E3D431.017B, 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: c6dbb008a91e8eb49a08c8cca0384a82 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 07/16] libxl/arm: Construct ACPI GTDT 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 Construct GTDT table with the interrupt information of timers. Signed-off-by: Shannon Zhao Acked-by: Julien Grall --- tools/libxl/libxl_arm_acpi.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index eb62096..2488c0f 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -25,10 +25,24 @@ typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; +typedef int64_t s64; #include #include +#ifndef BITS_PER_LONG +#ifdef _LP64 +#define BITS_PER_LONG 64 +#else +#define BITS_PER_LONG 32 +#endif +#endif +#define ACPI_MACHINE_WIDTH __BITS_PER_LONG +#define COMPILER_DEPENDENT_INT64 int64_t +#define COMPILER_DEPENDENT_UINT64 uint64_t + +#include + _hidden extern const unsigned char dsdt_anycpu_arm[]; _hidden @@ -190,6 +204,29 @@ static void make_acpi_xsdt(libxl__gc *gc, struct xc_dom_image *dom, acpitables[XSDT].size); } +static void make_acpi_gtdt(libxl__gc *gc, struct xc_dom_image *dom, + struct acpitable acpitables[]) +{ + uint64_t offset = acpitables[GTDT].addr - GUEST_ACPI_BASE; + struct acpi_table_gtdt *gtdt = (void *)dom->acpi_modules[0].data + offset; + + gtdt->non_secure_el1_interrupt = GUEST_TIMER_PHYS_NS_PPI; + gtdt->non_secure_el1_flags = + (ACPI_LEVEL_SENSITIVE << ACPI_GTDT_INTERRUPT_MODE) + |(ACPI_ACTIVE_LOW << ACPI_GTDT_INTERRUPT_POLARITY); + gtdt->virtual_timer_interrupt = GUEST_TIMER_VIRT_PPI; + gtdt->virtual_timer_flags = + (ACPI_LEVEL_SENSITIVE << ACPI_GTDT_INTERRUPT_MODE) + |(ACPI_ACTIVE_LOW << ACPI_GTDT_INTERRUPT_POLARITY); + + gtdt->counter_block_addresss = ~((uint64_t)0); + gtdt->counter_read_block_address = ~((uint64_t)0); + + make_acpi_header(>dt->header, "GTDT", acpitables[GTDT].size, 2); + calculate_checksum(gtdt, offsetof(struct acpi_table_header, checksum), + acpitables[GTDT].size); +} + int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom) @@ -220,6 +257,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, make_acpi_rsdp(gc, dom, acpitables); make_acpi_xsdt(gc, dom, acpitables); + make_acpi_gtdt(gc, dom, acpitables); out: return rc;