diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 16:09:51 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 16:09:51 -0400 |
commit | b3fec0fe35a4ff048484f1408385a27695d4273b (patch) | |
tree | 088c23f098421ea681d9976a83aad73d15be1027 /arch/x86/include | |
parent | e1f5b94fd0c93c3e27ede88b7ab652d086dc960f (diff) | |
parent | 722f2a6c87f34ee0fd0130a8cf45f81e0705594a (diff) |
Merge branch 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/vegard/kmemcheck
* 'for-linus2' of git://git.kernel.org/pub/scm/linux/kernel/git/vegard/kmemcheck: (39 commits)
signal: fix __send_signal() false positive kmemcheck warning
fs: fix do_mount_root() false positive kmemcheck warning
fs: introduce __getname_gfp()
trace: annotate bitfields in struct ring_buffer_event
net: annotate struct sock bitfield
c2port: annotate bitfield for kmemcheck
net: annotate inet_timewait_sock bitfields
ieee1394/csr1212: fix false positive kmemcheck report
ieee1394: annotate bitfield
net: annotate bitfields in struct inet_sock
net: use kmemcheck bitfields API for skbuff
kmemcheck: introduce bitfield API
kmemcheck: add opcode self-testing at boot
x86: unify pte_hidden
x86: make _PAGE_HIDDEN conditional
kmemcheck: make kconfig accessible for other architectures
kmemcheck: enable in the x86 Kconfig
kmemcheck: add hooks for the page allocator
kmemcheck: add hooks for page- and sg-dma-mappings
kmemcheck: don't track page tables
...
Diffstat (limited to 'arch/x86/include')
-rw-r--r-- | arch/x86/include/asm/dma-mapping.h | 7 | ||||
-rw-r--r-- | arch/x86/include/asm/kmemcheck.h | 42 | ||||
-rw-r--r-- | arch/x86/include/asm/pgtable.h | 5 | ||||
-rw-r--r-- | arch/x86/include/asm/pgtable_types.h | 9 | ||||
-rw-r--r-- | arch/x86/include/asm/string_32.h | 8 | ||||
-rw-r--r-- | arch/x86/include/asm/string_64.h | 8 | ||||
-rw-r--r-- | arch/x86/include/asm/thread_info.h | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/xor.h | 5 |
8 files changed, 84 insertions, 4 deletions
diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h index f82fdc412c64..b93405b228b4 100644 --- a/arch/x86/include/asm/dma-mapping.h +++ b/arch/x86/include/asm/dma-mapping.h | |||
@@ -6,6 +6,7 @@ | |||
6 | * Documentation/DMA-API.txt for documentation. | 6 | * Documentation/DMA-API.txt for documentation. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/kmemcheck.h> | ||
9 | #include <linux/scatterlist.h> | 10 | #include <linux/scatterlist.h> |
10 | #include <linux/dma-debug.h> | 11 | #include <linux/dma-debug.h> |
11 | #include <linux/dma-attrs.h> | 12 | #include <linux/dma-attrs.h> |
@@ -60,6 +61,7 @@ dma_map_single(struct device *hwdev, void *ptr, size_t size, | |||
60 | dma_addr_t addr; | 61 | dma_addr_t addr; |
61 | 62 | ||
62 | BUG_ON(!valid_dma_direction(dir)); | 63 | BUG_ON(!valid_dma_direction(dir)); |
64 | kmemcheck_mark_initialized(ptr, size); | ||
63 | addr = ops->map_page(hwdev, virt_to_page(ptr), | 65 | addr = ops->map_page(hwdev, virt_to_page(ptr), |
64 | (unsigned long)ptr & ~PAGE_MASK, size, | 66 | (unsigned long)ptr & ~PAGE_MASK, size, |
65 | dir, NULL); | 67 | dir, NULL); |
@@ -87,8 +89,12 @@ dma_map_sg(struct device *hwdev, struct scatterlist *sg, | |||
87 | { | 89 | { |
88 | struct dma_map_ops *ops = get_dma_ops(hwdev); | 90 | struct dma_map_ops *ops = get_dma_ops(hwdev); |
89 | int ents; | 91 | int ents; |
92 | struct scatterlist *s; | ||
93 | int i; | ||
90 | 94 | ||
91 | BUG_ON(!valid_dma_direction(dir)); | 95 | BUG_ON(!valid_dma_direction(dir)); |
96 | for_each_sg(sg, s, nents, i) | ||
97 | kmemcheck_mark_initialized(sg_virt(s), s->length); | ||
92 | ents = ops->map_sg(hwdev, sg, nents, dir, NULL); | 98 | ents = ops->map_sg(hwdev, sg, nents, dir, NULL); |
93 | debug_dma_map_sg(hwdev, sg, nents, ents, dir); | 99 | debug_dma_map_sg(hwdev, sg, nents, ents, dir); |
94 | 100 | ||
@@ -200,6 +206,7 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, | |||
200 | dma_addr_t addr; | 206 | dma_addr_t addr; |
201 | 207 | ||
202 | BUG_ON(!valid_dma_direction(dir)); | 208 | BUG_ON(!valid_dma_direction(dir)); |
209 | kmemcheck_mark_initialized(page_address(page) + offset, size); | ||
203 | addr = ops->map_page(dev, page, offset, size, dir, NULL); | 210 | addr = ops->map_page(dev, page, offset, size, dir, NULL); |
204 | debug_dma_map_page(dev, page, offset, size, dir, addr, false); | 211 | debug_dma_map_page(dev, page, offset, size, dir, addr, false); |
205 | 212 | ||
diff --git a/arch/x86/include/asm/kmemcheck.h b/arch/x86/include/asm/kmemcheck.h new file mode 100644 index 000000000000..ed01518f297e --- /dev/null +++ b/arch/x86/include/asm/kmemcheck.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef ASM_X86_KMEMCHECK_H | ||
2 | #define ASM_X86_KMEMCHECK_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <asm/ptrace.h> | ||
6 | |||
7 | #ifdef CONFIG_KMEMCHECK | ||
8 | bool kmemcheck_active(struct pt_regs *regs); | ||
9 | |||
10 | void kmemcheck_show(struct pt_regs *regs); | ||
11 | void kmemcheck_hide(struct pt_regs *regs); | ||
12 | |||
13 | bool kmemcheck_fault(struct pt_regs *regs, | ||
14 | unsigned long address, unsigned long error_code); | ||
15 | bool kmemcheck_trap(struct pt_regs *regs); | ||
16 | #else | ||
17 | static inline bool kmemcheck_active(struct pt_regs *regs) | ||
18 | { | ||
19 | return false; | ||
20 | } | ||
21 | |||
22 | static inline void kmemcheck_show(struct pt_regs *regs) | ||
23 | { | ||
24 | } | ||
25 | |||
26 | static inline void kmemcheck_hide(struct pt_regs *regs) | ||
27 | { | ||
28 | } | ||
29 | |||
30 | static inline bool kmemcheck_fault(struct pt_regs *regs, | ||
31 | unsigned long address, unsigned long error_code) | ||
32 | { | ||
33 | return false; | ||
34 | } | ||
35 | |||
36 | static inline bool kmemcheck_trap(struct pt_regs *regs) | ||
37 | { | ||
38 | return false; | ||
39 | } | ||
40 | #endif /* CONFIG_KMEMCHECK */ | ||
41 | |||
42 | #endif | ||
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 18ef7ebf2631..3cc06e3fceb8 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
@@ -317,6 +317,11 @@ static inline int pte_present(pte_t a) | |||
317 | return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE); | 317 | return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE); |
318 | } | 318 | } |
319 | 319 | ||
320 | static inline int pte_hidden(pte_t pte) | ||
321 | { | ||
322 | return pte_flags(pte) & _PAGE_HIDDEN; | ||
323 | } | ||
324 | |||
320 | static inline int pmd_present(pmd_t pmd) | 325 | static inline int pmd_present(pmd_t pmd) |
321 | { | 326 | { |
322 | return pmd_flags(pmd) & _PAGE_PRESENT; | 327 | return pmd_flags(pmd) & _PAGE_PRESENT; |
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index 4d258ad76a0f..54cb697f4900 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h | |||
@@ -18,7 +18,7 @@ | |||
18 | #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */ | 18 | #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */ |
19 | #define _PAGE_BIT_UNUSED1 9 /* available for programmer */ | 19 | #define _PAGE_BIT_UNUSED1 9 /* available for programmer */ |
20 | #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */ | 20 | #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */ |
21 | #define _PAGE_BIT_UNUSED3 11 | 21 | #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */ |
22 | #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */ | 22 | #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */ |
23 | #define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1 | 23 | #define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1 |
24 | #define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1 | 24 | #define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1 |
@@ -41,13 +41,18 @@ | |||
41 | #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL) | 41 | #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL) |
42 | #define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1) | 42 | #define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1) |
43 | #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP) | 43 | #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP) |
44 | #define _PAGE_UNUSED3 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED3) | ||
45 | #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT) | 44 | #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT) |
46 | #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE) | 45 | #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE) |
47 | #define _PAGE_SPECIAL (_AT(pteval_t, 1) << _PAGE_BIT_SPECIAL) | 46 | #define _PAGE_SPECIAL (_AT(pteval_t, 1) << _PAGE_BIT_SPECIAL) |
48 | #define _PAGE_CPA_TEST (_AT(pteval_t, 1) << _PAGE_BIT_CPA_TEST) | 47 | #define _PAGE_CPA_TEST (_AT(pteval_t, 1) << _PAGE_BIT_CPA_TEST) |
49 | #define __HAVE_ARCH_PTE_SPECIAL | 48 | #define __HAVE_ARCH_PTE_SPECIAL |
50 | 49 | ||
50 | #ifdef CONFIG_KMEMCHECK | ||
51 | #define _PAGE_HIDDEN (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN) | ||
52 | #else | ||
53 | #define _PAGE_HIDDEN (_AT(pteval_t, 0)) | ||
54 | #endif | ||
55 | |||
51 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) | 56 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) |
52 | #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) | 57 | #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX) |
53 | #else | 58 | #else |
diff --git a/arch/x86/include/asm/string_32.h b/arch/x86/include/asm/string_32.h index 0e0e3ba827f7..c86f452256de 100644 --- a/arch/x86/include/asm/string_32.h +++ b/arch/x86/include/asm/string_32.h | |||
@@ -177,10 +177,18 @@ static inline void *__memcpy3d(void *to, const void *from, size_t len) | |||
177 | * No 3D Now! | 177 | * No 3D Now! |
178 | */ | 178 | */ |
179 | 179 | ||
180 | #ifndef CONFIG_KMEMCHECK | ||
180 | #define memcpy(t, f, n) \ | 181 | #define memcpy(t, f, n) \ |
181 | (__builtin_constant_p((n)) \ | 182 | (__builtin_constant_p((n)) \ |
182 | ? __constant_memcpy((t), (f), (n)) \ | 183 | ? __constant_memcpy((t), (f), (n)) \ |
183 | : __memcpy((t), (f), (n))) | 184 | : __memcpy((t), (f), (n))) |
185 | #else | ||
186 | /* | ||
187 | * kmemcheck becomes very happy if we use the REP instructions unconditionally, | ||
188 | * because it means that we know both memory operands in advance. | ||
189 | */ | ||
190 | #define memcpy(t, f, n) __memcpy((t), (f), (n)) | ||
191 | #endif | ||
184 | 192 | ||
185 | #endif | 193 | #endif |
186 | 194 | ||
diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h index 2afe164bf1e6..19e2c468fc2c 100644 --- a/arch/x86/include/asm/string_64.h +++ b/arch/x86/include/asm/string_64.h | |||
@@ -27,6 +27,7 @@ static __always_inline void *__inline_memcpy(void *to, const void *from, size_t | |||
27 | function. */ | 27 | function. */ |
28 | 28 | ||
29 | #define __HAVE_ARCH_MEMCPY 1 | 29 | #define __HAVE_ARCH_MEMCPY 1 |
30 | #ifndef CONFIG_KMEMCHECK | ||
30 | #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 | 31 | #if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 |
31 | extern void *memcpy(void *to, const void *from, size_t len); | 32 | extern void *memcpy(void *to, const void *from, size_t len); |
32 | #else | 33 | #else |
@@ -42,6 +43,13 @@ extern void *__memcpy(void *to, const void *from, size_t len); | |||
42 | __ret; \ | 43 | __ret; \ |
43 | }) | 44 | }) |
44 | #endif | 45 | #endif |
46 | #else | ||
47 | /* | ||
48 | * kmemcheck becomes very happy if we use the REP instructions unconditionally, | ||
49 | * because it means that we know both memory operands in advance. | ||
50 | */ | ||
51 | #define memcpy(dst, src, len) __inline_memcpy((dst), (src), (len)) | ||
52 | #endif | ||
45 | 53 | ||
46 | #define __HAVE_ARCH_MEMSET | 54 | #define __HAVE_ARCH_MEMSET |
47 | void *memset(void *s, int c, size_t n); | 55 | void *memset(void *s, int c, size_t n); |
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 602c769fc98c..b0783520988b 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h | |||
@@ -154,9 +154,9 @@ struct thread_info { | |||
154 | 154 | ||
155 | /* thread information allocation */ | 155 | /* thread information allocation */ |
156 | #ifdef CONFIG_DEBUG_STACK_USAGE | 156 | #ifdef CONFIG_DEBUG_STACK_USAGE |
157 | #define THREAD_FLAGS (GFP_KERNEL | __GFP_ZERO) | 157 | #define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO) |
158 | #else | 158 | #else |
159 | #define THREAD_FLAGS GFP_KERNEL | 159 | #define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK) |
160 | #endif | 160 | #endif |
161 | 161 | ||
162 | #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR | 162 | #define __HAVE_ARCH_THREAD_INFO_ALLOCATOR |
diff --git a/arch/x86/include/asm/xor.h b/arch/x86/include/asm/xor.h index 11b3bb86e17b..7fcf6f3dbcc3 100644 --- a/arch/x86/include/asm/xor.h +++ b/arch/x86/include/asm/xor.h | |||
@@ -1,5 +1,10 @@ | |||
1 | #ifdef CONFIG_KMEMCHECK | ||
2 | /* kmemcheck doesn't handle MMX/SSE/SSE2 instructions */ | ||
3 | # include <asm-generic/xor.h> | ||
4 | #else | ||
1 | #ifdef CONFIG_X86_32 | 5 | #ifdef CONFIG_X86_32 |
2 | # include "xor_32.h" | 6 | # include "xor_32.h" |
3 | #else | 7 | #else |
4 | # include "xor_64.h" | 8 | # include "xor_64.h" |
5 | #endif | 9 | #endif |
10 | #endif | ||