1. 03 Apr, 2018 1 commit
    • David S. Miller's avatar
      sparc64: Make atomic_xchg() an inline function rather than a macro. · d13864b6
      David S. Miller authored
      This avoids a lot of -Wunused warnings such as:
      
      ====================
      kernel/debug/debug_core.c: In function ‘kgdb_cpu_enter’:
      ./arch/sparc/include/asm/cmpxchg_64.h:55:22: warning: value computed is not used [-Wunused-value]
       #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
      
      ./arch/sparc/include/asm/atomic_64.h:86:30: note: in expansion of macro ‘xchg’
       #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
                                    ^~~~
      kernel/debug/debug_core.c:508:4: note: in expansion of macro ‘atomic_xchg’
          atomic_xchg(&kgdb_active, cpu);
          ^~~~~~~~~~~
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d13864b6
  2. 02 Apr, 2018 2 commits
  3. 20 Mar, 2018 1 commit
  4. 18 Mar, 2018 13 commits
    • Guenter Roeck's avatar
      sparc64: Oracle DAX driver depends on SPARC64 · 9c548bb5
      Guenter Roeck authored
      sparc:allmodconfig fails to build as follows.
      
      ERROR: "mdesc_release" [drivers/sbus/char/oradax.ko] undefined!
      ERROR: "sun4v_hvapi_register" [drivers/sbus/char/oradax.ko] undefined!
      ERROR: "mdesc_get_property" [drivers/sbus/char/oradax.ko] undefined!
      ERROR: "mdesc_node_by_name" [drivers/sbus/char/oradax.ko] undefined!
      ERROR: "mdesc_grab" [drivers/sbus/char/oradax.ko] undefined!
      ERROR: "sun4v_ccb_info" [drivers/sbus/char/oradax.ko] undefined!
      ERROR: "sun4v_ccb_submit" [drivers/sbus/char/oradax.ko] undefined!
      ERROR: "sun4v_ccb_kill" [drivers/sbus/char/oradax.ko] undefined!
      
      The symbols are only available with SPARC64 builds, thus the driver
      depends on it.
      
      Fixes: dd027328 ("sparc64: Oracle DAX driver")
      Cc: Kees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9c548bb5
    • David S. Miller's avatar
      Merge branch 'sparc64-ADI' · 88fe3529
      David S. Miller authored
      Khalid Aziz says:
      
      ====================
      Application Data Integrity feature introduced by SPARC M7
      
      V12 changes:
      This series is same as v10 and v11 and was simply rebased on 4.16-rc2
      kernel and patch 11 was added to update signal delivery code to use the
      new helper functions added by Eric Biederman. Can mm maintainers please
      review patches 2, 7, 8 and 9 which are arch independent, and
      include/linux/mm.h and mm/ksm.c changes in patch 10 and ack these if
      everything looks good?
      
      SPARC M7 processor adds additional metadata for memory address space
      that can be used to secure access to regions of memory. This additional
      metadata is implemented as a 4-bit tag attached to each cacheline size
      block of memory. A task can set a tag on any number of such blocks.
      Access to such block is granted only if the virtual address used to
      access that block of memory has the tag encoded in the uppermost 4 bits
      of VA. Since sparc processor does not implement all 64 bits of VA, top 4
      bits are available for ADI tags. Any mismatch between tag encoded in VA
      and tag set on the memory block results in a trap. Tags are verified in
      the VA presented to the MMU and tags are associated with the physical
      page VA maps on to. If a memory page is swapped out and page frame gets
      reused for another task, the tags are lost and hence must be saved when
      swapping or migrating the page.
      
      A userspace task enables ADI through mprotect(). This patch series adds
      a page protection bit PROT_ADI and a corresponding VMA flag
      VM_SPARC_ADI. VM_SPARC_ADI is used to trigger setting TTE.mcd bit in the
      sparc pte that enables ADI checking on the corresponding page. MMU
      validates the tag embedded in VA for every page that has TTE.mcd bit set
      in its pte. After enabling ADI on a memory range, the userspace task can
      set ADI version tags using stxa instruction with ASI_MCD_PRIMARY or
      ASI_MCD_ST_BLKINIT_PRIMARY ASI.
      
      Once userspace task calls mprotect() with PROT_ADI, kernel takes
      following overall steps:
      
      1. Find the VMAs covering the address range passed in to mprotect and
      set VM_SPARC_ADI flag. If address range covers a subset of a VMA, the
      VMA will be split.
      
      2. When a page is allocated for a VA and the VMA covering this VA has
      VM_SPARC_ADI flag set, set the TTE.mcd bit so MMU will check the
      vwersion tag.
      
      3. Userspace can now set version tags on the memory it has enabled ADI
      on. Userspace accesses ADI enabled memory using a virtual address that
      has the version tag embedded in the high bits. MMU validates this
      version tag against the actual tag set on the memory. If tag matches,
      MMU performs the VA->PA translation and access is granted. If there is a
      mismatch, hypervisor sends a data access exception or precise memory
      corruption detected exception depending upon whether precise exceptions
      are enabled or not (controlled by MCDPERR register). Kernel sends
      SIGSEGV to the task with appropriate si_code.
      
      4. If a page is being swapped out or migrated, kernel must save any ADI
      tags set on the page. Kernel maintains a page worth of tag storage
      descriptors. Each descriptors pointsto a tag storage space and the
      address range it covers. If the page being swapped out or migrated has
      ADI enabled on it, kernel finds a tag storage descriptor that covers the
      address range for the page or allocates a new descriptor if none of the
      existing descriptors cover the address range. Kernel saves tags from the
      page into the tag storage space descriptor points to.
      
      5. When the page is swapped back in or reinstantiated after migration,
      kernel restores the version tags on the new physical page by retrieving
      the original tag from tag storage pointed to by a tag storage descriptor
      for the virtual address range for new page.
      
      User task can disable ADI by calling mprotect() again on the memory
      range with PROT_ADI bit unset. Kernel clears the VM_SPARC_ADI flag in
      VMAs, merges adjacent VMAs if necessary, and clears TTE.mcd bit in the
      corresponding ptes.
      
      IOMMU does not support ADI checking. Any version tags embedded in the
      top bits of VA meant for IOMMU, are cleared and replaced with sign
      extension of the first non-version tag bit (bit 59 for SPARC M7) for
      IOMMU addresses.
      
      This patch series adds support for this feature in 11 patches:
      
      Patch 1/11
        Tag mismatch on access by a task results in a trap from hypervisor as
        data access exception or a precide memory corruption detected
        exception. As part of handling these exceptions, kernel sends a
        SIGSEGV to user process with special si_code to indicate which fault
        occurred. This patch adds three new si_codes to differentiate between
        various mismatch errors.
      
      Patch 2/11
        When a page is swapped or migrated, metadata associated with the page
        must be saved so it can be restored later. This patch adds a new
        function that saves/restores this metadata when updating pte upon a
        swap/migration.
      
      Patch 3/11
        SPARC M7 processor adds new fields to control registers to support ADI
        feature. It also adds a new exception for precise traps on tag
        mismatch. This patch adds definitions for the new control register
        fields, new ASIs for ADI and an exception handler for the precise trap
        on tag mismatch.
      
      Patch 4/11
        New hypervisor fault types were added by sparc M7 processor to support
        ADI feature. This patch adds code to handle these fault types for data
        access exception handler.
      
      Patch 5/11
        When ADI is in use for a page and a tag mismatch occurs, processor
        raises "Memory corruption Detected" trap. This patch adds a handler
        for this trap.
      
      Patch 6/11
        ADI usage is governed by ADI properties on a platform. These
        properties are provided to kernel by firmware. Thsi patch adds new
        auxiliary vectors that provide these values to userpsace.
      
      Patch 7/11
        arch_validate_prot() is used to validate the new protection bits asked
        for by the userspace app. Validating protection bits may need the
        context of address space the bits are being applied to. One such
        example is PROT_ADI bit on sparc processor that enables ADI protection
        on an address range. ADI protection applies only to addresses covered
        by physical RAM and not other PFN mapped addresses or device
        addresses. This patch adds "address" to the parameters being passed to
        arch_validate_prot() to provide that context.
      
      Patch 8/11
        When protection bits are changed on a page, kernel carries forward all
        protection bits except for read/write/exec. Additional code was added
        to allow kernel to clear PKEY bits on x86 but this requirement to
        clear other bits is not unique to x86. This patch extends the existing
        code to allow other architectures to clear any other protection bits
        as well on protection bit change.
      
      Patch 9/11
        When a processor supports additional metadata on memory pages, that
        additional metadata needs to be copied to new memory pages when those
        pages are moved. This patch allows architecture specific code to
        replace the default copy_highpage() routine with arch specific
        version that copies the metadata as well besides the data on the page.
      
      Patch 10/11
        This patch adds support for a user space task to enable ADI and enable
        tag checking for subsets of its address space. As part of enabling
        this feature, this patch adds to support manipulation of precise
        exception for memory corruption detection, adds code to save and
        restore tags on page swap and migration, and adds code to handle ADI
        tagged addresses for DMA.
      
      Patch 11/11
        Update signal delivery code in arch/sparc/kernel/traps_64.c to use
        the new helper function force_sig_fault() added by commit
        f8ec6601 ("signal: Add send_sig_fault and force_sig_fault").
      
      Changelog v12:
      
      	  - Rebased to 4.16-rc2
      	  - Added patch 11 to update signal delivery functions
      
      Changelog v11:
      
      	  - Rebased to 4.15
      
      Changelog v10:
      
      	  - Patch 1/10: Updated si_codes definitions for SEGV to match 4.14
      	  - Patch 2/10: No changes
      	  - Patch 3/10: Updated copyright
      	  - Patch 4/10: No changes
      	  - Patch 5/10: No changes
      	  - Patch 6/10: Updated copyright
      	  - Patch 7/10: No changes
      	  - Patch 8/10: No changes
      	  - Patch 9/10: No changes
      	  - Patch 10/10: Added code to return from kernel path to set
      	    PSTATE.mcde if kernel continues execution in another thread
      	      (Suggested by Anthony)
      
      Changelog v9:
      
      	  - Patch 1/10: No changes
      	  - Patch 2/10: No changes
      	  - Patch 3/10: No changes
      	  - Patch 4/10: No changes
      	  - Patch 5/10: No changes
      	  - Patch 6/10: No changes
      	  - Patch 7/10: No changes
      	  - Patch 8/10: No changes
      	  - Patch 9/10: New patch
      	  - Patch 10/10: Patch 9 from v8. Added code to copy ADI tags when
      	    pages are migrated. Updated code to detect overflow and underflow
      	      of addresses when allocating tag storage.
      
      Changelog v8:
      
      	  - Patch 1/9: No changes
      	  - Patch 2/9: Fixed and erroneous "}"
      	  - Patch 3/9: Minor print formatting change
      	  - Patch 4/9: No changes
      	  - Patch 5/9: No changes
      	  - Patch 6/9: Added AT_ADI_UEONADI back
      	  - Patch 7/9: Added addr parameter to powerpc arch_validate_prot()
      	  - Patch 8/9: No changes
      	  - Patch 9/9:
      	    - Documentation updates
      	      - Added an IPI on mprotect(...PROT_ADI...) call and
      	      	  restore of TSTATE.MCDE on context switch
      		  	  - Removed restriction on enabling ADI on read-only
      			      memory
      				- Changed kzalloc() for tag storage to use GFP_NOWAIT
      				  - Added code to handle overflow and underflow when
      				      allocating tag storage
      				      		 - Replaced sun_m7_patch_1insn_range() with
      						     sun4v_patch_1insn_range()
      							- Added membar after restoring ADI tags in
      							    copy_user_highpage()
      
      Changelog v7:
      
      	  - Patch 1/9: No changes
      	  - Patch 2/9: Updated parameters to arch specific swap in/out
      	    handlers
      	    - Patch 3/9: No changes
      	    - Patch 4/9: new patch split off from patch 4/4 in v6
      	    - Patch 5/9: new patch split off from patch 4/4 in v6
      	    - Patch 6/9: new patch split off from patch 4/4 in v6
      	    - Patch 7/9: new patch
      	    - Patch 8/9: new patch
      	    - Patch 9/9:
      	      - Enhanced arch_validate_prot() to enable ADI only on
      	      	  writable addresses backed by physical RAM
      		  	   - Added support for saving/restoring ADI tags for each
      			       ADI block size address range on a page on swap in/out
      			       	   - copy ADI tags on COW
      				     - Updated values for auxiliary vectors to not conflict
      				         with values on other architectures to avoid conflict
      					        in glibc
      						   - Disable same page merging on ADI enabled pages
      						     - Enable ADI only on writable addresses backed by
      						         physical RAM
      							 	  - Split parts of patch off into separate patches
      
      Changelog v6:
      	  - Patch 1/4: No changes
      	  - Patch 2/4: No changes
      	  - Patch 3/4: Added missing nop in the delay slot in
      	    sun4v_mcd_detect_precise
      	    - Patch 4/4: Eliminated instructions to read and write PSTATE
      	      as well as MCDPER and PMCDPER on every access to userspace
      	        addresses by setting PSTATE and PMCDPER correctly upon entry
      		  into kernel
      
      Changelog v5:
      	  - Patch 1/4: No changes
      	  - Patch 2/4: Replaced set_swp_pte_at() with new architecture
      	    functions arch_do_swap_page() and arch_unmap_one() that
      	      suppoprt architecture specific actions to be taken on page
      	        swap and migration
      		- Patch 3/4: Fixed indentation issues in assembly code
      		- Patch 4/4:
      		  - Fixed indentation issues and instrcuctions in assembly
      		      code
      			- Removed CONFIG_SPARC64 from mdesc.c
      			  - Changed to maintain state of MCDPER register in thread
      			      info flags as opposed to in mm context. MCDPER is a
      			      	     per-thread state and belongs in thread info flag as
      				     		  opposed to mm context which is shared across threads.
      						  	    Added comments to clarify this is a lazily maintained
      							    	    state and must be updated on context switch and
      								    	    copy_process()
      									    		   - Updated code to use the new arch_do_swap_page() and
      											       arch_unmap_one() functions
      
      Testing:
      
      - All functionality was tested with 8K normal pages as well as hugepages
        using malloc, mmap and shm.
      - Multiple long duration stress tests were run using hugepages over 2+
        months. Normal pages were tested with shorter duration stress tests.
      - Tested swapping with malloc and shm by reducing max memory and
        allocating three times the available system memory by active processes
        using ADI on allocated memory. Ran through multiple hours long runs of
        this test.
      - Tested page migration with malloc and shm by migrating data pages of
        active ADI test process using migratepages, back and forth between two
        nodes every few seconds over an hour long run. Verified page migration
        through /proc/<pid>/numa_maps.
      - Tested COW support using test that forks children that read from
        ADI enabled pages shared with parent and other children and write to
        them as well forcing COW.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      88fe3529
    • Khalid Aziz's avatar
      sparc64: Update signal delivery to use new helper functions · b9fa0365
      Khalid Aziz authored
      Commit f8ec6601 ("signal: Add send_sig_fault and force_sig_fault")
      added new helper functions to streamline signal delivery. This patch
      updates signal delivery for new/updated handlers for ADI related
      exceptions to use the helper function.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Acked-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b9fa0365
    • Khalid Aziz's avatar
      sparc64: Add support for ADI (Application Data Integrity) · 74a04967
      Khalid Aziz authored
      ADI is a new feature supported on SPARC M7 and newer processors to allow
      hardware to catch rogue accesses to memory. ADI is supported for data
      fetches only and not instruction fetches. An app can enable ADI on its
      data pages, set version tags on them and use versioned addresses to
      access the data pages. Upper bits of the address contain the version
      tag. On M7 processors, upper four bits (bits 63-60) contain the version
      tag. If a rogue app attempts to access ADI enabled data pages, its
      access is blocked and processor generates an exception. Please see
      Documentation/sparc/adi.txt for further details.
      
      This patch extends mprotect to enable ADI (TSTATE.mcde), enable/disable
      MCD (Memory Corruption Detection) on selected memory ranges, enable
      TTE.mcd in PTEs, return ADI parameters to userspace and save/restore ADI
      version tags on page swap out/in or migration. ADI is not enabled by
      default for any task. A task must explicitly enable ADI on a memory
      range and set version tag for ADI to be effective for the task.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      74a04967
    • Khalid Aziz's avatar
      mm: Allow arch code to override copy_highpage() · a4602b62
      Khalid Aziz authored
      Some architectures can support metadata for memory pages and when a
      page is copied, its metadata must also be copied. Sparc processors
      from M7 onwards support metadata for memory pages. This metadata
      provides tag based protection for access to memory pages. To maintain
      this protection, the tag data must be copied to the new page when a
      page is migrated across NUMA nodes. This patch allows arch specific
      code to override default copy_highpage() and copy metadata along
      with page data upon migration.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Acked-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a4602b62
    • Khalid Aziz's avatar
      mm: Clear arch specific VM flags on protection change · 2c2d57b5
      Khalid Aziz authored
      When protection bits are changed on a VMA, some of the architecture
      specific flags should be cleared as well. An examples of this are the
      PKEY flags on x86. This patch expands the current code that clears
      PKEY flags for x86, to support similar functionality for other
      architectures as well.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Acked-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2c2d57b5
    • Khalid Aziz's avatar
      mm: Add address parameter to arch_validate_prot() · 9035cf9a
      Khalid Aziz authored
      A protection flag may not be valid across entire address space and
      hence arch_validate_prot() might need the address a protection bit is
      being set on to ensure it is a valid protection flag. For example, sparc
      processors support memory corruption detection (as part of ADI feature)
      flag on memory addresses mapped on to physical RAM but not on PFN mapped
      pages or addresses mapped on to devices. This patch adds address to the
      parameters being passed to arch_validate_prot() so protection bits can
      be validated in the relevant context.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Acked-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9035cf9a
    • Khalid Aziz's avatar
      sparc64: Add auxiliary vectors to report platform ADI properties · c6202ca7
      Khalid Aziz authored
      ADI feature on M7 and newer processors has three important properties
      relevant to userspace apps using ADI capabilities - (1) Size of block of
      memory an ADI version tag applies to, (2) Number of uppermost bits in
      virtual address used to encode ADI tag, and (3) The value M7 processor
      will force the ADI tags to if it detects uncorrectable error in an ADI
      tagged cacheline. Kernel can retrieve these properties for a platform
      through machine description provided by the firmware. This patch adds
      code to retrieve these properties and report them to userspace through
      auxiliary vectors.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c6202ca7
    • Khalid Aziz's avatar
      sparc64: Add handler for "Memory Corruption Detected" trap · 94addb35
      Khalid Aziz authored
      M7 and newer processors add a "Memory corruption Detected" trap with
      the addition of ADI feature. This trap is vectored into kernel by HV
      through resumable error trap with error attribute for the resumable
      error set to 0x00000800.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      94addb35
    • Khalid Aziz's avatar
      sparc64: Add HV fault type handlers for ADI related faults · 52df948d
      Khalid Aziz authored
      ADI (Application Data Integrity) feature on M7 and newer processors
      adds new fault types for hypervisor - Invalid ASI and MCD disabled.
      This patch expands data access exception handler to handle these
      faults.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      52df948d
    • Khalid Aziz's avatar
      sparc64: Add support for ADI register fields, ASIs and traps · 75037500
      Khalid Aziz authored
      SPARC M7 processor adds new control register fields, ASIs and a new
      trap to support the ADI (Application Data Integrity) feature. This
      patch adds definitions for these register fields, ASIs and a handler
      for the new precise memory corruption detected trap.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      75037500
    • Khalid Aziz's avatar
      mm, swap: Add infrastructure for saving page metadata on swap · ca827d55
      Khalid Aziz authored
      If a processor supports special metadata for a page, for example ADI
      version tags on SPARC M7, this metadata must be saved when the page is
      swapped out. The same metadata must be restored when the page is swapped
      back in. This patch adds two new architecture specific functions -
      arch_do_swap_page() to be called when a page is swapped in, and
      arch_unmap_one() to be called when a page is being unmapped for swap
      out. These architecture hooks allow page metadata to be saved if the
      architecture supports it.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Acked-by: default avatarJerome Marchand <jmarchan@redhat.com>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Acked-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ca827d55
    • Khalid Aziz's avatar
      signals, sparc: Add signal codes for ADI violations · d84bb709
      Khalid Aziz authored
      SPARC M7 processor introduces a new feature - Application Data
      Integrity (ADI). ADI allows MMU to  catch rogue accesses to memory.
      When a rogue access occurs, MMU blocks the access and raises an
      exception. In response to the exception, kernel sends the offending
      task a SIGSEGV with si_code that indicates the nature of exception.
      This patch adds three new signal codes specific to ADI feature:
      
      1. ADI is not enabled for the address and task attempted to access
         memory using ADI
      2. Task attempted to access memory using wrong ADI tag and caused
         a deferred exception.
      3. Task attempted to access memory using wrong ADI tag and caused
         a precise exception.
      Signed-off-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Cc: Khalid Aziz <khalid@gonehiking.org>
      Reviewed-by: default avatarAnthony Yznaga <anthony.yznaga@oracle.com>
      Acked-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d84bb709
  5. 16 Mar, 2018 13 commits
  6. 15 Mar, 2018 8 commits
    • Eric W. Biederman's avatar
      fs: Teach path_connected to handle nfs filesystems with multiple roots. · 95dd7758
      Eric W. Biederman authored
      On nfsv2 and nfsv3 the nfs server can export subsets of the same
      filesystem and report the same filesystem identifier, so that the nfs
      client can know they are the same filesystem.  The subsets can be from
      disjoint directory trees.  The nfsv2 and nfsv3 filesystems provides no
      way to find the common root of all directory trees exported form the
      server with the same filesystem identifier.
      
      The practical result is that in struct super s_root for nfs s_root is
      not necessarily the root of the filesystem.  The nfs mount code sets
      s_root to the root of the first subset of the nfs filesystem that the
      kernel mounts.
      
      This effects the dcache invalidation code in generic_shutdown_super
      currently called shrunk_dcache_for_umount and that code for years
      has gone through an additional list of dentries that might be dentry
      trees that need to be freed to accomodate nfs.
      
      When I wrote path_connected I did not realize nfs was so special, and
      it's hueristic for avoiding calling is_subdir can fail.
      
      The practical case where this fails is when there is a move of a
      directory from the subtree exposed by one nfs mount to the subtree
      exposed by another nfs mount.  This move can happen either locally or
      remotely.  With the remote case requiring that the move directory be cached
      before the move and that after the move someone walks the path
      to where the move directory now exists and in so doing causes the
      already cached directory to be moved in the dcache through the magic
      of d_splice_alias.
      
      If someone whose working directory is in the move directory or a
      subdirectory and now starts calling .. from the initial mount of nfs
      (where s_root == mnt_root), then path_connected as a heuristic will
      not bother with the is_subdir check.  As s_root really is not the root
      of the nfs filesystem this heuristic is wrong, and the path may
      actually not be connected and path_connected can fail.
      
      The is_subdir function might be cheap enough that we can call it
      unconditionally.  Verifying that will take some benchmarking and
      the result may not be the same on all kernels this fix needs
      to be backported to.  So I am avoiding that for now.
      
      Filesystems with snapshots such as nilfs and btrfs do something
      similar.  But as the directory tree of the snapshots are disjoint
      from one another and from the main directory tree rename won't move
      things between them and this problem will not occur.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarAl Viro <viro@ZenIV.linux.org.uk>
      Fixes: 397d425d ("vfs: Test for and handle paths that are unreachable from their mnt_root")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      95dd7758
    • Rodrigo Vivi's avatar
      Merge tag 'gvt-fixes-2018-03-15' of https://github.com/intel/gvt-linux into drm-intel-fixes · 05b429a8
      Rodrigo Vivi authored
      gvt-fixes-2018-03-15
      
      - Two warnings fix for runtime pm and usr copy (Xiong, Zhenyu)
      - OA context fix for vGPU profiling (Min)
      - privilege batch buffer reloc fix (Fred)
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20180315100023.5n5a74afky6qinoh@zhen-hp.sh.intel.com
      05b429a8
    • David S. Miller's avatar
      sparc64: Fix regression in pmdp_invalidate(). · cfb61b5e
      David S. Miller authored
      pmdp_invalidate() was changed to update the pmd atomically
      (to not lose dirty/access bits) and return the original pmd
      value.
      
      However, in doing so, we lost a lot of the essential work that
      set_pmd_at() does, namely to update hugepage mapping counts and
      queuing up the batched TLB flush entry.
      
      Thus we were not flushing entries out of the TLB when making
      such PMD changes.
      
      Fix this by abstracting the accounting work of set_pmd_at() out into a
      separate function, and call it from pmdp_establish().
      
      Fixes: a8e654f0 ("sparc64: update pmdp_invalidate() to return old pmd value")
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cfb61b5e
    • Linus Torvalds's avatar
      Merge tag 'sound-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · e2c15aff
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "A series of small fixes in ASoC, HD-audio and core stuff:
      
         - a UAF fix in ALSA PCM core
      
         - yet more hardening for ALSA sequencer
      
         - a regression fix for the previous HD-audio power_save option change
      
         - various ASoC codec fixes (sgtl5000, rt5651, hdmi-codec, wm_adsp)
      
         - minor ASoC platform fixes (AMD ACP, sun4i)"
      
      * tag 'sound-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ALSA: hda - Revert power_save option default value
        ALSA: pcm: Fix UAF in snd_pcm_oss_get_formats()
        ALSA: seq: Clear client entry before deleting else at closing
        ALSA: seq: Fix possible UAF in snd_seq_check_queue()
        ASoC: amd: 16bit resolution support for i2s sp instance
        ASoC: wm_adsp: For TLV controls only register TLV get/set
        ASoC: sun4i-i2s: Fix RX slot number of SUN8I
        ASoC: hdmi-codec: Fix module unloading caused kernel crash
        ASoC: rt5651: Fix regcache sync errors on resume
        ASoC: sgtl5000: Fix suspend/resume
        MAINTAINERS: Add myself as sgtl5000 maintainer
        ASoC: samsung: Add the DT binding files entry to MAINTAINERS
        sgtl5000: change digital_mute policy
      e2c15aff
    • Linus Torvalds's avatar
      Merge tag 'for-4.16/dm-fixes-3' of... · 667058ae
      Linus Torvalds authored
      Merge tag 'for-4.16/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
      
      Pull device mapper fixes from Mike Snitzer:
      
       - a stable DM multipath fix to restore ability to pass integrity data
      
       - two DM multipath fixes for a fix that was merged into 4.16-rc5
      
      * tag 'for-4.16/dm-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
        dm mpath: fix passing integrity data
        dm mpath: eliminate need to use scsi_device_from_queue
        dm mpath: fix uninitialized 'pg_init_wait' waitqueue_head NULL pointer
      667058ae
    • Zhenyu Wang's avatar
      drm/i915/gvt: fix user copy warning by whitelist workload rb_tail field · 850555d1
      Zhenyu Wang authored
      This is to fix warning got as:
      
      [ 6730.476938] ------------[ cut here ]------------
      [ 6730.476979] Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLAB object 'gvt-g_vgpu_workload' (offset 120, size 4)!
      [ 6730.477021] WARNING: CPU: 2 PID: 441 at mm/usercopy.c:81 usercopy_warn+0x7e/0xa0
      [ 6730.477042] Modules linked in: tun(E) bridge(E) stp(E) llc(E) kvmgt(E) x86_pkg_temp_thermal(E) vfio_mdev(E) intel_powerclamp(E) mdev(E) coretemp(E) vfio_iommu_type1(E) vfio(E) kvm_intel(E) kvm(E) hid_generic(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) usbhid(E) i915(E) crc32c_intel(E) hid(E) ghash_clmulni_intel(E) pcbc(E) aesni_intel(E) aes_x86_64(E) crypto_simd(E) cryptd(E) glue_helper(E) intel_cstate(E) idma64(E) evdev(E) virt_dma(E) iTCO_wdt(E) intel_uncore(E) intel_rapl_perf(E) intel_lpss_pci(E) sg(E) shpchp(E) mei_me(E) pcspkr(E) iTCO_vendor_support(E) intel_lpss(E) intel_pch_thermal(E) prime_numbers(E) mei(E) mfd_core(E) video(E) acpi_pad(E) button(E) binfmt_misc(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc16(E) mbcache(E) jbd2(E) fscrypto(E) sd_mod(E) e1000e(E) xhci_pci(E) sdhci_pci(E)
      [ 6730.477244]  ptp(E) cqhci(E) xhci_hcd(E) pps_core(E) sdhci(E) mmc_core(E) i2c_i801(E) usbcore(E) thermal(E) fan(E)
      [ 6730.477276] CPU: 2 PID: 441 Comm: gvt workload 0 Tainted: G            E    4.16.0-rc1-gvt-staging-0213+ #127
      [ 6730.477303] Hardware name:  /NUC6i5SYB, BIOS SYSKLi35.86A.0039.2016.0316.1747 03/16/2016
      [ 6730.477326] RIP: 0010:usercopy_warn+0x7e/0xa0
      [ 6730.477340] RSP: 0018:ffffba6301223d18 EFLAGS: 00010286
      [ 6730.477355] RAX: 0000000000000000 RBX: ffff8f41caae9838 RCX: 0000000000000006
      [ 6730.477375] RDX: 0000000000000007 RSI: 0000000000000082 RDI: ffff8f41dad166f0
      [ 6730.477395] RBP: 0000000000000004 R08: 0000000000000576 R09: 0000000000000000
      [ 6730.477415] R10: ffffffffb1293fb2 R11: 00000000ffffffff R12: 0000000000000001
      [ 6730.477447] R13: ffff8f41caae983c R14: ffff8f41caae9838 R15: 00007f183ca2b000
      [ 6730.477467] FS:  0000000000000000(0000) GS:ffff8f41dad00000(0000) knlGS:0000000000000000
      [ 6730.477489] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 6730.477506] CR2: 0000559462817291 CR3: 000000028b46c006 CR4: 00000000003626e0
      [ 6730.477526] Call Trace:
      [ 6730.477537]  __check_object_size+0x9c/0x1a0
      [ 6730.477562]  __kvm_write_guest_page+0x45/0x90 [kvm]
      [ 6730.477585]  kvm_write_guest+0x46/0x80 [kvm]
      [ 6730.477599]  kvmgt_rw_gpa+0x9b/0xf0 [kvmgt]
      [ 6730.477642]  workload_thread+0xa38/0x1040 [i915]
      [ 6730.477659]  ? do_wait_intr_irq+0xc0/0xc0
      [ 6730.477673]  ? finish_wait+0x80/0x80
      [ 6730.477707]  ? clean_workloads+0x120/0x120 [i915]
      [ 6730.477722]  kthread+0x111/0x130
      [ 6730.477733]  ? _kthread_create_worker_on_cpu+0x60/0x60
      [ 6730.477750]  ? exit_to_usermode_loop+0x6f/0xb0
      [ 6730.477766]  ret_from_fork+0x35/0x40
      [ 6730.477777] Code: 48 c7 c0 20 e3 25 b1 48 0f 44 c2 41 50 51 41 51 48 89 f9 49 89 f1 4d 89 d8 4c 89 d2 48 89 c6 48 c7 c7 78 e3 25 b1 e8 b2 bc e4 ff <0f> ff 48 83 c4 18 c3 48 c7 c6 09 d0 26 b1 49 89 f1 49 89 f3 eb
      [ 6730.477849] ---[ end trace cae869c1c323e45a ]---
      
      By whitelist guest page write from workload struct allocated from kmem cache.
      Reviewed-by: default avatarHang Yuan <hang.yuan@linux.intel.com>
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      (cherry picked from commit 5627705406874df57fdfad3b4e0c9aedd3b007df)
      850555d1
    • fred gao's avatar
      drm/i915/gvt: Correct the privilege shadow batch buffer address · ef75c685
      fred gao authored
      Once the ring buffer is copied to ring_scan_buffer and scanned,
      the shadow batch buffer start address is only updated into
      ring_scan_buffer, not the real ring address allocated through
      intel_ring_begin in later copy_workload_to_ring_buffer.
      
      This patch is only to set the right shadow batch buffer address
      from Ring buffer, not include the shadow_wa_ctx.
      
      v2:
      - refine some comments. (Zhenyu)
      v3:
      - fix typo in title. (Zhenyu)
      v4:
      - remove the unnecessary comments. (Zhenyu)
      - add comments in bb_start_cmd_va update. (Zhenyu)
      
      Fixes: 0a53bc07 ("drm/i915/gvt: Separate cmd scan from request allocation")
      Cc: stable@vger.kernel.org  # v4.15
      Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
      Cc: Yulei Zhang <yulei.zhang@intel.com>
      Signed-off-by: default avatarfred gao <fred.gao@intel.com>
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      ef75c685
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 0aa3fdb8
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "This is four patches, consisting of one regression from the merge
        window (qla2xxx), one long-standing memory leak (sd_zbc), one event
        queue mislabelling which we want to eliminate to discourage the
        pattern (mpt3sas), and one behaviour change because re-reading the
        partition table shouldn't clear the ro flag"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: sd: Keep disk read-only when re-reading partition
        scsi: qla2xxx: Fix crashes in qla2x00_probe_one on probe failure
        scsi: sd_zbc: Fix potential memory leak
        scsi: mpt3sas: Do not mark fw_event workqueue as WQ_MEM_RECLAIM
      0aa3fdb8
  7. 14 Mar, 2018 2 commits
    • Joern Engel's avatar
      btree: avoid variable-length allocations · 8df3aaaf
      Joern Engel authored
      geo->keylen cannot be larger than 4.  So we might as well make
      fixed-size allocations.
      
      Given the one remaining user, geo->keylen cannot even be larger than 1.
      Logfs used to have 64bit and 128bit keys, tcm_qla2xxx only has 32bit
      keys.  But let's not break the code if we don't have to.
      Signed-off-by: default avatarJoern Engel <joern@purestorage.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8df3aaaf
    • Linus Torvalds's avatar
      Merge branch 'percpu_ref-rcu-audit-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc · fed8f509
      Linus Torvalds authored
      Pull percpu_ref rcu fixes from Tejun Heo:
       "Jann Horn found that aio was depending on the internal RCU grace
        periods of percpu-ref and that it's broken because aio uses regular
        RCU while percpu_ref uses sched-RCU.
      
        Depending on percpu_ref's internal grace periods isn't a good idea
        because
      
         - The RCU type might not match.
      
         - percpu_ref's grace periods are used to switch to atomic mode. They
           aren't between the last put and the invocation of the last release.
           This is easy to get confused about and can lead to subtle bugs.
      
         - percpu_ref might not have grace periods at all depending on its
           current operation mode.
      
        This patchset audits and fixes percpu_ref users for their RCU usages"
      
      [ There's a continuation of this series that clarifies percpu_ref
        documentation that the internal grace periods must not be depended
        upon, and introduces rcu_work to simplify bouncing to a workqueue
        after an RCU grace period.
      
        That will go in for 4.17 - this is just the minimal set with the fixes
        that are tagged for -stable ]
      
      * 'percpu_ref-rcu-audit-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc:
        RDMAVT: Fix synchronization around percpu_ref
        fs/aio: Use RCU accessors for kioctx_table->table[]
        fs/aio: Add explicit RCU grace period when freeing kioctx
      fed8f509