Commit 92067bf4 authored by Igor Mammedov's avatar Igor Mammedov Committed by Andreas Färber
Browse files

target-i386: Move hyperv_* static globals to X86CPU



- since hyperv_* helper functions are used only in target-i386/kvm.c
  move them there as static helpers

Requested-by: default avatarEduardo Habkost <ehabkost@redhat.com>
Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
Signed-off-by: default avatarAndreas Färber <afaerber@suse.de>
parent 99a0b036
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ obj-y += excp_helper.o fpu_helper.o cc_helper.o int_helper.o svm_helper.o
obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o
obj-y += gdbstub.o
obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o
obj-$(CONFIG_KVM) += kvm.o hyperv.o
obj-$(CONFIG_KVM) += kvm.o
obj-$(CONFIG_NO_KVM) += kvm-stub.o
obj-$(CONFIG_LINUX_USER) += ioport-user.o
obj-$(CONFIG_BSD_USER) += ioport-user.o
+4 −0
Original line number Diff line number Diff line
@@ -66,6 +66,10 @@ typedef struct X86CPU {

    CPUX86State env;

    bool hyperv_vapic;
    bool hyperv_relaxed_timing;
    int hyperv_spinlock_attempts;

    /* Features that were filtered out because of missing host capabilities */
    uint32_t filtered_features[FEATURE_WORDS];

+11 −5
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@
#include "qapi/visitor.h"
#include "sysemu/arch_init.h"

#include "hyperv.h"

#include "hw/hw.h"
#if defined(CONFIG_KVM)
#include <linux/kvm_para.h>
@@ -1591,12 +1589,19 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
                object_property_parse(OBJECT(cpu), num, "tsc-frequency", errp);
            } else if (!strcmp(featurestr, "hv-spinlocks")) {
                char *err;
                const int min = 0xFFF;
                numvalue = strtoul(val, &err, 0);
                if (!*val || *err) {
                    error_setg(errp, "bad numerical value %s", val);
                    goto out;
                }
                hyperv_set_spinlock_retries(numvalue);
                if (numvalue < min) {
                    fprintf(stderr, "hv-spinlocks value shall always be >= 0x%x"
                            ", fixup will be removed in future versions\n",
                            min);
                    numvalue = min;
                }
                cpu->hyperv_spinlock_attempts = numvalue;
            } else {
                error_setg(errp, "unrecognized feature %s", featurestr);
                goto out;
@@ -1606,9 +1611,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
        } else if (!strcmp(featurestr, "enforce")) {
            check_cpuid = enforce_cpuid = 1;
        } else if (!strcmp(featurestr, "hv_relaxed")) {
            hyperv_enable_relaxed_timing(true);
            cpu->hyperv_relaxed_timing = true;
        } else if (!strcmp(featurestr, "hv_vapic")) {
            hyperv_enable_vapic_recommended(true);
            cpu->hyperv_vapic = true;
        } else {
            error_setg(errp, "feature string `%s' not in format (+feature|"
                       "-feature|feature=xyz)", featurestr);
@@ -2489,6 +2494,7 @@ static void x86_cpu_initfn(Object *obj)
                        x86_cpu_get_feature_words,
                        NULL, NULL, (void *)cpu->filtered_features, NULL);

    cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
    env->cpuid_apic_id = x86_cpu_apic_id_from_index(cs->cpu_index);

    /* init various static tables used in TCG mode */
+4 −0
Original line number Diff line number Diff line
@@ -549,6 +549,10 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS];
#define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
#define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */

#ifndef HYPERV_SPINLOCK_NEVER_RETRY
#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
#endif

#define EXCP00_DIVZ	0
#define EXCP01_DB	1
#define EXCP02_NMI	2

target-i386/hyperv.c

deleted100644 → 0
+0 −64
Original line number Diff line number Diff line
/*
 * 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;
}
Loading