diff --git a/hw/pci.c b/hw/pci.c
index aed3a24..344d72b 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -857,8 +857,7 @@ static pcibus_t pci_bar_address(PCIDevice *d,
     /* XXX: as we cannot support really dynamic
        mappings, we handle specific values as invalid
        mappings. */
-    if (last_addr <= new_addr || new_addr == 0 ||
-        last_addr == PCI_BAR_UNMAPPED) {
+    if (last_addr <= new_addr || new_addr == 0 || last_addr == ~(pcibus_t)0) {
         return PCI_BAR_UNMAPPED;
     }
 
