Commit 856c6088 authored by Rusty Russell's avatar Rusty Russell

lguest: rename switcher_page to switcher_pages.

There is a single page with the Switcher in it, but it's followed by 2
pages per Host CPU.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent c215a8b9
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
unsigned long switcher_addr; unsigned long switcher_addr;
static struct vm_struct *switcher_vma; static struct vm_struct *switcher_vma;
static struct page **switcher_page; 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);
...@@ -56,9 +56,9 @@ static __init int map_switcher(void) ...@@ -56,9 +56,9 @@ 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_page = kmalloc(sizeof(switcher_page[0])*TOTAL_SWITCHER_PAGES, switcher_pages = kmalloc(sizeof(switcher_pages[0])*TOTAL_SWITCHER_PAGES,
GFP_KERNEL); GFP_KERNEL);
if (!switcher_page) { if (!switcher_pages) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
...@@ -68,8 +68,8 @@ static __init int map_switcher(void) ...@@ -68,8 +68,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_page[i] = alloc_page(GFP_KERNEL|__GFP_ZERO); switcher_pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO);
if (!switcher_page[i]) { if (!switcher_pages[i]) {
err = -ENOMEM; err = -ENOMEM;
goto free_some_pages; goto free_some_pages;
} }
...@@ -110,7 +110,7 @@ static __init int map_switcher(void) ...@@ -110,7 +110,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_page; pagep = 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);
...@@ -135,8 +135,8 @@ static __init int map_switcher(void) ...@@ -135,8 +135,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_page[i], 0); __free_pages(switcher_pages[i], 0);
kfree(switcher_page); kfree(switcher_pages);
out: out:
return err; return err;
} }
...@@ -151,8 +151,8 @@ static void unmap_switcher(void) ...@@ -151,8 +151,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_page[i], 0); __free_pages(switcher_pages[i], 0);
kfree(switcher_page); kfree(switcher_pages);
} }
/*H:032 /*H:032
...@@ -326,7 +326,7 @@ static int __init init(void) ...@@ -326,7 +326,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_page, SHARED_SWITCHER_PAGES); err = init_pagetables(switcher_pages, SHARED_SWITCHER_PAGES);
if (err) if (err)
goto unmap; goto unmap;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <asm/lguest.h> #include <asm/lguest.h>
void free_pagetables(void); void free_pagetables(void);
int init_pagetables(struct page **switcher_page, unsigned int pages); int init_pagetables(struct page **switcher_pages, unsigned int pages);
struct pgdir { struct pgdir {
unsigned long gpgdir; unsigned long gpgdir;
......
...@@ -1084,7 +1084,7 @@ static void free_switcher_pte_pages(void) ...@@ -1084,7 +1084,7 @@ static void free_switcher_pte_pages(void)
* Currently the Switcher is less than a page long, so "pages" is always 1. * Currently the Switcher is less than a page long, so "pages" is always 1.
*/ */
static __init void populate_switcher_pte_page(unsigned int cpu, static __init void populate_switcher_pte_page(unsigned int cpu,
struct page *switcher_page[], struct page *switcher_pages[],
unsigned int pages) unsigned int pages)
{ {
unsigned int i; unsigned int i;
...@@ -1092,7 +1092,7 @@ static __init void populate_switcher_pte_page(unsigned int cpu, ...@@ -1092,7 +1092,7 @@ static __init void populate_switcher_pte_page(unsigned int cpu,
/* The first entries are easy: they map the Switcher code. */ /* The first entries are easy: they map the Switcher code. */
for (i = 0; i < pages; i++) { for (i = 0; i < pages; i++) {
set_pte(&pte[i], mk_pte(switcher_page[i], set_pte(&pte[i], mk_pte(switcher_pages[i],
__pgprot(_PAGE_PRESENT|_PAGE_ACCESSED))); __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED)));
} }
...@@ -1100,14 +1100,14 @@ static __init void populate_switcher_pte_page(unsigned int cpu, ...@@ -1100,14 +1100,14 @@ static __init void populate_switcher_pte_page(unsigned int cpu,
i = pages + cpu*2; i = pages + cpu*2;
/* First page (Guest registers) is writable from the Guest */ /* First page (Guest registers) is writable from the Guest */
set_pte(&pte[i], pfn_pte(page_to_pfn(switcher_page[i]), set_pte(&pte[i], pfn_pte(page_to_pfn(switcher_pages[i]),
__pgprot(_PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_RW))); __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_RW)));
/* /*
* The second page contains the "struct lguest_ro_state", and is * The second page contains the "struct lguest_ro_state", and is
* read-only. * read-only.
*/ */
set_pte(&pte[i+1], pfn_pte(page_to_pfn(switcher_page[i+1]), set_pte(&pte[i+1], pfn_pte(page_to_pfn(switcher_pages[i+1]),
__pgprot(_PAGE_PRESENT|_PAGE_ACCESSED))); __pgprot(_PAGE_PRESENT|_PAGE_ACCESSED)));
} }
...@@ -1128,7 +1128,7 @@ static __init void populate_switcher_pte_page(unsigned int cpu, ...@@ -1128,7 +1128,7 @@ static __init void populate_switcher_pte_page(unsigned int cpu,
* At boot or module load time, init_pagetables() allocates and populates * At boot or module load time, init_pagetables() allocates and populates
* the Switcher PTE page for each CPU. * the Switcher PTE page for each CPU.
*/ */
__init int init_pagetables(struct page **switcher_page, unsigned int pages) __init int init_pagetables(struct page **switcher_pages, unsigned int pages)
{ {
unsigned int i; unsigned int i;
...@@ -1138,7 +1138,7 @@ __init int init_pagetables(struct page **switcher_page, unsigned int pages) ...@@ -1138,7 +1138,7 @@ __init int init_pagetables(struct page **switcher_page, unsigned int pages)
free_switcher_pte_pages(); free_switcher_pte_pages();
return -ENOMEM; return -ENOMEM;
} }
populate_switcher_pte_page(i, switcher_page, pages); populate_switcher_pte_page(i, switcher_pages, pages);
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment