- Introduce the SM4 cipher algorithms (OSCCA GB/T 32907-2016).
- intel_iommu: Add missed sanity check for 256-bit invalidation queue
- linux-user: use 'max' instead of 'qemu32' / 'qemu64' by default
- chardev/baum: Use definitions to avoid dynamic stack allocation
- ui/console: Get tab completion working again in the SDL monitor vc
- s390x/tcg: Fix opcode for lzrf
- virtiofsd: use g_date_time_get_microsecond to get subsecond
- ui/curses: Avoid dynamic stack allocation
- target/m68k: always call gen_exit_tb() after writes to SR
- target/m68k: Perform writback before modifying SR
- target/m68k: Fix MACSR to CCR
- target/m68k: Implement atomic test-and-set
- block/nvme: nvme_process_completion() fix bound for cid
- hw/pci-host: pnv_phb{3, 4}: Fix heap out-of-bound access failure
- target/ppc: Zero second doubleword of VSR registers for FPR insns
- target/ppc: Set OV32 when OV is set
- target/ppc: Zero second doubleword for VSX madd instructions
- target/ppc: Set result to QNaN for DENBCD when VXCVI occurs
- hw/pci: Add parenthesis to PCI_BUILD_BDF macro
- intel_iommu: Send IQE event when setting reserved bit in IQT_TAIL
- acpi: cpuhp: fix guest-visible maximum access size to the legacy reg block
- acpi: ged: Add macro for acpi sleep control register
- hw/pci-bridge: Add a Kconfig switch for the normal PCI bridge
- ui/vnc: fix handling of VNC_FEATURE_XVP
- s390/sclp: fix SCLP facility map
- docs/tools/qemu-img.rst: fix typo (sumarizes)
- chardev/char: fix qemu_chr_is_busy() check
- edu: fix DMA range upper bound check
- platform-bus: fix refcount leak
- hw/net/virtio-net: fix qemu set used ring flag even vhost started
- hw/net/can/sja1000: fix bug for single acceptance filter and standard frame
- tests/avocado: fix typo in replay_linux
- util/userfaultfd: Remove unused uffd_poll_events
- hw/core/ptimer: fix timer zero period condition for freq > 1GHz
- hcd-ohci: Drop ohci_service_iso_td() if ed->head & OHCI_DPTR_MASK is zero
- tests/unit/test-vmstate: Avoid dynamic stack allocation
- hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation
- hw/i386/multiboot: Avoid dynamic stack allocation
- hw/ppc/spapr: Fix code style problems reported by checkpatch
- chardev/baum: Replace magic values by X_MAX / Y_MAX definitions
- hw/intc/xics: Avoid dynamic stack allocation
- hw/net/e1000e_core: Use definition to avoid dynamic stack allocation
- intel_iommu: Fix invalidation descriptor type field
- configs: Fix typo in the sh4-softmmu devices config file
Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
(cherry picked from commit 9813ed21ec2499c50cb58ac5fb114a1641708eb2)
102 lines
3.4 KiB
Diff
102 lines
3.4 KiB
Diff
From 309d5b48a969e67ee97a7cae0c77e67728742c19 Mon Sep 17 00:00:00 2001
|
|
From: Zhang Jiao <zhangjiao2_yewu@cmss.chinamobile.com>
|
|
Date: Wed, 16 Oct 2024 14:33:19 +0800
|
|
Subject: [PATCH] hw/core/ptimer: fix timer zero period condition for freq >
|
|
1GHz
|
|
|
|
cheery-pick from 446e5e8b4515e9a7be69ef6a29852975289bb6f0
|
|
|
|
The real period is zero when both period and period_frac are zero.
|
|
Check the method ptimer_set_freq, if freq is larger than 1000 MHz,
|
|
the period is zero, but the period_frac is not, in this case, the
|
|
ptimer will work but the current code incorrectly recognizes that
|
|
the ptimer is disabled.
|
|
|
|
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2306
|
|
Signed-off-by: JianZhou Yue <JianZhou.Yue@verisilicon.com>
|
|
Message-id: 3DA024AEA8B57545AF1B3CAA37077D0FB75E82C8@SHASXM03.verisilicon.com
|
|
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
|
|
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
|
|
Signed-off-by: Zhang Jiao <zhangjiao2_yewu@cmss.chinamobile.com>
|
|
---
|
|
hw/core/ptimer.c | 4 ++--
|
|
tests/unit/ptimer-test.c | 33 +++++++++++++++++++++++++++++++++
|
|
2 files changed, 35 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c
|
|
index 6ba19fd965..25063deefe 100644
|
|
--- a/hw/core/ptimer.c
|
|
+++ b/hw/core/ptimer.c
|
|
@@ -84,7 +84,7 @@ static void ptimer_reload(ptimer_state *s, int delta_adjust)
|
|
delta = s->delta = s->limit;
|
|
}
|
|
|
|
- if (s->period == 0) {
|
|
+ if (s->period == 0 && s->period_frac == 0) {
|
|
if (!qtest_enabled()) {
|
|
fprintf(stderr, "Timer with period zero, disabling\n");
|
|
}
|
|
@@ -310,7 +310,7 @@ void ptimer_run(ptimer_state *s, int oneshot)
|
|
|
|
assert(s->in_transaction);
|
|
|
|
- if (was_disabled && s->period == 0) {
|
|
+ if (was_disabled && s->period == 0 && s->period_frac == 0) {
|
|
if (!qtest_enabled()) {
|
|
fprintf(stderr, "Timer with period zero, disabling\n");
|
|
}
|
|
diff --git a/tests/unit/ptimer-test.c b/tests/unit/ptimer-test.c
|
|
index 9176b96c1c..8544b6486c 100644
|
|
--- a/tests/unit/ptimer-test.c
|
|
+++ b/tests/unit/ptimer-test.c
|
|
@@ -763,6 +763,33 @@ static void check_oneshot_with_load_0(gconstpointer arg)
|
|
ptimer_free(ptimer);
|
|
}
|
|
|
|
+static void check_freq_more_than_1000M(gconstpointer arg)
|
|
+{
|
|
+ const uint8_t *policy = arg;
|
|
+ ptimer_state *ptimer = ptimer_init(ptimer_trigger, NULL, *policy);
|
|
+ bool no_round_down = (*policy & PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
|
|
+
|
|
+ triggered = false;
|
|
+
|
|
+ ptimer_transaction_begin(ptimer);
|
|
+ ptimer_set_freq(ptimer, 2000000000);
|
|
+ ptimer_set_limit(ptimer, 8, 1);
|
|
+ ptimer_run(ptimer, 1);
|
|
+ ptimer_transaction_commit(ptimer);
|
|
+
|
|
+ qemu_clock_step(3);
|
|
+
|
|
+ g_assert_cmpuint(ptimer_get_count(ptimer), ==, no_round_down ? 3 : 2);
|
|
+ g_assert_false(triggered);
|
|
+
|
|
+ qemu_clock_step(1);
|
|
+
|
|
+ g_assert_cmpuint(ptimer_get_count(ptimer), ==, 0);
|
|
+ g_assert_true(triggered);
|
|
+
|
|
+ ptimer_free(ptimer);
|
|
+}
|
|
+
|
|
static void add_ptimer_tests(uint8_t policy)
|
|
{
|
|
char policy_name[256] = "";
|
|
@@ -857,6 +884,12 @@ static void add_ptimer_tests(uint8_t policy)
|
|
policy_name),
|
|
g_memdup(&policy, 1), check_oneshot_with_load_0, g_free);
|
|
g_free(tmp);
|
|
+
|
|
+ g_test_add_data_func_full(
|
|
+ tmp = g_strdup_printf("/ptimer/freq_more_than_1000M policy=%s",
|
|
+ policy_name),
|
|
+ g_memdup(&policy, 1), check_freq_more_than_1000M, g_free);
|
|
+ g_free(tmp);
|
|
}
|
|
|
|
static void add_all_ptimer_policies_comb_tests(void)
|
|
--
|
|
2.41.0.windows.1
|
|
|