Skip to content

Commit dee7cbb

Browse files
Venki PallipadiIngo Molnar
authored andcommitted
x86: PAT bug fix for attribute type check after reserve_memtype
Bug fixes for reserve_memtype() call in __ioremap and pci_mmap_page_range(). If reserve_memtype returns non-zero, then it is an error and subsequent free is not required. Requested and returned prot value check should be done when reserve_memtype returns success. Signed-off-by: Venkatesh Pallipadi <[email protected]> Signed-off-by: Suresh Siddha <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 9307cac commit dee7cbb

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

arch/x86/mm/ioremap.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ static void __iomem *__ioremap(resource_size_t phys_addr, unsigned long size,
124124
struct vm_struct *area;
125125
unsigned long new_prot_val;
126126
pgprot_t prot;
127+
int retval;
127128

128129
/* Don't allow wraparound or zero size */
129130
last_addr = phys_addr + size - 1;
@@ -163,8 +164,14 @@ static void __iomem *__ioremap(resource_size_t phys_addr, unsigned long size,
163164
phys_addr &= PAGE_MASK;
164165
size = PAGE_ALIGN(last_addr+1) - phys_addr;
165166

166-
if (reserve_memtype(phys_addr, phys_addr + size,
167-
prot_val, &new_prot_val)) {
167+
retval = reserve_memtype(phys_addr, phys_addr + size,
168+
prot_val, &new_prot_val);
169+
if (retval) {
170+
printk("reserve_memtype returned %d\n", retval);
171+
return NULL;
172+
}
173+
174+
if (prot_val != new_prot_val) {
168175
/*
169176
* Do not fallback to certain memory types with certain
170177
* requested type:

arch/x86/pci/i386.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
328328
unsigned long len = vma->vm_end - vma->vm_start;
329329
unsigned long flags;
330330
unsigned long new_flags;
331+
int retval;
331332

332333
/* I/O space cannot be accessed via normal processor loads and
333334
* stores on this platform.
@@ -344,7 +345,11 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
344345
vma->vm_page_prot = __pgprot(prot);
345346

346347
flags = pgprot_val(vma->vm_page_prot) & _PAGE_CACHE_MASK;
347-
if (reserve_memtype(addr, addr + len, flags, &new_flags)) {
348+
retval = reserve_memtype(addr, addr + len, flags, &new_flags);
349+
if (retval)
350+
return retval;
351+
352+
if (flags != new_flags) {
348353
/*
349354
* Do not fallback to certain memory types with certain
350355
* requested type:

0 commit comments

Comments
 (0)