linux/arch/s390/include/asm
Niklas Schnelle 9ffaf52290 iommu/s390: Make attach succeed when the device was surprise removed
When a PCI device is removed with surprise hotplug, there may still be
attempts to attach the device to the default domain as part of tear down
via (__iommu_release_dma_ownership()), or because the removal happens
during probe (__iommu_probe_device()). In both cases zpci_register_ioat()
fails with a cc value indicating that the device handle is invalid. This
is because the device is no longer part of the instance as far as the
hypervisor is concerned.

Currently this leads to an error return and s390_iommu_attach_device()
fails. This triggers the WARN_ON() in __iommu_group_set_domain_nofail()
because attaching to the default domain must never fail.

With the device fenced by the hypervisor no DMAs to or from memory are
possible and the IOMMU translations have no effect. Proceed as if the
registration was successful and let the hotplug event handling clean up
the device.

This is similar to how devices in the error state are handled since
commit 59bbf59679 ("iommu/s390: Make attach succeed even if the device
is in error state") except that for removal the domain will not be
registered later. This approach was also previously discussed at the
link.

Handle both cases, error state and removal, in a helper which checks if
the error needs to be propagated or ignored. Avoid magic number
condition codes by using the pre-existing, but never used, defines for
PCI load/store condition codes and rename them to reflect that they
apply to all PCI instructions.

Cc: stable@vger.kernel.org # v6.2
Link: https://lore.kernel.org/linux-iommu/20240808194155.GD1985367@ziepe.ca/
Suggested-by: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Link: https://lore.kernel.org/r/20250904-iommu_succeed_attach_removed-v1-1-e7f333d2f80f@linux.ibm.com
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2025-09-05 15:11:09 +02:00
..
trace
vdso s390/time: Remove in-kernel time steering 2025-07-21 12:41:55 +02:00
Kbuild
abs_lowcore.h
access-regs.h
airq.h
alternative.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
ap.h s390/ap: Unmask SLCF bit in card and queue ap functions sysfs 2025-07-31 18:59:26 +02:00
appldata.h
arch_hweight.h
archrandom.h
asce.h s390/mm: Reimplement lazy ASCE handling 2025-04-14 11:23:21 +02:00
asm-const.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
asm-extable.h
asm-prototypes.h
asm.h
atomic.h
atomic_ops.h
barrier.h
bitops.h
boot_data.h
bug.h
cache.h
ccwdev.h
ccwgroup.h
checksum.h
chpid.h
chsc.h
cio.h
clocksource.h
clp.h
cmb.h
cmpxchg.h
compat.h
cpacf.h s390/crypto: Add protected key hmac subfunctions for KMAC 2025-06-26 18:52:33 +08:00
cpcmd.h
cpu.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
cpu_mf-insn.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
cpu_mf.h
cpufeature.h watchdog: diag288_wdt: Implement module autoload 2025-04-16 09:26:49 +02:00
cputime.h
crw.h
css_chars.h
ctlreg.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
current.h
dat-bits.h
debug.h
delay.h
diag.h
diag288.h watchdog: diag288_wdt: Implement module autoload 2025-04-16 09:26:49 +02:00
dis.h
dma-types.h
dma.h
dwarf.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
eadm.h
ebcdic.h
elf.h
entry-common.h KVM: s390: Rework guest entry logic 2025-07-21 13:01:03 +00:00
exec.h
extable.h
extmem.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
facility.h
fault.h
fcx.h
fprobe.h
fpu-insn-asm.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
fpu-insn.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
fpu-types.h
fpu.h
ftrace.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
ftrace.lds.h
futex.h s390/mm: Reimplement lazy ASCE handling 2025-04-14 11:23:21 +02:00
gmap.h KVM: s390: Refactor and split some gmap helpers 2025-05-28 17:48:04 +02:00
gmap_helpers.h KVM: s390: Refactor and split some gmap helpers 2025-05-28 17:48:04 +02:00
hardirq.h
hiperdispatch.h
hugetlb.h s390 updates for 6.15 merge window 2025-03-29 11:59:43 -07:00
hw_irq.h
idals.h
idle.h
io.h - The 6 patch series "Enable strict percpu address space checks" from 2025-04-01 09:29:18 -07:00
ipl.h
irq.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
irq_work.h
irqflags.h
isc.h
itcw.h
jump_label.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
kasan.h
kdebug.h
kexec.h
kfence.h
kmsan.h
kprobes.h
kvm_host.h KVM: s390: Rework guest entry logic 2025-07-21 13:01:03 +00:00
kvm_host_types.h s390/kvm: Split kvm_host header file 2025-03-31 12:20:39 +02:00
kvm_para.h
linkage.h
lowcore.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
maccess.h
machine.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
march.h s390: Allow to compile with z17 optimizations 2025-04-09 12:12:41 +02:00
mem_encrypt.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
mmu.h
mmu_context.h s390/mm: Select ARCH_WANT_IRQS_OFF_ACTIVATE_MM 2025-04-14 11:23:21 +02:00
module.h
msi.h
nmi.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
nospec-branch.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
nospec-insn.h s390: Explicitly include <linux/export.h> 2025-06-17 18:18:02 +02:00
numa.h
os_info.h
page-states.h
page.h Merge branch 'uaccess-key' into features 2025-06-29 13:21:16 +02:00
pai.h
pci.h
pci_clp.h
pci_debug.h
pci_dma.h iommu/s390: allow larger region tables 2025-04-17 16:43:12 +02:00
pci_insn.h iommu/s390: Make attach succeed when the device was surprise removed 2025-09-05 15:11:09 +02:00
pci_io.h
percpu.h mm/percpu: conditionally define _shared_alloc_tag via CONFIG_ARCH_MODULE_NEEDS_WEAK_PER_CPU 2025-07-09 22:42:15 -07:00
perf_event.h
pfault.h
pgalloc.h mm: pass mm down to pagetable_{pte,pmd}_ctor 2025-05-11 17:48:21 -07:00
pgtable.h s390/mm: Enable THP_SWAP and THP_MIGRATION 2025-07-31 18:59:26 +02:00
physmem_info.h
pkey.h s390/pkey/crypto: Introduce xflags param for pkey in-kernel API 2025-04-30 11:34:03 +02:00
pnet.h
preempt.h
processor.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
ptrace.h s390 updates for 6.17 merge window 2025-07-29 20:17:08 -07:00
purgatory.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
qdio.h
runtime-const.h
runtime_instr.h
rwonce.h
schid.h
sclp.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
scsw.h
seccomp.h
sections.h
set_memory.h
setup.h s390/nmi: Print additional information 2025-06-26 15:30:51 +02:00
signal.h
sigp.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
skey.h s390/skey: Provide infrastructure for executing with non-default access key 2025-06-29 13:12:02 +02:00
smp.h
softirq_stack.h
sparsemem.h
spinlock.h
spinlock_types.h
stacktrace.h
stp.h
string.h s390/string: Remove strcpy() implementation 2025-04-30 11:41:28 +02:00
syscall.h syscall.h: introduce syscall_set_nr() 2025-05-11 17:48:15 -07:00
syscall_wrapper.h
sysinfo.h
text-patching.h
thread_info.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
timex.h s390/time: Use monotonic clock in get_cycles() 2025-07-21 12:41:55 +02:00
tlb.h Generic: 2025-06-02 12:24:58 -07:00
tlbflush.h
topology.h s390/smp: Add support for HOTPLUG_SMT 2025-03-31 12:20:39 +02:00
tpi.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
types.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
uaccess.h s390/uaccess: Make cmpxchg_user_key() library code 2025-06-29 13:12:01 +02:00
unistd.h
unwind.h
uprobes.h
user.h
uv.h Generic: 2025-06-02 12:24:58 -07:00
vdso-symbols.h
vdso.h s390: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-06-16 16:23:02 +02:00
vmalloc.h
vmlinux.lds.h
vtime.h
vtimer.h
word-at-a-time.h
xor.h