aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-08 18:57:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-08 18:57:47 -0400
commit8065be8d032f38da25b54bf077a05a30d9ce9f2a (patch)
tree32a7baf4b40e0240ab4b9dd6f2bbe6129929bb66 /init
parent27d438c56009e5ae632de36fe70985d1aab5e344 (diff)
parentecc265fe9e09e32a3573b2ba26e79b2099eb8bbb (diff)
Merge branch 'akpm' (second patchbomb from Andrew Morton)
Merge more incoming from Andrew Morton: "Two new syscalls: memfd_create in "shm: add memfd_create() syscall" kexec_file_load in "kexec: implementation of new syscall kexec_file_load" And: - Most (all?) of the rest of MM - Lots of the usual misc bits - fs/autofs4 - drivers/rtc - fs/nilfs - procfs - fork.c, exec.c - more in lib/ - rapidio - Janitorial work in filesystems: fs/ufs, fs/reiserfs, fs/adfs, fs/cramfs, fs/romfs, fs/qnx6. - initrd/initramfs work - "file sealing" and the memfd_create() syscall, in tmpfs - add pci_zalloc_consistent, use it in lots of places - MAINTAINERS maintenance - kexec feature work" * emailed patches from Andrew Morton <akpm@linux-foundation.org: (193 commits) MAINTAINERS: update nomadik patterns MAINTAINERS: update usb/gadget patterns MAINTAINERS: update DMA BUFFER SHARING patterns kexec: verify the signature of signed PE bzImage kexec: support kexec/kdump on EFI systems kexec: support for kexec on panic using new system call kexec-bzImage64: support for loading bzImage using 64bit entry kexec: load and relocate purgatory at kernel load time purgatory: core purgatory functionality purgatory/sha256: provide implementation of sha256 in purgaotory context kexec: implementation of new syscall kexec_file_load kexec: new syscall kexec_file_load() declaration kexec: make kexec_segment user buffer pointer a union resource: provide new functions to walk through resources kexec: use common function for kimage_normal_alloc() and kimage_crash_alloc() kexec: move segment verification code in a separate function kexec: rename unusebale_pages to unusable_pages kernel: build bin2c based on config option CONFIG_BUILD_BIN2C bin2c: move bin2c in scripts/basic shm: wait for pins to be released when sealing ...
Diffstat (limited to 'init')
-rw-r--r--init/Kconfig5
-rw-r--r--init/do_mounts.c12
-rw-r--r--init/do_mounts_rd.c10
-rw-r--r--init/initramfs.c60
-rw-r--r--init/main.c23
5 files changed, 73 insertions, 37 deletions
diff --git a/init/Kconfig b/init/Kconfig
index a291b7ef4738..44f9ed3dae22 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -783,8 +783,13 @@ endchoice
783 783
784endmenu # "RCU Subsystem" 784endmenu # "RCU Subsystem"
785 785
786config BUILD_BIN2C
787 bool
788 default n
789
786config IKCONFIG 790config IKCONFIG
787 tristate "Kernel .config support" 791 tristate "Kernel .config support"
792 select BUILD_BIN2C
788 ---help--- 793 ---help---
789 This option enables the complete Linux kernel ".config" file 794 This option enables the complete Linux kernel ".config" file
790 contents to be saved in the kernel. It provides documentation 795 contents to be saved in the kernel. It provides documentation
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 82f22885c87e..b6237c31b0e2 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -539,12 +539,6 @@ void __init prepare_namespace(void)
539{ 539{
540 int is_floppy; 540 int is_floppy;
541 541
542 if (root_delay) {
543 printk(KERN_INFO "Waiting %d sec before mounting root device...\n",
544 root_delay);
545 ssleep(root_delay);
546 }
547
548 /* 542 /*
549 * wait for the known devices to complete their probing 543 * wait for the known devices to complete their probing
550 * 544 *
@@ -571,6 +565,12 @@ void __init prepare_namespace(void)
571 if (initrd_load()) 565 if (initrd_load())
572 goto out; 566 goto out;
573 567
568 if (root_delay) {
569 pr_info("Waiting %d sec before mounting root device...\n",
570 root_delay);
571 ssleep(root_delay);
572 }
573
574 /* wait for any asynchronous scanning to complete */ 574 /* wait for any asynchronous scanning to complete */
575 if ((ROOT_DEV == 0) && root_wait) { 575 if ((ROOT_DEV == 0) && root_wait) {
576 printk(KERN_INFO "Waiting for root device %s...\n", 576 printk(KERN_INFO "Waiting for root device %s...\n",
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index a8227022e3a0..e5d059e8aa11 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -311,9 +311,9 @@ static int exit_code;
311static int decompress_error; 311static int decompress_error;
312static int crd_infd, crd_outfd; 312static int crd_infd, crd_outfd;
313 313
314static int __init compr_fill(void *buf, unsigned int len) 314static long __init compr_fill(void *buf, unsigned long len)
315{ 315{
316 int r = sys_read(crd_infd, buf, len); 316 long r = sys_read(crd_infd, buf, len);
317 if (r < 0) 317 if (r < 0)
318 printk(KERN_ERR "RAMDISK: error while reading compressed data"); 318 printk(KERN_ERR "RAMDISK: error while reading compressed data");
319 else if (r == 0) 319 else if (r == 0)
@@ -321,13 +321,13 @@ static int __init compr_fill(void *buf, unsigned int len)
321 return r; 321 return r;
322} 322}
323 323
324static int __init compr_flush(void *window, unsigned int outcnt) 324static long __init compr_flush(void *window, unsigned long outcnt)
325{ 325{
326 int written = sys_write(crd_outfd, window, outcnt); 326 long written = sys_write(crd_outfd, window, outcnt);
327 if (written != outcnt) { 327 if (written != outcnt) {
328 if (decompress_error == 0) 328 if (decompress_error == 0)
329 printk(KERN_ERR 329 printk(KERN_ERR
330 "RAMDISK: incomplete write (%d != %d)\n", 330 "RAMDISK: incomplete write (%ld != %ld)\n",
331 written, outcnt); 331 written, outcnt);
332 decompress_error = 1; 332 decompress_error = 1;
333 return -1; 333 return -1;
diff --git a/init/initramfs.c b/init/initramfs.c
index a8497fab1c3d..bece48c3461e 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -19,6 +19,29 @@
19#include <linux/syscalls.h> 19#include <linux/syscalls.h>
20#include <linux/utime.h> 20#include <linux/utime.h>
21 21
22static ssize_t __init xwrite(int fd, const char *p, size_t count)
23{
24 ssize_t out = 0;
25
26 /* sys_write only can write MAX_RW_COUNT aka 2G-4K bytes at most */
27 while (count) {
28 ssize_t rv = sys_write(fd, p, count);
29
30 if (rv < 0) {
31 if (rv == -EINTR || rv == -EAGAIN)
32 continue;
33 return out ? out : rv;
34 } else if (rv == 0)
35 break;
36
37 p += rv;
38 out += rv;
39 count -= rv;
40 }
41
42 return out;
43}
44
22static __initdata char *message; 45static __initdata char *message;
23static void __init error(char *x) 46static void __init error(char *x)
24{ 47{
@@ -174,7 +197,7 @@ static __initdata enum state {
174} state, next_state; 197} state, next_state;
175 198
176static __initdata char *victim; 199static __initdata char *victim;
177static __initdata unsigned count; 200static unsigned long count __initdata;
178static __initdata loff_t this_header, next_header; 201static __initdata loff_t this_header, next_header;
179 202
180static inline void __init eat(unsigned n) 203static inline void __init eat(unsigned n)
@@ -186,7 +209,7 @@ static inline void __init eat(unsigned n)
186 209
187static __initdata char *vcollected; 210static __initdata char *vcollected;
188static __initdata char *collected; 211static __initdata char *collected;
189static __initdata int remains; 212static long remains __initdata;
190static __initdata char *collect; 213static __initdata char *collect;
191 214
192static void __init read_into(char *buf, unsigned size, enum state next) 215static void __init read_into(char *buf, unsigned size, enum state next)
@@ -213,7 +236,7 @@ static int __init do_start(void)
213 236
214static int __init do_collect(void) 237static int __init do_collect(void)
215{ 238{
216 unsigned n = remains; 239 unsigned long n = remains;
217 if (count < n) 240 if (count < n)
218 n = count; 241 n = count;
219 memcpy(collect, victim, n); 242 memcpy(collect, victim, n);
@@ -346,7 +369,8 @@ static int __init do_name(void)
346static int __init do_copy(void) 369static int __init do_copy(void)
347{ 370{
348 if (count >= body_len) { 371 if (count >= body_len) {
349 sys_write(wfd, victim, body_len); 372 if (xwrite(wfd, victim, body_len) != body_len)
373 error("write error");
350 sys_close(wfd); 374 sys_close(wfd);
351 do_utime(vcollected, mtime); 375 do_utime(vcollected, mtime);
352 kfree(vcollected); 376 kfree(vcollected);
@@ -354,7 +378,8 @@ static int __init do_copy(void)
354 state = SkipIt; 378 state = SkipIt;
355 return 0; 379 return 0;
356 } else { 380 } else {
357 sys_write(wfd, victim, count); 381 if (xwrite(wfd, victim, count) != count)
382 error("write error");
358 body_len -= count; 383 body_len -= count;
359 eat(count); 384 eat(count);
360 return 1; 385 return 1;
@@ -384,7 +409,7 @@ static __initdata int (*actions[])(void) = {
384 [Reset] = do_reset, 409 [Reset] = do_reset,
385}; 410};
386 411
387static int __init write_buffer(char *buf, unsigned len) 412static long __init write_buffer(char *buf, unsigned long len)
388{ 413{
389 count = len; 414 count = len;
390 victim = buf; 415 victim = buf;
@@ -394,11 +419,11 @@ static int __init write_buffer(char *buf, unsigned len)
394 return len - count; 419 return len - count;
395} 420}
396 421
397static int __init flush_buffer(void *bufv, unsigned len) 422static long __init flush_buffer(void *bufv, unsigned long len)
398{ 423{
399 char *buf = (char *) bufv; 424 char *buf = (char *) bufv;
400 int written; 425 long written;
401 int origLen = len; 426 long origLen = len;
402 if (message) 427 if (message)
403 return -1; 428 return -1;
404 while ((written = write_buffer(buf, len)) < len && !message) { 429 while ((written = write_buffer(buf, len)) < len && !message) {
@@ -417,13 +442,13 @@ static int __init flush_buffer(void *bufv, unsigned len)
417 return origLen; 442 return origLen;
418} 443}
419 444
420static unsigned my_inptr; /* index of next byte to be processed in inbuf */ 445static unsigned long my_inptr; /* index of next byte to be processed in inbuf */
421 446
422#include <linux/decompress/generic.h> 447#include <linux/decompress/generic.h>
423 448
424static char * __init unpack_to_rootfs(char *buf, unsigned len) 449static char * __init unpack_to_rootfs(char *buf, unsigned long len)
425{ 450{
426 int written, res; 451 long written;
427 decompress_fn decompress; 452 decompress_fn decompress;
428 const char *compress_name; 453 const char *compress_name;
429 static __initdata char msg_buf[64]; 454 static __initdata char msg_buf[64];
@@ -457,7 +482,7 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len)
457 decompress = decompress_method(buf, len, &compress_name); 482 decompress = decompress_method(buf, len, &compress_name);
458 pr_debug("Detected %s compressed data\n", compress_name); 483 pr_debug("Detected %s compressed data\n", compress_name);
459 if (decompress) { 484 if (decompress) {
460 res = decompress(buf, len, NULL, flush_buffer, NULL, 485 int res = decompress(buf, len, NULL, flush_buffer, NULL,
461 &my_inptr, error); 486 &my_inptr, error);
462 if (res) 487 if (res)
463 error("decompressor failed"); 488 error("decompressor failed");
@@ -603,8 +628,13 @@ static int __init populate_rootfs(void)
603 fd = sys_open("/initrd.image", 628 fd = sys_open("/initrd.image",
604 O_WRONLY|O_CREAT, 0700); 629 O_WRONLY|O_CREAT, 0700);
605 if (fd >= 0) { 630 if (fd >= 0) {
606 sys_write(fd, (char *)initrd_start, 631 ssize_t written = xwrite(fd, (char *)initrd_start,
607 initrd_end - initrd_start); 632 initrd_end - initrd_start);
633
634 if (written != initrd_end - initrd_start)
635 pr_err("/initrd.image: incomplete write (%zd != %ld)\n",
636 written, initrd_end - initrd_start);
637
608 sys_close(fd); 638 sys_close(fd);
609 free_initrd(); 639 free_initrd();
610 } 640 }
diff --git a/init/main.c b/init/main.c
index e8ae1fef0908..bb1aed928f21 100644
--- a/init/main.c
+++ b/init/main.c
@@ -6,7 +6,7 @@
6 * GK 2/5/95 - Changed to support mounting root fs via NFS 6 * GK 2/5/95 - Changed to support mounting root fs via NFS
7 * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96 7 * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
8 * Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96 8 * Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96
9 * Simplified starting of init: Michael A. Griffith <grif@acm.org> 9 * Simplified starting of init: Michael A. Griffith <grif@acm.org>
10 */ 10 */
11 11
12#define DEBUG /* Enable initcall_debug */ 12#define DEBUG /* Enable initcall_debug */
@@ -136,7 +136,7 @@ static char *ramdisk_execute_command;
136 * Used to generate warnings if static_key manipulation functions are used 136 * Used to generate warnings if static_key manipulation functions are used
137 * before jump_label_init is called. 137 * before jump_label_init is called.
138 */ 138 */
139bool static_key_initialized __read_mostly = false; 139bool static_key_initialized __read_mostly;
140EXPORT_SYMBOL_GPL(static_key_initialized); 140EXPORT_SYMBOL_GPL(static_key_initialized);
141 141
142/* 142/*
@@ -159,8 +159,8 @@ static int __init set_reset_devices(char *str)
159 159
160__setup("reset_devices", set_reset_devices); 160__setup("reset_devices", set_reset_devices);
161 161
162static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, }; 162static const char *argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
163const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, }; 163const char *envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
164static const char *panic_later, *panic_param; 164static const char *panic_later, *panic_param;
165 165
166extern const struct obs_kernel_param __setup_start[], __setup_end[]; 166extern const struct obs_kernel_param __setup_start[], __setup_end[];
@@ -199,7 +199,6 @@ static int __init obsolete_checksetup(char *line)
199 * still work even if initially too large, it will just take slightly longer 199 * still work even if initially too large, it will just take slightly longer
200 */ 200 */
201unsigned long loops_per_jiffy = (1<<12); 201unsigned long loops_per_jiffy = (1<<12);
202
203EXPORT_SYMBOL(loops_per_jiffy); 202EXPORT_SYMBOL(loops_per_jiffy);
204 203
205static int __init debug_kernel(char *str) 204static int __init debug_kernel(char *str)
@@ -376,8 +375,8 @@ static void __init setup_command_line(char *command_line)
376 initcall_command_line = 375 initcall_command_line =
377 memblock_virt_alloc(strlen(boot_command_line) + 1, 0); 376 memblock_virt_alloc(strlen(boot_command_line) + 1, 0);
378 static_command_line = memblock_virt_alloc(strlen(command_line) + 1, 0); 377 static_command_line = memblock_virt_alloc(strlen(command_line) + 1, 0);
379 strcpy (saved_command_line, boot_command_line); 378 strcpy(saved_command_line, boot_command_line);
380 strcpy (static_command_line, command_line); 379 strcpy(static_command_line, command_line);
381} 380}
382 381
383/* 382/*
@@ -445,8 +444,8 @@ void __init parse_early_options(char *cmdline)
445/* Arch code calls this early on, or if not, just before other parsing. */ 444/* Arch code calls this early on, or if not, just before other parsing. */
446void __init parse_early_param(void) 445void __init parse_early_param(void)
447{ 446{
448 static __initdata int done = 0; 447 static int done __initdata;
449 static __initdata char tmp_cmdline[COMMAND_LINE_SIZE]; 448 static char tmp_cmdline[COMMAND_LINE_SIZE] __initdata;
450 449
451 if (done) 450 if (done)
452 return; 451 return;
@@ -500,7 +499,8 @@ static void __init mm_init(void)
500 499
501asmlinkage __visible void __init start_kernel(void) 500asmlinkage __visible void __init start_kernel(void)
502{ 501{
503 char * command_line, *after_dashes; 502 char *command_line;
503 char *after_dashes;
504 extern const struct kernel_param __start___param[], __stop___param[]; 504 extern const struct kernel_param __start___param[], __stop___param[];
505 505
506 /* 506 /*
@@ -572,7 +572,8 @@ asmlinkage __visible void __init start_kernel(void)
572 * fragile until we cpu_idle() for the first time. 572 * fragile until we cpu_idle() for the first time.
573 */ 573 */
574 preempt_disable(); 574 preempt_disable();
575 if (WARN(!irqs_disabled(), "Interrupts were enabled *very* early, fixing it\n")) 575 if (WARN(!irqs_disabled(),
576 "Interrupts were enabled *very* early, fixing it\n"))
576 local_irq_disable(); 577 local_irq_disable();
577 idr_init_cache(); 578 idr_init_cache();
578 rcu_init(); 579 rcu_init();