lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZJygmEIjdWHcqMQ7@google.com>
Date:   Wed, 28 Jun 2023 14:05:28 -0700
From:   Sean Christopherson <seanjc@...gle.com>
To:     Jinrong Liang <ljr.kernel@...il.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>, Like Xu <likexu@...cent.com>,
        David Matlack <dmatlack@...gle.com>,
        Aaron Lewis <aaronlewis@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jinrong Liang <cloudliang@...cent.com>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 7/8] KVM: selftests: Test Intel supported fixed
 counters bit mask

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()

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ