[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.3 71/87] target/riscv/kvm: fix timebase-frequency when using
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.3 71/87] target/riscv/kvm: fix timebase-frequency when using KVM acceleration |
Date: |
Wed, 10 Apr 2024 10:22:44 +0300 |
From: Yong-Xuan Wang <yongxuan.wang@sifive.com>
The timebase-frequency of guest OS should be the same with host
machine. The timebase-frequency value in DTS should be got from
hypervisor when using KVM acceleration.
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Message-ID: <20240314061510.9800-1-yongxuan.wang@sifive.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit 385e575cd5ab2436c123e4b7f8c9b383a64c0dbe)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: context fix due to missing other changes in this area in 8.2.x)
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index d2eac24156..7e802c3837 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -743,6 +743,8 @@ static void create_fdt_sockets(RISCVVirtState *s, const
MemMapEntry *memmap,
qemu_fdt_add_subnode(ms->fdt, "/cpus");
qemu_fdt_setprop_cell(ms->fdt, "/cpus", "timebase-frequency",
+ kvm_enabled() ?
+ kvm_riscv_get_timebase_frequency(first_cpu) :
RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ);
qemu_fdt_setprop_cell(ms->fdt, "/cpus", "#size-cells", 0x0);
qemu_fdt_setprop_cell(ms->fdt, "/cpus", "#address-cells", 0x1);
diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
index 117e33cf90..c1675158fe 100644
--- a/target/riscv/kvm/kvm-cpu.c
+++ b/target/riscv/kvm/kvm-cpu.c
@@ -684,6 +684,15 @@ static void kvm_riscv_put_regs_timer(CPUState *cs)
env->kvm_timer_dirty = false;
}
+uint64_t kvm_riscv_get_timebase_frequency(CPUState *cs)
+{
+ uint64_t reg;
+
+ KVM_RISCV_GET_TIMER(cs, frequency, reg);
+
+ return reg;
+}
+
typedef struct KVMScratchCPU {
int kvmfd;
int vmfd;
diff --git a/target/riscv/kvm/kvm_riscv.h b/target/riscv/kvm/kvm_riscv.h
index 8329cfab82..4728281632 100644
--- a/target/riscv/kvm/kvm_riscv.h
+++ b/target/riscv/kvm/kvm_riscv.h
@@ -27,5 +27,6 @@ void kvm_riscv_aia_create(MachineState *machine, uint64_t
group_shift,
uint64_t guest_num);
void riscv_kvm_aplic_request(void *opaque, int irq, int level);
int kvm_riscv_sync_mpstate_to_kvm(RISCVCPU *cpu, int state);
+uint64_t kvm_riscv_get_timebase_frequency(CPUState *cs);
#endif
--
2.39.2
- [Stable-8.2.3 62/87] target/riscv/vector_helper.c: set vstart = 0 in GEN_VEXT_VSLIDEUP_VX(), (continued)
- [Stable-8.2.3 62/87] target/riscv/vector_helper.c: set vstart = 0 in GEN_VEXT_VSLIDEUP_VX(), Michael Tokarev, 2024/04/10
- [Stable-8.2.3 65/87] target/riscv: always clear vstart in whole vec move insns, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 66/87] target/riscv/vector_helpers: do early exit when vstart >= vl, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 64/87] target/riscv/vector_helper.c: fix 'vmvr_v' memcpy endianess, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 67/87] target/riscv/vector_helper.c: optimize loops in ldst helpers, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 68/87] hw/intc: Update APLIC IDC after claiming iforce register, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 69/87] target/riscv: rvv: Remove the dependency of Zvfbfmin to Zfbfmin, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 70/87] target/riscv: Fix mode in riscv_tlb_fill, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 72/87] virtio-net: Fix vhost virtqueue notifiers for RSS, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 73/87] hw/net/net_tx_pkt: Fix virtio header without checksum offloading, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 71/87] target/riscv/kvm: fix timebase-frequency when using KVM acceleration,
Michael Tokarev <=
- [Stable-8.2.3 77/87] gitlab-ci/cirrus: switch from 'master' to 'latest', Michael Tokarev, 2024/04/10
- [Stable-8.2.3 76/87] migration/postcopy: Ensure postcopy_start() sets errp if it fails, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 75/87] target/hppa: Clear psw_n for BE on use_nullify_skip path, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 78/87] hw/intc/arm_gicv3: ICC_HPPIR* return SPURIOUS if int group is disabled, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 74/87] tcg/optimize: Fix sign_mask for logical right-shift, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 79/87] target/arm: take HSTR traps of cp15 accesses to EL2, not EL1, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 80/87] hw/net/virtio-net: fix qemu set used ring flag even vhost started, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 81/87] block/virtio-blk: Fix memory leak from virtio_blk_zone_report, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 82/87] migration/postcopy: ensure preempt channel is ready before loading states, Michael Tokarev, 2024/04/10
- [Stable-8.2.3 83/87] target/arm: Use correct SecuritySpace for AArch64 AT ops at EL3, Michael Tokarev, 2024/04/10