hvmloader: enable MMIO and I/O decode, after all resource allocation
authorHarsha Shamsundara Havanur <havanur@amazon.com>
Thu, 16 Apr 2020 08:58:46 +0000 (10:58 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 16 Apr 2020 08:58:46 +0000 (10:58 +0200)
commita8e0c228c79f3a000e19183090eb41fca173b034
treef61e5fdb3fc0018921849d10967a1b211dea7e89
parent6b93f3ca85e331e3ad24185668efbde506fb0e18
hvmloader: enable MMIO and I/O decode, after all resource allocation

It was observed that PCI MMIO and/or IO BARs were programmed with
memory and I/O decodes (bits 0 and 1 of PCI COMMAND register) enabled,
during PCI setup phase. This resulted in incorrect memory mapping as
soon as the lower half of the 64 bit bar is programmed.
This displaced any RAM mappings under 4G. After the
upper half is programmed PCI memory mapping is restored to its
intended high mem location, but the RAM displaced is not restored.
The OS then continues to boot and function until it tries to access
the displaced RAM at which point it suffers a page fault and crashes.

This patch address the issue by deferring enablement of memory and
I/O decode in command register until all the resources, like interrupts
I/O and/or MMIO BARs for all the PCI device functions are programmed,
in the descending order of memory requested.

Signed-off-by: Harsha Shamsundara Havanur <havanur@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
tools/firmware/hvmloader/pci.c