Skip to contentSkip to conversation

parisc: Fix handling off probe non-access faults

RFC PATCH Superseded John David Anglin 1 participant 1 message Mar 9, 2022 PA-RISC architecture

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 parisc: Fix handling off probe non-access faults

Currently, the parisc kernel does not fully support non-access TLB fault handling for probe instructions. In the fast path, we set the target register to zero if it is not a shadowed register. The slow path is not implemented, so we call do_page_fault. The architecture indicates that non-access faults should not cause a page fault from disk.

This change adds to code to provide non-access fault support for probe instructions. It also modifies the handling of faults on userspace so that if the address lies in a valid VMA and the access type matches that for the VMA, the probe target register is set to one. Otherwise, the target register is set to zero.

This was done to make probe instructions more useful for userspace. Probe instructions are not very useful if they set the target register to zero whenever a page is not present in memory. Nominally, the purpose of the probe instruction is determine whether read or write access to a given address is allowed.

This fixes a problem in function pointer comparison noticed in the glibc testsuite (stdio-common/tst-vfprintf-user-type). The same problem is likely in glibc (_dl_lookup_address).

---

arch/parisc/include/asm/traps.h +1 -0
index 34619f010c63..0ccdb738a9a3 100644
@@ -18,6 +18,7 @@ unsigned long parisc_acctyp(unsigned long code, unsigned int inst);
 const char *trap_name(unsigned long code);
 void do_page_fault(struct pt_regs *regs, unsigned long code,
 		unsigned long address);
+int handle_nadtlb_fault(struct pt_regs *regs);
 #endif
 
 #endif
arch/parisc/kernel/entry.S +2 -0
index 6e9cdb269862..85de7a0c26d0 100644
@@ -1348,6 +1348,8 @@ nadtlb_probe_check:
 	ldi             0x80,%r16
 	and             %r9,%r16,%r17
 	cmpb,<>,n       %r16,%r17,nadtlb_fault /* Must be probe,[rw]*/
+	mfctl		%isr,%r16
+	cmpib,COND(<>),n	0,%r16,nadtlb_fault
 	BL              get_register,%r25      /* Find the target register */
 	extrw,u         %r9,31,5,%r8           /* Get target register */
 	cmpib,COND(=),n        -1,%r1,nadtlb_fault    /* have to use slow path */
arch/parisc/kernel/traps.c +2 -0
index b6fdebddc8e9..39576a9245c7 100644
@@ -662,6 +662,8 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
 			 by hand. Technically we need to emulate:
 			 fdc,fdce,pdc,"fic,4f",prober,probeir,probew, probeiw
 		*/
+		if (code == 17 && handle_nadtlb_fault(regs))
+			return;
 		fault_address = regs->ior;
 		fault_space = regs->isr;
 		break;
arch/parisc/mm/fault.c +54 -0

57 lines not on this page · raw message