From bab523801c12bd1d2ea31be6e7aef7d4a6b0dde3 Mon Sep 17 00:00:00 2001 From: Philippe Aubertin <39178965+phaubertin@users.noreply.github.com> Date: Sun, 26 Jan 2025 18:37:31 -0500 Subject: [PATCH] Remove machine_clone_userspace_mapping() (#119) Remove unused function `machine_clone_userspace_mapping()`. See #118 . --- include/kernel/machine/pmap.h | 8 ----- kernel/infrastructure/i686/pmap/pmap.c | 50 -------------------------- 2 files changed, 58 deletions(-) diff --git a/include/kernel/machine/pmap.h b/include/kernel/machine/pmap.h index 404cd974..a3ba730f 100644 --- a/include/kernel/machine/pmap.h +++ b/include/kernel/machine/pmap.h @@ -45,14 +45,6 @@ bool machine_map_userspace( paddr_t paddr, int prot); -bool machine_clone_userspace_mapping( - process_t *dest_process, - addr_t dest_addr, - process_t *src_process, - addr_t src_addr, - size_t length, - int prot) ; - paddr_t machine_lookup_kernel_paddr(const void *addr); #endif diff --git a/kernel/infrastructure/i686/pmap/pmap.c b/kernel/infrastructure/i686/pmap/pmap.c index 7076a418..e473ceeb 100644 --- a/kernel/infrastructure/i686/pmap/pmap.c +++ b/kernel/infrastructure/i686/pmap/pmap.c @@ -880,56 +880,6 @@ void machine_unmap_kernel_page(void *addr) { unmap_page(NULL, addr); } -/** - * Clone mappings in range from one process' address space to another. - * - * After the operation, the range in the destination address space maps the same - * memory as the range in the source address space. Any portion of the range - * that does not point to memory in the source address space is unmapped in the - * destination address space. The permissions of the new mappings are specified - * by the prot argument. - * - * @param dest_process destination process - * @param src_process source process - * @param dest_addr start of range in destination address space - * @param src_addr start of range in source address space - * @param length length of mapping range - * @param prot protections flags - */ -bool machine_clone_userspace_mapping( - process_t *dest_process, - addr_t dest_addr, - process_t *src_process, - addr_t src_addr, - size_t length, - int prot) { - - addr_space_t *src_addr_space = &src_process->addr_space; - addr_space_t *dest_addr_space = &dest_process->addr_space; - - for(size_t idx = 0; idx < length / PAGE_SIZE; ++idx) { - /* TODO We should be able to optimize by not looking up the page table - * for each entry, both for source and destination. */ - pte_t *src_pte = lookup_page_table_entry(src_addr_space, src_addr, false, NULL); - - if(src_pte == NULL || !pte_is_present(src_pte)) { - unmap_page(dest_addr_space, dest_addr); - } - else { - paddr_t paddr = get_pte_paddr(src_pte); - - if(!map_userspace_page(dest_addr_space, dest_addr, paddr, prot)) { - return false; - } - } - - src_addr += PAGE_SIZE; - dest_addr += PAGE_SIZE; - } - - return true; -} - /** * Look up the physical address of an existing kernel-mapped page frame. *