2015-05-29 13:28:54 +03:00
|
|
|
/* Support for generating ACPI tables and passing them to Guests
|
|
|
|
*
|
|
|
|
* ARM virt ACPI generation
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net>
|
|
|
|
* Copyright (C) 2006 Fabrice Bellard
|
|
|
|
* Copyright (C) 2013 Red Hat Inc
|
|
|
|
*
|
|
|
|
* Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD.
|
|
|
|
*
|
|
|
|
* Author: Shannon Zhao <zhaoshenglong@huawei.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-12-07 19:23:45 +03:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 11:01:28 +03:00
|
|
|
#include "qapi/error.h"
|
2015-05-29 13:28:54 +03:00
|
|
|
#include "qemu/bitmap.h"
|
2023-07-06 20:06:10 +03:00
|
|
|
#include "qemu/error-report.h"
|
2015-05-29 13:28:54 +03:00
|
|
|
#include "trace.h"
|
2019-07-09 18:20:52 +03:00
|
|
|
#include "hw/core/cpu.h"
|
2015-05-29 13:28:54 +03:00
|
|
|
#include "hw/acpi/acpi-defs.h"
|
|
|
|
#include "hw/acpi/acpi.h"
|
2023-12-18 18:02:35 +03:00
|
|
|
#include "hw/nvram/fw_cfg_acpi.h"
|
2015-05-29 13:28:54 +03:00
|
|
|
#include "hw/acpi/bios-linker-loader.h"
|
|
|
|
#include "hw/acpi/aml-build.h"
|
2019-06-10 04:18:30 +03:00
|
|
|
#include "hw/acpi/utils.h"
|
2019-04-19 03:30:51 +03:00
|
|
|
#include "hw/acpi/pci.h"
|
2019-09-18 16:06:27 +03:00
|
|
|
#include "hw/acpi/memory_hotplug.h"
|
|
|
|
#include "hw/acpi/generic_event_device.h"
|
2020-06-01 12:57:36 +03:00
|
|
|
#include "hw/acpi/tpm.h"
|
2022-10-27 13:00:35 +03:00
|
|
|
#include "hw/acpi/hmat.h"
|
2015-05-29 13:28:57 +03:00
|
|
|
#include "hw/pci/pcie_host.h"
|
2015-05-29 13:28:59 +03:00
|
|
|
#include "hw/pci/pci.h"
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
#include "hw/pci/pci_bus.h"
|
2020-09-28 13:42:47 +03:00
|
|
|
#include "hw/pci-host/gpex.h"
|
2017-01-09 14:40:22 +03:00
|
|
|
#include "hw/arm/virt.h"
|
2023-04-05 14:48:26 +03:00
|
|
|
#include "hw/intc/arm_gicv3_its_common.h"
|
2020-04-21 15:59:30 +03:00
|
|
|
#include "hw/mem/nvdimm.h"
|
2020-06-22 17:06:19 +03:00
|
|
|
#include "hw/platform-bus.h"
|
2016-05-12 15:22:28 +03:00
|
|
|
#include "sysemu/numa.h"
|
2019-08-12 08:23:38 +03:00
|
|
|
#include "sysemu/reset.h"
|
2020-06-01 12:57:36 +03:00
|
|
|
#include "sysemu/tpm.h"
|
2019-08-12 08:23:45 +03:00
|
|
|
#include "migration/vmstate.h"
|
2020-05-12 06:06:03 +03:00
|
|
|
#include "hw/acpi/ghes.h"
|
2021-12-10 20:04:09 +03:00
|
|
|
#include "hw/acpi/viot.h"
|
2024-03-08 17:55:24 +03:00
|
|
|
#include "hw/acpi/acpi_generic_initiator.h"
|
2023-12-18 18:02:36 +03:00
|
|
|
#include "hw/virtio/virtio-acpi.h"
|
2024-01-18 23:06:31 +03:00
|
|
|
#include "target/arm/multiprocessing.h"
|
2015-05-29 13:28:54 +03:00
|
|
|
|
2015-05-29 13:28:55 +03:00
|
|
|
#define ARM_SPI_BASE 32
|
|
|
|
|
2020-11-19 04:48:38 +03:00
|
|
|
#define ACPI_BUILD_TABLE_SIZE 0x20000
|
|
|
|
|
2020-12-15 20:48:15 +03:00
|
|
|
static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms)
|
2015-05-29 13:28:55 +03:00
|
|
|
{
|
2020-12-15 20:48:15 +03:00
|
|
|
MachineState *ms = MACHINE(vms);
|
2015-05-29 13:28:55 +03:00
|
|
|
uint16_t i;
|
|
|
|
|
2020-12-15 20:48:15 +03:00
|
|
|
for (i = 0; i < ms->smp.cpus; i++) {
|
2016-09-06 21:52:17 +03:00
|
|
|
Aml *dev = aml_device("C%.03X", i);
|
2015-05-29 13:28:55 +03:00
|
|
|
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
|
|
|
|
aml_append(dev, aml_name_decl("_UID", aml_int(i)));
|
|
|
|
aml_append(scope, dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap,
|
2024-06-10 19:23:43 +03:00
|
|
|
uint32_t uart_irq, int uartidx)
|
2015-05-29 13:28:55 +03:00
|
|
|
{
|
2024-06-10 19:23:43 +03:00
|
|
|
Aml *dev = aml_device("COM%d", uartidx);
|
2015-05-29 13:28:55 +03:00
|
|
|
aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0011")));
|
2024-06-10 19:23:43 +03:00
|
|
|
aml_append(dev, aml_name_decl("_UID", aml_int(uartidx)));
|
2015-05-29 13:28:55 +03:00
|
|
|
|
|
|
|
Aml *crs = aml_resource_template();
|
|
|
|
aml_append(crs, aml_memory32_fixed(uart_memmap->base,
|
|
|
|
uart_memmap->size, AML_READ_WRITE));
|
|
|
|
aml_append(crs,
|
|
|
|
aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
|
2015-12-17 16:37:13 +03:00
|
|
|
AML_EXCLUSIVE, &uart_irq, 1));
|
2015-05-29 13:28:55 +03:00
|
|
|
aml_append(dev, aml_name_decl("_CRS", crs));
|
2015-06-15 20:06:11 +03:00
|
|
|
|
2015-05-29 13:28:55 +03:00
|
|
|
aml_append(scope, dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)
|
|
|
|
{
|
|
|
|
Aml *dev, *crs;
|
|
|
|
hwaddr base = flash_memmap->base;
|
2015-09-24 03:29:37 +03:00
|
|
|
hwaddr size = flash_memmap->size / 2;
|
2015-05-29 13:28:55 +03:00
|
|
|
|
|
|
|
dev = aml_device("FLS0");
|
|
|
|
aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0015")));
|
|
|
|
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
|
|
|
|
|
|
|
|
crs = aml_resource_template();
|
|
|
|
aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE));
|
|
|
|
aml_append(dev, aml_name_decl("_CRS", crs));
|
|
|
|
aml_append(scope, dev);
|
|
|
|
|
|
|
|
dev = aml_device("FLS1");
|
|
|
|
aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0015")));
|
|
|
|
aml_append(dev, aml_name_decl("_UID", aml_int(1)));
|
|
|
|
crs = aml_resource_template();
|
|
|
|
aml_append(crs, aml_memory32_fixed(base + size, size, AML_READ_WRITE));
|
|
|
|
aml_append(dev, aml_name_decl("_CRS", crs));
|
|
|
|
aml_append(scope, dev);
|
|
|
|
}
|
|
|
|
|
2015-12-17 16:37:13 +03:00
|
|
|
static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
|
2022-01-14 17:07:36 +03:00
|
|
|
uint32_t irq, VirtMachineState *vms)
|
2015-05-29 13:28:59 +03:00
|
|
|
{
|
2022-01-14 17:07:36 +03:00
|
|
|
int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
|
2020-09-28 13:42:47 +03:00
|
|
|
struct GPEXConfig cfg = {
|
|
|
|
.mmio32 = memmap[VIRT_PCIE_MMIO],
|
|
|
|
.pio = memmap[VIRT_PCIE_PIO],
|
|
|
|
.ecam = memmap[ecam_id],
|
|
|
|
.irq = irq,
|
2020-11-19 04:48:37 +03:00
|
|
|
.bus = vms->bus,
|
2020-09-28 13:42:47 +03:00
|
|
|
};
|
2015-05-29 13:28:59 +03:00
|
|
|
|
2022-01-14 17:07:36 +03:00
|
|
|
if (vms->highmem_mmio) {
|
2020-09-28 13:42:47 +03:00
|
|
|
cfg.mmio64 = memmap[VIRT_HIGH_PCIE_MMIO];
|
2015-09-07 12:39:29 +03:00
|
|
|
}
|
|
|
|
|
2020-09-28 13:42:47 +03:00
|
|
|
acpi_dsdt_add_gpex(scope, &cfg);
|
2015-05-29 13:28:59 +03:00
|
|
|
}
|
|
|
|
|
2015-12-17 16:37:14 +03:00
|
|
|
static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,
|
|
|
|
uint32_t gpio_irq)
|
|
|
|
{
|
|
|
|
Aml *dev = aml_device("GPO0");
|
|
|
|
aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0061")));
|
|
|
|
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
|
|
|
|
|
|
|
|
Aml *crs = aml_resource_template();
|
|
|
|
aml_append(crs, aml_memory32_fixed(gpio_memmap->base, gpio_memmap->size,
|
|
|
|
AML_READ_WRITE));
|
|
|
|
aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
|
|
|
|
AML_EXCLUSIVE, &gpio_irq, 1));
|
|
|
|
aml_append(dev, aml_name_decl("_CRS", crs));
|
2015-12-17 16:37:14 +03:00
|
|
|
|
|
|
|
Aml *aei = aml_resource_template();
|
|
|
|
/* Pin 3 for power button */
|
|
|
|
const uint32_t pin_list[1] = {3};
|
|
|
|
aml_append(aei, aml_gpio_int(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH,
|
|
|
|
AML_EXCLUSIVE, AML_PULL_UP, 0, pin_list, 1,
|
|
|
|
"GPO0", NULL, 0));
|
|
|
|
aml_append(dev, aml_name_decl("_AEI", aei));
|
|
|
|
|
|
|
|
/* _E03 is handle for power button */
|
|
|
|
Aml *method = aml_method("_E03", 0, AML_NOTSERIALIZED);
|
|
|
|
aml_append(method, aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE),
|
|
|
|
aml_int(0x80)));
|
|
|
|
aml_append(dev, method);
|
2015-12-17 16:37:14 +03:00
|
|
|
aml_append(scope, dev);
|
|
|
|
}
|
|
|
|
|
2021-06-15 17:21:18 +03:00
|
|
|
#ifdef CONFIG_TPM
|
2020-06-22 17:06:19 +03:00
|
|
|
static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms)
|
|
|
|
{
|
|
|
|
PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
|
|
|
|
hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base;
|
|
|
|
SysBusDevice *sbdev = SYS_BUS_DEVICE(tpm_find());
|
|
|
|
MemoryRegion *sbdev_mr;
|
|
|
|
hwaddr tpm_base;
|
|
|
|
|
|
|
|
if (!sbdev) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
|
|
|
|
assert(tpm_base != -1);
|
|
|
|
|
|
|
|
tpm_base += pbus_base;
|
|
|
|
|
|
|
|
sbdev_mr = sysbus_mmio_get_region(sbdev, 0);
|
|
|
|
|
|
|
|
Aml *dev = aml_device("TPM0");
|
|
|
|
aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101")));
|
2022-01-04 20:58:05 +03:00
|
|
|
aml_append(dev, aml_name_decl("_STR", aml_string("TPM 2.0 Device")));
|
2020-06-22 17:06:19 +03:00
|
|
|
aml_append(dev, aml_name_decl("_UID", aml_int(0)));
|
|
|
|
|
|
|
|
Aml *crs = aml_resource_template();
|
|
|
|
aml_append(crs,
|
|
|
|
aml_memory32_fixed(tpm_base,
|
|
|
|
(uint32_t)memory_region_size(sbdev_mr),
|
|
|
|
AML_READ_WRITE));
|
|
|
|
aml_append(dev, aml_name_decl("_CRS", crs));
|
|
|
|
aml_append(scope, dev);
|
|
|
|
}
|
2021-06-15 17:21:18 +03:00
|
|
|
#endif
|
2020-06-22 17:06:19 +03:00
|
|
|
|
2021-09-24 15:27:56 +03:00
|
|
|
#define ID_MAPPING_ENTRY_SIZE 20
|
2021-10-14 14:56:42 +03:00
|
|
|
#define SMMU_V3_ENTRY_SIZE 68
|
|
|
|
#define ROOT_COMPLEX_ENTRY_SIZE 36
|
2021-09-24 15:27:56 +03:00
|
|
|
#define IORT_NODE_OFFSET 48
|
|
|
|
|
2024-06-19 23:12:43 +03:00
|
|
|
/*
|
|
|
|
* Append an ID mapping entry as described by "Table 4 ID mapping format" in
|
|
|
|
* "IO Remapping Table System Software on ARM Platforms", Chapter 3.
|
|
|
|
* Document number: ARM DEN 0049E.f, Apr 2024
|
|
|
|
*
|
|
|
|
* Note that @id_count gets internally subtracted by one, following the spec.
|
|
|
|
*/
|
2021-09-24 15:27:56 +03:00
|
|
|
static void build_iort_id_mapping(GArray *table_data, uint32_t input_base,
|
|
|
|
uint32_t id_count, uint32_t out_ref)
|
|
|
|
{
|
|
|
|
build_append_int_noprefix(table_data, input_base, 4); /* Input base */
|
2024-06-19 23:12:43 +03:00
|
|
|
/* Number of IDs - The number of IDs in the range minus one */
|
|
|
|
build_append_int_noprefix(table_data, id_count - 1, 4);
|
2021-09-24 15:27:56 +03:00
|
|
|
build_append_int_noprefix(table_data, input_base, 4); /* Output base */
|
|
|
|
build_append_int_noprefix(table_data, out_ref, 4); /* Output Reference */
|
2021-10-14 14:56:42 +03:00
|
|
|
/* Flags */
|
|
|
|
build_append_int_noprefix(table_data, 0 /* Single mapping (disabled) */, 4);
|
2021-09-24 15:27:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
struct AcpiIortIdMapping {
|
|
|
|
uint32_t input_base;
|
|
|
|
uint32_t id_count;
|
|
|
|
};
|
|
|
|
typedef struct AcpiIortIdMapping AcpiIortIdMapping;
|
|
|
|
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
/* Build the iort ID mapping to SMMUv3 for a given PCI host bridge */
|
|
|
|
static int
|
|
|
|
iort_host_bridges(Object *obj, void *opaque)
|
|
|
|
{
|
|
|
|
GArray *idmap_blob = opaque;
|
|
|
|
|
|
|
|
if (object_dynamic_cast(obj, TYPE_PCI_HOST_BRIDGE)) {
|
|
|
|
PCIBus *bus = PCI_HOST_BRIDGE(obj)->bus;
|
|
|
|
|
|
|
|
if (bus && !pci_bus_bypass_iommu(bus)) {
|
|
|
|
int min_bus, max_bus;
|
|
|
|
|
|
|
|
pci_bus_range(bus, &min_bus, &max_bus);
|
|
|
|
|
|
|
|
AcpiIortIdMapping idmap = {
|
|
|
|
.input_base = min_bus << 8,
|
|
|
|
.id_count = (max_bus - min_bus + 1) << 8,
|
|
|
|
};
|
|
|
|
g_array_append_val(idmap_blob, idmap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int iort_idmap_compare(gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
AcpiIortIdMapping *idmap_a = (AcpiIortIdMapping *)a;
|
|
|
|
AcpiIortIdMapping *idmap_b = (AcpiIortIdMapping *)b;
|
|
|
|
|
|
|
|
return idmap_a->input_base - idmap_b->input_base;
|
|
|
|
}
|
|
|
|
|
2021-09-24 15:27:55 +03:00
|
|
|
/*
|
|
|
|
* Input Output Remapping Table (IORT)
|
|
|
|
* Conforms to "IO Remapping Table System Software on ARM Platforms",
|
2021-10-14 14:56:42 +03:00
|
|
|
* Document number: ARM DEN 0049E.b, Feb 2021
|
2021-09-24 15:27:55 +03:00
|
|
|
*/
|
2016-10-24 18:26:54 +03:00
|
|
|
static void
|
2018-05-04 20:05:52 +03:00
|
|
|
build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
2016-10-24 18:26:54 +03:00
|
|
|
{
|
2021-09-24 15:27:55 +03:00
|
|
|
int i, nb_nodes, rc_mapping_count;
|
|
|
|
size_t node_size, smmu_offset = 0;
|
2021-09-24 15:27:56 +03:00
|
|
|
AcpiIortIdMapping *idmap;
|
2021-10-14 14:56:42 +03:00
|
|
|
uint32_t id = 0;
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
GArray *smmu_idmaps = g_array_new(false, true, sizeof(AcpiIortIdMapping));
|
|
|
|
GArray *its_idmaps = g_array_new(false, true, sizeof(AcpiIortIdMapping));
|
2016-10-24 18:26:54 +03:00
|
|
|
|
2021-10-14 14:56:42 +03:00
|
|
|
AcpiTable table = { .sig = "IORT", .rev = 3, .oem_id = vms->oem_id,
|
2021-09-24 15:27:55 +03:00
|
|
|
.oem_table_id = vms->oem_table_id };
|
2021-09-24 15:27:56 +03:00
|
|
|
/* Table 2 The IORT */
|
|
|
|
acpi_table_begin(&table, table_data);
|
2016-10-24 18:26:54 +03:00
|
|
|
|
2018-05-04 20:05:52 +03:00
|
|
|
if (vms->iommu == VIRT_IOMMU_SMMUV3) {
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
AcpiIortIdMapping next_range = {0};
|
|
|
|
|
|
|
|
object_child_foreach_recursive(object_get_root(),
|
|
|
|
iort_host_bridges, smmu_idmaps);
|
|
|
|
|
|
|
|
/* Sort the smmu idmap by input_base */
|
|
|
|
g_array_sort(smmu_idmaps, iort_idmap_compare);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Split the whole RIDs by mapping from RC to SMMU,
|
|
|
|
* build the ID mapping from RC to ITS directly.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < smmu_idmaps->len; i++) {
|
|
|
|
idmap = &g_array_index(smmu_idmaps, AcpiIortIdMapping, i);
|
|
|
|
|
|
|
|
if (next_range.input_base < idmap->input_base) {
|
|
|
|
next_range.id_count = idmap->input_base - next_range.input_base;
|
|
|
|
g_array_append_val(its_idmaps, next_range);
|
|
|
|
}
|
|
|
|
|
|
|
|
next_range.input_base = idmap->input_base + idmap->id_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append the last RC -> ITS ID mapping */
|
2024-06-19 23:12:43 +03:00
|
|
|
if (next_range.input_base < 0x10000) {
|
|
|
|
next_range.id_count = 0x10000 - next_range.input_base;
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
g_array_append_val(its_idmaps, next_range);
|
|
|
|
}
|
|
|
|
|
2018-05-04 20:05:52 +03:00
|
|
|
nb_nodes = 3; /* RC, ITS, SMMUv3 */
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
rc_mapping_count = smmu_idmaps->len + its_idmaps->len;
|
2018-05-04 20:05:52 +03:00
|
|
|
} else {
|
|
|
|
nb_nodes = 2; /* RC, ITS */
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
rc_mapping_count = 1;
|
2018-05-04 20:05:52 +03:00
|
|
|
}
|
2021-09-24 15:27:55 +03:00
|
|
|
/* Number of IORT Nodes */
|
|
|
|
build_append_int_noprefix(table_data, nb_nodes, 4);
|
2021-09-24 15:27:56 +03:00
|
|
|
|
2021-09-24 15:27:55 +03:00
|
|
|
/* Offset to Array of IORT Nodes */
|
2021-09-24 15:27:56 +03:00
|
|
|
build_append_int_noprefix(table_data, IORT_NODE_OFFSET, 4);
|
2021-09-24 15:27:55 +03:00
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Reserved */
|
2016-10-24 18:26:54 +03:00
|
|
|
|
2021-10-14 14:56:42 +03:00
|
|
|
/* Table 12 ITS Group Format */
|
2021-09-24 15:27:56 +03:00
|
|
|
build_append_int_noprefix(table_data, 0 /* ITS Group */, 1); /* Type */
|
|
|
|
node_size = 20 /* fixed header size */ + 4 /* 1 GIC ITS Identifier */;
|
|
|
|
build_append_int_noprefix(table_data, node_size, 2); /* Length */
|
2021-10-14 14:56:42 +03:00
|
|
|
build_append_int_noprefix(table_data, 1, 1); /* Revision */
|
|
|
|
build_append_int_noprefix(table_data, id++, 4); /* Identifier */
|
2021-09-24 15:27:56 +03:00
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Number of ID mappings */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Reference to ID Array */
|
|
|
|
build_append_int_noprefix(table_data, 1, 4); /* Number of ITSs */
|
|
|
|
/* GIC ITS Identifier Array */
|
|
|
|
build_append_int_noprefix(table_data, 0 /* MADT translation_id */, 4);
|
2016-10-24 18:26:54 +03:00
|
|
|
|
2018-05-04 20:05:52 +03:00
|
|
|
if (vms->iommu == VIRT_IOMMU_SMMUV3) {
|
2019-03-15 14:12:28 +03:00
|
|
|
int irq = vms->irqmap[VIRT_SMMU] + ARM_SPI_BASE;
|
2018-05-04 20:05:52 +03:00
|
|
|
|
2021-09-24 15:27:56 +03:00
|
|
|
smmu_offset = table_data->len - table.table_offset;
|
2021-10-14 14:56:42 +03:00
|
|
|
/* Table 9 SMMUv3 Format */
|
2021-09-24 15:27:56 +03:00
|
|
|
build_append_int_noprefix(table_data, 4 /* SMMUv3 */, 1); /* Type */
|
|
|
|
node_size = SMMU_V3_ENTRY_SIZE + ID_MAPPING_ENTRY_SIZE;
|
|
|
|
build_append_int_noprefix(table_data, node_size, 2); /* Length */
|
2021-10-14 14:56:42 +03:00
|
|
|
build_append_int_noprefix(table_data, 4, 1); /* Revision */
|
|
|
|
build_append_int_noprefix(table_data, id++, 4); /* Identifier */
|
2021-09-24 15:27:56 +03:00
|
|
|
build_append_int_noprefix(table_data, 1, 4); /* Number of ID mappings */
|
|
|
|
/* Reference to ID Array */
|
|
|
|
build_append_int_noprefix(table_data, SMMU_V3_ENTRY_SIZE, 4);
|
|
|
|
/* Base address */
|
|
|
|
build_append_int_noprefix(table_data, vms->memmap[VIRT_SMMU].base, 8);
|
|
|
|
/* Flags */
|
2021-10-14 14:56:42 +03:00
|
|
|
build_append_int_noprefix(table_data, 1 /* COHACC Override */, 4);
|
2021-09-24 15:27:56 +03:00
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Reserved */
|
|
|
|
build_append_int_noprefix(table_data, 0, 8); /* VATOS address */
|
|
|
|
/* Model */
|
|
|
|
build_append_int_noprefix(table_data, 0 /* Generic SMMU-v3 */, 4);
|
|
|
|
build_append_int_noprefix(table_data, irq, 4); /* Event */
|
|
|
|
build_append_int_noprefix(table_data, irq + 1, 4); /* PRI */
|
|
|
|
build_append_int_noprefix(table_data, irq + 3, 4); /* GERR */
|
|
|
|
build_append_int_noprefix(table_data, irq + 2, 4); /* Sync */
|
2021-10-14 14:56:42 +03:00
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Proximity domain */
|
|
|
|
/* DeviceID mapping index (ignored since interrupts are GSIV based) */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4);
|
2021-09-24 15:27:56 +03:00
|
|
|
|
2018-05-04 20:05:52 +03:00
|
|
|
/* output IORT node is the ITS group node (the first node) */
|
2024-06-19 23:12:43 +03:00
|
|
|
build_iort_id_mapping(table_data, 0, 0x10000, IORT_NODE_OFFSET);
|
2018-05-04 20:05:52 +03:00
|
|
|
}
|
|
|
|
|
2021-10-14 14:56:42 +03:00
|
|
|
/* Table 17 Root Complex Node */
|
2021-09-24 15:27:56 +03:00
|
|
|
build_append_int_noprefix(table_data, 2 /* Root complex */, 1); /* Type */
|
|
|
|
node_size = ROOT_COMPLEX_ENTRY_SIZE +
|
|
|
|
ID_MAPPING_ENTRY_SIZE * rc_mapping_count;
|
|
|
|
build_append_int_noprefix(table_data, node_size, 2); /* Length */
|
2021-10-14 14:56:42 +03:00
|
|
|
build_append_int_noprefix(table_data, 3, 1); /* Revision */
|
|
|
|
build_append_int_noprefix(table_data, id++, 4); /* Identifier */
|
2021-09-24 15:27:56 +03:00
|
|
|
/* Number of ID mappings */
|
|
|
|
build_append_int_noprefix(table_data, rc_mapping_count, 4);
|
|
|
|
/* Reference to ID Array */
|
|
|
|
build_append_int_noprefix(table_data, ROOT_COMPLEX_ENTRY_SIZE, 4);
|
|
|
|
|
2021-10-14 14:56:42 +03:00
|
|
|
/* Table 14 Memory access properties */
|
2021-09-24 15:27:56 +03:00
|
|
|
/* CCA: Cache Coherent Attribute */
|
|
|
|
build_append_int_noprefix(table_data, 1 /* fully coherent */, 4);
|
|
|
|
build_append_int_noprefix(table_data, 0, 1); /* AH: Note Allocation Hints */
|
|
|
|
build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
2021-10-14 14:56:42 +03:00
|
|
|
/* Table 15 Memory Access Flags */
|
|
|
|
build_append_int_noprefix(table_data, 0x3 /* CCA = CPM = DACS = 1 */, 1);
|
2021-09-24 15:27:56 +03:00
|
|
|
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* ATS Attribute */
|
|
|
|
/* MCFG pci_segment */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* PCI Segment number */
|
|
|
|
|
2021-10-14 14:56:42 +03:00
|
|
|
/* Memory address size limit */
|
|
|
|
build_append_int_noprefix(table_data, 64, 1);
|
|
|
|
|
|
|
|
build_append_int_noprefix(table_data, 0, 3); /* Reserved */
|
|
|
|
|
2021-09-24 15:27:56 +03:00
|
|
|
/* Output Reference */
|
2018-05-04 20:05:52 +03:00
|
|
|
if (vms->iommu == VIRT_IOMMU_SMMUV3) {
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
AcpiIortIdMapping *range;
|
|
|
|
|
|
|
|
/* translated RIDs connect to SMMUv3 node: RC -> SMMUv3 -> ITS */
|
|
|
|
for (i = 0; i < smmu_idmaps->len; i++) {
|
|
|
|
range = &g_array_index(smmu_idmaps, AcpiIortIdMapping, i);
|
|
|
|
/* output IORT node is the smmuv3 node */
|
2021-09-24 15:27:56 +03:00
|
|
|
build_iort_id_mapping(table_data, range->input_base,
|
|
|
|
range->id_count, smmu_offset);
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* bypassed RIDs connect to ITS group node directly: RC -> ITS */
|
|
|
|
for (i = 0; i < its_idmaps->len; i++) {
|
|
|
|
range = &g_array_index(its_idmaps, AcpiIortIdMapping, i);
|
|
|
|
/* output IORT node is the ITS group node (the first node) */
|
2021-09-24 15:27:56 +03:00
|
|
|
build_iort_id_mapping(table_data, range->input_base,
|
2024-06-19 03:17:08 +03:00
|
|
|
range->id_count, IORT_NODE_OFFSET);
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
}
|
2018-05-04 20:05:52 +03:00
|
|
|
} else {
|
|
|
|
/* output IORT node is the ITS group node (the first node) */
|
2024-06-19 23:12:43 +03:00
|
|
|
build_iort_id_mapping(table_data, 0, 0x10000, IORT_NODE_OFFSET);
|
2018-05-04 20:05:52 +03:00
|
|
|
}
|
2016-10-24 18:26:54 +03:00
|
|
|
|
2021-09-24 15:27:55 +03:00
|
|
|
acpi_table_end(linker, &table);
|
hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3
When we build IORT table with SMMUv3 and bypass iommu feature enabled,
we can no longer setup one map from RC to SMMUv3 covering the whole RIDs.
We need to walk the PCI bus and check whether the root bus will bypass
iommu, setup RC -> SMMUv3 -> ITS map for RC which will not bypass iommu.
When a SMMUv3 node exist, we setup the idmap from SMMUv3 to ITS
covering the whole RIDs, and only modify the map from RC to SMMUv3.
We build RC -> SMMUv3 -> ITS map for root bus with bypass_iommu
disabled, and build idmap from RC to ITS directly for the rest of
the whole RID space.
For example we run qemu with command line:
qemu/build/aarch64-softmmu/qemu-system-aarch64 \
-kernel arch/arm64/boot/Image \
-enable-kvm \
-cpu host \
-m 8G \
-smp 8,sockets=2,cores=4,threads=1 \
-machine virt,kernel_irqchip=on,gic-version=3,iommu=smmuv3,default_bus_bypass_iommu=true \
-drive file=./QEMU_EFI-pflash.raw,if=pflash,format=raw,unit=0,readonly=on \
-device pxb-pcie,bus_nr=0x10,id=pci.10,bus=pcie.0,addr=0x3.0x1 \
-device pxb-pcie,bus_nr=0x20,id=pci.20,bus=pcie.0,addr=0x3.0x2,bypass_iommu=true \
-device pcie-root-port,port=0x20,chassis=1,id=pci.1,bus=pcie.0,addr=0x2 \
-device pcie-root-port,port=0x20,chassis=11,id=pci.11,bus=pci.10,addr=0x1 \
-device pcie-root-port,port=0x20,chassis=21,id=pci.21,bus=pci.20,addr=0x1 \
-device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
-device virtio-scsi-pci,id=scsi1,bus=pci.11,addr=0x1 \
-device virtio-scsi-pci,id=scsi2,bus=pci.21,addr=0x1 \
-initrd /mnt/davinci/wxg/kill-linux/rootfs/mfs.cpio.gz \
-nographic \
-append "rdinit=init console=ttyAMA0 earlycon=pl011,0x9000000 nokaslr" \
And we get guest configuration:
-+-[0000:20]---01.0-[21]--
+-[0000:10]---01.0-[11]--
\-[0000:00]-+-00.0 Device 1b36:0008
+-01.0 Device 1af4:1000
\-02.0-[01]--
With bypass_iommu enabled, the attached devices will bypass iommu.
/sys/class/iommu/smmu3.0x0000000009050000/
|-- device -> ../../../arm-smmu-v3.0.auto
|-- devices
| `-- 0000:10:01.0 -> ../../../../../pci0000:10/0000:10:01.0
Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Message-Id: <1625748919-52456-7-git-send-email-wangxingang5@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2021-07-08 15:55:16 +03:00
|
|
|
g_array_free(smmu_idmaps, true);
|
|
|
|
g_array_free(its_idmaps, true);
|
2016-10-24 18:26:54 +03:00
|
|
|
}
|
|
|
|
|
2021-09-24 15:27:58 +03:00
|
|
|
/*
|
|
|
|
* Serial Port Console Redirection Table (SPCR)
|
|
|
|
* Rev: 1.07
|
|
|
|
*/
|
2015-06-15 20:06:11 +03:00
|
|
|
static void
|
2024-01-29 05:14:39 +03:00
|
|
|
spcr_setup(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
2015-06-15 20:06:11 +03:00
|
|
|
{
|
2024-01-29 05:14:39 +03:00
|
|
|
AcpiSpcrData serial = {
|
|
|
|
.interface_type = 3, /* ARM PL011 UART */
|
|
|
|
.base_addr.id = AML_AS_SYSTEM_MEMORY,
|
|
|
|
.base_addr.width = 32,
|
|
|
|
.base_addr.offset = 0,
|
|
|
|
.base_addr.size = 3,
|
2024-06-10 19:23:42 +03:00
|
|
|
.base_addr.addr = vms->memmap[VIRT_UART0].base,
|
2024-01-29 05:14:39 +03:00
|
|
|
.interrupt_type = (1 << 3),/* Bit[3] ARMH GIC interrupt*/
|
|
|
|
.pc_interrupt = 0, /* IRQ */
|
2024-06-10 19:23:42 +03:00
|
|
|
.interrupt = (vms->irqmap[VIRT_UART0] + ARM_SPI_BASE),
|
2024-01-29 05:14:39 +03:00
|
|
|
.baud_rate = 3, /* 9600 */
|
|
|
|
.parity = 0, /* No Parity */
|
|
|
|
.stop_bits = 1, /* 1 Stop bit */
|
|
|
|
.flow_control = 1 << 1, /* RTS/CTS hardware flow control */
|
|
|
|
.terminal_type = 0, /* VT100 */
|
|
|
|
.language = 0, /* Language */
|
|
|
|
.pci_device_id = 0xffff, /* not a PCI device*/
|
|
|
|
.pci_vendor_id = 0xffff, /* not a PCI device*/
|
|
|
|
.pci_bus = 0,
|
|
|
|
.pci_device = 0,
|
|
|
|
.pci_function = 0,
|
|
|
|
.pci_flags = 0,
|
|
|
|
.pci_segment = 0,
|
|
|
|
};
|
2015-06-15 20:06:11 +03:00
|
|
|
|
2024-01-29 05:14:39 +03:00
|
|
|
build_spcr(table_data, linker, &serial, 2, vms->oem_id, vms->oem_table_id);
|
2015-06-15 20:06:11 +03:00
|
|
|
}
|
|
|
|
|
2021-09-24 15:27:44 +03:00
|
|
|
/*
|
|
|
|
* ACPI spec, Revision 5.1
|
|
|
|
* 5.2.16 System Resource Affinity Table (SRAT)
|
|
|
|
*/
|
2016-05-12 15:22:28 +03:00
|
|
|
static void
|
2017-01-09 14:40:22 +03:00
|
|
|
build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
2016-05-12 15:22:28 +03:00
|
|
|
{
|
2021-09-24 15:27:43 +03:00
|
|
|
int i;
|
2016-05-12 15:22:28 +03:00
|
|
|
uint64_t mem_base;
|
2017-05-10 14:29:54 +03:00
|
|
|
MachineClass *mc = MACHINE_GET_CLASS(vms);
|
2019-08-09 09:57:22 +03:00
|
|
|
MachineState *ms = MACHINE(vms);
|
|
|
|
const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(ms);
|
2021-09-24 15:27:43 +03:00
|
|
|
AcpiTable table = { .sig = "SRAT", .rev = 3, .oem_id = vms->oem_id,
|
|
|
|
.oem_table_id = vms->oem_table_id };
|
2016-05-12 15:22:28 +03:00
|
|
|
|
2021-09-24 15:27:43 +03:00
|
|
|
acpi_table_begin(&table, table_data);
|
|
|
|
build_append_int_noprefix(table_data, 1, 4); /* Reserved */
|
|
|
|
build_append_int_noprefix(table_data, 0, 8); /* Reserved */
|
2016-05-12 15:22:28 +03:00
|
|
|
|
2017-05-10 14:29:54 +03:00
|
|
|
for (i = 0; i < cpu_list->len; ++i) {
|
2021-09-24 15:27:44 +03:00
|
|
|
uint32_t nodeid = cpu_list->cpus[i].props.node_id;
|
|
|
|
/*
|
|
|
|
* 5.2.16.4 GICC Affinity Structure
|
|
|
|
*/
|
|
|
|
build_append_int_noprefix(table_data, 3, 1); /* Type */
|
|
|
|
build_append_int_noprefix(table_data, 18, 1); /* Length */
|
|
|
|
build_append_int_noprefix(table_data, nodeid, 4); /* Proximity Domain */
|
|
|
|
build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID */
|
|
|
|
/* Flags, Table 5-76 */
|
|
|
|
build_append_int_noprefix(table_data, 1 /* Enabled */, 4);
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Clock Domain */
|
2016-05-12 15:22:28 +03:00
|
|
|
}
|
|
|
|
|
2017-01-09 14:40:22 +03:00
|
|
|
mem_base = vms->memmap[VIRT_MEM].base;
|
2019-08-09 09:57:22 +03:00
|
|
|
for (i = 0; i < ms->numa_state->num_nodes; ++i) {
|
2019-08-09 09:57:24 +03:00
|
|
|
if (ms->numa_state->nodes[i].node_mem > 0) {
|
2021-09-24 15:27:44 +03:00
|
|
|
build_srat_memory(table_data, mem_base,
|
2019-08-09 09:57:24 +03:00
|
|
|
ms->numa_state->nodes[i].node_mem, i,
|
2018-09-25 16:02:30 +03:00
|
|
|
MEM_AFFINITY_ENABLED);
|
2019-08-09 09:57:24 +03:00
|
|
|
mem_base += ms->numa_state->nodes[i].node_mem;
|
2018-09-25 16:02:30 +03:00
|
|
|
}
|
2016-05-12 15:22:28 +03:00
|
|
|
}
|
|
|
|
|
2024-03-08 17:55:24 +03:00
|
|
|
build_srat_generic_pci_initiator(table_data);
|
|
|
|
|
hw/acpi/nvdimm: add a helper to augment SRAT generation
NVDIMMs can belong to their own proximity domains, as described by the
NFIT. In such cases, the SRAT needs to have Memory Affinity structures
in the SRAT for these NVDIMMs, otherwise Linux doesn't populate node
data structures properly during NUMA initialization. See the following
for an example failure case.
https://lore.kernel.org/linux-nvdimm/20200416225438.15208-1-vishal.l.verma@intel.com/
Introduce a new helper, nvdimm_build_srat(), and call it for both the
i386 and arm versions of 'build_srat()' to augment the SRAT with
memory affinity information for NVDIMMs.
The relevant command line options to exercise this are below. Nodes 0-1
contain CPUs and regular memory, and nodes 2-3 are the NVDIMM address
space.
-object memory-backend-ram,id=mem0,size=2048M
-numa node,nodeid=0,memdev=mem0,
-numa cpu,node-id=0,socket-id=0
-object memory-backend-ram,id=mem1,size=2048M
-numa node,nodeid=1,memdev=mem1,
-numa cpu,node-id=1,socket-id=1
-numa node,nodeid=2,
-object memory-backend-file,id=nvmem0,share,mem-path=nvdimm-0,size=16384M,align=1G
-device nvdimm,memdev=nvmem0,id=nv0,label-size=2M,node=2
-numa node,nodeid=3,
-object memory-backend-file,id=nvmem1,share,mem-path=nvdimm-1,size=16384M,align=1G
-device nvdimm,memdev=nvmem1,id=nv1,label-size=2M,node=3
Cc: Jingqi Liu <jingqi.liu@intel.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jingqi Liu <jingqi.liu@intel.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Message-Id: <20200606000911.9896-3-vishal.l.verma@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2020-06-06 03:09:10 +03:00
|
|
|
if (ms->nvdimms_state->is_enabled) {
|
|
|
|
nvdimm_build_srat(table_data);
|
|
|
|
}
|
|
|
|
|
2019-09-18 16:06:28 +03:00
|
|
|
if (ms->device_memory) {
|
2021-09-24 15:27:44 +03:00
|
|
|
build_srat_memory(table_data, ms->device_memory->base,
|
2019-09-18 16:06:28 +03:00
|
|
|
memory_region_size(&ms->device_memory->mr),
|
|
|
|
ms->numa_state->num_nodes - 1,
|
|
|
|
MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
|
|
|
|
}
|
|
|
|
|
2021-09-24 15:27:43 +03:00
|
|
|
acpi_table_end(linker, &table);
|
2016-05-12 15:22:28 +03:00
|
|
|
}
|
|
|
|
|
2021-09-24 15:27:59 +03:00
|
|
|
/*
|
2024-01-22 17:35:36 +03:00
|
|
|
* ACPI spec, Revision 6.5
|
|
|
|
* 5.2.25 Generic Timer Description Table (GTDT)
|
2021-09-24 15:27:59 +03:00
|
|
|
*/
|
2015-05-29 13:28:56 +03:00
|
|
|
static void
|
2017-01-09 14:40:23 +03:00
|
|
|
build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
2015-05-29 13:28:56 +03:00
|
|
|
{
|
2017-01-09 14:40:23 +03:00
|
|
|
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
|
2021-09-24 15:27:59 +03:00
|
|
|
/*
|
|
|
|
* Table 5-117 Flag Definitions
|
|
|
|
* set only "Timer interrupt Mode" and assume "Timer Interrupt
|
|
|
|
* polarity" bit as '0: Interrupt is Active high'
|
|
|
|
*/
|
|
|
|
uint32_t irqflags = vmc->claim_edge_triggered_timers ?
|
|
|
|
1 : /* Interrupt is Edge triggered */
|
|
|
|
0; /* Interrupt is Level triggered */
|
2024-01-22 17:35:36 +03:00
|
|
|
AcpiTable table = { .sig = "GTDT", .rev = 3, .oem_id = vms->oem_id,
|
2021-09-24 15:27:59 +03:00
|
|
|
.oem_table_id = vms->oem_table_id };
|
2015-05-29 13:28:56 +03:00
|
|
|
|
2021-09-24 15:27:59 +03:00
|
|
|
acpi_table_begin(&table, table_data);
|
2015-05-29 13:28:56 +03:00
|
|
|
|
2021-09-24 15:27:59 +03:00
|
|
|
/* CntControlBase Physical Address */
|
2022-09-20 19:21:36 +03:00
|
|
|
build_append_int_noprefix(table_data, 0xFFFFFFFFFFFFFFFF, 8);
|
2021-09-24 15:27:59 +03:00
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Reserved */
|
|
|
|
/*
|
|
|
|
* FIXME: clarify comment:
|
|
|
|
* The interrupt values are the same with the device tree when adding 16
|
|
|
|
*/
|
|
|
|
/* Secure EL1 timer GSIV */
|
2023-09-19 12:02:27 +03:00
|
|
|
build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ, 4);
|
2021-09-24 15:27:59 +03:00
|
|
|
/* Secure EL1 timer Flags */
|
|
|
|
build_append_int_noprefix(table_data, irqflags, 4);
|
|
|
|
/* Non-Secure EL1 timer GSIV */
|
2023-09-19 12:02:27 +03:00
|
|
|
build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ, 4);
|
2021-09-24 15:27:59 +03:00
|
|
|
/* Non-Secure EL1 timer Flags */
|
|
|
|
build_append_int_noprefix(table_data, irqflags |
|
|
|
|
1UL << 2, /* Always-on Capability */
|
|
|
|
4);
|
|
|
|
/* Virtual timer GSIV */
|
2023-09-19 12:02:27 +03:00
|
|
|
build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ, 4);
|
2021-09-24 15:27:59 +03:00
|
|
|
/* Virtual Timer Flags */
|
|
|
|
build_append_int_noprefix(table_data, irqflags, 4);
|
|
|
|
/* Non-Secure EL2 timer GSIV */
|
2023-09-19 12:02:27 +03:00
|
|
|
build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ, 4);
|
2021-09-24 15:27:59 +03:00
|
|
|
/* Non-Secure EL2 timer Flags */
|
|
|
|
build_append_int_noprefix(table_data, irqflags, 4);
|
|
|
|
/* CntReadBase Physical address */
|
2022-09-20 19:21:36 +03:00
|
|
|
build_append_int_noprefix(table_data, 0xFFFFFFFFFFFFFFFF, 8);
|
2021-09-24 15:27:59 +03:00
|
|
|
/* Platform Timer Count */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4);
|
|
|
|
/* Platform Timer Offset */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4);
|
2024-01-22 17:35:36 +03:00
|
|
|
if (vms->ns_el2_virt_timer_irq) {
|
|
|
|
/* Virtual EL2 Timer GSIV */
|
|
|
|
build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_VIRT_IRQ, 4);
|
|
|
|
/* Virtual EL2 Timer Flags */
|
|
|
|
build_append_int_noprefix(table_data, irqflags, 4);
|
|
|
|
} else {
|
|
|
|
build_append_int_noprefix(table_data, 0, 4);
|
|
|
|
build_append_int_noprefix(table_data, 0, 4);
|
|
|
|
}
|
2021-09-24 15:27:59 +03:00
|
|
|
acpi_table_end(linker, &table);
|
2015-05-29 13:28:56 +03:00
|
|
|
}
|
|
|
|
|
2021-10-19 11:00:36 +03:00
|
|
|
/* Debug Port Table 2 (DBG2) */
|
|
|
|
static void
|
|
|
|
build_dbg2(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|
|
|
{
|
|
|
|
AcpiTable table = { .sig = "DBG2", .rev = 0, .oem_id = vms->oem_id,
|
|
|
|
.oem_table_id = vms->oem_table_id };
|
|
|
|
int dbg2devicelength;
|
|
|
|
const char name[] = "COM0";
|
|
|
|
const int namespace_length = sizeof(name);
|
|
|
|
|
|
|
|
acpi_table_begin(&table, table_data);
|
|
|
|
|
|
|
|
dbg2devicelength = 22 + /* BaseAddressRegister[] offset */
|
|
|
|
12 + /* BaseAddressRegister[] */
|
|
|
|
4 + /* AddressSize[] */
|
|
|
|
namespace_length /* NamespaceString[] */;
|
|
|
|
|
|
|
|
/* OffsetDbgDeviceInfo */
|
|
|
|
build_append_int_noprefix(table_data, 44, 4);
|
|
|
|
/* NumberDbgDeviceInfo */
|
|
|
|
build_append_int_noprefix(table_data, 1, 4);
|
|
|
|
|
|
|
|
/* Table 2. Debug Device Information structure format */
|
|
|
|
build_append_int_noprefix(table_data, 0, 1); /* Revision */
|
|
|
|
build_append_int_noprefix(table_data, dbg2devicelength, 2); /* Length */
|
|
|
|
/* NumberofGenericAddressRegisters */
|
|
|
|
build_append_int_noprefix(table_data, 1, 1);
|
|
|
|
/* NameSpaceStringLength */
|
|
|
|
build_append_int_noprefix(table_data, namespace_length, 2);
|
|
|
|
build_append_int_noprefix(table_data, 38, 2); /* NameSpaceStringOffset */
|
|
|
|
build_append_int_noprefix(table_data, 0, 2); /* OemDataLength */
|
|
|
|
/* OemDataOffset (0 means no OEM data) */
|
|
|
|
build_append_int_noprefix(table_data, 0, 2);
|
|
|
|
|
|
|
|
/* Port Type */
|
|
|
|
build_append_int_noprefix(table_data, 0x8000 /* Serial */, 2);
|
|
|
|
/* Port Subtype */
|
|
|
|
build_append_int_noprefix(table_data, 0x3 /* ARM PL011 UART */, 2);
|
|
|
|
build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
|
|
|
/* BaseAddressRegisterOffset */
|
|
|
|
build_append_int_noprefix(table_data, 22, 2);
|
|
|
|
/* AddressSizeOffset */
|
|
|
|
build_append_int_noprefix(table_data, 34, 2);
|
|
|
|
|
|
|
|
/* BaseAddressRegister[] */
|
hw/arm/virt: Report correct register sizes in ACPI DBG2/SPCR tables.
Documentation for using the GAS in ACPI tables to report debug UART addresses at
https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table
states the following:
- The Register Bit Width field contains the register stride and must be a
power of 2 that is at least as large as the access size. On 32-bit
platforms this value cannot exceed 32. On 64-bit platforms this value
cannot exceed 64.
- The Access Size field is used to determine whether byte, WORD, DWORD, or
QWORD accesses are to be used. QWORD accesses are only valid on 64-bit
architectures.
Documentation for the ARM PL011 at
https://developer.arm.com/documentation/ddi0183/latest/
states that the registers are:
- spaced 4 bytes apart (see Table 3-2), so register stride must be 32.
- 16 bits in size in some cases (see individual registers), so access
size must be at least 2.
Linux doesn't seem to care about this error in the table, but it does
affect at least the NOVA microhypervisor.
In theory we therefore have a choice between reporting the access
size as 2 (16 bit accesses) or 3 (32-bit accesses). In practice,
Linux does not correctly handle the case where the table reports the
access size as 2: as of kernel commit 750b95887e5678, the code in
acpi_parse_spcr() tries to tell the serial driver to use 16 bit
accesses by passing "mmio16" in the option string, but the PL011
driver code in pl011_console_match() only recognizes "mmio" or
"mmio32". The result is that unless the user has enabled 'earlycon'
there is no console output from the guest kernel.
We therefore choose to report the access size as 32 bits; this works
for NOVA and also for Linux. It is also what the UEFI firmware on a
Raspberry Pi 4 reports, so we're in line with existing real-world
practice.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1938
Signed-off-by: Udo Steinberg <udo@hypervisor.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: minor commit message tweaks; use 32 bit accesses]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2023-11-06 18:00:26 +03:00
|
|
|
build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 32, 0, 3,
|
2024-06-10 19:23:42 +03:00
|
|
|
vms->memmap[VIRT_UART0].base);
|
2021-10-19 11:00:36 +03:00
|
|
|
|
|
|
|
/* AddressSize[] */
|
|
|
|
build_append_int_noprefix(table_data,
|
2024-06-10 19:23:42 +03:00
|
|
|
vms->memmap[VIRT_UART0].size, 4);
|
2021-10-19 11:00:36 +03:00
|
|
|
|
|
|
|
/* NamespaceString[] */
|
|
|
|
g_array_append_vals(table_data, name, namespace_length);
|
|
|
|
|
|
|
|
acpi_table_end(linker, &table);
|
|
|
|
};
|
|
|
|
|
2021-09-24 15:27:48 +03:00
|
|
|
/*
|
2022-10-11 21:17:29 +03:00
|
|
|
* ACPI spec, Revision 6.0 Errata A
|
2021-09-24 15:27:48 +03:00
|
|
|
* 5.2.12 Multiple APIC Description Table (MADT)
|
|
|
|
*/
|
2021-09-24 15:27:52 +03:00
|
|
|
static void build_append_gicr(GArray *table_data, uint64_t base, uint32_t size)
|
|
|
|
{
|
|
|
|
build_append_int_noprefix(table_data, 0xE, 1); /* Type */
|
|
|
|
build_append_int_noprefix(table_data, 16, 1); /* Length */
|
|
|
|
build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
2023-04-20 12:21:13 +03:00
|
|
|
/* Discovery Range Base Address */
|
2021-09-24 15:27:52 +03:00
|
|
|
build_append_int_noprefix(table_data, base, 8);
|
|
|
|
build_append_int_noprefix(table_data, size, 4); /* Discovery Range Length */
|
|
|
|
}
|
|
|
|
|
2015-05-29 13:28:56 +03:00
|
|
|
static void
|
2017-01-09 14:40:22 +03:00
|
|
|
build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
2015-05-29 13:28:56 +03:00
|
|
|
{
|
2021-09-24 15:27:52 +03:00
|
|
|
int i;
|
2017-01-09 14:40:22 +03:00
|
|
|
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
|
|
|
|
const MemMapEntry *memmap = vms->memmap;
|
2022-10-11 21:17:29 +03:00
|
|
|
AcpiTable table = { .sig = "APIC", .rev = 4, .oem_id = vms->oem_id,
|
2021-09-24 15:27:48 +03:00
|
|
|
.oem_table_id = vms->oem_table_id };
|
2015-05-29 13:28:56 +03:00
|
|
|
|
2021-09-24 15:27:48 +03:00
|
|
|
acpi_table_begin(&table, table_data);
|
|
|
|
/* Local Interrupt Controller Address */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4);
|
2021-09-24 15:27:52 +03:00
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Flags */
|
|
|
|
|
|
|
|
/* 5.2.12.15 GIC Distributor Structure */
|
|
|
|
build_append_int_noprefix(table_data, 0xC, 1); /* Type */
|
|
|
|
build_append_int_noprefix(table_data, 24, 1); /* Length */
|
|
|
|
build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* GIC ID */
|
|
|
|
/* Physical Base Address */
|
|
|
|
build_append_int_noprefix(table_data, memmap[VIRT_GIC_DIST].base, 8);
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* System Vector Base */
|
|
|
|
/* GIC version */
|
|
|
|
build_append_int_noprefix(table_data, vms->gic_version, 1);
|
|
|
|
build_append_int_noprefix(table_data, 0, 3); /* Reserved */
|
2015-05-29 13:28:56 +03:00
|
|
|
|
2020-12-15 20:48:15 +03:00
|
|
|
for (i = 0; i < MACHINE(vms)->smp.cpus; i++) {
|
2015-11-03 16:49:42 +03:00
|
|
|
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
|
2021-09-24 15:27:52 +03:00
|
|
|
uint64_t physical_base_address = 0, gich = 0, gicv = 0;
|
2023-09-19 12:02:27 +03:00
|
|
|
uint32_t vgic_interrupt = vms->virt ? ARCH_GIC_MAINT_IRQ : 0;
|
2021-09-24 15:27:52 +03:00
|
|
|
uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ?
|
2023-09-19 12:02:27 +03:00
|
|
|
VIRTUAL_PMU_IRQ : 0;
|
2015-11-03 16:49:42 +03:00
|
|
|
|
2022-08-12 05:20:18 +03:00
|
|
|
if (vms->gic_version == VIRT_GIC_VERSION_2) {
|
2021-09-24 15:27:52 +03:00
|
|
|
physical_base_address = memmap[VIRT_GIC_CPU].base;
|
|
|
|
gicv = memmap[VIRT_GIC_VCPU].base;
|
|
|
|
gich = memmap[VIRT_GIC_HYP].base;
|
2015-11-03 16:49:42 +03:00
|
|
|
}
|
2016-06-14 17:59:12 +03:00
|
|
|
|
2021-09-24 15:27:52 +03:00
|
|
|
/* 5.2.12.14 GIC Structure */
|
|
|
|
build_append_int_noprefix(table_data, 0xB, 1); /* Type */
|
2022-10-11 21:17:29 +03:00
|
|
|
build_append_int_noprefix(table_data, 80, 1); /* Length */
|
2021-09-24 15:27:52 +03:00
|
|
|
build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
|
|
|
build_append_int_noprefix(table_data, i, 4); /* GIC ID */
|
|
|
|
build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID */
|
|
|
|
/* Flags */
|
|
|
|
build_append_int_noprefix(table_data, 1, 4); /* Enabled */
|
|
|
|
/* Parking Protocol Version */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4);
|
|
|
|
/* Performance Interrupt GSIV */
|
|
|
|
build_append_int_noprefix(table_data, pmu_interrupt, 4);
|
|
|
|
build_append_int_noprefix(table_data, 0, 8); /* Parked Address */
|
|
|
|
/* Physical Base Address */
|
|
|
|
build_append_int_noprefix(table_data, physical_base_address, 8);
|
|
|
|
build_append_int_noprefix(table_data, gicv, 8); /* GICV */
|
|
|
|
build_append_int_noprefix(table_data, gich, 8); /* GICH */
|
|
|
|
/* VGIC Maintenance interrupt */
|
|
|
|
build_append_int_noprefix(table_data, vgic_interrupt, 4);
|
|
|
|
build_append_int_noprefix(table_data, 0, 8); /* GICR Base Address*/
|
|
|
|
/* MPIDR */
|
2024-01-18 23:06:30 +03:00
|
|
|
build_append_int_noprefix(table_data, arm_cpu_mp_affinity(armcpu), 8);
|
2022-10-11 21:17:29 +03:00
|
|
|
/* Processor Power Efficiency Class */
|
|
|
|
build_append_int_noprefix(table_data, 0, 1);
|
|
|
|
/* Reserved */
|
|
|
|
build_append_int_noprefix(table_data, 0, 3);
|
2015-11-03 16:49:42 +03:00
|
|
|
}
|
|
|
|
|
2022-08-12 05:20:18 +03:00
|
|
|
if (vms->gic_version != VIRT_GIC_VERSION_2) {
|
2021-09-24 15:27:52 +03:00
|
|
|
build_append_gicr(table_data, memmap[VIRT_GIC_REDIST].base,
|
|
|
|
memmap[VIRT_GIC_REDIST].size);
|
|
|
|
if (virt_gicv3_redist_region_count(vms) == 2) {
|
|
|
|
build_append_gicr(table_data, memmap[VIRT_HIGH_GIC_REDIST2].base,
|
|
|
|
memmap[VIRT_HIGH_GIC_REDIST2].size);
|
2018-06-22 15:28:36 +03:00
|
|
|
}
|
|
|
|
|
2017-01-09 14:40:22 +03:00
|
|
|
if (its_class_name() && !vmc->no_its) {
|
2021-09-24 15:27:52 +03:00
|
|
|
/*
|
|
|
|
* ACPI spec, Revision 6.0 Errata A
|
|
|
|
* (original 6.0 definition has invalid Length)
|
|
|
|
* 5.2.12.18 GIC ITS Structure
|
|
|
|
*/
|
|
|
|
build_append_int_noprefix(table_data, 0xF, 1); /* Type */
|
|
|
|
build_append_int_noprefix(table_data, 20, 1); /* Length */
|
|
|
|
build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* GIC ITS ID */
|
|
|
|
/* Physical Base Address */
|
|
|
|
build_append_int_noprefix(table_data, memmap[VIRT_GIC_ITS].base, 8);
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* Reserved */
|
2016-10-04 15:28:09 +03:00
|
|
|
}
|
2015-09-24 03:29:37 +03:00
|
|
|
} else {
|
2021-09-24 15:27:52 +03:00
|
|
|
const uint16_t spi_base = vms->irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE;
|
|
|
|
|
|
|
|
/* 5.2.12.16 GIC MSI Frame Structure */
|
|
|
|
build_append_int_noprefix(table_data, 0xD, 1); /* Type */
|
|
|
|
build_append_int_noprefix(table_data, 24, 1); /* Length */
|
|
|
|
build_append_int_noprefix(table_data, 0, 2); /* Reserved */
|
|
|
|
build_append_int_noprefix(table_data, 0, 4); /* GIC MSI Frame ID */
|
|
|
|
/* Physical Base Address */
|
|
|
|
build_append_int_noprefix(table_data, memmap[VIRT_GIC_V2M].base, 8);
|
|
|
|
build_append_int_noprefix(table_data, 1, 4); /* Flags */
|
|
|
|
/* SPI Count */
|
|
|
|
build_append_int_noprefix(table_data, NUM_GICV2M_SPIS, 2);
|
|
|
|
build_append_int_noprefix(table_data, spi_base, 2); /* SPI Base */
|
2015-09-24 03:29:37 +03:00
|
|
|
}
|
2021-09-24 15:27:48 +03:00
|
|
|
acpi_table_end(linker, &table);
|
2015-05-29 13:28:56 +03:00
|
|
|
}
|
|
|
|
|
2015-05-29 13:28:55 +03:00
|
|
|
/* FADT */
|
2022-10-11 21:17:28 +03:00
|
|
|
static void build_fadt_rev6(GArray *table_data, BIOSLinker *linker,
|
2018-02-28 17:23:53 +03:00
|
|
|
VirtMachineState *vms, unsigned dsdt_tbl_offset)
|
2015-05-29 13:28:55 +03:00
|
|
|
{
|
2024-01-22 17:35:36 +03:00
|
|
|
/* ACPI v6.3 */
|
2018-02-28 17:23:54 +03:00
|
|
|
AcpiFadtData fadt = {
|
2022-10-11 21:17:28 +03:00
|
|
|
.rev = 6,
|
2024-01-22 17:35:36 +03:00
|
|
|
.minor_ver = 3,
|
2018-02-28 17:23:54 +03:00
|
|
|
.flags = 1 << ACPI_FADT_F_HW_REDUCED_ACPI,
|
|
|
|
.xdsdt_tbl_offset = &dsdt_tbl_offset,
|
|
|
|
};
|
2017-01-20 14:15:10 +03:00
|
|
|
|
|
|
|
switch (vms->psci_conduit) {
|
|
|
|
case QEMU_PSCI_CONDUIT_DISABLED:
|
2018-02-28 17:23:54 +03:00
|
|
|
fadt.arm_boot_arch = 0;
|
2017-01-20 14:15:10 +03:00
|
|
|
break;
|
|
|
|
case QEMU_PSCI_CONDUIT_HVC:
|
2018-02-28 17:23:54 +03:00
|
|
|
fadt.arm_boot_arch = ACPI_FADT_ARM_PSCI_COMPLIANT |
|
|
|
|
ACPI_FADT_ARM_PSCI_USE_HVC;
|
2017-01-20 14:15:10 +03:00
|
|
|
break;
|
|
|
|
case QEMU_PSCI_CONDUIT_SMC:
|
2018-02-28 17:23:54 +03:00
|
|
|
fadt.arm_boot_arch = ACPI_FADT_ARM_PSCI_COMPLIANT;
|
2017-01-20 14:15:10 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
2015-05-29 13:28:55 +03:00
|
|
|
|
2021-01-19 03:32:13 +03:00
|
|
|
build_fadt(table_data, linker, &fadt, vms->oem_id, vms->oem_table_id);
|
2015-05-29 13:28:55 +03:00
|
|
|
}
|
|
|
|
|
2015-05-29 13:28:55 +03:00
|
|
|
/* DSDT */
|
|
|
|
static void
|
2017-01-09 14:40:22 +03:00
|
|
|
build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
2015-05-29 13:28:55 +03:00
|
|
|
{
|
2020-07-03 18:59:43 +03:00
|
|
|
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
|
2015-05-29 13:28:55 +03:00
|
|
|
Aml *scope, *dsdt;
|
2019-09-18 16:06:27 +03:00
|
|
|
MachineState *ms = MACHINE(vms);
|
2017-01-09 14:40:22 +03:00
|
|
|
const MemMapEntry *memmap = vms->memmap;
|
|
|
|
const int *irqmap = vms->irqmap;
|
2021-09-24 15:27:54 +03:00
|
|
|
AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = vms->oem_id,
|
|
|
|
.oem_table_id = vms->oem_table_id };
|
2015-05-29 13:28:55 +03:00
|
|
|
|
2021-09-24 15:27:54 +03:00
|
|
|
acpi_table_begin(&table, table_data);
|
2015-05-29 13:28:55 +03:00
|
|
|
dsdt = init_aml_allocator();
|
|
|
|
|
2016-01-15 17:11:31 +03:00
|
|
|
/* When booting the VM with UEFI, UEFI takes ownership of the RTC hardware.
|
|
|
|
* While UEFI can use libfdt to disable the RTC device node in the DTB that
|
|
|
|
* it passes to the OS, it cannot modify AML. Therefore, we won't generate
|
|
|
|
* the RTC ACPI device at all when using UEFI.
|
|
|
|
*/
|
2015-05-29 13:28:55 +03:00
|
|
|
scope = aml_scope("\\_SB");
|
2020-12-15 20:48:15 +03:00
|
|
|
acpi_dsdt_add_cpus(scope, vms);
|
2024-06-10 19:23:42 +03:00
|
|
|
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART0],
|
2024-06-10 19:23:43 +03:00
|
|
|
(irqmap[VIRT_UART0] + ARM_SPI_BASE), 0);
|
|
|
|
if (vms->second_ns_uart_present) {
|
|
|
|
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART1],
|
|
|
|
(irqmap[VIRT_UART1] + ARM_SPI_BASE), 1);
|
|
|
|
}
|
2020-07-03 18:59:43 +03:00
|
|
|
if (vmc->acpi_expose_flash) {
|
|
|
|
acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
|
|
|
|
}
|
2023-12-18 18:02:35 +03:00
|
|
|
fw_cfg_acpi_dsdt_add(scope, &memmap[VIRT_FW_CFG]);
|
2023-12-18 18:02:36 +03:00
|
|
|
virtio_acpi_dsdt_add(scope, memmap[VIRT_MMIO].base, memmap[VIRT_MMIO].size,
|
|
|
|
(irqmap[VIRT_MMIO] + ARM_SPI_BASE),
|
|
|
|
0, NUM_VIRTIO_TRANSPORTS);
|
2022-01-14 17:07:36 +03:00
|
|
|
acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms);
|
2019-09-18 16:06:27 +03:00
|
|
|
if (vms->acpi_dev) {
|
|
|
|
build_ged_aml(scope, "\\_SB."GED_DEVICE,
|
|
|
|
HOTPLUG_HANDLER(vms->acpi_dev),
|
|
|
|
irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY,
|
|
|
|
memmap[VIRT_ACPI_GED].base);
|
2019-09-18 16:06:30 +03:00
|
|
|
} else {
|
|
|
|
acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
|
|
|
|
(irqmap[VIRT_GPIO] + ARM_SPI_BASE));
|
2019-09-18 16:06:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (vms->acpi_dev) {
|
|
|
|
uint32_t event = object_property_get_uint(OBJECT(vms->acpi_dev),
|
|
|
|
"ged-event", &error_abort);
|
|
|
|
|
|
|
|
if (event & ACPI_GED_MEM_HOTPLUG_EVT) {
|
|
|
|
build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB", NULL,
|
|
|
|
AML_SYSTEM_MEMORY,
|
|
|
|
memmap[VIRT_PCDIMM_ACPI].base);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-17 16:37:14 +03:00
|
|
|
acpi_dsdt_add_power_button(scope);
|
2021-06-15 17:21:18 +03:00
|
|
|
#ifdef CONFIG_TPM
|
2020-06-22 17:06:19 +03:00
|
|
|
acpi_dsdt_add_tpm(scope, vms);
|
2021-06-15 17:21:18 +03:00
|
|
|
#endif
|
2015-05-29 13:28:59 +03:00
|
|
|
|
2015-05-29 13:28:55 +03:00
|
|
|
aml_append(dsdt, scope);
|
|
|
|
|
2021-09-24 15:27:54 +03:00
|
|
|
/* copy AML table into ACPI tables blob */
|
2015-05-29 13:28:55 +03:00
|
|
|
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
|
2021-09-24 15:27:54 +03:00
|
|
|
|
|
|
|
acpi_table_end(linker, &table);
|
2015-05-29 13:28:55 +03:00
|
|
|
free_aml_allocator();
|
|
|
|
}
|
|
|
|
|
2015-05-29 13:28:54 +03:00
|
|
|
typedef
|
|
|
|
struct AcpiBuildState {
|
|
|
|
/* Copy of table in RAM (for patching). */
|
|
|
|
MemoryRegion *table_mr;
|
|
|
|
MemoryRegion *rsdp_mr;
|
|
|
|
MemoryRegion *linker_mr;
|
|
|
|
/* Is table patched? */
|
|
|
|
bool patched;
|
|
|
|
} AcpiBuildState;
|
|
|
|
|
2020-11-19 04:48:38 +03:00
|
|
|
static void acpi_align_size(GArray *blob, unsigned align)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Align size to multiple of given size. This reduces the chance
|
|
|
|
* we need to change size in the future (breaking cross version migration).
|
|
|
|
*/
|
|
|
|
g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align));
|
|
|
|
}
|
|
|
|
|
2015-05-29 13:28:54 +03:00
|
|
|
static
|
2017-01-09 14:40:22 +03:00
|
|
|
void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
|
2015-05-29 13:28:54 +03:00
|
|
|
{
|
2017-01-09 14:40:22 +03:00
|
|
|
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
|
2015-05-29 13:28:54 +03:00
|
|
|
GArray *table_offsets;
|
2017-04-10 18:03:50 +03:00
|
|
|
unsigned dsdt, xsdt;
|
2015-05-29 13:28:55 +03:00
|
|
|
GArray *tables_blob = tables->table_data;
|
2019-08-09 09:57:22 +03:00
|
|
|
MachineState *ms = MACHINE(vms);
|
2015-05-29 13:28:54 +03:00
|
|
|
|
|
|
|
table_offsets = g_array_new(false, true /* clear */,
|
|
|
|
sizeof(uint32_t));
|
|
|
|
|
2016-05-19 16:19:26 +03:00
|
|
|
bios_linker_loader_alloc(tables->linker,
|
|
|
|
ACPI_BUILD_TABLE_FILE, tables_blob,
|
2015-05-29 13:28:54 +03:00
|
|
|
64, false /* high memory */);
|
|
|
|
|
2015-05-29 13:28:55 +03:00
|
|
|
/* DSDT is pointed to by FADT */
|
2015-05-29 13:28:55 +03:00
|
|
|
dsdt = tables_blob->len;
|
2017-01-09 14:40:22 +03:00
|
|
|
build_dsdt(tables_blob, tables->linker, vms);
|
2015-05-29 13:28:55 +03:00
|
|
|
|
2021-10-20 17:21:24 +03:00
|
|
|
/* FADT MADT PPTT GTDT MCFG SPCR DBG2 pointed to by RSDT */
|
2015-05-29 13:28:55 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2022-10-11 21:17:28 +03:00
|
|
|
build_fadt_rev6(tables_blob, tables->linker, vms, dsdt);
|
2015-05-29 13:28:55 +03:00
|
|
|
|
2015-05-29 13:28:56 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2017-01-09 14:40:22 +03:00
|
|
|
build_madt(tables_blob, tables->linker, vms);
|
2015-05-29 13:28:56 +03:00
|
|
|
|
2021-10-20 17:21:24 +03:00
|
|
|
if (!vmc->no_cpu_topology) {
|
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
|
|
|
build_pptt(tables_blob, tables->linker, ms,
|
|
|
|
vms->oem_id, vms->oem_table_id);
|
|
|
|
}
|
|
|
|
|
2015-05-29 13:28:56 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2017-01-09 14:40:23 +03:00
|
|
|
build_gtdt(tables_blob, tables->linker, vms);
|
2015-05-29 13:28:56 +03:00
|
|
|
|
2015-05-29 13:28:57 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2019-04-19 03:30:51 +03:00
|
|
|
{
|
|
|
|
AcpiMcfgInfo mcfg = {
|
|
|
|
.base = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].base,
|
|
|
|
.size = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].size,
|
|
|
|
};
|
2021-01-19 03:32:13 +03:00
|
|
|
build_mcfg(tables_blob, tables->linker, &mcfg, vms->oem_id,
|
|
|
|
vms->oem_table_id);
|
2019-04-19 03:30:51 +03:00
|
|
|
}
|
2015-05-29 13:28:57 +03:00
|
|
|
|
2015-06-15 20:06:11 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2024-01-29 05:14:39 +03:00
|
|
|
spcr_setup(tables_blob, tables->linker, vms);
|
2015-06-15 20:06:11 +03:00
|
|
|
|
2021-10-19 11:00:36 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
|
|
|
build_dbg2(tables_blob, tables->linker, vms);
|
|
|
|
|
2020-05-12 06:06:03 +03:00
|
|
|
if (vms->ras) {
|
|
|
|
build_ghes_error_table(tables->hardware_errors, tables->linker);
|
2020-05-12 06:06:04 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2021-01-19 03:32:13 +03:00
|
|
|
acpi_build_hest(tables_blob, tables->linker, vms->oem_id,
|
|
|
|
vms->oem_table_id);
|
2020-05-12 06:06:03 +03:00
|
|
|
}
|
|
|
|
|
2019-08-09 09:57:22 +03:00
|
|
|
if (ms->numa_state->num_nodes > 0) {
|
2016-05-12 15:22:28 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2017-01-09 14:40:22 +03:00
|
|
|
build_srat(tables_blob, tables->linker, vms);
|
2019-08-09 09:57:23 +03:00
|
|
|
if (ms->numa_state->have_numa_distance) {
|
2017-06-02 13:51:49 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2021-01-19 03:32:13 +03:00
|
|
|
build_slit(tables_blob, tables->linker, ms, vms->oem_id,
|
|
|
|
vms->oem_table_id);
|
2017-06-02 13:51:49 +03:00
|
|
|
}
|
2022-10-27 13:00:35 +03:00
|
|
|
|
|
|
|
if (ms->numa_state->hmat_enabled) {
|
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
|
|
|
build_hmat(tables_blob, tables->linker, ms->numa_state,
|
|
|
|
vms->oem_id, vms->oem_table_id);
|
|
|
|
}
|
2016-05-12 15:22:28 +03:00
|
|
|
}
|
|
|
|
|
2020-04-21 15:59:30 +03:00
|
|
|
if (ms->nvdimms_state->is_enabled) {
|
|
|
|
nvdimm_build_acpi(table_offsets, tables_blob, tables->linker,
|
2021-01-19 03:32:13 +03:00
|
|
|
ms->nvdimms_state, ms->ram_slots, vms->oem_id,
|
|
|
|
vms->oem_table_id);
|
2020-04-21 15:59:30 +03:00
|
|
|
}
|
|
|
|
|
2017-01-09 14:40:22 +03:00
|
|
|
if (its_class_name() && !vmc->no_its) {
|
2016-10-24 18:26:54 +03:00
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2018-05-04 20:05:52 +03:00
|
|
|
build_iort(tables_blob, tables->linker, vms);
|
2016-10-24 18:26:54 +03:00
|
|
|
}
|
|
|
|
|
2021-06-15 17:21:18 +03:00
|
|
|
#ifdef CONFIG_TPM
|
2020-06-01 12:57:36 +03:00
|
|
|
if (tpm_get_version(tpm_find()) == TPM_VERSION_2_0) {
|
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
2021-01-19 03:32:13 +03:00
|
|
|
build_tpm2(tables_blob, tables->linker, tables->tcpalog, vms->oem_id,
|
|
|
|
vms->oem_table_id);
|
2020-06-01 12:57:36 +03:00
|
|
|
}
|
2021-06-15 17:21:18 +03:00
|
|
|
#endif
|
2020-06-01 12:57:36 +03:00
|
|
|
|
2021-12-10 20:04:09 +03:00
|
|
|
if (vms->iommu == VIRT_IOMMU_VIRTIO) {
|
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
|
|
|
build_viot(ms, tables_blob, tables->linker, vms->virtio_iommu_bdf,
|
|
|
|
vms->oem_id, vms->oem_table_id);
|
|
|
|
}
|
|
|
|
|
2017-04-10 18:03:50 +03:00
|
|
|
/* XSDT is pointed to by RSDP */
|
|
|
|
xsdt = tables_blob->len;
|
2021-01-19 03:32:13 +03:00
|
|
|
build_xsdt(tables_blob, tables->linker, table_offsets, vms->oem_id,
|
|
|
|
vms->oem_table_id);
|
2015-05-29 13:28:56 +03:00
|
|
|
|
2015-05-29 13:28:56 +03:00
|
|
|
/* RSDP is in FSEG memory, so allocate it separately */
|
2018-12-17 13:48:34 +03:00
|
|
|
{
|
|
|
|
AcpiRsdpData rsdp_data = {
|
|
|
|
.revision = 2,
|
2021-01-19 03:32:13 +03:00
|
|
|
.oem_id = vms->oem_id,
|
2018-12-17 13:48:34 +03:00
|
|
|
.xsdt_tbl_offset = &xsdt,
|
|
|
|
.rsdt_tbl_offset = NULL,
|
|
|
|
};
|
|
|
|
build_rsdp(tables->rsdp, tables->linker, &rsdp_data);
|
|
|
|
}
|
2015-05-29 13:28:56 +03:00
|
|
|
|
2020-11-19 04:48:38 +03:00
|
|
|
/*
|
|
|
|
* The align size is 128, warn if 64k is not enough therefore
|
|
|
|
* the align size could be resized.
|
|
|
|
*/
|
|
|
|
if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) {
|
|
|
|
warn_report("ACPI table size %u exceeds %d bytes,"
|
|
|
|
" migration may not work",
|
|
|
|
tables_blob->len, ACPI_BUILD_TABLE_SIZE / 2);
|
|
|
|
error_printf("Try removing CPUs, NUMA nodes, memory slots"
|
2024-01-30 19:37:41 +03:00
|
|
|
" or PCI bridges.\n");
|
2020-11-19 04:48:38 +03:00
|
|
|
}
|
|
|
|
acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE);
|
|
|
|
|
|
|
|
|
2015-05-29 13:28:54 +03:00
|
|
|
/* Cleanup memory that's no longer used. */
|
|
|
|
g_array_free(table_offsets, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void acpi_ram_update(MemoryRegion *mr, GArray *data)
|
|
|
|
{
|
|
|
|
uint32_t size = acpi_data_len(data);
|
|
|
|
|
|
|
|
/* Make sure RAM size is correct - in case it got changed
|
|
|
|
* e.g. by migration */
|
|
|
|
memory_region_ram_resize(mr, size, &error_abort);
|
|
|
|
|
|
|
|
memcpy(memory_region_get_ram_ptr(mr), data->data, size);
|
|
|
|
memory_region_set_dirty(mr, 0, size);
|
|
|
|
}
|
|
|
|
|
2015-11-05 17:32:49 +03:00
|
|
|
static void virt_acpi_build_update(void *build_opaque)
|
2015-05-29 13:28:54 +03:00
|
|
|
{
|
|
|
|
AcpiBuildState *build_state = build_opaque;
|
|
|
|
AcpiBuildTables tables;
|
|
|
|
|
|
|
|
/* No state to update or already patched? Nothing to do. */
|
|
|
|
if (!build_state || build_state->patched) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
build_state->patched = true;
|
|
|
|
|
|
|
|
acpi_build_tables_init(&tables);
|
|
|
|
|
2017-01-09 14:40:22 +03:00
|
|
|
virt_acpi_build(VIRT_MACHINE(qdev_get_machine()), &tables);
|
2015-05-29 13:28:54 +03:00
|
|
|
|
|
|
|
acpi_ram_update(build_state->table_mr, tables.table_data);
|
|
|
|
acpi_ram_update(build_state->rsdp_mr, tables.rsdp);
|
2016-05-19 16:19:25 +03:00
|
|
|
acpi_ram_update(build_state->linker_mr, tables.linker->cmd_blob);
|
2015-05-29 13:28:54 +03:00
|
|
|
|
|
|
|
acpi_build_tables_cleanup(&tables, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void virt_acpi_build_reset(void *build_opaque)
|
|
|
|
{
|
|
|
|
AcpiBuildState *build_state = build_opaque;
|
|
|
|
build_state->patched = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription vmstate_virt_acpi_build = {
|
|
|
|
.name = "virt_acpi_build",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2023-12-21 06:15:59 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2015-05-29 13:28:54 +03:00
|
|
|
VMSTATE_BOOL(patched, AcpiBuildState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2017-01-09 14:40:22 +03:00
|
|
|
void virt_acpi_setup(VirtMachineState *vms)
|
2015-05-29 13:28:54 +03:00
|
|
|
{
|
|
|
|
AcpiBuildTables tables;
|
|
|
|
AcpiBuildState *build_state;
|
2020-05-12 06:06:05 +03:00
|
|
|
AcpiGedState *acpi_ged_state;
|
2015-05-29 13:28:54 +03:00
|
|
|
|
2017-01-09 14:40:23 +03:00
|
|
|
if (!vms->fw_cfg) {
|
2015-05-29 13:28:54 +03:00
|
|
|
trace_virt_acpi_setup();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-20 13:01:36 +03:00
|
|
|
if (!virt_is_acpi_enabled(vms)) {
|
2015-05-29 13:28:54 +03:00
|
|
|
trace_virt_acpi_setup();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
build_state = g_malloc0(sizeof *build_state);
|
|
|
|
|
|
|
|
acpi_build_tables_init(&tables);
|
2017-01-09 14:40:22 +03:00
|
|
|
virt_acpi_build(vms, &tables);
|
2015-05-29 13:28:54 +03:00
|
|
|
|
|
|
|
/* Now expose it all to Guest */
|
2019-06-10 04:18:30 +03:00
|
|
|
build_state->table_mr = acpi_add_rom_blob(virt_acpi_build_update,
|
|
|
|
build_state, tables.table_data,
|
2021-03-04 13:55:53 +03:00
|
|
|
ACPI_BUILD_TABLE_FILE);
|
2015-05-29 13:28:54 +03:00
|
|
|
assert(build_state->table_mr != NULL);
|
|
|
|
|
2021-03-04 13:55:53 +03:00
|
|
|
build_state->linker_mr = acpi_add_rom_blob(virt_acpi_build_update,
|
|
|
|
build_state,
|
|
|
|
tables.linker->cmd_blob,
|
|
|
|
ACPI_BUILD_LOADER_FILE);
|
2015-05-29 13:28:54 +03:00
|
|
|
|
2017-01-09 14:40:23 +03:00
|
|
|
fw_cfg_add_file(vms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data,
|
|
|
|
acpi_data_len(tables.tcpalog));
|
2015-05-29 13:28:54 +03:00
|
|
|
|
2020-05-12 06:06:05 +03:00
|
|
|
if (vms->ras) {
|
|
|
|
assert(vms->acpi_dev);
|
|
|
|
acpi_ged_state = ACPI_GED(vms->acpi_dev);
|
|
|
|
acpi_ghes_add_fw_cfg(&acpi_ged_state->ghes_state,
|
|
|
|
vms->fw_cfg, tables.hardware_errors);
|
|
|
|
}
|
|
|
|
|
2019-06-10 04:18:30 +03:00
|
|
|
build_state->rsdp_mr = acpi_add_rom_blob(virt_acpi_build_update,
|
|
|
|
build_state, tables.rsdp,
|
2021-03-04 13:55:53 +03:00
|
|
|
ACPI_BUILD_RSDP_FILE);
|
2015-05-29 13:28:54 +03:00
|
|
|
|
|
|
|
qemu_register_reset(virt_acpi_build_reset, build_state);
|
|
|
|
virt_acpi_build_reset(build_state);
|
|
|
|
vmstate_register(NULL, 0, &vmstate_virt_acpi_build, build_state);
|
|
|
|
|
|
|
|
/* Cleanup tables but don't free the memory: we track it
|
|
|
|
* in build_state.
|
|
|
|
*/
|
|
|
|
acpi_build_tables_cleanup(&tables, false);
|
|
|
|
}
|