Commit dea101a1 authored by Andrew Jones's avatar Andrew Jones Committed by Peter Maydell
Browse files

target/arm/cpu: Add the kvm-no-adjvtime CPU property



kvm-no-adjvtime is a KVM specific CPU property and a first of its
kind. To accommodate it we also add kvm_arm_add_vcpu_properties()
and a KVM specific CPU properties description to the CPU features
document.

Signed-off-by: default avatarAndrew Jones <drjones@redhat.com>
Message-id: 20200120101023.16030-7-drjones@redhat.com
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parent e5ac4200
Loading
Loading
Loading
Loading
+36 −1
Original line number Diff line number Diff line
@@ -31,7 +31,9 @@ supporting the feature or only supporting the feature under certain
configurations.  For example, the `aarch64` CPU feature, which, when
disabled, enables the optional AArch32 CPU feature, is only supported
when using the KVM accelerator and when running on a host CPU type that
supports the feature.
supports the feature.  While `aarch64` currently only works with KVM,
it could work with TCG.  CPU features that are specific to KVM are
prefixed with "kvm-" and are described in "KVM VCPU Features".

CPU Feature Probing
===================
@@ -171,6 +173,39 @@ disabling many SVE vector lengths would be quite verbose, the `sve<N>` CPU
properties have special semantics (see "SVE CPU Property Parsing
Semantics").

KVM VCPU Features
=================

KVM VCPU features are CPU features that are specific to KVM, such as
paravirt features or features that enable CPU virtualization extensions.
The features' CPU properties are only available when KVM is enabled and
are named with the prefix "kvm-".  KVM VCPU features may be probed,
enabled, and disabled in the same way as other CPU features.  Below is
the list of KVM VCPU features and their descriptions.

  kvm-no-adjvtime          By default kvm-no-adjvtime is disabled.  This
                           means that by default the virtual time
                           adjustment is enabled (vtime is *not not*
                           adjusted).

                           When virtual time adjustment is enabled each
                           time the VM transitions back to running state
                           the VCPU's virtual counter is updated to ensure
                           stopped time is not counted.  This avoids time
                           jumps surprising guest OSes and applications,
                           as long as they use the virtual counter for
                           timekeeping.  However it has the side effect of
                           the virtual and physical counters diverging.
                           All timekeeping based on the virtual counter
                           will appear to lag behind any timekeeping that
                           does not subtract VM stopped time.  The guest
                           may resynchronize its virtual counter with
                           other time sources as needed.

                           Enable kvm-no-adjvtime to disable virtual time
                           adjustment, also restoring the legacy (pre-5.0)
                           behavior.

SVE CPU Properties
==================

+8 −0
Original line number Diff line number Diff line
@@ -1663,6 +1663,11 @@ static void machvirt_init(MachineState *machine)
            }
        }

        if (vmc->kvm_no_adjvtime &&
            object_property_find(cpuobj, "kvm-no-adjvtime", NULL)) {
            object_property_set_bool(cpuobj, true, "kvm-no-adjvtime", NULL);
        }

        if (vmc->no_pmu && object_property_find(cpuobj, "pmu", NULL)) {
            object_property_set_bool(cpuobj, false, "pmu", NULL);
        }
@@ -2153,8 +2158,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 0)

static void virt_machine_4_2_options(MachineClass *mc)
{
    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));

    virt_machine_5_0_options(mc);
    compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
    vmc->kvm_no_adjvtime = true;
}
DEFINE_VIRT_MACHINE(4, 2)

+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ typedef struct {
    bool smbios_old_sys_ver;
    bool no_highmem_ecam;
    bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
    bool kvm_no_adjvtime;
} VirtMachineClass;

typedef struct {
+2 −0
Original line number Diff line number Diff line
@@ -2551,6 +2551,7 @@ static void arm_max_initfn(Object *obj)

    if (kvm_enabled()) {
        kvm_arm_set_cpu_features_from_host(cpu);
        kvm_arm_add_vcpu_properties(obj);
    } else {
        cortex_a15_initfn(obj);

@@ -2743,6 +2744,7 @@ static void arm_host_initfn(Object *obj)
    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
        aarch64_add_sve_properties(obj);
    }
    kvm_arm_add_vcpu_properties(obj);
    arm_cpu_post_init(obj);
}

+1 −0
Original line number Diff line number Diff line
@@ -605,6 +605,7 @@ static void aarch64_max_initfn(Object *obj)

    if (kvm_enabled()) {
        kvm_arm_set_cpu_features_from_host(cpu);
        kvm_arm_add_vcpu_properties(obj);
    } else {
        uint64_t t;
        uint32_t u;
Loading