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

Re: [PATCH v5 06/14] vpci/header: implement guest BAR register handlers


  • To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 31 Jan 2022 12:31:10 +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=4cQ35Usc9F4DMZwK91qhIhJ9HeCZc8KQtbGtfm9nJJs=; b=Acrowe3Ep6InMCIODBDelsw0Xuy/X7S1SC7Y+77yYQZQ+XuI3bDnRIvNLeE7wQDMyGqDNWfDwBP639LeoaPoOAukLVj/T2eA372JtwXGoPbp8DP4dz6ljdz807cu88UrTezz0u8wMiRRZYKKBKZzJMKWk1IjD2iaLlrHNUr6Z0pj4n5phAfxCeI8AkR3syHawLzkQdl5CaBeSLTCsieW2UhNMdLhPRfcvoZ5ynSKBj7K48ikkZCGCVwN0EGi8Ma/YXTlMFO1/ipCB7fdAep1Ye8U/Q+NMc/lRkIvFixdt8KuCOoi3ibKPcp/y7Um9/ZKmZAKNva8Taa/2fjZiLNSCQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NsPG/axfux62HgdOa2wciFN4tiDMWmBE08oOpqKxYkBuryDCN6SzZtdMmER5wTnwakiEHXD0sNrpW2ksHTxSdChewQ2SWwfrMVlYgvVldqLi8tk//Y1LDlSrC6HQpnzk4PYXz46ZLlNaCkh4w1kihj1zHzI1tOxcLWlo94sD5qg4Y2J9/tMSunP5DLTe64lYDuva38w1gErINC6d4GQQXQcjE94kRHxe2/bilhboOmqSJmVadgoPuEdiwO3z22PiL8iqFuSWQe3T6idrZIaBp2moPDJ1PwQDXjalbA0qgEXY75x6yClqrmWK94XoXWFR2MqcNtFHPAiWOdm+VcJQNg==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@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>
  • Delivery-date: Mon, 31 Jan 2022 11:31:22 +0000
  • Ironport-data: A9a23:Li1zEqMsQ32wH+XvrR2RkcFynXyQoLVcMsEvi/4bfWQNrUolg2NUy mAcWTvSM/qLZWb1KowlPou290hX6MXWx4A1Gwto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6UUsxNbVU8En150Ek6w7dRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYoyutlv5Ww v9RjLafSVcrD4fHodoGAyANRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpL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-sdr: kK98v7jlpyV1F3jYwiv55V/y7JgORlaxh2fpKF5Szz9RJ9FoA0Gip9leTB5Jj9DC5jYvMNgaiF +SHNkyHNNWgFxVzLqjdGu/WCHfpzxvbwBpeBUrL+7nq1yNRUKLePD/xsFxh2nwtCSgEpHK3vMR 4EKYRh3SJ0MwPV4JnKmD6IgvrqtlMWjuaPttX47c5m7WhevibjCGT2l9YIFtyPPLamHQ9p7iiW RwlUlELAL4S65TiZznu5VVsrgQcYPiQuQNSTLORl194+PpJCQQo6gJjIocjudf9cf0oDl73zXf 4WPIqws/CfyHjBTWrETLEsIk
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Jan 31, 2022 at 11:23:48AM +0000, Oleksandr Andrushchenko wrote:
> 
> 
> On 31.01.22 13:10, Roger Pau Monné wrote:
> > On Mon, Jan 31, 2022 at 10:40:47AM +0000, Oleksandr Andrushchenko wrote:
> >> On 31.01.22 11:47, Oleksandr Andrushchenko wrote:
> >>> Hi, Roger!
> >>>
> >>> On 12.01.22 14:35, Roger Pau Monné wrote:
> >>>>> +static void guest_rom_write(const struct pci_dev *pdev, unsigned int 
> >>>>> reg,
> >>>>> +                            uint32_t val, void *data)
> >>>>> +{
> >>>>> +}
> >>>>> +
> >>>>> +static uint32_t guest_rom_read(const struct pci_dev *pdev, unsigned 
> >>>>> int reg,
> >>>>> +                               void *data)
> >>>>> +{
> >>>>> +    return 0xffffffff;
> >>>>> +}
> >>>> There should be no need for those handlers. As said elsewhere: for
> >>>> guests registers not explicitly handled should return ~0 for reads and
> >>>> drop writes, which is what you are proposing here.
> >>> Yes, you are right: I can see in vpci_read that we end up reading ~0 if no
> >>> handler exists (which is what I do here with guest_rom_read). But I am 
> >>> not that
> >>> sure about the dropped writes:
> >>>
> >>> void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
> >>>                    uint32_t data)
> >>> {
> >>>        unsigned int data_offset = 0;
> >>>
> >>> [snip]
> >>>
> >>>        if ( data_offset < size )
> >>>            /* Tailing gap, write the remaining. */
> >>>            vpci_write_hw(sbdf, reg + data_offset, size - data_offset,
> >>>                          data >> (data_offset * 8));
> >>>
> >>> so it looks like for the un-handled writes we still reach the HW register.
> >>> Could you please tell if the code above needs improvement (like checking
> >>> if the write was handled) or I still need to provide a write handler, e.g.
> >>> guest_rom_write here?
> >> Hm, but the same applies to the reads as well... And this is no surprise,
> >> as for the guests I can see that it accesses all the configuration space
> >> registers that I don't handle. Without that I would have guests unable
> >> to properly setup a PCI device being passed through... And this is why
> >> I have a big TODO in this series describing unhandled registers.
> >> So, it seems that I do need to provide those handlers which I need to
> >> drop writes and return ~0 on reads.
> > Right (see my previous reply to this comment). I think it would be
> > easier (and cleaner) if you switched the default behavior regarding
> > unhandled register access for domUs at the start of the series (drop
> > writes, reads returns ~0), and then you won't need to add all those
> > dummy handler to drop writes and return ~0 for reads.
> >
> > It's going to be more work initially as you would need to support
> > passthrough of more registers, but it's the right approach that we
> > need implementation wise.
> While I agree in general, this effectively means that I'll need to provide
> handling for all PCIe registers and capabilities from the very start.

Well, we can only offer handling of the header and the MSI and MSI-X
capabilities right now, because that's all vPCI currently knows about.

> Otherwise no guest be able to properly initialize a PCI device without that.
> Of course, we may want starting from stubs instead of proper emulation,
> which will direct the access to real HW and later on we add proper emulation.
> But, again, this is going to be a rather big piece of code where we need
> to explicitly handle every possible capability.
> 
> At the moment we are not going to claim that vPCI provides all means to
> pass through a PCI device safely with this respect and this is why the feature
> itself won't even be a tech preview yet. For that reason I think we can still
> have implemented only crucial set of handlers and still allow the rest to
> be read/write directly without emulation.

See my other reply, you can probably move the special handlers into a
separate patch at the end of the series in order to test the
functionality without adding code that will need to be removed when
the defaults for domUs are changed.

> Another question is what needs to be done for vendor specific capabilities?
> How these are going to be emulated?

I think you will need some kind of permissive mode in order to allow a
guest to access those, as they shouldn't be exposed by default.

Thanks, Roger.



 


Rackspace

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