Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

222 executables parse #224

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME): $(BUILD_FOLDER)/kernel.bin grub.cfg
cp grub.cfg $(BUILD_FOLDER)/isofiles/boot/grub
cp $(BUILD_FOLDER)/kernel.bin $(BUILD_FOLDER)/isofiles/boot
cp $(BUILD_FOLDER)/kernel.map $(BUILD_FOLDER)/isofiles/boot
cp example.elf $(BUILD_FOLDER)/isofiles
cp example_syscall.elf $(BUILD_FOLDER)/isofiles
grub-mkrescue -o $(BUILD_FOLDER)/$(ISO_IMAGE_FILENAME) $(BUILD_FOLDER)/isofiles

$(BUILD_FOLDER)/%.o: src/%.s
Expand Down
Binary file removed example.elf
Binary file not shown.
Binary file added example_syscall.elf
DeanoBurrito marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
2 changes: 1 addition & 1 deletion grub.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set default=0

menuentry "DreamOs64" {
multiboot2 /boot/kernel.bin // Path to the loader executable
module2 /example.elf
module2 /example_syscall.elf
boot
// More modules may be added here in the form 'module <path> "<cmdline>"'
}
2 changes: 2 additions & 0 deletions src/include/kernel/loaders/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,7 @@ void load_elf(uintptr_t elf_start, uint64_t size);
bool parse_section_header(Elf64_Ehdr *elf_start, uint64_t size, executable_loader_type type);

Elf64_Half loop_phdrs(Elf64_Ehdr* e_phdr, Elf64_Half phdr_entries);
Elf64_Phdr *read_phdr(Elf64_Ehdr* e_hdr, Elf64_Half phdr_entry_number);

uint64_t elf_flags_to_memory_flags(Elf64_Word flags);
#endif
1 change: 1 addition & 0 deletions src/include/kernel/mem/hh_direct_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
void early_map_physical_memory(uint64_t end_of_reserved_area);

void *hhdm_get_variable ( uintptr_t phys_address );
void *hhdm_get_phys_address(uintptr_t hhdm_address);
void hhdm_map_physical_memory();

#endif
2 changes: 1 addition & 1 deletion src/include/kernel/scheduling/scheduler.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef _SCHEDULER_H_
#define _SCHEDULER_H_

#include <cpu.h>
#include <stdint.h>
#include <thread.h>
#include <task.h>
#include <cpu.h>

#define SCHEDULER_NUMBER_OF_TICKS 0x200
#define SCHEDULER_MAX_THREAD_NUMBER 0x10
Expand Down
12 changes: 10 additions & 2 deletions src/include/kernel/scheduling/task.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _TASK_H
#define _TASK_H

#include <elf.h>
#include <stddef.h>
#include <stdbool.h>
#include <thread.h>
Expand All @@ -27,14 +28,21 @@ struct task_t {

extern size_t next_task_id;

task_t* create_task( char *name, void (*_entry_point)(void *), void *args, bool is_supervisor );
task_t* create_task( char *name, bool is_supervisor );
task_t *create_task_from_func(char *name, void (*_entry_point)(void *), void *args, bool is_supervisor);
task_t *create_task_from_elf(char *name, void *args, Elf64_Ehdr *elf_header);

task_t* get_task( size_t task_id );

bool add_thread_to_task_by_id( size_t task_id, thread_t* thread );
bool add_thread_to_task( task_t* task, thread_t* thread );

bool delete_thread_from_task( size_t thread_id, task_t *task );
void prepare_virtual_memory_environment( task_t* task );

void prepare_virtual_memory_environment(task_t* task);

void print_thread_list( size_t task_id );

bool remove_thread_from_task(size_t thread_id, task_t *task);

#endif
2 changes: 1 addition & 1 deletion src/include/kernel/scheduling/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct thread_t {
extern size_t next_thread_id;


thread_t* create_thread(char* thread_name, void (*_entry_point)(void *) , void* arg, struct task_t* parent_task, bool is_supervisor);
thread_t* create_thread(char* thread_name, void (*_entry_point)(void *) , void* arg, struct task_t* parent_task, bool is_supervisor, bool is_elf);
void thread_execution_wrapper( void (*)(void *), void*);
void thread_suicide_trap();
void thread_sleep(size_t millis);
Expand Down
6 changes: 3 additions & 3 deletions src/kernel/arch/x86_64/mem/vmm_mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void *map_phys_to_virt_addr_hh(void* physical_address, void* address, size_t fla
clean_new_table(new_table_hhdm);
pdpr_root = new_table_hhdm;
} else {
pretty_log(Verbose, "No need to allocate pml4");
//pretty_log(Verbose, "No need to allocate pml4");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of commenting these out, why not remove them? can always re-add them later if needed

pdpr_root = (uint64_t *) hhdm_get_variable((uintptr_t) pml4_root[pml4_e] & VM_PAGE_TABLE_BASE_ADDRESS_MASK);
}

Expand All @@ -59,7 +59,7 @@ void *map_phys_to_virt_addr_hh(void* physical_address, void* address, size_t fla
clean_new_table(new_table_hhdm);
pd_root = new_table_hhdm;
} else {
pretty_log(Verbose, "No need to allocate pdpr");
//pretty_log(Verbose, "No need to allocate pdpr");
pd_root = (uint64_t *) hhdm_get_variable((uintptr_t) pdpr_root[pdpr_e] & VM_PAGE_TABLE_BASE_ADDRESS_MASK);
}

Expand All @@ -72,7 +72,7 @@ void *map_phys_to_virt_addr_hh(void* physical_address, void* address, size_t fla
clean_new_table(new_table_hhdm);
pt_table = new_table_hhdm;
} else {
pretty_log(Verbose, "No need to allocate pd");
//pretty_log(Verbose, "No need to allocate pd");
pt_table = (uint64_t *) hhdm_get_variable((uintptr_t) pd_root[pd_e] & VM_PAGE_TABLE_BASE_ADDRESS_MASK);
}

Expand Down
34 changes: 32 additions & 2 deletions src/kernel/loaders/elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ void load_elf(uintptr_t elf_start, uint64_t size) {
Elf64_Half phdr_entsize = elf_header->e_phentsize;
pretty_logf(Verbose, " Number of PHDR entries: 0x%x", phdr_entries);
pretty_logf(Verbose, " PHDR Entry Size: 0x%x", phdr_entsize );
pretty_logf(Verbose, " ELF Entry point: 0x%x", elf_header->e_entry);
Elf64_Half result = loop_phdrs(elf_header, phdr_entries);
if (result > 0) {
pretty_logf(Verbose, " Number of PT_LOAD entries: %d", result);
Elf64_Phdr *cur_phdr = read_phdr(elf_header, 0);
pretty_logf(Verbose, "\t[cur_phdr]: Type: 0x%x, Flags: 0x%x - Vaddr: 0x%x - aligned: 0x%x - p_align: 0x%x - p_memsz: 0%x - p_offset: 0x%x", cur_phdr->p_type, cur_phdr->p_flags, cur_phdr->p_vaddr, align_value_to_page(cur_phdr->p_vaddr), cur_phdr->p_align, cur_phdr->p_memsz, cur_phdr->p_offset);
cur_phdr = read_phdr(elf_header, 1);
pretty_logf(Verbose, "\t[cur_phdr]: Type: 0x%x, Flags: 0x%x - Vaddr: 0x%x - aligned: 0x%x - p_align: 0x%x - p_memsz: 0%x - p_offset: 0x%x", cur_phdr->p_type, cur_phdr->p_flags, cur_phdr->p_vaddr, align_value_to_page(cur_phdr->p_vaddr), cur_phdr->p_align, cur_phdr->p_memsz, cur_phdr->p_offset);
}
}
}
Expand All @@ -28,7 +33,7 @@ Elf64_Half loop_phdrs(Elf64_Ehdr* e_hdr, Elf64_Half phdr_entries) {
Elf64_Half number_of_pt_loads = 0;
for (size_t i = 0; i < phdr_entries; i++) {
Elf64_Phdr phdr = phdr_list[i];
pretty_logf(Verbose, "\t[%d]: Type: 0x%x, Flags: 0x%x - Vaddr: 0x%x - aligned: 0x%x ", i, phdr.p_type, phdr.p_flags, phdr.p_vaddr, align_value_to_page(phdr.p_vaddr));
pretty_logf(Verbose, "\t[%d]: Type: 0x%x, Flags: 0x%x - Vaddr: 0x%x - aligned: 0x%x - offset: 0x%x ", i, phdr.p_type, phdr.p_flags, phdr.p_vaddr, align_value_to_page(phdr.p_vaddr), phdr.p_offset);
if ( is_address_aligned(phdr.p_vaddr, PAGE_SIZE_IN_BYTES) ) {
pretty_log(Verbose, "\tThe address is aligned");
} else {
Expand All @@ -39,6 +44,14 @@ Elf64_Half loop_phdrs(Elf64_Ehdr* e_hdr, Elf64_Half phdr_entries) {
return number_of_pt_loads;
}

/**
* This function return the phdr entry at the pdhrd_entry_number provided.
*
*
* @param e_hdr the elf header
* @param phdr_entry_number the entry number we want to read
* @return Elf64_Phdr * the selected P_hdr or NULL if not found.
*/
Elf64_Phdr *read_phdr(Elf64_Ehdr* e_hdr, Elf64_Half phdr_entry_number) {
Elf64_Half phdr_entries = e_hdr->e_phnum;

Expand All @@ -48,7 +61,6 @@ Elf64_Phdr *read_phdr(Elf64_Ehdr* e_hdr, Elf64_Half phdr_entry_number) {
}

return NULL;

}


Expand Down Expand Up @@ -91,3 +103,21 @@ bool parse_section_header(Elf64_Ehdr *elf_start, uint64_t size, executable_loade
}
return false;
}

/**
* This function given an elf p_hdr flag returns the architecture dependent vmm flags
*
*
* @param flags elf flags
* @return architecture dependant flags
*/
uint64_t elf_flags_to_memory_flags(Elf64_Word flags) {
// This function will be movede into the arch dependant code
// Elf flags:
// 1 = Read
// 2 = Write
// 4 = Execute
// They can be mixed.
uint64_t flags_to_return = (flags & 0b10);
return flags_to_return;
}
9 changes: 5 additions & 4 deletions src/kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void _init_basic_system(unsigned long addr){
tag_start = (struct multiboot_tag *) (addr + _HIGHER_HALF_KERNEL_MEM_START + 8);
_mmap_parse(tagmmap);
pmm_setup(addr, mbi_size);
kernel_settings.kernel_uptime = 0;
kernel_settings.kernel_uptime = 0;
kernel_settings.paging.page_root_address = p4_table;
uint64_t p4_table_phys_address = (uint64_t) p4_table - _HIGHER_HALF_KERNEL_MEM_START;
kernel_settings.paging.hhdm_page_root_address = (uint64_t*) hhdm_get_variable( (uintptr_t) p4_table_phys_address);
Expand Down Expand Up @@ -235,7 +235,7 @@ void kernel_start(unsigned long addr, unsigned long magic){
init_apic();
if (loaded_module != NULL) {
if ( load_module_hh(loaded_module) ) {
pretty_log(Verbose, " The ELF module can be loaded succesfully" );
pretty_logf(Verbose, " The ELF module can be loaded succesfully (Phys addr: 0x%x)", loaded_module->mod_start );
elf_module_start_phys = loaded_module->mod_start;
}
}
Expand Down Expand Up @@ -264,9 +264,10 @@ void kernel_start(unsigned long addr, unsigned long magic){
#endif
init_scheduler();
char a = 'a';
task_t* idle_task = create_task("idle", idle, &a, true);
task_t* idle_task = create_task_from_func("idle", idle, &a, true);
idle_thread = idle_task->threads;
task_t* userspace_task = create_task("userspace_idle", NULL, &a, false);
//task_t* userspace_task = create_task_from_func("userspace_idle", NULL, &a, false);
task_t* elf_task = create_task_from_elf("elf_idle", NULL, (Elf64_Ehdr *) (uintptr_t) hhdm_get_variable(elf_module_start_phys));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the purpose of the double cast: (Elf64_Ehdr*)(uintptr_t)?

//create_thread("ledi", noop2, &c, eldi_task);
//create_task("sleeper", noop3, &d);
//execute_runtime_tests();
Expand Down
11 changes: 11 additions & 0 deletions src/kernel/mem/hh_direct_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ void *hhdm_get_variable ( uintptr_t phys_address ) {
return NULL;
}

/**
* This is an helper function return the physical address given a hhdm one
*
*
* @return phys_address the physical address we want to retrieve
* @param hhdm_address of the physical address or NULL in case of error
*/
void *hhdm_get_phys_address(uintptr_t hhdm_address) {
return (void *)(hhdm_address - higherHalfDirectMapBase);
}


void hhdm_map_physical_memory() {
// This function should be called only once, and the hhdm shouldn't change during the kernel uptime
Expand Down
1 change: 0 additions & 1 deletion src/kernel/scheduling/scheduler.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include <framebuffer.h>
#include <scheduler.h>
#include <string.h>
Expand Down
80 changes: 65 additions & 15 deletions src/kernel/scheduling/task.c
Original file line number Diff line number Diff line change
@@ -1,46 +1,97 @@
#include <elf.h>
#include <hh_direct_map.h>
#include <task.h>
#include <scheduler.h>
#include <kernel.h>
#include <kheap.h>
#include <string.h>
#include <logging.h>
#include <vm.h>
#include <kernel.h>
#include <pmm.h>
#include <scheduler.h>
#include <task.h>
#include <string.h>
#include <vmm.h>
#include <vmm_mapping.h>
#include <pmm.h>
#include <vmm_util.h>

extern uint64_t p4_table[];
extern uint64_t p3_table[];
extern uint64_t p3_table_hh[];

task_t* create_task(char *name, void (*_entry_point)(void *), void *args, bool is_supervisor) {
task_t* create_task(char *name, bool is_supervisor) {
//disable interrupts while creating a task
asm("cli");
task_t* new_task = (task_t*) kmalloc(sizeof(task_t));
strcpy(new_task->task_name, name);
new_task->parent = NULL;
new_task->task_id = next_task_id++;
pretty_logf(Verbose, "Task created with name: %s - Task id: %d", new_task->task_name, new_task->task_id);
prepare_virtual_memory_environment(new_task);
//prepare_virtual_memory_environment(new_task);
if ( is_supervisor ){
vmm_init(VMM_LEVEL_SUPERVISOR, &(new_task->vmm_data));
} else {
vmm_init(VMM_LEVEL_USER, &(new_task->vmm_data));
}
if( is_supervisor) {
//scheduler_add_task(new_task);
//re-enable interrupts
return new_task;
}

task_t *create_task_from_elf(char *name, void *args, Elf64_Ehdr *elf_header){
asm("cli");
// I will not create a task from elf if is_supervisor is true.
task_t* new_task = create_task(name, false);
prepare_virtual_memory_environment(new_task);
if(elf_header != NULL) {
//Here i will put the code to handle the case where an Elf is passed.
Elf64_Half phdr_entries = elf_header->e_phnum;
Elf64_Half phdr_entsize = elf_header->e_phentsize;
pretty_logf(Verbose, " Number of PHDR entries: 0x%x", phdr_entries);
pretty_logf(Verbose, " PHDR Entry Size: 0x%x", phdr_entsize );
pretty_logf(Verbose, " ELF Entry point: 0x%x", elf_header->e_entry);
Elf64_Phdr *phdr_list = (Elf64_Phdr*) ((uintptr_t) elf_header + elf_header->e_phoff);
for ( int i = 0; i < phdr_entries; i++) {
// I need first to compute the number of pages required for each phdr
// clear all the memory not used
// compute the entries for each page and insert them into the page tables.
Elf64_Phdr phdr = phdr_list[i];
size_t vmm_hdr_flags = elf_flags_to_memory_flags(phdr.p_type);
pretty_logf(Verbose, "\t[%d]: Type: 0x%x, Flags: 0x%x - Vaddr: 0x%x - aligned: 0x%x ", i, phdr.p_type, phdr.p_flags, phdr.p_vaddr, align_value_to_page(phdr.p_vaddr));
pretty_logf(Verbose, "\t\t - FileSz: 0x%x, Memsz: 0x%x, vmm flags: 0x%x - p_align: 0x%x - p_offset: 0x%x", phdr.p_filesz, phdr.p_memsz, vmm_hdr_flags, phdr.p_align, phdr.p_offset);
Elf64_Half mem_pages = (Elf64_Half) get_number_of_pages_from_size(phdr.p_memsz);
Elf64_Half filesz_pages = (Elf64_Half) get_number_of_pages_from_size(phdr.p_filesz);
uint64_t offset_address = (uint64_t) ((uint64_t) elf_header + (uint64_t) phdr.p_offset);
uint64_t vaddr_address = align_value_to_page(phdr.p_vaddr);
for (int j = 0; j < mem_pages; j++) {
pretty_logf(Verbose, "[%d]: Mapping: offset: 0x%x (virtual: 0x%x) in vaddr: 0x%x", j, hhdm_get_phys_address((uintptr_t) offset_address), offset_address, vaddr_address);
map_phys_to_virt_addr_hh(hhdm_get_phys_address(offset_address), (void *) vaddr_address, VMM_FLAGS_USER_LEVEL | vmm_hdr_flags | VMM_FLAGS_PRESENT, (uint64_t *) new_task->vmm_data.root_table_hhdm);
//I need a mem copy. I need to fopy the content of elf_header + phdr.p_offset into phdr.p_vaddr
offset_address += (uint64_t) phdr.p_align;
vaddr_address += (uint64_t) phdr.p_align;
//I need to allocate memory and map it into the new memory space,
}
}
thread_t* thread = create_thread(name, (void (*)(void *))elf_header->e_entry, args, new_task, false, true);
pretty_logf(Verbose, "Thread created: id: %d - Entry Point: 0x%x - elf header entry point: 0x%x", thread->tid, thread->execution_frame->rip, elf_header->e_entry);
}
// Create a new thread
scheduler_add_task(new_task);
asm("sti");
return new_task;
}

task_t *create_task_from_func(char *name, void (*_entry_point)(void *), void *args, bool is_supervisor) {
asm("cli");
task_t* new_task = create_task(name, is_supervisor);
prepare_virtual_memory_environment(new_task);
if( is_supervisor) {
pretty_logf(Verbose, "creating new supervisor thread: %s", name);
thread_t* thread = create_thread(name, _entry_point, args, new_task, is_supervisor);
thread_t* thread = create_thread(name, _entry_point, args, new_task, is_supervisor, false);
new_task->threads = thread;
} else {
pretty_logf(Verbose, "creating new userspace thread %s", name);
thread_t* thread = create_thread(name, NULL, args, new_task, is_supervisor);
thread_t* thread = create_thread(name, NULL, args, new_task, is_supervisor, false);
new_task->threads = thread;
}
scheduler_add_task(new_task);
//re-enable interrupts
asm("sti");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you enable interrupts unconditionally here, what if they were previously disabled before calling this function? Now the caller thinks they are disabled but in reality they arent. This is a pattern that will be used a lot, so it can be helpful to have something like:

const bool restore_intrs = disable_interrupts(); //returns previous state and ensure interrupts are disabled
[ ... ]
if (restore_intrs)
    enable_interrupts();

return new_task;
}

void prepare_virtual_memory_environment(task_t* task) {
Expand All @@ -51,8 +102,7 @@ void prepare_virtual_memory_environment(task_t* task) {
//pretty_logf(Verbose, "vm_root_page_table address: %x", task->vm_root_page_table);
//identity_map_phys_address(task->vm_root_page_table, 0);
// I will get the page frame first, then get virtual address to map it to with vmm_alloc, and then do the mapping on the virtual address.
// Technically the vmm_alloc is not needed, since i have the direct memory map already accessible, so i just need to access it through the direct map.

// Technically the vmm_alloc is not needed, since i have the direct memory map already accessible, so i just need to access it through the direct m
//void* vm_root_vaddress = vmm_alloc(PAGE_SIZE_IN_BYTES, VMM_FLAGS_ADDRESS_ONLY, NULL);
void* vm_root_vaddress = hhdm_get_variable ((uintptr_t) task->vm_root_page_table);
task->vmm_data.root_table_hhdm = (uintptr_t) vm_root_vaddress;
Expand Down
13 changes: 10 additions & 3 deletions src/kernel/scheduling/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ unsigned char code_to_run[] = {
0xeb, 0xfe
};

thread_t* create_thread(char* thread_name, void (*_entry_point)(void *), void* arg, task_t* parent_task, bool is_supervisor) {
thread_t* create_thread(char* thread_name, void (*_entry_point)(void *), void* arg, task_t* parent_task, bool is_supervisor, bool is_elf) {
// The first part is pretty trivial mostly bureaucray. Setting basic thread information like name, tid, parent...
// Just like when registtering a new born child :D
if ( parent_task == NULL) {
Expand All @@ -30,7 +30,9 @@ thread_t* create_thread(char* thread_name, void (*_entry_point)(void *), void* a
new_thread->next = NULL;
new_thread->next_sibling = NULL;
new_thread->ticks = 0;
pretty_logf(Verbose, "Creating thread with arg: %c - arg: %x - name: %s - rip: %x", (char) *((char*) arg), arg, thread_name, _entry_point);
if (arg != NULL) {
pretty_logf(Verbose, "Creating thread with arg: %c - arg: %x - name: %s - rip: %x", (char) *((char*) arg), arg, thread_name, _entry_point);
}

//Here we create a new execution frame to be used when switching to a newly created task
new_thread->execution_frame = kmalloc(sizeof(cpu_status_t));
Expand All @@ -39,7 +41,12 @@ thread_t* create_thread(char* thread_name, void (*_entry_point)(void *), void* a
if (!is_supervisor) {
// This piece of code is temporary, just to test a userspace task, it run just an infinite loop.
pretty_logf(Verbose, "vmm_data address: 0x%x", &(parent_task->vmm_data));
new_thread->execution_frame->rip = prepare_userspace_function(&(parent_task->vmm_data));
if (is_elf ) {
pretty_logf(Verbose, "Preparing to launch an ELF. entry_pint = 0x%x", (uint64_t) _entry_point);
new_thread->execution_frame->rip = (uint64_t)_entry_point;
} else {
new_thread->execution_frame->rip = prepare_userspace_function(&(parent_task->vmm_data));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the purpose of doing it this way? I feel like you could have prepare_userspace_function called when creating the task for the elf, and then create_thread doesnt need to know if the thread is for an elf or not. You can just tell it what address to begin executing and itll use that. It would also simplify things a bit.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the prepare_userspace_function is/was a temporary function that was basically copying a program (same for the one that now i'm running from ELF) from a char array into a userspace memory space and launch it.

I think this will be removed soon (but i think i'll keep it around until i fix the building of the elf that match the kernel PAGE_SIZE)

Copy link
Owner Author

@dreamos82 dreamos82 Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yeah, that function maybe can be repurposed to prepare the memory space for a new thread being launched from an executable file.

}
pretty_logf(Verbose, "using userspace function address: 0x%x", new_thread->execution_frame->rip);
new_thread->execution_frame->rdi = 0;
new_thread->execution_frame->rsi = 0;
Expand Down
Loading