Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

m68k: Rework BI_VIRT_RNG_SEED as BI_RNG_SEED

This is useful on !virt platforms for kexec, so change things from
BI_VIRT_RNG_SEED to be BI_RNG_SEED, and simply remove BI_VIRT_RNG_SEED
because it only ever lasted one release, and nothing is broken by not
having it. At the same time, keep a comment noting that it's been
removed, so that ID isn't reused. In addition, we previously documented
2-byte alignment, but 4-byte alignment is actually necessary, so update
that comment.

Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: a1ee38ab1a75 ("m68k: virt: Use RNG seed from bootinfo block")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Link: https://lore.kernel.org/r/20220927130835.1629806-2-Jason@zx2c4.com
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

authored by

Jason A. Donenfeld and committed by
Geert Uytterhoeven
dc63a086 7c236d93

+21 -18
+2 -7
arch/m68k/include/uapi/asm/bootinfo-virt.h
··· 13 13 #define BI_VIRT_VIRTIO_BASE 0x8004 14 14 #define BI_VIRT_CTRL_BASE 0x8005 15 15 16 - /* 17 - * A random seed used to initialize the RNG. Record format: 18 - * 19 - * - length [ 2 bytes, 16-bit big endian ] 20 - * - seed data [ `length` bytes, padded to preserve 2-byte alignment ] 21 - */ 22 - #define BI_VIRT_RNG_SEED 0x8006 16 + /* No longer used -- replaced with BI_RNG_SEED -- but don't reuse this index: 17 + * #define BI_VIRT_RNG_SEED 0x8006 */ 23 18 24 19 #define VIRT_BOOTI_VERSION MK_BI_VERSION(2, 0) 25 20
+7
arch/m68k/include/uapi/asm/bootinfo.h
··· 64 64 /* (struct mem_info) */ 65 65 #define BI_COMMAND_LINE 0x0007 /* kernel command line parameters */ 66 66 /* (string) */ 67 + /* 68 + * A random seed used to initialize the RNG. Record format: 69 + * 70 + * - length [ 2 bytes, 16-bit big endian ] 71 + * - seed data [ `length` bytes, padded to preserve 4-byte struct alignment ] 72 + */ 73 + #define BI_RNG_SEED 0x0008 67 74 68 75 69 76 /*
+12
arch/m68k/kernel/setup_mm.c
··· 25 25 #include <linux/module.h> 26 26 #include <linux/nvram.h> 27 27 #include <linux/initrd.h> 28 + #include <linux/random.h> 28 29 29 30 #include <asm/bootinfo.h> 30 31 #include <asm/byteorder.h> ··· 151 150 strscpy(m68k_command_line, data, 152 151 sizeof(m68k_command_line)); 153 152 break; 153 + 154 + case BI_RNG_SEED: { 155 + u16 len = be16_to_cpup(data); 156 + add_bootloader_randomness(data + 2, len); 157 + /* 158 + * Zero the data to preserve forward secrecy, and zero the 159 + * length to prevent kexec from using it. 160 + */ 161 + memzero_explicit((void *)data, len + 2); 162 + break; 163 + } 154 164 155 165 default: 156 166 if (MACH_IS_AMIGA)
-11
arch/m68k/virt/config.c
··· 2 2 3 3 #include <linux/reboot.h> 4 4 #include <linux/serial_core.h> 5 - #include <linux/random.h> 6 5 #include <clocksource/timer-goldfish.h> 7 6 8 7 #include <asm/bootinfo.h> ··· 92 93 data += 4; 93 94 virt_bi_data.virtio.irq = be32_to_cpup(data); 94 95 break; 95 - case BI_VIRT_RNG_SEED: { 96 - u16 len = be16_to_cpup(data); 97 - add_bootloader_randomness(data + 2, len); 98 - /* 99 - * Zero the data to preserve forward secrecy, and zero the 100 - * length to prevent kexec from using it. 101 - */ 102 - memzero_explicit((void *)data, len + 2); 103 - break; 104 - } 105 96 default: 106 97 unknown = 1; 107 98 break;