1. 25 Jan, 2018 1 commit
    • Paul E. McKenney's avatar
      Automate memory-barriers.txt; provide Linux-kernel memory model · 1c27b644
      Paul E. McKenney authored
      There is some reason to believe that Documentation/memory-barriers.txt
      could use some help, and a major purpose of this patch is to provide
      that help in the form of a design-time tool that can produce all valid
      executions of a small fragment of concurrent Linux-kernel code, which is
      called a "litmus test".  This tool's functionality is roughly similar to
      a full state-space search.  Please note that this is a design-time tool,
      not useful for regression testing.  However, we hope that the underlying
      Linux-kernel memory model will be incorporated into other tools capable
      of analyzing large bodies of code for regression-testing purposes.
      
      The main tool is herd7, together with the linux-kernel.bell,
      linux-kernel.cat, linux-kernel.cfg, linux-kernel.def, and lock.cat files
      added by this patch.  The herd7 executable takes the other files as input,
      and all of these files collectively define the Linux-kernel memory memory
      model.  A brief description of each of these other files is provided
      in the README file.  Although this tool does have its limitations,
      which are documented in the README file, it does improve on the version
      reported on in the LWN series (https://lwn.net/Articles/718628/ and
      https://lwn.net/Articles/720550/) by supporting locking and arithmetic,
      including a much wider variety of read-modify-write atomic operations.
      Please note that herd7 is not part of this submission, but is freely
      available from http://diy.inria.fr/sources/index.html (and via "git"
      at https://github.com/herd/herdtools7).
      
      A second tool is klitmus7, which converts litmus tests to loadable
      kernel modules for direct testing.  As with herd7, the klitmus7
      code is freely available from http://diy.inria.fr/sources/index.html
      (and via "git" at https://github.com/herd/herdtools7).
      
      Of course, litmus tests are not always the best way to fully understand a
      memory model, so this patch also includes Documentation/explanation.txt,
      which describes the memory model in detail.  In addition,
      Documentation/recipes.txt provides example known-good and known-bad use
      cases for those who prefer working by example.
      
      This patch also includes a few sample litmus tests, and a great many
      more litmus tests are available at https://github.com/paulmckrcu/litmus.
      
      This patch was the result of a most excellent collaboration founded
      by Jade Alglave and also including Alan Stern, Andrea Parri, and Luc
      Maranget.  For more details on the history of this collaboration, please
      refer to the Linux-kernel memory model presentations at 2016 LinuxCon EU,
      2016 Kernel Summit, 2016 Linux Plumbers Conference, 2017 linux.conf.au,
      or 2017 Linux Plumbers Conference microconference.  However, one aspect
      of the history does bear repeating due to weak copyright tracking earlier
      in this project, which extends back to early 2015.  This weakness came
      to light in late 2017 after an LKMM presentation by Paul in which an
      audience member noted the similarity of some LKMM code to code in early
      published papers.  This prompted a copyright review.
      
      From Alan Stern:
      
      	To say that the model was mine is not entirely accurate.
      	Pieces of it (especially the Scpv and Atomic axioms) were taken
      	directly from Jade's models.  And of course the Happens-before
      	and Propagation relations and axioms were heavily based on
      	Jade and Luc's work, even though they weren't identical to the
      	earlier versions.  Only the RCU portion was completely original.
      
      	. . .
      
      	One can make a much better case that I wrote the bulk of lock.cat.
      	However, it was inspired by Luc's earlier version (and still
      	shares some elements in common), and of course it benefited from
      	feedback and testing from all members of our group.
      
      The model prior to Alan's was Luc Maranget's.  From Luc:
      
      	 I totally agree on Alan Stern's account of the linux kernel model
      	 genesis.  I thank him for his acknowledgments of my participation
      	 to previous model drafts.  I'd like to complete Alan Stern's
      	 statement: any bell cat code I have written has its roots in
      	 discussions with Jade Alglave and Paul McKenney. Moreover I
      	 have borrowed cat and bell code written by Jade Alglave freely.
      
      This copyright review therefore resulted in late adds to the copyright
      statements of several files.
      
      Discussion of v1 has raised several issues, which we do not believe should
      block acceptance given that this level of change will be ongoing, just
      as it has been with memory-barriers.txt:
      
      o	Under what conditions should ordering provided by pure locking
      	be seen by CPUs not holding the relevant lock(s)?  In particular,
      	should the message-passing pattern be forbidden?
      
      o	Should examples involving C11 release sequences be forbidden?
      	Note that this C11 is still a moving target for this issue:
      	http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0735r0.html
      
      o	Some details of the handling of internal dependencies for atomic
      	read-modify-write atomic operations are still subject to debate.
      
      o	Changes recently accepted into mainline greatly reduce the need
      	to handle DEC Alpha as a special case.  These changes add an
      	smp_read_barrier_depends() to READ_ONCE(), thus causing Alpha
      	to respect ordering of dependent reads.  If these changes stick,
      	the memory model can be simplified accordingly.
      
      o	Will changes be required to accommodate RISC-V?
      
      Differences from v1:
      	(http://lkml.kernel.org/r/20171113184031.GA26302@linux.vnet.ibm.com)
      
      o	Add SPDX notations to .bell and .cat files, replacing
      	textual license statements.
      
      o	Add reference to upcoming ASPLOS paper to .bell and .cat files.
      
      o	Updated identifier names in .bell and .cat files to match those
      	used in the ASPLOS paper.
      
      o	Updates to READMEs and other documentation based on review
      	feedback.
      
      o	Added a memory-ordering cheatsheet.
      
      o	Update sigs to new Co-Developed-by and add acks and
      	reviewed-bys.
      
      o	Simplify rules detecting nested RCU read-side critical sections.
      
      o	Update copyright statements as noted above.
      Co-Developed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Co-Developed-by: default avatarAndrea Parri <parri.andrea@gmail.com>
      Co-Developed-by: default avatarJade Alglave <j.alglave@ucl.ac.uk>
      Co-Developed-by: default avatarLuc Maranget <luc.maranget@inria.fr>
      Co-Developed-by: default avatar"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarAndrea Parri <parri.andrea@gmail.com>
      Signed-off-by: default avatarJade Alglave <j.alglave@ucl.ac.uk>
      Signed-off-by: default avatarLuc Maranget <luc.maranget@inria.fr>
      Signed-off-by: default avatar"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Reviewed-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Acked-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Acked-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatar"Reshetova, Elena" <elena.reshetova@intel.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarAkira Yokosawa <akiyks@gmail.com>
      Cc: <linux-arch@vger.kernel.org>
      1c27b644
  2. 21 Jan, 2018 7 commits
    • Linus Torvalds's avatar
      Linux 4.15-rc9 · 0c5b9b5d
      Linus Torvalds authored
      0c5b9b5d
    • Linus Torvalds's avatar
      Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 55151142
      Linus Torvalds authored
      Pull x86 pti fixes from Thomas Gleixner:
       "A small set of fixes for the meltdown/spectre mitigations:
      
         - Make kprobes aware of retpolines to prevent probes in the retpoline
           thunks.
      
         - Make the machine check exception speculation protected. MCE used to
           issue an indirect call directly from the ASM entry code. Convert
           that to a direct call into a C-function and issue the indirect call
           from there so the compiler can add the retpoline protection,
      
         - Make the vmexit_fill_RSB() assembly less stupid
      
         - Fix a typo in the PTI documentation"
      
      * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/retpoline: Optimize inline assembler for vmexit_fill_RSB
        x86/pti: Document fix wrong index
        kprobes/x86: Disable optimizing on the function jumps to indirect thunk
        kprobes/x86: Blacklist indirect thunk functions for kprobes
        retpoline: Introduce start/end markers of indirect thunk
        x86/mce: Make machine check speculation protected
      55151142
    • Linus Torvalds's avatar
      Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 319f1e04
      Linus Torvalds authored
      Pull x86 kexec fix from Thomas Gleixner:
       "A single fix for the WBINVD issue introduced by the SME support which
        causes kexec fails on non AMD/SME capable CPUs. Issue WBINVD only when
        the CPU has SME and avoid doing so in a loop"
      
      [ Side note: this patch fixes the problem, but it isn't entirely clear
        why it is required. The wbinvd should just work regardless, but there
        seems to be some system - as opposed to CPU - issue, since the wbinvd
        causes more problems later in the shutdown sequence, but wbinvd
        instructions while the system is still active are not problematic.
      
        Possibly some SMI or pending machine check issue on the affected system ]
      
      * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/mm: Rework wbinvd, hlt operation in stop_this_cpu()
      319f1e04
    • Linus Torvalds's avatar
      Merge branch 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 66f81624
      Linus Torvalds authored
      Pull irq fix from Thomas Gleixner:
       "A single fix for the new matrix allocator to prevent vector exhaustion
        by certain network drivers which allocate gazillions of unused vectors
        which cannot be put into reservation mode due to MSI and the lack of
        MSI entry masking.
      
        The fix/workaround is to spread the vectors across CPUs by searching
        the supplied target CPU mask for the CPU with the smallest number of
        allocated vectors"
      
      * 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        irq/matrix: Spread interrupts on allocation
      66f81624
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha · d517bb79
      Linus Torvalds authored
      Pull alpha fixes from Matt Turner:
       "A build fix and a regression fix"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha:
        alpha/PCI: Fix noname IRQ level detection
        alpha: extend memset16 to EV6 optimised routines
      d517bb79
    • Laura Abbott's avatar
      x86: Use __nostackprotect for sme_encrypt_kernel · 91cfc88c
      Laura Abbott authored
      Commit bacf6b49 ("x86/mm: Use a struct to reduce parameters for SME
      PGD mapping") moved some parameters into a structure.
      
      The structure was large enough to trigger the stack protection canary in
      sme_encrypt_kernel which doesn't work this early, causing reboots.
      
      Mark sme_encrypt_kernel appropriately to not use the canary.
      
      Fixes: bacf6b49 ("x86/mm: Use a struct to reduce parameters for SME PGD mapping")
      Signed-off-by: default avatarLaura Abbott <labbott@redhat.com>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      91cfc88c
    • Lorenzo Pieralisi's avatar
      alpha/PCI: Fix noname IRQ level detection · 86be8993
      Lorenzo Pieralisi authored
      The conversion of the alpha architecture PCI host bridge legacy IRQ
      mapping/swizzling to the new PCI host bridge map/swizzle hooks carried
      out through:
      
      commit 0e4c2eeb ("alpha/PCI: Replace pci_fixup_irqs() call with
      host bridge IRQ mapping hooks")
      
      implies that IRQ for devices are now allocated through pci_assign_irq()
      function in pci_device_probe() that is called when a driver matching a
      device is found in order to probe the device through the device driver.
      
      Alpha noname platforms required IRQ level programming to be executed
      in sio_fixup_irq_levels(), that is called in noname_init_pci(), a
      platform hook called within a subsys_initcall.
      
      In noname_init_pci(), present IRQs are detected through
      sio_collect_irq_levels() that check the struct pci_dev->irq number
      to detect if an IRQ has been allocated for the device.
      
      By the time sio_collect_irq_levels() is called, some devices may still
      have not a matching driver loaded to match them (eg loadable module)
      therefore their IRQ allocation is still pending - which means that
      sio_collect_irq_levels() does not programme the correct IRQ level for
      those devices, causing their IRQ handling to be broken when the device
      driver is actually loaded and the device is probed.
      
      Fix the issue by adding code in the noname map_irq() function
      (noname_map_irq()) that, whilst mapping/swizzling the IRQ line, it also
      ensures that the correct IRQ level programming is executed at platform
      level, fixing the issue.
      
      Fixes: 0e4c2eeb ("alpha/PCI: Replace pci_fixup_irqs() call with
      host bridge IRQ mapping hooks")
      Reported-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Cc: stable@vger.kernel.org # 4.14
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: Meelis Roos <mroos@linux.ee>
      Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
      86be8993
  3. 20 Jan, 2018 4 commits
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 24b61240
      Linus Torvalds authored
      Pull KVM fixes from Radim Krčmář:
       "ARM:
         - fix incorrect huge page mappings on systems using the contiguous
           hint for hugetlbfs
         - support alternative GICv4 init sequence
         - correctly implement the ARM SMCC for HVC and SMC handling
      
        PPC:
         - add KVM IOCTL for reporting vulnerability and workaround status
      
        s390:
         - provide userspace interface for branch prediction changes in
           firmware
      
        x86:
         - use correct macros for bits"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: s390: wire up bpb feature
        KVM: PPC: Book3S: Provide information about hardware/firmware CVE workarounds
        KVM/x86: Fix wrong macro references of X86_CR0_PG_BIT and X86_CR4_PAE_BIT in kvm_valid_sregs()
        arm64: KVM: Fix SMCCC handling of unimplemented SMC/HVC calls
        KVM: arm64: Fix GICv4 init when called from vgic_its_create
        KVM: arm/arm64: Check pagesize when allocating a hugepage at Stage 2
      24b61240
    • Linus Torvalds's avatar
      Merge tag 'mips_fixes_4.15_2' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips · e6252e7f
      Linus Torvalds authored
      Pull MIPS fixes from James Hogan:
       "Some final MIPS fixes for 4.15, including important build fixes and a
        MAINTAINERS update:
      
         - Add myself as MIPS co-maintainer.
      
         - Fix various all*config build failures (particularly as a result of
           switching the default MIPS platform to the "generic" platform).
      
         - Fix GCC7 build failures (duplicate const and questionable calls to
           missing __multi3 intrinsic on mips64r6).
      
         - Fix warnings when CPU Idle is enabled (4.14).
      
         - Fix AR7 serial output (since 3.17).
      
         - Fix ralink platform_get_irq error checking (since 3.12)"
      
      * tag 'mips_fixes_4.15_2' of git://git.kernel.org/pub/scm/linux/kernel/git/jhogan/mips:
        MAINTAINERS: Add James as MIPS co-maintainer
        MIPS: Fix undefined reference to physical_memsize
        MIPS: Implement __multi3 for GCC7 MIPS64r6 builds
        MIPS: mm: Fix duplicate "const" on insn_table_MM
        MIPS: CM: Drop WARN_ON(vp != 0)
        MIPS: ralink: Fix platform_get_irq's error checking
        MIPS: Fix CPS SMP NS16550 UART defaults
        MIPS: BCM47XX Avoid compile error with MIPS allnoconfig
        MIPS: RB532: Avoid undefined mac_pton without GENERIC_NET_UTILS
        MIPS: RB532: Avoid undefined early_serial_setup() without SERIAL_8250_CONSOLE
        MIPS: ath25: Avoid undefined early_serial_setup() without SERIAL_8250_CONSOLE
        MIPS: AR7: ensure the port type's FCR value is used
      e6252e7f
    • Christian Borntraeger's avatar
      KVM: s390: wire up bpb feature · 35b3fde6
      Christian Borntraeger authored
      The new firmware interfaces for branch prediction behaviour changes
      are transparently available for the guest. Nevertheless, there is
      new state attached that should be migrated and properly resetted.
      Provide a mechanism for handling reset, migration and VSIE.
      Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      [Changed capability number to 152. - Radim]
      Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
      35b3fde6
    • Radim Krčmář's avatar
      Merge tag 'kvm-ppc-cve-4.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc · 29d24e3f
      Radim Krčmář authored
      Add PPC KVM ioctl to report vulnerability and workaround status to userspace.
      29d24e3f
  4. 19 Jan, 2018 28 commits