Giter Site home page Giter Site logo

Fixing VMO/VMAR about zcore HOT 9 OPEN

rcore-os avatar rcore-os commented on August 16, 2024
Fixing VMO/VMAR

from zcore.

Comments (9)

wangrunji0408 avatar wangrunji0408 commented on August 16, 2024

And recover a simple version of VMO (#76), even if it will fail many core-tests.

from zcore.

benpigchu avatar benpigchu commented on August 16, 2024

Let's do some simple fixes first.

  • Allocate a child vmar with size larger the parent should be an INVALID_ARGS instead of a NO_MEMORY (see Vmar.AllocateUnsatisfiableTest)
  • We should not check the permission of a mapping in zx_vmar_map, since we can add the permission with zx_vmar_protect later (see Vmar.VmarMapRangeOffsetTest)
  • the actual in zx_process_*_memory should be a pointer to usize
  • You cannot use MAP_RANGE with SPECIFIC_OVERWRITE in zx_vmar_map (see Vmar.InvalidArgsTest)
  • Length in zx_vmar_map cannot be zero (see Vmar.InvalidArgsTest)
  • Invalid bits in zx_vm_option_t should be rejected

from zcore.

benpigchu avatar benpigchu commented on August 16, 2024

We somehow handles permission of a VmMapping incorrectly. We should storage a limitation of permission in the VmMapping, and allowing increasing premission with zx_vmar_protect .

from zcore.

benpigchu avatar benpigchu commented on August 16, 2024

zx_vmar_protect is actually doing nothing. I attempted to fix it but since it do not support partially protect a VmMapping it will break at startup.
Maybe we should store flags of each pages in the VmMapping?

from zcore.

benpigchu avatar benpigchu commented on August 16, 2024

Currently there is a workaround in VmAddressRegion::new_root to separate address space of different processes. We do not need this in qemu since we have the real page table, so we should remove this workaround on qemu.

from zcore.

benpigchu avatar benpigchu commented on August 16, 2024

Another easy fix: vmar.*_memory should limit length with map size
Also, we should add support to multiple mappings.
Should we use a unified lock in vmar instead to avoid race condition when read/write memory?

from zcore.

benpigchu avatar benpigchu commented on August 16, 2024

zx_vmar_protect somehow works now when I modified how the flags of each page storaged.
The next thing could be implement the ZX_VM_MAP_RANGE flag

from zcore.

benpigchu avatar benpigchu commented on August 16, 2024

It seems the content of the vmo is not correct if we do not always map the vmo in the page table(!)

See core-test VmoClone2TestCase.ManyCloneMappingOffset

The first issue is: we should not map the page as writable when we page fault when reading the page, otherwise we will breaks the copy-on-write semantic.
The second issue is: after a vmo.write call, the correct page to map should be changed. However, if we need to update page table when commiting the page, we get a deadlock when mapping the pages. But fortunately, If we are updating the page table, we do not need to update it with vmo, so it should be OK to just use try_lock instead of lock.

from zcore.

benpigchu avatar benpigchu commented on August 16, 2024

It should be possible to commit the page in vmo when we are copying things to user space! (See core-test VmoTestCase.MapRead etc.)
We need #146 to solve this problem
Another thing: VmoTestCase.ZeroPage encounter page fault forever since the 0x8 bit is set in the error_code
Another thing: vmo contiguous may breaks

from zcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.