x86 PAT fixes
Subsystems (6)
Linus,
Please pull the latest x86-pat-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-pat-for-linus
This is the PAT lineup that solves a range of 3D problems under X. It has two commits excluded [the 1MB legacy one and the resource_size_t ioremap_wc() one]- in the hope of fixing the crash Torsten Kaiser reported.
Torsten, could you please try this tree too, is it stable and does it solve the 3D problems?
out-of-topic modifications in x86-pat-for-linus:
------------------------------------------------include/asm-generic/pgtable.h # e4b866e: x86 PAT: change track_pfn_vma_newmm/memory.c # e4b866e: x86 PAT: change track_pfn_vma_new
# a367061: x86 PAT: remove PFNMAP type on tr
Thanks,
Ingo
------------------>
[email protected] (5):
x86 PAT: remove PFNMAP type on track_pfn_vma_new() error x86 PAT: consolidate old memtype new memtype check into a function x86 PAT: change track_pfn_vma_new to take pgprot_t pointer param x86 PAT: return compatible mapping to remap_pfn_range callers x86 PAT: remove CPA WARN_ON for zero pte
arch/x86/include/asm/pgtable.h | 19 ++++++++ arch/x86/mm/pageattr.c | 10 +++-- arch/x86/mm/pat.c | 90 +++++++++++++++++++++++++++------------- arch/x86/pci/i386.c | 12 +----- include/asm-generic/pgtable.h | 4 +- mm/memory.c | 15 +++++-- 6 files changed, 100 insertions(+), 50 deletions(-)
arch/x86/include/asm/pgtable.h +19 -0
@@ -341,6 +341,25 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)#define canon_pgprot (p) __pgprot(pgprot_val(p) & __supported_pte_mask) +static inline int is_new_memtype_allowed (unsigned long flags, +unsigned long new_flags) +{ +/* +* Certain new memtypes are not allowed with certain +* requested memtype: +* - request is uncached, return cannot be write-back +* - request is write-combine, return cannot be write-back +*/ +if ((flags == _PAGE_CACHE_UC_MINUS && + new_flags == _PAGE_CACHE_WB) || + (flags == _PAGE_CACHE_WC && + new_flags == _PAGE_CACHE_WB)) { +return 0 ; + } + +return 1 ; +} +#ifndef __ASSEMBLY__/* Indicate that x86 has its own track and untrack pfn vma functions */ #define __HAVE_PFNMAP_TRACKING
arch/x86/mm/pageattr.c +6 -4
@@ -555,10 +555,12 @@ repeat:if (!pte_val (old_pte)) {if (!primary)return 0 ; -WARN (1 ,KERN_WARNING "CPA: called for zero pte. " -"vaddr = %lx cpa->vaddr = %lx\n" , address, - *cpa->vaddr); -return -EINVAL ; + +/* +* Special error value returned, indicating that the mapping +* did not exist at this address. +*/ +return -EFAULT ; }if (level ==PG_LEVEL_4K ) {
arch/x86/mm/pat.c +61 -29
155 lines not on this page · raw message
arch/x86/pci/i386.c +1 -11
@@ -314,17 +314,7 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,return retval;if (flags != new_flags) { -/* -* Do not fallback to certain memory types with certain -* requested type: -* - request is uncached, return cannot be write-back -* - request is uncached, return cannot be write-combine -* - request is write-combine, return cannot be write-back -*/ -if ((flags == _PAGE_CACHE_UC_MINUS && - (new_flags == _PAGE_CACHE_WB)) || - (flags == _PAGE_CACHE_WC && - new_flags == _PAGE_CACHE_WB)) { +if (!is_new_memtype_allowed (flags, new_flags)) {free_memtype (addr, addr+len);return -EINVAL ; }
include/asm-generic/pgtable.h +2 -2
@@ -301,7 +301,7 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm,* track_pfn_vma_new is called when a _new_ pfn mapping is being established * for physical range indicated by pfn and size. */ -static inline int track_pfn_vma_new (struct vm_area_struct *vma,pgprot_t prot, +static inline int track_pfn_vma_new (struct vm_area_struct *vma,pgprot_t *prot,unsigned long pfn,unsigned long size) {return 0 ;
@@ -332,7 +332,7 @@ static inline void untrack_pfn_vma(struct vm_area_struct *vma, { }#else -extern int track_pfn_vma_new (struct vm_area_struct *vma,pgprot_t prot, +extern int track_pfn_vma_new (struct vm_area_struct *vma,pgprot_t *prot,unsigned long pfn,unsigned long size);extern int track_pfn_vma_copy (struct vm_area_struct *vma); extern void untrack_pfn_vma(struct vm_area_struct *vma, unsigned long pfn,
mm/memory.c +11 -4
@@ -1511,6 +1511,7 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn) {int ret; +pgprot_t pgprot = vma->vm_page_prot;/* * Technically, architectures with pte_special can avoid all these * restrictions (same for remap_pfn_range). However we would like
@@ -1525,10 +1526,10 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,if (addr < vma->vm_start || addr >= vma->vm_end)return -EFAULT ; -if (track_pfn_vma_new (vma, vma->vm_page_prot, pfn,PAGE_SIZE )) +if (track_pfn_vma_new (vma, &pgprot, pfn,PAGE_SIZE ))return -EINVAL ; - ret =insert_pfn (vma, addr, pfn, vma->vm_page_prot); + ret =insert_pfn (vma, addr, pfn, pgprot);if (ret)untrack_pfn_vma (vma, pfn,PAGE_SIZE );
@@ -1671,9 +1672,15 @@ int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, vma->vm_flags |=VM_IO |VM_RESERVED |VM_PFNMAP ; - err =track_pfn_vma_new (vma, prot, pfn,PAGE_ALIGN (size)); -if (err) + err =track_pfn_vma_new (vma, &prot, pfn,PAGE_ALIGN (size)); +if (err) { +/* +* To indicate that track_pfn related cleanup is not +* needed from higher level routine calling unmap_vmas +*/ + vma->vm_flags &= ~(VM_IO |VM_RESERVED |VM_PFNMAP );return -EINVAL ; + }BUG_ON (addr >= end); pfn -= addr >>PAGE_SHIFT ;