From patchwork Sun Sep 13 12:43:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 53531 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id C67DB22B26 for ; Sun, 13 Sep 2015 12:49:15 +0000 (UTC) Received: by lanb10 with SMTP id b10sf40064877lan.3 for ; Sun, 13 Sep 2015 05:49:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=WYGobB4GCORh+Pf7V34uAa8MngzXsWu5Jy2pEOUjq+w=; b=ec8Du7pi/QjVYKuWAWCRbAAx6HdbMsR1PeFwImxW4MxBM1mv4ZTvgUWKRfvdwgG3Yn tmkvOTJB4Uxi3nOxepnY2IHdeHRJ1fvnD9xdrQnO1ubdSIt1M48lzdl0dSq3zhWHxPsL Q5JOGzzvVeGy1a6FkflBjcv3Z3G1CcjbCYoW8rDtImx/2Ff57ChvKVm8YFgt2db04/qQ zSfHSrLNkBTRnmRTo/vuFcx/8ETzJYERenRlgmkk1Hd+zV9V3ZYzNDU4bUwi95CYI/XT F6T8hOYnGcUPZ2LvRaLvU40Rp55yMnIru9rSO1Ge4xGbW15r9itQpJ7cGI4G2UZKxeLV mJaA== X-Gm-Message-State: ALoCoQmtv2G5bUAmUQDZoxPoRBOOInFDgcWNkeW04rLXTv/hJlqaGODkidGhoXoqxbf6n4QClvMX X-Received: by 10.152.22.101 with SMTP id c5mr1444198laf.0.1442148554108; Sun, 13 Sep 2015 05:49:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.4.9 with SMTP id ca9ls572761lad.20.gmail; Sun, 13 Sep 2015 05:49:13 -0700 (PDT) X-Received: by 10.152.1.72 with SMTP id 8mr8500431lak.70.1442148553914; Sun, 13 Sep 2015 05:49:13 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id l9si6433735lae.99.2015.09.13.05.49.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Sep 2015 05:49:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbcao8 with SMTP id ao8so56042567lbc.3 for ; Sun, 13 Sep 2015 05:49:13 -0700 (PDT) X-Received: by 10.152.18.194 with SMTP id y2mr8498116lad.88.1442148553715; Sun, 13 Sep 2015 05:49:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp702269lbq; Sun, 13 Sep 2015 05:49:12 -0700 (PDT) X-Received: by 10.107.136.213 with SMTP id s82mr16951908ioi.111.1442148552726; Sun, 13 Sep 2015 05:49:12 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m2si4940103igr.10.2015.09.13.05.49.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 13 Sep 2015 05:49:12 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:35762 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zb6iV-0003PW-VL for patch@linaro.org; Sun, 13 Sep 2015 08:49:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zb6de-0003k6-AL for qemu-devel@nongnu.org; Sun, 13 Sep 2015 08:44:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zb6db-0008Ph-7E for qemu-devel@nongnu.org; Sun, 13 Sep 2015 08:44:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zb6db-0008P0-0M for qemu-devel@nongnu.org; Sun, 13 Sep 2015 08:44:07 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id B45B0C0B919A for ; Sun, 13 Sep 2015 12:44:06 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8DChnOv024712; Sun, 13 Sep 2015 08:44:04 -0400 From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Sun, 13 Sep 2015 14:43:39 +0200 Message-Id: <1442148227-17343-6-git-send-email-lersek@redhat.com> In-Reply-To: <1442148227-17343-1-git-send-email-lersek@redhat.com> References: <55F5647C.6030901@redhat.com> <1442148227-17343-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gal Hammer , Paolo Bonzini , "Michael S. Tsirkin" , Igor Mammedov Subject: [Qemu-devel] [PATCH FYI 05/13] hw/acpi: add more flexible acpi_add_table() and build_header() variants X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lersek@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 acpi_add_table() and build_header() hardcode a number of traits that we'd like to pass in later on, on a table-by-table basis. These are: - The fw_cfg file name of the blob that contains the ACPI table. ACPI_BUILD_TABLE_FILE is hard-coded at the moment. - The OEM Table ID field. Due to the way the DataTableRegion() operator works, the OEM Table ID field is our only possibility to ensure a unique lookup for DataTableRegion(), since we don't populate (Signature, OEM ID) uniquely. However, currently OEM Table ID is directly derived from Signature. Unicity for DataTableRegion() requires making OEM Table ID independent. Expose the internals of the functions that we have now, so that callers can control the above traits. Cc: Paolo Bonzini Cc: Gal Hammer Cc: Igor Mammedov Cc: "Michael S. Tsirkin" Signed-off-by: Laszlo Ersek --- include/hw/acpi/aml-build.h | 6 +++++ hw/acpi/aml-build.c | 53 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 7518659..47d28c9 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -285,9 +285,15 @@ typedef struct BlobOffset BlobOffset; void build_header(GArray *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev); +void +build_header2(GArray *linker, GArray *table_data, const char *blob_name, + AcpiTableHeader *h, const char *sig, const char *oem_table_id, + int len, uint8_t rev); void *acpi_data_push(GArray *table_data, unsigned size); unsigned acpi_data_len(GArray *table); void acpi_add_table(GArray *table_offsets, GArray *table_data); +void acpi_add_table2(GArray *table_offsets, GArray *table_data, + const char *blob_name); void acpi_build_tables_init(AcpiBuildTables *tables); void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre); void diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 60c7c2e..03111a3 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1139,18 +1139,48 @@ void build_header(GArray *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev) { + char oem_table_id[8]; + + memcpy(oem_table_id, ACPI_BUILD_APPNAME4, 4); + memcpy(oem_table_id + 4, sig, 4); + build_header2(linker, table_data, ACPI_BUILD_TABLE_FILE, h, sig, + oem_table_id, len, rev); +} + +/* Fill in the SDT header of an ACPI table, and add a linker command to update + * its checksum. + * + * @linker: The linker/loader command file. This will receive the checksum + * update command. + * @table_data: The blob in which the ACPI table is embedded. + * @blob_name: The fw_cfg file name of the blob under which @table_data will be + * exposed later. + * @h: Pointer to the ACPI table header. Must reside within @table_data. + * @sig: Signature to place into the ACPI table header. Exactly four bytes will + * be copied. + * @oem_table_id: OEM Table ID to place into the ACPI table header. Exactly + * eight bytes will be copied. + * @len: Length of the ACPI table, including the SDT header. This determines + * the length field in the header itself, and the number of bytes the + * checksum will cover. + * @rev: Revision to place into the ACPI table header. + */ +void +build_header2(GArray *linker, GArray *table_data, const char *blob_name, + AcpiTableHeader *h, const char *sig, const char *oem_table_id, + int len, uint8_t rev) +{ memcpy(&h->signature, sig, 4); h->length = cpu_to_le32(len); h->revision = rev; memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6); - memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4); - memcpy(h->oem_table_id + 4, sig, 4); + memcpy(h->oem_table_id, oem_table_id, 8); h->oem_revision = cpu_to_le32(1); memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4); h->asl_compiler_revision = cpu_to_le32(1); h->checksum = 0; /* Checksum to be filled in by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, + bios_linker_loader_add_checksum(linker, blob_name, table_data->data, h, len, &h->checksum); } @@ -1171,8 +1201,23 @@ unsigned acpi_data_len(GArray *table) void acpi_add_table(GArray *table_offsets, GArray *table_data) { + acpi_add_table2(table_offsets, table_data, ACPI_BUILD_TABLE_FILE); +} + +/* Register an ACPI table to be referenced from the RSDT. + * + * @table_offsets: The array collecting the registrations, with element type + * BlobOffset. + * @table_data: The blob to which the caller will append the ACPI table, after + * this function returns. + * @blob_name: The fw_cfg file name of the blob under which @table_data will be + * exposed later. + */ +void acpi_add_table2(GArray *table_offsets, GArray *table_data, + const char *blob_name) +{ BlobOffset blob_offset = { - .blob_name = ACPI_BUILD_TABLE_FILE, + .blob_name = blob_name, .offset = cpu_to_le32(table_data->len) }; g_array_append_val(table_offsets, blob_offset);