From 4b19c9405c4bf7e26cd173bd4cae93b1485bfacb Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 7 Sep 2002 22:22:03 -0700 Subject: [PATCH] atomic copy_*_user infrastructure The patch implements the atomic copy_*_user() function. If the kernel takes a pagefault while running copy_*_user() in an atomic region, the copy_*_user() will fail (return a short value). And with this patch, holding an atomic kmap() puts the CPU into an atomic region. - Increment preempt_count() in kmap_atomic() regardless of the setting of CONFIG_PREEMPT. The pagefault handler recognises this as an atomic region and refuses to service the fault. copy_*_user will return a non-zero value. - Attempts to propagate the in_atomic() predicate to all the other highmem-capable architectures' pagefault handlers. But the code is only tested on x86. - Fixed a PPC bug in kunmap_atomic(): it forgot to reenable preemption if HIGHMEM_DEBUG is turned on. - Fixed a sparc bug in kunmap_atomic(): it forgot to reenable preemption all the time, for non-fixmap pages. - Fix an error in - in the CONFIG_HIGHMEM=n case, kunmap_atomic() takes an address, not a page *. --- include/linux/highmem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/linux') diff --git a/include/linux/highmem.h b/include/linux/highmem.h index b389a75be5d7..370177037315 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -24,8 +24,8 @@ static inline void *kmap(struct page *page) { return page_address(page); } #define kunmap(page) do { (void) (page); } while (0) -#define kmap_atomic(page,idx) kmap(page) -#define kunmap_atomic(page,idx) kunmap(page) +#define kmap_atomic(page, idx) page_address(page) +#define kunmap_atomic(addr, idx) do { } while (0) #endif /* CONFIG_HIGHMEM */ -- cgit v1.2.3