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]
Message-ID: <ZG+e55VbXd/YCnnV@google.com>
Date:   Thu, 25 May 2023 10:46:15 -0700
From:   Sean Christopherson <seanjc@...gle.com>
To:     Jinrong Liang <ljr.kernel@...il.com>
Cc:     Like Xu <like.xu.linux@...il.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Jonathan Corbet <corbet@....net>,
        Shuah Khan <shuah@...nel.org>,
        Aaron Lewis <aaronlewis@...gle.com>,
        David Matlack <dmatlack@...gle.com>,
        Vishal Annapurve <vannapurve@...gle.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Bagas Sanjaya <bagasdotme@...il.com>,
        Jinrong Liang <cloudliang@...cent.com>,
        linux-kselftest@...r.kernel.org, linux-doc@...r.kernel.org,
        kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/7] KVM: selftests: Test unavailable event filters are rejected

On Thu, Apr 20, 2023, Jinrong Liang wrote:
> From: Jinrong Liang <cloudliang@...cent.com>
> 
> From: Jinrong Liang <cloudliang@...cent.com>
> 
> Adds unsupported input test cases for PMU filter. Specifically,
> it tests the input of unsupported "action" values, unsupported
> "flags" values, and unsupported "nevents" values, which should
> all return an error, as they are currently unsupported by the
> filter. Additionally, the patch tests setting non-exist fixed
> counters in the fixed bitmap doesn't fail.
> 
> This change aims to improve the testing of the PMU filter and
> ensure that it functions correctly in all supported use cases.
> The patch has been tested and verified to function correctly.
> 
> Signed-off-by: Jinrong Liang <cloudliang@...cent.com>
> ---
>  .../kvm/x86_64/pmu_event_filter_test.c        | 52 +++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> index 4e87eea6986b..a3d5c30ce914 100644
> --- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c
> @@ -27,6 +27,10 @@
>  #define ARCH_PERFMON_BRANCHES_RETIRED		5
>  
>  #define NUM_BRANCHES 42
> +#define FIXED_CTR_NUM_MASK				GENMASK_ULL(4, 0)
> +#define PMU_EVENT_FILTER_INVALID_ACTION		(KVM_PMU_EVENT_DENY + 1)
> +#define PMU_EVENT_FILTER_INVALID_FLAGS			(KVM_PMU_EVENT_FLAG_MASKED_EVENTS + 1)
> +#define PMU_EVENT_FILTER_INVALID_NEVENTS		(MAX_FILTER_EVENTS + 1)
>  
>  /*
>   * This is how the event selector and unit mask are stored in an AMD
> @@ -743,10 +747,22 @@ static int run_filter_test(struct kvm_vcpu *vcpu, const uint64_t *events,
>  	return r;
>  }
>  
> +static uint8_t get_kvm_supported_fixed_num(void)
> +{
> +	const struct kvm_cpuid_entry2 *kvm_entry;
> +
> +	if (host_cpu_is_amd)
> +		return 0;
> +
> +	kvm_entry = get_cpuid_entry(kvm_get_supported_cpuid(), 0xa, 0);
> +	return kvm_entry->edx & FIXED_CTR_NUM_MASK;

Ah, I got ahead of myself.  This is where the KVM_X86_PROPERTY comes in.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ