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