Skip to content

Commit

Permalink
Merge pull request rcore-os#174 from benpigchu/vmo
Browse files Browse the repository at this point in the history
Various vmo/vmar fixes, Part 1
  • Loading branch information
benpigchu authored Nov 11, 2020
2 parents 2aac624 + ba6fea4 commit d60dcbc
Show file tree
Hide file tree
Showing 16 changed files with 373 additions and 195 deletions.
4 changes: 4 additions & 0 deletions kernel-hal-bare/src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ impl PageTableTrait for PageTableImpl {
flush.flush();
trace!("unmap: {:x?} in {:#x?}", vaddr, self.root_paddr);
}
Err(mapper::UnmapError::PageNotMapped) => {
trace!("unmap not mapped, skip: {:x?} in {:#x?}", vaddr, self.root_paddr);
return Ok(())
}
Err(err) => {
debug!(
"unmap failed: {:x?} err={:x?} in {:#x?}",
Expand Down
1 change: 1 addition & 0 deletions kernel-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod defs {
const WRITE = 1 << 3;
const EXECUTE = 1 << 4;
const USER = 1 << 5;
const RXW = Self::READ.bits | Self::WRITE.bits | Self::EXECUTE.bits;
}
}
numeric_enum! {
Expand Down
2 changes: 1 addition & 1 deletion linux-loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ async-std = { version = "1.6", features = ["attributes"], optional = true }

[features]
default = ["std"]
std = ["env_logger", "async-std", "kernel-hal-unix", "rcore-fs-hostfs"]
std = ["env_logger", "async-std", "kernel-hal-unix", "rcore-fs-hostfs", "zircon-object/aspace-separate"]
2 changes: 1 addition & 1 deletion scripts/core-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def flush(self):
lines = f.readlines()
positive = [line for line in lines if not line.startswith('-')]
negative = [line[1:] for line in lines if line.startswith('-')]
test_filter = (','.join(positive) + (('-' + ','.join(negative) if len(negative) > 0 else "") )).replace('\n', '')
test_filter = (','.join(positive) + ((',-' + ','.join(negative) if len(negative) > 0 else "") )).replace('\n', '')

child = pexpect.spawn("make -C %s test mode=release test_filter='%s'" % (ZCORE_PATH, test_filter),
timeout=TIMEOUT, encoding='utf-8')
Expand Down
1 change: 1 addition & 0 deletions scripts/linux/test-allow-failed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
/libc-test/src/functional/pthread_robust.exe
/libc-test/src/math/powf.exe
/libc-test/src/math/fmal.exe
/libc-test/src/math/modfl.exe
/libc-test/src/regression/pthread_cond_wait-cancel_ignored.exe
/libc-test/src/regression/raise-race.exe
/libc-test/src/regression/pthread_once-deadlock.exe
Expand Down
21 changes: 17 additions & 4 deletions scripts/zircon/test-check-passed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ HandleWaitTest.HandleWaitMultipleThreads
MemoryMappingTest.MmapZerofilledTest
MemoryMappingTest.MmapLenTest
MemoryMappingTest.MmapOffsetTest
MemoryMappingTest.MmapProtExecTest
MemoryMappingTest.MmapFlagsTest
ObjectChildTest.InvalidHandleReturnsBadHandle
ObjectGetInfoTest.OpenValidHandleSuceeds
Expand Down Expand Up @@ -364,9 +363,25 @@ Vmar.DestroyTest
Vmar.BasicAllocateTest
Vmar.MapInCompactTest
Vmar.AllocateOobTest
Vmar.AllocateUnsatisfiableTest
Vmar.DestroyedVmarTest
Vmar.VmarMapRangeOffsetTest
Vmar.UnalignedLenTest
Vmar.UnalignedLenMapTest
Vmar.RightsDropTest
Vmar.ProtectTest
Vmar.VmarMapRangeOffsetTest
Vmar.ObjectInfoTest
Vmar.UnmapSplitTest
Vmar.UnmapMultipleTest
Vmar.UnmapBaseNotMappedTest
Vmar.ProtectSplitTest
Vmar.ProtectMultipleTest
Vmar.PartialUnmapAndRead
Vmar.PartialUnmapAndWrite
Vmar.PartialUnmapWithVmarOffset
Vmar.AllowFaultsTest
Vmar.ConcurrentUnmapReadMemory
VmoCloneTestCase.SizeAlign
VmoCloneTestCase.NameProperty
VmoCloneTestCase.Decommit
Expand Down Expand Up @@ -401,6 +416,7 @@ VmoClone2TestCase.ManyChildren
VmoClone2TestCase.ManyChildrenRevClose
VmoClone2TestCase.ManyCloneMapping
VmoClone2TestCase.ManyCloneOffset
VmoClone2TestCase.ManyCloneMappingOffset
VmoClone2TestCase.ForbidContiguousVmo
VmoClone2TestCase.PinBeforeCreateFailure
VmoClone2TestCase.Uncached
Expand Down Expand Up @@ -447,13 +463,10 @@ VmoTestCase.Create
VmoTestCase.ReadWriteBadLen
VmoTestCase.ReadWriteRange
VmoTestCase.Map
VmoTestCase.MapRead
VmoTestCase.ParallelRead
VmoTestCase.Resize
VmoTestCase.NoResize
VmoTestCase.SizeAlign
VmoTestCase.ResizeAlign
VmoTestCase.ZeroPage
VmoTestCase.UncachedContiguous
Bti.Create
Bti.Pin
Expand Down
10 changes: 10 additions & 0 deletions scripts/zircon/testcases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,24 @@
-Vmar.NestedRegionPermsTest
-Vmar.MapSpecificOverwriteTest
-Vmar.MapOverDestroyedTest
-MemoryMappingTest.MprotectTest
-MemoryMappingTest.MmapProtExecTest
-MemoryMappingTest.MmapProtTest
-VmoTestCase.ReadOnlyMap
-VmoTestCase.MapRead
-VmoTestCase.ParallelRead
-VmoTestCase.NoPermMap
-VmoTestCase.NoPermProtect
-VmoTestCase.Commit
-VmoTestCase.CacheOp
-VmoTestCase.ResizeHazard
-VmoTestCase.Cache*
-VmoTestCase.ZeroPage
-VmoTestCase.PinTests
-VmoCloneTestCase.Commit
-VmoClone2TestCase.PinClonePages
-SocketTest.ReadIntoBadBuffer
-SocketTest.WriteFromBadBuffer
-VersionTest.*
-BadAccessTest.*
-InterruptTest.BindTriggeredIrqToPort
Expand Down
2 changes: 1 addition & 1 deletion zircon-loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ async-std = { version = "1.6", features = ["attributes"], optional = true }

[features]
default = ["std"]
std = ["env_logger", "structopt", "async-std", "kernel-hal-unix"]
std = ["env_logger", "structopt", "async-std", "kernel-hal-unix", "zircon-object/aspace-separate"]
29 changes: 22 additions & 7 deletions zircon-loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,30 @@ async fn new_thread(thread: CurrentThread) {
}
0xe => {
EXCEPTIONS_PGFAULT.add(1);
let flags = if error_code & 0x2 == 0 {
MMUFlags::READ
} else {
MMUFlags::WRITE
};
let mut flags = MMUFlags::empty();
if error_code & 0x01 != 0 {
flags.insert(MMUFlags::READ)
}
if error_code & 0x02 != 0 {
flags.insert(MMUFlags::WRITE)
}
if error_code & 0x04 != 0 {
flags.insert(MMUFlags::USER)
}
if error_code & 0x08 != 0 {
warn!("page table entry has reserved bits set!")
}
if error_code & 0x10 != 0 {
flags.insert(MMUFlags::EXECUTE)
}
let fault_vaddr = kernel_hal::fetch_fault_vaddr();
info!("page fault from user mode {:#x} {:#x?}", fault_vaddr, flags);
info!(
"page fault from user mode {:#x} {:#x?} {:?}",
fault_vaddr, error_code, flags
);
let vmar = thread.proc().vmar();
if vmar.handle_page_fault(fault_vaddr, flags).is_err() {
if let Err(err) = vmar.handle_page_fault(fault_vaddr, flags) {
error!("handle_page_fault error: {:?}", err);
thread.handle_exception(ExceptionType::FatalPageFault).await;
}
}
Expand Down
1 change: 1 addition & 0 deletions zircon-object/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description = "Zircon kernel objects"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
aspace-separate=[]
elf = ["xmas-elf"]
hypervisor = ["rvm"]

Expand Down
2 changes: 1 addition & 1 deletion zircon-object/src/hypervisor/guest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl GuestPhysMemorySetTrait for GuestPhysMemorySet {
fn handle_page_fault(&self, gpaddr: GuestPhysAddr) -> RvmResult {
if let Some(mapping) = self.vmar.find_mapping(gpaddr) {
mapping
.handle_page_fault(gpaddr, mapping.get_flags())
.handle_page_fault(gpaddr, mapping.get_flags(gpaddr).unwrap())
.map_err(From::from)
} else {
Err(RvmError::NotFound)
Expand Down
Loading

0 comments on commit d60dcbc

Please sign in to comment.