From patchwork Thu May 10 19:58:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pedromfc X-Patchwork-Id: 27208 Received: (qmail 47033 invoked by alias); 10 May 2018 19:59:21 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 46962 invoked by uid 89); 10 May 2018 19:59:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=ev0 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 May 2018 19:59:16 +0000 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4AJx0PG024029 for ; Thu, 10 May 2018 15:59:15 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hvum6tqsq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 May 2018 15:59:14 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 May 2018 15:59:13 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 10 May 2018 15:59:10 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4AJx9h965404994 for ; Thu, 10 May 2018 19:59:09 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9187FAC046 for ; Thu, 10 May 2018 16:00:41 -0400 (EDT) Received: from pedro.localdomain (unknown [9.18.235.221]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id 66184AC041 for ; Thu, 10 May 2018 16:00:41 -0400 (EDT) Received: by pedro.localdomain (Postfix, from userid 1000) id 66E8A3C03DC; Thu, 10 May 2018 16:59:07 -0300 (-03) From: Pedro Franco de Carvalho To: gdb-patches@sourceware.org Subject: [PATCH 3/8] [PowerPC] Disable regsets using zero sizes in gdbserver Date: Thu, 10 May 2018 16:58:35 -0300 In-Reply-To: <20180510195840.17734-1-pedromfc@linux.vnet.ibm.com> References: <20180510195840.17734-1-pedromfc@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18051019-0044-0000-0000-000004129C9F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009001; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000259; SDB=6.01030392; UDB=6.00526595; IPR=6.00809523; MB=3.00021034; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-10 19:59:11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051019-0045-0000-0000-00000844ABF8 Message-Id: <20180510195840.17734-4-pedromfc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-10_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805100185 X-IsSubscribed: yes Currently the linux-ppc-low.c fill/store functions for extended regsets check whether they should execute by using the global hwcap variable. This patch explicitly sets the regset sizes to zero when needed to disable them instead, so that the fill/store functions are not called in the first place by regsets_fetch_inferior_registers in linux-low.c. gdb/gdbserver/ChangeLog: yyyy-mm-dd Pedro Franco de Carvalho * linux-ppc-low.c (ppc_fill_vsxregset): Remove ppc_hwcap check. (ppc_store_vsxregset): Likewise. (ppc_fill_vrregset): Likewise. (ppc_store_vrregset): Likewise. (ppc_fill_evrregset): Likewise. (ppc_store_evrregset): Likewise. (ppc_regsets): Set VSX/VR/EVR regset sizes to 0. (ppc_arch_setup): Iterate through ppc_regsets and set sizes when needed. --- gdb/gdbserver/linux-ppc-low.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c index a4182633d7..825b46219c 100644 --- a/gdb/gdbserver/linux-ppc-low.c +++ b/gdb/gdbserver/linux-ppc-low.c @@ -467,9 +467,6 @@ ppc_fill_vsxregset (struct regcache *regcache, void *buf) int i, base; char *regset = (char *) buf; - if (!(ppc_hwcap & PPC_FEATURE_HAS_VSX)) - return; - base = find_regno (regcache->tdesc, "vs0h"); for (i = 0; i < 32; i++) collect_register (regcache, base + i, ®set[i * 8]); @@ -481,9 +478,6 @@ ppc_store_vsxregset (struct regcache *regcache, const void *buf) int i, base; const char *regset = (const char *) buf; - if (!(ppc_hwcap & PPC_FEATURE_HAS_VSX)) - return; - base = find_regno (regcache->tdesc, "vs0h"); for (i = 0; i < 32; i++) supply_register (regcache, base + i, ®set[i * 8]); @@ -497,9 +491,6 @@ ppc_fill_vrregset (struct regcache *regcache, void *buf) int i, base; char *regset = (char *) buf; - if (!(ppc_hwcap & PPC_FEATURE_HAS_ALTIVEC)) - return; - base = find_regno (regcache->tdesc, "vr0"); for (i = 0; i < 32; i++) collect_register (regcache, base + i, ®set[i * 16]); @@ -514,9 +505,6 @@ ppc_store_vrregset (struct regcache *regcache, const void *buf) int i, base; const char *regset = (const char *) buf; - if (!(ppc_hwcap & PPC_FEATURE_HAS_ALTIVEC)) - return; - base = find_regno (regcache->tdesc, "vr0"); for (i = 0; i < 32; i++) supply_register (regcache, base + i, ®set[i * 16]); @@ -538,9 +526,6 @@ ppc_fill_evrregset (struct regcache *regcache, void *buf) int i, ev0; struct gdb_evrregset_t *regset = (struct gdb_evrregset_t *) buf; - if (!(ppc_hwcap & PPC_FEATURE_HAS_SPE)) - return; - ev0 = find_regno (regcache->tdesc, "ev0h"); for (i = 0; i < 32; i++) collect_register (regcache, ev0 + i, ®set->evr[i]); @@ -555,9 +540,6 @@ ppc_store_evrregset (struct regcache *regcache, const void *buf) int i, ev0; const struct gdb_evrregset_t *regset = (const struct gdb_evrregset_t *) buf; - if (!(ppc_hwcap & PPC_FEATURE_HAS_SPE)) - return; - ev0 = find_regno (regcache->tdesc, "ev0h"); for (i = 0; i < 32; i++) supply_register (regcache, ev0 + i, ®set->evr[i]); @@ -579,11 +561,11 @@ static struct regset_info ppc_regsets[] = { fetch them every time, but still fall back to PTRACE_PEEKUSER for the general registers. Some kernels support these, but not the newer PPC_PTRACE_GETREGS. */ - { PTRACE_GETVSXREGS, PTRACE_SETVSXREGS, 0, SIZEOF_VSXREGS, EXTENDED_REGS, + { PTRACE_GETVSXREGS, PTRACE_SETVSXREGS, 0, 0, EXTENDED_REGS, ppc_fill_vsxregset, ppc_store_vsxregset }, - { PTRACE_GETVRREGS, PTRACE_SETVRREGS, 0, SIZEOF_VRREGS, EXTENDED_REGS, + { PTRACE_GETVRREGS, PTRACE_SETVRREGS, 0, 0, EXTENDED_REGS, ppc_fill_vrregset, ppc_store_vrregset }, - { PTRACE_GETEVRREGS, PTRACE_SETEVRREGS, 0, 32 * 4 + 8 + 4, EXTENDED_REGS, + { PTRACE_GETEVRREGS, PTRACE_SETEVRREGS, 0, 0, EXTENDED_REGS, ppc_fill_evrregset, ppc_store_evrregset }, { 0, 0, 0, 0, GENERAL_REGS, ppc_fill_gregset, NULL }, NULL_REGSET @@ -620,6 +602,7 @@ ppc_arch_setup (void) { const struct target_desc *tdesc; struct ppc_linux_features features = ppc_linux_no_features; + struct regset_info *regset; int tid = lwpid_of (current_thread); @@ -672,6 +655,23 @@ ppc_arch_setup (void) #endif current_process ()->tdesc = tdesc; + + for (regset = ppc_regsets; regset->size >= 0; regset++) + switch (regset->get_request) + { + case PTRACE_GETVRREGS: + regset->size = features.altivec ? SIZEOF_VRREGS : 0; + break; + case PTRACE_GETVSXREGS: + regset->size = features.vsx ? SIZEOF_VSXREGS : 0; + break; + case PTRACE_GETEVRREGS: + if (ppc_hwcap & PPC_FEATURE_HAS_SPE) + regset->size = 32 * 4 + 8 + 4; + break; + default: + break; + } } /* Implementation of linux_target_ops method "supports_tracepoints". */