diff options
author | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2009-04-07 16:34:16 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2009-04-07 16:34:16 -0400 |
commit | 38f4b8c0da01ae7cd9b93386842ce272d6fde9ab (patch) | |
tree | 3c8c52201aac038094bfea7efdd0984a8f62045e /arch/x86/mm/pageattr.c | |
parent | a811454027352c762e0d5bba1b1d8f7d26bf96ae (diff) | |
parent | 8e2c4f2844c0e8dcdfe312e5f2204854ca8532c6 (diff) |
Merge commit 'origin/master' into for-linus/xen/master
* commit 'origin/master': (4825 commits)
Fix build errors due to CONFIG_BRANCH_TRACER=y
parport: Use the PCI IRQ if offered
tty: jsm cleanups
Adjust path to gpio headers
KGDB_SERIAL_CONSOLE check for module
Change KCONFIG name
tty: Blackin CTS/RTS
Change hardware flow control from poll to interrupt driven
Add support for the MAX3100 SPI UART.
lanana: assign a device name and numbering for MAX3100
serqt: initial clean up pass for tty side
tty: Use the generic RS485 ioctl on CRIS
tty: Correct inline types for tty_driver_kref_get()
splice: fix deadlock in splicing to file
nilfs2: support nanosecond timestamp
nilfs2: introduce secondary super block
nilfs2: simplify handling of active state of segments
nilfs2: mark minor flag for checkpoint created by internal operation
nilfs2: clean up sketch file
nilfs2: super block operations fix endian bug
...
Conflicts:
arch/x86/include/asm/thread_info.h
arch/x86/lguest/boot.c
drivers/xen/manage.c
Diffstat (limited to 'arch/x86/mm/pageattr.c')
-rw-r--r-- | arch/x86/mm/pageattr.c | 147 |
1 files changed, 116 insertions, 31 deletions
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 9015e5e412b5..660cac75ae11 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <asm/processor.h> | 16 | #include <asm/processor.h> |
17 | #include <asm/tlbflush.h> | 17 | #include <asm/tlbflush.h> |
18 | #include <asm/sections.h> | 18 | #include <asm/sections.h> |
19 | #include <asm/setup.h> | ||
19 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
20 | #include <asm/pgalloc.h> | 21 | #include <asm/pgalloc.h> |
21 | #include <asm/proto.h> | 22 | #include <asm/proto.h> |
@@ -33,6 +34,7 @@ struct cpa_data { | |||
33 | unsigned long pfn; | 34 | unsigned long pfn; |
34 | unsigned force_split : 1; | 35 | unsigned force_split : 1; |
35 | int curpage; | 36 | int curpage; |
37 | struct page **pages; | ||
36 | }; | 38 | }; |
37 | 39 | ||
38 | /* | 40 | /* |
@@ -45,6 +47,7 @@ static DEFINE_SPINLOCK(cpa_lock); | |||
45 | 47 | ||
46 | #define CPA_FLUSHTLB 1 | 48 | #define CPA_FLUSHTLB 1 |
47 | #define CPA_ARRAY 2 | 49 | #define CPA_ARRAY 2 |
50 | #define CPA_PAGES_ARRAY 4 | ||
48 | 51 | ||
49 | #ifdef CONFIG_PROC_FS | 52 | #ifdef CONFIG_PROC_FS |
50 | static unsigned long direct_pages_count[PG_LEVEL_NUM]; | 53 | static unsigned long direct_pages_count[PG_LEVEL_NUM]; |
@@ -95,7 +98,7 @@ static inline unsigned long highmap_start_pfn(void) | |||
95 | 98 | ||
96 | static inline unsigned long highmap_end_pfn(void) | 99 | static inline unsigned long highmap_end_pfn(void) |
97 | { | 100 | { |
98 | return __pa(roundup((unsigned long)_end, PMD_SIZE)) >> PAGE_SHIFT; | 101 | return __pa(roundup(_brk_end, PMD_SIZE)) >> PAGE_SHIFT; |
99 | } | 102 | } |
100 | 103 | ||
101 | #endif | 104 | #endif |
@@ -201,10 +204,10 @@ static void cpa_flush_range(unsigned long start, int numpages, int cache) | |||
201 | } | 204 | } |
202 | } | 205 | } |
203 | 206 | ||
204 | static void cpa_flush_array(unsigned long *start, int numpages, int cache) | 207 | static void cpa_flush_array(unsigned long *start, int numpages, int cache, |
208 | int in_flags, struct page **pages) | ||
205 | { | 209 | { |
206 | unsigned int i, level; | 210 | unsigned int i, level; |
207 | unsigned long *addr; | ||
208 | 211 | ||
209 | BUG_ON(irqs_disabled()); | 212 | BUG_ON(irqs_disabled()); |
210 | 213 | ||
@@ -225,14 +228,22 @@ static void cpa_flush_array(unsigned long *start, int numpages, int cache) | |||
225 | * will cause all other CPUs to flush the same | 228 | * will cause all other CPUs to flush the same |
226 | * cachelines: | 229 | * cachelines: |
227 | */ | 230 | */ |
228 | for (i = 0, addr = start; i < numpages; i++, addr++) { | 231 | for (i = 0; i < numpages; i++) { |
229 | pte_t *pte = lookup_address(*addr, &level); | 232 | unsigned long addr; |
233 | pte_t *pte; | ||
234 | |||
235 | if (in_flags & CPA_PAGES_ARRAY) | ||
236 | addr = (unsigned long)page_address(pages[i]); | ||
237 | else | ||
238 | addr = start[i]; | ||
239 | |||
240 | pte = lookup_address(addr, &level); | ||
230 | 241 | ||
231 | /* | 242 | /* |
232 | * Only flush present addresses: | 243 | * Only flush present addresses: |
233 | */ | 244 | */ |
234 | if (pte && (pte_val(*pte) & _PAGE_PRESENT)) | 245 | if (pte && (pte_val(*pte) & _PAGE_PRESENT)) |
235 | clflush_cache_range((void *) *addr, PAGE_SIZE); | 246 | clflush_cache_range((void *)addr, PAGE_SIZE); |
236 | } | 247 | } |
237 | } | 248 | } |
238 | 249 | ||
@@ -584,7 +595,9 @@ static int __change_page_attr(struct cpa_data *cpa, int primary) | |||
584 | unsigned int level; | 595 | unsigned int level; |
585 | pte_t *kpte, old_pte; | 596 | pte_t *kpte, old_pte; |
586 | 597 | ||
587 | if (cpa->flags & CPA_ARRAY) | 598 | if (cpa->flags & CPA_PAGES_ARRAY) |
599 | address = (unsigned long)page_address(cpa->pages[cpa->curpage]); | ||
600 | else if (cpa->flags & CPA_ARRAY) | ||
588 | address = cpa->vaddr[cpa->curpage]; | 601 | address = cpa->vaddr[cpa->curpage]; |
589 | else | 602 | else |
590 | address = *cpa->vaddr; | 603 | address = *cpa->vaddr; |
@@ -687,7 +700,9 @@ static int cpa_process_alias(struct cpa_data *cpa) | |||
687 | * No need to redo, when the primary call touched the direct | 700 | * No need to redo, when the primary call touched the direct |
688 | * mapping already: | 701 | * mapping already: |
689 | */ | 702 | */ |
690 | if (cpa->flags & CPA_ARRAY) | 703 | if (cpa->flags & CPA_PAGES_ARRAY) |
704 | vaddr = (unsigned long)page_address(cpa->pages[cpa->curpage]); | ||
705 | else if (cpa->flags & CPA_ARRAY) | ||
691 | vaddr = cpa->vaddr[cpa->curpage]; | 706 | vaddr = cpa->vaddr[cpa->curpage]; |
692 | else | 707 | else |
693 | vaddr = *cpa->vaddr; | 708 | vaddr = *cpa->vaddr; |
@@ -698,7 +713,7 @@ static int cpa_process_alias(struct cpa_data *cpa) | |||
698 | alias_cpa = *cpa; | 713 | alias_cpa = *cpa; |
699 | temp_cpa_vaddr = (unsigned long) __va(cpa->pfn << PAGE_SHIFT); | 714 | temp_cpa_vaddr = (unsigned long) __va(cpa->pfn << PAGE_SHIFT); |
700 | alias_cpa.vaddr = &temp_cpa_vaddr; | 715 | alias_cpa.vaddr = &temp_cpa_vaddr; |
701 | alias_cpa.flags &= ~CPA_ARRAY; | 716 | alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY); |
702 | 717 | ||
703 | 718 | ||
704 | ret = __change_page_attr_set_clr(&alias_cpa, 0); | 719 | ret = __change_page_attr_set_clr(&alias_cpa, 0); |
@@ -711,7 +726,7 @@ static int cpa_process_alias(struct cpa_data *cpa) | |||
711 | * No need to redo, when the primary call touched the high | 726 | * No need to redo, when the primary call touched the high |
712 | * mapping already: | 727 | * mapping already: |
713 | */ | 728 | */ |
714 | if (within(vaddr, (unsigned long) _text, (unsigned long) _end)) | 729 | if (within(vaddr, (unsigned long) _text, _brk_end)) |
715 | return 0; | 730 | return 0; |
716 | 731 | ||
717 | /* | 732 | /* |
@@ -724,7 +739,7 @@ static int cpa_process_alias(struct cpa_data *cpa) | |||
724 | alias_cpa = *cpa; | 739 | alias_cpa = *cpa; |
725 | temp_cpa_vaddr = (cpa->pfn << PAGE_SHIFT) + __START_KERNEL_map - phys_base; | 740 | temp_cpa_vaddr = (cpa->pfn << PAGE_SHIFT) + __START_KERNEL_map - phys_base; |
726 | alias_cpa.vaddr = &temp_cpa_vaddr; | 741 | alias_cpa.vaddr = &temp_cpa_vaddr; |
727 | alias_cpa.flags &= ~CPA_ARRAY; | 742 | alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY); |
728 | 743 | ||
729 | /* | 744 | /* |
730 | * The high mapping range is imprecise, so ignore the return value. | 745 | * The high mapping range is imprecise, so ignore the return value. |
@@ -745,7 +760,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias) | |||
745 | */ | 760 | */ |
746 | cpa->numpages = numpages; | 761 | cpa->numpages = numpages; |
747 | /* for array changes, we can't use large page */ | 762 | /* for array changes, we can't use large page */ |
748 | if (cpa->flags & CPA_ARRAY) | 763 | if (cpa->flags & (CPA_ARRAY | CPA_PAGES_ARRAY)) |
749 | cpa->numpages = 1; | 764 | cpa->numpages = 1; |
750 | 765 | ||
751 | if (!debug_pagealloc) | 766 | if (!debug_pagealloc) |
@@ -769,7 +784,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias) | |||
769 | */ | 784 | */ |
770 | BUG_ON(cpa->numpages > numpages); | 785 | BUG_ON(cpa->numpages > numpages); |
771 | numpages -= cpa->numpages; | 786 | numpages -= cpa->numpages; |
772 | if (cpa->flags & CPA_ARRAY) | 787 | if (cpa->flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) |
773 | cpa->curpage++; | 788 | cpa->curpage++; |
774 | else | 789 | else |
775 | *cpa->vaddr += cpa->numpages * PAGE_SIZE; | 790 | *cpa->vaddr += cpa->numpages * PAGE_SIZE; |
@@ -786,7 +801,8 @@ static inline int cache_attr(pgprot_t attr) | |||
786 | 801 | ||
787 | static int change_page_attr_set_clr(unsigned long *addr, int numpages, | 802 | static int change_page_attr_set_clr(unsigned long *addr, int numpages, |
788 | pgprot_t mask_set, pgprot_t mask_clr, | 803 | pgprot_t mask_set, pgprot_t mask_clr, |
789 | int force_split, int array) | 804 | int force_split, int in_flag, |
805 | struct page **pages) | ||
790 | { | 806 | { |
791 | struct cpa_data cpa; | 807 | struct cpa_data cpa; |
792 | int ret, cache, checkalias; | 808 | int ret, cache, checkalias; |
@@ -801,15 +817,7 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages, | |||
801 | return 0; | 817 | return 0; |
802 | 818 | ||
803 | /* Ensure we are PAGE_SIZE aligned */ | 819 | /* Ensure we are PAGE_SIZE aligned */ |
804 | if (!array) { | 820 | if (in_flag & CPA_ARRAY) { |
805 | if (*addr & ~PAGE_MASK) { | ||
806 | *addr &= PAGE_MASK; | ||
807 | /* | ||
808 | * People should not be passing in unaligned addresses: | ||
809 | */ | ||
810 | WARN_ON_ONCE(1); | ||
811 | } | ||
812 | } else { | ||
813 | int i; | 821 | int i; |
814 | for (i = 0; i < numpages; i++) { | 822 | for (i = 0; i < numpages; i++) { |
815 | if (addr[i] & ~PAGE_MASK) { | 823 | if (addr[i] & ~PAGE_MASK) { |
@@ -817,6 +825,18 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages, | |||
817 | WARN_ON_ONCE(1); | 825 | WARN_ON_ONCE(1); |
818 | } | 826 | } |
819 | } | 827 | } |
828 | } else if (!(in_flag & CPA_PAGES_ARRAY)) { | ||
829 | /* | ||
830 | * in_flag of CPA_PAGES_ARRAY implies it is aligned. | ||
831 | * No need to cehck in that case | ||
832 | */ | ||
833 | if (*addr & ~PAGE_MASK) { | ||
834 | *addr &= PAGE_MASK; | ||
835 | /* | ||
836 | * People should not be passing in unaligned addresses: | ||
837 | */ | ||
838 | WARN_ON_ONCE(1); | ||
839 | } | ||
820 | } | 840 | } |
821 | 841 | ||
822 | /* Must avoid aliasing mappings in the highmem code */ | 842 | /* Must avoid aliasing mappings in the highmem code */ |
@@ -825,6 +845,7 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages, | |||
825 | vm_unmap_aliases(); | 845 | vm_unmap_aliases(); |
826 | 846 | ||
827 | cpa.vaddr = addr; | 847 | cpa.vaddr = addr; |
848 | cpa.pages = pages; | ||
828 | cpa.numpages = numpages; | 849 | cpa.numpages = numpages; |
829 | cpa.mask_set = mask_set; | 850 | cpa.mask_set = mask_set; |
830 | cpa.mask_clr = mask_clr; | 851 | cpa.mask_clr = mask_clr; |
@@ -832,8 +853,8 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages, | |||
832 | cpa.curpage = 0; | 853 | cpa.curpage = 0; |
833 | cpa.force_split = force_split; | 854 | cpa.force_split = force_split; |
834 | 855 | ||
835 | if (array) | 856 | if (in_flag & (CPA_ARRAY | CPA_PAGES_ARRAY)) |
836 | cpa.flags |= CPA_ARRAY; | 857 | cpa.flags |= in_flag; |
837 | 858 | ||
838 | /* No alias checking for _NX bit modifications */ | 859 | /* No alias checking for _NX bit modifications */ |
839 | checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX; | 860 | checkalias = (pgprot_val(mask_set) | pgprot_val(mask_clr)) != _PAGE_NX; |
@@ -859,9 +880,10 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages, | |||
859 | * wbindv): | 880 | * wbindv): |
860 | */ | 881 | */ |
861 | if (!ret && cpu_has_clflush) { | 882 | if (!ret && cpu_has_clflush) { |
862 | if (cpa.flags & CPA_ARRAY) | 883 | if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) { |
863 | cpa_flush_array(addr, numpages, cache); | 884 | cpa_flush_array(addr, numpages, cache, |
864 | else | 885 | cpa.flags, pages); |
886 | } else | ||
865 | cpa_flush_range(*addr, numpages, cache); | 887 | cpa_flush_range(*addr, numpages, cache); |
866 | } else | 888 | } else |
867 | cpa_flush_all(cache); | 889 | cpa_flush_all(cache); |
@@ -874,14 +896,28 @@ static inline int change_page_attr_set(unsigned long *addr, int numpages, | |||
874 | pgprot_t mask, int array) | 896 | pgprot_t mask, int array) |
875 | { | 897 | { |
876 | return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0), 0, | 898 | return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0), 0, |
877 | array); | 899 | (array ? CPA_ARRAY : 0), NULL); |
878 | } | 900 | } |
879 | 901 | ||
880 | static inline int change_page_attr_clear(unsigned long *addr, int numpages, | 902 | static inline int change_page_attr_clear(unsigned long *addr, int numpages, |
881 | pgprot_t mask, int array) | 903 | pgprot_t mask, int array) |
882 | { | 904 | { |
883 | return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask, 0, | 905 | return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask, 0, |
884 | array); | 906 | (array ? CPA_ARRAY : 0), NULL); |
907 | } | ||
908 | |||
909 | static inline int cpa_set_pages_array(struct page **pages, int numpages, | ||
910 | pgprot_t mask) | ||
911 | { | ||
912 | return change_page_attr_set_clr(NULL, numpages, mask, __pgprot(0), 0, | ||
913 | CPA_PAGES_ARRAY, pages); | ||
914 | } | ||
915 | |||
916 | static inline int cpa_clear_pages_array(struct page **pages, int numpages, | ||
917 | pgprot_t mask) | ||
918 | { | ||
919 | return change_page_attr_set_clr(NULL, numpages, __pgprot(0), mask, 0, | ||
920 | CPA_PAGES_ARRAY, pages); | ||
885 | } | 921 | } |
886 | 922 | ||
887 | int _set_memory_uc(unsigned long addr, int numpages) | 923 | int _set_memory_uc(unsigned long addr, int numpages) |
@@ -1029,7 +1065,7 @@ int set_memory_np(unsigned long addr, int numpages) | |||
1029 | int set_memory_4k(unsigned long addr, int numpages) | 1065 | int set_memory_4k(unsigned long addr, int numpages) |
1030 | { | 1066 | { |
1031 | return change_page_attr_set_clr(&addr, numpages, __pgprot(0), | 1067 | return change_page_attr_set_clr(&addr, numpages, __pgprot(0), |
1032 | __pgprot(0), 1, 0); | 1068 | __pgprot(0), 1, 0, NULL); |
1033 | } | 1069 | } |
1034 | 1070 | ||
1035 | int set_pages_uc(struct page *page, int numpages) | 1071 | int set_pages_uc(struct page *page, int numpages) |
@@ -1040,6 +1076,35 @@ int set_pages_uc(struct page *page, int numpages) | |||
1040 | } | 1076 | } |
1041 | EXPORT_SYMBOL(set_pages_uc); | 1077 | EXPORT_SYMBOL(set_pages_uc); |
1042 | 1078 | ||
1079 | int set_pages_array_uc(struct page **pages, int addrinarray) | ||
1080 | { | ||
1081 | unsigned long start; | ||
1082 | unsigned long end; | ||
1083 | int i; | ||
1084 | int free_idx; | ||
1085 | |||
1086 | for (i = 0; i < addrinarray; i++) { | ||
1087 | start = (unsigned long)page_address(pages[i]); | ||
1088 | end = start + PAGE_SIZE; | ||
1089 | if (reserve_memtype(start, end, _PAGE_CACHE_UC_MINUS, NULL)) | ||
1090 | goto err_out; | ||
1091 | } | ||
1092 | |||
1093 | if (cpa_set_pages_array(pages, addrinarray, | ||
1094 | __pgprot(_PAGE_CACHE_UC_MINUS)) == 0) { | ||
1095 | return 0; /* Success */ | ||
1096 | } | ||
1097 | err_out: | ||
1098 | free_idx = i; | ||
1099 | for (i = 0; i < free_idx; i++) { | ||
1100 | start = (unsigned long)page_address(pages[i]); | ||
1101 | end = start + PAGE_SIZE; | ||
1102 | free_memtype(start, end); | ||
1103 | } | ||
1104 | return -EINVAL; | ||
1105 | } | ||
1106 | EXPORT_SYMBOL(set_pages_array_uc); | ||
1107 | |||
1043 | int set_pages_wb(struct page *page, int numpages) | 1108 | int set_pages_wb(struct page *page, int numpages) |
1044 | { | 1109 | { |
1045 | unsigned long addr = (unsigned long)page_address(page); | 1110 | unsigned long addr = (unsigned long)page_address(page); |
@@ -1048,6 +1113,26 @@ int set_pages_wb(struct page *page, int numpages) | |||
1048 | } | 1113 | } |
1049 | EXPORT_SYMBOL(set_pages_wb); | 1114 | EXPORT_SYMBOL(set_pages_wb); |
1050 | 1115 | ||
1116 | int set_pages_array_wb(struct page **pages, int addrinarray) | ||
1117 | { | ||
1118 | int retval; | ||
1119 | unsigned long start; | ||
1120 | unsigned long end; | ||
1121 | int i; | ||
1122 | |||
1123 | retval = cpa_clear_pages_array(pages, addrinarray, | ||
1124 | __pgprot(_PAGE_CACHE_MASK)); | ||
1125 | |||
1126 | for (i = 0; i < addrinarray; i++) { | ||
1127 | start = (unsigned long)page_address(pages[i]); | ||
1128 | end = start + PAGE_SIZE; | ||
1129 | free_memtype(start, end); | ||
1130 | } | ||
1131 | |||
1132 | return retval; | ||
1133 | } | ||
1134 | EXPORT_SYMBOL(set_pages_array_wb); | ||
1135 | |||
1051 | int set_pages_x(struct page *page, int numpages) | 1136 | int set_pages_x(struct page *page, int numpages) |
1052 | { | 1137 | { |
1053 | unsigned long addr = (unsigned long)page_address(page); | 1138 | unsigned long addr = (unsigned long)page_address(page); |