diff options
author | Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> | 2009-07-10 12:57:41 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-08-26 18:41:35 -0400 |
commit | d886c73cd4cf02a71e1650cbcb6176799d78aac1 (patch) | |
tree | b7bf968f5d9661e4d6fd56b35386556779194df1 /arch/x86/mm/pat.c | |
parent | 1087637616dd5e96d834164ea462aed6159d039b (diff) |
x86, pat: Sanity check remap_pfn_range for RAM region
Add sanity check for remap_pfn_range of RAM regions using
lookup_memtype(). Previously, we did not have anyway to get the type of
RAM memory regions as they were tracked using a single bit in
page_struct (WB, nonWB). Now we can get the actual type from page struct
(WB, WC, UC_MINUS) and make sure the requester gets that type.
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/mm/pat.c')
-rw-r--r-- | arch/x86/mm/pat.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index b629f75f73de..a6cace0694a2 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -783,11 +783,29 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot, | |||
783 | is_ram = pat_pagerange_is_ram(paddr, paddr + size); | 783 | is_ram = pat_pagerange_is_ram(paddr, paddr + size); |
784 | 784 | ||
785 | /* | 785 | /* |
786 | * reserve_pfn_range() doesn't support RAM pages. Maintain the current | 786 | * reserve_pfn_range() for RAM pages. We do not refcount to keep |
787 | * behavior with RAM pages by returning success. | 787 | * track of number of mappings of RAM pages. We can assert that |
788 | * the type requested matches the type of first page in the range. | ||
788 | */ | 789 | */ |
789 | if (is_ram != 0) | 790 | if (is_ram) { |
791 | if (!pat_enabled) | ||
792 | return 0; | ||
793 | |||
794 | flags = lookup_memtype(paddr); | ||
795 | if (want_flags != flags) { | ||
796 | printk(KERN_WARNING | ||
797 | "%s:%d map pfn RAM range req %s for %Lx-%Lx, got %s\n", | ||
798 | current->comm, current->pid, | ||
799 | cattr_name(want_flags), | ||
800 | (unsigned long long)paddr, | ||
801 | (unsigned long long)(paddr + size), | ||
802 | cattr_name(flags)); | ||
803 | *vma_prot = __pgprot((pgprot_val(*vma_prot) & | ||
804 | (~_PAGE_CACHE_MASK)) | | ||
805 | flags); | ||
806 | } | ||
790 | return 0; | 807 | return 0; |
808 | } | ||
791 | 809 | ||
792 | ret = reserve_memtype(paddr, paddr + size, want_flags, &flags); | 810 | ret = reserve_memtype(paddr, paddr + size, want_flags, &flags); |
793 | if (ret) | 811 | if (ret) |