From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:44942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnblF-0001ZE-Mu for qemu-devel@nongnu.org; Wed, 18 Jan 2012 15:05:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RnblE-0002TU-96 for qemu-devel@nongnu.org; Wed, 18 Jan 2012 15:05:33 -0500 Received: from fmmailgate04.web.de ([217.72.192.242]:38156) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RnblC-0002Sq-IZ for qemu-devel@nongnu.org; Wed, 18 Jan 2012 15:05:32 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate04.web.de (Postfix) with ESMTP id 66A9670FFBEA for ; Wed, 18 Jan 2012 21:05:17 +0100 (CET) Message-ID: <4F1725F6.90501@web.de> Date: Wed, 18 Jan 2012 21:05:10 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <1324241294-26089-1-git-send-email-vrozenfe@redhat.com> <1324241294-26089-2-git-send-email-vrozenfe@redhat.com> In-Reply-To: <1324241294-26089-2-git-send-email-vrozenfe@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC8CDA97032ACA296A7852C85" Subject: Re: [Qemu-devel] [PATCH RFC v3 1/2] hyper-v: introduce Hyper-V support infrastructure. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vadim Rozenfeld Cc: Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC8CDA97032ACA296A7852C85 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable On 2011-12-18 21:48, Vadim Rozenfeld wrote: > --- > Makefile.target | 2 + > target-i386/cpuid.c | 14 ++++++++++ > target-i386/hyperv.c | 65 ++++++++++++++++++++++++++++++++++++++++++= ++++++++ > target-i386/hyperv.h | 37 ++++++++++++++++++++++++++++ > 4 files changed, 118 insertions(+), 0 deletions(-) > create mode 100644 target-i386/hyperv.c > create mode 100644 target-i386/hyperv.h >=20 > diff --git a/Makefile.target b/Makefile.target > index 6e742c2..6245796 100644 > --- a/Makefile.target > +++ b/Makefile.target > @@ -209,6 +209,8 @@ obj-$(CONFIG_NO_KVM) +=3D kvm-stub.o > obj-y +=3D memory.o > LIBS+=3D-lz > =20 > +obj-i386-y +=3Dhyperv.o > + > QEMU_CFLAGS +=3D $(VNC_TLS_CFLAGS) > QEMU_CFLAGS +=3D $(VNC_SASL_CFLAGS) > QEMU_CFLAGS +=3D $(VNC_JPEG_CFLAGS) > diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c > index 1e8bcff..4193df1 100644 > --- a/target-i386/cpuid.c > +++ b/target-i386/cpuid.c > @@ -27,6 +27,8 @@ > #include "qemu-option.h" > #include "qemu-config.h" > =20 > +#include "hyperv.h" > + > /* feature flags taken from "Intel Processor Identification and the CP= UID > * Instruction" and AMD's "CPUID Specification". In cases of disagree= ment > * between feature naming conventions, aliases may be added. > @@ -716,6 +718,14 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu= _def, const char *cpu_model) > goto error; > } > x86_cpu_def->tsc_khz =3D tsc_freq / 1000; > + } else if (!strcmp(featurestr, "hv_spinlocks")) { > + char *err; > + numvalue =3D strtoul(val, &err, 0); > + if (!*val || *err) { > + fprintf(stderr, "bad numerical value %s\n", val); > + goto error; > + } > + hyperv_set_spinlock_retries(numvalue); > } else { > fprintf(stderr, "unrecognized feature %s\n", featurest= r); > goto error; > @@ -724,6 +734,10 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu= _def, const char *cpu_model) > check_cpuid =3D 1; > } else if (!strcmp(featurestr, "enforce")) { > check_cpuid =3D enforce_cpuid =3D 1; > + } else if (!strcmp(featurestr, "hv_relaxed")) { > + hyperv_enable_relaxed_timing(true); > + } else if (!strcmp(featurestr, "hv_vapic")) { > + hyperv_enable_vapic_recommended(true); > } else { > fprintf(stderr, "feature string `%s' not in format (+featu= re|-feature|feature=3Dxyz)\n", featurestr); > goto error; > diff --git a/target-i386/hyperv.c b/target-i386/hyperv.c > new file mode 100644 > index 0000000..b2e57ad > --- /dev/null > +++ b/target-i386/hyperv.c > @@ -0,0 +1,65 @@ > +/* > + * QEMU Hyper-V support > + * > + * Copyright Red Hat, Inc. 2011 > + * > + * Author: Vadim Rozenfeld > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or = later. > + * See the COPYING file in the top-level directory. > + * > + */ > + > +#include "hyperv.h" > + > +static bool hyperv_vapic; > +static bool hyperv_relaxed_timing; > +static int hyperv_spinlock_attempts =3D HYPERV_SPINLOCK_NEVER_RETRY; > + > +void hyperv_enable_vapic_recommended(bool val) > +{ > + hyperv_vapic =3D val; > +} > + > +void hyperv_enable_relaxed_timing(bool val) > +{ > + hyperv_relaxed_timing =3D val; > +} > + > +void hyperv_set_spinlock_retries(int val) > +{ > + hyperv_spinlock_attempts =3D val; > + if (hyperv_spinlock_attempts < 0xFFF) { > + hyperv_spinlock_attempts =3D 0xFFF; > + } > +} > + > +bool hyperv_enabled(void) > +{ > + return hyperv_hypercall_available() || hyperv_relaxed_timing_enabl= ed(); > +} > + > +bool hyperv_hypercall_available(void) > +{ > + if (hyperv_vapic || > + (hyperv_spinlock_attempts !=3D HYPERV_SPINLOCK_NEVER_RETRY)) {= > + return true; > + } > + return false; > +} > + > +bool hyperv_vapic_recommended(void) > +{ > + return hyperv_vapic; > +} > + > +bool hyperv_relaxed_timing_enabled(void) > +{ > + return hyperv_relaxed_timing; > +} > + > +int hyperv_get_spinlock_retries(void) > +{ > + return hyperv_spinlock_attempts; > +} > + > diff --git a/target-i386/hyperv.h b/target-i386/hyperv.h > new file mode 100644 > index 0000000..0d742f8 > --- /dev/null > +++ b/target-i386/hyperv.h > @@ -0,0 +1,37 @@ > +/* > + * QEMU Hyper-V support > + * > + * Copyright Red Hat, Inc. 2011 > + * > + * Author: Vadim Rozenfeld > + * > + * This work is licensed under the terms of the GNU GPL, version 2 or = later. > + * See the COPYING file in the top-level directory. > + * > + */ > + > +#ifndef QEMU_HW_HYPERV_H > +#define QEMU_HW_HYPERV_H 1 > + > +#include "qemu-common.h" > +#include > + > +#ifndef HYPERV_SPINLOCK_NEVER_RETRY > +#define HYPERV_SPINLOCK_NEVER_RETRY 0xFFFFFFFF > +#endif > + > +#ifndef KVM_CPUID_SIGNATURE_NEXT > +#define KVM_CPUID_SIGNATURE_NEXT 0x40000100 > +#endif > + > +void hyperv_enable_vapic_recommended(bool val); > +void hyperv_enable_relaxed_timing(bool val); > +void hyperv_set_spinlock_retries(int val); > + > +bool hyperv_enabled(void); > +bool hyperv_hypercall_available(void); > +bool hyperv_vapic_recommended(void); > +bool hyperv_relaxed_timing_enabled(void); > +int hyperv_get_spinlock_retries(void); > + > +#endif /* QEMU_HW_HYPERV_H */ This doesn't build for user mode as references in cpu_x86_find_by_name aren't available then. Jan --------------enigC8CDA97032ACA296A7852C85 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8XJfsACgkQitSsb3rl5xQJsACfRe9FdqawAsQZarbIEjhltJ8n GMQAoIT8iTBDGIHP9E50p9TqwNVdyNn+ =Ej2p -----END PGP SIGNATURE----- --------------enigC8CDA97032ACA296A7852C85--