# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1180722908 -32400 # Node ID 15b2b115a8813cac6f600d94f3ada1ca781b0908 # Parent bd3d6b4c52ec809f080c89c4ffcf61dc6e445978 Various fixes blktap_clear_pte(). added pte_get_and_clear_full() for auto translated physmap mode. added pte_get_and_clear_full() for io ring page. fix index calculation of map[]. This function is always called so that removed warning. PATCHNAME: fix_blktap_clear_pte Signed-off-by: Isaku Yamahata diff -r bd3d6b4c52ec -r 15b2b115a881 linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Fri Jun 01 14:50:52 2007 +0100 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c Sat Jun 02 03:35:08 2007 +0900 @@ -309,32 +309,25 @@ static pte_t blktap_clear_pte(struct vm_ unsigned long uvaddr, pte_t *ptep, int is_fullmm) { - pte_t copy = *ptep; - tap_blkif_t *info; + pte_t copy; + tap_blkif_t *info = vma->vm_file->private_data; int offset, seg, usr_idx, pending_idx, mmap_idx; - unsigned long uvstart = vma->vm_start + (RING_PAGES << PAGE_SHIFT); + unsigned long uvstart = info->user_vstart; unsigned long kvaddr; struct page **map; struct page *pg; struct grant_handle_pair *khandle; struct gnttab_unmap_grant_ref unmap[2]; int count = 0; - static int print_warning = 1; - - /* Print a warning message once, if the hook gets called. */ - if (print_warning) { - WPRINTK("Clear pte hook called!\n"); - print_warning = 0; - } /* * If the address is before the start of the grant mapped region or * if vm_file is NULL (meaning mmap failed and we have nothing to do) */ if (uvaddr < uvstart || vma->vm_file == NULL) - return copy; - - info = vma->vm_file->private_data; + return ptep_get_and_clear_full(vma->vm_mm, uvaddr, ptep, + is_fullmm); + map = vma->vm_private_data; /* TODO Should these be changed to if statements? */ @@ -352,6 +345,7 @@ static pte_t blktap_clear_pte(struct vm_ kvaddr = idx_to_kaddr(mmap_idx, pending_idx, seg); pg = pfn_to_page(__pa(kvaddr) >> PAGE_SHIFT); ClearPageReserved(pg); + offset = (uvaddr - vma->vm_start) >> PAGE_SHIFT; map[offset] = NULL; khandle = &pending_handle(mmap_idx, pending_idx, seg); @@ -368,12 +362,19 @@ static pte_t blktap_clear_pte(struct vm_ if (khandle->user != INVALID_GRANT_HANDLE) { BUG_ON(xen_feature(XENFEAT_auto_translated_physmap)); + copy = *ptep; gnttab_set_unmap_op(&unmap[count], virt_to_machine(ptep), GNTMAP_host_map | GNTMAP_application_map | GNTMAP_contains_pte, khandle->user); count++; + } else { + BUG_ON(!xen_feature(XENFEAT_auto_translated_physmap)); + + /* USING SHADOW PAGE TABLES. */ + copy = ptep_get_and_clear_full(vma->vm_mm, uvaddr, ptep, + is_fullmm); } if (count) { @@ -979,6 +980,7 @@ static void fast_flush_area(pending_req_ MMAP_VADDR(info->user_vstart, u_idx, 0), req->nr_pages << PAGE_SHIFT, NULL); up_write(&info->vma->vm_mm->mmap_sem); + return; } mmap_idx = req->mem_idx;