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 06FA83858D28 for ; Tue, 11 Apr 2023 16:25:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 06FA83858D28 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 4Pwrmd6L6Yz4KQ5; Tue, 11 Apr 2023 16:25:37 +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 4Pwrmd51pzz3p7l; Tue, 11 Apr 2023 16:25:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681230337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AlzZXpunQeS3Sn3urxBz5ySnLkaVsl2noN0314lBFRU=; b=QiUNO5uzvMpaVyGhRiuaHJl6YkauOBlVAbgkW25w3cKXlYpCo1YgFqNVmZ9X0++8Wx0zZl pcwBVTqpWSFwT+76emo+6Yjzoc/UppcRTRswGqlXCQ3nrRnTPocDb0raR7xDoW+p4kCwvz +9DyP3JbnCTtOTDv4Vmjm3zZUMI1WFINpoa+DvsiatH88iz4Kh1FBJ8odWptMFTaT6slsC ZfYoZvbu9f/puUmGZHNl3W+guIlb4WuimG405sEl3OFem3YDigdhmsy2V2XLRbC90PsFAi 6PRKje9nY72YOA7fLzeN7WM++zctCCvsN9AUtArIQ5cGbPboctJnKzYxUVjYLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681230337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AlzZXpunQeS3Sn3urxBz5ySnLkaVsl2noN0314lBFRU=; b=Ru1YsvZtDX02PYMpw5VEh3CZJwd24pHYD67j3fG5rHzM9t1yX6jZE6c9pvKVwzBVOlCQum z31y0yYsUManb1/amQFIQZhRtolAkX58XFWOorTGvBsEvRp3eHKpyJ9944DjlO+pB/mdKJ mNlazbyWbB5kysIRQt8DotSIuDiI2jB0ek81XONaGpi3c7PR3iRsDz4572OQ2H7XvBQGhZ gONtmGW2FAmbx8hOfsIMi4/aJe8vhxfNySwo4x9+d+KOOXKrxjoF5oeR58oRVvSmK3vXhI A80Mr+YVrICv5dU3AsCjnQWd/qavW5RuLSF4e1cbTg/0pavRJnBJWfLzYd4ASg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681230337; a=rsa-sha256; cv=none; b=l335yDYLH44f8XcBCQTu3yVfM86znpke04nUJHhUy3CNIPpNXSysn1VeoyvBrmcyfmi6bm G5gtQDmGnyfO48xVRh5rPso8gmzNgAgthrYgq20X6fXn3W9Cp+t6a+6uVOund0vEvuRvQL sFUfMpJVmvjFSumY9MT2a5/obXwrUuHObXNeTHQILU0tgPSbzmjV/uYqojMAzsS/3A9y0T Wv96j+2yQNCNzd5j4qrIFdWRAz/cDqY1HrsTgfzA5tvT5EFfJyxEM8ZsCQbk43QII3fbi+ EOBZBaOWB4f1YYzqLv5I6Z82GSP+o0bKXUE3YFC+AuLenWueZfwC65xwZj5o4g== Received: from [IPV6:2601:648:8680:16b0:14bb:55bb:f654:b139] (unknown [IPv6:2601:648:8680:16b0:14bb:55bb:f654:b139]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4Pwrmd1WbVz14PD; Tue, 11 Apr 2023 16:25:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Tue, 11 Apr 2023 09:25:36 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US To: Pedro Alves , gdb-patches@sourceware.org Cc: Aleksandar Paunovic References: <20230318010905.14294-1-jhb@FreeBSD.org> <20230318010905.14294-13-jhb@FreeBSD.org> <856d374c-9fd4-0db3-2bee-60850604c16a@palves.net> From: John Baldwin Subject: Re: [PATCH v4 12/13] gdbserver: Read offsets of the XSAVE extended region via CPUID In-Reply-To: <856d374c-9fd4-0db3-2bee-60850604c16a@palves.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP 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 4/11/23 7:46 AM, Pedro Alves wrote: > On 2023-03-18 1:09 a.m., John Baldwin wrote: > >> SDM recommends to obtain memory offsets values only by calling CPUID >> because they can change depending on the CPU mode. > > I'm not sure what this sentence is saying -- only by calling CPUID, as > opposed to doing what instead? Is this saying that consulting CPUID > for the host (the machine running gdbserver in this case) returns the correct > result even if gdbserver is 64 bit, and the inferior is 32 bit, but that > with some other method (but which?) it wouldn't? Humm, I hadn't reworded Aleksandar's message, but I should perhaps clarify this part. I think the layout of XSAVE does not change between 32-bit and 64-bit inferiors while you are in long mode (and for most (all relevant?) OS's you are doing the XSAVE in the kernel which is always 64-bit). I do think that in theory the layout might change based on the enabled mask in XCR0. Certainly the "compact" layout (which OS's currently do not expose to debuggers) changes based on the XCR0 layout (right now FreeBSD doesn't use the cmopact format in the kernel, and Linux is careful to expand the "compact" format out to the "standard" format when exporting XSAVE state as a register set for ptrace and core dumps). Also, I think the alternative to doing CPUID is what GDB does today which is to have a set of hard-coded constants describing the starting offset of each region in the extended save area. -- John Baldwin