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: <239535781889c5f541e166dc6c36621c550d82e1.camel@redhat.com>
Date:   Thu, 12 Oct 2023 22:51:36 +0300
From:   Maxim Levitsky <mlevitsk@...hat.com>
To:     Vitaly Kuznetsov <vkuznets@...hat.com>, kvm@...r.kernel.org,
        Paolo Bonzini <pbonzini@...hat.com>,
        Sean Christopherson <seanjc@...gle.com>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC 11/11] KVM: nSVM: hyper-v: Hide more stuff under
 CONFIG_KVM_HYPERV/CONFIG_HYPERV

У вт, 2023-10-10 у 18:03 +0200, Vitaly Kuznetsov пише:
> 'struct hv_vmcb_enlightenments' in VMCB only make sense when either
> CONFIG_KVM_HYPERV or CONFIG_HYPERV is enabled.
> 
> No functional change intended.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
> ---
>  arch/x86/kvm/svm/nested.c | 20 ++++++++++++++------
>  arch/x86/kvm/svm/svm.h    |  2 ++
>  2 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
> index 4d8cd378a30b..5ae41a708005 100644
> --- a/arch/x86/kvm/svm/nested.c
> +++ b/arch/x86/kvm/svm/nested.c
> @@ -187,7 +187,6 @@ void recalc_intercepts(struct vcpu_svm *svm)
>   */
>  static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
>  {
> -	struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
>  	int i;
>  
>  	/*
> @@ -198,11 +197,16 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
>  	 * - Nested hypervisor (L1) is using Hyper-V emulation interface and
>  	 * tells KVM (L0) there were no changes in MSR bitmap for L2.
>  	 */
> -	if (!svm->nested.force_msr_bitmap_recalc &&
> -	    kvm_hv_hypercall_enabled(&svm->vcpu) &&
> -	    hve->hv_enlightenments_control.msr_bitmap &&
> -	    (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS)))
> -		goto set_msrpm_base_pa;
> +#ifdef CONFIG_KVM_HYPERV
> +	if (!svm->nested.force_msr_bitmap_recalc) {
> +		struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
> +
> +		if (kvm_hv_hypercall_enabled(&svm->vcpu) &&
> +		    hve->hv_enlightenments_control.msr_bitmap &&
> +		    (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS)))
> +			goto set_msrpm_base_pa;
> +	}
> +#endif
>  
>  	if (!(vmcb12_is_intercept(&svm->nested.ctl, INTERCEPT_MSR_PROT)))
>  		return true;
> @@ -230,7 +234,9 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
>  
>  	svm->nested.force_msr_bitmap_recalc = false;
>  
> +#ifdef CONFIG_KVM_HYPERV
>  set_msrpm_base_pa:
> +#endif
>  	svm->vmcb->control.msrpm_base_pa = __sme_set(__pa(svm->nested.msrpm));
>  
>  	return true;
> @@ -378,12 +384,14 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu,
>  	to->msrpm_base_pa &= ~0x0fffULL;
>  	to->iopm_base_pa  &= ~0x0fffULL;
>  
> +#ifdef CONFIG_KVM_HYPERV
>  	/* Hyper-V extensions (Enlightened VMCB) */
>  	if (kvm_hv_hypercall_enabled(vcpu)) {
>  		to->clean = from->clean;
>  		memcpy(&to->hv_enlightenments, &from->hv_enlightenments,
>  		       sizeof(to->hv_enlightenments));
>  	}
> +#endif
>  }
>  
>  void nested_copy_vmcb_control_to_cache(struct vcpu_svm *svm,
> diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
> index be67ab7fdd10..59adff7bbf55 100644
> --- a/arch/x86/kvm/svm/svm.h
> +++ b/arch/x86/kvm/svm/svm.h
> @@ -148,7 +148,9 @@ struct vmcb_ctrl_area_cached {
>  	u64 virt_ext;
>  	u32 clean;
>  	union {
> +#if IS_ENABLED(CONFIG_HYPERV) || IS_ENABLED(CONFIG_KVM_HYPERV)
>  		struct hv_vmcb_enlightenments hv_enlightenments;
> +#endif
>  		u8 reserved_sw[32];
>  	};
>  };

Reviewed-by: Maxim Levitsky <mlevitsk@...hat.com>

Best regards,
	Maxim Levitsky

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ