i386/pc: Enable CXL fixed memory windows
Add the CFMWs memory regions to the memorymap and adjust the PCI window to avoid hitting the same memory. Signed-off-by: Jonathan Cameron <jonathan.cameron@huawei.com> Message-Id: <20220429144110.25167-36-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
3540bf56e4
commit
6d302cf46d
31
hw/i386/pc.c
31
hw/i386/pc.c
@ -817,7 +817,7 @@ void pc_memory_init(PCMachineState *pcms,
|
|||||||
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
MachineClass *mc = MACHINE_GET_CLASS(machine);
|
||||||
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
|
PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
|
||||||
X86MachineState *x86ms = X86_MACHINE(pcms);
|
X86MachineState *x86ms = X86_MACHINE(pcms);
|
||||||
hwaddr cxl_base;
|
hwaddr cxl_base, cxl_resv_end = 0;
|
||||||
|
|
||||||
assert(machine->ram_size == x86ms->below_4g_mem_size +
|
assert(machine->ram_size == x86ms->below_4g_mem_size +
|
||||||
x86ms->above_4g_mem_size);
|
x86ms->above_4g_mem_size);
|
||||||
@ -925,6 +925,24 @@ void pc_memory_init(PCMachineState *pcms,
|
|||||||
e820_add_entry(cxl_base, cxl_size, E820_RESERVED);
|
e820_add_entry(cxl_base, cxl_size, E820_RESERVED);
|
||||||
memory_region_init(mr, OBJECT(machine), "cxl_host_reg", cxl_size);
|
memory_region_init(mr, OBJECT(machine), "cxl_host_reg", cxl_size);
|
||||||
memory_region_add_subregion(system_memory, cxl_base, mr);
|
memory_region_add_subregion(system_memory, cxl_base, mr);
|
||||||
|
cxl_resv_end = cxl_base + cxl_size;
|
||||||
|
if (machine->cxl_devices_state->fixed_windows) {
|
||||||
|
hwaddr cxl_fmw_base;
|
||||||
|
GList *it;
|
||||||
|
|
||||||
|
cxl_fmw_base = ROUND_UP(cxl_base + cxl_size, 256 * MiB);
|
||||||
|
for (it = machine->cxl_devices_state->fixed_windows; it; it = it->next) {
|
||||||
|
CXLFixedWindow *fw = it->data;
|
||||||
|
|
||||||
|
fw->base = cxl_fmw_base;
|
||||||
|
memory_region_init_io(&fw->mr, OBJECT(machine), &cfmws_ops, fw,
|
||||||
|
"cxl-fixed-memory-region", fw->size);
|
||||||
|
memory_region_add_subregion(system_memory, fw->base, &fw->mr);
|
||||||
|
e820_add_entry(fw->base, fw->size, E820_RESERVED);
|
||||||
|
cxl_fmw_base += fw->size;
|
||||||
|
cxl_resv_end = cxl_fmw_base;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize PC system firmware */
|
/* Initialize PC system firmware */
|
||||||
@ -954,6 +972,10 @@ void pc_memory_init(PCMachineState *pcms,
|
|||||||
if (!pcmc->broken_reserved_end) {
|
if (!pcmc->broken_reserved_end) {
|
||||||
res_mem_end += memory_region_size(&machine->device_memory->mr);
|
res_mem_end += memory_region_size(&machine->device_memory->mr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (machine->cxl_devices_state->is_enabled) {
|
||||||
|
res_mem_end = cxl_resv_end;
|
||||||
|
}
|
||||||
*val = cpu_to_le64(ROUND_UP(res_mem_end, 1 * GiB));
|
*val = cpu_to_le64(ROUND_UP(res_mem_end, 1 * GiB));
|
||||||
fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
|
fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*val));
|
||||||
}
|
}
|
||||||
@ -990,6 +1012,13 @@ uint64_t pc_pci_hole64_start(void)
|
|||||||
if (ms->cxl_devices_state->host_mr.addr) {
|
if (ms->cxl_devices_state->host_mr.addr) {
|
||||||
hole64_start = ms->cxl_devices_state->host_mr.addr +
|
hole64_start = ms->cxl_devices_state->host_mr.addr +
|
||||||
memory_region_size(&ms->cxl_devices_state->host_mr);
|
memory_region_size(&ms->cxl_devices_state->host_mr);
|
||||||
|
if (ms->cxl_devices_state->fixed_windows) {
|
||||||
|
GList *it;
|
||||||
|
for (it = ms->cxl_devices_state->fixed_windows; it; it = it->next) {
|
||||||
|
CXLFixedWindow *fw = it->data;
|
||||||
|
hole64_start = fw->mr.addr + memory_region_size(&fw->mr);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (pcmc->has_reserved_memory && ms->device_memory->base) {
|
} else if (pcmc->has_reserved_memory && ms->device_memory->base) {
|
||||||
hole64_start = ms->device_memory->base;
|
hole64_start = ms->device_memory->base;
|
||||||
if (!pcmc->broken_reserved_end) {
|
if (!pcmc->broken_reserved_end) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user