From: Jan Kiszka <jan.kiszka@siemens.com>
To: Vadim Rozenfeld <vrozenfe@redhat.com>
Cc: Avi Kivity <avi@redhat.com>, kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH RFC v1 1/2] hyper-v: introduce Hyper-V support infrastructure.
Date: Mon, 17 Oct 2011 11:37:58 +0200 [thread overview]
Message-ID: <4E9BF776.4080802@siemens.com> (raw)
In-Reply-To: <1318843022-20344-2-git-send-email-vrozenfe@redhat.com>
On 2011-10-17 11:17, Vadim Rozenfeld wrote:
> with the following series of patches we are starting to implement
> some basic Microsoft Hyper-V Enlightenment functionality, like relaxed
> timing, spinlock, and virtual apic support.
>
> For more Hyper-V related information please see:
> "Hypervisor Functional Specification v2.0: For Windows Server 2008 R2" at
> http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18673
> ---
> Makefile.target | 2 +
> default-configs/i386-softmmu.mak | 1 +
> default-configs/x86_64-softmmu.mak | 1 +
> target-i386/cpuid.c | 14 +++++++
> target-i386/hyperv.c | 69 ++++++++++++++++++++++++++++++++++++
> target-i386/hyperv.h | 30 +++++++++++++++
> 6 files changed, 117 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 40cc592..2c8e1b8 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -202,6 +202,8 @@ obj-$(CONFIG_NO_KVM) += kvm-stub.o
> obj-y += memory.o
> LIBS+=-lz
>
> +obj-$(CONFIG_HYPERV) += hyperv.o
obj-i386-y
> +
> QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
> QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
> QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
> diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
> index 55589fa..ee69a0a 100644
> --- a/default-configs/i386-softmmu.mak
> +++ b/default-configs/i386-softmmu.mak
> @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
> CONFIG_SOUND=y
> CONFIG_HPET=y
> CONFIG_APPLESMC=y
> +CONFIG_HYPERV=y
> diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
> index 8895028..35b1c00 100644
> --- a/default-configs/x86_64-softmmu.mak
> +++ b/default-configs/x86_64-softmmu.mak
> @@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
> CONFIG_SOUND=y
> CONFIG_HPET=y
> CONFIG_APPLESMC=y
> +CONFIG_HYPERV=y
Useless config options (that do not work anyway as Kevin noted).
> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index 1e8bcff..50b2d0e 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -27,6 +27,8 @@
> #include "qemu-option.h"
> #include "qemu-config.h"
>
> +#include "hyperv.h"
> +
> /* feature flags taken from "Intel Processor Identification and the CPUID
> * Instruction" and AMD's "CPUID Specification". In cases of disagreement
> * 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 = tsc_freq / 1000;
> + } else if (!strcmp(featurestr, "hv_spinlocks")) {
> + char* err;
> + numvalue = 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", featurestr);
> 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 = 1;
> } else if (!strcmp(featurestr, "enforce")) {
> check_cpuid = enforce_cpuid = 1;
> + } else if (!strcmp(featurestr, "hv_relaxed")) {
> + hyperv_set_relaxed_timing(1);
> + } else if (!strcmp(featurestr, "hv_vapic")) {
> + hyperv_set_vapic_recommended(1);
> } else {
> fprintf(stderr, "feature string `%s' not in format (+feature|-feature|feature=xyz)\n", featurestr);
> goto error;
> diff --git a/target-i386/hyperv.c b/target-i386/hyperv.c
> new file mode 100644
> index 0000000..bed859e
> --- /dev/null
> +++ b/target-i386/hyperv.c
> @@ -0,0 +1,69 @@
> +/*
> + * QEMU Hyper-V support
> + *
> + * Copyright Red Hat, Inc. 2011
> + *
> + * Author: Vadim Rozenfeld <vrozenfe@redhat.com>
> + *
> + * 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 int hyperv_vapic;
> +static int hyperv_relaxed_timing;
> +static int hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
> +
> +void hyperv_set_vapic_recommended(int val)
> +{
> + hyperv_vapic = val;
> +}
> +
> +void hyperv_set_relaxed_timing(int val)
> +{
> + hyperv_relaxed_timing = val;
> +}
> +
> +void hyperv_set_spinlock_retries(int val)
> +{
> + hyperv_spinlock_attempts = val;
> + if (hyperv_spinlock_attempts < 0xFFF) {
> + hyperv_spinlock_attempts = 0xFFF;
> + }
> +}
hyperv_enabled_x(bool enable) would be nicer.
> +
> +int hyperv_enabled(void)
> +{
> + return hyperv_hypercall_available() || hyperv_get_relaxed_timing();
> +}
> +
> +int hyperv_hypercall_available(void)
> +{
> + if (hyperv_vapic ||
> + (hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY)) {
> + return 1;
> + }
> + return 0;
> +}
> +
> +int hyperv_get_vapic_recommended(void)
> +{
> +#ifdef KVM_CAP_IRQCHIP
This is x86-only code, and x86 supports KVM_CAP_IRQCHIP. So drop this
#ifdef.
> + return hyperv_vapic;
> +#else
> + return 0;
> +#endif
> +}
> +
> +int hyperv_get_relaxed_timing(void)
> +{
> + return hyperv_relaxed_timing;
> +}
> +
> +int hyperv_get_spinlock_retries(void)
> +{
> + return hyperv_spinlock_attempts;
> +}
bool hyperv_vapic_recommend(void), hyperv_relaxed_timing_enabled etc.
"get" implies to me that there is actual a non-boolean value returned
which is not.
> +
> diff --git a/target-i386/hyperv.h b/target-i386/hyperv.h
> new file mode 100644
> index 0000000..1ea5e99
> --- /dev/null
> +++ b/target-i386/hyperv.h
> @@ -0,0 +1,30 @@
> +/*
> + * QEMU Hyper-V support
> + *
> + * Copyright Red Hat, Inc. 2011
> + *
> + * Author: Vadim Rozenfeld <vrozenfe@redhat.com>
> + *
> + * 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 <asm/hyperv.h>
> +
> +#define HYPERV_SPINLOCK_NEVER_RETRY 0xFFFFFFFF
> +
> +void hyperv_set_vapic_recommended(int val);
> +void hyperv_set_relaxed_timing(int val);
> +void hyperv_set_spinlock_retries(int val);
> +
> +int hyperv_enabled(void);
> +int hyperv_hypercall_available(void);
> +int hyperv_get_vapic_recommended(void);
> +int hyperv_get_relaxed_timing(void);
> +int hyperv_get_spinlock_retries(void);
> +
> +#endif /* QEMU_HW_HYPERV_H */
Looks good otherwise.
Jan
--
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2011-10-17 9:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-17 9:17 [Qemu-devel] [PATCH RFC v1 0/2] Initial support for Microsoft Hyper-V Vadim Rozenfeld
2011-10-17 9:17 ` [Qemu-devel] [PATCH RFC v1 1/2] hyper-v: introduce Hyper-V support infrastructure Vadim Rozenfeld
2011-10-17 9:30 ` Kevin Wolf
2011-10-17 9:37 ` Jan Kiszka [this message]
2011-10-17 9:17 ` [Qemu-devel] [PATCH RFC v1 2/2] hyper-v: initialize Hyper-V CPUID leafs Vadim Rozenfeld
2011-10-17 9:40 ` Paolo Bonzini
2011-10-17 10:41 ` Avi Kivity
2011-10-17 10:42 ` Paolo Bonzini
2011-10-17 13:57 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E9BF776.4080802@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=qemu-devel@nongnu.org \
--cc=vrozenfe@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).