Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | #ifndef __M68K_UACCESS_H #define __M68K_UACCESS_H /* * User space memory access functions */ #include <linux/sched.h> #include <asm/segment.h> #define VERIFY_READ 0 #define VERIFY_WRITE 1 /* We let the MMU do all checking */ #define access_ok(type,addr,size) 1 extern inline int verify_area(int type, const void * addr, unsigned long size) { return access_ok(type,addr,size)?0:-EFAULT; } /* * The exception table consists of pairs of addresses: the first is the * address of an instruction that is allowed to fault, and the second is * the address at which the program should continue. No registers are * modified, so it is entirely up to the continuation code to figure out * what to do. * * All the routines below use bits of fixup code that are out of line * with the main instruction path. This means when everything is well, * we don't even have to jump over them. Further, they do not intrude * on our cache or tlb entries. */ struct exception_table_entry { unsigned long insn, fixup; }; /* Returns 0 if exception not found and fixup otherwise. */ extern unsigned long search_exception_table(unsigned long); /* * These are the main single-value transfer routines. They automatically * use the right size if we just have the right pointer type. */ #define put_user(x, ptr) \ ({ \ int __pu_err; \ typeof(*(ptr)) __pu_val = (x); \ switch (sizeof (*(ptr))) { \ case 1: \ __put_user_asm(__pu_err, __pu_val, ptr, b); \ break; \ case 2: \ __put_user_asm(__pu_err, __pu_val, ptr, w); \ break; \ case 4: \ __put_user_asm(__pu_err, __pu_val, ptr, l); \ break; \ default: \ __pu_err = __put_user_bad(); \ break; \ } \ __pu_err; \ }) #define __put_user(x, ptr) put_user(x, ptr) extern int __put_user_bad(void); /* * Tell gcc we read from memory instead of writing: this is because * we do not write to any memory gcc knows about, so there are no * aliasing issues. */ #define __put_user_asm(err,x,ptr,bwl) \ __asm__ __volatile__ \ ("21:moves" #bwl " %2,%1\n" \ "1:\n" \ ".section .fixup,\"ax\"\n" \ " .even\n" \ "2: movel %3,%0\n" \ " jra 1b\n" \ ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 4\n" \ " .long 21b,2b\n" \ " .long 1b,2b\n" \ ".previous" \ : "=d"(err) \ : "m"(*(ptr)), "r"(x), "i"(-EFAULT), "0"(0)) #define get_user(x, ptr) \ ({ \ int __gu_err; \ typeof(*(ptr)) __gu_val; \ switch (sizeof(*(ptr))) { \ case 1: \ __get_user_asm(__gu_err, __gu_val, ptr, b, "=d"); \ break; \ case 2: \ __get_user_asm(__gu_err, __gu_val, ptr, w, "=r"); \ break; \ case 4: \ __get_user_asm(__gu_err, __gu_val, ptr, l, "=r"); \ break; \ default: \ __gu_val = 0; \ __gu_err = __get_user_bad(); \ break; \ } \ (x) = __gu_val; \ __gu_err; \ }) #define __get_user(x, ptr) get_user(x, ptr) extern int __get_user_bad(void); #define __get_user_asm(err,x,ptr,bwl,reg) \ __asm__ __volatile__ \ ("1: moves" #bwl " %2,%1\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ " .even\n" \ "3: movel %3,%0\n" \ " sub" #bwl " %1,%1\n" \ " jra 2b\n" \ ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 4\n" \ " .long 1b,3b\n" \ ".previous" \ : "=d"(err), reg(x) \ : "m"(*(ptr)), "i" (-EFAULT), "0"(0)) static inline unsigned long __generic_copy_from_user(void *to, const void *from, unsigned long n) { unsigned long tmp; __asm__ __volatile__ (" tstl %2\n" " jeq 2f\n" "1: movesl (%1)+,%3\n" " movel %3,(%0)+\n" " subql #1,%2\n" " jne 1b\n" "2: movel %4,%2\n" " bclr #1,%2\n" " jeq 4f\n" "3: movesw (%1)+,%3\n" " movew %3,(%0)+\n" "4: bclr #0,%2\n" " jeq 6f\n" "5: movesb (%1)+,%3\n" " moveb %3,(%0)+\n" "6:\n" ".section .fixup,\"ax\"\n" " .even\n" "7: movel %2,%%d0\n" "71:clrl (%0)+\n" " subql #1,%%d0\n" " jne 71b\n" " lsll #2,%2\n" " addl %4,%2\n" " btst #1,%4\n" " jne 81f\n" " btst #0,%4\n" " jne 91f\n" " jra 6b\n" "8: addql #2,%2\n" "81:clrw (%0)+\n" " btst #0,%4\n" " jne 91f\n" " jra 6b\n" "9: addql #1,%2\n" "91:clrb (%0)+\n" " jra 6b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,7b\n" " .long 3b,8b\n" " .long 5b,9b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n), "=&d"(tmp) : "d"(n & 3), "0"(to), "1"(from), "2"(n/4) : "d0", "memory"); return n; } static inline unsigned long __generic_copy_to_user(void *to, const void *from, unsigned long n) { unsigned long tmp; __asm__ __volatile__ (" tstl %2\n" " jeq 3f\n" "1: movel (%1)+,%3\n" "22:movesl %3,(%0)+\n" "2: subql #1,%2\n" " jne 1b\n" "3: movel %4,%2\n" " bclr #1,%2\n" " jeq 4f\n" " movew (%1)+,%3\n" "24:movesw %3,(%0)+\n" "4: bclr #0,%2\n" " jeq 5f\n" " moveb (%1)+,%3\n" "25:movesb %3,(%0)+\n" "5:\n" ".section .fixup,\"ax\"\n" " .even\n" "60:addql #1,%2\n" "6: lsll #2,%2\n" " addl %4,%2\n" " jra 5b\n" "7: addql #2,%2\n" " jra 5b\n" "8: addql #1,%2\n" " jra 5b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,60b\n" " .long 22b,6b\n" " .long 2b,6b\n" " .long 24b,7b\n" " .long 3b,60b\n" " .long 4b,7b\n" " .long 25b,8b\n" " .long 5b,8b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n), "=&d"(tmp) : "r"(n & 3), "0"(to), "1"(from), "2"(n / 4) : "memory"); return n; } #define __copy_from_user_big(to, from, n, fixup, copy) \ __asm__ __volatile__ \ ("10: movesl (%1)+,%%d0\n" \ " movel %%d0,(%0)+\n" \ " subql #1,%2\n" \ " jne 10b\n" \ ".section .fixup,\"ax\"\n" \ " .even\n" \ "11: movel %2,%%d0\n" \ "13: clrl (%0)+\n" \ " subql #1,%%d0\n" \ " jne 13b\n" \ " lsll #2,%2\n" \ fixup "\n" \ " jra 12f\n" \ ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 4\n" \ " .long 10b,11b\n" \ ".previous\n" \ copy "\n" \ "12:" \ : "=a"(to), "=a"(from), "=d"(n) \ : "0"(to), "1"(from), "2"(n/4) \ : "d0", "memory") static inline unsigned long __constant_copy_from_user(void *to, const void *from, unsigned long n) { switch (n) { case 0: break; case 1: __asm__ __volatile__ ("1: movesb (%1)+,%%d0\n" " moveb %%d0,(%0)+\n" "2:\n" ".section .fixup,\"ax\"\n" " .even\n" "3: addql #1,%2\n" " clrb (%0)+\n" " jra 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 2: __asm__ __volatile__ ("1: movesw (%1)+,%%d0\n" " movew %%d0,(%0)+\n" "2:\n" ".section .fixup,\"ax\"\n" " .even\n" "3: addql #2,%2\n" " clrw (%0)+\n" " jra 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 3: __asm__ __volatile__ ("1: movesw (%1)+,%%d0\n" " movew %%d0,(%0)+\n" "2: movesb (%1)+,%%d0\n" " moveb %%d0,(%0)+\n" "3:" ".section .fixup,\"ax\"\n" " .even\n" "4: addql #2,%2\n" " clrw (%0)+\n" "5: addql #1,%2\n" " clrb (%0)+\n" " jra 3b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,4b\n" " .long 2b,5b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 4: __asm__ __volatile__ ("1: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "2:" ".section .fixup,\"ax\"\n" " .even\n" "3: addql #4,%2\n" " clrl (%0)+\n" " jra 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 8: __asm__ __volatile__ ("1: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "2: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "3:" ".section .fixup,\"ax\"\n" " .even\n" "4: addql #4,%2\n" " clrl (%0)+\n" "5: addql #4,%2\n" " clrl (%0)+\n" " jra 3b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,4b\n" " .long 2b,5b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 12: __asm__ __volatile__ ("1: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "2: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "3: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "4:" ".section .fixup,\"ax\"\n" " .even\n" "5: addql #4,%2\n" " clrl (%0)+\n" "6: addql #4,%2\n" " clrl (%0)+\n" "7: addql #4,%2\n" " clrl (%0)+\n" " jra 4b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,5b\n" " .long 2b,6b\n" " .long 3b,7b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 16: __asm__ __volatile__ ("1: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "2: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "3: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "4: movesl (%1)+,%%d0\n" " movel %%d0,(%0)+\n" "5:" ".section .fixup,\"ax\"\n" " .even\n" "6: addql #4,%2\n" " clrl (%0)+\n" "7: addql #4,%2\n" " clrl (%0)+\n" "8: addql #4,%2\n" " clrl (%0)+\n" "9: addql #4,%2\n" " clrl (%0)+\n" " jra 5b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,6b\n" " .long 2b,7b\n" " .long 3b,8b\n" " .long 4b,9b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; default: switch (n & 3) { case 0: __copy_from_user_big(to, from, n, "", ""); break; case 1: __copy_from_user_big(to, from, n, /* fixup */ "1: addql #1,%2\n" " clrb (%0)+", /* copy */ "2: movesb (%1)+,%%d0\n" " moveb %%d0,(%0)+\n" ".section __ex_table,\"a\"\n" " .long 2b,1b\n" ".previous"); break; case 2: __copy_from_user_big(to, from, n, /* fixup */ "1: addql #2,%2\n" " clrw (%0)+", /* copy */ "2: movesw (%1)+,%%d0\n" " movew %%d0,(%0)+\n" ".section __ex_table,\"a\"\n" " .long 2b,1b\n" ".previous"); break; case 3: __copy_from_user_big(to, from, n, /* fixup */ "1: addql #2,%2\n" " clrw (%0)+\n" "2: addql #1,%2\n" " clrb (%0)+", /* copy */ "3: movesw (%1)+,%%d0\n" " movew %%d0,(%0)+\n" "4: movesb (%1)+,%%d0\n" " moveb %%d0,(%0)+\n" ".section __ex_table,\"a\"\n" " .long 3b,1b\n" " .long 4b,2b\n" ".previous"); break; } break; } return n; } #define __copy_to_user_big(to, from, n, fixup, copy) \ __asm__ __volatile__ \ ("10: movel (%1)+,%%d0\n" \ "31: movesl %%d0,(%0)+\n" \ "11: subql #1,%2\n" \ " jne 10b\n" \ "41:\n" \ ".section .fixup,\"ax\"\n" \ " .even\n" \ "22: addql #1,%2\n" \ "12: lsll #2,%2\n" \ fixup "\n" \ " jra 13f\n" \ ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 4\n" \ " .long 10b,22b\n" \ " .long 31b,12b\n" \ " .long 11b,12b\n" \ " .long 41b,22b\n" \ ".previous\n" \ copy "\n" \ "13:" \ : "=a"(to), "=a"(from), "=d"(n) \ : "0"(to), "1"(from), "2"(n/4) \ : "d0", "memory") static inline unsigned long __constant_copy_to_user(void *to, const void *from, unsigned long n) { switch (n) { case 0: break; case 1: __asm__ __volatile__ (" moveb (%1)+,%%d0\n" "21:movesb %%d0,(%0)+\n" "1:\n" ".section .fixup,\"ax\"\n" " .even\n" "2: addql #1,%2\n" " jra 1b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n " " .long 21b,2b\n" " .long 1b,2b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 2: __asm__ __volatile__ (" movew (%1)+,%%d0\n" "21:movesw %%d0,(%0)+\n" "1:\n" ".section .fixup,\"ax\"\n" " .even\n" "2: addql #2,%2\n" " jra 1b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 21b,2b\n" " .long 1b,2b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 3: __asm__ __volatile__ (" movew (%1)+,%%d0\n" "21:movesw %%d0,(%0)+\n" "1: moveb (%1)+,%%d0\n" "22:movesb %%d0,(%0)+\n" "2:\n" ".section .fixup,\"ax\"\n" " .even\n" "3: addql #2,%2\n" "4: addql #1,%2\n" " jra 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 21b,3b\n" " .long 1b,3b\n" " .long 22b,4b\n" " .long 2b,4b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 4: __asm__ __volatile__ (" movel (%1)+,%%d0\n" "21:movesl %%d0,(%0)+\n" "1:\n" ".section .fixup,\"ax\"\n" " .even\n" "2: addql #4,%2\n" " jra 1b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 21b,2b\n" " .long 1b,2b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 8: __asm__ __volatile__ (" movel (%1)+,%%d0\n" "21:movesl %%d0,(%0)+\n" "1: movel (%1)+,%%d0\n" "22:movesl %%d0,(%0)+\n" "2:\n" ".section .fixup,\"ax\"\n" " .even\n" "3: addql #4,%2\n" "4: addql #4,%2\n" " jra 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 21b,3b\n" " .long 1b,3b\n" " .long 22b,4b\n" " .long 2b,4b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 12: __asm__ __volatile__ (" movel (%1)+,%%d0\n" "21:movesl %%d0,(%0)+\n" "1: movel (%1)+,%%d0\n" "22:movesl %%d0,(%0)+\n" "2: movel (%1)+,%%d0\n" "23:movesl %%d0,(%0)+\n" "3:\n" ".section .fixup,\"ax\"\n" " .even\n" "4: addql #4,%2\n" "5: addql #4,%2\n" "6: addql #4,%2\n" " jra 3b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 21b,4b\n" " .long 1b,4b\n" " .long 22b,5b\n" " .long 2b,5b\n" " .long 23b,6b\n" " .long 3b,6b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; case 16: __asm__ __volatile__ (" movel (%1)+,%%d0\n" "21:movesl %%d0,(%0)+\n" "1: movel (%1)+,%%d0\n" "22:movesl %%d0,(%0)+\n" "2: movel (%1)+,%%d0\n" "23:movesl %%d0,(%0)+\n" "3: movel (%1)+,%%d0\n" "24:movesl %%d0,(%0)+\n" "4:" ".section .fixup,\"ax\"\n" " .even\n" "5: addql #4,%2\n" "6: addql #4,%2\n" "7: addql #4,%2\n" "8: addql #4,%2\n" " jra 4b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 21b,5b\n" " .long 1b,5b\n" " .long 22b,6b\n" " .long 2b,6b\n" " .long 23b,7b\n" " .long 3b,7b\n" " .long 24b,8b\n" " .long 4b,8b\n" ".previous" : "=a"(to), "=a"(from), "=d"(n) : "0"(to), "1"(from), "2"(0) : "d0", "memory"); break; default: switch (n & 3) { case 0: __copy_to_user_big(to, from, n, "", ""); break; case 1: __copy_to_user_big(to, from, n, /* fixup */ "1: addql #1,%2", /* copy */ " moveb (%1)+,%%d0\n" "22:movesb %%d0,(%0)+\n" "2:" ".section __ex_table,\"a\"\n" " .long 22b,1b\n" " .long 2b,1b\n" ".previous"); break; case 2: __copy_to_user_big(to, from, n, /* fixup */ "1: addql #2,%2", /* copy */ " movew (%1)+,%%d0\n" "22:movesw %%d0,(%0)+\n" "2:" ".section __ex_table,\"a\"\n" " .long 22b,1b\n" " .long 2b,1b\n" ".previous"); break; case 3: __copy_to_user_big(to, from, n, /* fixup */ "1: addql #2,%2\n" "2: addql #1,%2", /* copy */ " movew (%1)+,%%d0\n" "23:movesw %%d0,(%0)+\n" "3: moveb (%1)+,%%d0\n" "24:movesb %%d0,(%0)+\n" "4:" ".section __ex_table,\"a\"\n" " .long 23b,1b\n" " .long 3b,1b\n" " .long 24b,2b\n" " .long 4b,2b\n" ".previous"); break; } break; } return n; } #define copy_from_user(to, from, n) \ (__builtin_constant_p(n) ? \ __constant_copy_from_user(to, from, n) : \ __generic_copy_from_user(to, from, n)) #define copy_to_user(to, from, n) \ (__builtin_constant_p(n) ? \ __constant_copy_to_user(to, from, n) : \ __generic_copy_to_user(to, from, n)) #define __copy_from_user(to, from, n) copy_from_user(to, from, n) #define __copy_to_user(to, from, n) copy_to_user(to, from, n) /* * Copy a null terminated string from userspace. */ static inline long strncpy_from_user(char *dst, const char *src, long count) { long res; if (count == 0) return count; __asm__ __volatile__ ("1: movesb (%2)+,%%d0\n" "12:moveb %%d0,(%1)+\n" " jeq 2f\n" " subql #1,%3\n" " jne 1b\n" "2: subl %3,%0\n" "3:\n" ".section .fixup,\"ax\"\n" " .even\n" "4: movel %4,%0\n" " jra 3b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,4b\n" " .long 12b,4b\n" ".previous" : "=d"(res), "=a"(dst), "=a"(src), "=d"(count) : "i"(-EFAULT), "0"(count), "1"(dst), "2"(src), "3"(count) : "d0", "memory"); return res; } /* * Return the size of a string (including the ending 0) * * Return 0 on exception, a value greater than N if too long */ static inline long strnlen_user(const char *src, long n) { long res; res = -(long)src; __asm__ __volatile__ ("1:\n" " tstl %2\n" " jeq 3f\n" "2: movesb (%1)+,%%d0\n" "22:\n" " subql #1,%2\n" " tstb %%d0\n" " jne 1b\n" " jra 4f\n" "3:\n" " addql #1,%0\n" "4:\n" " addl %1,%0\n" "5:\n" ".section .fixup,\"ax\"\n" " .even\n" "6: moveq %3,%0\n" " jra 5b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 2b,6b\n" " .long 22b,6b\n" ".previous" : "=d"(res), "=a"(src), "=d"(n) : "i"(0), "0"(res), "1"(src), "2"(n) : "d0"); return res; } #define strlen_user(str) strnlen_user(str, 32767) /* * Zero Userspace */ static inline unsigned long clear_user(void *to, unsigned long n) { __asm__ __volatile__ (" tstl %1\n" " jeq 3f\n" "1: movesl %3,(%0)+\n" "2: subql #1,%1\n" " jne 1b\n" "3: movel %2,%1\n" " bclr #1,%1\n" " jeq 4f\n" "24:movesw %3,(%0)+\n" "4: bclr #0,%1\n" " jeq 5f\n" "25:movesb %3,(%0)+\n" "5:\n" ".section .fixup,\"ax\"\n" " .even\n" "61:addql #1,%1\n" "6: lsll #2,%1\n" " addl %2,%1\n" " jra 5b\n" "7: addql #2,%1\n" " jra 5b\n" "8: addql #1,%1\n" " jra 5b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,61b\n" " .long 2b,6b\n" " .long 3b,61b\n" " .long 24b,7b\n" " .long 4b,7b\n" " .long 25b,8b\n" " .long 5b,8b\n" ".previous" : "=a"(to), "=d"(n) : "r"(n & 3), "r"(0), "0"(to), "1"(n/4)); return n; } #endif /* _M68K_UACCESS_H */ |