OSDN Git Service

parisc: Fix userspace graphics card breakage due to pgtable special bit
authorHelge Deller <deller@gmx.de>
Fri, 14 Oct 2022 08:18:53 +0000 (10:18 +0200)
committerHelge Deller <deller@gmx.de>
Fri, 14 Oct 2022 08:45:12 +0000 (10:45 +0200)
commit70be49f2f6223ddd2fcddb0089a40864c37e1494
treeb81243ea631703443dac1ebc2763bb1befa79d8f
parentaca7c13d3bee81a968337a5515411409ae9d095d
parisc: Fix userspace graphics card breakage due to pgtable special bit

Commit df24e1783e6e ("parisc: Add vDSO support") introduced the vDSO
support, for which a _PAGE_SPECIAL page table flag was needed.  Since we
wanted to keep every page table entry in 32-bits, this patch re-used the
existing - but yet unused - _PAGE_DMB flag (which triggers a hardware break
if a page is accessed) to store the special bit.

But when graphics card memory is mmapped into userspace, the kernel uses
vm_iomap_memory() which sets the the special flag. So, with the DMB bit
set, every access to the graphics memory now triggered a hardware
exception and segfaulted the userspace program.

Fix this breakage by dropping the DMB bit when writing the page
protection bits to the CPU TLB.

In addition this patch adds a small optimization: if huge pages aren't
configured (which is at least the case for 32-bit kernels), then the
special bit is stored in the hpage (HUGE PAGE) bit instead. That way we
can skip to reset the DMB bit.

Fixes: df24e1783e6e ("parisc: Add vDSO support")
Cc: <stable@vger.kernel.org> # 5.18+
Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/include/asm/pgtable.h
arch/parisc/kernel/entry.S