Sun Aug 8 18:18:58 2010 UTC ()
fix copy{in,out}{,str}() to return the error returned by uvm_fault().
part of PR 41813 that I missed earlier.


(chs)
diff -r1.5 -r1.6 src/sys/arch/ia64/ia64/support.S

cvs diff -r1.5 -r1.6 src/sys/arch/ia64/ia64/support.S (expand / switch to unified diff)

--- src/sys/arch/ia64/ia64/support.S 2009/11/27 03:23:10 1.5
+++ src/sys/arch/ia64/ia64/support.S 2010/08/08 18:18:58 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: support.S,v 1.5 2009/11/27 03:23:10 rmind Exp $ */ 1/* $NetBSD: support.S,v 1.6 2010/08/08 18:18:58 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998 Doug Rabson 4 * Copyright (c) 1998 Doug Rabson
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -47,27 +47,26 @@ @@ -47,27 +47,26 @@
47 * Carnegie Mellon requests users of this software to return to 47 * Carnegie Mellon requests users of this software to return to
48 * 48 *
49 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
50 * School of Computer Science 50 * School of Computer Science
51 * Carnegie Mellon University 51 * Carnegie Mellon University
52 * Pittsburgh PA 15213-3890 52 * Pittsburgh PA 15213-3890
53 * 53 *
54 * any improvements or extensions that they make and grant Carnegie the 54 * any improvements or extensions that they make and grant Carnegie the
55 * rights to redistribute these changes. 55 * rights to redistribute these changes.
56 */ 56 */
57 57
58#include <machine/asm.h> 58#include <machine/asm.h>
59#include <machine/ia64_cpu.h> 59#include <machine/ia64_cpu.h>
60#include <machine/vmparam.h> 
61 60
62#include "assym.h" 61#include "assym.h"
63 62
64.text 63.text
65 64
66/* 65/*
67 * ia64_change_mode: change mode to/from physical mode 66 * ia64_change_mode: change mode to/from physical mode
68 * 67 *
69 * Arguments: 68 * Arguments:
70 * r14 psr for desired mode 69 * r14 psr for desired mode
71 * 70 *
72 * Modifies: 71 * Modifies:
73 * r15-r19 scratch 72 * r15-r19 scratch
@@ -698,27 +697,27 @@ END(copystr) @@ -698,27 +697,27 @@ END(copystr)
698ENTRY(copyinstr, 4) 697ENTRY(copyinstr, 4)
699 .prologue 698 .prologue
700 .regstk 4, 3, 4, 0 699 .regstk 4, 3, 4, 0
701 .save ar.pfs,loc0 700 .save ar.pfs,loc0
702 alloc loc0=ar.pfs,4,3,4,0 701 alloc loc0=ar.pfs,4,3,4,0
703 .save rp,loc1 702 .save rp,loc1
704 mov loc1=rp 703 mov loc1=rp
705 .body 704 .body
706 705
707 movl loc2=VM_MAX_ADDRESS // make sure that src addr 706 movl loc2=VM_MAX_ADDRESS // make sure that src addr
708 ;; 707 ;;
709 cmp.geu p6,p0=in0,loc2 // is in user space. 708 cmp.geu p6,p0=in0,loc2 // is in user space.
710 ;; 709 ;;
711(p6) br.cond.spnt.few copyerr // if it's not, error out. 710(p6) br.cond.spnt.few copyefault // if it's not, error out.
712 movl r14=copyerr // set up fault handler. 711 movl r14=copyerr // set up fault handler.
713 add r15=PC_CURLWP,r13 // find curthread 712 add r15=PC_CURLWP,r13 // find curthread
714 ;; 713 ;;
715 ld8 r15=[r15] 714 ld8 r15=[r15]
716 ;; 715 ;;
717 add r15=L_PCB,r15 // find pcb 716 add r15=L_PCB,r15 // find pcb
718 ;; 717 ;;
719 ld8 r15=[r15] 718 ld8 r15=[r15]
720 ;; 719 ;;
721 add loc2=PCB_ONFAULT,r15 720 add loc2=PCB_ONFAULT,r15
722 ;; 721 ;;
723 st8 [loc2]=r14 722 st8 [loc2]=r14
724 ;; 723 ;;
@@ -737,27 +736,27 @@ END(copyinstr) @@ -737,27 +736,27 @@ END(copyinstr)
737ENTRY(copyoutstr, 4) 736ENTRY(copyoutstr, 4)
738 .prologue 737 .prologue
739 .regstk 4, 3, 4, 0 738 .regstk 4, 3, 4, 0
740 .save ar.pfs,loc0 739 .save ar.pfs,loc0
741 alloc loc0=ar.pfs,4,3,4,0 740 alloc loc0=ar.pfs,4,3,4,0
742 .save rp,loc1 741 .save rp,loc1
743 mov loc1=rp 742 mov loc1=rp
744 .body 743 .body
745 744
746 movl loc2=VM_MAX_ADDRESS // make sure that dest addr 745 movl loc2=VM_MAX_ADDRESS // make sure that dest addr
747 ;; 746 ;;
748 cmp.geu p6,p0=in1,loc2 // is in user space. 747 cmp.geu p6,p0=in1,loc2 // is in user space.
749 ;; 748 ;;
750(p6) br.cond.spnt.few copyerr // if it's not, error out. 749(p6) br.cond.spnt.few copyefault // if it's not, error out.
751 movl r14=copyerr // set up fault handler. 750 movl r14=copyerr // set up fault handler.
752 add r15=PC_CURLWP,r13 // find curthread 751 add r15=PC_CURLWP,r13 // find curthread
753 ;; 752 ;;
754 ld8 r15=[r15] 753 ld8 r15=[r15]
755 ;; 754 ;;
756 add r15=L_PCB,r15 // find pcb 755 add r15=L_PCB,r15 // find pcb
757 ;; 756 ;;
758 ld8 r15=[r15] 757 ld8 r15=[r15]
759 ;; 758 ;;
760 add loc2=PCB_ONFAULT,r15 759 add loc2=PCB_ONFAULT,r15
761 ;; 760 ;;
762 st8 [loc2]=r14 761 st8 [loc2]=r14
763 ;; 762 ;;
@@ -888,27 +887,27 @@ END(kcopy) @@ -888,27 +887,27 @@ END(kcopy)
888ENTRY(copyin, 3) 887ENTRY(copyin, 3)
889 .prologue 888 .prologue
890 .regstk 3, 3, 3, 0 889 .regstk 3, 3, 3, 0
891 .save ar.pfs,loc0 890 .save ar.pfs,loc0
892 alloc loc0=ar.pfs,3,3,3,0 891 alloc loc0=ar.pfs,3,3,3,0
893 .save rp,loc1 892 .save rp,loc1
894 mov loc1=rp 893 mov loc1=rp
895 .body 894 .body
896 895
897 movl loc2=VM_MAX_ADDRESS // make sure that src addr 896 movl loc2=VM_MAX_ADDRESS // make sure that src addr
898 ;; 897 ;;
899 cmp.geu p6,p0=in0,loc2 // is in user space. 898 cmp.geu p6,p0=in0,loc2 // is in user space.
900 ;; 899 ;;
901(p6) br.cond.spnt.few copyerr // if it's not, error out. 900(p6) br.cond.spnt.few copyefault // if it's not, error out.
902 movl r14=copyerr // set up fault handler. 901 movl r14=copyerr // set up fault handler.
903 add r15=PC_CURLWP,r13 // find curthread 902 add r15=PC_CURLWP,r13 // find curthread
904 ;; 903 ;;
905 ld8 r15=[r15] 904 ld8 r15=[r15]
906 ;; 905 ;;
907 add r15=L_PCB,r15 // find pcb 906 add r15=L_PCB,r15 // find pcb
908 ;; 907 ;;
909 ld8 r15=[r15] 908 ld8 r15=[r15]
910 ;; 909 ;;
911 add loc2=PCB_ONFAULT,r15 910 add loc2=PCB_ONFAULT,r15
912 ;; 911 ;;
913 st8 [loc2]=r14 912 st8 [loc2]=r14
914 ;; 913 ;;
@@ -926,27 +925,27 @@ END(copyin) @@ -926,27 +925,27 @@ END(copyin)
926ENTRY(copyout, 3) 925ENTRY(copyout, 3)
927 .prologue 926 .prologue
928 .regstk 3, 3, 3, 0 927 .regstk 3, 3, 3, 0
929 .save ar.pfs,loc0 928 .save ar.pfs,loc0
930 alloc loc0=ar.pfs,3,3,3,0 929 alloc loc0=ar.pfs,3,3,3,0
931 .save rp,loc1 930 .save rp,loc1
932 mov loc1=rp 931 mov loc1=rp
933 .body 932 .body
934 933
935 movl loc2=VM_MAX_ADDRESS // make sure that dest addr 934 movl loc2=VM_MAX_ADDRESS // make sure that dest addr
936 ;; 935 ;;
937 cmp.geu p6,p0=in1,loc2 // is in user space. 936 cmp.geu p6,p0=in1,loc2 // is in user space.
938 ;; 937 ;;
939(p6) br.cond.spnt.few copyerr // if it's not, error out. 938(p6) br.cond.spnt.few copyefault // if it's not, error out.
940 movl r14=copyerr // set up fault handler. 939 movl r14=copyerr // set up fault handler.
941 add r15=PC_CURLWP,r13 // find curthread 940 add r15=PC_CURLWP,r13 // find curthread
942 ;; 941 ;;
943 ld8 r15=[r15] 942 ld8 r15=[r15]
944 ;; 943 ;;
945 add r15=L_PCB,r15 // find pcb 944 add r15=L_PCB,r15 // find pcb
946 ;; 945 ;;
947 ld8 r15=[r15] 946 ld8 r15=[r15]
948 ;; 947 ;;
949 add loc2=PCB_ONFAULT,r15 948 add loc2=PCB_ONFAULT,r15
950 ;; 949 ;;
951 st8 [loc2]=r14 950 st8 [loc2]=r14
952 ;; 951 ;;
@@ -959,30 +958,41 @@ ENTRY(copyout, 3) @@ -959,30 +958,41 @@ ENTRY(copyout, 3)
959 mov ar.pfs=loc0 // restore ar.pfs 958 mov ar.pfs=loc0 // restore ar.pfs
960 mov rp=loc1 // restore ra. 959 mov rp=loc1 // restore ra.
961 br.ret.sptk.few rp // ret0 left over from bcopy 960 br.ret.sptk.few rp // ret0 left over from bcopy
962END(copyout) 961END(copyout)
963 962
964ENTRY(copyerr, 0) 963ENTRY(copyerr, 0)
965 add r14=PC_CURLWP,r13 ;; // find curthread 964 add r14=PC_CURLWP,r13 ;; // find curthread
966 ld8 r14=[r14] ;; 965 ld8 r14=[r14] ;;
967 add r14=L_PCB,r14 ;; // curthread->td_addr 966 add r14=L_PCB,r14 ;; // curthread->td_addr
968 ld8 r14=[r14] ;; 967 ld8 r14=[r14] ;;
969 add r14=PCB_ONFAULT,r14 ;; // &curthread->td_pcb->pcb_onfault 968 add r14=PCB_ONFAULT,r14 ;; // &curthread->td_pcb->pcb_onfault
970 st8 [r14]=r0 // reset fault handler 969 st8 [r14]=r0 // reset fault handler
971 970
972 mov ret0=EFAULT // return EFAULT 
973 br.ret.sptk.few rp 971 br.ret.sptk.few rp
974END(copyerr) 972END(copyerr)
975 973
 974ENTRY(copyefault, 0)
 975 add r14=PC_CURLWP,r13 ;; // find curthread
 976 ld8 r14=[r14] ;;
 977 add r14=L_PCB,r14 ;; // curthread->td_addr
 978 ld8 r14=[r14] ;;
 979 add r14=PCB_ONFAULT,r14 ;; // &curthread->td_pcb->pcb_onfault
 980 st8 [r14]=r0 // reset fault handler
 981
 982 mov ret0=EFAULT // return EFAULT
 983 br.ret.sptk.few rp
 984END(copyefault)
 985
976#if defined(GPROF) 986#if defined(GPROF)
977/* 987/*
978 * Important registers: 988 * Important registers:
979 * r8 structure return address 989 * r8 structure return address
980 * rp our return address 990 * rp our return address
981 * in0 caller's ar.pfs 991 * in0 caller's ar.pfs
982 * in1 caller's gp 992 * in1 caller's gp
983 * in2 caller's rp 993 * in2 caller's rp
984 * in3 GOT entry 994 * in3 GOT entry
985 * ar.pfs our pfs 995 * ar.pfs our pfs
986 */ 996 */
987ENTRY_NOPROFILE(_mcount, 4) 997ENTRY_NOPROFILE(_mcount, 4)
988 alloc loc0 = ar.pfs, 4, 3, 2, 0 998 alloc loc0 = ar.pfs, 4, 3, 2, 0