Lines Matching full:lg
20 #include "lg.h"
106 return &cpu->lg->pgdirs[i].pgdir[index]; in spgd_addr()
164 return cpu->lg->pgdirs[cpu->cpu_pgd].gpgdir + index * sizeof(pgd_t); in gpgd_addr()
244 base = (unsigned long)cpu->lg->mem_base / PAGE_SIZE; in gpte_to_spte()
281 pte_pfn(gpte) >= cpu->lg->pfn_limit) in check_gpte()
288 (pgd_pfn(gpgd) >= cpu->lg->pfn_limit)) in check_gpgd()
296 (pmd_pfn(gpmd) >= cpu->lg->pfn_limit)) in check_gpmd()
601 static void flush_user_mappings(struct lguest *lg, int idx) in flush_user_mappings() argument
605 for (i = 0; i < pgd_index(lg->kernel_address); i++) in flush_user_mappings()
606 release_pgd(lg->pgdirs[idx].pgdir + i); in flush_user_mappings()
618 flush_user_mappings(cpu->lg, cpu->cpu_pgd); in guest_pagetable_flush_user()
662 static unsigned int find_pgdir(struct lguest *lg, unsigned long pgtable) in find_pgdir() argument
665 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) in find_pgdir()
666 if (lg->pgdirs[i].pgdir && lg->pgdirs[i].gpgdir == pgtable) in find_pgdir()
689 next = random32() % ARRAY_SIZE(cpu->lg->pgdirs); in new_pgdir()
691 if (!cpu->lg->pgdirs[next].pgdir) { in new_pgdir()
692 cpu->lg->pgdirs[next].pgdir = in new_pgdir()
695 if (!cpu->lg->pgdirs[next].pgdir) in new_pgdir()
705 free_page((long)cpu->lg->pgdirs[next].pgdir); in new_pgdir()
706 set_pgd(cpu->lg->pgdirs[next].pgdir, __pgd(0)); in new_pgdir()
709 set_pgd(cpu->lg->pgdirs[next].pgdir + in new_pgdir()
724 cpu->lg->pgdirs[next].gpgdir = gpgdir; in new_pgdir()
726 flush_user_mappings(cpu->lg, next); in new_pgdir()
736 static void release_all_pagetables(struct lguest *lg) in release_all_pagetables() argument
741 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) in release_all_pagetables()
742 if (lg->pgdirs[i].pgdir) { in release_all_pagetables()
749 spgd = lg->pgdirs[i].pgdir + SWITCHER_PGD_INDEX; in release_all_pagetables()
761 release_pgd(lg->pgdirs[i].pgdir + j); in release_all_pagetables()
773 release_all_pagetables(cpu->lg); in guest_pagetable_clear_all()
794 release_all_pagetables(cpu->lg); in guest_new_pagetable()
797 newpgdir = ARRAY_SIZE(cpu->lg->pgdirs); in guest_new_pagetable()
800 newpgdir = find_pgdir(cpu->lg, pgtable); in guest_new_pagetable()
807 if (newpgdir == ARRAY_SIZE(cpu->lg->pgdirs)) in guest_new_pagetable()
904 if (vaddr >= cpu->lg->kernel_address) { in guest_set_pte()
906 for (i = 0; i < ARRAY_SIZE(cpu->lg->pgdirs); i++) in guest_set_pte()
907 if (cpu->lg->pgdirs[i].pgdir) in guest_set_pte()
911 int pgdir = find_pgdir(cpu->lg, gpgdir); in guest_set_pte()
912 if (pgdir != ARRAY_SIZE(cpu->lg->pgdirs)) in guest_set_pte()
932 void guest_set_pgd(struct lguest *lg, unsigned long gpgdir, u32 idx) in guest_set_pgd() argument
940 pgdir = find_pgdir(lg, gpgdir); in guest_set_pgd()
941 if (pgdir < ARRAY_SIZE(lg->pgdirs)) in guest_set_pgd()
943 release_pgd(lg->pgdirs[pgdir].pgdir + idx); in guest_set_pgd()
948 void guest_set_pmd(struct lguest *lg, unsigned long pmdp, u32 idx) in guest_set_pmd() argument
950 guest_pagetable_clear_all(&lg->cpus[0]); in guest_set_pmd()
962 int init_guest_pagetable(struct lguest *lg) in init_guest_pagetable() argument
964 struct lg_cpu *cpu = &lg->cpus[0]; in init_guest_pagetable()
967 /* lg (and lg->cpus[]) starts zeroed: this allocates a new pgdir */ in init_guest_pagetable()
981 if (get_user(cpu->lg->kernel_address, in page_table_guest_data_init()
982 &cpu->lg->lguest_data->kernel_address) in page_table_guest_data_init()
988 &cpu->lg->lguest_data->reserve_mem)) { in page_table_guest_data_init()
989 kill_guest(cpu, "bad guest page %p", cpu->lg->lguest_data); in page_table_guest_data_init()
995 * "pgd_index(lg->kernel_address)". This assumes it won't hit the in page_table_guest_data_init()
999 if (pgd_index(cpu->lg->kernel_address) == SWITCHER_PGD_INDEX && in page_table_guest_data_init()
1000 pmd_index(cpu->lg->kernel_address) == SWITCHER_PMD_INDEX) in page_table_guest_data_init()
1002 if (pgd_index(cpu->lg->kernel_address) >= SWITCHER_PGD_INDEX) in page_table_guest_data_init()
1005 cpu->lg->kernel_address); in page_table_guest_data_init()
1009 void free_guest_pagetable(struct lguest *lg) in free_guest_pagetable() argument
1014 release_all_pagetables(lg); in free_guest_pagetable()
1016 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) in free_guest_pagetable()
1017 free_page((long)lg->pgdirs[i].pgdir); in free_guest_pagetable()
1042 pmd_table = __va(pgd_pfn(cpu->lg-> in map_switcher_in_guest()
1056 cpu->lg->pgdirs[cpu->cpu_pgd].pgdir[SWITCHER_PGD_INDEX] = switcher_pgd; in map_switcher_in_guest()