Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412AbbG1RXw (ORCPT ); Tue, 28 Jul 2015 13:23:52 -0400 Received: from mail-bl2on0140.outbound.protection.outlook.com ([65.55.169.140]:54387 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752433AbbG1RXt (ORCPT ); Tue, 28 Jul 2015 13:23:49 -0400 From: Bhushan Bharat To: Alex Williamson , Pranavkumar Sawargaonkar CC: "kvm@vger.kernel.org" , "kvmarm@lists.cs.columbia.edu" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "christoffer.dall@linaro.org" , "marc.zyngier@arm.com" , "will.deacon@arm.com" , "bhelgaas@google.com" , "arnd@arndb.de" , "rob.herring@linaro.org" , "eric.auger@linaro.org" , "patches@apm.com" , Stuart Yoder Subject: RE: [RFC 0/2] VFIO: Add virtual MSI doorbell support. Thread-Topic: [RFC 0/2] VFIO: Add virtual MSI doorbell support. Thread-Index: AQHQyVGEOINbGWv4NkGVayNldIK0kp3xHbOg Date: Tue, 28 Jul 2015 17:23:45 +0000 Message-ID: References: <1437728590-23126-1-git-send-email-pranavkumar@linaro.org> <1438100507.5211.170.camel@redhat.com> In-Reply-To: <1438100507.5211.170.camel@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: redhat.com; dkim=none (message not signed) header.d=none; x-originating-ip: [192.88.169.1] x-microsoft-exchange-diagnostics: 1;CY1PR0301MB0748;5:nN3Gj1f/vhkiqcX/A0v49+VhQ9pTDYrknBzuJC0CVL+cZgEUtnhqEIh+5O6e/iKsi9/Z9zUd+2X1qD8gTSAe5sIPXv5X/OxavXwd1DmIm4moS/rqBJwjPUmXhe1A8+2F81OVcAOOIKjiyFXDxMd7TQ==;24:xSVXt7wyIHn9hnXkwveETmiGE7holnLb54iD2OfDYmfAlAfaUtS1xqbx4vLypWveDelwmtrWKaXINKvxv8E7XXrfrfpUtppzjDvBgKiuJyw=;20:dodXYYw340pHhCgsEVQ5dL972EL0/9Z/o5pR+KdJ163a4wwYyRtRiiGB5OQI7bzlFAPkxIMRN2leAE7h5PdUwg== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0748; cy1pr0301mb0748: X-MS-Exchange-Organization-RulesExecuted x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:CY1PR0301MB0748;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB0748; x-forefront-prvs: 06515DA04B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(377424004)(13464003)(24454002)(164054003)(377454003)(87936001)(76176999)(92566002)(50986999)(54356999)(86362001)(74316001)(5002640100001)(189998001)(5001960100002)(107886002)(46102003)(5003600100002)(106116001)(77156002)(62966003)(2656002)(77096005)(102836002)(33656002)(99286002)(2950100001)(2900100001)(40100003)(5001770100001)(19580395003)(66066001)(122556002)(5001920100001)(19580405001)(76576001)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB0748;H:CY1PR0301MB1276.namprd03.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jul 2015 17:23:45.9128 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0748 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id t6SHNwwB020216 Content-Length: 4274 Lines: 77 Hi Alex, > -----Original Message----- > From: Alex Williamson [mailto:alex.williamson@redhat.com] > Sent: Tuesday, July 28, 2015 9:52 PM > To: Pranavkumar Sawargaonkar > Cc: kvm@vger.kernel.org; kvmarm@lists.cs.columbia.edu; linux-arm- > kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > christoffer.dall@linaro.org; marc.zyngier@arm.com; will.deacon@arm.com; > bhelgaas@google.com; arnd@arndb.de; rob.herring@linaro.org; > eric.auger@linaro.org; patches@apm.com; Bhushan Bharat-R65777; Yoder > Stuart-B08248 > Subject: Re: [RFC 0/2] VFIO: Add virtual MSI doorbell support. > > On Fri, 2015-07-24 at 14:33 +0530, Pranavkumar Sawargaonkar wrote: > > In current VFIO MSI/MSI-X implementation, linux host kernel allocates > > MSI/MSI-X vectors when userspace requests through vfio ioctls. > > Vfio creates irqfd mappings to notify MSI/MSI-X interrupts to the > > userspace when raised. > > Guest OS will see emulated MSI/MSI-X controller and receives an > > interrupt when kernel notifies the same via irqfd. > > > > Host kernel allocates MSI/MSI-X using standard linux routines like > > pci_enable_msix_range() and pci_enable_msi_range(). > > These routines along with requset_irq() in host kernel sets up > > MSI/MSI-X vectors with Physical MSI/MSI-X addresses provided by > > interrupt controller driver in host kernel. > > > > This means when a device is assigned with the guest OS, MSI/MSI-X > > addresses present in PCIe EP are the PAs programmed by the host linux > kernel. > > > > In x86 MSI/MSI-X physical address range is reserved and iommu is aware > > about these addreses and transalation is bypassed for these address range. > > > > Unlike x86, ARM/ARM64 does not reserve MSI/MSI-X Physical address > > range and all the transactions including MSI go through iommu/smmu > without bypass. > > This requires extending current vfio MSI layer with additional > > functionality for ARM/ARM64 by 1. Programing IOVA (referred as a MSI > > virtual doorbell address) > > in device's MSI vector as a MSI address. > > This IOVA will be provided by the userspace based on the > > MSI/MSI-X addresses reserved for the guest. > > 2. Create an IOMMU mapping between this IOVA and > > Physical address (PA) assigned to the MSI vector. > > > > This RFC is proposing a solution for MSI/MSI-X passthrough for > ARM/ARM64. > > > Hi Pranavkumar, > > Freescale has the same, or very similar, need, so any solution in this space > will need to work for both ARM and powerpc. I'm not a big fan of this > approach as it seems to require the user to configure MSI/X via ioctl and then > call a separate ioctl mapping the doorbells. That's more code for the user, > more code to get wrong and potentially a gap between configuring MSI/X > and enabling mappings where we could see IOMMU faults. > > If we know that doorbell mappings are required, why can't we set aside a > bank of IOVA space and have them mapped automatically as MSI/X is being > configured? Then the user's need for special knowledge and handling of this > case is limited to setup. The IOVA space will be mapped and used as needed, > we only need the user to specify the IOVA space reserved for this. Thanks, We probably need a mix of both to support Freescale PowerPC and ARM based machines. In this mix mode kernel vfio driver will reserve some IOVA for mapping MSI page/s. If any other iova mapping will overlap with this then it will return error and user-space. Ideally this should be choosen in such a way that it never overlap, which is easy on some systems but can be tricky on some other system like Freescale PowerPC. This is not sufficient for at-least Freescale PowerPC based SOC. This is because of hardware limitation, where we need to fit this reserved iova address within aperture decided by user-space. So if we allow user-space to change this reserved iova address to a value decided by user-spece itself then we can support both ARM/PowerPC based solutions. I have some implementation ready/tested with this approach and if this approach looks good then I can submit a RFC patch. Thanks -Bharat > > Alex ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?