Loading drivers/lguest/core.c +13 −12 Original line number Original line Diff line number Diff line Loading @@ -21,8 +21,8 @@ #include "lg.h" #include "lg.h" unsigned long switcher_addr; unsigned long switcher_addr; struct page **lg_switcher_pages; static struct vm_struct *switcher_vma; static struct vm_struct *switcher_vma; static struct page **switcher_pages; /* This One Big lock protects all inter-guest data structures. */ /* This One Big lock protects all inter-guest data structures. */ DEFINE_MUTEX(lguest_lock); DEFINE_MUTEX(lguest_lock); Loading Loading @@ -63,9 +63,10 @@ static __init int map_switcher(void) * We allocate an array of struct page pointers. map_vm_area() wants * We allocate an array of struct page pointers. map_vm_area() wants * this, rather than just an array of pages. * this, rather than just an array of pages. */ */ switcher_pages = kmalloc(sizeof(switcher_pages[0])*TOTAL_SWITCHER_PAGES, lg_switcher_pages = kmalloc(sizeof(lg_switcher_pages[0]) * TOTAL_SWITCHER_PAGES, GFP_KERNEL); GFP_KERNEL); if (!switcher_pages) { if (!lg_switcher_pages) { err = -ENOMEM; err = -ENOMEM; goto out; goto out; } } Loading @@ -75,8 +76,8 @@ static __init int map_switcher(void) * so we make sure they're zeroed. * so we make sure they're zeroed. */ */ for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) { for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) { switcher_pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO); lg_switcher_pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO); if (!switcher_pages[i]) { if (!lg_switcher_pages[i]) { err = -ENOMEM; err = -ENOMEM; goto free_some_pages; goto free_some_pages; } } Loading Loading @@ -117,7 +118,7 @@ static __init int map_switcher(void) * array of struct pages. It increments that pointer, but we don't * array of struct pages. It increments that pointer, but we don't * care. * care. */ */ pagep = switcher_pages; pagep = lg_switcher_pages; err = map_vm_area(switcher_vma, PAGE_KERNEL_EXEC, &pagep); err = map_vm_area(switcher_vma, PAGE_KERNEL_EXEC, &pagep); if (err) { if (err) { printk("lguest: map_vm_area failed: %i\n", err); printk("lguest: map_vm_area failed: %i\n", err); Loading @@ -142,8 +143,8 @@ static __init int map_switcher(void) i = TOTAL_SWITCHER_PAGES; i = TOTAL_SWITCHER_PAGES; free_some_pages: free_some_pages: for (--i; i >= 0; i--) for (--i; i >= 0; i--) __free_pages(switcher_pages[i], 0); __free_pages(lg_switcher_pages[i], 0); kfree(switcher_pages); kfree(lg_switcher_pages); out: out: return err; return err; } } Loading @@ -158,8 +159,8 @@ static void unmap_switcher(void) vunmap(switcher_vma->addr); vunmap(switcher_vma->addr); /* Now we just need to free the pages we copied the switcher into */ /* Now we just need to free the pages we copied the switcher into */ for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) __free_pages(switcher_pages[i], 0); __free_pages(lg_switcher_pages[i], 0); kfree(switcher_pages); kfree(lg_switcher_pages); } } /*H:032 /*H:032 Loading Loading @@ -333,7 +334,7 @@ static int __init init(void) goto out; goto out; /* Now we set up the pagetable implementation for the Guests. */ /* Now we set up the pagetable implementation for the Guests. */ err = init_pagetables(switcher_pages); err = init_pagetables(lg_switcher_pages); if (err) if (err) goto unmap; goto unmap; Loading drivers/lguest/lg.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -124,6 +124,7 @@ bool lguest_address_ok(const struct lguest *lg, unsigned long addr, unsigned long len); unsigned long addr, unsigned long len); void __lgread(struct lg_cpu *, void *, unsigned long, unsigned); void __lgread(struct lg_cpu *, void *, unsigned long, unsigned); void __lgwrite(struct lg_cpu *, unsigned long, const void *, unsigned); void __lgwrite(struct lg_cpu *, unsigned long, const void *, unsigned); extern struct page **lg_switcher_pages; /*H:035 /*H:035 * Using memory-copy operations like that is usually inconvient, so we * Using memory-copy operations like that is usually inconvient, so we Loading Loading
drivers/lguest/core.c +13 −12 Original line number Original line Diff line number Diff line Loading @@ -21,8 +21,8 @@ #include "lg.h" #include "lg.h" unsigned long switcher_addr; unsigned long switcher_addr; struct page **lg_switcher_pages; static struct vm_struct *switcher_vma; static struct vm_struct *switcher_vma; static struct page **switcher_pages; /* This One Big lock protects all inter-guest data structures. */ /* This One Big lock protects all inter-guest data structures. */ DEFINE_MUTEX(lguest_lock); DEFINE_MUTEX(lguest_lock); Loading Loading @@ -63,9 +63,10 @@ static __init int map_switcher(void) * We allocate an array of struct page pointers. map_vm_area() wants * We allocate an array of struct page pointers. map_vm_area() wants * this, rather than just an array of pages. * this, rather than just an array of pages. */ */ switcher_pages = kmalloc(sizeof(switcher_pages[0])*TOTAL_SWITCHER_PAGES, lg_switcher_pages = kmalloc(sizeof(lg_switcher_pages[0]) * TOTAL_SWITCHER_PAGES, GFP_KERNEL); GFP_KERNEL); if (!switcher_pages) { if (!lg_switcher_pages) { err = -ENOMEM; err = -ENOMEM; goto out; goto out; } } Loading @@ -75,8 +76,8 @@ static __init int map_switcher(void) * so we make sure they're zeroed. * so we make sure they're zeroed. */ */ for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) { for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) { switcher_pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO); lg_switcher_pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO); if (!switcher_pages[i]) { if (!lg_switcher_pages[i]) { err = -ENOMEM; err = -ENOMEM; goto free_some_pages; goto free_some_pages; } } Loading Loading @@ -117,7 +118,7 @@ static __init int map_switcher(void) * array of struct pages. It increments that pointer, but we don't * array of struct pages. It increments that pointer, but we don't * care. * care. */ */ pagep = switcher_pages; pagep = lg_switcher_pages; err = map_vm_area(switcher_vma, PAGE_KERNEL_EXEC, &pagep); err = map_vm_area(switcher_vma, PAGE_KERNEL_EXEC, &pagep); if (err) { if (err) { printk("lguest: map_vm_area failed: %i\n", err); printk("lguest: map_vm_area failed: %i\n", err); Loading @@ -142,8 +143,8 @@ static __init int map_switcher(void) i = TOTAL_SWITCHER_PAGES; i = TOTAL_SWITCHER_PAGES; free_some_pages: free_some_pages: for (--i; i >= 0; i--) for (--i; i >= 0; i--) __free_pages(switcher_pages[i], 0); __free_pages(lg_switcher_pages[i], 0); kfree(switcher_pages); kfree(lg_switcher_pages); out: out: return err; return err; } } Loading @@ -158,8 +159,8 @@ static void unmap_switcher(void) vunmap(switcher_vma->addr); vunmap(switcher_vma->addr); /* Now we just need to free the pages we copied the switcher into */ /* Now we just need to free the pages we copied the switcher into */ for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) for (i = 0; i < TOTAL_SWITCHER_PAGES; i++) __free_pages(switcher_pages[i], 0); __free_pages(lg_switcher_pages[i], 0); kfree(switcher_pages); kfree(lg_switcher_pages); } } /*H:032 /*H:032 Loading Loading @@ -333,7 +334,7 @@ static int __init init(void) goto out; goto out; /* Now we set up the pagetable implementation for the Guests. */ /* Now we set up the pagetable implementation for the Guests. */ err = init_pagetables(switcher_pages); err = init_pagetables(lg_switcher_pages); if (err) if (err) goto unmap; goto unmap; Loading
drivers/lguest/lg.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -124,6 +124,7 @@ bool lguest_address_ok(const struct lguest *lg, unsigned long addr, unsigned long len); unsigned long addr, unsigned long len); void __lgread(struct lg_cpu *, void *, unsigned long, unsigned); void __lgread(struct lg_cpu *, void *, unsigned long, unsigned); void __lgwrite(struct lg_cpu *, unsigned long, const void *, unsigned); void __lgwrite(struct lg_cpu *, unsigned long, const void *, unsigned); extern struct page **lg_switcher_pages; /*H:035 /*H:035 * Using memory-copy operations like that is usually inconvient, so we * Using memory-copy operations like that is usually inconvient, so we Loading