1. 20 Nov, 2020 15 commits
  2. 18 Nov, 2020 4 commits
  3. 12 Nov, 2020 3 commits
  4. 09 Nov, 2020 18 commits
    • Harald Freudenberger's avatar
      s390/zcrypt/pkey: introduce zcrypt_wait_api_operational() function · 43cb5a7c
      Harald Freudenberger authored
      The zcrypt api provides a new function to wait until the zcrypt
      api is operational:
      
        int zcrypt_wait_api_operational(void);
      
      The AP bus scan and the binding of ap devices to device drivers is
      an asynchronous job. This function waits until these initial jobs
      are done and so the zcrypt api should be ready to serve crypto
      requests - if there are resources available. The function uses an
      internal timeout of 60s. The very first caller will either wait for
      ap bus bindings complete or the timeout happens. This state will be
      remembered for further callers which will only be blocked until a
      decision is made (timeout or bindings complete).
      Reviewed-by: default avatarIngo Franzki <ifranzki@linux.ibm.com>
      Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      43cb5a7c
    • Harald Freudenberger's avatar
      s390/ap: ap bus userspace notifications for some bus conditions · 837cd105
      Harald Freudenberger authored
      This patch adds notifications to userspace for two important
      conditions of the ap bus:
      
      I) Initial ap bus scan done. This indicates that the initial
         scan of all the ap devices (cards, queues) is complete and
         ap devices have been build up for all the hardware found.
         This condition is signaled with
         1) An ap bus change uevent send to userspace with an environment
            key/value pair "INITSCAN=done":
      	# udevadm monitor -k -p
      	...
      	KERNEL[97.830919] change   /devices/ap (ap)
      	ACTION=change
      	DEVPATH=/devices/ap
      	SUBSYSTEM=ap
      	INITSCAN=done
      	SEQNUM=10421
         2) A sysfs attribute /sys/bus/ap/scans which shows the
            number of completed ap bus scans done since bus init.
            So a value of 1 or greater signals that the initial
            ap bus scan is complete.
         Note: The initial ap bus scan complete condition is fulfilled
         and will be signaled even if there was no ap resource found.
      
      II) APQN driver bindings complete. This indicates that all
          APQNs have been bound to an zcrypt or alternate device
          driver. Only with the help of an device driver an APQN
          can be used for crypto load. So the binding complete
          condition is the starting point for user space to be
          sure all crypto resources on the ap bus are available
          for use.
          This condition is signaled with
          1) An ap bus change uevent send to userspace with an environment
             key/value pair "BINDINGS=complete":
      	 # udevadm monitor -k -p
      	 ...
      	 KERNEL[97.830975] change   /devices/ap (ap)
      	 ACTION=change
      	 DEVPATH=/devices/ap
      	 SUBSYSTEM=ap
      	 BINDINGS=complete
      	 SEQNUM=10422
          2) A sysfs attribute /sys/bus/ap/bindings showing
      	 "<nr of bound apqns>/<total nr of apqns> (complete)"
             when all available apqns have been bound to device drivers, or
      	 "<nr of bound apqns>/<total nr of apqns>"
             when there are some apqns not bound to an device driver.
          Note: The binding complete condition is also fulfilled, when
          there are no apqns available to bind any device driver. In
          this case the binding complete will be signaled AFTER init
          scan is done.
          Note: This condition may arise multiple times when after
          initial scan modifications on the bindings take place. For
          example a manual unbind of an APQN switches the binding
          complete condition off. When at a later time the unbound APQNs
          are bound with an device driver the binding is (again) complete
          resulting in another uevent and marking the bindings sysfs
          attribute with '(complete)'.
      
      There is also a new function to be used within the kernel:
      
        int ap_wait_init_apqn_bindings_complete(unsigned long timeout)
      
      Interface to wait for the AP bus to have done one initial ap bus
      scan and all detected APQNs have been bound to device drivers.
      If these both conditions are not fulfilled, this function blocks
      on a condition with wait_for_completion_interruptible_timeout().
      If these both conditions are fulfilled (before the timeout hits)
      the return value is 0. If the timeout (in jiffies) hits instead
      -ETIME is returned. On failures negative return values are
      returned to the caller. Please note that further unbind/bind
      actions after initial binding complete is through do not cause this
      function to block again.
      Reviewed-by: default avatarIngo Franzki <ifranzki@linux.ibm.com>
      Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      837cd105
    • Christian Borntraeger's avatar
      s390/trng: set quality to 1024 · d041315e
      Christian Borntraeger authored
      The s390-trng does provide 100% entropy. The quality value is supported
      to be between 1 and 1024 and not 1..1000.  Use 1024 to make this driver
      the preferred one. If we ever have a better driver that has the same
      quality but is faster we can change this again when merging the new
      driver. No need to be conservative.
      
      This makes sure that the hw variant is preferred over things like
      virtio-rng, where the hypervisor has a potential to be misconfigured
      and thus should have a slightly lower confidence.
      
      Cc: Harald Freudenberger <freude@linux.ibm.com>
      Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      d041315e
    • Daniel Vetter's avatar
      s390/pci: remove races against pte updates · a67a88b0
      Daniel Vetter authored
      Way back it was a reasonable assumptions that iomem mappings never
      change the pfn range they point at. But this has changed:
      
      - gpu drivers dynamically manage their memory nowadays, invalidating
      ptes with unmap_mapping_range when buffers get moved
      
      - contiguous dma allocations have moved from dedicated carvetouts to
      cma regions. This means if we miss the unmap the pfn might contain
      pagecache or anon memory (well anything allocated with GFP_MOVEABLE)
      
      - even /dev/mem now invalidates mappings when the kernel requests that
      iomem region when CONFIG_IO_STRICT_DEVMEM is set, see
      commit 3234ac66 ("/dev/mem: Revoke mappings when a driver claims the
      region")
      
      Accessing pfns obtained from ptes without holding all the locks is
      therefore no longer a good idea. Fix this.
      
      Since zpci_memcpy_from|toio seems to not do anything nefarious with
      locks we just need to open code get_pfn and follow_pfn and make sure
      we drop the locks only after we're done. The write function also needs
      the copy_from_user move, since we can't take userspace faults while
      holding the mmap sem.
      Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: John Hubbard <jhubbard@nvidia.com>
      Cc: Jérôme Glisse <jglisse@redhat.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: linux-mm@kvack.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-samsung-soc@vger.kernel.org
      Cc: linux-media@vger.kernel.org
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: linux-s390@vger.kernel.org
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      a67a88b0
    • Vasily Gorbik's avatar
      s390/early: rewrite program parameter setup in C · d7e7fbba
      Vasily Gorbik authored
      And move it earlier in the decompressor.
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      d7e7fbba
    • Vasily Gorbik's avatar
      s390/kasan: move memory needs estimation into a function · 0c4ec024
      Vasily Gorbik authored
      Also correct rounding downs in estimation calculations.
      Reviewed-by: default avatarAlexander Egorenkov <egorenar@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      0c4ec024
    • Vasily Gorbik's avatar
      s390/kasan: make kasan header self-contained · e385b550
      Vasily Gorbik authored
      It is relying on _REGION1_SHIFT / _REGION2_SHIFT values which come from
      asm/pgtable.h, so include it.
      Reviewed-by: default avatarAlexander Egorenkov <egorenar@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      e385b550
    • Vasily Gorbik's avatar
      s390/kasan: remove obvious parameter with the only possible value · 54b52981
      Vasily Gorbik authored
      Kasan early code is only working on init_mm, remove unneeded pgd
      parameter from kasan_copy_shadow and rename it to
      kasan_copy_shadow_mapping.
      Reviewed-by: default avatarAlexander Egorenkov <egorenar@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      54b52981
    • Vasily Gorbik's avatar
      s390/kasan: avoid confusing naming · 92bca2fe
      Vasily Gorbik authored
      Kasan has nothing to do with vmemmap, strip vmemmap from function names
      to avoid confusing people.
      Reviewed-by: default avatarAlexander Egorenkov <egorenar@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      92bca2fe
    • Vasily Gorbik's avatar
      s390/decompressor: fix build warning · 39f2899b
      Vasily Gorbik authored
      Fixes the following warning with CONFIG_KERNEL_UNCOMPRESSED=y
      
      arch/s390/boot/compressed/decompressor.h:6:46: warning: non-void function
      does not return a value [-Wreturn-type]
      static inline void *decompress_kernel(void) {}
                                                   ^
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      39f2899b
    • Heiko Carstens's avatar
      s390/mm: let vmalloc area size depend on physical memory size · 90178c19
      Heiko Carstens authored
      To make sure that the vmalloc area size is for almost all cases large
      enough let it depend on the (potential) physical memory size. There is
      still the possibility to override this with the vmalloc kernel command
      line parameter.
      Reviewed-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Reviewed-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
      Reviewed-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      90178c19
    • Heiko Carstens's avatar
      s390/mm: extend default vmalloc area size to 512GB · fc67c880
      Heiko Carstens authored
      We've seen several occurences in the past where the default vmalloc
      size of 128GB is not sufficient. Therefore extend the default size.
      Reviewed-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
      Reviewed-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      fc67c880
    • Vasily Gorbik's avatar
      s390: make sure vmemmap is top region table entry aligned · 97b142b7
      Vasily Gorbik authored
      Since commit 29d37e5b ("s390/protvirt: add ultravisor initialization")
      vmax is adjusted to the ultravisor secure storage limit. This limit is
      currently applied when 4-level paging is used. Later vmax is also used
      to align vmemmap address to the top region table entry border. When vmax
      is set to the ultravisor secure storage limit this is no longer the case.
      
      Instead of changing vmax, make only MODULES_END be affected by the
      secure storage limit, so that vmax stays intact for further vmemmap
      address alignment.
      Reviewed-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      97b142b7
    • Vasily Gorbik's avatar
      s390/kasan: remove 3-level paging support · a3453d92
      Vasily Gorbik authored
      Compiling the kernel with Kasan disables automatic 3-level vs 4-level
      kernel space paging selection, because the shadow memory offset has
      to be known at compile time and there is no such offset which would be
      acceptable for both 3 and 4-level paging. Instead S390_4_LEVEL_PAGING
      option was introduced which allowed to pick how many paging levels to
      use under Kasan.
      
      With the introduction of protected virtualization, kernel memory layout
      may be affected due to ultravisor secure storage limit. This adds
      additional complexity into how memory layout would look like in
      combination with Kasan predefined shadow memory offsets. To simplify
      this make Kasan 4-level paging default and remove Kasan 3-level paging
      support.
      Suggested-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Reviewed-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      a3453d92
    • Vasily Gorbik's avatar
      s390: remove unused s390_base_ext_handler · f38b0a74
      Vasily Gorbik authored
      s390_base_ext_handler_fn haven't been used since its introduction in
      commit ab14de6c ("[S390] Convert memory detection into C code.").
      
      s390_base_ext_handler itself is currently falsely storing 16 registers
      at __LC_SAVE_AREA_ASYNC rewriting several following lowcore values:
      cpu_flags, return_psw, return_mcck_psw, sync_enter_timer and
      async_enter_timer.
      
      Besides that s390_base_ext_handler itself is only potentially hiding
      EXT interrupts which should not have happen in the first place. Any
      piece of code which requires EXT interrupts before fully functional
      ext_int_handler is enabled has to do it on its own, like this is done
      by sclp_early_cmd() which is doing EXT interrupts handling synchronously
      in sclp_early_wait_irq().
      
      With s390_base_ext_handler removed unexpected EXT interrupt leads
      to disabled wait with the address 0x1b0 (__LC_EXT_NEW_PSW), which is
      currently setup in the decompressor.
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      f38b0a74
    • Vasily Gorbik's avatar
      s390/udelay: make it work for the early code · 85cde019
      Vasily Gorbik authored
      Currently udelay relies on working EXT interrupts handler, which is not
      the case during early startup. In such cases udelay_simple() has to be
      used instead.
      
      To avoid mistakes of calling udelay too early, which could happen from
      the common code as well - make udelay work for the early code by
      introducing static branch and redirecting all udelay calls to
      udelay_simple until EXT interrupts handler is fully initialized and
      async stack is allocated.
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      85cde019
    • Vasily Gorbik's avatar
      s390/head: set io/ext handlers to disabled wait · 13b5bd8a
      Vasily Gorbik authored
      Set io/ext handlers to disabled wait in the initial lowcore, so that they
      are effective right from the kernel start, when a boot method used does
      not rewrite this part of the lowcore for its own needs (i.e. kexec, z/vm
      ipl reader boot, qemu direct boot, load from removable media or server).
      
      When the kernel is loaded by zipl, scsi loader or qemu loader, some or
      all of the io/ext/pgm handlers addresses might be rewritten. Rewrite them
      to initial values again as early as possible.
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      13b5bd8a
    • Heiko Carstens's avatar
      s390: fix system call exit path · ce9dfafe
      Heiko Carstens authored
      The system call exit path is running with interrupts enabled while
      checking for TIF/PIF/CIF bits which require special handling. If all
      bits have been checked interrupts are disabled and the kernel exits to
      user space.
      The problem is that after checking all bits and before interrupts are
      disabled bits can be set already again, due to interrupt handling.
      
      This means that the kernel can exit to user space with some
      TIF/PIF/CIF bits set, which should never happen. E.g. TIF_NEED_RESCHED
      might be set, which might lead to additional latencies, since that bit
      will only be recognized with next exit to user space.
      
      Fix this by checking the corresponding bits only when interrupts are
      disabled.
      
      Fixes: 0b0ed657 ("s390: remove critical section cleanup from entry.S")
      Cc: <stable@vger.kernel.org> # 5.8
      Acked-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      ce9dfafe