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

Loading…
Cancel
Save