csumcpfruser.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Add-on to transform csum_partial_copy_nocheck in checksumcopy.S into
  3. * csum_partial_copy_from_user by adding exception records.
  4. *
  5. * Copyright (C) 2001 Axis Communications AB.
  6. *
  7. * Author: Hans-Peter Nilsson.
  8. */
  9. #include <asm/errno.h>
  10. /* Same function body, but a different name. If we just added exception
  11. records to _csum_partial_copy_nocheck and made it generic, we wouldn't
  12. know a user fault from a kernel fault and we would have overhead in
  13. each kernel caller for the error-pointer argument.
  14. unsigned int csum_partial_copy_from_user
  15. (const char *src, char *dst, int len, unsigned int sum, int *errptr);
  16. Note that the errptr argument is only set if we encounter an error.
  17. It is conveniently located on the stack, so the normal function body
  18. does not have to handle it. */
  19. #define csum_partial_copy_nocheck csum_partial_copy_from_user
  20. /* There are local labels numbered 1, 2 and 3 present to mark the
  21. different from-user accesses. */
  22. #include "checksumcopy.S"
  23. .section .fixup,"ax"
  24. ;; Here from the movem loop; restore stack.
  25. 4:
  26. movem [$sp+],$r8
  27. ;; r12 is already decremented. Add back chunk_size-2.
  28. addq 40-2,$r12
  29. ;; Here from the word loop; r12 is off by 2; add it back.
  30. 5:
  31. addq 2,$r12
  32. ;; Here from a failing single byte.
  33. 6:
  34. ;; Signal in *errptr that we had a failing access.
  35. moveq -EFAULT,$r9
  36. move.d $r9,[[$sp]]
  37. ;; Clear the rest of the destination area using memset. Preserve the
  38. ;; checksum for the readable bytes.
  39. push $srp
  40. push $r13
  41. move.d $r11,$r10
  42. clear.d $r11
  43. jsr memset
  44. pop $r10
  45. jump [$sp+]
  46. .previous
  47. .section __ex_table,"a"
  48. .dword 1b,4b
  49. .dword 2b,5b
  50. .dword 3b,6b
  51. .previous