Linus Torvalds

    0
    46
    RSS Source: https://lkml.org/
    Default Action: directlink
    Default Link Follow: nofollow
    Default Link Target: newtab
    Affiliate Code:
    Default Link Color is defined : #CDD8D8
    Feed Title: lkml.org

    Paul Moore writes: On Wed, Dec 1, 2021 at 10:12 PM Bernard Zhao wrote: + } Thanks for catching this and submitting a patch, but would it be simpler to do the "(!s)" check before the "(!opts)" check? simpler to do the "(!s)" check before the "(!opts)" check? 2.33.1

    Lu Baolu writes: (Summary) #include "pci.h" #include "pcie/portdrv.h" @@ -1590,9 +1591,16 @@ static int pci_bus_num_vf(struct device *dev) */ static int pci_dma_configure(struct device *dev) { + struct pci_driver *driver = to_pci_driver(dev->driver); +} + struct bus_type pci_bus_type = { .name = "pci", .match = pci_bus_match, @@ -1621,6 +1641,7 @@ struct bus_type pci_bus_type = { .pm = PCI_PM_OPS_PTR, .num_vf = pci_bus_num_vf, .dma_configure = pci_dma_configure, + .dma_cleanup = pci_dma_cleanup, };

    huangxuesen writes: (Summary) From: huangxuesen From: huangxuesen Fix typo in comment from 'bpf_skeleton_map' to 'bpf_map_skeleton' and from 'bpf_skeleton_prog' to 'bpf_prog_skeleton'. 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index c0d62dd..2fa046a9 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -1038,11 +1038,11 @@ struct bpf_object_skeleton { struct bpf_object **obj; /* sizeof(struct bpf_skeleton_map) */ + int map_skel_sz; /* sizeof(struct bpf_skeleton_prog) */ + int prog_skel_sz;

    Joakim Zhang writes: (Summary) DQpIaSBTaGF3biwNCg0KPiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBTaGF3 biBHdW8gPHNoYXduZ3VvQGtlcm5lbC5vcmc+DQo+IFNlbnQ6IDIwMjHE6jEy1MI2yNUgOToxNg0K PiBUbzogSm9ha2ltIFpoYW5nIDxxaWFuZ3FpbmcuemhhbmdAbnhwLmNvbT4NCj4gQ2M6IHJvYmgr ZHRAa2VybmVsLm9yZzsgcy5oYXVlckBwZW5ndXRyb25peC5kZTsga2VybmVsQHBlbmd1dHJvbml4 LmRlOw0KPiBmZXN0ZXZhbUBnbWFpbC5jb207IGRsLWxpbnV4LWlteCA8bGludXgtaW14QG54cC5j b20+Ow0KPiBkZXZpY2V0cmVlQHZnZXIua2VybmVsLm9yZzsgbGludXgta2VybmVsQHZnZXIua2Vy bmVsLm9yZw0KPiBTdWJqZWN0OiBSZTogW1BBVENIIDQvN10gYXJtNjQ6IGR0czogaW14OG06IGNv bmZpZ3VyZSBGRUMgUEhZIFZERElPDQo+IHZvbHRhZ2UNCj4gDQo+IE9uIFR1ZSwgTm92IDIzLCAy MDIxIGF0IDA0OjA1OjAzUE0gKzA4MDAsIEpvYWtpbSBaaGFuZyB3cm90ZToNCj4gPiBBcyBjb21t aXQgMmY2NjQ4MjNhNDcwICgibmV0OiBwaHk6IGF0ODAzeDogYWRkIGRldmljZSB0cmVlIGJpbmRp bmciKQ0KPiA+IGRlc2NyaWJlZCwgY29uZmlndXJlIEZFQyBQSFkgVkRESU8gdm9sdGFnZSBhY2Nv cmRpbmcgdG8gYm9hcmQgZGVzaWduLg0KPiA+DQo+ID4gU2lnbmVkLW9mZi1ieTogSm9ha2ltIFpo YW5nIDxxaWFuZ3FpbmcuemhhbmdAbnhwLmNvbT4NCj4gPiAtLS0NCj4gPiAgYXJjaC9hcm02NC9i b290L2R0cy9mcmVlc2NhbGU

    Lu Baolu writes: (Summary) This is based on v5.16-rc3 and available on github: https://github.com/LuBaolu/intel-iommu/commits/iommu-dma-ownership-v3 Best regards, baolu Jason Gunthorpe (2): vfio: Delete the unbound_list drm/tegra: Use the iommu dma_owner mechanism Lu Baolu (16): iommu: Add device dma ownership set/release interfaces driver core: Add dma_cleanup callback in bus_type driver core: platform: Rename platform_dma_configure() driver core: platform: Add driver dma ownership management amba: Add driver dma ownership management bus: fsl-mc: Add driver dma ownership management PCI: Add driver dma ownership management PCI: pci_stub: Suppress kernel DMA ownership auto-claiming PCI: portdrv: Suppress kernel DMA ownership auto-claiming iommu: Add security context management for assigned devices iommu: Expose group variants of dma ownership interfaces iommu: Add iommu_at[de]tach_device_shared() for multi-device groups

    Lu Baolu writes: (Summary) From the perspective of who is initiating the device to do DMA, device DMA could be divided into the following types: DMA could be divided into the following types: DMA_OWNER_DMA_API: Device DMAs are initiated by a kernel driver through the kernel DMA API. DMA_OWNER_PRIVATE_DOMAIN: Device DMAs are initiated by a kernel driver with its own PRIVATE domain. DMA_OWNER_PRIVATE_DOMAIN_USER: Device DMAs are initiated by userspace. userspace. Different DMA ownerships are exclusive for all devices in the same iommu group as an iommu group is the smallest granularity of device isolation and protection that the IOMMU subsystem can guarantee.

    Lu Baolu writes: (Summary) This adds the paired dma_cleanup() callback and calls it during driver unbinding so that bus drivers can do some cleanup work. some cleanup work. One use case for this paired DMA callbacks is for the bus driver to check for DMA ownership conflicts during driver binding, where multiple devices belonging to a same IOMMU group (the minimum granularity of isolation and protection) may be assigned to kernel drivers or user space respectively.

    Lu Baolu writes: (Summary) +} + static const struct dev_pm_ops platform_dev_pm_ops = { SET_RUNTIME_PM_OPS(pm_generic_runtime_suspend, pm_generic_runtime_resume, NULL) USE_PLATFORM_PM_SLEEP_OPS @@ -1477,7 +1504,8 @@ struct bus_type platform_bus_type = { .probe = platform_probe, .remove = platform_remove, .shutdown = platform_shutdown, - .dma_configure = firmware_dma_configure, + .dma_configure = platform_dma_configure, + .dma_cleanup = platform_dma_cleanup, .pm = &platform_dev_pm_ops, };

    Lu Baolu writes: (Summary) #ifdef CONFIG_PM_SLEEP #define USE_PLATFORM_PM_SLEEP_OPS \ diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 720aa6cdd402..08c094124c0e 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -319,7 +319,7 @@ struct bus_type amba_bustype = { .probe = amba_probe, .remove = amba_remove, .shutdown = amba_shutdown, - .dma_configure = platform_dma_configure, + .dma_configure = firmware_dma_configure, .pm = &amba_pm, }; @@ -1478,7 +1477,7 @@ struct bus_type platform_bus_type = { .probe = platform_probe, .remove = platform_remove, .shutdown = platform_shutdown, - .dma_configure = platform_dma_configure, + .dma_configure = firmware_dma_configure, .pm = &platform_dev_pm_ops, };

    Lu Baolu writes: (Summary) + + if (!drv->suppress_auto_claim_dma_owner) { + ret = iommu_device_set_dma_owner(dev, DMA_OWNER_DMA_API, NULL); + } + + ret = firmware_dma_configure(dev); +} + +static void amba_dma_cleanup(struct device *dev) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); @@ -319,7 +346,8 @@ struct bus_type amba_bustype = { .probe = amba_probe, .remove = amba_remove, .shutdown = amba_shutdown, - .dma_configure = firmware_dma_configure, + .dma_configure = amba_dma_configure, + .dma_cleanup = amba_dma_cleanup, .pm = &amba_pm, };

    Lu Baolu writes: (Summary) + + if (!mc_drv->suppress_auto_claim_dma_owner) { + ret = iommu_device_set_dma_owner(dev, DMA_OWNER_DMA_API, NULL); +} + +static void fsl_mc_dma_cleanup(struct device *dev) +{ + struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver); } static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, @@ -312,6 +333,7 @@ struct bus_type fsl_mc_bus_type = { .match = fsl_mc_bus_match, .uevent = fsl_mc_bus_uevent, .dma_configure = fsl_mc_dma_configure, + .dma_cleanup = fsl_mc_dma_cleanup, .dev_groups = fsl_mc_dev_groups, .bus_groups = fsl_mc_bus_groups, };

    Lu Baolu writes: (Summary) This allows the pci_stub still able to be used by the admin to block driver binding after applying the DMA ownership to vfio. applying the DMA ownership to vfio. Signed-off-by: Lu Baolu 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pci/pci-stub.c b/drivers/pci/pci-stub.c index e408099fea52..14b9b9f2ad2b 100644 --- a/drivers/pci/pci-stub.c +++ b/drivers/pci/pci-stub.c @@ -36,6 +36,7 @@ static struct pci_driver stub_driver = { .name = "pci-stub", .id_table = NULL, /* only dynamic id's */ .probe = pci_stub_probe, + .suppress_auto_claim_dma_owner = true, };

    "Lihua (lihua, ran)" writes: (Summary) Fixes: d0b27fa77854 ("sched: rt-group: synchonised bandwidth period") Fixes: d0b27fa77854 ("sched: rt-group: synchonised bandwidth period") --- Thanks for your review~~ 在 On Fri, Dec 03, 2021 at 03:36:18AM +0000, Li Hua wrote: >> Run a FIFO task named A that executes while(1) >> When rt_runtime is -1, The rt period timer will not be activated when task >> And then the task will be throttled after setting rt_runtime to >> The task will always be throttled because the rt period timer is >>

    Lu Baolu writes: (Summary) Calling pci_set_master() or a dma_map_* API is a sure indicate the driver is doing DMA a dma_map_* API is a sure indicate the driver is doing DMA 2) If the bridge driver uses MMIO, is it tolerant to hostile userspace also touching the same MMIO registers via P2P DMA attacks? attacks? Conservatively if the driver maps an MMIO region at all, we can say that it fails the test. it fails the test. Suggested-by: Jason Gunthorpe

    Lu Baolu writes: (Summary) - if (group->default_domain) { + /* + * If any device in the group has been initialized for user dma, + * avoid attaching the default domain. + + /* + * We must ensure that any device DMAs issued after this call + * are discarded. + */ + if (owner == DMA_OWNER_PRIVATE_DOMAIN_USER) { + if (group->domain) { + if (group->domain != group->default_domain) { + group->dma_owner = DMA_OWNER_NONE; + + /* + * The UNMANAGED domain should be detached before all USER + * owners have been released.

    Lu Baolu writes: (Summary) #else /* CONFIG_IOMMU_API */ @@ -1117,6 +1121,23 @@ static inline void iommu_device_release_dma_owner(struct device *dev, enum iommu_dma_owner owner) { } + +static inline int iommu_group_set_dma_owner(struct iommu_group *group, + enum iommu_dma_owner owner, + void *owner_cookie) +{ + return -EINVAL; +} + +static inline void iommu_group_release_dma_owner(struct iommu_group *group, + enum iommu_dma_owner owner) +{ +} + +static inline bool iommu_group_dma_owner_unclaimed(struct iommu_group *group) +{ + return false;

    Lu Baolu writes: (Summary) +} + static inline void iommu_detach_device(struct iommu_domain *domain, struct device *dev) { } +static inline void iommu_detach_device_shared(struct iommu_domain *domain, + struct device *dev) +{ +} + static inline struct iommu_domain *iommu_get_domain_for_dev(struct device *dev) { return NULL; + } + + ret = __iommu_attach_group(domain, group);

    Lu Baolu writes: (Summary) 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 00f89acfec39..63e24f746b82 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1316,12 +1316,6 @@ static int vfio_group_set_container(struct vfio_group *group, int container_fd) return ret; } -static bool vfio_group_viable(struct vfio_group *group) -{ - return (iommu_group_for_each_dev(group->iommu_group, - group, vfio_dev_viable) == 0); !vfio_group_viable(group)) { + if (!group->container->iommu_driver) { atomic_dec(&group->container_users);

    Lu Baolu writes: (Summary) 13 ++++++++++++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c index 6e2e62c6f47a..5f36ffbb07d1 100644 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c @@ -588,6 +588,7 @@ static struct fsl_mc_driver vfio_fsl_mc_driver = { .name = "vfio-fsl-mc", .owner = THIS_MODULE, }, + .suppress_auto_claim_dma_owner = true, }; diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c index 68a1c87066d7..8bda68775b97 100644 --- a/drivers/vfio/platform/vfio_platform.c +++ b/drivers/vfio/platform/vfio_platform.c @@ -76,6 +76,7 @@ static struct platform_driver vfio_platform_driver = { .driver = { .name = "vfio-platform", }, + .suppress_auto_claim_dma_owner = true, };

    Lu Baolu writes: (Summary) - - list_for_each_entry_safe(unbound, tmp, - &group->unbound_list, unbound_next) { - list_del(&unbound->unbound_next); - list_for_each_entry(unbound, &group->unbound_list, unbound_next) { - if (dev == unbound->dev) { - ret = 0; - } - } - mutex_unlock(&group->unbound_lock); - list_for_each_entry(unbound, - &group->unbound_list, unbound_next) { - if (dev == unbound->dev) { - list_del(&unbound->unbound_next); - } - } - mutex_unlock(&group->unbound_lock);

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here