[tip:x86/pat] x86, PAT, PCI: Change vma prot in pci_mmap to reflect inherited prot

From: Pallipadi, Venkatesh
Date: Tue Mar 24 2009 - 05:46:52 EST


Commit-ID: 9cdec049389ce2c324fd1ec508a71528a27d4a07
Gitweb: http://git.kernel.org/tip/9cdec049389ce2c324fd1ec508a71528a27d4a07
Author: Pallipadi, Venkatesh <venkatesh.pallipadi@xxxxxxxxx>
AuthorDate: Mon, 23 Mar 2009 12:07:20 -0700
Committer: Ingo Molnar <mingo@xxxxxxx>
CommitDate: Tue, 24 Mar 2009 10:42:35 +0100

x86, PAT, PCI: Change vma prot in pci_mmap to reflect inherited prot

While looking at the issue in the thread:

http://marc.info/?l=dri-devel&m=123606627824556&w=2

noticed a bug in pci PAT code and memory type setting.

PCI mmap code did not set the proper protection in vma, when it
inherited protection in reserve_memtype. This bug only affects
the case where there exists a WC mapping before X does an mmap
with /proc or /sys pci interface. This will cause X userlevel
mmap from /proc or /sysfs to fail on fork.

Reported-by: Kevin Winchester <kjwinchester@xxxxxxxxx>
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx>
Signed-off-by: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
Cc: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx>
Cc: Dave Airlie <airlied@xxxxxxxxxx>
Cc: <stable@xxxxxxxxxx>
LKML-Reference: <20090323190720.GA16831@xxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxx>


---
arch/x86/pci/i386.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 5ead808..f234a37 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -319,6 +319,9 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
return -EINVAL;
}
flags = new_flags;
+ vma->vm_page_prot = __pgprot(
+ (pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK) |
+ flags);
}

if (((vma->vm_pgoff < max_low_pfn_mapped) ||
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/