diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:34:01 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:34:01 -0500 |
commit | 34eff1d75b26eac5c04f9c5b52ba9e3bf1dd8877 (patch) | |
tree | f295a70be2df45f35cff4e3e36264a2d6a56d896 | |
parent | b65e6390fb99ca93877ffc1c84e93c857f32dafc (diff) |
x86: simplify __change_page_attr()
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/mm/pageattr_64.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/arch/x86/mm/pageattr_64.c b/arch/x86/mm/pageattr_64.c index cbded8300e36..5eff244c16db 100644 --- a/arch/x86/mm/pageattr_64.c +++ b/arch/x86/mm/pageattr_64.c | |||
@@ -67,8 +67,7 @@ split_large_page(unsigned long address, pgprot_t ref_prot) | |||
67 | } | 67 | } |
68 | 68 | ||
69 | static int | 69 | static int |
70 | __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot, | 70 | __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot) |
71 | pgprot_t ref_prot) | ||
72 | { | 71 | { |
73 | struct page *kpte_page; | 72 | struct page *kpte_page; |
74 | pte_t *kpte; | 73 | pte_t *kpte; |
@@ -84,32 +83,24 @@ repeat: | |||
84 | oldprot = pte_pgprot(*kpte); | 83 | oldprot = pte_pgprot(*kpte); |
85 | BUG_ON(PageLRU(kpte_page)); | 84 | BUG_ON(PageLRU(kpte_page)); |
86 | BUG_ON(PageCompound(kpte_page)); | 85 | BUG_ON(PageCompound(kpte_page)); |
87 | ref_prot = canon_pgprot(ref_prot); | ||
88 | prot = canon_pgprot(prot); | 86 | prot = canon_pgprot(prot); |
89 | 87 | ||
90 | if (pgprot_val(prot) != pgprot_val(ref_prot)) { | 88 | if (level == 4) { |
91 | if (level == 4) { | 89 | set_pte(kpte, pfn_pte(pfn, prot)); |
92 | set_pte(kpte, pfn_pte(pfn, prot)); | ||
93 | } else { | ||
94 | /* | ||
95 | * split_large_page will take the reference for this | ||
96 | * change_page_attr on the split page. | ||
97 | */ | ||
98 | struct page *split; | ||
99 | |||
100 | ref_prot2 = pte_pgprot(pte_clrhuge(*kpte)); | ||
101 | split = split_large_page(address, ref_prot2); | ||
102 | if (!split) | ||
103 | return -ENOMEM; | ||
104 | pgprot_val(ref_prot2) &= ~_PAGE_NX; | ||
105 | set_pte(kpte, mk_pte(split, ref_prot2)); | ||
106 | goto repeat; | ||
107 | } | ||
108 | } else { | 90 | } else { |
109 | if (level == 4) { | 91 | /* |
110 | set_pte(kpte, pfn_pte(pfn, ref_prot)); | 92 | * split_large_page will take the reference for this |
111 | } else | 93 | * change_page_attr on the split page. |
112 | BUG(); | 94 | */ |
95 | struct page *split; | ||
96 | |||
97 | ref_prot2 = pte_pgprot(pte_clrhuge(*kpte)); | ||
98 | split = split_large_page(address, ref_prot2); | ||
99 | if (!split) | ||
100 | return -ENOMEM; | ||
101 | pgprot_val(ref_prot2) &= ~_PAGE_NX; | ||
102 | set_pte(kpte, mk_pte(split, ref_prot2)); | ||
103 | goto repeat; | ||
113 | } | 104 | } |
114 | 105 | ||
115 | return 0; | 106 | return 0; |
@@ -144,8 +135,7 @@ int change_page_attr_addr(unsigned long address, int numpages, pgprot_t prot) | |||
144 | unsigned long pfn = __pa(address) >> PAGE_SHIFT; | 135 | unsigned long pfn = __pa(address) >> PAGE_SHIFT; |
145 | 136 | ||
146 | if (!kernel_map || pte_present(pfn_pte(0, prot))) { | 137 | if (!kernel_map || pte_present(pfn_pte(0, prot))) { |
147 | err = __change_page_attr(address, pfn, prot, | 138 | err = __change_page_attr(address, pfn, prot); |
148 | PAGE_KERNEL); | ||
149 | if (err) | 139 | if (err) |
150 | break; | 140 | break; |
151 | } | 141 | } |
@@ -158,8 +148,7 @@ int change_page_attr_addr(unsigned long address, int numpages, pgprot_t prot) | |||
158 | addr2 = __START_KERNEL_map + __pa(address); | 148 | addr2 = __START_KERNEL_map + __pa(address); |
159 | /* Make sure the kernel mappings stay executable */ | 149 | /* Make sure the kernel mappings stay executable */ |
160 | prot2 = pte_pgprot(pte_mkexec(pfn_pte(0, prot))); | 150 | prot2 = pte_pgprot(pte_mkexec(pfn_pte(0, prot))); |
161 | err = __change_page_attr(addr2, pfn, prot2, | 151 | err = __change_page_attr(addr2, pfn, prot2); |
162 | PAGE_KERNEL_EXEC); | ||
163 | } | 152 | } |
164 | } | 153 | } |
165 | up_write(&init_mm.mmap_sem); | 154 | up_write(&init_mm.mmap_sem); |