diff options
author | Vadim Rozenfeld <vrozenfe@redhat.com> | 2011-12-18 22:48:13 +0200 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2012-01-19 08:32:12 -0200 |
commit | 28f52cc04d341045e810bd487a478fa9ec5f40be (patch) | |
tree | 2e92fa49e8ea688f9013ed5d8b1dd553a95f2d42 /target-i386/hyperv.c | |
parent | 8c4ec5c0269bda18bb777a64b2008088d1c632dc (diff) | |
download | hqemu-28f52cc04d341045e810bd487a478fa9ec5f40be.zip hqemu-28f52cc04d341045e810bd487a478fa9ec5f40be.tar.gz |
hyper-v: introduce Hyper-V support infrastructure.
[Jan: fix build with CONFIG_USER_ONLY]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'target-i386/hyperv.c')
-rw-r--r-- | target-i386/hyperv.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/target-i386/hyperv.c b/target-i386/hyperv.c new file mode 100644 index 0000000..f284e99 --- /dev/null +++ b/target-i386/hyperv.c @@ -0,0 +1,64 @@ +/* + * 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 bool hyperv_vapic; +static bool hyperv_relaxed_timing; +static int hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY; + +void hyperv_enable_vapic_recommended(bool val) +{ + hyperv_vapic = val; +} + +void hyperv_enable_relaxed_timing(bool 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; + } +} + +bool hyperv_enabled(void) +{ + return hyperv_hypercall_available() || hyperv_relaxed_timing_enabled(); +} + +bool hyperv_hypercall_available(void) +{ + if (hyperv_vapic || + (hyperv_spinlock_attempts != 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; +} |