From patchwork Thu Sep 29 01:18:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 9355525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 88D546077A for ; Thu, 29 Sep 2016 01:22:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72AB328E6B for ; Thu, 29 Sep 2016 01:22:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6755729710; Thu, 29 Sep 2016 01:22:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BAEF8296CB for ; Thu, 29 Sep 2016 01:22:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpQ0n-0001Ph-Sr; Thu, 29 Sep 2016 01:19:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpQ0m-0001MV-1G for xen-devel@lists.xen.org; Thu, 29 Sep 2016 01:19:44 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id D1/15-28857-F2C6CE75; Thu, 29 Sep 2016 01:19:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsVyMfTAFl29nDf hBjuOGVgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBk/5z5kL7gjUnH7eitzA+MdgS5GLg4hgYmM Eh3/VrODOCwC85glpizrZQZxJAT6WSU+Tf7D2sXICeTESPxatAfKrpZ4+349mC0koCax7PBCZ ohRTUwSx1/eYARJsAnoSLyYtJMNxBYRkJa49vkyI0gRs8ARRolb808ygySEBewkPlzrAGtgEV CVmNbwkh3E5hWwlnix5DjUNk2J6bNeg9VzCthIfGj5xQyx2Vpi2bfNLBMYBRYwMqxi1ChOLSp LLdI1tNBLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAgMLwYg2MF4c2PAIUZJDiYl UV5OnzfhQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4r2QB5QSLUtNTK9Iyc4CBDpOW4OBREuF9B ZLmLS5IzC3OTIdInWI05tjy+9paJo5tU++tZRJiycvPS5US570KUioAUppRmgc3CBaBlxhlpY R5GYFOE+IpSC3KzSxBlX/FKM7BqCTMq5wNNIUnM68Ebt8roFOYgE5ZeuIFyCkliQgpqQbG8Fl sN4IsP/5+fcWlPiTA4Zpa6rLbGuJu7f/7Ba4/6q3QSl43paNzvk9kzZyCOg0uEYPe+oMftWZ/ ldr5ibHlxpFV87zZ2rkEuJ5eWnB9d2dHQ63abQG2ho8LT7+aJHvn35IN7/SMDm2R/1d2+O2MF /36eh0H5F4YnlwmE+H7cf7qs4uTWIM+KrEUZyQaajEXFScCAMchLIO7AgAA X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-12.tower-21.messagelabs.com!1475111981!35600572!1 X-Originating-IP: [209.85.192.180] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23224 invoked from network); 29 Sep 2016 01:19:42 -0000 Received: from mail-pf0-f180.google.com (HELO mail-pf0-f180.google.com) (209.85.192.180) by server-12.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Sep 2016 01:19:42 -0000 Received: by mail-pf0-f180.google.com with SMTP id 21so22908798pfy.0 for ; Wed, 28 Sep 2016 18:19:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BbZ952CTqmSSq/uAZi3xq0t/gHFlQqJXaAUKe4qkvSc=; b=i4n8/zPpd8h0k3q0wnfqQVEUxxr9sdmbGW0iv6Z87lfVp4aqMeeiCWlO1WYD2wamhK RhfYjgxy9Nm74Tcdm//NGsbj82LlSIn23kBkCpYnbyvjy/wNRG+pCc+0koRvWNyjpR63 Gdv080xEkgbBDl4awTjD5szptVdWS7EW7KiRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BbZ952CTqmSSq/uAZi3xq0t/gHFlQqJXaAUKe4qkvSc=; b=MpS+qlzlKxScm3YAH5fnLJ/f+3nkltxJd48Gkwid3boB4M3IzVgXW62mjovLGGFXfM RorouSI8c5Ry6IuoYsCjc8yyOHkJf1k6zu7lArI+84THQiXOHAlsbWItyoll4vzTi0eP 7BAI0eCZvcCblM09YL4aj84Tzc0PZvC9yeSDSfghy7A9Xy8bFva5yrkHzDGBFhdBeK5L j216RI5yWb1fxwtVxRV9xeHhd+iVLBU0LXfPiEHO3/NZj4fZ4poqxgWQKwhQKDrGoSbn p7sB1vMBMNkMl9Q7LlzqUqfOAN6hsaZT4WXbUCkQG4P2IF7UWDSlNMPvFinza6g7T+RT PpxQ== X-Gm-Message-State: AE9vXwOLV3P0dKn83zZ4s98XcrPjwY3bqJGdUfmXkdPZH68D2d4xG+Dq2S6NEmjgoRIwHqF6 X-Received: by 10.98.219.196 with SMTP id f187mr60994672pfg.39.1475111981097; Wed, 28 Sep 2016 18:19:41 -0700 (PDT) Received: from HZA160860128-A.china.huawei.com ([67.238.99.186]) by smtp.gmail.com with ESMTPSA id wd7sm15228744pab.2.2016.09.28.18.19.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Sep 2016 18:19:40 -0700 (PDT) From: Shannon Zhao To: xen-devel@lists.xen.org Date: Wed, 28 Sep 2016 18:18:53 -0700 Message-Id: <20160929011902.7784-8-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20160929011902.7784-1-shannon.zhao@linaro.org> References: <20160929011902.7784-1-shannon.zhao@linaro.org> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, julien.grall@arm.com, Shannon Zhao , zhaoshenglong@huawei.com, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v8 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Construct GTDT table with the interrupt information of timers. Signed-off-by: Shannon Zhao Acked-by: Julien Grall Acked-by: Wei Liu --- 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 ab68bf8..b2136fd 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, struct xc_dom_image *dom) { @@ -216,6 +253,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;