wok-current view linux/stuff/linux-efi.u @ rev 24401

updated check and check-dev (0.13.0 -> 0.15.2)
author Hans-G?nter Theisgen
date Tue Feb 08 17:05:29 2022 +0100 (2022-02-08)
parents 02ed2446b480
children
line source
1 --- linux-3.16.53/drivers/firmware/efi/efi-stub-helper.c
2 +++ linux-3.16.53/drivers/firmware/efi/efi-stub-helper.c
3 @@ -321,6 +321,79 @@
6 /*
7 + *
8 + */
9 +static efi_status_t get_file_size(efi_system_table_t *sys_table_arg,
10 + efi_loaded_image_t *image,
11 + efi_char16_t *filename_16,
12 + struct file_info *file)
13 +{
14 + efi_status_t status;
15 + efi_file_handle_t *fh = NULL;
16 +#ifdef CONFIG_X86_64
17 + efi_char16_t *p, c;
18 +#endif
19 +
20 + /* Only open the volume once. */
21 + if (!fh) {
22 + status = efi_open_volume(sys_table_arg, image,
23 + (void **)&fh);
24 + if (status != EFI_SUCCESS)
25 + return status;
26 + }
27 +#ifdef CONFIG_X86_64
28 + for (p = filename_16; *p != '\0'; p++);
29 + c = p[-2];
30 + file->size = EFI_FILE_SIZE_MUTE;
31 + while (1) {
32 +#endif
33 + status = efi_file_size(sys_table_arg, fh, filename_16,
34 + (void **)&file->handle, &file->size);
35 +#ifdef CONFIG_X86_64
36 + if (status != EFI_SUCCESS && p[-2] != '\0') {
37 + p[-2] = '\0';
38 + file->size++;
39 + continue;
40 + }
41 + break;
42 + }
43 + p[-2] = c;
44 +#endif
45 + return status;
46 +}
47 +
48 +/*
49 + *
50 + */
51 +static efi_status_t read_efi_file(efi_system_table_t *sys_table_arg,
52 + struct file_info *file,
53 + unsigned long addr,
54 + unsigned long size)
55 +{
56 + efi_status_t status;
57 +
58 + while (size) {
59 + unsigned long chunksize;
60 + if (size > EFI_READ_CHUNK_SIZE)
61 + chunksize = EFI_READ_CHUNK_SIZE;
62 + else
63 + chunksize = size;
64 +
65 + status = efi_file_read(file->handle,
66 + &chunksize,
67 + (void *)addr);
68 + if (status != EFI_SUCCESS) {
69 + pr_efi_err(sys_table_arg, "Failed to read file\n");
70 + break;
71 + }
72 + addr += chunksize;
73 + size -= chunksize;
74 + }
75 + efi_file_close(file->handle);
76 + return status;
77 +}
78 +
79 +/*
80 * Check the cmdline for a LILO-style file= arguments.
81 *
82 * We only support loading a file from the same filesystem as
83 @@ -414,18 +487,14 @@
84 }
85 }
87 +#ifdef CONFIG_X86_64
88 + *p++ = '6';
89 + *p++ = '4';
90 +#endif
91 *p = '\0';
93 - /* Only open the volume once. */
94 - if (!i) {
95 - status = efi_open_volume(sys_table_arg, image,
96 - (void **)&fh);
97 - if (status != EFI_SUCCESS)
98 - goto free_files;
99 - }
100 -
101 - status = efi_file_size(sys_table_arg, fh, filename_16,
102 - (void **)&file->handle, &file->size);
103 + status = get_file_size(sys_table_arg,image,filename_16,file);
104 +
105 if (status != EFI_SUCCESS)
106 goto close_handles;
108 @@ -456,28 +525,11 @@
110 addr = file_addr;
111 for (j = 0; j < nr_files; j++) {
112 - unsigned long size;
113 -
114 - size = files[j].size;
115 - while (size) {
116 - unsigned long chunksize;
117 - if (size > EFI_READ_CHUNK_SIZE)
118 - chunksize = EFI_READ_CHUNK_SIZE;
119 - else
120 - chunksize = size;
121 -
122 - status = efi_file_read(files[j].handle,
123 - &chunksize,
124 - (void *)addr);
125 - if (status != EFI_SUCCESS) {
126 - pr_efi_err(sys_table_arg, "Failed to read file\n");
127 - goto free_file_total;
128 - }
129 - addr += chunksize;
130 - size -= chunksize;
131 - }
132 -
133 - efi_file_close(files[j].handle);
134 + status = read_efi_file(sys_table_arg, &files[j], addr, files[j].size);
135 + if (status != EFI_SUCCESS)
136 + goto free_file_total;
137 + addr += files[j].size + 3;
138 + addr &= 0xFFFFFFFCUL;
139 }
141 }
142 @@ -649,6 +701,30 @@
143 }
145 if (!options_chars) {
146 + /* No command line options, look for linux.cmdline */
147 +#ifdef CONFIG_X86_64
148 +#define cmdline_name L"EFI\\BOOT\\linux.cmdline64"
149 +#else
150 +#define cmdline_name L"EFI\\BOOT\\linux.cmdline"
151 +#endif
152 + struct file_info file;
153 + efi_char16_t filename_16[sizeof(cmdline_name)];
154 +
155 + memcpy((void *)filename_16, (void *)cmdline_name, sizeof(cmdline_name));
156 + if (get_file_size(sys_table_arg, image, filename_16, &file) != EFI_SUCCESS)
157 + goto no_cmdline_file;
158 +
159 + options_bytes = file.size+1;
160 + if (efi_low_alloc(sys_table_arg, options_bytes, 0, &cmdline_addr) != EFI_SUCCESS)
161 + goto no_cmdline_file;
162 +
163 + *((u8 *)cmdline_addr + file.size) = '\0';
164 + if (read_efi_file(sys_table_arg, &file, cmdline_addr, file.size) == EFI_SUCCESS)
165 + goto return_cmdline;
166 + }
167 + no_cmdline_file:
168 +
169 + if (!options_chars) {
170 /* No command line options, so return empty string*/
171 options = &zero;
172 }
173 @@ -665,6 +741,7 @@
174 s1 = efi_utf16_to_utf8(s1, s2, options_chars);
175 *s1 = '\0';
177 +return_cmdline:
178 *cmd_line_len = options_bytes;
179 return (char *)cmdline_addr;
180 }
181 --- linux-3.16.53/arch/x86/boot/compressed/eboot.c
182 +++ linux-3.16.53/arch/x86/boot/compressed/eboot.c
183 @@ -51,6 +51,7 @@
184 static void efi_printk(efi_system_table_t *, char *);
185 static void efi_char16_printk(efi_system_table_t *, efi_char16_t *);
187 +#define EFI_FILE_SIZE_MUTE 0x4554554d20525245LL
188 static efi_status_t
189 __file_size32(void *__fh, efi_char16_t *filename_16,
190 void **handle, u64 *file_sz)
191 @@ -64,9 +65,11 @@
192 status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16,
193 EFI_FILE_MODE_READ, (u64)0);
194 if (status != EFI_SUCCESS) {
195 - efi_printk(sys_table, "Failed to open file: ");
196 - efi_char16_printk(sys_table, filename_16);
197 - efi_printk(sys_table, "\n");
198 + if (*file_sz != EFI_FILE_SIZE_MUTE) {
199 + efi_printk(sys_table, "Failed to open file: ");
200 + efi_char16_printk(sys_table, filename_16);
201 + efi_printk(sys_table, "\n");
202 + }
203 return status;
204 }
206 @@ -117,9 +120,11 @@
207 status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16,
208 EFI_FILE_MODE_READ, (u64)0);
209 if (status != EFI_SUCCESS) {
210 - efi_printk(sys_table, "Failed to open file: ");
211 - efi_char16_printk(sys_table, filename_16);
212 - efi_printk(sys_table, "\n");
213 + if (*file_sz != EFI_FILE_SIZE_MUTE) {
214 + efi_printk(sys_table, "Failed to open file: ");
215 + efi_char16_printk(sys_table, filename_16);
216 + efi_printk(sys_table, "\n");
217 + }
218 return status;
219 }