From: John Baldwin <jhb@FreeBSD.org>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: palves@redhat.com, gdb-patches@sourceware.org
Subject: Re: [PATCH] Add support for the x86 XSAVE extended state on FreeBSD/x86.
Date: Sat, 21 Mar 2015 22:29:00 -0000 [thread overview]
Message-ID: <550DF0AA.9070707@FreeBSD.org> (raw)
In-Reply-To: <201503212018.t2LKI3jm000615@glazunov.sibelius.xs4all.nl>
On 3/21/15 4:18 PM, Mark Kettenis wrote:
>> That could be reused for the core read_description callback as
>> well as the native ones. This could also be reused by other
>> systems that grow XSAVE support in the future.
>
> Probably a good idea. I'm working on XSAVE support in the OpenBSD
> kernel, so I'll eventually need this as well.
>
> I have no real objection to adding the ptrace-specific bits to the
> generic BSD native code like your diff is doing. I'll probably try to
> use the same interface for my OpenBSD implementation. I have one
> concern about that code though. The _supply_xsave() and
> _collect_xsave() functions don't accept a length, so they can't do any
> bounds checking. Therefore, 'xstat_bv' as returned by the kernel must
> be set correctly (i.e. not have bits sets that imply state beyond
> x86_save_len is present. Does the FreeBSD kernel guarantee that?
FreeBSD determines a system-wide xsave mask during boot and then leaves
%xcr0 unchanged. The x86_xstate_len returned by PT_GETXSTATE_INFO is
also determined at boot time and doesn't change after that. The kernel
does assume that xsave/xsaveopt do not store any bits in xstate_bv that
aren't set in %xcr0. Attempts to restore a saved state via PT_SETXSTATE
that set a bit in xstate_bv that isn't set in %xcr0 results in
PT_SETXSTATE failing. Those should ensure that xstate_bv does not
return an invalid length.
However, we could do additional bounds checking in the routines in
*bsd-nat.c by making them compare X86_XSTATE_SIZE(xstate_bv) against
x86_xstate_len and fail if x86_xstate_len is too small.
> Oh, and please rename x86_xsave_len into amd64bsd_xsave_len and
> i386bsd_xsave_len to keep the "namesapce" clean.
Will do.
--
John Baldwin
prev parent reply other threads:[~2015-03-21 22:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-16 14:50 John Baldwin
2015-03-18 20:00 ` Pedro Alves
2015-03-21 19:14 ` John Baldwin
2015-03-21 20:18 ` Mark Kettenis
2015-03-21 22:29 ` John Baldwin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=550DF0AA.9070707@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox