From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RncMZ-0000Zw-IR for qemu-devel@nongnu.org; Wed, 18 Jan 2012 15:44:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RncMX-0000FQ-R7 for qemu-devel@nongnu.org; Wed, 18 Jan 2012 15:44:07 -0500 Received: from fmmailgate01.web.de ([217.72.192.221]:46319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RncMX-0000F9-By for qemu-devel@nongnu.org; Wed, 18 Jan 2012 15:44:05 -0500 Received: from moweb001.kundenserver.de (moweb001.kundenserver.de [172.19.20.114]) by fmmailgate01.web.de (Postfix) with ESMTP id 52C8E1A90C299 for ; Wed, 18 Jan 2012 21:43:49 +0100 (CET) Message-ID: <4F172F03.7020505@web.de> Date: Wed, 18 Jan 2012 21:43:47 +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> <4F1725F6.90501@web.de> In-Reply-To: <4F1725F6.90501@web.de> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigDD514B67F8B33BF33B51FFA1" 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) --------------enigDD514B67F8B33BF33B51FFA1 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable On 2012-01-18 21:05, Jan Kiszka wrote: > 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 >> >> 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 C= PUID >> * Instruction" and AMD's "CPUID Specification". In cases of disagre= ement >> * between feature naming conventions, aliases may be added. >> @@ -716,6 +718,14 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cp= u_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", features= tr); >> goto error; >> @@ -724,6 +734,10 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cp= u_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 (+feat= ure|-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_enab= led(); >> +} >> + >> +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 */ >=20 > This doesn't build for user mode as references in cpu_x86_find_by_name > aren't available then. Just fold this into the patch: diff --git a/target-i386/hyperv.h b/target-i386/hyperv.h index 0d742f8..15467bf 100644 --- a/target-i386/hyperv.h +++ b/target-i386/hyperv.h @@ -24,9 +24,15 @@ #define KVM_CPUID_SIGNATURE_NEXT 0x40000100 #endif +#ifndef CONFIG_USER_ONLY void hyperv_enable_vapic_recommended(bool val); void hyperv_enable_relaxed_timing(bool val); void hyperv_set_spinlock_retries(int val); +#else +static inline void hyperv_enable_vapic_recommended(bool val) { } +static inline void hyperv_enable_relaxed_timing(bool val) { } +static inline void hyperv_set_spinlock_retries(int val) { } +#endif bool hyperv_enabled(void); bool hyperv_hypercall_available(void); Jan --------------enigDD514B67F8B33BF33B51FFA1 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/ iEYEARECAAYFAk8XLwMACgkQitSsb3rl5xS5LACcCNS2bc/4A/4uB+AEGgedMsWe +LMAn0XYnFfpwrm+x0cR5M5JlkOg86Kr =BAa4 -----END PGP SIGNATURE----- --------------enigDD514B67F8B33BF33B51FFA1--