From nobody Tue Feb 10 05:10:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549292186749192.81097930415808; Mon, 4 Feb 2019 06:56:26 -0800 (PST) Received: from localhost ([127.0.0.1]:44008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqffY-0001cU-OX for importer@patchew.org; Mon, 04 Feb 2019 09:56:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gqfaU-00066m-H2 for qemu-devel@nongnu.org; Mon, 04 Feb 2019 09:51:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gqfTd-0005iJ-Uc for qemu-devel@nongnu.org; Mon, 04 Feb 2019 09:44:03 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:41083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gqfTc-0005hO-Th for qemu-devel@nongnu.org; Mon, 04 Feb 2019 09:44:01 -0500 Received: by mail-qt1-f195.google.com with SMTP id b15so73634qto.8 for ; Mon, 04 Feb 2019 06:44:00 -0800 (PST) Received: from redhat.com (pool-173-76-246-42.bstnma.fios.verizon.net. [173.76.246.42]) by smtp.gmail.com with ESMTPSA id n67sm12210510qkd.95.2019.02.04.06.43.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Feb 2019 06:43:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=PB7tFUdGSkzn3PVY7MbFdLrdwr8jFa3OuNPfI11QD7c=; b=XgiEmLmUuEJ0slNc3pV/DxYEuPAfKej9vMbOp5Ul1LpNj7wCBK9JvMV22tKDlYJ/Cn mIYNiMu/af5LO+HQ6GsM/sIgsjr8GMWlC0VU4PI1tm3L5JsHfJtX9qcSXiClxJKSzuDf mPOLf+OKLKjWi7kXKDlGaNENflffzOHd0YJqMQABXFtU+UP46YFm7JAOUnGF6pIUepEz U6Tqtx8vN7U+ZWtU9eN1Em3PzDCbWLIFtDPxbLgP8Zd+8qSclswLzx7mHqi7Bgo09GQi ArJC45nEs++F53g6rECcUjfPxS6I4EM+FDAJ1m6Jk2ePqPN/IS8yiacvhbyftRMJRn4M MnMQ== X-Gm-Message-State: AJcUukdY1QM7tVOYzy0KVEnqbSSX49JWQE6uR8FTwIG/T6VMpf9g5vMN kD5TM++gLSud+tuG+FWnpkklAI/HLQcrzQ== X-Google-Smtp-Source: ALg8bN6OK6bqbVF4eFGNjO80IUmE701yr+KsKqOJhZ+0kwsYwySEviNnoSWA19CxHLZkKfxMQpId2g== X-Received: by 2002:a0c:fc09:: with SMTP id z9mr49117825qvo.157.1549291439633; Mon, 04 Feb 2019 06:43:59 -0800 (PST) Date: Mon, 4 Feb 2019 09:43:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20190204142638.27021-21-mst@redhat.com> References: <20190204142638.27021-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20190204142638.27021-1-mst@redhat.com> X-Mailer: git-send-email 2.17.1.1206.gb667731e2e.dirty X-Mutt-Fcc: =sent X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.160.195 Subject: [Qemu-devel] [PULL 20/25] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw" 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 , Laszlo Ersek , Li Qiang , Markus Armbruster , Gerd Hoffmann , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Stefano Garzarella Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Laszlo Ersek Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally", 2019-01-04) changed the storage duration of the "qemu_extra_params_fw" array from static to automatic. This broke the interface contract on the fw_cfg_add_file() function, which is documented as follows, in "include/hw/nvram/fw_cfg.h": > [...] The data referenced by the starting pointer is only linked, NOT > copied, into the data structure of the fw_cfg device. [...] As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg file, it now sees garbage. Fix the regression by changing the storage duration to allocated. (The call is reached at most once, on the realize path of the board-specific fw_cfg sysbus device.) While at it, clean up the name and the assignment of the object as well. Cc: Gerd Hoffmann Cc: Markus Armbruster Cc: Philippe Mathieu-Daud=C3=A9 Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d Signed-off-by: Laszlo Ersek Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Gerd Hoffmann Reviewed-by: Li Qiang Reviewed-by: Stefano Garzarella Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/nvram/fw_cfg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 53e8e010a8..7fdf04adc9 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s) { const char *boot_splash_filename =3D NULL; const char *boot_splash_time =3D NULL; - uint8_t qemu_extra_params_fw[2]; char *filename, *file_data; gsize file_size; int file_type; @@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s) /* insert splash time if user configurated */ if (boot_splash_time) { int64_t bst_val =3D qemu_opt_get_number(opts, "splash-time", -1); + uint16_t bst_le16; + /* validate the input */ if (bst_val < 0 || bst_val > 0xffff) { error_report("splash-time is invalid," @@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s) exit(1); } /* use little endian format */ - qemu_extra_params_fw[0] =3D (uint8_t)(bst_val & 0xff); - qemu_extra_params_fw[1] =3D (uint8_t)((bst_val >> 8) & 0xff); - fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2); + bst_le16 =3D cpu_to_le16(bst_val); + fw_cfg_add_file(s, "etc/boot-menu-wait", + g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_l= e16); } =20 /* insert splash file if user configurated */ --=20 MST