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: <310d674c-44e7-7b46-064f-7cb88c456d0f@redhat.com>
Date:   Tue, 26 Jan 2021 10:33:09 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Like Xu <like.xu@...ux.intel.com>,
        Sean Christopherson <seanjc@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Borislav Petkov <bp@...en8.de>,
        "H . Peter Anvin" <hpa@...or.com>, ak@...ux.intel.com,
        wei.w.wang@...el.com, kan.liang@...el.com, x86@...nel.org,
        kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RESEND v13 10/10] KVM: vmx/pmu: Release guest LBR event via lazy
 release mechanism

On 08/01/21 02:37, Like Xu wrote:
> The vPMU uses GUEST_LBR_IN_USE_IDX (bit 58) in 'pmu->pmc_in_use' to
> indicate whether a guest LBR event is still needed by the vcpu. If the
> vcpu no longer accesses LBR related registers within a scheduling time
> slice, and the enable bit of LBR has been unset, vPMU will treat the
> guest LBR event as a bland event of a vPMC counter and release it
> as usual. Also, the pass-through state of LBR records msrs is cancelled.
> 
> Signed-off-by: Like Xu <like.xu@...ux.intel.com>
> Reviewed-by: Andi Kleen <ak@...ux.intel.com>
> ---
>   arch/x86/kvm/pmu.c           |  7 +++++++
>   arch/x86/kvm/pmu.h           |  4 ++++
>   arch/x86/kvm/vmx/pmu_intel.c | 17 ++++++++++++++++-
>   3 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
> index 405890c723a1..e7c72eea07d4 100644
> --- a/arch/x86/kvm/pmu.c
> +++ b/arch/x86/kvm/pmu.c
> @@ -463,6 +463,7 @@ void kvm_pmu_cleanup(struct kvm_vcpu *vcpu)
>   	struct kvm_pmc *pmc = NULL;
>   	DECLARE_BITMAP(bitmask, X86_PMC_IDX_MAX);
>   	int i;
> +	bool extra_cleanup = false;
>   
>   	pmu->need_cleanup = false;
>   
> @@ -474,8 +475,14 @@ void kvm_pmu_cleanup(struct kvm_vcpu *vcpu)
>   
>   		if (pmc && pmc->perf_event && !pmc_speculative_in_use(pmc))
>   			pmc_stop_counter(pmc);
> +
> +		if (i == INTEL_GUEST_LBR_INUSE)
> +			extra_cleanup = true;
>   	}
>   
> +	if (extra_cleanup && kvm_x86_ops.pmu_ops->cleanup)
> +		kvm_x86_ops.pmu_ops->cleanup(vcpu);
> +

You can call this function always, it's cleaner than hardcoding 
INTEL_GUEST_LBR_INUSE.

You can also use INTEL_PMC_IDX_FIXED_VLBR directly instead of 
INTEL_GUEST_LBR_INUSE.

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ