blob: e55dfc1ad453be7b84215a6016a444b497656034 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_CACHEFLUSH_H
2#define _ASM_X86_CACHEFLUSH_H
Thomas Gleixnerb2bba722007-10-15 23:28:20 +02003
4/* Keep includes the same across arches. */
5#include <linux/mm.h>
6
7/* Caches aren't brain-dead on the intel. */
Tejun Heod3251002009-02-25 11:01:40 +09008static inline void flush_cache_all(void) { }
9static inline void flush_cache_mm(struct mm_struct *mm) { }
10static inline void flush_cache_dup_mm(struct mm_struct *mm) { }
11static inline void flush_cache_range(struct vm_area_struct *vma,
12 unsigned long start, unsigned long end) { }
13static inline void flush_cache_page(struct vm_area_struct *vma,
14 unsigned long vmaddr, unsigned long pfn) { }
15static inline void flush_dcache_page(struct page *page) { }
16static inline void flush_dcache_mmap_lock(struct address_space *mapping) { }
17static inline void flush_dcache_mmap_unlock(struct address_space *mapping) { }
18static inline void flush_icache_range(unsigned long start,
19 unsigned long end) { }
20static inline void flush_icache_page(struct vm_area_struct *vma,
21 struct page *page) { }
22static inline void flush_icache_user_range(struct vm_area_struct *vma,
23 struct page *page,
24 unsigned long addr,
25 unsigned long len) { }
26static inline void flush_cache_vmap(unsigned long start, unsigned long end) { }
27static inline void flush_cache_vunmap(unsigned long start,
28 unsigned long end) { }
Thomas Gleixnerb2bba722007-10-15 23:28:20 +020029
Tejun Heod3251002009-02-25 11:01:40 +090030static inline void copy_to_user_page(struct vm_area_struct *vma,
31 struct page *page, unsigned long vaddr,
32 void *dst, const void *src,
33 unsigned long len)
34{
35 memcpy(dst, src, len);
36}
37
38static inline void copy_from_user_page(struct vm_area_struct *vma,
39 struct page *page, unsigned long vaddr,
40 void *dst, const void *src,
41 unsigned long len)
42{
43 memcpy(dst, src, len);
44}
Thomas Gleixnerb2bba722007-10-15 23:28:20 +020045
Suresh Siddha9542ada2008-09-24 08:53:33 -070046#define PG_non_WB PG_arch_1
47PAGEFLAG(NonWB, non_WB)
Arjan van de Ven75cbade2008-01-30 13:34:06 +010048
Arjan van de Ven7219beb2008-04-17 17:41:31 +020049/*
50 * The set_memory_* API can be used to change various attributes of a virtual
51 * address range. The attributes include:
52 * Cachability : UnCached, WriteCombining, WriteBack
53 * Executability : eXeutable, NoteXecutable
54 * Read/Write : ReadOnly, ReadWrite
55 * Presence : NotPresent
56 *
57 * Within a catagory, the attributes are mutually exclusive.
58 *
59 * The implementation of this API will take care of various aspects that
60 * are associated with changing such attributes, such as:
61 * - Flushing TLBs
62 * - Flushing CPU caches
63 * - Making sure aliases of the memory behind the mapping don't violate
64 * coherency rules as defined by the CPU in the system.
65 *
66 * What this API does not do:
67 * - Provide exclusion between various callers - including callers that
68 * operation on other mappings of the same physical page
69 * - Restore default attributes when a page is freed
70 * - Guarantee that mappings other than the requested one are
71 * in any state, other than that these do not violate rules for
72 * the CPU you have. Do not depend on any effects on other mappings,
73 * CPUs other than the one you have may have more relaxed rules.
74 * The caller is required to take care of these.
75 */
Arjan van de Ven75cbade2008-01-30 13:34:06 +010076
venkatesh.pallipadi@intel.com12193332008-03-18 17:00:18 -070077int _set_memory_uc(unsigned long addr, int numpages);
venkatesh.pallipadi@intel.comef354af2008-03-18 17:00:23 -070078int _set_memory_wc(unsigned long addr, int numpages);
venkatesh.pallipadi@intel.com12193332008-03-18 17:00:18 -070079int _set_memory_wb(unsigned long addr, int numpages);
Arjan van de Ven75cbade2008-01-30 13:34:06 +010080int set_memory_uc(unsigned long addr, int numpages);
venkatesh.pallipadi@intel.comef354af2008-03-18 17:00:23 -070081int set_memory_wc(unsigned long addr, int numpages);
Arjan van de Ven75cbade2008-01-30 13:34:06 +010082int set_memory_wb(unsigned long addr, int numpages);
83int set_memory_x(unsigned long addr, int numpages);
84int set_memory_nx(unsigned long addr, int numpages);
85int set_memory_ro(unsigned long addr, int numpages);
86int set_memory_rw(unsigned long addr, int numpages);
Ingo Molnarf62d0f02008-01-30 13:34:07 +010087int set_memory_np(unsigned long addr, int numpages);
Andi Kleenc9caa022008-03-12 03:53:29 +010088int set_memory_4k(unsigned long addr, int numpages);
Arjan van de Ven75cbade2008-01-30 13:34:06 +010089
Shaohua Lid75586a2008-08-21 10:46:06 +080090int set_memory_array_uc(unsigned long *addr, int addrinarray);
91int set_memory_array_wb(unsigned long *addr, int addrinarray);
92
venkatesh.pallipadi@intel.com0f350752009-03-19 14:51:15 -070093int set_pages_array_uc(struct page **pages, int addrinarray);
94int set_pages_array_wb(struct page **pages, int addrinarray);
95
Arjan van de Ven7219beb2008-04-17 17:41:31 +020096/*
97 * For legacy compatibility with the old APIs, a few functions
98 * are provided that work on a "struct page".
99 * These functions operate ONLY on the 1:1 kernel mapping of the
100 * memory that the struct page represents, and internally just
101 * call the set_memory_* function. See the description of the
102 * set_memory_* function for more details on conventions.
103 *
104 * These APIs should be considered *deprecated* and are likely going to
105 * be removed in the future.
106 * The reason for this is the implicit operation on the 1:1 mapping only,
107 * making this not a generally useful API.
108 *
109 * Specifically, many users of the old APIs had a virtual address,
110 * called virt_to_page() or vmalloc_to_page() on that address to
111 * get a struct page* that the old API required.
112 * To convert these cases, use set_memory_*() on the original
113 * virtual address, do not use these functions.
114 */
115
116int set_pages_uc(struct page *page, int numpages);
117int set_pages_wb(struct page *page, int numpages);
118int set_pages_x(struct page *page, int numpages);
119int set_pages_nx(struct page *page, int numpages);
120int set_pages_ro(struct page *page, int numpages);
121int set_pages_rw(struct page *page, int numpages);
122
123
Ingo Molnar4c61afc2008-01-30 13:34:09 +0100124void clflush_cache_range(void *addr, unsigned int size);
Thomas Gleixnerb2bba722007-10-15 23:28:20 +0200125
Thomas Gleixnerb2bba722007-10-15 23:28:20 +0200126#ifdef CONFIG_DEBUG_RODATA
127void mark_rodata_ro(void);
Harvey Harrison7bfeab92008-02-12 12:12:01 -0800128extern const int rodata_test_data;
Steven Rostedt16239632009-02-17 17:57:30 -0500129void set_kernel_text_rw(void);
130void set_kernel_text_ro(void);
131#else
132static inline void set_kernel_text_rw(void) { }
133static inline void set_kernel_text_ro(void) { }
Thomas Gleixnerb2bba722007-10-15 23:28:20 +0200134#endif
Harvey Harrison7bfeab92008-02-12 12:12:01 -0800135
Arjan van de Venedeed302008-01-30 13:34:08 +0100136#ifdef CONFIG_DEBUG_RODATA_TEST
Harvey Harrison7bfeab92008-02-12 12:12:01 -0800137int rodata_test(void);
Arjan van de Venedeed302008-01-30 13:34:08 +0100138#else
Harvey Harrison7bfeab92008-02-12 12:12:01 -0800139static inline int rodata_test(void)
Arjan van de Venedeed302008-01-30 13:34:08 +0100140{
Harvey Harrison7bfeab92008-02-12 12:12:01 -0800141 return 0;
Arjan van de Venedeed302008-01-30 13:34:08 +0100142}
143#endif
Thomas Gleixnerb2bba722007-10-15 23:28:20 +0200144
H. Peter Anvin1965aae2008-10-22 22:26:29 -0700145#endif /* _ASM_X86_CACHEFLUSH_H */