From patchwork Fri Mar 8 01:32:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35E3B139A for ; Fri, 8 Mar 2019 01:34:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 150AA2F3E3 for ; Fri, 8 Mar 2019 01:34:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 090BC2F3E6; Fri, 8 Mar 2019 01:34:30 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9EA212F3E5 for ; Fri, 8 Mar 2019 01:34:29 +0000 (UTC) Received: from localhost ([127.0.0.1]:34445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24P5-0003DJ-3o for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:34:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24NY-0001tK-Tg for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:32:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24NX-0008F4-00 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:32:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24NR-00087U-61; Thu, 07 Mar 2019 20:32:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 181CB80467; Fri, 8 Mar 2019 01:32:42 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C860060BE5; Fri, 8 Mar 2019 01:32:36 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:05 +0100 Message-Id: <20190308013222.12524-2-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 08 Mar 2019 01:32:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 01/18] hw/arm/virt: Remove null-check in virt_build_smbios() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since commit 578f3c7b0835 ("arm: add fw_cfg to "virt" board", 2014-12-22), the machvirt_init() unconditionally creates the fw_cfg object. Later, commit c30e15658b1b ("smbios: implement smbios support for mach-virt", 2015-09-07) added a superfluous null-check on it. Remove this superfluous check. Fixes: c30e15658b1b Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Markus Armbruster --- v2: Corrected commit reference (Laszlo) --- hw/arm/virt.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index c7fb5348ae..bb7255a080 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1282,10 +1282,6 @@ static void virt_build_smbios(VirtMachineState *vms) size_t smbios_tables_len, smbios_anchor_len; const char *product = "QEMU Virtual Machine"; - if (!vms->fw_cfg) { - return; - } - if (kvm_enabled()) { product = "KVM Virtual Machine"; } From patchwork Fri Mar 8 01:32:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D99114DE for ; Fri, 8 Mar 2019 01:37:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48F062F3F1 for ; Fri, 8 Mar 2019 01:37:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D28F2F3F5; Fri, 8 Mar 2019 01:37:38 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D69392F3F1 for ; Fri, 8 Mar 2019 01:37:37 +0000 (UTC) Received: from localhost ([127.0.0.1]:34522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24S9-0006A0-4i for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:37:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Ns-000296-6f for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24No-00006F-8l for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42410) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Nd-0008JR-9B; Thu, 07 Mar 2019 20:32:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A313030718E7; Fri, 8 Mar 2019 01:32:55 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F70860BE5; Fri, 8 Mar 2019 01:32:42 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:06 +0100 Message-Id: <20190308013222.12524-3-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 08 Mar 2019 01:32:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 02/18] hw/i386: Remove unused include X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek Reviewed-by: Thomas Huth --- v2: Drop files that do use fw_cfg (Michael): - hw/i386/acpi-build.c - hw/i386/pc.c --- hw/acpi/piix4.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index 8fd25a5926..7b98121070 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -28,7 +28,6 @@ #include "sysemu/sysemu.h" #include "qapi/error.h" #include "qemu/range.h" -#include "hw/nvram/fw_cfg.h" #include "exec/address-spaces.h" #include "hw/acpi/piix4.h" #include "hw/acpi/pcihp.h" From patchwork Fri Mar 8 01:32:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A0C6914DE for ; Fri, 8 Mar 2019 01:40:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A6F52EEF2 for ; Fri, 8 Mar 2019 01:40:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E5012EF55; Fri, 8 Mar 2019 01:40:19 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1BFA02EEF2 for ; Fri, 8 Mar 2019 01:40:19 +0000 (UTC) Received: from localhost ([127.0.0.1]:34581 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Uk-0000Fk-4j for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:40:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24O0-0002EZ-B4 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24Ny-0000If-41 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42438) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Ns-0008WN-1j; Thu, 07 Mar 2019 20:33:12 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F9293089ED3; Fri, 8 Mar 2019 01:33:06 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 942D160BE5; Fri, 8 Mar 2019 01:32:55 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:07 +0100 Message-Id: <20190308013222.12524-4-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 08 Mar 2019 01:33:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 03/18] cutils: Add qemu_strdup_hexlify() and qemu_strdup_unhexlify() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add two helpers: one to represent a binary data as a string of hexadecimal values, and one to restore a such string into its original binary data. Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/cutils.h | 33 ++++++++++++++++++++++++++ util/cutils.c | 55 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index d2dad3057c..375a5508b0 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -171,6 +171,39 @@ bool test_buffer_is_zero_next_accel(void); int uleb128_encode_small(uint8_t *out, uint32_t n); int uleb128_decode_small(const uint8_t *in, uint32_t *n); +/** + * qemu_strdup_hexlify: + * + * Encode a sequence of binary data into its hexadecimal stringified + * representation. + * + * @ptr: Buffer to hexlify + * @size: Length of the buffer + * + * Use qemu_strdup_unhexlify() to convert the hex string to original data. + * + * Returns: A newly allocated, zero-terminated hex encoded string representing + * the data. The returned string must be freed with g_free(). + */ +gchar *qemu_strdup_hexlify(gconstpointer ptr, gsize size); + +/** + * qemu_strdup_unhexlify: + * + * Decode a sequence of hexadecimal encoded text into binary data. + * + * @hex_string: String to unhexlify + * @out_size: if not NULL: gsize to be written with the data length + * + * This function is the opposite of qemu_strdup_hexlify(). + * + * Returns: A newly allocated buffer containing the binary data that text + * represents. The returned buffer must be freed with g_free(). + * Note that the returned binary data is not necessarily zero-terminated, + * so it should not be used as a character string. + */ +gpointer qemu_strdup_unhexlify(const gchar *hex_string, gsize *out_size); + /** * qemu_pstrcmp0: * @str1: a non-NULL pointer to a C string (*str1 can be NULL) diff --git a/util/cutils.c b/util/cutils.c index e098debdc0..bf324c0d8b 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -779,6 +779,61 @@ int uleb128_decode_small(const uint8_t *in, uint32_t *n) } } +static guchar hexval(const gchar v) +{ + switch (v) { + case '0' ... '9': + return v - '0'; + case 'A' ... 'F': + return v - 'A' + 10; + case 'a' ... 'f': + return v - 'a' + 10; + default: + return 0; + } +} + +gchar *qemu_strdup_hexlify(gconstpointer ptr, gsize len) +{ + guchar *data = (guchar *)ptr; + gchar *hex_string; + + if (!ptr || !len) { + return g_strdup(""); + } + + hex_string = g_malloc(2 * len + 1); + for (gsize i = 0; i < len; i++) { + g_snprintf(&hex_string[2 * i], 3, "%02x", data[i]); + } + + return hex_string; +} + +gpointer qemu_strdup_unhexlify(const gchar *hex_string, gsize *out_size) +{ + size_t size = 0; + guchar *data = NULL; + + if (hex_string) { + size = strlen(hex_string) / 2; + if (size) { + size_t i; + + data = g_new(guchar, size + 1); + for (i = 0; i < size; i++) { + data[i] = hexval(*hex_string++) << 4; + data[i] |= hexval(*hex_string++); + } + data[i] = '\0'; + } + } + if (out_size) { + *out_size = size; + } + return data; +} + /* * helper to parse debug environment variables */ From patchwork Fri Mar 8 01:32:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844063 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1962D139A for ; Fri, 8 Mar 2019 01:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 024BA2F0EF for ; Fri, 8 Mar 2019 01:35:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA2122F3E6; Fri, 8 Mar 2019 01:35:22 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 16F362F0EF for ; Fri, 8 Mar 2019 01:35:22 +0000 (UTC) Received: from localhost ([127.0.0.1]:34437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Px-0002dq-7h for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:35:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24O9-0002Je-9f for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24O7-0000bs-G1 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35282) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24O2-0000Of-4c; Thu, 07 Mar 2019 20:33:23 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4638F59466; Fri, 8 Mar 2019 01:33:21 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8123760BE5; Fri, 8 Mar 2019 01:33:06 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:08 +0100 Message-Id: <20190308013222.12524-5-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 08 Mar 2019 01:33:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 04/18] hw/nvram/fw_cfg: Add trace events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add fw_cfg_arch_key_name() to be able to resolve architecture specific keys. All architectures do have specific keys, thus implement this function. Architectures that don't use the fw_cfg device don't have to implement this function, however to ease the Makefile rules and satisfy the linking, we provide a stub. Now than we can resolve keys into "well know numeric", add trace events to display more information when keys are added (and dump the key content when possible). Signed-off-by: Philippe Mathieu-Daudé --- v2: Added fw_cfg_arch_key_name() -> reset R-b --- MAINTAINERS | 1 + hw/i386/pc.c | 21 +++++++++++++ hw/nvram/fw_cfg.c | 63 ++++++++++++++++++++++++++++++++++++++- hw/nvram/trace-events | 7 ++++- hw/ppc/Makefile.objs | 2 +- hw/ppc/fw_cfg.c | 31 +++++++++++++++++++ hw/sparc/sun4m.c | 19 ++++++++++++ hw/sparc64/sun4u.c | 19 ++++++++++++ include/hw/nvram/fw_cfg.h | 11 +++++++ stubs/Makefile.objs | 1 + stubs/fw_cfg.c | 19 ++++++++++++ 11 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 hw/ppc/fw_cfg.c create mode 100644 stubs/fw_cfg.c diff --git a/MAINTAINERS b/MAINTAINERS index 074ad46d47..306fc2aefa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1659,6 +1659,7 @@ R: Gerd Hoffmann S: Supported F: docs/specs/fw_cfg.txt F: hw/nvram/fw_cfg.c +F: stubs/fw_cfg.c F: include/hw/nvram/fw_cfg.h F: include/standard-headers/linux/qemu_fw_cfg.h F: tests/libqos/fw_cfg.c diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 42128183e9..0848cdc18f 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -349,6 +349,27 @@ GlobalProperty pc_compat_1_4[] = { }; const size_t pc_compat_1_4_len = G_N_ELEMENTS(pc_compat_1_4); +const char *fw_cfg_arch_key_name(uint16_t key) +{ + static const struct { + uint16_t key; + const char *name; + } fw_cfg_arch_wellknown_keys[] = { + {FW_CFG_ACPI_TABLES, "acpi_tables"}, + {FW_CFG_SMBIOS_ENTRIES, "smbios_entries"}, + {FW_CFG_IRQ0_OVERRIDE, "irq0_override"}, + {FW_CFG_E820_TABLE, "e820_tables"}, + {FW_CFG_HPET, "hpet"}, + }; + + for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) { + if (fw_cfg_arch_wellknown_keys[i].key == key) { + return fw_cfg_arch_wellknown_keys[i].name; + } + } + return NULL; +} + void gsi_handler(void *opaque, int n, int level) { GSIState *s = opaque; diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 7fdf04adc9..684c2cf00a 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -60,6 +60,62 @@ struct FWCfgEntry { FWCfgWriteCallback write_cb; }; +/** + * key_name: + * + * @key: The uint16 selector key. + * + * Returns: The stringified name if the selector refers to a well-known + * numerically defined item, or NULL on key lookup failure. + */ +static const char *key_name(uint16_t key) +{ + static const char *fw_cfg_wellknown_keys[FW_CFG_FILE_FIRST] = { + [FW_CFG_SIGNATURE] = "signature", + [FW_CFG_ID] = "id", + [FW_CFG_UUID] = "uuid", + [FW_CFG_RAM_SIZE] = "ram_size", + [FW_CFG_NOGRAPHIC] = "nographic", + [FW_CFG_NB_CPUS] = "nb_cpus", + [FW_CFG_MACHINE_ID] = "machine_id", + [FW_CFG_KERNEL_ADDR] = "kernel_addr", + [FW_CFG_KERNEL_SIZE] = "kernel_size", + [FW_CFG_KERNEL_CMDLINE] = "kernel_cmdline", + [FW_CFG_INITRD_ADDR] = "initrd_addr", + [FW_CFG_INITRD_SIZE] = "initdr_size", + [FW_CFG_BOOT_DEVICE] = "boot_device", + [FW_CFG_NUMA] = "numa", + [FW_CFG_BOOT_MENU] = "boot_menu", + [FW_CFG_MAX_CPUS] = "max_cpus", + [FW_CFG_KERNEL_ENTRY] = "kernel_entry", + [FW_CFG_KERNEL_DATA] = "kernel_data", + [FW_CFG_INITRD_DATA] = "initrd_data", + [FW_CFG_CMDLINE_ADDR] = "cmdline_addr", + [FW_CFG_CMDLINE_SIZE] = "cmdline_size", + [FW_CFG_CMDLINE_DATA] = "cmdline_data", + [FW_CFG_SETUP_ADDR] = "setup_addr", + [FW_CFG_SETUP_SIZE] = "setup_size", + [FW_CFG_SETUP_DATA] = "setup_data", + [FW_CFG_FILE_DIR] = "file_dir", + }; + + if (key & FW_CFG_ARCH_LOCAL) { + return fw_cfg_arch_key_name(key); + } + if (key < FW_CFG_FILE_FIRST) { + return fw_cfg_wellknown_keys[key]; + } + + return NULL; +} + +static inline const char *trace_key_name(uint16_t key) +{ + const char *name = key_name(key); + + return name ? name : "unknown"; +} + #define JPG_FILE 0 #define BMP_FILE 1 @@ -234,7 +290,7 @@ static int fw_cfg_select(FWCfgState *s, uint16_t key) } } - trace_fw_cfg_select(s, key, ret); + trace_fw_cfg_select(s, key, trace_key_name(key), ret); return ret; } @@ -617,6 +673,7 @@ static void *fw_cfg_modify_bytes_read(FWCfgState *s, uint16_t key, void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len) { + trace_fw_cfg_add_bytes(key, trace_key_name(key), len); fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, true); } @@ -624,6 +681,7 @@ void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value) { size_t sz = strlen(value) + 1; + trace_fw_cfg_add_string(key, trace_key_name(key), value); fw_cfg_add_bytes(s, key, g_memdup(value, sz), sz); } @@ -633,6 +691,7 @@ void fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value) copy = g_malloc(sizeof(value)); *copy = cpu_to_le16(value); + trace_fw_cfg_add_i16(key, trace_key_name(key), value); fw_cfg_add_bytes(s, key, copy, sizeof(value)); } @@ -652,6 +711,7 @@ void fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value) copy = g_malloc(sizeof(value)); *copy = cpu_to_le32(value); + trace_fw_cfg_add_i32(key, trace_key_name(key), value); fw_cfg_add_bytes(s, key, copy, sizeof(value)); } @@ -661,6 +721,7 @@ void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value) copy = g_malloc(sizeof(value)); *copy = cpu_to_le64(value); + trace_fw_cfg_add_i64(key, trace_key_name(key), value); fw_cfg_add_bytes(s, key, copy, sizeof(value)); } diff --git a/hw/nvram/trace-events b/hw/nvram/trace-events index 6b55ba7a09..4d8fa992fe 100644 --- a/hw/nvram/trace-events +++ b/hw/nvram/trace-events @@ -5,6 +5,11 @@ nvram_read(uint32_t addr, uint32_t ret) "read addr %d: 0x%02x" nvram_write(uint32_t addr, uint32_t old, uint32_t val) "write addr %d: 0x%02x -> 0x%02x" # hw/nvram/fw_cfg.c -fw_cfg_select(void *s, uint16_t key, int ret) "%p key %d = %d" +fw_cfg_select(void *s, uint16_t key_value, const char *key_name, int ret) "%p key 0x%04" PRIx16 " '%s', ret: %d" fw_cfg_read(void *s, uint64_t ret) "%p = 0x%"PRIx64 +fw_cfg_add_bytes(uint16_t key_value, const char *key_name, size_t len) "key 0x%04" PRIx16 " '%s', %zu bytes" fw_cfg_add_file(void *s, int index, char *name, size_t len) "%p #%d: %s (%zd bytes)" +fw_cfg_add_string(uint16_t key_value, const char *key_name, const char *value) "key 0x%04" PRIx16 " '%s', value '%s'" +fw_cfg_add_i16(uint16_t key_value, const char *key_name, uint16_t value) "key 0x%04" PRIx16 " '%s', value 0x%" PRIx16 +fw_cfg_add_i32(uint16_t key_value, const char *key_name, uint32_t value) "key 0x%04" PRIx16 " '%s', value 0x%" PRIx32 +fw_cfg_add_i64(uint16_t key_value, const char *key_name, uint64_t value) "key 0x%04" PRIx16 " '%s', value 0x%" PRIx64 diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs index 1111b218a0..ae94098155 100644 --- a/hw/ppc/Makefile.objs +++ b/hw/ppc/Makefile.objs @@ -1,5 +1,5 @@ # shared objects -obj-y += ppc.o ppc_booke.o fdt.o +obj-y += ppc.o ppc_booke.o fdt.o fw_cfg.o # IBM pSeries (sPAPR) obj-$(CONFIG_PSERIES) += spapr.o spapr_caps.o spapr_vio.o spapr_events.o obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o diff --git a/hw/ppc/fw_cfg.c b/hw/ppc/fw_cfg.c new file mode 100644 index 0000000000..0e7616b78a --- /dev/null +++ b/hw/ppc/fw_cfg.c @@ -0,0 +1,31 @@ +#include "qemu/osdep.h" +#include "hw/ppc/ppc.h" +#include "hw/nvram/fw_cfg.h" + +const char *fw_cfg_arch_key_name(uint16_t key) +{ + static const struct { + uint16_t key; + const char *name; + } fw_cfg_arch_wellknown_keys[] = { + {FW_CFG_PPC_WIDTH, "width"}, + {FW_CFG_PPC_HEIGHT, "height"}, + {FW_CFG_PPC_DEPTH, "depth"}, + {FW_CFG_PPC_TBFREQ, "tbfreq"}, + {FW_CFG_PPC_CLOCKFREQ, "clockfreq"}, + {FW_CFG_PPC_IS_KVM, "is_kvm"}, + {FW_CFG_PPC_KVM_HC, "kvm_hc"}, + {FW_CFG_PPC_KVM_PID, "pid"}, + {FW_CFG_PPC_NVRAM_ADDR, "nvram_addr"}, + {FW_CFG_PPC_BUSFREQ, "busfreq"}, + {FW_CFG_PPC_NVRAM_FLAT, "nvram_flat"}, + {FW_CFG_PPC_VIACONFIG, "viaconfig"}, + }; + + for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) { + if (fw_cfg_arch_wellknown_keys[i].key == key) { + return fw_cfg_arch_wellknown_keys[i].name; + } + } + return NULL; +} diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index ca1e3825d5..49251d62b3 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -97,6 +97,25 @@ struct sun4m_hwdef { uint8_t nvram_machine_id; }; +const char *fw_cfg_arch_key_name(uint16_t key) +{ + static const struct { + uint16_t key; + const char *name; + } fw_cfg_arch_wellknown_keys[] = { + {FW_CFG_SUN4M_DEPTH, "depth"}, + {FW_CFG_SUN4M_WIDTH, "width"}, + {FW_CFG_SUN4M_HEIGHT, "height"}, + }; + + for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) { + if (fw_cfg_arch_wellknown_keys[i].key == key) { + return fw_cfg_arch_wellknown_keys[i].name; + } + } + return NULL; +} + static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) { diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 399f2d73c8..4230b17b87 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -91,6 +91,25 @@ typedef struct EbusState { #define TYPE_EBUS "ebus" #define EBUS(obj) OBJECT_CHECK(EbusState, (obj), TYPE_EBUS) +const char *fw_cfg_arch_key_name(uint16_t key) +{ + static const struct { + uint16_t key; + const char *name; + } fw_cfg_arch_wellknown_keys[] = { + {FW_CFG_SPARC64_WIDTH, "width"}, + {FW_CFG_SPARC64_HEIGHT, "height"}, + {FW_CFG_SPARC64_DEPTH, "depth"}, + }; + + for (size_t i = 0; i < ARRAY_SIZE(fw_cfg_arch_wellknown_keys); i++) { + if (fw_cfg_arch_wellknown_keys[i].key == key) { + return fw_cfg_arch_wellknown_keys[i].name; + } + } + return NULL; +} + static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) { diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index f5a6895a74..828ad9dedc 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -226,4 +226,15 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr, FWCfgState *fw_cfg_find(void); bool fw_cfg_dma_enabled(void *opaque); +/** + * fw_cfg_arch_key_name: + * + * @key: The uint16 selector key. + * + * Returns: The stringified architecture-specific name if the selector + * refers to a well-known numerically defined item, or NULL on + * key lookup failure. + */ +const char *fw_cfg_arch_key_name(uint16_t key); + #endif diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 269dfa5832..73452ad265 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -39,3 +39,4 @@ stub-obj-y += xen-hvm.o stub-obj-y += pci-host-piix.o stub-obj-y += ram-block.o stub-obj-y += ramfb.o +stub-obj-y += fw_cfg.o diff --git a/stubs/fw_cfg.c b/stubs/fw_cfg.c new file mode 100644 index 0000000000..2b886c94d6 --- /dev/null +++ b/stubs/fw_cfg.c @@ -0,0 +1,19 @@ +/* + * fw_cfg stubs + * + * Copyright (c) 2019 Red Hat, Inc. + * + * Author: + * Philippe Mathieu-Daudé + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/nvram/fw_cfg.h" + +const char *fw_cfg_arch_key_name(uint16_t key) +{ + return NULL; +} From patchwork Fri Mar 8 01:32:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C364139A for ; Fri, 8 Mar 2019 01:39:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1394F2D93F for ; Fri, 8 Mar 2019 01:39:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02FE42D947; Fri, 8 Mar 2019 01:39:12 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC3662D93F for ; Fri, 8 Mar 2019 01:39:12 +0000 (UTC) Received: from localhost ([127.0.0.1]:34544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Tf-0007cR-UQ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:39:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24OB-0002Ln-Sb for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24OB-0000jB-4v for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56670) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24O7-0000b9-Oh; Thu, 07 Mar 2019 20:33:29 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E28B03099FCB; Fri, 8 Mar 2019 01:33:26 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C024760BE5; Fri, 8 Mar 2019 01:33:21 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:09 +0100 Message-Id: <20190308013222.12524-6-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 08 Mar 2019 01:33:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 05/18] hw/nvram/fw_cfg: Use the ldst API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The load/store API eases code review. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 684c2cf00a..8eb76a382c 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -141,7 +141,7 @@ static char *read_splashfile(char *filename, gsize *file_sizep, } /* check magic ID */ - filehead = ((content[0] & 0xff) + (content[1] << 8)) & 0xffff; + filehead = lduw_le_p(content); if (filehead == 0xd8ff) { file_type = JPG_FILE; } else if (filehead == 0x4d42) { @@ -152,7 +152,7 @@ static char *read_splashfile(char *filename, gsize *file_sizep, /* check BMP bpp */ if (file_type == BMP_FILE) { - bmp_bpp = (content[28] + (content[29] << 8)) & 0xffff; + bmp_bpp = lduw_le_p(&content[28]); if (bmp_bpp != 24) { goto error; } From patchwork Fri Mar 8 01:32:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BACD0139A for ; Fri, 8 Mar 2019 01:38:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4CCD2F3F5 for ; Fri, 8 Mar 2019 01:38:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 975222F3FA; Fri, 8 Mar 2019 01:38:49 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 426362F3F5 for ; Fri, 8 Mar 2019 01:38:49 +0000 (UTC) Received: from localhost ([127.0.0.1]:34538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24TI-0007Am-GH for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:38:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24OV-0002cK-Ki for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24OU-000199-Nu for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5916) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24OM-0000vD-F4; Thu, 07 Mar 2019 20:33:43 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9788DC053FDA; Fri, 8 Mar 2019 01:33:36 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 685E660BE5; Fri, 8 Mar 2019 01:33:27 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:10 +0100 Message-Id: <20190308013222.12524-7-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 08 Mar 2019 01:33:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/18] hw/nvram/fw_cfg: Remove the unnecessary boot_splash_filedata_size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The 'boot_splash_filedata_size' was introduced as a global variable in 3d3b8303c6f. This variable is used as a 'size' argument to the fw_cfg_add_file(). This function has an interface contract with his 'data' argument, but there is no such contract for 'size' (this is not a referenced pointer). We can simply remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 5 ++--- include/sysemu/sysemu.h | 1 - vl.c | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 8eb76a382c..b2dc0a80cb 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -217,15 +217,14 @@ static void fw_cfg_bootsplash(FWCfgState *s) } g_free(boot_splash_filedata); boot_splash_filedata = (uint8_t *)file_data; - boot_splash_filedata_size = file_size; /* insert data */ if (file_type == JPG_FILE) { fw_cfg_add_file(s, "bootsplash.jpg", - boot_splash_filedata, boot_splash_filedata_size); + boot_splash_filedata, file_size); } else { fw_cfg_add_file(s, "bootsplash.bmp", - boot_splash_filedata, boot_splash_filedata_size); + boot_splash_filedata, file_size); } g_free(filename); } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 89604a8328..6065d9e420 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -110,7 +110,6 @@ extern int old_param; extern int boot_menu; extern bool boot_strict; extern uint8_t *boot_splash_filedata; -extern size_t boot_splash_filedata_size; extern bool enable_mlock; extern bool enable_cpu_pm; extern QEMUClockType rtc_clock; diff --git a/vl.c b/vl.c index 4c5cc0d8ad..fad6fec38c 100644 --- a/vl.c +++ b/vl.c @@ -188,7 +188,6 @@ const char *prom_envs[MAX_PROM_ENVS]; int boot_menu; bool boot_strict; uint8_t *boot_splash_filedata; -size_t boot_splash_filedata_size; bool wakeup_suspend_enabled; int icount_align_option; From patchwork Fri Mar 8 01:32:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C01DD139A for ; Fri, 8 Mar 2019 01:36:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7BD02F3F1 for ; Fri, 8 Mar 2019 01:36:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BDE42F3F5; Fri, 8 Mar 2019 01:36:22 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A8AC2F3F1 for ; Fri, 8 Mar 2019 01:36:22 +0000 (UTC) Received: from localhost ([127.0.0.1]:34502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Qv-00054U-Gh for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:36:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24OX-0002e9-9m for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24OV-0001BC-TD for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:33:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24OT-00013u-F8; Thu, 07 Mar 2019 20:33:49 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E521307E079; Fri, 8 Mar 2019 01:33:46 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 157E060BE5; Fri, 8 Mar 2019 01:33:36 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:11 +0100 Message-Id: <20190308013222.12524-8-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 08 Mar 2019 01:33:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 07/18] hw/nvram/fw_cfg: Add fw_cfg_common_unrealize() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Back in abe147e0ce4 when fw_cfg_add_file() was introduced, there was no QOM design, object where not created and released at runtime. Later 38f3adc34d finished the QOM conversion of the fw_cfg device, adding the fw_cfg_common_realize() method. The time has come to add the equivalent destructor and release the memory allocated for 'files'. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/nvram/fw_cfg.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index b2dc0a80cb..0fb020edce 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -959,6 +959,13 @@ static void fw_cfg_common_realize(DeviceState *dev, Error **errp) qemu_add_machine_init_done_notifier(&s->machine_ready); } +static void fw_cfg_common_unrealize(DeviceState *dev, Error **errp) +{ + FWCfgState *s = FW_CFG(dev); + + g_free(s->files); +} + FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, AddressSpace *dma_as) { @@ -1127,6 +1134,7 @@ static void fw_cfg_io_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = fw_cfg_io_realize; + dc->unrealize = fw_cfg_common_unrealize; dc->props = fw_cfg_io_properties; } @@ -1190,6 +1198,7 @@ static void fw_cfg_mem_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = fw_cfg_mem_realize; + dc->unrealize = fw_cfg_common_unrealize; dc->props = fw_cfg_mem_properties; } From patchwork Fri Mar 8 01:32:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6A84B14DE for ; Fri, 8 Mar 2019 01:43:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5302C2EFD5 for ; Fri, 8 Mar 2019 01:43:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46B1A2F076; Fri, 8 Mar 2019 01:43:30 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E0F4E2EFD5 for ; Fri, 8 Mar 2019 01:43:29 +0000 (UTC) Received: from localhost ([127.0.0.1]:34653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Xp-00035i-72 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:43:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Ol-0002sX-Op for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:34:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24Oj-0001S5-PG for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:34:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Oa-0001Fk-A3; Thu, 07 Mar 2019 20:33:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1732287637; Fri, 8 Mar 2019 01:33:54 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D680260BE5; Fri, 8 Mar 2019 01:33:46 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:12 +0100 Message-Id: <20190308013222.12524-9-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 08 Mar 2019 01:33:54 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 08/18] hw/nvram/fw_cfg: Move fw_cfg_file_slots_allocate() to common_realize() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Each implementation (I/O and MEM) calls fw_cfg_file_slots_allocate() then fw_cfg_common_realize(). Simplify by moving the fw_cfg_file_slots_allocate() call into fw_cfg_common_realize() where it belongs. Signed-off-by: Philippe Mathieu-Daudé --- hw/nvram/fw_cfg.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 0fb020edce..ca58d279a4 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -929,19 +929,26 @@ static void fw_cfg_machine_ready(struct Notifier *n, void *data) qemu_register_reset(fw_cfg_machine_reset, s); } - +static void fw_cfg_file_slots_allocate(FWCfgState *s, Error **errp); static void fw_cfg_common_realize(DeviceState *dev, Error **errp) { FWCfgState *s = FW_CFG(dev); MachineState *machine = MACHINE(qdev_get_machine()); uint32_t version = FW_CFG_VERSION; + Error *local_err = NULL; if (!fw_cfg_find()) { error_setg(errp, "at most one %s device is permitted", TYPE_FW_CFG); return; } + fw_cfg_file_slots_allocate(s, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, &qemu_uuid, 16); fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)!machine->enable_graphics); @@ -1108,7 +1115,7 @@ static void fw_cfg_io_realize(DeviceState *dev, Error **errp) FWCfgIoState *s = FW_CFG_IO(dev); Error *local_err = NULL; - fw_cfg_file_slots_allocate(FW_CFG(s), &local_err); + fw_cfg_common_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -1125,8 +1132,6 @@ static void fw_cfg_io_realize(DeviceState *dev, Error **errp) &fw_cfg_dma_mem_ops, FW_CFG(s), "fwcfg.dma", sizeof(dma_addr_t)); } - - fw_cfg_common_realize(dev, errp); } static void fw_cfg_io_class_init(ObjectClass *klass, void *data) @@ -1162,7 +1167,7 @@ static void fw_cfg_mem_realize(DeviceState *dev, Error **errp) const MemoryRegionOps *data_ops = &fw_cfg_data_mem_ops; Error *local_err = NULL; - fw_cfg_file_slots_allocate(FW_CFG(s), &local_err); + fw_cfg_common_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -1189,8 +1194,6 @@ static void fw_cfg_mem_realize(DeviceState *dev, Error **errp) sizeof(dma_addr_t)); sysbus_init_mmio(sbd, &FW_CFG(s)->dma_iomem); } - - fw_cfg_common_realize(dev, errp); } static void fw_cfg_mem_class_init(ObjectClass *klass, void *data) From patchwork Fri Mar 8 01:32:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4372B14DE for ; Fri, 8 Mar 2019 01:39:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 309BC2D93F for ; Fri, 8 Mar 2019 01:39:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 246922D947; Fri, 8 Mar 2019 01:39:22 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D50902D93F for ; Fri, 8 Mar 2019 01:39:21 +0000 (UTC) Received: from localhost ([127.0.0.1]:34536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Tp-0006Uo-2Y for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:39:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Ox-00034W-1Y for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:34:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24Ov-0001gW-4U for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:34:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Or-0001Z9-7k; Thu, 07 Mar 2019 20:34:13 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4F9C3082E51; Fri, 8 Mar 2019 01:34:10 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A27DC60BE5; Fri, 8 Mar 2019 01:33:54 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:13 +0100 Message-Id: <20190308013222.12524-10-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 08 Mar 2019 01:34:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 09/18] hw/nvram/fw_cfg: Free file_slots in common_unrealize() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Called by fw_cfg_common_realize(), fw_cfg_file_slots_allocate() allocates various buffers. Free them in fw_cfg_common_unrealize(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Laszlo Ersek --- hw/nvram/fw_cfg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index ca58d279a4..b73a591eff 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -971,6 +971,10 @@ static void fw_cfg_common_unrealize(DeviceState *dev, Error **errp) FWCfgState *s = FW_CFG(dev); g_free(s->files); + + g_free(s->entries[0]); + g_free(s->entries[1]); + g_free(s->entry_order); } FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, From patchwork Fri Mar 8 01:32:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C8FA139A for ; Fri, 8 Mar 2019 01:42:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 493E12EFB9 for ; Fri, 8 Mar 2019 01:42:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C9482EFD5; Fri, 8 Mar 2019 01:42:24 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DD6532EFB9 for ; Fri, 8 Mar 2019 01:42:23 +0000 (UTC) Received: from localhost ([127.0.0.1]:34642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Wl-00029E-6q for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:42:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24P7-0003ES-5S for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:34:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24P4-0001nu-Vh for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:34:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33796) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24P0-0001i9-O6; Thu, 07 Mar 2019 20:34:22 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A6A04C0578F8; Fri, 8 Mar 2019 01:34:18 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B83E6B473; Fri, 8 Mar 2019 01:34:11 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:14 +0100 Message-Id: <20190308013222.12524-11-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 08 Mar 2019 01:34:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 10/18] hw/nvram/fw_cfg: Add reboot_timeout to FWCfgState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Due to the contract interface of fw_cfg_add_file(), the 'reboot_timeout' data has to be valid for the lifetime of the FwCfg object. For this reason it is copied on the heap with memdup(). The object state, 'FWCfgState', is also meant to be valid during the lifetime of the object. Move the 'reboot_timeout' in FWCfgState to achieve the same purpose. Doing so we avoid a memory leak. Signed-off-by: Philippe Mathieu-Daudé --- hw/nvram/fw_cfg.c | 4 +++- include/hw/nvram/fw_cfg.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index b73a591eff..182d27f59a 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -250,7 +250,9 @@ static void fw_cfg_reboot(FWCfgState *s) } } - fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_val, 4), 4); + s->reboot_timeout = rt_val; + fw_cfg_add_file(s, "etc/boot-fail-wait", + &s->reboot_timeout, sizeof(s->reboot_timeout)); } static void fw_cfg_write(FWCfgState *s, uint8_t value) diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 828ad9dedc..99f6fafcaa 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -53,6 +53,8 @@ struct FWCfgState { dma_addr_t dma_addr; AddressSpace *dma_as; MemoryRegion dma_iomem; + + uint32_t reboot_timeout; }; struct FWCfgIoState { From patchwork Fri Mar 8 01:32:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20A611515 for ; Fri, 8 Mar 2019 01:45:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B3BF2F2A4 for ; Fri, 8 Mar 2019 01:45:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFFDA2F2CD; Fri, 8 Mar 2019 01:45:12 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 97D6A2F2A4 for ; Fri, 8 Mar 2019 01:45:12 +0000 (UTC) Received: from localhost ([127.0.0.1]:34714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24ZT-0004gp-Tb for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:45:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24PL-0003Sy-Vj for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:34:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24PL-0002G5-1W for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:34:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60410) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24PH-000297-U4; Thu, 07 Mar 2019 20:34:40 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0FD593092672; Fri, 8 Mar 2019 01:34:39 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 231C060BE5; Fri, 8 Mar 2019 01:34:18 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:15 +0100 Message-Id: <20190308013222.12524-12-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 08 Mar 2019 01:34:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 11/18] hw/nvram/fw_cfg: Add boot_splash.time_le16 to FWCfgState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Similar to the previous commit, use the FWCfgState lifetime state to hold the 'bst_le16' variable content (renaned as time_le16). Doing so we avoid a memory leak. Signed-off-by: Philippe Mathieu-Daudé --- hw/nvram/fw_cfg.c | 6 +++--- include/hw/nvram/fw_cfg.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 182d27f59a..3ac6687a04 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -187,7 +187,6 @@ static void fw_cfg_bootsplash(FWCfgState *s) /* insert splash time if user configurated */ if (boot_splash_time) { int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1); - uint16_t bst_le16; /* validate the input */ if (bst_val < 0 || bst_val > 0xffff) { @@ -196,9 +195,10 @@ static void fw_cfg_bootsplash(FWCfgState *s) exit(1); } /* use little endian format */ - bst_le16 = cpu_to_le16(bst_val); + s->boot_splash.time_le16 = cpu_to_le16(bst_val); fw_cfg_add_file(s, "etc/boot-menu-wait", - g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16); + &s->boot_splash.time_le16, + sizeof(s->boot_splash.time_le16)); } /* insert splash file if user configurated */ diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 99f6fafcaa..fcb771186c 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -55,6 +55,9 @@ struct FWCfgState { MemoryRegion dma_iomem; uint32_t reboot_timeout; + struct { + uint16_t time_le16; + } boot_splash; }; struct FWCfgIoState { From patchwork Fri Mar 8 01:32:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32FA1139A for ; Fri, 8 Mar 2019 01:42:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D88F2EFB9 for ; Fri, 8 Mar 2019 01:42:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 109A82EFD5; Fri, 8 Mar 2019 01:42:07 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A02FC2EFB9 for ; Fri, 8 Mar 2019 01:42:06 +0000 (UTC) Received: from localhost ([127.0.0.1]:34598 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24WT-0000jh-RB for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:42:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Q1-00045g-Hi for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24Pz-0002xh-HT for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44218) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Pr-0002gz-Oi; Thu, 07 Mar 2019 20:35:16 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B13A53084247; Fri, 8 Mar 2019 01:35:07 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7B7C60BE5; Fri, 8 Mar 2019 01:34:39 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:16 +0100 Message-Id: <20190308013222.12524-13-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 08 Mar 2019 01:35:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 12/18] hw/nvram/fw_cfg: Keep reference of file_data in FWCfgState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The 'file_data' is allocated by read_splashfile() (introduced in commit 3d3b8303c6f8). It is then used by fw_cfg_add_file(). Due to the contract interface of fw_cfg_add_file(), it has to be valid for the lifetime of the FwCfg object. Keep a reference of 'file_data' in FWCfgState to be able to free this memory in fw_cfg_common_unrealize(). We can now remove the res_free() from the main() loop. The global boot_splash_filedata is now unused, remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/nvram/fw_cfg.c | 10 ++++++---- include/hw/nvram/fw_cfg.h | 1 + include/sysemu/sysemu.h | 1 - vl.c | 9 --------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 3ac6687a04..fc392cb7e0 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -215,16 +215,16 @@ static void fw_cfg_bootsplash(FWCfgState *s) g_free(filename); return; } - g_free(boot_splash_filedata); - boot_splash_filedata = (uint8_t *)file_data; + g_free(s->boot_splash.file_data); + s->boot_splash.file_data = file_data; /* insert data */ if (file_type == JPG_FILE) { fw_cfg_add_file(s, "bootsplash.jpg", - boot_splash_filedata, file_size); + s->boot_splash.file_data, file_size); } else { fw_cfg_add_file(s, "bootsplash.bmp", - boot_splash_filedata, file_size); + s->boot_splash.file_data, file_size); } g_free(filename); } @@ -974,6 +974,8 @@ static void fw_cfg_common_unrealize(DeviceState *dev, Error **errp) g_free(s->files); + g_free(s->boot_splash.file_data); + g_free(s->entries[0]); g_free(s->entries[1]); g_free(s->entry_order); diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index fcb771186c..83a0540b6c 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -56,6 +56,7 @@ struct FWCfgState { uint32_t reboot_timeout; struct { + char *file_data; uint16_t time_le16; } boot_splash; }; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 6065d9e420..3cd856b015 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -109,7 +109,6 @@ extern int no_shutdown; extern int old_param; extern int boot_menu; extern bool boot_strict; -extern uint8_t *boot_splash_filedata; extern bool enable_mlock; extern bool enable_cpu_pm; extern QEMUClockType rtc_clock; diff --git a/vl.c b/vl.c index fad6fec38c..47dd63a309 100644 --- a/vl.c +++ b/vl.c @@ -187,7 +187,6 @@ unsigned int nb_prom_envs = 0; const char *prom_envs[MAX_PROM_ENVS]; int boot_menu; bool boot_strict; -uint8_t *boot_splash_filedata; bool wakeup_suspend_enabled; int icount_align_option; @@ -558,12 +557,6 @@ const char *qemu_get_vm_name(void) return qemu_name; } -static void res_free(void) -{ - g_free(boot_splash_filedata); - boot_splash_filedata = NULL; -} - static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp) { const char *driver = qemu_opt_get(opts, "driver"); @@ -4591,8 +4584,6 @@ int main(int argc, char **argv, char **envp) job_cancel_sync_all(); bdrv_close_all(); - res_free(); - /* vhost-user must be cleaned up before chardevs. */ tpm_cleanup(); net_cleanup(); From patchwork Fri Mar 8 01:32:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8FFED1515 for ; Fri, 8 Mar 2019 01:47:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BC7D2F212 for ; Fri, 8 Mar 2019 01:47:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E6FC2F2F0; Fri, 8 Mar 2019 01:47:33 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D6B552F212 for ; Fri, 8 Mar 2019 01:47:32 +0000 (UTC) Received: from localhost ([127.0.0.1]:34748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24bk-0006Yv-4R for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:47:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Q7-0004AZ-Fj for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24Q3-00034I-Ho for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59282) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Pv-0002q2-KT; Thu, 07 Mar 2019 20:35:21 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8DDA9B0ADA; Fri, 8 Mar 2019 01:35:15 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 300FD60BE5; Fri, 8 Mar 2019 01:35:07 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:17 +0100 Message-Id: <20190308013222.12524-14-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 08 Mar 2019 01:35:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 13/18] hw/nvram/fw_cfg: Add QMP 'info fw_cfg' command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When debugging a paravirtualized guest firmware, it results very useful to dump the fw_cfg table. Add a QMP command which returns the most useful fields. Since the QMP protocol is not designed for passing stream data, we don't display a fw_cfg item data, only it's size: { "execute": "query-fw_cfg-items" } { "return": [ { "architecture_specific": false, "key": 0, "writeable": false, "size": 4, "keyname": "signature" }, { "architecture_specific": false, "key": 1, "writeable": false, "size": 4, "keyname": "id" }, { "architecture_specific": false, "key": 2, "writeable": false, "size": 16, "keyname": "uuid" }, ... { "order": 40, "architecture_specific": false, "key": 36, "writeable": false, "path": "etc/e820", "size": 20, "keyname": "file" }, { "order": 30, "architecture_specific": false, "key": 37, "writeable": false, "path": "etc/smbios/smbios-anchor", "size": 31, "keyname": "file" }, ... { "architecture_specific": true, "key": 3, "writeable": false, "size": 324, "keyname": "e820_tables" }, { "architecture_specific": true, "key": 4, "writeable": false, "size": 121, "keyname": "hpet" } ] } Signed-off-by: Philippe Mathieu-Daudé --- v2: New commit, asked by Eric/Michael, using Laszlo suggestions --- hw/nvram/fw_cfg.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++ qapi/misc.json | 44 +++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index fc392cb7e0..2a8d69ba07 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -35,6 +35,7 @@ #include "qemu/config-file.h" #include "qemu/cutils.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #define FW_CFG_FILE_SLOTS_DFLT 0x20 @@ -1229,3 +1230,78 @@ static void fw_cfg_register_types(void) } type_init(fw_cfg_register_types) + +static FirmwareConfigurationItem *create_qmp_fw_cfg_item(FWCfgState *s, + FWCfgEntry *e, + bool is_arch_specific, + uint16_t key, + size_t hex_length) +{ + FirmwareConfigurationItem *item = g_malloc0(sizeof(*item)); + + item->key = key; + item->writeable = e->allow_write; + item->architecture_specific = is_arch_specific; + item->size = e->len; + if (hex_length) { + item->has_data = true; + item->data = qemu_strdup_hexlify(e->data, hex_length); + } + + if (!is_arch_specific && key >= FW_CFG_FILE_FIRST) { + int id = key - FW_CFG_FILE_FIRST; + const char *path = s->files->f[id].name; + + item->has_keyname = true; + item->keyname = g_strdup("file"); + item->has_order = true; + item->order = get_fw_cfg_order(s, path); + item->has_path = true; + item->path = g_strdup(path); + } else { + const char *name; + + if (is_arch_specific) { + key |= FW_CFG_ARCH_LOCAL; + } + name = key_name(key); + if (name) { + item->has_keyname = true; + item->keyname = g_strdup(name); + } + } + return item; +} + +FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) +{ + FirmwareConfigurationItemList *item_list = NULL; + uint32_t max_entries; + int arch, key; + FWCfgState *s = fw_cfg_find(); + + if (s == NULL) { + return NULL; + } + + max_entries = fw_cfg_max_entry(s); + for (arch = ARRAY_SIZE(s->entries) - 1; arch >= 0 ; --arch) { + for (key = max_entries - 1; key >= 0; --key) { + FirmwareConfigurationItemList *info; + FWCfgEntry *e = &s->entries[arch][key]; + size_t qmp_hex_length = 0; + + if (!e->len) { + continue; + } + + info = g_malloc0(sizeof(*info)); + info->value = create_qmp_fw_cfg_item(s, e, arch, key, + qmp_hex_length); + info->next = item_list; + item_list = info; + } + } + + return item_list; +} diff --git a/qapi/misc.json b/qapi/misc.json index 8b3ca4fdd3..9d1da7c766 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3051,3 +3051,47 @@ 'data': 'NumaOptions', 'allow-preconfig': true } + +## +# @FirmwareConfigurationItem: +# +# Firmware Configuration (fw_cfg) item. +# +# @key: The uint16 selector key. +# @keyname: The stringified name if the selector refers to a well-known +# numerically defined item. +# @architecture_specific: Indicates whether the configuration setting is +# architecture specific. +# false: The item is a generic configuration item. +# true: The item is specific to a particular architecture. +# @writeable: Indicates whether the configuration setting is writeable by +# the guest. +# @size: The length of @data associated with the item. +# @data: A string representating the firmware configuration data. +# Note: This field is currently not used. +# @path: If the key is a 'file', the named file path. +# @order: If the key is a 'file', the named file order. +# +# Since 4.0 +## +{ 'struct': 'FirmwareConfigurationItem', + 'data': { 'key': 'uint16', + '*keyname': 'str', + 'architecture_specific': 'bool', + 'writeable': 'bool', + '*data': 'str', + 'size': 'int', + '*path': 'str', + '*order': 'int' } } + + +## +# @query-fw_cfg-items: +# +# Returns the list of Firmware Configuration items. +# +# Returns: A list of @FirmwareConfigurationItem for each entry. +# +# Since 4.0 +## +{ 'command': 'query-fw_cfg-items', 'returns': ['FirmwareConfigurationItem']} From patchwork Fri Mar 8 01:32:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44016139A for ; Fri, 8 Mar 2019 01:44:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C4562F0F1 for ; Fri, 8 Mar 2019 01:44:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CFE22F0F7; Fri, 8 Mar 2019 01:44:11 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6F8792F0F1 for ; Fri, 8 Mar 2019 01:44:10 +0000 (UTC) Received: from localhost ([127.0.0.1]:34662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24YT-0003dN-Lu for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:44:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24QE-0004No-MF for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24QC-0003JG-OT for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50604) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Q3-0002zx-Dn; Thu, 07 Mar 2019 20:35:29 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52A093082E51; Fri, 8 Mar 2019 01:35:25 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1612B18977; Fri, 8 Mar 2019 01:35:15 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:18 +0100 Message-Id: <20190308013222.12524-15-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 08 Mar 2019 01:35:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 14/18] hw/nvram/fw_cfg: Add HMP 'info fw_cfg' command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When debugging a paravirtualized guest firmware, it results very useful to dump the fw_cfg table. Add a HMP command which displays the most useful fields. We display each fw_cfg item data in hexadecimal (only the first 8 bytes): $ (echo info fw_cfg; echo q) | qemu-system-x86_64 -S -monitor stdio (qemu) info fw_cfg Selector Well-Known Key Pathname ArchSpec Perm Size Order Hex Data 0x0000 signature RO 4 51454d55 0x0001 id RO 4 03000000 0x0002 uuid RO 16 0000000000000000.. 0x0003 ram_size RO 8 0000000800000000 0x0004 nographic RO 2 0000 0x0005 nb_cpus RO 2 0100 0x000d numa RO 16 0000000000000000.. 0x000e boot_menu RO 2 0000 0x000f max_cpus RO 2 0100 0x0019 file_dir RO 2052 0000000b00000000.. 0x0021 file: etc/acpi/rsdp RO 20 160 5253442050545220.. 0x0022 file: etc/acpi/tables RO 131072 130 4641435340000000.. 0x0023 file: etc/boot-fail-wait RO 4 15 ffffffff 0x0024 file: etc/e820 RO 20 40 0000000000000000.. 0x0025 file: etc/smbios/smbios-anchor RO 31 30 5f534d5f001f0208.. 0x0026 file: etc/smbios/smbios-tables RO 321 20 011b000101020300.. 0x0027 file: etc/system-states RO 6 90 800000818280 0x0028 file: etc/table-loader RO 4096 140 010000006574632f.. 0x002a file: genroms/kvmvapic.bin RO 9216 55 55aa12060e0731c0.. 0x0002 irq0_override * RO 4 01000000 0x0003 e820_tables * RO 324 0000000000000000.. 0x0004 hpet * RO 121 0101a286800000d0.. (qemu) q $ (echo info fw_cfg; echo q) | qemu-system-mips -S -monitor stdio (qemu) info fw_cfg This machine does not use fw_cfg (qemu) q $ (echo info fw_cfg; echo q) | qemu-system-ppc -S -monitor stdio (qemu) info fw_cfg Selector Well-Known Key Pathname ArchSpec Perm Size Order Hex Data 0x0000 signature RO 4 51454d55 0x0001 id RO 4 01000000 0x0002 uuid RO 16 0000000000000000.. 0x0003 ram_size RO 8 0000000800000000 0x0004 nographic RO 2 0000 0x0005 nb_cpus RO 2 0100 0x0006 machine_id RO 2 0200 0x0007 kernel_addr RO 4 00000000 0x0008 kernel_size RO 4 00000000 0x0009 kernel_cmdline RO 4 00000000 0x000a initrd_addr RO 4 00000000 0x000b initdr_size RO 4 00000000 0x000c boot_device RO 2 6300 0x000e boot_menu RO 2 0000 0x000f max_cpus RO 2 0100 0x0019 file_dir RO 2052 0000000200000000.. 0x0021 file: etc/boot-fail-wait RO 4 15 ffffffff 0x0000 width * RO 2 2003 0x0001 height * RO 2 5802 0x0002 depth * RO 2 2000 0x0003 tbfreq * RO 4 c04bfd00 0x0004 clockfreq * RO 4 80d6da0f 0x0005 is_kvm * RO 4 00000000 0x0009 busfreq * RO 4 8014ef03 (qemu) q Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Dr. David Alan Gilbert --- v2: Check fw_cfg != NULL (Michael) Rename keys, display data in hexa (Laszlo) --- hmp-commands-info.hx | 17 ++++++++++ hw/nvram/fw_cfg.c | 71 ++++++++++++++++++++++++++++++++++++++- include/hw/nvram/fw_cfg.h | 2 ++ 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index cbee8b944d..2c9538c8da 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -916,6 +916,23 @@ STEXI @item info sev @findex info sev Show SEV information. +ETEXI + + { + .name = "fw_cfg", + .args_type = "", + .params = "", + .help = "Display the table firmware configuration entries " + "registered by a paravirtualized machine. Helpful " + "when debugging guest firmwares.", + .cmd = hmp_info_fw_cfg, + }, + +STEXI +@item info fw_cfg +@findex info fw_cfg +Display the table firmware configuration entries registered by a paravirtualized +machine. This information is useful when debugging guest firmwares. ETEXI STEXI diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 2a8d69ba07..4c82dcc125 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -35,6 +35,7 @@ #include "qemu/config-file.h" #include "qemu/cutils.h" #include "qapi/error.h" +#include "monitor/monitor.h" #include "qapi/qapi-commands-misc.h" #define FW_CFG_FILE_SLOTS_DFLT 0x20 @@ -1273,7 +1274,18 @@ static FirmwareConfigurationItem *create_qmp_fw_cfg_item(FWCfgState *s, return item; } -FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) +/** + * query_fw_cfg_items: + * + * @use_hexdump: Whether to populate the @data field with the hexadecimal + * representation of the item data. + * @errp: Pointer to a NULL initialized error object. + * + * Returns: A list of @FirmwareConfigurationItem, reverse sorted by the + * item selector key. + */ +static FirmwareConfigurationItemList *query_fw_cfg_items(bool use_hexdump, + Error **errp) { FirmwareConfigurationItemList *item_list = NULL; uint32_t max_entries; @@ -1294,6 +1306,9 @@ FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) if (!e->len) { continue; } + if (use_hexdump) { + qmp_hex_length = MIN(e->len, 8); + } info = g_malloc0(sizeof(*info)); info->value = create_qmp_fw_cfg_item(s, e, arch, key, @@ -1305,3 +1320,57 @@ FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) return item_list; } + +FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) +{ + return query_fw_cfg_items(false, errp); +} + +void hmp_info_fw_cfg(Monitor *mon, const QDict *qdict) +{ + FirmwareConfigurationItemList *item_list, *method; + Error *err = NULL; + + item_list = query_fw_cfg_items(true, &err); + if (!item_list) { + monitor_printf(mon, "This machine does not use fw_cfg\n"); + return; + } + if (err) { + monitor_printf(mon, "Could not query fw_cfg entries: %s\n", + error_get_pretty(err)); + error_free(err); + return; + } + + monitor_printf(mon, "Selector Well-Known Key Pathname" + " ArchSpec Perm Size Order Hex Data\n"); + for (method = item_list; method; method = method->next) { + if (method->value->has_path) { + monitor_printf(mon, + " 0x%04x file: %-28s %2s %7" PRId64 + " %3" PRId64 " %-16s%s\n", + method->value->key, + method->value->path, + method->value->writeable ? "RW" : "RO", + method->value->size, + method->value->order, + method->value->data, + method->value->size > 8 ? ".." : ""); + } else { + monitor_printf(mon, + " 0x%04x %-30s %c %2s %7" PRId64 + " %-16s%s\n", + method->value->key, + method->value->has_keyname + ? method->value->keyname : "", + method->value->architecture_specific ? '*' : ' ', + method->value->writeable ? "RW" : "RO", + method->value->size, + method->value->data, + method->value->size > 8 ? ".." : ""); + } + } + + qapi_free_FirmwareConfigurationItemList(item_list); +} diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 83a0540b6c..5ac9adfe1f 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -243,4 +243,6 @@ bool fw_cfg_dma_enabled(void *opaque); */ const char *fw_cfg_arch_key_name(uint16_t key); +void hmp_info_fw_cfg(Monitor *mon, const QDict *qdict); + #endif From patchwork Fri Mar 8 01:32:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 504ED1515 for ; Fri, 8 Mar 2019 01:47:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A58C2F212 for ; Fri, 8 Mar 2019 01:47:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A9A22F2F0; Fri, 8 Mar 2019 01:47:11 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BDFFC2F212 for ; Fri, 8 Mar 2019 01:47:10 +0000 (UTC) Received: from localhost ([127.0.0.1]:34724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24bN-00055B-Up for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:47:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59138) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24QH-0004QU-3S for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24QE-0003L8-7P for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41388) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Q9-0003Ae-VZ; Thu, 07 Mar 2019 20:35:35 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F423B307DABB; Fri, 8 Mar 2019 01:35:32 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7B5860BE5; Fri, 8 Mar 2019 01:35:25 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:19 +0100 Message-Id: <20190308013222.12524-16-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 08 Mar 2019 01:35:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 15/18] hw/nvram/fw_cfg: Add fw_cfg_add_file_from_host() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a function to read the full content of file on the host, and add a new 'file' name item to the fw_cfg device. Signed-off-by: Philippe Mathieu-Daudé --- v2: s/ptr/data, corrected documentation (Laszlo) --- hw/nvram/fw_cfg.c | 21 +++++++++++++++++++++ include/hw/nvram/fw_cfg.h | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 4c82dcc125..a46a7c8f06 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -890,6 +890,27 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename, fw_cfg_add_file_callback(s, filename, NULL, NULL, NULL, data, len, true); } +void *fw_cfg_add_file_from_host(FWCfgState *s, const char *filename, + const char *host_path, size_t *len) +{ + GError *gerr = NULL; + gchar *data = NULL; + gsize contents_len = 0; + + if (g_file_get_contents(host_path, &data, &contents_len, &gerr)) { + fw_cfg_add_file(s, filename, data, contents_len); + } else { + error_report("%s", gerr->message); + g_error_free(gerr); + return NULL; + } + if (len) { + *len = contents_len; + } + + return data; +} + void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, size_t len) { diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h index 5ac9adfe1f..75a29858dc 100644 --- a/include/hw/nvram/fw_cfg.h +++ b/include/hw/nvram/fw_cfg.h @@ -172,6 +172,29 @@ void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value); void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data, size_t len); +/** + * fw_cfg_add_file_from_host: + * @s: fw_cfg device being modified + * @filename: name of new fw_cfg file item + * @host_path: path of the host file to read the data from + * @len: pointer to hold the length of the host file (optional) + * + * Read the content of a host file as a raw "blob" then add a new NAMED + * fw_cfg item of the file size. If @len is provided, it will contain the + * total length read from the host file. The data read from the host + * filesystem is owned by the new fw_cfg entry, and is stored into the data + * structure of the fw_cfg device. + * The next available (unused) selector key starting at FW_CFG_FILE_FIRST + * will be used; also, a new entry will be added to the file directory + * structure residing at key value FW_CFG_FILE_DIR, containing the item name, + * data size, and assigned selector key value. + * + * Returns: pointer to the newly allocated file content, or NULL if an error + * occured. The returned pointer must be freed with g_free(). + */ +void *fw_cfg_add_file_from_host(FWCfgState *s, const char *filename, + const char *host_path, size_t *len); + /** * fw_cfg_add_file_callback: * @s: fw_cfg device being modified From patchwork Fri Mar 8 01:32:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844095 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BB8E139A for ; Fri, 8 Mar 2019 01:50:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 165272ED5F for ; Fri, 8 Mar 2019 01:50:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14B7C2E6B4; Fri, 8 Mar 2019 01:50:54 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 632132ED5F for ; Fri, 8 Mar 2019 01:50:53 +0000 (UTC) Received: from localhost ([127.0.0.1]:34887 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24ey-0000wT-O2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:50:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24QV-0004eu-Ap for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24QR-0003bG-40 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:35:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35766) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24QG-0003Md-Sl; Thu, 07 Mar 2019 20:35:42 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D827C071881; Fri, 8 Mar 2019 01:35:38 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D69160C5F; Fri, 8 Mar 2019 01:35:33 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:20 +0100 Message-Id: <20190308013222.12524-17-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 08 Mar 2019 01:35:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 16/18] hw/firmware: Add Edk2Crypto and edk2_add_host_crypto_policy() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The Edk2Crypto object is used to hold configuration values specific to EDK2. The edk2_add_host_crypto_policy() function loads crypto policies from the host, and register them as fw_cfg named file items. So far only the 'https' policy is supported. An usercase example is the 'HTTPS Boof' feature of OVMF [*]. Usage example: $ qemu-system-x86_64 \ -object edk2_crypto,id=https,\ ciphers=/etc/crypto-policies/back-ends/openssl.config,\ cacerts=/etc/pki/ca-trust/extracted/edk2/cacerts.bin (On Fedora these files are provided by the ca-certificates and crypto-policies packages). [*]: https://github.com/tianocore/edk2/blob/master/OvmfPkg/README Signed-off-by: Philippe Mathieu-Daudé --- MAINTAINERS | 8 ++ hw/Makefile.objs | 1 + hw/firmware/Makefile.objs | 1 + hw/firmware/uefi_edk2_crypto_policies.c | 166 ++++++++++++++++++++++++ include/hw/firmware/uefi_edk2.h | 28 ++++ 5 files changed, 204 insertions(+) create mode 100644 hw/firmware/Makefile.objs create mode 100644 hw/firmware/uefi_edk2_crypto_policies.c create mode 100644 include/hw/firmware/uefi_edk2.h diff --git a/MAINTAINERS b/MAINTAINERS index 306fc2aefa..3696b63249 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2205,6 +2205,14 @@ F: include/hw/i2c/smbus_master.h F: include/hw/i2c/smbus_slave.h F: include/hw/i2c/smbus_eeprom.h +EDK2 Firmware +M: Laszlo Ersek +M: Philippe Mathieu-Daudé +S: Maintained +F: docs/interop/firmware.json +F: hw/firmware/uefi_edk2_crypto_policies.c +F: include/hw/firmware/uefi_edk2.h + Usermode Emulation ------------------ Overall diff --git a/hw/Makefile.objs b/hw/Makefile.objs index e2fcd6aafc..da4fb91285 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -8,6 +8,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += char/ devices-dirs-$(CONFIG_SOFTMMU) += cpu/ devices-dirs-$(CONFIG_SOFTMMU) += display/ devices-dirs-$(CONFIG_SOFTMMU) += dma/ +devices-dirs-$(CONFIG_SOFTMMU) += firmware/ devices-dirs-$(CONFIG_SOFTMMU) += gpio/ devices-dirs-$(CONFIG_HYPERV) += hyperv/ devices-dirs-$(CONFIG_SOFTMMU) += i2c/ diff --git a/hw/firmware/Makefile.objs b/hw/firmware/Makefile.objs new file mode 100644 index 0000000000..ea1f6d44df --- /dev/null +++ b/hw/firmware/Makefile.objs @@ -0,0 +1 @@ +common-obj-y += uefi_edk2_crypto_policies.o diff --git a/hw/firmware/uefi_edk2_crypto_policies.c b/hw/firmware/uefi_edk2_crypto_policies.c new file mode 100644 index 0000000000..660c7f3655 --- /dev/null +++ b/hw/firmware/uefi_edk2_crypto_policies.c @@ -0,0 +1,166 @@ +/* + * UEFI EDK2 Support + * + * Copyright (c) 2019 Red Hat Inc. + * + * Author: + * Philippe Mathieu-Daudé + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qom/object_interfaces.h" +#include "hw/firmware/uefi_edk2.h" + + +#define TYPE_EDK2_CRYPTO "edk2_crypto" + +#define EDK2_CRYPTO_CLASS(klass) \ + OBJECT_CLASS_CHECK(Edk2CryptoClass, (klass), \ + TYPE_EDK2_CRYPTO) +#define EDK2_CRYPTO_GET_CLASS(obj) \ + OBJECT_GET_CLASS(Edk2CryptoClass, (obj), \ + TYPE_EDK2_CRYPTO) +#define EDK2_CRYPTO(obj) \ + INTERFACE_CHECK(Edk2Crypto, (obj), \ + TYPE_EDK2_CRYPTO) + +typedef struct Edk2Crypto { + Object parent_obj; + + /* + * Path to the acceptable ciphersuites and the preferred order from + * the host-side crypto policy. + */ + char *ciphers_path; + + /* Path to the trusted CA certificates configured on the host side. */ + char *cacerts_path; +} Edk2Crypto; + +typedef struct Edk2CryptoClass { + ObjectClass parent_class; +} Edk2CryptoClass; + + +static void edk2_crypto_prop_set_ciphers(Object *obj, const char *value, + Error **errp G_GNUC_UNUSED) +{ + Edk2Crypto *s = EDK2_CRYPTO(obj); + + g_free(s->ciphers_path); + s->ciphers_path = g_strdup(value); +} + +static char *edk2_crypto_prop_get_ciphers(Object *obj, + Error **errp G_GNUC_UNUSED) +{ + Edk2Crypto *s = EDK2_CRYPTO(obj); + + return g_strdup(s->ciphers_path); +} + +static void edk2_crypto_prop_set_cacerts(Object *obj, const char *value, + Error **errp G_GNUC_UNUSED) +{ + Edk2Crypto *s = EDK2_CRYPTO(obj); + + g_free(s->cacerts_path); + s->cacerts_path = g_strdup(value); +} + +static char *edk2_crypto_prop_get_cacerts(Object *obj, + Error **errp G_GNUC_UNUSED) +{ + Edk2Crypto *s = EDK2_CRYPTO(obj); + + return g_strdup(s->cacerts_path); +} + +static void edk2_crypto_finalize(Object *obj) +{ + Edk2Crypto *s = EDK2_CRYPTO(obj); + + g_free(s->ciphers_path); + g_free(s->cacerts_path); +} + +static void edk2_crypto_class_init(ObjectClass *oc, void *data) +{ + object_class_property_add_str(oc, "ciphers", + edk2_crypto_prop_get_ciphers, + edk2_crypto_prop_set_ciphers, + NULL); + object_class_property_add_str(oc, "cacerts", + edk2_crypto_prop_get_cacerts, + edk2_crypto_prop_set_cacerts, + NULL); +} + +static const TypeInfo edk2_crypto_info = { + .parent = TYPE_OBJECT, + .name = TYPE_EDK2_CRYPTO, + .instance_size = sizeof(Edk2Crypto), + .instance_finalize = edk2_crypto_finalize, + .class_size = sizeof(Edk2CryptoClass), + .class_init = edk2_crypto_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } +}; + +static void edk2_crypto_register_types(void) +{ + type_register_static(&edk2_crypto_info); +} + +type_init(edk2_crypto_register_types); + +static Edk2Crypto *edk2_crypto_by_id(const char *edk_crypto_id, Error **errp) +{ + Object *obj; + Object *container; + + container = object_get_objects_root(); + obj = object_resolve_path_component(container, + edk_crypto_id); + if (!obj) { + error_setg(errp, "Cannot find EDK2 crypto object ID %s", + edk_crypto_id); + return NULL; + } + + if (!object_dynamic_cast(obj, TYPE_EDK2_CRYPTO)) { + error_setg(errp, "Object '%s' is not a EDK2 crypto subclass", + edk_crypto_id); + return NULL; + } + + return EDK2_CRYPTO(obj); +} + +void edk2_add_host_crypto_policy(FWCfgState *fw_cfg) +{ + Edk2Crypto *s; + + s = edk2_crypto_by_id("https", NULL); + if (!s) { + return; + } + + if (s->ciphers_path) { + /* TODO g_free the returned pointer */ + fw_cfg_add_file_from_host(fw_cfg, "etc/edk2/https/ciphers", + s->ciphers_path, NULL); + } + + if (s->cacerts_path) { + /* TODO g_free the returned pointer */ + fw_cfg_add_file_from_host(fw_cfg, "etc/edk2/https/cacerts", + s->cacerts_path, NULL); + } +} diff --git a/include/hw/firmware/uefi_edk2.h b/include/hw/firmware/uefi_edk2.h new file mode 100644 index 0000000000..e0b2fb160a --- /dev/null +++ b/include/hw/firmware/uefi_edk2.h @@ -0,0 +1,28 @@ +/* + * UEFI EDK2 Support + * + * Copyright (c) 2019 Red Hat Inc. + * + * Author: + * Philippe Mathieu-Daudé + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_FIRMWARE_UEFI_EDK2_H +#define HW_FIRMWARE_UEFI_EDK2_H + +#include "hw/nvram/fw_cfg.h" + +/** + * edk2_add_host_crypto_policy: + * @s: fw_cfg device being modified + * + * Add a new named file containing the host crypto policy. + * + * Currently only the 'https' policy is supported. + */ +void edk2_add_host_crypto_policy(FWCfgState *s); + +#endif /* HW_FIRMWARE_UEFI_EDK2_H */ From patchwork Fri Mar 8 01:32:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5187139A for ; Fri, 8 Mar 2019 01:50:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B85EC2E7A6 for ; Fri, 8 Mar 2019 01:50:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B67F12EDAD; Fri, 8 Mar 2019 01:50:47 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 54D8D2E7A6 for ; Fri, 8 Mar 2019 01:50:47 +0000 (UTC) Received: from localhost ([127.0.0.1]:34881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24es-0000tF-6A for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:50:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Qi-0004tH-9m for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:36:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24Qc-0003no-KR for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:36:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50712) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24QR-0003Z4-2r; Thu, 07 Mar 2019 20:35:51 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AF343089E62; Fri, 8 Mar 2019 01:35:48 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E8FE18977; Fri, 8 Mar 2019 01:35:38 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:21 +0100 Message-Id: <20190308013222.12524-18-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 08 Mar 2019 01:35:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 17/18] hw/i386: Use edk2_add_host_crypto_policy() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Enable the EDK2 Crypto Policy features on the PC machine. Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/pc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 0848cdc18f..736211d623 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -38,6 +38,7 @@ #include "hw/nvram/fw_cfg.h" #include "hw/timer/hpet.h" #include "hw/firmware/smbios.h" +#include "hw/firmware/uefi_edk2.h" #include "hw/loader.h" #include "elf.h" #include "multiboot.h" @@ -1067,6 +1068,11 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms) return fw_cfg; } +static void pc_uefi_setup(PCMachineState *pcms) +{ + edk2_add_host_crypto_policy(pcms->fw_cfg); +} + static long get_file_size(FILE *f) { long where, size; @@ -1666,6 +1672,7 @@ void pc_machine_done(Notifier *notifier, void *data) if (pcms->fw_cfg) { pc_build_smbios(pcms); pc_build_feature_control_file(pcms); + pc_uefi_setup(pcms); /* update FW_CFG_NB_CPUS to account for -device added CPUs */ fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); } From patchwork Fri Mar 8 01:32:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10844097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2BE78922 for ; Fri, 8 Mar 2019 01:53:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B7502F2F4 for ; Fri, 8 Mar 2019 01:53:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F19DE2F388; Fri, 8 Mar 2019 01:53:24 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D17112F2F4 for ; Fri, 8 Mar 2019 01:53:23 +0000 (UTC) Received: from localhost ([127.0.0.1]:34995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24hO-0002iE-6D for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 20:53:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h24Qp-0004z8-7Z for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:36:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h24Qo-00047D-8D for qemu-devel@nongnu.org; Thu, 07 Mar 2019 20:36:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51462) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h24Qc-0003gf-BJ; Thu, 07 Mar 2019 20:36:04 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1495358596; Fri, 8 Mar 2019 01:35:56 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E327A60BE5; Fri, 8 Mar 2019 01:35:48 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org Date: Fri, 8 Mar 2019 02:32:22 +0100 Message-Id: <20190308013222.12524-19-philmd@redhat.com> In-Reply-To: <20190308013222.12524-1-philmd@redhat.com> References: <20190308013222.12524-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 08 Mar 2019 01:35:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 18/18] hw/arm/virt: Use edk2_add_host_crypto_policy() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , Mark Cave-Ayland , "Dr. David Alan Gilbert" , Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Igor Mammedov , Paolo Bonzini , David Gibson , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Enable the EDK2 Crypto Policy features on the Virt machine. Signed-off-by: Philippe Mathieu-Daudé --- hw/arm/virt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index bb7255a080..bc2b14af48 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -56,6 +56,7 @@ #include "hw/intc/arm_gicv3_common.h" #include "kvm_arm.h" #include "hw/firmware/smbios.h" +#include "hw/firmware/uefi_edk2.h" #include "qapi/visitor.h" #include "standard-headers/linux/input.h" #include "hw/arm/smmuv3.h" @@ -1301,6 +1302,11 @@ static void virt_build_smbios(VirtMachineState *vms) } } +static void virt_uefi_setup(VirtMachineState *vms) +{ + edk2_add_host_crypto_policy(vms->fw_cfg); +} + static void virt_machine_done(Notifier *notifier, void *data) { @@ -1329,6 +1335,7 @@ void virt_machine_done(Notifier *notifier, void *data) virt_acpi_setup(vms); virt_build_smbios(vms); + virt_uefi_setup(vms); } static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)