diff options
| author | Dan Williams <dan.j.williams@intel.com> | 2009-09-08 20:55:21 -0400 |
|---|---|---|
| committer | Dan Williams <dan.j.williams@intel.com> | 2009-09-08 20:55:21 -0400 |
| commit | bbb20089a3275a19e475dbc21320c3742e3ca423 (patch) | |
| tree | 216fdc1cbef450ca688135c5b8969169482d9a48 /include/linux/kmemcheck.h | |
| parent | 3e48e656903e9fd8bc805c6a2c4264d7808d315b (diff) | |
| parent | 657a77fa7284d8ae28dfa48f1dc5d919bf5b2843 (diff) | |
Merge branch 'dmaengine' into async-tx-next
Conflicts:
crypto/async_tx/async_xor.c
drivers/dma/ioat/dma_v2.h
drivers/dma/ioat/pci.c
drivers/md/raid5.c
Diffstat (limited to 'include/linux/kmemcheck.h')
| -rw-r--r-- | include/linux/kmemcheck.h | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/include/linux/kmemcheck.h b/include/linux/kmemcheck.h new file mode 100644 index 000000000000..47b39b7c7e84 --- /dev/null +++ b/include/linux/kmemcheck.h | |||
| @@ -0,0 +1,153 @@ | |||
| 1 | #ifndef LINUX_KMEMCHECK_H | ||
| 2 | #define LINUX_KMEMCHECK_H | ||
| 3 | |||
| 4 | #include <linux/mm_types.h> | ||
| 5 | #include <linux/types.h> | ||
| 6 | |||
| 7 | #ifdef CONFIG_KMEMCHECK | ||
| 8 | extern int kmemcheck_enabled; | ||
| 9 | |||
| 10 | /* The slab-related functions. */ | ||
| 11 | void kmemcheck_alloc_shadow(struct page *page, int order, gfp_t flags, int node); | ||
| 12 | void kmemcheck_free_shadow(struct page *page, int order); | ||
| 13 | void kmemcheck_slab_alloc(struct kmem_cache *s, gfp_t gfpflags, void *object, | ||
| 14 | size_t size); | ||
| 15 | void kmemcheck_slab_free(struct kmem_cache *s, void *object, size_t size); | ||
| 16 | |||
| 17 | void kmemcheck_pagealloc_alloc(struct page *p, unsigned int order, | ||
| 18 | gfp_t gfpflags); | ||
| 19 | |||
| 20 | void kmemcheck_show_pages(struct page *p, unsigned int n); | ||
| 21 | void kmemcheck_hide_pages(struct page *p, unsigned int n); | ||
| 22 | |||
| 23 | bool kmemcheck_page_is_tracked(struct page *p); | ||
| 24 | |||
| 25 | void kmemcheck_mark_unallocated(void *address, unsigned int n); | ||
| 26 | void kmemcheck_mark_uninitialized(void *address, unsigned int n); | ||
| 27 | void kmemcheck_mark_initialized(void *address, unsigned int n); | ||
| 28 | void kmemcheck_mark_freed(void *address, unsigned int n); | ||
| 29 | |||
| 30 | void kmemcheck_mark_unallocated_pages(struct page *p, unsigned int n); | ||
| 31 | void kmemcheck_mark_uninitialized_pages(struct page *p, unsigned int n); | ||
| 32 | void kmemcheck_mark_initialized_pages(struct page *p, unsigned int n); | ||
| 33 | |||
| 34 | int kmemcheck_show_addr(unsigned long address); | ||
| 35 | int kmemcheck_hide_addr(unsigned long address); | ||
| 36 | |||
| 37 | #else | ||
| 38 | #define kmemcheck_enabled 0 | ||
| 39 | |||
| 40 | static inline void | ||
| 41 | kmemcheck_alloc_shadow(struct page *page, int order, gfp_t flags, int node) | ||
| 42 | { | ||
| 43 | } | ||
| 44 | |||
| 45 | static inline void | ||
| 46 | kmemcheck_free_shadow(struct page *page, int order) | ||
| 47 | { | ||
| 48 | } | ||
| 49 | |||
| 50 | static inline void | ||
| 51 | kmemcheck_slab_alloc(struct kmem_cache *s, gfp_t gfpflags, void *object, | ||
| 52 | size_t size) | ||
| 53 | { | ||
| 54 | } | ||
| 55 | |||
| 56 | static inline void kmemcheck_slab_free(struct kmem_cache *s, void *object, | ||
| 57 | size_t size) | ||
| 58 | { | ||
| 59 | } | ||
| 60 | |||
| 61 | static inline void kmemcheck_pagealloc_alloc(struct page *p, | ||
| 62 | unsigned int order, gfp_t gfpflags) | ||
| 63 | { | ||
| 64 | } | ||
| 65 | |||
| 66 | static inline bool kmemcheck_page_is_tracked(struct page *p) | ||
| 67 | { | ||
| 68 | return false; | ||
| 69 | } | ||
| 70 | |||
| 71 | static inline void kmemcheck_mark_unallocated(void *address, unsigned int n) | ||
| 72 | { | ||
| 73 | } | ||
| 74 | |||
| 75 | static inline void kmemcheck_mark_uninitialized(void *address, unsigned int n) | ||
| 76 | { | ||
| 77 | } | ||
| 78 | |||
| 79 | static inline void kmemcheck_mark_initialized(void *address, unsigned int n) | ||
| 80 | { | ||
| 81 | } | ||
| 82 | |||
| 83 | static inline void kmemcheck_mark_freed(void *address, unsigned int n) | ||
| 84 | { | ||
| 85 | } | ||
| 86 | |||
| 87 | static inline void kmemcheck_mark_unallocated_pages(struct page *p, | ||
| 88 | unsigned int n) | ||
| 89 | { | ||
| 90 | } | ||
| 91 | |||
| 92 | static inline void kmemcheck_mark_uninitialized_pages(struct page *p, | ||
| 93 | unsigned int n) | ||
| 94 | { | ||
| 95 | } | ||
| 96 | |||
| 97 | static inline void kmemcheck_mark_initialized_pages(struct page *p, | ||
| 98 | unsigned int n) | ||
| 99 | { | ||
| 100 | } | ||
| 101 | |||
| 102 | #endif /* CONFIG_KMEMCHECK */ | ||
| 103 | |||
| 104 | /* | ||
| 105 | * Bitfield annotations | ||
| 106 | * | ||
| 107 | * How to use: If you have a struct using bitfields, for example | ||
| 108 | * | ||
| 109 | * struct a { | ||
| 110 | * int x:8, y:8; | ||
| 111 | * }; | ||
| 112 | * | ||
| 113 | * then this should be rewritten as | ||
| 114 | * | ||
| 115 | * struct a { | ||
| 116 | * kmemcheck_bitfield_begin(flags); | ||
| 117 | * int x:8, y:8; | ||
| 118 | * kmemcheck_bitfield_end(flags); | ||
| 119 | * }; | ||
| 120 | * | ||
| 121 | * Now the "flags_begin" and "flags_end" members may be used to refer to the | ||
| 122 | * beginning and end, respectively, of the bitfield (and things like | ||
| 123 | * &x.flags_begin is allowed). As soon as the struct is allocated, the bit- | ||
| 124 | * fields should be annotated: | ||
| 125 | * | ||
| 126 | * struct a *a = kmalloc(sizeof(struct a), GFP_KERNEL); | ||
| 127 | * kmemcheck_annotate_bitfield(a, flags); | ||
| 128 | * | ||
| 129 | * Note: We provide the same definitions for both kmemcheck and non- | ||
| 130 | * kmemcheck kernels. This makes it harder to introduce accidental errors. It | ||
| 131 | * is also allowed to pass NULL pointers to kmemcheck_annotate_bitfield(). | ||
| 132 | */ | ||
| 133 | #define kmemcheck_bitfield_begin(name) \ | ||
| 134 | int name##_begin[0]; | ||
| 135 | |||
| 136 | #define kmemcheck_bitfield_end(name) \ | ||
| 137 | int name##_end[0]; | ||
| 138 | |||
| 139 | #define kmemcheck_annotate_bitfield(ptr, name) \ | ||
| 140 | do if (ptr) { \ | ||
| 141 | int _n = (long) &((ptr)->name##_end) \ | ||
| 142 | - (long) &((ptr)->name##_begin); \ | ||
| 143 | BUILD_BUG_ON(_n < 0); \ | ||
| 144 | \ | ||
| 145 | kmemcheck_mark_initialized(&((ptr)->name##_begin), _n); \ | ||
| 146 | } while (0) | ||
| 147 | |||
| 148 | #define kmemcheck_annotate_variable(var) \ | ||
| 149 | do { \ | ||
| 150 | kmemcheck_mark_initialized(&(var), sizeof(var)); \ | ||
| 151 | } while (0) \ | ||
| 152 | |||
| 153 | #endif /* LINUX_KMEMCHECK_H */ | ||
