v3: - Added a target/arm/kvm_arm.h comment cleanup patch (1/6) - Minor refactoring of assert_has_feature_enabled/disabled in 4/6, kept Richard's r-b. - Rewrote kvm-no-adjvtime documentation in 6/6. - Reworked approach in 5/6 to properly deal with migration and to track running vs. !running, rather than running vs. paused states. v2: - Reworked it enough that I brought back the RFC tag and retitled the series. Also had to drop r-b's from a couple of patches, and even drop patches. - Changed approach from writing the QEMU virtual time to the guest vtime counter to saving and restoring the guest vtime counter. - Changed the kvm-adjvtime property, which was off by default, to a kvm-no-adjvtime property, which is also off by default, meaning the effective "adjust vtime" property is now on by default (but only for 5.0 virt machine types and later) v1: - move from RFC status to v1 - put kvm_arm_vm_state_change() in kvm.c to share among kvm32.c and kvm64.c - add r-b's from Richard This series is inspired by a series[1] posted by Bijan Mottahedeh over a year ago and by the patch[2] posted by Heyi Guo almost a year ago. The problem described in the cover letter of [1] is easily reproducible and some users would like to have the option to avoid it. However the solution, which is to adjust the virtual counter each time the VM transitions to the running state, introduces a different problem, which is that the virtual and physical counters diverge. As described in the cover letter of [1] this divergence is easily observed when comparing the output of `date` and `hwclock` after suspending the guest, waiting a while, and then resuming it. Because this different problem may actually be worse for some users, unlike [1], the series posted here makes the virtual counter adjustment optional. Besides the adjustment being optional, this series approaches the needed changes differently to apply them in more appropriate locations. Additional notes ---------------- Note 1 ------ As described above, when running a guest with kvm-no-adjtime disabled it will be less likely the guest OS and guest applications get surprise time jumps when they use the virtual counter. However the counter will no longer reflect real time. It will lag behind. If this is a problem then the guest can resynchronize its time from an external source or even from its physical counter. If the suspend/resume is done with libvirt's virsh, and the guest is running the guest agent, then it's also possible to use a sequence like this $ virsh suspend $GUEST $ virsh resume $GUEST $ virsh domtime --sync $GUEST in order to resynchronize a guest right after the resume. Of course there will still be time when the clock is not right, possibly creating confusing timestamps in logs, for example, and the guest must still be tolerant to the time synchronizations. Note 2 ------ Userspace that wants to set KVM_REG_ARM_TIMER_CNT should beware that the KVM register ID is not correct. This cannot be fixed because it's UAPI and if the UAPI headers are used then it can't be a problem. However, if a userspace attempts to create the ID themselves from the register's specification, then they will get KVM_REG_ARM_TIMER_CVAL instead, as the _CNT and _CVAL definitions have their register parameters swapped. Note 3 ------ I didn't test this with a 32-bit KVM host, but the changes to kvm32.c are the same as kvm64.c. So what could go wrong? Test results would be appreciated. [1] https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05713.html [2] https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg03695.html upstream url: https://patchwork.kernel.org/cover/11341629/
145 lines
4.3 KiB
Diff
145 lines
4.3 KiB
Diff
From c057499f90af4be8b26f57f8755aca0ddfcf9467 Mon Sep 17 00:00:00 2001
|
|
From: Ying Fang <fangying1@huawei.com>
|
|
Date: Tue, 21 Apr 2020 16:52:07 +0800
|
|
Subject: [PATCH 1/4] target/arm/kvm: trivial: Clean up header documentation
|
|
|
|
Signed-off-by: Andrew Jones <drjones@redhat.com>
|
|
Message-id: 20200120101023.16030-2-drjones@redhat.com
|
|
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
---
|
|
target/arm/kvm_arm.h | 38 +++++++++++++++++++++++---------------
|
|
1 file changed, 23 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
|
|
index a9f3ccab..32d97ce5 100644
|
|
--- a/target/arm/kvm_arm.h
|
|
+++ b/target/arm/kvm_arm.h
|
|
@@ -61,8 +61,8 @@ void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t group,
|
|
int kvm_arm_init_cpreg_list(ARMCPU *cpu);
|
|
|
|
/**
|
|
- * kvm_arm_reg_syncs_via_cpreg_list
|
|
- * regidx: KVM register index
|
|
+ * kvm_arm_reg_syncs_via_cpreg_list:
|
|
+ * @regidx: KVM register index
|
|
*
|
|
* Return true if this KVM register should be synchronized via the
|
|
* cpreg list of arbitrary system registers, false if it is synchronized
|
|
@@ -71,8 +71,8 @@ int kvm_arm_init_cpreg_list(ARMCPU *cpu);
|
|
bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx);
|
|
|
|
/**
|
|
- * kvm_arm_cpreg_level
|
|
- * regidx: KVM register index
|
|
+ * kvm_arm_cpreg_level:
|
|
+ * @regidx: KVM register index
|
|
*
|
|
* Return the level of this coprocessor/system register. Return value is
|
|
* either KVM_PUT_RUNTIME_STATE, KVM_PUT_RESET_STATE, or KVM_PUT_FULL_STATE.
|
|
@@ -134,6 +134,8 @@ void kvm_arm_init_serror_injection(CPUState *cs);
|
|
* @cpu: ARMCPU
|
|
*
|
|
* Get VCPU related state from kvm.
|
|
+ *
|
|
+ * Returns: 0 if success else < 0 error code
|
|
*/
|
|
int kvm_get_vcpu_events(ARMCPU *cpu);
|
|
|
|
@@ -142,6 +144,8 @@ int kvm_get_vcpu_events(ARMCPU *cpu);
|
|
* @cpu: ARMCPU
|
|
*
|
|
* Put VCPU related state to kvm.
|
|
+ *
|
|
+ * Returns: 0 if success else < 0 error code
|
|
*/
|
|
int kvm_put_vcpu_events(ARMCPU *cpu);
|
|
|
|
@@ -191,10 +195,12 @@ typedef struct ARMHostCPUFeatures {
|
|
|
|
/**
|
|
* kvm_arm_get_host_cpu_features:
|
|
- * @ahcc: ARMHostCPUClass to fill in
|
|
+ * @ahcf: ARMHostCPUClass to fill in
|
|
*
|
|
* Probe the capabilities of the host kernel's preferred CPU and fill
|
|
* in the ARMHostCPUClass struct accordingly.
|
|
+ *
|
|
+ * Returns true on success and false otherwise.
|
|
*/
|
|
bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf);
|
|
|
|
@@ -208,26 +214,30 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf);
|
|
void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);
|
|
|
|
/**
|
|
- * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the
|
|
- * IPA address space supported by KVM
|
|
- *
|
|
+ * kvm_arm_get_max_vm_ipa_size:
|
|
* @ms: Machine state handle
|
|
+ *
|
|
+ * Returns the number of bits in the IPA address space supported by KVM
|
|
*/
|
|
int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
|
|
|
|
/**
|
|
- * kvm_arm_sync_mpstate_to_kvm
|
|
+ * kvm_arm_sync_mpstate_to_kvm:
|
|
* @cpu: ARMCPU
|
|
*
|
|
* If supported set the KVM MP_STATE based on QEMU's model.
|
|
+ *
|
|
+ * Returns 0 on success and -1 on failure.
|
|
*/
|
|
int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu);
|
|
|
|
/**
|
|
- * kvm_arm_sync_mpstate_to_qemu
|
|
+ * kvm_arm_sync_mpstate_to_qemu:
|
|
* @cpu: ARMCPU
|
|
*
|
|
* If supported get the MP_STATE from KVM and store in QEMU's model.
|
|
+ *
|
|
+ * Returns 0 on success and aborts on failure.
|
|
*/
|
|
int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu);
|
|
|
|
@@ -241,7 +251,8 @@ int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
|
|
|
|
static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
|
|
{
|
|
- /* This should never actually be called in the "not KVM" case,
|
|
+ /*
|
|
+ * This should never actually be called in the "not KVM" case,
|
|
* but set up the fields to indicate an error anyway.
|
|
*/
|
|
cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
|
|
@@ -310,23 +321,20 @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit);
|
|
*
|
|
* Return: TRUE if any hardware breakpoints in use.
|
|
*/
|
|
-
|
|
bool kvm_arm_hw_debug_active(CPUState *cs);
|
|
|
|
/**
|
|
* kvm_arm_copy_hw_debug_data:
|
|
- *
|
|
* @ptr: kvm_guest_debug_arch structure
|
|
*
|
|
* Copy the architecture specific debug registers into the
|
|
* kvm_guest_debug ioctl structure.
|
|
*/
|
|
struct kvm_guest_debug_arch;
|
|
-
|
|
void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr);
|
|
|
|
/**
|
|
- * its_class_name
|
|
+ * its_class_name:
|
|
*
|
|
* Return the ITS class name to use depending on whether KVM acceleration
|
|
* and KVM CAP_SIGNAL_MSI are supported
|
|
--
|
|
2.23.0
|