Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760235AbXLTME5 (ORCPT ); Thu, 20 Dec 2007 07:04:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761085AbXLTMAr (ORCPT ); Thu, 20 Dec 2007 07:00:47 -0500 Received: from mx1.redhat.com ([66.187.233.31]:38402 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760767AbXLTMAW (ORCPT ); Thu, 20 Dec 2007 07:00:22 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit From: Roland McGrath To: Andrew Morton , Linus Torvalds X-Fcc: ~/Mail/linus Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Cc: linuxppc-dev@ozlabs.org, Paul Mackerras In-Reply-To: Roland McGrath's message of Thursday, 20 December 2007 03:52:00 -0800 <20071220115200.C767E26F98A@magilla.localdomain> References: <20071220115200.C767E26F98A@magilla.localdomain> Subject: [PATCH -mm 10/43] powerpc user_regset fpregs Message-Id: <20071220115734.37FA126F98A@magilla.localdomain> Date: Thu, 20 Dec 2007 03:57:34 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2629 Lines: 83 This implements user_regset-style accessors for the powerpc FPU data, and rewrites the existing ptrace code in terms of those calls. Signed-off-by: Roland McGrath --- arch/powerpc/kernel/ptrace.c | 37 +++++++++++++++++++++++++++++++------ 1 files changed, 31 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 8b056d2..f1ce646 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -103,24 +104,48 @@ int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data) } +static int fpr_get(struct task_struct *target, const struct user_regset *regset, + unsigned int pos, unsigned int count, + void *kbuf, void __user *ubuf) +{ + flush_fp_to_thread(target); + + BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != + offsetof(struct thread_struct, fpr[32])); + + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, + &target->thread.fpr, 0, -1); +} + +static int fpr_set(struct task_struct *target, const struct user_regset *regset, + unsigned int pos, unsigned int count, + const void *kbuf, const void __user *ubuf) +{ + flush_fp_to_thread(target); + + BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != + offsetof(struct thread_struct, fpr[32])); + + return user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &target->thread.fpr, 0, -1); +} + static int get_fpregs(void __user *data, struct task_struct *task, int has_fpscr) { unsigned int count = has_fpscr ? 33 : 32; - - if (copy_to_user(data, task->thread.fpr, count * sizeof(double))) + if (!access_ok(VERIFY_WRITE, data, count * sizeof(double))) return -EFAULT; - return 0; + return fpr_get(task, NULL, 0, count * sizeof(double), NULL, data); } static int set_fpregs(void __user *data, struct task_struct *task, int has_fpscr) { unsigned int count = has_fpscr ? 33 : 32; - - if (copy_from_user(task->thread.fpr, data, count * sizeof(double))) + if (!access_ok(VERIFY_READ, data, count * sizeof(double))) return -EFAULT; - return 0; + return fpr_set(task, NULL, 0, count * sizeof(double), NULL, data); } -- 1.5.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/