Lines Matching refs:lg

88 	return &cpu->lg->pgdirs[i].pgdir[index];  in spgd_addr()
139 return cpu->lg->pgdirs[cpu->cpu_pgd].gpgdir + index * sizeof(pgd_t); in gpgd_addr()
219 base = (unsigned long)cpu->lg->mem_base / PAGE_SIZE; in gpte_to_spte()
259 return (pte_pfn(gpte) >= cpu->lg->pfn_limit in gpte_in_iomem()
260 && pte_pfn(gpte) < cpu->lg->device_limit); in gpte_in_iomem()
266 pte_pfn(gpte) >= cpu->lg->pfn_limit) { in check_gpte()
276 (pgd_pfn(gpgd) >= cpu->lg->pfn_limit)) { in check_gpgd()
287 (pmd_pfn(gpmd) >= cpu->lg->pfn_limit)) { in check_gpmd()
654 static void flush_user_mappings(struct lguest *lg, int idx) in flush_user_mappings() argument
658 for (i = 0; i < pgd_index(lg->kernel_address); i++) in flush_user_mappings()
659 release_pgd(lg->pgdirs[idx].pgdir + i); in flush_user_mappings()
671 flush_user_mappings(cpu->lg, cpu->cpu_pgd); in guest_pagetable_flush_user()
733 static unsigned int find_pgdir(struct lguest *lg, unsigned long pgtable) in find_pgdir() argument
736 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) in find_pgdir()
737 if (lg->pgdirs[i].pgdir && lg->pgdirs[i].gpgdir == pgtable) in find_pgdir()
757 next = prandom_u32() % ARRAY_SIZE(cpu->lg->pgdirs); in new_pgdir()
759 if (!cpu->lg->pgdirs[next].pgdir) { in new_pgdir()
760 cpu->lg->pgdirs[next].pgdir = in new_pgdir()
763 if (!cpu->lg->pgdirs[next].pgdir) in new_pgdir()
774 cpu->lg->pgdirs[next].gpgdir = gpgdir; in new_pgdir()
776 flush_user_mappings(cpu->lg, next); in new_pgdir()
779 cpu->lg->pgdirs[next].last_host_cpu = -1; in new_pgdir()
818 cpu->lg->pgdirs[cpu->cpu_pgd].switcher_mapped = true; in allocate_switcher_mapping()
827 static void release_all_pagetables(struct lguest *lg) in release_all_pagetables() argument
832 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) { in release_all_pagetables()
833 if (!lg->pgdirs[i].pgdir) in release_all_pagetables()
838 release_pgd(lg->pgdirs[i].pgdir + j); in release_all_pagetables()
839 lg->pgdirs[i].switcher_mapped = false; in release_all_pagetables()
840 lg->pgdirs[i].last_host_cpu = -1; in release_all_pagetables()
852 release_all_pagetables(cpu->lg); in guest_pagetable_clear_all()
876 release_all_pagetables(cpu->lg); in guest_new_pagetable()
879 newpgdir = ARRAY_SIZE(cpu->lg->pgdirs); in guest_new_pagetable()
882 newpgdir = find_pgdir(cpu->lg, pgtable); in guest_new_pagetable()
889 if (newpgdir == ARRAY_SIZE(cpu->lg->pgdirs)) in guest_new_pagetable()
900 if (!cpu->lg->pgdirs[cpu->cpu_pgd].switcher_mapped) { in guest_new_pagetable()
1002 if (vaddr >= cpu->lg->kernel_address) { in guest_set_pte()
1004 for (i = 0; i < ARRAY_SIZE(cpu->lg->pgdirs); i++) in guest_set_pte()
1005 if (cpu->lg->pgdirs[i].pgdir) in guest_set_pte()
1009 int pgdir = find_pgdir(cpu->lg, gpgdir); in guest_set_pte()
1010 if (pgdir != ARRAY_SIZE(cpu->lg->pgdirs)) in guest_set_pte()
1030 void guest_set_pgd(struct lguest *lg, unsigned long gpgdir, u32 idx) in guest_set_pgd() argument
1035 kill_guest(&lg->cpus[0], "Attempt to set pgd %u/%u", in guest_set_pgd()
1041 pgdir = find_pgdir(lg, gpgdir); in guest_set_pgd()
1042 if (pgdir < ARRAY_SIZE(lg->pgdirs)) { in guest_set_pgd()
1044 release_pgd(lg->pgdirs[pgdir].pgdir + idx); in guest_set_pgd()
1046 if (!allocate_switcher_mapping(&lg->cpus[0])) { in guest_set_pgd()
1047 kill_guest(&lg->cpus[0], in guest_set_pgd()
1050 lg->pgdirs[pgdir].last_host_cpu = -1; in guest_set_pgd()
1056 void guest_set_pmd(struct lguest *lg, unsigned long pmdp, u32 idx) in guest_set_pmd() argument
1058 guest_pagetable_clear_all(&lg->cpus[0]); in guest_set_pmd()
1073 int init_guest_pagetable(struct lguest *lg) in init_guest_pagetable() argument
1075 struct lg_cpu *cpu = &lg->cpus[0]; in init_guest_pagetable()
1088 release_all_pagetables(lg); in init_guest_pagetable()
1106 if (get_user(cpu->lg->kernel_address, in page_table_guest_data_init()
1107 &cpu->lg->lguest_data->kernel_address) in page_table_guest_data_init()
1112 || put_user(top, &cpu->lg->lguest_data->reserve_mem)) { in page_table_guest_data_init()
1113 kill_guest(cpu, "bad guest page %p", cpu->lg->lguest_data); in page_table_guest_data_init()
1122 if (cpu->lg->kernel_address >= switcher_addr) in page_table_guest_data_init()
1124 cpu->lg->kernel_address); in page_table_guest_data_init()
1128 void free_guest_pagetable(struct lguest *lg) in free_guest_pagetable() argument
1133 release_all_pagetables(lg); in free_guest_pagetable()
1135 for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++) in free_guest_pagetable()
1136 free_page((long)lg->pgdirs[i].pgdir); in free_guest_pagetable()
1172 struct pgdir *pgdir = &cpu->lg->pgdirs[cpu->cpu_pgd]; in map_switcher_in_guest()