fn user_virt_addr_valid(pid: Pid, base: u64, size: u64) -> Result<(u64, u64), KError> {
    let mut base = base;
    let upper_addr = base + size;

    if upper_addr < KERNEL_BASE {
        while base <= upper_addr {
            // Validate addresses for the buffer end.
            if upper_addr - base <= BASE_PAGE_SIZE as u64 {
                let _r = nrproc::NrProcess::<Ring3Process>::resolve(pid, VAddr::from(base))?;
                return nrproc::NrProcess::<Ring3Process>::resolve(
                    pid,
                    VAddr::from(upper_addr - 1),
                );
            }

            let _r = nrproc::NrProcess::<Ring3Process>::resolve(pid, VAddr::from(base))?;
            base += BASE_PAGE_SIZE as u64;
        }
        return Ok((base, size));
    }
    Err(KError::BadAddress)
}
/// TODO: This method makes file-operations slow, improve it to use large page
/// sizes. Or maintain a list of (low, high) memory limits per process and check
/// if (base, size) are within the process memory limits.
This method makes file-operations slow, improve it to use large page
sizes. Or maintain a list of (low, high) memory limits per process and check
if (base, size) are within the process memory limits.
This method makes file - operations slow improve it to use large page sizes . Or maintain a list of ( low high ) memory limits per process and check if ( base size ) are within the process memory limits .
fn user_virt_addr_valid(pid: Pid, base: u64, size: u64) -> Result<(u64, u64), KError> {
    let mut base = base;
    let upper_addr = base + size;
    if upper_addr < KERNEL_BASE {
        while base <= upper_addr {
            // Validate addresses for the buffer end.
            if upper_addr - base <= BASE_PAGE_SIZE as u64 {
                let _r = nrproc::NrProcess::<Ring3Process>::resolve(pid, VAddr::from(base))?;
                return nrproc::NrProcess::<Ring3Process>::resolve(
                    pid,
                    VAddr::from(upper_addr - 1),
                );
            }
            let _r = nrproc::NrProcess::<Ring3Process>::resolve(pid, VAddr::from(base))?;
            base += BASE_PAGE_SIZE as u64;
        }
        return Ok((base, size));
    }
    Err(KError::BadAddress)
}
fn user_virt_addr_valid ( pid : Pid , base : u64 , size : u64 ) -> Result < ( u64 , u64 ) , KError > { let mut base = base ; let upper_addr = base + size ; if upper_addr < KERNEL_BASE { while base <= upper_addr { // Validate addresses for the buffer end. if upper_addr - base <= BASE_PAGE_SIZE as u64 { let _r = nrproc :: NrProcess :: < Ring3Process > :: resolve ( pid , VAddr :: from ( base ) ) ? ; return nrproc :: NrProcess :: < Ring3Process > :: resolve ( pid , VAddr :: from ( upper_addr - 1 ) , ) ; } let _r = nrproc :: NrProcess :: < Ring3Process > :: resolve ( pid , VAddr :: from ( base ) ) ? ; base += BASE_PAGE_SIZE as u64 ; } return Ok ( ( base , size ) ) ; } Err ( KError :: BadAddress ) }
TODO: This method makes file-operations slow, improve it to use large page
sizes.
TODO : This method makes file - operations slow improve it to use large page sizes .
pid
Pid
base
u64
size
u64
pid
Pid
base
u64
size
u64