1. 17 8月, 2018 1 次提交
  2. 29 6月, 2018 1 次提交
    • S
      kvm: Delete the slot if and only if the KVM_MEM_READONLY flag is changed · 6c090d4a
      Shannon Zhao 提交于
      According to KVM commit 75d61fbc, it needs to delete the slot before
      changing the KVM_MEM_READONLY flag. But QEMU commit 235e8982 only check
      whether KVM_MEM_READONLY flag is set instead of changing. It doesn't
      need to delete the slot if the KVM_MEM_READONLY flag is not changed.
      
      This fixes a issue that migrating a VM at the OVMF startup stage and
      VM is executing the codes in rom. Between the deleting and adding the
      slot in kvm_set_user_memory_region, there is a chance that guest access
      rom and trap to KVM, then KVM can't find the corresponding memslot.
      While KVM (on ARM) injects an abort to guest due to the broken hva, then
      guest will get stuck.
      Signed-off-by: NShannon Zhao <zhaoshenglong@huawei.com>
      Message-Id: <1526462314-19720-1-git-send-email-zhaoshenglong@huawei.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6c090d4a
  3. 13 3月, 2018 2 次提交
  4. 05 2月, 2018 1 次提交
  5. 25 1月, 2018 1 次提交
  6. 19 1月, 2018 1 次提交
  7. 18 10月, 2017 5 次提交
  8. 02 10月, 2017 2 次提交
    • G
      kvm: check KVM_CAP_NR_VCPUS with kvm_vm_check_extension() · 11748ba7
      Greg Kurz 提交于
      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.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NThomas Huth <thuth@redhat.com>
      Message-Id: <150600966286.30533.10909862523552370889.stgit@bahia.lan>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      11748ba7
    • G
      kvm: check KVM_CAP_SYNC_MMU with kvm_vm_check_extension() · 62dd4eda
      Greg Kurz 提交于
      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.
      Signed-off-by: NGreg Kurz <groug@kaod.org>
      Message-Id: <150600965332.30533.14702405809647835716.stgit@bahia.lan>
      Reviewed-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      62dd4eda
  9. 21 9月, 2017 1 次提交
  10. 19 9月, 2017 7 次提交
    • A
      Convert multi-line fprintf() to warn_report() · 8297be80
      Alistair Francis 提交于
      Convert all the multi-line uses of fprintf(stderr, "warning:"..."\n"...
      to use warn_report() instead. This helps standardise on a single
      method of printing warnings to the user.
      
      All of the warnings were changed using these commands:
        find ./* -type f -exec sed -i \
          'N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
        find ./* -type f -exec sed -i \
          'N;N;N;N;N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
          {} +
      
      Indentation fixed up manually afterwards.
      
      Some of the lines were manually edited to reduce the line length to below
      80 charecters. Some of the lines with newlines in the middle of the
      string were also manually edit to avoid checkpatch errrors.
      
      The #include lines were manually updated to allow the code to compile.
      
      Several of the warning messages can be improved after this patch, to
      keep this patch mechanical this has been moved into a later patch.
      Signed-off-by: NAlistair Francis <alistair.francis@xilinx.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Kevin Wolf <kwolf@redhat.com>
      Cc: Max Reitz <mreitz@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Stefano Stabellini <sstabellini@kernel.org>
      Cc: Anthony Perard <anthony.perard@citrix.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Eduardo Habkost <ehabkost@redhat.com>
      Cc: Aurelien Jarno <aurelien@aurel32.net>
      Cc: Yongbok Kim <yongbok.kim@imgtec.com>
      Cc: Cornelia Huck <cohuck@redhat.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Alexander Graf <agraf@suse.de>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: David Gibson <david@gibson.dropbear.id.au>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Acked-by: NCornelia Huck <cohuck@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <5def63849ca8f551630c6f2b45bcb1c482f765a6.1505158760.git.alistair.francis@xilinx.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      8297be80
    • D
      kvm: kvm_log_sync() is only called with known memory sections · 67548f09
      David Hildenbrand 提交于
      Flatview will make sure that we can only end up in this function with
      memory sections that correspond to exactly one slot. So we don't
      have to iterate multiple times. There won't be overlapping slots but
      only matching slots.
      
      Properly align the section and look up the corresponding slot. This
      heavily simplifies this function.
      
      We can now get rid of kvm_lookup_overlapping_slot().
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20170911174933.20789-7-david@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      67548f09
    • D
      kvm: kvm_log_start/stop are only called with known sections · 343562e8
      David Hildenbrand 提交于
      Let's properly align the sections first and bail out if we would ever
      get called with a memory section we don't know yet.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20170911174933.20789-6-david@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      343562e8
    • D
      kvm: we never have overlapping slots in kvm_set_phys_mem() · f357f564
      David Hildenbrand 提交于
      The way flatview handles memory sections, we will never have overlapping
      memory sections in kvm.
      
      address_space_update_topology_pass() will make sure that we will only
      get called for
      
      a) an existing memory section for which we only update parameters
      (log_start, log_stop).
      b) an existing memory section we want to delete (region_del)
      c) a brand new memory section we want to add (region_add)
      
      We cannot have overlapping memory sections in kvm as we will first remove
      the overlapping sections and then add the ones without conflicts.
      
      Therefore we can remove the complexity for handling prefix and suffix
      slots.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20170911174933.20789-5-david@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f357f564
    • D
      kvm: use start + size for memory ranges · 2747e716
      David Hildenbrand 提交于
      Convert kvm_lookup_matching_slot().
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20170911174933.20789-4-david@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2747e716
    • D
      kvm: factor out alignment of memory section · 5ea69c2e
      David Hildenbrand 提交于
      Factor it out, so we can reuse it later.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20170911174933.20789-3-david@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      5ea69c2e
    • D
      kvm: require JOIN_MEMORY_REGIONS_WORKS · 89de4b91
      David Hildenbrand 提交于
      We already require DESTROY_MEMORY_REGION_WORKS, JOIN_MEMORY_REGIONS_WORKS
      was added just half a year later.
      
      In addition, with flatview overlapping memory regions are first
      removed before adding the changed one. So we can't really detect joining
      memory regions this way.
      
      Let's just get rid of this special handling.
      Signed-off-by: NDavid Hildenbrand <david@redhat.com>
      Message-Id: <20170911174933.20789-2-david@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      89de4b91
  11. 31 8月, 2017 1 次提交
  12. 11 7月, 2017 1 次提交
    • A
      ARM: KVM: Enable in-kernel timers with user space gic · 5d721b78
      Alexander Graf 提交于
      When running with KVM enabled, you can choose between emulating the
      gic in kernel or user space. If the kernel supports in-kernel virtualization
      of the interrupt controller, it will default to that. If not, if will
      default to user space emulation.
      
      Unfortunately when running in user mode gic emulation, we miss out on
      interrupt events which are only available from kernel space, such as the timer.
      This patch leverages the new kernel/user space pending line synchronization for
      timer events. It does not handle PMU events yet.
      Signed-off-by: NAlexander Graf <agraf@suse.de>
      Reviewed-by: NAndrew Jones <drjones@redhat.com>
      Message-id: 1498577737-130264-1-git-send-email-agraf@suse.de
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      5d721b78
  13. 04 7月, 2017 2 次提交
  14. 15 6月, 2017 2 次提交
  15. 13 6月, 2017 1 次提交
  16. 08 6月, 2017 1 次提交
    • G
      kvm: don't register smram_listener when smm is off · d870cfde
      Gonglei 提交于
      If the user set disable smm by '-machine smm=off', we
      should not register smram_listener so that we can
      avoid waster memory in kvm since the added sencond
      address space.
      
      Meanwhile we should assign value of the global kvm_state
      before invoking the kvm_arch_init(), because
      pc_machine_is_smm_enabled() may use it by kvm_has_mm().
      Signed-off-by: NGonglei <arei.gonglei@huawei.com>
      Message-Id: <1496316915-121196-1-git-send-email-arei.gonglei@huawei.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d870cfde
  17. 07 6月, 2017 1 次提交
  18. 06 6月, 2017 1 次提交
    • D
      migration: Mark CPU states dirty before incoming migration/loadvm · 75e972da
      David Gibson 提交于
      As a rule, CPU internal state should never be updated when
      !cpu->kvm_vcpu_dirty (or the HAX equivalent).  If that is done, then
      subsequent calls to cpu_synchronize_state() - usually safe and idempotent -
      will clobber state.
      
      However, we routinely do this during a loadvm or incoming migration.
      Usually this is called shortly after a reset, which will clear all the cpu
      dirty flags with cpu_synchronize_all_post_reset().  Nothing is expected
      to set the dirty flags again before the cpu state is loaded from the
      incoming stream.
      
      This means that it isn't safe to call cpu_synchronize_state() from a
      post_load handler, which is non-obvious and potentially inconvenient.
      
      We could cpu_synchronize_all_state() before the loadvm, but that would be
      overkill since a) we expect the state to already be synchronized from the
      reset and b) we expect to completely rewrite the state with a call to
      cpu_synchronize_all_post_init() at the end of qemu_loadvm_state().
      
      To clear this up, this patch introduces cpu_synchronize_pre_loadvm() and
      associated helpers, which simply marks the cpu state as dirty without
      actually changing anything.  i.e. it says we want to discard any existing
      KVM (or HAX) state and replace it with what we're going to load.
      
      Cc: Juan Quintela <quintela@redhat.com>
      Cc: Dave Gilbert <dgilbert@redhat.com>
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      75e972da
  19. 23 5月, 2017 1 次提交
    • E
      shutdown: Add source information to SHUTDOWN and RESET · cf83f140
      Eric Blake 提交于
      Time to wire up all the call sites that request a shutdown or
      reset to use the enum added in the previous patch.
      
      It would have been less churn to keep the common case with no
      arguments as meaning guest-triggered, and only modified the
      host-triggered code paths, via a wrapper function, but then we'd
      still have to audit that I didn't miss any host-triggered spots;
      changing the signature forces us to double-check that I correctly
      categorized all callers.
      
      Since command line options can change whether a guest reset request
      causes an actual reset vs. a shutdown, it's easy to also add the
      information to reset requests.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Acked-by: David Gibson <david@gibson.dropbear.id.au> [ppc parts]
      Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> [SPARC part]
      Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> [s390x parts]
      Message-Id: <20170515214114.15442-5-eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      cf83f140
  20. 14 3月, 2017 1 次提交
  21. 03 3月, 2017 5 次提交
    • P
      KVM: use KVM_CAP_IMMEDIATE_EXIT · cf0f7cf9
      Paolo Bonzini 提交于
      The purpose of the KVM_SET_SIGNAL_MASK API is to let userspace "kick"
      a VCPU out of KVM_RUN through a POSIX signal.  A signal is attached
      to a dummy signal handler; by blocking the signal outside KVM_RUN and
      unblocking it inside, this possible race is closed:
      
                VCPU thread                     service thread
         --------------------------------------------------------------
              check flag
                                                set flag
                                                raise signal
              (signal handler does nothing)
              KVM_RUN
      
      However, one issue with KVM_SET_SIGNAL_MASK is that it has to take
      tsk->sighand->siglock on every KVM_RUN.  This lock is often on a
      remote NUMA node, because it is on the node of a thread's creator.
      Taking this lock can be very expensive if there are many userspace
      exits (as is the case for SMP Windows VMs without Hyper-V reference
      time counter).
      
      KVM_CAP_IMMEDIATE_EXIT provides an alternative, where the flag is
      placed directly in kvm_run so that KVM can see it:
      
                VCPU thread                     service thread
         --------------------------------------------------------------
                                                raise signal
              signal handler
                set run->immediate_exit
              KVM_RUN
                check run->immediate_exit
      
      The previous patches changed QEMU so that the only blocked signal is
      SIG_IPI, so we can now stop using KVM_SET_SIGNAL_MASK and sigtimedwait
      if KVM_CAP_IMMEDIATE_EXIT is available.
      
      On a 14-VCPU guest, an "inl" operation goes down from 30k to 6k on
      an unlocked (no BQL) MemoryRegion, or from 30k to 15k if the BQL
      is involved.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      cf0f7cf9
    • P
      c5c6679d
    • P
      KVM: move SIG_IPI handling to kvm-all.c · 18268b60
      Paolo Bonzini 提交于
      This lets us remove a bunch of CONFIG_LINUX defines.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      18268b60
    • P
      KVM: do not use sigtimedwait to catch SIGBUS · 2ae41db2
      Paolo Bonzini 提交于
      Call kvm_on_sigbus_vcpu asynchronously from the VCPU thread.
      Information for the SIGBUS can be stored in thread-local variables
      and processed later in kvm_cpu_exec.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2ae41db2
    • P
      KVM: remove kvm_arch_on_sigbus · 4d39892c
      Paolo Bonzini 提交于
      Build it on kvm_arch_on_sigbus_vcpu instead.  They do the same
      for "action optional" SIGBUSes, and the main thread should never get
      "action required" SIGBUSes because it blocks the signal.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4d39892c
  22. 16 2月, 2017 1 次提交