07 Jan, 2012

1 commit


29 Nov, 2011

1 commit

  • In the case where CONFIG_PSTORE=n, the function efi_pstore_read() doesn't
    have the correct list of parameters. This patch provides a definition
    of efi_pstore_read() with 'char **buf' added to fix this warning:
    "drivers/firmware/efivars.c:609: warning: initialization from".

    problem introduced in commit f6f8285132907757ef84ef8dae0a1244b8cde6ac

    Signed-off-by: Christoph Fritz
    Signed-off-by: Tony Luck

    Christoph Fritz
     

18 Nov, 2011

2 commits

  • This allows a backend to filter on the dmesg reason as well as the pstore
    reason. When ramoops is switched to pstore, this is needed since it has
    no interest in storing non-crash dmesg details.

    Drop pstore_write() as it has no users, and handling the "reason" here
    has no obviously correct value.

    Signed-off-by: Kees Cook
    Signed-off-by: Tony Luck

    Kees Cook
     
  • The buf_lock cannot be held while populating the inodes, so make the backend
    pass forward an allocated and filled buffer instead. This solves the following
    backtrace. The effect is that "buf" is only ever used to notify the backends
    that something was written to it, and shouldn't be used in the read path.

    To replace the buf_lock during the read path, isolate the open/read/close
    loop with a separate mutex to maintain serialized access to the backend.

    Note that is is up to the pstore backend to cope if the (*write)() path is
    called in the middle of the read path.

    [ 59.691019] BUG: sleeping function called from invalid context at .../mm/slub.c:847
    [ 59.691019] in_atomic(): 0, irqs_disabled(): 1, pid: 1819, name: mount
    [ 59.691019] Pid: 1819, comm: mount Not tainted 3.0.8 #1
    [ 59.691019] Call Trace:
    [ 59.691019] [] __might_sleep+0xc3/0xca
    [ 59.691019] [] kmem_cache_alloc+0x32/0xf3
    [ 59.691019] [] ? __d_lookup_rcu+0x6f/0xf4
    [ 59.691019] [] alloc_inode+0x2a/0x64
    [ 59.691019] [] new_inode+0x18/0x43
    [ 59.691019] [] pstore_get_inode.isra.1+0x11/0x98
    [ 59.691019] [] pstore_mkfile+0xae/0x26f
    [ 59.691019] [] ? kmem_cache_free+0x19/0xb1
    [ 59.691019] [] ? ida_get_new_above+0x140/0x158
    [ 59.691019] [] ? __init_rwsem+0x1e/0x2c
    [ 59.691019] [] ? inode_init_always+0x111/0x1b0
    [ 59.691019] [] ? should_resched+0xd/0x27
    [ 59.691019] [] ? _cond_resched+0xd/0x21
    [ 59.691019] [] pstore_get_records+0x52/0xa7
    [ 59.691019] [] pstore_fill_super+0x7d/0x91
    [ 59.691019] [] mount_single+0x46/0x82
    [ 59.691019] [] pstore_mount+0x15/0x17
    [ 59.691019] [] ? pstore_get_inode.isra.1+0x98/0x98
    [ 59.691019] [] mount_fs+0x5a/0x12d
    [ 59.691019] [] ? alloc_vfsmnt+0xa4/0x14a
    [ 59.691019] [] vfs_kern_mount+0x4f/0x7d
    [ 59.691019] [] do_kern_mount+0x34/0xb2
    [ 59.691019] [] do_mount+0x5fc/0x64a
    [ 59.691019] [] ? strndup_user+0x2e/0x3f
    [ 59.691019] [] sys_mount+0x66/0x99
    [ 59.691019] [] sysenter_do_call+0x12/0x26

    Signed-off-by: Kees Cook
    Signed-off-by: Tony Luck

    Kees Cook
     

13 Oct, 2011

1 commit


17 Aug, 2011

1 commit

  • pstore was using mutex locking to protect read/write access to the
    backend plug-ins. This causes problems when pstore is executed in
    an NMI context through panic() -> kmsg_dump().

    This patch changes the mutex to a spin_lock_irqsave then also checks to
    see if we are in an NMI context. If we are in an NMI and can't get the
    lock, just print a message stating that and blow by the locking.

    All this is probably a hack around the bigger locking problem but it
    solves my current situation of trying to sleep in an NMI context.

    Tested by loading the lkdtm module and executing a HARDLOCKUP which
    will cause the machine to panic inside the nmi handler.

    Signed-off-by: Don Zickus
    Acked-by: Matthew Garrett
    Signed-off-by: Tony Luck

    Don Zickus
     

03 Aug, 2011

1 commit

  • drivers/firmware/efivars.c:161: warning: ‘utf16_strlen’ defined but not used
    utf16_strlen() is only used inside CONFIG_PSTORE - make this "static inline"
    to shut the compiler up [thanks to hpa for the suggestion].

    drivers/firmware/efivars.c:602: warning: initialization from incompatible pointer type
    Between v1 and v2 of this patch series we decided to make the "part" number
    unsigned - but missed fixing the stub version of efi_pstore_write()

    Acked-by: Matthew Garrett
    Acked-by: Mike Waychison
    Signed-off-by: Tony Luck

    Tony Luck
     

23 Jul, 2011

5 commits

  • Consolidate the attributes listed for pstore operations in one place,
    PSTORE_EFI_ATTRIBUTES.

    Signed-off-by: Mike Waychison
    Signed-off-by: Tony Luck

    Mike Waychison
     
  • Instead of open-coding the string operations for comparing the prefix of
    the variable names, use the provided utf16_* string functions.

    This patch also changes the calls to efi.set_variable to
    efivars->ops->set_variable so that the right function gets called in the
    case of gsmi (which doesn't have a valid efi structure).

    As well, make sure that we only consider variables with the right vendor
    string.

    Signed-off-by: Mike Waychison
    Signed-off-by: Tony Luck

    Mike Waychison
     
  • Introduce utf16_strncmp which is used in the next patch. Semantics
    should be the same as the strncmp C function.

    Signed-off-by: Mike Waychison
    Signed-off-by: Tony Luck

    Mike Waychison
     
  • Fix the string functions in the efivars driver to be called utf16_*
    instead of utf8_* as the encoding is utf16, not utf8.

    As well, rename utf16_strlen to utf16_strnlen as it takes a maxlength
    argument and the name should be consistent with the standard C function
    names. utf16_strlen is still provided for convenience in a subsequent
    patch.

    Signed-off-by: Mike Waychison
    Signed-off-by: Tony Luck

    Mike Waychison
     
  • EFI provides an area of nonvolatile storage managed by the firmware. We
    can use this as a pstore backend to maintain copies of oopses, aiding
    diagnosis.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Tony Luck

    Matthew Garrett
     

24 May, 2011

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (39 commits)
    b43: fix comment typo reqest -> request
    Haavard Skinnemoen has left Atmel
    cris: typo in mach-fs Makefile
    Kconfig: fix copy/paste-ism for dell-wmi-aio driver
    doc: timers-howto: fix a typo ("unsgined")
    perf: Only include annotate.h once in tools/perf/util/ui/browsers/annotate.c
    md, raid5: Fix spelling error in comment ('Ofcourse' --> 'Of course').
    treewide: fix a few typos in comments
    regulator: change debug statement be consistent with the style of the rest
    Revert "arm: mach-u300/gpio: Fix mem_region resource size miscalculations"
    audit: acquire creds selectively to reduce atomic op overhead
    rtlwifi: don't touch with treewide double semicolon removal
    treewide: cleanup continuations and remove logging message whitespace
    ath9k_hw: don't touch with treewide double semicolon removal
    include/linux/leds-regulator.h: fix syntax in example code
    tty: fix typo in descripton of tty_termios_encode_baud_rate
    xtensa: remove obsolete BKL kernel option from defconfig
    m68k: fix comment typo 'occcured'
    arch:Kconfig.locks Remove unused config option.
    treewide: remove extra semicolons
    ...

    Linus Torvalds
     

10 May, 2011

1 commit


07 May, 2011

1 commit

  • efivars_exit() should check for efi_enabled and not undo
    allocations when efi is not enabled. Otherwise there is an Oops
    during module unload:

    calling efivars_init+0x0/0x1000 [efivars] @ 2810
    EFI Variables Facility v0.08 2004-May-17
    initcall efivars_init+0x0/0x1000 [efivars] returned 0 after 5120 usecs
    Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
    last sysfs file: /sys/module/firmware_class/initstate
    CPU 1
    Modules linked in: efivars(-) af_packet tun nfsd lockd nfs_acl auth_rpcgss sunrpc ipt_REJECT nf_conntrack_ipv4 nf_defrag_ipv4 iptable_filter ip_tables ip6t_REJECT xt_tcpudp nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables x_tables ipv6 cpufreq_ondemand acpi_cpufreq freq_table mperf binfmt_misc dm_mirror dm_region_hash dm_log dm_multipath scsi_dh dm_mod snd_hda_codec_analog snd_hda_intel snd_hda_codec snd_hwdep mousedev snd_seq joydev snd_seq_device mac_hid evdev snd_pcm usbkbd usbmouse usbhid snd_timer hid tg3 snd sr_mod pcspkr rtc_cmos soundcore cdrom iTCO_wdt processor sg dcdbas i2c_i801 rtc_core iTCO_vendor_support intel_agp snd_page_alloc thermal_sys rtc_lib intel_gtt 8250_pnp button hwmon unix ide_pci_generic ide_core ata_generic pata_acpi ata_piix sd_mod crc_t10dif ext3 jbd mbcache uhci_hcd ohci_hcd ssb mmc_core pcmcia pcmcia_core firmware_class ehci_hcd usbcore [last unloaded: dell_rbu]

    Pid: 2812, comm: rmmod Not tainted 2.6.39-rc6 #1 Dell Inc. OptiPlex 745 /0TY565
    RIP: 0010:[] [] unregister_efivars+0x28/0x12c [efivars]
    RSP: 0018:ffff88005eedde98 EFLAGS: 00010283
    RAX: ffffffffa06a23fc RBX: ffffffffa06a44c0 RCX: ffff88007c227a50
    RDX: 0000000000000000 RSI: 00000055ac13db78 RDI: ffffffffa06a44c0
    RBP: ffff88005eeddec8 R08: 0000000000000000 R09: ffff88005eeddd78
    R10: ffffffffa06a4220 R11: ffff88005eeddd78 R12: fffffffffffff7d0
    R13: 00007fff5a3aaec0 R14: 0000000000000000 R15: ffffffffa06a4508
    FS: 00007fa8dcc4a6f0(0000) GS:ffff88007c200000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    CR2: 0000000000000000 CR3: 000000005d148000 CR4: 00000000000006e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    Process rmmod (pid: 2812, threadinfo ffff88005eedc000, task ffff88006754b000)
    Stack:
    ffff88005eeddec8 ffffffffa06a4220 0000000000000000 00007fff5a3aaec0
    0000000000000000 0000000000000001 ffff88005eedded8 ffffffffa06a2418
    ffff88005eeddf78 ffffffff810d3598 ffffffffa06a4220 0000000000000880
    Call Trace:
    [] efivars_exit+0x1c/0xc04 [efivars]
    [] sys_delete_module+0x2d6/0x368
    [] ? lockdep_sys_exit_thunk+0x35/0x67
    [] ? audit_syscall_entry+0x172/0x1a5
    [] system_call_fastpath+0x16/0x1b
    Code: 5c c9 c3 55 48 89 e5 41 57 41 56 41 55 41 54 53 48 83 ec 08 0f 1f 44 00 00 4c 8b 67 48 48 89 fb 4c 8d 7f 48 49 81 ec 30 08 00 00 8b ac 24 30 08 00 00 49 81 ed 30 08 00 00 eb 59 48 89 df 48
    RIP [] unregister_efivars+0x28/0x12c [efivars]
    RSP
    CR2: 0000000000000000
    ---[ end trace aa99b99090f70baa ]---

    Matt apparently removed such a check in 2004 (with no reason given):
    * 17 May 2004 - Matt Domsch
    * remove check for efi_enabled in exit
    but there have been several changes since then.

    Signed-off-by: Randy Dunlap
    Signed-off-by: Mike Waychison
    Tested-by: Randy Dunlap
    Cc: Matt Domsch
    Cc:
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     

20 Apr, 2011

2 commits


14 Mar, 2011

6 commits

  • Signed-off-by: Mike Waychison
    Cc: Matt Domsch ,
    Signed-off-by: Greg Kroah-Hartman

    Mike Waychison
     
  • Instead of letting efivars access struct efi directly when dealing with
    variables, use an operations structure. This allows a later change to
    reuse the efivars logic without having to pretend to support everything
    in struct efi.

    Signed-off-by: Mike Waychison
    Cc: Matt Domsch ,
    Signed-off-by: Greg Kroah-Hartman

    Mike Waychison
     
  • In anticipation of re-using the variable facilities in efivars from
    elsewhere, split out the registration and unregistration of struct
    efivars from the rest of the EFI specific sysfs code.

    Signed-off-by: Mike Waychison
    Cc: Matt Domsch ,
    Signed-off-by: Greg Kroah-Hartman

    Mike Waychison
     
  • Now that we all global variable state is encapsulated by struct efivars,
    parameterize all functions to the efivars local to the control flow rather
    than at file scope. We do this by removing the variable "efivars" at file
    scope and move its storage down to the end of the file.

    Variables get at efivars by storing the efivars pointer within each
    efivar_entry. The "new_var" and "del_var" binary attribute files get at
    the efivars through the private pointer.

    Signed-off-by: Mike Waychison
    Cc: Matt Domsch ,
    Signed-off-by: Greg Kroah-Hartman

    Mike Waychison
     
  • In preparation for encapsulating efivars, we need to have the
    bin_attributes be dynamically allocated so that we can use their
    ->private fields to get back to the struct efivars structure.

    Signed-off-by: Mike Waychison
    Cc: Matt Domsch ,
    Signed-off-by: Greg Kroah-Hartman

    Mike Waychison
     
  • In preparation for abstracting out efivars to be usable by other similar
    variable services, move the global lock, list and kset into a structure.
    Later patches will change the scope of 'efivars' and have it be passed
    by function argument.

    Signed-off-by: Mike Waychison
    Cc: Matt Domsch ,
    Signed-off-by: Greg Kroah-Hartman

    Mike Waychison
     

22 May, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

08 Mar, 2010

1 commit

  • Constify struct sysfs_ops.

    This is part of the ops structure constification
    effort started by Arjan van de Ven et al.

    Benefits of this constification:

    * prevents modification of data that is shared
    (referenced) by many other structure instances
    at runtime

    * detects/prevents accidental (but not intentional)
    modification attempts on archs that enforce
    read-only kernel data at runtime

    * potentially better optimized code as the compiler
    can assume that the const data cannot be changed

    * the compiler/linker move const data into .rodata
    and therefore exclude them from false sharing

    Signed-off-by: Emese Revfy
    Acked-by: David Teigland
    Acked-by: Matt Domsch
    Acked-by: Maciej Sosnowski
    Acked-by: Hans J. Koch
    Acked-by: Pekka Enberg
    Acked-by: Jens Axboe
    Acked-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Emese Revfy
     

25 Jan, 2008

9 commits


13 Oct, 2007

1 commit


12 Jul, 2007

1 commit

  • sysfs is now completely out of driver/module lifetime game. After
    deletion, a sysfs node doesn't access anything outside sysfs proper,
    so there's no reason to hold onto the attribute owners. Note that
    often the wrong modules were accounted for as owners leading to
    accessing removed modules.

    This patch kills now unnecessary attribute->owner. Note that with
    this change, userland holding a sysfs node does not prevent the
    backing module from being unloaded.

    For more info regarding lifetime rule cleanup, please read the
    following message.

    http://article.gmane.org/gmane.linux.kernel/510293

    (tweaked by Greg to not delete the field just yet, to make it easier to
    merge things properly.)

    Signed-off-by: Tejun Heo
    Cc: Cornelia Huck
    Cc: Andrew Morton
    Signed-off-by: Greg Kroah-Hartman

    Tejun Heo
     

03 May, 2007

1 commit


27 Jan, 2007

1 commit

  • Fix race when deleting an EFI variable and issuing another EFI command on
    the same variable. The removal of the variable from the efivars_list
    should be done in efivar_delete and not delayed until the kobject release.

    Furthermore, remove the item from the list at module unload time, and use
    list_for_each_entry_safe() rather than list_for_each_safe() for
    readability.

    Tested on ia64.

    Signed-off-by: Prarit Bhargava
    Signed-off-by: Matt Domsch
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matt Domsch
     

12 Oct, 2006

1 commit