1. 12 Apr, 2021 16 commits
    • Heiko Carstens's avatar
      s390/atomic: use proper constraints · ca897bb1
      Heiko Carstens authored
      Use the R,T, and S constraints instead of the Q constraint in atomic
      inline assemblies wherever possible. This allows the compiler to
      generate better code. (~ -2kb code size).
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      ca897bb1
    • Heiko Carstens's avatar
      s390/atomic: move remaining inline assemblies to atomic_ops.h · c8a91c28
      Heiko Carstens authored
      Move all remaining inline assemblies from atomic.h to
      atomic_ops.h. That way all atomic inline assemblies are
      contained within only a single header file.
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      c8a91c28
    • Heiko Carstens's avatar
      s390/bitops: make bitops only work on longs · 6000b5f4
      Heiko Carstens authored
      The bitops code was optimized to generate test under mask instructions
      with the __bitops_byte() helper. However that was many years ago and
      in the meantime a lot of new instructions were introduced.
      
      Changing the code so that it always operates on longs nowadays even
      generates shorter code (~ -20kb, defconfig, gcc 10, march=zE12).
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      6000b5f4
    • Heiko Carstens's avatar
      s390/traps,mm: add conditional trap handlers · 17a363dc
      Heiko Carstens authored
      Add conditional trap handlers similar to conditional system calls
      (COND_SYSCALL), to reduce the number of ifdefs.
      
      Trap handlers which may or may not exist depending on config options
      are supposed to have a COND_TRAP entry, which redirects to
      default_trap_handler() for non-existent trap handlers during link
      time.
      
      This allows to get rid of the secure execution trap handlers for the
      !PGSTE case.
      Reviewed-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      17a363dc
    • Niklas Schnelle's avatar
      s390/pci: narrow scope of zpci_configure_device() · 61311e32
      Niklas Schnelle authored
      Currently zpci_configure_device() can be called on a zPCI function in
      two completely different states. Either the underlying zPCI function has
      already been configured by the platform and we are only doing the
      scanning to get it usable by Linux drivers. Or the underlying function
      is in Standby and we first do an SCLP to get it configured. This makes
      zpci_configure_device() harder to reason about. Since calling
      zpci_configure_device() on a function in Standby only happens in
      enable_slot() simply pull out the SCLP call and setting of zdev->state
      and thus call zpci_configure_device() under the same circumstances as
      in the event handling code.
      Reviewed-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Reviewed-by: default avatarPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      61311e32
    • Niklas Schnelle's avatar
      s390/pci: separate zbus registration from scanning · 14c87ba8
      Niklas Schnelle authored
      Now that the zbus can be created without being scanned we can go one
      step further and make registering a device to a zbus independent from
      scanning it. This way the zbus handling becomes much more natural
      in that functions can be registered on the zbus to be scanned later more
      closely resembling the handling of both real PCI hardware and other
      virtual PCI busses like Hyper-V's virtual PCI bus (see for example
      drivers/pci/controller/pci-hyperv.c:create_root_hv_pci_bus()).
      
      Having zbus registration separate from scanning allows us to return
      fully initialized but still disabled zdevs from zpci_create_device()
      which can then be configured just as we would configure a zdev from
      standby (minus the SCLP Configure already done by the platform).  There
      is still the exception that a PCI function with non-zero devfn can be
      plugged before its PCI bus, which depends on the function with zero
      devfn, is created. In this case the zdev returend from
      zpci_create_device() is still missing its bus, hotplug slot, and
      resources which need to be created later but at least it doesn't wait in
      the enabled state and can otherwise be treated as initialized.
      
      With this we also separate the initial PCI scan using CLP List PCI
      Functions into two phases. In the CLP loop's callback we only register
      each function with a virtual zbus creating the latter as needed. Then,
      after we have built this virtual PCI topology based on our list of
      zbusses, we can make use of the common code functionality to scan each
      complete zbus as a separate child bus.
      Reviewed-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Acked-by: default avatarPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      14c87ba8
    • Niklas Schnelle's avatar
      s390/pci: use mutex not spinlock for zbus list · 03502761
      Niklas Schnelle authored
      In a later change we will first collect all PCI functions from the CLP
      List PCI functions call, then register them to/creating the relevant
      zbus. Then only after we've created our virtual bus structure will we
      scan all zbusses iterating over the zbus list. Since scanning is
      relatively slow a spinlock is a bad fit for protecting the
      loop over the devices on the zbus. Furthermore doing the probing on the
      bus we need to use pci_lock_rescan_remove() as devices are added to
      the PCI subsystem and that is a mutex which can't be locked nested
      inside a spinlock section. Note that the contention of this lock should
      be very low either way as zbusses are only added/removed concurrently on
      hotplug events.
      Reviewed-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Reviewed-by: default avatarPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      03502761
    • Niklas Schnelle's avatar
      s390/pci: separate zbus creation from scanning · a50297cf
      Niklas Schnelle authored
      In the existing code the creation of the PCI bus and the scanning of
      function zero all happens in zpci_scan_bus(). This in turn requires
      functions to be enabled and their resources to be available before the
      PCI bus is even created.
      
      This not only means that functions are enabled long before they are
      actually made available to the common PCI subsystem. In case of
      functions with non-zero devfn which appeared before the function with
      devfn zero they can wait arbitrarily long in this enabled but not
      scanned state.
      
      Fix this by separating the creation of the PCI bus from scanning it and
      only prepare, that is enable and setup MMIO bus resources, functions
      just before they are scanned. As they may be scanned multiple times
      track if we already created resources in the zdev.
      Reviewed-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Acked-by: default avatarPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      a50297cf
    • Niklas Schnelle's avatar
      s390/pci: do more bus setup in zpci_bus_scan() · 7dc697d6
      Niklas Schnelle authored
      Pull setting the maximum bus speed and multifunction attribute into
      zpci_bus_scan() in preparation for handling bus creation separately
      from scanning the bus.
      Reviewed-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Acked-by: default avatarPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      7dc697d6
    • Niklas Schnelle's avatar
      s390/pci: introduce zpci_bus_scan_device() · faf29a4d
      Niklas Schnelle authored
      To match zpci_bus_scan_device() and the PCI common code terminology and
      to remove some code duplication, we pull the multiple uses of
      pci_scan_single_device() into a function. For now this has the side
      effect of adding each device to the PCI bus separately and locking and
      unlocking the rescan/remove lock for each instead of just once per bus.
      This is clearly less efficient but provides a correct intermediate
      behavior until a follow on change does both the adding and scanning only
      once per bus.
      Reviewed-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
      Acked-by: default avatarPierre Morel <pmorel@linux.ibm.com>
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      faf29a4d
    • Heiko Carstens's avatar
      s390/traps: convert pgm_check.S to C · 6f8daa29
      Heiko Carstens authored
      Convert the program check table to C. Which allows to get rid of yet
      another assembler file, and also enables proper type checking for the
      table.
      Reviewed-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      6f8daa29
    • Vineeth Vijayan's avatar
      s390/cio: use DECLARE_WAIT_QUEUE_HEAD for static work_queue_head_t · 3081e616
      Vineeth Vijayan authored
      Use DECLARE_WAIT_QUEUE_HEAD to declare and statically initialize the
      work_queue_head_t.
      Signed-off-by: default avatarVineeth Vijayan <vneethv@linux.ibm.com>
      Reviewed-by: default avatarPeter Oberparleiter <oberpar@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      3081e616
    • zhongbaisong's avatar
      s390/protvirt: fix error return code in uv_info_init() · 64497517
      zhongbaisong authored
      Fix to return a negative error code from the error handling
      case instead of 0, as done elsewhere in this function.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarBaisong Zhong <zhongbaisong@huawei.com>
      Fixes: 37564ed8 ("s390/uv: add prot virt guest/host indication files")
      Link: https://lore.kernel.org/r/2f7d62a4-3e75-b2b4-951b-75ef8ef59d16@huawei.comSigned-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      64497517
    • Heiko Carstens's avatar
      Merge branch 'fixes' into features · 0ee3f739
      Heiko Carstens authored
      * fixes:
        s390/entry: save the caller of psw_idle
        s390/entry: avoid setting up backchain in ext|io handlers
        s390/setup: use memblock_free_late() to free old stack
        s390/irq: fix reading of ext_params2 field from lowcore
        s390/unwind: add machine check handler stack
        s390/cpcmd: fix inline assembly register clobbering
        MAINTAINERS: add backups for s390 vfio drivers
        s390/vdso: fix initializing and updating of vdso_data
        s390/vdso: fix tod_steering_delta type
        s390/vdso: copy tod_steering_delta value to vdso_data page
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      0ee3f739
    • Vasily Gorbik's avatar
      s390/entry: save the caller of psw_idle · a994eddb
      Vasily Gorbik authored
      Currently psw_idle does not allocate a stack frame and does not
      save its r14 and r15 into the save area. Even though this is valid from
      call ABI point of view, because psw_idle does not make any calls
      explicitly, in reality psw_idle is an entry point for controlled
      transition into serving interrupts. So, in practice, psw_idle stack
      frame is analyzed during stack unwinding. Depending on build options
      that r14 slot in the save area of psw_idle might either contain a value
      saved by previous sibling call or complete garbage.
      
        [task    0000038000003c28] do_ext_irq+0xd6/0x160
        [task    0000038000003c78] ext_int_handler+0xba/0xe8
        [task   *0000038000003dd8] psw_idle_exit+0x0/0x8 <-- pt_regs
       ([task    0000038000003dd8] 0x0)
        [task    0000038000003e10] default_idle_call+0x42/0x148
        [task    0000038000003e30] do_idle+0xce/0x160
        [task    0000038000003e70] cpu_startup_entry+0x36/0x40
        [task    0000038000003ea0] arch_call_rest_init+0x76/0x80
      
      So, to make a stacktrace nicer and actually point for the real caller of
      psw_idle in this frequently occurring case, make psw_idle save its r14.
      
        [task    0000038000003c28] do_ext_irq+0xd6/0x160
        [task    0000038000003c78] ext_int_handler+0xba/0xe8
        [task   *0000038000003dd8] psw_idle_exit+0x0/0x6 <-- pt_regs
       ([task    0000038000003dd8] arch_cpu_idle+0x3c/0xd0)
        [task    0000038000003e10] default_idle_call+0x42/0x148
        [task    0000038000003e30] do_idle+0xce/0x160
        [task    0000038000003e70] cpu_startup_entry+0x36/0x40
        [task    0000038000003ea0] arch_call_rest_init+0x76/0x80
      Reviewed-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      a994eddb
    • Vasily Gorbik's avatar
      s390/entry: avoid setting up backchain in ext|io handlers · b74e409e
      Vasily Gorbik authored
      Currently when interrupt arrives to cpu while in kernel context
      INT_HANDLER macro (used for ext_int_handler and io_int_handler)
      allocates new stack frame and pt_regs on the kernel stack and
      sets up the backchain to jump over the pt_regs to the frame which has
      been interrupted. This is not ideal to two reasons:
      
      1. This hides the fact that kernel stack contains interrupt frame in it
         and hence breaks arch_stack_walk_reliable(), which needs to know that to
         guarantee "reliability" and checks that there are no pt_regs on the way.
      
      2. It breaks the backchain unwinder logic, which assumes that the next
         stack frame after an interrupt frame is reliable, while it is not.
         In some cases (when r14 contains garbage) this leads to early unwinding
         termination with an error, instead of marking frame as unreliable
         and continuing.
      
      To address that, only set backchain to 0.
      
      Fixes: 56e62a73 ("s390: convert to generic entry")
      Reviewed-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      b74e409e
  2. 07 Apr, 2021 3 commits
  3. 05 Apr, 2021 9 commits
    • Alexander Gordeev's avatar
      s390/mm: fix phys vs virt confusion in mark_kernel_pXd() functions family · 3784231b
      Alexander Gordeev authored
      Due to historical reasons mark_kernel_pXd() functions
      misuse the notion of physical vs virtual addresses
      difference.
      Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      3784231b
    • Tony Krowiak's avatar
      s390/vfio-ap: fix circular lockdep when setting/clearing crypto masks · 0cc00c8d
      Tony Krowiak authored
      This patch fixes a lockdep splat introduced by commit f21916ec
      ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated").
      The lockdep splat only occurs when starting a Secure Execution guest.
      Crypto virtualization (vfio_ap) is not yet supported for SE guests;
      however, in order to avoid this problem when support becomes available,
      this fix is being provided.
      
      The circular locking dependency was introduced when the setting of the
      masks in the guest's APCB was executed while holding the matrix_dev->lock.
      While the lock is definitely needed to protect the setting/unsetting of the
      matrix_mdev->kvm pointer, it is not necessarily critical for setting the
      masks; so, the matrix_dev->lock will be released while the masks are being
      set or cleared.
      
      Keep in mind, however, that another process that takes the matrix_dev->lock
      can get control while the masks in the guest's APCB are being set or
      cleared as a result of the driver being notified that the KVM pointer
      has been set or unset. This could result in invalid access to the
      matrix_mdev->kvm pointer by the intervening process. To avoid this
      scenario, two new fields are being added to the ap_matrix_mdev struct:
      
      struct ap_matrix_mdev {
      	...
      	bool kvm_busy;
      	wait_queue_head_t wait_for_kvm;
         ...
      };
      
      The functions that handle notification that the KVM pointer value has
      been set or cleared will set the kvm_busy flag to true until they are done
      processing at which time they will set it to false and wake up the tasks on
      the matrix_mdev->wait_for_kvm wait queue. Functions that require
      access to matrix_mdev->kvm will sleep on the wait queue until they are
      awakened at which time they can safely access the matrix_mdev->kvm
      field.
      
      Fixes: f21916ec ("s390/vfio-ap: clean up vfio_ap resources when KVM pointer invalidated")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTony Krowiak <akrowiak@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      0cc00c8d
    • Wan Jiabing's avatar
      s390/cio: remove duplicate struct ccw1 declaration · f38033c8
      Wan Jiabing authored
      struct ccw1 is declared twice. One has been declared
      at 21st line. Remove the duplicate.
      Signed-off-by: default avatarWan Jiabing <wanjiabing@vivo.com>
      Acked-by: default avatarVineeth Vijayan <vneethv@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      f38033c8
    • Shixin Liu's avatar
      s390/cio: use DECLARE_WAIT_QUEUE_HEAD() for wait_queue · 4e774d59
      Shixin Liu authored
      wait_queue_head_t can be initialized automatically with
      DECLARE_WAIT_QUEUE_HEAD() rather than explicitly calling
      init_waitqueue_head().
      Signed-off-by: default avatarShixin Liu <liushixin2@huawei.com>
      Acked-by: default avatarVineeth Vijayan <vneethv@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      4e774d59
    • Shixin Liu's avatar
      s390/cio: use DEFINE_SPINLOCK() for spinlock · 1034c96c
      Shixin Liu authored
      static spinlock can be initialized automatically with DEFINE_SPINLOCK()
      rather than explicitly calling spin_lock_init().
      Signed-off-by: default avatarShixin Liu <liushixin2@huawei.com>
      Acked-by: default avatarVineeth Vijayan <vneethv@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      1034c96c
    • Niklas Schnelle's avatar
      s390/pci: expose UID uniqueness guarantee · 408f2c9c
      Niklas Schnelle authored
      On s390 each PCI device has a user-defined ID (UID) exposed under
      /sys/bus/pci/devices/<dev>/uid. This ID was designed to serve as the PCI
      device's primary index and to match the device within Linux to the
      device configured in the hypervisor. To serve as a primary identifier
      the UID must be unique within the Linux instance, this is guaranteed by
      the platform if and only if the UID Uniqueness Checking flag is set
      within the CLP List PCI Functions response.
      
      While the UID has been exposed to userspace since commit ac4995b9
      ("s390/pci: add some new arch specific pci attributes") whether or not
      the platform guarantees its uniqueness for the lifetime of the Linux
      instance while defined is not visible from userspace. Remedy this by
      exposing this as a per device attribute at
      
      /sys/bus/pci/devices/<dev>/uid_is_unique
      
      Keeping this a per device attribute allows for maximum flexibility if we
      ever end up with some devices not having a UID or not enjoying the
      guaranteed uniqueness.
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Reviewed-by: default avatarViktor Mihajlovski <mihajlov@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      408f2c9c
    • Heiko Carstens's avatar
      s390/irq: fix reading of ext_params2 field from lowcore · 85012e76
      Heiko Carstens authored
      The contents of the ext_params2 field of the lowcore should just be
      copied to the pt_regs structure, not dereferenced.
      
      Fixes crashes / program check loops like this:
      
      Krnl PSW : 0404c00180000000 00000000d6d02b3c (do_ext_irq+0x74/0x170)
                 R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 RI:0 EA:3
      Krnl GPRS: 0000000000000000 80000000000b974e 00000000d71abee0 00000000d71abee0
                 0000000080030000 000000000000000f 0000000000000000 0000000000000000
                 0000000000000001 00000380000bf918 00000000d73ef780 00000380000bf518
                 0000000080348000 00000000d6d13350 00000000d6d02b1e 00000380000bf428
      Krnl Code: 00000000d6d02b2e: 58100080            l       %r1,128
                 00000000d6d02b32: 5010b0a4            st      %r1,164(%r11)
                #00000000d6d02b36: e31001b80104        lg      %r1,4536
                >00000000d6d02b3c: e31010000004        lg      %r1,0(%r1)
                 00000000d6d02b42: e310b0a80024        stg     %r1,168(%r11)
                 00000000d6d02b48: c01000242270        larl    %r1,00000000d7187028
                 00000000d6d02b4e: d5071000b010        clc     0(8,%r1),16(%r11)
                 00000000d6d02b54: a784001b            brc     8,00000000d6d02b8a
      Call Trace:
       [<00000000d6d02b3c>] do_ext_irq+0x74/0x170
       [<00000000d6d0ea5c>] ext_int_handler+0xc4/0xf4
       [<00000000d621d266>] die+0x106/0x188
       [<00000000d62305b8>] do_no_context+0xc8/0x100
       [<00000000d6d02790>] __do_pgm_check+0xe0/0x1f0
       [<00000000d6d0e950>] pgm_check_handler+0x118/0x160
       [<00000000d6d02b3c>] do_ext_irq+0x74/0x170
       [<00000000d6d0ea5c>] ext_int_handler+0xc4/0xf4
       [<00000000d621d266>] die+0x106/0x188
       [<00000000d62305b8>] do_no_context+0xc8/0x100
       [<00000000d6d02790>] __do_pgm_check+0xe0/0x1f0
       [<00000000d6d0e950>] pgm_check_handler+0x118/0x160
       [<00000000d6d02b3c>] do_ext_irq+0x74/0x170
       [<00000000d6d0ea5c>] ext_int_handler+0xc4/0xf4
       [<0000000000000000>] 0x0
       [<00000000d6d0e57a>] default_idle_call+0x42/0x110
       [<00000000d629856e>] do_idle+0xce/0x160
       [<00000000d62987be>] cpu_startup_entry+0x36/0x40
       [<00000000d621f2f2>] smp_start_secondary+0x82/0x88
      
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Fixes: 56e62a73 ("s390: convert to generic entry")
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      85012e76
    • Vasily Gorbik's avatar
      s390/unwind: add machine check handler stack · 08edb968
      Vasily Gorbik authored
      Fixes: b61b1595 ("s390: add stack for machine check handler")
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      08edb968
    • Alexander Gordeev's avatar
      s390/cpcmd: fix inline assembly register clobbering · 7a2f9144
      Alexander Gordeev authored
      Register variables initialized using arithmetic. That leads to
      kasan instrumentaton code corrupting the registers contents.
      Follow GCC guidlines and use temporary variables for assigning
      init values to register variables.
      
      Fixes: 94c12cc7 ("[S390] Inline assembly cleanup.")
      Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Acked-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      Link: https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Local-Register-Variables.htmlSigned-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      7a2f9144
  4. 28 Mar, 2021 3 commits
  5. 25 Mar, 2021 3 commits
    • Heiko Carstens's avatar
      s390/vdso: fix initializing and updating of vdso_data · 5b43bd18
      Heiko Carstens authored
      Li Wang reported that clock_gettime(CLOCK_MONOTONIC_RAW, ...) returns
      incorrect values when time is provided via vdso instead of system call:
      
      vdso_ts_nsec = 4484351380985507, vdso_ts.tv_sec = 4484351, vdso_ts.tv_nsec = 380985507
      sys_ts_nsec  = 1446923235377, sys_ts.tv_sec  = 1446, sys_ts.tv_nsec  = 923235377
      
      Within the s390 specific vdso function __arch_get_hw_counter() reads
      tod clock steering values from the arch_data member of the passed in
      vdso_data structure.
      
      Problem is that only for the CS_HRES_COARSE vdso_data arch_data is
      initialized and gets updated. The CS_RAW specific vdso_data does not
      contain any valid tod_clock_steering information, which explains the
      different values.
      
      Fix this by initializing and updating all vdso_datas.
      Reported-by: default avatarLi Wang <liwang@redhat.com>
      Tested-by: default avatarLi Wang <liwang@redhat.com>
      Fixes: 1ba2d6c0 ("s390/vdso: simplify __arch_get_hw_counter()")
      Link: https://lore.kernel.org/linux-s390/YFnxr1ZlMIOIqjfq@osirisSigned-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      5b43bd18
    • Heiko Carstens's avatar
      s390/vdso: fix tod_steering_delta type · b24bacd6
      Heiko Carstens authored
      The s390 specific vdso function __arch_get_hw_counter() is supposed to
      consider tod clock steering.
      
      If a tod clock steering event happens and the tod clock is set to a
      new value __arch_get_hw_counter() will not return the real tod clock
      value but slowly drift it from the old delta until the returned value
      finally matches the real tod clock value again.
      
      Unfortunately the type of tod_steering_delta unsigned while it is
      supposed to be signed. It depends on if tod_steering_delta is negative
      or positive in which direction the vdso code drifts the clock value.
      
      Worst case is now that instead of drifting the clock slowly it will
      jump into the opposite direction by a factor of two.
      
      Fix this by simply making tod_steering_delta signed.
      
      Fixes: 4bff8cb5 ("s390: convert to GENERIC_VDSO")
      Cc: <stable@vger.kernel.org> # 5.10
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      b24bacd6
    • Heiko Carstens's avatar
      s390/vdso: copy tod_steering_delta value to vdso_data page · 72bbc226
      Heiko Carstens authored
      When converting the vdso assembler code to C it was forgotten to
      actually copy the tod_steering_delta value to vdso_data page.
      
      Which in turn means that tod clock steering will not work correctly.
      
      Fix this by simply copying the value whenever it is updated.
      
      Fixes: 4bff8cb5 ("s390: convert to GENERIC_VDSO")
      Cc: <stable@vger.kernel.org> # 5.10
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      72bbc226
  6. 24 Mar, 2021 2 commits
  7. 22 Mar, 2021 4 commits