yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-hw-nvram-fw_cfg-Store-reboot-timeout-as-little-endia.patch

4ec855
From 5bb1365ea92b83615937e3082a9c250728384989 Mon Sep 17 00:00:00 2001
4ec855
From: Markus Armbruster <armbru@redhat.com>
4ec855
Date: Mon, 7 Oct 2019 07:35:09 +0100
4ec855
Subject: [PATCH 16/22] hw/nvram/fw_cfg: Store 'reboot-timeout' as little
4ec855
 endian
4ec855
MIME-Version: 1.0
4ec855
Content-Type: text/plain; charset=UTF-8
4ec855
Content-Transfer-Encoding: 8bit
4ec855
4ec855
RH-Author: Markus Armbruster <armbru@redhat.com>
4ec855
Message-id: <20191007073509.5887-5-armbru@redhat.com>
4ec855
Patchwork-id: 90976
4ec855
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 4/4] hw/nvram/fw_cfg: Store 'reboot-timeout' as little endian
4ec855
Bugzilla: 1607367
4ec855
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4ec855
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
4ec855
4ec855
From: Li Qiang <liq3ea@163.com>
4ec855
4ec855
The current codebase is not specific about the endianess of the
4ec855
fw_cfg 'file' entry 'reboot-timeout'.
4ec855
4ec855
Per docs/specs/fw_cfg.txt:
4ec855
4ec855
  === All Other Data Items ===
4ec855
4ec855
  Please consult the QEMU source for the most up-to-date
4ec855
  and authoritative list of selector keys and their respective
4ec855
  items' purpose, format and writeability.
4ec855
4ec855
Checking the git history, this code was introduced in commit
4ec855
ac05f3492421, very similar to commit 3d3b8303c6f8 for the
4ec855
'boot-menu-wait' entry, which explicitely use little-endian.
4ec855
4ec855
OVMF consumes 'boot-menu-wait' as little-endian, however it does
4ec855
not consume 'reboot-timeout'.
4ec855
4ec855
Regarding the git history and OVMF use, we choose to explicit
4ec855
'reboot-timeout' endianess as little-endian.
4ec855
4ec855
Signed-off-by: Li Qiang <liq3ea@163.com>
4ec855
Tested-by: Thomas Huth <thuth@redhat.com>
4ec855
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
Message-Id: <20190424140643.62457-4-liq3ea@163.com>
4ec855
[PMD: Reword commit description based on review comments]
4ec855
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4ec855
(cherry picked from commit 04da973501b591525ce68c2925c61c8886badd4d)
4ec855
4ec855
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
4ec855
---
4ec855
 hw/nvram/fw_cfg.c | 4 +++-
4ec855
 1 file changed, 3 insertions(+), 1 deletion(-)
4ec855
4ec855
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
4ec855
index 02ab458..954de33 100644
4ec855
--- a/hw/nvram/fw_cfg.c
4ec855
+++ b/hw/nvram/fw_cfg.c
4ec855
@@ -178,6 +178,7 @@ static void fw_cfg_reboot(FWCfgState *s)
4ec855
 {
4ec855
     const char *reboot_timeout = NULL;
4ec855
     int64_t rt_val = -1;
4ec855
+    uint32_t rt_le32;
4ec855
 
4ec855
     /* get user configuration */
4ec855
     QemuOptsList *plist = qemu_find_opts("boot-opts");
4ec855
@@ -194,7 +195,8 @@ static void fw_cfg_reboot(FWCfgState *s)
4ec855
         }
4ec855
     }
4ec855
 
4ec855
-    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_val, 4), 4);
4ec855
+    rt_le32 = cpu_to_le32(rt_val);
4ec855
+    fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_le32, 4), 4);
4ec855
 }
4ec855
 
4ec855
 static void fw_cfg_write(FWCfgState *s, uint8_t value)
4ec855
-- 
4ec855
1.8.3.1
4ec855