qemu/hw/m68k/bootinfo.h
Jason A. Donenfeld 281ac13ece m68k: write bootinfo as rom section and re-randomize on reboot
Rather than poking directly into RAM, add the bootinfo block as a proper
ROM, so that it's restored when rebooting the system. This way, if the
guest corrupts any of the bootinfo items, but then tries to reboot,
it'll still be restored back to normal as expected.

Then, since the RNG seed needs to be fresh on each boot, regenerate the
RNG seed in the ROM when reseting the CPU.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Message-Id: <20221023191340.36238-1-Jason@zx2c4.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2022-10-24 10:47:14 +02:00

77 lines
2 KiB
C

/*
* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
*
* Bootinfo tags from linux bootinfo.h and bootinfo-mac.h:
* This is an easily parsable and extendable structure containing all
* information to be passed from the bootstrap to the kernel
*
* This structure is copied right after the kernel by the bootstrap
* routine.
*/
#ifndef HW_M68K_BOOTINFO_H
#define HW_M68K_BOOTINFO_H
#define BOOTINFO0(base, id) \
do { \
stw_p(base, id); \
base += 2; \
stw_p(base, sizeof(struct bi_record)); \
base += 2; \
} while (0)
#define BOOTINFO1(base, id, value) \
do { \
stw_p(base, id); \
base += 2; \
stw_p(base, sizeof(struct bi_record) + 4); \
base += 2; \
stl_p(base, value); \
base += 4; \
} while (0)
#define BOOTINFO2(base, id, value1, value2) \
do { \
stw_p(base, id); \
base += 2; \
stw_p(base, sizeof(struct bi_record) + 8); \
base += 2; \
stl_p(base, value1); \
base += 4; \
stl_p(base, value2); \
base += 4; \
} while (0)
#define BOOTINFOSTR(base, id, string) \
do { \
int i; \
stw_p(base, id); \
base += 2; \
stw_p(base, \
(sizeof(struct bi_record) + strlen(string) + \
1 /* null termination */ + 3 /* padding */) & ~3); \
base += 2; \
for (i = 0; string[i]; i++) { \
stb_p(base++, string[i]); \
} \
stb_p(base++, 0); \
base = QEMU_ALIGN_PTR_UP(base, 4); \
} while (0)
#define BOOTINFODATA(base, id, data, len) \
do { \
int i; \
stw_p(base, id); \
base += 2; \
stw_p(base, \
(sizeof(struct bi_record) + len + \
2 /* length field */ + 3 /* padding */) & ~3); \
base += 2; \
stw_p(base, len); \
base += 2; \
for (i = 0; i < len; ++i) { \
stb_p(base++, data[i]); \
} \
base = QEMU_ALIGN_PTR_UP(base, 4); \
} while (0)
#endif