Commit 1d94dc0b authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Linus Torvalds

[PATCH] parisc: assembly fixes and comments

Add comments and references for relied-upon translations
Add some extra comment to space_check
Add support for prober and probew in our non-access TLB fault emulation path
Force sr2 to 0 in syscall_restore
Committed-by: default avatarCarlos O'Donell <carlos@parisc-linux.org>
parent d0a160cb
...@@ -440,8 +440,17 @@ ...@@ -440,8 +440,17 @@
mfctl %cr25,\reg mfctl %cr25,\reg
.endm .endm
/* Only allow faults on different spaces from the /*
* currently active one if we're the kernel */ space_check(spc,tmp,fault)
spc - The space we saw the fault with.
tmp - The place to store the current space.
fault - Function to call on failure.
Only allow faults on different spaces from the
currently active one if we're the kernel
*/
.macro space_check spc,tmp,fault .macro space_check spc,tmp,fault
mfsp %sr7,\tmp mfsp %sr7,\tmp
or,COND(<>) %r0,\spc,%r0 /* user may execute gateway page or,COND(<>) %r0,\spc,%r0 /* user may execute gateway page
...@@ -939,6 +948,7 @@ syscall_exit_rfi: ...@@ -939,6 +948,7 @@ syscall_exit_rfi:
STREG %r19,PT_SR7(%r16) STREG %r19,PT_SR7(%r16)
intr_return: intr_return:
/* NOTE: Need to enable interrupts incase we schedule. */
ssm PSW_SM_I, %r0 ssm PSW_SM_I, %r0
/* Check for software interrupts */ /* Check for software interrupts */
...@@ -982,6 +992,8 @@ intr_restore: ...@@ -982,6 +992,8 @@ intr_restore:
ldo PT_FR31(%r29),%r1 ldo PT_FR31(%r29),%r1
rest_fp %r1 rest_fp %r1
rest_general %r29 rest_general %r29
/* Create a "relied upon translation" PA 2.0 Arch. F-5 */
ssm 0,%r0 ssm 0,%r0
nop nop
nop nop
...@@ -992,8 +1004,15 @@ intr_restore: ...@@ -992,8 +1004,15 @@ intr_restore:
nop nop
tophys_r1 %r29 tophys_r1 %r29
rsm (PSW_SM_Q|PSW_SM_P|PSW_SM_D|PSW_SM_I),%r0 rsm (PSW_SM_Q|PSW_SM_P|PSW_SM_D|PSW_SM_I),%r0
/* Restore space id's and special cr's from PT_REGS
* structure pointed to by r29 */
rest_specials %r29 rest_specials %r29
/* Important: Note that rest_stack restores r29
* last (we are using it)! It also restores r1 and r30. */
rest_stack rest_stack
rfi rfi
nop nop
nop nop
...@@ -1036,7 +1055,14 @@ intr_do_resched: ...@@ -1036,7 +1055,14 @@ intr_do_resched:
.import do_signal,code .import do_signal,code
intr_do_signal: intr_do_signal:
/* Only do signals if we are returning to user space */ /*
This check is critical to having LWS
working. The IASQ is zero on the gateway
page and we cannot deliver any signals until
we get off the gateway page.
Only do signals if we are returning to user space
*/
LDREG PT_IASQ0(%r16), %r20 LDREG PT_IASQ0(%r16), %r20
CMPIB= 0,%r20,intr_restore /* backward */ CMPIB= 0,%r20,intr_restore /* backward */
nop nop
...@@ -1443,15 +1469,20 @@ nadtlb_emulate: ...@@ -1443,15 +1469,20 @@ nadtlb_emulate:
* of the instruction. Since we don't insert a translation * of the instruction. Since we don't insert a translation
* we can get a lot of faults during a flush loop, so it makes * we can get a lot of faults during a flush loop, so it makes
* sense to try to do it here with minimum overhead. We only * sense to try to do it here with minimum overhead. We only
* emulate fdc,fic & pdc instructions whose base and index * emulate fdc,fic,pdc,probew,prober instructions whose base
* registers are not shadowed. We defer everything else to the * and index registers are not shadowed. We defer everything
* "slow" path. * else to the "slow" path.
*/ */
mfctl %cr19,%r9 /* Get iir */ mfctl %cr19,%r9 /* Get iir */
/* PA 2.0 Arch Ref. Book pg 382 has a good description of the insn bits.
Checks for fdc,fdce,pdc,"fic,4f",prober,probeir,probew, probeiw */
/* Checks for fdc,fdce,pdc,"fic,4f" only */
ldi 0x280,%r16 ldi 0x280,%r16
and %r9,%r16,%r17 and %r9,%r16,%r17
cmpb,<>,n %r16,%r17,nadtlb_fault /* Not fdc,fic,pdc */ cmpb,<>,n %r16,%r17,nadtlb_probe_check
bb,>=,n %r9,26,nadtlb_nullify /* m bit not set, just nullify */ bb,>=,n %r9,26,nadtlb_nullify /* m bit not set, just nullify */
BL get_register,%r25 BL get_register,%r25
extrw,u %r9,15,5,%r8 /* Get index register # */ extrw,u %r9,15,5,%r8 /* Get index register # */
...@@ -1472,6 +1503,32 @@ nadtlb_nullify: ...@@ -1472,6 +1503,32 @@ nadtlb_nullify:
rfir rfir
nop nop
/*
When there is no translation for the probe address then we
must nullify the insn and return zero in the target regsiter.
This will indicate to the calling code that it does not have
write/read privileges to this address.
This should technically work for prober and probew in PA 1.1,
and also probe,r and probe,w in PA 2.0
WARNING: USE ONLY NON-SHADOW REGISTERS WITH PROBE INSN!
THE SLOW-PATH EMULATION HAS NOT BEEN WRITTEN YET.
*/
nadtlb_probe_check:
ldi 0x80,%r16
and %r9,%r16,%r17
cmpb,<>,n %r16,%r17,nadtlb_fault /* Must be probe,[rw]*/
BL get_register,%r25 /* Find the target register */
extrw,u %r9,31,5,%r8 /* Get target register */
CMPIB=,n -1,%r1,nadtlb_fault /* have to use slow path */
BL set_register,%r25
copy %r0,%r1 /* Write zero to target register */
b nadtlb_nullify /* Nullify return insn */
nop
#ifdef __LP64__ #ifdef __LP64__
itlb_miss_20w: itlb_miss_20w:
...@@ -1981,9 +2038,11 @@ sys_rt_sigsuspend_wrapper: ...@@ -1981,9 +2038,11 @@ sys_rt_sigsuspend_wrapper:
.export syscall_exit .export syscall_exit
syscall_exit: syscall_exit:
/* NOTE: HP-UX syscalls also come through here /* NOTE: HP-UX syscalls also come through here
after hpux_syscall_exit fixes up return * after hpux_syscall_exit fixes up return
values. */ * values. */
/* NOTE: Not all syscalls exit this way. rt_sigreturn will exit /* NOTE: Not all syscalls exit this way. rt_sigreturn will exit
* via syscall_exit_rfi if the signal was received while the process * via syscall_exit_rfi if the signal was received while the process
* was running. * was running.
...@@ -2082,11 +2141,15 @@ syscall_restore: ...@@ -2082,11 +2141,15 @@ syscall_restore:
LDREG TASK_PT_GR29(%r1),%r29 LDREG TASK_PT_GR29(%r1),%r29
LDREG TASK_PT_GR31(%r1),%r31 /* restore syscall rp */ LDREG TASK_PT_GR31(%r1),%r31 /* restore syscall rp */
/* NOTE: We use rsm/ssm pair to make this operation atomic */
rsm PSW_SM_I, %r0 rsm PSW_SM_I, %r0
LDREG TASK_PT_GR30(%r1),%r30 /* restore user sp */ LDREG TASK_PT_GR30(%r1),%r30 /* restore user sp */
mfsp %sr3,%r1 /* Get users space id */ mfsp %sr3,%r1 /* Get users space id */
mtsp %r1,%sr7 /* Restore sr7 */ mtsp %r1,%sr7 /* Restore sr7 */
ssm PSW_SM_I, %r0 ssm PSW_SM_I, %r0
/* Set sr2 to zero for userspace syscalls to work. */
mtsp %r0,%sr2
mtsp %r1,%sr4 /* Restore sr4 */ mtsp %r1,%sr4 /* Restore sr4 */
mtsp %r1,%sr5 /* Restore sr5 */ mtsp %r1,%sr5 /* Restore sr5 */
mtsp %r1,%sr6 /* Restore sr6 */ mtsp %r1,%sr6 /* Restore sr6 */
...@@ -2154,12 +2217,18 @@ syscall_restore_rfi: ...@@ -2154,12 +2217,18 @@ syscall_restore_rfi:
bb,< %r2,30,pt_regs_ok /* Branch if D set */ bb,< %r2,30,pt_regs_ok /* Branch if D set */
ldo TASK_REGS(%r1),%r25 ldo TASK_REGS(%r1),%r25
reg_save %r25 /* Save r3 to r18 */ reg_save %r25 /* Save r3 to r18 */
/* Save the current sr */
mfsp %sr0,%r2 mfsp %sr0,%r2
STREG %r2,TASK_PT_SR0(%r1) STREG %r2,TASK_PT_SR0(%r1)
/* Save the scratch sr */
mfsp %sr1,%r2 mfsp %sr1,%r2
STREG %r2,TASK_PT_SR1(%r1) STREG %r2,TASK_PT_SR1(%r1)
mfsp %sr2,%r2
STREG %r2,TASK_PT_SR2(%r1) /* sr2 should be set to zero for userspace syscalls */
STREG %r0,TASK_PT_SR2(%r1)
pt_regs_ok: pt_regs_ok:
LDREG TASK_PT_GR31(%r1),%r2 LDREG TASK_PT_GR31(%r1),%r2
depi 3,31,2,%r2 /* ensure return to user mode. */ depi 3,31,2,%r2 /* ensure return to user mode. */
...@@ -2174,6 +2243,9 @@ pt_regs_ok: ...@@ -2174,6 +2243,9 @@ pt_regs_ok:
syscall_do_softirq: syscall_do_softirq:
bl do_softirq,%r2 bl do_softirq,%r2
nop nop
/* NOTE: We enable I-bit incase we schedule later,
* and we might be going back to userspace if we were
* traced. */
b syscall_check_resched b syscall_check_resched
ssm PSW_SM_I, %r0 /* do_softirq returns with I bit off */ ssm PSW_SM_I, %r0 /* do_softirq returns with I bit off */
......
...@@ -68,7 +68,7 @@ flush_tlb_all_local: ...@@ -68,7 +68,7 @@ flush_tlb_all_local:
* consolidated. * consolidated.
*/ */
rsm PSW_SM_I,%r19 /* relied upon translation! */ rsm PSW_SM_I,%r19 /* relied upon translation! PA 2.0 Arch. F-5 */
nop nop
nop nop
nop nop
......
...@@ -149,7 +149,7 @@ restore_control_regs: ...@@ -149,7 +149,7 @@ restore_control_regs:
rfi_virt2real: rfi_virt2real:
/* switch to real mode... */ /* switch to real mode... */
ssm 0,0 /* See "relied upon translation" */ ssm 0,0 /* See "relied upon translation" */
nop /* comment in interruption.S */ nop /* PA 2.0 Arch. F-5 */
nop nop
nop nop
nop nop
...@@ -186,7 +186,7 @@ rfi_v2r_1: ...@@ -186,7 +186,7 @@ rfi_v2r_1:
.align 128 .align 128
rfi_real2virt: rfi_real2virt:
ssm 0,0 /* See "relied upon translation" */ ssm 0,0 /* See "relied upon translation" */
nop /* comment in interruption.S */ nop /* PA 2.0 Arch. F-5 */
nop nop
nop nop
nop nop
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment