linux-2.6-microblaze.git
2 years agos390/ap: use the common driver-data pointer
Julian Wiedmann [Mon, 7 Jun 2021 09:18:44 +0000 (11:18 +0200)]
s390/ap: use the common driver-data pointer

The device struct provides a pointer for driver-private data. Use this
in the zcrypt drivers (as vfio_ap already does), and then remove the
custom pointer from the AP device structs.

As really_probe() will always clear the drvdata pointer on error, we
no longer have to do so ourselves.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/ap: use the common device_driver pointer
Julian Wiedmann [Mon, 7 Jun 2021 09:18:43 +0000 (11:18 +0200)]
s390/ap: use the common device_driver pointer

The device struct itself already contains a pointer to its driver.
Use this consistently, instead of duplicating it.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/pci: reset zdev->zbus on registration failure
Niklas Schnelle [Fri, 6 Aug 2021 10:12:11 +0000 (12:12 +0200)]
s390/pci: reset zdev->zbus on registration failure

On failure to register a struct zpci_dev with a struct zpci_bus we left
a dangling pointer in zdev->zbus. As zpci_create_device() bails if
zpci_bus_device_register() fails this is of no consequence but still bad
practice.

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/pci: cleanup resources only if necessary
Niklas Schnelle [Fri, 6 Aug 2021 08:28:40 +0000 (10:28 +0200)]
s390/pci: cleanup resources only if necessary

It's currently safe to call zpci_cleanup_bus_resources() even if the
resources were never created but it makes no sense so check
zdev->has_resources before we call zpci_cleanup_bus_resources() in
zpci_release_device().

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Acked-by: Pierre Morel <pmorel@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/sclp: reserve memory occupied by sclp early buffer
Alexander Egorenkov [Tue, 10 Aug 2021 13:20:00 +0000 (15:20 +0200)]
s390/sclp: reserve memory occupied by sclp early buffer

The memory block occupied by the SCLP early buffer that is allocated
by the decompressor and then handed over to the decompressed kernel,
must be reserved to prevent it from being reused for other purposes.
This is necessary because the SCLP early buffer is still in use
during kernel initialization.

Fixes: f1d3c5323772 ("s390/boot: move sclp early buffer from fixed address in asm to C")
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reported-by: Alexander Gordeev <agordeev@linux.ibm.com>
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/zcrypt: fix wrong offset index for APKA master key valid state
Harald Freudenberger [Fri, 6 Aug 2021 10:02:00 +0000 (12:02 +0200)]
s390/zcrypt: fix wrong offset index for APKA master key valid state

Tests showed a mismatch between what the CCA tool reports about
the APKA master key state and what's displayed by the zcrypt dd
in sysfs. After some investigation, we found out that the
documentation which was the source for the zcrypt dd implementation
lacks the listing of 3 fields. So this patch now moves the
evaluation of the APKA master key state to the correct offset.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/mm: remove unused cmma functions
David Hildenbrand [Fri, 6 Aug 2021 07:54:30 +0000 (09:54 +0200)]
s390/mm: remove unused cmma functions

The last user of arch_set_page_states(), arch_set_page_nodat() and
arch_test_page_nodat() was removed in commit 394216275c7d
("s390: remove broken hibernate / power management support"),
let's remove these functions.

Signed-off-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20210806075430.6103-1-david@redhat.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/qdio: remove unused support for SLIB parameters
Julian Wiedmann [Mon, 26 Jul 2021 06:27:58 +0000 (08:27 +0200)]
s390/qdio: remove unused support for SLIB parameters

Neither of the two drivers provides any SLIB parameter data, so get rid
of the dead code.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/qdio: consolidate QIB code
Julian Wiedmann [Mon, 26 Jul 2021 06:25:41 +0000 (08:25 +0200)]
s390/qdio: consolidate QIB code

Move all QIB-related code into qdio_setup_qib(), and slightly re-order
it according to the order of the struct's fields. This makes it easier
to understand what the QIB actually looks like before we send it to HW.

Also get rid of the qebsm_possible() helper - as 31-bit support is long
gone, the comment doesn't make any sense. And while removing some stale
QIB-related comment, also move the clearing of the QDR into its proper
place.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/qdio: use dev_info() in qdio_print_subchannel_info()
Julian Wiedmann [Mon, 12 Jul 2021 07:39:57 +0000 (09:39 +0200)]
s390/qdio: use dev_info() in qdio_print_subchannel_info()

Prefer dev_info() over a raw printk. This also adds the device and
driver names into the output, so that we have:

Before:
    qdio: 0.0.17c0 ZFCP on SC 17 using [...]

After:
    zfcp 0.0.17c0: qdio: ZFCP on SC 17 using [...]

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/qdio: fine-tune the queue sync
Julian Wiedmann [Fri, 23 Jul 2021 08:02:17 +0000 (10:02 +0200)]
s390/qdio: fine-tune the queue sync

Push the sync check from qdio_inspect_queue() down into the two
get_*_buffer_frontier() code paths, where we actually need the sync to
look at the current queue state. This lets us avoid the check when we
know that there is no work on the queue (ie. when q->nr_buf_used is 0).

While at it introduce the qdio_sync_*_queue() helpers, so that we can
avoid the branch on q->is_input_q when we already know the queue type.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/qdio: clean up SIGA capability tracking
Julian Wiedmann [Fri, 23 Jul 2021 06:06:50 +0000 (08:06 +0200)]
s390/qdio: clean up SIGA capability tracking

Don't bother with translating the SIGA-related capability bits into
our own internal format, just cache the full qdioac1 field instead.

Also adjust the helper macros so that they take a qdio_irq argument
and can be used everywhere, instead of taking a qdio_q and then
internally dereferencing the parent pointer.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/qdio: remove unused sync-after-IRQ infrastructure
Julian Wiedmann [Tue, 23 Mar 2021 22:43:02 +0000 (23:43 +0100)]
s390/qdio: remove unused sync-after-IRQ infrastructure

The queue processing is fully decoupled from any preceding interrupt,
so we're no longer making any use of the sync-after-IRQ HW capabilities.

And as SIGA-sync is a legacy feature, there's also not much point in
re-designing the driver & qdio-layer code just so that we can
potentially avoid a few syncs. So just remove all the leftover code.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/qdio: use absolute data address in ESTABLISH ccw
Julian Wiedmann [Thu, 8 Jul 2021 06:32:46 +0000 (08:32 +0200)]
s390/qdio: use absolute data address in ESTABLISH ccw

Clean up yet another path where HW wants an absolute address, and we've
been implicitly relying on V=R.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/cio: add dev_busid sysfs entry for each subchannel
Vineeth Vijayan [Sun, 25 Apr 2021 08:52:38 +0000 (10:52 +0200)]
s390/cio: add dev_busid sysfs entry for each subchannel

Introduce dev_busid, which exports the device-id associated with the
io-subchannel (and message-subchannel). The dev_busid indicates that of
the device which may be physically installed on the corrosponding
subchannel. The dev_busid value "none" indicates that the subchannel
is not valid, there is no I/O device currently associated with the
subchannel.

The dev_busid information would be helpful to write device-specific
udev-rules associated with the subchannel. The dev_busid interface would
be available even when the sch is not bound to any driver or if there is
no operational device connected on it. Hence this attribute can be used to
write udev-rules which are specific to the device associated with the
subchannel.

Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390/cio: add rescan functionality on channel subsystem
Vineeth Vijayan [Sun, 25 Apr 2021 09:27:59 +0000 (11:27 +0200)]
s390/cio: add rescan functionality on channel subsystem

This patch introduces a new rescan sys-interface for channel-subsystem.
The rescan interface allows the user to invoke an evaluation of all
subchannels defined in the I/O configuration.

The new rescan interface can be found at /sys/devices/css0/rescan
and can be triggered by,

echo > /sys/devices/css0/rescan

Writing to this interface triggers subchannel evaluation. The write
request completes only after scan-related work has completed

This user-invoked subchannel evaluation allows manual recovery in error
situations such as:
 - restart of device discovery after resolution of temporary device
   error
 - inconsistent OS view of subchannel state due to missing state-change
   interrupts (CRWs)

Signed-off-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2 years agos390: rename dma section to amode31
Heiko Carstens [Wed, 4 Aug 2021 11:40:31 +0000 (13:40 +0200)]
s390: rename dma section to amode31

The dma section name is confusing, since the code which resides within
that section has nothing to do with direct memory access.  Instead the
limitation is that the code has to run in 31 bit addressing mode, and
therefore has to reside below 2GB.  So the name was chosen since
ZONE_DMA is the same region.

To reduce confusion rename the section to amode31, which hopefully
describes better what this is about.

Note: this will also change vmcoreinfo strings
- SDMA=... gets renamed to SAMODE31=...
- EDMA=... gets renamed to EAMODE31=...

Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/mm: use page_to_virt() in __kernel_map_pages()
Heiko Carstens [Tue, 3 Aug 2021 12:42:29 +0000 (14:42 +0200)]
s390/mm: use page_to_virt() in __kernel_map_pages()

Fix virtual vs physical address confusion (which currently are the same).

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/sclp: replace deprecated CPU-hotplug functions
Sebastian Andrzej Siewior [Tue, 3 Aug 2021 14:15:48 +0000 (16:15 +0200)]
s390/sclp: replace deprecated CPU-hotplug functions

The functions get_online_cpus() and put_online_cpus() have been
deprecated during the CPU hotplug rework. They map directly to
cpus_read_lock() and cpus_read_unlock().

Replace deprecated CPU-hotplug functions with the official version.
The behavior remains unchanged.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20210803141621.780504-6-bigeasy@linutronix.de
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390: replace deprecated CPU-hotplug functions
Sebastian Andrzej Siewior [Tue, 3 Aug 2021 14:15:47 +0000 (16:15 +0200)]
s390: replace deprecated CPU-hotplug functions

The functions get_online_cpus() and put_online_cpus() have been
deprecated during the CPU hotplug rework. They map directly to
cpus_read_lock() and cpus_read_unlock().

Replace deprecated CPU-hotplug functions with the official version.
The behavior remains unchanged.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20210803141621.780504-5-bigeasy@linutronix.de
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/ftrace: implement hotpatching
Ilya Leoshkevich [Wed, 28 Jul 2021 21:25:46 +0000 (23:25 +0200)]
s390/ftrace: implement hotpatching

s390 allows hotpatching the mask of a conditional jump instruction.
Make use of this feature in order to avoid the expensive stop_machine()
call.

The new trampolines are split in 3 stages:

- A first stage is a 6-byte relative conditional long branch located at
  each function's entry point. Its offset always points to the second
  stage for the corresponding function, and its mask is either all 0s
  (ftrace off) or all 1s (ftrace on). The code for flipping the mask is
  borrowed from ftrace_{enable,disable}_ftrace_graph_caller. After
  flipping, ftrace_arch_code_modify_post_process() syncs with all the
  other CPUs by sending SIGPs.

- Second stages for vmlinux are stored in a separate part of the .text
  section reserved by the linker script, and in dynamically allocated
  memory for modules. This prevents the icache pollution. The total
  size of second stages is about 1.5% of that of the kernel image.

  Putting second stages in the .bss section is possible and decreases
  the size of the non-compressed vmlinux, but splits the kernel 1:1
  mapping, which is a bad tradeoff.

  Each second stage contains a call to the third stage, a pointer to
  the part of the intercepted function right after the first stage, and
  a pointer to an interceptor function (e.g. ftrace_caller).

  Second stages are 8-byte aligned for the future direct calls
  implementation.

- There are only two copies of the third stage: in the .text section
  for vmlinux and in dynamically allocated memory for modules. It can be
  an expoline, which is relatively large, so inlining it into each
  second stage is prohibitively expensive.

As a result of this organization, phoronix-test-suite with ftrace off
does not show any performance degradation.

Suggested-by: Sven Schnelle <svens@linux.ibm.com>
Suggested-by: Vasily Gorbik <gor@linux.ibm.com>
Co-developed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Link: https://lore.kernel.org/r/20210728212546.128248-3-iii@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agoftrace: Introduce ftrace_need_init_nop()
Ilya Leoshkevich [Wed, 28 Jul 2021 21:25:45 +0000 (23:25 +0200)]
ftrace: Introduce ftrace_need_init_nop()

Implementing live patching on s390 requires each function's prologue to
contain a very special kind of nop, which gcc and clang don't generate.
However, the current code assumes that if CC_USING_NOP_MCOUNT is
defined, then whatever the compiler generates is good enough.

Move the CC_USING_NOP_MCOUNT check into the new ftrace_need_init_nop()
macro, that the architectures can override.

An alternative solution is to disable using -mnop-mcount in the
Makefile, however, this makes the build logic (even) more complicated
and forces the arch-specific code to deal with the useless __fentry__
symbol.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20210728212546.128248-2-iii@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390: move the install rule to arch/s390/Makefile
Masahiro Yamada [Thu, 29 Jul 2021 14:23:38 +0000 (23:23 +0900)]
s390: move the install rule to arch/s390/Makefile

Currently, the install target in arch/s390/Makefile descends into
arch/s390/boot/Makefile to invoke the shell script, but there is no
good reason to do so.

arch/s390/Makefile can run the shell script directly.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Link: https://lore.kernel.org/r/20210729142338.446002-1-masahiroy@kernel.org
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390: enable KCSAN
Ilya Leoshkevich [Wed, 28 Jul 2021 11:59:04 +0000 (13:59 +0200)]
s390: enable KCSAN

s390x GCC and SystemZ Clang have ThreadSanitizer support now [1] [2],
so enable KCSAN for s390.

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ea22954e7c58
[2] https://reviews.llvm.org/D105629

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agokcsan: use u64 instead of cycles_t
Heiko Carstens [Thu, 29 Jul 2021 14:28:11 +0000 (16:28 +0200)]
kcsan: use u64 instead of cycles_t

cycles_t has a different type across architectures: unsigned int,
unsinged long, or unsigned long long. Depending on architecture this
will generate this warning:

kernel/kcsan/debugfs.c: In function ‘microbenchmark’:
./include/linux/kern_levels.h:5:25: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘cycles_t’ {aka ‘long unsigned int’} [-Wformat=]

To avoid this simply change the type of cycle to u64 in microbenchmark(),
since u64 is of type unsigned long long for all architectures.

Acked-by: Marco Elver <elver@google.com>
Link: https://lore.kernel.org/r/20210729142811.1309391-1-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390: add kfence region to pagetable dumper
Sven Schnelle [Wed, 28 Jul 2021 19:02:54 +0000 (21:02 +0200)]
s390: add kfence region to pagetable dumper

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Link: https://lore.kernel.org/r/20210728190254.3921642-5-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390: add support for KFENCE
Sven Schnelle [Wed, 28 Jul 2021 19:02:53 +0000 (21:02 +0200)]
s390: add support for KFENCE

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
[hca@linux.ibm.com: simplify/rework code]
Link: https://lore.kernel.org/r/20210728190254.3921642-4-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agokfence: add function to mask address bits
Sven Schnelle [Wed, 28 Jul 2021 19:02:52 +0000 (21:02 +0200)]
kfence: add function to mask address bits

s390 only reports the page address during a translation fault.
To make the kfence unit tests pass, add a function that might
be implemented by architectures to mask out address bits.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Marco Elver <elver@google.com>
Link: https://lore.kernel.org/r/20210728190254.3921642-3-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/mm: implement set_memory_4k()
Heiko Carstens [Wed, 28 Jul 2021 19:02:51 +0000 (21:02 +0200)]
s390/mm: implement set_memory_4k()

Implement set_memory_4k() which will split any present large or huge
mapping in the given range to a 4k mapping.

Link: https://lore.kernel.org/r/20210728190254.3921642-2-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agokfence, x86: only define helpers if !MODULE
Marco Elver [Wed, 28 Jul 2021 19:57:41 +0000 (21:57 +0200)]
kfence, x86: only define helpers if !MODULE

x86's <asm/tlbflush.h> only declares non-module accessible functions
(such as flush_tlb_one_kernel) if !MODULE.

In preparation of including <asm/kfence.h> from the KFENCE test module,
only define the helpers if !MODULE to avoid breaking the build with
CONFIG_KFENCE_KUNIT_TEST=m.

Signed-off-by: Marco Elver <elver@google.com>
Link: https://lore.kernel.org/r/YQJdarx6XSUQ1tFZ@elver.google.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/delay: get rid of not needed header includes
Heiko Carstens [Sun, 25 Jul 2021 13:13:12 +0000 (15:13 +0200)]
s390/delay: get rid of not needed header includes

After all the changes to delay.c there are many includes which are not
needed anymore. Get rid of them.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: get rid of arithmetics on function pointers
Heiko Carstens [Sun, 25 Jul 2021 13:07:25 +0000 (15:07 +0200)]
s390/boot: get rid of arithmetics on function pointers

sparse warning:
  CHECK   arch/s390/boot/startup.c
arch/s390/boot/startup.c:283:39: error: arithmetics on pointers to functions

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/headers: fix code style in module.h
Ilya Leoshkevich [Thu, 15 Jul 2021 11:51:02 +0000 (13:51 +0200)]
s390/headers: fix code style in module.h

struct brace should be on the same line.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: make sie capability regular hwcap
Heiko Carstens [Wed, 21 Jul 2021 12:03:33 +0000 (14:03 +0200)]
s390/hwcaps: make sie capability regular hwcap

Commit 7f16d7e787b7 ("s390: show virtualization support in /proc/cpuinfo")
introduced special handling for sie capability, saying this should not be
exposed via hwcaps, without giving a reason.

However this leads to an inconsistent /proc/cpuinfo features line
where all features except the sie capability are also present in
hwcaps. I really don't see a reason to not add that to hwcaps - it
might be quite pointless, but at least this way it is possible to get
rid of some special handling.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: remove hwcap stfle check
Heiko Carstens [Wed, 21 Jul 2021 19:05:35 +0000 (21:05 +0200)]
s390/hwcaps: remove hwcap stfle check

Remove the not so obvious "(elf_hwcap & (1UL << 2)" which only checks
if stfle is available. This used to be required for old code before
test_facility() was introduced. test_facility() will do the right
thing, regardless if stfle is available or not.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: remove z/Architecture mode active check
Heiko Carstens [Wed, 21 Jul 2021 19:03:44 +0000 (21:03 +0200)]
s390/hwcaps: remove z/Architecture mode active check

Remove a leftover from the common 31/64 bit code. z/Architecture mode
is now always active, there is no need to check.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: use consistent coding style / remove comments
Heiko Carstens [Wed, 21 Jul 2021 19:03:04 +0000 (21:03 +0200)]
s390/hwcaps: use consistent coding style / remove comments

Use a consistent coding style within setup_hwcaps() and remove obvious
and outdated comments.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: open code initialization of first six hwcap bits
Heiko Carstens [Wed, 21 Jul 2021 18:58:03 +0000 (20:58 +0200)]
s390/hwcaps: open code initialization of first six hwcap bits

The first six hwcap bits are initialized in a rather odd way: an array
contains the stfl(e) bits which need to be set, so that the
corresponding bit position (= array index) within hwcaps are set.

Better open code it like it is done for all other bits, making it
obvious which bit is set when.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: split setup_hwcaps()
Heiko Carstens [Wed, 21 Jul 2021 11:25:21 +0000 (13:25 +0200)]
s390/hwcaps: split setup_hwcaps()

setup_hwcaps() is a quite large function. Make it smaller by moving
the elf platform setup code into an independent setup function.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: move setup_hwcaps()
Heiko Carstens [Wed, 21 Jul 2021 11:23:07 +0000 (13:23 +0200)]
s390/hwcaps: move setup_hwcaps()

Move setup_hwcaps() to processor.c for two reasons:
- make setup.c a bit smaller
- have allmost all of the hwcap code in one file

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: add sanity checks
Heiko Carstens [Wed, 21 Jul 2021 09:39:25 +0000 (11:39 +0200)]
s390/hwcaps: add sanity checks

Add BUILD_BUG_ON() sanity checks to make sure the hwcap string array
contains a string for each hwcap.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: use named initializers for hwcap string arrays
Heiko Carstens [Wed, 21 Jul 2021 09:35:19 +0000 (11:35 +0200)]
s390/hwcaps: use named initializers for hwcap string arrays

Use named initializers to make it obvious which hwcap string array
element belongs to which hwcap.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: introduce HWCAP bit numbers
Heiko Carstens [Wed, 21 Jul 2021 09:12:36 +0000 (11:12 +0200)]
s390/hwcaps: introduce HWCAP bit numbers

Introduce HWCAP bit numbers, making it easier to tell at which bit
number we currently are. Also use these bits with the BIT macro to
define the real HWCAP masks.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/hwcaps: shorten HWCAP defines
Heiko Carstens [Wed, 21 Jul 2021 08:56:57 +0000 (10:56 +0200)]
s390/hwcaps: shorten HWCAP defines

Remove s390 part of all HWCAP defines, just to make them shorter and
easier to handle. The namespace is anyway per architecture.
This is similar to what arm64 has.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390: add HWCAP_S390_PCI_MIO to ELF hwcaps
Niklas Schnelle [Thu, 8 Jul 2021 13:43:13 +0000 (15:43 +0200)]
s390: add HWCAP_S390_PCI_MIO to ELF hwcaps

In order to support the use of enhanced PCI instructions in both kernel-
and userspace we need both hardware support and proper setup in the
kernel. The latter can be toggled off with the pci=nomio command line
option.

Thus availability of this feature in userspace depends on all of kernel
configuration (CONFIG_PCI), hardware support and the current kernel
command line and can thus not rely solely on a facility bit. Instead
let's introduce a new ELF hardware capability bit HWCAP_S390_PCI_MIO to
tell userspace whether these PCI instructions can be used.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390: make PCI mio support a machine flag
Niklas Schnelle [Thu, 8 Jul 2021 12:55:42 +0000 (14:55 +0200)]
s390: make PCI mio support a machine flag

Kernel support for the newer PCI mio instructions can be toggled off
with the pci=nomio command line option which needs to integrate with
common code PCI option parsing. However this option then toggles static
branches which can't be toggled yet in an early_param() call.

Thus commit 9964f396f1d0 ("s390: fix setting of mio addressing control")
moved toggling the static branches to the PCI init routine.

With this setup however we can't check for mio support outside the PCI
code during early boot, i.e. before switching the static branches, which
we need to be able to export this as an ELF HWCAP.

Improve on this by turning mio availability into a machine flag that
gets initially set based on CONFIG_PCI and the facility bit and gets
toggled off if pci=nomio is found during PCI option parsing allowing
simple access to this machine flag after early init.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/disassembler: add instructions
Heiko Carstens [Mon, 15 Feb 2021 19:57:53 +0000 (20:57 +0100)]
s390/disassembler: add instructions

Add more instructions to the kernel disassembler.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390: report more CPU capabilities
Heiko Carstens [Wed, 13 Jan 2021 13:14:01 +0000 (14:14 +0100)]
s390: report more CPU capabilities

Add hardware capability bits and feature tags to /proc/cpuinfo
for NNPA and Vector-Packed-Decimal-Enhancement Facility 2.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/qdio: remove unused macros
Julian Wiedmann [Mon, 22 Feb 2021 09:18:33 +0000 (10:18 +0100)]
s390/qdio: remove unused macros

These macros haven't seen any use in a long time. Also note that the
queue_irqs_*() ones wouldn't even compile anymore.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/qdio: clarify reporting of errors to the drivers
Julian Wiedmann [Wed, 14 Jul 2021 16:03:51 +0000 (18:03 +0200)]
s390/qdio: clarify reporting of errors to the drivers

Now that all drivers use qdio_inspect_queue() and qdio's internal
queue tasklets are gone, the driver-specified queue handlers are
only called for async error reporting (eg. for an error condition in
the QEBSM code).

So take a moment to clean up the Output Queue handlers (they are
_always_ called with qdio_error != 0), and clarify which error types
can be reported through what interface. As Benjamin already suggested
a while ago, we should turn these into distinct enums at some point.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/qdio: remove unneeded siga-sync for Output Queue
Julian Wiedmann [Mon, 12 Jul 2021 06:29:32 +0000 (08:29 +0200)]
s390/qdio: remove unneeded siga-sync for Output Queue

get_outbound_buffer_frontier() is only reached via qdio_inspect_queue(),
and there we already call qdio_siga_sync_q() unconditionally.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/qdio: remove remaining tasklet & timer code
Julian Wiedmann [Mon, 15 Mar 2021 18:39:20 +0000 (19:39 +0100)]
s390/qdio: remove remaining tasklet & timer code

Both qdio drivers have moved away from using qdio's internal tasklet
and timer mechanisms for Output Queues. Rip out all the leftovers.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/qdio: propagate error when cancelling a ccw fails
Julian Wiedmann [Tue, 1 Jun 2021 06:20:09 +0000 (08:20 +0200)]
s390/qdio: propagate error when cancelling a ccw fails

If qdio_cancel_ccw() times out (or is interrupted) before the interrupt
for the {halt,clear} action arrives, report this back to the caller as
an error.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/qdio: improve roll-back after error on ESTABLISH ccw
Julian Wiedmann [Mon, 31 May 2021 15:38:04 +0000 (18:38 +0300)]
s390/qdio: improve roll-back after error on ESTABLISH ccw

If the ESTABLISH ccw fails (ie. the qdio_irq is set to
QDIO_IRQ_STATE_ERR), we don't need to call qdio_shutdown() for rolling
back our earlier actions. All the needed logic is already available in
qdio_establish()'s error chain, and using it means we don't have to
temporarily drop the setup_mutex either.

This makes qdio_shutdown() a purely external function, that should only
be called by the driver if an earlier qdio_establish() succeeded.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/qdio: cancel the ESTABLISH ccw after timeout
Julian Wiedmann [Mon, 31 May 2021 15:33:02 +0000 (18:33 +0300)]
s390/qdio: cancel the ESTABLISH ccw after timeout

When the ESTABLISH ccw does not complete within the specified timeout,
try our best to cancel the ccw program that is still active on the
device. Otherwise the IO subsystem might be accessing it even after
the driver eg. called qdio_free().

Fixes: 779e6e1c724d ("[S390] qdio: new qdio driver.")
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Cc: <stable@vger.kernel.org> # 2.6.27
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/qdio: fix roll-back after timeout on ESTABLISH ccw
Julian Wiedmann [Mon, 31 May 2021 15:40:06 +0000 (18:40 +0300)]
s390/qdio: fix roll-back after timeout on ESTABLISH ccw

When qdio_establish() times out while waiting for the ESTABLISH ccw to
complete, it calls qdio_shutdown() to roll back all of its previous
actions. But at this point the qdio_irq's state is still
QDIO_IRQ_STATE_INACTIVE, so qdio_shutdown() will exit immediately
without doing any actual work.

Which means that eg. the qdio_irq's thinint-indicator stays registered,
and cdev->handler isn't restored to its old value. And since
commit 954d6235be41 ("s390/qdio: make thinint registration symmetric")
the qdio_irq also stays on the tiq_list, so on the next qdio_establish()
we might get a helpful BUG from the list-debugging code:

...
[ 4633.512591] list_add double add: new=00000000005a4110, prev=00000001b357db78, next=00000000005a4110.
[ 4633.512621] ------------[ cut here ]------------
[ 4633.512623] kernel BUG at lib/list_debug.c:29!
...
[ 4633.512796]  [<00000001b2c6ee9a>] __list_add_valid+0x82/0xa0
[ 4633.512798] ([<00000001b2c6ee96>] __list_add_valid+0x7e/0xa0)
[ 4633.512800]  [<00000001b2fcecce>] qdio_establish_thinint+0x116/0x190
[ 4633.512805]  [<00000001b2fcbe58>] qdio_establish+0x128/0x498
...

Fix this by extracting a goto-chain from the existing error exits in
qdio_establish(), and check the return value of the wait_event_...()
to detect the timeout condition.

Fixes: 779e6e1c724d ("[S390] qdio: new qdio driver.")
Root-caused-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Cc: <stable@vger.kernel.org> # 2.6.27
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/setup: don't reserve memory that occupied decompressor's head
Alexander Egorenkov [Wed, 16 Jun 2021 12:10:03 +0000 (14:10 +0200)]
s390/setup: don't reserve memory that occupied decompressor's head

There is no useful information within [STARTUP_NORMAL_OFFSET, HEAD_END] now.

But the memory region [0, STARTUP_NORMAL_OFFSET] is used by:
* lowcore
* kdump for swapping memory
* stand-alone zipl dumpers for code, data, stack and heap

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: move dma sections from decompressor to decompressed kernel
Alexander Egorenkov [Tue, 15 Jun 2021 17:17:36 +0000 (19:17 +0200)]
s390/boot: move dma sections from decompressor to decompressed kernel

This change simplifies the task of making the decompressor relocatable.

The decompressor's image contains special DMA sections between _sdma and
_edma. This DMA segment is loaded at boot as part of the decompressor and
then simply handed over to the decompressed kernel. The decompressor itself
never uses it in any way. The primary reason for this is the need to keep
the aforementioned DMA segment below 2GB which is required by architecture,
and because the decompressor is always loaded at a fixed low physical
address, it is guaranteed that the DMA region will not cross the 2GB
memory limit. If the DMA region had been placed in the decompressed kernel,
then KASLR would make this guarantee impossible to fulfill or it would
be restricted to the first 2GB of memory address space.

This commit moves all DMA sections between _sdma and _edma from
the decompressor's image to the decompressed kernel's image. The complete
DMA region is placed in the init section of the decompressed kernel and
immediately relocated below 2GB at start-up before it is needed by other
parts of the decompressed kernel. The relocation of the DMA region happens
even if the decompressed kernel is already located below 2GB in order
to keep the first implementation simple. The relocation should not have
any noticeable impact on boot time because the DMA segment is only a couple
of pages.

After relocating the DMA sections, the kernel has to fix all references
which point into it. In order to automate this, place all variables
pointing into the DMA sections in a special .dma.refs section. All such
variables must be defined using the new __dma_ref macro. Only variables
containing addresses within the DMA sections must be placed in the new
.dma.refs section.

Furthermore, move the initialization of control registers from
the decompressor to the decompressed kernel because some control registers
reference tables that must be placed in the DMA data section to
guarantee that their addresses are below 2G. Because the decompressed
kernel relocates the DMA sections at startup, the content of control
registers CR2, CR5 and CR15 must be updated with new addresses after
the relocation. The decompressed kernel initializes all control registers
early at boot and then updates the content of CR2, CR5 and CR15
as soon as the DMA relocation has occurred. This practically reverts
the commit a80313ff91ab ("s390/kernel: introduce .dma sections").

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/ctl_reg: add ctlreg5 and ctlreg15 unions
Heiko Carstens [Sun, 25 Jul 2021 12:12:58 +0000 (14:12 +0200)]
s390/ctl_reg: add ctlreg5 and ctlreg15 unions

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: make _diag308_reset_dma() position-independent
Alexander Egorenkov [Tue, 15 Jun 2021 14:05:09 +0000 (16:05 +0200)]
s390/boot: make _diag308_reset_dma() position-independent

As a preparation for moving the .dma.data section from the decompressor to
the decompressed kernel, the .dma.data section must be made relocatable
by replacing absolute memory addressing with relative one. This is required
in order to be able to relocate the DMA section to a memory address <= 2G
as required by the hardware architecture. The DMA section must be
relocated in case the decompressed kernel was loaded to an address >= 2G
which can occur if KASAN is enabled. By making the whole DMA section
position-independent we avoid applying relocations to it whenever it is
moved to a different address, which becomes possible as soon as it becomes
a part of the decompressed kernel.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: move EP_OFFSET and EP_STRING to head.S
Alexander Egorenkov [Wed, 21 Jul 2021 14:47:20 +0000 (16:47 +0200)]
s390/boot: move EP_OFFSET and EP_STRING to head.S

Both macros are used only in decompressor's head.S, unnecessary to put
them in a global header used in many places like setup.h is.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/setup: generate asm offsets from struct parmarea
Alexander Egorenkov [Wed, 21 Jul 2021 10:27:59 +0000 (12:27 +0200)]
s390/setup: generate asm offsets from struct parmarea

To reduce duplication, replace error-prone and hard-coded parameter area
offsets with auto-generated ones.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/setup: drop _OFFSET macros
Alexander Egorenkov [Wed, 21 Jul 2021 09:54:33 +0000 (11:54 +0200)]
s390/setup: drop _OFFSET macros

The macros
* IPL_DEVICE_OFFSET
* INITRD_START_OFFSET
* INITRD_SIZE_OFFSET
* OLDMEM_BASE_OFFSET
* OLDMEM_SIZE_OFFSET
* KERNEL_VERSION_OFFSET
* COMMAND_LINE_OFFSET
are no longer necessary and used only to define another set of macros
with the same names but w/o the suffix _OFFSET. Therefore, drop this
unnecessary indirection.

Drop the macro KERNEL_VERSION_OFFSET w/o renaming it to KERNEL_VERSION
because it is used nowhere.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/setup: remove unused symbolic constants for C code from setup.h
Alexander Egorenkov [Tue, 15 Jun 2021 10:57:31 +0000 (12:57 +0200)]
s390/setup: remove unused symbolic constants for C code from setup.h

These symbolic constants are used only by assembler code now:
* COMMAND_LINE
* IPL_DEVICE

C code of the decompressed kernel should use boot data passed
by the decompressor instead.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/dump: introduce boot data 'oldmem_data'
Alexander Egorenkov [Tue, 15 Jun 2021 12:25:41 +0000 (14:25 +0200)]
s390/dump: introduce boot data 'oldmem_data'

The new boot data struct shall replace global variables OLDMEM_BASE and
OLDMEM_SIZE. It is initialized in the decompressor and passed
to the decompressed kernel. In comparison to the old solution, this one
doesn't access data at fixed physical addresses which will become important
when the decompressor becomes relocatable.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: introduce boot data 'initrd_data'
Alexander Egorenkov [Tue, 15 Jun 2021 12:15:07 +0000 (14:15 +0200)]
s390/boot: introduce boot data 'initrd_data'

The new boot data struct shall replace global variables INITRD_START and
INITRD_SIZE. It is initialized in the decompressor and passed
to the decompressed kernel. In comparison to the old solution, this one
doesn't access data at fixed physical addresses which will become important
when the decompressor becomes relocatable.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: move sclp early buffer from fixed address in asm to C
Alexander Egorenkov [Thu, 5 Nov 2020 12:09:06 +0000 (13:09 +0100)]
s390/boot: move sclp early buffer from fixed address in asm to C

To make the decompressor relocatable, the early SCLP buffer with a fixed
address must be replaced with a relocatable C buffer of the according size
and alignment as required by SCLP.

Introduce a new function sclp_early_set_buffer() into the SCLP driver
which enables the decompressor to change the SCLP early buffer at any time.
This will be useful when the decompressor becomes fully relocatable and
might need to change the SCLP early buffer to one with an address < 2G
as required by SCLP because it was loaded at an address >= 2G.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: get rid of magic numbers for startup offsets
Alexander Egorenkov [Tue, 15 Jun 2021 13:59:32 +0000 (15:59 +0200)]
s390/boot: get rid of magic numbers for startup offsets

Use STARTUP_NORMAL_OFFSET and STARTUP_KDUMP_OFFSET instead of magic numbers.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/vdso: use system call functions
Heiko Carstens [Tue, 13 Jul 2021 14:21:24 +0000 (16:21 +0200)]
s390/vdso: use system call functions

Use system call functions instead of open-coding svc inline
assemblies. This is mostly to get rid of even more register asm
constructs.
Besides that, it makes the code also a bit easier to understand.
The generated code is identical to what is was before.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/syscall: provide generic system call functions
Heiko Carstens [Tue, 13 Jul 2021 14:21:07 +0000 (16:21 +0200)]
s390/syscall: provide generic system call functions

Provide generic system call functions which should be used whenever a
system call needs to be done from user space. The only in-kernel code
is vdso, which will be converted with a follow on patch.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/cpacf: get rid of register asm
Heiko Carstens [Fri, 25 Jun 2021 14:42:55 +0000 (16:42 +0200)]
s390/cpacf: get rid of register asm

Using register asm statements has been proven to be very error prone,
especially when using code instrumentation where gcc may add function
calls, which clobbers register contents in an unexpected way.

Therefore get rid of register asm statements in cpacf code, and make
sure this bug class cannot happen.

Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/debug: remove unused print defines
Heiko Carstens [Tue, 13 Jul 2021 19:09:58 +0000 (21:09 +0200)]
s390/debug: remove unused print defines

Remove unused print defines from debug feature header file.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/dasd: remove debug printk
Heiko Carstens [Tue, 13 Jul 2021 19:07:47 +0000 (21:07 +0200)]
s390/dasd: remove debug printk

Remove dasd ioctl debug printk which seems to be a leftover from the
very early days. At least it seems to be quite pointless.

Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/uv: de-duplicate checks for Protected Host Virtualization
Alexander Egorenkov [Fri, 25 Jun 2021 07:51:15 +0000 (09:51 +0200)]
s390/uv: de-duplicate checks for Protected Host Virtualization

De-duplicate checks for Protected Host Virtualization in decompressor and
kernel.

Set prot_virt_host=0 in the decompressor in *any* of the following cases
and hand it over to the decompressed kernel:
* No explicit prot_virt=1 is given on the kernel command-line
* Protected Guest Virtualization is enabled
* Hardware support not present
* kdump or stand-alone dump

The decompressed kernel needs to use only is_prot_virt_host() instead of
performing again all checks done by the decompressor.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: disable Secure Execution in dump mode
Alexander Egorenkov [Mon, 5 Jul 2021 17:37:25 +0000 (19:37 +0200)]
s390/boot: disable Secure Execution in dump mode

A dump kernel is neither required nor able to support Secure Execution.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: move uv function declarations to boot/uv.h
Alexander Egorenkov [Mon, 5 Jul 2021 17:33:27 +0000 (19:33 +0200)]
s390/boot: move uv function declarations to boot/uv.h

The functions adjust_to_uv_max() and uv_query_info() are used only
in the decompressor. Therefore, move the function declarations from
the global arch/s390/include/asm/uv.h to arch/s390/boot/uv.h.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/jump_label: print real address in a case of a jump label bug
Heiko Carstens [Mon, 12 Jul 2021 17:26:01 +0000 (19:26 +0200)]
s390/jump_label: print real address in a case of a jump label bug

In case of a jump label print the real address of the piece of code
where a mismatch was detected. This is right before the system panics,
so there is nothing revealed.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/mm: don't print hashed values for pte_ERROR() & friends
Heiko Carstens [Mon, 12 Jul 2021 17:19:03 +0000 (19:19 +0200)]
s390/mm: don't print hashed values for pte_ERROR() & friends

Print the real pte, pmd, etc. values instead of some hashed
value. Otherwise debugging would be even more difficult.
This also matches what most other architectures are doing.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/mm: use pr_err() instead of printk() for pte_ERROR & friends
Heiko Carstens [Mon, 12 Jul 2021 17:33:09 +0000 (19:33 +0200)]
s390/mm: use pr_err() instead of printk() for pte_ERROR & friends

Use pr_err() to use a proper printk level.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/sclp: use only one sclp early buffer to send commands
Alexander Egorenkov [Sat, 10 Oct 2020 01:34:25 +0000 (03:34 +0200)]
s390/sclp: use only one sclp early buffer to send commands

A buffer that can be used for communication with SCLP is required
to lie below 2GB memory address. Therefore, both sclp_info_sccb
and sclp_early_sccb must fulfill this requirement if passed directly
to the sclp_early_cmd() function. Instead, use only sclp_early_sccb
for communication with SCLP. This allows the buffer sclp_info_sccb
to be placed anywhere in the memory address space and, therefore,
simplifies the process of making the decompressor relocatable later on,
one thing less to relocate. And make sure that the length of the new unified
early SCLP buffer is no less than the length of the removed sclp_info_sccb
buffer which might be larger than the length of the sclp_early_sccb buffer.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/cio: remove unused include linux/spinlock.h from cio.h
Alexander Egorenkov [Tue, 15 Jun 2021 07:20:26 +0000 (09:20 +0200)]
s390/cio: remove unused include linux/spinlock.h from cio.h

* The linux/spinlock.h header was included indirectly by the decompressor
  and brought unnecessary build dependencies.
* Use proper includes in files which either directly or indirectly included
  cio.h and were hidden until now by the included linux/spinlock.h, e.g.
  linux/string.h for memcpy() or asm/page.h for PAGE_SIZE.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: make stacks part of the decompressor's image
Alexander Egorenkov [Wed, 30 Jun 2021 15:17:53 +0000 (17:17 +0200)]
s390/boot: make stacks part of the decompressor's image

Instead of using constant addresses for the normal and dump-info stacks,
allocate both stacks in the decompressor's image and load the stack register
in a position-independent manner.

This will allow loading and entering the decompressor at an arbitrary
memory address without corrupting the content at the fixed addresses
used until now for both stacks. This is one of the prerequisites
for being able to kexec the decompressor from its load address without
relocating it first.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agos390/boot: move all linker symbol declarations from c to h files
Alexander Egorenkov [Wed, 30 Jun 2021 15:12:25 +0000 (17:12 +0200)]
s390/boot: move all linker symbol declarations from c to h files

To prevent multiple incompatible declarations of symbols and to catch
such mistakes at compile time.

Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2 years agoLinux 5.14-rc3
Linus Torvalds [Sun, 25 Jul 2021 22:35:14 +0000 (15:35 -0700)]
Linux 5.14-rc3

2 years agosmpboot: fix duplicate and misplaced inlining directive
Linus Torvalds [Sun, 25 Jul 2021 18:06:37 +0000 (11:06 -0700)]
smpboot: fix duplicate and misplaced inlining directive

gcc doesn't care, but clang quite reasonably pointed out that the recent
commit e9ba16e68cce ("smpboot: Mark idle_init() as __always_inlined to
work around aggressive compiler un-inlining") did some really odd
things:

    kernel/smpboot.c:50:20: warning: duplicate 'inline' declaration specifier [-Wduplicate-decl-specifier]
    static inline void __always_inline idle_init(unsigned int cpu)
                       ^

which not only has that duplicate inlining specifier, but the new
__always_inline was put in the wrong place of the function definition.

We put the storage class specifiers (ie things like "static" and
"extern") first, and the type information after that.  And while the
compiler may not care, we put the inline specifier before the types.

So it should be just

    static __always_inline void idle_init(unsigned int cpu)

instead.

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2 years agoMerge tag 'powerpc-5.14-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
Linus Torvalds [Sun, 25 Jul 2021 17:33:48 +0000 (10:33 -0700)]
Merge tag 'powerpc-5.14-3' of git://git./linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:

 - Fix guest to host memory corruption in H_RTAS due to missing nargs
   check.

 - Fix guest triggerable host crashes due to bad handling of nested
   guest TM state.

 - Fix possible crashes due to incorrect reference counting in
   kvm_arch_vcpu_ioctl().

 - Two commits fixing some regressions in KVM transactional memory
   handling introduced by the recent rework of the KVM code.

Thanks to Nicholas Piggin, Alexey Kardashevskiy, and Michael Neuling.

* tag 'powerpc-5.14-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  KVM: PPC: Book3S HV Nested: Sanitise H_ENTER_NESTED TM state
  KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow
  KVM: PPC: Fix kvm_arch_vcpu_ioctl vcpu_load leak
  KVM: PPC: Book3S: Fix CONFIG_TRANSACTIONAL_MEM=n crash
  KVM: PPC: Book3S HV P9: Fix guest TM support

2 years agoMerge tag 'timers-urgent-2021-07-25' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 25 Jul 2021 17:27:44 +0000 (10:27 -0700)]
Merge tag 'timers-urgent-2021-07-25' of git://git./linux/kernel/git/tip/tip

Pull timer fixes from Thomas Gleixner:
 "A small set of timer related fixes:

   - Plug a race between rearm and process tick in the posix CPU timers
     code

   - Make the optimization to avoid recalculation of the next timer
     interrupt work correctly when there are no timers pending"

* tag 'timers-urgent-2021-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  timers: Fix get_next_timer_interrupt() with no timers pending
  posix-cpu-timers: Fix rearm racing against process tick

2 years agoMerge tag 'locking-urgent-2021-07-25' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 25 Jul 2021 17:21:19 +0000 (10:21 -0700)]
Merge tag 'locking-urgent-2021-07-25' of git://git./linux/kernel/git/tip/tip

Pull x86 jump label fix from Thomas Gleixner:
 "A single fix for jump labels to prevent the compiler from agressive
  un-inlining which results in a section mismatch"

* tag 'locking-urgent-2021-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  jump_labels: Mark __jump_label_transform() as __always_inlined to work around aggressive compiler un-inlining

2 years agoMerge tag 'efi-urgent-2021-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 25 Jul 2021 17:04:27 +0000 (10:04 -0700)]
Merge tag 'efi-urgent-2021-07-25' of git://git./linux/kernel/git/tip/tip

Pull EFI fixes from Thomas Gleixner:
 "A set of EFI fixes:

   - Prevent memblock and I/O reserved resources to get out of sync when
     EFI memreserve is in use.

   - Don't claim a non-existing table is invalid

   - Don't warn when firmware memory is already reserved correctly"

* tag 'efi-urgent-2021-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  efi/mokvar: Reserve the table only if it is in boot services data
  efi/libstub: Fix the efi_load_initrd function description
  firmware/efi: Tell memblock about EFI iomem reservations
  efi/tpm: Differentiate missing and invalid final event log table.

2 years agoMerge tag 'core-urgent-2021-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sun, 25 Jul 2021 16:52:48 +0000 (09:52 -0700)]
Merge tag 'core-urgent-2021-07-25' of git://git./linux/kernel/git/tip/tip

Pull core fix from Thomas Gleixner:
 "A single update for the boot code to prevent aggressive un-inlining
  which causes a section mismatch"

* tag 'core-urgent-2021-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  smpboot: Mark idle_init() as __always_inlined to work around aggressive compiler un-inlining

2 years agoMerge tag 'dma-mapping-5.14-1' of git://git.infradead.org/users/hch/dma-mapping
Linus Torvalds [Sun, 25 Jul 2021 16:46:17 +0000 (09:46 -0700)]
Merge tag 'dma-mapping-5.14-1' of git://git.infradead.org/users/hch/dma-mapping

Pull dma-mapping fix from Christoph Hellwig:

 - handle vmalloc addresses in dma_common_{mmap,get_sgtable} (Roman
   Skakun)

* tag 'dma-mapping-5.14-1' of git://git.infradead.org/users/hch/dma-mapping:
  dma-mapping: handle vmalloc addresses in dma_common_{mmap,get_sgtable}

2 years agoMerge tag '5.14-rc2-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sun, 25 Jul 2021 00:26:47 +0000 (17:26 -0700)]
Merge tag '5.14-rc2-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "Five cifs/smb3 fixes, including a DFS failover fix, two fallocate
  fixes, and two trivial coverity cleanups"

* tag '5.14-rc2-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: fix fallocate when trying to allocate a hole.
  CIFS: Clarify SMB1 code for POSIX delete file
  CIFS: Clarify SMB1 code for POSIX Create
  cifs: support share failover when remounting
  cifs: only write 64kb at a time when fallocating a small region of a file

2 years agoMerge tag 'riscv-for-linus-5.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 24 Jul 2021 22:34:04 +0000 (15:34 -0700)]
Merge tag 'riscv-for-linus-5.14-rc3' of git://git./linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:

 - properly set the memory size, which fixes 32-bit systems

 - allow initrd to load anywhere in memory, rather that restricting it
   to the first 256MiB

 - fix the 'mem=' parameter on 64-bit systems to properly account for
   the maximum supported memory now that the kernel is outside the
   linear map

 - avoid installing mappings into the last 4KiB of memory, which
   conflicts with error values

 - avoid the stack from being freed while it is being walked

 - a handful of fixes to the new copy to/from user routines

* tag 'riscv-for-linus-5.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: __asm_copy_to-from_user: Fix: Typos in comments
  riscv: __asm_copy_to-from_user: Remove unnecessary size check
  riscv: __asm_copy_to-from_user: Fix: fail on RV32
  riscv: __asm_copy_to-from_user: Fix: overrun copy
  riscv: stacktrace: pin the task's stack in get_wchan
  riscv: Make sure the kernel mapping does not overlap with IS_ERR_VALUE
  riscv: Make sure the linear mapping does not use the kernel mapping
  riscv: Fix memory_limit for 64-bit kernel
  RISC-V: load initrd wherever it fits into memory
  riscv: Fix 32-bit RISC-V boot failure

2 years agoACPI: fix NULL pointer dereference
Linus Torvalds [Sat, 24 Jul 2021 22:25:54 +0000 (15:25 -0700)]
ACPI: fix NULL pointer dereference

Commit 71f642833284 ("ACPI: utils: Fix reference counting in
for_each_acpi_dev_match()") started doing "acpi_dev_put()" on a pointer
that was possibly NULL.  That fails miserably, because that helper
inline function is not set up to handle that case.

Just make acpi_dev_put() silently accept a NULL pointer, rather than
calling down to put_device() with an invalid offset off that NULL
pointer.

Link: https://lore.kernel.org/lkml/a607c149-6bf6-0fd0-0e31-100378504da2@kernel.dk/
Reported-and-tested-by: Jens Axboe <axboe@kernel.dk>
Tested-by: Daniel Scally <djrscally@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2 years agoMerge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Linus Torvalds [Sat, 24 Jul 2021 20:08:31 +0000 (13:08 -0700)]
Merge tag 'scsi-fixes' of git://git./linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Four fixes, all in drivers, all of which can lead to user visible
  problems in certain situations"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: target: Fix NULL dereference on XCOPY completion
  scsi: mpt3sas: Transition IOC to Ready state during shutdown
  scsi: target: Fix protect handling in WRITE SAME(32)
  scsi: iscsi: Fix iface sysfs attr detection

2 years agoMerge tag 'io_uring-5.14-2021-07-24' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 24 Jul 2021 20:03:40 +0000 (13:03 -0700)]
Merge tag 'io_uring-5.14-2021-07-24' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:

 - Fix a memory leak due to a race condition in io_init_wq_offload
   (Yang)

 - Poll error handling fixes (Pavel)

 - Fix early fdput() regression (me)

 - Don't reissue iopoll requests off release path (me)

 - Add a safety check for io-wq queue off wrong path (me)

* tag 'io_uring-5.14-2021-07-24' of git://git.kernel.dk/linux-block:
  io_uring: explicitly catch any illegal async queue attempt
  io_uring: never attempt iopoll reissue from release path
  io_uring: fix early fdput() of file
  io_uring: fix memleak in io_init_wq_offload()
  io_uring: remove double poll entry on arm failure
  io_uring: explicitly count entries for poll reqs

2 years agoMerge tag 'block-5.14-2021-07-24' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 24 Jul 2021 19:57:06 +0000 (12:57 -0700)]
Merge tag 'block-5.14-2021-07-24' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:

 - NVMe pull request (Christoph):
    - tracing fix (Keith Busch)
    - fix multipath head refcounting (Hannes Reinecke)
    - Write Zeroes vs PI fix (me)
    - drop a bogus WARN_ON (Zhihao Cheng)

 - Increase max blk-cgroup policy size, now that mq-deadline
   uses it too (Oleksandr)

* tag 'block-5.14-2021-07-24' of git://git.kernel.dk/linux-block:
  nvme: set the PRACT bit when using Write Zeroes with T10 PI
  nvme: fix nvme_setup_command metadata trace event
  nvme: fix refcounting imbalance when all paths are down
  nvme-pci: don't WARN_ON in nvme_reset_work if ctrl.state is not RESETTING
  block: increase BLKCG_MAX_POLS

2 years agoMerge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa...
Linus Torvalds [Sat, 24 Jul 2021 19:55:06 +0000 (12:55 -0700)]
Merge branch 'i2c/for-current' of git://git./linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
 "Two bugfixes for the I2C subsystem"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
  i2c: mpc: Poll for MCF
  misc: eeprom: at24: Always append device id even if label property is set.

2 years agoMerge branch 'akpm' (patches from Andrew)
Linus Torvalds [Sat, 24 Jul 2021 19:27:16 +0000 (12:27 -0700)]
Merge branch 'akpm' (patches from Andrew)

Merge misc mm fixes from Andrew Morton:
 "15 patches.

  VM subsystems affected by this patch series: userfaultfd, kfence,
  highmem, pagealloc, memblock, pagecache, secretmem, pagemap, and
  hugetlbfs"

* akpm:
  hugetlbfs: fix mount mode command line processing
  mm: fix the deadlock in finish_fault()
  mm: mmap_lock: fix disabling preemption directly
  mm/secretmem: wire up ->set_page_dirty
  writeback, cgroup: do not reparent dax inodes
  writeback, cgroup: remove wb from offline list before releasing refcnt
  memblock: make for_each_mem_range() traverse MEMBLOCK_HOTPLUG regions
  mm: page_alloc: fix page_poison=1 / INIT_ON_ALLOC_DEFAULT_ON interaction
  mm: use kmap_local_page in memzero_page
  mm: call flush_dcache_page() in memcpy_to_page() and memzero_page()
  kfence: skip all GFP_ZONEMASK allocations
  kfence: move the size check to the beginning of __kfence_alloc()
  kfence: defer kfence_test_init to ensure that kunit debugfs is created
  selftest: use mmap instead of posix_memalign to allocate memory
  userfaultfd: do not untag user pointers

2 years agoriscv: __asm_copy_to-from_user: Fix: Typos in comments
Akira Tsukamoto [Tue, 20 Jul 2021 08:53:23 +0000 (17:53 +0900)]
riscv: __asm_copy_to-from_user: Fix: Typos in comments

Fixing typos and grammar mistakes and using more intuitive label
name.

Signed-off-by: Akira Tsukamoto <akira.tsukamoto@gmail.com>
Fixes: ca6eaaa210de ("riscv: __asm_copy_to-from_user: Optimize unaligned memory access and pipeline stall")
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>