Avoid beyond bounds copy while caching ACL
[zen-stable.git] / arch / hexagon / include / asm / fixmap.h
blobb27f4941645b3fedefc9297b60795e07b46c9c3c
1 /*
2 * Fixmap support for Hexagon - enough to support highmem features
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
21 #ifndef _ASM_FIXMAP_H
22 #define _ASM_FIXMAP_H
25 * A lot of the fixmap info is already in mem-layout.h
27 #include <asm/mem-layout.h>
30 * Full fixmap support involves set_fixmap() functions, but
31 * these may not be needed if all we're after is an area for
32 * highmem kernel mappings.
34 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
35 #define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
37 extern void __this_fixmap_does_not_exist(void);
39 /**
40 * fix_to_virt -- "index to address" translation.
42 * If anyone tries to use the idx directly without translation,
43 * we catch the bug with a NULL-deference kernel oops. Illegal
44 * ranges of incoming indices are caught too.
46 static inline unsigned long fix_to_virt(const unsigned int idx)
49 * This branch gets completely eliminated after inlining,
50 * except when someone tries to use fixaddr indices in an
51 * illegal way. (such as mixing up address types or using
52 * out-of-range indices).
54 * If it doesn't get removed, the linker will complain
55 * loudly with a reasonably clear error message..
57 if (idx >= __end_of_fixed_addresses)
58 __this_fixmap_does_not_exist();
60 return __fix_to_virt(idx);
63 static inline unsigned long virt_to_fix(const unsigned long vaddr)
65 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
66 return __virt_to_fix(vaddr);
69 #define kmap_get_fixmap_pte(vaddr) \
70 pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), \
71 (vaddr)), (vaddr)), (vaddr))
73 #endif