1. 07 11月, 2014 11 次提交
  2. 03 11月, 2014 29 次提交
    • T
      kvm: kvmclock: use get_cpu() and put_cpu() · c6338ce4
      Tiejun Chen 提交于
      We can use get_cpu() and put_cpu() to replace
      preempt_disable()/cpu = smp_processor_id() and
      preempt_enable() for slightly better code.
      Signed-off-by: NTiejun Chen <tiejun.chen@intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c6338ce4
    • R
      KVM: x86: optimize some accesses to LVTT and SPIV · f30ebc31
      Radim Krčmář 提交于
      We mirror a subset of these registers in separate variables.
      Using them directly should be faster.
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f30ebc31
    • R
      KVM: x86: detect LVTT changes under APICv · a323b409
      Radim Krčmář 提交于
      APIC-write VM exits are "trap-like": they save CS:RIP values for the
      instruction after the write, and more importantly, the handler will
      already see the new value in the virtual-APIC page.  This means that
      apic_reg_write cannot use kvm_apic_get_reg to omit timer cancelation
      when mode changes.
      
      timer_mode_mask shouldn't be changing as it depends on cpuid.
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      a323b409
    • R
      KVM: x86: detect SPIV changes under APICv · e462755c
      Radim Krčmář 提交于
      APIC-write VM exits are "trap-like": they save CS:RIP values for the
      instruction after the write, and more importantly, the handler will
      already see the new value in the virtual-APIC page.
      
      This caused a bug if you used KVM_SET_IRQCHIP to set the SW-enabled bit
      in the SPIV register.  The chain of events is as follows:
      
      * When the irqchip is added to the destination VM, the apic_sw_disabled
      static key is incremented (1)
      
      * When the KVM_SET_IRQCHIP ioctl is invoked, it is decremented (0)
      
      * When the guest disables the bit in the SPIV register, e.g. as part of
      shutdown, apic_set_spiv does not notice the change and the static key is
      _not_ incremented.
      
      * When the guest is destroyed, the static key is decremented (-1),
      resulting in this trace:
      
        WARNING: at kernel/jump_label.c:81 __static_key_slow_dec+0xa6/0xb0()
        jump label: negative count!
      
        [<ffffffff816bf898>] dump_stack+0x19/0x1b
        [<ffffffff8107c6f1>] warn_slowpath_common+0x61/0x80
        [<ffffffff8107c76c>] warn_slowpath_fmt+0x5c/0x80
        [<ffffffff811931e6>] __static_key_slow_dec+0xa6/0xb0
        [<ffffffff81193226>] static_key_slow_dec_deferred+0x16/0x20
        [<ffffffffa0637698>] kvm_free_lapic+0x88/0xa0 [kvm]
        [<ffffffffa061c63e>] kvm_arch_vcpu_uninit+0x2e/0xe0 [kvm]
        [<ffffffffa05ff301>] kvm_vcpu_uninit+0x21/0x40 [kvm]
        [<ffffffffa067cec7>] vmx_free_vcpu+0x47/0x70 [kvm_intel]
        [<ffffffffa061bc50>] kvm_arch_vcpu_free+0x50/0x60 [kvm]
        [<ffffffffa061ca22>] kvm_arch_destroy_vm+0x102/0x260 [kvm]
        [<ffffffff810b68fd>] ? synchronize_srcu+0x1d/0x20
        [<ffffffffa06030d1>] kvm_put_kvm+0xe1/0x1c0 [kvm]
        [<ffffffffa06036f8>] kvm_vcpu_release+0x18/0x20 [kvm]
        [<ffffffff81215c62>] __fput+0x102/0x310
        [<ffffffff81215f4e>] ____fput+0xe/0x10
        [<ffffffff810ab664>] task_work_run+0xb4/0xe0
        [<ffffffff81083944>] do_exit+0x304/0xc60
        [<ffffffff816c8dfc>] ? _raw_spin_unlock_irq+0x2c/0x50
        [<ffffffff810fd22d>] ?  trace_hardirqs_on_caller+0xfd/0x1c0
        [<ffffffff8108432c>] do_group_exit+0x4c/0xc0
        [<ffffffff810843b4>] SyS_exit_group+0x14/0x20
        [<ffffffff816d33a9>] system_call_fastpath+0x16/0x1b
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      e462755c
    • D
      KVM: trivial fix comment regarding __kvm_set_memory_region · 02d5d55b
      Dominik Dingel 提交于
      commit 72dc67a6 ("KVM: remove the usage of the mmap_sem for the protection of the memory slots.")
      changed the lock which will be taken. This should be reflected in the function
      commentary.
      Signed-off-by: NDominik Dingel <dingel@linux.vnet.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      02d5d55b
    • C
      KVM: x86: Enable Intel AVX-512 for guest · 612263b3
      Chao Peng 提交于
      Expose Intel AVX-512 feature bits to guest. Also add checks for
      xcr0 AVX512 related bits according to spec:
      http://download-software.intel.com/sites/default/files/managed/71/2e/319433-017.pdfSigned-off-by: NChao Peng <chao.p.peng@linux.intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      612263b3
    • M
      kvm: drop unsupported capabilities, fix documentation · 7f05db6a
      Michael S. Tsirkin 提交于
      No kernel ever reported KVM_CAP_DEVICE_MSIX, KVM_CAP_DEVICE_MSI,
      KVM_CAP_DEVICE_ASSIGNMENT, KVM_CAP_DEVICE_DEASSIGNMENT.
      
      This makes the documentation wrong, and no application ever
      written to use these capabilities has a chance to work correctly.
      The only way to detect support is to try, and test errno for ENOTTY.
      That's unfortunate, but we can't fix the past.
      
      Document the actual semantics, and drop the definitions from
      the exported header to make it easier for application
      developers to note and fix the bug.
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7f05db6a
    • R
      KVM: x86: fix deadline tsc interrupt injection · 1e0ad70c
      Radim Krčmář 提交于
      The check in kvm_set_lapic_tscdeadline_msr() was trying to prevent a
      situation where we lose a pending deadline timer in a MSR write.
      Losing it is fine, because it effectively occurs before the timer fired,
      so we should be able to cancel or postpone it.
      
      Another problem comes from interaction with QEMU, or other userspace
      that can set deadline MSR without a good reason, when timer is already
      pending:  one guest's deadline request results in more than one
      interrupt because one is injected immediately on MSR write from
      userspace and one through hrtimer later.
      
      The solution is to remove the injection when replacing a pending timer
      and to improve the usual QEMU path, we inject without a hrtimer when the
      deadline has already passed.
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      Reported-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      1e0ad70c
    • R
      KVM: x86: add apic_timer_expired() · 5d87db71
      Radim Krčmář 提交于
      Make the code reusable.
      
      If the timer was already pending, we shouldn't be waiting in a queue,
      so wake_up can be skipped, simplifying the path.
      
      There is no 'reinject' case => the comment is removed.
      Current race behaves correctly.
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      5d87db71
    • T
      Documentation: virtual: kvm: correct one bit description in APF case · 91690bf3
      Tiejun Chen 提交于
      When commit 6adba527 (KVM: Let host know whether the guest can
      handle async PF in non-userspace context.) is introduced, actually
      bit 2 still is reserved and should be zero. Instead, bit 1 is 1 to
      indicate if asynchronous page faults can be injected when vcpu is
      in cpl == 0, and also please see this,
      
      in the file kvm_para.h, #define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1).
      Signed-off-by: NTiejun Chen <tiejun.chen@intel.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      91690bf3
    • N
      KVM: vmx: Unavailable DR4/5 is checked before CPL · 16f8a6f9
      Nadav Amit 提交于
      If DR4/5 is accessed when it is unavailable (since CR4.DE is set), then #UD
      should be generated even if CPL>0. This is according to Intel SDM Table 6-2:
      "Priority Among Simultaneous Exceptions and Interrupts".
      
      Note, that this may happen on the first DR access, even if the host does not
      sets debug breakpoints. Obviously, it occurs when the host debugs the guest.
      
      This patch moves the DR4/5 checks from __kvm_set_dr/_kvm_get_dr to handle_dr.
      The emulator already checks DR4/5 availability in check_dr_read. Nested
      virutalization related calls to kvm_set_dr/kvm_get_dr would not like to inject
      exceptions to the guest.
      
      As for SVM, the patch follows the previous logic as much as possible. Anyhow,
      it appears the DR interception code might be buggy - even if the DR access
      may cause an exception, the instruction is skipped.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      16f8a6f9
    • N
      KVM: x86: Emulator performs code segment checks on read access · c49c759f
      Nadav Amit 提交于
      When read access is performed using a readable code segment, the "conforming"
      and "non-conforming" checks should not be done.  As a result, read using
      non-conforming readable code segment fails.
      
      This is according to Intel SDM 5.6.1 ("Accessing Data in Code Segments").
      
      The fix is not to perform the "non-conforming" checks if the access is not a
      fetch; the relevant checks are already done when loading the segment.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Reviewed-by: NRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c49c759f
    • N
      KVM: x86: Clear DR7.LE during task-switch · 0e8a0996
      Nadav Amit 提交于
      DR7.LE should be cleared during task-switch. This feature is poorly documented.
      For reference, see:
      http://pdos.csail.mit.edu/6.828/2005/readings/i386/s12_02.htm
      
      SDM [17.2.4]:
        This feature is not supported in the P6 family processors, later IA-32
        processors, and Intel 64 processors.
      
      AMD [2:13.1.1.4]:
        This bit is ignored by implementations of the AMD64 architecture.
      
      Intel's formulation could mean that it isn't even zeroed, but current
      hardware indeed does not behave like that.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Reviewed-by: NRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      0e8a0996
    • N
      KVM: x86: Emulator does not calculate address correctly · 518547b3
      Nadav Amit 提交于
      In long-mode, when the address size is 4 bytes, the linear address is not
      truncated as the emulator mistakenly does.  Instead, the offset within the
      segment (the ea field) should be truncated according to the address size.
      
      As Intel SDM says: "In 64-bit mode, the effective address components are added
      and the effective address is truncated ... before adding the full 64-bit
      segment base."
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      518547b3
    • N
      KVM: x86: DR7.GD should be cleared upon any #DB exception · 6bdf0662
      Nadav Amit 提交于
      Intel SDM 17.2.4 (Debug Control Register (DR7)) says: "The processor clears the
      GD flag upon entering to the debug exception handler." This sentence may be
      misunderstood as if it happens only on #DB due to debug-register protection,
      but it happens regardless to the cause of the #DB.
      
      Fix the behavior to match both real hardware and Bochs.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6bdf0662
    • N
      KVM: x86: some apic broadcast modes does not work · 394457a9
      Nadav Amit 提交于
      KVM does not deliver x2APIC broadcast messages with physical mode.  Intel SDM
      (10.12.9 ICR Operation in x2APIC Mode) states: "A destination ID value of
      FFFF_FFFFH is used for broadcast of interrupts in both logical destination and
      physical destination modes."
      
      In addition, the local-apic enables cluster mode broadcast. As Intel SDM
      10.6.2.2 says: "Broadcast to all local APICs is achieved by setting all
      destination bits to one." This patch enables cluster mode broadcast.
      
      The fix tries to combine broadcast in different modes through a unified code.
      
      One rare case occurs when the source of IPI has its APIC disabled.  In such
      case, the source can still issue IPIs, but since the source is not obliged to
      have the same LAPIC mode as the enabled ones, we cannot rely on it.
      Since it is a rare case, it is unoptimized and done on the slow-path.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Reviewed-by: NRadim Krčmář <rkrcmar@redhat.com>
      Reviewed-by: NWanpeng Li <wanpeng.li@linux.intel.com>
      [As per Radim's review, use unsigned int for X2APIC_BROADCAST, return bool from
       kvm_apic_broadcast. - Paolo]
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      394457a9
    • A
      x86,kvm,vmx: Don't trap writes to CR4.TSD · 52ce3c21
      Andy Lutomirski 提交于
      CR4.TSD is guest-owned; don't trap writes to it in VMX guests.  This
      avoids a VM exit on context switches into or out of a PR_TSC_SIGSEGV
      task.
      
      I think that this fixes an unintentional side-effect of:
          4c38609a KVM: VMX: Make guest cr4 mask more conservative
      Signed-off-by: NAndy Lutomirski <luto@amacapital.net>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      52ce3c21
    • N
      KVM: x86: Sysexit emulation does not mask RIP/RSP · bf0b682c
      Nadav Amit 提交于
      If the operand size is not 64-bit, then the sysexit instruction should assign
      ECX to RSP and EDX to RIP.  The current code assigns the full 64-bits.
      
      Fix it by masking.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      bf0b682c
    • N
      KVM: x86: Distinguish between stack operation and near branches · 58b7075d
      Nadav Amit 提交于
      In 64-bit, stack operations default to 64-bits, but can be overriden (to
      16-bit) using opsize override prefix. In contrast, near-branches are always
      64-bit.  This patch distinguish between the different behaviors.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      58b7075d
    • N
      KVM: x86: Getting rid of grp45 in emulator · f7784046
      Nadav Amit 提交于
      Breaking grp45 to the relevant functions to speed up the emulation and simplify
      the code. In addition, it is necassary the next patch will distinguish between
      far and near branches according to the flags.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      f7784046
    • N
      KVM: x86: Use new is_noncanonical_address in _linearize · 4be4de7e
      Nadav Amit 提交于
      Replace the current canonical address check with the new function which is
      identical.
      Signed-off-by: NNadav Amit <namit@cs.technion.ac.il>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4be4de7e
    • P
      KVM: emulator: always inline __linearize · d09155d2
      Paolo Bonzini 提交于
      The two callers have a lot of constant arguments that can be
      optimized out.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      d09155d2
    • P
      Merge remote-tracking branch 'origin/master' into HEAD · 123b2dd1
      Paolo Bonzini 提交于
      Several important fixes went in between 3.18-rc1 and 3.18-rc3, so
      KVM/x86 work for 3.19 will be based on 3.18-rc3.
      123b2dd1
    • L
      Linux 3.18-rc3 · 0df1f248
      Linus Torvalds 提交于
      0df1f248
    • L
      Merge tag 'for-linus-20141102' of git://git.infradead.org/linux-mtd · 81d92dc1
      Linus Torvalds 提交于
      Pull MTD fixes from Brian Norris:
       "Three main MTD fixes for 3.18:
      
         - A regression from 3.16 which was noticed in 3.17.  With the
           restructuring of the m25p80.c driver and the SPI NOR library
           framework, we omitted proper listing of the SPI device IDs.  This
           means m25p80.c wouldn't auto-load (modprobe) properly when built as
           a module.  For now, we duplicate the device IDs into both modules.
      
         - The OMAP / ELM modules were depending on an implicit link ordering.
           Use deferred probing so that the new link order (in 3.18-rc) can
           still allow for successful probing.
      
         - Fix suspend/resume support for LH28F640BF NOR flash"
      
      * tag 'for-linus-20141102' of git://git.infradead.org/linux-mtd:
        mtd: cfi_cmdset_0001.c: fix resume for LH28F640BF chips
        mtd: omap: fix mtd devices not showing up
        mtd: m25p80,spi-nor: Fix module aliases for m25p80
        mtd: spi-nor: make spi_nor_scan() take a chip type name, not spi_device_id
        mtd: m25p80: get rid of spi_get_device_id
      81d92dc1
    • L
      Merge tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · ad2be379
      Linus Torvalds 提交于
      Pull SCSI fixes from James Bottomley:
       "This is a set of six patches consisting of:
         - two MAINTAINER updates
         - two scsi-mq fixs for the old parallel interface (not every request
           is tagged and we need to set the right flags to populate the SPI
           tag message)
         - a fix for a memory leak in scatterlist traversal caused by a
           preallocation update in 3.17
         - an ipv6 fix for cxgbi"
      
      [ The scatterlist fix also came in separately through the block layer tree ]
      
      * tag 'scsi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        MAINTAINERS: ufs - remove self
        MAINTAINERS: change hpsa and cciss maintainer
        libcxgbi : support ipv6 address host_param
        scsi: set REQ_QUEUE for the blk-mq case
        Revert "block: all blk-mq requests are tagged"
        lib/scatterlist: fix memory leak with scsi-mq
      ad2be379
    • L
      Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux · 12267166
      Linus Torvalds 提交于
      Pull drm fixes from Dave Airlie:
       "Nothing too astounding or major: radeon, i915, vmwgfx, armada and
        exynos.
      
        Biggest ones:
         - vmwgfx has one big locking regression fix
         - i915 has come displayport fixes
         - radeon has some stability and a memory alloc failure
         - armada and exynos have some vblank fixes"
      
      * 'drm-fixes' of git://people.freedesktop.org/~airlied/linux: (24 commits)
        drm/exynos: correct connector->dpms field before resuming
        drm/exynos: enable vblank after DPMS on
        drm/exynos: init kms poll at the end of initialization
        drm/exynos: propagate plane initialization errors
        drm/exynos: vidi: fix build warning
        drm/exynos: remove explicit encoder/connector de-initialization
        drm/exynos: init vblank with real number of crtcs
        drm/vmwgfx: Filter out modes those cannot be supported by the current VRAM size.
        drm/vmwgfx: Fix hash key computation
        drm/vmwgfx: fix lock breakage
        drm/i915/dp: only use training pattern 3 on platforms that support it
        drm/radeon: remove some buggy dead code
        drm/i915: Ignore VBT backlight check on Macbook 2, 1
        drm/radeon: remove invalid pci id
        drm/radeon: dpm fixes for asrock systems
        radeon: clean up coding style differences in radeon_get_bios()
        drm/radeon: Use drm_malloc_ab instead of kmalloc_array
        drm/radeon/dpm: disable ulv support on SI
        drm/i915: Fix GMBUSFREQ on vlv/chv
        drm/i915: Ignore long hpds on eDP ports
        ...
      12267166
    • L
      Merge branch 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm · 3c43de0f
      Linus Torvalds 提交于
      Pull ARM fixes from Russell King:
       - add the new bpf syscall to ARM.
       - drop a redundant return statement in __iommu_alloc_remap()
       - fix a performance issue noticed by Thomas Petazzoni with
         kmap_atomic().
       - fix an issue with the L2 cache OF parsing code which caused it to
         incorrectly print warnings on each boot, and make the warning text
         more consistent with the rest of the code
      
      * 'fixes' of git://ftp.arm.linux.org.uk/~rmk/linux-arm:
        ARM: 8180/1: mm: implement no-highmem fast path in kmap_atomic_pfn()
        ARM: 8183/1: l2c: Improve l2c310_of_parse() error message
        ARM: 8181/1: Drop extra return statement
        ARM: 8182/1: l2c: Make l2x0_cache_size_of_parse() return 'int'
        ARM: enable bpf syscall
      3c43de0f
    • L
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 7501a533
      Linus Torvalds 提交于
      Pull kvm fixes from Paolo Bonzini:
       "A small set of x86 fixes.  The most serious is an SRCU lockdep fix.
      
        A bit late - needed some time to test the SRCU fix, which only came in
        on Friday"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: vmx: defer load of APIC access page address during reset
        KVM: nVMX: Disable preemption while reading from shadow VMCS
        KVM: x86: Fix far-jump to non-canonical check
        KVM: emulator: fix execution close to the segment limit
        KVM: emulator: fix error code for __linearize
      7501a533