Commit f4c0346c authored by John David Anglin's avatar John David Anglin Committed by Kyle McMartin

parisc: LWS fixes for syscall.S

1) Gate immediately and save a branch.
2) Fix off by one error in checking entry number.
3) Use sr7 instead of sr3 in error return path as sr3 might not
   contain correct value.
4) Enable locking on UP systems to prevent incorrect operation of
   the cas_action critical region on page faults.

Tested on several systems, including UP c3750 with 2.6.33.2 kernel.
Signed-off-by: default avatarJohn David Anglin <dave.anglin@nrc-cnrc.gc.ca>
Signed-off-by: default avatarKyle McMartin <kyle@parisc-linux.org>
parent c2dc988e
...@@ -47,18 +47,17 @@ ENTRY(linux_gateway_page) ...@@ -47,18 +47,17 @@ ENTRY(linux_gateway_page)
KILL_INSN KILL_INSN
.endr .endr
/* ADDRESS 0xb0 to 0xb4, lws uses 1 insns for entry */ /* ADDRESS 0xb0 to 0xb8, lws uses two insns for entry */
/* Light-weight-syscall entry must always be located at 0xb0 */ /* Light-weight-syscall entry must always be located at 0xb0 */
/* WARNING: Keep this number updated with table size changes */ /* WARNING: Keep this number updated with table size changes */
#define __NR_lws_entries (2) #define __NR_lws_entries (2)
lws_entry: lws_entry:
/* Unconditional branch to lws_start, located on the gate lws_start, %r0 /* increase privilege */
same gateway page */ depi 3, 31, 2, %r31 /* Ensure we return into user mode. */
b,n lws_start
/* Fill from 0xb4 to 0xe0 */ /* Fill from 0xb8 to 0xe0 */
.rept 11 .rept 10
KILL_INSN KILL_INSN
.endr .endr
...@@ -423,9 +422,6 @@ tracesys_sigexit: ...@@ -423,9 +422,6 @@ tracesys_sigexit:
*********************************************************/ *********************************************************/
lws_start: lws_start:
/* Gate and ensure we return to userspace */
gate .+8, %r0
depi 3, 31, 2, %r31 /* Ensure we return to userspace */
#ifdef CONFIG_64BIT #ifdef CONFIG_64BIT
/* FIXME: If we are a 64-bit kernel just /* FIXME: If we are a 64-bit kernel just
...@@ -442,7 +438,7 @@ lws_start: ...@@ -442,7 +438,7 @@ lws_start:
#endif #endif
/* Is the lws entry number valid? */ /* Is the lws entry number valid? */
comiclr,>>= __NR_lws_entries, %r20, %r0 comiclr,>> __NR_lws_entries, %r20, %r0
b,n lws_exit_nosys b,n lws_exit_nosys
/* WARNING: Trashing sr2 and sr3 */ /* WARNING: Trashing sr2 and sr3 */
...@@ -473,7 +469,7 @@ lws_exit: ...@@ -473,7 +469,7 @@ lws_exit:
/* now reset the lowest bit of sp if it was set */ /* now reset the lowest bit of sp if it was set */
xor %r30,%r1,%r30 xor %r30,%r1,%r30
#endif #endif
be,n 0(%sr3, %r31) be,n 0(%sr7, %r31)
...@@ -529,7 +525,6 @@ lws_compare_and_swap32: ...@@ -529,7 +525,6 @@ lws_compare_and_swap32:
#endif #endif
lws_compare_and_swap: lws_compare_and_swap:
#ifdef CONFIG_SMP
/* Load start of lock table */ /* Load start of lock table */
ldil L%lws_lock_start, %r20 ldil L%lws_lock_start, %r20
ldo R%lws_lock_start(%r20), %r28 ldo R%lws_lock_start(%r20), %r28
...@@ -572,8 +567,6 @@ cas_wouldblock: ...@@ -572,8 +567,6 @@ cas_wouldblock:
ldo 2(%r0), %r28 /* 2nd case */ ldo 2(%r0), %r28 /* 2nd case */
b lws_exit /* Contended... */ b lws_exit /* Contended... */
ldo -EAGAIN(%r0), %r21 /* Spin in userspace */ ldo -EAGAIN(%r0), %r21 /* Spin in userspace */
#endif
/* CONFIG_SMP */
/* /*
prev = *addr; prev = *addr;
...@@ -601,13 +594,11 @@ cas_action: ...@@ -601,13 +594,11 @@ cas_action:
1: ldw 0(%sr3,%r26), %r28 1: ldw 0(%sr3,%r26), %r28
sub,<> %r28, %r25, %r0 sub,<> %r28, %r25, %r0
2: stw %r24, 0(%sr3,%r26) 2: stw %r24, 0(%sr3,%r26)
#ifdef CONFIG_SMP
/* Free lock */ /* Free lock */
stw %r20, 0(%sr2,%r20) stw %r20, 0(%sr2,%r20)
# if ENABLE_LWS_DEBUG #if ENABLE_LWS_DEBUG
/* Clear thread register indicator */ /* Clear thread register indicator */
stw %r0, 4(%sr2,%r20) stw %r0, 4(%sr2,%r20)
# endif
#endif #endif
/* Return to userspace, set no error */ /* Return to userspace, set no error */
b lws_exit b lws_exit
...@@ -615,12 +606,10 @@ cas_action: ...@@ -615,12 +606,10 @@ cas_action:
3: 3:
/* Error occured on load or store */ /* Error occured on load or store */
#ifdef CONFIG_SMP
/* Free lock */ /* Free lock */
stw %r20, 0(%sr2,%r20) stw %r20, 0(%sr2,%r20)
# if ENABLE_LWS_DEBUG #if ENABLE_LWS_DEBUG
stw %r0, 4(%sr2,%r20) stw %r0, 4(%sr2,%r20)
# endif
#endif #endif
b lws_exit b lws_exit
ldo -EFAULT(%r0),%r21 /* set errno */ ldo -EFAULT(%r0),%r21 /* set errno */
...@@ -672,7 +661,6 @@ ENTRY(sys_call_table64) ...@@ -672,7 +661,6 @@ ENTRY(sys_call_table64)
END(sys_call_table64) END(sys_call_table64)
#endif #endif
#ifdef CONFIG_SMP
/* /*
All light-weight-syscall atomic operations All light-weight-syscall atomic operations
will use this set of locks will use this set of locks
...@@ -694,8 +682,6 @@ ENTRY(lws_lock_start) ...@@ -694,8 +682,6 @@ ENTRY(lws_lock_start)
.endr .endr
END(lws_lock_start) END(lws_lock_start)
.previous .previous
#endif
/* CONFIG_SMP for lws_lock_start */
.end .end
......
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