Retire incomplete features

This commit is contained in:
Ruihan Li 2025-05-01 23:30:37 +08:00 committed by Tate, Hongliang Tian
parent 54bd64269b
commit 7de9666e65
5 changed files with 19 additions and 48 deletions

View File

@ -6,7 +6,6 @@
#![no_std] #![no_std]
#![no_main] #![no_main]
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![expect(incomplete_features)]
#![feature(btree_cursors)] #![feature(btree_cursors)]
#![feature(btree_extract_if)] #![feature(btree_extract_if)]
#![feature(debug_closure_helpers)] #![feature(debug_closure_helpers)]
@ -22,10 +21,6 @@
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(panic_can_unwind)] #![feature(panic_can_unwind)]
#![feature(register_tool)] #![feature(register_tool)]
// FIXME: This feature is used to support vm capbility now as a work around.
// Since this is an incomplete feature, use this feature is unsafe.
// We should find a proper method to replace this feature with min_specialization, which is a sound feature.
#![feature(specialization)]
#![feature(step_trait)] #![feature(step_trait)]
#![feature(trait_alias)] #![feature(trait_alias)]
#![feature(trait_upcasting)] #![feature(trait_upcasting)]

View File

@ -109,7 +109,7 @@ impl Vmar<Rights> {
/// # Access rights /// # Access rights
/// ///
/// The method requires the Read right. /// The method requires the Read right.
pub fn fork_from(vmar: &Vmar) -> Result<Self> { pub fn fork_from(vmar: &Self) -> Result<Self> {
vmar.check_rights(Rights::READ)?; vmar.check_rights(Rights::READ)?;
let vmar_ = vmar.0.new_fork_root()?; let vmar_ = vmar.0.new_fork_root()?;
Ok(Vmar(vmar_, Rights::all())) Ok(Vmar(vmar_, Rights::all()))

View File

@ -17,7 +17,6 @@ use self::{
interval_set::{Interval, IntervalSet}, interval_set::{Interval, IntervalSet},
vm_mapping::{MappedVmo, VmMapping}, vm_mapping::{MappedVmo, VmMapping},
}; };
use super::page_fault_handler::PageFaultHandler;
use crate::{ use crate::{
prelude::*, prelude::*,
process::{Process, ResourceType}, process::{Process, ResourceType},
@ -50,8 +49,15 @@ pub struct Vmar<R = Rights>(Arc<Vmar_>, R);
pub trait VmarRightsOp { pub trait VmarRightsOp {
/// Returns the access rights. /// Returns the access rights.
fn rights(&self) -> Rights; fn rights(&self) -> Rights;
/// Checks whether current rights meet the input `rights`. /// Checks whether current rights meet the input `rights`.
fn check_rights(&self, rights: Rights) -> Result<()>; fn check_rights(&self, rights: Rights) -> Result<()> {
if self.rights().contains(rights) {
Ok(())
} else {
return_errno_with_message!(Errno::EACCES, "VMAR rights are insufficient");
}
}
} }
impl<R> PartialEq for Vmar<R> { impl<R> PartialEq for Vmar<R> {
@ -60,26 +66,6 @@ impl<R> PartialEq for Vmar<R> {
} }
} }
impl<R> VmarRightsOp for Vmar<R> {
default fn rights(&self) -> Rights {
unimplemented!()
}
default fn check_rights(&self, rights: Rights) -> Result<()> {
if self.rights().contains(rights) {
Ok(())
} else {
return_errno_with_message!(Errno::EACCES, "Rights check failed");
}
}
}
impl<R> PageFaultHandler for Vmar<R> {
default fn handle_page_fault(&self, _page_fault_info: &PageFaultInfo) -> Result<()> {
unimplemented!()
}
}
impl<R> Vmar<R> { impl<R> Vmar<R> {
/// FIXME: This function should require access control /// FIXME: This function should require access control
pub fn vm_space(&self) -> &Arc<VmSpace> { pub fn vm_space(&self) -> &Arc<VmSpace> {
@ -608,7 +594,12 @@ impl<'a, R1, R2> VmarMapOptions<'a, R1, R2> {
self.handle_page_faults_around = true; self.handle_page_faults_around = true;
self self
} }
}
impl<'a, R1, R2> VmarMapOptions<'a, R1, R2>
where
Vmo<R2>: VmoRightsOp,
{
/// Creates the mapping and adds it to the parent VMAR. /// Creates the mapping and adds it to the parent VMAR.
/// ///
/// All options will be checked at this point. /// All options will be checked at this point.

View File

@ -2,7 +2,7 @@
use core::ops::Range; use core::ops::Range;
use aster_rights::{Dup, Rights, TRightSet, TRights, Write}; use aster_rights::{Dup, Read, Rights, TRightSet, TRights, Write};
use aster_rights_proc::require; use aster_rights_proc::require;
use super::{VmPerms, Vmar, VmarMapOptions, VmarRightsOp, Vmar_}; use super::{VmPerms, Vmar, VmarMapOptions, VmarRightsOp, Vmar_};
@ -120,8 +120,8 @@ impl<R: TRights> Vmar<TRightSet<R>> {
/// # Access rights /// # Access rights
/// ///
/// The method requires the Read right. /// The method requires the Read right.
pub fn fork_from<R1>(vmar: &Vmar<R1>) -> Result<Self> { #[require(R > Read)]
vmar.check_rights(Rights::READ)?; pub fn fork_from(vmar: &Self) -> Result<Self> {
let vmar_ = vmar.0.new_fork_root()?; let vmar_ = vmar.0.new_fork_root()?;
Ok(Vmar(vmar_, TRightSet(R::new()))) Ok(Vmar(vmar_, TRightSet(R::new())))
} }

View File

@ -82,12 +82,12 @@ pub trait VmoRightsOp {
/// Returns the access rights. /// Returns the access rights.
fn rights(&self) -> Rights; fn rights(&self) -> Rights;
/// Check whether rights is included in self /// Checks whether current rights meet the input `rights`.
fn check_rights(&self, rights: Rights) -> Result<()> { fn check_rights(&self, rights: Rights) -> Result<()> {
if self.rights().contains(rights) { if self.rights().contains(rights) {
Ok(()) Ok(())
} else { } else {
return_errno_with_message!(Errno::EINVAL, "vmo rights check failed"); return_errno_with_message!(Errno::EACCES, "VMO rights are insufficient");
} }
} }
@ -97,21 +97,6 @@ pub trait VmoRightsOp {
Self: Sized; Self: Sized;
} }
// We implement this trait for VMO, so we can use functions on type like Vmo<R> without trait bounds.
// FIXME: This requires the incomplete feature specialization, which should be fixed further.
impl<R> VmoRightsOp for Vmo<R> {
default fn rights(&self) -> Rights {
unimplemented!()
}
default fn to_dyn(self) -> Vmo<Rights>
where
Self: Sized,
{
unimplemented!()
}
}
bitflags! { bitflags! {
/// VMO flags. /// VMO flags.
pub struct VmoFlags: u32 { pub struct VmoFlags: u32 {