fn read_config(&self, offset: usize, data: &mut [u8]) {
        let size = data.len();
        let end = offset + size;
        if end > (self.config_size as usize) || size > 4 {
            error!(
                "Failed to read pci config space at offset {} with data size {}",
                offset, size
            );
            return;
        }

        // BAR and header_type are always controlled by StratoVirt.
        if ranges_overlap(offset, end, BAR_0 as usize, (BAR_5 as usize) + REG_SIZE)
            || ranges_overlap(
                offset,
                end,
                HEADER_TYPE as usize,
                (HEADER_TYPE as usize) + 2,
            )
        {
            self.pci_config.read(offset, data);
            return;
        }

        if let Err(e) = self
            .vfio_device
            .read_region(data, self.config_offset, offset as u64)
        {
            error!("Failed to read device pci config, error is {}", e);
            return;
        }
        for (i, data) in data.iter_mut().enumerate().take(size) {
            if i + offset == 0x3d {
                // Clear INIx
                *data &= 0;
            }
        }
    }
/// Read pci data from pci config if it emulate, otherwise read from vfio device.
Read pci data from pci config if it emulate, otherwise read from vfio device.
Read pci data from pci config if it emulate otherwise read from vfio device .
fn read_config(&self, offset: usize, data: &mut [u8]) {
        let size = data.len();
        let end = offset + size;
        if end > (self.config_size as usize) || size > 4 {
            error!(
                "Failed to read pci config space at offset {} with data size {}",
                offset, size
            );
            return;
        }
        // BAR and header_type are always controlled by StratoVirt.
        if ranges_overlap(offset, end, BAR_0 as usize, (BAR_5 as usize) + REG_SIZE)
            || ranges_overlap(
                offset,
                end,
                HEADER_TYPE as usize,
                (HEADER_TYPE as usize) + 2,
            )
        {
            self.pci_config.read(offset, data);
            return;
        }
        if let Err(e) = self
            .vfio_device
            .read_region(data, self.config_offset, offset as u64)
        {
            error!("Failed to read device pci config, error is {}", e);
            return;
        }
        for (i, data) in data.iter_mut().enumerate().take(size) {
            if i + offset == 0x3d {
                // Clear INIx
                *data &= 0;
            }
        }
    }
fn read_config ( & self , offset : usize , data : & mut [ u8 ] ) { let size = data . len ( ) ; let end = offset + size ; if end > ( self . config_size as usize ) || size > 4 { error ! ( " " offset size ) ; return ; } // BAR and header_type are always controlled by StratoVirt. if ranges_overlap ( offset , end , BAR_0 as usize , ( BAR_5 as usize ) + REG_SIZE ) || ranges_overlap ( offset , end , HEADER_TYPE as usize , ( HEADER_TYPE as usize ) + 2 , ) { self . pci_config . read ( offset , data ) ; return ; } if let Err ( e ) = self . vfio_device . read_region ( data , self . config_offset , offset as u64 ) { error ! ( " " e ) ; return ; } for ( i , data ) in data . iter_mut ( ) . enumerate ( ) . take ( size ) { if i + offset == 0x3d { // Clear INIx * data &= 0 ; } } }
Read pci data from pci config if it emulate, otherwise read from vfio device.
Read pci data from pci config if it emulate otherwise read from vfio device .
&self
offset
usize
data
&mut [u8]
&self
offset
usize
data
&mut [u8]