From patchwork Mon May 21 20:44:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pedromfc X-Patchwork-Id: 27379 Received: (qmail 15063 invoked by alias); 21 May 2018 20:46:29 -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 14876 invoked by uid 89); 21 May 2018 20:46:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 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=5406 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 May 2018 20:46:25 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4LKipkK078274 for ; Mon, 21 May 2018 16:46:24 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j42xbwmk0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 21 May 2018 16:46:23 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 21 May 2018 14:46:23 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 21 May 2018 14:46:20 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4LKkIbZ11338128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 21 May 2018 13:46:18 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E78A1BE038; Mon, 21 May 2018 14:46:17 -0600 (MDT) Received: from pedro.localdomain (unknown [9.18.235.153]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id B32B7BE03B; Mon, 21 May 2018 14:46:17 -0600 (MDT) Received: by pedro.localdomain (Postfix, from userid 1000) id 6282A3C03BB; Mon, 21 May 2018 17:45:45 -0300 (-03) From: Pedro Franco de Carvalho To: gdb-patches@sourceware.org Cc: uweigand@de.ibm.com Subject: [PATCH v2 3/8] [PowerPC] Disable regsets using zero sizes in gdbserver Date: Mon, 21 May 2018 17:44:53 -0300 In-Reply-To: <20180521204458.19070-1-pedromfc@linux.vnet.ibm.com> References: <20180510195840.17734-1-pedromfc@linux.vnet.ibm.com> <20180521204458.19070-1-pedromfc@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18052120-8235-0000-0000-00000D8AACC0 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009062; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000261; SDB=6.01035688; UDB=6.00529761; IPR=6.00814816; MB=3.00021228; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-21 20:46:22 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052120-8236-0000-0000-0000411196EF Message-Id: <20180521204458.19070-3-pedromfc@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-21_08:, , 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-1805210246 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 | 45 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c index 30fcd4115a..b440b0e0a7 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 @@ -619,7 +601,9 @@ static void ppc_arch_setup (void) { const struct target_desc *tdesc; + struct regset_info *regset; struct ppc_linux_features features = ppc_linux_no_features; + int tid = lwpid_of (current_thread); features.wordsize = ppc_linux_target_wordsize (tid); @@ -671,6 +655,25 @@ 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; + else + regset->size = 0; + break; + default: + break; + } } /* Implementation of linux_target_ops method "supports_tracepoints". */