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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 31 Jan 2022 17:19:44 +0100
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, Like Xu <like.xu.linux@...il.com>
Subject: Re: [PATCH 09/22] KVM: x86: Uninline and export hv_track_root_tdp()

Sean Christopherson <seanjc@...gle.com> writes:

> Uninline and export Hyper-V's hv_track_root_tdp(), which is (somewhat
> indirectly) the last remaining reference to kvm_x86_ops from vendor
> modules, i.e. will allow unexporting kvm_x86_ops.  Reloading the TDP PGD
> isn't the fastest of paths, hv_track_root_tdp() isn't exactly tiny, and
> disallowing vendor code from accessing kvm_x86_ops provides nice-to-have
> encapsulation of common x86 code (and of Hyper-V code for that
> matter).

We can add a static branch for "kvm_x86_ops.tlb_remote_flush ==
hv_remote_flush_tlb" condition and check it in vendor modules prior to
calling into hv_track_root_tdp() but I seriously doubt it'll bring us
noticable performance gain.

>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
>  arch/x86/kvm/kvm_onhyperv.c | 14 ++++++++++++++
>  arch/x86/kvm/kvm_onhyperv.h | 14 +-------------
>  2 files changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/arch/x86/kvm/kvm_onhyperv.c b/arch/x86/kvm/kvm_onhyperv.c
> index b469f45e3fe4..ee4f696a0782 100644
> --- a/arch/x86/kvm/kvm_onhyperv.c
> +++ b/arch/x86/kvm/kvm_onhyperv.c
> @@ -92,3 +92,17 @@ int hv_remote_flush_tlb(struct kvm *kvm)
>  	return hv_remote_flush_tlb_with_range(kvm, NULL);
>  }
>  EXPORT_SYMBOL_GPL(hv_remote_flush_tlb);
> +
> +void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)
> +{
> +	struct kvm_arch *kvm_arch = &vcpu->kvm->arch;
> +
> +	if (kvm_x86_ops.tlb_remote_flush == hv_remote_flush_tlb) {
> +		spin_lock(&kvm_arch->hv_root_tdp_lock);
> +		vcpu->arch.hv_root_tdp = root_tdp;
> +		if (root_tdp != kvm_arch->hv_root_tdp)
> +			kvm_arch->hv_root_tdp = INVALID_PAGE;
> +		spin_unlock(&kvm_arch->hv_root_tdp_lock);
> +	}
> +}
> +EXPORT_SYMBOL_GPL(hv_track_root_tdp);
> diff --git a/arch/x86/kvm/kvm_onhyperv.h b/arch/x86/kvm/kvm_onhyperv.h
> index 1c67abf2eba9..287e98ef9df3 100644
> --- a/arch/x86/kvm/kvm_onhyperv.h
> +++ b/arch/x86/kvm/kvm_onhyperv.h
> @@ -10,19 +10,7 @@
>  int hv_remote_flush_tlb_with_range(struct kvm *kvm,
>  		struct kvm_tlb_range *range);
>  int hv_remote_flush_tlb(struct kvm *kvm);
> -
> -static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)
> -{
> -	struct kvm_arch *kvm_arch = &vcpu->kvm->arch;
> -
> -	if (kvm_x86_ops.tlb_remote_flush == hv_remote_flush_tlb) {
> -		spin_lock(&kvm_arch->hv_root_tdp_lock);
> -		vcpu->arch.hv_root_tdp = root_tdp;
> -		if (root_tdp != kvm_arch->hv_root_tdp)
> -			kvm_arch->hv_root_tdp = INVALID_PAGE;
> -		spin_unlock(&kvm_arch->hv_root_tdp_lock);
> -	}
> -}
> +void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp);
>  #else /* !CONFIG_HYPERV */
>  static inline void hv_track_root_tdp(struct kvm_vcpu *vcpu, hpa_t root_tdp)
>  {

Reviewed-by: Vitaly Kuznetsov <vkuznets@...hat.com>

-- 
Vitaly

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ