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 377A83858CDA for ; Fri, 28 Jul 2023 16:30:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 377A83858CDA 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 [96.47.72.80]) (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 4RCCmM0nNdz4FSv; Fri, 28 Jul 2023 16:30:27 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 4RCCmL74Lxz3kgy; Fri, 28 Jul 2023 16:30:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690561827; 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=j1ouXeRiedsEilCZTGPRIbqnUXfww6gHXNPVjxSAEl4=; b=gF2CmOol4FFuvnfJYABM2gmnxv8J4FRFuR9aZgRNBbosgGKMqgZGYcm+/2TQRAb/TZ9CMz EvNAB6HO5HVuDV87RetkSDG4+tXY7KbPeO2IlD1EwQ4PcqP1mpNczkk1eysIYiSDJpoMTm 2QuJuQub27SAQBHSXxo43nwmr2B9NixFETwRYhvCW1zSDtP1tF4qkW8QNSSBbcTx7O8Tni oApW0V6WPsGq07ci8n4Nyr85NRdqWJUSLD3XPFipCncSYPouP/rZwPk9CKzmDIBDGVcdDV DBe5e8AQhKh1uRRGNYK8FXEDDFXuXuz0OLK5G+U44BoYmb4oeSjtxtiUKTauuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690561827; 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=j1ouXeRiedsEilCZTGPRIbqnUXfww6gHXNPVjxSAEl4=; b=HPCYTTdkTg2Hn12i2ogIzeaDsjtVH+ePsZ0srnzsw1gxaikDnK3Ud4A44ZHlXjwfLW0rKs 8Z5yFEZMIPduNzdcu2SX9xUwrNmQ5WyjXvStGXIJ3NCvpvQOqgh9tkTrOySahGu8nyGWsd xlWkz7VT8rXXzytL5LRFlrNrB83oWbM9GqhCCicUvSFRhDnv3MLUE7/8ePwXA7auit9cXk KvIS70xdW6Ve+zg1XAKen1GurMLH6GurlhvkvQpNKCCTbR2tzeVXROoGLOqhZOexFh4i2u RO/pA4nIudmsv3UzUbA6Rwxx7Os0MwAfPuDwLd2wHFkIM7dK608WOM1hIES05Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690561827; a=rsa-sha256; cv=none; b=iSMBNZhmtE/A5Ko0+TqBno92ZJLO147DNluS8NO+QfPPCCJ3Bb17feEIe13I0QBwJ4xsWv tJUpS0iHH5Bm/Pmy5KPfhXxsI8E6/dvSLjuASy1lHLFUVeXvUV+dn3YUO9J1TFHivn/DhH K284fj9P8DXJYz12obz+oVxPIX+a02YJOal55aHwBxHv1bkeD4ch+ZSfY0spy8ZwYmtpZs oqFIO443eO4n9IE22p233zPC+LAL9IG8IG5wRf2LDXuxD05LM8WbvcYY3VUuL1LdTT942w w9HP3QH6UayY4jQG6j0DCwS/hQsKrdCt0shWMOvaGeNnCjgJ7VL2rfY5m2z40Q== Received: from [IPV6:2601:648:8680:16b0:d827:d078:99cc:3ccc] (unknown [IPv6:2601:648:8680:16b0:d827:d078:99cc:3ccc]) (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 4RCCmL3zs4z18p4; Fri, 28 Jul 2023 16:30:26 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Fri, 28 Jul 2023 09:30:24 -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: Simon Marchi , gdb-patches@sourceware.org References: <20230714155151.21723-1-jhb@FreeBSD.org> <20230714155151.21723-9-jhb@FreeBSD.org> <45c8bfbf-42d2-c9d9-d246-0ffd6fc4668c@polymtl.ca> <70fd2a39-f5a4-7188-dd8c-4e0eda971733@FreeBSD.org> From: John Baldwin Subject: Re: [PATCH v6 08/15] gdb: Update x86 Linux architectures to support XSAVE layouts. In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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/27/23 2:48 PM, Simon Marchi wrote: > >> Ooo, that's a good catch. This function is shared with amd64, so I think >> it's best if it keeps returning an xcr0 value, but we could patch >> i386_linux_core_read_description to instead do this: >> >> static const struct target_desc * >> i386_linux_core_read_description (struct gdbarch *gdbarch, >> struct target_ops *target, >> bfd *abfd) >> { >> /* Linux/i386. */ >> x86_xsave_layout layout; >> uint64_t xcr0 = i386_linux_core_read_xsave_info (abfd, layout); >> if (xcr0 == X86_XSTATE_X87_MASK >> && bfd_get_section_by_name (abfd, ".reg-xfp") != NULL) >> xcr0 = X86_XSTATE_SSE_MASK; >> >> return i386_linux_read_description (xcr0); >> } > > And i386_linux_core_read_xsave_info would return X86_XSTATE_X87_MASK if > it does not find a .reg-xstate section? Hmmm. It would need to do something like that yes. I realize I have a bug for i386-fbsd as well where it would return SSE when it should be returning X87. For amd64, both Linux and FreeBSD use FXSAVE (which includes SSE) as .reg2 (generic FP regs). For i386, both use FSAVE (which only includes X87) for .reg2, and Linux/i386 also has .reg-fxp that uses FXSAVE. This means that the "default" xcr0 value really should be SSE for amd64, and X87 for i386. I was considering returning a bool from the helper methods (i386_*_core_read_xsave_info yesterday (it makes the new gdbarch method implementations slightly easier to read IMO). Other options are to add a parameter to the helper that is the "default" value of xcr0 to use, or to return a value of 0 for xcr0 when no valid XSAVE info is found. Returning 0 is pretty close to the bool approach without requiring a dummy xcr0 arg in the gdbarch methods, so I think I'll go with that. In that case, i386_linux_core_read_description would go back to what it was in this patch, but the amd64 version would change slightly: static const struct target_desc * amd64_linux_core_read_description (struct gdbarch *gdbarch, struct target_ops *target, bfd *abfd) { /* Linux/x86-64. */ x86_xsave_layout layout; uint64_t xcr0 = i386_linux_core_read_xsave_info (abfd, layout); if (xcr0 == 0) xcr0 = X86_XSTATE_SSE_MASK; return amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK, gdbarch_ptr_bit (gdbarch) == 32); } Namely to add the 'xcr == 0' case. If that approach seems sensible I will post a new series since it touches both this patch and the FreeBSD one. -- John Baldwin