From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965307AbcLVORV (ORCPT ); Thu, 22 Dec 2016 09:17:21 -0500 Received: from mail-db5eur01on0065.outbound.protection.outlook.com ([104.47.2.65]:55376 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S936591AbcLVORT (ORCPT ); Thu, 22 Dec 2016 09:17:19 -0500 From: Diana Madalina Craciun To: Eric Auger , "eric.auger.pro@gmail.com" , "christoffer.dall@linaro.org" , "marc.zyngier@arm.com" , "robin.murphy@arm.com" , "alex.williamson@redhat.com" , "will.deacon@arm.com" , "joro@8bytes.org" , "tglx@linutronix.de" , "jason@lakedaemon.net" , "linux-arm-kernel@lists.infradead.org" CC: "kvm@vger.kernel.org" , "drjones@redhat.com" , "linux-kernel@vger.kernel.org" , "pranav.sawargaonkar@gmail.com" , "iommu@lists.linux-foundation.org" , "punit.agrawal@arm.com" , "gpkulkarni@gmail.com" , "shankerd@codeaurora.org" , Bharat Bhushan Subject: Re: [RFC v4 15/16] vfio/type1: Check MSI remapping at irq domain level Thread-Topic: [RFC v4 15/16] vfio/type1: Check MSI remapping at irq domain level Thread-Index: AQHSVYABCcCILtvpUkCpNzOSO+giMQ== Date: Thu, 22 Dec 2016 12:41:53 +0000 Message-ID: References: <1481661034-3088-1-git-send-email-eric.auger@redhat.com> <1481661034-3088-16-git-send-email-eric.auger@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=diana.craciun@nxp.com; x-originating-ip: [192.88.146.1] x-microsoft-exchange-diagnostics: 1;HE1PR0401MB2556;7:LoufQ5YLQBcCV2YM+AIC8aZI0fVtOMyrYKy9hsn+i+OXWAzFyiz8HfEF2D02/U/lqHnhjX/aZ5y0AlxRvyk0hNBroOerowJcLsQsAXvcW0ehvq49vvGGfqysZBJ/K8bgjjtcAs7JJYx1uWvgM702IKMh6UqMDuus59x/bJkYLAvj48PLD2WkJICXdAJu0ie+mlSjM3fXxGjGM6nu2FXmNDDk62cS1qDUm8GQOh/QpMKjtTVm9CfcjxApoD/620HOqUh9GAVkz2Z+ey/7N62Yz/D7sR23vLwR6Mm8BCxO0eGxLOl7STTTv+ouFe2b8F793vv73QeogjEvJTfU8qas6Tr9hTDUI0pSjclAxrxQnLTGoNpqoC9j6vCplHJ109MGNEMlKmuagtL2JK/pEhUjPRtUoevt0t77Zl1MaVT1bTpN//WK5dn7cmRCXF+494+lrNCzEJHutOJvtjA7upVyqQ== x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(6009001)(7916002)(39410400002)(39850400002)(39840400002)(39860400002)(39450400003)(189002)(24454002)(377454003)(199003)(102836003)(7696004)(5890100001)(6436002)(3660700001)(2501003)(2906002)(8676002)(2201001)(6506006)(3280700002)(39060400001)(229853002)(8936002)(86362001)(38730400001)(77096006)(25786008)(81156014)(76576001)(66066001)(81166006)(4326007)(9686002)(106356001)(105586002)(189998001)(5660300001)(106116001)(5001770100001)(97736004)(7416002)(7736002)(74316002)(6116002)(2900100001)(101416001)(76176999)(305945005)(54356999)(33656002)(68736007)(122556002)(3846002)(92566002)(50986999)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0401MB2556;H:HE1PR04MB1321.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-correlation-id: 051ca1cb-207d-49c9-1d43-08d42a67e8de x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:HE1PR0401MB2556; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123560025)(20161123564025)(20161123555025)(6072148)(6047074);SRVR:HE1PR0401MB2556;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0401MB2556; x-forefront-prvs: 01644DCF4A spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Dec 2016 12:41:54.0048 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0401MB2556 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 quoted-printable to 8bit by mail.home.local id uBMEHRTm016397 Hi Eric, On 12/13/2016 10:32 PM, Eric Auger wrote: > In case the IOMMU does not bypass MSI transactions (typical > case on ARM), we check all MSI controllers are IRQ remapping > capable. If not the IRQ assignment may be unsafe. > > At this stage the arm-smmu-(v3) still advertise the > IOMMU_CAP_INTR_REMAP capability at IOMMU level. This will be > removed in subsequent patches. > > Signed-off-by: Eric Auger > --- > drivers/vfio/vfio_iommu_type1.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index d07fe73..a05648b 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > > #define DRIVER_VERSION "0.2" > #define DRIVER_AUTHOR "Alex Williamson " > @@ -765,7 +766,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > struct vfio_domain *domain, *d; > struct bus_type *bus = NULL; > int ret; > - bool resv_msi; > + bool resv_msi, msi_remap; > phys_addr_t resv_msi_base; > > mutex_lock(&iommu->lock); > @@ -818,8 +819,10 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > INIT_LIST_HEAD(&domain->group_list); > list_add(&group->next, &domain->group_list); > > - if (!allow_unsafe_interrupts && > - !iommu_capable(bus, IOMMU_CAP_INTR_REMAP)) { > + msi_remap = resv_msi ? irq_domain_check_msi_remap() : > + iommu_capable(bus, IOMMU_CAP_INTR_REMAP); > + > + if (!allow_unsafe_interrupts && !msi_remap) { > pr_warn("%s: No interrupt remapping support. Use the module param \"allow_unsafe_interrupts\" to enable VFIO IOMMU support on this platform\n", > __func__); > ret = -EPERM; I tested your v4.9-reserved-v4 branch on a ITS capable hardware (NXP LS2080), so I did not set allow_unsafe_interrupts. It fails here complaining that the there is no interrupt remapping support. The irq_domain_check_msi_remap function returns false as none of the checked domains has the IRQ_DOMAIN_FLAG_MSI_REMAP flag set. I think the reason is that the flags are not propagated through the domain hierarchy when the domain is created. Thanks, Diana