From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46EFCC38A2D for ; Wed, 26 Oct 2022 21:25:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233282AbiJZVZH (ORCPT ); Wed, 26 Oct 2022 17:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233379AbiJZVZF (ORCPT ); Wed, 26 Oct 2022 17:25:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8B511AF0D for ; Wed, 26 Oct 2022 14:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666819503; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2ys5yrKnSWNrdXyOIt/+2hibuD6RgZdYjr5anEvm87I=; b=D7n9VPvOxaB/v9f6dEkYAchSorgHnHxw512HrRhVSP/KWGg6UTkdpFrUCoRMSAoWsMiBCl BSj78YNEAizdIMmBbvW/Vwb8WYDQrNy8R9WEvA3qnbK5HzvQyxH6IqqMYSXprh+wRKf8VV DXNxGQoXDPR/kQKqJoe7TWEv6iPqgW4= Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-207-znyQVfaDOOKCDosKiL9H8w-1; Wed, 26 Oct 2022 17:25:02 -0400 X-MC-Unique: znyQVfaDOOKCDosKiL9H8w-1 Received: by mail-io1-f69.google.com with SMTP id a6-20020a056602208600b006bff2e56943so5383497ioa.11 for ; Wed, 26 Oct 2022 14:25:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2ys5yrKnSWNrdXyOIt/+2hibuD6RgZdYjr5anEvm87I=; b=34fA/0H8N1g7ohQ6GshDBRNfy5+Vcr3IzGmev6SveEn+4KWvDITWAEVXumlwc4E6RL 4Gz48W8LYObiXDmgzU2A7Pr6KzUGNyEwfn4JyAmzBMd6rF/d/z82ZMbfLgB8AmAEiEPn 8bo+kL5sOPKAGMrhEHutRbn+ZzMPBbwNKOspp/nrYGCJS8PICNiDPdfk7nlfvFt1Mkx0 04Wx8hUpXECJTCDtdc+YLq7wLqPfpVLxcdBXfyMygJVW2tFwnAb+Kohu6x4N8HN3NjZV mVC1QtYcywdiIzWZv41avJlmU1pL6o14dgTIXrXUgj2ldp9EYvgWQxaePpvUGrY6mBnQ dlvg== X-Gm-Message-State: ACrzQf3ba3sZkj4yhePBYTU47sWsCmU3YAzWDgKp7HlJmEZEMhd4Hyv8 FK5UpKstHMGdfnCPifrqRlve4TXaxoztVVurelrtLrL+mgMn7lqVDRyUhxSvdh2kDNdGo4OS+zA lcQIg6K6byl0WLmvpeHfrhg== X-Received: by 2002:a05:6602:13c8:b0:68a:db5d:269d with SMTP id o8-20020a05660213c800b0068adb5d269dmr27084614iov.209.1666819496944; Wed, 26 Oct 2022 14:24:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78B1N1rhquL7I27LvLWaJii8bhooCw6yJ0rMTPt8axTAAIzjlyMmOikhzath1gqGNuTiEASg== X-Received: by 2002:a05:6e02:1b08:b0:2fc:4df6:e468 with SMTP id i8-20020a056e021b0800b002fc4df6e468mr27916129ilv.148.1666819486067; Wed, 26 Oct 2022 14:24:46 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id x13-20020a02948d000000b0036c8a246f54sm2409348jah.142.2022.10.26.14.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 14:24:45 -0700 (PDT) Date: Wed, 26 Oct 2022 15:24:42 -0600 From: Alex Williamson To: Jason Gunthorpe Cc: Alexander Gordeev , David Airlie , Tony Krowiak , Christian Borntraeger , Cornelia Huck , Daniel Vetter , Diana Craciun , dri-devel@lists.freedesktop.org, Eric Auger , Eric Farman , Harald Freudenberger , Vasily Gorbik , Heiko Carstens , intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, iommu@lists.linux.dev, Jani Nikula , Jason Herne , Joonas Lahtinen , Joerg Roedel , Kevin Tian , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Longfang Liu , Matthew Rosato , Peter Oberparleiter , Halil Pasic , Robin Murphy , Rodrigo Vivi , Shameer Kolothum , Sven Schnelle , Tvrtko Ursulin , Vineeth Vijayan , Will Deacon , Yishai Hadas , Zhenyu Wang , Zhi Wang , Lu Baolu , Nicolin Chen , Yi Liu Subject: Re: [PATCH 04/10] vfio: Move storage of allow_unsafe_interrupts to vfio_main.c Message-ID: <20221026152442.4855c5de.alex.williamson@redhat.com> In-Reply-To: <4-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> References: <0-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> <4-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On Tue, 25 Oct 2022 15:17:10 -0300 Jason Gunthorpe wrote: > This legacy module knob has become uAPI, when set on the vfio_iommu_type1 > it disables some security protections in the iommu drivers. Move the > storage for this knob to vfio_main.c so that iommufd can access it too. I don't really understand this, we're changing the behavior of the iommufd_device_attach() operation based on the modules options of vfio_iommu_type1, which may not be loaded or even compiled into the kernel. Our compatibility story falls apart when VFIO_CONTAINER is not set, iommufd sneaks in to usurp /dev/vfio/vfio, and the user's module options for type1 go unprocessed. I hate to suggest that type1 becomes a module that does nothing more than maintain consistency of this variable when the full type1 isn't available, but is that what we need to do? Thanks, Alex > Signed-off-by: Jason Gunthorpe > --- > drivers/vfio/vfio.h | 2 ++ > drivers/vfio/vfio_iommu_type1.c | 5 ++--- > drivers/vfio/vfio_main.c | 3 +++ > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h > index f95f4925b83bbd..54e5a8e0834ccb 100644 > --- a/drivers/vfio/vfio.h > +++ b/drivers/vfio/vfio.h > @@ -130,4 +130,6 @@ extern bool vfio_noiommu __read_mostly; > enum { vfio_noiommu = false }; > #endif > > +extern bool vfio_allow_unsafe_interrupts; > + > #endif > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index 23c24fe98c00d4..186e33a006d314 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -44,9 +44,8 @@ > #define DRIVER_AUTHOR "Alex Williamson " > #define DRIVER_DESC "Type1 IOMMU driver for VFIO" > > -static bool allow_unsafe_interrupts; > module_param_named(allow_unsafe_interrupts, > - allow_unsafe_interrupts, bool, S_IRUGO | S_IWUSR); > + vfio_allow_unsafe_interrupts, bool, S_IRUGO | S_IWUSR); > MODULE_PARM_DESC(allow_unsafe_interrupts, > "Enable VFIO IOMMU support for on platforms without interrupt remapping support."); > > @@ -2282,7 +2281,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > iommu_group_for_each_dev(iommu_group, (void *)IOMMU_CAP_INTR_REMAP, > vfio_iommu_device_capable); > > - if (!allow_unsafe_interrupts && !msi_remap) { > + if (!vfio_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; > diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c > index 8d809ecd982b39..1e414b2c48a511 100644 > --- a/drivers/vfio/vfio_main.c > +++ b/drivers/vfio/vfio_main.c > @@ -51,6 +51,9 @@ static struct vfio { > struct ida device_ida; > } vfio; > > +bool vfio_allow_unsafe_interrupts; > +EXPORT_SYMBOL_GPL(vfio_allow_unsafe_interrupts); > + > static DEFINE_XARRAY(vfio_device_set_xa); > static const struct file_operations vfio_group_fops; > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B1102C38A2D for ; Wed, 26 Oct 2022 21:25:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0466810E365; Wed, 26 Oct 2022 21:25:02 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id E897110E366 for ; Wed, 26 Oct 2022 21:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666819498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2ys5yrKnSWNrdXyOIt/+2hibuD6RgZdYjr5anEvm87I=; b=SWU8rY9dU+rv13ZhNBygJ6c8ulXbdc3Ezj704zKrk9vZ5ViztJg7gtlT6msKJz/vVAPYQm R5b2rIFA6WJHKkllZvL8sheDqsgg6AtKVuKcCoRJxZsoqL5VVhJvMgbhfHjiyqohnnqwIP x0WRE7oTGFzaA/lewn5lMKJJ+wW+VxE= Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-120-SlMuhVsuNgKrkcic-LgRaQ-1; Wed, 26 Oct 2022 17:24:57 -0400 X-MC-Unique: SlMuhVsuNgKrkcic-LgRaQ-1 Received: by mail-io1-f72.google.com with SMTP id i21-20020a6bf415000000b006bc987bf9faso11298618iog.6 for ; Wed, 26 Oct 2022 14:24:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2ys5yrKnSWNrdXyOIt/+2hibuD6RgZdYjr5anEvm87I=; b=GQXnhdqhzfrdAgfIbaxWbqalB5hwiGUu11pl9Q9rVkjCtq+en8Lwy6SLqv8uBQ/9iQ KsP7+Ve2imV8YVO7sKyekcHpldOwSWKz6RE9I51Oy50YYys1cJPOx6Jgdxn2TzfE7yZu acc/7xxjKc3d+k82OadmPBUWNxTdY4gFQzndQHIq3hnz6RsNUYzgjuVdGhFNI5FDEQAz uX+f4Yc4eH6TdFJ5Dg3U4clqrT87MG6nklAHD50nzO9+3W0E/qkxjZpW+sdfIgimor3y QtPRu2ynzuYCKRw1As8x7SBhXYp+PcEPa1Mh24B8yVtHXGUxDsyl43RxDVqy6Uukg0OY LuXg== X-Gm-Message-State: ACrzQf0PF1YJm9t+c/WPh1wkYDAZJxfG3jo69HHmDNPmMmywl8iGhf8D PM485M5IOVYQCRerFLT+I/ZxcyncrElPESOqhjJHIsgCklTJAEK6bKqXJBfvIwRyyzJAgG5BQJA lGAR0tcOl/3hwUbTL72RDXD57oii6 X-Received: by 2002:a05:6e02:787:b0:300:4249:560f with SMTP id q7-20020a056e02078700b003004249560fmr6449856ils.79.1666819496584; Wed, 26 Oct 2022 14:24:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78B1N1rhquL7I27LvLWaJii8bhooCw6yJ0rMTPt8axTAAIzjlyMmOikhzath1gqGNuTiEASg== X-Received: by 2002:a05:6e02:1b08:b0:2fc:4df6:e468 with SMTP id i8-20020a056e021b0800b002fc4df6e468mr27916129ilv.148.1666819486067; Wed, 26 Oct 2022 14:24:46 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id x13-20020a02948d000000b0036c8a246f54sm2409348jah.142.2022.10.26.14.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 14:24:45 -0700 (PDT) Date: Wed, 26 Oct 2022 15:24:42 -0600 From: Alex Williamson To: Jason Gunthorpe Subject: Re: [PATCH 04/10] vfio: Move storage of allow_unsafe_interrupts to vfio_main.c Message-ID: <20221026152442.4855c5de.alex.williamson@redhat.com> In-Reply-To: <4-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> References: <0-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> <4-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Kevin Tian , dri-devel@lists.freedesktop.org, Vineeth Vijayan , Diana Craciun , Alexander Gordeev , Longfang Liu , linux-s390@vger.kernel.org, Yi Liu , Matthew Rosato , Will Deacon , Joerg Roedel , Halil Pasic , iommu@lists.linux.dev, Nicolin Chen , Christian Borntraeger , intel-gfx@lists.freedesktop.org, Zhi Wang , Jason Herne , Eric Farman , Vasily Gorbik , Heiko Carstens , Eric Auger , Harald Freudenberger , Rodrigo Vivi , intel-gvt-dev@lists.freedesktop.org, Tony Krowiak , Tvrtko Ursulin , Yishai Hadas , Cornelia Huck , Peter Oberparleiter , Shameer Kolothum , Sven Schnelle , Robin Murphy , Lu Baolu Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, 25 Oct 2022 15:17:10 -0300 Jason Gunthorpe wrote: > This legacy module knob has become uAPI, when set on the vfio_iommu_type1 > it disables some security protections in the iommu drivers. Move the > storage for this knob to vfio_main.c so that iommufd can access it too. I don't really understand this, we're changing the behavior of the iommufd_device_attach() operation based on the modules options of vfio_iommu_type1, which may not be loaded or even compiled into the kernel. Our compatibility story falls apart when VFIO_CONTAINER is not set, iommufd sneaks in to usurp /dev/vfio/vfio, and the user's module options for type1 go unprocessed. I hate to suggest that type1 becomes a module that does nothing more than maintain consistency of this variable when the full type1 isn't available, but is that what we need to do? Thanks, Alex > Signed-off-by: Jason Gunthorpe > --- > drivers/vfio/vfio.h | 2 ++ > drivers/vfio/vfio_iommu_type1.c | 5 ++--- > drivers/vfio/vfio_main.c | 3 +++ > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h > index f95f4925b83bbd..54e5a8e0834ccb 100644 > --- a/drivers/vfio/vfio.h > +++ b/drivers/vfio/vfio.h > @@ -130,4 +130,6 @@ extern bool vfio_noiommu __read_mostly; > enum { vfio_noiommu = false }; > #endif > > +extern bool vfio_allow_unsafe_interrupts; > + > #endif > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index 23c24fe98c00d4..186e33a006d314 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -44,9 +44,8 @@ > #define DRIVER_AUTHOR "Alex Williamson " > #define DRIVER_DESC "Type1 IOMMU driver for VFIO" > > -static bool allow_unsafe_interrupts; > module_param_named(allow_unsafe_interrupts, > - allow_unsafe_interrupts, bool, S_IRUGO | S_IWUSR); > + vfio_allow_unsafe_interrupts, bool, S_IRUGO | S_IWUSR); > MODULE_PARM_DESC(allow_unsafe_interrupts, > "Enable VFIO IOMMU support for on platforms without interrupt remapping support."); > > @@ -2282,7 +2281,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > iommu_group_for_each_dev(iommu_group, (void *)IOMMU_CAP_INTR_REMAP, > vfio_iommu_device_capable); > > - if (!allow_unsafe_interrupts && !msi_remap) { > + if (!vfio_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; > diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c > index 8d809ecd982b39..1e414b2c48a511 100644 > --- a/drivers/vfio/vfio_main.c > +++ b/drivers/vfio/vfio_main.c > @@ -51,6 +51,9 @@ static struct vfio { > struct ida device_ida; > } vfio; > > +bool vfio_allow_unsafe_interrupts; > +EXPORT_SYMBOL_GPL(vfio_allow_unsafe_interrupts); > + > static DEFINE_XARRAY(vfio_device_set_xa); > static const struct file_operations vfio_group_fops; > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34C6FC433FE for ; Wed, 26 Oct 2022 21:25:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 22FCD10E3A7; Wed, 26 Oct 2022 21:25:11 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE15D10E394 for ; Wed, 26 Oct 2022 21:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666819502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2ys5yrKnSWNrdXyOIt/+2hibuD6RgZdYjr5anEvm87I=; b=Vvq8AXeBox8vEqHJj0qtp0m6EfFfcbAbksNpD0bZfMhnKv6YHnX17c3t6KAEwufl6/5Ac6 9Wstpy6zKDS+ljuh/eILrfxQRLCGkfrme3UorRy0J0KbtcFFLN6qHD3bujCCQ9LIxg31ko zKxxTchD+o9nqladGNRFrptgJP/Ivkg= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-304-oPQOOaVCOA-ezGFLZuSXew-1; Wed, 26 Oct 2022 17:25:01 -0400 X-MC-Unique: oPQOOaVCOA-ezGFLZuSXew-1 Received: by mail-pg1-f197.google.com with SMTP id a33-20020a630b61000000b00429d91cc649so8533573pgl.8 for ; Wed, 26 Oct 2022 14:25:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2ys5yrKnSWNrdXyOIt/+2hibuD6RgZdYjr5anEvm87I=; b=IWoEq1Pl85xW5/0JTQDgM0tovLDALISnjfsWxyHH4Es6Vm9RA87nWby0pbqvT4Vlhi R0REmlO7lFePGlIEve75Pp19/a0CmFE5H6Da5wCfx+xC15TwcFIWwGtt20nnCa9i1rgm +8HXrdoLIkTCjJptayy+QmbgBSafKveBMTRUlSn7IjDI9K/I4G5qv8qnw9ghUqGaxQVD GLwJFmArjnJomkavThVHggfkhHh5pErhEuiBnxagG3LJCuiIikpj7MfdhuHaLwkFlvw6 SnrJCJNgqPibmFpSBSmjzxQNjXLphLfv7wq2+L4+CedQZeg7htJDg8jhy0/6bB0wkV5N Jxhw== X-Gm-Message-State: ACrzQf3TlX1nkNqdqfzfAL0nprbIQBVaRclF/Gd958qt6jkBN72ZugWZ so8aqb3GNMd8mJ5TzNmxhThhL2l8t5TIjPfdyco1CCOJOc93kJE9LQqPqZEFZuBsmD1uEOMfzSe 410rI+Z/YDJUqtAO6aygqxEnEIuGr X-Received: by 2002:a63:2c4c:0:b0:434:e001:89fd with SMTP id s73-20020a632c4c000000b00434e00189fdmr38998214pgs.444.1666819496802; Wed, 26 Oct 2022 14:24:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78B1N1rhquL7I27LvLWaJii8bhooCw6yJ0rMTPt8axTAAIzjlyMmOikhzath1gqGNuTiEASg== X-Received: by 2002:a05:6e02:1b08:b0:2fc:4df6:e468 with SMTP id i8-20020a056e021b0800b002fc4df6e468mr27916129ilv.148.1666819486067; Wed, 26 Oct 2022 14:24:46 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id x13-20020a02948d000000b0036c8a246f54sm2409348jah.142.2022.10.26.14.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 14:24:45 -0700 (PDT) Date: Wed, 26 Oct 2022 15:24:42 -0600 From: Alex Williamson To: Jason Gunthorpe Message-ID: <20221026152442.4855c5de.alex.williamson@redhat.com> In-Reply-To: <4-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> References: <0-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> <4-v1-4991695894d8+211-vfio_iommufd_jgg@nvidia.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Intel-gfx] [PATCH 04/10] vfio: Move storage of allow_unsafe_interrupts to vfio_main.c X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, Vineeth Vijayan , Diana Craciun , Alexander Gordeev , David Airlie , Longfang Liu , linux-s390@vger.kernel.org, Yi Liu , Matthew Rosato , Will Deacon , Joerg Roedel , Halil Pasic , iommu@lists.linux.dev, Nicolin Chen , Christian Borntraeger , intel-gfx@lists.freedesktop.org, Jason Herne , Eric Farman , Vasily Gorbik , Heiko Carstens , Eric Auger , Harald Freudenberger , Rodrigo Vivi , intel-gvt-dev@lists.freedesktop.org, Tony Krowiak , Yishai Hadas , Cornelia Huck , Peter Oberparleiter , Shameer Kolothum , Sven Schnelle , Daniel Vetter , Robin Murphy , Lu Baolu Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Tue, 25 Oct 2022 15:17:10 -0300 Jason Gunthorpe wrote: > This legacy module knob has become uAPI, when set on the vfio_iommu_type1 > it disables some security protections in the iommu drivers. Move the > storage for this knob to vfio_main.c so that iommufd can access it too. I don't really understand this, we're changing the behavior of the iommufd_device_attach() operation based on the modules options of vfio_iommu_type1, which may not be loaded or even compiled into the kernel. Our compatibility story falls apart when VFIO_CONTAINER is not set, iommufd sneaks in to usurp /dev/vfio/vfio, and the user's module options for type1 go unprocessed. I hate to suggest that type1 becomes a module that does nothing more than maintain consistency of this variable when the full type1 isn't available, but is that what we need to do? Thanks, Alex > Signed-off-by: Jason Gunthorpe > --- > drivers/vfio/vfio.h | 2 ++ > drivers/vfio/vfio_iommu_type1.c | 5 ++--- > drivers/vfio/vfio_main.c | 3 +++ > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/vfio/vfio.h b/drivers/vfio/vfio.h > index f95f4925b83bbd..54e5a8e0834ccb 100644 > --- a/drivers/vfio/vfio.h > +++ b/drivers/vfio/vfio.h > @@ -130,4 +130,6 @@ extern bool vfio_noiommu __read_mostly; > enum { vfio_noiommu = false }; > #endif > > +extern bool vfio_allow_unsafe_interrupts; > + > #endif > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c > index 23c24fe98c00d4..186e33a006d314 100644 > --- a/drivers/vfio/vfio_iommu_type1.c > +++ b/drivers/vfio/vfio_iommu_type1.c > @@ -44,9 +44,8 @@ > #define DRIVER_AUTHOR "Alex Williamson " > #define DRIVER_DESC "Type1 IOMMU driver for VFIO" > > -static bool allow_unsafe_interrupts; > module_param_named(allow_unsafe_interrupts, > - allow_unsafe_interrupts, bool, S_IRUGO | S_IWUSR); > + vfio_allow_unsafe_interrupts, bool, S_IRUGO | S_IWUSR); > MODULE_PARM_DESC(allow_unsafe_interrupts, > "Enable VFIO IOMMU support for on platforms without interrupt remapping support."); > > @@ -2282,7 +2281,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, > iommu_group_for_each_dev(iommu_group, (void *)IOMMU_CAP_INTR_REMAP, > vfio_iommu_device_capable); > > - if (!allow_unsafe_interrupts && !msi_remap) { > + if (!vfio_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; > diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c > index 8d809ecd982b39..1e414b2c48a511 100644 > --- a/drivers/vfio/vfio_main.c > +++ b/drivers/vfio/vfio_main.c > @@ -51,6 +51,9 @@ static struct vfio { > struct ida device_ida; > } vfio; > > +bool vfio_allow_unsafe_interrupts; > +EXPORT_SYMBOL_GPL(vfio_allow_unsafe_interrupts); > + > static DEFINE_XARRAY(vfio_device_set_xa); > static const struct file_operations vfio_group_fops; >