aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/regset.h
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-01-30 07:31:47 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:47 -0500
commit5bde4d181793be84351bc21c256d8c71cfcd313a (patch)
tree58c1c534ef5af5f425de61532b8aa5d24048136f /include/linux/regset.h
parentb9d36d5d000294a128f7f174fe67623a10e29d61 (diff)
x86: user_regset user-copy helpers
This defines two new inlines in linux/regset.h, for use in arch_ptrace implementations and the like. These provide simplified wrappers for using the user_regset interfaces to copy thread regset data into the caller's user-space memory. The inlines are trivial, but make the common uses in places such as ptrace implementation much more concise, easier to read, and less prone to code-copying errors. Signed-off-by: Roland McGrath <roland@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/linux/regset.h')
-rw-r--r--include/linux/regset.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/linux/regset.h b/include/linux/regset.h
index 761c931af975..8abee6556223 100644
--- a/include/linux/regset.h
+++ b/include/linux/regset.h
@@ -318,5 +318,51 @@ static inline int user_regset_copyin_ignore(unsigned int *pos,
318 return 0; 318 return 0;
319} 319}
320 320
321/**
322 * copy_regset_to_user - fetch a thread's user_regset data into user memory
323 * @target: thread to be examined
324 * @view: &struct user_regset_view describing user thread machine state
325 * @setno: index in @view->regsets
326 * @offset: offset into the regset data, in bytes
327 * @size: amount of data to copy, in bytes
328 * @data: user-mode pointer to copy into
329 */
330static inline int copy_regset_to_user(struct task_struct *target,
331 const struct user_regset_view *view,
332 unsigned int setno,
333 unsigned int offset, unsigned int size,
334 void __user *data)
335{
336 const struct user_regset *regset = &view->regsets[setno];
337
338 if (!access_ok(VERIFY_WRITE, data, size))
339 return -EIO;
340
341 return regset->get(target, regset, offset, size, NULL, data);
342}
343
344/**
345 * copy_regset_from_user - store into thread's user_regset data from user memory
346 * @target: thread to be examined
347 * @view: &struct user_regset_view describing user thread machine state
348 * @setno: index in @view->regsets
349 * @offset: offset into the regset data, in bytes
350 * @size: amount of data to copy, in bytes
351 * @data: user-mode pointer to copy from
352 */
353static inline int copy_regset_from_user(struct task_struct *target,
354 const struct user_regset_view *view,
355 unsigned int setno,
356 unsigned int offset, unsigned int size,
357 const void __user *data)
358{
359 const struct user_regset *regset = &view->regsets[setno];
360
361 if (!access_ok(VERIFY_READ, data, size))
362 return -EIO;
363
364 return regset->set(target, regset, offset, size, NULL, data);
365}
366
321 367
322#endif /* <linux/regset.h> */ 368#endif /* <linux/regset.h> */