wok-6.x rev 20626
linux-libre: add efi boot cmdline patch
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Dec 31 22:00:24 2018 +0100 (2018-12-31) |
parents | d8337abf6290 |
children | 834e572bb395 |
files | linux-libre/receipt linux-libre/stuff/linux-libre-efi-3.18.129-gnu.u |
line diff
1.1 --- a/linux-libre/receipt Mon Dec 31 19:46:12 2018 +0100 1.2 +++ b/linux-libre/receipt Mon Dec 31 22:00:24 2018 +0100 1.3 @@ -39,6 +39,7 @@ 1.4 done <<EOT 1.5 $PACKAGE-lzma-$VERSION.u 1.6 $PACKAGE-freeinitrd-$VERSION.u 1.7 +$PACKAGE-efi-$VERSION.u 1.8 EOT 1.9 1.10 make mrproper
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/linux-libre/stuff/linux-libre-efi-3.18.129-gnu.u Mon Dec 31 22:00:24 2018 +0100 2.3 @@ -0,0 +1,220 @@ 2.4 +--- linux-3.16.53/drivers/firmware/efi/libstub/efi-stub-helper.c 2.5 ++++ linux-3.16.53/drivers/firmware/efi/libstub/efi-stub-helper.c 2.6 +@@ -341,6 +341,79 @@ 2.7 + } 2.8 + 2.9 + /* 2.10 ++ * 2.11 ++ */ 2.12 ++static efi_status_t get_file_size(efi_system_table_t *sys_table_arg, 2.13 ++ efi_loaded_image_t *image, 2.14 ++ efi_char16_t *filename_16, 2.15 ++ struct file_info *file) 2.16 ++{ 2.17 ++ efi_status_t status; 2.18 ++ efi_file_handle_t *fh = NULL; 2.19 ++#ifdef CONFIG_X86_64 2.20 ++ efi_char16_t *p, c; 2.21 ++#endif 2.22 ++ 2.23 ++ /* Only open the volume once. */ 2.24 ++ if (!fh) { 2.25 ++ status = efi_open_volume(sys_table_arg, image, 2.26 ++ (void **)&fh); 2.27 ++ if (status != EFI_SUCCESS) 2.28 ++ return status; 2.29 ++ } 2.30 ++#ifdef CONFIG_X86_64 2.31 ++ for (p = filename_16; *p != '\0'; p++); 2.32 ++ c = p[-2]; 2.33 ++ file->size = EFI_FILE_SIZE_MUTE; 2.34 ++ while (1) { 2.35 ++#endif 2.36 ++ status = efi_file_size(sys_table_arg, fh, filename_16, 2.37 ++ (void **)&file->handle, &file->size); 2.38 ++#ifdef CONFIG_X86_64 2.39 ++ if (status != EFI_SUCCESS && p[-2] != '\0') { 2.40 ++ p[-2] = '\0'; 2.41 ++ file->size++; 2.42 ++ continue; 2.43 ++ } 2.44 ++ break; 2.45 ++ } 2.46 ++ p[-2] = c; 2.47 ++#endif 2.48 ++ return status; 2.49 ++} 2.50 ++ 2.51 ++/* 2.52 ++ * 2.53 ++ */ 2.54 ++static efi_status_t read_efi_file(efi_system_table_t *sys_table_arg, 2.55 ++ struct file_info *file, 2.56 ++ unsigned long addr, 2.57 ++ unsigned long size) 2.58 ++{ 2.59 ++ efi_status_t status; 2.60 ++ 2.61 ++ while (size) { 2.62 ++ unsigned long chunksize; 2.63 ++ if (size > __chunk_size) 2.64 ++ chunksize = __chunk_size; 2.65 ++ else 2.66 ++ chunksize = size; 2.67 ++ 2.68 ++ status = efi_file_read(file->handle, 2.69 ++ &chunksize, 2.70 ++ (void *)addr); 2.71 ++ if (status != EFI_SUCCESS) { 2.72 ++ pr_efi_err(sys_table_arg, "Failed to read file\n"); 2.73 ++ break; 2.74 ++ } 2.75 ++ addr += chunksize; 2.76 ++ size -= chunksize; 2.77 ++ } 2.78 ++ efi_file_close(file->handle); 2.79 ++ return status; 2.80 ++} 2.81 ++ 2.82 ++/* 2.83 + * Check the cmdline for a LILO-style file= arguments. 2.84 + * 2.85 + * We only support loading a file from the same filesystem as 2.86 +@@ -434,18 +507,14 @@ 2.87 + } 2.88 + } 2.89 + 2.90 ++#ifdef CONFIG_X86_64 2.91 ++ *p++ = '6'; 2.92 ++ *p++ = '4'; 2.93 ++#endif 2.94 + *p = '\0'; 2.95 + 2.96 +- /* Only open the volume once. */ 2.97 +- if (!i) { 2.98 +- status = efi_open_volume(sys_table_arg, image, 2.99 +- (void **)&fh); 2.100 +- if (status != EFI_SUCCESS) 2.101 +- goto free_files; 2.102 +- } 2.103 +- 2.104 +- status = efi_file_size(sys_table_arg, fh, filename_16, 2.105 +- (void **)&file->handle, &file->size); 2.106 ++ status = get_file_size(sys_table_arg,image,filename_16,file); 2.107 ++ 2.108 + if (status != EFI_SUCCESS) 2.109 + goto close_handles; 2.110 + 2.111 +@@ -476,28 +545,11 @@ 2.112 + 2.113 + addr = file_addr; 2.114 + for (j = 0; j < nr_files; j++) { 2.115 +- unsigned long size; 2.116 +- 2.117 +- size = files[j].size; 2.118 +- while (size) { 2.119 +- unsigned long chunksize; 2.120 +- if (size > __chunk_size) 2.121 +- chunksize = __chunk_size; 2.122 +- else 2.123 +- chunksize = size; 2.124 +- 2.125 +- status = efi_file_read(files[j].handle, 2.126 +- &chunksize, 2.127 +- (void *)addr); 2.128 +- if (status != EFI_SUCCESS) { 2.129 +- pr_efi_err(sys_table_arg, "Failed to read file\n"); 2.130 +- goto free_file_total; 2.131 +- } 2.132 +- addr += chunksize; 2.133 +- size -= chunksize; 2.134 +- } 2.135 +- 2.136 +- efi_file_close(files[j].handle); 2.137 ++ status = read_efi_file(sys_table_arg, &files[j], addr, files[j].size); 2.138 ++ if (status != EFI_SUCCESS) 2.139 ++ goto free_file_total; 2.140 ++ addr += files[j].size + 3; 2.141 ++ addr &= 0xFFFFFFFCUL; 2.142 + } 2.143 + 2.144 + } 2.145 +@@ -669,6 +721,30 @@ 2.146 + } 2.147 + 2.148 + if (!options_chars) { 2.149 ++ /* No command line options, look for linux.cmdline */ 2.150 ++#ifdef CONFIG_X86_64 2.151 ++#define cmdline_name L"EFI\\BOOT\\linux.cmdline64" 2.152 ++#else 2.153 ++#define cmdline_name L"EFI\\BOOT\\linux.cmdline" 2.154 ++#endif 2.155 ++ struct file_info file; 2.156 ++ efi_char16_t filename_16[sizeof(cmdline_name)]; 2.157 ++ 2.158 ++ memcpy((void *)filename_16, (void *)cmdline_name, sizeof(cmdline_name)); 2.159 ++ if (get_file_size(sys_table_arg, image, filename_16, &file) != EFI_SUCCESS) 2.160 ++ goto no_cmdline_file; 2.161 ++ 2.162 ++ options_bytes = file.size+1; 2.163 ++ if (efi_low_alloc(sys_table_arg, options_bytes, 0, &cmdline_addr) != EFI_SUCCESS) 2.164 ++ goto no_cmdline_file; 2.165 ++ 2.166 ++ *((u8 *)cmdline_addr + file.size) = '\0'; 2.167 ++ if (read_efi_file(sys_table_arg, &file, cmdline_addr, file.size) == EFI_SUCCESS) 2.168 ++ goto return_cmdline; 2.169 ++ } 2.170 ++ no_cmdline_file: 2.171 ++ 2.172 ++ if (!options_chars) { 2.173 + /* No command line options, so return empty string*/ 2.174 + options = &zero; 2.175 + } 2.176 +@@ -685,6 +761,7 @@ 2.177 + s1 = efi_utf16_to_utf8(s1, s2, options_chars); 2.178 + *s1 = '\0'; 2.179 + 2.180 ++return_cmdline: 2.181 + *cmd_line_len = options_bytes; 2.182 + return (char *)cmdline_addr; 2.183 + } 2.184 +--- linux-3.16.53/arch/x86/boot/compressed/eboot.c 2.185 ++++ linux-3.16.53/arch/x86/boot/compressed/eboot.c 2.186 +@@ -50,6 +50,7 @@ 2.187 + 2.188 + void efi_char16_printk(efi_system_table_t *, efi_char16_t *); 2.189 + 2.190 ++#define EFI_FILE_SIZE_MUTE 0x4554554d20525245LL 2.191 + static efi_status_t 2.192 + __file_size32(void *__fh, efi_char16_t *filename_16, 2.193 + void **handle, u64 *file_sz) 2.194 +@@ -63,9 +64,11 @@ 2.195 + status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16, 2.196 + EFI_FILE_MODE_READ, (u64)0); 2.197 + if (status != EFI_SUCCESS) { 2.198 +- efi_printk(sys_table, "Failed to open file: "); 2.199 +- efi_char16_printk(sys_table, filename_16); 2.200 +- efi_printk(sys_table, "\n"); 2.201 ++ if (*file_sz != EFI_FILE_SIZE_MUTE) { 2.202 ++ efi_printk(sys_table, "Failed to open file: "); 2.203 ++ efi_char16_printk(sys_table, filename_16); 2.204 ++ efi_printk(sys_table, "\n"); 2.205 ++ } 2.206 + return status; 2.207 + } 2.208 + 2.209 +@@ -116,9 +119,11 @@ 2.210 + status = efi_early->call((unsigned long)fh->open, fh, &h, filename_16, 2.211 + EFI_FILE_MODE_READ, (u64)0); 2.212 + if (status != EFI_SUCCESS) { 2.213 +- efi_printk(sys_table, "Failed to open file: "); 2.214 +- efi_char16_printk(sys_table, filename_16); 2.215 +- efi_printk(sys_table, "\n"); 2.216 ++ if (*file_sz != EFI_FILE_SIZE_MUTE) { 2.217 ++ efi_printk(sys_table, "Failed to open file: "); 2.218 ++ efi_char16_printk(sys_table, filename_16); 2.219 ++ efi_printk(sys_table, "\n"); 2.220 ++ } 2.221 + return status; 2.222 + } 2.223 +