From e46154fbb4cbbf8ec5d93b0d81915b220fd4c7a3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 23 Jun 2015 20:37:55 +0100 Subject: [PATCH] [pci] Use flat real mode to call INT 1a,b101 Some HP BIOSes (observed with an HP ProLiant m710p Server Cartridge) have a bug in the implementation of INT 1a,b101: they blithely assume that real-mode code is able to read from anywhere in the 32-bit memory space. This problem affects the call to INT 1a,b101 made from within pcibios_num_bus() (which uses REAL_CODE() and hence executes in genuine real mode) but does not affect the call made from within romprefix.S (since with a PMM BIOS, that call executes in flat real mode anyway). Work around the problem by explicitly calling flatten_real_mode() before invoking INT 1a,b101. This is a rarely-used code path, and so the extra overhead of emulating instructions in some VM configurations (see commit 6d4deee ("[librm] Use genuine real mode to accelerate operation in virtual machines") for more details) is negligible. Reported-by: Wissam Shoukair Debugged-by: Wissam Shoukair Debugged-by: Michael Brown Signed-off-by: Michael Brown --- src/arch/i386/interface/pcbios/pcibios.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/arch/i386/interface/pcbios/pcibios.c b/src/arch/i386/interface/pcbios/pcibios.c index bec70bf30..34efa0b39 100644 --- a/src/arch/i386/interface/pcbios/pcibios.c +++ b/src/arch/i386/interface/pcbios/pcibios.c @@ -42,7 +42,11 @@ static int pcibios_num_bus ( void ) { int discard_a, discard_D; uint8_t max_bus; - __asm__ __volatile__ ( REAL_CODE ( "stc\n\t" + /* We issue this call using flat real mode, to work around a + * bug in some HP BIOSes. + */ + __asm__ __volatile__ ( REAL_CODE ( "call flatten_real_mode\n\t" + "stc\n\t" "int $0x1a\n\t" "jnc 1f\n\t" "xorw %%cx, %%cx\n\t" -- 2.47.2