cryptospore / 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

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