x86: PAT bug fix for attribute type check after reserve_memtype
PATCH 1/1 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.
--- arch/x86/mm/ioremap.c | 11 +++++++++-- arch/x86/pci/i386.c | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-)
arch/x86/mm/ioremap.c +9 -2
@@ -126,6 +126,7 @@ static void __iomem *__ioremap(unsignedunsigned long new_prot_val;pgprot_t prot;void __iomem *ret_addr; +int retval;/* Don't allow wraparound or zero size */ last_addr = phys_addr + size -1 ;
@@ -165,8 +166,14 @@ static void __iomem *__ioremap(unsigned phys_addr &=PAGE_MASK ; size =PAGE_ALIGN (last_addr+1 ) - phys_addr; -if (reserve_memtype (phys_addr, phys_addr + size, - prot_val, &new_prot_val)) { + retval =reserve_memtype (phys_addr, phys_addr + size, + prot_val, &new_prot_val); +if (retval) { +printk ("reserve_memtype returned %d\n" , retval); +return NULL ; + } + +if (prot_val != new_prot_val) {/* * Do not fallback to certain memory types with certain * requested type:
arch/x86/pci/i386.c +6 -1
@@ -328,6 +328,7 @@ int pci_mmap_page_range(struct pci_dev *unsigned long len = vma->vm_end - vma->vm_start;unsigned long flags;unsigned long new_flags; +int retval;/* I/O space cannot be accessed via normal processor loads and * stores on this platform.
@@ -344,7 +345,11 @@ int pci_mmap_page_range(struct pci_dev * vma->vm_page_prot =__pgprot (prot); flags =pgprot_val (vma->vm_page_prot) & _PAGE_CACHE_MASK; -if (reserve_memtype (addr, addr + len, flags, &new_flags)) { + retval =reserve_memtype (addr, addr + len, flags, &new_flags); +if (retval) +return retval; + +if (flags != new_flags) {/* * Do not fallback to certain memory types with certain * requested type:
Ingo Molnar
AppliedQuoted 4 lines · Venki Pallipadi
Bug fixes for
reserve_memtype()call in__ioremapandpci_mmap_page_range(). Ifreserve_memtypereturns non-zero, then it is an error and subsequent free is not required. Requested and returned prot value check should be done whenreserve_memtypereturns success.
thanks, applied.
arch/x86/mm/ioremap.c static void __iomem *__ioremap(unsigned · line 172
Quoted 2 lines
arch/x86/mm/ioremap.c +2
-0+if (retval) { +printk ("reserve_memtype returned %d\n" , retval);
that needs a KERN_INFO, and should be labeled "Warning: ...".
Ingo