From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Geert Uytterhoeven <geert@linux-m68k.org>
Subject: [PULL 1/2] m68k: rework BI_VIRT_RNG_SEED as BI_RNG_SEED
Date: Sat, 22 Oct 2022 11:17:49 +0200 [thread overview]
Message-ID: <20221022091750.2713763-2-laurent@vivier.eu> (raw)
In-Reply-To: <20221022091750.2713763-1-laurent@vivier.eu>
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
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>
---
include/standard-headers/asm-m68k/bootinfo-virt.h | 4 +++-
include/standard-headers/asm-m68k/bootinfo.h | 8 +++++++-
hw/m68k/q800.c | 7 +++++++
hw/m68k/virt.c | 8 ++++----
4 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/include/standard-headers/asm-m68k/bootinfo-virt.h b/include/standard-headers/asm-m68k/bootinfo-virt.h
index 1b1ffd4705d6..75ac6bbd7d73 100644
--- a/include/standard-headers/asm-m68k/bootinfo-virt.h
+++ b/include/standard-headers/asm-m68k/bootinfo-virt.h
@@ -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)
diff --git a/include/standard-headers/asm-m68k/bootinfo.h b/include/standard-headers/asm-m68k/bootinfo.h
index 7b790e8ec8d6..b7a8dd2514fe 100644
--- a/include/standard-headers/asm-m68k/bootinfo.h
+++ b/include/standard-headers/asm-m68k/bootinfo.h
@@ -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)
diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
index 101ab0f803f6..a4590c2cb0b1 100644
--- a/hw/m68k/q800.c
+++ b/hw/m68k/q800.c
@@ -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);
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
index 2f3ffc0de677..f7b903ea1b62 100644
--- a/hw/m68k/virt.c
+++ b/hw/m68k/virt.c
@@ -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) {
--
2.37.3
next prev parent reply other threads:[~2022-10-22 10:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-22 9:17 [PULL 0/2] M68k for 7.2 patches Laurent Vivier
2022-10-22 9:17 ` Laurent Vivier [this message]
2022-10-22 9:17 ` [PULL 2/2] m68k: write bootinfo as rom section and re-randomize on reboot Laurent Vivier
2022-10-24 7:29 ` [PULL 0/2] M68k for 7.2 patches Laurent Vivier
-- strict thread matches above, loose matches on Subject: below --
2022-10-24 8:58 Laurent Vivier
2022-10-24 8:58 ` [PULL 1/2] m68k: rework BI_VIRT_RNG_SEED as BI_RNG_SEED Laurent Vivier
2022-10-14 7:23 [PULL 0/2] M68k for 7.2 patches Laurent Vivier
2022-10-14 7:23 ` [PULL 1/2] m68k: rework BI_VIRT_RNG_SEED as BI_RNG_SEED Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221022091750.2713763-2-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=Jason@zx2c4.com \
--cc=geert@linux-m68k.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).