pub(crate) fn handle_page_fault(&self, vaddr: VirtAddr, access_flags: MMUFlags) -> ZxResult {
        let vaddr = round_down_pages(vaddr);
        let (vmo_offset, mut flags) = {
            let inner = self.inner.lock();
            let offset = vaddr - inner.addr;
            (offset + inner.vmo_offset, inner.flags[offset / PAGE_SIZE])
        };
        if !flags.contains(access_flags) {
            return Err(ZxError::ACCESS_DENIED);
        }
        if !access_flags.contains(MMUFlags::WRITE) {
            // 注意一下!
            warn!("handle_page_fault remove MMUFlags::WRITE !");
            flags.remove(MMUFlags::WRITE)
        }
        let paddr = self.vmo.commit_page(vmo_offset / PAGE_SIZE, access_flags)?;
        let mut pg_table = self.page_table.lock();
        let mut res = pg_table.map(Page::new_aligned(vaddr, PageSize::Size4K), paddr, flags);
        if let Err(PagingError::AlreadyMapped) = res {
            res = pg_table.update(vaddr, Some(paddr), Some(flags)).map(|_| ());
        }
        res.map_err(|_| ZxError::ACCESS_DENIED)?;
        Ok(())
    }
/// Handle page fault happened on this VmMapping.
Handle page fault happened on this VmMapping.
Handle page fault happened on this VmMapping .
pub(crate) fn handle_page_fault(&self, vaddr: VirtAddr, access_flags: MMUFlags) -> ZxResult {
        let vaddr = round_down_pages(vaddr);
        let (vmo_offset, mut flags) = {
            let inner = self.inner.lock();
            let offset = vaddr - inner.addr;
            (offset + inner.vmo_offset, inner.flags[offset / PAGE_SIZE])
        };
        if !flags.contains(access_flags) {
            return Err(ZxError::ACCESS_DENIED);
        }
        if !access_flags.contains(MMUFlags::WRITE) {
            // 注意一下!
            warn!("handle_page_fault remove MMUFlags::WRITE !");
            flags.remove(MMUFlags::WRITE)
        }
        let paddr = self.vmo.commit_page(vmo_offset / PAGE_SIZE, access_flags)?;
        let mut pg_table = self.page_table.lock();
        let mut res = pg_table.map(Page::new_aligned(vaddr, PageSize::Size4K), paddr, flags);
        if let Err(PagingError::AlreadyMapped) = res {
            res = pg_table.update(vaddr, Some(paddr), Some(flags)).map(|_| ());
        }
        res.map_err(|_| ZxError::ACCESS_DENIED)?;
        Ok(())
    }
pub ( crate ) fn handle_page_fault ( & self , vaddr : VirtAddr , access_flags : MMUFlags ) -> ZxResult { let vaddr = round_down_pages ( vaddr ) ; let ( vmo_offset , mut flags ) = { let inner = self . inner . lock ( ) ; let offset = vaddr - inner . addr ; ( offset + inner . vmo_offset , inner . flags [ offset / PAGE_SIZE ] ) } ; if ! flags . contains ( access_flags ) { return Err ( ZxError :: ACCESS_DENIED ) ; } if ! access_flags . contains ( MMUFlags :: WRITE ) { // 注意一下! warn ! ( " " ) ; flags . remove ( MMUFlags :: WRITE ) } let paddr = self . vmo . commit_page ( vmo_offset / PAGE_SIZE , access_flags ) ? ; let mut pg_table = self . page_table . lock ( ) ; let mut res = pg_table . map ( Page :: new_aligned ( vaddr , PageSize :: Size4K ) , paddr , flags ) ; if let Err ( PagingError :: AlreadyMapped ) = res { res = pg_table . update ( vaddr , Some ( paddr ) , Some ( flags ) ) . map ( | _ | ( ) ) ; } res . map_err ( | _ | ZxError :: ACCESS_DENIED ) ? ; Ok ( ( ) ) }
Handle page fault happened on this VmMapping.
Handle page fault happened on this VmMapping .
&self
vaddr
VirtAddr
access_flags
MMUFlags
&self
vaddr
VirtAddr
access_flags
MMUFlags