Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp5076ybz; Thu, 16 Apr 2020 18:05:48 -0700 (PDT) X-Google-Smtp-Source: APiQypJALWHgNkjNTrm2hNGuQIy4tpHbdw++3m2AMQhUmgtXS/8a+vIQ9BpsgrrgNxK9PG5kU5Ur X-Received: by 2002:a17:906:af99:: with SMTP id mj25mr684536ejb.151.1587085547905; Thu, 16 Apr 2020 18:05:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587085547; cv=none; d=google.com; s=arc-20160816; b=klsrtScfOSR0alOyapUr8Ch5Ueij77uhnYWvTWqRwFsqJk+Si6J56IWDO10kPidsk/ 6hljiZenjMTd/FChU7IhVHVfFJbgV3C9B/OP2TtyKJvyi5gtV4tXCsThd2lyNftZCeq8 QdsVjKCA4Uu/4ASr1OYFBEZaKECW7K2EsGxYyexBzqBsewJwOehCpYHkRnglp3TfbbCf HwEbiSUVyor9laryWIvDpmA13KomTCpwWMooOyOknDhUX8u/ruDm27UwL3/ujjQljkQn 9zJx+3nX1s797lCHQ3sGdTDE1XW4YjuDqdYiH4lTKe5/SgilWT5yXYFhYFgMdfS9JpUG xeDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0ZL5DKQEN5tIRYMA9bsAF7qYyxlNKGNuVSjiADQ9SPk=; b=dx4If6vKsX0yiXcJmH2aBf4FjU9aAE8bLwf4nRsygGY2KsfSVKrOlSp2uyu/q3NMh9 3uH+o8LChiQV8y8NzJ0DyUAnx0DWcJbbxv+QQuA2LuUFezmvIaQHWiHMRhP6gbiwlgEp IytssteVBOGdSCfx0BETjr7uaiCWrf574W6SYd2G1z0790rTqEylSWoQzOVcLszYVo1A c2w48W/NCH3b5cKKNUWX6NSv/8ZEPxISBNwQHPo88L2z0KNfldQcTgTqIgrZyoX+Svcu zO2b+tfUPtgriNLRN9/xcG0S+7GEnFlbZIK65yjhyOHgTWQStn0fBfdJPadUUG5zJe2P LW8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=FrdtkA3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si11875948eja.257.2020.04.16.18.05.23; Thu, 16 Apr 2020 18:05:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@endlessm-com.20150623.gappssmtp.com header.s=20150623 header.b=FrdtkA3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728623AbgDQBDr (ORCPT + 99 others); Thu, 16 Apr 2020 21:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728454AbgDQBDq (ORCPT ); Thu, 16 Apr 2020 21:03:46 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0FD7C061A41 for ; Thu, 16 Apr 2020 18:03:44 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id g2so326951plo.3 for ; Thu, 16 Apr 2020 18:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0ZL5DKQEN5tIRYMA9bsAF7qYyxlNKGNuVSjiADQ9SPk=; b=FrdtkA3N/A0B10cQBR1BRxqf+/pg1uBkd6DO7lHtdKgOqGpk1/7USrxTk4rdlzJ0Pn oQGe7ba6HSEplsOy6ec3K4H8Fpx1j9/0meJ+gk7xvdUqFq7CDtsNxsMJzjX3kGdDbbz8 GCSySEUU8oXzqHDM2sby4knjcPLSSaIgNvaO9PtWZWWefGILL8HPrNXdIlKHYq2YILWZ AMHiZb/IAXXMBCtRYZZ2S6R7t7InyUg113cLru837l9P5It247de3hDzpXYYYkdzsiNW l3eKB2Wxab5vn9CTNWz5BkklF52xIUVdN24g+AL8C9OhFHLjLh5Ls1ropaQnpLD31b3o DqaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0ZL5DKQEN5tIRYMA9bsAF7qYyxlNKGNuVSjiADQ9SPk=; b=USOjXq/YVeflxnI35LnHPAOjw+/S+1Hgt6Q/FJgKpqbeiSZqsoAHT0YEjb/QmALm2w YLsjMndxJwMiLZq2uQdY0Q8TjueyVV+v9q0ZqzNncN1FSuWAJdvSZz3GEs7jMYjCIpJh yhuzjS88xy4TvQuUvr5xgVapWzw0XrXDWRFRwkpv2gzUY4EleXW60kG94Jvfp8DOZKud 3UITuyvxm+CCv/IkF93OJNxdFOaG2aMliQNSqDDvvMAAb4yxWKarcGnScNDA2xJnC6rj 0byUBkwjGQH1lUFWUy5YGKXCBdRqWNCdIEE14nySQrQ010arwqQHoiQrcTmmFZ7kOt14 uPHw== X-Gm-Message-State: AGi0PuZ1oiuHNoPLCi9LZHWKvLtY3XK8uSKuQePZK0Y4AOb+UrfmMAIp Yew/OEcGXz7Zoy3kh6I9alnktw== X-Received: by 2002:a17:902:fe09:: with SMTP id g9mr366208plj.171.1587085424144; Thu, 16 Apr 2020 18:03:44 -0700 (PDT) Received: from limbo.local (host-160.218-14-119.dynamic.totalbb.net.tw. [119.14.218.160]) by smtp.gmail.com with ESMTPSA id u8sm16518026pgl.19.2020.04.16.18.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Apr 2020 18:03:43 -0700 (PDT) From: Daniel Drake To: joro@8bytes.org Cc: agross@kernel.org, baolu.lu@linux.intel.com, bjorn.andersson@linaro.org, dwmw2@infradead.org, gerald.schaefer@de.ibm.com, heiko@sntech.de, iommu@lists.linux-foundation.org, jean-philippe@linaro.org, jonathanh@nvidia.com, kgene@kernel.org, krzk@kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, m.szyprowski@samsung.com, matthias.bgg@gmail.com, robdclark@gmail.com, robin.murphy@arm.com, thierry.reding@gmail.com, virtualization@lists.linux-foundation.org, will@kernel.org, jonathan.derrick@intel.com Subject: Re: [PATCH v2 00/33] iommu: Move iommu_group setup to IOMMU core code Date: Fri, 17 Apr 2020 09:03:35 +0800 Message-Id: <20200417010335.31739-1-drake@endlessm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414131542.25608-1-joro@8bytes.org> References: <20200414131542.25608-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Joerg, > Hi, > > here is the second version of this patch-set. The first version with > some more introductory text can be found here: > > https://lore.kernel.org/lkml/20200407183742.4344-1-joro@8bytes.org/ Thanks for the continued improvements in this area! I may have spotted a problem with setups like VMD. The core PCI bus is set up during early boot. Then, for the PCI bus, we reach iommu_bus_init() -> bus_iommu_probe(). In there, we call probe_iommu_group() -> dev_iommu_get() for each PCI device, which allocates dev->iommu in each case. So far so good. The problem is that this is the last time that we'll call dev_iommu_get(). If any PCI bus devices get added after this point, they do not get passed to dev_iommu_get(). So when the vmd module gets loaded later, and creates more PCI devices, we end up in iommu_bus_notifier() -> iommu_probe_device() -> __iommu_probe_device() which does: dev->iommu->iommu_dev = iommu_dev; dev->iommu-> is a NULL dereference because dev_iommu_get() was never called for this new device. Daniel