mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
pci: Keep detect_bar_reprogramming internal to PciConfiguration
A BAR reprogramming of a PCI device will only happen when the (guest) kernel write to its PCI config space, e.g. the detection of bar reprogramming (`detect_bar_repgraomming()`) can be embedded to the PCI config space write (`write_config_register()`). It simplifies APIs exposed by the `struct PciConfiguration` and `trait PciDevice`. It also prepares for easier handling of pending bar reprogramming when the MSE bit of the COMMAND register is not enabled at the time of changing BAR registers. See: https://github.com/cloud-hypervisor/cloud-hypervisor/issues/7027#issuecomment-2853642959 Signed-off-by: Bo Chen <bchen@crusoe.ai>
This commit is contained in:
@@ -912,7 +912,7 @@ impl PciDevice for VirtioPciDevice {
|
||||
reg_idx: usize,
|
||||
offset: u64,
|
||||
data: &[u8],
|
||||
) -> Option<Arc<Barrier>> {
|
||||
) -> (Option<BarReprogrammingParams>, Option<Arc<Barrier>>) {
|
||||
// Handle the special case where the capability VIRTIO_PCI_CAP_PCI_CFG
|
||||
// is accessed. This capability has a special meaning as it allows the
|
||||
// guest to access other capabilities without mapping the PCI BAR.
|
||||
@@ -922,11 +922,13 @@ impl PciDevice for VirtioPciDevice {
|
||||
<= self.cap_pci_cfg_info.offset + self.cap_pci_cfg_info.cap.bytes().len()
|
||||
{
|
||||
let offset = base + offset as usize - self.cap_pci_cfg_info.offset;
|
||||
self.write_cap_pci_cfg(offset, data)
|
||||
(None, self.write_cap_pci_cfg(offset, data))
|
||||
} else {
|
||||
self.configuration
|
||||
.write_config_register(reg_idx, offset, data);
|
||||
None
|
||||
(
|
||||
self.configuration
|
||||
.write_config_register(reg_idx, offset, data),
|
||||
None,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,14 +949,6 @@ impl PciDevice for VirtioPciDevice {
|
||||
}
|
||||
}
|
||||
|
||||
fn detect_bar_reprogramming(
|
||||
&mut self,
|
||||
reg_idx: usize,
|
||||
data: &[u8],
|
||||
) -> Option<BarReprogrammingParams> {
|
||||
self.configuration.detect_bar_reprogramming(reg_idx, data)
|
||||
}
|
||||
|
||||
fn allocate_bars(
|
||||
&mut self,
|
||||
_allocator: &Arc<Mutex<SystemAllocator>>,
|
||||
|
||||
Reference in New Issue
Block a user