csumpartialcopyuser.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * linux/arch/arm/lib/csumpartialcopyuser.S
  3. *
  4. * Copyright (C) 1995-1998 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * 27/03/03 Ian Molton Clean up CONFIG_CPU
  11. *
  12. */
  13. #include <linux/linkage.h>
  14. #include <asm/assembler.h>
  15. #include <asm/errno.h>
  16. #include <asm/asm-offsets.h>
  17. .text
  18. #ifdef CONFIG_CPU_SW_DOMAIN_PAN
  19. .macro save_regs
  20. mrc p15, 0, ip, c3, c0, 0
  21. stmfd sp!, {r1, r2, r4 - r8, ip, lr}
  22. uaccess_enable ip
  23. .endm
  24. .macro load_regs
  25. ldmfd sp!, {r1, r2, r4 - r8, ip, lr}
  26. mcr p15, 0, ip, c3, c0, 0
  27. ret lr
  28. .endm
  29. #else
  30. .macro save_regs
  31. stmfd sp!, {r1, r2, r4 - r8, lr}
  32. .endm
  33. .macro load_regs
  34. ldmfd sp!, {r1, r2, r4 - r8, pc}
  35. .endm
  36. #endif
  37. .macro load1b, reg1
  38. ldrusr \reg1, r0, 1
  39. .endm
  40. .macro load2b, reg1, reg2
  41. ldrusr \reg1, r0, 1
  42. ldrusr \reg2, r0, 1
  43. .endm
  44. .macro load1l, reg1
  45. ldrusr \reg1, r0, 4
  46. .endm
  47. .macro load2l, reg1, reg2
  48. ldrusr \reg1, r0, 4
  49. ldrusr \reg2, r0, 4
  50. .endm
  51. .macro load4l, reg1, reg2, reg3, reg4
  52. ldrusr \reg1, r0, 4
  53. ldrusr \reg2, r0, 4
  54. ldrusr \reg3, r0, 4
  55. ldrusr \reg4, r0, 4
  56. .endm
  57. /*
  58. * unsigned int
  59. * csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *err_ptr)
  60. * r0 = src, r1 = dst, r2 = len, r3 = sum, [sp] = *err_ptr
  61. * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
  62. */
  63. #define FN_ENTRY ENTRY(csum_partial_copy_from_user)
  64. #define FN_EXIT ENDPROC(csum_partial_copy_from_user)
  65. #include "csumpartialcopygeneric.S"
  66. /*
  67. * FIXME: minor buglet here
  68. * We don't return the checksum for the data present in the buffer. To do
  69. * so properly, we would have to add in whatever registers were loaded before
  70. * the fault, which, with the current asm above is not predictable.
  71. */
  72. .pushsection .text.fixup,"ax"
  73. .align 4
  74. 9001: mov r4, #-EFAULT
  75. #ifdef CONFIG_CPU_SW_DOMAIN_PAN
  76. ldr r5, [sp, #9*4] @ *err_ptr
  77. #else
  78. ldr r5, [sp, #8*4] @ *err_ptr
  79. #endif
  80. str r4, [r5]
  81. ldmia sp, {r1, r2} @ retrieve dst, len
  82. add r2, r2, r1
  83. mov r0, #0 @ zero the buffer
  84. 9002: teq r2, r1
  85. strneb r0, [r1], #1
  86. bne 9002b
  87. load_regs
  88. .popsection