Skip to contentSkip to conversation

M68k for 7.1 patches

GIT PULL Applied Laurent Vivier 2 participants 4 messages Jul 6, 2022 – Jul 7, 2022

lore
Share & tools
lore
#0 lore raw

The following changes since commit 180c2f24d5e8eada41e012a3899d29bb695aae06:

Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into staging (2022-07-06 10:41:34 +0530)

are available in the Git repository at:

https://github.com/vivier/qemu-m68k.git tags/m68k-for-7.1-pull-request

for you to fetch changes up to a988465d0eb7e2ee31a3679bbe3fbe71681820da:

m68k: virt: pass RNG seed via bootinfo block (2022-07-06 12:30:41 +0200)

----------------------------------------------------------------
Pull request m68k 20220706

pass RNG seed via bootinfo block

----------------------------------------------------------------

Jason A. Donenfeld (2):
m68k: use correct variable name in boot info string macro
m68k: virt: pass RNG seed via bootinfo block

 hw/m68k/bootinfo.h                             | 18 +++++++++++++++++-
 .../standard-headers/asm-m68k/bootinfo-virt.h  |  1 +
 hw/m68k/virt.c                                 |  7 +++++++
 3 files changed, 25 insertions(+), 1 deletion(-)
Signature · 1 line
2.36.1
#1 lore raw

[PULL 2/2] m68k: virt: pass RNG seed via bootinfo block

From: "Jason A. Donenfeld" <[email protected]>

This commit wires up bootinfo's RNG seed attribute so that Linux VMs can have their RNG seeded from the earliest possible time in boot, just like the "rng-seed" device tree property on those platforms. The link contains the corresponding Linux patch.

Based-on: <[email protected]>

Message-Id: <[email protected]>

---
 hw/m68k/bootinfo.h                               | 16 ++++++++++++++++
 .../standard-headers/asm-m68k/bootinfo-virt.h    |  1 +
 hw/m68k/virt.c                                   |  7 +++++++
 3 files changed, 24 insertions(+)
hw/m68k/bootinfo.h +16 -0
index ff4e155a3cc8..bd8b212fd35c 100644
@@ -56,4 +56,20 @@
         stb_phys(as, base++, 0); \
         base = (base + 1) & ~1; \
     } while (0)
+
+#define BOOTINFODATA(as, base, id, data, len) \
+    do { \
+        int i; \
+        stw_phys(as, base, id); \
+        base += 2; \
+        stw_phys(as, base, \
+                 (sizeof(struct bi_record) + len + 3) & ~1); \
+        base += 2; \
+        stw_phys(as, base, len); \
+        base += 2; \
+        for (i = 0; i < len; ++i) { \
+            stb_phys(as, base++, data[i]); \
+        } \
+        base = (base + 1) & ~1; \
+    } while (0)
 #endif
include/standard-headers/asm-m68k/bootinfo-virt.h +1 -0
index 81be1e092497..1b1ffd4705d6 100644
@@ -12,6 +12,7 @@
 #define BI_VIRT_GF_TTY_BASE	0x8003
 #define BI_VIRT_VIRTIO_BASE	0x8004
 #define BI_VIRT_CTRL_BASE	0x8005
+#define BI_VIRT_RNG_SEED	0x8006
 
 #define VIRT_BOOTI_VERSION	MK_BI_VERSION(2, 0)
 
hw/m68k/virt.c +7 -0
index e215aa3d4217..0aa383fa6bda 100644
@@ -9,6 +9,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/units.h"
+#include "qemu/guest-random.h"
 #include "sysemu/sysemu.h"
 #include "cpu.h"
 #include "hw/boards.h"
@@ -120,6 +121,7 @@ static void virt_init(MachineState *machine)
     hwaddr io_base;
     int i;
     ResetInfo *reset_info;
+    uint8_t rng_seed[32];
 
     if (ram_size > 3399672 * KiB) {
         /*
@@ -245,6 +247,11 @@ static void virt_init(MachineState *machine)
                         kernel_cmdline);
         }
 
+	/* Pass seed to RNG. */
+	qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed));
+	BOOTINFODATA(cs->as, parameters_base, BI_VIRT_RNG_SEED,
+		     rng_seed, sizeof(rng_seed));
+
         /* load initrd */
         if (initrd_filename) {
             initrd_size = get_image_size(initrd_filename);
Signature · 1 line
2.36.1
#2 lore raw

[PULL 1/2] m68k: use correct variable name in boot info string macro

In reply to Laurent Vivier

From: "Jason A. Donenfeld" <[email protected]>

Every time this macro is used, the caller is passing in "parameters_base", so this bug wasn't spotted. But the actual macro variable name is "base", so use that instead.

Message-Id: <[email protected]>

---
 hw/m68k/bootinfo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/m68k/bootinfo.h +1 -1
index adbf0c5521e5..ff4e155a3cc8 100644
@@ -54,6 +54,6 @@
             stb_phys(as, base++, string[i]); \
         } \
         stb_phys(as, base++, 0); \
-        base = (parameters_base + 1) & ~1; \
+        base = (base + 1) & ~1; \
     } while (0)
 #endif
Signature · 1 line
2.36.1
#3 lore raw
In reply to Laurent Vivier
Quoted 8 lines · Laurent Vivier

The following changes since commit 180c2f24d5e8eada41e012a3899d29bb695aae06:

   Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into staging (2022-07-06 10:41:34 +0530)

are available in the Git repository at:

   https://github.com/vivier/qemu-m68k.git tags/m68k-for-7.1-pull-request
Quoted 8 lines

for you to fetch changes up to a988465d0eb7e2ee31a3679bbe3fbe71681820da:

m68k: virt: pass RNG seed via bootinfo block (2022-07-06 12:30:41 +0200)

----------------------------------------------------------------
Pull request m68k 20220706

pass RNG seed via bootinfo block

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.

r~

Quoted 12 lines

----------------------------------------------------------------

Jason A. Donenfeld (2):
m68k: use correct variable name in boot info string macro
m68k: virt: pass RNG seed via bootinfo block

  hw/m68k/bootinfo.h                             | 18 +++++++++++++++++-
  .../standard-headers/asm-m68k/bootinfo-virt.h  |  1 +
  hw/m68k/virt.c                                 |  7 +++++++
  3 files changed, 25 insertions(+), 1 deletion(-)