Skip to content

Commit c8eaf81

Browse files
committed
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
virtio,acpi: features, fixes, cleanups. vdpa support virtio-mem support a handy script for disassembling acpi tables misc fixes and cleanups Signed-off-by: Michael S. Tsirkin <[email protected]> # gpg: Signature made Tue 07 Jul 2020 13:00:35 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: (41 commits) vhost-vdpa: introduce vhost-vdpa net client vhost-vdpa: introduce vhost-vdpa backend vhost_net: introduce set_config & get_config vhost: implement vhost_force_iommu method vhost: introduce new VhostOps vhost_force_iommu vhost: implement vhost_vq_get_addr method vhost: introduce new VhostOps vhost_vq_get_addr vhost: implement vhost_dev_start method vhost: introduce new VhostOps vhost_dev_start vhost: check the existence of vhost_set_iotlb_callback virtio-pci: implement queue_enabled method virtio-bus: introduce queue_enabled method vhost_net: use the function qemu_get_peer net: introduce qemu_get_peer MAINTAINERS: add VT-d entry docs: vhost-user: add Virtio status protocol feature tests/acpi: remove stale allowed tables numa: Auto-enable NUMA when any memory devices are possible virtio-mem: Exclude unplugged memory during migration virtio-mem: Add trace events ... Signed-off-by: Peter Maydell <[email protected]> # Conflicts: # hw/arm/virt.c # hw/virtio/trace-events
2 parents 710fb08 + 1e0a84e commit c8eaf81

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2639
-169
lines changed

MAINTAINERS

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,15 @@ F: hw/virtio/virtio-crypto.c
17921792
F: hw/virtio/virtio-crypto-pci.c
17931793
F: include/hw/virtio/virtio-crypto.h
17941794

1795+
virtio-mem
1796+
M: David Hildenbrand <[email protected]>
1797+
S: Supported
1798+
W: https://virtio-mem.gitlab.io/
1799+
F: hw/virtio/virtio-mem.c
1800+
F: hw/virtio/virtio-mem-pci.h
1801+
F: hw/virtio/virtio-mem-pci.c
1802+
F: include/hw/virtio/virtio-mem.h
1803+
17951804
nvme
17961805
M: Keith Busch <[email protected]>
17971806
@@ -2617,6 +2626,15 @@ F: tests/uefi-test-tools/
26172626
F: .gitlab-ci.d/edk2.yml
26182627
F: .gitlab-ci.d/edk2/
26192628

2629+
VT-d Emulation
2630+
M: Michael S. Tsirkin <[email protected]>
2631+
M: Peter Xu <[email protected]>
2632+
R: Jason Wang <[email protected]>
2633+
S: Supported
2634+
F: hw/i386/intel_iommu.c
2635+
F: hw/i386/intel_iommu_internal.h
2636+
F: include/hw/i386/intel_iommu.h
2637+
26202638
Usermode Emulation
26212639
------------------
26222640
Overall usermode emulation

accel/kvm/kvm-all.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#include "trace.h"
4141
#include "hw/irq.h"
4242
#include "sysemu/sev.h"
43-
#include "sysemu/balloon.h"
4443
#include "qapi/visitor.h"
4544
#include "qapi/qapi-types-common.h"
4645
#include "qapi/qapi-visit-common.h"
@@ -2229,7 +2228,8 @@ static int kvm_init(MachineState *ms)
22292228

22302229
s->sync_mmu = !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
22312230
if (!s->sync_mmu) {
2232-
qemu_balloon_inhibit(true);
2231+
ret = ram_block_discard_disable(true);
2232+
assert(!ret);
22332233
}
22342234

22352235
return 0;

balloon.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,6 @@
3636
static QEMUBalloonEvent *balloon_event_fn;
3737
static QEMUBalloonStatus *balloon_stat_fn;
3838
static void *balloon_opaque;
39-
static int balloon_inhibit_count;
40-
41-
bool qemu_balloon_is_inhibited(void)
42-
{
43-
return atomic_read(&balloon_inhibit_count) > 0;
44-
}
45-
46-
void qemu_balloon_inhibit(bool state)
47-
{
48-
if (state) {
49-
atomic_inc(&balloon_inhibit_count);
50-
} else {
51-
atomic_dec(&balloon_inhibit_count);
52-
}
53-
54-
assert(atomic_read(&balloon_inhibit_count) >= 0);
55-
}
5639

5740
static bool have_balloon(Error **errp)
5841
{

configure

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,10 @@ for opt do
15751575
;;
15761576
--enable-vhost-user) vhost_user="yes"
15771577
;;
1578+
--disable-vhost-vdpa) vhost_vdpa="no"
1579+
;;
1580+
--enable-vhost-vdpa) vhost_vdpa="yes"
1581+
;;
15781582
--disable-vhost-kernel) vhost_kernel="no"
15791583
;;
15801584
--enable-vhost-kernel) vhost_kernel="yes"
@@ -1883,6 +1887,7 @@ disabled with --disable-FEATURE, default is enabled if available:
18831887
vhost-crypto vhost-user-crypto backend support
18841888
vhost-kernel vhost kernel backend support
18851889
vhost-user vhost-user backend support
1890+
vhost-vdpa vhost-vdpa kernel backend support
18861891
spice spice
18871892
rbd rados block device (rbd)
18881893
libiscsi iscsi support
@@ -2394,6 +2399,10 @@ test "$vhost_user" = "" && vhost_user=yes
23942399
if test "$vhost_user" = "yes" && test "$mingw32" = "yes"; then
23952400
error_exit "vhost-user isn't available on win32"
23962401
fi
2402+
test "$vhost_vdpa" = "" && vhost_vdpa=$linux
2403+
if test "$vhost_vdpa" = "yes" && test "$linux" != "yes"; then
2404+
error_exit "vhost-vdpa is only available on Linux"
2405+
fi
23972406
test "$vhost_kernel" = "" && vhost_kernel=$linux
23982407
if test "$vhost_kernel" = "yes" && test "$linux" != "yes"; then
23992408
error_exit "vhost-kernel is only available on Linux"
@@ -2422,6 +2431,11 @@ test "$vhost_user_fs" = "" && vhost_user_fs=$vhost_user
24222431
if test "$vhost_user_fs" = "yes" && test "$vhost_user" = "no"; then
24232432
error_exit "--enable-vhost-user-fs requires --enable-vhost-user"
24242433
fi
2434+
#vhost-vdpa backends
2435+
test "$vhost_net_vdpa" = "" && vhost_net_vdpa=$vhost_vdpa
2436+
if test "$vhost_net_vdpa" = "yes" && test "$vhost_vdpa" = "no"; then
2437+
error_exit "--enable-vhost-net-vdpa requires --enable-vhost-vdpa"
2438+
fi
24252439

24262440
# OR the vhost-kernel and vhost-user values for simplicity
24272441
if test "$vhost_net" = ""; then
@@ -6947,6 +6961,7 @@ echo "vhost-scsi support $vhost_scsi"
69476961
echo "vhost-vsock support $vhost_vsock"
69486962
echo "vhost-user support $vhost_user"
69496963
echo "vhost-user-fs support $vhost_user_fs"
6964+
echo "vhost-vdpa support $vhost_vdpa"
69506965
echo "Trace backends $trace_backends"
69516966
if have_backend "simple"; then
69526967
echo "Trace output file $trace_file-<pid>"
@@ -7454,6 +7469,9 @@ fi
74547469
if test "$vhost_net_user" = "yes" ; then
74557470
echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
74567471
fi
7472+
if test "$vhost_net_vdpa" = "yes" ; then
7473+
echo "CONFIG_VHOST_NET_VDPA=y" >> $config_host_mak
7474+
fi
74577475
if test "$vhost_crypto" = "yes" ; then
74587476
echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
74597477
fi
@@ -7469,6 +7487,9 @@ fi
74697487
if test "$vhost_user" = "yes" ; then
74707488
echo "CONFIG_VHOST_USER=y" >> $config_host_mak
74717489
fi
7490+
if test "$vhost_vdpa" = "yes" ; then
7491+
echo "CONFIG_VHOST_VDPA=y" >> $config_host_mak
7492+
fi
74727493
if test "$vhost_user_fs" = "yes" ; then
74737494
echo "CONFIG_VHOST_USER_FS=y" >> $config_host_mak
74747495
fi

docs/interop/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ Contents:
2020
qemu-ga
2121
vhost-user
2222
vhost-user-gpu
23+
vhost-vdpa

docs/interop/vhost-user.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ Protocol features
816816
#define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13
817817
#define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS 14
818818
#define VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS 15
819+
#define VHOST_USER_PROTOCOL_F_STATUS 16
819820
820821
Master message types
821822
--------------------
@@ -1307,6 +1308,29 @@ Master message types
13071308
``VHOST_USER_ADD_MEM_REG`` message, this message is used to set and
13081309
update the memory tables of the slave device.
13091310

1311+
``VHOST_USER_SET_STATUS``
1312+
:id: 39
1313+
:equivalent ioctl: VHOST_VDPA_SET_STATUS
1314+
:slave payload: N/A
1315+
:master payload: ``u64``
1316+
1317+
When the ``VHOST_USER_PROTOCOL_F_STATUS`` protocol feature has been
1318+
successfully negotiated, this message is submitted by the master to
1319+
notify the backend with updated device status as defined in the Virtio
1320+
specification.
1321+
1322+
``VHOST_USER_GET_STATUS``
1323+
:id: 40
1324+
:equivalent ioctl: VHOST_VDPA_GET_STATUS
1325+
:slave payload: ``u64``
1326+
:master payload: N/A
1327+
1328+
When the ``VHOST_USER_PROTOCOL_F_STATUS`` protocol feature has been
1329+
successfully negotiated, this message is submitted by the master to
1330+
query the backend for its device status as defined in the Virtio
1331+
specification.
1332+
1333+
13101334
Slave message types
13111335
-------------------
13121336

docs/interop/vhost-vdpa.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=====================
2+
Vhost-vdpa Protocol
3+
=====================
4+
5+
Introduction
6+
=============
7+
vDPA(Virtual data path acceleration) device is a device that uses
8+
a datapath which complies with the virtio specifications with vendor
9+
specific control path. vDPA devices can be both physically located on
10+
the hardware or emulated by software.
11+
12+
This document describes the vDPA support in qemu
13+
14+
Here is the kernel commit here
15+
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4c8cf31885f69e86be0b5b9e6677a26797365e1d
16+
17+
TODO : More information will add later

exec.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4115,4 +4115,56 @@ void mtree_print_dispatch(AddressSpaceDispatch *d, MemoryRegion *root)
41154115
}
41164116
}
41174117

4118+
/*
4119+
* If positive, discarding RAM is disabled. If negative, discarding RAM is
4120+
* required to work and cannot be disabled.
4121+
*/
4122+
static int ram_block_discard_disabled;
4123+
4124+
int ram_block_discard_disable(bool state)
4125+
{
4126+
int old;
4127+
4128+
if (!state) {
4129+
atomic_dec(&ram_block_discard_disabled);
4130+
return 0;
4131+
}
4132+
4133+
do {
4134+
old = atomic_read(&ram_block_discard_disabled);
4135+
if (old < 0) {
4136+
return -EBUSY;
4137+
}
4138+
} while (atomic_cmpxchg(&ram_block_discard_disabled, old, old + 1) != old);
4139+
return 0;
4140+
}
4141+
4142+
int ram_block_discard_require(bool state)
4143+
{
4144+
int old;
4145+
4146+
if (!state) {
4147+
atomic_inc(&ram_block_discard_disabled);
4148+
return 0;
4149+
}
4150+
4151+
do {
4152+
old = atomic_read(&ram_block_discard_disabled);
4153+
if (old > 0) {
4154+
return -EBUSY;
4155+
}
4156+
} while (atomic_cmpxchg(&ram_block_discard_disabled, old, old - 1) != old);
4157+
return 0;
4158+
}
4159+
4160+
bool ram_block_discard_is_disabled(void)
4161+
{
4162+
return atomic_read(&ram_block_discard_disabled) > 0;
4163+
}
4164+
4165+
bool ram_block_discard_is_required(void)
4166+
{
4167+
return atomic_read(&ram_block_discard_disabled) < 0;
4168+
}
4169+
41184170
#endif

hw/arm/virt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
24012401
hc->unplug = virt_machine_device_unplug_cb;
24022402
mc->nvdimm_supported = true;
24032403
mc->auto_enable_numa_with_memhp = true;
2404+
mc->auto_enable_numa_with_memdev = true;
24042405
mc->default_ram_id = "mach-virt.ram";
24052406

24062407
object_class_property_add(oc, "acpi", "OnOffAuto",
@@ -2516,6 +2517,7 @@ static void virt_machine_5_0_options(MachineClass *mc)
25162517
compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
25172518
mc->numa_mem_supported = true;
25182519
vmc->acpi_expose_flash = true;
2520+
mc->auto_enable_numa_with_memdev = false;
25192521
}
25202522
DEFINE_VIRT_MACHINE(5, 0)
25212523

hw/core/numa.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,9 @@ void numa_complete_configuration(MachineState *ms)
688688
NodeInfo *numa_info = ms->numa_state->nodes;
689689

690690
/*
691-
* If memory hotplug is enabled (slots > 0) but without '-numa'
692-
* options explicitly on CLI, guestes will break.
691+
* If memory hotplug is enabled (slot > 0) or memory devices are enabled
692+
* (ms->maxram_size > ram_size) but without '-numa' options explicitly on
693+
* CLI, guests will break.
693694
*
694695
* Windows: won't enable memory hotplug without SRAT table at all
695696
*
@@ -704,9 +705,9 @@ void numa_complete_configuration(MachineState *ms)
704705
* assume there is just one node with whole RAM.
705706
*/
706707
if (ms->numa_state->num_nodes == 0 &&
707-
((ms->ram_slots > 0 &&
708-
mc->auto_enable_numa_with_memhp) ||
709-
mc->auto_enable_numa)) {
708+
((ms->ram_slots && mc->auto_enable_numa_with_memhp) ||
709+
(ms->maxram_size > ms->ram_size && mc->auto_enable_numa_with_memdev) ||
710+
mc->auto_enable_numa)) {
710711
NumaNodeOptions node = { };
711712
parse_numa_node(ms, &node, &error_abort);
712713
numa_info[0].node_mem = ram_size;
@@ -824,6 +825,7 @@ static void numa_stat_memory_devices(NumaNodeMem node_mem[])
824825
MemoryDeviceInfoList *info;
825826
PCDIMMDeviceInfo *pcdimm_info;
826827
VirtioPMEMDeviceInfo *vpi;
828+
VirtioMEMDeviceInfo *vmi;
827829

828830
for (info = info_list; info; info = info->next) {
829831
MemoryDeviceInfo *value = info->value;
@@ -844,6 +846,11 @@ static void numa_stat_memory_devices(NumaNodeMem node_mem[])
844846
node_mem[0].node_mem += vpi->size;
845847
node_mem[0].node_plugged_mem += vpi->size;
846848
break;
849+
case MEMORY_DEVICE_INFO_KIND_VIRTIO_MEM:
850+
vmi = value->u.virtio_mem.data;
851+
node_mem[vmi->node].node_mem += vmi->size;
852+
node_mem[vmi->node].node_plugged_mem += vmi->size;
853+
break;
847854
default:
848855
g_assert_not_reached();
849856
}

0 commit comments

Comments
 (0)