Skip to content

Commit 5e725d1

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm/x86 fixes from Paolo Bonzini: - zero all padding for KVM_GET_DEBUGREGS - fix rST warning - disable vPMU support on hybrid CPUs * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: kvm: initialize all of the kvm_debugregs structure before sending it to userspace perf/x86: Refuse to export capabilities for hybrid PMUs KVM: x86/pmu: Disable vPMU support on hybrid CPUs (host PMUs) Documentation/hw-vuln: Fix rST warning
2 parents 0c2822b + 2c10b61 commit 5e725d1

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

Documentation/admin-guide/hw-vuln/cross-thread-rsb.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,4 @@ capability to override those interceptions, but since this is not common, the
8888
mitigation that covers this path is not enabled by default.
8989

9090
The mitigation for the KVM_CAP_X86_DISABLE_EXITS capability can be turned on
91-
using the boolean module parameter mitigate_smt_rsb, e.g.:
92-
kvm.mitigate_smt_rsb=1
91+
using the boolean module parameter mitigate_smt_rsb, e.g. ``kvm.mitigate_smt_rsb=1``.

arch/x86/events/core.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2974,17 +2974,19 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
29742974

29752975
void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
29762976
{
2977-
if (!x86_pmu_initialized()) {
2977+
/* This API doesn't currently support enumerating hybrid PMUs. */
2978+
if (WARN_ON_ONCE(cpu_feature_enabled(X86_FEATURE_HYBRID_CPU)) ||
2979+
!x86_pmu_initialized()) {
29782980
memset(cap, 0, sizeof(*cap));
29792981
return;
29802982
}
29812983

2982-
cap->version = x86_pmu.version;
29832984
/*
2984-
* KVM doesn't support the hybrid PMU yet.
2985-
* Return the common value in global x86_pmu,
2986-
* which available for all cores.
2985+
* Note, hybrid CPU models get tracked as having hybrid PMUs even when
2986+
* all E-cores are disabled via BIOS. When E-cores are disabled, the
2987+
* base PMU holds the correct number of counters for P-cores.
29872988
*/
2989+
cap->version = x86_pmu.version;
29882990
cap->num_counters_gp = x86_pmu.num_counters;
29892991
cap->num_counters_fixed = x86_pmu.num_counters_fixed;
29902992
cap->bit_width_gp = x86_pmu.cntval_bits;

arch/x86/kvm/pmu.h

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,27 @@ static inline void kvm_init_pmu_capability(void)
165165
{
166166
bool is_intel = boot_cpu_data.x86_vendor == X86_VENDOR_INTEL;
167167

168-
perf_get_x86_pmu_capability(&kvm_pmu_cap);
169-
170-
/*
171-
* For Intel, only support guest architectural pmu
172-
* on a host with architectural pmu.
173-
*/
174-
if ((is_intel && !kvm_pmu_cap.version) || !kvm_pmu_cap.num_counters_gp)
168+
/*
169+
* Hybrid PMUs don't play nice with virtualization without careful
170+
* configuration by userspace, and KVM's APIs for reporting supported
171+
* vPMU features do not account for hybrid PMUs. Disable vPMU support
172+
* for hybrid PMUs until KVM gains a way to let userspace opt-in.
173+
*/
174+
if (cpu_feature_enabled(X86_FEATURE_HYBRID_CPU))
175175
enable_pmu = false;
176176

177+
if (enable_pmu) {
178+
perf_get_x86_pmu_capability(&kvm_pmu_cap);
179+
180+
/*
181+
* For Intel, only support guest architectural pmu
182+
* on a host with architectural pmu.
183+
*/
184+
if ((is_intel && !kvm_pmu_cap.version) ||
185+
!kvm_pmu_cap.num_counters_gp)
186+
enable_pmu = false;
187+
}
188+
177189
if (!enable_pmu) {
178190
memset(&kvm_pmu_cap, 0, sizeof(kvm_pmu_cap));
179191
return;

arch/x86/kvm/x86.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5263,12 +5263,11 @@ static void kvm_vcpu_ioctl_x86_get_debugregs(struct kvm_vcpu *vcpu,
52635263
{
52645264
unsigned long val;
52655265

5266+
memset(dbgregs, 0, sizeof(*dbgregs));
52665267
memcpy(dbgregs->db, vcpu->arch.db, sizeof(vcpu->arch.db));
52675268
kvm_get_dr(vcpu, 6, &val);
52685269
dbgregs->dr6 = val;
52695270
dbgregs->dr7 = vcpu->arch.dr7;
5270-
dbgregs->flags = 0;
5271-
memset(&dbgregs->reserved, 0, sizeof(dbgregs->reserved));
52725271
}
52735272

52745273
static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,

0 commit comments

Comments
 (0)