Re: [PATCH v2 7/8] KVM: selftests: Test Intel supported fixed counters bit mask

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 30, 2023, Jinrong Liang wrote:
> +static void test_fixed_counters_setup(struct kvm_vcpu *vcpu, uint8_t edx_fix_num,
> +				      uint32_t fixed_bitmask, bool expected)
> +{
> +	struct kvm_cpuid_entry2 *entry;
> +	uint8_t max_fixed_num = X86_INTEL_MAX_FIXED_CTR_NUM;
> +	uint64_t supported_bitmask = 0;
> +	uint64_t msr_val;
> +	unsigned int i;
> +
> +	entry = vcpu_get_cpuid_entry(vcpu, 0xa);
> +	entry->ecx = fixed_bitmask;
> +	entry->edx = (entry->edx & ~FIXED_CTR_NUM_MASK) | edx_fix_num;
> +	vcpu_set_cpuid(vcpu);
> +
> +	for (i = 0; i < max_fixed_num; i++) {
> +		if (entry->ecx & BIT_ULL(i) ||
> +		    ((entry->edx & FIXED_CTR_NUM_MASK) > i))
> +			supported_bitmask |= BIT_ULL(i);
> +	}
> +
> +	vcpu_args_set(vcpu, 2, supported_bitmask, max_fixed_num);

All of this can be queried from the guest, no?  Then you also verify that KVM is
passing in the correct CPUID info too.

> +	while (run_vcpu(vcpu, &msr_val) != UCALL_DONE)
> +		TEST_ASSERT(!!msr_val == expected,
> +			    "Unexpected when testing fixed counter.");

ASSERT_EQ()



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux