mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 18:14:53 +00:00
HV: centralize the pci cfg read/write sanity checking code
Do the pci cfg read/write sanity checking before the request is dispatched to submodules, so that the checking is centralized rather than scattered across multiple files/places Tracked-On: #2534 Signed-off-by: dongshen <dongsheng.x.zhang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -50,7 +50,7 @@ void sharing_mode_cfgread(__unused struct acrn_vpci *vpci, union pci_bdf bdf,
|
||||
vdev = sharing_mode_find_vdev_sos(bdf);
|
||||
|
||||
/* vdev == NULL: Could be hit for PCI enumeration from guests */
|
||||
if ((vdev == NULL) || ((bytes != 1U) && (bytes != 2U) && (bytes != 4U))) {
|
||||
if (vdev == NULL) {
|
||||
*val = ~0U;
|
||||
} else {
|
||||
if ((vmsi_cfgread(vdev, offset, bytes, val) != 0)
|
||||
@@ -67,15 +67,13 @@ void sharing_mode_cfgwrite(__unused struct acrn_vpci *vpci, union pci_bdf bdf,
|
||||
{
|
||||
struct pci_vdev *vdev;
|
||||
|
||||
if ((bytes == 1U) || (bytes == 2U) || (bytes == 4U)) {
|
||||
vdev = sharing_mode_find_vdev_sos(bdf);
|
||||
if (vdev != NULL) {
|
||||
if ((vmsi_cfgwrite(vdev, offset, bytes, val) != 0)
|
||||
&& (vmsix_cfgwrite(vdev, offset, bytes, val) != 0)
|
||||
) {
|
||||
/* Not handled by any handlers, passthru to physical device */
|
||||
pci_pdev_write_cfg(vdev->pdev->bdf, offset, bytes, val);
|
||||
}
|
||||
vdev = sharing_mode_find_vdev_sos(bdf);
|
||||
if (vdev != NULL) {
|
||||
if ((vmsi_cfgwrite(vdev, offset, bytes, val) != 0)
|
||||
&& (vmsix_cfgwrite(vdev, offset, bytes, val) != 0)
|
||||
) {
|
||||
/* Not handled by any handlers, passthru to physical device */
|
||||
pci_pdev_write_cfg(vdev->pdev->bdf, offset, bytes, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user