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

Re: [PATCH v6 04/13] vpci: restrict unhandled read/write operations for guests


  • To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 8 Feb 2022 10:05:27 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=O8c49+exqzIWGjgj1m09xmEF8LO+OXQwJssQsXtvCzo=; b=cSGPswqw8UF9F5jVf/q/KomjvkreAHuMVHP/QuVqIzoad3OZk1puRqYwDJxDGP72mA8SZBrcyWTKN/vgJh1D2Bq2RQ38/Qp9RxCm6Yf3gNMNw4oNhGe5IcygkNZ6Xhf6TFNTV49I5Muv4lDmrSXHTVMRhQ8gJDXST0eWiK2PyZ4ZRiVqlCKx2EBAc/7wlWC/L2YGxJyocDoFFJm2N1gwEAtRC1atyYikxKj3wvJSLzGFZrCJjEMwJlaesT4j4u5iGlskQ/EDclFcGGldh1IOkjwMr0/vnuYVDPeekkVmDNvNnlESnvLVmSb9EXqyfei06pr1uMVdVWUtF8jDm/9lIw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ST3RM8TV2Mj4TiVoSljUlf9J6/EQR789Xx7Jz4WxHwlAB4C5VJkPex3d7GjF+N/ZYcoI2TzQNx+vLBnSruaxD/oXVETazojdqCnMdxQrLT/y1YqvQQ/W57cZpAODW9lKFSmbF+k1uEWAPVkfwxg/mlZ53/s2Kl97sMej8rWJjKkPRCymWxZntLaCk53XAE1ZcQHKqT7I296VnSe4Gep/DkIfCHoWIamGXl0CJUoTvR5fgj+0ae14VS9YKDhMLLN6GIQOU6xGPhHAVC440xbFeNjylT/5FgskzX0CZKc0zbVWXwxrlinkVWTzftbuoP2GtulEAb6roIozyFcvesoXFw==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 08 Feb 2022 09:06:00 +0000
  • Ironport-data: A9a23:pgIGzq6NCh4J28I5q4A0jgxRtBjBchMFZxGqfqrLsTDasY5as4F+v mscXmrQOqyCMDDxc4x0O9iz8BlT6sWHmNViTQBs+S83Hi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuV3zyIQUBUjclkfJKlYAL/En03FV8MpBsJ00o5wbZj2t4w2LBVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Z6 9FIlL+oaVgSF7zsqPs0XDsHASVhIvgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1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ws7Zsc9klXGC9pB5J04ov7hxMYPLREhVnfETKvCC2NKH3pmXZYbxMBQi3xuYnJ79TIjQ 2pb0uLzNBNE+Qz0XqInIm0+1g/A0lEGt4SI6FBsKNAHIeAXkPoDIZ+Lk7Ofomw6yrwk/RbMI+t 02A2ohWUpW3XStrY0yLoadQmes8FWAVDFeIUZNjrAONahk/9Zw2OhIotRAnbUdV3hcQE5mSgpA KV4hSCm6qHawZMjBjN3085DGQnaoKsET/xGf/DzQpXwO82UN2E1WwDvXANFqUStuwnTFGiFFb+ Y2fNrfg4oN98VSvgRhoB9Nj7
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Feb 08, 2022 at 08:00:28AM +0000, Oleksandr Andrushchenko wrote:
> 
> On 04.02.22 16:24, Oleksandr Andrushchenko wrote:
> >
> > On 04.02.22 16:11, Jan Beulich wrote:
> >> On 04.02.2022 07:34, Oleksandr Andrushchenko wrote:
> >>> A guest can read and write those registers which are not emulated and
> >>> have no respective vPCI handlers, so it can access the HW directly.
> >> I don't think this describes the present situation. Or did I miss where
> >> devices can actually be exposed to guests already, despite much of the
> >> support logic still missing?
> > No, they are not exposed yet and you know that.
> > I will update the commit message
> BTW, all this work is about adding vpci for guests and of course this
> is not going to be enabled right away.
> I would like to hear the common acceptable way of documenting such
> things: either we just say something like "A guest can read and write"
> elsewhere or we need to invent something neutral not directly mentioning
> what the change does. With the later it all seems a bit confusing IMO
> as we do know what we are doing and for what reason: enable vpci for guests
> >>> In order to prevent a guest from reads and writes from/to the unhandled
> >>> registers make sure only hardware domain can access HW directly and 
> >>> restrict
> >>> guests from doing so.
> >> Tangential question: Going over the titles of the remaining patches I
> >> notice patch 6 is going to deal with BAR accesses. But (going just
> >> from the titles) I can't spot anywhere that vendor and device IDs
> >> would be exposed to guests. Yet that's the first thing guests will need
> >> in order to actually recognize devices. As said before, allowing guests
> >> access to such r/o fields is quite likely going to be fine.
> > Agree, I was thinking about adding such a patch to allow IDs,
> > but finally decided not to add more to this series.
> > Again, the whole thing is not working yet and for the development
> > this patch can/needs to be reverted. So, either we implement IDs
> > or not this doesn't change anything with this respect
> Roger, do you want an additional patch with IDs in v7?

I would expect a lot more work to be required, you need IDs and the
Header type as a minimum I would say. And then in order to have
something functional you will also need to handle the capabilities
pointer.

I'm fine for this to be added in a followup series. I think it's clear
the status after this series is not going to be functional.

> >>> --- a/xen/drivers/vpci/vpci.c
> >>> +++ b/xen/drivers/vpci/vpci.c
> >>> @@ -215,11 +215,15 @@ int vpci_remove_register(struct vpci *vpci, 
> >>> unsigned int offset,
> >>>    }
> >>>    
> >>>    /* Wrappers for performing reads/writes to the underlying hardware. */
> >>> -static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg,
> >>> +static uint32_t vpci_read_hw(bool is_hwdom, pci_sbdf_t sbdf, unsigned 
> >>> int reg,
> >>>                                 unsigned int size)
> >> Was the passing around of a boolean the consensus which was reached?
> > Was this patch committed yet?
> >> Personally I'd fine it more natural if the two functions checked
> >> current->domain themselves.
> > This is also possible, but I would like to hear Roger's view on this as well
> > I am fine either way
> Roger, what's your maintainer's preference here? Additional argument
> to vpci_read_hw of make it use current->domain internally?

My recommendation would be to use current->domain. Handlers will
always be executed in guest context, so there's no need to pass a
parameter around.

Thanks, Roger.



 


Rackspace

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