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

提供的代码疑似存在bug #15

Open
zzjrabbit opened this issue Oct 2, 2024 · 0 comments
Open

提供的代码疑似存在bug #15

zzjrabbit opened this issue Oct 2, 2024 · 0 comments

Comments

@zzjrabbit
Copy link

我抄过来了第四章第三节的代码,但是在我试图运行的时候发现,在加载userboot时,使用allocate从root VMAR中分配了一块子VMAR,但是其立即把这一块区域放进了子VMAR的inner中,导致在map时通不过test_map检查

// vmar.rs
pub fn allocate(    
        self: &Arc<Self>,
        offset: Option<usize>,
        len: usize,
        flags: VmarFlags,
        align: usize,
    ) -> RcResult<Arc<Self>> {
        let mut guard = self.inner.lock();
        let inner = guard.as_mut().ok_or(RcError::BAD_STATE)?;
        let offset = self.determine_offset(inner, offset, len, align)?;
        let child = Arc::new(VmAddressRegion {
            flags,
            base: KObjectBase::default(),
            addr: self.addr + offset,
            size: len,
            parent: Some(self.clone()),
            page_table: self.page_table.clone(),
            inner: Mutex::new(Some(VmarInner::default())),
        });
        inner.children.push(child.clone());
        Ok(child)
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant