Misc patches for 2017-10-03
The following changes since commit ab161529261928ae7f3556e3220829c34b2686ec:
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20170927a' into staging (2017-09-27 22:44:51 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to 346b1215b1e9f7cc6d8fe9fb6f3c2778b890afb6:
kvmclock: use the updated system_timer_msr (2017-10-02 14:39:51 +0200)
----------------------------------------------------------------
* iothread bugfix (Eduardo)
* Linux headers sync (Dave)
* .gitignore fix (Eric)
* KVM capability check fixes (Greg)
* kvmclock fix (Jim)
----------------------------------------------------------------
Alexey Perevalov (1):
linux-headers: sync against v4.14-rc1
Eduardo Habkost (1):
iothread: Make iothread_stop() idempotent
Eric Blake (1):
scsi: Ignore executable for in-tree builds
Greg Kurz (2):
kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension()
kvm: check KVM_CAP_NR_VCPUS with kvm_vm_check_extension()
Jim Somerville (1):
kvmclock: use the updated system_timer_msr
.gitignore | 1 + accel/kvm/kvm-all.c | 51 +++++++++++++++------------- accel/stubs/kvm-stub.c | 4 +-- hw/i386/kvm/clock.c | 3 +- include/standard-headers/asm-x86/hyperv.h | 19 ++++++++--- include/standard-headers/linux/pci_regs.h | 42 +++++++++++++---------- include/standard-headers/linux/virtio_ring.h | 4 +-- include/sysemu/kvm.h | 2 +- iothread.c | 2 +- linux-headers/asm-s390/kvm.h | 6 ++++ linux-headers/linux/kvm.h | 3 +- linux-headers/linux/userfaultfd.h | 16 ++++++++- 12 files changed, 98 insertions(+), 55 deletions(-)
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 1/6] scsi: Ignore executable for in-tree builds
From: Eric Blake <[email protected]>
The new qemu-pr-helper (commit b855f8d17) should not be checked in, even when doing in-tree builds.
Message-Id: <[email protected]>
--- .gitignore | 1 + 1 file changed, 1 insertion(+)
.gitignore +1 -0
@@ -49,6 +49,7 @@ /qemu-version.h /qemu-version.h.tmp /module_block.h +/scsi/qemu-pr-helper /vscclient /vhost-user-scsi /fsdev/virtfs-proxy-helper
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 2/6] iothread: Make iothread_stop() idempotent
In reply to Paolo BonziniFrom: Eduardo Habkost <[email protected]>
Currently, iothread_stop_all() makes all iothread objects unsafe to be destroyed, because qemu_thread_join() ends up being called twice.
To fix this, make iothread_stop() idempotent by checking thread->stopped.
Fixes the following crash:
qemu-system-x86_64 -object iothread,id=iothread0 -monitor stdio -display none QEMU 2.10.50 monitor - type 'help' for more information
(qemu) quit
qemu: qemu_thread_join: No such process
Aborted (core dumped)
Message-Id: <[email protected]>
--- iothread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
iothread.c +1 -1
@@ -85,7 +85,7 @@ static int iothread_stop(Object *object, void *opaque)IOThread *iothread; iothread = (IOThread *)object_dynamic_cast (object,TYPE_IOTHREAD ); -if (!iothread || !iothread->ctx) { +if (!iothread || !iothread->ctx || iothread->stopping) {return 0 ; } iothread->stopping = true;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 4/6] kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension()
In reply to Paolo BonziniFrom: Greg Kurz <[email protected]>
On a server-class ppc host, this capability depends on the KVM type, ie, HV or PR. If both KVM are present in the kernel, we will always get the HV specific value, even if we explicitely requested PR on the command line.
This can have an impact if we're using hugepages or a balloon device.
Since we've already created the VM at the time any user calls kvm_has_sync_mmu(), switching to kvm_vm_check_extension() is enough to fix any potential issue.
It is okay for the other archs that also implement KVM_CAP_SYNC_MMU, ie, mips, s390, x86 and arm, because they don't depend on the VM being created or not.
While here, let's cache the state of this extension in a bool variable, since it has several users in the code, as suggested by Thomas Huth.
Message-Id: <[email protected]>
--- accel/kvm/kvm-all.c | 8 +++++--- accel/stubs/kvm-stub.c | 4 ++-- include/sysemu/kvm.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-)
accel/kvm/kvm-all.c +5 -3
@@ -87,6 +87,7 @@ struct KVMState#endif int many_ioeventfds;int intx_set_mask; +bool sync_mmu;/* The man page (and posix) say ioctl numbers are signed int, but * they're not. Linux, glibc and *BSD all treat ioctl numbers as * unsigned, and treating them as signed here can break things */
@@ -1664,6 +1665,8 @@ static int kvm_init(MachineState *ms) s->many_ioeventfds =kvm_check_many_ioeventfds (); + s->sync_mmu = !!kvm_vm_check_extension (kvm_state,KVM_CAP_SYNC_MMU ); +return 0 ; err:
@@ -2130,10 +2133,9 @@ int kvm_device_access(int fd, int group, uint64_t attr,return err; } -/* Return 1 on success, 0 on failure */ -int kvm_has_sync_mmu (void ) +bool kvm_has_sync_mmu (void ) { -return kvm_check_extension (kvm_state,KVM_CAP_SYNC_MMU ); +return kvm_state->sync_mmu; }int kvm_has_vcpu_events (void )
accel/stubs/kvm-stub.c +2 -2
@@ -64,9 +64,9 @@ int kvm_cpu_exec(CPUState *cpu)abort (); } -int kvm_has_sync_mmu (void ) +bool kvm_has_sync_mmu (void ) { -return 0 ; +return false; }int kvm_has_many_ioeventfds (void )
include/sysemu/kvm.h +1 -1
@@ -207,7 +207,7 @@ extern KVMState *kvm_state;/* external API */ bool kvm_has_free_slot (MachineState *ms); -int kvm_has_sync_mmu (void ); +bool kvm_has_sync_mmu (void );int kvm_has_vcpu_events (void );int kvm_has_robust_singlestep (void );int kvm_has_debugregs (void );
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 3/6] linux-headers: sync against v4.14-rc1
In reply to Paolo BonziniFrom: Alexey Perevalov <[email protected]>
Message-Id: <[email protected]>
--- include/standard-headers/asm-x86/hyperv.h | 19 ++++++++++--- include/standard-headers/linux/pci_regs.h | 42 ++++++++++++++++------------ include/standard-headers/linux/virtio_ring.h | 4 +-- linux-headers/asm-s390/kvm.h | 6 ++++ linux-headers/linux/kvm.h | 3 +- linux-headers/linux/userfaultfd.h | 16 ++++++++++- 6 files changed, 64 insertions(+), 26 deletions(-)
include/standard-headers/asm-x86/hyperv.h +15 -4
@@ -149,12 +149,9 @@*/ #define HV_X64_DEPRECATING_AEOI_RECOMMENDED (1 << 9) -/* -* HV_VP_SET available -*/ +/* Recommend using the newer ExProcessorMasks interface */ #define HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED (1 << 11) -/* * Crash notification flag. */
@@ -242,7 +239,11 @@ (~((1ull <<HV_X64_MSR_HYPERCALL_PAGE_ADDRESS_SHIFT ) -1 )) /* Declare the various hypercall operations. */ +#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE 0x0002 +#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST 0x0003#define HVCALL_NOTIFY_LONG_SPIN_WAIT 0x0008 +#define HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX 0x0013 +#define HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX 0x0014#define HVCALL_POST_MESSAGE 0x005c#define HVCALL_SIGNAL_EVENT 0x005d
@@ -259,6 +260,16 @@#define HV_PROCESSOR_POWER_STATE_C2 2#define HV_PROCESSOR_POWER_STATE_C3 3 +#define HV_FLUSH_ALL_PROCESSORS BIT(0) +#define HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES BIT(1) +#define HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY BIT(2) +#define HV_FLUSH_USE_EXTENDED_RANGE_FORMAT BIT(3) + +enum HV_GENERIC_SET_FORMAT { +HV_GENERIC_SET_SPARCE_4K , +HV_GENERIC_SET_ALL , +}; +/* hypercall status code */ #define HV_STATUS_SUCCESS 0#define HV_STATUS_INVALID_HYPERCALL_CODE 2
include/standard-headers/linux/pci_regs.h +24 -18
85 lines not on this page · raw message
include/standard-headers/linux/virtio_ring.h +2 -2
@@ -1,7 +1,7 @@#ifndef _LINUX_VIRTIO_RING_H#define _LINUX_VIRTIO_RING_H -/* An interface for efficient virtio implementation, currently for use by KVM -* and lguest, but hopefully others soon. Do NOT change this since it will +/* An interface for efficient virtio implementation, currently for use by KVM, +* but hopefully others soon. Do NOT change this since it will * break existing servers and clients. * * This header is BSD licensed so anyone can use the definitions to implement
linux-headers/asm-s390/kvm.h +6 -0
@@ -88,6 +88,12 @@ struct kvm_s390_io_adapter_req {/* kvm attributes for KVM_S390_VM_TOD */ #define KVM_S390_VM_TOD_LOW 0#define KVM_S390_VM_TOD_HIGH 1 +#define KVM_S390_VM_TOD_EXT 2 + +struct kvm_s390_vm_tod_clock { +__u8 epoch_idx; +__u64 tod; +};/* kvm attributes for KVM_S390_VM_CPU_MODEL */ /* processor related attributes are r/w */
linux-headers/linux/kvm.h +2 -1
@@ -711,7 +711,8 @@ struct kvm_ppc_one_seg_page_size {struct kvm_ppc_smmu_info {__u64 flags;__u32 slb_size; -__u32 pad; +__u16 data_keys;/* # storage keys supported for data */ +__u16 instr_keys;/* # storage keys supported for instructions */ struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ ]; };
linux-headers/linux/userfaultfd.h +15 -1
@@ -23,7 +23,9 @@ UFFD_FEATURE_EVENT_REMOVE | \ UFFD_FEATURE_EVENT_UNMAP | \ UFFD_FEATURE_MISSING_HUGETLBFS | \ - UFFD_FEATURE_MISSING_SHMEM) + UFFD_FEATURE_MISSING_SHMEM | \ + UFFD_FEATURE_SIGBUS | \ + UFFD_FEATURE_THREAD_ID)#define UFFD_API_IOCTLS \ ((__u64)1 << _UFFDIO_REGISTER | \ (__u64)1 << _UFFDIO_UNREGISTER | \
@@ -78,6 +80,9 @@ struct uffd_msg {struct {__u64 flags;__u64 address; +union { +__u32 ptid; + } feat; } pagefault;struct {
@@ -153,6 +158,13 @@ struct uffdio_api {* UFFD_FEATURE_MISSING_SHMEM works the same as * UFFD_FEATURE_MISSING_HUGETLBFS, but it applies to shmem * (i.e. tmpfs and other shmem based APIs). +* +* UFFD_FEATURE_SIGBUS feature means no page-fault +* (UFFD_EVENT_PAGEFAULT) event will be delivered, instead +* a SIGBUS signal will be sent to the faulting process. +* +* UFFD_FEATURE_THREAD_ID pid of the page faulted task_struct will +* be returned, if feature is not requested 0 will be returned. */ #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0)#define UFFD_FEATURE_EVENT_FORK (1<<1)
@@ -161,6 +173,8 @@ struct uffdio_api {#define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4)#define UFFD_FEATURE_MISSING_SHMEM (1<<5)#define UFFD_FEATURE_EVENT_UNMAP (1<<6) +#define UFFD_FEATURE_SIGBUS (1<<7) +#define UFFD_FEATURE_THREAD_ID (1<<8)__u64 features;__u64 ioctls;
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 5/6] kvm: check KVM_CAP_NR_VCPUS with kvm_vm_check_extension()
In reply to Paolo BonziniFrom: Greg Kurz <[email protected]>
On a modern server-class ppc host with the following CPU topology:
Architecture: ppc64le Byte Order: Little Endian CPU(s): 32 On-line CPU(s) list: 0,8,16,24 Off-line CPU(s) list: 1-7,9-15,17-23,25-31 Thread(s) per core: 1
If both KVM PR and KVM HV loaded and we pass:
-machine pseries,accel=kvm,kvm-type=PR -smp 8
We expect QEMU to warn that this exceeds the number of online CPUs:
Warning: Number of SMP cpus requested (8) exceeds the recommended
cpus supported by KVM (4)
Warning: Number of hotpluggable cpus requested (8) exceeds the
recommended cpus supported by KVM (4)
but nothing is printed...
This happens because on ppc the KVM_CAP_NR_VCPUS capability is VM specific ndreally depends on the KVM type, but we currently use it as a global capability. And KVM returns a fallback value based on KVM HV being present. Maybe KVM on POWER shouldn't presume anything as long as it doesn't have a VM, but in all cases, we should call KVM_CREATE_VM first and use KVM_CAP_NR_VCPUS as a VM capability.
This patch hence changes kvm_recommended_vcpus() accordingly and moves the sanity checking of smp_cpus after the VM creation.
It is okay for the other archs that also implement KVM_CAP_NR_VCPUS, ie, mips, s390, x86 and arm, because they don't depend on the VM being created or not.
Message-Id: <[email protected]>
--- accel/kvm/kvm-all.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-)
accel/kvm/kvm-all.c +22 -21
@@ -1440,7 +1440,7 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s)*/ static int kvm_recommended_vcpus (KVMState *s) { -int ret =kvm_check_extension (s,KVM_CAP_NR_VCPUS ); +int ret =kvm_vm_check_extension (s,KVM_CAP_NR_VCPUS );return (ret) ? ret :4 ; }
@@ -1530,26 +1530,6 @@ static int kvm_init(MachineState *ms) s->nr_slots =32 ; } -/* check the vcpu limits */ - soft_vcpus_limit =kvm_recommended_vcpus (s); - hard_vcpus_limit =kvm_max_vcpus (s); - -while (nc->name) { -if (nc->num > soft_vcpus_limit) { -warn_report ("Number of %s cpus requested (%d) exceeds " -"the recommended cpus supported by KVM (%d)" , - nc->name, nc->num, soft_vcpus_limit); - -if (nc->num > hard_vcpus_limit) { -fprintf (stderr,"Number of %s cpus requested (%d) exceeds " -"the maximum cpus supported by KVM (%d)\n" , - nc->name, nc->num, hard_vcpus_limit); -exit (1 ); - } - } - nc++; - } - kvm_type =qemu_opt_get (qemu_get_machine_opts (),"kvm-type" );if (mc->kvm_type) { type = mc->kvm_type (kvm_type);
@@ -1584,6 +1564,27 @@ static int kvm_init(MachineState *ms) } s->vmfd = ret; + +/* check the vcpu limits */ + soft_vcpus_limit =kvm_recommended_vcpus (s); + hard_vcpus_limit =kvm_max_vcpus (s); + +while (nc->name) { +if (nc->num > soft_vcpus_limit) { +warn_report ("Number of %s cpus requested (%d) exceeds " +"the recommended cpus supported by KVM (%d)" , + nc->name, nc->num, soft_vcpus_limit); + +if (nc->num > hard_vcpus_limit) { +fprintf (stderr,"Number of %s cpus requested (%d) exceeds " +"the maximum cpus supported by KVM (%d)\n" , + nc->name, nc->num, hard_vcpus_limit); +exit (1 ); + } + } + nc++; + } + missing_cap =kvm_check_extension_list (s, kvm_required_capabilites);if (!missing_cap) { missing_cap =
Signature · 1 line
1.8.3.1
[Qemu-devel] [PULL 6/6] kvmclock: use the updated system_timer_msr
In reply to Paolo BonziniFrom: Jim Somerville <[email protected]>
Fixes e2b6c17 (kvmclock: update system_time_msr address forcibly) which makes a call to get the latest value of the address stored in system_timer_msr, but then uses the old address anyway.
Message-Id: <59b67db0bd15a46ab47c3aa657c81a4c11f168ea.1506702472.git.Jim.Somerville@windriver.com>
--- hw/i386/kvm/clock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/kvm/clock.c +2 -1
@@ -62,7 +62,7 @@ static uint64_t kvmclock_current_nsec(KVMClockState *s) {CPUState *cpu = first_cpu;CPUX86State *env = cpu->env_ptr; -hwaddr kvmclock_struct_pa = env->system_time_msr & ~1ULL ; +hwaddr kvmclock_struct_pa;uint64_t migration_tsc = env->tsc;struct pvclock_vcpu_time_info time;uint64_t delta;
@@ -77,6 +77,7 @@ static uint64_t kvmclock_current_nsec(KVMClockState *s)return 0 ; } + kvmclock_struct_pa = env->system_time_msr & ~1ULL ;cpu_physical_memory_read (kvmclock_struct_pa, &time,sizeof (time));assert (time.tsc_timestamp <= migration_tsc);
Signature · 1 line
1.8.3.1
Peter Maydell
AppliedQuoted 11 lines · Paolo Bonzini
The following changes since commit
ab161529261928ae7f3556e3220829c34b2686ec:Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20170927a' into staging (2017-09-27 22:44:51 +0100)
are available in the git repository at:
git://github.com/bonzini/qemu.gittags/for-upstreamfor you to fetch changes up to
346b1215b1e9f7cc6d8fe9fb6f3c2778b890afb6:
Quoted 9 lines
kvmclock: use the updated
system_timer_msr(2017-10-02 14:39:51 +0200)----------------------------------------------------------------
* iothread bugfix (Eduardo)
* Linux headers sync (Dave)
* .gitignore fix (Eric)
* KVM capability check fixes (Greg)
* kvmclock fix (Jim)
Applied, thanks.
-- PMM