From patchwork Tue Dec 29 11:31:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 7929851 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A18ACBEEE5 for ; Tue, 29 Dec 2015 11:42:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFC2D20221 for ; Tue, 29 Dec 2015 11:42:35 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9473E201EC for ; Tue, 29 Dec 2015 11:42:34 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aDsVz-0001Pj-Ot; Tue, 29 Dec 2015 11:32:31 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aDsVy-0001Oa-74 for xen-devel@lists.xen.org; Tue, 29 Dec 2015 11:32:30 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id CB/58-13905-D4F62865; Tue, 29 Dec 2015 11:32:29 +0000 X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1451388747!12858134!1 X-Originating-IP: [192.55.52.88] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjg4ID0+IDM3NDcyNQ==\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2876 invoked from network); 29 Dec 2015 11:32:28 -0000 Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by server-7.tower-206.messagelabs.com with SMTP; 29 Dec 2015 11:32:28 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 29 Dec 2015 03:32:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,495,1444719600"; d="scan'208";a="882793731" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.13.40]) by fmsmga002.fm.intel.com with ESMTP; 29 Dec 2015 03:32:25 -0800 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Tue, 29 Dec 2015 19:31:51 +0800 Message-Id: <1451388711-18646-5-git-send-email-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.4.8 In-Reply-To: <1451388711-18646-1-git-send-email-haozhong.zhang@intel.com> References: <1451388711-18646-1-git-send-email-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Kevin Tian , Keir Fraser , Ian Campbell , Stefano Stabellini , Jun Nakajima , Andrew Cooper , Ian Jackson , Jan Beulich , Wei Liu Subject: [Xen-devel] [PATCH 4/4] hvmloader: add support to load extra ACPI tables from qemu X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP NVDIMM devices are detected and configured by software through ACPI. Currently, QEMU maintains ACPI tables of vNVDIMM devices. This patch extends the existing mechanism in hvmloader of loading passthrough ACPI tables to load extra ACPI tables built by QEMU. Signed-off-by: Haozhong Zhang --- tools/firmware/hvmloader/acpi/build.c | 34 +++++++++++++++++++++++++++------ xen/include/public/hvm/hvm_xs_strings.h | 3 +++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index 503648c..72be3e0 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -292,8 +292,10 @@ static struct acpi_20_slit *construct_slit(void) return slit; } -static int construct_passthrough_tables(unsigned long *table_ptrs, - int nr_tables) +static int construct_passthrough_tables_common(unsigned long *table_ptrs, + int nr_tables, + const char *xs_acpi_pt_addr, + const char *xs_acpi_pt_length) { const char *s; uint8_t *acpi_pt_addr; @@ -304,26 +306,28 @@ static int construct_passthrough_tables(unsigned long *table_ptrs, uint32_t total = 0; uint8_t *buffer; - s = xenstore_read(HVM_XS_ACPI_PT_ADDRESS, NULL); + s = xenstore_read(xs_acpi_pt_addr, NULL); if ( s == NULL ) - return 0; + return 0; acpi_pt_addr = (uint8_t*)(uint32_t)strtoll(s, NULL, 0); if ( acpi_pt_addr == NULL ) return 0; - s = xenstore_read(HVM_XS_ACPI_PT_LENGTH, NULL); + s = xenstore_read(xs_acpi_pt_length, NULL); if ( s == NULL ) return 0; acpi_pt_length = (uint32_t)strtoll(s, NULL, 0); for ( nr_added = 0; nr_added < nr_max; nr_added++ ) - { + { if ( (acpi_pt_length - total) < sizeof(struct acpi_header) ) break; header = (struct acpi_header*)acpi_pt_addr; + set_checksum(header, offsetof(struct acpi_header, checksum), + header->length); buffer = mem_alloc(header->length, 16); if ( buffer == NULL ) @@ -338,6 +342,21 @@ static int construct_passthrough_tables(unsigned long *table_ptrs, return nr_added; } +static int construct_passthrough_tables(unsigned long *table_ptrs, + int nr_tables) +{ + return construct_passthrough_tables_common(table_ptrs, nr_tables, + HVM_XS_ACPI_PT_ADDRESS, + HVM_XS_ACPI_PT_LENGTH); +} + +static int construct_dm_tables(unsigned long *table_ptrs, int nr_tables) +{ + return construct_passthrough_tables_common(table_ptrs, nr_tables, + HVM_XS_DM_ACPI_PT_ADDRESS, + HVM_XS_DM_ACPI_PT_LENGTH); +} + static int construct_secondary_tables(unsigned long *table_ptrs, struct acpi_info *info) { @@ -454,6 +473,9 @@ static int construct_secondary_tables(unsigned long *table_ptrs, /* Load any additional tables passed through. */ nr_tables += construct_passthrough_tables(table_ptrs, nr_tables); + /* Load any additional tables from device model */ + nr_tables += construct_dm_tables(table_ptrs, nr_tables); + table_ptrs[nr_tables] = 0; return nr_tables; } diff --git a/xen/include/public/hvm/hvm_xs_strings.h b/xen/include/public/hvm/hvm_xs_strings.h index 146b0b0..4698495 100644 --- a/xen/include/public/hvm/hvm_xs_strings.h +++ b/xen/include/public/hvm/hvm_xs_strings.h @@ -41,6 +41,9 @@ #define HVM_XS_ACPI_PT_ADDRESS "hvmloader/acpi/address" #define HVM_XS_ACPI_PT_LENGTH "hvmloader/acpi/length" +#define HVM_XS_DM_ACPI_PT_ADDRESS "hvmloader/dm-acpi/address" +#define HVM_XS_DM_ACPI_PT_LENGTH "hvmloader/dm-acpi/length" + /* Any number of SMBIOS types can be passed through to an HVM guest using * the following xenstore values. The values specify the guest physical * address and length of a block of SMBIOS structures for hvmloader to use.