From 0a515ab2ea2813b5d590c382145896a68b281a48 Mon Sep 17 00:00:00 2001 From: Fei Li Date: Thu, 9 Sep 2021 16:40:56 +0800 Subject: [PATCH] hv: pci: fix a minor bug about is_pci_cfg_multifunction Before checking whether a PCI device is a Multi-Function Device or not, we need make sure this PCI device is a valid PCI device. For a valid PCI device, the 'Header Layout' field in Header Type Register must be 000 0000b (Type 0 PCI device) or 000 0001b (Type 1 PCI device). So for a valid PCI device, the Header Type can't be 0xff. Tracked-On: #4134 Signed-off-by: Fei Li Acked-by: Eddie Dong --- hypervisor/include/hw/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypervisor/include/hw/pci.h b/hypervisor/include/hw/pci.h index dca0c58c4..7c4bd6585 100644 --- a/hypervisor/include/hw/pci.h +++ b/hypervisor/include/hw/pci.h @@ -391,7 +391,7 @@ static inline bool is_pci_vendor_valid(uint32_t vendor_id) static inline bool is_pci_cfg_multifunction(uint8_t header_type) { - return ((header_type & PCIM_MFDEV) == PCIM_MFDEV); + return ((header_type != 0xffU) && ((header_type & PCIM_MFDEV) == PCIM_MFDEV)); } static inline bool pci_is_valid_access_offset(uint32_t offset, uint32_t bytes)