ptrace.c 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318
  1. /*
  2. * Kernel support for the ptrace() and syscall tracing interfaces.
  3. *
  4. * Copyright (C) 1999-2005 Hewlett-Packard Co
  5. * David Mosberger-Tang <davidm@hpl.hp.com>
  6. * Copyright (C) 2006 Intel Co
  7. * 2006-08-12 - IA64 Native Utrace implementation support added by
  8. * Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
  9. *
  10. * Derived from the x86 and Alpha versions.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/sched.h>
  14. #include <linux/slab.h>
  15. #include <linux/mm.h>
  16. #include <linux/errno.h>
  17. #include <linux/ptrace.h>
  18. #include <linux/smp_lock.h>
  19. #include <linux/user.h>
  20. #include <linux/security.h>
  21. #include <linux/audit.h>
  22. #include <linux/signal.h>
  23. #include <linux/regset.h>
  24. #include <linux/elf.h>
  25. #include <asm/pgtable.h>
  26. #include <asm/processor.h>
  27. #include <asm/ptrace_offsets.h>
  28. #include <asm/rse.h>
  29. #include <asm/system.h>
  30. #include <asm/uaccess.h>
  31. #include <asm/unwind.h>
  32. #ifdef CONFIG_PERFMON
  33. #include <asm/perfmon.h>
  34. #endif
  35. #include "entry.h"
  36. /*
  37. * Bits in the PSR that we allow ptrace() to change:
  38. * be, up, ac, mfl, mfh (the user mask; five bits total)
  39. * db (debug breakpoint fault; one bit)
  40. * id (instruction debug fault disable; one bit)
  41. * dd (data debug fault disable; one bit)
  42. * ri (restart instruction; two bits)
  43. * is (instruction set; one bit)
  44. */
  45. #define IPSR_MASK (IA64_PSR_UM | IA64_PSR_DB | IA64_PSR_IS \
  46. | IA64_PSR_ID | IA64_PSR_DD | IA64_PSR_RI)
  47. #define MASK(nbits) ((1UL << (nbits)) - 1) /* mask with NBITS bits set */
  48. #define PFM_MASK MASK(38)
  49. #define PTRACE_DEBUG 0
  50. #if PTRACE_DEBUG
  51. # define dprintk(format...) printk(format)
  52. # define inline
  53. #else
  54. # define dprintk(format...)
  55. #endif
  56. /* Return TRUE if PT was created due to kernel-entry via a system-call. */
  57. static inline int
  58. in_syscall (struct pt_regs *pt)
  59. {
  60. return (long) pt->cr_ifs >= 0;
  61. }
  62. /*
  63. * Collect the NaT bits for r1-r31 from scratch_unat and return a NaT
  64. * bitset where bit i is set iff the NaT bit of register i is set.
  65. */
  66. unsigned long
  67. ia64_get_scratch_nat_bits (struct pt_regs *pt, unsigned long scratch_unat)
  68. {
  69. # define GET_BITS(first, last, unat) \
  70. ({ \
  71. unsigned long bit = ia64_unat_pos(&pt->r##first); \
  72. unsigned long nbits = (last - first + 1); \
  73. unsigned long mask = MASK(nbits) << first; \
  74. unsigned long dist; \
  75. if (bit < first) \
  76. dist = 64 + bit - first; \
  77. else \
  78. dist = bit - first; \
  79. ia64_rotr(unat, dist) & mask; \
  80. })
  81. unsigned long val;
  82. /*
  83. * Registers that are stored consecutively in struct pt_regs
  84. * can be handled in parallel. If the register order in
  85. * struct_pt_regs changes, this code MUST be updated.
  86. */
  87. val = GET_BITS( 1, 1, scratch_unat);
  88. val |= GET_BITS( 2, 3, scratch_unat);
  89. val |= GET_BITS(12, 13, scratch_unat);
  90. val |= GET_BITS(14, 14, scratch_unat);
  91. val |= GET_BITS(15, 15, scratch_unat);
  92. val |= GET_BITS( 8, 11, scratch_unat);
  93. val |= GET_BITS(16, 31, scratch_unat);
  94. return val;
  95. # undef GET_BITS
  96. }
  97. /*
  98. * Set the NaT bits for the scratch registers according to NAT and
  99. * return the resulting unat (assuming the scratch registers are
  100. * stored in PT).
  101. */
  102. unsigned long
  103. ia64_put_scratch_nat_bits (struct pt_regs *pt, unsigned long nat)
  104. {
  105. # define PUT_BITS(first, last, nat) \
  106. ({ \
  107. unsigned long bit = ia64_unat_pos(&pt->r##first); \
  108. unsigned long nbits = (last - first + 1); \
  109. unsigned long mask = MASK(nbits) << first; \
  110. long dist; \
  111. if (bit < first) \
  112. dist = 64 + bit - first; \
  113. else \
  114. dist = bit - first; \
  115. ia64_rotl(nat & mask, dist); \
  116. })
  117. unsigned long scratch_unat;
  118. /*
  119. * Registers that are stored consecutively in struct pt_regs
  120. * can be handled in parallel. If the register order in
  121. * struct_pt_regs changes, this code MUST be updated.
  122. */
  123. scratch_unat = PUT_BITS( 1, 1, nat);
  124. scratch_unat |= PUT_BITS( 2, 3, nat);
  125. scratch_unat |= PUT_BITS(12, 13, nat);
  126. scratch_unat |= PUT_BITS(14, 14, nat);
  127. scratch_unat |= PUT_BITS(15, 15, nat);
  128. scratch_unat |= PUT_BITS( 8, 11, nat);
  129. scratch_unat |= PUT_BITS(16, 31, nat);
  130. return scratch_unat;
  131. # undef PUT_BITS
  132. }
  133. #define IA64_MLX_TEMPLATE 0x2
  134. #define IA64_MOVL_OPCODE 6
  135. void
  136. ia64_increment_ip (struct pt_regs *regs)
  137. {
  138. unsigned long w0, ri = ia64_psr(regs)->ri + 1;
  139. if (ri > 2) {
  140. ri = 0;
  141. regs->cr_iip += 16;
  142. } else if (ri == 2) {
  143. get_user(w0, (char __user *) regs->cr_iip + 0);
  144. if (((w0 >> 1) & 0xf) == IA64_MLX_TEMPLATE) {
  145. /*
  146. * rfi'ing to slot 2 of an MLX bundle causes
  147. * an illegal operation fault. We don't want
  148. * that to happen...
  149. */
  150. ri = 0;
  151. regs->cr_iip += 16;
  152. }
  153. }
  154. ia64_psr(regs)->ri = ri;
  155. }
  156. void
  157. ia64_decrement_ip (struct pt_regs *regs)
  158. {
  159. unsigned long w0, ri = ia64_psr(regs)->ri - 1;
  160. if (ia64_psr(regs)->ri == 0) {
  161. regs->cr_iip -= 16;
  162. ri = 2;
  163. get_user(w0, (char __user *) regs->cr_iip + 0);
  164. if (((w0 >> 1) & 0xf) == IA64_MLX_TEMPLATE) {
  165. /*
  166. * rfi'ing to slot 2 of an MLX bundle causes
  167. * an illegal operation fault. We don't want
  168. * that to happen...
  169. */
  170. ri = 1;
  171. }
  172. }
  173. ia64_psr(regs)->ri = ri;
  174. }
  175. /*
  176. * This routine is used to read an rnat bits that are stored on the
  177. * kernel backing store. Since, in general, the alignment of the user
  178. * and kernel are different, this is not completely trivial. In
  179. * essence, we need to construct the user RNAT based on up to two
  180. * kernel RNAT values and/or the RNAT value saved in the child's
  181. * pt_regs.
  182. *
  183. * user rbs
  184. *
  185. * +--------+ <-- lowest address
  186. * | slot62 |
  187. * +--------+
  188. * | rnat | 0x....1f8
  189. * +--------+
  190. * | slot00 | \
  191. * +--------+ |
  192. * | slot01 | > child_regs->ar_rnat
  193. * +--------+ |
  194. * | slot02 | / kernel rbs
  195. * +--------+ +--------+
  196. * <- child_regs->ar_bspstore | slot61 | <-- krbs
  197. * +- - - - + +--------+
  198. * | slot62 |
  199. * +- - - - + +--------+
  200. * | rnat |
  201. * +- - - - + +--------+
  202. * vrnat | slot00 |
  203. * +- - - - + +--------+
  204. * = =
  205. * +--------+
  206. * | slot00 | \
  207. * +--------+ |
  208. * | slot01 | > child_stack->ar_rnat
  209. * +--------+ |
  210. * | slot02 | /
  211. * +--------+
  212. * <--- child_stack->ar_bspstore
  213. *
  214. * The way to think of this code is as follows: bit 0 in the user rnat
  215. * corresponds to some bit N (0 <= N <= 62) in one of the kernel rnat
  216. * value. The kernel rnat value holding this bit is stored in
  217. * variable rnat0. rnat1 is loaded with the kernel rnat value that
  218. * form the upper bits of the user rnat value.
  219. *
  220. * Boundary cases:
  221. *
  222. * o when reading the rnat "below" the first rnat slot on the kernel
  223. * backing store, rnat0/rnat1 are set to 0 and the low order bits are
  224. * merged in from pt->ar_rnat.
  225. *
  226. * o when reading the rnat "above" the last rnat slot on the kernel
  227. * backing store, rnat0/rnat1 gets its value from sw->ar_rnat.
  228. */
  229. static unsigned long
  230. get_rnat (struct task_struct *task, struct switch_stack *sw,
  231. unsigned long *krbs, unsigned long *urnat_addr,
  232. unsigned long *urbs_end)
  233. {
  234. unsigned long rnat0 = 0, rnat1 = 0, urnat = 0, *slot0_kaddr;
  235. unsigned long umask = 0, mask, m;
  236. unsigned long *kbsp, *ubspstore, *rnat0_kaddr, *rnat1_kaddr, shift;
  237. long num_regs, nbits;
  238. struct pt_regs *pt;
  239. pt = task_pt_regs(task);
  240. kbsp = (unsigned long *) sw->ar_bspstore;
  241. ubspstore = (unsigned long *) pt->ar_bspstore;
  242. if (urbs_end < urnat_addr)
  243. nbits = ia64_rse_num_regs(urnat_addr - 63, urbs_end);
  244. else
  245. nbits = 63;
  246. mask = MASK(nbits);
  247. /*
  248. * First, figure out which bit number slot 0 in user-land maps
  249. * to in the kernel rnat. Do this by figuring out how many
  250. * register slots we're beyond the user's backingstore and
  251. * then computing the equivalent address in kernel space.
  252. */
  253. num_regs = ia64_rse_num_regs(ubspstore, urnat_addr + 1);
  254. slot0_kaddr = ia64_rse_skip_regs(krbs, num_regs);
  255. shift = ia64_rse_slot_num(slot0_kaddr);
  256. rnat1_kaddr = ia64_rse_rnat_addr(slot0_kaddr);
  257. rnat0_kaddr = rnat1_kaddr - 64;
  258. if (ubspstore + 63 > urnat_addr) {
  259. /* some bits need to be merged in from pt->ar_rnat */
  260. umask = MASK(ia64_rse_slot_num(ubspstore)) & mask;
  261. urnat = (pt->ar_rnat & umask);
  262. mask &= ~umask;
  263. if (!mask)
  264. return urnat;
  265. }
  266. m = mask << shift;
  267. if (rnat0_kaddr >= kbsp)
  268. rnat0 = sw->ar_rnat;
  269. else if (rnat0_kaddr > krbs)
  270. rnat0 = *rnat0_kaddr;
  271. urnat |= (rnat0 & m) >> shift;
  272. m = mask >> (63 - shift);
  273. if (rnat1_kaddr >= kbsp)
  274. rnat1 = sw->ar_rnat;
  275. else if (rnat1_kaddr > krbs)
  276. rnat1 = *rnat1_kaddr;
  277. urnat |= (rnat1 & m) << (63 - shift);
  278. return urnat;
  279. }
  280. /*
  281. * The reverse of get_rnat.
  282. */
  283. static void
  284. put_rnat (struct task_struct *task, struct switch_stack *sw,
  285. unsigned long *krbs, unsigned long *urnat_addr, unsigned long urnat,
  286. unsigned long *urbs_end)
  287. {
  288. unsigned long rnat0 = 0, rnat1 = 0, *slot0_kaddr, umask = 0, mask, m;
  289. unsigned long *kbsp, *ubspstore, *rnat0_kaddr, *rnat1_kaddr, shift;
  290. long num_regs, nbits;
  291. struct pt_regs *pt;
  292. unsigned long cfm, *urbs_kargs;
  293. pt = task_pt_regs(task);
  294. kbsp = (unsigned long *) sw->ar_bspstore;
  295. ubspstore = (unsigned long *) pt->ar_bspstore;
  296. urbs_kargs = urbs_end;
  297. if (in_syscall(pt)) {
  298. /*
  299. * If entered via syscall, don't allow user to set rnat bits
  300. * for syscall args.
  301. */
  302. cfm = pt->cr_ifs;
  303. urbs_kargs = ia64_rse_skip_regs(urbs_end, -(cfm & 0x7f));
  304. }
  305. if (urbs_kargs >= urnat_addr)
  306. nbits = 63;
  307. else {
  308. if ((urnat_addr - 63) >= urbs_kargs)
  309. return;
  310. nbits = ia64_rse_num_regs(urnat_addr - 63, urbs_kargs);
  311. }
  312. mask = MASK(nbits);
  313. /*
  314. * First, figure out which bit number slot 0 in user-land maps
  315. * to in the kernel rnat. Do this by figuring out how many
  316. * register slots we're beyond the user's backingstore and
  317. * then computing the equivalent address in kernel space.
  318. */
  319. num_regs = ia64_rse_num_regs(ubspstore, urnat_addr + 1);
  320. slot0_kaddr = ia64_rse_skip_regs(krbs, num_regs);
  321. shift = ia64_rse_slot_num(slot0_kaddr);
  322. rnat1_kaddr = ia64_rse_rnat_addr(slot0_kaddr);
  323. rnat0_kaddr = rnat1_kaddr - 64;
  324. if (ubspstore + 63 > urnat_addr) {
  325. /* some bits need to be place in pt->ar_rnat: */
  326. umask = MASK(ia64_rse_slot_num(ubspstore)) & mask;
  327. pt->ar_rnat = (pt->ar_rnat & ~umask) | (urnat & umask);
  328. mask &= ~umask;
  329. if (!mask)
  330. return;
  331. }
  332. /*
  333. * Note: Section 11.1 of the EAS guarantees that bit 63 of an
  334. * rnat slot is ignored. so we don't have to clear it here.
  335. */
  336. rnat0 = (urnat << shift);
  337. m = mask << shift;
  338. if (rnat0_kaddr >= kbsp)
  339. sw->ar_rnat = (sw->ar_rnat & ~m) | (rnat0 & m);
  340. else if (rnat0_kaddr > krbs)
  341. *rnat0_kaddr = ((*rnat0_kaddr & ~m) | (rnat0 & m));
  342. rnat1 = (urnat >> (63 - shift));
  343. m = mask >> (63 - shift);
  344. if (rnat1_kaddr >= kbsp)
  345. sw->ar_rnat = (sw->ar_rnat & ~m) | (rnat1 & m);
  346. else if (rnat1_kaddr > krbs)
  347. *rnat1_kaddr = ((*rnat1_kaddr & ~m) | (rnat1 & m));
  348. }
  349. static inline int
  350. on_kernel_rbs (unsigned long addr, unsigned long bspstore,
  351. unsigned long urbs_end)
  352. {
  353. unsigned long *rnat_addr = ia64_rse_rnat_addr((unsigned long *)
  354. urbs_end);
  355. return (addr >= bspstore && addr <= (unsigned long) rnat_addr);
  356. }
  357. /*
  358. * Read a word from the user-level backing store of task CHILD. ADDR
  359. * is the user-level address to read the word from, VAL a pointer to
  360. * the return value, and USER_BSP gives the end of the user-level
  361. * backing store (i.e., it's the address that would be in ar.bsp after
  362. * the user executed a "cover" instruction).
  363. *
  364. * This routine takes care of accessing the kernel register backing
  365. * store for those registers that got spilled there. It also takes
  366. * care of calculating the appropriate RNaT collection words.
  367. */
  368. long
  369. ia64_peek (struct task_struct *child, struct switch_stack *child_stack,
  370. unsigned long user_rbs_end, unsigned long addr, long *val)
  371. {
  372. unsigned long *bspstore, *krbs, regnum, *laddr, *urbs_end, *rnat_addr;
  373. struct pt_regs *child_regs;
  374. size_t copied;
  375. long ret;
  376. urbs_end = (long *) user_rbs_end;
  377. laddr = (unsigned long *) addr;
  378. child_regs = task_pt_regs(child);
  379. bspstore = (unsigned long *) child_regs->ar_bspstore;
  380. krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
  381. if (on_kernel_rbs(addr, (unsigned long) bspstore,
  382. (unsigned long) urbs_end))
  383. {
  384. /*
  385. * Attempt to read the RBS in an area that's actually
  386. * on the kernel RBS => read the corresponding bits in
  387. * the kernel RBS.
  388. */
  389. rnat_addr = ia64_rse_rnat_addr(laddr);
  390. ret = get_rnat(child, child_stack, krbs, rnat_addr, urbs_end);
  391. if (laddr == rnat_addr) {
  392. /* return NaT collection word itself */
  393. *val = ret;
  394. return 0;
  395. }
  396. if (((1UL << ia64_rse_slot_num(laddr)) & ret) != 0) {
  397. /*
  398. * It is implementation dependent whether the
  399. * data portion of a NaT value gets saved on a
  400. * st8.spill or RSE spill (e.g., see EAS 2.6,
  401. * 4.4.4.6 Register Spill and Fill). To get
  402. * consistent behavior across all possible
  403. * IA-64 implementations, we return zero in
  404. * this case.
  405. */
  406. *val = 0;
  407. return 0;
  408. }
  409. if (laddr < urbs_end) {
  410. /*
  411. * The desired word is on the kernel RBS and
  412. * is not a NaT.
  413. */
  414. regnum = ia64_rse_num_regs(bspstore, laddr);
  415. *val = *ia64_rse_skip_regs(krbs, regnum);
  416. return 0;
  417. }
  418. }
  419. copied = access_process_vm(child, addr, &ret, sizeof(ret), 0);
  420. if (copied != sizeof(ret))
  421. return -EIO;
  422. *val = ret;
  423. return 0;
  424. }
  425. long
  426. ia64_poke (struct task_struct *child, struct switch_stack *child_stack,
  427. unsigned long user_rbs_end, unsigned long addr, long val)
  428. {
  429. unsigned long *bspstore, *krbs, regnum, *laddr;
  430. unsigned long *urbs_end = (long *) user_rbs_end;
  431. struct pt_regs *child_regs;
  432. laddr = (unsigned long *) addr;
  433. child_regs = task_pt_regs(child);
  434. bspstore = (unsigned long *) child_regs->ar_bspstore;
  435. krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
  436. if (on_kernel_rbs(addr, (unsigned long) bspstore,
  437. (unsigned long) urbs_end))
  438. {
  439. /*
  440. * Attempt to write the RBS in an area that's actually
  441. * on the kernel RBS => write the corresponding bits
  442. * in the kernel RBS.
  443. */
  444. if (ia64_rse_is_rnat_slot(laddr))
  445. put_rnat(child, child_stack, krbs, laddr, val,
  446. urbs_end);
  447. else {
  448. if (laddr < urbs_end) {
  449. regnum = ia64_rse_num_regs(bspstore, laddr);
  450. *ia64_rse_skip_regs(krbs, regnum) = val;
  451. }
  452. }
  453. } else if (access_process_vm(child, addr, &val, sizeof(val), 1)
  454. != sizeof(val))
  455. return -EIO;
  456. return 0;
  457. }
  458. /*
  459. * Calculate the address of the end of the user-level register backing
  460. * store. This is the address that would have been stored in ar.bsp
  461. * if the user had executed a "cover" instruction right before
  462. * entering the kernel. If CFMP is not NULL, it is used to return the
  463. * "current frame mask" that was active at the time the kernel was
  464. * entered.
  465. */
  466. unsigned long
  467. ia64_get_user_rbs_end (struct task_struct *child, struct pt_regs *pt,
  468. unsigned long *cfmp)
  469. {
  470. unsigned long *krbs, *bspstore, cfm = pt->cr_ifs;
  471. long ndirty;
  472. krbs = (unsigned long *) child + IA64_RBS_OFFSET/8;
  473. bspstore = (unsigned long *) pt->ar_bspstore;
  474. ndirty = ia64_rse_num_regs(krbs, krbs + (pt->loadrs >> 19));
  475. if (in_syscall(pt))
  476. ndirty += (cfm & 0x7f);
  477. else
  478. cfm &= ~(1UL << 63); /* clear valid bit */
  479. if (cfmp)
  480. *cfmp = cfm;
  481. return (unsigned long) ia64_rse_skip_regs(bspstore, ndirty);
  482. }
  483. /*
  484. * Synchronize (i.e, write) the RSE backing store living in kernel
  485. * space to the VM of the CHILD task. SW and PT are the pointers to
  486. * the switch_stack and pt_regs structures, respectively.
  487. * USER_RBS_END is the user-level address at which the backing store
  488. * ends.
  489. */
  490. long
  491. ia64_sync_user_rbs (struct task_struct *child, struct switch_stack *sw,
  492. unsigned long user_rbs_start, unsigned long user_rbs_end)
  493. {
  494. unsigned long addr, val;
  495. long ret;
  496. /* now copy word for word from kernel rbs to user rbs: */
  497. for (addr = user_rbs_start; addr < user_rbs_end; addr += 8) {
  498. ret = ia64_peek(child, sw, user_rbs_end, addr, &val);
  499. if (ret < 0)
  500. return ret;
  501. if (access_process_vm(child, addr, &val, sizeof(val), 1)
  502. != sizeof(val))
  503. return -EIO;
  504. }
  505. return 0;
  506. }
  507. static long
  508. ia64_sync_kernel_rbs (struct task_struct *child, struct switch_stack *sw,
  509. unsigned long user_rbs_start, unsigned long user_rbs_end)
  510. {
  511. unsigned long addr, val;
  512. long ret;
  513. /* now copy word for word from user rbs to kernel rbs: */
  514. for (addr = user_rbs_start; addr < user_rbs_end; addr += 8) {
  515. if (access_process_vm(child, addr, &val, sizeof(val), 0)
  516. != sizeof(val))
  517. return -EIO;
  518. ret = ia64_poke(child, sw, user_rbs_end, addr, val);
  519. if (ret < 0)
  520. return ret;
  521. }
  522. return 0;
  523. }
  524. typedef long (*syncfunc_t)(struct task_struct *, struct switch_stack *,
  525. unsigned long, unsigned long);
  526. static void do_sync_rbs(struct unw_frame_info *info, void *arg)
  527. {
  528. struct pt_regs *pt;
  529. unsigned long urbs_end;
  530. syncfunc_t fn = arg;
  531. if (unw_unwind_to_user(info) < 0)
  532. return;
  533. pt = task_pt_regs(info->task);
  534. urbs_end = ia64_get_user_rbs_end(info->task, pt, NULL);
  535. fn(info->task, info->sw, pt->ar_bspstore, urbs_end);
  536. }
  537. /*
  538. * when a thread is stopped (ptraced), debugger might change thread's user
  539. * stack (change memory directly), and we must avoid the RSE stored in kernel
  540. * to override user stack (user space's RSE is newer than kernel's in the
  541. * case). To workaround the issue, we copy kernel RSE to user RSE before the
  542. * task is stopped, so user RSE has updated data. we then copy user RSE to
  543. * kernel after the task is resummed from traced stop and kernel will use the
  544. * newer RSE to return to user. TIF_RESTORE_RSE is the flag to indicate we need
  545. * synchronize user RSE to kernel.
  546. */
  547. void ia64_ptrace_stop(void)
  548. {
  549. if (test_and_set_tsk_thread_flag(current, TIF_RESTORE_RSE))
  550. return;
  551. tsk_set_notify_resume(current);
  552. unw_init_running(do_sync_rbs, ia64_sync_user_rbs);
  553. }
  554. /*
  555. * This is called to read back the register backing store.
  556. */
  557. void ia64_sync_krbs(void)
  558. {
  559. clear_tsk_thread_flag(current, TIF_RESTORE_RSE);
  560. tsk_clear_notify_resume(current);
  561. unw_init_running(do_sync_rbs, ia64_sync_kernel_rbs);
  562. }
  563. /*
  564. * After PTRACE_ATTACH, a thread's register backing store area in user
  565. * space is assumed to contain correct data whenever the thread is
  566. * stopped. arch_ptrace_stop takes care of this on tracing stops.
  567. * But if the child was already stopped for job control when we attach
  568. * to it, then it might not ever get into ptrace_stop by the time we
  569. * want to examine the user memory containing the RBS.
  570. */
  571. void
  572. ptrace_attach_sync_user_rbs (struct task_struct *child)
  573. {
  574. int stopped = 0;
  575. struct unw_frame_info info;
  576. /*
  577. * If the child is in TASK_STOPPED, we need to change that to
  578. * TASK_TRACED momentarily while we operate on it. This ensures
  579. * that the child won't be woken up and return to user mode while
  580. * we are doing the sync. (It can only be woken up for SIGKILL.)
  581. */
  582. read_lock(&tasklist_lock);
  583. if (child->signal) {
  584. spin_lock_irq(&child->sighand->siglock);
  585. if (child->state == TASK_STOPPED &&
  586. !test_and_set_tsk_thread_flag(child, TIF_RESTORE_RSE)) {
  587. tsk_set_notify_resume(child);
  588. child->state = TASK_TRACED;
  589. stopped = 1;
  590. }
  591. spin_unlock_irq(&child->sighand->siglock);
  592. }
  593. read_unlock(&tasklist_lock);
  594. if (!stopped)
  595. return;
  596. unw_init_from_blocked_task(&info, child);
  597. do_sync_rbs(&info, ia64_sync_user_rbs);
  598. /*
  599. * Now move the child back into TASK_STOPPED if it should be in a
  600. * job control stop, so that SIGCONT can be used to wake it up.
  601. */
  602. read_lock(&tasklist_lock);
  603. if (child->signal) {
  604. spin_lock_irq(&child->sighand->siglock);
  605. if (child->state == TASK_TRACED &&
  606. (child->signal->flags & SIGNAL_STOP_STOPPED)) {
  607. child->state = TASK_STOPPED;
  608. }
  609. spin_unlock_irq(&child->sighand->siglock);
  610. }
  611. read_unlock(&tasklist_lock);
  612. }
  613. static inline int
  614. thread_matches (struct task_struct *thread, unsigned long addr)
  615. {
  616. unsigned long thread_rbs_end;
  617. struct pt_regs *thread_regs;
  618. if (ptrace_check_attach(thread, 0) < 0)
  619. /*
  620. * If the thread is not in an attachable state, we'll
  621. * ignore it. The net effect is that if ADDR happens
  622. * to overlap with the portion of the thread's
  623. * register backing store that is currently residing
  624. * on the thread's kernel stack, then ptrace() may end
  625. * up accessing a stale value. But if the thread
  626. * isn't stopped, that's a problem anyhow, so we're
  627. * doing as well as we can...
  628. */
  629. return 0;
  630. thread_regs = task_pt_regs(thread);
  631. thread_rbs_end = ia64_get_user_rbs_end(thread, thread_regs, NULL);
  632. if (!on_kernel_rbs(addr, thread_regs->ar_bspstore, thread_rbs_end))
  633. return 0;
  634. return 1; /* looks like we've got a winner */
  635. }
  636. /*
  637. * Write f32-f127 back to task->thread.fph if it has been modified.
  638. */
  639. inline void
  640. ia64_flush_fph (struct task_struct *task)
  641. {
  642. struct ia64_psr *psr = ia64_psr(task_pt_regs(task));
  643. /*
  644. * Prevent migrating this task while
  645. * we're fiddling with the FPU state
  646. */
  647. preempt_disable();
  648. if (ia64_is_local_fpu_owner(task) && psr->mfh) {
  649. psr->mfh = 0;
  650. task->thread.flags |= IA64_THREAD_FPH_VALID;
  651. ia64_save_fpu(&task->thread.fph[0]);
  652. }
  653. preempt_enable();
  654. }
  655. /*
  656. * Sync the fph state of the task so that it can be manipulated
  657. * through thread.fph. If necessary, f32-f127 are written back to
  658. * thread.fph or, if the fph state hasn't been used before, thread.fph
  659. * is cleared to zeroes. Also, access to f32-f127 is disabled to
  660. * ensure that the task picks up the state from thread.fph when it
  661. * executes again.
  662. */
  663. void
  664. ia64_sync_fph (struct task_struct *task)
  665. {
  666. struct ia64_psr *psr = ia64_psr(task_pt_regs(task));
  667. ia64_flush_fph(task);
  668. if (!(task->thread.flags & IA64_THREAD_FPH_VALID)) {
  669. task->thread.flags |= IA64_THREAD_FPH_VALID;
  670. memset(&task->thread.fph, 0, sizeof(task->thread.fph));
  671. }
  672. ia64_drop_fpu(task);
  673. psr->dfh = 1;
  674. }
  675. static int
  676. access_fr (struct unw_frame_info *info, int regnum, int hi,
  677. unsigned long *data, int write_access)
  678. {
  679. struct ia64_fpreg fpval;
  680. int ret;
  681. ret = unw_get_fr(info, regnum, &fpval);
  682. if (ret < 0)
  683. return ret;
  684. if (write_access) {
  685. fpval.u.bits[hi] = *data;
  686. ret = unw_set_fr(info, regnum, fpval);
  687. } else
  688. *data = fpval.u.bits[hi];
  689. return ret;
  690. }
  691. /*
  692. * Change the machine-state of CHILD such that it will return via the normal
  693. * kernel exit-path, rather than the syscall-exit path.
  694. */
  695. static void
  696. convert_to_non_syscall (struct task_struct *child, struct pt_regs *pt,
  697. unsigned long cfm)
  698. {
  699. struct unw_frame_info info, prev_info;
  700. unsigned long ip, sp, pr;
  701. unw_init_from_blocked_task(&info, child);
  702. while (1) {
  703. prev_info = info;
  704. if (unw_unwind(&info) < 0)
  705. return;
  706. unw_get_sp(&info, &sp);
  707. if ((long)((unsigned long)child + IA64_STK_OFFSET - sp)
  708. < IA64_PT_REGS_SIZE) {
  709. dprintk("ptrace.%s: ran off the top of the kernel "
  710. "stack\n", __func__);
  711. return;
  712. }
  713. if (unw_get_pr (&prev_info, &pr) < 0) {
  714. unw_get_rp(&prev_info, &ip);
  715. dprintk("ptrace.%s: failed to read "
  716. "predicate register (ip=0x%lx)\n",
  717. __func__, ip);
  718. return;
  719. }
  720. if (unw_is_intr_frame(&info)
  721. && (pr & (1UL << PRED_USER_STACK)))
  722. break;
  723. }
  724. /*
  725. * Note: at the time of this call, the target task is blocked
  726. * in notify_resume_user() and by clearling PRED_LEAVE_SYSCALL
  727. * (aka, "pLvSys") we redirect execution from
  728. * .work_pending_syscall_end to .work_processed_kernel.
  729. */
  730. unw_get_pr(&prev_info, &pr);
  731. pr &= ~((1UL << PRED_SYSCALL) | (1UL << PRED_LEAVE_SYSCALL));
  732. pr |= (1UL << PRED_NON_SYSCALL);
  733. unw_set_pr(&prev_info, pr);
  734. pt->cr_ifs = (1UL << 63) | cfm;
  735. /*
  736. * Clear the memory that is NOT written on syscall-entry to
  737. * ensure we do not leak kernel-state to user when execution
  738. * resumes.
  739. */
  740. pt->r2 = 0;
  741. pt->r3 = 0;
  742. pt->r14 = 0;
  743. memset(&pt->r16, 0, 16*8); /* clear r16-r31 */
  744. memset(&pt->f6, 0, 6*16); /* clear f6-f11 */
  745. pt->b7 = 0;
  746. pt->ar_ccv = 0;
  747. pt->ar_csd = 0;
  748. pt->ar_ssd = 0;
  749. }
  750. static int
  751. access_nat_bits (struct task_struct *child, struct pt_regs *pt,
  752. struct unw_frame_info *info,
  753. unsigned long *data, int write_access)
  754. {
  755. unsigned long regnum, nat_bits, scratch_unat, dummy = 0;
  756. char nat = 0;
  757. if (write_access) {
  758. nat_bits = *data;
  759. scratch_unat = ia64_put_scratch_nat_bits(pt, nat_bits);
  760. if (unw_set_ar(info, UNW_AR_UNAT, scratch_unat) < 0) {
  761. dprintk("ptrace: failed to set ar.unat\n");
  762. return -1;
  763. }
  764. for (regnum = 4; regnum <= 7; ++regnum) {
  765. unw_get_gr(info, regnum, &dummy, &nat);
  766. unw_set_gr(info, regnum, dummy,
  767. (nat_bits >> regnum) & 1);
  768. }
  769. } else {
  770. if (unw_get_ar(info, UNW_AR_UNAT, &scratch_unat) < 0) {
  771. dprintk("ptrace: failed to read ar.unat\n");
  772. return -1;
  773. }
  774. nat_bits = ia64_get_scratch_nat_bits(pt, scratch_unat);
  775. for (regnum = 4; regnum <= 7; ++regnum) {
  776. unw_get_gr(info, regnum, &dummy, &nat);
  777. nat_bits |= (nat != 0) << regnum;
  778. }
  779. *data = nat_bits;
  780. }
  781. return 0;
  782. }
  783. static int
  784. access_uarea (struct task_struct *child, unsigned long addr,
  785. unsigned long *data, int write_access)
  786. {
  787. unsigned long *ptr, regnum, urbs_end, cfm;
  788. struct switch_stack *sw;
  789. struct pt_regs *pt;
  790. # define pt_reg_addr(pt, reg) ((void *) \
  791. ((unsigned long) (pt) \
  792. + offsetof(struct pt_regs, reg)))
  793. pt = task_pt_regs(child);
  794. sw = (struct switch_stack *) (child->thread.ksp + 16);
  795. if ((addr & 0x7) != 0) {
  796. dprintk("ptrace: unaligned register address 0x%lx\n", addr);
  797. return -1;
  798. }
  799. if (addr < PT_F127 + 16) {
  800. /* accessing fph */
  801. if (write_access)
  802. ia64_sync_fph(child);
  803. else
  804. ia64_flush_fph(child);
  805. ptr = (unsigned long *)
  806. ((unsigned long) &child->thread.fph + addr);
  807. } else if ((addr >= PT_F10) && (addr < PT_F11 + 16)) {
  808. /* scratch registers untouched by kernel (saved in pt_regs) */
  809. ptr = pt_reg_addr(pt, f10) + (addr - PT_F10);
  810. } else if (addr >= PT_F12 && addr < PT_F15 + 16) {
  811. /*
  812. * Scratch registers untouched by kernel (saved in
  813. * switch_stack).
  814. */
  815. ptr = (unsigned long *) ((long) sw
  816. + (addr - PT_NAT_BITS - 32));
  817. } else if (addr < PT_AR_LC + 8) {
  818. /* preserved state: */
  819. struct unw_frame_info info;
  820. char nat = 0;
  821. int ret;
  822. unw_init_from_blocked_task(&info, child);
  823. if (unw_unwind_to_user(&info) < 0)
  824. return -1;
  825. switch (addr) {
  826. case PT_NAT_BITS:
  827. return access_nat_bits(child, pt, &info,
  828. data, write_access);
  829. case PT_R4: case PT_R5: case PT_R6: case PT_R7:
  830. if (write_access) {
  831. /* read NaT bit first: */
  832. unsigned long dummy;
  833. ret = unw_get_gr(&info, (addr - PT_R4)/8 + 4,
  834. &dummy, &nat);
  835. if (ret < 0)
  836. return ret;
  837. }
  838. return unw_access_gr(&info, (addr - PT_R4)/8 + 4, data,
  839. &nat, write_access);
  840. case PT_B1: case PT_B2: case PT_B3:
  841. case PT_B4: case PT_B5:
  842. return unw_access_br(&info, (addr - PT_B1)/8 + 1, data,
  843. write_access);
  844. case PT_AR_EC:
  845. return unw_access_ar(&info, UNW_AR_EC, data,
  846. write_access);
  847. case PT_AR_LC:
  848. return unw_access_ar(&info, UNW_AR_LC, data,
  849. write_access);
  850. default:
  851. if (addr >= PT_F2 && addr < PT_F5 + 16)
  852. return access_fr(&info, (addr - PT_F2)/16 + 2,
  853. (addr & 8) != 0, data,
  854. write_access);
  855. else if (addr >= PT_F16 && addr < PT_F31 + 16)
  856. return access_fr(&info,
  857. (addr - PT_F16)/16 + 16,
  858. (addr & 8) != 0,
  859. data, write_access);
  860. else {
  861. dprintk("ptrace: rejecting access to register "
  862. "address 0x%lx\n", addr);
  863. return -1;
  864. }
  865. }
  866. } else if (addr < PT_F9+16) {
  867. /* scratch state */
  868. switch (addr) {
  869. case PT_AR_BSP:
  870. /*
  871. * By convention, we use PT_AR_BSP to refer to
  872. * the end of the user-level backing store.
  873. * Use ia64_rse_skip_regs(PT_AR_BSP, -CFM.sof)
  874. * to get the real value of ar.bsp at the time
  875. * the kernel was entered.
  876. *
  877. * Furthermore, when changing the contents of
  878. * PT_AR_BSP (or PT_CFM) while the task is
  879. * blocked in a system call, convert the state
  880. * so that the non-system-call exit
  881. * path is used. This ensures that the proper
  882. * state will be picked up when resuming
  883. * execution. However, it *also* means that
  884. * once we write PT_AR_BSP/PT_CFM, it won't be
  885. * possible to modify the syscall arguments of
  886. * the pending system call any longer. This
  887. * shouldn't be an issue because modifying
  888. * PT_AR_BSP/PT_CFM generally implies that
  889. * we're either abandoning the pending system
  890. * call or that we defer it's re-execution
  891. * (e.g., due to GDB doing an inferior
  892. * function call).
  893. */
  894. urbs_end = ia64_get_user_rbs_end(child, pt, &cfm);
  895. if (write_access) {
  896. if (*data != urbs_end) {
  897. if (in_syscall(pt))
  898. convert_to_non_syscall(child,
  899. pt,
  900. cfm);
  901. /*
  902. * Simulate user-level write
  903. * of ar.bsp:
  904. */
  905. pt->loadrs = 0;
  906. pt->ar_bspstore = *data;
  907. }
  908. } else
  909. *data = urbs_end;
  910. return 0;
  911. case PT_CFM:
  912. urbs_end = ia64_get_user_rbs_end(child, pt, &cfm);
  913. if (write_access) {
  914. if (((cfm ^ *data) & PFM_MASK) != 0) {
  915. if (in_syscall(pt))
  916. convert_to_non_syscall(child,
  917. pt,
  918. cfm);
  919. pt->cr_ifs = ((pt->cr_ifs & ~PFM_MASK)
  920. | (*data & PFM_MASK));
  921. }
  922. } else
  923. *data = cfm;
  924. return 0;
  925. case PT_CR_IPSR:
  926. if (write_access) {
  927. unsigned long tmp = *data;
  928. /* psr.ri==3 is a reserved value: SDM 2:25 */
  929. if ((tmp & IA64_PSR_RI) == IA64_PSR_RI)
  930. tmp &= ~IA64_PSR_RI;
  931. pt->cr_ipsr = ((tmp & IPSR_MASK)
  932. | (pt->cr_ipsr & ~IPSR_MASK));
  933. } else
  934. *data = (pt->cr_ipsr & IPSR_MASK);
  935. return 0;
  936. case PT_AR_RSC:
  937. if (write_access)
  938. pt->ar_rsc = *data | (3 << 2); /* force PL3 */
  939. else
  940. *data = pt->ar_rsc;
  941. return 0;
  942. case PT_AR_RNAT:
  943. ptr = pt_reg_addr(pt, ar_rnat);
  944. break;
  945. case PT_R1:
  946. ptr = pt_reg_addr(pt, r1);
  947. break;
  948. case PT_R2: case PT_R3:
  949. ptr = pt_reg_addr(pt, r2) + (addr - PT_R2);
  950. break;
  951. case PT_R8: case PT_R9: case PT_R10: case PT_R11:
  952. ptr = pt_reg_addr(pt, r8) + (addr - PT_R8);
  953. break;
  954. case PT_R12: case PT_R13:
  955. ptr = pt_reg_addr(pt, r12) + (addr - PT_R12);
  956. break;
  957. case PT_R14:
  958. ptr = pt_reg_addr(pt, r14);
  959. break;
  960. case PT_R15:
  961. ptr = pt_reg_addr(pt, r15);
  962. break;
  963. case PT_R16: case PT_R17: case PT_R18: case PT_R19:
  964. case PT_R20: case PT_R21: case PT_R22: case PT_R23:
  965. case PT_R24: case PT_R25: case PT_R26: case PT_R27:
  966. case PT_R28: case PT_R29: case PT_R30: case PT_R31:
  967. ptr = pt_reg_addr(pt, r16) + (addr - PT_R16);
  968. break;
  969. case PT_B0:
  970. ptr = pt_reg_addr(pt, b0);
  971. break;
  972. case PT_B6:
  973. ptr = pt_reg_addr(pt, b6);
  974. break;
  975. case PT_B7:
  976. ptr = pt_reg_addr(pt, b7);
  977. break;
  978. case PT_F6: case PT_F6+8: case PT_F7: case PT_F7+8:
  979. case PT_F8: case PT_F8+8: case PT_F9: case PT_F9+8:
  980. ptr = pt_reg_addr(pt, f6) + (addr - PT_F6);
  981. break;
  982. case PT_AR_BSPSTORE:
  983. ptr = pt_reg_addr(pt, ar_bspstore);
  984. break;
  985. case PT_AR_UNAT:
  986. ptr = pt_reg_addr(pt, ar_unat);
  987. break;
  988. case PT_AR_PFS:
  989. ptr = pt_reg_addr(pt, ar_pfs);
  990. break;
  991. case PT_AR_CCV:
  992. ptr = pt_reg_addr(pt, ar_ccv);
  993. break;
  994. case PT_AR_FPSR:
  995. ptr = pt_reg_addr(pt, ar_fpsr);
  996. break;
  997. case PT_CR_IIP:
  998. ptr = pt_reg_addr(pt, cr_iip);
  999. break;
  1000. case PT_PR:
  1001. ptr = pt_reg_addr(pt, pr);
  1002. break;
  1003. /* scratch register */
  1004. default:
  1005. /* disallow accessing anything else... */
  1006. dprintk("ptrace: rejecting access to register "
  1007. "address 0x%lx\n", addr);
  1008. return -1;
  1009. }
  1010. } else if (addr <= PT_AR_SSD) {
  1011. ptr = pt_reg_addr(pt, ar_csd) + (addr - PT_AR_CSD);
  1012. } else {
  1013. /* access debug registers */
  1014. if (addr >= PT_IBR) {
  1015. regnum = (addr - PT_IBR) >> 3;
  1016. ptr = &child->thread.ibr[0];
  1017. } else {
  1018. regnum = (addr - PT_DBR) >> 3;
  1019. ptr = &child->thread.dbr[0];
  1020. }
  1021. if (regnum >= 8) {
  1022. dprintk("ptrace: rejecting access to register "
  1023. "address 0x%lx\n", addr);
  1024. return -1;
  1025. }
  1026. #ifdef CONFIG_PERFMON
  1027. /*
  1028. * Check if debug registers are used by perfmon. This
  1029. * test must be done once we know that we can do the
  1030. * operation, i.e. the arguments are all valid, but
  1031. * before we start modifying the state.
  1032. *
  1033. * Perfmon needs to keep a count of how many processes
  1034. * are trying to modify the debug registers for system
  1035. * wide monitoring sessions.
  1036. *
  1037. * We also include read access here, because they may
  1038. * cause the PMU-installed debug register state
  1039. * (dbr[], ibr[]) to be reset. The two arrays are also
  1040. * used by perfmon, but we do not use
  1041. * IA64_THREAD_DBG_VALID. The registers are restored
  1042. * by the PMU context switch code.
  1043. */
  1044. if (pfm_use_debug_registers(child)) return -1;
  1045. #endif
  1046. if (!(child->thread.flags & IA64_THREAD_DBG_VALID)) {
  1047. child->thread.flags |= IA64_THREAD_DBG_VALID;
  1048. memset(child->thread.dbr, 0,
  1049. sizeof(child->thread.dbr));
  1050. memset(child->thread.ibr, 0,
  1051. sizeof(child->thread.ibr));
  1052. }
  1053. ptr += regnum;
  1054. if ((regnum & 1) && write_access) {
  1055. /* don't let the user set kernel-level breakpoints: */
  1056. *ptr = *data & ~(7UL << 56);
  1057. return 0;
  1058. }
  1059. }
  1060. if (write_access)
  1061. *ptr = *data;
  1062. else
  1063. *data = *ptr;
  1064. return 0;
  1065. }
  1066. static long
  1067. ptrace_getregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
  1068. {
  1069. unsigned long psr, ec, lc, rnat, bsp, cfm, nat_bits, val;
  1070. struct unw_frame_info info;
  1071. struct ia64_fpreg fpval;
  1072. struct switch_stack *sw;
  1073. struct pt_regs *pt;
  1074. long ret, retval = 0;
  1075. char nat = 0;
  1076. int i;
  1077. if (!access_ok(VERIFY_WRITE, ppr, sizeof(struct pt_all_user_regs)))
  1078. return -EIO;
  1079. pt = task_pt_regs(child);
  1080. sw = (struct switch_stack *) (child->thread.ksp + 16);
  1081. unw_init_from_blocked_task(&info, child);
  1082. if (unw_unwind_to_user(&info) < 0) {
  1083. return -EIO;
  1084. }
  1085. if (((unsigned long) ppr & 0x7) != 0) {
  1086. dprintk("ptrace:unaligned register address %p\n", ppr);
  1087. return -EIO;
  1088. }
  1089. if (access_uarea(child, PT_CR_IPSR, &psr, 0) < 0
  1090. || access_uarea(child, PT_AR_EC, &ec, 0) < 0
  1091. || access_uarea(child, PT_AR_LC, &lc, 0) < 0
  1092. || access_uarea(child, PT_AR_RNAT, &rnat, 0) < 0
  1093. || access_uarea(child, PT_AR_BSP, &bsp, 0) < 0
  1094. || access_uarea(child, PT_CFM, &cfm, 0)
  1095. || access_uarea(child, PT_NAT_BITS, &nat_bits, 0))
  1096. return -EIO;
  1097. /* control regs */
  1098. retval |= __put_user(pt->cr_iip, &ppr->cr_iip);
  1099. retval |= __put_user(psr, &ppr->cr_ipsr);
  1100. /* app regs */
  1101. retval |= __put_user(pt->ar_pfs, &ppr->ar[PT_AUR_PFS]);
  1102. retval |= __put_user(pt->ar_rsc, &ppr->ar[PT_AUR_RSC]);
  1103. retval |= __put_user(pt->ar_bspstore, &ppr->ar[PT_AUR_BSPSTORE]);
  1104. retval |= __put_user(pt->ar_unat, &ppr->ar[PT_AUR_UNAT]);
  1105. retval |= __put_user(pt->ar_ccv, &ppr->ar[PT_AUR_CCV]);
  1106. retval |= __put_user(pt->ar_fpsr, &ppr->ar[PT_AUR_FPSR]);
  1107. retval |= __put_user(ec, &ppr->ar[PT_AUR_EC]);
  1108. retval |= __put_user(lc, &ppr->ar[PT_AUR_LC]);
  1109. retval |= __put_user(rnat, &ppr->ar[PT_AUR_RNAT]);
  1110. retval |= __put_user(bsp, &ppr->ar[PT_AUR_BSP]);
  1111. retval |= __put_user(cfm, &ppr->cfm);
  1112. /* gr1-gr3 */
  1113. retval |= __copy_to_user(&ppr->gr[1], &pt->r1, sizeof(long));
  1114. retval |= __copy_to_user(&ppr->gr[2], &pt->r2, sizeof(long) *2);
  1115. /* gr4-gr7 */
  1116. for (i = 4; i < 8; i++) {
  1117. if (unw_access_gr(&info, i, &val, &nat, 0) < 0)
  1118. return -EIO;
  1119. retval |= __put_user(val, &ppr->gr[i]);
  1120. }
  1121. /* gr8-gr11 */
  1122. retval |= __copy_to_user(&ppr->gr[8], &pt->r8, sizeof(long) * 4);
  1123. /* gr12-gr15 */
  1124. retval |= __copy_to_user(&ppr->gr[12], &pt->r12, sizeof(long) * 2);
  1125. retval |= __copy_to_user(&ppr->gr[14], &pt->r14, sizeof(long));
  1126. retval |= __copy_to_user(&ppr->gr[15], &pt->r15, sizeof(long));
  1127. /* gr16-gr31 */
  1128. retval |= __copy_to_user(&ppr->gr[16], &pt->r16, sizeof(long) * 16);
  1129. /* b0 */
  1130. retval |= __put_user(pt->b0, &ppr->br[0]);
  1131. /* b1-b5 */
  1132. for (i = 1; i < 6; i++) {
  1133. if (unw_access_br(&info, i, &val, 0) < 0)
  1134. return -EIO;
  1135. __put_user(val, &ppr->br[i]);
  1136. }
  1137. /* b6-b7 */
  1138. retval |= __put_user(pt->b6, &ppr->br[6]);
  1139. retval |= __put_user(pt->b7, &ppr->br[7]);
  1140. /* fr2-fr5 */
  1141. for (i = 2; i < 6; i++) {
  1142. if (unw_get_fr(&info, i, &fpval) < 0)
  1143. return -EIO;
  1144. retval |= __copy_to_user(&ppr->fr[i], &fpval, sizeof (fpval));
  1145. }
  1146. /* fr6-fr11 */
  1147. retval |= __copy_to_user(&ppr->fr[6], &pt->f6,
  1148. sizeof(struct ia64_fpreg) * 6);
  1149. /* fp scratch regs(12-15) */
  1150. retval |= __copy_to_user(&ppr->fr[12], &sw->f12,
  1151. sizeof(struct ia64_fpreg) * 4);
  1152. /* fr16-fr31 */
  1153. for (i = 16; i < 32; i++) {
  1154. if (unw_get_fr(&info, i, &fpval) < 0)
  1155. return -EIO;
  1156. retval |= __copy_to_user(&ppr->fr[i], &fpval, sizeof (fpval));
  1157. }
  1158. /* fph */
  1159. ia64_flush_fph(child);
  1160. retval |= __copy_to_user(&ppr->fr[32], &child->thread.fph,
  1161. sizeof(ppr->fr[32]) * 96);
  1162. /* preds */
  1163. retval |= __put_user(pt->pr, &ppr->pr);
  1164. /* nat bits */
  1165. retval |= __put_user(nat_bits, &ppr->nat);
  1166. ret = retval ? -EIO : 0;
  1167. return ret;
  1168. }
  1169. static long
  1170. ptrace_setregs (struct task_struct *child, struct pt_all_user_regs __user *ppr)
  1171. {
  1172. unsigned long psr, rsc, ec, lc, rnat, bsp, cfm, nat_bits, val = 0;
  1173. struct unw_frame_info info;
  1174. struct switch_stack *sw;
  1175. struct ia64_fpreg fpval;
  1176. struct pt_regs *pt;
  1177. long ret, retval = 0;
  1178. int i;
  1179. memset(&fpval, 0, sizeof(fpval));
  1180. if (!access_ok(VERIFY_READ, ppr, sizeof(struct pt_all_user_regs)))
  1181. return -EIO;
  1182. pt = task_pt_regs(child);
  1183. sw = (struct switch_stack *) (child->thread.ksp + 16);
  1184. unw_init_from_blocked_task(&info, child);
  1185. if (unw_unwind_to_user(&info) < 0) {
  1186. return -EIO;
  1187. }
  1188. if (((unsigned long) ppr & 0x7) != 0) {
  1189. dprintk("ptrace:unaligned register address %p\n", ppr);
  1190. return -EIO;
  1191. }
  1192. /* control regs */
  1193. retval |= __get_user(pt->cr_iip, &ppr->cr_iip);
  1194. retval |= __get_user(psr, &ppr->cr_ipsr);
  1195. /* app regs */
  1196. retval |= __get_user(pt->ar_pfs, &ppr->ar[PT_AUR_PFS]);
  1197. retval |= __get_user(rsc, &ppr->ar[PT_AUR_RSC]);
  1198. retval |= __get_user(pt->ar_bspstore, &ppr->ar[PT_AUR_BSPSTORE]);
  1199. retval |= __get_user(pt->ar_unat, &ppr->ar[PT_AUR_UNAT]);
  1200. retval |= __get_user(pt->ar_ccv, &ppr->ar[PT_AUR_CCV]);
  1201. retval |= __get_user(pt->ar_fpsr, &ppr->ar[PT_AUR_FPSR]);
  1202. retval |= __get_user(ec, &ppr->ar[PT_AUR_EC]);
  1203. retval |= __get_user(lc, &ppr->ar[PT_AUR_LC]);
  1204. retval |= __get_user(rnat, &ppr->ar[PT_AUR_RNAT]);
  1205. retval |= __get_user(bsp, &ppr->ar[PT_AUR_BSP]);
  1206. retval |= __get_user(cfm, &ppr->cfm);
  1207. /* gr1-gr3 */
  1208. retval |= __copy_from_user(&pt->r1, &ppr->gr[1], sizeof(long));
  1209. retval |= __copy_from_user(&pt->r2, &ppr->gr[2], sizeof(long) * 2);
  1210. /* gr4-gr7 */
  1211. for (i = 4; i < 8; i++) {
  1212. retval |= __get_user(val, &ppr->gr[i]);
  1213. /* NaT bit will be set via PT_NAT_BITS: */
  1214. if (unw_set_gr(&info, i, val, 0) < 0)
  1215. return -EIO;
  1216. }
  1217. /* gr8-gr11 */
  1218. retval |= __copy_from_user(&pt->r8, &ppr->gr[8], sizeof(long) * 4);
  1219. /* gr12-gr15 */
  1220. retval |= __copy_from_user(&pt->r12, &ppr->gr[12], sizeof(long) * 2);
  1221. retval |= __copy_from_user(&pt->r14, &ppr->gr[14], sizeof(long));
  1222. retval |= __copy_from_user(&pt->r15, &ppr->gr[15], sizeof(long));
  1223. /* gr16-gr31 */
  1224. retval |= __copy_from_user(&pt->r16, &ppr->gr[16], sizeof(long) * 16);
  1225. /* b0 */
  1226. retval |= __get_user(pt->b0, &ppr->br[0]);
  1227. /* b1-b5 */
  1228. for (i = 1; i < 6; i++) {
  1229. retval |= __get_user(val, &ppr->br[i]);
  1230. unw_set_br(&info, i, val);
  1231. }
  1232. /* b6-b7 */
  1233. retval |= __get_user(pt->b6, &ppr->br[6]);
  1234. retval |= __get_user(pt->b7, &ppr->br[7]);
  1235. /* fr2-fr5 */
  1236. for (i = 2; i < 6; i++) {
  1237. retval |= __copy_from_user(&fpval, &ppr->fr[i], sizeof(fpval));
  1238. if (unw_set_fr(&info, i, fpval) < 0)
  1239. return -EIO;
  1240. }
  1241. /* fr6-fr11 */
  1242. retval |= __copy_from_user(&pt->f6, &ppr->fr[6],
  1243. sizeof(ppr->fr[6]) * 6);
  1244. /* fp scratch regs(12-15) */
  1245. retval |= __copy_from_user(&sw->f12, &ppr->fr[12],
  1246. sizeof(ppr->fr[12]) * 4);
  1247. /* fr16-fr31 */
  1248. for (i = 16; i < 32; i++) {
  1249. retval |= __copy_from_user(&fpval, &ppr->fr[i],
  1250. sizeof(fpval));
  1251. if (unw_set_fr(&info, i, fpval) < 0)
  1252. return -EIO;
  1253. }
  1254. /* fph */
  1255. ia64_sync_fph(child);
  1256. retval |= __copy_from_user(&child->thread.fph, &ppr->fr[32],
  1257. sizeof(ppr->fr[32]) * 96);
  1258. /* preds */
  1259. retval |= __get_user(pt->pr, &ppr->pr);
  1260. /* nat bits */
  1261. retval |= __get_user(nat_bits, &ppr->nat);
  1262. retval |= access_uarea(child, PT_CR_IPSR, &psr, 1);
  1263. retval |= access_uarea(child, PT_AR_RSC, &rsc, 1);
  1264. retval |= access_uarea(child, PT_AR_EC, &ec, 1);
  1265. retval |= access_uarea(child, PT_AR_LC, &lc, 1);
  1266. retval |= access_uarea(child, PT_AR_RNAT, &rnat, 1);
  1267. retval |= access_uarea(child, PT_AR_BSP, &bsp, 1);
  1268. retval |= access_uarea(child, PT_CFM, &cfm, 1);
  1269. retval |= access_uarea(child, PT_NAT_BITS, &nat_bits, 1);
  1270. ret = retval ? -EIO : 0;
  1271. return ret;
  1272. }
  1273. void
  1274. user_enable_single_step (struct task_struct *child)
  1275. {
  1276. struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
  1277. set_tsk_thread_flag(child, TIF_SINGLESTEP);
  1278. child_psr->ss = 1;
  1279. }
  1280. void
  1281. user_enable_block_step (struct task_struct *child)
  1282. {
  1283. struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
  1284. set_tsk_thread_flag(child, TIF_SINGLESTEP);
  1285. child_psr->tb = 1;
  1286. }
  1287. void
  1288. user_disable_single_step (struct task_struct *child)
  1289. {
  1290. struct ia64_psr *child_psr = ia64_psr(task_pt_regs(child));
  1291. /* make sure the single step/taken-branch trap bits are not set: */
  1292. clear_tsk_thread_flag(child, TIF_SINGLESTEP);
  1293. child_psr->ss = 0;
  1294. child_psr->tb = 0;
  1295. }
  1296. /*
  1297. * Called by kernel/ptrace.c when detaching..
  1298. *
  1299. * Make sure the single step bit is not set.
  1300. */
  1301. void
  1302. ptrace_disable (struct task_struct *child)
  1303. {
  1304. user_disable_single_step(child);
  1305. }
  1306. long
  1307. arch_ptrace (struct task_struct *child, long request, long addr, long data)
  1308. {
  1309. switch (request) {
  1310. case PTRACE_PEEKTEXT:
  1311. case PTRACE_PEEKDATA:
  1312. /* read word at location addr */
  1313. if (access_process_vm(child, addr, &data, sizeof(data), 0)
  1314. != sizeof(data))
  1315. return -EIO;
  1316. /* ensure return value is not mistaken for error code */
  1317. force_successful_syscall_return();
  1318. return data;
  1319. /* PTRACE_POKETEXT and PTRACE_POKEDATA is handled
  1320. * by the generic ptrace_request().
  1321. */
  1322. case PTRACE_PEEKUSR:
  1323. /* read the word at addr in the USER area */
  1324. if (access_uarea(child, addr, &data, 0) < 0)
  1325. return -EIO;
  1326. /* ensure return value is not mistaken for error code */
  1327. force_successful_syscall_return();
  1328. return data;
  1329. case PTRACE_POKEUSR:
  1330. /* write the word at addr in the USER area */
  1331. if (access_uarea(child, addr, &data, 1) < 0)
  1332. return -EIO;
  1333. return 0;
  1334. case PTRACE_OLD_GETSIGINFO:
  1335. /* for backwards-compatibility */
  1336. return ptrace_request(child, PTRACE_GETSIGINFO, addr, data);
  1337. case PTRACE_OLD_SETSIGINFO:
  1338. /* for backwards-compatibility */
  1339. return ptrace_request(child, PTRACE_SETSIGINFO, addr, data);
  1340. case PTRACE_GETREGS:
  1341. return ptrace_getregs(child,
  1342. (struct pt_all_user_regs __user *) data);
  1343. case PTRACE_SETREGS:
  1344. return ptrace_setregs(child,
  1345. (struct pt_all_user_regs __user *) data);
  1346. default:
  1347. return ptrace_request(child, request, addr, data);
  1348. }
  1349. }
  1350. static void
  1351. syscall_trace (void)
  1352. {
  1353. /*
  1354. * The 0x80 provides a way for the tracing parent to
  1355. * distinguish between a syscall stop and SIGTRAP delivery.
  1356. */
  1357. ptrace_notify(SIGTRAP
  1358. | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
  1359. /*
  1360. * This isn't the same as continuing with a signal, but it
  1361. * will do for normal use. strace only continues with a
  1362. * signal if the stopping signal is not SIGTRAP. -brl
  1363. */
  1364. if (current->exit_code) {
  1365. send_sig(current->exit_code, current, 1);
  1366. current->exit_code = 0;
  1367. }
  1368. }
  1369. /* "asmlinkage" so the input arguments are preserved... */
  1370. asmlinkage void
  1371. syscall_trace_enter (long arg0, long arg1, long arg2, long arg3,
  1372. long arg4, long arg5, long arg6, long arg7,
  1373. struct pt_regs regs)
  1374. {
  1375. if (test_thread_flag(TIF_SYSCALL_TRACE)
  1376. && (current->ptrace & PT_PTRACED))
  1377. syscall_trace();
  1378. /* copy user rbs to kernel rbs */
  1379. if (test_thread_flag(TIF_RESTORE_RSE))
  1380. ia64_sync_krbs();
  1381. if (unlikely(current->audit_context)) {
  1382. long syscall;
  1383. int arch;
  1384. if (IS_IA32_PROCESS(&regs)) {
  1385. syscall = regs.r1;
  1386. arch = AUDIT_ARCH_I386;
  1387. } else {
  1388. syscall = regs.r15;
  1389. arch = AUDIT_ARCH_IA64;
  1390. }
  1391. audit_syscall_entry(arch, syscall, arg0, arg1, arg2, arg3);
  1392. }
  1393. }
  1394. /* "asmlinkage" so the input arguments are preserved... */
  1395. asmlinkage void
  1396. syscall_trace_leave (long arg0, long arg1, long arg2, long arg3,
  1397. long arg4, long arg5, long arg6, long arg7,
  1398. struct pt_regs regs)
  1399. {
  1400. if (unlikely(current->audit_context)) {
  1401. int success = AUDITSC_RESULT(regs.r10);
  1402. long result = regs.r8;
  1403. if (success != AUDITSC_SUCCESS)
  1404. result = -result;
  1405. audit_syscall_exit(success, result);
  1406. }
  1407. if ((test_thread_flag(TIF_SYSCALL_TRACE)
  1408. || test_thread_flag(TIF_SINGLESTEP))
  1409. && (current->ptrace & PT_PTRACED))
  1410. syscall_trace();
  1411. /* copy user rbs to kernel rbs */
  1412. if (test_thread_flag(TIF_RESTORE_RSE))
  1413. ia64_sync_krbs();
  1414. }
  1415. /* Utrace implementation starts here */
  1416. struct regset_get {
  1417. void *kbuf;
  1418. void __user *ubuf;
  1419. };
  1420. struct regset_set {
  1421. const void *kbuf;
  1422. const void __user *ubuf;
  1423. };
  1424. struct regset_getset {
  1425. struct task_struct *target;
  1426. const struct user_regset *regset;
  1427. union {
  1428. struct regset_get get;
  1429. struct regset_set set;
  1430. } u;
  1431. unsigned int pos;
  1432. unsigned int count;
  1433. int ret;
  1434. };
  1435. static int
  1436. access_elf_gpreg(struct task_struct *target, struct unw_frame_info *info,
  1437. unsigned long addr, unsigned long *data, int write_access)
  1438. {
  1439. struct pt_regs *pt;
  1440. unsigned long *ptr = NULL;
  1441. int ret;
  1442. char nat = 0;
  1443. pt = task_pt_regs(target);
  1444. switch (addr) {
  1445. case ELF_GR_OFFSET(1):
  1446. ptr = &pt->r1;
  1447. break;
  1448. case ELF_GR_OFFSET(2):
  1449. case ELF_GR_OFFSET(3):
  1450. ptr = (void *)&pt->r2 + (addr - ELF_GR_OFFSET(2));
  1451. break;
  1452. case ELF_GR_OFFSET(4) ... ELF_GR_OFFSET(7):
  1453. if (write_access) {
  1454. /* read NaT bit first: */
  1455. unsigned long dummy;
  1456. ret = unw_get_gr(info, addr/8, &dummy, &nat);
  1457. if (ret < 0)
  1458. return ret;
  1459. }
  1460. return unw_access_gr(info, addr/8, data, &nat, write_access);
  1461. case ELF_GR_OFFSET(8) ... ELF_GR_OFFSET(11):
  1462. ptr = (void *)&pt->r8 + addr - ELF_GR_OFFSET(8);
  1463. break;
  1464. case ELF_GR_OFFSET(12):
  1465. case ELF_GR_OFFSET(13):
  1466. ptr = (void *)&pt->r12 + addr - ELF_GR_OFFSET(12);
  1467. break;
  1468. case ELF_GR_OFFSET(14):
  1469. ptr = &pt->r14;
  1470. break;
  1471. case ELF_GR_OFFSET(15):
  1472. ptr = &pt->r15;
  1473. }
  1474. if (write_access)
  1475. *ptr = *data;
  1476. else
  1477. *data = *ptr;
  1478. return 0;
  1479. }
  1480. static int
  1481. access_elf_breg(struct task_struct *target, struct unw_frame_info *info,
  1482. unsigned long addr, unsigned long *data, int write_access)
  1483. {
  1484. struct pt_regs *pt;
  1485. unsigned long *ptr = NULL;
  1486. pt = task_pt_regs(target);
  1487. switch (addr) {
  1488. case ELF_BR_OFFSET(0):
  1489. ptr = &pt->b0;
  1490. break;
  1491. case ELF_BR_OFFSET(1) ... ELF_BR_OFFSET(5):
  1492. return unw_access_br(info, (addr - ELF_BR_OFFSET(0))/8,
  1493. data, write_access);
  1494. case ELF_BR_OFFSET(6):
  1495. ptr = &pt->b6;
  1496. break;
  1497. case ELF_BR_OFFSET(7):
  1498. ptr = &pt->b7;
  1499. }
  1500. if (write_access)
  1501. *ptr = *data;
  1502. else
  1503. *data = *ptr;
  1504. return 0;
  1505. }
  1506. static int
  1507. access_elf_areg(struct task_struct *target, struct unw_frame_info *info,
  1508. unsigned long addr, unsigned long *data, int write_access)
  1509. {
  1510. struct pt_regs *pt;
  1511. unsigned long cfm, urbs_end;
  1512. unsigned long *ptr = NULL;
  1513. pt = task_pt_regs(target);
  1514. if (addr >= ELF_AR_RSC_OFFSET && addr <= ELF_AR_SSD_OFFSET) {
  1515. switch (addr) {
  1516. case ELF_AR_RSC_OFFSET:
  1517. /* force PL3 */
  1518. if (write_access)
  1519. pt->ar_rsc = *data | (3 << 2);
  1520. else
  1521. *data = pt->ar_rsc;
  1522. return 0;
  1523. case ELF_AR_BSP_OFFSET:
  1524. /*
  1525. * By convention, we use PT_AR_BSP to refer to
  1526. * the end of the user-level backing store.
  1527. * Use ia64_rse_skip_regs(PT_AR_BSP, -CFM.sof)
  1528. * to get the real value of ar.bsp at the time
  1529. * the kernel was entered.
  1530. *
  1531. * Furthermore, when changing the contents of
  1532. * PT_AR_BSP (or PT_CFM) while the task is
  1533. * blocked in a system call, convert the state
  1534. * so that the non-system-call exit
  1535. * path is used. This ensures that the proper
  1536. * state will be picked up when resuming
  1537. * execution. However, it *also* means that
  1538. * once we write PT_AR_BSP/PT_CFM, it won't be
  1539. * possible to modify the syscall arguments of
  1540. * the pending system call any longer. This
  1541. * shouldn't be an issue because modifying
  1542. * PT_AR_BSP/PT_CFM generally implies that
  1543. * we're either abandoning the pending system
  1544. * call or that we defer it's re-execution
  1545. * (e.g., due to GDB doing an inferior
  1546. * function call).
  1547. */
  1548. urbs_end = ia64_get_user_rbs_end(target, pt, &cfm);
  1549. if (write_access) {
  1550. if (*data != urbs_end) {
  1551. if (in_syscall(pt))
  1552. convert_to_non_syscall(target,
  1553. pt,
  1554. cfm);
  1555. /*
  1556. * Simulate user-level write
  1557. * of ar.bsp:
  1558. */
  1559. pt->loadrs = 0;
  1560. pt->ar_bspstore = *data;
  1561. }
  1562. } else
  1563. *data = urbs_end;
  1564. return 0;
  1565. case ELF_AR_BSPSTORE_OFFSET:
  1566. ptr = &pt->ar_bspstore;
  1567. break;
  1568. case ELF_AR_RNAT_OFFSET:
  1569. ptr = &pt->ar_rnat;
  1570. break;
  1571. case ELF_AR_CCV_OFFSET:
  1572. ptr = &pt->ar_ccv;
  1573. break;
  1574. case ELF_AR_UNAT_OFFSET:
  1575. ptr = &pt->ar_unat;
  1576. break;
  1577. case ELF_AR_FPSR_OFFSET:
  1578. ptr = &pt->ar_fpsr;
  1579. break;
  1580. case ELF_AR_PFS_OFFSET:
  1581. ptr = &pt->ar_pfs;
  1582. break;
  1583. case ELF_AR_LC_OFFSET:
  1584. return unw_access_ar(info, UNW_AR_LC, data,
  1585. write_access);
  1586. case ELF_AR_EC_OFFSET:
  1587. return unw_access_ar(info, UNW_AR_EC, data,
  1588. write_access);
  1589. case ELF_AR_CSD_OFFSET:
  1590. ptr = &pt->ar_csd;
  1591. break;
  1592. case ELF_AR_SSD_OFFSET:
  1593. ptr = &pt->ar_ssd;
  1594. }
  1595. } else if (addr >= ELF_CR_IIP_OFFSET && addr <= ELF_CR_IPSR_OFFSET) {
  1596. switch (addr) {
  1597. case ELF_CR_IIP_OFFSET:
  1598. ptr = &pt->cr_iip;
  1599. break;
  1600. case ELF_CFM_OFFSET:
  1601. urbs_end = ia64_get_user_rbs_end(target, pt, &cfm);
  1602. if (write_access) {
  1603. if (((cfm ^ *data) & PFM_MASK) != 0) {
  1604. if (in_syscall(pt))
  1605. convert_to_non_syscall(target,
  1606. pt,
  1607. cfm);
  1608. pt->cr_ifs = ((pt->cr_ifs & ~PFM_MASK)
  1609. | (*data & PFM_MASK));
  1610. }
  1611. } else
  1612. *data = cfm;
  1613. return 0;
  1614. case ELF_CR_IPSR_OFFSET:
  1615. if (write_access) {
  1616. unsigned long tmp = *data;
  1617. /* psr.ri==3 is a reserved value: SDM 2:25 */
  1618. if ((tmp & IA64_PSR_RI) == IA64_PSR_RI)
  1619. tmp &= ~IA64_PSR_RI;
  1620. pt->cr_ipsr = ((tmp & IPSR_MASK)
  1621. | (pt->cr_ipsr & ~IPSR_MASK));
  1622. } else
  1623. *data = (pt->cr_ipsr & IPSR_MASK);
  1624. return 0;
  1625. }
  1626. } else if (addr == ELF_NAT_OFFSET)
  1627. return access_nat_bits(target, pt, info,
  1628. data, write_access);
  1629. else if (addr == ELF_PR_OFFSET)
  1630. ptr = &pt->pr;
  1631. else
  1632. return -1;
  1633. if (write_access)
  1634. *ptr = *data;
  1635. else
  1636. *data = *ptr;
  1637. return 0;
  1638. }
  1639. static int
  1640. access_elf_reg(struct task_struct *target, struct unw_frame_info *info,
  1641. unsigned long addr, unsigned long *data, int write_access)
  1642. {
  1643. if (addr >= ELF_GR_OFFSET(1) && addr <= ELF_GR_OFFSET(15))
  1644. return access_elf_gpreg(target, info, addr, data, write_access);
  1645. else if (addr >= ELF_BR_OFFSET(0) && addr <= ELF_BR_OFFSET(7))
  1646. return access_elf_breg(target, info, addr, data, write_access);
  1647. else
  1648. return access_elf_areg(target, info, addr, data, write_access);
  1649. }
  1650. void do_gpregs_get(struct unw_frame_info *info, void *arg)
  1651. {
  1652. struct pt_regs *pt;
  1653. struct regset_getset *dst = arg;
  1654. elf_greg_t tmp[16];
  1655. unsigned int i, index, min_copy;
  1656. if (unw_unwind_to_user(info) < 0)
  1657. return;
  1658. /*
  1659. * coredump format:
  1660. * r0-r31
  1661. * NaT bits (for r0-r31; bit N == 1 iff rN is a NaT)
  1662. * predicate registers (p0-p63)
  1663. * b0-b7
  1664. * ip cfm user-mask
  1665. * ar.rsc ar.bsp ar.bspstore ar.rnat
  1666. * ar.ccv ar.unat ar.fpsr ar.pfs ar.lc ar.ec
  1667. */
  1668. /* Skip r0 */
  1669. if (dst->count > 0 && dst->pos < ELF_GR_OFFSET(1)) {
  1670. dst->ret = user_regset_copyout_zero(&dst->pos, &dst->count,
  1671. &dst->u.get.kbuf,
  1672. &dst->u.get.ubuf,
  1673. 0, ELF_GR_OFFSET(1));
  1674. if (dst->ret || dst->count == 0)
  1675. return;
  1676. }
  1677. /* gr1 - gr15 */
  1678. if (dst->count > 0 && dst->pos < ELF_GR_OFFSET(16)) {
  1679. index = (dst->pos - ELF_GR_OFFSET(1)) / sizeof(elf_greg_t);
  1680. min_copy = ELF_GR_OFFSET(16) > (dst->pos + dst->count) ?
  1681. (dst->pos + dst->count) : ELF_GR_OFFSET(16);
  1682. for (i = dst->pos; i < min_copy; i += sizeof(elf_greg_t),
  1683. index++)
  1684. if (access_elf_reg(dst->target, info, i,
  1685. &tmp[index], 0) < 0) {
  1686. dst->ret = -EIO;
  1687. return;
  1688. }
  1689. dst->ret = user_regset_copyout(&dst->pos, &dst->count,
  1690. &dst->u.get.kbuf, &dst->u.get.ubuf, tmp,
  1691. ELF_GR_OFFSET(1), ELF_GR_OFFSET(16));
  1692. if (dst->ret || dst->count == 0)
  1693. return;
  1694. }
  1695. /* r16-r31 */
  1696. if (dst->count > 0 && dst->pos < ELF_NAT_OFFSET) {
  1697. pt = task_pt_regs(dst->target);
  1698. dst->ret = user_regset_copyout(&dst->pos, &dst->count,
  1699. &dst->u.get.kbuf, &dst->u.get.ubuf, &pt->r16,
  1700. ELF_GR_OFFSET(16), ELF_NAT_OFFSET);
  1701. if (dst->ret || dst->count == 0)
  1702. return;
  1703. }
  1704. /* nat, pr, b0 - b7 */
  1705. if (dst->count > 0 && dst->pos < ELF_CR_IIP_OFFSET) {
  1706. index = (dst->pos - ELF_NAT_OFFSET) / sizeof(elf_greg_t);
  1707. min_copy = ELF_CR_IIP_OFFSET > (dst->pos + dst->count) ?
  1708. (dst->pos + dst->count) : ELF_CR_IIP_OFFSET;
  1709. for (i = dst->pos; i < min_copy; i += sizeof(elf_greg_t),
  1710. index++)
  1711. if (access_elf_reg(dst->target, info, i,
  1712. &tmp[index], 0) < 0) {
  1713. dst->ret = -EIO;
  1714. return;
  1715. }
  1716. dst->ret = user_regset_copyout(&dst->pos, &dst->count,
  1717. &dst->u.get.kbuf, &dst->u.get.ubuf, tmp,
  1718. ELF_NAT_OFFSET, ELF_CR_IIP_OFFSET);
  1719. if (dst->ret || dst->count == 0)
  1720. return;
  1721. }
  1722. /* ip cfm psr ar.rsc ar.bsp ar.bspstore ar.rnat
  1723. * ar.ccv ar.unat ar.fpsr ar.pfs ar.lc ar.ec ar.csd ar.ssd
  1724. */
  1725. if (dst->count > 0 && dst->pos < (ELF_AR_END_OFFSET)) {
  1726. index = (dst->pos - ELF_CR_IIP_OFFSET) / sizeof(elf_greg_t);
  1727. min_copy = ELF_AR_END_OFFSET > (dst->pos + dst->count) ?
  1728. (dst->pos + dst->count) : ELF_AR_END_OFFSET;
  1729. for (i = dst->pos; i < min_copy; i += sizeof(elf_greg_t),
  1730. index++)
  1731. if (access_elf_reg(dst->target, info, i,
  1732. &tmp[index], 0) < 0) {
  1733. dst->ret = -EIO;
  1734. return;
  1735. }
  1736. dst->ret = user_regset_copyout(&dst->pos, &dst->count,
  1737. &dst->u.get.kbuf, &dst->u.get.ubuf, tmp,
  1738. ELF_CR_IIP_OFFSET, ELF_AR_END_OFFSET);
  1739. }
  1740. }
  1741. void do_gpregs_set(struct unw_frame_info *info, void *arg)
  1742. {
  1743. struct pt_regs *pt;
  1744. struct regset_getset *dst = arg;
  1745. elf_greg_t tmp[16];
  1746. unsigned int i, index;
  1747. if (unw_unwind_to_user(info) < 0)
  1748. return;
  1749. /* Skip r0 */
  1750. if (dst->count > 0 && dst->pos < ELF_GR_OFFSET(1)) {
  1751. dst->ret = user_regset_copyin_ignore(&dst->pos, &dst->count,
  1752. &dst->u.set.kbuf,
  1753. &dst->u.set.ubuf,
  1754. 0, ELF_GR_OFFSET(1));
  1755. if (dst->ret || dst->count == 0)
  1756. return;
  1757. }
  1758. /* gr1-gr15 */
  1759. if (dst->count > 0 && dst->pos < ELF_GR_OFFSET(16)) {
  1760. i = dst->pos;
  1761. index = (dst->pos - ELF_GR_OFFSET(1)) / sizeof(elf_greg_t);
  1762. dst->ret = user_regset_copyin(&dst->pos, &dst->count,
  1763. &dst->u.set.kbuf, &dst->u.set.ubuf, tmp,
  1764. ELF_GR_OFFSET(1), ELF_GR_OFFSET(16));
  1765. if (dst->ret)
  1766. return;
  1767. for ( ; i < dst->pos; i += sizeof(elf_greg_t), index++)
  1768. if (access_elf_reg(dst->target, info, i,
  1769. &tmp[index], 1) < 0) {
  1770. dst->ret = -EIO;
  1771. return;
  1772. }
  1773. if (dst->count == 0)
  1774. return;
  1775. }
  1776. /* gr16-gr31 */
  1777. if (dst->count > 0 && dst->pos < ELF_NAT_OFFSET) {
  1778. pt = task_pt_regs(dst->target);
  1779. dst->ret = user_regset_copyin(&dst->pos, &dst->count,
  1780. &dst->u.set.kbuf, &dst->u.set.ubuf, &pt->r16,
  1781. ELF_GR_OFFSET(16), ELF_NAT_OFFSET);
  1782. if (dst->ret || dst->count == 0)
  1783. return;
  1784. }
  1785. /* nat, pr, b0 - b7 */
  1786. if (dst->count > 0 && dst->pos < ELF_CR_IIP_OFFSET) {
  1787. i = dst->pos;
  1788. index = (dst->pos - ELF_NAT_OFFSET) / sizeof(elf_greg_t);
  1789. dst->ret = user_regset_copyin(&dst->pos, &dst->count,
  1790. &dst->u.set.kbuf, &dst->u.set.ubuf, tmp,
  1791. ELF_NAT_OFFSET, ELF_CR_IIP_OFFSET);
  1792. if (dst->ret)
  1793. return;
  1794. for (; i < dst->pos; i += sizeof(elf_greg_t), index++)
  1795. if (access_elf_reg(dst->target, info, i,
  1796. &tmp[index], 1) < 0) {
  1797. dst->ret = -EIO;
  1798. return;
  1799. }
  1800. if (dst->count == 0)
  1801. return;
  1802. }
  1803. /* ip cfm psr ar.rsc ar.bsp ar.bspstore ar.rnat
  1804. * ar.ccv ar.unat ar.fpsr ar.pfs ar.lc ar.ec ar.csd ar.ssd
  1805. */
  1806. if (dst->count > 0 && dst->pos < (ELF_AR_END_OFFSET)) {
  1807. i = dst->pos;
  1808. index = (dst->pos - ELF_CR_IIP_OFFSET) / sizeof(elf_greg_t);
  1809. dst->ret = user_regset_copyin(&dst->pos, &dst->count,
  1810. &dst->u.set.kbuf, &dst->u.set.ubuf, tmp,
  1811. ELF_CR_IIP_OFFSET, ELF_AR_END_OFFSET);
  1812. if (dst->ret)
  1813. return;
  1814. for ( ; i < dst->pos; i += sizeof(elf_greg_t), index++)
  1815. if (access_elf_reg(dst->target, info, i,
  1816. &tmp[index], 1) < 0) {
  1817. dst->ret = -EIO;
  1818. return;
  1819. }
  1820. }
  1821. }
  1822. #define ELF_FP_OFFSET(i) (i * sizeof(elf_fpreg_t))
  1823. void do_fpregs_get(struct unw_frame_info *info, void *arg)
  1824. {
  1825. struct regset_getset *dst = arg;
  1826. struct task_struct *task = dst->target;
  1827. elf_fpreg_t tmp[30];
  1828. int index, min_copy, i;
  1829. if (unw_unwind_to_user(info) < 0)
  1830. return;
  1831. /* Skip pos 0 and 1 */
  1832. if (dst->count > 0 && dst->pos < ELF_FP_OFFSET(2)) {
  1833. dst->ret = user_regset_copyout_zero(&dst->pos, &dst->count,
  1834. &dst->u.get.kbuf,
  1835. &dst->u.get.ubuf,
  1836. 0, ELF_FP_OFFSET(2));
  1837. if (dst->count == 0 || dst->ret)
  1838. return;
  1839. }
  1840. /* fr2-fr31 */
  1841. if (dst->count > 0 && dst->pos < ELF_FP_OFFSET(32)) {
  1842. index = (dst->pos - ELF_FP_OFFSET(2)) / sizeof(elf_fpreg_t);
  1843. min_copy = min(((unsigned int)ELF_FP_OFFSET(32)),
  1844. dst->pos + dst->count);
  1845. for (i = dst->pos; i < min_copy; i += sizeof(elf_fpreg_t),
  1846. index++)
  1847. if (unw_get_fr(info, i / sizeof(elf_fpreg_t),
  1848. &tmp[index])) {
  1849. dst->ret = -EIO;
  1850. return;
  1851. }
  1852. dst->ret = user_regset_copyout(&dst->pos, &dst->count,
  1853. &dst->u.get.kbuf, &dst->u.get.ubuf, tmp,
  1854. ELF_FP_OFFSET(2), ELF_FP_OFFSET(32));
  1855. if (dst->count == 0 || dst->ret)
  1856. return;
  1857. }
  1858. /* fph */
  1859. if (dst->count > 0) {
  1860. ia64_flush_fph(dst->target);
  1861. if (task->thread.flags & IA64_THREAD_FPH_VALID)
  1862. dst->ret = user_regset_copyout(
  1863. &dst->pos, &dst->count,
  1864. &dst->u.get.kbuf, &dst->u.get.ubuf,
  1865. &dst->target->thread.fph,
  1866. ELF_FP_OFFSET(32), -1);
  1867. else
  1868. /* Zero fill instead. */
  1869. dst->ret = user_regset_copyout_zero(
  1870. &dst->pos, &dst->count,
  1871. &dst->u.get.kbuf, &dst->u.get.ubuf,
  1872. ELF_FP_OFFSET(32), -1);
  1873. }
  1874. }
  1875. void do_fpregs_set(struct unw_frame_info *info, void *arg)
  1876. {
  1877. struct regset_getset *dst = arg;
  1878. elf_fpreg_t fpreg, tmp[30];
  1879. int index, start, end;
  1880. if (unw_unwind_to_user(info) < 0)
  1881. return;
  1882. /* Skip pos 0 and 1 */
  1883. if (dst->count > 0 && dst->pos < ELF_FP_OFFSET(2)) {
  1884. dst->ret = user_regset_copyin_ignore(&dst->pos, &dst->count,
  1885. &dst->u.set.kbuf,
  1886. &dst->u.set.ubuf,
  1887. 0, ELF_FP_OFFSET(2));
  1888. if (dst->count == 0 || dst->ret)
  1889. return;
  1890. }
  1891. /* fr2-fr31 */
  1892. if (dst->count > 0 && dst->pos < ELF_FP_OFFSET(32)) {
  1893. start = dst->pos;
  1894. end = min(((unsigned int)ELF_FP_OFFSET(32)),
  1895. dst->pos + dst->count);
  1896. dst->ret = user_regset_copyin(&dst->pos, &dst->count,
  1897. &dst->u.set.kbuf, &dst->u.set.ubuf, tmp,
  1898. ELF_FP_OFFSET(2), ELF_FP_OFFSET(32));
  1899. if (dst->ret)
  1900. return;
  1901. if (start & 0xF) { /* only write high part */
  1902. if (unw_get_fr(info, start / sizeof(elf_fpreg_t),
  1903. &fpreg)) {
  1904. dst->ret = -EIO;
  1905. return;
  1906. }
  1907. tmp[start / sizeof(elf_fpreg_t) - 2].u.bits[0]
  1908. = fpreg.u.bits[0];
  1909. start &= ~0xFUL;
  1910. }
  1911. if (end & 0xF) { /* only write low part */
  1912. if (unw_get_fr(info, end / sizeof(elf_fpreg_t),
  1913. &fpreg)) {
  1914. dst->ret = -EIO;
  1915. return;
  1916. }
  1917. tmp[end / sizeof(elf_fpreg_t) - 2].u.bits[1]
  1918. = fpreg.u.bits[1];
  1919. end = (end + 0xF) & ~0xFUL;
  1920. }
  1921. for ( ; start < end ; start += sizeof(elf_fpreg_t)) {
  1922. index = start / sizeof(elf_fpreg_t);
  1923. if (unw_set_fr(info, index, tmp[index - 2])) {
  1924. dst->ret = -EIO;
  1925. return;
  1926. }
  1927. }
  1928. if (dst->ret || dst->count == 0)
  1929. return;
  1930. }
  1931. /* fph */
  1932. if (dst->count > 0 && dst->pos < ELF_FP_OFFSET(128)) {
  1933. ia64_sync_fph(dst->target);
  1934. dst->ret = user_regset_copyin(&dst->pos, &dst->count,
  1935. &dst->u.set.kbuf,
  1936. &dst->u.set.ubuf,
  1937. &dst->target->thread.fph,
  1938. ELF_FP_OFFSET(32), -1);
  1939. }
  1940. }
  1941. static int
  1942. do_regset_call(void (*call)(struct unw_frame_info *, void *),
  1943. struct task_struct *target,
  1944. const struct user_regset *regset,
  1945. unsigned int pos, unsigned int count,
  1946. const void *kbuf, const void __user *ubuf)
  1947. {
  1948. struct regset_getset info = { .target = target, .regset = regset,
  1949. .pos = pos, .count = count,
  1950. .u.set = { .kbuf = kbuf, .ubuf = ubuf },
  1951. .ret = 0 };
  1952. if (target == current)
  1953. unw_init_running(call, &info);
  1954. else {
  1955. struct unw_frame_info ufi;
  1956. memset(&ufi, 0, sizeof(ufi));
  1957. unw_init_from_blocked_task(&ufi, target);
  1958. (*call)(&ufi, &info);
  1959. }
  1960. return info.ret;
  1961. }
  1962. static int
  1963. gpregs_get(struct task_struct *target,
  1964. const struct user_regset *regset,
  1965. unsigned int pos, unsigned int count,
  1966. void *kbuf, void __user *ubuf)
  1967. {
  1968. return do_regset_call(do_gpregs_get, target, regset, pos, count,
  1969. kbuf, ubuf);
  1970. }
  1971. static int gpregs_set(struct task_struct *target,
  1972. const struct user_regset *regset,
  1973. unsigned int pos, unsigned int count,
  1974. const void *kbuf, const void __user *ubuf)
  1975. {
  1976. return do_regset_call(do_gpregs_set, target, regset, pos, count,
  1977. kbuf, ubuf);
  1978. }
  1979. static void do_gpregs_writeback(struct unw_frame_info *info, void *arg)
  1980. {
  1981. do_sync_rbs(info, ia64_sync_user_rbs);
  1982. }
  1983. /*
  1984. * This is called to write back the register backing store.
  1985. * ptrace does this before it stops, so that a tracer reading the user
  1986. * memory after the thread stops will get the current register data.
  1987. */
  1988. static int
  1989. gpregs_writeback(struct task_struct *target,
  1990. const struct user_regset *regset,
  1991. int now)
  1992. {
  1993. if (test_and_set_tsk_thread_flag(target, TIF_RESTORE_RSE))
  1994. return 0;
  1995. tsk_set_notify_resume(target);
  1996. return do_regset_call(do_gpregs_writeback, target, regset, 0, 0,
  1997. NULL, NULL);
  1998. }
  1999. static int
  2000. fpregs_active(struct task_struct *target, const struct user_regset *regset)
  2001. {
  2002. return (target->thread.flags & IA64_THREAD_FPH_VALID) ? 128 : 32;
  2003. }
  2004. static int fpregs_get(struct task_struct *target,
  2005. const struct user_regset *regset,
  2006. unsigned int pos, unsigned int count,
  2007. void *kbuf, void __user *ubuf)
  2008. {
  2009. return do_regset_call(do_fpregs_get, target, regset, pos, count,
  2010. kbuf, ubuf);
  2011. }
  2012. static int fpregs_set(struct task_struct *target,
  2013. const struct user_regset *regset,
  2014. unsigned int pos, unsigned int count,
  2015. const void *kbuf, const void __user *ubuf)
  2016. {
  2017. return do_regset_call(do_fpregs_set, target, regset, pos, count,
  2018. kbuf, ubuf);
  2019. }
  2020. static const struct user_regset native_regsets[] = {
  2021. {
  2022. .core_note_type = NT_PRSTATUS,
  2023. .n = ELF_NGREG,
  2024. .size = sizeof(elf_greg_t), .align = sizeof(elf_greg_t),
  2025. .get = gpregs_get, .set = gpregs_set,
  2026. .writeback = gpregs_writeback
  2027. },
  2028. {
  2029. .core_note_type = NT_PRFPREG,
  2030. .n = ELF_NFPREG,
  2031. .size = sizeof(elf_fpreg_t), .align = sizeof(elf_fpreg_t),
  2032. .get = fpregs_get, .set = fpregs_set, .active = fpregs_active
  2033. },
  2034. };
  2035. static const struct user_regset_view user_ia64_view = {
  2036. .name = "ia64",
  2037. .e_machine = EM_IA_64,
  2038. .regsets = native_regsets, .n = ARRAY_SIZE(native_regsets)
  2039. };
  2040. const struct user_regset_view *task_user_regset_view(struct task_struct *tsk)
  2041. {
  2042. return &user_ia64_view;
  2043. }