1. 23 9月, 2017 1 次提交
    • J
      x86/asm: Fix inline asm call constraints for Clang · f5caf621
      Josh Poimboeuf 提交于
      For inline asm statements which have a CALL instruction, we list the
      stack pointer as a constraint to convince GCC to ensure the frame
      pointer is set up first:
      
        static inline void foo()
        {
      	register void *__sp asm(_ASM_SP);
      	asm("call bar" : "+r" (__sp))
        }
      
      Unfortunately, that pattern causes Clang to corrupt the stack pointer.
      
      The fix is easy: convert the stack pointer register variable to a global
      variable.
      
      It should be noted that the end result is different based on the GCC
      version.  With GCC 6.4, this patch has exactly the same result as
      before:
      
      	defconfig	defconfig-nofp	distro		distro-nofp
       before	9820389		9491555		8816046		8516940
       after	9820389		9491555		8816046		8516940
      
      With GCC 7.2, however, GCC's behavior has changed.  It now changes its
      behavior based on the conversion of the register variable to a global.
      That somehow convinces it to *always* set up the frame pointer before
      inserting *any* inline asm.  (Therefore, listing the variable as an
      output constraint is a no-op and is no longer necessary.)  It's a bit
      overkill, but the performance impact should be negligible.  And in fact,
      there's a nice improvement with frame pointers disabled:
      
      	defconfig	defconfig-nofp	distro		distro-nofp
       before	9796316		9468236		9076191		8790305
       after	9796957		9464267		9076381		8785949
      
      So in summary, while listing the stack pointer as an output constraint
      is no longer necessary for newer versions of GCC, it's still needed for
      older versions.
      Suggested-by: NAndrey Ryabinin <aryabinin@virtuozzo.com>
      Reported-by: NMatthias Kaehlcke <mka@chromium.org>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Dmitriy Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/3db862e970c432ae823cf515c52b54fec8270e0e.1505942196.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      f5caf621
  2. 18 9月, 2017 4 次提交
  3. 15 9月, 2017 9 次提交
    • J
      kvm: nVMX: Handle deferred early VMLAUNCH/VMRESUME failure properly · 4f350c6d
      Jim Mattson 提交于
      When emulating a nested VM-entry from L1 to L2, several control field
      validation checks are deferred to the hardware. Should one of these
      validation checks fail, vcpu_vmx_run will set the vmx->fail flag. When
      this happens, the L2 guest state is not loaded (even in part), and
      execution should continue in L1 with the next instruction after the
      VMLAUNCH/VMRESUME.
      
      The VMCS12 is not modified (except for the VM-instruction error
      field), the VMCS12 MSR save/load lists are not processed, and the CPU
      state is not loaded from the VMCS12 host area. Moreover, the vmcs02
      exit reason is stale, so it should not be consulted for any reason.
      Signed-off-by: NJim Mattson <jmattson@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4f350c6d
    • J
      kvm: vmx: Handle VMLAUNCH/VMRESUME failure properly · b060ca3b
      Jim Mattson 提交于
      On an early VMLAUNCH/VMRESUME failure (i.e. one which sets the
      VM-instruction error field of the current VMCS), the launch state of
      the current VMCS is not set to "launched," and the VM-exit information
      fields of the current VMCS (including IDT-vectoring information and
      exit reason) are stale.
      
      On a late VMLAUNCH/VMRESUME failure (i.e. one which sets the high bit
      of the exit reason field), the launch state of the current VMCS is not
      set to "launched," and only two of the VM-exit information fields of
      the current VMCS are modified (exit reason and exit
      qualification). The remaining VM-exit information fields of the
      current VMCS (including IDT-vectoring information, in particular) are
      stale.
      Signed-off-by: NJim Mattson <jmattson@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      b060ca3b
    • J
      kvm: nVMX: Remove nested_vmx_succeed after successful VM-entry · 7881f96c
      Jim Mattson 提交于
      After a successful VM-entry, RFLAGS is cleared, with the exception of
      bit 1, which is always set. This is handled by load_vmcs12_host_state.
      Signed-off-by: NJim Mattson <jmattson@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      7881f96c
    • D
      kvm,x86: Fix apf_task_wake_one() wq serialization · a0cff57b
      Davidlohr Bueso 提交于
      During code inspection, the following potential race was seen:
      
      CPU0   	    		    	     	CPU1
      kvm_async_pf_task_wait			apf_task_wake_one
      					  [L] swait_active(&n->wq)
        [S] prepare_to_swait(&n.wq)
        [L] if (!hlist_unhahed(&n.link))
      	schedule()			  [S] hlist_del_init(&n->link);
      
      Properly serialize swait_active() checks such that a wakeup is
      not missed.
      Signed-off-by: NDavidlohr Bueso <dbueso@suse.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      a0cff57b
    • D
      kvm,lapic: Justify use of swait_active() · cc1b4680
      Davidlohr Bueso 提交于
      A comment might serve future readers.
      Signed-off-by: NDavidlohr Bueso <dbueso@suse.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      cc1b4680
    • J
      KVM: VMX: Do not BUG() on out-of-bounds guest IRQ · 3a8b0677
      Jan H. Schönherr 提交于
      The value of the guest_irq argument to vmx_update_pi_irte() is
      ultimately coming from a KVM_IRQFD API call. Do not BUG() in
      vmx_update_pi_irte() if the value is out-of bounds. (Especially,
      since KVM as a whole seems to hang after that.)
      
      Instead, print a message only once if we find that we don't have a
      route for a certain IRQ (which can be out-of-bounds or within the
      array).
      
      This fixes CVE-2017-1000252.
      
      Fixes: efc64404 ("KVM: x86: Update IRTE for posted-interrupts")
      Signed-off-by: NJan H. Schönherr <jschoenh@amazon.de>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3a8b0677
    • J
      kvm: nVMX: Don't allow L2 to access the hardware CR8 · 51aa68e7
      Jim Mattson 提交于
      If L1 does not specify the "use TPR shadow" VM-execution control in
      vmcs12, then L0 must specify the "CR8-load exiting" and "CR8-store
      exiting" VM-execution controls in vmcs02. Failure to do so will give
      the L2 VM unrestricted read/write access to the hardware CR8.
      
      This fixes CVE-2017-12154.
      Signed-off-by: NJim Mattson <jmattson@google.com>
      Reviewed-by: NDavid Hildenbrand <david@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      51aa68e7
    • B
      x86/cpu/AMD: Fix erratum 1076 (CPB bit) · f7f3dc00
      Borislav Petkov 提交于
      CPUID Fn8000_0007_EDX[CPB] is wrongly 0 on models up to B1. But they do
      support CPB (AMD's Core Performance Boosting cpufreq CPU feature), so fix that.
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sherry Hurwitz <sherry.hurwitz@amd.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20170907170821.16021-1-bp@alien8.deSigned-off-by: NIngo Molnar <mingo@kernel.org>
      f7f3dc00
    • W
      KVM: async_pf: Fix #DF due to inject "Page not Present" and "Page Ready" exceptions simultaneously · 9a6e7c39
      Wanpeng Li 提交于
      qemu-system-x86-8600  [004] d..1  7205.687530: kvm_entry: vcpu 2
      qemu-system-x86-8600  [004] ....  7205.687532: kvm_exit: reason EXCEPTION_NMI rip 0xffffffffa921297d info ffffeb2c0e44e018 80000b0e
      qemu-system-x86-8600  [004] ....  7205.687532: kvm_page_fault: address ffffeb2c0e44e018 error_code 0
      qemu-system-x86-8600  [004] ....  7205.687620: kvm_try_async_get_page: gva = 0xffffeb2c0e44e018, gfn = 0x427e4e
      qemu-system-x86-8600  [004] .N..  7205.687628: kvm_async_pf_not_present: token 0x8b002 gva 0xffffeb2c0e44e018
          kworker/4:2-7814  [004] ....  7205.687655: kvm_async_pf_completed: gva 0xffffeb2c0e44e018 address 0x7fcc30c4e000
      qemu-system-x86-8600  [004] ....  7205.687703: kvm_async_pf_ready: token 0x8b002 gva 0xffffeb2c0e44e018
      qemu-system-x86-8600  [004] d..1  7205.687711: kvm_entry: vcpu 2
      
      After running some memory intensive workload in guest, I catch the kworker
      which completes the GUP too quickly, and queues an "Page Ready" #PF exception
      after the "Page not Present" exception before the next vmentry as the above
      trace which will result in #DF injected to guest.
      
      This patch fixes it by clearing the queue for "Page not Present" if "Page Ready"
      occurs before the next vmentry since the GUP has already got the required page
      and shadow page table has already been fixed by "Page Ready" handler.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Radim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NWanpeng Li <wanpeng.li@hotmail.com>
      Fixes: 7c90705b ("KVM: Inject asynchronous page fault into a PV guest if page is swapped out.")
      [Changed indentation and added clearing of injected. - Radim]
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      9a6e7c39
  4. 14 9月, 2017 7 次提交
  5. 13 9月, 2017 11 次提交
  6. 11 9月, 2017 2 次提交
  7. 09 9月, 2017 6 次提交