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

Re: [PATCH for-4.15 v2] xen/dmop: Strip __XEN_TOOLS__ header guard from public API


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 11 Mar 2021 13:00:53 +0000
  • 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-SenderADCheck; bh=Ajpze4cH1ExYhZ/fAlLPgE41D+0bllP+1rV/FTpxLa4=; b=fXoo024suvXf3rRflBYzimLNw03aAp3BWHkorMJsnDq6/Zi/cR2QtAxUoLoyRzkucqThbmQU0kRFSoukV76cBj/OBhyyRjfxz+zKnqlKfSoNAb+JQslHEf2GG1LSDISYlRGqkTyTM+YNf04yYVFLZAXQtK2LK+kbaB4IVgS8LbOeL3Lb0NEJsiG4jEzx6bne9uu1/jpGkqf59v0g4U5HdJft+E0hhpu8Y2Yu0gnbpoUC20XJZXXUYAFYUtOaZfqWTjwVsa8FkQd0eQ9zyGQvZPH1p+ZwPYwORuNJ9Wj8ybBoWTzgOz9DiW23Q24Y7zuabsSr6o4hf+B3mm3M67Uxeg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gq8E+bYP/w2DRNamVvtzae9hvqnXnc24Kym7qUhEGp6qihvzE1jsbnO7MYhhW1qAK45CdsM95wp+KU3WmpfuUDGWPhuGsyySipGqQhHHnn39EOmJeazvtmzs06o0Nb5zrgc69S8wcYnJkZS+/Ge8atkYli/DbRMBVLIWzMwA/znBV0rSzV1RNgSY5gNkV/89aYippVGwp+oyH9JGlGEKYrlns0EpZujUtZHcA9+KnRyMgi5KUtj9npGlNPsnjJY1cGj0CI/ZjPTXEAv91DviSYLFTt/VIVN8RZYB9cL8YIWN26foD7kQu0woNvttkoTAqguDfOGuX5mrgIJgziqN9A==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "Paul Durrant" <paul@xxxxxxx>
  • Delivery-date: Thu, 11 Mar 2021 13:01:24 +0000
  • Ironport-hdrordr: A9a23:vP+viaGuDgp/lOEtpLqFR5TXdLJzesId70hD6mlYcjYQWtCEls yogfQQ3QL1jjFUY307hdWcIsC7L0/03aVepa0cJ62rUgWjgmunK4l+8ZDvqgeOJwTXzcQY76 tpdsFFZOHYJURmjMr8/QmzG8shxt7Cy6yzmeLC1R5WLT1CQYsI1XYcNi+wFEpqSA5aQb8wE5 SB7sRKzgDQB0g/RMK9G3UDQqz/vNXNjp3relorABQg5QmIg1qTmcHHOjKf2QoTVC4K/Kc6/Q H+4nDEz4iAk9X+8B/T0GfP849b8eGB9vJvDNGB4/JlUQnEpR2vYO1aKtu/lRAz5Nqi8VM71O TLyi1QQvhbz1P0UiWLrQD22w/muQxemUPK7VODm3PsrYjYaVsBerJ8rLlUeBfY9EYs1esUuM kgshP7xvgneS/opyjz68PFUBtnjCOP0B0fuNUekmBFVs8mYKJRxLZvj399KosKHy7x9ekcYZ BTJfzbjcwmFG+yU2rUpS1GztCqQx0Ib227a3lHkMmU3z9KpWt+3ksVyecO901whK4Vet1q4f /JPb9vk6wLZsgKbbhlDONEesevDHfRKCi8fl66EBDCLuUqKnjNo5n47PEc4/yrQoUByN8XlI 7aWF1VmGYucyvVeIyz9awO1iqIbHS2XDzrxM0bzYN+oKfASL3iNjDGYEwykuO7ys9vQPHzar KWAtZ7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0Jr5/RVz8N/gVkc0dthw0OavfDupJjBR UVdaR7MAWz9JEJ3wiJrexpOnLXiK+7mZES47kgdXDDZ/xvhHEripn6PA5dm5ic3mYfOAY0way7 AaJEBPq8M7iXzDtWeP7Ug6E9nPraO+epOGXLc0SbA3p+pzLSroSVkH4Mq8Oi9SVaeEczoEQYZW aaL9o7wPNhCAOzlQDaSys4FFJrI2C/O1Nym597lL7Or7MjDA2cfxSF5YKbE1T4qIROtH8A/VoN ztc=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11/03/2021 11:41, Jan Beulich wrote:
> On 11.03.2021 12:05, Andrew Cooper wrote:
>> On 11/03/2021 08:27, Jan Beulich wrote:
>>> On 10.03.2021 18:22, Andrew Cooper wrote:
>>>> On 10/03/2021 17:12, Jan Beulich wrote:
>>>>> On 10.03.2021 16:07, Andrew Cooper wrote:
>>>>>> --- a/docs/designs/dmop.pandoc
>>>>>> +++ b/docs/designs/dmop.pandoc
>>>>>> @@ -4,9 +4,13 @@ DMOP
>>>>>>  Introduction
>>>>>>  ------------
>>>>>>  
>>>>>> -The aim of DMOP is to prevent a compromised device model from 
>>>>>> compromising
>>>>>> -domains other than the one it is providing emulation for (which is 
>>>>>> therefore
>>>>>> -likely already compromised).
>>>>>> +The DMOP hypercall has a new ABI design to solve problems in the Xen
>>>>>> +ecosystem.  First, the ABI is fully stable, to reduce the coupling 
>>>>>> between
>>>>>> +device models and the version of Xen.
>>>>>> +
>>>>>> +Secondly, for device models in userspace, the ABI is designed 
>>>>>> specifically to
>>>>>> +allow a kernel to audit the memory ranges used, without having to know 
>>>>>> the
>>>>>> +internal structure of sub-ops.
>>>>> I appreciate the editing, but the cited points still don't justify ...
>>>>>
>>>>>> --- a/xen/include/public/hvm/dm_op.h
>>>>>> +++ b/xen/include/public/hvm/dm_op.h
>>>>>> @@ -25,9 +25,6 @@
>>>>>>  #define __XEN_PUBLIC_HVM_DM_OP_H__
>>>>>>  
>>>>>>  #include "../xen.h"
>>>>>> -
>>>>>> -#if defined(__XEN__) || defined(__XEN_TOOLS__)
>>>>>> -
>>>>>>  #include "../event_channel.h"
>>>>>>  
>>>>>>  #ifndef uint64_aligned_t
>>>>>> @@ -491,8 +488,6 @@ struct xen_dm_op {
>>>>>>      } u;
>>>>>>  };
>>>>>>  
>>>>>> -#endif /* __XEN__ || __XEN_TOOLS__ */
>>>>>> -
>>>>>>  struct xen_dm_op_buf {
>>>>>>      XEN_GUEST_HANDLE(void) h;
>>>>>>      xen_ulong_t size;
>>>>> ... this removal: What the kernel needs for its auditing (your 2nd
>>>>> point) is already outside of this guarded region, as you can see
>>>>> from the context above. You said there was a design goal of allowing
>>>>> use of this interface by (and not only through) the kernel, e.g. by
>>>>> a kernel module (which I don't think you mean to be covered by
>>>>> "device models"). If that was indeed a goal (Paul - can you confirm
>>>>> this?), this would now want listing as a 3rd item. Without such a
>>>>> statement I'd call it a bug to not have the guards there, and hence
>>>>> might either feel tempted myself to add them back at some point, or
>>>>> would ack a patch doing so.
>>>> Xen has absolutely no business dictating stuff like this.
>>> Actually there's no "dictating" here anyway: People are free to clone
>>> the headers and omit the guards anyway.
>> That is somewhere between busywork and just plain rude to 3rd parties. 
>> "here are some headers but you need to unbreak them locally before use".
>>
>>> Outside of our own build
>>> system they really mainly serve a documentation purpose.
>> Header guards are not documentation
> And I didn't say so - I said they server a documentation purpose.
>
>> - they are active attempt to
>> segregate hypercalls by "who we think is supposed to use them".
>>
>> MiniOS, which uses this header within our build system, is not a part of
>> the toolstack, and should not need to define __XEN_TOOLS__ to be able to
>> use stable-ABI hypercalls.
> I've not been able to spot a definition of __XEN_TOOLS__ in the
> mini-os sources. Are you perhaps referring to tool stack libraries
> getting built also for it?

Things in stubdom/ which include xenctrl.h get __XEN_TOOLS__ set behind
the scenes, which is the only way that including libxendevicemodel.h
worked before last week.

>
>> Equally, the fact that libxendevicemodel's private.h needed to define
>> __XEN_TOOLS__ demonstrates the problem - dm_op.h (the structs and
>> defines - not just the types) are necessary to use the ioctl() on
>> /dev/xen/devicemodel in the first place.
> But this library _is_ part of the tool stack. Looks like it really
> boils down to ...
>
>>>>   It is an
>>>> internal and opaque property of the domain if the hypercalls happen to
>>>> originate from logic in user mode or kernel mode.  Stubdomains would
>>>> fall into the same "kernel" category as xengt in the dom0 i915 driver.
>>>>
>>>> However, the actual bug I'm trying to fix with this is the need for
>>>> userspace, which doesn't link against libxc, to do
>>>>
>>>> #define __XEN_TOOLS__
>>>> #include <xendevicemodel.h>
>>>>
>>>> to be able to use the libxendevicemodel stable library.
>>>>
>>>> The __XEN_TOOLS__ guard is buggy even ignoring the kernel device model
>>>> aspect.
>>> Depends on what __XEN_TOOLS__ really means - to guard things accessible
>>> to any part of the tool stack, or to guard unstable interfaces only.
>> As far as I'm concerned, __XEN_TOOLS__ should always have been spelled
>> __XEN_UNSTABLE_ABI__.
> ... this. If you added half a sentence to this effect to the description,
> you may feel free to add
> Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
>
> I still would appreciate if you also added the kernel (module) aspect to
> the doc change.

Thanks, will do, and I'll post a v3 just to check that everyone is happy.


However, having laid things out in this way today, it occurs to me that
we should consider further cleanup as well.

I do agree that code wanting to use the libxendevicemodel.h API almost
certainly don't want/need the dmop ABI.  (i.e. an individual consumer
will want one, or the other, but almost certainly not both together).

Should libxendevicemodel.h really be including dm_op.h?  AFAICT, it is
only the ioserverid_t typedef which is API shared between the two
contexts, and we can trivially typedef that locally.

This is something which we should either do now, or not at all.

~Andrew




 


Rackspace

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