The pgrot_<type>() interfaces only set the _PAGE_PCD and/or _PAGE_PWT bits by assuming that a given pgprot_t value is always set to the PA0 slot. This patch changes the pgrot_<type>() interfaces to assure that a requested memory type is set to the given pgprot_t regardless of the original pgprot_t value. Signed-off-by: Toshi Kani <toshi.kani@xxxxxx> --- arch/x86/include/asm/pgtable.h | 2 +- arch/x86/include/asm/pgtable_types.h | 4 ++++ arch/x86/mm/pat.c | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 0ec0560..df18b14 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -11,7 +11,7 @@ */ #define pgprot_noncached(prot) \ ((boot_cpu_data.x86 > 3) \ - ? (__pgprot(pgprot_val(prot) | _PAGE_CACHE_UC_MINUS)) \ + ? pgprot_set_cache(prot, _PAGE_CACHE_UC_MINUS) \ : (prot)) #ifndef __ASSEMBLY__ diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 1fe8af7..81a3859 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -136,6 +136,10 @@ #define _PAGE_CACHE_UC_MINUS (_PAGE_PCD) #define _PAGE_CACHE_UC (_PAGE_CACHE_UC_MINUS) +/* Macro to set a page cache value */ +#define pgprot_set_cache(_prot, _type) \ + __pgprot((pgprot_val(_prot) & ~_PAGE_CACHE_MASK) | (_type)) + #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \ _PAGE_ACCESSED | _PAGE_NX) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index a987071..0be7ebd 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -790,7 +790,7 @@ void untrack_pfn(struct vm_area_struct *vma, unsigned long pfn, pgprot_t pgprot_writecombine(pgprot_t prot) { if (pat_enabled) - return __pgprot(pgprot_val(prot) | _PAGE_CACHE_WC); + return pgprot_set_cache(prot, _PAGE_CACHE_WC); else return pgprot_noncached(prot); } @@ -799,7 +799,7 @@ EXPORT_SYMBOL_GPL(pgprot_writecombine); pgprot_t pgprot_writethrough(pgprot_t prot) { if (pat_enabled) - return __pgprot(pgprot_val(prot) | _PAGE_CACHE_WT); + return pgprot_set_cache(prot, _PAGE_CACHE_WT); else return pgprot_noncached(prot); } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>