diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2014-07-14 18:27:50 -0400 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2014-08-14 03:59:17 -0400 |
commit | 22def7681186f65f4f1256ae9b0b6db2a7720cb1 (patch) | |
tree | fb80ce6465ab17c3f0b1ce87bed58e8ec9ffa78f /arch | |
parent | 52247123749cc3cbc30168b33ad8c69515c96d23 (diff) |
xtensa: make fixmap region addressing grow with index
It's much easier to reason about alignment and coloring of regions
located in the fixmap when fixmap index is just a PFN within the fixmap
region. Change fixmap addressing so that index 0 corresponds to
FIXADDR_START instead of the FIXADDR_TOP.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/xtensa/include/asm/fixmap.h | 27 | ||||
-rw-r--r-- | arch/xtensa/mm/highmem.c | 6 |
2 files changed, 27 insertions, 6 deletions
diff --git a/arch/xtensa/include/asm/fixmap.h b/arch/xtensa/include/asm/fixmap.h index 9f6c33d0428a..a43cd5265556 100644 --- a/arch/xtensa/include/asm/fixmap.h +++ b/arch/xtensa/include/asm/fixmap.h | |||
@@ -23,8 +23,8 @@ | |||
23 | * Here we define all the compile-time 'special' virtual | 23 | * Here we define all the compile-time 'special' virtual |
24 | * addresses. The point is to have a constant address at | 24 | * addresses. The point is to have a constant address at |
25 | * compile time, but to set the physical address only | 25 | * compile time, but to set the physical address only |
26 | * in the boot process. We allocate these special addresses | 26 | * in the boot process. We allocate these special addresses |
27 | * from the end of the consistent memory region backwards. | 27 | * from the start of the consistent memory region upwards. |
28 | * Also this lets us do fail-safe vmalloc(), we | 28 | * Also this lets us do fail-safe vmalloc(), we |
29 | * can guarantee that these special addresses and | 29 | * can guarantee that these special addresses and |
30 | * vmalloc()-ed addresses never overlap. | 30 | * vmalloc()-ed addresses never overlap. |
@@ -47,7 +47,28 @@ enum fixed_addresses { | |||
47 | #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) | 47 | #define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) |
48 | #define FIXADDR_START ((FIXADDR_TOP - FIXADDR_SIZE) & PMD_MASK) | 48 | #define FIXADDR_START ((FIXADDR_TOP - FIXADDR_SIZE) & PMD_MASK) |
49 | 49 | ||
50 | #include <asm-generic/fixmap.h> | 50 | #define __fix_to_virt(x) (FIXADDR_START + ((x) << PAGE_SHIFT)) |
51 | #define __virt_to_fix(x) (((x) - FIXADDR_START) >> PAGE_SHIFT) | ||
52 | |||
53 | #ifndef __ASSEMBLY__ | ||
54 | /* | ||
55 | * 'index to address' translation. If anyone tries to use the idx | ||
56 | * directly without translation, we catch the bug with a NULL-deference | ||
57 | * kernel oops. Illegal ranges of incoming indices are caught too. | ||
58 | */ | ||
59 | static __always_inline unsigned long fix_to_virt(const unsigned int idx) | ||
60 | { | ||
61 | BUILD_BUG_ON(idx >= __end_of_fixed_addresses); | ||
62 | return __fix_to_virt(idx); | ||
63 | } | ||
64 | |||
65 | static inline unsigned long virt_to_fix(const unsigned long vaddr) | ||
66 | { | ||
67 | BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START); | ||
68 | return __virt_to_fix(vaddr); | ||
69 | } | ||
70 | |||
71 | #endif | ||
51 | 72 | ||
52 | #define kmap_get_fixmap_pte(vaddr) \ | 73 | #define kmap_get_fixmap_pte(vaddr) \ |
53 | pte_offset_kernel( \ | 74 | pte_offset_kernel( \ |
diff --git a/arch/xtensa/mm/highmem.c b/arch/xtensa/mm/highmem.c index 17a8c0d6fd17..2e95a7665bf3 100644 --- a/arch/xtensa/mm/highmem.c +++ b/arch/xtensa/mm/highmem.c | |||
@@ -28,9 +28,9 @@ void *kmap_atomic(struct page *page) | |||
28 | idx = type + KM_TYPE_NR * smp_processor_id(); | 28 | idx = type + KM_TYPE_NR * smp_processor_id(); |
29 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); | 29 | vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); |
30 | #ifdef CONFIG_DEBUG_HIGHMEM | 30 | #ifdef CONFIG_DEBUG_HIGHMEM |
31 | BUG_ON(!pte_none(*(kmap_pte - idx))); | 31 | BUG_ON(!pte_none(*(kmap_pte + idx))); |
32 | #endif | 32 | #endif |
33 | set_pte(kmap_pte - idx, mk_pte(page, PAGE_KERNEL_EXEC)); | 33 | set_pte(kmap_pte + idx, mk_pte(page, PAGE_KERNEL_EXEC)); |
34 | 34 | ||
35 | return (void *)vaddr; | 35 | return (void *)vaddr; |
36 | } | 36 | } |
@@ -51,7 +51,7 @@ void __kunmap_atomic(void *kvaddr) | |||
51 | * is a bad idea also, in case the page changes cacheability | 51 | * is a bad idea also, in case the page changes cacheability |
52 | * attributes or becomes a protected page in a hypervisor. | 52 | * attributes or becomes a protected page in a hypervisor. |
53 | */ | 53 | */ |
54 | pte_clear(&init_mm, kvaddr, kmap_pte - idx); | 54 | pte_clear(&init_mm, kvaddr, kmap_pte + idx); |
55 | local_flush_tlb_kernel_range((unsigned long)kvaddr, | 55 | local_flush_tlb_kernel_range((unsigned long)kvaddr, |
56 | (unsigned long)kvaddr + PAGE_SIZE); | 56 | (unsigned long)kvaddr + PAGE_SIZE); |
57 | 57 | ||