11 Sep, 2015

1 commit

  • There are two kexec load syscalls, kexec_load another and kexec_file_load.
    kexec_file_load has been splited as kernel/kexec_file.c. In this patch I
    split kexec_load syscall code to kernel/kexec.c.

    And add a new kconfig option KEXEC_CORE, so we can disable kexec_load and
    use kexec_file_load only, or vice verse.

    The original requirement is from Ted Ts'o, he want kexec kernel signature
    being checked with CONFIG_KEXEC_VERIFY_SIG enabled. But kexec-tools use
    kexec_load syscall can bypass the checking.

    Vivek Goyal proposed to create a common kconfig option so user can compile
    in only one syscall for loading kexec kernel. KEXEC/KEXEC_FILE selects
    KEXEC_CORE so that old config files still work.

    Because there's general code need CONFIG_KEXEC_CORE, so I updated all the
    architecture Kconfig with a new option KEXEC_CORE, and let KEXEC selects
    KEXEC_CORE in arch Kconfig. Also updated general kernel code with to
    kexec_load syscall.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Dave Young
    Cc: Eric W. Biederman
    Cc: Vivek Goyal
    Cc: Petr Tesarik
    Cc: Theodore Ts'o
    Cc: Josh Boyer
    Cc: David Howells
    Cc: Geert Uytterhoeven
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dave Young
     

14 Oct, 2014

1 commit

  • Resolve shadow warnings that are produced in W=2 builds by renaming a
    global with a too-generic name and renaming a formal parameter.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Mark Rustad
    Signed-off-by: Jeff Kirsher
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mark Rustad
     

09 Aug, 2014

3 commits

  • On a system with low memory extracting the initramfs may fail. If this
    happens the user gets "Failed to execute /init" instead of an initramfs
    error.

    Check return value of sys_write and call error() when the write was
    incomplete or failed.

    Signed-off-by: David Engraf
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Engraf
     
  • Now with 64bit bzImage and kexec tools, we support ramdisk that size is
    bigger than 2g, as we could put it above 4G.

    Found compressed initramfs image could not be decompressed properly. It
    turns out that image length is int during decompress detection, and it
    will become < 0 when length is more than 2G. Furthermore, during
    decompressing len as int is used for inbuf count, that has problem too.

    Change len to long, that should be ok as on 32 bit platform long is
    32bits.

    Tested with following compressed initramfs image as root with kexec.
    gzip, bzip2, xz, lzma, lzop, lz4.
    run time for populate_rootfs():
    size name Nehalem-EX Westmere-EX Ivybridge-EX
    9034400256 root_img : 26s 24s 30s
    3561095057 root_img.lz4 : 28s 27s 27s
    3459554629 root_img.lzo : 29s 29s 28s
    3219399480 root_img.gz : 64s 62s 49s
    2251594592 root_img.xz : 262s 260s 183s
    2226366598 root_img.lzma: 386s 376s 277s
    2901482513 root_img.bz2 : 635s 599s

    Signed-off-by: Yinghai Lu
    Cc: "H. Peter Anvin"
    Cc: Ingo Molnar
    Cc: Rashika Kheria
    Cc: Josh Triplett
    Cc: Kyungsik Lee
    Cc: P J P
    Cc: Al Viro
    Cc: Tetsuo Handa
    Cc: "Daniel M. Weeks"
    Cc: Alexandre Courbot
    Cc: Jan Beulich
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yinghai Lu
     
  • When initrd (compressed or not) is used, kernel report data corrupted with
    /dev/ram0.

    The root cause:
    During initramfs checking, if it is initrd, it will be transferred to
    /initrd.image with sys_write.
    sys_write only support 2G-4K write, so if the initrd ram is more than
    that, /initrd.image will not complete at all.

    Add local xwrite to loop calling sys_write to workaround the problem.

    Also need to use xwrite in write_buffer() to handle:
    image is uncompressed cpio and there is one big file (>2G) in it.
    unpack_to_rootfs ===> write_buffer ===> actions[]/do_copy

    At the same time, we don't need to worry about sys_read/sys_write in
    do_mounts_rd.c::crd_load. As decompressor will have fill/flush and local
    buffer that is smaller than 2G.

    Test with uncompressed initrd, and compressed ones with gz, bz2, lzma,xz,
    lzop.

    Signed-off-by: Yinghai Lu
    Acked-by: H. Peter Anvin
    Cc: Ingo Molnar
    Cc: Geert Uytterhoeven
    Cc: Tetsuo Handa
    Cc: "Daniel M. Weeks"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Yinghai Lu
     

08 Apr, 2014

1 commit

  • This can greatly aid in narrowing down the real source of initramfs
    problems such as failures related to the compression of the in-kernel
    initramfs when an external initramfs is in use as well. Existing errors
    are ambiguous as to which initramfs is a problem and why.

    [akpm@linux-foundation.org: use pr_debug()]
    Signed-off-by: Daniel M. Weeks
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Daniel M. Weeks
     

24 Jan, 2014

1 commit


19 Jan, 2013

1 commit

  • This patch adds default module loading and uses it to load the default
    block elevator. During boot, it's called right after initramfs or
    initrd is made available and right before control is passed to
    userland. This ensures that as long as the modules are available in
    the usual places in initramfs, initrd or the root filesystem, the
    default modules are loaded as soon as possible.

    This will replace the on-demand elevator module loading from elevator
    init path.

    v2: Fixed build breakage when !CONFIG_BLOCK. Reported by kbuild test
    robot.

    Signed-off-by: Tejun Heo
    Cc: Jens Axboe
    Cc: Arjan van de Ven
    Cc: Linus Torvalds
    Cc: Alex Riesen
    Cc: Fengguang We

    Tejun Heo
     

01 Jun, 2012

1 commit

  • The init/mount.o source files produce a number of sparse warnings of the
    type:

    warning: incorrect type in argument 1 (different address spaces)
    expected char [noderef] *dev_name
    got char *name

    This is due to the syscalls expecting some of the arguments to be user
    pointers but they are being passed as kernel pointers. This is harmless
    but adds a lot of noise to a sparse build.

    To limit the noise just disable the sparse checking in the relevant source
    files, but still display a warning so that the user knows this has been
    done.

    Since the sparse checking has been disabled we can also remove the __user
    __force casts that are scattered thru the source.

    Signed-off-by: H Hartley Sweeten
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    H Hartley Sweeten
     

04 Jan, 2012

1 commit


29 Oct, 2010

1 commit

  • * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6:
    initramfs: Fix build break on symbol-prefixed archs
    initramfs: fix initramfs size calculation
    initramfs: generalize initramfs_data.xxx.S variants
    scripts/kallsyms: Enable error messages while hush up unnecessary warnings
    scripts/setlocalversion: update comment
    kbuild: Use a single clean rule for kernel and external modules
    kbuild: Do not run make clean in $(srctree)
    scripts/mod/modpost.c: fix commentary accordingly to last changes
    kbuild: Really don't clean bounds.h and asm-offsets.h

    Linus Torvalds
     

27 Oct, 2010

1 commit

  • When calling syscall service routines in kernel, some of arguments should
    be user pointers but were missing __user markup on string literals. Add
    it. Removes some sparse warnings.

    Signed-off-by: Namhyung Kim
    Cc: Phillip Lougher
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Namhyung Kim
     

29 Sep, 2010

1 commit

  • The size of a built-in initramfs is calculated in init/initramfs.c by
    "__initramfs_end - __initramfs_start". Those symbols are defined in the
    linker script include/asm-generic/vmlinux.lds.h:

    #define INIT_RAM_FS \
    . = ALIGN(PAGE_SIZE); \
    VMLINUX_SYMBOL(__initramfs_start) = .; \
    *(.init.ramfs) \
    VMLINUX_SYMBOL(__initramfs_end) = .;

    If the initramfs file has an odd number of bytes, the "__initramfs_end"
    symbol points to an odd address, for example, the symbols in the
    System.map might look like:

    0000000000572000 T __initramfs_start
    00000000005bcd05 T __initramfs_end :
    540a9c: eb cf f0 78 00 24 stmg %r12,%r15,120(%r15),
    540aa2: c0 10 00 01 8a af larl %r1,572000
    540aa8: c0 c0 00 03 e1 2e larl %r12,5bcd04
    (Instead of 5bcd05)
    ...
    540abe: 1b c1 sr %r12,%r1

    To fix the problem, this patch introduces the global variable
    __initramfs_size, which is calculated in the "usr/initramfs_data.S" file.
    The populate_rootfs() function can then use the start marker of the
    .init.ramfs section and the value of __initramfs_size for loading the
    initramfs. Because the start marker and size is sufficient, the
    __initramfs_end symbol is no longer needed and is removed.

    Signed-off-by: Michael Holzheu
    Signed-off-by: Hendrik Brueckner
    Reviewed-by: WANG Cong
    Acked-by: Michal Marek
    Acked-by: "H. Peter Anvin"
    Cc: Heiko Carstens
    Cc: Martin Schwidefsky
    Signed-off-by: Andrew Morton
    Signed-off-by: Michal Marek

    Hendrik Brueckner
     

25 Apr, 2010

1 commit

  • The unpack routine fails to handle the decompress_method() returning
    unrecognised decompressor (compress_name == NULL). This results in the
    routine looping eventually oopsing on an out of bounds memory access.

    Note this bug is usually hidden, only triggering on trailing junk after
    one or more correct compressed blocks. The case of the compressed archive
    being complete junk is (by accident?) caught by the if (state != Reset)
    check because state is initialised to Start, but not updated due to the
    decompressor not having been called. Obviously if the junk is trailing a
    correctly decompressed buffer, state == Reset from the previous call to
    the decompressor.

    Signed-off-by: Phillip Lougher
    Reported-by: Aaro Koskinen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Phillip Lougher
     

07 Mar, 2010

1 commit


16 Dec, 2009

1 commit

  • The decompressors return error by calling a supplied error function, and/or
    by returning an error return value. The initramfs code, however, fails to
    check the exit code returned by the decompressor, and only checks the error
    status set by calling the error function.

    This patch adds a return code check and calls the error function.

    Signed-off-by: Phillip Lougher
    LKML-Reference:
    Signed-off-by: H. Peter Anvin

    Phillip Lougher
     

07 May, 2009

1 commit

  • With the removal of duplicate unpack_to_rootfs() (commit
    df52092f3c97788592ef72501a43fb7ac6a3cfe0) the messages displayed do not
    actually correspond to what the kernel is doing. In addition, depending
    if ramdisks are supported or not, the messages are not at all the same.

    So keep the messages more in sync with what is really doing the kernel,
    and only display a second message in case of failure. This also ensure
    that the printk message cannot be split by other printk's.

    Signed-off-by: Eric Piel
    Acked-by: H. Peter Anvin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eric Piel
     

14 Apr, 2009

2 commits

  • Change cb6ff208076b5f434db1b8c983429269d719cef5 ("NOMMU: Support XIP on
    initramfs") seems to have broken booting from initramfs with /sbin/init
    being a hardlink.

    It seems like the logic required for XIP on nommu, i.e. ftruncate to
    reported cpio header file size (body_len) is broken for hardlinks, which
    have a reported size of 0, and the truncate thus nukes the contents of the
    file (in my case busybox), making boot impossible and ending with runaway
    loop modprobe binfmt-0000 - and of course 0000 is not a valid binary
    format.

    My fix is to only call ftruncate if size is non-zero which fixes things
    for me, but I'm not certain whether this will break XIP for those files on
    nommu systems, although I would guess not.

    Signed-off-by: Randy Robertson
    Acked-by: David Howells
    Acked-by: Paul Mundt
    Acked-by: H. Peter Anvin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Robertson
     
  • init/initramfs.c:520: warning: 'clean_rootfs' defined but not used

    Signed-off-by: Nikanth Karthikesan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nikanth Karthikesan
     

03 Apr, 2009

1 commit

  • initramfs uses printk without a linefeed, then does some work, then uses
    printk to finish the message off. However if some other code does a
    printk in between, then the messages get mixed together. Better for each
    message to be an independent line...

    Example of problem that this fixes:

    checking if image is initramfs...Switched to high resolution mode on CPU 1
    Switched to high resolution mode on CPU 0
    it is

    Signed-off-by: Simon Kitching
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Simon Kitching
     

29 Mar, 2009

2 commits

  • * git://git.kernel.org/pub/scm/linux/kernel/git/arjan/linux-2.6-async-for-30:
    fastboot: remove duplicate unpack_to_rootfs()
    ide/net: flip the order of SATA and network init
    async: remove the temporary (2.6.29) "async is off by default" code

    Fix up conflicts in init/initramfs.c manually

    Linus Torvalds
     
  • we check if initrd is initramfs first and then do the real unpack. The check
    isn't required, we can directly do unpack. If the initrd isn't an
    initramfs, we can remove the garbage. In my laptop, this saves 0.1s boot
    time.

    This patch penalizes non-initramfs initrd case, but nowadays, initramfs is
    the most widely used method for initrds.

    Signed-off-by: Shaohua Li
    Acked-by: Arjan van de Ven
    Signed-off-by: Ingo Molnar

    Li, Shaohua
     

15 Jan, 2009

1 commit

  • Impact: More consistent behaviour, avoid policy in the kernel

    Upgrade/downgrade initrd/initramfs decompression failure from
    inconsistently a panic or a KERN_ALERT message to a KERN_EMERG event.
    It is, however, possible do design a system which can recover from
    this (using the kernel builtin code and/or the internal initramfs),
    which means this is policy, not a technical necessity.

    A good way to handle this would be to have a panic-level=X option, to
    force a panic on a printk above a certain level. That is a separate
    patch, however.

    Signed-off-by: H. Peter Anvin

    H. Peter Anvin
     

13 Jan, 2009

1 commit


10 Jan, 2009

2 commits


09 Jan, 2009

1 commit


08 Jan, 2009

1 commit

  • Support XIP on files unpacked from the initramfs image on NOMMU systems. This
    simply requires the length of the file to be preset so that the ramfs fs can
    attempt to garner sufficient contiguous storage to store the file (NOMMU mmap
    can only map contiguous RAM).

    All the other bits to do XIP on initramfs files are present:

    (1) ramfs's truncate attempts to allocate a contiguous run of pages when a
    file is truncated upwards from nothing.

    (2) ramfs sets BDI on its files to indicate direct mapping is possible, and
    that its files can be mapped for read, write and exec.

    (3) NOMMU mmap() will use the above bits to determine that it can do XIP.
    Possibly this needs better controls, because it will _always_ try and do
    XIP.

    One disadvantage of this very simplistic approach is that sufficient space
    will be allocated to store the whole file, and not just the bit that would be
    XIP'd. To deal with this, though, the initramfs unpacker would have to be
    able to parse the file contents.

    Signed-off-by: David Howells
    Acked-by: Paul Mundt

    David Howells
     

07 Jan, 2009

1 commit

  • Impact: Resolves build failures in some configurations

    Makes it possible to disable CONFIG_RD_GZIP . In that case, the
    built-in initramfs will be compressed by whatever compressor is
    available (bzip2 or lzma) or left uncompressed if none is available.

    It also removes a couple of warnings which occur when no ramdisk
    compression at all is chosen.

    It also restores the select ZLIB_INFLATE in drivers/block/Kconfig
    which somehow came missing. This is needed to activate compilation of
    the stuff in zlib_deflate.

    Signed-off-by: Alain Knaff
    Signed-off-by: H. Peter Anvin

    Alain Knaff
     

05 Jan, 2009

1 commit

  • Impact: New code for initramfs decompression, new features

    This is the second part of the bzip2/lzma patch

    The bzip patch is based on an idea by Christian Ludwig, includes support for
    compressing the kernel with bzip2 or lzma rather than gzip. Both
    compressors give smaller sizes than gzip. Lzma's decompresses faster
    than bzip2.

    It also supports ramdisks and initramfs' compressed using these two
    compressors.

    The functionality has been successfully used for a couple of years by
    the udpcast project

    This version applies to "tip" kernel 2.6.28

    This part contains:
    - support for new compressions (bzip2 and lzma) in initramfs and
    old-style ramdisk
    - config dialog for kernel compression (but new kernel compressions
    not yet supported)

    Signed-off-by: Alain Knaff
    Signed-off-by: H. Peter Anvin

    Alain Knaff
     

17 Oct, 2008

1 commit

  • When unpacking the cpio into the initramfs, mtimes are not preserved by
    default. This patch adds an INITRAMFS_PRESERVE_MTIME option that allows
    mtimes stored in the cpio image to be used when constructing the
    initramfs.

    For embedded applications that run exclusively out of the initramfs, this
    is invaluable:

    When building embedded application initramfs images, its nice to know when
    the files were actually created during the build process - that makes it
    easier to see what files were modified when so we can compare the files
    that are being used on the image with the files used during the build
    process. This might help (for example) to determine if the target system
    has all the updated files you expect to see w/o having to check MD5s etc.

    In our environment, the whole system runs off the initramfs partition, and
    seeing the modified times of the shared libraries (for example) helps us
    find bugs that may have been introduced by the build system incorrectly
    propogating outdated shared libraries into the image.

    Similarly, many of the initializion/configuration files in /etc might be
    dynamically built by the build system, and knowing when they were modified
    helps us sanity check whether the target system has the "latest" files
    etc.

    Finally, we might use last modified times to determine whether a hot fix
    should be applied or not to the running ramfs.

    Signed-off-by: Nye Liu
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nye Liu
     

26 Jul, 2008

1 commit

  • Inflate requires some dynamic memory allocation very early in the boot
    process and this is provided with a set of four functions:
    malloc/free/gzip_mark/gzip_release.

    The old inflate code used a mark/release strategy rather than implement
    free. This new version instead keeps a count on the number of outstanding
    allocations and when it hits zero, it resets the malloc arena.

    This allows removing all the mark and release implementations and unifying
    all the malloc/free implementations.

    The architecture-dependent code must define two addresses:
    - free_mem_ptr, the address of the beginning of the area in which
    allocations should be made
    - free_mem_end_ptr, the address of the end of the area in which
    allocations should be made. If set to 0, then no check is made on
    the number of allocations, it just grows as much as needed

    The architecture-dependent code can also provide an arch_decomp_wdog()
    function call. This function will be called several times during the
    decompression process, and allow to notify the watchdog that the system is
    still running. If an architecture provides such a call, then it must
    define ARCH_HAS_DECOMP_WDOG so that the generic inflate code calls
    arch_decomp_wdog().

    Work initially done by Matt Mackall, updated to a recent version of the
    kernel and improved by me.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Thomas Petazzoni
    Cc: Matt Mackall
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Mikael Starvik
    Cc: Jesper Nilsson
    Cc: Haavard Skinnemoen
    Cc: David Howells
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Andi Kleen
    Cc: "H. Peter Anvin"
    Acked-by: Paul Mundt
    Acked-by: Yoshinori Sato
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Petazzoni
     

29 Apr, 2008

1 commit

  • Instead of using the malloc() and free() wrappers needed by the
    lib/inflate.c code for allocations, simply use kmalloc() and kfree() in the
    initramfs code. This is needed for a further lib/inflate.c-related cleanup
    patch that will remove the malloc() and free() functions.

    Take that opportunity to remove the useless kmalloc() return value
    cast.

    Based on work done by Matt Mackall.

    Signed-off-by: Thomas Petazzoni
    Signed-off-by: Matt Mackall
    Cc: Jan Engelhardt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Petazzoni
     

16 Mar, 2008

1 commit

  • This essentially reverts commit 71fc47a9adf8ee89e5c96a47222915c5485ac437
    ("ACPI: basic initramfs DSDT override support"), because the code simply
    isn't ready.

    It did ugly things to the init sequence to populate the rootfs image
    early, but that just ended up showing other problems with the whole
    approach. The fact is, the VFS layer simply isn't initialized this
    early, and the relevant ACPI code should either run much later, or this
    shouldn't be done at all.

    For 2.6.25, we'll just pick the latter option. We can revisit this
    concept later if necessary.

    Cc: Dave Hansen
    Cc: Tilman Schmidt
    Cc: Andrew Morton
    Cc: Thomas Renninger
    Cc: Eric Piel
    Cc: Len Brown
    Cc: Christoph Hellwig
    Cc: Markus Gaugusch
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

07 Feb, 2008

2 commits

  • The basics of DSDT from initramfs. In case this option is selected,
    populate_rootfs() is called a bit earlier to have the initramfs content
    available during ACPI initialization.

    This is a very similar path to the one available at
    http://gaugusch.at/kernel.shtml but with some update in the
    documentation, default set to No and the change of populate_rootfs() the
    "Jeff Mahony way" (which avoids reading the initramfs twice).

    Signed-off-by: Thomas Renninger
    Signed-off-by: Eric Piel
    Signed-off-by: Len Brown

    Markus Gaugusch
     
  • Given that init/Makefile includes initramfs.c in the build only if
    CONFIG_BLK_DEV_INITRD is defined, there seems to be no point checking for
    it yet again.

    Signed-off-by: Robert P. J. Day
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     

27 Jul, 2007

1 commit


12 Feb, 2007

1 commit

  • Add retain_initrd option to control freeing of initrd memory after
    extraction. By default, free memory as previously.

    The first boot will need to hold a copy of the in memory fs for the second
    boot. This image can be large (much larger than the kernel), hence we can
    save time when the memory loader is slow. Also, it reduces the memory
    footprint while extracting the first boot since you don't need another copy
    of the fs.

    Signed-off-by: Michael Neuling
    Cc: "Randy.Dunlap"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Neuling
     

12 Dec, 2006

1 commit


08 Dec, 2006

1 commit

  • It turns out that the "-c" option of cpio is highly unportable even between
    distros let alone unix variants, and may actually make the wrong type of
    cpio archive. I just wasted quite some time on this, and the kernel can
    detect this and warn about it (it's __init memory so it gets thrown away
    and thus there is no runtime overhead)

    Signed-off-by: Arjan van de Ven
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven