From: Keir Fraser <keir@xen.org>
To: Jan Beulich <JBeulich@suse.com>,
wei.huang2@amd.com, weiwang.dd@gmail.com,
xiantao.zhang@intel.com
Cc: Dario Faggioli <raistlin@linux.it>, Tim Deegan <tim@xen.org>,
xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] IOMMU: don't disable bus mastering on faults for devices used by Xen or Dom0
Date: Mon, 05 Nov 2012 17:15:26 +0000 [thread overview]
Message-ID: <CCBDA4AE.51026%keir@xen.org> (raw)
In-Reply-To: <5097FD2902000078000A66BF@nat28.tlf.novell.com>
On 05/11/2012 16:53, "Jan Beulich" <JBeulich@suse.com> wrote:
> Under the assumption that in these cases recurring faults aren't a
> security issue and it can be expected that the drivers there are going
> to try to take care of the problem.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Solving an observed problem?
-- Keir
> --- a/xen/drivers/passthrough/amd/iommu_init.c
> +++ b/xen/drivers/passthrough/amd/iommu_init.c
> @@ -625,6 +625,18 @@ static void parse_event_log_entry(struct
> for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ )
> if ( get_dma_requestor_id(iommu->seg, bdf) == device_id )
> {
> + const struct pci_dev *pdev;
> +
> + spin_lock(&pcidevs_lock);
> + pdev = pci_get_pdev(iommu->seg, PCI_BUS(bdf),
> PCI_DEVFN2(bdf));
> + if ( pdev && pdev->domain != dom_xen &&
> + (!pdev->domain || !IS_PRIV(pdev->domain)) )
> + pdev = NULL;
> + spin_unlock(&pcidevs_lock);
> +
> + if ( pdev )
> + continue;
> +
> cword = pci_conf_read16(iommu->seg, PCI_BUS(bdf),
> PCI_SLOT(bdf), PCI_FUNC(bdf),
> PCI_COMMAND);
> --- a/xen/drivers/passthrough/vtd/iommu.c
> +++ b/xen/drivers/passthrough/vtd/iommu.c
> @@ -916,7 +916,8 @@ static void __do_iommu_page_fault(struct
> reg = cap_fault_reg_offset(iommu->cap);
> while (1)
> {
> - u8 fault_reason;
> + const struct pci_dev *pdev;
> + u8 fault_reason, bus;
> u16 source_id, cword;
> u32 data;
> u64 guest_addr;
> @@ -950,14 +951,27 @@ static void __do_iommu_page_fault(struct
> iommu_page_fault_do_one(iommu, type, fault_reason,
> source_id, guest_addr);
>
> - /* Tell the device to stop DMAing; we can't rely on the guest to
> - * control it for us. */
> - cword = pci_conf_read16(iommu->intel->drhd->segment,
> - PCI_BUS(source_id), PCI_SLOT(source_id),
> - PCI_FUNC(source_id), PCI_COMMAND);
> - pci_conf_write16(iommu->intel->drhd->segment, PCI_BUS(source_id),
> - PCI_SLOT(source_id), PCI_FUNC(source_id),
> - PCI_COMMAND, cword & ~PCI_COMMAND_MASTER);
> + bus = PCI_BUS(source_id);
> +
> + spin_lock(&pcidevs_lock);
> + pdev = pci_get_pdev(iommu->intel->drhd->segment, bus,
> + PCI_DEVFN2(source_id));
> + if ( pdev && pdev->domain != dom_xen &&
> + (!pdev->domain || !IS_PRIV(pdev->domain)) )
> + pdev = NULL;
> + spin_unlock(&pcidevs_lock);
> +
> + if ( !pdev )
> + {
> + /* Tell the device to stop DMAing; we can't rely on the guest to
> + * control it for us. */
> + cword = pci_conf_read16(iommu->intel->drhd->segment, bus,
> + PCI_SLOT(source_id), PCI_FUNC(source_id),
> + PCI_COMMAND);
> + pci_conf_write16(iommu->intel->drhd->segment, bus,
> + PCI_SLOT(source_id), PCI_FUNC(source_id),
> + PCI_COMMAND, cword & ~PCI_COMMAND_MASTER);
> + }
>
> fault_index++;
> if ( fault_index > cap_num_fault_regs(iommu->cap) )
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2012-11-05 17:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-05 16:53 [PATCH] IOMMU: don't disable bus mastering on faults for devices used by Xen or Dom0 Jan Beulich
2012-11-05 17:15 ` Keir Fraser [this message]
2012-11-06 9:08 ` Jan Beulich
2012-11-06 9:44 ` Tim Deegan
2012-11-06 10:19 ` Jan Beulich
2012-11-06 12:08 ` Dario Faggioli
2012-11-06 12:38 ` Jan Beulich
2012-11-06 12:06 ` Dario Faggioli
2012-11-06 12:51 ` Jan Beulich
2012-11-06 13:58 ` Tim Deegan
2012-11-06 14:16 ` Dario Faggioli
2012-11-06 14:17 ` Jan Beulich
2012-11-06 14:29 ` Dario Faggioli
2012-11-08 12:42 ` Tim Deegan
2012-11-06 14:24 ` Dario Faggioli
2012-11-07 16:05 ` [PATCH, v2] IOMMU: don't immediately disable bus mastering on faults Jan Beulich
2012-11-08 12:46 ` Tim Deegan
2012-11-08 13:46 ` Jan Beulich
2012-11-08 14:23 ` Tim Deegan
2012-11-08 18:07 ` Dario Faggioli
2012-11-30 9:42 ` [PATCH] IOMMU: don't disable bus mastering on faults for devices used by Xen or Dom0 Keir Fraser
2012-11-30 9:50 ` Jan Beulich
2012-12-03 6:08 ` Zhang, Xiantao
2012-12-03 7:36 ` Jan Beulich
2012-12-04 0:55 ` Zhang, Xiantao
2012-12-04 8:19 ` 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=CCBDA4AE.51026%keir@xen.org \
--to=keir@xen.org \
--cc=JBeulich@suse.com \
--cc=raistlin@linux.it \
--cc=tim@xen.org \
--cc=wei.huang2@amd.com \
--cc=weiwang.dd@gmail.com \
--cc=xen-devel@lists.xen.org \
--cc=xiantao.zhang@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).