1. 17 2月, 2016 8 次提交
    • P
      KVM: x86: fix missed hardware breakpoints · 4e422bdd
      Paolo Bonzini 提交于
      Sometimes when setting a breakpoint a process doesn't stop on it.
      This is because the debug registers are not loaded correctly on
      VCPU load.
      
      The following simple reproducer from Oleg Nesterov tries using debug
      registers in both the host and the guest, for example by running "./bp
      0 1" on the host and "./bp 14 15" under QEMU.
      
          #include <unistd.h>
          #include <signal.h>
          #include <stdlib.h>
          #include <stdio.h>
          #include <sys/wait.h>
          #include <sys/ptrace.h>
          #include <sys/user.h>
          #include <asm/debugreg.h>
          #include <assert.h>
      
          #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
      
          unsigned long encode_dr7(int drnum, int enable, unsigned int type, unsigned int len)
          {
              unsigned long dr7;
      
              dr7 = ((len | type) & 0xf)
                  << (DR_CONTROL_SHIFT + drnum * DR_CONTROL_SIZE);
              if (enable)
                  dr7 |= (DR_GLOBAL_ENABLE << (drnum * DR_ENABLE_SIZE));
      
              return dr7;
          }
      
          int write_dr(int pid, int dr, unsigned long val)
          {
              return ptrace(PTRACE_POKEUSER, pid,
                      offsetof (struct user, u_debugreg[dr]),
                      val);
          }
      
          void set_bp(pid_t pid, void *addr)
          {
              unsigned long dr7;
              assert(write_dr(pid, 0, (long)addr) == 0);
              dr7 = encode_dr7(0, 1, DR_RW_EXECUTE, DR_LEN_1);
              assert(write_dr(pid, 7, dr7) == 0);
          }
      
          void *get_rip(int pid)
          {
              return (void*)ptrace(PTRACE_PEEKUSER, pid,
                      offsetof(struct user, regs.rip), 0);
          }
      
          void test(int nr)
          {
              void *bp_addr = &&label + nr, *bp_hit;
              int pid;
      
              printf("test bp %d\n", nr);
              assert(nr < 16); // see 16 asm nops below
      
              pid = fork();
              if (!pid) {
                  assert(ptrace(PTRACE_TRACEME, 0,0,0) == 0);
                  kill(getpid(), SIGSTOP);
                  for (;;) {
                      label: asm (
                          "nop; nop; nop; nop;"
                          "nop; nop; nop; nop;"
                          "nop; nop; nop; nop;"
                          "nop; nop; nop; nop;"
                      );
                  }
              }
      
              assert(pid == wait(NULL));
              set_bp(pid, bp_addr);
      
              for (;;) {
                  assert(ptrace(PTRACE_CONT, pid, 0, 0) == 0);
                  assert(pid == wait(NULL));
      
                  bp_hit = get_rip(pid);
                  if (bp_hit != bp_addr)
                      fprintf(stderr, "ERR!! hit wrong bp %ld != %d\n",
                          bp_hit - &&label, nr);
              }
          }
      
          int main(int argc, const char *argv[])
          {
              while (--argc) {
                  int nr = atoi(*++argv);
                  if (!fork())
                      test(nr);
              }
      
              while (wait(NULL) > 0)
                  ;
              return 0;
          }
      
      Cc: stable@vger.kernel.org
      Suggested-by: NNadadv Amit <namit@cs.technion.ac.il>
      Reported-by: NAndrey Wagin <avagin@gmail.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4e422bdd
    • R
      KVM: x86: fix *NULL on invalid low-prio irq · 4efd805f
      Radim Krčmář 提交于
      Smatch noticed a NULL dereference in kvm_intr_is_single_vcpu_fast that
      happens if VM already warned about invalid lowest-priority interrupt.
      
      Create a function for common code while fixing it.
      
      Fixes: 6228a0da ("KVM: x86: Add lowest-priority support for vt-d posted-interrupts")
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4efd805f
    • P
      KVM: x86: rewrite handling of scaled TSC for kvmclock · 78db6a50
      Paolo Bonzini 提交于
      This is the same as before:
      
          kvm_scale_tsc(tgt_tsc_khz)
              = tgt_tsc_khz * ratio
              = tgt_tsc_khz * user_tsc_khz / tsc_khz   (see set_tsc_khz)
              = user_tsc_khz                           (see kvm_guest_time_update)
              = vcpu->arch.virtual_tsc_khz             (see kvm_set_tsc_khz)
      
      However, computing it through kvm_scale_tsc will make it possible
      to include the NTP correction in tgt_tsc_khz.
      Reviewed-by: NMarcelo Tosatti <mtosatti@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      78db6a50
    • P
      KVM: x86: rename argument to kvm_set_tsc_khz · 4941b8cb
      Paolo Bonzini 提交于
      This refers to the desired (scaled) frequency, which is called
      user_tsc_khz in the rest of the file.
      Reviewed-by: NMarcelo Tosatti <mtosatti@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      4941b8cb
    • J
      KVM: VMX: Fix guest debugging while in L2 · 6f05485d
      Jan Kiszka 提交于
      When we take a #DB or #BP vmexit while in guest mode, we first of all
      need to check if there is ongoing guest debugging that might be
      interested in the event. Currently, we unconditionally leave L2 and
      inject the event into L1 if it is intercepting the exceptions. That
      breaks things marvelously.
      Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6f05485d
    • J
      KVM: VMX: Factor out is_exception_n helper · 5bb16016
      Jan Kiszka 提交于
      There is quite some common code in all these is_<exception>() helpers.
      Factor it out before adding even more of them.
      Signed-off-by: NJan Kiszka <jan.kiszka@siemens.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      5bb16016
    • C
      KVM: halt_polling: improve grow/shrink settings · 6b6de68c
      Christian Borntraeger 提交于
      Right now halt_poll_ns can be change during runtime. The
      grow and shrink factors can only be set during module load.
      Lets fix several aspects of grow shrink:
      - make grow/shrink changeable by root
      - make all variables unsigned int
      - read the variables once to prevent races
      Signed-off-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      6b6de68c
    • P
      Merge tag 'kvm-s390-next-4.6-1' of... · efef127c
      Paolo Bonzini 提交于
      Merge tag 'kvm-s390-next-4.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD
      
      KVM: s390: Fixes and features for kvm/next (4.6)
      
      1. also provide the floating point registers via sync regs
      2. Separate out intruction vs. data accesses
      3. Fix program interrupts in some cases
      4. Documentation fixes
      5. dirty log improvements for huge guests
      efef127c
  2. 10 2月, 2016 18 次提交
  3. 09 2月, 2016 11 次提交
  4. 08 2月, 2016 3 次提交
    • P
      Merge tag 'kvm-arm-for-4.5-rc2' of... · afc60743
      Paolo Bonzini 提交于
      Merge tag 'kvm-arm-for-4.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into kvm-master
      
      KVM/ARM fixes for v4.5-rc2
      
      A few random fixes, mostly coming from the PMU work by Shannon:
      
      - fix for injecting faults coming from the guest's userspace
      - cleanup for our CPTR_EL2 accessors (reserved bits)
      - fix for a bug impacting perf (user/kernel discrimination)
      - fix for a 32bit sysreg handling bug
      afc60743
    • L
      Linux 4.5-rc3 · 388f7b1d
      Linus Torvalds 提交于
      388f7b1d
    • L
      Merge tag 'armsoc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc · c17dfb01
      Linus Torvalds 提交于
      Pull ARM SoC fixes from Olof Johansson:
       "The first real batch of fixes for this release cycle, so there are a
        few more than usual.
      
        Most of these are fixes and tweaks to board support (DT bugfixes,
        etc).  I've also picked up a couple of small cleanups that seemed
        innocent enough that there was little reason to wait (const/
        __initconst and Kconfig deps).
      
        Quite a bit of the changes on OMAP were due to fixes to no longer
        write to rodata from assembly when ARM_KERNMEM_PERMS was enabled, but
        there were also other fixes.
      
        Kirkwood had a bunch of gpio fixes for some boards.  OMAP had RTC
        fixes on OMAP5, and Nomadik had changes to MMC parameters in DT.
      
        All in all, mostly the usual mix of various fixes"
      
      * tag 'armsoc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (46 commits)
        ARM: multi_v7_defconfig: enable DW_WATCHDOG
        ARM: nomadik: fix up SD/MMC DT settings
        ARM64: tegra: Add chosen node for tegra132 norrin
        ARM: realview: use "depends on" instead of "if" after prompt
        ARM: tango: use "depends on" instead of "if" after prompt
        ARM: tango: use const and __initconst for smp_operations
        ARM: realview: use const and __initconst for smp_operations
        bus: uniphier-system-bus: revive tristate prompt
        arm64: dts: Add missing DMA Abort interrupt to Juno
        bus: vexpress-config: Add missing of_node_put
        ARM: dts: am57xx: sbc-am57x: correct Eth PHY settings
        ARM: dts: am57xx: cl-som-am57x: fix CPSW EMAC pinmux
        ARM: dts: am57xx: sbc-am57x: fix UART3 pinmux
        ARM: dts: am57xx: cl-som-am57x: update SPI Flash frequency
        ARM: dts: am57xx: cl-som-am57x: set HOST mode for USB2
        ARM: dts: am57xx: sbc-am57x: fix SB-SOM EEPROM I2C address
        ARM: dts: LogicPD Torpedo: Revert Duplicative Entries
        ARM: dts: am437x: pixcir_tangoc: use correct flags for irq types
        ARM: dts: am4372: fix irq type for arm twd and global timer
        ARM: dts: at91: sama5d4 xplained: fix phy0 IRQ type
        ...
      c17dfb01