From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
"Jinoh Kang" <jinoh.kang.kr@gmail.com>,
Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH 1/3] x86: Reject bad %dr6/%dr7 values when loading guest state
Date: Wed, 30 Aug 2023 16:28:44 +0100 [thread overview]
Message-ID: <2ced7357-b8ec-e071-9ce5-c4d23b1a6a03@citrix.com> (raw)
In-Reply-To: <0708d6fd-2672-a0f9-e782-83e6eb66dbeb@suse.com>
On 30/08/2023 4:12 pm, Jan Beulich wrote:
> On 30.08.2023 16:35, Andrew Cooper wrote:
>> On 29/08/2023 3:08 pm, Jan Beulich wrote:
>>> On 29.08.2023 15:43, Andrew Cooper wrote:
>>>> --- a/xen/arch/x86/domain.c
>>>> +++ b/xen/arch/x86/domain.c
>>>> @@ -1074,8 +1074,27 @@ int arch_set_info_guest(
>>>> #endif
>>>> flags = c(flags);
>>>>
>>>> + if ( !compat )
>>>> + {
>>>> + if ( c(debugreg[6]) != (uint32_t)c(debugreg[6]) ||
>>>> + c(debugreg[7]) != (uint32_t)c(debugreg[7]) )
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>> if ( is_pv_domain(d) )
>>>> {
>>>> + /*
>>>> + * Prior to Xen 4.11, dr5 was used to hold the emulated-only
>>>> + * subset of dr7, and dr4 was unused.
>>>> + *
>>>> + * In Xen 4.11 and later, dr4/5 are written as zero, ignored for
>>>> + * backwards compatibility, and dr7 emulation is handled
>>>> + * internally.
>>>> + */
>>>> + for ( i = 0; i < ARRAY_SIZE(v->arch.dr); i++ )
>>>> + if ( !access_ok(c(debugreg[i]), sizeof(long)) )
>>> Don't you mean __addr_ok() here, i.e. not including the
>>> is_compat_arg_xlat_range() check? (Else I would have asked why
>>> sizeof(long), but that question resolves itself with using the other
>>> macro.)
>> For now, I'm simply moving a check from set_debugreg() earlier in
>> arch_set_info_guest().
>>
>> I think it would be beneficial to keep that change independent.
> Hmm, difficult. I'd be okay if you indeed moved the other check. But
> you duplicate it here, and duplicating questionable code is, well,
> questionable.
It can't be removed in set_debugreg() because that's used in other paths
too.
And the error from set_debugreg() can't fail arch_set_info_guest()
because that introduces a failure after mutation of the vCPU state.
This isn't a fastpath. It's used approximately once per vCPU lifetime.
~Andrew
next prev parent reply other threads:[~2023-08-30 15:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 13:43 [PATCH 0/3] x86: Debug Regs fixes, part 1 Andrew Cooper
2023-08-29 13:43 ` [PATCH 1/3] x86: Reject bad %dr6/%dr7 values when loading guest state Andrew Cooper
2023-08-29 14:08 ` Jan Beulich
2023-08-30 14:35 ` Andrew Cooper
2023-08-30 15:12 ` Jan Beulich
2023-08-30 15:28 ` Andrew Cooper [this message]
2023-08-30 16:13 ` Jan Beulich
2023-08-30 17:02 ` Andrew Cooper
2023-08-31 6:08 ` Jan Beulich
2023-08-30 6:46 ` Jan Beulich
2023-08-30 14:39 ` Andrew Cooper
2023-08-29 13:43 ` [PATCH 2/3] x86: Introduce new debug.c for debug register infrastructure Andrew Cooper
2023-08-29 14:10 ` Jan Beulich
2023-08-29 14:25 ` Andrew Cooper
2023-08-29 13:43 ` [PATCH 3/3] x86: Fix calculation of %dr6/dr7 reserved bits Andrew Cooper
2023-08-29 14:21 ` Jan Beulich
2023-08-29 14:29 ` Andrew Cooper
2023-08-29 15:47 ` Jan Beulich
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=2ced7357-b8ec-e071-9ce5-c4d23b1a6a03@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=jinoh.kang.kr@gmail.com \
--cc=roger.pau@citrix.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.