From patchwork Sun Sep 13 12:43:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 53525 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id CC10722B26 for ; Sun, 13 Sep 2015 12:45:27 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf37519336lbb.3 for ; Sun, 13 Sep 2015 05:45:26 -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=JTLFMyFGueQA/yjpmmxbyL6qPDWaYagoHmMH1ZaiMcQ=; b=IvY8H3IzeHKXWoTnQQq+7OwXuAb3cEXEnAVknNMdTo6oIblAi2u3mrC7LxrYjHi+8s 30PC4vkl705jCWdNGETgrdP9fe2v0lg6wIC/l7Q/kPgXQJiW42hKBAH4tUJa2nH5F7Ba mwo4moWmmNXWyCz/OEvMVFidSccwqgsG+nfJMLkGizFhHblKgV+Rhd956Fuq1iSHjyNL eT1zMzR40AZ/rlXqvX3VWy/lhB4Yhcy+M6OQ8EvbnM8cjpLzUdhqee3BlIbZDOiLFVoD S4QneOCYmVtWpdc3ofP59C5fnUURAU8HW2m6JqrAO847Cb9kELY0xp3j/FktBGWYm+k5 8OKA== X-Gm-Message-State: ALoCoQkcWqd91O0q78h3gZuTFUfaxBfgYX8rzwc9signcNRJ9setqnC9XvYxZw6H4ptTwqJfvOfh X-Received: by 10.180.81.165 with SMTP id b5mr1830169wiy.1.1442148326750; Sun, 13 Sep 2015 05:45:26 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.232 with SMTP id 8ls465185lap.103.gmail; Sun, 13 Sep 2015 05:45:26 -0700 (PDT) X-Received: by 10.112.136.201 with SMTP id qc9mr8447250lbb.94.1442148326541; Sun, 13 Sep 2015 05:45:26 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id uz4si5882883lac.71.2015.09.13.05.45.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Sep 2015 05:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lahg1 with SMTP id g1so42239336lah.1 for ; Sun, 13 Sep 2015 05:45:26 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr8463104lac.73.1442148326418; Sun, 13 Sep 2015 05:45:26 -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 w3csp700797lbq; Sun, 13 Sep 2015 05:45:25 -0700 (PDT) X-Received: by 10.107.130.84 with SMTP id e81mr19136110iod.77.1442148325363; Sun, 13 Sep 2015 05:45:25 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h7si6024606ioi.142.2015.09.13.05.45.24 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 13 Sep 2015 05:45:25 -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]:35722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zb6eq-0005HE-3v for patch@linaro.org; Sun, 13 Sep 2015 08:45:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zb6de-0003jg-1O 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 1Zb6dZ-0008Lx-6o for qemu-devel@nongnu.org; Sun, 13 Sep 2015 08:44:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zb6dZ-0008LM-0F for qemu-devel@nongnu.org; Sun, 13 Sep 2015 08:44:05 -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 AA9413091D6; Sun, 13 Sep 2015 12:44:04 +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 t8DChnOu024712; Sun, 13 Sep 2015 08:44:01 -0400 From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Sun, 13 Sep 2015 14:43:38 +0200 Message-Id: <1442148227-17343-5-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" , Shannon Zhao , Igor Mammedov Subject: [Qemu-devel] [PATCH FYI 04/13] hw/acpi: allow RSDT entries to be relocated to various fw_cfg blobs 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.215.43 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 The build_rsdt() function can relocate RSDT entries only to ACPI tables that exist inside the same ACPI_BUILD_TABLE_FILE blob. In order to relax this limitation, change the element type of the "table_offsets" array from plain offset (always into ACPI_BUILD_TABLE_FILE) to a (pointed-to-blob, offset) pair. For compatibility with the current callers of acpi_add_table() and build_rsdt(), acpi_add_table() will hard-code ACPI_BUILD_TABLE_FILE as pointed-to-blob. However, the pointed-to-blob can now be determined when adding an ACPI table, case by case, not when building the RSDT. Cc: Paolo Bonzini Cc: Gal Hammer Cc: Igor Mammedov Cc: "Michael S. Tsirkin" Cc: Shannon Zhao Signed-off-by: Laszlo Ersek --- include/hw/acpi/aml-build.h | 6 ++++++ hw/acpi/aml-build.c | 16 ++++++++++------ hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 7d89c40..7518659 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -276,6 +276,12 @@ Aml *aml_varpackage(uint32_t num_elements); Aml *aml_touuid(const char *uuid); Aml *aml_unicode(const char *str); +struct BlobOffset { + const char *blob_name; /* no ownership; set from ACPI_BUILD_*_FILE */ + uint32_t offset; /* offset into blob named @blob_name */ +}; +typedef struct BlobOffset BlobOffset; + void build_header(GArray *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev); diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 2c7d59d..60c7c2e 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1171,8 +1171,11 @@ unsigned acpi_data_len(GArray *table) void acpi_add_table(GArray *table_offsets, GArray *table_data) { - uint32_t offset = cpu_to_le32(table_data->len); - g_array_append_val(table_offsets, offset); + BlobOffset blob_offset = { + .blob_name = ACPI_BUILD_TABLE_FILE, + .offset = cpu_to_le32(table_data->len) + }; + g_array_append_val(table_offsets, blob_offset); } void acpi_build_tables_init(AcpiBuildTables *tables) @@ -1199,16 +1202,17 @@ build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets) AcpiRsdtDescriptorRev1 *rsdt; size_t rsdt_len; int i; - const int table_data_len = (sizeof(uint32_t) * table_offsets->len); - rsdt_len = sizeof(*rsdt) + table_data_len; + rsdt_len = sizeof(*rsdt) + sizeof(uint32_t) * table_offsets->len; rsdt = acpi_data_push(table_data, rsdt_len); - memcpy(rsdt->table_offset_entry, table_offsets->data, table_data_len); for (i = 0; i < table_offsets->len; ++i) { + BlobOffset *blob_offset = (BlobOffset *)table_offsets->data + i; + + rsdt->table_offset_entry[i] = blob_offset->offset; /* rsdt->table_offset_entry to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, - ACPI_BUILD_TABLE_FILE, + blob_offset->blob_name, table_data, &rsdt->table_offset_entry[i], sizeof(uint32_t)); } diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index fcbb2d7..5725994 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -557,7 +557,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) virt_acpi_get_cpu_info(&cpuinfo); table_offsets = g_array_new(false, true /* clear */, - sizeof(uint32_t)); + sizeof(BlobOffset)); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE, 64, false /* high memory */); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 2cd8891..baebfcc 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1679,7 +1679,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) acpi_get_pci_info(&pci); table_offsets = g_array_new(false, true /* clear */, - sizeof(uint32_t)); + sizeof(BlobOffset)); ACPI_BUILD_DPRINTF("init ACPI tables\n"); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE,