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: <51E92CAB.7020906@redhat.com>
Date:	Fri, 19 Jul 2013 14:10:19 +0200
From:	Paolo Bonzini <pbonzini@...hat.com>
To:	Jason Wang <jasowang@...hat.com>
CC:	gleb@...hat.com, tglx@...utronix.de, mingo@...hat.com,
	hpa@...or.com, x86@...nel.org, kvm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Vadim Rozenfeld <vrozenfe@...hat.com>,
	"K. Y. Srinivasan" <kys@...rosoft.com>
Subject: Re: [PATCH] x86: properly handle KVM emulation of hyperv

Il 19/07/2013 12:25, Jason Wang ha scritto:
> Recent kvm has some basic support of hyperv, this will cause the guest to
> identify itself running on top of hyperv instead of kvm which will disable kvm
> pv functionality. Solve this by check kvm para platform first and also check
> KVM_CPUID_SIGNATURE_NEXT which were set when kvm emulate hyperv.
> 
> Cc: Gleb Natapov <gleb@...hat.com>
> Cc: Paolo Bonzini <pbonzini@...hat.com>
> Cc: Vadim Rozenfeld <vrozenfe@...hat.com>
> Cc: K. Y. Srinivasan <kys@...rosoft.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: "H. Peter Anvin" <hpa@...or.com>
> Signed-off-by: Jason Wang <jasowang@...hat.com>
> ---
>  arch/x86/include/asm/kvm_para.h      |   25 +++++++++++++++++--------
>  arch/x86/include/uapi/asm/kvm_para.h |    1 +
>  arch/x86/kernel/cpu/hypervisor.c     |    2 +-
>  3 files changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h
> index 695399f..aa8f3a7 100644
> --- a/arch/x86/include/asm/kvm_para.h
> +++ b/arch/x86/include/asm/kvm_para.h
> @@ -85,22 +85,31 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
>  	return ret;
>  }
>  
> -static inline bool kvm_para_available(void)
> +static inline bool kvm_para_available_function(unsigned int function)
>  {
>  	unsigned int eax, ebx, ecx, edx;
>  	char signature[13];
>  
> +	cpuid(function, &eax, &ebx, &ecx, &edx);
> +	memcpy(signature + 0, &ebx, 4);
> +	memcpy(signature + 4, &ecx, 4);
> +	memcpy(signature + 8, &edx, 4);
> +	signature[12] = 0;
> +
> +	if (strcmp(signature, "KVMKVMKVM") == 0)
> +		return true;
> +
> +	return false;
> +}
> +
> +static inline bool kvm_para_available(void)
> +{
>  	if (boot_cpu_data.cpuid_level < 0)
>  		return false;	/* So we don't blow up on old processors */
>  
>  	if (cpu_has_hypervisor) {
> -		cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
> -		memcpy(signature + 0, &ebx, 4);
> -		memcpy(signature + 4, &ecx, 4);
> -		memcpy(signature + 8, &edx, 4);
> -		signature[12] = 0;
> -
> -		if (strcmp(signature, "KVMKVMKVM") == 0)
> +		if (kvm_para_available_function(KVM_CPUID_SIGNATURE) ||
> +		    kvm_para_available_function(KVM_CPUID_SIGNATURE_NEXT))
>  			return true;
>  	}

Nice catch.  Just one small thing, you should loop until 0x40010000, as
done in arch/x86/include/asm/xen/hypervisor.h, in case one day a third
hypervisor implements three extensions (Hyper-V, KVM and its own set).

Paolo

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ