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

virtio,acpi,pci,pc: backlog from pre-5.0

Mostly fixes, cleanups, but also new features for arm/virt and pc acpi.

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

# gpg: Signature made Mon 04 May 2020 15:27:06 BST
# 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: (29 commits)
  hw/i386: Make vmmouse helpers static
  hw/i386: Add 'vmport.h' local header
  hw/i386/vmport: Remove unused 'hw/input/i8042.h' include
  hw/i386/pc: Create 'vmport' device in place
  acpi: unit-test: Update WAET ACPI Table expected binaries
  acpi: Add Windows ACPI Emulated Device Table (WAET)
  acpi: unit-test: Ignore diff in WAET ACPI table
  Refactor vhost_user_set_mem_table functions
  tests/acpi: add expected tables for bios-tables-test
  bios-tables-test: test pc-dimm and nvdimm coldplug for arm/virt
  tests: Update ACPI tables list for upcoming arm/virt test changes
  hw/arm/virt: Add nvdimm hotplug support
  hw/arm/virt: Add nvdimm hot-plug infrastructure
  nvdimm: Use configurable ACPI IO base and size
  hw/acpi/nvdimm: Fix for NVDIMM incorrect DSM output buffer length
  acpi: DSDT without _STA
  checkpatch: ignore allowed diff list
  checkpatch: fix acpi check with multiple file name
  vhost-user-blk: fix invalid memory access
  virtio-pci: update virtio pci bar layout documentation
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed May 4, 2020
2 parents 9af638c + d8a0599 commit 5375af3
Show file tree
Hide file tree
Showing 59 changed files with 449 additions and 173 deletions.
3 changes: 2 additions & 1 deletion docs/specs/acpi_hw_reduced_hotplug.rst
Expand Up @@ -63,7 +63,8 @@ GED IO interface (4 byte access)
bits:
0: Memory hotplug event
1: System power down event
2-31: Reserved
2: NVDIMM hotplug event
3-31: Reserved

**write_access:**

Expand Down
4 changes: 2 additions & 2 deletions hw/acpi/Makefile.objs
Expand Up @@ -20,6 +20,6 @@ common-obj-$(CONFIG_TPM) += tpm.o
common-obj-$(CONFIG_IPMI) += ipmi.o
common-obj-$(call lnot,$(CONFIG_IPMI)) += ipmi-stub.o
else
common-obj-y += acpi-stub.o
common-obj-y += acpi-stub.o aml-build-stub.o
endif
common-obj-$(CONFIG_ALL) += acpi-stub.o acpi-x86-stub.o ipmi-stub.o
common-obj-$(CONFIG_ALL) += acpi-stub.o aml-build-stub.o acpi-x86-stub.o ipmi-stub.o
79 changes: 79 additions & 0 deletions hw/acpi/aml-build-stub.c
@@ -0,0 +1,79 @@
/*
* ACPI aml builder stubs for platforms that don't support ACPI.
*
* Copyright (c) 2006 Fabrice Bellard
* Copyright (c) 2016 Red Hat, Inc.
*
* 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/>.
*/

#include "qemu/osdep.h"
#include "hw/acpi/acpi.h"
#include "hw/acpi/aml-build.h"

void aml_append(Aml *parent_ctx, Aml *child)
{
}

Aml *aml_resource_template(void)
{
return NULL;
}

Aml *aml_device(const char *name_format, ...)
{
return NULL;
}

Aml *aml_eisaid(const char *str)
{
return NULL;
}

Aml *aml_name_decl(const char *name, Aml *val)
{
return NULL;
}

Aml *aml_io(AmlIODecode dec, uint16_t min_base, uint16_t max_base,
uint8_t aln, uint8_t len)
{
return NULL;
}

Aml *aml_irq_no_flags(uint8_t irq)
{
return NULL;
}

Aml *aml_int(const uint64_t val)
{
return NULL;
}

Aml *aml_package(uint8_t num_elements)
{
return NULL;
}

Aml *aml_dma(AmlDmaType typ, AmlDmaBusMaster bm, AmlTransferSize sz,
uint8_t channel)
{
return NULL;
}

Aml *aml_buffer(int buffer_size, uint8_t *byte_list)
{
return NULL;
}
15 changes: 14 additions & 1 deletion hw/acpi/generic_event_device.c
Expand Up @@ -16,13 +16,15 @@
#include "hw/acpi/generic_event_device.h"
#include "hw/irq.h"
#include "hw/mem/pc-dimm.h"
#include "hw/mem/nvdimm.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
#include "qemu/error-report.h"

static const uint32_t ged_supported_events[] = {
ACPI_GED_MEM_HOTPLUG_EVT,
ACPI_GED_PWR_DOWN_EVT,
ACPI_GED_NVDIMM_HOTPLUG_EVT,
};

/*
Expand Down Expand Up @@ -110,6 +112,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE),
aml_int(0x80)));
break;
case ACPI_GED_NVDIMM_HOTPLUG_EVT:
aml_append(if_ctx,
aml_notify(aml_name("\\_SB.NVDR"),
aml_int(0x80)));
break;
default:
/*
* Please make sure all the events in ged_supported_events[]
Expand Down Expand Up @@ -175,7 +182,11 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
AcpiGedState *s = ACPI_GED(hotplug_dev);

if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
if (object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM)) {
nvdimm_acpi_plug_cb(hotplug_dev, dev);
} else {
acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
}
} else {
error_setg(errp, "virt: device plug request for unsupported device"
" type: %s", object_get_typename(OBJECT(dev)));
Expand All @@ -192,6 +203,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
sel = ACPI_GED_MEM_HOTPLUG_EVT;
} else if (ev & ACPI_POWER_DOWN_STATUS) {
sel = ACPI_GED_PWR_DOWN_EVT;
} else if (ev & ACPI_NVDIMM_HOTPLUG_STATUS) {
sel = ACPI_GED_NVDIMM_HOTPLUG_EVT;
} else {
/* Unknown event. Return without generating interrupt. */
warn_report("GED: Unsupported event %d. No irq injected", ev);
Expand Down
72 changes: 59 additions & 13 deletions hw/acpi/nvdimm.c
Expand Up @@ -900,11 +900,13 @@ void nvdimm_acpi_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev)
}

void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io,
struct AcpiGenericAddress dsm_io,
FWCfgState *fw_cfg, Object *owner)
{
state->dsm_io = dsm_io;
memory_region_init_io(&state->io_mr, owner, &nvdimm_dsm_ops, state,
"nvdimm-acpi-io", NVDIMM_ACPI_IO_LEN);
memory_region_add_subregion(io, NVDIMM_ACPI_IO_BASE, &state->io_mr);
"nvdimm-acpi-io", dsm_io.bit_width >> 3);
memory_region_add_subregion(io, dsm_io.address, &state->io_mr);

state->dsm_mem = g_array_new(false, true /* clear */, 1);
acpi_data_push(state->dsm_mem, sizeof(NvdimmDsmIn));
Expand Down Expand Up @@ -933,12 +935,15 @@ void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io,

#define NVDIMM_QEMU_RSVD_UUID "648B9CF2-CDA1-4312-8AD9-49C4AF32BD62"

static void nvdimm_build_common_dsm(Aml *dev)
static void nvdimm_build_common_dsm(Aml *dev,
NVDIMMState *nvdimm_state)
{
Aml *method, *ifctx, *function, *handle, *uuid, *dsm_mem, *elsectx2;
Aml *elsectx, *unsupport, *unpatched, *expected_uuid, *uuid_invalid;
Aml *pckg, *pckg_index, *pckg_buf, *field, *dsm_out_buf, *dsm_out_buf_size;
Aml *whilectx, *offset;
uint8_t byte_list[1];
AmlRegionSpace rs;

method = aml_method(NVDIMM_COMMON_DSM, 5, AML_SERIALIZED);
uuid = aml_arg(0);
Expand All @@ -949,9 +954,16 @@ static void nvdimm_build_common_dsm(Aml *dev)

aml_append(method, aml_store(aml_name(NVDIMM_ACPI_MEM_ADDR), dsm_mem));

if (nvdimm_state->dsm_io.space_id == AML_AS_SYSTEM_IO) {
rs = AML_SYSTEM_IO;
} else {
rs = AML_SYSTEM_MEMORY;
}

/* map DSM memory and IO into ACPI namespace. */
aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, AML_SYSTEM_IO,
aml_int(NVDIMM_ACPI_IO_BASE), NVDIMM_ACPI_IO_LEN));
aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, rs,
aml_int(nvdimm_state->dsm_io.address),
nvdimm_state->dsm_io.bit_width >> 3));
aml_append(method, aml_operation_region(NVDIMM_DSM_MEMORY,
AML_SYSTEM_MEMORY, dsm_mem, sizeof(NvdimmDsmIn)));

Expand All @@ -966,7 +978,7 @@ static void nvdimm_build_common_dsm(Aml *dev)
field = aml_field(NVDIMM_DSM_IOPORT, AML_DWORD_ACC, AML_NOLOCK,
AML_PRESERVE);
aml_append(field, aml_named_field(NVDIMM_DSM_NOTIFY,
NVDIMM_ACPI_IO_LEN * BITS_PER_BYTE));
nvdimm_state->dsm_io.bit_width));
aml_append(method, field);

/*
Expand Down Expand Up @@ -1091,13 +1103,46 @@ static void nvdimm_build_common_dsm(Aml *dev)
/* RLEN is not included in the payload returned to guest. */
aml_append(method, aml_subtract(aml_name(NVDIMM_DSM_OUT_BUF_SIZE),
aml_int(4), dsm_out_buf_size));

/*
* As per ACPI spec 6.3, Table 19-419 Object Conversion Rules, if
* the Buffer Field <= to the size of an Integer (in bits), it will
* be treated as an integer. Moreover, the integer size depends on
* DSDT tables revision number. If revision number is < 2, integer
* size is 32 bits, otherwise it is 64 bits.
* Because of this CreateField() canot be used if RLEN < Integer Size.
*
* Also please note that APCI ASL operator SizeOf() doesn't support
* Integer and there isn't any other way to figure out the Integer
* size. Hence we assume 8 byte as Integer size and if RLEN < 8 bytes,
* build dsm_out_buf byte by byte.
*/
ifctx = aml_if(aml_lless(dsm_out_buf_size, aml_int(8)));
offset = aml_local(2);
aml_append(ifctx, aml_store(aml_int(0), offset));
aml_append(ifctx, aml_name_decl("TBUF", aml_buffer(1, NULL)));
aml_append(ifctx, aml_store(aml_buffer(0, NULL), dsm_out_buf));

whilectx = aml_while(aml_lless(offset, dsm_out_buf_size));
/* Copy 1 byte at offset from ODAT to temporary buffer(TBUF). */
aml_append(whilectx, aml_store(aml_derefof(aml_index(
aml_name(NVDIMM_DSM_OUT_BUF), offset)),
aml_index(aml_name("TBUF"), aml_int(0))));
aml_append(whilectx, aml_concatenate(dsm_out_buf, aml_name("TBUF"),
dsm_out_buf));
aml_append(whilectx, aml_increment(offset));
aml_append(ifctx, whilectx);

aml_append(ifctx, aml_return(dsm_out_buf));
aml_append(method, ifctx);

/* If RLEN >= Integer size, just use CreateField() operator */
aml_append(method, aml_store(aml_shiftleft(dsm_out_buf_size, aml_int(3)),
dsm_out_buf_size));
aml_append(method, aml_create_field(aml_name(NVDIMM_DSM_OUT_BUF),
aml_int(0), dsm_out_buf_size, "OBUF"));
aml_append(method, aml_concatenate(aml_buffer(0, NULL), aml_name("OBUF"),
dsm_out_buf));
aml_append(method, aml_return(dsm_out_buf));
aml_append(method, aml_return(aml_name("OBUF")));

aml_append(dev, method);
}

Expand Down Expand Up @@ -1234,7 +1279,8 @@ 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, GArray *dsm_dma_area,
BIOSLinker *linker,
NVDIMMState *nvdimm_state,
uint32_t ram_slots)
{
Aml *ssdt, *sb_scope, *dev;
Expand Down Expand Up @@ -1262,7 +1308,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,
*/
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0012")));

nvdimm_build_common_dsm(dev);
nvdimm_build_common_dsm(dev, nvdimm_state);

/* 0 is reserved for root device. */
nvdimm_build_device_dsm(dev, 0);
Expand All @@ -1281,7 +1327,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,
NVDIMM_ACPI_MEM_ADDR);

bios_linker_loader_alloc(linker,
NVDIMM_DSM_MEM_FILE, dsm_dma_area,
NVDIMM_DSM_MEM_FILE, nvdimm_state->dsm_mem,
sizeof(NvdimmDsmIn), false /* high memory */);
bios_linker_loader_add_pointer(linker,
ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t),
Expand All @@ -1303,7 +1349,7 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data,
return;
}

nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem,
nvdimm_build_ssdt(table_offsets, table_data, linker, state,
ram_slots);

device_list = nvdimm_get_device_list();
Expand Down
1 change: 1 addition & 0 deletions hw/arm/Kconfig
Expand Up @@ -25,6 +25,7 @@ config ARM_VIRT
select DIMM
select ACPI_MEMORY_HOTPLUG
select ACPI_HW_REDUCED
select ACPI_NVDIMM

config CHEETAH
bool
Expand Down
6 changes: 6 additions & 0 deletions hw/arm/virt-acpi-build.c
Expand Up @@ -44,6 +44,7 @@
#include "hw/pci/pcie_host.h"
#include "hw/pci/pci.h"
#include "hw/arm/virt.h"
#include "hw/mem/nvdimm.h"
#include "sysemu/numa.h"
#include "sysemu/reset.h"
#include "kvm_arm.h"
Expand Down Expand Up @@ -826,6 +827,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
}
}

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

if (its_class_name() && !vmc->no_its) {
acpi_add_table(table_offsets, tables_blob);
build_iort(tables_blob, tables->linker, vms);
Expand Down

0 comments on commit 5375af3

Please sign in to comment.