diff options
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/amd.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/generic.c | 16 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/if.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/main.c | 8 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/mtrr.h | 6 | ||||
-rw-r--r-- | include/asm-x86/mtrr.h | 8 |
6 files changed, 26 insertions, 29 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/amd.c b/arch/x86/kernel/cpu/mtrr/amd.c index 0949cdbf848a..ee2331b0e58f 100644 --- a/arch/x86/kernel/cpu/mtrr/amd.c +++ b/arch/x86/kernel/cpu/mtrr/amd.c | |||
@@ -53,8 +53,6 @@ static void amd_set_mtrr(unsigned int reg, unsigned long base, | |||
53 | <base> The base address of the region. | 53 | <base> The base address of the region. |
54 | <size> The size of the region. If this is 0 the region is disabled. | 54 | <size> The size of the region. If this is 0 the region is disabled. |
55 | <type> The type of the region. | 55 | <type> The type of the region. |
56 | <do_safe> If TRUE, do the change safely. If FALSE, safety measures should | ||
57 | be done externally. | ||
58 | [RETURNS] Nothing. | 56 | [RETURNS] Nothing. |
59 | */ | 57 | */ |
60 | { | 58 | { |
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index 992f08dfbb6c..1c331c373a43 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c | |||
@@ -188,7 +188,7 @@ static inline void k8_enable_fixed_iorrs(void) | |||
188 | * \param changed pointer which indicates whether the MTRR needed to be changed | 188 | * \param changed pointer which indicates whether the MTRR needed to be changed |
189 | * \param msrwords pointer to the MSR values which the MSR should have | 189 | * \param msrwords pointer to the MSR values which the MSR should have |
190 | */ | 190 | */ |
191 | static void set_fixed_range(int msr, int * changed, unsigned int * msrwords) | 191 | static void set_fixed_range(int msr, bool *changed, unsigned int *msrwords) |
192 | { | 192 | { |
193 | unsigned lo, hi; | 193 | unsigned lo, hi; |
194 | 194 | ||
@@ -200,7 +200,7 @@ static void set_fixed_range(int msr, int * changed, unsigned int * msrwords) | |||
200 | ((msrwords[0] | msrwords[1]) & K8_MTRR_RDMEM_WRMEM_MASK)) | 200 | ((msrwords[0] | msrwords[1]) & K8_MTRR_RDMEM_WRMEM_MASK)) |
201 | k8_enable_fixed_iorrs(); | 201 | k8_enable_fixed_iorrs(); |
202 | mtrr_wrmsr(msr, msrwords[0], msrwords[1]); | 202 | mtrr_wrmsr(msr, msrwords[0], msrwords[1]); |
203 | *changed = TRUE; | 203 | *changed = true; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
@@ -260,7 +260,7 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base, | |||
260 | static int set_fixed_ranges(mtrr_type * frs) | 260 | static int set_fixed_ranges(mtrr_type * frs) |
261 | { | 261 | { |
262 | unsigned long long *saved = (unsigned long long *) frs; | 262 | unsigned long long *saved = (unsigned long long *) frs; |
263 | int changed = FALSE; | 263 | bool changed = false; |
264 | int block=-1, range; | 264 | int block=-1, range; |
265 | 265 | ||
266 | while (fixed_range_blocks[++block].ranges) | 266 | while (fixed_range_blocks[++block].ranges) |
@@ -273,17 +273,17 @@ static int set_fixed_ranges(mtrr_type * frs) | |||
273 | 273 | ||
274 | /* Set the MSR pair relating to a var range. Returns TRUE if | 274 | /* Set the MSR pair relating to a var range. Returns TRUE if |
275 | changes are made */ | 275 | changes are made */ |
276 | static int set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr) | 276 | static bool set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr) |
277 | { | 277 | { |
278 | unsigned int lo, hi; | 278 | unsigned int lo, hi; |
279 | int changed = FALSE; | 279 | bool changed = false; |
280 | 280 | ||
281 | rdmsr(MTRRphysBase_MSR(index), lo, hi); | 281 | rdmsr(MTRRphysBase_MSR(index), lo, hi); |
282 | if ((vr->base_lo & 0xfffff0ffUL) != (lo & 0xfffff0ffUL) | 282 | if ((vr->base_lo & 0xfffff0ffUL) != (lo & 0xfffff0ffUL) |
283 | || (vr->base_hi & (size_and_mask >> (32 - PAGE_SHIFT))) != | 283 | || (vr->base_hi & (size_and_mask >> (32 - PAGE_SHIFT))) != |
284 | (hi & (size_and_mask >> (32 - PAGE_SHIFT)))) { | 284 | (hi & (size_and_mask >> (32 - PAGE_SHIFT)))) { |
285 | mtrr_wrmsr(MTRRphysBase_MSR(index), vr->base_lo, vr->base_hi); | 285 | mtrr_wrmsr(MTRRphysBase_MSR(index), vr->base_lo, vr->base_hi); |
286 | changed = TRUE; | 286 | changed = true; |
287 | } | 287 | } |
288 | 288 | ||
289 | rdmsr(MTRRphysMask_MSR(index), lo, hi); | 289 | rdmsr(MTRRphysMask_MSR(index), lo, hi); |
@@ -292,7 +292,7 @@ static int set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr) | |||
292 | || (vr->mask_hi & (size_and_mask >> (32 - PAGE_SHIFT))) != | 292 | || (vr->mask_hi & (size_and_mask >> (32 - PAGE_SHIFT))) != |
293 | (hi & (size_and_mask >> (32 - PAGE_SHIFT)))) { | 293 | (hi & (size_and_mask >> (32 - PAGE_SHIFT)))) { |
294 | mtrr_wrmsr(MTRRphysMask_MSR(index), vr->mask_lo, vr->mask_hi); | 294 | mtrr_wrmsr(MTRRphysMask_MSR(index), vr->mask_lo, vr->mask_hi); |
295 | changed = TRUE; | 295 | changed = true; |
296 | } | 296 | } |
297 | return changed; | 297 | return changed; |
298 | } | 298 | } |
@@ -417,8 +417,6 @@ static void generic_set_mtrr(unsigned int reg, unsigned long base, | |||
417 | <base> The base address of the region. | 417 | <base> The base address of the region. |
418 | <size> The size of the region. If this is 0 the region is disabled. | 418 | <size> The size of the region. If this is 0 the region is disabled. |
419 | <type> The type of the region. | 419 | <type> The type of the region. |
420 | <do_safe> If TRUE, do the change safely. If FALSE, safety measures should | ||
421 | be done externally. | ||
422 | [RETURNS] Nothing. | 420 | [RETURNS] Nothing. |
423 | */ | 421 | */ |
424 | { | 422 | { |
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c index c7d8f1756745..14535686c099 100644 --- a/arch/x86/kernel/cpu/mtrr/if.c +++ b/arch/x86/kernel/cpu/mtrr/if.c | |||
@@ -37,7 +37,7 @@ const char *mtrr_attrib_to_str(int x) | |||
37 | 37 | ||
38 | static int | 38 | static int |
39 | mtrr_file_add(unsigned long base, unsigned long size, | 39 | mtrr_file_add(unsigned long base, unsigned long size, |
40 | unsigned int type, char increment, struct file *file, int page) | 40 | unsigned int type, bool increment, struct file *file, int page) |
41 | { | 41 | { |
42 | int reg, max; | 42 | int reg, max; |
43 | unsigned int *fcount = FILE_FCOUNT(file); | 43 | unsigned int *fcount = FILE_FCOUNT(file); |
@@ -55,7 +55,7 @@ mtrr_file_add(unsigned long base, unsigned long size, | |||
55 | base >>= PAGE_SHIFT; | 55 | base >>= PAGE_SHIFT; |
56 | size >>= PAGE_SHIFT; | 56 | size >>= PAGE_SHIFT; |
57 | } | 57 | } |
58 | reg = mtrr_add_page(base, size, type, 1); | 58 | reg = mtrr_add_page(base, size, type, true); |
59 | if (reg >= 0) | 59 | if (reg >= 0) |
60 | ++fcount[reg]; | 60 | ++fcount[reg]; |
61 | return reg; | 61 | return reg; |
@@ -141,7 +141,7 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos) | |||
141 | size >>= PAGE_SHIFT; | 141 | size >>= PAGE_SHIFT; |
142 | err = | 142 | err = |
143 | mtrr_add_page((unsigned long) base, (unsigned long) size, i, | 143 | mtrr_add_page((unsigned long) base, (unsigned long) size, i, |
144 | 1); | 144 | true); |
145 | if (err < 0) | 145 | if (err < 0) |
146 | return err; | 146 | return err; |
147 | return len; | 147 | return len; |
@@ -217,7 +217,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg) | |||
217 | if (!capable(CAP_SYS_ADMIN)) | 217 | if (!capable(CAP_SYS_ADMIN)) |
218 | return -EPERM; | 218 | return -EPERM; |
219 | err = | 219 | err = |
220 | mtrr_file_add(sentry.base, sentry.size, sentry.type, 1, | 220 | mtrr_file_add(sentry.base, sentry.size, sentry.type, true, |
221 | file, 0); | 221 | file, 0); |
222 | break; | 222 | break; |
223 | case MTRRIOC_SET_ENTRY: | 223 | case MTRRIOC_SET_ENTRY: |
@@ -226,7 +226,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg) | |||
226 | #endif | 226 | #endif |
227 | if (!capable(CAP_SYS_ADMIN)) | 227 | if (!capable(CAP_SYS_ADMIN)) |
228 | return -EPERM; | 228 | return -EPERM; |
229 | err = mtrr_add(sentry.base, sentry.size, sentry.type, 0); | 229 | err = mtrr_add(sentry.base, sentry.size, sentry.type, false); |
230 | break; | 230 | break; |
231 | case MTRRIOC_DEL_ENTRY: | 231 | case MTRRIOC_DEL_ENTRY: |
232 | #ifdef CONFIG_COMPAT | 232 | #ifdef CONFIG_COMPAT |
@@ -270,7 +270,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg) | |||
270 | if (!capable(CAP_SYS_ADMIN)) | 270 | if (!capable(CAP_SYS_ADMIN)) |
271 | return -EPERM; | 271 | return -EPERM; |
272 | err = | 272 | err = |
273 | mtrr_file_add(sentry.base, sentry.size, sentry.type, 1, | 273 | mtrr_file_add(sentry.base, sentry.size, sentry.type, true, |
274 | file, 1); | 274 | file, 1); |
275 | break; | 275 | break; |
276 | case MTRRIOC_SET_PAGE_ENTRY: | 276 | case MTRRIOC_SET_PAGE_ENTRY: |
@@ -279,7 +279,8 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg) | |||
279 | #endif | 279 | #endif |
280 | if (!capable(CAP_SYS_ADMIN)) | 280 | if (!capable(CAP_SYS_ADMIN)) |
281 | return -EPERM; | 281 | return -EPERM; |
282 | err = mtrr_add_page(sentry.base, sentry.size, sentry.type, 0); | 282 | err = |
283 | mtrr_add_page(sentry.base, sentry.size, sentry.type, false); | ||
283 | break; | 284 | break; |
284 | case MTRRIOC_DEL_PAGE_ENTRY: | 285 | case MTRRIOC_DEL_PAGE_ENTRY: |
285 | #ifdef CONFIG_COMPAT | 286 | #ifdef CONFIG_COMPAT |
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index beb45c9c0835..60af5ed2b5c0 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
@@ -311,7 +311,7 @@ static void set_mtrr(unsigned int reg, unsigned long base, | |||
311 | */ | 311 | */ |
312 | 312 | ||
313 | int mtrr_add_page(unsigned long base, unsigned long size, | 313 | int mtrr_add_page(unsigned long base, unsigned long size, |
314 | unsigned int type, char increment) | 314 | unsigned int type, bool increment) |
315 | { | 315 | { |
316 | int i, replace, error; | 316 | int i, replace, error; |
317 | mtrr_type ltype; | 317 | mtrr_type ltype; |
@@ -394,7 +394,9 @@ int mtrr_add_page(unsigned long base, unsigned long size, | |||
394 | if (likely(replace < 0)) | 394 | if (likely(replace < 0)) |
395 | usage_table[i] = 1; | 395 | usage_table[i] = 1; |
396 | else { | 396 | else { |
397 | usage_table[i] = usage_table[replace] + !!increment; | 397 | usage_table[i] = usage_table[replace]; |
398 | if (increment) | ||
399 | usage_table[i]++; | ||
398 | if (unlikely(replace != i)) { | 400 | if (unlikely(replace != i)) { |
399 | set_mtrr(replace, 0, 0, 0); | 401 | set_mtrr(replace, 0, 0, 0); |
400 | usage_table[replace] = 0; | 402 | usage_table[replace] = 0; |
@@ -460,7 +462,7 @@ static int mtrr_check(unsigned long base, unsigned long size) | |||
460 | 462 | ||
461 | int | 463 | int |
462 | mtrr_add(unsigned long base, unsigned long size, unsigned int type, | 464 | mtrr_add(unsigned long base, unsigned long size, unsigned int type, |
463 | char increment) | 465 | bool increment) |
464 | { | 466 | { |
465 | if (mtrr_check(base, size)) | 467 | if (mtrr_check(base, size)) |
466 | return -EINVAL; | 468 | return -EINVAL; |
diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h index 289dfe6030e3..54347e9a95c0 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h | |||
@@ -2,10 +2,8 @@ | |||
2 | * local mtrr defines. | 2 | * local mtrr defines. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef TRUE | 5 | #include <linux/types.h> |
6 | #define TRUE 1 | 6 | #include <linux/stddef.h> |
7 | #define FALSE 0 | ||
8 | #endif | ||
9 | 7 | ||
10 | #define MTRRcap_MSR 0x0fe | 8 | #define MTRRcap_MSR 0x0fe |
11 | #define MTRRdefType_MSR 0x2ff | 9 | #define MTRRdefType_MSR 0x2ff |
diff --git a/include/asm-x86/mtrr.h b/include/asm-x86/mtrr.h index e8320e4e6ca2..262670e42078 100644 --- a/include/asm-x86/mtrr.h +++ b/include/asm-x86/mtrr.h | |||
@@ -89,9 +89,9 @@ struct mtrr_gentry | |||
89 | extern void mtrr_save_fixed_ranges(void *); | 89 | extern void mtrr_save_fixed_ranges(void *); |
90 | extern void mtrr_save_state(void); | 90 | extern void mtrr_save_state(void); |
91 | extern int mtrr_add (unsigned long base, unsigned long size, | 91 | extern int mtrr_add (unsigned long base, unsigned long size, |
92 | unsigned int type, char increment); | 92 | unsigned int type, bool increment); |
93 | extern int mtrr_add_page (unsigned long base, unsigned long size, | 93 | extern int mtrr_add_page (unsigned long base, unsigned long size, |
94 | unsigned int type, char increment); | 94 | unsigned int type, bool increment); |
95 | extern int mtrr_del (int reg, unsigned long base, unsigned long size); | 95 | extern int mtrr_del (int reg, unsigned long base, unsigned long size); |
96 | extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); | 96 | extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); |
97 | extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); | 97 | extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); |
@@ -101,12 +101,12 @@ extern void mtrr_bp_init(void); | |||
101 | #define mtrr_save_fixed_ranges(arg) do {} while (0) | 101 | #define mtrr_save_fixed_ranges(arg) do {} while (0) |
102 | #define mtrr_save_state() do {} while (0) | 102 | #define mtrr_save_state() do {} while (0) |
103 | static __inline__ int mtrr_add (unsigned long base, unsigned long size, | 103 | static __inline__ int mtrr_add (unsigned long base, unsigned long size, |
104 | unsigned int type, char increment) | 104 | unsigned int type, bool increment) |
105 | { | 105 | { |
106 | return -ENODEV; | 106 | return -ENODEV; |
107 | } | 107 | } |
108 | static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, | 108 | static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, |
109 | unsigned int type, char increment) | 109 | unsigned int type, bool increment) |
110 | { | 110 | { |
111 | return -ENODEV; | 111 | return -ENODEV; |
112 | } | 112 | } |