]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
m68k: rework BI_VIRT_RNG_SEED as BI_RNG_SEED
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 26 Sep 2022 11:38:59 +0000 (13:38 +0200)
committerLaurent Vivier <laurent@vivier.eu>
Fri, 21 Oct 2022 18:46:10 +0000 (20:46 +0200)
Following a change on the kernel side (see link), pass BI_RNG_SEED
instead of BI_VIRT_RNG_SEED. This should have no impact on
compatibility, as there will simply be no effect if it's an old kernel,
which is how things have always been. We then use this as an opportunity
to add this to q800, since now we can, which is a nice improvement.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Link: https://lore.kernel.org/lkml/20220923170340.4099226-3-Jason@zx2c4.com/
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Message-Id: <20220926113900.1256630-1-Jason@zx2c4.com>
[lv: s/^I/         /g]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
hw/m68k/q800.c
hw/m68k/virt.c
include/standard-headers/asm-m68k/bootinfo-virt.h
include/standard-headers/asm-m68k/bootinfo.h

index 101ab0f803f6c95940f8cdf31f1a57207ac54b98..a4590c2cb0b1cf8dbf6a9d0092d255cfb0c6dd85 100644 (file)
@@ -23,6 +23,7 @@
 #include "qemu/osdep.h"
 #include "qemu/units.h"
 #include "qemu/datadir.h"
+#include "qemu/guest-random.h"
 #include "sysemu/sysemu.h"
 #include "cpu.h"
 #include "hw/boards.h"
@@ -385,6 +386,7 @@ static void q800_init(MachineState *machine)
     NubusBus *nubus;
     DeviceState *glue;
     DriveInfo *dinfo;
+    uint8_t rng_seed[32];
 
     linux_boot = (kernel_filename != NULL);
 
@@ -634,6 +636,11 @@ static void q800_init(MachineState *machine)
                         kernel_cmdline);
         }
 
+        /* Pass seed to RNG. */
+        qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed));
+        BOOTINFODATA(cs->as, parameters_base, BI_RNG_SEED,
+                     rng_seed, sizeof(rng_seed));
+
         /* load initrd */
         if (initrd_filename) {
             initrd_size = get_image_size(initrd_filename);
index 2f3ffc0de677e39dbb166e00fe6c4f9dc744ef25..f7b903ea1b62bf2984d073de90896c7a6a7821e7 100644 (file)
@@ -248,10 +248,10 @@ 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));
+        /* Pass seed to RNG. */
+        qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed));
+        BOOTINFODATA(cs->as, parameters_base, BI_RNG_SEED,
+                     rng_seed, sizeof(rng_seed));
 
         /* load initrd */
         if (initrd_filename) {
index 1b1ffd4705d683fdeb1425041364f33b7002f735..75ac6bbd7d73818a6933e6a6752b16a77a8ce2eb 100644 (file)
@@ -12,7 +12,9 @@
 #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
+
+/* No longer used -- replaced with BI_RNG_SEED -- but don't reuse this index:
+ * #define BI_VIRT_RNG_SEED    0x8006 */
 
 #define VIRT_BOOTI_VERSION     MK_BI_VERSION(2, 0)
 
index 7b790e8ec8d64871721525870125ad165c8bd06a..b7a8dd2514fe8ce15e72ec2fa2a3b51b1ce6adc3 100644 (file)
@@ -57,7 +57,13 @@ struct mem_info {
                                        /* (struct mem_info) */
 #define BI_COMMAND_LINE                0x0007  /* kernel command line parameters */
                                        /* (string) */
-
+/*
+ * A random seed used to initialize the RNG. Record format:
+ *
+ *   - length       [ 2 bytes, 16-bit big endian ]
+ *   - seed data    [ `length` bytes, padded to preserve 4-byte struct alignment ]
+ */
+#define BI_RNG_SEED            0x0008
 
     /*
      *  Linux/m68k Architectures (BI_MACHTYPE)