소스 검색

[ioapi] Fail ioremap() when attempting to map a zero bus address

When a 32-bit iPXE binary is running on a system which allocates PCI
memory BARs above 4GB, our PCI subsystem will return the base address
for any such BARs as zero (with a warning message if DEBUG=pci is
enabled).  Currently, ioremap() will happily map an address pointing
to the start of physical memory, providing no sensible indication of
failure.

Fix by always returning NULL if we are asked to ioremap() a zero bus
address.

With a totally flat memory model (e.g. under EFI), this provides an
accurate failure indication since no PCI peripheral will be mapped to
the zero bus address.

With the librm memory model, there is the possibility of a spurious
NULL return from ioremap() if the bus address happens to be equal to
virt_offset.  Under the current virtual memory map, the NULL virtual
address will always be the start of .textdata, and so this problem
cannot occur; a NULL return from ioremap() will always be an accurate
failure indication.

Debugged-by: Anton D. Kachalov <mouse@yandex-team.ru>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 년 전
부모
커밋
ae778091ca
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1
    1
      src/arch/x86/include/ipxe/x86_io.h

+ 1
- 1
src/arch/x86/include/ipxe/x86_io.h 파일 보기

@@ -45,7 +45,7 @@ IOAPI_INLINE ( x86, bus_to_phys ) ( unsigned long bus_addr ) {
45 45
 
46 46
 static inline __always_inline void *
47 47
 IOAPI_INLINE ( x86, ioremap ) ( unsigned long bus_addr, size_t len __unused ) {
48
-	return phys_to_virt ( bus_addr );
48
+	return ( bus_addr ? phys_to_virt ( bus_addr ) : NULL );
49 49
 }
50 50
 
51 51
 static inline __always_inline void

Loading…
취소
저장