diff options
author | venkatesh.pallipadi@intel.com <venkatesh.pallipadi@intel.com> | 2008-03-18 20:00:20 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-24 17:40:47 -0400 |
commit | f0970c13b6a5b01189aeb196ebb573cf87d95839 (patch) | |
tree | c33836b693ca066c19dc8986165aee5849fbcdd9 /arch/x86/mm | |
parent | e045fb2a988a9a1964059b0d33dbaf18d12f925f (diff) |
x86: PAT phys_mem_access_prot_allowed for dev/mem mmap
Introduce phys_mem_access_prot_allowed(), which checks whether the mapping
is possible, without any conflicts and returns success or failure based on that.
phys_mem_access_prot() by itself does not allow failure case. This ability
to return error is needed for PAT where we may have aliasing conflicts.
x86 setup __HAVE_PHYS_MEM_ACCESS_PROT and move x86 specific code out of
/dev/mem into arch specific area.
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r-- | arch/x86/mm/pat.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 72c0f6097402..64cc0c18233e 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -419,3 +419,42 @@ int free_memtype(u64 start, u64 end) | |||
419 | return err; | 419 | return err; |
420 | } | 420 | } |
421 | 421 | ||
422 | |||
423 | /* /dev/mem interface. Use the previous mapping */ | ||
424 | pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, | ||
425 | unsigned long size, pgprot_t vma_prot) | ||
426 | { | ||
427 | return vma_prot; | ||
428 | } | ||
429 | |||
430 | int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn, | ||
431 | unsigned long size, pgprot_t *vma_prot) | ||
432 | { | ||
433 | |||
434 | if (file->f_flags & O_SYNC) { | ||
435 | *vma_prot = pgprot_noncached(*vma_prot); | ||
436 | return 1; | ||
437 | } | ||
438 | |||
439 | #ifdef CONFIG_X86_32 | ||
440 | /* | ||
441 | * On the PPro and successors, the MTRRs are used to set | ||
442 | * memory types for physical addresses outside main memory, | ||
443 | * so blindly setting UC or PWT on those pages is wrong. | ||
444 | * For Pentiums and earlier, the surround logic should disable | ||
445 | * caching for the high addresses through the KEN pin, but | ||
446 | * we maintain the tradition of paranoia in this code. | ||
447 | */ | ||
448 | if (!pat_wc_enabled && | ||
449 | ! ( test_bit(X86_FEATURE_MTRR, boot_cpu_data.x86_capability) || | ||
450 | test_bit(X86_FEATURE_K6_MTRR, boot_cpu_data.x86_capability) || | ||
451 | test_bit(X86_FEATURE_CYRIX_ARR, boot_cpu_data.x86_capability) || | ||
452 | test_bit(X86_FEATURE_CENTAUR_MCR, boot_cpu_data.x86_capability)) && | ||
453 | (pfn << PAGE_SHIFT) >= __pa(high_memory)) { | ||
454 | *vma_prot = pgprot_noncached(*vma_prot); | ||
455 | return 1; | ||
456 | } | ||
457 | #endif | ||
458 | |||
459 | return 1; | ||
460 | } | ||