File: hyperv.c

package info (click to toggle)
qemu 1.1.2%2Bdfsg-6a%2Bdeb7u12
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 44,200 kB
  • sloc: ansic: 603,655; asm: 10,184; sh: 6,663; perl: 4,223; python: 3,802; makefile: 1,089; objc: 843; xml: 409
file content (64 lines) | stat: -rw-r--r-- 1,252 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;
}