public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Fenghua Yu <fenghua.yu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: lkml <linux-kernel@vger.kernel.org>, torvalds@linux-foundation.org
Subject: [PATCH] More Sanity checks for DMAR
Date: Mon, 19 Nov 2007 15:03:48 -0800	[thread overview]
Message-ID: <20071119230348.GA18775@linux-os.sc.intel.com> (raw)
In-Reply-To: <BAE9DCEF64577A439B3A37F36F9B691C0339372B@orsmsx418.amr.corp.intel.com>


This patch adds and changes a few sanity checks in dmar.c.

1. The haw field in ACPI DMAR table in VT-d spec doesn't describe the range of
haw. But since DMA page size is 4KB in DMA remapping, haw should be at least
4KB. The current VT-d code in dmar.c returns failure when haw==0. This sanity
check is not accurate and execution can pass when haw is less than one page
size 4KB. This patch changes the haw sanity check to validate if haw is less
than 4KB.
2. Add dmar_rmrr_units verification.
3. Add parse_dmar_table() verification.

Thanks.

-Fenghua

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>

---

 dmar.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 5dfdfda..a5b6ed0 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -25,6 +25,7 @@
 
 #include <linux/pci.h>
 #include <linux/dmar.h>
+#include "iova.h"
 
 #undef PREFIX
 #define PREFIX "DMAR:"
@@ -263,8 +264,8 @@ parse_dmar_table(void)
 	if (!dmar)
 		return -ENODEV;
 
-	if (!dmar->width) {
-		printk (KERN_WARNING PREFIX "Zero: Invalid DMAR haw\n");
+	if (dmar->width < PAGE_SHIFT_4K - 1) {
+		printk (KERN_WARNING PREFIX "Invalid DMAR haw\n");
 		return -EINVAL;
 	}
 
@@ -301,11 +302,24 @@ parse_dmar_table(void)
 int __init dmar_table_init(void)
 {
 
-	parse_dmar_table();
+	int ret;
+	
+	ret = parse_dmar_table();
+	if (ret) {
+		printk(KERN_INFO PREFIX "parse DMAR table failure.\n");
+		return ret;
+	}
+
 	if (list_empty(&dmar_drhd_units)) {
 		printk(KERN_INFO PREFIX "No DMAR devices found\n");
 		return -ENODEV;
 	}
+
+	if (list_empty(&dmar_rmrr_units)) {
+		printk(KERN_INFO PREFIX "No RMRR found\n");
+		return -ENODEV;
+	}
+
 	return 0;
 }
 

       reply	other threads:[~2007-11-19 23:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BAE9DCEF64577A439B3A37F36F9B691C0339372B@orsmsx418.amr.corp.intel.com>
2007-11-19 23:03 ` Fenghua Yu [this message]
2007-11-20 18:58   ` [PATCH] More Sanity checks for DMAR mark gross
     [not found] ` <617E1C2C70743745A92448908E030B2A02AD5AD7@scsmsx411.amr.corp.intel.com>
2008-05-02 22:26   ` [PATCH] Handle invalid ACPI SLIT table Fenghua Yu
2008-10-01 16:57   ` [PATCH 1/2]Add Variable Page Size and IA64 Support in Intel IOMMU: Generic Part Fenghua Yu
2008-10-02  8:29     ` Ingo Molnar
2008-10-02 22:06       ` Yu, Fenghua
2008-10-03  8:54         ` Ingo Molnar
2008-10-02 15:31     ` Bjorn Helgaas
2008-10-02 21:46       ` Yu, Fenghua
2008-10-03 15:33         ` Bjorn Helgaas
2008-10-04  0:21           ` Yu, Fenghua
2008-10-07  0:01     ` [PATCH V2 1/2] Add " Fenghua Yu
2009-08-04 22:10   ` [PATCH 2/4] Bug Fix drivers/pci/intel-iommu.c: secure sg_next() calling Fenghua Yu
2009-08-05  8:09     ` David Woodhouse

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=20071119230348.GA18775@linux-os.sc.intel.com \
    --to=fenghua.yu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox