diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-06-20 07:18:12 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2023-08-31 19:47:43 +0200 |
commit | b797c98de4106b0d8cd1daa7d32f31e47e9f1d46 (patch) | |
tree | 1588414dcf9add5f74bd9092a871a6a28abf259f /hw | |
parent | f8324611c1ec100fd601842d3943cbf8acd1420f (diff) | |
download | qemu-b797c98de4106b0d8cd1daa7d32f31e47e9f1d46.zip qemu-b797c98de4106b0d8cd1daa7d32f31e47e9f1d46.tar.gz qemu-b797c98de4106b0d8cd1daa7d32f31e47e9f1d46.tar.bz2 |
hw/i386: Remove unuseful kvmclock_create() stub
We shouldn't call kvmclock_create() when KVM is not available
or disabled:
- check for kvm_enabled() before calling it
- assert KVM is enabled once called
Since the call is elided when KVM is not available, we can
remove the stub (it is never compiled).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20230620083228.88796-2-philmd@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/i386/kvm/clock.c | 4 | ||||
-rw-r--r-- | hw/i386/microvm.c | 4 | ||||
-rw-r--r-- | hw/i386/pc_piix.c | 2 | ||||
-rw-r--r-- | hw/i386/pc_q35.c | 4 |
4 files changed, 10 insertions, 4 deletions
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index df70b4a..0824c6d 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -332,8 +332,10 @@ void kvmclock_create(bool create_always) { X86CPU *cpu = X86_CPU(first_cpu); - if (!kvm_enabled() || !kvm_has_adjust_clock()) + assert(kvm_enabled()); + if (!kvm_has_adjust_clock()) { return; + } if (create_always || cpu->env.features[FEAT_KVM] & ((1ULL << KVM_FEATURE_CLOCKSOURCE) | diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index 7227a21..6b762bc 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -180,7 +180,9 @@ static void microvm_devices_init(MicrovmMachineState *mms) x86ms->ioapic2 = ioapic_init_secondary(gsi_state); } - kvmclock_create(true); + if (kvm_enabled()) { + kvmclock_create(true); + } mms->virtio_irq_base = 5; mms->virtio_num_transports = 8; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index ce1ac95..3de8e0d 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -192,7 +192,7 @@ static void pc_init1(MachineState *machine, pc_machine_init_sgx_epc(pcms); x86_cpus_init(x86ms, pcmc->default_cpu_version); - if (pcmc->kvmclock_enabled) { + if (kvm_enabled() && pcmc->kvmclock_enabled) { kvmclock_create(pcmc->kvmclock_create_always); } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 37c4814..a95c5d0 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -183,7 +183,9 @@ static void pc_q35_init(MachineState *machine) pc_machine_init_sgx_epc(pcms); x86_cpus_init(x86ms, pcmc->default_cpu_version); - kvmclock_create(pcmc->kvmclock_create_always); + if (kvm_enabled()) { + kvmclock_create(pcmc->kvmclock_create_always); + } /* pci enabled */ if (pcmc->pci_enabled) { |