linux/arch
Robert O'Callahan bba82fd756 KVM: x86: never specify a sample period for virtualized in_tx_cp counters
pmc_reprogram_counter() always sets a sample period based on the value of
pmc->counter. However, hsw_hw_config() rejects sample periods less than
2^31 - 1. So for example, if a KVM guest does

    struct perf_event_attr attr;
    memset(&attr, 0, sizeof(attr));
    attr.type = PERF_TYPE_RAW;
    attr.size = sizeof(attr);
    attr.config = 0x2005101c4; // conditional branches retired IN_TXCP
    attr.sample_period = 0;
    int fd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
    ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
    ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);

the guest kernel counts some conditional branch events, then updates the
virtual PMU register with a nonzero count. The host reaches
pmc_reprogram_counter() with nonzero pmc->counter, triggers EOPNOTSUPP
in hsw_hw_config(), prints "kvm_pmu: event creation failed" in
pmc_reprogram_counter(), and silently (from the guest's point of view) stops
counting events.

We fix event counting by forcing attr.sample_period to always be zero for
in_tx_cp counters. Sampling doesn't work, but it already didn't work and
can't be fixed without major changes to the approach in hsw_hw_config().

Signed-off-by: Robert O'Callahan <robert@ocallahan.org>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
2017-03-01 14:19:46 +01:00
..
alpha Final extable.h related changes. 2017-02-21 14:28:55 -08:00
arc ARC updates for 4.11 rc1 2017-02-22 10:33:53 -08:00
arm 4.11 is going to be a relatively large release for KVM, with a little over 2017-02-22 18:22:53 -08:00
arm64 4.11 is going to be a relatively large release for KVM, with a little over 2017-02-22 18:22:53 -08:00
avr32 sched/cputime: Remove generic asm headers 2017-02-01 09:14:07 +01:00
blackfin sched/cputime: Remove generic asm headers 2017-02-01 09:14:07 +01:00
c6x sched/cputime: Remove generic asm headers 2017-02-01 09:14:07 +01:00
cris Final extable.h related changes. 2017-02-21 14:28:55 -08:00
frv Final extable.h related changes. 2017-02-21 14:28:55 -08:00
h8300 sched/cputime: Remove generic asm headers 2017-02-01 09:14:07 +01:00
hexagon Final extable.h related changes. 2017-02-21 14:28:55 -08:00
ia64 Final extable.h related changes. 2017-02-21 14:28:55 -08:00
m32r Final extable.h related changes. 2017-02-21 14:28:55 -08:00
m68k powerpc updates for 4.11 part 1. 2017-02-22 10:30:38 -08:00
metag Final extable.h related changes. 2017-02-21 14:28:55 -08:00
microblaze Final extable.h related changes. 2017-02-21 14:28:55 -08:00
mips 4.11 is going to be a relatively large release for KVM, with a little over 2017-02-22 18:22:53 -08:00
mn10300 Final extable.h related changes. 2017-02-21 14:28:55 -08:00
nios2 Final extable.h related changes. 2017-02-21 14:28:55 -08:00
openrisc Final extable.h related changes. 2017-02-21 14:28:55 -08:00
parisc This renames the (now inaccurate) CONFIG_DEBUG_RODATA and related config 2017-02-21 17:56:45 -08:00
powerpc 4.11 is going to be a relatively large release for KVM, with a little over 2017-02-22 18:22:53 -08:00
s390 4.11 is going to be a relatively large release for KVM, with a little over 2017-02-22 18:22:53 -08:00
score Final extable.h related changes. 2017-02-21 14:28:55 -08:00
sh TTY/Serial driver patches for 4.11-rc1 2017-02-22 12:17:25 -08:00
sparc Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2017-02-22 10:15:09 -08:00
tile Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-02-20 12:52:55 -08:00
um Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-02-20 13:23:30 -08:00
unicore32 Final extable.h related changes. 2017-02-21 14:28:55 -08:00
x86 KVM: x86: never specify a sample period for virtualized in_tx_cp counters 2017-03-01 14:19:46 +01:00
xtensa Final extable.h related changes. 2017-02-21 14:28:55 -08:00
.gitignore
Kconfig Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2017-02-22 10:15:09 -08:00