• Niklas Schnelle's avatar
    s390/pci: Fix s390_mmio_read/write with MIO · f058599e
    Niklas Schnelle authored
    The s390_mmio_read/write syscalls are currently broken when running with
    MIO.
    
    The new pcistb_mio/pcstg_mio/pcilg_mio instructions are executed
    similiarly to normal load/store instructions and do address translation
    in the current address space. That means inside the kernel they are
    aware of mappings into kernel address space while outside the kernel
    they use user space mappings (usually created through mmap'ing a PCI
    device file).
    
    Now when existing user space applications use the s390_pci_mmio_write
    and s390_pci_mmio_read syscalls, they pass I/O addresses that are mapped
    into user space so as to be usable with the new instructions without
    needing a syscall. Accessing these addresses with the old instructions
    as done currently leads to a kernel panic.
    
    Also, for such a user space mapping there may not exist an equivalent
    kernel space mapping which means we can't just use the new instructions
    in kernel space.
    
    Instead of replicating user mappings in the kernel which then might
    collide with other mappings, we can conceptually execute the new
    instructions as if executed by the user space application using the
    secondary address space. This even allows us to directly store to the
    user pointer without the need for copy_to/from_user().
    
    Cc: stable@vger.kernel.org
    Fixes: 71ba41c9 ("s390/pci: provide support for MIO instructions")
    Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
    Reviewed-by: default avatarSven Schnelle <svens@linux.ibm.com>
    Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
    f058599e
pci_mmio.c 7.46 KB