From patchwork Fri Oct 4 15:52:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 175231 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp889713ill; Fri, 4 Oct 2019 08:57:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJ6HnXDTYUCvAbtPVkf9i6uWdS/1wbYBevRuaRZsnP4Gwl//rx9DWGTvXfzVdJX5vC+lti X-Received: by 2002:ae9:de84:: with SMTP id s126mr10590431qkf.245.1570204653473; Fri, 04 Oct 2019 08:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570204653; cv=none; d=google.com; s=arc-20160816; b=I7+f8Tm5IwSk6rA8Ynr3q38B3bOv0TKrIohkcvdOiK+GbcuBJXVs192aKIWpoXv8Nz w6548UD91rEsWb8RuSZRO8K7TQqUf/OB/u6Zw09mpmIcjOgcuAXhrkZYuQKSTYS0ERMS O2uGbl4rTKoRMztOLWGeZPvvVY6DVOWkQhabZHiPwbpxhbMwyh5miI1rDfTvEMDL5Fr/ EjjxxBdHzWUrdbRfQJXxpvcfMN03t+fKXZtCCbh9flIQyZuCFaTu8m0axIk4hx4rLa02 V+waaX5wPS5OYl0i9nmAN8ISPiwAH6VW5cqbtvinfLMB+4qpjrHCpekFnH40vp9Dy1mL rmVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:references :in-reply-to:message-id:date:subject:to:from; bh=8im/z8BRcG2cgBR/bymEYRODDEPl3un3kKapyjA7hHI=; b=Mo3d3aYyr55em/CGbN022On91PmJhqIsj3wAGR/HIZsfDM7nuqYjshE7+l0K0f+6C0 B//pBngAHg/0ZGcoPLRn13t/1fyid2WhTZL37NQ/Ml6TH/CfXJ7dPNsL2L/VxbeJz3it ghyk+15p8Y1H9JcpfQnlVEtSbAO8fxWPYjyzcFx60FeumI3e8OyRgc/vCk0ZALguvD9a 8XpkzKyoZXxlpNMI3qs2P3KlCYAjfjmzHo4hYjcUBAe4sfKj4IIqmDe5DC6i9CgUcRum 6bwLqRX4poSlyGtMk1SV02lmhx5nCgKHsBdFzTmF/RxZo09klVvjpf7ie4ObFijVOEwK CR5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v10si6103335qta.300.2019.10.04.08.57.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Oct 2019 08:57:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:50024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGPxU-00076e-JX for patch@linaro.org; Fri, 04 Oct 2019 11:57:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42236) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iGPuU-0006Ll-H9 for qemu-devel@nongnu.org; Fri, 04 Oct 2019 11:54:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iGPuS-0000Y2-JI for qemu-devel@nongnu.org; Fri, 04 Oct 2019 11:54:25 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44636 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iGPuO-0000QO-93; Fri, 04 Oct 2019 11:54:20 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id BB987C4B2364335D9FB1; Fri, 4 Oct 2019 23:54:12 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Fri, 4 Oct 2019 23:54:03 +0800 From: Shameer Kolothum To: , , , Subject: [PATCH 1/5] hw/arm: Align ACPI blob len to PAGE size Date: Fri, 4 Oct 2019 16:52:58 +0100 Message-ID: <20191004155302.4632-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20191004155302.4632-1-shameerali.kolothum.thodi@huawei.com> References: <20191004155302.4632-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 45.249.212.35 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, lersek@redhat.com, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If ACPI blob length modifications happens after the initial virt_acpi_build() call, and the changed blob length is within the PAGE size boundary, then the revised size is not seen by the firmware on Guest reboot. The is because in the virt_acpi_build_update() -> acpi_ram_update() -> qemu_ram_resize() path, qemu_ram_resize() uses ram_block size which is aligned to PAGE size and the "resize callback" to update the size seen by firmware is not getting invoked. Hence align ACPI blob sizes to PAGE boundary. Signed-off-by: Shameer Kolothum --- More details on this issue can be found here, https://patchwork.kernel.org/patch/11154757/ --- hw/arm/virt-acpi-build.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.17.1 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 4cd50175e0..074e0c858e 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -790,6 +790,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) GArray *table_offsets; unsigned dsdt, xsdt; GArray *tables_blob = tables->table_data; + GArray *cmd_blob = tables->linker->cmd_blob; MachineState *ms = MACHINE(vms); table_offsets = g_array_new(false, true /* clear */, @@ -854,6 +855,19 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) build_rsdp(tables->rsdp, tables->linker, &rsdp_data); } + /* + * Align the ACPI blob lengths to PAGE size so that on ACPI table + * regeneration, the length that firmware sees really gets updated + * through 'resize' callback in qemu_ram_resize() in the + * virt_acpi_build_update() -> acpi_ram_update() -> qemu_ram_resize() + * path. + */ + g_array_set_size(tables_blob, + TARGET_PAGE_ALIGN(acpi_data_len(tables_blob))); + g_array_set_size(tables->rsdp, + TARGET_PAGE_ALIGN(acpi_data_len(tables->rsdp))); + g_array_set_size(cmd_blob, + TARGET_PAGE_ALIGN(acpi_data_len(cmd_blob))); /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); }