Merge branch 'core-fixes-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'core-fixes-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: dma-debug: Fix the overlap() function to be correct and readable oprofile: reset bt_lost_no_mapping with other stats x86/oprofile: rename kernel parameter for architectural perfmon to arch_perfmon signals: declare sys_rt_tgsigqueueinfo in syscalls.h rcu: Mark Hierarchical RCU no longer experimental dma-debug: Put all hash-chain locks into the same lock class dma-debug: fix off-by-one error in overlap function
This commit is contained in:
@ -716,7 +716,7 @@ void dma_debug_init(u32 num_entries)
|
||||
|
||||
for (i = 0; i < HASH_SIZE; ++i) {
|
||||
INIT_LIST_HEAD(&dma_entry_hash[i].list);
|
||||
dma_entry_hash[i].lock = SPIN_LOCK_UNLOCKED;
|
||||
spin_lock_init(&dma_entry_hash[i].lock);
|
||||
}
|
||||
|
||||
if (dma_debug_fs_init() != 0) {
|
||||
@ -856,22 +856,21 @@ static void check_for_stack(struct device *dev, void *addr)
|
||||
"stack [addr=%p]\n", addr);
|
||||
}
|
||||
|
||||
static inline bool overlap(void *addr, u64 size, void *start, void *end)
|
||||
static inline bool overlap(void *addr, unsigned long len, void *start, void *end)
|
||||
{
|
||||
void *addr2 = (char *)addr + size;
|
||||
unsigned long a1 = (unsigned long)addr;
|
||||
unsigned long b1 = a1 + len;
|
||||
unsigned long a2 = (unsigned long)start;
|
||||
unsigned long b2 = (unsigned long)end;
|
||||
|
||||
return ((addr >= start && addr < end) ||
|
||||
(addr2 >= start && addr2 < end) ||
|
||||
((addr < start) && (addr2 >= end)));
|
||||
return !(b1 <= a2 || a1 >= b2);
|
||||
}
|
||||
|
||||
static void check_for_illegal_area(struct device *dev, void *addr, u64 size)
|
||||
static void check_for_illegal_area(struct device *dev, void *addr, unsigned long len)
|
||||
{
|
||||
if (overlap(addr, size, _text, _etext) ||
|
||||
overlap(addr, size, __start_rodata, __end_rodata))
|
||||
err_printk(dev, NULL, "DMA-API: device driver maps "
|
||||
"memory from kernel text or rodata "
|
||||
"[addr=%p] [size=%llu]\n", addr, size);
|
||||
if (overlap(addr, len, _text, _etext) ||
|
||||
overlap(addr, len, __start_rodata, __end_rodata))
|
||||
err_printk(dev, NULL, "DMA-API: device driver maps memory from kernel text or rodata [addr=%p] [len=%lu]\n", addr, len);
|
||||
}
|
||||
|
||||
static void check_sync(struct device *dev,
|
||||
@ -969,7 +968,8 @@ void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
|
||||
entry->type = dma_debug_single;
|
||||
|
||||
if (!PageHighMem(page)) {
|
||||
void *addr = ((char *)page_address(page)) + offset;
|
||||
void *addr = page_address(page) + offset;
|
||||
|
||||
check_for_stack(dev, addr);
|
||||
check_for_illegal_area(dev, addr, size);
|
||||
}
|
||||
|
Reference in New Issue
Block a user