Skip to content

Commit dc63a08

Browse files
zx2c4geertu
authored andcommitted
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 <[email protected]> Fixes: a1ee38a ("m68k: virt: Use RNG seed from bootinfo block") Signed-off-by: Jason A. Donenfeld <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 7c236d9 commit dc63a08

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

arch/m68k/include/uapi/asm/bootinfo-virt.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
#define BI_VIRT_VIRTIO_BASE 0x8004
1414
#define BI_VIRT_CTRL_BASE 0x8005
1515

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 */
2318

2419
#define VIRT_BOOTI_VERSION MK_BI_VERSION(2, 0)
2520

arch/m68k/include/uapi/asm/bootinfo.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ struct mem_info {
6464
/* (struct mem_info) */
6565
#define BI_COMMAND_LINE 0x0007 /* kernel command line parameters */
6666
/* (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
6774

6875

6976
/*

arch/m68k/kernel/setup_mm.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/module.h>
2626
#include <linux/nvram.h>
2727
#include <linux/initrd.h>
28+
#include <linux/random.h>
2829

2930
#include <asm/bootinfo.h>
3031
#include <asm/byteorder.h>
@@ -151,6 +152,17 @@ static void __init m68k_parse_bootinfo(const struct bi_record *record)
151152
sizeof(m68k_command_line));
152153
break;
153154

155+
case BI_RNG_SEED: {
156+
u16 len = be16_to_cpup(data);
157+
add_bootloader_randomness(data + 2, len);
158+
/*
159+
* Zero the data to preserve forward secrecy, and zero the
160+
* length to prevent kexec from using it.
161+
*/
162+
memzero_explicit((void *)data, len + 2);
163+
break;
164+
}
165+
154166
default:
155167
if (MACH_IS_AMIGA)
156168
unknown = amiga_parse_bootinfo(record);

arch/m68k/virt/config.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <linux/reboot.h>
44
#include <linux/serial_core.h>
5-
#include <linux/random.h>
65
#include <clocksource/timer-goldfish.h>
76

87
#include <asm/bootinfo.h>
@@ -93,16 +92,6 @@ int __init virt_parse_bootinfo(const struct bi_record *record)
9392
data += 4;
9493
virt_bi_data.virtio.irq = be32_to_cpup(data);
9594
break;
96-
case BI_VIRT_RNG_SEED: {
97-
u16 len = be16_to_cpup(data);
98-
add_bootloader_randomness(data + 2, len);
99-
/*
100-
* Zero the data to preserve forward secrecy, and zero the
101-
* length to prevent kexec from using it.
102-
*/
103-
memzero_explicit((void *)data, len + 2);
104-
break;
105-
}
10695
default:
10796
unknown = 1;
10897
break;

0 commit comments

Comments
 (0)