From patchwork Thu Jul 28 02:57:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Guo X-Patchwork-Id: 653556 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s0HNk6406z9sR8 for ; Thu, 28 Jul 2016 13:27:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=wQusIeLB; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3s0HNk4lV0zDrgY for ; Thu, 28 Jul 2016 13:27:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=wQusIeLB; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3s0Gmj1FBHzDrKs for ; Thu, 28 Jul 2016 12:59:49 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=wQusIeLB; dkim-atps=neutral Received: by mail-pf0-x241.google.com with SMTP id g202so2847964pfb.1 for ; Wed, 27 Jul 2016 19:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qs93+5bFjLwmhRMpEQxqUzwF/CSAJKm6IQXbLoVNLPc=; b=wQusIeLBxqOPbcnb0gCab7boKcQ3wLWf6Ds18/oNp7VCZec9ZWZysboNE8mAj9SfKB QKqFUPCFZQq31tHBJOU4No8V63EuFjh06AiBFWORpBEujG08tfIofZIjPKXH28nAYAha jjynAhnhXr5UGFXoxw3N2yK47ZrbqkCFMX/CdDn3P+yNMxGKC4Kt0ACjGYT70d80UaYh Iawo+jK9XGcIEwGIyld2pOyg33hLL4vXbqrU8wUOzLSvIbnCn/kin+WdlhVyVQJkwOJh lILS9ylkduF5MTm0Ky0IWIGHx9uYDVQEqJDZJUH1f7A78fBsAyZhP33BFMQKyBDtk4s2 29JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qs93+5bFjLwmhRMpEQxqUzwF/CSAJKm6IQXbLoVNLPc=; b=E3fxquN96pmNjD/HYjGsgnYtBnPxtOITuXOwrnKngyPcpxhNdrfa3VTFp/SsCzsy/n knktlFig43V5H9bsBVvVyFhBQ5igTGgpMVnPd8Doyd3cn2O4lqocpv4KtVp9TsMFOlCx 7Xi773JkD3BC8k08erI3raACbMrfuESWcLjanFdVNelsN4QIAeXbMl62FUudhlhykIxv 5YTq1+DVq9ArEXQwk/U66dHlFDVuOm2lV0dbYVuCB3D+A8XUBqpFnucsfJu8QmMmECbP VRHbrkaPBo32Yt5OQdRjuHlOeAiODmG3MDOdSx5knzzTFEIVMwHFZydaBw7o65u4AGIA vEug== X-Gm-Message-State: AEkoouuatUVM9LR58PDmfreVEKPQxXyuwigvWRbp21DrR8U99W1CuN+hsO58OMdm1di9Bw== X-Received: by 10.98.24.194 with SMTP id 185mr55311362pfy.52.1469674787367; Wed, 27 Jul 2016 19:59:47 -0700 (PDT) Received: from simonLocalRHEL7.cn.ibm.com ([106.38.0.85]) by smtp.gmail.com with ESMTPSA id t80sm12281548pfj.38.2016.07.27.19.59.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jul 2016 19:59:46 -0700 (PDT) From: wei.guo.simon@gmail.com To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v13 14/30] powerpc/ptrace: Enable support for EBB registers Date: Thu, 28 Jul 2016 10:57:43 +0800 Message-Id: <1469674679-8580-15-git-send-email-wei.guo.simon@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1469674679-8580-1-git-send-email-wei.guo.simon@gmail.com> References: <1469674679-8580-1-git-send-email-wei.guo.simon@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jessica Yu , Michael Neuling , Kees Cook , Chris Smart , linux-kselftest@vger.kernel.org, Simon Guo , Shuah Khan , Rashmica Gupta , Ulrich Weigand , Anton Blanchard , Suraj Jitindar Singh , Jiri Kosina , Andrew Morton , Miroslav Benes , Cyril Bur , Khem Raj , Anshuman Khandual MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Anshuman Khandual This patch enables support for EBB state registers related ELF core note NT_PPC_EBB based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding one new register sets REGSET_EBB in powerpc corresponding to the ELF core note sections added in this regard. It also implements the get, set and active functions for this new register sets added. Signed-off-by: Anshuman Khandual Signed-off-by: Simon Guo --- arch/powerpc/include/uapi/asm/elf.h | 1 + arch/powerpc/kernel/ptrace.c | 75 +++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/arch/powerpc/include/uapi/asm/elf.h b/arch/powerpc/include/uapi/asm/elf.h index e703c64..8c4d71a 100644 --- a/arch/powerpc/include/uapi/asm/elf.h +++ b/arch/powerpc/include/uapi/asm/elf.h @@ -94,6 +94,7 @@ #define ELF_NVMX 34 /* includes all vector registers */ #define ELF_NVSX 32 /* includes all VSX registers */ #define ELF_NTMSPRREG 3 /* include tfhar, tfiar, texasr */ +#define ELF_NEBB 3 /* includes ebbrr, ebbhr, bescr */ typedef unsigned long elf_greg_t64; typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG]; diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index c710060..5cbabdb 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -1760,6 +1760,70 @@ static int tar_set(struct task_struct *target, &target->thread.tar, 0, sizeof(u64)); return ret; } + +static int ebb_active(struct task_struct *target, + const struct user_regset *regset) +{ + if (!cpu_has_feature(CPU_FTR_ARCH_207S)) + return -ENODEV; + + if (target->thread.used_ebb) + return regset->n; + + return 0; +} + +static int ebb_get(struct task_struct *target, + const struct user_regset *regset, + unsigned int pos, unsigned int count, + void *kbuf, void __user *ubuf) +{ + /* Build tests */ + BUILD_BUG_ON(TSO(ebbrr) + sizeof(unsigned long) != TSO(ebbhr)); + BUILD_BUG_ON(TSO(ebbhr) + sizeof(unsigned long) != TSO(bescr)); + + if (!cpu_has_feature(CPU_FTR_ARCH_207S)) + return -ENODEV; + + if (!target->thread.used_ebb) + return -ENODATA; + + return user_regset_copyout(&pos, &count, &kbuf, &ubuf, + &target->thread.ebbrr, 0, 3 * sizeof(unsigned long)); +} + +static int ebb_set(struct task_struct *target, + const struct user_regset *regset, + unsigned int pos, unsigned int count, + const void *kbuf, const void __user *ubuf) +{ + int ret = 0; + + /* Build tests */ + BUILD_BUG_ON(TSO(ebbrr) + sizeof(unsigned long) != TSO(ebbhr)); + BUILD_BUG_ON(TSO(ebbhr) + sizeof(unsigned long) != TSO(bescr)); + + if (!cpu_has_feature(CPU_FTR_ARCH_207S)) + return -ENODEV; + + if (target->thread.used_ebb) + return -ENODATA; + + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &target->thread.ebbrr, 0, sizeof(unsigned long)); + + if (!ret) + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &target->thread.ebbhr, sizeof(unsigned long), + 2 * sizeof(unsigned long)); + + if (!ret) + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &target->thread.bescr, + 2 * sizeof(unsigned long), 3 * sizeof(unsigned long)); + + return ret; +} #endif /* * These are our native regset flavors. @@ -1792,6 +1856,7 @@ enum powerpc_regset { #endif #ifdef CONFIG_PPC_BOOK3S_64 REGSET_TAR, /* TAR register */ + REGSET_EBB, /* EBB registers */ #endif }; @@ -1887,6 +1952,11 @@ static const struct user_regset native_regsets[] = { .size = sizeof(u64), .align = sizeof(u64), .get = tar_get, .set = tar_set }, + [REGSET_EBB] = { + .core_note_type = NT_PPC_EBB, .n = ELF_NEBB, + .size = sizeof(u64), .align = sizeof(u64), + .active = ebb_active, .get = ebb_get, .set = ebb_set + }, #endif }; @@ -2173,6 +2243,11 @@ static const struct user_regset compat_regsets[] = { .size = sizeof(u64), .align = sizeof(u64), .get = tar_get, .set = tar_set }, + [REGSET_EBB] = { + .core_note_type = NT_PPC_EBB, .n = ELF_NEBB, + .size = sizeof(u64), .align = sizeof(u64), + .active = ebb_active, .get = ebb_get, .set = ebb_set + }, #endif };