[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.17?] x86/paging: return -EINVAL for paging domctls for dying domains


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 8 Nov 2022 18:15:33 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=V9+hvvG2mqZMLMmDMzXi42EbSUyCbjQSm+0O55VfEdk=; b=E6UQxgloCfJlBZh+xJcjufDRbE7UDPF3fqBc72lMYseMSpoT0KgrjAsjTeHKt2SHY81IWijxaH2XBi1D9byEfc4VBHInxKhAk1Xs7VhyfjfcOQfVusigN32mQklQPWc1XCuy4rlUNQIhcuPvyarYPNY19e4ncPPLGnDElSg8sQsc+uzqW5E0PaT6MRfI/DqRbfGgE+zT8KRa/S0THabDqgkmHzRlgqquIVIfF+hsvN58HokmaCa8WzrqyL59YFNGUN4MPsVB9nEYyD/84MHm68Iu+KAKrj80rq0sg509FDn6vwwPzxaBpverZ1zSAvRjC1QOC4FFRDfKBbSMTsjSGQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fdUWhzwYFLbf94YHHSwHkbAhauXOZkx4NNRI2NGx96mBKHodicdRODuVLx1XXnqb0dH4kvZz5cmgoXPxEoYqlr0r2PBMeoH08lMucXXiVu6IS+S5IS7YhIdRGfZXzJH1aUorHfI3UiGm3FokO3reQRrzgngrAU0mqUv0xfOh4WciwClh3NSds8+8kSiWTNW2AvmE1fOqRN3xc3XCTwD3HAYlTX0rXdJi/Gqszfy084MBiI7Dqam7VoxkL19iQTe93rZkFICr06Ja4bLmcxkwA+eUQStvQYs0LF8uBnwcPvXZkGJxlFUmuO9KAlcASq2oc/THCXbw5n7c102kF0K6pQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Henry.Wang@xxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Edwin Török <edvin.torok@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 08 Nov 2022 17:15:50 +0000
  • Ironport-data: A9a23:JJBLkK9Gm4fr+PYBM3wiDrUDs3+TJUtcMsCJ2f8bNWPcYEJGY0x3z TAbUT3SO6qOMDTwe9p3a9ni9k4GsZ7cyYdmGlA5/Ck8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKucYHsZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ire7kIx1BjOkGlA5AZnPKgb5AW2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDkkVx 6QTFSBONiq8vO6wxuu1ZftwhukaeZyD0IM34hmMzBn/JNN/GNXpZfWP4tVVmjAtmspJAPDSI dIDbiZiZwjBZBsJPUoLDJU5n6GjgXyXnz9w8QrJ4/ZopTWDilUvgdABM/KMEjCObd9SkUuC4 HrP4kzyAw0ANczZwj2Amp6prr+TwXuqBd5IfFG+3tI2n33IzTIfMQQXUFzqoMKmpX67UOsKf iT4/QJr98De7neDTNPwQhm5q36spQMHVpxbFOhSwCGAzLDFpTmQAGcsRyRELtchsaceWjgCx lKP2dTzClRHoLCTDH6Q6LqQhTezIjQOa38PYzceSgkI6MWlp5s85i8jVf5mGa+xy9fzSTf5x mnTqDBk3utCy8kWy6+84FbLxSq2oYTERRI04QORWX+56gR+Z8iuYInABUXn0Mus5b2xFjGp1 EXoUeDHhAzSJflhTBCwfdg=
  • Ironport-hdrordr: A9a23:dMEqgKp19zvNEFerlKGzFAUaV5rReYIsimQD101hICG9Evb0qy lhppQmPH7P+VIssRQb8+xoV5PufZqxz/BICOoqTNKftWvdyQiVxehZhOOP/9SJIUbDH4VmpM VdmsZFaeEZDTJB/LvHCAvTKadd/DFQmprY+ts3zB1WPH9Xg7kL1XYfNu4CeHcGPzWvA/ACZf yhz/sCnRWMU1INYP+2A3EUNtKz3eEixPrdEGc77wdM0nj3sQ+V
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

This is a domctl interface, so we are fine to do such changes.  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.

> >> As a minor remark: _If_ you're changing the printk(), then please
> >> also switch to using %pd.
> > 
> > I've considered this, but then printing: "Tried to do a paging domctl
> > op on dying domain dX" felt kind of repetitive to me because of the
> > usage of domain and dX in the same sentence.  Anyway, will adjust.
> 
> Simply drop the word "domain", as we've done elsewhere when switching
> to %pd?

OK.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.