Skip to content

Commit f291e2d

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull kvm fixes from Paolo Bonzini: "Two small fixes, one of which was being worked around in selftests" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: KVM: x86: Retry page fault if MMU reload is pending and root has no sp KVM: selftests: vmx_pmu_msrs_test: Drop tests mangling guest visible CPUIDs KVM: x86: Drop guest CPUID check for host initiated writes to MSR_IA32_PERF_CAPABILITIES
2 parents 2da09da + 18c841e commit f291e2d

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

arch/x86/kvm/mmu/mmu.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -3987,7 +3987,21 @@ static bool kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,
39873987
static bool is_page_fault_stale(struct kvm_vcpu *vcpu,
39883988
struct kvm_page_fault *fault, int mmu_seq)
39893989
{
3990-
if (is_obsolete_sp(vcpu->kvm, to_shadow_page(vcpu->arch.mmu->root_hpa)))
3990+
struct kvm_mmu_page *sp = to_shadow_page(vcpu->arch.mmu->root_hpa);
3991+
3992+
/* Special roots, e.g. pae_root, are not backed by shadow pages. */
3993+
if (sp && is_obsolete_sp(vcpu->kvm, sp))
3994+
return true;
3995+
3996+
/*
3997+
* Roots without an associated shadow page are considered invalid if
3998+
* there is a pending request to free obsolete roots. The request is
3999+
* only a hint that the current root _may_ be obsolete and needs to be
4000+
* reloaded, e.g. if the guest frees a PGD that KVM is tracking as a
4001+
* previous root, then __kvm_mmu_prepare_zap_page() signals all vCPUs
4002+
* to reload even if no vCPU is actively using the root.
4003+
*/
4004+
if (!sp && kvm_test_request(KVM_REQ_MMU_RELOAD, vcpu))
39914005
return true;
39924006

39934007
return fault->slot &&

arch/x86/kvm/x86.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3413,7 +3413,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
34133413

34143414
if (!msr_info->host_initiated)
34153415
return 1;
3416-
if (guest_cpuid_has(vcpu, X86_FEATURE_PDCM) && kvm_get_msr_feature(&msr_ent))
3416+
if (kvm_get_msr_feature(&msr_ent))
34173417
return 1;
34183418
if (data & ~msr_ent.data)
34193419
return 1;

tools/testing/selftests/kvm/x86_64/vmx_pmu_msrs_test.c

-17
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,5 @@ int main(int argc, char *argv[])
110110
ret = _vcpu_set_msr(vm, 0, MSR_IA32_PERF_CAPABILITIES, PMU_CAP_LBR_FMT);
111111
TEST_ASSERT(ret == 0, "Bad PERF_CAPABILITIES didn't fail.");
112112

113-
/* testcase 4, set capabilities when we don't have PDCM bit */
114-
entry_1_0->ecx &= ~X86_FEATURE_PDCM;
115-
vcpu_set_cpuid(vm, VCPU_ID, cpuid);
116-
ret = _vcpu_set_msr(vm, 0, MSR_IA32_PERF_CAPABILITIES, host_cap.capabilities);
117-
TEST_ASSERT(ret == 0, "Bad PERF_CAPABILITIES didn't fail.");
118-
119-
/* testcase 5, set capabilities when we don't have PMU version bits */
120-
entry_1_0->ecx |= X86_FEATURE_PDCM;
121-
eax.split.version_id = 0;
122-
entry_1_0->ecx = eax.full;
123-
vcpu_set_cpuid(vm, VCPU_ID, cpuid);
124-
ret = _vcpu_set_msr(vm, 0, MSR_IA32_PERF_CAPABILITIES, PMU_CAP_FW_WRITES);
125-
TEST_ASSERT(ret == 0, "Bad PERF_CAPABILITIES didn't fail.");
126-
127-
vcpu_set_msr(vm, 0, MSR_IA32_PERF_CAPABILITIES, 0);
128-
ASSERT_EQ(vcpu_get_msr(vm, VCPU_ID, MSR_IA32_PERF_CAPABILITIES), 0);
129-
130113
kvm_vm_free(vm);
131114
}

0 commit comments

Comments
 (0)