diff options
Diffstat (limited to 'arch/x86/mm/pat.c')
| -rw-r--r-- | arch/x86/mm/pat.c | 77 |
1 files changed, 49 insertions, 28 deletions
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index e0ab173b6974..2ed37158012d 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | #ifdef CONFIG_X86_PAT | 31 | #ifdef CONFIG_X86_PAT |
| 32 | int __read_mostly pat_enabled = 1; | 32 | int __read_mostly pat_enabled = 1; |
| 33 | 33 | ||
| 34 | void __cpuinit pat_disable(char *reason) | 34 | void __cpuinit pat_disable(const char *reason) |
| 35 | { | 35 | { |
| 36 | pat_enabled = 0; | 36 | pat_enabled = 0; |
| 37 | printk(KERN_INFO "%s\n", reason); | 37 | printk(KERN_INFO "%s\n", reason); |
| @@ -43,6 +43,11 @@ static int __init nopat(char *str) | |||
| 43 | return 0; | 43 | return 0; |
| 44 | } | 44 | } |
| 45 | early_param("nopat", nopat); | 45 | early_param("nopat", nopat); |
| 46 | #else | ||
| 47 | static inline void pat_disable(const char *reason) | ||
| 48 | { | ||
| 49 | (void)reason; | ||
| 50 | } | ||
| 46 | #endif | 51 | #endif |
| 47 | 52 | ||
| 48 | 53 | ||
| @@ -79,16 +84,20 @@ void pat_init(void) | |||
| 79 | if (!pat_enabled) | 84 | if (!pat_enabled) |
| 80 | return; | 85 | return; |
| 81 | 86 | ||
| 82 | /* Paranoia check. */ | 87 | if (!cpu_has_pat) { |
| 83 | if (!cpu_has_pat && boot_pat_state) { | 88 | if (!boot_pat_state) { |
| 84 | /* | 89 | pat_disable("PAT not supported by CPU."); |
| 85 | * If this happens we are on a secondary CPU, but | 90 | return; |
| 86 | * switched to PAT on the boot CPU. We have no way to | 91 | } else { |
| 87 | * undo PAT. | 92 | /* |
| 88 | */ | 93 | * If this happens we are on a secondary CPU, but |
| 89 | printk(KERN_ERR "PAT enabled, " | 94 | * switched to PAT on the boot CPU. We have no way to |
| 90 | "but not supported by secondary CPU\n"); | 95 | * undo PAT. |
| 91 | BUG(); | 96 | */ |
| 97 | printk(KERN_ERR "PAT enabled, " | ||
| 98 | "but not supported by secondary CPU\n"); | ||
| 99 | BUG(); | ||
| 100 | } | ||
| 92 | } | 101 | } |
| 93 | 102 | ||
| 94 | /* Set PWT to Write-Combining. All other bits stay the same */ | 103 | /* Set PWT to Write-Combining. All other bits stay the same */ |
| @@ -626,6 +635,33 @@ void unmap_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot) | |||
| 626 | } | 635 | } |
| 627 | 636 | ||
| 628 | /* | 637 | /* |
| 638 | * Change the memory type for the physial address range in kernel identity | ||
| 639 | * mapping space if that range is a part of identity map. | ||
| 640 | */ | ||
| 641 | int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags) | ||
| 642 | { | ||
| 643 | unsigned long id_sz; | ||
| 644 | |||
| 645 | if (!pat_enabled || base >= __pa(high_memory)) | ||
| 646 | return 0; | ||
| 647 | |||
| 648 | id_sz = (__pa(high_memory) < base + size) ? | ||
| 649 | __pa(high_memory) - base : | ||
| 650 | size; | ||
| 651 | |||
| 652 | if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) { | ||
| 653 | printk(KERN_INFO | ||
| 654 | "%s:%d ioremap_change_attr failed %s " | ||
| 655 | "for %Lx-%Lx\n", | ||
| 656 | current->comm, current->pid, | ||
| 657 | cattr_name(flags), | ||
| 658 | base, (unsigned long long)(base + size)); | ||
| 659 | return -EINVAL; | ||
| 660 | } | ||
| 661 | return 0; | ||
| 662 | } | ||
| 663 | |||
| 664 | /* | ||
| 629 | * Internal interface to reserve a range of physical memory with prot. | 665 | * Internal interface to reserve a range of physical memory with prot. |
| 630 | * Reserved non RAM regions only and after successful reserve_memtype, | 666 | * Reserved non RAM regions only and after successful reserve_memtype, |
| 631 | * this func also keeps identity mapping (if any) in sync with this new prot. | 667 | * this func also keeps identity mapping (if any) in sync with this new prot. |
| @@ -634,7 +670,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot, | |||
| 634 | int strict_prot) | 670 | int strict_prot) |
| 635 | { | 671 | { |
| 636 | int is_ram = 0; | 672 | int is_ram = 0; |
| 637 | int id_sz, ret; | 673 | int ret; |
| 638 | unsigned long flags; | 674 | unsigned long flags; |
| 639 | unsigned long want_flags = (pgprot_val(*vma_prot) & _PAGE_CACHE_MASK); | 675 | unsigned long want_flags = (pgprot_val(*vma_prot) & _PAGE_CACHE_MASK); |
| 640 | 676 | ||
| @@ -671,23 +707,8 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot, | |||
| 671 | flags); | 707 | flags); |
| 672 | } | 708 | } |
| 673 | 709 | ||
| 674 | /* Need to keep identity mapping in sync */ | 710 | if (kernel_map_sync_memtype(paddr, size, flags) < 0) { |
| 675 | if (paddr >= __pa(high_memory)) | ||
| 676 | return 0; | ||
| 677 | |||
| 678 | id_sz = (__pa(high_memory) < paddr + size) ? | ||
| 679 | __pa(high_memory) - paddr : | ||
| 680 | size; | ||
| 681 | |||
| 682 | if (ioremap_change_attr((unsigned long)__va(paddr), id_sz, flags) < 0) { | ||
| 683 | free_memtype(paddr, paddr + size); | 711 | free_memtype(paddr, paddr + size); |
| 684 | printk(KERN_ERR | ||
| 685 | "%s:%d reserve_pfn_range ioremap_change_attr failed %s " | ||
| 686 | "for %Lx-%Lx\n", | ||
| 687 | current->comm, current->pid, | ||
| 688 | cattr_name(flags), | ||
| 689 | (unsigned long long)paddr, | ||
| 690 | (unsigned long long)(paddr + size)); | ||
| 691 | return -EINVAL; | 712 | return -EINVAL; |
| 692 | } | 713 | } |
| 693 | return 0; | 714 | return 0; |
