All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Maciek <gotoc64@gmail.com>
Cc: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [driver question] IOMMU concept in Xen
Date: Mon, 10 Oct 2016 01:44:32 -0600	[thread overview]
Message-ID: <57FB63000200007800115F88@prv-mh.provo.novell.com> (raw)
In-Reply-To: <a126e873-899e-f5d0-3585-61c0d8c5923c@gmail.com>

>>> On 10.10.16 at 02:19, <gotoc64@gmail.com> wrote:
> During development of linux kernel PCI driver with SR-IOV I meet some 
> difficulty and I wanted to make sure that I understand correctly Xen 
> concepts.
> 
> Things that confuse me is build in function: iommu_present. Is usually 
> used in driver that are using iommu to work.
> My problem is that this function work perfectly fine on bare-metal 
> linux, but when I move to Xen (or XenServer) then this function return 
> always false.
> 
> I know that Xen concept move IOMMU from linux kernel (which is on xen 
> just VM) to the hyperviosr. In XenServer is done using command: 
> xen-cmdline --set-xen iommu=1. After this command (and restart) iommu 
> should work.
> I can also add this parameter to kernel cmd line (intel_iommu=on). Using 
> that in kernel messages I can see message: Intel-IOMMU: enabled. But no 
> matter which way I follow, iommu_present will always return me false.
> 
> I just commented out this check block and run whole driver, there wasn't 
> any issue and driver works perfectly.
> 
> After that I if there are other drivers in kernel that have the same 
> issue, but I didn't find anything that can solve this issue. One driver 
> check has conditional compilation for iommu_present block: #if 
> IS_ENABLED(CONFIG_IOMMU_API), but in XenServer (I checked XS 6.5) this 
> option is set to yes in kernel configuration. (This driver source is: 
> drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c)
> 
> Using grep I found other drivers that can run into same trouble (doesn't 
> start or throw warning log) inside Xen as dom0:
> ## drivers that are uisng iommu_present
> drivers/gpu/drm/tegra/drm.c
> drivers/infiniband/hw/usnic/usnic_uiom.c
> drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
> drivers/vfio/vfio.c
> drivers/gpu/drm/msm/msm_gem.c
> drivers/gpu/drm/msm/msm_drv.c
> drivers/gpu/drm/mediatek/mtk_drm_drv.c
> drivers/crypto/qat/qat_common/adf_sriov.c
> 
> So there are two options: there drivers are not designed for Xen or I 
> totally mess up something.
> 
> In my driver I started thinking to use #if IS_ENABLED(CONFIG_XEN_DOM0) 
> to handle different Hypervisor, but maybe is not right solution.

What you don't clarify in all of the above explanations and analysis
is - why do you need to know in the driver in the first place. To a
guest the presence of an IOMMU should be transparent. There may
be certain cases where Dom0 drivers need to know, but such then
need to be made interact with Xen (as the entity driving the IOMMU),
i.e. can't normally work on Xen without some minimal adjustments.
And this should really be the exception, not the rule.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-10-10  7:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10  0:19 [driver question] IOMMU concept in Xen Maciek
2016-10-10  7:44 ` Jan Beulich [this message]
2016-10-10 20:15   ` Maciek
2016-10-11 12:49     ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57FB63000200007800115F88@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=gotoc64@gmail.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.