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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 24 May 2023 15:52:34 -0700
From:   Sean Christopherson <seanjc@...gle.com>
To:     Like Xu <like.xu.linux@...il.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Jinrong Liang <cloudliang@...cent.com>,
        linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [PATCH 7/7] KVM: selftests: Test Intel counters' bit width emulation

On Thu, Mar 23, 2023, Like Xu wrote:
> +static uint64_t test_ctrs_bit_width_setup(struct kvm_vcpu *vcpu,
> +					  uint8_t bit_width,
> +					  uint64_t perf_cap,
> +					  uint32_t msr_base)
> +{
> +	struct kvm_cpuid_entry2 *entry;
> +	bool fw_wr = perf_cap & PMU_CAP_FW_WRITES;
> +	uint64_t kvm_width;
> +	uint64_t value;
> +
> +	entry = vcpu_get_cpuid_entry(vcpu, 0xa);
> +	if (msr_base != MSR_CORE_PERF_FIXED_CTR0) {
> +		kvm_width = kvm_gp_ctr_bit_width();
> +		entry->eax = (entry->eax & ~GP_WIDTH_MASK) |
> +			(bit_width << GP_WIDTH_OFS_BIT);
> +	} else {
> +		kvm_width = kvm_fixed_ctr_bit_width();
> +		entry->edx = (entry->edx & ~FIXED_WIDTH_MASK) |
> +			(bit_width << FIXED_WIDTH_OFS_BIT);
> +	}
> +	TEST_REQUIRE(kvm_width > 31);

Unfortunately, using TEST_REQUIRE() in a subtest is generally a bad idea.  This
will skip _all_ tests if the requirement isn't met.  That might be a signal that
the test is doing too much, i.e. should be split into multiple tests.  Unlike KUT,
selftests are more geared towards lots of small tests, not a handful of massive
tests.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ