Re: PATCH: 1/6: Add AVX support

H.J. Lu
2010-03-04T19:29:47Z

On Thu, Mar 4, 2010 at 11:09 AM, Daniel Jacobowitz <dan@codesourcery.com> wrote:
> On Thu, Mar 04, 2010 at 10:02:19AM -0800, H.J. Lu wrote:
>> 4. Remote gdb protocol extension. GDB will send
>>
>> x86:xstate=BYTES:xcr0=VALUE
>>
>> in qSupported request packet to indicate that GDB supports x86 XSAVE
>> extended state. BYTES specifies the maximum size in bytes of x86 XSAVE
>> extended state GDB supports. VALUE specifies the maximum value of XCR0
>> GDB supports.  Gdbserver will select the best target description
>> supported by GDB, based on BYTES and VALUE. The older gdbserver will
>> always return SSE target.
>
> The whole point of target descriptions, and the thing we've been going
> to so much trouble to implement for the past month, is that this
> negotiation is not supposed to be needed.  Why does it matter what GDB
> supports?  If there are new registers that GDB does not know about,
> in the target description supplied by gdbserver, then GDB will not use
> them specially for debug info or function calls.  But it will
> otherwise handle them fine.
>

AVX registers aren't new registers, on top of SSE registers. AVX
registers are the super set of SSE registers. XMM0 is the alias
of the lower 128bit of YMM0. So we have either SSE target or
AVX target, depending on the processor/OS. We may have
remote gdb stub on an AVX processor/OS. But gdb, which
the stub is talking to, may not support AVX at all. If the stub
sends the AVX target description to gdb, gdb won't understand it
and will fail.

This may not be a serious issue today since the new stub with
x86 XML target descriptions can only talk to gdb with x86 XML
support, which very likely supports AVX XML. But between my x86
XML checkin and AVX checkin, there are some snapshots of
gdb, which only supports SSE XML. If gdbserver sends AVX
XML to them, those gdbs will fail.

In the future, we will add more states to XSAVE extended state
and we will extend gdb to support them. Gdbserver should
send the XML target, which is supported by gdb, to gdb so
that the new x86 gdb stub can talk to older gdb with x86
XML support.. The XCR0 bits in qSupported request packet
are used for this purpose to provide forward compatibility.

--
H.J.