blob: 657857146c980750f9b499ccb65d17cb84549907 [file] [log] [blame]
Lorenz Brunfd166512020-04-01 17:29:45 +02001From 12a40099310177c4a494654b592e7f76ec4045f4 Mon Sep 17 00:00:00 2001
Lorenz Brun0bcaaee2019-11-06 12:42:39 +01002From: Matthew Garrett <mjg59@coreos.com>
3Date: Thu, 9 Apr 2015 13:25:00 -0700
Lorenz Brunfd166512020-04-01 17:29:45 +02004Subject: [PATCH 1/4] x86: Allow built-in command line to work in early kernel
Lorenz Brun0bcaaee2019-11-06 12:42:39 +01005 init
6
7The kernel supports having a command line built into it. Unfortunately this
8doesn't work in all cases - the built-in command line is only appended
9after we've jumped to the kernel proper, but various parts of the early
10boot process also pay attention to the command line.
11
12This patch moves the command line override code from the kernel itself to
13the early init code. Unfortunately the kernel can be executed by jumping
14to the 16-bit entry point, the UEFI entry point, directly to the 32-bit
15entry point or even to the entry point of the uncompressed image, and
16there is no guarantee that any of these will have access to data held in
17the others. As a result, four copies of the command line will be embedded
18in the kernel.
19
20This patch also defines a new field in boot_params in order to allow the
21earlier entry points to inform the generic setup code that the command line
22has already been appended and so shouldn't be added once more.
23
24Updated for Linux 4.19 by Lorenz Brun <lorenz@nexantic.com>
Leopold Schabelf1d34d32020-01-07 14:15:44 +010025Updated for Linux 5.4 by Leopold Schabel <leo@nexantic.com>
Lorenz Brunfd166512020-04-01 17:29:45 +020026Updated for Linux 5.6 by Lorenz Brun <lorenz@nexantic.com>
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010027
28Signed-off-by: Matthew Garrett <mjg59@coreos.com>
29---
Leopold Schabelf1d34d32020-01-07 14:15:44 +010030 Documentation/x86/zero-page.rst | 1 +
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010031 arch/x86/boot/boot.h | 10 ++++
32 arch/x86/boot/cmdline.c | 37 ++++++++++++++
Leopold Schabelf1d34d32020-01-07 14:15:44 +010033 arch/x86/boot/compressed/cmdline.c | 10 ++++
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010034 arch/x86/boot/compressed/eboot.c | 3 ++
35 arch/x86/boot/compressed/misc.c | 2 +
Leopold Schabelf1d34d32020-01-07 14:15:44 +010036 arch/x86/boot/compressed/misc.h | 1 +
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010037 arch/x86/boot/main.c | 3 ++
38 arch/x86/include/uapi/asm/bootparam.h | 5 +-
39 arch/x86/kernel/setup.c | 16 +++---
Lorenz Brunfd166512020-04-01 17:29:45 +020040 .../firmware/efi/libstub/efi-stub-helper.c | 51 +++++++++++++++++--
41 11 files changed, 127 insertions(+), 12 deletions(-)
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010042
Leopold Schabelf1d34d32020-01-07 14:15:44 +010043diff --git a/Documentation/x86/zero-page.rst b/Documentation/x86/zero-page.rst
Lorenz Brunfd166512020-04-01 17:29:45 +020044index f088f5881666..5339329af8d2 100644
Leopold Schabelf1d34d32020-01-07 14:15:44 +010045--- a/Documentation/x86/zero-page.rst
46+++ b/Documentation/x86/zero-page.rst
47@@ -16,6 +16,7 @@ Offset/Size Proto Name Meaning
48 000/040 ALL screen_info Text mode or frame buffer information
49 (struct screen_info)
50 040/014 ALL apm_bios_info APM BIOS information (struct apm_bios_info)
51+054/004 ALL setup_flags Flags passed from early kernel setup
52 058/008 ALL tboot_addr Physical address of tboot shared page
53 060/010 ALL ist_info Intel SpeedStep (IST) BIOS support information
54 (struct ist_info)
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010055diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
Leopold Schabelf1d34d32020-01-07 14:15:44 +010056index ca866f1cca2e..a97502baba73 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010057--- a/arch/x86/boot/boot.h
58+++ b/arch/x86/boot/boot.h
Leopold Schabelf1d34d32020-01-07 14:15:44 +010059@@ -269,6 +269,7 @@ void intcall(u8 int_no, const struct biosregs *ireg, struct biosregs *oreg);
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010060 /* cmdline.c */
61 int __cmdline_find_option(unsigned long cmdline_ptr, const char *option, char *buffer, int bufsize);
62 int __cmdline_find_option_bool(unsigned long cmdline_ptr, const char *option);
63+int __cmdline_init(unsigned long cmdline_ptr, struct boot_params *params);
64 static inline int cmdline_find_option(const char *option, char *buffer, int bufsize)
65 {
66 unsigned long cmd_line_ptr = boot_params.hdr.cmd_line_ptr;
Leopold Schabelf1d34d32020-01-07 14:15:44 +010067@@ -289,6 +290,15 @@ static inline int cmdline_find_option_bool(const char *option)
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010068 return __cmdline_find_option_bool(cmd_line_ptr, option);
69 }
Lorenz Brunfd166512020-04-01 17:29:45 +020070
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010071+static inline int cmdline_init(void)
72+{
73+ unsigned long cmd_line_ptr = boot_params.hdr.cmd_line_ptr;
74+
75+ if (cmd_line_ptr >= 0x100000)
76+ return -1; /* inaccessible */
77+
78+ return __cmdline_init(cmd_line_ptr, &boot_params);
79+}
80 /* cpu.c, cpucheck.c */
81 int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr);
82 int check_knl_erratum(void);
83diff --git a/arch/x86/boot/cmdline.c b/arch/x86/boot/cmdline.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +010084index 4ff01176c1cc..b5dfbe0b3209 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010085--- a/arch/x86/boot/cmdline.c
86+++ b/arch/x86/boot/cmdline.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +010087@@ -12,6 +12,10 @@
Lorenz Brunfd166512020-04-01 17:29:45 +020088
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010089 #include "boot.h"
Lorenz Brunfd166512020-04-01 17:29:45 +020090
Lorenz Brun0bcaaee2019-11-06 12:42:39 +010091+#ifdef CONFIG_CMDLINE_BOOL
92+static char builtin_cmdline[] = CONFIG_CMDLINE;
93+#endif
94+
95 static inline int myisspace(u8 c)
96 {
97 return c <= ' '; /* Close enough approximation */
Leopold Schabelf1d34d32020-01-07 14:15:44 +010098@@ -154,3 +158,36 @@ int __cmdline_find_option_bool(unsigned long cmdline_ptr, const char *option)
Lorenz Brunfd166512020-04-01 17:29:45 +020099
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100100 return 0; /* Buffer overrun */
101 }
102+
103+int __cmdline_init(unsigned long cmdline_ptr, struct boot_params *params)
104+{
105+#ifdef CONFIG_CMDLINE_BOOL
106+ addr_t cptr;
107+ int i = 0;
108+
109+ if (!cmdline_ptr)
110+ return -1; /* No command line */
111+
112+ set_fs(cmdline_ptr >> 4);
113+ cptr = cmdline_ptr & 0xf;
114+
115+#ifndef CONFIG_CMDLINE_OVERRIDE
116+ while (cptr < 0x10000) {
117+ char c = rdfs8(cptr);
118+ if (!c) {
119+ wrfs8(' ', cptr++);
120+ break;
121+ }
122+ cptr++;
123+ }
124+#endif /* !CONFIG_CMDLINE_OVERRIDE */
125+ while (builtin_cmdline[i] && cptr < 0xffff)
126+ wrfs8(builtin_cmdline[i++], cptr++);
127+
128+ wrfs8('\0', cptr);
129+
130+ params->setup_flags |= SETUP_CMDLINE_APPENDED;
131+#endif /* CONFIG_CMDLINE_BOOL */
132+
133+ return 0;
134+}
135diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100136index f1add5d85da9..c69b27a5e76d 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100137--- a/arch/x86/boot/compressed/cmdline.c
138+++ b/arch/x86/boot/compressed/cmdline.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100139@@ -11,6 +11,10 @@ static inline char rdfs8(addr_t addr)
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100140 {
141 return *((char *)(fs + addr));
142 }
143+static inline void wrfs8(u8 v, addr_t addr)
144+{
145+ *((char *)(fs + addr)) = v;
146+}
147 #include "../cmdline.c"
148 unsigned long get_cmd_line_ptr(void)
149 {
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100150@@ -28,3 +32,9 @@ int cmdline_find_option_bool(const char *option)
151 {
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100152 return __cmdline_find_option_bool(get_cmd_line_ptr(), option);
153 }
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100154+int cmdline_init(void)
155+{
156+ if (!(boot_params->setup_flags & SETUP_CMDLINE_APPENDED))
157+ return __cmdline_init(get_cmd_line_ptr(), boot_params);
158+ return 0;
159+}
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100160diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
Lorenz Brunfd166512020-04-01 17:29:45 +0200161index 287393d725f0..6854fe44ac2c 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100162--- a/arch/x86/boot/compressed/eboot.c
163+++ b/arch/x86/boot/compressed/eboot.c
Lorenz Brunfd166512020-04-01 17:29:45 +0200164@@ -413,6 +413,9 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100165 /* Fill in upper bits of command line address, NOP on 32 bit */
166 boot_params->ext_cmd_line_ptr = (u64)(unsigned long)cmdline_ptr >> 32;
Lorenz Brunfd166512020-04-01 17:29:45 +0200167
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100168+#ifdef CONFIG_CMDLINE_BOOL
169+ boot_params->setup_flags |= SETUP_CMDLINE_APPENDED;
170+#endif
171 hdr->ramdisk_image = 0;
172 hdr->ramdisk_size = 0;
Lorenz Brunfd166512020-04-01 17:29:45 +0200173
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100174diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100175index 9652d5c2afda..05fd4372b630 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100176--- a/arch/x86/boot/compressed/misc.c
177+++ b/arch/x86/boot/compressed/misc.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100178@@ -366,6 +366,8 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100179 lines = boot_params->screen_info.orig_video_lines;
180 cols = boot_params->screen_info.orig_video_cols;
Lorenz Brunfd166512020-04-01 17:29:45 +0200181
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100182+ cmdline_init();
183+
184 console_init();
Lorenz Brunfd166512020-04-01 17:29:45 +0200185
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100186 /*
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100187diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100188index c8181392f70d..e2f962e7c0d4 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100189--- a/arch/x86/boot/compressed/misc.h
190+++ b/arch/x86/boot/compressed/misc.h
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100191@@ -68,6 +68,7 @@ static inline void debug_puthex(const char *s)
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100192 /* cmdline.c */
193 int cmdline_find_option(const char *option, char *buffer, int bufsize);
194 int cmdline_find_option_bool(const char *option);
195+int cmdline_init(void);
Lorenz Brunfd166512020-04-01 17:29:45 +0200196
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100197 struct mem_vector {
198 unsigned long long start;
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100199diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100200index e3add857c2c9..e20e81253a7d 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100201--- a/arch/x86/boot/main.c
202+++ b/arch/x86/boot/main.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100203@@ -136,6 +136,9 @@ void main(void)
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100204 /* First, copy the boot header into the "zeropage" */
205 copy_boot_params();
Lorenz Brunfd166512020-04-01 17:29:45 +0200206
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100207+ /* Handle built-in command line */
208+ cmdline_init();
209+
210 /* Initialize the early-boot console */
211 console_init();
212 if (cmdline_find_option_bool("debug"))
213diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h
Lorenz Brunfd166512020-04-01 17:29:45 +0200214index 8669c6bdbb84..e11a678d4afa 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100215--- a/arch/x86/include/uapi/asm/bootparam.h
216+++ b/arch/x86/include/uapi/asm/bootparam.h
Lorenz Brunfd166512020-04-01 17:29:45 +0200217@@ -37,6 +37,9 @@
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100218 #define XLF_5LEVEL (1<<5)
219 #define XLF_5LEVEL_ENABLED (1<<6)
Lorenz Brunfd166512020-04-01 17:29:45 +0200220
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100221+/* setup_flags */
222+#define SETUP_CMDLINE_APPENDED (1<<0)
223+
224 #ifndef __ASSEMBLY__
Lorenz Brunfd166512020-04-01 17:29:45 +0200225
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100226 #include <linux/types.h>
Lorenz Brunfd166512020-04-01 17:29:45 +0200227@@ -175,7 +178,7 @@ struct jailhouse_setup_data {
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100228 struct boot_params {
229 struct screen_info screen_info; /* 0x000 */
230 struct apm_bios_info apm_bios_info; /* 0x040 */
231- __u8 _pad2[4]; /* 0x054 */
232+ __u32 setup_flags; /* 0x054 */
233 __u64 tboot_addr; /* 0x058 */
234 struct ist_info ist_info; /* 0x060 */
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100235 __u64 acpi_rsdp_addr; /* 0x070 */
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100236diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
Lorenz Brunfd166512020-04-01 17:29:45 +0200237index a74262c71484..6dcc6722ca73 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100238--- a/arch/x86/kernel/setup.c
239+++ b/arch/x86/kernel/setup.c
Lorenz Brunfd166512020-04-01 17:29:45 +0200240@@ -903,16 +903,18 @@ void __init setup_arch(char **cmdline_p)
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100241 bss_resource.end = __pa_symbol(__bss_stop)-1;
Lorenz Brunfd166512020-04-01 17:29:45 +0200242
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100243 #ifdef CONFIG_CMDLINE_BOOL
244+ if (!(boot_params.setup_flags & SETUP_CMDLINE_APPENDED)) {
245 #ifdef CONFIG_CMDLINE_OVERRIDE
246- strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
247-#else
248- if (builtin_cmdline[0]) {
249- /* append boot loader cmdline to builtin */
250- strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
251- strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
252 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
253- }
254+#else
255+ if (builtin_cmdline[0]) {
256+ /* append boot loader cmdline to builtin */
257+ strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
258+ strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
259+ strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
260+ }
261 #endif
262+ }
263 #endif
Lorenz Brunfd166512020-04-01 17:29:45 +0200264
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100265 strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
266diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
Lorenz Brunfd166512020-04-01 17:29:45 +0200267index 74ddfb496140..5b066819befb 100644
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100268--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
269+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
Leopold Schabelf1d34d32020-01-07 14:15:44 +0100270@@ -9,9 +9,14 @@
Lorenz Brunfd166512020-04-01 17:29:45 +0200271
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100272 #include <linux/efi.h>
273 #include <asm/efi.h>
274+#include <asm/setup.h>
Lorenz Brunfd166512020-04-01 17:29:45 +0200275
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100276 #include "efistub.h"
Lorenz Brunfd166512020-04-01 17:29:45 +0200277
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100278+#ifdef CONFIG_CMDLINE_BOOL
279+static char builtin_cmdline[] = CONFIG_CMDLINE;
280+#endif
281+
282 /*
283 * Some firmware implementations have problems reading files in one go.
284 * A read chunk size of 1MB seems to work for most platforms.
Lorenz Brunfd166512020-04-01 17:29:45 +0200285@@ -814,6 +819,20 @@ static u8 *efi_utf16_to_utf8(u8 *dst, const u16 *src, int n)
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100286 #ifndef MAX_CMDLINE_ADDRESS
287 #define MAX_CMDLINE_ADDRESS ULONG_MAX
288 #endif
289+static size_t efi_strlcat(char *dest, const char *src, size_t count)
290+{
291+ size_t dsize = strlen(dest);
292+ size_t len = strlen(src);
293+ size_t res = dsize + len;
294+
295+ dest += dsize;
296+ count -= dsize;
297+ if (len >= count)
298+ len = count-1;
299+ memcpy(dest, src, len);
300+ dest[len] = 0;
301+ return res;
302+}
Lorenz Brunfd166512020-04-01 17:29:45 +0200303
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100304 /*
305 * Convert the unicode UEFI command line to ASCII to pass to kernel.
Lorenz Brunfd166512020-04-01 17:29:45 +0200306@@ -823,14 +842,16 @@ static u8 *efi_utf16_to_utf8(u8 *dst, const u16 *src, int n)
307 char *efi_convert_cmdline(efi_loaded_image_t *image,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100308 int *cmd_line_len)
309 {
310+ unsigned long cmdline_addr = 0;
311+ int i;
312+ efi_status_t status;
313+#ifndef CONFIG_CMDLINE_OVERRIDE
314 const u16 *s2;
315 u8 *s1 = NULL;
316- unsigned long cmdline_addr = 0;
317 int load_options_chars = image->load_options_size / 2; /* UTF-16 */
318 const u16 *options = image->load_options;
319 int options_bytes = 0; /* UTF-8 bytes */
320 int options_chars = 0; /* UTF-16 chars */
321- efi_status_t status;
322 u16 zero = 0;
Lorenz Brunfd166512020-04-01 17:29:45 +0200323
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100324 if (options) {
Lorenz Brunfd166512020-04-01 17:29:45 +0200325@@ -849,8 +870,13 @@ char *efi_convert_cmdline(efi_loaded_image_t *image,
326
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100327 options_bytes++; /* NUL termination */
Lorenz Brunfd166512020-04-01 17:29:45 +0200328
329- status = efi_high_alloc(options_bytes, 0, &cmdline_addr,
330- MAX_CMDLINE_ADDRESS);
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100331+#ifdef CONFIG_CMDLINE_BOOL
332+ /* Add length of the built-in command line, plus a space */
333+ options_bytes += strlen(builtin_cmdline);
334+ options_bytes++;
335+#endif
Lorenz Brunfd166512020-04-01 17:29:45 +0200336+ status = efi_high_alloc(options_bytes, 0,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100337+ &cmdline_addr, MAX_CMDLINE_ADDRESS);
338 if (status != EFI_SUCCESS)
339 return NULL;
Lorenz Brunfd166512020-04-01 17:29:45 +0200340
341@@ -860,7 +886,24 @@ char *efi_convert_cmdline(efi_loaded_image_t *image,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100342 s1 = efi_utf16_to_utf8(s1, s2, options_chars);
343 *s1 = '\0';
Lorenz Brunfd166512020-04-01 17:29:45 +0200344
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100345+#ifdef CONFIG_CMDLINE_BOOL
346+ efi_strlcat((char *)cmdline_addr, " ", COMMAND_LINE_SIZE);
347+ efi_strlcat((char *)cmdline_addr, builtin_cmdline, COMMAND_LINE_SIZE);
348+#endif
349 *cmd_line_len = options_bytes;
350+#else /* CONFIG_CMDLINE_OVERRIDE */
Lorenz Brunfd166512020-04-01 17:29:45 +0200351+ status = efi_high_alloc(strlen(builtin_cmdline), 0,
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100352+ &cmdline_addr, MAX_CMDLINE_ADDRESS);
353+ if (status != EFI_SUCCESS)
354+ return NULL;
355+ while (builtin_cmdline[i] && i < COMMAND_LINE_SIZE) {
356+ ((char *)cmdline_addr)[i] = builtin_cmdline[i];
357+ i++;
358+ }
359+ ((char *)cmdline_addr)[i] = '\0';
360+ *cmd_line_len = strlen(builtin_cmdline);
361+#endif /* CONFIG_CMDLINE_OVERRIDE */
362+
363 return (char *)cmdline_addr;
364 }
Lorenz Brunfd166512020-04-01 17:29:45 +0200365
366--
3672.20.1
Lorenz Brun0bcaaee2019-11-06 12:42:39 +0100368