Skip to content

Commit 70be49f

Browse files
committed
parisc: Fix userspace graphics card breakage due to pgtable special bit
Commit df24e17 ("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: df24e17 ("parisc: Add vDSO support") Cc: <[email protected]> # 5.18+ Signed-off-by: Helge Deller <[email protected]>
1 parent aca7c13 commit 70be49f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

arch/parisc/include/asm/pgtable.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ extern void __update_cache(pte_t pte);
192192
#define _PAGE_PRESENT_BIT 22 /* (0x200) Software: translation valid */
193193
#define _PAGE_HPAGE_BIT 21 /* (0x400) Software: Huge Page */
194194
#define _PAGE_USER_BIT 20 /* (0x800) Software: User accessible page */
195+
#ifdef CONFIG_HUGETLB_PAGE
196+
#define _PAGE_SPECIAL_BIT _PAGE_DMB_BIT /* DMB feature is currently unused */
197+
#else
198+
#define _PAGE_SPECIAL_BIT _PAGE_HPAGE_BIT /* use unused HUGE PAGE bit */
199+
#endif
195200

196201
/* N.B. The bits are defined in terms of a 32 bit word above, so the */
197202
/* following macro is ok for both 32 and 64 bit. */
@@ -219,7 +224,7 @@ extern void __update_cache(pte_t pte);
219224
#define _PAGE_PRESENT (1 << xlate_pabit(_PAGE_PRESENT_BIT))
220225
#define _PAGE_HUGE (1 << xlate_pabit(_PAGE_HPAGE_BIT))
221226
#define _PAGE_USER (1 << xlate_pabit(_PAGE_USER_BIT))
222-
#define _PAGE_SPECIAL (_PAGE_DMB)
227+
#define _PAGE_SPECIAL (1 << xlate_pabit(_PAGE_SPECIAL_BIT))
223228

224229
#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | _PAGE_DIRTY | _PAGE_ACCESSED)
225230
#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_SPECIAL)

arch/parisc/kernel/entry.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@
499499
* Finally, _PAGE_READ goes in the top bit of PL1 (so we
500500
* trigger an access rights trap in user space if the user
501501
* tries to read an unreadable page */
502+
#if _PAGE_SPECIAL_BIT == _PAGE_DMB_BIT
503+
/* need to drop DMB bit, as it's used as SPECIAL flag */
504+
depi 0,_PAGE_SPECIAL_BIT,1,\pte
505+
#endif
502506
depd \pte,8,7,\prot
503507

504508
/* PAGE_USER indicates the page can be read with user privileges,
@@ -529,6 +533,10 @@
529533
* makes the tlb entry for the differently formatted pa11
530534
* insertion instructions */
531535
.macro make_insert_tlb_11 spc,pte,prot
536+
#if _PAGE_SPECIAL_BIT == _PAGE_DMB_BIT
537+
/* need to drop DMB bit, as it's used as SPECIAL flag */
538+
depi 0,_PAGE_SPECIAL_BIT,1,\pte
539+
#endif
532540
zdep \spc,30,15,\prot
533541
dep \pte,8,7,\prot
534542
extru,= \pte,_PAGE_NO_CACHE_BIT,1,%r0

0 commit comments

Comments
 (0)