fixup.S 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Linux/PA-RISC Project (http://www.parisc-linux.org/)
  3. *
  4. * Copyright (C) 2004 Randolph Chung <tausq@debian.org>
  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 as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. * Fixup routines for kernel exception handling.
  21. */
  22. #include <asm/asm-offsets.h>
  23. #include <asm/assembly.h>
  24. #include <asm/errno.h>
  25. #include <linux/linkage.h>
  26. #ifdef CONFIG_SMP
  27. .macro get_fault_ip t1 t2
  28. loadgp
  29. addil LT%__per_cpu_offset,%r27
  30. LDREG RT%__per_cpu_offset(%r1),\t1
  31. /* t2 = smp_processor_id() */
  32. mfctl 30,\t2
  33. ldw TI_CPU(\t2),\t2
  34. #ifdef CONFIG_64BIT
  35. extrd,u \t2,63,32,\t2
  36. #endif
  37. /* t2 = &__per_cpu_offset[smp_processor_id()]; */
  38. LDREGX \t2(\t1),\t2
  39. addil LT%exception_data,%r27
  40. LDREG RT%exception_data(%r1),\t1
  41. /* t1 = this_cpu_ptr(&exception_data) */
  42. add,l \t1,\t2,\t1
  43. /* %r27 = t1->fault_gp - restore gp */
  44. LDREG EXCDATA_GP(\t1), %r27
  45. /* t1 = t1->fault_ip */
  46. LDREG EXCDATA_IP(\t1), \t1
  47. .endm
  48. #else
  49. .macro get_fault_ip t1 t2
  50. loadgp
  51. /* t1 = this_cpu_ptr(&exception_data) */
  52. addil LT%exception_data,%r27
  53. LDREG RT%exception_data(%r1),\t2
  54. /* %r27 = t2->fault_gp - restore gp */
  55. LDREG EXCDATA_GP(\t2), %r27
  56. /* t1 = t2->fault_ip */
  57. LDREG EXCDATA_IP(\t2), \t1
  58. .endm
  59. #endif
  60. .level LEVEL
  61. .text
  62. .section .fixup, "ax"
  63. /* get_user() fixups, store -EFAULT in r8, and 0 in r9 */
  64. ENTRY_CFI(fixup_get_user_skip_1)
  65. get_fault_ip %r1,%r8
  66. ldo 4(%r1), %r1
  67. ldi -EFAULT, %r8
  68. bv %r0(%r1)
  69. copy %r0, %r9
  70. ENDPROC_CFI(fixup_get_user_skip_1)
  71. ENTRY_CFI(fixup_get_user_skip_2)
  72. get_fault_ip %r1,%r8
  73. ldo 8(%r1), %r1
  74. ldi -EFAULT, %r8
  75. bv %r0(%r1)
  76. copy %r0, %r9
  77. ENDPROC_CFI(fixup_get_user_skip_2)
  78. /* put_user() fixups, store -EFAULT in r8 */
  79. ENTRY_CFI(fixup_put_user_skip_1)
  80. get_fault_ip %r1,%r8
  81. ldo 4(%r1), %r1
  82. bv %r0(%r1)
  83. ldi -EFAULT, %r8
  84. ENDPROC_CFI(fixup_put_user_skip_1)
  85. ENTRY_CFI(fixup_put_user_skip_2)
  86. get_fault_ip %r1,%r8
  87. ldo 8(%r1), %r1
  88. bv %r0(%r1)
  89. ldi -EFAULT, %r8
  90. ENDPROC_CFI(fixup_put_user_skip_2)