| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: copyin.c,v 1.4 2011/06/20 05:20:37 matt Exp $ */ | | 1 | /* $NetBSD: copyin.c,v 1.4.8.1 2012/05/17 18:29:25 riz Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects | | 8 | * by Raytheon BBN Technologies Corp and Defense Advanced Research Projects |
9 | * Agency and which was developed by Matt Thomas of 3am Software Foundry. | | 9 | * Agency and which was developed by Matt Thomas of 3am Software Foundry. |
10 | * | | 10 | * |
11 | * This material is based upon work supported by the Defense Advanced Research | | 11 | * This material is based upon work supported by the Defense Advanced Research |
12 | * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under | | 12 | * Projects Agency and Space and Naval Warfare Systems Center, Pacific, under |
13 | * Contract No. N66001-09-C-2073. | | 13 | * Contract No. N66001-09-C-2073. |
14 | * Approved for Public Release, Distribution Unlimited | | 14 | * Approved for Public Release, Distribution Unlimited |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 26 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 27 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 29 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.4 2011/06/20 05:20:37 matt Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: copyin.c,v 1.4.8.1 2012/05/17 18:29:25 riz Exp $"); |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/lwp.h> | | 42 | #include <sys/lwp.h> |
43 | | | 43 | |
44 | #include <powerpc/pcb.h> | | 44 | #include <powerpc/pcb.h> |
45 | | | 45 | |
46 | #include <powerpc/booke/cpuvar.h> | | 46 | #include <powerpc/booke/cpuvar.h> |
47 | | | 47 | |
48 | static inline uint8_t | | 48 | static inline uint8_t |
49 | copyin_byte(const uint8_t * const usaddr8, register_t ds_msr) | | 49 | copyin_byte(const uint8_t * const usaddr8, register_t ds_msr) |
50 | { | | 50 | { |
51 | register_t msr; | | 51 | register_t msr; |
52 | uint8_t data; | | 52 | uint8_t data; |
| @@ -304,15 +304,18 @@ copyinstr(const void *usaddr, void *kdad | | | @@ -304,15 +304,18 @@ copyinstr(const void *usaddr, void *kdad |
304 | data = copyin_word_bswap(usaddr32++, ds_msr); | | 304 | data = copyin_word_bswap(usaddr32++, ds_msr); |
305 | wlen = 4; | | 305 | wlen = 4; |
306 | } | | 306 | } |
307 | *kdaddr8++ = data; | | 307 | *kdaddr8++ = data; |
308 | if ((uint8_t) data == 0) { | | 308 | if ((uint8_t) data == 0) { |
309 | copylen++; | | 309 | copylen++; |
310 | break; | | 310 | break; |
311 | } | | 311 | } |
312 | } | | 312 | } |
313 | | | 313 | |
314 | pcb->pcb_onfault = NULL; | | 314 | pcb->pcb_onfault = NULL; |
315 | if (done) | | 315 | if (done) |
316 | *done = copylen; | | 316 | *done = copylen; |
317 | return 0; | | 317 | /* |
| | | 318 | * If the last byte is not NUL (0), then the name is too long. |
| | | 319 | */ |
| | | 320 | return (uint8_t)data ? ENAMETOOLONG : 0; |
318 | } | | 321 | } |