From: Jan Beulich <jbeulich@suse.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: Henry.Wang@arm.com, "Andrew Cooper" <andrew.cooper3@citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>,
"Wei Liu" <wl@xen.org>, "Edwin Török" <edvin.torok@citrix.com>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH for-4.17?] x86/paging: return -EINVAL for paging domctls for dying domains
Date: Wed, 9 Nov 2022 08:48:46 +0100 [thread overview]
Message-ID: <76cde159-088a-3351-56e2-0cf14e9c8116@suse.com> (raw)
In-Reply-To: <Y2qOtSyuM43RfwAx@Air-de-Roger>
On 08.11.2022 18:15, Roger Pau Monné wrote:
> On Tue, Nov 08, 2022 at 06:03:54PM +0100, Jan Beulich wrote:
>> On 08.11.2022 17:43, Roger Pau Monné wrote:
>>> On Tue, Nov 08, 2022 at 05:14:40PM +0100, Jan Beulich wrote:
>>>> On 08.11.2022 12:38, Roger Pau Monne wrote:
>>>>> Like on the Arm side, return -EINVAL when attempting to do a p2m
>>>>> operation on dying domains.
>>>>>
>>>>> The current logic returns 0 and leaves the domctl parameter
>>>>> uninitialized for any parameter fetching operations (like the
>>>>> GET_ALLOCATION operation), which is not helpful from a toolstack point
>>>>> of view, because there's no indication that the data hasn't been
>>>>> fetched.
>>>>
>>>> While I can see how the present behavior is problematic when it comes
>>>> to consuming supposedly returned data, ...
>>>>
>>>>> --- a/xen/arch/x86/mm/paging.c
>>>>> +++ b/xen/arch/x86/mm/paging.c
>>>>> @@ -694,9 +694,10 @@ int paging_domctl(struct domain *d, struct xen_domctl_shadow_op *sc,
>>>>>
>>>>> if ( unlikely(d->is_dying) )
>>>>> {
>>>>> - gdprintk(XENLOG_INFO, "Ignoring paging op on dying domain %u\n",
>>>>> + gdprintk(XENLOG_INFO,
>>>>> + "Tried to do a paging domctl op on dying domain %u\n",
>>>>> d->domain_id);
>>>>> - return 0;
>>>>> + return -EINVAL;
>>>>> }
>>>>
>>>> ... going from "success" to "failure" here has a meaningful risk of
>>>> regressing callers. It is my understanding that it was deliberate to
>>>> mimic success in this case (without meaning to assign "good" or "bad"
>>>> to that decision).
>>>
>>> I would assume that was the original intention, yes, albeit the commit
>>> message doesn't go into details about why mimicking success is
>>> required, it's very well possible the code relying on this was xend.
>>
>> Quite possible, but you never know who else has cloned code from there.
>>
>>>> Can you instead fill the data to be returned in
>>>> some simple enough way? I assume a mere memset() isn't going to be
>>>> good enough, though (albeit public/domctl.h doesn't explicitly name
>>>> any input-only fields, so it may not be necessary to preserve
>>>> anything). Maybe zeroing ->mb and ->stats would do?
>>>
>>> Hm, it still feels kind of wrong. We do return errors elsewhere for
>>> operations attempted against dying domains, and that seems all fine,
>>> not sure why paging operations need to be different in this regard.
>>> Arm does also return -EINVAL in that case.
>>>
>>> So what about postponing this change to 4.18 in order to avoid
>>> surprises, but then taking it in its current form at the start of the
>>> development window, as to have time to detect any issues?
>>
>> Maybe, but to be honest I'm not convinced. Arm can't really be taken
>> for comparison, since the op is pretty new there iirc.
>
> Indeed, but the tools code paths are likely shared between x86 and
> Arm, as the hypercalls are the same.
On x86 we have both xc_shadow_control() and (functional)
xc_logdirty_control(); on Arm only the former is used, while the latter
would also be impacted by your change. Plus you're not accounting for
external tool stacks (like xend would be if anyone had cared to forward
port it, when - as you said earlier - the suspicion is that the original
change was made to "please" xend).
> This is a domctl interface, so we are fine to do such changes.
We're fine to make changes to domctl which are either binary compatible
with earlier versions or which are associated with a bump of the
interface version. The latter wouldn't help in this case, while the
former is simply not true here. For Andrew's proposed new paging pool
interface the behavior suggested here would of course be fully
appropriate, demanding that tool stack either don't issue such requests
against dying domains or that they be prepared to get back errors.
Thinking about it again I'm also not convinced EINVAL is an appropriate
error code to use here. The operation isn't necessarily invalid; we
only prefer to not carry out any such anymore. EOPNOTSUPP, EPERM, or
EACCES would all seem more appropriate. Or, for ease of recognition, a
rarely used one, e.g. ENODATA, EILSEQ, or EROFS.
Finally I'm not convinced of the usefulness of this dying check in the
first place: is_dying may become set immediately after the check was
done.
Jan
> I
> understand that we want to avoid such interface changes as much as
> possible, but I think we need to fix the hypercall to return error
> codes rather than implementing workarounds to try to cope with a wrong
> interface behavior in the first place. Or else we could be
> accumulation workarounds here in order to fool caller into thinking
> the hypercall has somehow succeed, and provide kind of suitable
> looking data for the output parameters.
next prev parent reply other threads:[~2022-11-09 7:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 11:38 [PATCH for-4.17?] x86/paging: return -EINVAL for paging domctls for dying domains Roger Pau Monne
2022-11-08 16:14 ` Jan Beulich
2022-11-08 16:43 ` Roger Pau Monné
2022-11-08 17:03 ` Jan Beulich
2022-11-08 17:15 ` Roger Pau Monné
2022-11-09 7:48 ` Jan Beulich [this message]
2022-11-09 9:45 ` Edwin Torok
2022-11-09 9:58 ` Jan Beulich
2022-11-09 10:11 ` Roger Pau Monné
2022-11-09 10:23 ` Jan Beulich
2022-11-09 11:36 ` Roger Pau Monné
2022-11-09 12:02 ` Jan Beulich
2022-11-09 13:22 ` Roger Pau Monné
2022-11-10 9:03 ` Jan Beulich
2022-11-08 17:30 ` Edwin Torok
2022-11-09 16:11 ` Andrew Cooper
2022-11-10 9:02 ` 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=76cde159-088a-3351-56e2-0cf14e9c8116@suse.com \
--to=jbeulich@suse.com \
--cc=Henry.Wang@arm.com \
--cc=andrew.cooper3@citrix.com \
--cc=edvin.torok@citrix.com \
--cc=george.dunlap@citrix.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.