mirror of https://gitee.com/openkylin/qemu.git
hw/apci: handle 64-bit MMIO regions correctly
In build_crs(), the calculation and merging of the ranges already happens in 64-bit, but the entry boundaries are silently truncated to 32-bit in the call to aml_dword_memory(). Fix it by handling the 64-bit MMIO ranges separately. This fixes 64-bit BARs behind PXBs. Reported-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
2df5a7b52f
commit
16de88a416
|
@ -754,18 +754,22 @@ static void crs_range_free(gpointer data)
|
|||
typedef struct CrsRangeSet {
|
||||
GPtrArray *io_ranges;
|
||||
GPtrArray *mem_ranges;
|
||||
GPtrArray *mem_64bit_ranges;
|
||||
} CrsRangeSet;
|
||||
|
||||
static void crs_range_set_init(CrsRangeSet *range_set)
|
||||
{
|
||||
range_set->io_ranges = g_ptr_array_new_with_free_func(crs_range_free);
|
||||
range_set->mem_ranges = g_ptr_array_new_with_free_func(crs_range_free);
|
||||
range_set->mem_64bit_ranges =
|
||||
g_ptr_array_new_with_free_func(crs_range_free);
|
||||
}
|
||||
|
||||
static void crs_range_set_free(CrsRangeSet *range_set)
|
||||
{
|
||||
g_ptr_array_free(range_set->io_ranges, true);
|
||||
g_ptr_array_free(range_set->mem_ranges, true);
|
||||
g_ptr_array_free(range_set->mem_64bit_ranges, true);
|
||||
}
|
||||
|
||||
static gint crs_range_compare(gconstpointer a, gconstpointer b)
|
||||
|
@ -923,8 +927,14 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
|
|||
* that do not support multiple root buses
|
||||
*/
|
||||
if (range_base && range_base <= range_limit) {
|
||||
crs_range_insert(temp_range_set.mem_ranges,
|
||||
range_base, range_limit);
|
||||
uint64_t length = range_limit - range_base + 1;
|
||||
if (range_limit <= UINT32_MAX && length <= UINT32_MAX) {
|
||||
crs_range_insert(temp_range_set.mem_ranges,
|
||||
range_base, range_limit);
|
||||
} else {
|
||||
crs_range_insert(temp_range_set.mem_64bit_ranges,
|
||||
range_base, range_limit);
|
||||
}
|
||||
}
|
||||
|
||||
range_base =
|
||||
|
@ -937,8 +947,14 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
|
|||
* that do not support multiple root buses
|
||||
*/
|
||||
if (range_base && range_base <= range_limit) {
|
||||
crs_range_insert(temp_range_set.mem_ranges,
|
||||
range_base, range_limit);
|
||||
uint64_t length = range_limit - range_base + 1;
|
||||
if (range_limit <= UINT32_MAX && length <= UINT32_MAX) {
|
||||
crs_range_insert(temp_range_set.mem_ranges,
|
||||
range_base, range_limit);
|
||||
} else {
|
||||
crs_range_insert(temp_range_set.mem_64bit_ranges,
|
||||
range_base, range_limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -966,6 +982,19 @@ static Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set)
|
|||
crs_range_insert(range_set->mem_ranges, entry->base, entry->limit);
|
||||
}
|
||||
|
||||
crs_range_merge(temp_range_set.mem_64bit_ranges);
|
||||
for (i = 0; i < temp_range_set.mem_64bit_ranges->len; i++) {
|
||||
entry = g_ptr_array_index(temp_range_set.mem_64bit_ranges, i);
|
||||
aml_append(crs,
|
||||
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED,
|
||||
AML_MAX_FIXED, AML_NON_CACHEABLE,
|
||||
AML_READ_WRITE,
|
||||
0, entry->base, entry->limit, 0,
|
||||
entry->limit - entry->base + 1));
|
||||
crs_range_insert(range_set->mem_64bit_ranges,
|
||||
entry->base, entry->limit);
|
||||
}
|
||||
|
||||
crs_range_set_free(&temp_range_set);
|
||||
|
||||
aml_append(crs,
|
||||
|
@ -2088,11 +2117,18 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
|
|||
}
|
||||
|
||||
if (!range_is_empty(pci_hole64)) {
|
||||
aml_append(crs,
|
||||
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
|
||||
AML_CACHEABLE, AML_READ_WRITE,
|
||||
0, range_lob(pci_hole64), range_upb(pci_hole64), 0,
|
||||
range_upb(pci_hole64) + 1 - range_lob(pci_hole64)));
|
||||
crs_replace_with_free_ranges(crs_range_set.mem_64bit_ranges,
|
||||
range_lob(pci_hole64),
|
||||
range_upb(pci_hole64));
|
||||
for (i = 0; i < crs_range_set.mem_64bit_ranges->len; i++) {
|
||||
entry = g_ptr_array_index(crs_range_set.mem_64bit_ranges, i);
|
||||
aml_append(crs,
|
||||
aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED,
|
||||
AML_MAX_FIXED,
|
||||
AML_CACHEABLE, AML_READ_WRITE,
|
||||
0, entry->base, entry->limit,
|
||||
0, entry->limit - entry->base + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (misc->tpm_version != TPM_VERSION_UNSPEC) {
|
||||
|
|
Loading…
Reference in New Issue