From patchwork Thu Dec 13 05:34:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 205741 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 61D7D2C00BD for ; Thu, 13 Dec 2012 16:34:45 +1100 (EST) Received: from mail-ia0-f179.google.com (mail-ia0-f179.google.com [209.85.210.179]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 91D032C008D for ; Thu, 13 Dec 2012 16:34:14 +1100 (EST) Received: by mail-ia0-f179.google.com with SMTP id o25so1585022iad.38 for ; Wed, 12 Dec 2012 21:34:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=rrJ0itrLukRdOh9X+MgR3YYfGoP1An/hDlY96sXqmuM=; b=JJdVSmdNUHCX+7GhbNADZUNJpoRuLEfHo9QU5HEkG8B/N+UgqwGxxxgUP+Is1IJLN7 uIQGgXAYpccVyWyRG04bfcp/w05+pw4lkU77l126HlWZXBTt3myFIBxB3EazdpZiV7Ia igFqA4Rx8DM+xze8eFp1KdbZkRfnIXX1stOSysk5yJ5KNEIXcLFPVjQSA66/TAzoBxFI R2wS4jxnjSXgdRKn+2Af9D0S63ZrMYrJHY1oYqohP7Qr8r1dmT7W/rMKUOtm+sdNgw7u Uuh96R7dMRtsEJNwx3rht3ATM/LBhJGhAcTj89BsPfHTTCI9ZOBdt/l7YPGhrgXrZF1Q S4ow== Received: by 10.50.41.225 with SMTP id i1mr496804igl.73.1355376851660; Wed, 12 Dec 2012 21:34:11 -0800 (PST) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPS id gs6sm492759igc.11.2012.12.12.21.34.07 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 21:34:10 -0800 (PST) From: Alexey Kardashevskiy To: Benjamin Herrenschmidt Subject: [PATCH] powerpc: added DSCR support to ptrace Date: Thu, 13 Dec 2012 16:34:00 +1100 Message-Id: <1355376840-9287-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQmqJF07UD4FyLVChfnJdK4w9QjLq4UPz3scUzYPvxnIhT9TuhxxhirG9/NcVr+ZZtl+7+8g Cc: Alexey Kardashevskiy , linuxppc-dev@lists.ozlabs.org, Anton Blanchard , linux-kernel@vger.kernel.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The DSCR (aka Data Stream Control Register) is supported on some server PowerPC chips and allow some control over the prefetch of data streams. The kernel already supports DSCR value per thread but there is also a need in a ability to change it from an external process for the specific pid. The patch adds new register index PT_DSCR (index=44) which can be set/get by: ptrace(PTRACE_POKEUSER, traced_process, PT_DSCR << 3, dscr); dscr = ptrace(PTRACE_PEEKUSER, traced_process, PT_DSCR << 3, NULL); Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/ptrace.h | 1 + arch/powerpc/kernel/ptrace.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h index 9c21ed4..340fe36 100644 --- a/arch/powerpc/include/asm/ptrace.h +++ b/arch/powerpc/include/asm/ptrace.h @@ -276,6 +276,7 @@ static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, #define PT_DAR 41 #define PT_DSISR 42 #define PT_RESULT 43 +#define PT_DSCR 44 #define PT_REGS_COUNT 44 #define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */ diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index c10fc28..aa19389 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -179,6 +179,18 @@ static int set_user_msr(struct task_struct *task, unsigned long msr) return 0; } +static unsigned long get_user_dscr(struct task_struct *task) +{ + return task->thread.dscr; +} + +static int set_user_dscr(struct task_struct *task, unsigned long dscr) +{ + task->thread.dscr = dscr; + task->thread.dscr_inherit = 1; + return 0; +} + /* * We prevent mucking around with the reserved area of trap * which are used internally by the kernel. @@ -200,6 +212,9 @@ unsigned long ptrace_get_reg(struct task_struct *task, int regno) if (regno == PT_MSR) return get_user_msr(task); + if (regno == PT_DSCR) + return get_user_dscr(task); + if (regno < (sizeof(struct pt_regs) / sizeof(unsigned long))) return ((unsigned long *)task->thread.regs)[regno]; @@ -218,6 +233,8 @@ int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data) return set_user_msr(task, data); if (regno == PT_TRAP) return set_user_trap(task, data); + if (regno == PT_DSCR) + return set_user_dscr(task, data); if (regno <= PT_MAX_PUT_REG) { ((unsigned long *)task->thread.regs)[regno] = data;