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:   Mon, 22 May 2023 23:30:35 +0000
From:   "Huang, Kai" <kai.huang@...el.com>
To:     "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "Christopherson,, Sean" <seanjc@...gle.com>
CC:     "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Gao, Chao" <chao.gao@...el.com>,
        "andrew.cooper3@...rix.com" <andrew.cooper3@...rix.com>
Subject: Re: [PATCH v3 15/18] KVM: VMX: Ensure CPU is stable when probing
 basic VMX support

On Fri, 2023-05-12 at 16:50 -0700, Sean Christopherson wrote:
> Disable migration when probing VMX support during module load to ensure
> the CPU is stable, mostly to match similar SVM logic, where allowing
> migration effective requires deliberately writing buggy code.  As a bonus,
> KVM won't report the wrong CPU to userspace if VMX is unsupported, but in
> practice that is a very, very minor bonus as the only way that reporting
> the wrong CPU would actually matter is if hardware is broken or if the
> system is misconfigured, i.e. if KVM gets migrated from a CPU that _does_
> support VMX to a CPU that does _not_ support VMX.
> 
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>

Reviewed-by: Kai Huang <kai.huang@...el.com>

> ---
>  arch/x86/kvm/vmx/vmx.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index e00dba166a9e..008914396180 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -2740,9 +2740,9 @@ static int setup_vmcs_config(struct vmcs_config *vmcs_conf,
>  	return 0;
>  }
>  
> -static bool kvm_is_vmx_supported(void)
> +static bool __kvm_is_vmx_supported(void)
>  {
> -	int cpu = raw_smp_processor_id();
> +	int cpu = smp_processor_id();
>  
>  	if (!(cpuid_ecx(1) & feature_bit(VMX))) {
>  		pr_err("VMX not supported by CPU %d\n", cpu);
> @@ -2758,13 +2758,24 @@ static bool kvm_is_vmx_supported(void)
>  	return true;
>  }
>  
> +static bool kvm_is_vmx_supported(void)
> +{
> +	bool supported;
> +
> +	migrate_disable();
> +	supported = __kvm_is_vmx_supported();
> +	migrate_enable();
> +
> +	return supported;
> +}
> +
>  static int vmx_check_processor_compat(void)
>  {
>  	int cpu = raw_smp_processor_id();
>  	struct vmcs_config vmcs_conf;
>  	struct vmx_capability vmx_cap;
>  
> -	if (!kvm_is_vmx_supported())
> +	if (!__kvm_is_vmx_supported())
>  		return -EIO;
>  
>  	if (setup_vmcs_config(&vmcs_conf, &vmx_cap) < 0) {
> -- 
> 2.40.1.606.ga4b1b128d6-goog
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ