Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into sta…
Browse files Browse the repository at this point in the history
…ging

pc,virtio: fixes, features

Fixes all over the place.
Ability to control ACPI OEM ID's.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

# gpg: Signature made Wed 27 Jan 2021 13:03:55 GMT
# gpg:                using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg:                issuer "mst@redhat.com"
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [full]
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>" [full]
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17  0970 C350 3912 AFBE 8E67
#      Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA  8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream:
  virtio-pmem: add trace events
  tests/acpi: disallow updates for expected data files
  tests/acpi: update expected data files
  tests/acpi: add OEM ID and OEM TABLE ID test
  acpi: Permit OEM ID and OEM table ID fields to be changed
  tests/acpi: allow updates for expected data files
  virtio: Add corresponding memory_listener_unregister to unrealize
  virtio-mmio: fix guest kernel crash with SHM regions
  virtio: move 'use-disabled-flag' property to hw_compat_4_2

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Feb 2, 2021
2 parents 77f3804 + 737242e commit e3f9594
Show file tree
Hide file tree
Showing 121 changed files with 514 additions and 118 deletions.
29 changes: 12 additions & 17 deletions hw/acpi/aml-build.c
Expand Up @@ -30,6 +30,7 @@
#include "hw/pci/pci_host.h"
#include "hw/pci/pci_bus.h"
#include "hw/pci/pci_bridge.h"
#include "qemu/cutils.h"

static GArray *build_alloc_array(void)
{
Expand Down Expand Up @@ -1674,21 +1675,12 @@ build_header(BIOSLinker *linker, GArray *table_data,
h->length = cpu_to_le32(len);
h->revision = rev;

if (oem_id) {
strncpy((char *)h->oem_id, oem_id, sizeof h->oem_id);
} else {
memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6);
}

if (oem_table_id) {
strncpy((char *)h->oem_table_id, oem_table_id, sizeof(h->oem_table_id));
} else {
memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4);
memcpy(h->oem_table_id + 4, sig, 4);
}
strpadcpy((char *)h->oem_id, sizeof h->oem_id, oem_id, ' ');
strpadcpy((char *)h->oem_table_id, sizeof h->oem_table_id,
oem_table_id, ' ');

h->oem_revision = cpu_to_le32(1);
memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4);
memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME8, 4);
h->asl_compiler_revision = cpu_to_le32(1);
/* Checksum to be filled in by Guest linker */
bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
Expand Down Expand Up @@ -1871,7 +1863,8 @@ void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base,
* ACPI spec 5.2.17 System Locality Distance Information Table
* (Revision 2.0 or later)
*/
void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms)
void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms,
const char *oem_id, const char *oem_table_id)
{
int slit_start, i, j;
slit_start = table_data->len;
Expand All @@ -1892,7 +1885,7 @@ void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms)
build_header(linker, table_data,
(void *)(table_data->data + slit_start),
"SLIT",
table_data->len - slit_start, 1, NULL, NULL);
table_data->len - slit_start, 1, oem_id, oem_table_id);
}

/* build rev1/rev3/rev5.1 FADT */
Expand Down Expand Up @@ -2024,7 +2017,8 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
* table 7: TCG Hardware Interface Description Table Format for TPM 2.0
* of TCG ACPI Specification, Family “1.2” and “2.0”, Version 1.2, Rev 8
*/
void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)
void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
const char *oem_id, const char *oem_table_id)
{
uint8_t start_method_params[12] = {};
unsigned log_addr_offset, tpm2_start;
Expand Down Expand Up @@ -2073,7 +2067,8 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog)
log_addr_offset, 8,
ACPI_BUILD_TPMLOG_FILE, 0);
build_header(linker, table_data,
tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, NULL, NULL);
tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, oem_id,
oem_table_id);
}

Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,
Expand Down
5 changes: 3 additions & 2 deletions hw/acpi/ghes.c
Expand Up @@ -359,7 +359,8 @@ static void build_ghes_v2(GArray *table_data, int source_id, BIOSLinker *linker)
}

/* Build Hardware Error Source Table */
void acpi_build_hest(GArray *table_data, BIOSLinker *linker)
void acpi_build_hest(GArray *table_data, BIOSLinker *linker,
const char *oem_id, const char *oem_table_id)
{
uint64_t hest_start = table_data->len;

Expand All @@ -372,7 +373,7 @@ void acpi_build_hest(GArray *table_data, BIOSLinker *linker)
build_ghes_v2(table_data, ACPI_HEST_SRC_ID_SEA, linker);

build_header(linker, table_data, (void *)(table_data->data + hest_start),
"HEST", table_data->len - hest_start, 1, NULL, NULL);
"HEST", table_data->len - hest_start, 1, oem_id, oem_table_id);
}

void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s,
Expand Down
5 changes: 3 additions & 2 deletions hw/acpi/hmat.c
Expand Up @@ -253,7 +253,8 @@ static void hmat_build_table_structs(GArray *table_data, NumaState *numa_state)
}
}

void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_state)
void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_state,
const char *oem_id, const char *oem_table_id)
{
int hmat_start = table_data->len;

Expand All @@ -264,5 +265,5 @@ void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_state)

build_header(linker, table_data,
(void *)(table_data->data + hmat_start),
"HMAT", table_data->len - hmat_start, 2, NULL, NULL);
"HMAT", table_data->len - hmat_start, 2, oem_id, oem_table_id);
}
3 changes: 2 additions & 1 deletion hw/acpi/hmat.h
Expand Up @@ -37,6 +37,7 @@
*/
#define HMAT_PROXIMITY_INITIATOR_VALID 0x1

void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_state);
void build_hmat(GArray *table_data, BIOSLinker *linker, NumaState *numa_state,
const char *oem_id, const char *oem_table_id);

#endif
18 changes: 11 additions & 7 deletions hw/acpi/nvdimm.c
Expand Up @@ -402,7 +402,8 @@ void nvdimm_plug(NVDIMMState *state)
}

static void nvdimm_build_nfit(NVDIMMState *state, GArray *table_offsets,
GArray *table_data, BIOSLinker *linker)
GArray *table_data, BIOSLinker *linker,
const char *oem_id, const char *oem_table_id)
{
NvdimmFitBuffer *fit_buf = &state->fit_buf;
unsigned int header;
Expand All @@ -417,7 +418,8 @@ static void nvdimm_build_nfit(NVDIMMState *state, GArray *table_offsets,

build_header(linker, table_data,
(void *)(table_data->data + header), "NFIT",
sizeof(NvdimmNfitHeader) + fit_buf->fit->len, 1, NULL, NULL);
sizeof(NvdimmNfitHeader) + fit_buf->fit->len, 1, oem_id,
oem_table_id);
}

#define NVDIMM_DSM_MEMORY_SIZE 4096
Expand Down Expand Up @@ -1278,7 +1280,7 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots)
static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,
BIOSLinker *linker,
NVDIMMState *nvdimm_state,
uint32_t ram_slots)
uint32_t ram_slots, const char *oem_id)
{
Aml *ssdt, *sb_scope, *dev;
int mem_addr_offset, nvdimm_ssdt;
Expand Down Expand Up @@ -1331,7 +1333,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,
NVDIMM_DSM_MEM_FILE, 0);
build_header(linker, table_data,
(void *)(table_data->data + nvdimm_ssdt),
"SSDT", table_data->len - nvdimm_ssdt, 1, NULL, "NVDIMM");
"SSDT", table_data->len - nvdimm_ssdt, 1, oem_id, "NVDIMM");
free_aml_allocator();
}

Expand Down Expand Up @@ -1359,7 +1361,8 @@ void nvdimm_build_srat(GArray *table_data)

void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
BIOSLinker *linker, NVDIMMState *state,
uint32_t ram_slots)
uint32_t ram_slots, const char *oem_id,
const char *oem_table_id)
{
GSList *device_list;

Expand All @@ -1369,14 +1372,15 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
}

nvdimm_build_ssdt(table_offsets, table_data, linker, state,
ram_slots);
ram_slots, oem_id);

device_list = nvdimm_get_device_list();
/* no NVDIMM device is plugged. */
if (!device_list) {
return;
}

nvdimm_build_nfit(state, table_offsets, table_data, linker);
nvdimm_build_nfit(state, table_offsets, table_data, linker,
oem_id, oem_table_id);
g_slist_free(device_list);
}
5 changes: 3 additions & 2 deletions hw/acpi/pci.c
Expand Up @@ -28,7 +28,8 @@
#include "hw/acpi/pci.h"
#include "hw/pci/pcie_host.h"

void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
const char *oem_id, const char *oem_table_id)
{
int mcfg_start = table_data->len;

Expand Down Expand Up @@ -56,6 +57,6 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
build_append_int_noprefix(table_data, 0, 4);

build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
"MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
"MCFG", table_data->len - mcfg_start, 1, oem_id, oem_table_id);
}

4 changes: 2 additions & 2 deletions hw/acpi/vmgenid.c
Expand Up @@ -24,7 +24,7 @@
#include "sysemu/reset.h"

void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,
BIOSLinker *linker)
BIOSLinker *linker, const char *oem_id)
{
Aml *ssdt, *dev, *scope, *method, *addr, *if_ctx;
uint32_t vgia_offset;
Expand Down Expand Up @@ -118,7 +118,7 @@ void vmgenid_build_acpi(VmGenIdState *vms, GArray *table_data, GArray *guid,

build_header(linker, table_data,
(void *)(table_data->data + table_data->len - ssdt->buf->len),
"SSDT", ssdt->buf->len, 1, NULL, "VMGENID");
"SSDT", ssdt->buf->len, 1, oem_id, "VMGENID");
free_aml_allocator();
}

Expand Down
40 changes: 26 additions & 14 deletions hw/arm/virt-acpi-build.c
Expand Up @@ -341,7 +341,8 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
iort->length = cpu_to_le32(iort_length);

build_header(linker, table_data, (void *)(table_data->data + iort_start),
"IORT", table_data->len - iort_start, 0, NULL, NULL);
"IORT", table_data->len - iort_start, 0, vms->oem_id,
vms->oem_table_id);
}

static void
Expand Down Expand Up @@ -375,7 +376,8 @@ build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
spcr->pci_vendor_id = 0xffff; /* PCI Vendor ID: not a PCI device */

build_header(linker, table_data, (void *)(table_data->data + spcr_start),
"SPCR", table_data->len - spcr_start, 2, NULL, NULL);
"SPCR", table_data->len - spcr_start, 2, vms->oem_id,
vms->oem_table_id);
}

static void
Expand Down Expand Up @@ -427,7 +429,8 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
}

build_header(linker, table_data, (void *)(table_data->data + srat_start),
"SRAT", table_data->len - srat_start, 3, NULL, NULL);
"SRAT", table_data->len - srat_start, 3, vms->oem_id,
vms->oem_table_id);
}

/* GTDT */
Expand Down Expand Up @@ -462,7 +465,8 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)

build_header(linker, table_data,
(void *)(table_data->data + gtdt_start), "GTDT",
table_data->len - gtdt_start, 2, NULL, NULL);
table_data->len - gtdt_start, 2, vms->oem_id,
vms->oem_table_id);
}

/* MADT */
Expand Down Expand Up @@ -551,7 +555,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)

build_header(linker, table_data,
(void *)(table_data->data + madt_start), "APIC",
table_data->len - madt_start, 3, NULL, NULL);
table_data->len - madt_start, 3, vms->oem_id,
vms->oem_table_id);
}

/* FADT */
Expand Down Expand Up @@ -581,7 +586,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
g_assert_not_reached();
}

build_fadt(table_data, linker, &fadt, NULL, NULL);
build_fadt(table_data, linker, &fadt, vms->oem_id, vms->oem_table_id);
}

/* DSDT */
Expand Down Expand Up @@ -645,7 +650,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len);
build_header(linker, table_data,
(void *)(table_data->data + table_data->len - dsdt->buf->len),
"DSDT", dsdt->buf->len, 2, NULL, NULL);
"DSDT", dsdt->buf->len, 2, vms->oem_id,
vms->oem_table_id);
free_aml_allocator();
}

Expand Down Expand Up @@ -704,7 +710,8 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
.base = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].base,
.size = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].size,
};
build_mcfg(tables_blob, tables->linker, &mcfg);
build_mcfg(tables_blob, tables->linker, &mcfg, vms->oem_id,
vms->oem_table_id);
}

acpi_add_table(table_offsets, tables_blob);
Expand All @@ -713,21 +720,24 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
if (vms->ras) {
build_ghes_error_table(tables->hardware_errors, tables->linker);
acpi_add_table(table_offsets, tables_blob);
acpi_build_hest(tables_blob, tables->linker);
acpi_build_hest(tables_blob, tables->linker, vms->oem_id,
vms->oem_table_id);
}

if (ms->numa_state->num_nodes > 0) {
acpi_add_table(table_offsets, tables_blob);
build_srat(tables_blob, tables->linker, vms);
if (ms->numa_state->have_numa_distance) {
acpi_add_table(table_offsets, tables_blob);
build_slit(tables_blob, tables->linker, ms);
build_slit(tables_blob, tables->linker, ms, vms->oem_id,
vms->oem_table_id);
}
}

if (ms->nvdimms_state->is_enabled) {
nvdimm_build_acpi(table_offsets, tables_blob, tables->linker,
ms->nvdimms_state, ms->ram_slots);
ms->nvdimms_state, ms->ram_slots, vms->oem_id,
vms->oem_table_id);
}

if (its_class_name() && !vmc->no_its) {
Expand All @@ -737,18 +747,20 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)

if (tpm_get_version(tpm_find()) == TPM_VERSION_2_0) {
acpi_add_table(table_offsets, tables_blob);
build_tpm2(tables_blob, tables->linker, tables->tcpalog);
build_tpm2(tables_blob, tables->linker, tables->tcpalog, vms->oem_id,
vms->oem_table_id);
}

/* XSDT is pointed to by RSDP */
xsdt = tables_blob->len;
build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
build_xsdt(tables_blob, tables->linker, table_offsets, vms->oem_id,
vms->oem_table_id);

/* RSDP is in FSEG memory, so allocate it separately */
{
AcpiRsdpData rsdp_data = {
.revision = 2,
.oem_id = ACPI_BUILD_APPNAME6,
.oem_id = vms->oem_id,
.xsdt_tbl_offset = &xsdt,
.rsdt_tbl_offset = NULL,
};
Expand Down

0 comments on commit e3f9594

Please sign in to comment.