Browse Source

[efi] Avoid returning uninitialised data from PCI configuration space reads

Under UEFI, reads from PCI configuration space may fail.  If this
happens, we should return all-ones (which will mimic the behaviour of
an absent PCI device).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
f94d651632
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      src/include/ipxe/efi/efi_pci_api.h

+ 3
- 0
src/include/ipxe/efi/efi_pci_api.h View File

@@ -55,6 +55,7 @@ static inline __always_inline int
55 55
 PCIAPI_INLINE ( efi, pci_read_config_byte ) ( struct pci_device *pci,
56 56
 					      unsigned int where,
57 57
 					      uint8_t *value ) {
58
+	*value = 0xff;
58 59
 	return efipci_read ( pci,
59 60
 			     EFIPCI_LOCATION ( where, EFIPCI_WIDTH_BYTE ),
60 61
 			     value );
@@ -72,6 +73,7 @@ static inline __always_inline int
72 73
 PCIAPI_INLINE ( efi, pci_read_config_word ) ( struct pci_device *pci,
73 74
 					      unsigned int where,
74 75
 					      uint16_t *value ) {
76
+	*value = 0xffff;
75 77
 	return efipci_read ( pci,
76 78
 			     EFIPCI_LOCATION ( where, EFIPCI_WIDTH_WORD ),
77 79
 			     value );
@@ -89,6 +91,7 @@ static inline __always_inline int
89 91
 PCIAPI_INLINE ( efi, pci_read_config_dword ) ( struct pci_device *pci,
90 92
 					       unsigned int where,
91 93
 					       uint32_t *value ) {
94
+	*value = 0xffffffffUL;
92 95
 	return efipci_read ( pci,
93 96
 			     EFIPCI_LOCATION ( where, EFIPCI_WIDTH_DWORD ),
94 97
 			     value );

Loading…
Cancel
Save