Skip to content

Commit 558ca24

Browse files
danglin44gregkh
authored andcommitted
parisc: Avoid trashing sr2 and sr3 in LWS code
commit f4125cfdb3008363137f744c101e5d76ead760ba upstream. There is no need to trash sr2 and sr3 in the Light-weight syscall (LWS). sr2 already points to kernel space (it's zero in userspace, otherwise syscalls wouldn't work), and since the LWS code is executed in userspace, we can simply ignore to preload sr3. Signed-off-by: John David Anglin <dave.anglin@bell.net> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6f0dee7 commit 558ca24

1 file changed

Lines changed: 24 additions & 29 deletions

File tree

arch/parisc/kernel/syscall.S

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,6 @@ lws_start:
479479
comiclr,>> __NR_lws_entries, %r20, %r0
480480
b,n lws_exit_nosys
481481

482-
/* WARNING: Trashing sr2 and sr3 */
483-
mfsp %sr7,%r1 /* get userspace into sr3 */
484-
mtsp %r1,%sr3
485-
mtsp %r0,%sr2 /* get kernel space into sr2 */
486-
487482
/* Load table start */
488483
ldil L%lws_table, %r1
489484
ldo R%lws_table(%r1), %r28 /* Scratch use of r28 */
@@ -632,9 +627,9 @@ cas_action:
632627
stw %r1, 4(%sr2,%r20)
633628
#endif
634629
/* The load and store could fail */
635-
1: ldw,ma 0(%sr3,%r26), %r28
630+
1: ldw,ma 0(%r26), %r28
636631
sub,<> %r28, %r25, %r0
637-
2: stw,ma %r24, 0(%sr3,%r26)
632+
2: stw,ma %r24, 0(%r26)
638633
/* Free lock */
639634
stw,ma %r20, 0(%sr2,%r20)
640635
#if ENABLE_LWS_DEBUG
@@ -711,29 +706,29 @@ lws_compare_and_swap_2:
711706
nop
712707

713708
/* 8bit load */
714-
4: ldb 0(%sr3,%r25), %r25
709+
4: ldb 0(%r25), %r25
715710
b cas2_lock_start
716-
5: ldb 0(%sr3,%r24), %r24
711+
5: ldb 0(%r24), %r24
717712
nop
718713
nop
719714
nop
720715
nop
721716
nop
722717

723718
/* 16bit load */
724-
6: ldh 0(%sr3,%r25), %r25
719+
6: ldh 0(%r25), %r25
725720
b cas2_lock_start
726-
7: ldh 0(%sr3,%r24), %r24
721+
7: ldh 0(%r24), %r24
727722
nop
728723
nop
729724
nop
730725
nop
731726
nop
732727

733728
/* 32bit load */
734-
8: ldw 0(%sr3,%r25), %r25
729+
8: ldw 0(%r25), %r25
735730
b cas2_lock_start
736-
9: ldw 0(%sr3,%r24), %r24
731+
9: ldw 0(%r24), %r24
737732
nop
738733
nop
739734
nop
@@ -742,14 +737,14 @@ lws_compare_and_swap_2:
742737

743738
/* 64bit load */
744739
#ifdef CONFIG_64BIT
745-
10: ldd 0(%sr3,%r25), %r25
746-
11: ldd 0(%sr3,%r24), %r24
740+
10: ldd 0(%r25), %r25
741+
11: ldd 0(%r24), %r24
747742
#else
748743
/* Load new value into r22/r23 - high/low */
749-
10: ldw 0(%sr3,%r25), %r22
750-
11: ldw 4(%sr3,%r25), %r23
744+
10: ldw 0(%r25), %r22
745+
11: ldw 4(%r25), %r23
751746
/* Load new value into fr4 for atomic store later */
752-
12: flddx 0(%sr3,%r24), %fr4
747+
12: flddx 0(%r24), %fr4
753748
#endif
754749

755750
cas2_lock_start:
@@ -799,53 +794,53 @@ cas2_action:
799794
ldo 1(%r0),%r28
800795

801796
/* 8bit CAS */
802-
13: ldb,ma 0(%sr3,%r26), %r29
797+
13: ldb,ma 0(%r26), %r29
803798
sub,= %r29, %r25, %r0
804799
b,n cas2_end
805-
14: stb,ma %r24, 0(%sr3,%r26)
800+
14: stb,ma %r24, 0(%r26)
806801
b cas2_end
807802
copy %r0, %r28
808803
nop
809804
nop
810805

811806
/* 16bit CAS */
812-
15: ldh,ma 0(%sr3,%r26), %r29
807+
15: ldh,ma 0(%r26), %r29
813808
sub,= %r29, %r25, %r0
814809
b,n cas2_end
815-
16: sth,ma %r24, 0(%sr3,%r26)
810+
16: sth,ma %r24, 0(%r26)
816811
b cas2_end
817812
copy %r0, %r28
818813
nop
819814
nop
820815

821816
/* 32bit CAS */
822-
17: ldw,ma 0(%sr3,%r26), %r29
817+
17: ldw,ma 0(%r26), %r29
823818
sub,= %r29, %r25, %r0
824819
b,n cas2_end
825-
18: stw,ma %r24, 0(%sr3,%r26)
820+
18: stw,ma %r24, 0(%r26)
826821
b cas2_end
827822
copy %r0, %r28
828823
nop
829824
nop
830825

831826
/* 64bit CAS */
832827
#ifdef CONFIG_64BIT
833-
19: ldd,ma 0(%sr3,%r26), %r29
828+
19: ldd,ma 0(%r26), %r29
834829
sub,*= %r29, %r25, %r0
835830
b,n cas2_end
836-
20: std,ma %r24, 0(%sr3,%r26)
831+
20: std,ma %r24, 0(%r26)
837832
copy %r0, %r28
838833
#else
839834
/* Compare first word */
840-
19: ldw,ma 0(%sr3,%r26), %r29
835+
19: ldw,ma 0(%r26), %r29
841836
sub,= %r29, %r22, %r0
842837
b,n cas2_end
843838
/* Compare second word */
844-
20: ldw,ma 4(%sr3,%r26), %r29
839+
20: ldw,ma 4(%r26), %r29
845840
sub,= %r29, %r23, %r0
846841
b,n cas2_end
847842
/* Perform the store */
848-
21: fstdx %fr4, 0(%sr3,%r26)
843+
21: fstdx %fr4, 0(%r26)
849844
copy %r0, %r28
850845
#endif
851846

0 commit comments

Comments
 (0)