Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen: use generic functions instead of xen_{alloc, free}_vm_area()

Replace calls to the Xen-specific xen_alloc_vm_area() and
xen_free_vm_area() functions with the generic equivalent
(alloc_vm_area() and free_vm_area()).

On x86, these were identical already.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

authored by

David Vrabel and committed by
Konrad Rzeszutek Wilk
4dcaebbf a102a9ec

+4 -103
-29
arch/ia64/include/asm/xen/grant_table.h
··· 1 - /****************************************************************************** 2 - * arch/ia64/include/asm/xen/grant_table.h 3 - * 4 - * Copyright (c) 2008 Isaku Yamahata <yamahata at valinux co jp> 5 - * VA Linux Systems Japan K.K. 6 - * 7 - * This program is free software; you can redistribute it and/or modify 8 - * it under the terms of the GNU General Public License as published by 9 - * the Free Software Foundation; either version 2 of the License, or 10 - * (at your option) any later version. 11 - * 12 - * This program is distributed in the hope that it will be useful, 13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 - * GNU General Public License for more details. 16 - * 17 - * You should have received a copy of the GNU General Public License 18 - * along with this program; if not, write to the Free Software 19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 - * 21 - */ 22 - 23 - #ifndef _ASM_IA64_XEN_GRANT_TABLE_H 24 - #define _ASM_IA64_XEN_GRANT_TABLE_H 25 - 26 - struct vm_struct *xen_alloc_vm_area(unsigned long size); 27 - void xen_free_vm_area(struct vm_struct *area); 28 - 29 - #endif /* _ASM_IA64_XEN_GRANT_TABLE_H */
-62
arch/ia64/xen/grant-table.c
··· 31 31 32 32 #include <asm/xen/hypervisor.h> 33 33 34 - struct vm_struct *xen_alloc_vm_area(unsigned long size) 35 - { 36 - int order; 37 - unsigned long virt; 38 - unsigned long nr_pages; 39 - struct vm_struct *area; 40 - 41 - order = get_order(size); 42 - virt = __get_free_pages(GFP_KERNEL, order); 43 - if (virt == 0) 44 - goto err0; 45 - nr_pages = 1 << order; 46 - scrub_pages(virt, nr_pages); 47 - 48 - area = kmalloc(sizeof(*area), GFP_KERNEL); 49 - if (area == NULL) 50 - goto err1; 51 - 52 - area->flags = VM_IOREMAP; 53 - area->addr = (void *)virt; 54 - area->size = size; 55 - area->pages = NULL; 56 - area->nr_pages = nr_pages; 57 - area->phys_addr = 0; /* xenbus_map_ring_valloc uses this field! */ 58 - 59 - return area; 60 - 61 - err1: 62 - free_pages(virt, order); 63 - err0: 64 - return NULL; 65 - } 66 - EXPORT_SYMBOL_GPL(xen_alloc_vm_area); 67 - 68 - void xen_free_vm_area(struct vm_struct *area) 69 - { 70 - unsigned int order = get_order(area->size); 71 - unsigned long i; 72 - unsigned long phys_addr = __pa(area->addr); 73 - 74 - /* This area is used for foreign page mappping. 75 - * So underlying machine page may not be assigned. */ 76 - for (i = 0; i < (1 << order); i++) { 77 - unsigned long ret; 78 - unsigned long gpfn = (phys_addr >> PAGE_SHIFT) + i; 79 - struct xen_memory_reservation reservation = { 80 - .nr_extents = 1, 81 - .address_bits = 0, 82 - .extent_order = 0, 83 - .domid = DOMID_SELF 84 - }; 85 - set_xen_guest_handle(reservation.extent_start, &gpfn); 86 - ret = HYPERVISOR_memory_op(XENMEM_populate_physmap, 87 - &reservation); 88 - BUG_ON(ret != 1); 89 - } 90 - free_pages((unsigned long)area->addr, order); 91 - kfree(area); 92 - } 93 - EXPORT_SYMBOL_GPL(xen_free_vm_area); 94 - 95 - 96 34 /**************************************************************************** 97 35 * grant table hack 98 36 * cmd: GNTTABOP_xxx
-7
arch/x86/include/asm/xen/grant_table.h
··· 1 - #ifndef _ASM_X86_XEN_GRANT_TABLE_H 2 - #define _ASM_X86_XEN_GRANT_TABLE_H 3 - 4 - #define xen_alloc_vm_area(size) alloc_vm_area(size) 5 - #define xen_free_vm_area(area) free_vm_area(area) 6 - 7 - #endif /* _ASM_X86_XEN_GRANT_TABLE_H */
+1 -1
arch/x86/xen/grant-table.c
··· 71 71 72 72 if (shared == NULL) { 73 73 struct vm_struct *area = 74 - xen_alloc_vm_area(PAGE_SIZE * max_nr_gframes); 74 + alloc_vm_area(PAGE_SIZE * max_nr_gframes); 75 75 BUG_ON(area == NULL); 76 76 shared = area->addr; 77 77 *__shared = shared;
+3 -3
drivers/xen/xenbus/xenbus_client.c
··· 443 443 444 444 *vaddr = NULL; 445 445 446 - area = xen_alloc_vm_area(PAGE_SIZE); 446 + area = alloc_vm_area(PAGE_SIZE); 447 447 if (!area) 448 448 return -ENOMEM; 449 449 ··· 453 453 BUG(); 454 454 455 455 if (op.status != GNTST_okay) { 456 - xen_free_vm_area(area); 456 + free_vm_area(area); 457 457 xenbus_dev_fatal(dev, op.status, 458 458 "mapping in shared page %d from domain %d", 459 459 gnt_ref, dev->otherend_id); ··· 552 552 BUG(); 553 553 554 554 if (op.status == GNTST_okay) 555 - xen_free_vm_area(area); 555 + free_vm_area(area); 556 556 else 557 557 xenbus_dev_error(dev, op.status, 558 558 "unmapping page at handle %d error %d",
-1
include/xen/grant_table.h
··· 43 43 #include <xen/interface/grant_table.h> 44 44 45 45 #include <asm/xen/hypervisor.h> 46 - #include <asm/xen/grant_table.h> 47 46 48 47 #include <xen/features.h> 49 48