18 Mar, 2018

1 commit

  • commit de19e5c3c51fdb1ff20d0f61d099db902ff7494b upstream.

    trigger_on() means that the trigger is available but not ready, however
    trigger_on() was making it ready. That can segfault if the signal comes
    before trigger_ready(). e.g. (USR2 signal delivery not shown)

    $ perf record -e intel_pt//u -S sleep 1
    perf: Segmentation fault
    Obtained 16 stack frames.
    /home/ahunter/bin/perf(sighandler_dump_stack+0x40) [0x4ec550]
    /lib/x86_64-linux-gnu/libc.so.6(+0x36caf) [0x7fa76411acaf]
    /home/ahunter/bin/perf(perf_evsel__disable+0x26) [0x4b9dd6]
    /home/ahunter/bin/perf() [0x43a45b]
    /lib/x86_64-linux-gnu/libc.so.6(+0x36caf) [0x7fa76411acaf]
    /lib/x86_64-linux-gnu/libc.so.6(__xstat64+0x15) [0x7fa7641d2cc5]
    /home/ahunter/bin/perf() [0x4ec6c9]
    /home/ahunter/bin/perf() [0x4ec73b]
    /home/ahunter/bin/perf() [0x4ec73b]
    /home/ahunter/bin/perf() [0x4ec73b]
    /home/ahunter/bin/perf() [0x4eca15]
    /home/ahunter/bin/perf(machine__create_kernel_maps+0x257) [0x4f0b77]
    /home/ahunter/bin/perf(perf_session__new+0xc0) [0x4f86f0]
    /home/ahunter/bin/perf(cmd_record+0x722) [0x43c132]
    /home/ahunter/bin/perf() [0x4a11ae]
    /home/ahunter/bin/perf(main+0x5d4) [0x427fb4]

    Note, for testing purposes, this is hard to hit unless you add some sleep()
    in builtin-record.c before record__open().

    Signed-off-by: Adrian Hunter
    Acked-by: Jiri Olsa
    Cc: Wang Nan
    Cc: stable@vger.kernel.org
    Fixes: 3dcc4436fa6f ("perf tools: Introduce trigger class")
    Link: http://lkml.kernel.org/r/1519807144-30694-1-git-send-email-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Adrian Hunter
     

25 Feb, 2018

3 commits

  • commit e572d0887137acfc53f18175522964ec19d88175 upstream.

    When doing a kernel build with 'make -s', everything is silenced except
    the objtool build. That's because the tools tree support for silent
    builds is some combination of missing and broken.

    Three changes are needed to fix it:

    - Makefile: propagate '-s' to the sub-make's MAKEFLAGS variable so the
    tools Makefiles can see it.

    - tools/scripts/Makefile.include: fix the tools Makefiles' ability to
    recognize '-s'. The MAKE_VERSION and MAKEFLAGS checks are copied from
    the top-level Makefile. This silences the "DESCEND objtool" message.

    - tools/build/Makefile.build: add support to the tools Build files for
    recognizing '-s'. Again the MAKE_VERSION and MAKEFLAGS checks are
    copied from the top-level Makefile. This silences all the object
    compile/link messages.

    Reported-and-Tested-by: Peter Zijlstra
    Signed-off-by: Josh Poimboeuf
    Cc: Jiri Olsa
    Cc: Michal Marek
    Link: http://lkml.kernel.org/r/e8967562ef640c3ae9a76da4ae0f4e47df737c34.1484799200.git.jpoimboe@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     
  • [ Upstream commit 321a7c35c90cc834851ceda18a8ee18f1d032b92 ]

    Certain systems are designed to have sparse/discontiguous nodes. On
    such systems, 'perf bench numa' hangs, shows wrong number of nodes and
    shows values for non-existent nodes. Handle this by only taking nodes
    that are exposed by kernel to userspace.

    Signed-off-by: Satheesh Rajendran
    Reviewed-by: Srikar Dronamraju
    Acked-by: Naveen N. Rao
    Link: http://lkml.kernel.org/r/1edbcd353c009e109e93d78f2f46381930c340fe.1511368645.git.sathnaga@linux.vnet.ibm.com
    Signed-off-by: Balamuruhan S
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Satheesh Rajendran
     
  • [ Upstream commit 89d0aeab4252adc2a7ea693637dd21c588bfa2d1 ]

    The stdio perf top crashes when we change the terminal
    window size. The reason is that we assumed we get the
    perf_top pointer as a signal handler argument which is
    not the case.

    Changing the SIGWINCH handler logic to change global
    resize variable, which is checked in the main thread
    loop.

    Signed-off-by: Jiri Olsa
    Tested-by: Arnaldo Carvalho de Melo
    Tested-by: Ravi Bangoria
    Cc: Adrian Hunter
    Cc: Andi Kleen
    Cc: David Ahern
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-ysuzwz77oev1ftgvdscn9bpu@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jiri Olsa
     

22 Feb, 2018

5 commits

  • commit 961888b1d76d84efc66a8f5604b06ac12ac2f978 upstream.

    For distributions with old userspace header files, the _sigfault
    structure is different. mpx-mini-test fails with the following
    error:

    [root@Purley]# mpx-mini-test_64 tabletest
    XSAVE is supported by HW & OS
    XSAVE processor supported state mask: 0x2ff
    XSAVE OS supported state mask: 0x2ff
    BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
    BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0
    starting mpx bounds table test
    ERROR: siginfo bounds do not match shadow bounds for register 0

    Fix it by using the correct offset of _lower/_upper in _sigfault.
    RHEL needs this patch to work.

    Signed-off-by: Rui Wang
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: dave.hansen@linux.intel.com
    Fixes: e754aedc26ef ("x86/mpx, selftests: Add MPX self test")
    Link: http://lkml.kernel.org/r/1513586050-1641-1-git-send-email-rui.y.wang@intel.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Rui Wang
     
  • commit 4105c69703cdeba76f384b901712c9397b04e9c2 upstream.

    On 64-bit builds, we should not rely on "int $0x80" working (it only does if
    CONFIG_IA32_EMULATION=y is enabled). To keep the "Set TF and check int80"
    test running on 64-bit installs with CONFIG_IA32_EMULATION=y enabled, build
    this test only if we can also build 32-bit binaries (which should be a
    good approximation for that).

    Signed-off-by: Dominik Brodowski
    Cc: Andy Lutomirski
    Cc: Dmitry Safonov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kselftest@vger.kernel.org
    Cc: shuah@kernel.org
    Link: http://lkml.kernel.org/r/20180211111013.16888-5-linux@dominikbrodowski.net
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Dominik Brodowski
     
  • commit 2cbc0d66de0480449c75636f55697c7ff3af61fc upstream.

    On 64-bit builds, we should not rely on "int $0x80" working (it only does if
    CONFIG_IA32_EMULATION=y is enabled).

    Without this patch, the move test may succeed, but the "int $0x80" causes
    a segfault, resulting in a false negative output of this self-test.

    Signed-off-by: Dominik Brodowski
    Cc: Andy Lutomirski
    Cc: Dmitry Safonov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kselftest@vger.kernel.org
    Cc: shuah@kernel.org
    Link: http://lkml.kernel.org/r/20180211111013.16888-4-linux@dominikbrodowski.net
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Dominik Brodowski
     
  • commit ce676638fe7b284132a7d7d5e7e7ad81bab9947e upstream.

    This also gets rid of two build warnings:

    protection_keys.c: In function ‘dumpit’:
    protection_keys.c:419:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
    write(1, buf, nr_read);
    ^~~~~~~~~~~~~~~~~~~~~~

    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Dave Hansen
    Cc: Shuah Khan
    Cc: Andy Lutomirski
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Ingo Molnar
     
  • commit 4c1baad223906943b595a887305f2e8124821dad upstream.

    Running the compaction_test sometimes results in out-of-memory
    failures. When I debugged this, it turned out that the code to
    reset the number of hugepages to the initial value is simply
    broken since we write into an open sysctl file descriptor
    multiple times without seeking back to the start.

    Adding the lseek here fixes the problem.

    Cc: stable@vger.kernel.org
    Reported-by: Naresh Kamboju
    Link: https://bugs.linaro.org/show_bug.cgi?id=3145
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     

04 Feb, 2018

5 commits

  • commit ef824501f50846589f02173d73ce3fe6021a9d2a upstream.

    usbip host lists devices attached to vhci_hcd on the same server
    when user does attach over localhost or specifies the server as the
    remote.

    usbip attach -r localhost -b busid
    or
    usbip attach -r servername (or server IP)

    Fix it to check and not list devices that are attached to vhci_hcd.

    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Shuah Khan
     
  • commit ef54cf0c600fb8f5737fb001a9e357edda1a1de8 upstream.

    usbip host binds to devices attached to vhci_hcd on the same server
    when user does attach over localhost or specifies the server as the
    remote.

    usbip attach -r localhost -b busid
    or
    usbip attach -r servername (or server IP)

    Unbind followed by bind works, however device is left in a bad state with
    accesses via the attached busid result in errors and system hangs during
    shutdown.

    Fix it to check and bail out if the device is already attached to vhci_hcd.

    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Shuah Khan
     
  • [ Upstream commit dbdc468f35ee827cab2753caa1c660bdb832243a ]

    cpuidle_monitor used to assume that cpu0 is always online which is not
    a valid assumption on POWER machines. This patch fixes this by getting
    the cpu on which the current thread is running, instead of always using
    cpu0 for monitoring which may not be online.

    Signed-off-by: Abhishek Goel
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Abhishek Goel
     
  • [ Upstream commit 53d1cd6b125fb9d69303516a1179ebc3b72f797a ]

    cpupower_is_cpu_online was incorrectly checking for 0. This patch fixes
    this by checking for 1 when the cpu is online.

    Signed-off-by: Abhishek Goel
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Abhishek Goel
     
  • commit 1696784eb7b52b13b62d160c028ef2c2c981d4f2 upstream.

    The GPIO tools build fails when using a buildroot toolchain that uses musl
    as it's C library:

    arm-broomstick-linux-musleabi-gcc -Wp,-MD,./.gpio-event-mon.o.d \
    -Wp,-MT,gpio-event-mon.o -O2 -Wall -g -D_GNU_SOURCE \
    -Iinclude -D"BUILD_STR(s)=#s" -c -o gpio-event-mon.o gpio-event-mon.c
    gpio-event-mon.c:30:6: error: unknown type name ‘u_int32_t’; did you mean ‘uint32_t’?
    u_int32_t handleflags,
    ^~~~~~~~~
    uint32_t

    The glibc headers installed on my laptop include sys/types.h in
    unistd.h, but it appears that musl does not.

    Fixes: 97f69747d8b1 ("tools/gpio: add the gpio-event-mon tool")
    Signed-off-by: Joel Stanley
    Signed-off-by: Linus Walleij
    Signed-off-by: Greg Kroah-Hartman

    Joel Stanley
     

31 Jan, 2018

3 commits

  • commit e5dfa3f902b9a642ae8c6997d57d7c41e384a90b upstream.

    The usbip userspace tools call sprintf()/snprintf() and don't check for
    the return value which can lead the paths to overflow, truncating the
    final file in the path.

    More urgently, GCC 7 now warns that these aren't checked with
    -Wformat-overflow, and with -Werror enabled in configure.ac, that makes
    these tools unbuildable.

    This patch fixes these problems by replacing sprintf() with snprintf() in
    one place and adding checks for the return value of snprintf().

    Reviewed-by: Peter Senna Tschudin
    Signed-off-by: Jonathan Dieter
    Acked-by: Shuah Khan
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Jonathan Dieter
     
  • commit cfd6ed4537a9e938fa76facecd4b9cd65b6d1563 upstream.

    GCC 7 now warns when switch statements fall through implicitly, and with
    -Werror enabled in configure.ac, that makes these tools unbuildable.

    We fix this by notifying the compiler that this particular case statement
    is meant to fall through.

    Reviewed-by: Peter Senna Tschudin
    Signed-off-by: Jonathan Dieter
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Jonathan Dieter
     
  • commit 2f2d0088eb93db5c649d2a5e34a3800a8a935fc5 upstream.

    When a client has a USB device attached over IP, the vhci_hcd driver is
    locally leaking a socket pointer address via the

    /sys/devices/platform/vhci_hcd/status file (world-readable) and in debug
    output when "usbip --debug port" is run.

    Fix it to not leak. The socket pointer address is not used at the moment
    and it was made visible as a convenient way to find IP address from socket
    pointer address by looking up /proc/net/{tcp,tcp6}.

    As this opens a security hole, the fix replaces socket pointer address with
    sockfd.

    Reported-by: Secunia Research
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Shuah Khan
     

24 Jan, 2018

2 commits

  • commit 7a759cd8e8272ee18922838ee711219c7c796a31 upstream.

    With commit: 0a943cb10ce78 (tools build: Add HOSTARCH Makefile variable)
    when building for ARCH=x86_64, ARCH=x86_64 is passed to perf instead of
    ARCH=x86, so the perf build process searchs header files from
    tools/arch/x86_64/include, which doesn't exist.

    The following build failure is seen:

    In file included from util/event.c:2:0:
    tools/include/uapi/linux/mman.h:4:27: fatal error: uapi/asm/mman.h: No such file or directory
    compilation terminated.

    Fix this issue by using SRCARCH instead of ARCH in perf, just like the
    main kernel Makefile and tools/objtool's.

    Signed-off-by: Jiada Wang
    Tested-by: Arnaldo Carvalho de Melo
    Acked-by: Jiri Olsa
    Cc: Alexander Shishkin
    Cc: Andi Kleen
    Cc: Eugeniu Rosca
    Cc: Jan Stancek
    Cc: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Ravi Bangoria
    Cc: Rui Teng
    Cc: Sukadev Bhattiprolu
    Cc: Wang Nan
    Fixes: 0a943cb10ce7 ("tools build: Add HOSTARCH Makefile variable")
    Link: http://lkml.kernel.org/r/1491793357-14977-2-git-send-email-jiada_wang@mentor.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Tuomas Tynkkynen
    Signed-off-by: Greg Kroah-Hartman

    Jiada Wang
     
  • commit 385d11b152c4eb638eeb769edcb3249533bb9a00 upstream.

    If a nonexistent file is supplied to objtool, it complains with a
    non-helpful error:

    open: No such file or directory

    Improve it to:

    objtool: Can't open 'foo': No such file or directory

    Reported-by: Markus
    Signed-off-by: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/406a3d00a21225eee2819844048e17f68523ccf6.1516025651.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     

17 Jan, 2018

5 commits

  • Objtool 1.0 (pre-ORC) produces the following warning when it encounters
    a retpoline:

    arch/x86/crypto/camellia-aesni-avx2-asm_64.o: warning: objtool: .altinstr_replacement+0xf: return instruction outside of a callable function

    That warning is meant to catch GCC bugs and missing ENTRY/ENDPROC
    annotations, neither of which are applicable to alternatives. Silence
    the warning for alternative instructions, just like objtool 2.0 already
    does.

    Reported-by: David Woodhouse
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     
  • commit 352909b49ba0d74929b96af6dfbefc854ab6ebb5 upstream.

    This tests that the vsyscall entries do what they're expected to do.
    It also confirms that attempts to read the vsyscall page behave as
    expected.

    If changes are made to the vsyscall code or its memory map handling,
    running this test in all three of vsyscall=none, vsyscall=emulate,
    and vsyscall=native are helpful.

    (Because it's easy, this also compares the vsyscall results to their
    vDSO equivalents.)

    Note to KAISER backporters: please test this under all three
    vsyscall modes. Also, in the emulate and native modes, make sure
    that test_vsyscall_64 agrees with the command line or config
    option as to which mode you're in. It's quite easy to mess up
    the kernel such that native mode accidentally emulates
    or vice versa.

    Greg, etc: please backport this to all your Meltdown-patched
    kernels. It'll help make sure the patches didn't regress
    vsyscalls.

    CSigned-off-by: Andy Lutomirski
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Dave Hansen
    Cc: Greg Kroah-Hartman
    Cc: H. Peter Anvin
    Cc: Hugh Dickins
    Cc: Josh Poimboeuf
    Cc: Juergen Gross
    Cc: Kees Cook
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: stable@vger.kernel.org
    Link: http://lkml.kernel.org/r/2b9c5a174c1d60fd7774461d518aa75598b1d8fd.1515719552.git.luto@kernel.org
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Andy Lutomirski
     
  • commit 258c76059cece01bebae098e81bacb1af2edad17 upstream.

    Getting objtool to understand retpolines is going to be a bit of a
    challenge. For now, take advantage of the fact that retpolines are
    patched in with alternatives. Just read the original (sane)
    non-alternative instruction, and ignore the patched-in retpoline.

    This allows objtool to understand the control flow *around* the
    retpoline, even if it can't yet follow what's inside. This means the
    ORC unwinder will fail to unwind from inside a retpoline, but will work
    fine otherwise.

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: David Woodhouse
    Signed-off-by: Thomas Gleixner
    Cc: gnomes@lxorguk.ukuu.org.uk
    Cc: Rik van Riel
    Cc: Andi Kleen
    Cc: thomas.lendacky@amd.com
    Cc: Peter Zijlstra
    Cc: Linus Torvalds
    Cc: Jiri Kosina
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Kees Cook
    Cc: Tim Chen
    Cc: Greg Kroah-Hartman
    Cc: Paul Turner
    Link: https://lkml.kernel.org/r/1515707194-20531-3-git-send-email-dwmw@amazon.co.uk
    [dwmw2: Applies to tools/objtool/builtin-check.c not check.[ch]]
    Signed-off-by: David Woodhouse
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     
  • commit 39b735332cb8b33a27c28592d969e4016c86c3ea upstream.

    A direct jump to a retpoline thunk is really an indirect jump in
    disguise. Change the objtool instruction type accordingly.

    Objtool needs to know where indirect branches are so it can detect
    switch statement jump tables.

    This fixes a bunch of warnings with CONFIG_RETPOLINE like:

    arch/x86/events/intel/uncore_nhmex.o: warning: objtool: nhmex_rbox_msr_enable_event()+0x44: sibling call from callable instruction with modified stack frame
    kernel/signal.o: warning: objtool: copy_siginfo_to_user()+0x91: sibling call from callable instruction with modified stack frame
    ...

    Signed-off-by: Josh Poimboeuf
    Signed-off-by: David Woodhouse
    Signed-off-by: Thomas Gleixner
    Cc: gnomes@lxorguk.ukuu.org.uk
    Cc: Rik van Riel
    Cc: Andi Kleen
    Cc: thomas.lendacky@amd.com
    Cc: Peter Zijlstra
    Cc: Linus Torvalds
    Cc: Jiri Kosina
    Cc: Andy Lutomirski
    Cc: Dave Hansen
    Cc: Kees Cook
    Cc: Tim Chen
    Cc: Greg Kroah-Hartman
    Cc: Paul Turner
    Link: https://lkml.kernel.org/r/1515707194-20531-2-git-send-email-dwmw@amazon.co.uk
    [dwmw2: Applies to tools/objtool/builtin-check.c not check.c]
    Signed-off-by: David Woodhouse
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     
  • commit e390f9a9689a42f477a6073e2e7df530a4c1b740 upstream.

    The '__unreachable' and '__func_stack_frame_non_standard' sections are
    only used at compile time. They're discarded for vmlinux but they
    should also be discarded for modules.

    Since this is a recurring pattern, prefix the section names with
    ".discard.". It's a nice convention and vmlinux.lds.h already discards
    such sections.

    Also remove the 'a' (allocatable) flag from the __unreachable section
    since it doesn't make sense for a discarded section.

    Suggested-by: Linus Torvalds
    Signed-off-by: Josh Poimboeuf
    Cc: Jessica Yu
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: d1091c7fa3d5 ("objtool: Improve detection of BUG() and other dead ends")
    Link: http://lkml.kernel.org/r/20170301180444.lhd53c5tibc4ns77@treble
    Signed-off-by: Ingo Molnar
    [dwmw2: Remove the unreachable part in backporting since it's not here yet]
    Signed-off-by: David Woodhouse
    Signed-off-by: Greg Kroah-Hartman

    Josh Poimboeuf
     

05 Jan, 2018

2 commits

  • This renames CONFIG_KAISER to CONFIG_PAGE_TABLE_ISOLATION.

    Signed-off-by: Kees Cook
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • Added "nokaiser" boot option: an early param like "noinvpcid".
    Most places now check int kaiser_enabled (#defined 0 when not
    CONFIG_KAISER) instead of #ifdef CONFIG_KAISER; but entry_64.S
    and entry_64_compat.S are using the ALTERNATIVE technique, which
    patches in the preferred instructions at runtime. That technique
    is tied to x86 cpu features, so X86_FEATURE_KAISER is fabricated.

    Prior to "nokaiser", Kaiser #defined _PAGE_GLOBAL 0: revert that,
    but be careful with both _PAGE_GLOBAL and CR4.PGE: setting them when
    nokaiser like when !CONFIG_KAISER, but not setting either when kaiser -
    neither matters on its own, but it's hard to be sure that _PAGE_GLOBAL
    won't get set in some obscure corner, or something add PGE into CR4.
    By omitting _PAGE_GLOBAL from __supported_pte_mask when kaiser_enabled,
    all page table setup which uses pte_pfn() masks it out of the ptes.

    It's slightly shameful that the same declaration versus definition of
    kaiser_enabled appears in not one, not two, but in three header files
    (asm/kaiser.h, asm/pgtable.h, asm/tlbflush.h). I felt safer that way,
    than with #including any of those in any of the others; and did not
    feel it worth an asm/kaiser_enabled.h - kernel/cpu/common.c includes
    them all, so we shall hear about it if they get out of synch.

    Cleanups while in the area: removed the silly #ifdef CONFIG_KAISER
    from kaiser.c; removed the unused native_get_normal_pgd(); removed
    the spurious reg clutter from SWITCH_*_CR3 macro stubs; corrected some
    comments. But more interestingly, set CR4.PSE in secondary_startup_64:
    the manual is clear that it does not matter whether it's 0 or 1 when
    4-level-pts are enabled, but I was distracted to find cr4 different on
    BSP and auxiliaries - BSP alone was adding PSE, in probe_page_size_mask().

    Signed-off-by: Hugh Dickins
    Acked-by: Jiri Kosina
    Signed-off-by: Greg Kroah-Hartman

    Hugh Dickins
     

03 Jan, 2018

2 commits

  • commit 544c4605acc5ae4afe7dd5914147947db182f2fb upstream.

    usbip bind writes commands followed by random string when writing to
    match_busid attribute in sysfs, caused by using full variable size
    instead of string length.

    Signed-off-by: Juan Zea
    Acked-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Juan Zea
     
  • When building objtool, we get the warning:
    warning: objtool: x86 instruction decoder differs from kernel

    That's due to commit 2816c0455cea088f07a210f8a00701a82a78aa9c which was
    commit 12a78d43de767eaf8fb272facb7a7b6f2dc6a9df upstream that modified
    arch/x86/lib/x86-opcode-map.txt without also updating the objtool copy.
    The objtool copy was updated in a much larger patch upstream, but we
    don't need all of that here, so just update the single file.

    If this gets too annoying, I'll just end up doing what we did for 4.14
    and backport the whole series to keep this from happening again, but as
    this seems to be rare in the 4.9-stable series, this single patch should
    be fine.

    Cc: Masami Hiramatsu
    Cc: H. Peter Anvin
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

20 Dec, 2017

2 commits

  • [ Upstream commit e7ede72a6d40cb3a30c087142d79381ca8a31dab ]

    The current symbols__fixup_end() heuristic for the last entry in the rb
    tree is suboptimal as it leads to not being able to recognize the symbol
    in the call graph in a couple of corner cases, for example:

    i) If the symbol has a start address (f.e. exposed via kallsyms)
    that is at a page boundary, then the roundup(curr->start, 4096)
    for the last entry will result in curr->start == curr->end with
    a symbol length of zero.

    ii) If the symbol has a start address that is shortly before a page
    boundary, then also here, curr->end - curr->start will just be
    very few bytes, where it's unrealistic that we could perform a
    match against.

    Instead, change the heuristic to roundup(curr->start, 4096) + 4096, so
    that we can catch such corner cases and have a better chance to find
    that specific symbol. It's still just best effort as the real end of the
    symbol is unknown to us (and could even be at a larger offset than the
    current range), but better than the current situation.

    Alexei reported that he recently run into case i) with a JITed eBPF
    program (these are all page aligned) as the last symbol which wasn't
    properly shown in the call graph (while other eBPF program symbols in
    the rb tree were displayed correctly). Since this is a generic issue,
    lets try to improve the heuristic a bit.

    Reported-and-Tested-by: Alexei Starovoitov
    Signed-off-by: Daniel Borkmann
    Fixes: 2e538c4a1847 ("perf tools: Improve kernel/modules symbol lookup")
    Link: http://lkml.kernel.org/r/bb5c80d27743be6f12afc68405f1956a330e1bc9.1489614365.git.daniel@iogearbox.net
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Daniel Borkmann
     
  • [ Upstream commit 46aa6a302b53f543f8e8b8e1714dc5e449ad36a6 ]

    linux/tools/testing/selftests/vm $ make

    gcc -Wall -I ../../../../usr/include compaction_test.c -lrt -o /compaction_test
    /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../x86_64-pc-linux-gnu/bin/ld: cannot open output file /compaction_test: Permission denied
    collect2: error: ld returned 1 exit status
    make: *** [../lib.mk:54: /compaction_test] Error 1

    Since commit a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
    selftests/vm build fails if run from the "selftests/vm" directory, but
    it works in the selftests/ directory. It's quicker to be able to do a
    local vm-only build after a tree wipe and this patch allows for it
    again.

    Link: http://lkml.kernel.org/r/20170302173738.18994-4-aarcange@redhat.com
    Signed-off-by: Andrea Arcangeli
    Cc: Mike Rapoport
    Cc: "Dr. David Alan Gilbert"
    Cc: Mike Kravetz
    Cc: Pavel Emelyanov
    Cc: Hillf Danton
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Andrea Arcangeli
     

14 Dec, 2017

4 commits

  • [ Upstream commit a6400120d042397675fcf694060779d21e9e762d ]

    The MPX hardware data structurse are defined in a weird way: they define
    their size in bytes and then union that with the type with which we want
    to access them.

    Yes, this is weird, but it does work. But, new GCC's complain that we
    are accessing the array out of bounds. Just make it a zero-sized array
    so gcc will stop complaining. There was not really a bug here.

    Signed-off-by: Dave Hansen
    Acked-by: Thomas Gleixner
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20171111001229.58A7933D@viggo.jf.intel.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Dave Hansen
     
  • [ Upstream commit a6d8a21596df041f36f4c2ccc260c459e3e851f1 ]

    Tests under alignment subdirectory are skipped when executed on previous
    generation hardware, but harness still marks them as failed.

    test: test_copy_unaligned
    tags: git_version:unknown
    [SKIP] Test skipped on line 26
    skip: test_copy_unaligned
    selftests: copy_unaligned [FAIL]

    The MAGIC_SKIP_RETURN_VALUE value assigned to rc variable is retained till
    the program exit which causes the test to be marked as failed.

    This patch resets the value before returning to the main() routine.
    With this patch the test o/p is as follows:

    test: test_copy_unaligned
    tags: git_version:unknown
    [SKIP] Test skipped on line 26
    skip: test_copy_unaligned
    selftests: copy_unaligned [PASS]

    Signed-off-by: Sachin Sant
    Signed-off-by: Michael Ellerman
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sachin Sant
     
  • [ Upstream commit 2a4d0c627f5374f365a873dea4e10ae0bb437680 ]

    Kernel erases R8..R11 registers prior returning to userspace
    from int80:

    https://lkml.org/lkml/2009/10/1/164

    GCC can reuse these registers and doesn't expect them to change
    during syscall invocation. I met this kind of bug in CRIU once
    GCC 6.1 and CLANG stored local variables in those registers
    and the kernel zerofied them during syscall:

    https://github.com/xemul/criu/commit/990d33f1a1cdd17bca6c2eb059ab3be2564f7fa2

    By that reason I suggest to add those registers to clobbers
    in selftests. Also, as noted by Andy - removed unneeded clobber
    for flags in INT $0x80 inline asm.

    Signed-off-by: Dmitry Safonov
    Acked-by: Andy Lutomirski
    Cc: 0x7f454c46@gmail.com
    Cc: Borislav Petkov
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Shuah Khan
    Cc: Thomas Gleixner
    Cc: linux-kselftest@vger.kernel.org
    Link: http://lkml.kernel.org/r/20170213101336.20486-1-dsafonov@virtuozzo.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Dmitry Safonov
     
  • commit 297d6b6e56c2977fc504c61bbeeaa21296923f89 upstream.

    While reading in more than one block (50) of KVP records, the allocation
    goes per block, but the reads used the total number of allocated records
    (without resetting the pointer/stream). This causes the records buffer to
    overrun when the refresh reads more than one block over the previous
    capacity (e.g. reading more than 100 KVP records whereas the in-memory
    database was empty before).

    Fix this by reading the correct number of KVP records from file each time.

    Signed-off-by: Paul Meyer
    Signed-off-by: Long Li
    Signed-off-by: K. Y. Srinivasan
    Signed-off-by: Greg Kroah-Hartman

    Paul Meyer
     

10 Dec, 2017

4 commits

  • [ Upstream commit 6ae8eefc6c8fe050f057781b70a83262eb0a61ee ]

    LIST_POISON[12] are used to initialize list_head and hlist_node
    pointers, and do void pointer arithmetic, which C++ doesn't like, so, to
    avoid drifting from the kernel by introducing some HLIST_POISON to do
    away with void pointer math, just make those poisoned pointers be NULL
    when building it with a C++ compiler.

    Noticed with:

    $ make LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
    CXX util/c++/clang.o
    CXX util/c++/clang-test.o
    In file included from /home/lizj/linux/tools/include/linux/list.h:5:0,
    from /home/lizj/linux/tools/perf/util/namespaces.h:13,
    from /home/lizj/linux/tools/perf/util/util.h:15,
    from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
    from util/c++/clang-c.h:5,
    from util/c++/clang-test.cpp:2:
    /home/lizj/linux/tools/include/linux/list.h: In function ‘void list_del(list_head*)’:
    /home/lizj/linux/tools/include/linux/poison.h:14:31: error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]
    # define POISON_POINTER_DELTA 0
    ^
    /home/lizj/linux/tools/include/linux/poison.h:22:41: note: in expansion of macro ‘POISON_POINTER_DELTA’
    #define LIST_POISON1 ((void *) 0x100 + POISON_POINTER_DELTA)
    ^
    /home/lizj/linux/tools/include/linux/list.h:107:16: note: in expansion of macro ‘LIST_POISON1’
    entry->next = LIST_POISON1;
    ^
    In file included from /home/lizj/linux/tools/perf/util/namespaces.h:13:0,
    from /home/lizj/linux/tools/perf/util/util.h:15,
    from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
    from util/c++/clang-c.h:5,
    from util/c++/clang-test.cpp:2:
    /home/lizj/linux/tools/include/linux/list.h:107:14: error: invalid conversion from ‘void*’ to ‘list_head*’ [-fpermissive]

    Reported-by: Li Zhijian
    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Philip Li
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-m5ei2o0mjshucbr28baf5lqz@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Arnaldo Carvalho de Melo
     
  • [ Upstream commit 22905582f6dd4bbd0c370fe5732c607452010c04 ]

    Command perf test -v 16 (Setup struct perf_event_attr test) always
    reports success even if the test case fails. It works correctly if you
    also specify -F (for don't fork).

    root@s35lp76 perf]# ./perf test -v 16
    15: Setup struct perf_event_attr :
    --- start ---
    running './tests/attr/test-record-no-delay'
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.002 MB /tmp/tmp4E1h7R/perf.data
    (1 samples) ]
    expected task=0, got 1
    expected precise_ip=0, got 3
    expected wakeup_events=1, got 0
    FAILED './tests/attr/test-record-no-delay' - match failure
    test child finished with 0
    ---- end ----
    Setup struct perf_event_attr: Ok

    The reason for the wrong error reporting is the return value of the
    system() library call. It is called in run_dir() file tests/attr.c and
    returns the exit status, in above case 0xff00.

    This value is given as parameter to the exit() function which can only
    handle values 0-0xff.

    The child process terminates with exit value of 0 and the parent does
    not detect any error.

    This patch corrects the error reporting and prints the correct test
    result.

    Signed-off-by: Thomas-Mich Richter
    Acked-by: Jiri Olsa
    Cc: Heiko Carstens
    Cc: Hendrik Brueckner
    Cc: Martin Schwidefsky
    Cc: Thomas-Mich Richter
    LPU-Reference: 20170913081209.39570-2-tmricht@linux.vnet.ibm.com
    Link: http://lkml.kernel.org/n/tip-rdube6rfcjsr1nzue72c7lqn@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Thomas Richter
     
  • [ Upstream commit c15562c0dcb2c7f26e891923b784cf1926b8c833 ]

    usbip_host_driver.h now depends on several additional headers, which
    need to be installed along with it.

    Fixes: 021aed845303 ("staging: usbip: userspace: migrate usbip_host_driver ...")
    Fixes: 3391ba0e2792 ("usbip: tools: Extract generic code to be shared with ...")
    Signed-off-by: Ben Hutchings
    Acked-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Ben Hutchings
     
  • [ Upstream commit fec8f5ae1715a01c72ad52cb2ecd8aacaf142302 ]

    We weren't testing the .limit and .limit_in_pages fields very well.
    Add more tests.

    This addition seems to trigger the "bits 16:19 are undefined" issue
    that was fixed in an earlier patch. I think that, at least on my
    CPU, the high nibble of the limit ends in LAR bits 16:19.

    Signed-off-by: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/5601c15ea9b3113d288953fd2838b18bedf6bc67.1509794321.git.luto@kernel.org
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Andy Lutomirski
     

15 Nov, 2017

2 commits

  • commit afb999cdef69148f366839e74470d8f5375ba5f1 upstream.

    Some distributions (Debian, OpenSUSE) have a udev rule in place to cancel
    all fallback mechanism uevents immediately. This would obviously
    make it hard to test against the fallback mechanism test interface,
    so we need to check for this.

    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Amit Pundir
    Signed-off-by: Greg Kroah-Hartman

    Luis R. Rodriguez
     
  • commit 880444e214cfd293a2e8cc4bd3505f7ffa6ce33a upstream.

    Error that we expect should not be spilled to stdout.

    Without this we get:

    ./fw_filesystem.sh: line 58: printf: write error: Invalid argument
    ./fw_filesystem.sh: line 63: printf: write error: No such device
    ./fw_filesystem.sh: line 69: echo: write error: No such file or directory
    ./fw_filesystem.sh: filesystem loading works
    ./fw_filesystem.sh: async filesystem loading works

    With it:

    ./fw_filesystem.sh: filesystem loading works
    ./fw_filesystem.sh: async filesystem loading works

    Signed-off-by: Luis R. Rodriguez
    Signed-off-by: Amit Pundir
    Signed-off-by: Greg Kroah-Hartman

    Luis R. Rodriguez