From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id 69730385AFAD for ; Tue, 25 Jul 2023 18:59:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69730385AFAD Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4R9RCF6nTQz3FwY; Tue, 25 Jul 2023 18:59:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R9RCF63QZz3xDm; Tue, 25 Jul 2023 18:59:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690311545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fRxBbqS95KfLLeXLrMQwaAvbPyoCQBY4GXFNQZGOPZE=; b=DA4y2lrbn1gv4+KpJK+bRT1GjjJu4EBWtPJxUSZIIdagc8ZzWmU29jMAizjqR1bkdKOe/W /su2j0hKbKOfUpgRiDYmCEWcIJAXsGClyUWsyFTwgPTzsCPYKKI29psP0TbXPLVMtFMgo1 He0UsZrJvZcbHlbuLKvKGhKlXv+/mLftFAGksyDukYpv+kixT2xh1RWPM5oCbOkbTp8Jvy 3Mz887agoRt3FKls+5knhL/JDqeT+Jz4bzYNttz8MiUUaSpnLy9tjOiXFWBaPCmirNw7I+ YAKbPqT3FRvKLjqfiM3wjVi67HwVowl3FP0h1MrqVkJg2xbzvi9Gdll6qOthvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690311545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fRxBbqS95KfLLeXLrMQwaAvbPyoCQBY4GXFNQZGOPZE=; b=EQ3ZJjcsHHecTTz+9uQuz1RBC0gnnQpcRFLYFjordUR8oByGVefHyJUXIJSr2cOcT4a9Eb aRy7ROnuMR17JFPKE7MiEdJtqSe2yQtfQt2NG9ZcEzPHxfpddG1A06bMWiP9WYAVZqMbOw TRpwhaeX95n9Hj94J54XZHepN5LVFdVx70c5zAYSNINh4ZuZdpHahETNsnV5UabX//+nQl 1FnNeqJ/nfTP341FWfiHm5jqy7UgFi/B7k0QTsL6eNq97kovGFysFaXpJ5m/8icMRQcdhw M+8S/jJWliH9vx3ccjw3af9DppESgW/wCVsdAxVdeLXBnCBEm6I2Vq4gQckP9A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690311545; a=rsa-sha256; cv=none; b=B47PacDGmqOijxtKb/BZQ1PF8yeSOb+8cDTedvf0D04ugkF/otXIhd4QyYRRg07HARtFn1 b/eq0Gs/M8rXywpp7SBj70BWSPpwfIh17VRa3o8c66yZv/AMa42nqWx85yv8tZLi/DPb9V enjxFn7kg1C8rh+Cv9jgl9F+rBoFkpczhGc7jWbN5IaTlQ8Z5nUUz2dWtN0kBteJ0oUEam Clrz2URFjtUHi9lgdKi32epLHPIAqXrqEAatwO3ja0wHozaW+8BRErmymd4QZMBnYsOl9f tc/5aiu3hSWGJJemr6jIN/fqcPdlfYSoB/iADDjwQBnIHI2MbT/WPVhVd4kb3Q== Received: from [IPV6:2601:648:8680:16b0:3097:7875:9e86:db21] (unknown [IPv6:2601:648:8680:16b0:3097:7875:9e86:db21]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4R9RCF3Ckdzkmd; Tue, 25 Jul 2023 18:59:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <6a412964-2a25-da39-7c3b-38050437795a@FreeBSD.org> Date: Tue, 25 Jul 2023 11:59:03 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: Keith Seitz , gdb-patches@sourceware.org References: <20230714155151.21723-1-jhb@FreeBSD.org> From: John Baldwin Subject: Re: [PATCH v6 00/15] Handle variable XSAVE layouts In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 7/25/23 11:43 AM, Keith Seitz wrote: > On 7/25/23 11:15, John Baldwin wrote: >> On 7/25/23 10:17 AM, Keith Seitz wrote: >>> On 7/14/23 08:51, John Baldwin wrote: >>> 0x55ef54d4e9bf memcpy >>>           /usr/include/bits/string_fortified.h:29 >>> 0x55ef54d4e9bf _Z18i387_collect_xsavePK8regcacheiPvi >>>           ../../gdb/i387-tdep.c:1543 >> >> Can you confirm where this is in your patched copy?  For me this line is here: >> >>   if (gcore) >>     { >>       /* Clear XSAVE extended state.  */ >>       memset (regs, 0, tdep->xsave_layout.sizeof_xsave); >> >>       /* Update XCR0 and `xstate_bv' with XCR0 for gcore.  */ >>       if (tdep->xsave_xcr0_offset != -1) >>>>>     memcpy (regs + tdep->xsave_xcr0_offset, &tdep->xcr0, 8); >>       memcpy (XSAVE_XSTATE_BV_ADDR (regs), &tdep->xcr0, 8); >>     } > > Yes, that's the problem spot. > >> If you have a core handy, could you provide the output of 'p tdep->xsave_layout' >> and 'p tdep->xsave_xcr0_offset'? >> > > I do have a corefile: > > (gdb) up > #6 i387_collect_xsave (regcache=0x5568a96b1ab0, regnum=-1, xsave=0x0, gcore=1) > at ../../gdb/i387-tdep.c:1543 > 1543 memcpy (regs + tdep->xsave_xcr0_offset, &tdep->xcr0, 8); > (gdb) p tdep->xsave_layout > $1 = {sizeof_xsave = 0, avx_offset = 0, bndregs_offset = 0, bndcfg_offset = 0, > k_offset = 0, zmm_h_offset = 0, zmm_offset = 0, pkru_offset = 0} > (gdb) p tdep->xsave_xcr0_offset > $2 = 464 > > If there's anything I can do to help, please do not hesitate to ask! Hmm, I would not expect to have an empty layout (xsave_layout.sizeof_xsave == 0) and then calling collect_xsave. We only call collect_xsave in i386_linux_tdep.c if tdep->xcr0 indicates AVX is present. Possibly we should only call it if tdep->xsave_layout.sizeof_xsave != 0 instead (that is what I think I did on the FreeBSD arches). That said, the inconsistency in tdep->xcr0 vs xsave_layout could be problematic elsewhere so I'd rather root it out. Can you please run a failing test with this local patch: diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index d5423681802..dab3428c8e6 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -8383,6 +8383,8 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep, if (!feature_sse) return 0; + gdb_assert(tdep->xsave_layout.sizeof_xsave != 0); + if (!feature_avx512) tdep->xcr0 = X86_XSTATE_AVX_MASK; @@ -8768,12 +8770,12 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) info.tdesc_data = tdesc_data.get (); gdbarch_init_osabi (info, gdbarch); + tdep->xsave_layout = xsave_layout; if (!i386_validate_tdesc_p (tdep, tdesc_data.get ())) { gdbarch_free (gdbarch); return NULL; } - tdep->xsave_layout = xsave_layout; num_bnd_cooked = (tdep->bnd0r_regnum > 0 ? I387_NUM_BND_REGS : 0); Hopefully it triggers the assertion, and then what will be useful is to see what features the tdesc contains ('info locals' would cover that if they aren't all optimized out). -- John Baldwin