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, 29 Sep 2008 10:24:22 +0200
From:	Gerd Hoffmann <kraxel@...hat.com>
To:	akataria@...are.com
CC:	Ingo Molnar <mingo@...e.hu>, "H. Peter Anvin" <hpa@...or.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	LKML <linux-kernel@...r.kernel.org>,
	the arch/x86 maintainers <x86@...nel.org>,
	Jeremy Fitzhardinge <jeremy@...p.org>, avi@...hat.com,
	Rusty Russell <rusty@...tcorp.com.au>,
	Zachary Amsden <zach@...are.com>,
	Dan Hecht <dhecht@...are.com>, Jun.Nakajima@...el.Com
Subject: Re: Use CPUID to communicate with the hypervisor.

  Hi,

> +unsigned long hypervisor_tsc_freq(void)
> +{
> +	unsigned long tsc_khz;
> +	unsigned int max_cpuid_leaf;
> +
> +	if (cpu_has_hypervisor) {
> +		max_cpuid_leaf = cpuid_eax(HYPERVISOR_INFO_LEAF);
> +		if (max_cpuid_leaf >= HYPERVISOR_TIMING_LEAF) {
> +			tsc_khz = cpuid_eax(HYPERVISOR_TIMING_LEAF);
> +			printk(KERN_INFO
> +				"TSC frequency read from hypervisor\n");
> +			return tsc_khz;
> +		}
> +	}
> +	return 0;
> +}

Shouldn't you check the hypervisor signature here?

>  /*
> + * Intel & AMD have reserved the cpuid levels 0x40000000 - 0x400000FF for
> + * software use. Hypervisors can use these levels to provide an interface
> + * to pass information from the hypervisor to the guest. This is similar
> + * to how we extract information about a physical cpu by using cpuid.
> + */
> +
> +/*
> + * This CPUID leaf returns the information about the hypervisor.
> + * EAX : maximum input value for CPUID supported by the hypervisor.
> + * EBX, ECX, EDX : Hypervisor vendor ID signature. E.g. VMwareVMware.
> + */
> +#define HYPERVISOR_INFO_LEAF   0x40000000
> +/*
> + * This leaf gets timing information from the hypervisor.info.
> + * EAX: (Virtual) TSC frequency in kHz.
> + * EBX: (Virtual) Bus (local apic timer) frequency in kHz.
> + * ECX, EDX: RESERVED
> + */
> +#define HYPERVISOR_TIMING_LEAF 0x40000010

Likewise, I think this should be HYPERVISOR_VMWARE_TIMING_LEAF.

Or we need some way to
  (a) standardize hypervisor cpuid leafes (or parts of it) and
  (b) handle sparsely filled cpuid info.

Right now both kvm and xen use the first one or two leafes (after info),
but in incompatible ways, so for these the signature *must* be checked
before using the info found there.

0x40000010 doesn't clash with anything as far I know, so we could
attempt to make that standard accross hypervisors.

cheers,
  Gerd
--
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