diff --git a/arch/x86/kernel/memory.c b/arch/x86/kernel/memory.c index 28159839..f85b75e0 100644 --- a/arch/x86/kernel/memory.c +++ b/arch/x86/kernel/memory.c @@ -490,8 +490,10 @@ uint64_t ihk_mc_pt_virt_to_pagemap(struct page_table *pt, unsigned long virt) return pagemap; } -int ihk_mc_pt_virt_to_phys(struct page_table *pt, - const void *virt, unsigned long *phys) +int ihk_mc_pt_virt_to_phys_size(struct page_table *pt, + const void *virt, + unsigned long *phys, + unsigned long *size) { int l4idx, l3idx, l2idx, l1idx; unsigned long v = (unsigned long)virt; @@ -513,6 +515,7 @@ int ihk_mc_pt_virt_to_phys(struct page_table *pt, if ((pt->entry[l3idx] & PFL3_SIZE)) { *phys = pte_get_phys(&pt->entry[l3idx]) | (v & (PTL3_SIZE - 1)); + if (size) *size = PTL3_SIZE; return 0; } pt = phys_to_virt(pte_get_phys(&pt->entry[l3idx])); @@ -523,6 +526,7 @@ int ihk_mc_pt_virt_to_phys(struct page_table *pt, if ((pt->entry[l2idx] & PFL2_SIZE)) { *phys = pte_get_phys(&pt->entry[l2idx]) | (v & (PTL2_SIZE - 1)); + if (size) *size = PTL2_SIZE; return 0; } pt = phys_to_virt(pte_get_phys(&pt->entry[l2idx])); @@ -532,9 +536,17 @@ int ihk_mc_pt_virt_to_phys(struct page_table *pt, } *phys = pte_get_phys(&pt->entry[l1idx]) | (v & (PTL1_SIZE - 1)); + if (size) *size = PTL1_SIZE; return 0; } +int ihk_mc_pt_virt_to_phys(struct page_table *pt, + const void *virt, unsigned long *phys) +{ + return ihk_mc_pt_virt_to_phys_size(pt, virt, phys, NULL); +} + + int ihk_mc_pt_print_pte(struct page_table *pt, void *virt) { int l4idx, l3idx, l2idx, l1idx; diff --git a/kernel/syscall.c b/kernel/syscall.c index 9c39a1a5..f8f8378e 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -7694,6 +7694,7 @@ static int do_process_vm_read_writev(int pid, struct process_vm *rvm = NULL; unsigned long rphys; unsigned long rpage_left; + unsigned long psize; void *rva; struct vm_range *range; struct mcs_rwlock_node_irqsave lock; diff --git a/lib/include/ihk/mm.h b/lib/include/ihk/mm.h index c8e7c39e..9ceee283 100644 --- a/lib/include/ihk/mm.h +++ b/lib/include/ihk/mm.h @@ -164,6 +164,10 @@ struct page_table *ihk_mc_pt_create(enum ihk_mc_ap_flag ap_flag); /* XXX: proper use of struct page_table and page_table_t is unknown */ void ihk_mc_pt_destroy(struct page_table *pt); void ihk_mc_load_page_table(struct page_table *pt); +int ihk_mc_pt_virt_to_phys_size(struct page_table *pt, + const void *virt, + unsigned long *phys, + unsigned long *size); int ihk_mc_pt_virt_to_phys(struct page_table *pt, const void *virt, unsigned long *phys); uint64_t ihk_mc_pt_virt_to_pagemap(struct page_table *pt, unsigned long virt);