Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+28 -16
+1 -2
Documentation/admin-guide/hw-vuln/cross-thread-rsb.rst
··· 88 88 mitigation that covers this path is not enabled by default. 89 89 90 90 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``.
+7 -5
arch/x86/events/core.c
··· 2974 2974 2975 2975 void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap) 2976 2976 { 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()) { 2978 2980 memset(cap, 0, sizeof(*cap)); 2979 2981 return; 2980 2982 } 2981 2983 2982 - cap->version = x86_pmu.version; 2983 2984 /* 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. 2987 2988 */ 2989 + cap->version = x86_pmu.version; 2988 2990 cap->num_counters_gp = x86_pmu.num_counters; 2989 2991 cap->num_counters_fixed = x86_pmu.num_counters_fixed; 2990 2992 cap->bit_width_gp = x86_pmu.cntval_bits;
+19 -7
arch/x86/kvm/pmu.h
··· 165 165 { 166 166 bool is_intel = boot_cpu_data.x86_vendor == X86_VENDOR_INTEL; 167 167 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)) 175 175 enable_pmu = false; 176 + 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 + } 176 188 177 189 if (!enable_pmu) { 178 190 memset(&kvm_pmu_cap, 0, sizeof(kvm_pmu_cap));
+1 -2
arch/x86/kvm/x86.c
··· 5263 5263 { 5264 5264 unsigned long val; 5265 5265 5266 + memset(dbgregs, 0, sizeof(*dbgregs)); 5266 5267 memcpy(dbgregs->db, vcpu->arch.db, sizeof(vcpu->arch.db)); 5267 5268 kvm_get_dr(vcpu, 6, &val); 5268 5269 dbgregs->dr6 = val; 5269 5270 dbgregs->dr7 = vcpu->arch.dr7; 5270 - dbgregs->flags = 0; 5271 - memset(&dbgregs->reserved, 0, sizeof(dbgregs->reserved)); 5272 5271 } 5273 5272 5274 5273 static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,