18 Jul, 2012

9 commits

  • Decoding the binary trace w/ a different kernel might be troublesome
    since we convert addresses to symbols. For kernels with minimal changes,
    the mappings would probably match, but it's not guaranteed at all.
    (But still we could convert the addresses by hand, since we do print
    raw addresses.)

    If we use modules, the symbols could be loaded at different addresses
    from the previously booted kernel, and so this would also fail, but
    there's nothing we can do about it.

    Also, the binary data format that pstore/ram is using in its ringbuffer
    may change between the kernels, so here we too must ensure that we're
    running the same kernel.

    So, there are two questions really:

    1. How to compute the unique kernel tag;
    2. Where to store it.

    In this patch we're using LINUX_VERSION_CODE, just as hibernation
    (suspend-to-disk) does. This way we are protecting from the kernel
    version mismatch, making sure that we're running the same kernel
    version and patch level. We could use CRC of a symbol table (as
    suggested by Tony Luck), but for now let's not be that strict.

    And as for storing, we are using a small trick here. Instead of
    allocating a dedicated buffer for the tag (i.e. another prz), or
    hacking ram_core routines to "reserve" some control data in the
    buffer, we are just encoding the tag into the buffer signature
    (and XOR'ing it with the actual signature value, so that buffers
    not needing a tag can just pass zero, which will result into the
    plain old PRZ signature).

    Suggested-by: Steven Rostedt
    Suggested-by: Tony Luck
    Suggested-by: Colin Cross
    Signed-off-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Headers should really include all the needed prototypes, types, defines
    etc. to be self-contained. This is a long-standing issue, but apparently
    the new tracing code unearthed it (SMP=n is also a prerequisite):

    In file included from fs/pstore/internal.h:4:0,
    from fs/pstore/ftrace.c:21:
    include/linux/pstore.h:43:15: error: field ‘read_mutex’ has incomplete type

    While at it, I also added the following:

    linux/types.h -> size_t, phys_addr_t, uXX and friends
    linux/spinlock.h -> spinlock_t
    linux/errno.h -> Exxxx
    linux/time.h -> struct timespec (struct passed by value)
    struct module and rs_control forward declaration (passed via pointers).

    Signed-off-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • The ftrace log size is configurable via ramoops.ftrace_size
    module option, and the log itself is available via
    /ftrace-ramoops file.

    Signed-off-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Don't use pstore.buf directly, instead convert the code to write_buf callback
    which passes a pointer to a buffer as an argument.

    Signed-off-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • With this support kernel can save function call chain log into a
    persistent ram buffer that can be decoded and dumped after reboot
    through pstore filesystem. It can be used to determine what function
    was last called before a reset or panic.

    We store the log in a binary format and then decode it at read time.

    p.s.
    Mostly the code comes from trace_persistent.c driver found in the
    Android git tree, written by Colin Cross
    (according to sign-off history). I reworked the driver a little bit,
    and ported it to pstore.

    Signed-off-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • For function tracing we need to stop using pstore.buf directly, since
    in a tracing callback we can't use spinlocks, and thus we can't safely
    use the global buffer.

    With write_buf callback, backends no longer need to access pstore.buf
    directly, and thus we can pass any buffers (e.g. allocated on stack).

    Signed-off-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Nowadays we can use prz->ecc_size as a flag, no need for the special
    member in the prz struct.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • This is now pretty straightforward: instead of using bool, just pass
    an integer. For backwards compatibility ramoops.ecc=1 means 16 bytes
    ECC (using 1 byte for ECC isn't much of use anyway).

    Suggested-by: Arve Hjønnevåg
    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • The struct members were never used anywhere outside of
    persistent_ram_init_ecc(), so there's actually no need for them
    to be in the struct.

    If we ever want to make polynomial or symbol size configurable,
    it would make more sense to just pass initialized rs_decoder
    to the persistent_ram init functions.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     

26 Jun, 2012

1 commit


21 Jun, 2012

5 commits

  • - Instead of exploiting unsigned overflows (which doesn't work for all
    sizes), use straightforward checking for ECC total size not exceeding
    initial buffer size;

    - Printing overflowed buffer_size is not informative. Instead, print
    ecc_size and buffer_size;

    - No need for buffer_size argument in persistent_ram_init_ecc(),
    we can address prz->buffer_size directly.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • We will implement variable-sized ECC buffers soon, so post_init routine
    might fail much more likely, so we'd better check for its errors.

    To make error handling simple, modify persistent_ram_free() to it be safe
    at all times.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • persistent_ram_new() returns ERR_PTR() value on errors, so during
    freeing of the przs we should check for both NULL and IS_ERR() entries,
    otherwise bad things will happen.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Registering the platform driver before module_init allows us to log oopses
    that happen during device probing.

    This requires changing module_init to postcore_initcall, and switching
    from platform_driver_probe to platform_driver_register because the
    platform device is not registered when the platform driver is registered;
    and because we use driver_register, now can't use create_bundle() (since
    it will try to register the same driver once again), so we have to switch
    to platform_device_register_data().

    Also, some __init -> __devinit changes were needed.

    Overall, the registration logic is now much clearer, since we have only
    one driver registration point, and just an optional dummy device, which
    is created from the module parameters.

    Suggested-by: Colin Cross
    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Pull staging tree fixes from Greg Kroah-Hartman:
    "Here are a number of small fixes for the drivers/staging tree, as well
    as iio and pstore drivers (which came from the staging tree in the
    3.5-rc1 merge). All of these are tiny, but resolve issues that people
    have been reporting.

    There's also a documentation update to reflect what the iio drivers
    really are doing, which is good to get straightened out.

    Signed-off-by: Greg Kroah-Hartman "

    * tag 'staging-3.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
    staging: r8712u: Add new USB IDs
    staging: gdm72xx: Release netlink socket properly
    iio: drop wrong reference from Kconfig
    pstore/inode: Make pstore_fill_super() static
    pstore/ram: Should zap persistent zone on unlink
    pstore/ram_core: Factor persistent_ram_zap() out of post_init()
    pstore/ram_core: Do not reset restored zone's position and size
    pstore/ram: Should update old dmesg buffer before reading
    staging:iio:ad7298: Fix linker error due to missing IIO kfifo buffer
    Revert "staging: usbip: bugfix for stack corruption on 64-bit architectures"
    staging: usbip: bugfix for stack corruption on 64-bit architectures
    staging/comedi: fix build for USB not enabled
    staging: omapdrm: fix crash when freeing bad fb
    staging:iio:ad7606: Re-add missing scale attribute
    iio: Fix potential use after free
    staging:iio: remove num_interrupt_lines from documentation
    iio: documentation: Add out_altvoltage and friends

    Linus Torvalds
     

16 Jun, 2012

1 commit

  • Provide an iterator to receive the log buffer content, and convert all
    kmsg_dump() users to it.

    The structured data in the kmsg buffer now contains binary data, which
    should no longer be copied verbatim to the kmsg_dump() users.

    The iterator should provide reliable access to the buffer data, and also
    supports proper log line-aware chunking of data while iterating.

    Signed-off-by: Kay Sievers
    Tested-by: Tony Luck
    Reported-by: Anton Vorontsov
    Tested-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

14 Jun, 2012

14 commits

  • Having automatic updates seems pointless for production system, and
    even dangerous and thus counter-productive:

    1. If we can mount pstore, or read files, we can as well read
    /proc/kmsg. So, there's little point in duplicating the
    functionality and present the same information but via another
    userland ABI;

    2. Expecting the kernel to behave sanely after oops/panic is naive.
    It might work, but you'd rather not try it. Screwed up kernel
    can do rather bad things, like recursive faults[1]; and pstore
    rather provoking bad things to happen. It uses:

    1. Timers (assumes sane interrupts state);
    2. Workqueues and mutexes (assumes scheduler in a sane state);
    3. kzalloc (a working slab allocator);

    That's too much for a dead kernel, so the debugging facility
    itself might just make debugging harder, which is not what
    we want.

    Maybe for non-oops message types it would make sense to re-enable
    automatic updates, but so far I don't see any use case for this.
    Even for tracing, it has its own run-time/normal ABI, so we're
    only interested in pstore upon next boot, to retrieve what has
    gone wrong with HW or SW.

    So, let's disable the updates by default.

    [1]
    BUG: unable to handle kernel paging request at fffffffffffffff8
    IP: [] kthread_data+0xb/0x20
    [...]
    Process kworker/0:1 (pid: 14, threadinfo ffff8800072c0000, task ffff88000725b100)
    [...
    Call Trace:
    [] wq_worker_sleeping+0x10/0xa0
    [] __schedule+0x568/0x7d0
    [] ? trace_hardirqs_on+0xd/0x10
    [] ? call_rcu_sched+0x12/0x20
    [] ? release_task+0x156/0x2d0
    [] ? release_task+0x1e/0x2d0
    [] ? trace_hardirqs_on+0xd/0x10
    [] schedule+0x24/0x70
    [] do_exit+0x1f8/0x370
    [] oops_end+0x77/0xb0
    [] no_context+0x1a6/0x1b5
    [] __bad_area_nosemaphore+0x1ce/0x1ed
    [] ? ttwu_queue+0xc6/0xe0
    [] bad_area_nosemaphore+0xe/0x10
    [] do_page_fault+0x2c7/0x450
    [] ? __lock_release+0x6b/0xe0
    [] ? mark_held_locks+0x61/0x140
    [] ? __wake_up+0x4e/0x70
    [] ? trace_hardirqs_off_thunk+0x3a/0x3c
    [] ? pstore_register+0x120/0x120
    [] page_fault+0x1f/0x30
    [] ? pstore_register+0x120/0x120
    [] ? memcpy+0x68/0x110
    [] ? pstore_get_records+0x3a/0x130
    [] ? persistent_ram_copy_old+0x64/0x90
    [] ramoops_pstore_read+0x84/0x130
    [] pstore_get_records+0x79/0x130
    [] ? process_one_work+0x116/0x450
    [] ? pstore_register+0x120/0x120
    [] pstore_dowork+0xe/0x10
    [] process_one_work+0x174/0x450
    [] ? process_one_work+0x116/0x450
    [] worker_thread+0x123/0x2d0
    [] ? manage_workers.isra.28+0x120/0x120
    [] kthread+0x8e/0xa0
    [] kernel_thread_helper+0x4/0x10
    [] ? retint_restore_args+0xe/0xe
    [] ? __init_kthread_worker+0x70/0x70
    [] ? gs_change+0xb/0xb
    Code: be e2 00 00 00 48 c7 c7 d1 2a 4e 81 e8 bf fb fd ff 48 8b 5d f0 4c 8b 65 f8 c9 c3 0f 1f 44 00 00 48 8b 87 08 02 00 00 55 48 89 e5 8b 40 f8 5d c3 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00
    RIP [] kthread_data+0xb/0x20
    RSP
    CR2: fffffffffffffff8
    ---[ end trace 996a332dc399111d ]---
    Fixing recursive fault but reboot is needed!

    Signed-off-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • There is no behavioural change, the default value is still 60 seconds.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • The code tried to maintain the global list of persistent ram zones,
    which isn't a great idea overall, plus since Android's ram_console
    is no longer there, we can remove some unused functions.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Acked-by: Colin Cross
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Since we use multiple regions, the messages are somewhat annoying.
    We do print total mapped memory already, so no need to print the
    information for each region in the library routines.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Acked-by: Colin Cross
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • The console log size is configurable via ramoops.console_size
    module option, and the log itself is available via
    /console-ramoops file.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • This will help make code clearer when we'll add support for other
    message types.

    The patch also changes return value from -EINVAL to 0 in case of
    end-of-records. The exact value doesn't matter for pstore (it should
    be just
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • This will help make code clearer when we'll add support for other
    message types.

    This also makes probe() much shorter and understandable, plus
    makes mem/record size checking a bit easier.

    Implementation detail: we now use a paddr pointer, this will
    be used for allocating persistent ram zones for other message
    types.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • We're about to add support for other message types, so let's rename
    some variables to not be confused later.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Pstore doesn't support logging kernel messages in run-time, it only
    dumps dmesg when kernel oopses/panics. This makes pstore useless for
    debugging hangs caused by HW issues or improper use of HW (e.g.
    weird device inserted -> driver tried to write a reserved bits ->
    SoC hanged. In that case we don't get any messages in the pstore.

    Therefore, let's add a runtime logging support: PSTORE_TYPE_CONSOLE.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Acked-by: Colin Cross
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • There's no reason to extern it. The patch fixes the annoying sparse
    warning:

    CHECK fs/pstore/inode.c
    fs/pstore/inode.c:264:5: warning: symbol 'pstore_fill_super' was not
    declared. Should it be static?

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Otherwise, unlinked file will reappear on the next boot.

    Reported-by: Kees Cook
    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • A handy function that we will use outside of ram_core soon. But
    so far just factor it out and start using it in post_init().

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Otherwise, the files will survive just one reboot, and on a subsequent
    boot they will disappear.

    Signed-off-by: Anton Vorontsov
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • Without the update, we'll only see the new dmesg buffer after the
    reboot, but previously we could see it right away. Making an oops
    visible in pstore filesystem before reboot is a somewhat dubious
    feature, but removing it wasn't an intentional change, so let's
    restore it.

    For this we have to make persistent_ram_save_old() safe for calling
    multiple times, and also extern it.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     

29 May, 2012

1 commit

  • Pull writeback tree from Wu Fengguang:
    "Mainly from Jan Kara to avoid iput() in the flusher threads."

    * tag 'writeback' of git://git.kernel.org/pub/scm/linux/kernel/git/wfg/linux:
    writeback: Avoid iput() from flusher thread
    vfs: Rename end_writeback() to clear_inode()
    vfs: Move waiting for inode writeback from end_writeback() to evict_inode()
    writeback: Refactor writeback_single_inode()
    writeback: Remove wb->list_lock from writeback_single_inode()
    writeback: Separate inode requeueing after writeback
    writeback: Move I_DIRTY_PAGES handling
    writeback: Move requeueing when I_SYNC set to writeback_sb_inodes()
    writeback: Move clearing of I_SYNC into inode_sync_complete()
    writeback: initialize global_dirty_limit
    fs: remove 8 bytes of padding from struct writeback_control on 64 bit builds
    mm: page-writeback.c: local functions should not be exposed globally

    Linus Torvalds
     

17 May, 2012

3 commits

  • This is now straightforward: just introduce a module parameter and pass
    the needed value to persistent_ram_new().

    Signed-off-by: Anton Vorontsov
    Acked-by: Marco Stornelli
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • The patch switches pstore RAM backend to use persistent_ram routines,
    one step closer to the ECC support.

    Signed-off-by: Anton Vorontsov
    Acked-by: Marco Stornelli
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     
  • This is a first step for adding ECC support for pstore RAM backend: we
    will use the persistent_ram routines, kindly provided by Google.

    Basically, persistent_ram is a set of helper routines to deal with the
    [optionally] ECC-protected persistent ram regions.

    A bit of Makefile, Kconfig and header files adjustments were needed
    because of the move.

    Signed-off-by: Anton Vorontsov
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     

16 May, 2012

1 commit

  • Since ramoops was converted to pstore, it has nothing to do with character
    devices nowadays. Instead, today it is just a RAM backend for pstore.

    The patch just moves things around. There are a few changes were needed
    because of the move:

    1. Kconfig and Makefiles fixups, of course.

    2. In pstore/ram.c we have to play a bit with MODULE_PARAM_PREFIX, this
    is needed to keep user experience the same as with ramoops driver
    (i.e. so that ramoops.foo kernel command line arguments would still
    work).

    Signed-off-by: Anton Vorontsov
    Acked-by: Marco Stornelli
    Acked-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Anton Vorontsov
     

06 May, 2012

1 commit

  • After we moved inode_sync_wait() from end_writeback() it doesn't make sense
    to call the function end_writeback() anymore. Rename it to clear_inode()
    which well says what the function really does - set I_CLEAR flag.

    Signed-off-by: Jan Kara
    Signed-off-by: Fengguang Wu

    Jan Kara
     

06 Apr, 2012

2 commits

  • Merge batch of fixes from Andrew Morton:
    "The simple_open() cleanup was held back while I wanted for laggards to
    merge things.

    I still need to send a few checkpoint/restore patches. I've been
    wobbly about merging them because I'm wobbly about the overall
    prospects for success of the project. But after speaking with Pavel
    at the LSF conference, it sounds like they're further toward
    completion than I feared - apparently davem is at the "has stopped
    complaining" stage regarding the net changes. So I need to go back
    and re-review those patchs and their (lengthy) discussion."

    * emailed from Andrew Morton : (16 patches)
    memcg swap: use mem_cgroup_uncharge_swap fix
    backlight: add driver for DA9052/53 PMIC v1
    C6X: use set_current_blocked() and block_sigmask()
    MAINTAINERS: add entry for sparse checker
    MAINTAINERS: fix REMOTEPROC F: typo
    alpha: use set_current_blocked() and block_sigmask()
    simple_open: automatically convert to simple_open()
    scripts/coccinelle/api/simple_open.cocci: semantic patch for simple_open()
    libfs: add simple_open()
    hugetlbfs: remove unregister_filesystem() when initializing module
    drivers/rtc/rtc-88pm860x.c: fix rtc irq enable callback
    fs/xattr.c:setxattr(): improve handling of allocation failures
    fs/xattr.c:listxattr(): fall back to vmalloc() if kmalloc() failed
    fs/xattr.c: suppress page allocation failure warnings from sys_listxattr()
    sysrq: use SEND_SIG_FORCED instead of force_sig()
    proc: fix mount -t proc -o AAA

    Linus Torvalds
     
  • Many users of debugfs copy the implementation of default_open() when
    they want to support a custom read/write function op. This leads to a
    proliferation of the default_open() implementation across the entire
    tree.

    Now that the common implementation has been consolidated into libfs we
    can replace all the users of this function with simple_open().

    This replacement was done with the following semantic patch:

    @ open @
    identifier open_f != simple_open;
    identifier i, f;
    @@
    -int open_f(struct inode *i, struct file *f)
    -{
    (
    -if (i->i_private)
    -f->private_data = i->i_private;
    |
    -f->private_data = i->i_private;
    )
    -return 0;
    -}

    @ has_open depends on open @
    identifier fops;
    identifier open.open_f;
    @@
    struct file_operations fops = {
    ...
    -.open = open_f,
    +.open = simple_open,
    ...
    };

    [akpm@linux-foundation.org: checkpatch fixes]
    Signed-off-by: Stephen Boyd
    Cc: Greg Kroah-Hartman
    Cc: Al Viro
    Cc: Julia Lawall
    Acked-by: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Boyd
     

01 Apr, 2012

1 commit


24 Mar, 2012

1 commit