Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.48 KB | None | 0 0
  1. Index: include/cpu.h
  2. ===================================================================
  3. RCS file: /cvsroot/src/sys/arch/vax/include/cpu.h,v
  4. retrieving revision 1.89
  5. diff -u -r1.89 cpu.h
  6. --- include/cpu.h 1 Jul 2010 19:50:12 -0000 1.89
  7. +++ include/cpu.h 12 Nov 2010 19:35:34 -0000
  8. @@ -144,6 +144,7 @@
  9. long ci_ipimsgs; /* Sent IPI bits */
  10. struct trapframe *ci_ddb_regs; /* Used by DDB */
  11. SIMPLEQ_ENTRY(cpu_info) ci_next; /* next cpu_info */
  12. + uintptr_t ci_cas_addr; /* current address doing CAS in a RAS */
  13. #endif
  14. };
  15. #define CI_MASTERCPU 1 /* Set if master CPU */
  16. Index: include/trap.h
  17. ===================================================================
  18. RCS file: /cvsroot/src/sys/arch/vax/include/trap.h,v
  19. retrieving revision 1.22
  20. diff -u -r1.22 trap.h
  21. --- include/trap.h 16 Feb 2009 23:55:31 -0000 1.22
  22. +++ include/trap.h 12 Nov 2010 19:35:34 -0000
  23. @@ -73,6 +73,9 @@
  24. #define AFLT_FLTDIV 0x9 /* floating divide-by-zero */
  25. #define AFLT_FLTUND 0xa /* floating underflow */
  26.  
  27. +/* Used by RAS to detect an interrupted CAS */
  28. +#define CASMAGIC 0xBEDABABE /* high end of S0 space */
  29. +
  30. /* Trap's coming from user mode */
  31. #define T_USER 0x100
  32.  
  33. Index: vax/genassym.cf
  34. ===================================================================
  35. RCS file: /cvsroot/src/sys/arch/vax/vax/genassym.cf,v
  36. retrieving revision 1.46
  37. diff -u -r1.46 genassym.cf
  38. --- vax/genassym.cf 12 May 2010 14:43:48 -0000 1.46
  39. +++ vax/genassym.cf 12 Nov 2010 19:35:34 -0000
  40. @@ -99,6 +99,7 @@
  41. define CI_MTX_COUNT offsetof(struct cpu_info, ci_mtx_count)
  42. define CI_MTX_OLDSPL offsetof(struct cpu_info, ci_mtx_oldspl)
  43. define CI_SOFTLWPS offsetof(struct cpu_info, ci_softlwps)
  44. +define CI_CAS_ADDR offsetof(struct cpu_info, ci_cas_addr)
  45.  
  46. # mtpr register numbers
  47. define PR_KSP PR_KSP
  48. @@ -135,6 +136,8 @@
  49. define T_ASTFLT T_ASTFLT
  50. define T_KDBTRAP T_KDBTRAP
  51.  
  52. +define CASMAGIC CASMAGIC
  53. +
  54. define USPACE USPACE
  55. define TRAPFRAMELEN sizeof(struct trapframe)
  56. define CALLSFRAMELEN sizeof(struct callsframe)
  57. Index: vax/lock_stubs.S
  58. ===================================================================
  59. RCS file: /cvsroot/src/sys/arch/vax/vax/lock_stubs.S,v
  60. retrieving revision 1.16
  61. diff -u -r1.16 lock_stubs.S
  62. --- vax/lock_stubs.S 1 Jul 2010 19:50:12 -0000 1.16
  63. +++ vax/lock_stubs.S 12 Nov 2010 19:35:34 -0000
  64. @@ -61,6 +61,9 @@
  65. #endif
  66. clrl %r2 /* set old value (zero) */
  67. mfpr $PR_SSP, %r3 /* set new value (curlwp) */
  68. +#ifndef MULTIPROCESSOR
  69. + addl3 $CI_CAS_ADDR, L_CPU(%r3), %r4 /* r4 == &curcpu()->ci_cas_addr */
  70. +#endif
  71. bsbw _do_cas+2 /* do the compare-and-swap */
  72. tstl %r0 /* is the old value what we wanted? */
  73. beql 2f /* yep, just branch to the return */
  74. @@ -78,6 +81,9 @@
  75. #endif
  76. mfpr $PR_SSP, %r2 /* get curlwp (old) */
  77. clrl %r3 /* get zero (new) */
  78. +#ifndef MULTIPROCESSOR
  79. + addl3 $CI_CAS_ADDR, L_CPU(%r2), %r4 /* r4 == &curcpu()->ci_cas_addr */
  80. +#endif
  81. bsbw _do_cas+2 /* do the compare-and-swap */
  82. cmpl %r0,%r2 /* return == old? */
  83. beql 2f /* yes, branch to return */
  84. @@ -160,6 +166,10 @@
  85. /* write active or pending? */
  86. bneq 3f /* yep, go slow */
  87. addl3 $RW_READ_INCR, %r2, %r3 /* incr. reader count (new) */
  88. +#ifndef MULTIPROCESSOR
  89. + mfpr $PR_SSP, %r4
  90. + addl3 $CI_CAS_ADDR, L_CPU(%r4), %r4 /* r4 == &curcpu()->ci_cas_addr */
  91. +#endif
  92. 1: bsbw _do_cas+2 /* do the compare-and-swap */
  93. cmpl %r0, %r2 /* did it succeed? */
  94. bneq 3f /* nope, go slow */
  95. @@ -185,6 +195,10 @@
  96. blbs %r2, 3f /* RW_HAS_WAITERS mbz */
  97. subl3 $RW_READ_INCR, %r2, %r3 /* decr. reader count (new) */
  98. blss 3f /* if less then 0, go slow */
  99. +#ifndef MULTIPROCESSOR
  100. + mfpr $PR_SSP, %r4 /* get curlwp */
  101. + addl3 $CI_CAS_ADDR, L_CPU(%r4), %r4 /* r4 == &curcpu()->ci_cas_addr */
  102. +#endif
  103. 1: bsbw _do_cas+2 /* do the compare-and-swap */
  104. cmpl %r0, %r2 /* did it succeed? */
  105. bneq 3f /* nope, go slow */
  106. @@ -211,6 +225,10 @@
  107. /* write active or pending? */
  108. bneq 2f /* yes, return failure */
  109. addl3 $RW_READ_INCR, %r2, %r3 /* incr reader count (new) */
  110. +#ifndef MULTIPROCESSOR
  111. + mfpr $PR_SSP, %r4
  112. + addl3 $CI_CAS_ADDR, L_CPU(%r4), %r4 /* r4 == &curcpu()->ci_cas_addr */
  113. +#endif
  114. 1: bsbw _do_cas+2 /* do the compare-and-swap */
  115. cmpl %r0, %r2 /* did it succeed? */
  116. bneq 2f /* no, we failed. */
  117. @@ -231,6 +249,10 @@
  118. ENTRY(_atomic_cas_32, 0)
  119. movq 4(%ap), %r1 /* cache ptr, old */
  120. movl 12(%ap), %r3 /* cache new */
  121. +#ifndef MULTIPROCESSOR
  122. + mfpr $PR_SSP, %r4
  123. + addl3 $CI_CAS_ADDR, L_CPU(%r4), %r4 /* r4 == &curcpu()->ci_cas_addr */
  124. +#endif
  125. bsbw _do_cas+2 /* do it */
  126. ret
  127.  
  128. @@ -257,15 +279,27 @@
  129. 4:
  130. rsb /* return */
  131. #else
  132. - mfpr $PR_IPL, %r5 /* save IPL */
  133. - mtpr $IPL_SCHED, $PR_IPL /* block interrupts */
  134. - movl (%r1), %r0 /* get current value */
  135. - cmpl %r2, %r0 /* does it equal old value? */
  136. - bneq 1f /* no, don't update */
  137. - movl %r3, (%r1) /* yes, update */
  138. -1: mtpr %r5, $PR_IPL /* drop/restore IPL */
  139. - rsb /* return */
  140. -#endif
  141. +/*
  142. + * entry:
  143. + * r1 = address to be CAS'ed
  144. + * r2 = old value
  145. + * r3 = new value
  146. + * r4 = global cell to hold CAS address (common to all callers)
  147. + * e.g. address of curcpu()->ci_cas_addr
  148. + * exit:
  149. + * r0 = old value
  150. + */
  151. +JSBENTRY(cas32_ras_start)
  152. + movl %r1, (%r4)
  153. + movl *(%r4), %r0
  154. + cmpl %r2, %r0
  155. + bneq 1f
  156. + movl %r3, *(%r4)
  157. +JSBENTRY(cas32_ras_end)
  158. +1:
  159. + movl $CASMAGIC, *(%r4)
  160. + rsb
  161. +#endif /* !MULTIPROCESSOR */
  162. STRONG_ALIAS(atomic_cas_ptr,_atomic_cas_32)
  163. STRONG_ALIAS(_atomic_cas_ptr,_atomic_cas_32)
  164. STRONG_ALIAS(atomic_cas_uint,_atomic_cas_32)
  165. Index: vax/trap.c
  166. ===================================================================
  167. RCS file: /cvsroot/src/sys/arch/vax/vax/trap.c,v
  168. retrieving revision 1.124
  169. diff -u -r1.124 trap.c
  170. --- vax/trap.c 23 Apr 2010 19:18:10 -0000 1.124
  171. +++ vax/trap.c 12 Nov 2010 19:35:34 -0000
  172. @@ -179,6 +179,22 @@
  173. }
  174.  
  175. case T_PTELEN:
  176. +#ifndef MULTIPROCESSOR
  177. + /*
  178. + * If we referred to an address beyond the end of the system
  179. + * page table, it may be due to a failed CAS
  180. + * restartable-atomic-sequence. If it is, restart it at the
  181. + * beginning and restart.
  182. + */
  183. + extern const uint8_t cas32_ras_start[], cas32_ras_end[];
  184. + if (frame->code == CASMAGIC
  185. + && frame->pc >= (uintptr_t) cas32_ras_start
  186. + && frame->pc < (uintptr_t) cas32_ras_end) {
  187. + frame->pc = (uintptr_t) cas32_ras_start;
  188. + trapsig = false;
  189. + break;
  190. + }
  191. +#endif
  192. case T_ACCFLT:
  193. #ifdef TRAPDEBUG
  194. if(faultdebug)printf("trap accflt type %lx, code %lx, pc %lx, psl %lx\n",
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement