xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] VT-d: avoid faulting in print_iommu_regs()
Date: Tue, 23 Mar 2010 16:56:54 +0000	[thread overview]
Message-ID: <4BA900E6020000780003691A@vpn.id2.novell.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1448 bytes --]

In c/s 21027 I overlooked that using this function when bad table data
was found requires the function to also do some range checking.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-03-22.orig/xen/drivers/passthrough/vtd/utils.c	2010-03-17 22:19:25.000000000 +0100
+++ 2010-03-22/xen/drivers/passthrough/vtd/utils.c	2010-03-23 17:52:20.000000000 +0100
@@ -67,10 +67,13 @@ void print_iommu_regs(struct acpi_drhd_u
     printk(" CAP = %"PRIx64"\n", cap = dmar_readq(iommu->reg, DMAR_CAP_REG));
     printk(" n_fault_reg = %"PRIx64"\n", cap_num_fault_regs(cap));
     printk(" fault_recording_offset = %"PRIx64"\n", cap_fault_reg_offset(cap));
-    printk(" fault_recording_reg_l = %"PRIx64"\n",
-           dmar_readq(iommu->reg, cap_fault_reg_offset(cap)));
-    printk(" fault_recording_reg_h = %"PRIx64"\n",
-           dmar_readq(iommu->reg, cap_fault_reg_offset(cap) + 8));
+    if ( cap_fault_reg_offset(cap) < PAGE_SIZE )
+    {
+        printk(" fault_recording_reg_l = %"PRIx64"\n",
+               dmar_readq(iommu->reg, cap_fault_reg_offset(cap)));
+        printk(" fault_recording_reg_h = %"PRIx64"\n",
+               dmar_readq(iommu->reg, cap_fault_reg_offset(cap) + 8));
+    }
     printk(" ECAP = %"PRIx64"\n", dmar_readq(iommu->reg, DMAR_ECAP_REG));
     printk(" GCMD = %x\n", dmar_readl(iommu->reg, DMAR_GCMD_REG));
     printk(" GSTS = %x\n", dmar_readl(iommu->reg, DMAR_GSTS_REG));




[-- Attachment #2: vtd-print-regs-check.patch --]
[-- Type: text/plain, Size: 1442 bytes --]

In c/s 21027 I overlooked that using this function when bad table data
was found requires the function to also do some range checking.

Signed-off-by: Jan Beulich <jbeulich@novell.com>

--- 2010-03-22.orig/xen/drivers/passthrough/vtd/utils.c	2010-03-17 22:19:25.000000000 +0100
+++ 2010-03-22/xen/drivers/passthrough/vtd/utils.c	2010-03-23 17:52:20.000000000 +0100
@@ -67,10 +67,13 @@ void print_iommu_regs(struct acpi_drhd_u
     printk(" CAP = %"PRIx64"\n", cap = dmar_readq(iommu->reg, DMAR_CAP_REG));
     printk(" n_fault_reg = %"PRIx64"\n", cap_num_fault_regs(cap));
     printk(" fault_recording_offset = %"PRIx64"\n", cap_fault_reg_offset(cap));
-    printk(" fault_recording_reg_l = %"PRIx64"\n",
-           dmar_readq(iommu->reg, cap_fault_reg_offset(cap)));
-    printk(" fault_recording_reg_h = %"PRIx64"\n",
-           dmar_readq(iommu->reg, cap_fault_reg_offset(cap) + 8));
+    if ( cap_fault_reg_offset(cap) < PAGE_SIZE )
+    {
+        printk(" fault_recording_reg_l = %"PRIx64"\n",
+               dmar_readq(iommu->reg, cap_fault_reg_offset(cap)));
+        printk(" fault_recording_reg_h = %"PRIx64"\n",
+               dmar_readq(iommu->reg, cap_fault_reg_offset(cap) + 8));
+    }
     printk(" ECAP = %"PRIx64"\n", dmar_readq(iommu->reg, DMAR_ECAP_REG));
     printk(" GCMD = %x\n", dmar_readl(iommu->reg, DMAR_GCMD_REG));
     printk(" GSTS = %x\n", dmar_readl(iommu->reg, DMAR_GSTS_REG));

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2010-03-23 16:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4BA900E6020000780003691A@vpn.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=xen-devel@lists.xensource.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).