14 Feb, 2014

23 commits

  • For LTO we need to run the link step with gcc, not ld.
    Since there are a lot of linker options passed to it, add a gcc-ld wrapper
    that wraps them as -Wl,

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-10-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • To check the linker version. Used by the LTO makefile.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-9-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • LTO turns all global symbols effectively into statics. This
    has the side effect that they all have a .NUMBER postfix to make
    them unique. In modpost drop this postfix because it confuses
    it.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-8-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • This reference is discarded, but can cause warnings when it refers to
    exit. Ignore for now.

    This is a workaround and can be removed once we get rid of
    -fno-toplevel-reorder

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-7-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • The assembler alias code in cond_syscall does not work
    when compiled for LTO. Just disable LTO for that file.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-6-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • Here is the workaround I made for having the kernel not reject modules
    built with -flto. The clean solution would be to get the compiler to not
    emit the symbol. Or if it has to emit the symbol, then emit it as
    initialized data but put it into a comdat/linkonce section.

    Minor tweaks by AK over Joe's patch.

    Cc: Rusty Russell
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-5-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Joe Mario
     
  • Work around a LTO gcc problem: when there is no reference to a variable
    in a module it will be moved to the end of the program. This causes
    reordering of initcalls which the kernel does not like.
    Add a dummy reference function to avoid this. The function is
    deleted by the linker.

    This replaces a previous much slower workaround.

    Thanks to Jan "Honza" Hubička for suggesting this technique.

    Suggested-by: Jan Hubička
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-4-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-3-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • The VDSO does not play well with LTO, so just disable LTO for it.
    Also pass a 32bit linker flag for the 32bit version.

    [ hpa: change braces to parens to match kernel Makefile style ]

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-1-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • const data must be initconst.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-14-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • const must be __initconst.

    Cc: Douglas_Warzecha@dell.com
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-13-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • These functions are called from assembler, and thus need to be
    __visible.

    Cc: Steven Rostedt
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-12-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • These functions can be called implicitely from gcc, and thus need to be
    visible.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-11-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • In LTO symbols implicitely referenced by the compiler need
    to be visible. Earlier these symbols were visible implicitely
    from being exported, but we disabled implicit visibility fo
    EXPORTs when modules are disabled to improve code size. So
    now these symbols have to be marked visible explicitely.

    Do this for __stack_chk_fail (with stack protector)
    and memcmp.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-10-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • Mark the rwsem functions that can be called from assembler asmlinkage.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-9-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • main_extable_sort_needed is used by the build system and needs
    to be a normal ELF symbol. Make it visible so that LTO
    does not remove or mangle it.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-8-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • Various kernel/mutex.c functions can be called from
    inline assembler, so they should be all global and
    __visible.

    Cc: Ingo Molnar
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-7-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • Can be called from assembler code.

    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-6-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • lockdep_sys_exit can be called from assembler code, so make it
    asmlinkage.

    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-5-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • Mark variables referenced from assembler files visible.

    This fixes compile problems with LTO.

    Cc: Jaroslav Kysela
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-4-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • Jiffies is referenced by the linker script, so it has to be visible.

    Handled both the generic and the x86 version.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-3-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • This is a assembler function on x86, so it should be visible.

    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-2-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     
  • kvm_rebooting is referenced from assembler code, thus
    needs to be visible.

    Cc: Gleb Natapov
    Cc: Paolo Bonzini
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391845930-28580-1-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Andi Kleen
     

10 Feb, 2014

8 commits

  • Linus Torvalds
     
  • Pull SELinux fixes from James Morris.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    SELinux: Fix kernel BUG on empty security contexts.
    selinux: add SOCK_DIAG_BY_FAMILY to the list of netlink message types

    Linus Torvalds
     
  • Pull vfs fixes from Al Viro:
    "A couple of fixes, both -stable fodder. The O_SYNC bug is fairly
    old..."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fix a kmap leak in virtio_console
    fix O_SYNC|O_APPEND syncing the wrong range on write()

    Linus Torvalds
     
  • James Morris
     
  • While we are at it, don't do kmap() under kmap_atomic(), *especially*
    for a page we'd allocated with GFP_KERNEL. It's spelled "page_address",
    and had that been more than that, we'd have a real trouble - kmap_high()
    can block, and doing that while holding kmap_atomic() is a Bad Idea(tm).

    Signed-off-by: Al Viro

    Al Viro
     
  • It actually goes back to 2004 ([PATCH] Concurrent O_SYNC write support)
    when sync_page_range() had been introduced; generic_file_write{,v}() correctly
    synced
    pos_after_write - written .. pos_after_write - 1
    but generic_file_aio_write() synced
    pos_before_write .. pos_before_write + written - 1
    instead. Which is not the same thing with O_APPEND, obviously.
    A couple of years later correct variant had been killed off when
    everything switched to use of generic_file_aio_write().

    All users of generic_file_aio_write() are affected, and the same bug
    has been copied into other instances of ->aio_write().

    The fix is trivial; the only subtle point is that generic_write_sync()
    ought to be inlined to avoid calculations useless for the majority of
    calls.

    Signed-off-by: Al Viro

    Al Viro
     
  • Pull btrfs fixes from Chris Mason:
    "This is a small collection of fixes"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
    Btrfs: fix data corruption when reading/updating compressed extents
    Btrfs: don't loop forever if we can't run because of the tree mod log
    btrfs: reserve no transaction units in btrfs_ioctl_set_features
    btrfs: commit transaction after setting label and features
    Btrfs: fix assert screwup for the pending move stuff

    Linus Torvalds
     
  • Pull perf fixes from Ingo Molnar:
    "Tooling fixes, mostly related to the KASLR fallout, but also other
    fixes"

    * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    perf buildid-cache: Check relocation when checking for existing kcore
    perf tools: Adjust kallsyms for relocated kernel
    perf tests: No need to set up ref_reloc_sym
    perf symbols: Prevent the use of kcore if the kernel has moved
    perf record: Get ref_reloc_sym from kernel map
    perf machine: Set up ref_reloc_sym in machine__create_kernel_maps()
    perf machine: Add machine__get_kallsyms_filename()
    perf tools: Add kallsyms__get_function_start()
    perf symbols: Fix symbol annotation for relocated kernel
    perf tools: Fix include for non x86 architectures
    perf tools: Fix AAAAARGH64 memory barriers
    perf tools: Demangle kernel and kernel module symbols too
    perf/doc: Remove mention of non-existent set_perf_event_pending() from design.txt

    Linus Torvalds
     

09 Feb, 2014

9 commits

  • When using a mix of compressed file extents and prealloc extents, it
    is possible to fill a page of a file with random, garbage data from
    some unrelated previous use of the page, instead of a sequence of zeroes.

    A simple sequence of steps to get into such case, taken from the test
    case I made for xfstests, is:

    _scratch_mkfs
    _scratch_mount "-o compress-force=lzo"
    $XFS_IO_PROG -f -c "pwrite -S 0x06 -b 18670 266978 18670" $SCRATCH_MNT/foobar
    $XFS_IO_PROG -c "falloc 26450 665194" $SCRATCH_MNT/foobar
    $XFS_IO_PROG -c "truncate 542872" $SCRATCH_MNT/foobar
    $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar

    This results in the following file items in the fs tree:

    item 4 key (257 INODE_ITEM 0) itemoff 15879 itemsize 160
    inode generation 6 transid 6 size 542872 block group 0 mode 100600
    item 5 key (257 INODE_REF 256) itemoff 15863 itemsize 16
    inode ref index 2 namelen 6 name: foobar
    item 6 key (257 EXTENT_DATA 0) itemoff 15810 itemsize 53
    extent data disk byte 0 nr 0 gen 6
    extent data offset 0 nr 24576 ram 266240
    extent compression 0
    item 7 key (257 EXTENT_DATA 24576) itemoff 15757 itemsize 53
    prealloc data disk byte 12849152 nr 241664 gen 6
    prealloc data offset 0 nr 241664
    item 8 key (257 EXTENT_DATA 266240) itemoff 15704 itemsize 53
    extent data disk byte 12845056 nr 4096 gen 6
    extent data offset 0 nr 20480 ram 20480
    extent compression 2
    item 9 key (257 EXTENT_DATA 286720) itemoff 15651 itemsize 53
    prealloc data disk byte 13090816 nr 405504 gen 6
    prealloc data offset 0 nr 258048

    The on disk extent at offset 266240 (which corresponds to 1 single disk block),
    contains 5 compressed chunks of file data. Each of the first 4 compress 4096
    bytes of file data, while the last one only compresses 3024 bytes of file data.
    Therefore a read into the file region [285648 ; 286720[ (length = 4096 - 3024 =
    1072 bytes) should always return zeroes (our next extent is a prealloc one).

    The solution here is the compression code path to zero the remaining (untouched)
    bytes of the last page it uncompressed data into, as the information about how
    much space the file data consumes in the last page is not known in the upper layer
    fs/btrfs/extent_io.c:__do_readpage(). In __do_readpage we were correctly zeroing
    the remainder of the page but only if it corresponds to the last page of the inode
    and if the inode's size is not a multiple of the page size.

    This would cause not only returning random data on reads, but also permanently
    storing random data when updating parts of the region that should be zeroed.
    For the example above, it means updating a single byte in the region [285648 ; 286720[
    would store that byte correctly but also store random data on disk.

    A test case for xfstests follows soon.

    Signed-off-by: Filipe David Borba Manana
    Signed-off-by: Chris Mason

    Filipe David Borba Manana
     
  • A user reported a 100% cpu hang with my new delayed ref code. Turns out I
    forgot to increase the count check when we can't run a delayed ref because of
    the tree mod log. If we can't run any delayed refs during this there is no
    point in continuing to look, and we need to break out. Thanks,

    Signed-off-by: Josef Bacik
    Signed-off-by: Chris Mason

    Josef Bacik
     
  • Added in patch "btrfs: add ioctls to query/change feature bits online"
    modifications to superblock don't need to reserve metadata blocks when
    starting a transaction.

    Signed-off-by: David Sterba
    Signed-off-by: Chris Mason

    David Sterba
     
  • The set_fslabel ioctl uses btrfs_end_transaction, which means it's
    possible that the change will be lost if the system crashes, same for
    the newly set features. Let's use btrfs_commit_transaction instead.

    Signed-off-by: Jeff Mahoney
    Signed-off-by: David Sterba
    Signed-off-by: Chris Mason

    Jeff Mahoney
     
  • Wang noticed that he was failing btrfs/030 even though me and Filipe couldn't
    reproduce. Turns out this is because Wang didn't have CONFIG_BTRFS_ASSERT set,
    which meant that a key part of Filipe's original patch was not being built in.
    This appears to be a mess up with merging Filipe's patch as it does not exist in
    his original patch. Fix this by changing how we make sure del_waiting_dir_move
    asserts that it did not error and take the function out of the ifdef check.
    This makes btrfs/030 pass with the assert on or off. Thanks,

    Signed-off-by: Josef Bacik
    Reviewed-by: Filipe Manana
    Signed-off-by: Chris Mason

    Josef Bacik
     
  • Pull pinctrl fixes from Linus Walleij:
    "First round of pin control fixes for v3.14:

    - Protect pinctrl_list_add() with the proper mutex. This was
    identified by RedHat. Caused nasty locking warnings was rootcased
    by Stanislaw Gruszka.

    - Avoid adding dangerous debugfs files when either half of the
    subsystem is unused: pinmux or pinconf.

    - Various fixes to various drivers: locking, hardware particulars, DT
    parsing, error codes"

    * tag 'pinctrl-v3.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
    pinctrl: tegra: return correct error type
    pinctrl: do not init debugfs entries for unimplemented functionalities
    pinctrl: protect pinctrl_list add
    pinctrl: sirf: correct the pin index of ac97_pins group
    pinctrl: imx27: fix offset calculation in imx_read_2bit
    pinctrl: vt8500: Change devicetree data parsing
    pinctrl: imx27: fix wrong offset to ICONFB
    pinctrl: at91: use locked variant of irq_set_handler

    Linus Torvalds
     
  • Pull irq fix from Thomas Gleixner:
    "Add a missing Kconfig dependency"

    * 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    genirq: Generic irq chip requires IRQ_DOMAIN

    Linus Torvalds
     
  • Pull x86 fixes from Peter Anvin:
    "Quite a varied little collection of fixes. Most of them are
    relatively small or isolated; the biggest one is Mel Gorman's fixes
    for TLB range flushing.

    A couple of AMD-related fixes (including not crashing when given an
    invalid microcode image) and fix a crash when compiled with gcov"

    * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86, microcode, AMD: Unify valid container checks
    x86, hweight: Fix BUG when booting with CONFIG_GCOV_PROFILE_ALL=y
    x86/efi: Allow mapping BGRT on x86-32
    x86: Fix the initialization of physnode_map
    x86, cpu hotplug: Fix stack frame warning in check_irq_vectors_for_cpu_disable()
    x86/intel/mid: Fix X86_INTEL_MID dependencies
    arch/x86/mm/srat: Skip NUMA_NO_NODE while parsing SLIT
    mm, x86: Revisit tlb_flushall_shift tuning for page flushes except on IvyBridge
    x86: mm: change tlb_flushall_shift for IvyBridge
    x86/mm: Eliminate redundant page table walk during TLB range flushing
    x86/mm: Clean up inconsistencies when flushing TLB ranges
    mm, x86: Account for TLB flushes only when debugging
    x86/AMD/NB: Fix amd_set_subcaches() parameter type
    x86/quirks: Add workaround for AMD F16h Erratum792
    x86, doc, kconfig: Fix dud URL for Microcode data

    Linus Torvalds
     
  • Pull jfs fix from David Kleikamp:
    "Fix regression"

    * tag 'jfs-3.14-rc2' of git://github.com/kleikamp/linux-shaggy:
    jfs: fix generic posix ACL regression

    Linus Torvalds