Skip to content

Commit b5ab62b

Browse files
committed
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging
* pc: Add a description for the i8042 property * kvm: support for nested FRED * tests/unit: fix warning when compiling test-nested-aio-poll with LTO * kvm: refactoring of VM creation * target/i386: expose IBPB-BRTYPE and SBPB CPUID bits to the guest * hw/char: clean up serial * remove virtfs-proxy-helper * target/i386/kvm: Report which action failed in kvm_arch_put/get_registers * qom: improvements to object_resolve_path*() # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmb++MsUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroPVnwf/cdvfxvDm22tEdlh8vHlV17HtVdcC # Hw334M/3PDvbTmGzPBg26lzo4nFS6SLrZ8ETCeqvuJrtKzqVk9bI8ssZW5KA4ijM # nkxguRPHO8E6U33ZSucc+Hn56+bAx4I2X80dLKXJ87OsbMffIeJ6aHGSEI1+fKVh # pK7q53+Y3lQWuRBGhDIyKNuzqU4g+irpQwXOhux63bV3ADadmsqzExP6Gmtl8OKM # DylPu1oK7EPZumlSiJa7Gy1xBqL4Rc4wGPNYx2RVRjp+i7W2/Y1uehm3wSBw+SXC # a6b7SvLoYfWYS14/qCF4cBL3sJH/0f/4g8ZAhDDxi2i5kBr0/5oioDyE/A== # =/zo4 # -----END PGP SIGNATURE----- # gpg: Signature made Thu 03 Oct 2024 21:04:27 BST # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "[email protected]" # gpg: Good signature from "Paolo Bonzini <[email protected]>" [full] # gpg: aka "Paolo Bonzini <[email protected]>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: (23 commits) qom: update object_resolve_path*() documentation qom: set *ambiguous on all paths qom: rename object_resolve_path_type() "ambiguousp" target/i386/kvm: Report which action failed in kvm_arch_put/get_registers kvm: Allow kvm_arch_get/put_registers to accept Error** accel/kvm: refactor dirty ring setup minikconf: print error entirely on stderr 9p: remove 'proxy' filesystem backend driver hw/char: Extract serial-mm hw/char/serial.h: Extract serial-isa.h hw: Remove unused inclusion of hw/char/serial.h target/i386: Expose IBPB-BRTYPE and SBPB CPUID bits to the guest kvm: refactor core virtual machine creation into its own function kvm/i386: replace identity_base variable with a constant kvm/i386: refactor kvm_arch_init and split it into smaller functions kvm: replace fprintf with error_report()/printf() in kvm_init() kvm/i386: fix return values of is_host_cpu_intel() kvm/i386: make kvm_filter_msr() and related definitions private to kvm module hw/i386/pc: Add a description for the i8042 property tests/unit: remove block layer code from test-nested-aio-poll ... Signed-off-by: Peter Maydell <[email protected]> # Conflicts: # hw/arm/Kconfig # hw/arm/pxa2xx.c
2 parents a3fb4e9 + 7cca79f commit b5ab62b

Some content is hidden

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

97 files changed

+767
-3270
lines changed

MAINTAINERS

-8
Original file line numberDiff line numberDiff line change
@@ -2207,20 +2207,12 @@ S: Maintained
22072207
W: https://wiki.qemu.org/Documentation/9p
22082208
F: hw/9pfs/
22092209
X: hw/9pfs/xen-9p*
2210-
X: hw/9pfs/9p-proxy*
22112210
F: fsdev/
2212-
X: fsdev/virtfs-proxy-helper.c
22132211
F: tests/qtest/virtio-9p-test.c
22142212
F: tests/qtest/libqos/virtio-9p*
22152213
T: git https://gitlab.com/gkurz/qemu.git 9p-next
22162214
T: git https://github.com/cschoenebeck/qemu.git 9p.next
22172215

2218-
virtio-9p-proxy
2219-
F: hw/9pfs/9p-proxy*
2220-
F: fsdev/virtfs-proxy-helper.c
2221-
F: docs/tools/virtfs-proxy-helper.rst
2222-
S: Obsolete
2223-
22242216
virtio-blk
22252217
M: Stefan Hajnoczi <[email protected]>
22262218

accel/kvm/kvm-all.c

+146-92
Original file line numberDiff line numberDiff line change
@@ -2381,6 +2381,109 @@ uint32_t kvm_dirty_ring_size(void)
23812381
return kvm_state->kvm_dirty_ring_size;
23822382
}
23832383

2384+
static int do_kvm_create_vm(MachineState *ms, int type)
2385+
{
2386+
KVMState *s;
2387+
int ret;
2388+
2389+
s = KVM_STATE(ms->accelerator);
2390+
2391+
do {
2392+
ret = kvm_ioctl(s, KVM_CREATE_VM, type);
2393+
} while (ret == -EINTR);
2394+
2395+
if (ret < 0) {
2396+
error_report("ioctl(KVM_CREATE_VM) failed: %s", strerror(-ret));
2397+
2398+
#ifdef TARGET_S390X
2399+
if (ret == -EINVAL) {
2400+
error_printf("Host kernel setup problem detected."
2401+
" Please verify:\n");
2402+
error_printf("- for kernels supporting the"
2403+
" switch_amode or user_mode parameters, whether");
2404+
error_printf(" user space is running in primary address space\n");
2405+
error_printf("- for kernels supporting the vm.allocate_pgste"
2406+
" sysctl, whether it is enabled\n");
2407+
}
2408+
#elif defined(TARGET_PPC)
2409+
if (ret == -EINVAL) {
2410+
error_printf("PPC KVM module is not loaded. Try modprobe kvm_%s.\n",
2411+
(type == 2) ? "pr" : "hv");
2412+
}
2413+
#endif
2414+
}
2415+
2416+
return ret;
2417+
}
2418+
2419+
static int find_kvm_machine_type(MachineState *ms)
2420+
{
2421+
MachineClass *mc = MACHINE_GET_CLASS(ms);
2422+
int type;
2423+
2424+
if (object_property_find(OBJECT(current_machine), "kvm-type")) {
2425+
g_autofree char *kvm_type;
2426+
kvm_type = object_property_get_str(OBJECT(current_machine),
2427+
"kvm-type",
2428+
&error_abort);
2429+
type = mc->kvm_type(ms, kvm_type);
2430+
} else if (mc->kvm_type) {
2431+
type = mc->kvm_type(ms, NULL);
2432+
} else {
2433+
type = kvm_arch_get_default_type(ms);
2434+
}
2435+
return type;
2436+
}
2437+
2438+
static int kvm_setup_dirty_ring(KVMState *s)
2439+
{
2440+
uint64_t dirty_log_manual_caps;
2441+
int ret;
2442+
2443+
/*
2444+
* Enable KVM dirty ring if supported, otherwise fall back to
2445+
* dirty logging mode
2446+
*/
2447+
ret = kvm_dirty_ring_init(s);
2448+
if (ret < 0) {
2449+
return ret;
2450+
}
2451+
2452+
/*
2453+
* KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is not needed when dirty ring is
2454+
* enabled. More importantly, KVM_DIRTY_LOG_INITIALLY_SET will assume no
2455+
* page is wr-protected initially, which is against how kvm dirty ring is
2456+
* usage - kvm dirty ring requires all pages are wr-protected at the very
2457+
* beginning. Enabling this feature for dirty ring causes data corruption.
2458+
*
2459+
* TODO: Without KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 and kvm clear dirty log,
2460+
* we may expect a higher stall time when starting the migration. In the
2461+
* future we can enable KVM_CLEAR_DIRTY_LOG to work with dirty ring too:
2462+
* instead of clearing dirty bit, it can be a way to explicitly wr-protect
2463+
* guest pages.
2464+
*/
2465+
if (!s->kvm_dirty_ring_size) {
2466+
dirty_log_manual_caps =
2467+
kvm_check_extension(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
2468+
dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
2469+
KVM_DIRTY_LOG_INITIALLY_SET);
2470+
s->manual_dirty_log_protect = dirty_log_manual_caps;
2471+
if (dirty_log_manual_caps) {
2472+
ret = kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0,
2473+
dirty_log_manual_caps);
2474+
if (ret) {
2475+
warn_report("Trying to enable capability %"PRIu64" of "
2476+
"KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 but failed. "
2477+
"Falling back to the legacy mode. ",
2478+
dirty_log_manual_caps);
2479+
s->manual_dirty_log_protect = 0;
2480+
}
2481+
}
2482+
}
2483+
2484+
return 0;
2485+
}
2486+
23842487
static int kvm_init(MachineState *ms)
23852488
{
23862489
MachineClass *mc = MACHINE_GET_CLASS(ms);
@@ -2400,7 +2503,6 @@ static int kvm_init(MachineState *ms)
24002503
const KVMCapabilityInfo *missing_cap;
24012504
int ret;
24022505
int type;
2403-
uint64_t dirty_log_manual_caps;
24042506

24052507
qemu_mutex_init(&kml_slots_lock);
24062508

@@ -2423,7 +2525,7 @@ static int kvm_init(MachineState *ms)
24232525
QLIST_INIT(&s->kvm_parked_vcpus);
24242526
s->fd = qemu_open_old(s->device ?: "/dev/kvm", O_RDWR);
24252527
if (s->fd == -1) {
2426-
fprintf(stderr, "Could not access KVM kernel module: %m\n");
2528+
error_report("Could not access KVM kernel module: %m");
24272529
ret = -errno;
24282530
goto err;
24292531
}
@@ -2433,13 +2535,13 @@ static int kvm_init(MachineState *ms)
24332535
if (ret >= 0) {
24342536
ret = -EINVAL;
24352537
}
2436-
fprintf(stderr, "kvm version too old\n");
2538+
error_report("kvm version too old");
24372539
goto err;
24382540
}
24392541

24402542
if (ret > KVM_API_VERSION) {
24412543
ret = -EINVAL;
2442-
fprintf(stderr, "kvm version not supported\n");
2544+
error_report("kvm version not supported");
24432545
goto err;
24442546
}
24452547

@@ -2463,49 +2565,14 @@ static int kvm_init(MachineState *ms)
24632565
}
24642566
s->as = g_new0(struct KVMAs, s->nr_as);
24652567

2466-
if (object_property_find(OBJECT(current_machine), "kvm-type")) {
2467-
g_autofree char *kvm_type = object_property_get_str(OBJECT(current_machine),
2468-
"kvm-type",
2469-
&error_abort);
2470-
type = mc->kvm_type(ms, kvm_type);
2471-
} else if (mc->kvm_type) {
2472-
type = mc->kvm_type(ms, NULL);
2473-
} else {
2474-
type = kvm_arch_get_default_type(ms);
2475-
}
2476-
2568+
type = find_kvm_machine_type(ms);
24772569
if (type < 0) {
24782570
ret = -EINVAL;
24792571
goto err;
24802572
}
24812573

2482-
do {
2483-
ret = kvm_ioctl(s, KVM_CREATE_VM, type);
2484-
} while (ret == -EINTR);
2485-
2574+
ret = do_kvm_create_vm(ms, type);
24862575
if (ret < 0) {
2487-
fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret,
2488-
strerror(-ret));
2489-
2490-
#ifdef TARGET_S390X
2491-
if (ret == -EINVAL) {
2492-
fprintf(stderr,
2493-
"Host kernel setup problem detected. Please verify:\n");
2494-
fprintf(stderr, "- for kernels supporting the switch_amode or"
2495-
" user_mode parameters, whether\n");
2496-
fprintf(stderr,
2497-
" user space is running in primary address space\n");
2498-
fprintf(stderr,
2499-
"- for kernels supporting the vm.allocate_pgste sysctl, "
2500-
"whether it is enabled\n");
2501-
}
2502-
#elif defined(TARGET_PPC)
2503-
if (ret == -EINVAL) {
2504-
fprintf(stderr,
2505-
"PPC KVM module is not loaded. Try modprobe kvm_%s.\n",
2506-
(type == 2) ? "pr" : "hv");
2507-
}
2508-
#endif
25092576
goto err;
25102577
}
25112578

@@ -2522,9 +2589,9 @@ static int kvm_init(MachineState *ms)
25222589
nc->name, nc->num, soft_vcpus_limit);
25232590

25242591
if (nc->num > hard_vcpus_limit) {
2525-
fprintf(stderr, "Number of %s cpus requested (%d) exceeds "
2526-
"the maximum cpus supported by KVM (%d)\n",
2527-
nc->name, nc->num, hard_vcpus_limit);
2592+
error_report("Number of %s cpus requested (%d) exceeds "
2593+
"the maximum cpus supported by KVM (%d)",
2594+
nc->name, nc->num, hard_vcpus_limit);
25282595
exit(1);
25292596
}
25302597
}
@@ -2538,56 +2605,20 @@ static int kvm_init(MachineState *ms)
25382605
}
25392606
if (missing_cap) {
25402607
ret = -EINVAL;
2541-
fprintf(stderr, "kvm does not support %s\n%s",
2542-
missing_cap->name, upgrade_note);
2608+
error_report("kvm does not support %s", missing_cap->name);
2609+
error_printf("%s", upgrade_note);
25432610
goto err;
25442611
}
25452612

25462613
s->coalesced_mmio = kvm_check_extension(s, KVM_CAP_COALESCED_MMIO);
25472614
s->coalesced_pio = s->coalesced_mmio &&
25482615
kvm_check_extension(s, KVM_CAP_COALESCED_PIO);
25492616

2550-
/*
2551-
* Enable KVM dirty ring if supported, otherwise fall back to
2552-
* dirty logging mode
2553-
*/
2554-
ret = kvm_dirty_ring_init(s);
2617+
ret = kvm_setup_dirty_ring(s);
25552618
if (ret < 0) {
25562619
goto err;
25572620
}
25582621

2559-
/*
2560-
* KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 is not needed when dirty ring is
2561-
* enabled. More importantly, KVM_DIRTY_LOG_INITIALLY_SET will assume no
2562-
* page is wr-protected initially, which is against how kvm dirty ring is
2563-
* usage - kvm dirty ring requires all pages are wr-protected at the very
2564-
* beginning. Enabling this feature for dirty ring causes data corruption.
2565-
*
2566-
* TODO: Without KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 and kvm clear dirty log,
2567-
* we may expect a higher stall time when starting the migration. In the
2568-
* future we can enable KVM_CLEAR_DIRTY_LOG to work with dirty ring too:
2569-
* instead of clearing dirty bit, it can be a way to explicitly wr-protect
2570-
* guest pages.
2571-
*/
2572-
if (!s->kvm_dirty_ring_size) {
2573-
dirty_log_manual_caps =
2574-
kvm_check_extension(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
2575-
dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
2576-
KVM_DIRTY_LOG_INITIALLY_SET);
2577-
s->manual_dirty_log_protect = dirty_log_manual_caps;
2578-
if (dirty_log_manual_caps) {
2579-
ret = kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0,
2580-
dirty_log_manual_caps);
2581-
if (ret) {
2582-
warn_report("Trying to enable capability %"PRIu64" of "
2583-
"KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 but failed. "
2584-
"Falling back to the legacy mode. ",
2585-
dirty_log_manual_caps);
2586-
s->manual_dirty_log_protect = 0;
2587-
}
2588-
}
2589-
}
2590-
25912622
#ifdef KVM_CAP_VCPU_EVENTS
25922623
s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS);
25932624
#endif
@@ -2762,9 +2793,15 @@ void kvm_flush_coalesced_mmio_buffer(void)
27622793
static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg)
27632794
{
27642795
if (!cpu->vcpu_dirty && !kvm_state->guest_state_protected) {
2765-
int ret = kvm_arch_get_registers(cpu);
2796+
Error *err = NULL;
2797+
int ret = kvm_arch_get_registers(cpu, &err);
27662798
if (ret) {
2767-
error_report("Failed to get registers: %s", strerror(-ret));
2799+
if (err) {
2800+
error_reportf_err(err, "Failed to synchronize CPU state: ");
2801+
} else {
2802+
error_report("Failed to get registers: %s", strerror(-ret));
2803+
}
2804+
27682805
cpu_dump_state(cpu, stderr, CPU_DUMP_CODE);
27692806
vm_stop(RUN_STATE_INTERNAL_ERROR);
27702807
}
@@ -2782,9 +2819,15 @@ void kvm_cpu_synchronize_state(CPUState *cpu)
27822819

27832820
static void do_kvm_cpu_synchronize_post_reset(CPUState *cpu, run_on_cpu_data arg)
27842821
{
2785-
int ret = kvm_arch_put_registers(cpu, KVM_PUT_RESET_STATE);
2822+
Error *err = NULL;
2823+
int ret = kvm_arch_put_registers(cpu, KVM_PUT_RESET_STATE, &err);
27862824
if (ret) {
2787-
error_report("Failed to put registers after reset: %s", strerror(-ret));
2825+
if (err) {
2826+
error_reportf_err(err, "Restoring resisters after reset: ");
2827+
} else {
2828+
error_report("Failed to put registers after reset: %s",
2829+
strerror(-ret));
2830+
}
27882831
cpu_dump_state(cpu, stderr, CPU_DUMP_CODE);
27892832
vm_stop(RUN_STATE_INTERNAL_ERROR);
27902833
}
@@ -2799,9 +2842,15 @@ void kvm_cpu_synchronize_post_reset(CPUState *cpu)
27992842

28002843
static void do_kvm_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg)
28012844
{
2802-
int ret = kvm_arch_put_registers(cpu, KVM_PUT_FULL_STATE);
2845+
Error *err = NULL;
2846+
int ret = kvm_arch_put_registers(cpu, KVM_PUT_FULL_STATE, &err);
28032847
if (ret) {
2804-
error_report("Failed to put registers after init: %s", strerror(-ret));
2848+
if (err) {
2849+
error_reportf_err(err, "Putting registers after init: ");
2850+
} else {
2851+
error_report("Failed to put registers after init: %s",
2852+
strerror(-ret));
2853+
}
28052854
exit(1);
28062855
}
28072856

@@ -2991,10 +3040,15 @@ int kvm_cpu_exec(CPUState *cpu)
29913040
MemTxAttrs attrs;
29923041

29933042
if (cpu->vcpu_dirty) {
2994-
ret = kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE);
3043+
Error *err = NULL;
3044+
ret = kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE, &err);
29953045
if (ret) {
2996-
error_report("Failed to put registers after init: %s",
2997-
strerror(-ret));
3046+
if (err) {
3047+
error_reportf_err(err, "Putting registers after init: ");
3048+
} else {
3049+
error_report("Failed to put registers after init: %s",
3050+
strerror(-ret));
3051+
}
29983052
ret = -1;
29993053
break;
30003054
}

docs/about/deprecated.rst

-22
Original file line numberDiff line numberDiff line change
@@ -314,28 +314,6 @@ the addition of volatile memory support, it is now necessary to distinguish
314314
between persistent and volatile memory backends. As such, memdev is deprecated
315315
in favor of persistent-memdev.
316316

317-
``-fsdev proxy`` and ``-virtfs proxy`` (since 8.1)
318-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
319-
320-
The 9p ``proxy`` filesystem backend driver has been deprecated and will be
321-
removed (along with its proxy helper daemon) in a future version of QEMU. Please
322-
use ``-fsdev local`` or ``-virtfs local`` for using the 9p ``local`` filesystem
323-
backend, or alternatively consider deploying virtiofsd instead.
324-
325-
The 9p ``proxy`` backend was originally developed as an alternative to the 9p
326-
``local`` backend. The idea was to enhance security by dispatching actual low
327-
level filesystem operations from 9p server (QEMU process) over to a separate
328-
process (the virtfs-proxy-helper binary). However this alternative never gained
329-
momentum. The proxy backend is much slower than the local backend, hasn't seen
330-
any development in years, and showed to be less secure, especially due to the
331-
fact that its helper daemon must be run as root, whereas with the local backend
332-
QEMU is typically run as unprivileged user and allows to tighten behaviour by
333-
mapping permissions et al by using its 'mapped' security model option.
334-
335-
Nowadays it would make sense to reimplement the ``proxy`` backend by using
336-
QEMU's ``vhost`` feature, which would eliminate the high latency costs under
337-
which the 9p ``proxy`` backend currently suffers. However as of to date nobody
338-
has indicated plans for such kind of reimplementation unfortunately.
339317

340318
RISC-V CPU properties which start with capital 'Z' (since 8.2)
341319
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)