Skip to content

Commit 14e5526

Browse files
committed
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
pc: bugfixes, maintainers A couple of bugfixes. Add a new vhost-user-blk maintainer. Signed-off-by: Michael S. Tsirkin <[email protected]> # gpg: Signature made Mon 13 Apr 2020 11:57:17 BST # gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469 # gpg: issuer "[email protected]" # gpg: Good signature from "Michael S. Tsirkin <[email protected]>" [full] # gpg: aka "Michael S. Tsirkin <[email protected]>" [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: exec: Fix for qemu_ram_resize() callback fw_cfg: Migrate ACPI table mr sizes separately acpi: Use macro for table-loader file name MAINTAINERS: Add myself as vhost-user-blk maintainer Signed-off-by: Peter Maydell <[email protected]>
2 parents e33d61c + ce4adc0 commit 14e5526

File tree

8 files changed

+126
-5
lines changed

8 files changed

+126
-5
lines changed

MAINTAINERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,18 @@ F: hw/display/virtio-gpu*
18531853
F: hw/display/virtio-vga.*
18541854
F: include/hw/virtio/virtio-gpu.h
18551855

1856+
vhost-user-blk
1857+
M: Raphael Norwitz <[email protected]>
1858+
S: Maintained
1859+
F: contrib/vhost-user-blk/
1860+
F: contrib/vhost-user-scsi/
1861+
F: hw/block/vhost-user-blk.c
1862+
F: hw/scsi/vhost-user-scsi.c
1863+
F: hw/virtio/vhost-user-blk-pci.c
1864+
F: hw/virtio/vhost-user-scsi-pci.c
1865+
F: include/hw/virtio/vhost-user-blk.h
1866+
F: include/hw/virtio/vhost-user-scsi.h
1867+
18561868
vhost-user-gpu
18571869
M: Marc-André Lureau <[email protected]>
18581870
M: Gerd Hoffmann <[email protected]>

exec.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,11 +2074,23 @@ static int memory_try_enable_merging(void *addr, size_t len)
20742074
*/
20752075
int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
20762076
{
2077+
const ram_addr_t unaligned_size = newsize;
2078+
20772079
assert(block);
20782080

20792081
newsize = HOST_PAGE_ALIGN(newsize);
20802082

20812083
if (block->used_length == newsize) {
2084+
/*
2085+
* We don't have to resize the ram block (which only knows aligned
2086+
* sizes), however, we have to notify if the unaligned size changed.
2087+
*/
2088+
if (unaligned_size != memory_region_size(block->mr)) {
2089+
memory_region_set_size(block->mr, unaligned_size);
2090+
if (block->resized) {
2091+
block->resized(block->idstr, unaligned_size, block->host);
2092+
}
2093+
}
20822094
return 0;
20832095
}
20842096

@@ -2102,9 +2114,9 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsize, Error **errp)
21022114
block->used_length = newsize;
21032115
cpu_physical_memory_set_dirty_range(block->offset, block->used_length,
21042116
DIRTY_CLIENTS_ALL);
2105-
memory_region_set_size(block->mr, newsize);
2117+
memory_region_set_size(block->mr, unaligned_size);
21062118
if (block->resized) {
2107-
block->resized(block->idstr, newsize, block->host);
2119+
block->resized(block->idstr, unaligned_size, block->host);
21082120
}
21092121
return 0;
21102122
}

hw/arm/virt-acpi-build.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ void virt_acpi_setup(VirtMachineState *vms)
929929

930930
build_state->linker_mr =
931931
acpi_add_rom_blob(virt_acpi_build_update, build_state,
932-
tables.linker->cmd_blob, "etc/table-loader", 0);
932+
tables.linker->cmd_blob, ACPI_BUILD_LOADER_FILE, 0);
933933

934934
fw_cfg_add_file(vms->fw_cfg, ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data,
935935
acpi_data_len(tables.tcpalog));

hw/core/machine.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ GlobalProperty hw_compat_4_2[] = {
3939
{ "usb-redir", "suppress-remote-wake", "off" },
4040
{ "qxl", "revision", "4" },
4141
{ "qxl-vga", "revision", "4" },
42+
{ "fw_cfg", "acpi-mr-restore", "false" },
4243
};
4344
const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
4445

hw/i386/acpi-build.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3043,7 +3043,7 @@ void acpi_setup(void)
30433043

30443044
build_state->linker_mr =
30453045
acpi_add_rom_blob(acpi_build_update, build_state,
3046-
tables.linker->cmd_blob, "etc/table-loader", 0);
3046+
tables.linker->cmd_blob, ACPI_BUILD_LOADER_FILE, 0);
30473047

30483048
fw_cfg_add_file(x86ms->fw_cfg, ACPI_BUILD_TPMLOG_FILE,
30493049
tables.tcpalog->data, acpi_data_len(tables.tcpalog));

hw/nvram/fw_cfg.c

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "qemu/config-file.h"
4040
#include "qemu/cutils.h"
4141
#include "qapi/error.h"
42+
#include "hw/acpi/aml-build.h"
4243

4344
#define FW_CFG_FILE_SLOTS_DFLT 0x20
4445

@@ -610,6 +611,55 @@ bool fw_cfg_dma_enabled(void *opaque)
610611
return s->dma_enabled;
611612
}
612613

614+
static bool fw_cfg_acpi_mr_restore(void *opaque)
615+
{
616+
FWCfgState *s = opaque;
617+
bool mr_aligned;
618+
619+
mr_aligned = QEMU_IS_ALIGNED(s->table_mr_size, qemu_real_host_page_size) &&
620+
QEMU_IS_ALIGNED(s->linker_mr_size, qemu_real_host_page_size) &&
621+
QEMU_IS_ALIGNED(s->rsdp_mr_size, qemu_real_host_page_size);
622+
return s->acpi_mr_restore && !mr_aligned;
623+
}
624+
625+
static void fw_cfg_update_mr(FWCfgState *s, uint16_t key, size_t size)
626+
{
627+
MemoryRegion *mr;
628+
ram_addr_t offset;
629+
int arch = !!(key & FW_CFG_ARCH_LOCAL);
630+
void *ptr;
631+
632+
key &= FW_CFG_ENTRY_MASK;
633+
assert(key < fw_cfg_max_entry(s));
634+
635+
ptr = s->entries[arch][key].data;
636+
mr = memory_region_from_host(ptr, &offset);
637+
638+
memory_region_ram_resize(mr, size, &error_abort);
639+
}
640+
641+
static int fw_cfg_acpi_mr_restore_post_load(void *opaque, int version_id)
642+
{
643+
FWCfgState *s = opaque;
644+
int i, index;
645+
646+
assert(s->files);
647+
648+
index = be32_to_cpu(s->files->count);
649+
650+
for (i = 0; i < index; i++) {
651+
if (!strcmp(s->files->f[i].name, ACPI_BUILD_TABLE_FILE)) {
652+
fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->table_mr_size);
653+
} else if (!strcmp(s->files->f[i].name, ACPI_BUILD_LOADER_FILE)) {
654+
fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->linker_mr_size);
655+
} else if (!strcmp(s->files->f[i].name, ACPI_BUILD_RSDP_FILE)) {
656+
fw_cfg_update_mr(s, FW_CFG_FILE_FIRST + i, s->rsdp_mr_size);
657+
}
658+
}
659+
660+
return 0;
661+
}
662+
613663
static const VMStateDescription vmstate_fw_cfg_dma = {
614664
.name = "fw_cfg/dma",
615665
.needed = fw_cfg_dma_enabled,
@@ -619,6 +669,20 @@ static const VMStateDescription vmstate_fw_cfg_dma = {
619669
},
620670
};
621671

672+
static const VMStateDescription vmstate_fw_cfg_acpi_mr = {
673+
.name = "fw_cfg/acpi_mr",
674+
.version_id = 1,
675+
.minimum_version_id = 1,
676+
.needed = fw_cfg_acpi_mr_restore,
677+
.post_load = fw_cfg_acpi_mr_restore_post_load,
678+
.fields = (VMStateField[]) {
679+
VMSTATE_UINT64(table_mr_size, FWCfgState),
680+
VMSTATE_UINT64(linker_mr_size, FWCfgState),
681+
VMSTATE_UINT64(rsdp_mr_size, FWCfgState),
682+
VMSTATE_END_OF_LIST()
683+
},
684+
};
685+
622686
static const VMStateDescription vmstate_fw_cfg = {
623687
.name = "fw_cfg",
624688
.version_id = 2,
@@ -631,6 +695,7 @@ static const VMStateDescription vmstate_fw_cfg = {
631695
},
632696
.subsections = (const VMStateDescription*[]) {
633697
&vmstate_fw_cfg_dma,
698+
&vmstate_fw_cfg_acpi_mr,
634699
NULL,
635700
}
636701
};
@@ -815,6 +880,23 @@ static struct {
815880
#define FW_CFG_ORDER_OVERRIDE_LAST 200
816881
};
817882

883+
/*
884+
* Any sub-page size update to these table MRs will be lost during migration,
885+
* as we use aligned size in ram_load_precopy() -> qemu_ram_resize() path.
886+
* In order to avoid the inconsistency in sizes save them seperately and
887+
* migrate over in vmstate post_load().
888+
*/
889+
static void fw_cfg_acpi_mr_save(FWCfgState *s, const char *filename, size_t len)
890+
{
891+
if (!strcmp(filename, ACPI_BUILD_TABLE_FILE)) {
892+
s->table_mr_size = len;
893+
} else if (!strcmp(filename, ACPI_BUILD_LOADER_FILE)) {
894+
s->linker_mr_size = len;
895+
} else if (!strcmp(filename, ACPI_BUILD_RSDP_FILE)) {
896+
s->rsdp_mr_size = len;
897+
}
898+
}
899+
818900
static int get_fw_cfg_order(FWCfgState *s, const char *name)
819901
{
820902
int i;
@@ -914,6 +996,7 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
914996
trace_fw_cfg_add_file(s, index, s->files->f[index].name, len);
915997

916998
s->files->count = cpu_to_be32(count+1);
999+
fw_cfg_acpi_mr_save(s, filename, len);
9171000
}
9181001

9191002
void fw_cfg_add_file(FWCfgState *s, const char *filename,
@@ -937,6 +1020,7 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *filename,
9371020
ptr = fw_cfg_modify_bytes_read(s, FW_CFG_FILE_FIRST + i,
9381021
data, len);
9391022
s->files->f[i].size = cpu_to_be32(len);
1023+
fw_cfg_acpi_mr_save(s, filename, len);
9401024
return ptr;
9411025
}
9421026
}
@@ -973,7 +1057,10 @@ static void fw_cfg_machine_ready(struct Notifier *n, void *data)
9731057
qemu_register_reset(fw_cfg_machine_reset, s);
9741058
}
9751059

976-
1060+
static Property fw_cfg_properties[] = {
1061+
DEFINE_PROP_BOOL("acpi-mr-restore", FWCfgState, acpi_mr_restore, true),
1062+
DEFINE_PROP_END_OF_LIST(),
1063+
};
9771064

9781065
static void fw_cfg_common_realize(DeviceState *dev, Error **errp)
9791066
{
@@ -1097,6 +1184,8 @@ static void fw_cfg_class_init(ObjectClass *klass, void *data)
10971184

10981185
dc->reset = fw_cfg_reset;
10991186
dc->vmsd = &vmstate_fw_cfg;
1187+
1188+
device_class_set_props(dc, fw_cfg_properties);
11001189
}
11011190

11021191
static const TypeInfo fw_cfg_info = {

include/hw/acpi/aml-build.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define ACPI_BUILD_TABLE_FILE "etc/acpi/tables"
1414
#define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp"
1515
#define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log"
16+
#define ACPI_BUILD_LOADER_FILE "etc/table-loader"
1617

1718
#define AML_NOTIFY_METHOD "NTFY"
1819

include/hw/nvram/fw_cfg.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ struct FWCfgState {
5353
dma_addr_t dma_addr;
5454
AddressSpace *dma_as;
5555
MemoryRegion dma_iomem;
56+
57+
/* restore during migration */
58+
bool acpi_mr_restore;
59+
uint64_t table_mr_size;
60+
uint64_t linker_mr_size;
61+
uint64_t rsdp_mr_size;
5662
};
5763

5864
struct FWCfgIoState {

0 commit comments

Comments
 (0)