Flush TLB correctly when remapping
Seperate mouse and keyboard structs in PS/2 driver
This commit is contained in:
parent
44e8b99b46
commit
8563961f28
8 changed files with 169 additions and 112 deletions
|
@ -13,7 +13,6 @@ use goblin::elf64::{header, program_header};
|
|||
use arch::externs::{memcpy, memset};
|
||||
use arch::paging::{entry, ActivePageTable, Page, VirtualAddress};
|
||||
use arch::start::usermode;
|
||||
use arch::x86::tlb;
|
||||
|
||||
/// An ELF executable
|
||||
pub struct Elf<'a> {
|
||||
|
@ -63,11 +62,9 @@ impl<'a> Elf<'a> {
|
|||
for page in Page::range_inclusive(start_page, end_page) {
|
||||
active_table.map(page, entry::NO_EXECUTE | entry::WRITABLE);
|
||||
}
|
||||
active_table.flush_all();
|
||||
|
||||
unsafe {
|
||||
// Update the page table
|
||||
tlb::flush_all();
|
||||
|
||||
// Copy file data
|
||||
memcpy(segment.p_vaddr as *mut u8,
|
||||
(self.data.as_ptr() as usize + segment.p_offset as usize) as *const u8,
|
||||
|
@ -94,26 +91,20 @@ impl<'a> Elf<'a> {
|
|||
for page in Page::range_inclusive(start_page, end_page) {
|
||||
active_table.remap(page, flags);
|
||||
}
|
||||
|
||||
unsafe {
|
||||
// Update the page table
|
||||
tlb::flush_all();
|
||||
}
|
||||
active_table.flush_all();
|
||||
}
|
||||
}
|
||||
|
||||
// Map stack
|
||||
let start_page = Page::containing_address(VirtualAddress::new(0x80000000));
|
||||
let end_page = Page::containing_address(VirtualAddress::new(0x80000000 + 64*1024 - 1));
|
||||
|
||||
for page in Page::range_inclusive(start_page, end_page) {
|
||||
active_table.map(page, entry::NO_EXECUTE | entry::WRITABLE | entry::USER_ACCESSIBLE);
|
||||
}
|
||||
active_table.flush_all();
|
||||
|
||||
unsafe {
|
||||
// Map stack
|
||||
let start_page = Page::containing_address(VirtualAddress::new(0x80000000));
|
||||
let end_page = Page::containing_address(VirtualAddress::new(0x80000000 + 64*1024 - 1));
|
||||
|
||||
for page in Page::range_inclusive(start_page, end_page) {
|
||||
active_table.map(page, entry::NO_EXECUTE | entry::WRITABLE | entry::USER_ACCESSIBLE);
|
||||
}
|
||||
|
||||
// Update the page table
|
||||
tlb::flush_all();
|
||||
|
||||
// Clear stack
|
||||
memset(0x80000000 as *mut u8, 0, 64 * 1024);
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ pub fn brk(address: usize) -> Result<usize> {
|
|||
if active_table.translate_page(page).is_none() {
|
||||
//println!("Not found - mapping");
|
||||
active_table.map(page, entry::PRESENT | entry::WRITABLE | entry::NO_EXECUTE | entry::USER_ACCESSIBLE);
|
||||
active_table.flush(page);
|
||||
} else {
|
||||
//println!("Found - skipping");
|
||||
}
|
||||
|
@ -49,6 +50,7 @@ pub fn brk(address: usize) -> Result<usize> {
|
|||
if active_table.translate_page(page).is_some() {
|
||||
//println!("Found - unmapping");
|
||||
active_table.unmap(page);
|
||||
active_table.flush(page);
|
||||
} else {
|
||||
//println!("Not found - skipping");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue