1. 06 8月, 2018 9 次提交
    • P
      kvm: selftests: add basic test for state save and restore · fa3899ad
      Paolo Bonzini 提交于
      The test calls KVM_RUN repeatedly, and creates an entirely new VM with the
      old memory and vCPU state on every exit to userspace.  The kvm_util API is
      expanded with two functions that manage the lifetime of a kvm_vm struct:
      the first closes the file descriptors and leaves the memory allocated,
      and the second opens the file descriptors and reuses the memory from
      the previous incarnation of the kvm_vm struct.
      
      For now the test is very basic, as it does not test for example XSAVE or
      vCPU events.  However, it will test nested virtualization state starting
      with the next patch.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      fa3899ad
    • P
      kvm: selftests: ensure vcpu file is released · 0a505fe6
      Paolo Bonzini 提交于
      The selftests were not munmap-ing the kvm_run area from the vcpu file descriptor.
      The result was that kvm_vcpu_release was not called and a reference was left in the
      parent "struct kvm".  Ultimately this was visible in the upcoming state save/restore
      test as an error when KVM attempted to create a duplicate debugfs entry.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0a505fe6
    • P
      kvm: selftests: actually use all of lib/vmx.c · 87ccb7db
      Paolo Bonzini 提交于
      The allocation of the VMXON and VMCS is currently done twice, in
      lib/vmx.c and in vmx_tsc_adjust_test.c.  Reorganize the code to
      provide a cleaner and easier to use API to the tests.  lib/vmx.c
      now does the complete setup of the VMX data structures, but does not
      create the VM or set CPUID.  This has to be done by the caller.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      87ccb7db
    • P
      kvm: selftests: create a GDT and TSS · 2305339e
      Paolo Bonzini 提交于
      The GDT and the TSS base were left to zero, and this has interesting effects
      when the TSS descriptor is later read to set up a VMCS's TR_BASE.  Basically
      it worked by chance, and this patch fixes it by setting up all the protected
      mode data structures properly.
      
      Because the GDT and TSS addresses are virtual, the page tables now always
      exist at the time of vcpu setup.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2305339e
    • P
      KVM: x86: ensure all MSRs can always be KVM_GET/SET_MSR'd · 44883f01
      Paolo Bonzini 提交于
      Some of the MSRs returned by GET_MSR_INDEX_LIST currently cannot be sent back
      to KVM_GET_MSR and/or KVM_SET_MSR; either they can never be sent back, or you
      they are only accepted under special conditions.  This makes the API a pain to
      use.
      
      To avoid this pain, this patch makes it so that the result of the get-list
      ioctl can always be used for host-initiated get and set.  Since we don't have
      a separate way to check for read-only MSRs, this means some Hyper-V MSRs are
      ignored when written.  Arguably they should not even be in the result of
      GET_MSR_INDEX_LIST, but I am leaving there in case userspace is using the
      outcome of GET_MSR_INDEX_LIST to derive the support for the corresponding
      Hyper-V feature.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      44883f01
    • S
      KVM: vmx: remove save/restore of host BNDCGFS MSR · cf81a7e5
      Sean Christopherson 提交于
      Linux does not support Memory Protection Extensions (MPX) in the
      kernel itself, thus the BNDCFGS (Bound Config Supervisor) MSR will
      always be zero in the KVM host, i.e. RDMSR in vmx_save_host_state()
      is superfluous.  KVM unconditionally sets VM_EXIT_CLEAR_BNDCFGS,
      i.e. BNDCFGS will always be zero after VMEXIT, thus manually loading
      BNDCFGS is also superfluous.
      
      And in the event the MPX kernel support is added (unlikely given
      that MPX for userspace is in its death throes[1]), BNDCFGS will
      likely be common across all CPUs[2], and at the least shouldn't
      change on a regular basis, i.e. saving the MSR on every VMENTRY is
      completely unnecessary.
      
      WARN_ONCE in hardware_setup() if the host's BNDCFGS is non-zero to
      document that KVM does not preserve BNDCFGS and to serve as a hint
      as to how BNDCFGS likely should be handled if MPX is used in the
      kernel, e.g. BNDCFGS should be saved once during KVM setup.
      
      [1] https://lkml.org/lkml/2018/4/27/1046
      [2] http://www.openwall.com/lists/kernel-hardening/2017/07/24/28Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      cf81a7e5
    • K
      KVM: Switch 'requests' to be 64-bit (explicitly) · 86dafed5
      KarimAllah Ahmed 提交于
      Switch 'requests' to be explicitly 64-bit and update BUILD_BUG_ON check to
      use the size of "requests" instead of the hard-coded '32'.
      
      That gives us a bit more room again for arch-specific requests as we
      already ran out of space for x86 due to the hard-coded check.
      
      The only exception here is ARM32 as it is still 32-bits.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Radim KrÄmář <rkrcmar@redhat.com>
      Cc: kvm@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Reviewed-by: NJim Mattson <jmattson@google.com>
      Signed-off-by: NKarimAllah Ahmed <karahmed@amazon.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      86dafed5
    • W
      kvm: selftests: add cr4_cpuid_sync_test · ca359066
      Wei Huang 提交于
      KVM is supposed to update some guest VM's CPUID bits (e.g. OSXSAVE) when
      CR4 is changed. A bug was found in KVM recently and it was fixed by
      Commit c4d21882 ("KVM: x86: Update cpuid properly when CR4.OSXAVE or
      CR4.PKE is changed"). This patch adds a test to verify the synchronization
      between guest VM's CR4 and CPUID bits.
      Signed-off-by: NWei Huang <wei@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      ca359066
    • P
      Merge tag 'v4.18-rc6' into HEAD · d2ce98ca
      Paolo Bonzini 提交于
      Pull bug fixes into the KVM development tree to avoid nasty conflicts.
      d2ce98ca
  2. 02 8月, 2018 2 次提交
  3. 31 7月, 2018 4 次提交
  4. 30 7月, 2018 11 次提交
  5. 26 7月, 2018 3 次提交
    • P
      KVM: PPC: Book3S HV: Read kvm->arch.emul_smt_mode under kvm->lock · b5c6f760
      Paul Mackerras 提交于
      Commit 1e175d2e ("KVM: PPC: Book3S HV: Pack VCORE IDs to access full
      VCPU ID space", 2018-07-25) added code that uses kvm->arch.emul_smt_mode
      before any VCPUs are created.  However, userspace can change
      kvm->arch.emul_smt_mode at any time up until the first VCPU is created.
      Hence it is (theoretically) possible for the check in
      kvmppc_core_vcpu_create_hv() to race with another userspace thread
      changing kvm->arch.emul_smt_mode.
      
      This fixes it by moving the test that uses kvm->arch.emul_smt_mode into
      the block where kvm->lock is held.
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      b5c6f760
    • P
      KVM: PPC: Book3S HV: Allow creating max number of VCPUs on POWER9 · 1ebe6b81
      Paul Mackerras 提交于
      Commit 1e175d2e ("KVM: PPC: Book3S HV: Pack VCORE IDs to access full
      VCPU ID space", 2018-07-25) allowed use of VCPU IDs up to
      KVM_MAX_VCPU_ID on POWER9 in all guest SMT modes and guest emulated
      hardware SMT modes.  However, with the current definition of
      KVM_MAX_VCPU_ID, a guest SMT mode of 1 and an emulated SMT mode of 8,
      it is only possible to create KVM_MAX_VCPUS / 2 VCPUS, because
      threads_per_subcore is 4 on POWER9 CPUs.  (Using an emulated SMT mode
      of 8 is useful when migrating VMs to or from POWER8 hosts.)
      
      This increases KVM_MAX_VCPU_ID to 8 * KVM_MAX_VCPUS when HV KVM is
      configured in, so that a full complement of KVM_MAX_VCPUS VCPUs can
      be created on POWER9 in all guest SMT modes and emulated hardware
      SMT modes.
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      1ebe6b81
    • S
      KVM: PPC: Book3S HV: Pack VCORE IDs to access full VCPU ID space · 1e175d2e
      Sam Bobroff 提交于
      It is not currently possible to create the full number of possible
      VCPUs (KVM_MAX_VCPUS) on Power9 with KVM-HV when the guest uses fewer
      threads per core than its core stride (or "VSMT mode"). This is
      because the VCORE ID and XIVE offsets grow beyond KVM_MAX_VCPUS
      even though the VCPU ID is less than KVM_MAX_VCPU_ID.
      
      To address this, "pack" the VCORE ID and XIVE offsets by using
      knowledge of the way the VCPU IDs will be used when there are fewer
      guest threads per core than the core stride. The primary thread of
      each core will always be used first. Then, if the guest uses more than
      one thread per core, these secondary threads will sequentially follow
      the primary in each core.
      
      So, the only way an ID above KVM_MAX_VCPUS can be seen, is if the
      VCPUs are being spaced apart, so at least half of each core is empty,
      and IDs between KVM_MAX_VCPUS and (KVM_MAX_VCPUS * 2) can be mapped
      into the second half of each core (4..7, in an 8-thread core).
      
      Similarly, if IDs above KVM_MAX_VCPUS * 2 are seen, at least 3/4 of
      each core is being left empty, and we can map down into the second and
      third quarters of each core (2, 3 and 5, 6 in an 8-thread core).
      
      Lastly, if IDs above KVM_MAX_VCPUS * 4 are seen, only the primary
      threads are being used and 7/8 of the core is empty, allowing use of
      the 1, 5, 3 and 7 thread slots.
      
      (Strides less than 8 are handled similarly.)
      
      This allows the VCORE ID or offset to be calculated quickly from the
      VCPU ID or XIVE server numbers, without access to the VCPU structure.
      
      [paulus@ozlabs.org - tidied up comment a little, changed some WARN_ONCE
       to pr_devel, wrapped line, fixed id check.]
      Signed-off-by: NSam Bobroff <sam.bobroff@au1.ibm.com>
      Signed-off-by: NPaul Mackerras <paulus@ozlabs.org>
      1e175d2e
  6. 23 7月, 2018 4 次提交
    • L
      Linux 4.18-rc6 · d72e90f3
      Linus Torvalds 提交于
      d72e90f3
    • L
      Merge tag 'nvme-for-4.18' of git://git.infradead.org/nvme · 74413084
      Linus Torvalds 提交于
      Pull NVMe fixes from Christoph Hellwig:
      
       - fix a regression in 4.18 that causes a memory leak on probe failure
         (Keith Bush)
      
       - fix a deadlock in the passthrough ioctl code (Scott Bauer)
      
       - don't enable AENs if not supported (Weiping Zhang)
      
       - fix an old regression in metadata handling in the passthrough ioctl
         code (Roland Dreier)
      
      * tag 'nvme-for-4.18' of git://git.infradead.org/nvme:
        nvme: fix handling of metadata_len for NVME_IOCTL_IO_CMD
        nvme: don't enable AEN if not supported
        nvme: ensure forward progress during Admin passthru
        nvme-pci: fix memory leak on probe failure
      74413084
    • L
      Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs · 165ea0d1
      Linus Torvalds 提交于
      Pull vfs fixes from Al Viro:
       "Fix several places that screw up cleanups after failures halfway
        through opening a file (one open-coding filp_clone_open() and getting
        it wrong, two misusing alloc_file()). That part is -stable fodder from
        the 'work.open' branch.
      
        And Christoph's regression fix for uapi breakage in aio series;
        include/uapi/linux/aio_abi.h shouldn't be pulling in the kernel
        definition of sigset_t, the reason for doing so in the first place had
        been bogus - there's no need to expose struct __aio_sigset in
        aio_abi.h at all"
      
      * 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
        aio: don't expose __aio_sigset in uapi
        ocxlflash_getfile(): fix double-iput() on alloc_file() failures
        cxl_getfile(): fix double-iput() on alloc_file() failures
        drm_mode_create_lease_ioctl(): fix open-coded filp_clone_open()
      165ea0d1
    • A
      alpha: fix osf_wait4() breakage · f88a333b
      Al Viro 提交于
      kernel_wait4() expects a userland address for status - it's only
      rusage that goes as a kernel one (and needs a copyout afterwards)
      
      [ Also, fix the prototype of kernel_wait4() to have that __user
        annotation   - Linus ]
      
      Fixes: 92ebce5a ("osf_wait4: switch to kernel_wait4()")
      Cc: stable@kernel.org # v4.13+
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f88a333b
  7. 22 7月, 2018 7 次提交