1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
From: David Daney <david.daney@cavium.com>
If 'rd_name=xxx' is passed to the kernel, the named block with name
'xxx' is used for the initrd.
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Leonid Rosenboim <lrosenboim@caviumnetworks.com>
Signed-off-by: Aleksey Makarov <aleksey.makarov@auriga.com>
Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
[forward porting to 5.4]
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -28,6 +28,7 @@
#include <linux/of_fdt.h>
#include <linux/libfdt.h>
#include <linux/kexec.h>
+#include <linux/initrd.h>
#include <asm/processor.h>
#include <asm/reboot.h>
@@ -298,6 +299,9 @@
extern asmlinkage void handle_int(void);
+/* If an initrd named block is specified, its name goes here. */
+static char rd_name[64] __initdata;
+
/**
* Return non zero if we are currently running in the Octeon simulator
*
@@ -877,6 +881,10 @@
max_memory = 32ull << 30;
if (*p == '@')
reserve_low_mem = memparse(p + 1, &p);
+ } else if (strncmp(arg, "rd_name=", 8) == 0) {
+ strncpy(rd_name, arg + 8, sizeof(rd_name));
+ rd_name[sizeof(rd_name) - 1] = 0;
+ goto append_arg;
#ifdef CONFIG_KEXEC
} else if (strncmp(arg, "crashkernel=", 12) == 0) {
crashk_size = memparse(arg+12, &p);
@@ -889,11 +897,15 @@
* parse_crashkernel(arg, sysinfo->system_dram_size,
* &crashk_size, &crashk_base);
*/
+ goto append_arg;
#endif
- } else if (strlen(arcs_cmdline) + strlen(arg) + 1 <
- sizeof(arcs_cmdline) - 1) {
- strcat(arcs_cmdline, " ");
- strcat(arcs_cmdline, arg);
+ } else {
+append_arg:
+ if (strlen(arcs_cmdline) + strlen(arg) + 1
+ < sizeof(arcs_cmdline) - 1) {
+ strcat(arcs_cmdline, " ");
+ strcat(arcs_cmdline, arg);
+ }
}
}
@@ -978,6 +990,23 @@
total = 0;
crashk_end = 0;
+
+#ifdef CONFIG_BLK_DEV_INITRD
+
+ if (rd_name[0]) {
+ const struct cvmx_bootmem_named_block_desc *initrd_block;
+
+ initrd_block = cvmx_bootmem_find_named_block(rd_name);
+ if (initrd_block != NULL) {
+ initrd_start = initrd_block->base_addr + PAGE_OFFSET;
+ initrd_end = initrd_start + initrd_block->size;
+ add_memory_region(initrd_block->base_addr,
+ initrd_block->size, BOOT_MEM_INIT_RAM);
+ initrd_in_reserved = 1;
+ total += initrd_block->size;
+ }
+ }
+#endif
/*
* The Mips memory init uses the first memory location for
--- a/arch/mips/include/asm/bootinfo.h
+++ b/arch/mips/include/asm/bootinfo.h
@@ -167,4 +167,8 @@
#endif /* CONFIG_RELOCATABLE */
#endif /* CONFIG_USE_OF */
+#ifdef CONFIG_BLK_DEV_INITRD
+extern bool initrd_in_reserved;
+#endif
+
#endif /* _ASM_BOOTINFO_H */
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -63,6 +63,10 @@
EXPORT_SYMBOL(mips_machtype);
+#ifdef CONFIG_BLK_DEV_INITRD
+bool initrd_in_reserved;
+#endif
+
static char __initdata command_line[COMMAND_LINE_SIZE];
char __initdata arcs_cmdline[COMMAND_LINE_SIZE];
@@ -310,6 +314,12 @@
* will reserve the area used for the initrd.
*/
init_initrd();
+
+#ifdef CONFIG_BLK_DEV_INITRD
+ if (initrd_in_reserved) {
+ pr_info("Initramfs image loaded from rd_name= parameter.\n");
+ }
+#endif
/* Reserve memory occupied by kernel. */
memblock_reserve(__pa_symbol(&_text),
|