1
Arm queue; bugfixes only.
1
It's been quiet on the arm front this week, so all I have is
2
these coverity fixes I posted a while back...
2
3
3
thanks
4
-- PMM
4
-- PMM
5
5
6
The following changes since commit 48aa8f0ac536db3550a35c295ff7de94e4c33739:
6
The following changes since commit 853546f8128476eefb701d4a55b2781bb3a46faa:
7
7
8
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-11-16' into staging (2020-11-17 11:07:00 +0000)
8
Merge tag 'pull-loongarch-20240322' of https://gitlab.com/gaosong/qemu into staging (2024-03-22 10:59:57 +0000)
9
9
10
are available in the Git repository at:
10
are available in the Git repository at:
11
11
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201117
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240325
13
13
14
for you to fetch changes up to ab135622cf478585bdfcb68b85e4a817d74a0c42:
14
for you to fetch changes up to 55c79639d553c1b7a82b4cde781ad5f316f45b0e:
15
15
16
tmp105: Correct handling of temperature limit checks (2020-11-17 12:56:33 +0000)
16
tests/qtest/libqtest.c: Check for g_setenv() failure (2024-03-25 10:41:01 +0000)
17
17
18
----------------------------------------------------------------
18
----------------------------------------------------------------
19
target-arm queue:
19
target-arm queue:
20
* hw/arm/virt: ARM_VIRT must select ARM_GIC
20
* Fixes for seven minor coverity issues
21
* exynos: Fix bad printf format specifiers
22
* hw/input/ps2.c: Remove remnants of printf debug
23
* target/openrisc: Remove dead code attempting to check "is timer disabled"
24
* register: Remove unnecessary NULL check
25
* util/cutils: Fix Coverity array overrun in freq_to_str()
26
* configure: Make "does libgio work" test pull in some actual functions
27
* tmp105: reset the T_low and T_High registers
28
* tmp105: Correct handling of temperature limit checks
29
21
30
----------------------------------------------------------------
22
----------------------------------------------------------------
31
Alex Chen (1):
23
Peter Maydell (7):
32
exynos: Fix bad printf format specifiers
24
tests/qtest/npcm7xx_emc_test: Don't leak cmd_line
25
tests/unit/socket-helpers: Don't close(-1)
26
net/af-xdp.c: Don't leak sock_fds array in net_init_af_xdp()
27
hw/misc/pca9554: Correct error check bounds in get/set pin functions
28
hw/nvram/mac_nvram: Report failure to write data
29
tests/unit/test-throttle: Avoid unintended integer division
30
tests/qtest/libqtest.c: Check for g_setenv() failure
33
31
34
Alistair Francis (1):
32
hw/misc/pca9554.c | 4 ++--
35
register: Remove unnecessary NULL check
33
hw/nvram/mac_nvram.c | 5 ++++-
36
34
net/af-xdp.c | 3 +--
37
Andrew Jones (1):
35
tests/qtest/libqtest.c | 6 +++++-
38
hw/arm/virt: ARM_VIRT must select ARM_GIC
36
tests/qtest/npcm7xx_emc-test.c | 4 ++--
39
37
tests/unit/socket-helpers.c | 4 +++-
40
Peter Maydell (5):
38
tests/unit/test-throttle.c | 4 ++--
41
hw/input/ps2.c: Remove remnants of printf debug
39
7 files changed, 19 insertions(+), 11 deletions(-)
42
target/openrisc: Remove dead code attempting to check "is timer disabled"
43
configure: Make "does libgio work" test pull in some actual functions
44
hw/misc/tmp105: reset the T_low and T_High registers
45
tmp105: Correct handling of temperature limit checks
46
47
Philippe Mathieu-Daudé (1):
48
util/cutils: Fix Coverity array overrun in freq_to_str()
49
50
configure | 11 +++++--
51
hw/misc/tmp105.h | 7 +++++
52
hw/core/register.c | 4 ---
53
hw/input/ps2.c | 9 ------
54
hw/misc/tmp105.c | 73 ++++++++++++++++++++++++++++++++++++++------
55
hw/timer/exynos4210_mct.c | 4 +--
56
hw/timer/exynos4210_pwm.c | 8 ++---
57
target/openrisc/sys_helper.c | 3 --
58
util/cutils.c | 3 +-
59
hw/arm/Kconfig | 1 +
60
10 files changed, 89 insertions(+), 34 deletions(-)
61
diff view generated by jsdifflib
Deleted patch
1
From: Andrew Jones <drjones@redhat.com>
2
1
3
The removal of the selection of A15MPCORE from ARM_VIRT also
4
removed what A15MPCORE selects, ARM_GIC. We still need ARM_GIC.
5
6
Fixes: bec3c97e0cf9 ("hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals")
7
Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
8
Signed-off-by: Andrew Jones <drjones@redhat.com>
9
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20201111143440.112763-1-drjones@redhat.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/arm/Kconfig | 1 +
15
1 file changed, 1 insertion(+)
16
17
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/Kconfig
20
+++ b/hw/arm/Kconfig
21
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
22
imply VFIO_PLATFORM
23
imply VFIO_XGMAC
24
imply TPM_TIS_SYSBUS
25
+ select ARM_GIC
26
select ACPI
27
select ARM_SMMUV3
28
select GPIO_KEY
29
--
30
2.20.1
31
32
diff view generated by jsdifflib
Deleted patch
1
From: Alex Chen <alex.chen@huawei.com>
2
1
3
We should use printf format specifier "%u" instead of "%d" for
4
argument of type "unsigned int".
5
6
Reported-by: Euler Robot <euler.robot@huawei.com>
7
Signed-off-by: Alex Chen <alex.chen@huawei.com>
8
Message-id: 20201111073651.72804-1-alex.chen@huawei.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/timer/exynos4210_mct.c | 4 ++--
13
hw/timer/exynos4210_pwm.c | 8 ++++----
14
2 files changed, 6 insertions(+), 6 deletions(-)
15
16
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/timer/exynos4210_mct.c
19
+++ b/hw/timer/exynos4210_mct.c
20
@@ -XXX,XX +XXX,XX @@ static void exynos4210_gcomp_raise_irq(void *opaque, uint32_t id)
21
/* If CSTAT is pending and IRQ is enabled */
22
if ((s->reg.int_cstat & G_INT_CSTAT_COMP(id)) &&
23
(s->reg.int_enb & G_INT_ENABLE(id))) {
24
- DPRINTF("gcmp timer[%d] IRQ\n", id);
25
+ DPRINTF("gcmp timer[%u] IRQ\n", id);
26
qemu_irq_raise(s->irq[id]);
27
}
28
}
29
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s)
30
MCT_CFG_GET_DIVIDER(s->reg_mct_cfg));
31
32
if (freq != s->freq) {
33
- DPRINTF("freq=%dHz\n", s->freq);
34
+ DPRINTF("freq=%uHz\n", s->freq);
35
36
/* global timer */
37
tx_ptimer_set_freq(s->g_timer.ptimer_frc, s->freq);
38
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/timer/exynos4210_pwm.c
41
+++ b/hw/timer/exynos4210_pwm.c
42
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_update_freq(Exynos4210PWMState *s, uint32_t id)
43
44
if (freq != s->timer[id].freq) {
45
ptimer_set_freq(s->timer[id].ptimer, s->timer[id].freq);
46
- DPRINTF("freq=%dHz\n", s->timer[id].freq);
47
+ DPRINTF("freq=%uHz\n", s->timer[id].freq);
48
}
49
}
50
51
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
52
uint32_t id = s->id;
53
bool cmp;
54
55
- DPRINTF("timer %d tick\n", id);
56
+ DPRINTF("timer %u tick\n", id);
57
58
/* set irq status */
59
p->reg_tint_cstat |= TINT_CSTAT_STATUS(id);
60
61
/* raise IRQ */
62
if (p->reg_tint_cstat & TINT_CSTAT_ENABLE(id)) {
63
- DPRINTF("timer %d IRQ\n", id);
64
+ DPRINTF("timer %u IRQ\n", id);
65
qemu_irq_raise(p->timer[id].irq);
66
}
67
68
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
69
}
70
71
if (cmp) {
72
- DPRINTF("auto reload timer %d count to %x\n", id,
73
+ DPRINTF("auto reload timer %u count to %x\n", id,
74
p->timer[id].reg_tcntb);
75
ptimer_set_count(p->timer[id].ptimer, p->timer[id].reg_tcntb);
76
ptimer_run(p->timer[id].ptimer, 1);
77
--
78
2.20.1
79
80
diff view generated by jsdifflib
1
The TMP105 datasheet says that in Interrupt Mode (when TM==1) the device
1
In test_rx() and test_tx() we allocate a GString *cmd_line
2
signals an alert when the temperature equals or exceeds the T_high value and
2
but never free it. This is pretty harmless in a test case, but
3
then remains high until a device register is read or the device responds to
3
Coverity spotted it.
4
the SMBUS Alert Response address, or the device is put into Shutdown Mode.
5
Thereafter the Alert pin will only be re-signalled when temperature falls
6
below T_low; alert can then be cleared in the same set of ways, and the
7
device returns to its initial "alert when temperature goes above T_high"
8
mode. (If this textual description is confusing, see figure 3 in the
9
TI datasheet at https://www.ti.com/lit/gpn/tmp105 .)
10
4
11
We were misimplementing this as a simple "always alert if temperature is
5
Resolves: Coverity CID 1507122
12
above T_high or below T_low" condition, which gives a spurious alert on
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
startup if using the "T_high = 80 degrees C, T_low = 75 degrees C" reset
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
limit values.
8
Reviewed-by: Thomas Huth <thuth@redhat.com>
9
Message-id: 20240312183810.557768-2-peter.maydell@linaro.org
10
---
11
tests/qtest/npcm7xx_emc-test.c | 4 ++--
12
1 file changed, 2 insertions(+), 2 deletions(-)
15
13
16
Implement the correct (hysteresis) behaviour by tracking whether we
14
diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
17
are currently looking for the temperature to rise over T_high or
18
for it to fall below T_low. Our implementation of the comparator
19
mode (TM==0) wasn't wrong, but rephrase it to match the way that
20
interrupt mode is now handled for clarity.
21
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Reviewed-by: Cédric Le Goater <clg@kaod.org>
24
Message-id: 20201110150023.25533-3-peter.maydell@linaro.org
25
---
26
hw/misc/tmp105.h | 7 +++++
27
hw/misc/tmp105.c | 70 +++++++++++++++++++++++++++++++++++++++++-------
28
2 files changed, 68 insertions(+), 9 deletions(-)
29
30
diff --git a/hw/misc/tmp105.h b/hw/misc/tmp105.h
31
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/misc/tmp105.h
16
--- a/tests/qtest/npcm7xx_emc-test.c
33
+++ b/hw/misc/tmp105.h
17
+++ b/tests/qtest/npcm7xx_emc-test.c
34
@@ -XXX,XX +XXX,XX @@ struct TMP105State {
18
@@ -XXX,XX +XXX,XX @@ static void emc_test_ptle(QTestState *qts, const EMCModule *mod, int fd)
35
int16_t limit[2];
19
static void test_tx(gconstpointer test_data)
36
int faults;
20
{
37
uint8_t alarm;
21
const TestData *td = test_data;
38
+ /*
22
- GString *cmd_line = g_string_new("-machine quanta-gsj");
39
+ * The TMP105 initially looks for a temperature rising above T_high;
23
+ g_autoptr(GString) cmd_line = g_string_new("-machine quanta-gsj");
40
+ * once this is detected, the condition it looks for next is the
24
int *test_sockets = packet_test_init(emc_module_index(td->module),
41
+ * temperature falling below T_low. This flag is false when initially
25
cmd_line);
42
+ * looking for T_high, true when looking for T_low.
26
QTestState *qts = qtest_init(cmd_line->str);
43
+ */
27
@@ -XXX,XX +XXX,XX @@ static void test_tx(gconstpointer test_data)
44
+ bool detect_falling;
28
static void test_rx(gconstpointer test_data)
45
};
29
{
46
30
const TestData *td = test_data;
47
#endif
31
- GString *cmd_line = g_string_new("-machine quanta-gsj");
48
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
32
+ g_autoptr(GString) cmd_line = g_string_new("-machine quanta-gsj");
49
index XXXXXXX..XXXXXXX 100644
33
int *test_sockets = packet_test_init(emc_module_index(td->module),
50
--- a/hw/misc/tmp105.c
34
cmd_line);
51
+++ b/hw/misc/tmp105.c
35
QTestState *qts = qtest_init(cmd_line->str);
52
@@ -XXX,XX +XXX,XX @@ static void tmp105_alarm_update(TMP105State *s)
53
return;
54
}
55
56
- if ((s->config >> 1) & 1) {                    /* TM */
57
- if (s->temperature >= s->limit[1])
58
- s->alarm = 1;
59
- else if (s->temperature < s->limit[0])
60
- s->alarm = 1;
61
+ if (s->config >> 1 & 1) {
62
+ /*
63
+ * TM == 1 : Interrupt mode. We signal Alert when the
64
+ * temperature rises above T_high, and expect the guest to clear
65
+ * it (eg by reading a device register).
66
+ */
67
+ if (s->detect_falling) {
68
+ if (s->temperature < s->limit[0]) {
69
+ s->alarm = 1;
70
+ s->detect_falling = false;
71
+ }
72
+ } else {
73
+ if (s->temperature >= s->limit[1]) {
74
+ s->alarm = 1;
75
+ s->detect_falling = true;
76
+ }
77
+ }
78
} else {
79
- if (s->temperature >= s->limit[1])
80
- s->alarm = 1;
81
- else if (s->temperature < s->limit[0])
82
- s->alarm = 0;
83
+ /*
84
+ * TM == 0 : Comparator mode. We signal Alert when the temperature
85
+ * rises above T_high, and stop signalling it when the temperature
86
+ * falls below T_low.
87
+ */
88
+ if (s->detect_falling) {
89
+ if (s->temperature < s->limit[0]) {
90
+ s->alarm = 0;
91
+ s->detect_falling = false;
92
+ }
93
+ } else {
94
+ if (s->temperature >= s->limit[1]) {
95
+ s->alarm = 1;
96
+ s->detect_falling = true;
97
+ }
98
+ }
99
}
100
101
tmp105_interrupt_update(s);
102
@@ -XXX,XX +XXX,XX @@ static int tmp105_post_load(void *opaque, int version_id)
103
return 0;
104
}
105
106
+static bool detect_falling_needed(void *opaque)
107
+{
108
+ TMP105State *s = opaque;
109
+
110
+ /*
111
+ * We only need to migrate the detect_falling bool if it's set;
112
+ * for migration from older machines we assume that it is false
113
+ * (ie temperature is not out of range).
114
+ */
115
+ return s->detect_falling;
116
+}
117
+
118
+static const VMStateDescription vmstate_tmp105_detect_falling = {
119
+ .name = "TMP105/detect-falling",
120
+ .version_id = 1,
121
+ .minimum_version_id = 1,
122
+ .needed = detect_falling_needed,
123
+ .fields = (VMStateField[]) {
124
+ VMSTATE_BOOL(detect_falling, TMP105State),
125
+ VMSTATE_END_OF_LIST()
126
+ }
127
+};
128
+
129
static const VMStateDescription vmstate_tmp105 = {
130
.name = "TMP105",
131
.version_id = 0,
132
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_tmp105 = {
133
VMSTATE_UINT8(alarm, TMP105State),
134
VMSTATE_I2C_SLAVE(i2c, TMP105State),
135
VMSTATE_END_OF_LIST()
136
+ },
137
+ .subsections = (const VMStateDescription*[]) {
138
+ &vmstate_tmp105_detect_falling,
139
+ NULL
140
}
141
};
142
143
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
144
s->config = 0;
145
s->faults = tmp105_faultq[(s->config >> 3) & 3];
146
s->alarm = 0;
147
+ s->detect_falling = false;
148
149
s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
150
s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
151
--
36
--
152
2.20.1
37
2.34.1
153
154
diff view generated by jsdifflib
1
In commit 76346b6264a9b01979 we tried to add a configure check that
1
In socket_check_afunix_support() we call socket(PF_UNIX, SOCK_STREAM, 0)
2
the libgio pkg-config data was correct, which builds an executable
2
to see if it works, but we call close() on the result whether it
3
linked against it. Unfortunately this doesn't catch the problem
3
worked or not. Only close the fd if the socket() call succeeded.
4
(missing static library dependency info), because a "do nothing" test
4
Spotted by Coverity.
5
source file doesn't have any symbol references that cause the linker
6
to pull in .o files from libgio.a, and so we don't see the "missing
7
symbols from libmount" error that a full QEMU link triggers.
8
5
9
(The ineffective test went unnoticed because of a typo that
6
Resolves: Coverity CID 1497481
10
effectively disabled libgio unconditionally, but after commit
11
3569a5dfc11f2 fixed that, a static link of the system emulator on
12
Ubuntu stopped working again.)
13
14
Improve the gio test by having the test source fragment reference a
15
g_dbus function (which is what is indirectly causing us to end up
16
wanting functions from libmount).
17
7
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20201116104617.18333-1-peter.maydell@linaro.org
10
Reviewed-by: Thomas Huth <thuth@redhat.com>
11
Message-id: 20240312183810.557768-3-peter.maydell@linaro.org
21
---
12
---
22
configure | 11 +++++++++--
13
tests/unit/socket-helpers.c | 4 +++-
23
1 file changed, 9 insertions(+), 2 deletions(-)
14
1 file changed, 3 insertions(+), 1 deletion(-)
24
15
25
diff --git a/configure b/configure
16
diff --git a/tests/unit/socket-helpers.c b/tests/unit/socket-helpers.c
26
index XXXXXXX..XXXXXXX 100755
17
index XXXXXXX..XXXXXXX 100644
27
--- a/configure
18
--- a/tests/unit/socket-helpers.c
28
+++ b/configure
19
+++ b/tests/unit/socket-helpers.c
29
@@ -XXX,XX +XXX,XX @@ if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
20
@@ -XXX,XX +XXX,XX @@ void socket_check_afunix_support(bool *has_afunix)
30
# Check that the libraries actually work -- Ubuntu 18.04 ships
21
int fd;
31
# with pkg-config --static --libs data for gio-2.0 that is missing
22
32
# -lblkid and will give a link error.
23
fd = socket(PF_UNIX, SOCK_STREAM, 0);
33
- write_c_skeleton
24
- close(fd);
34
- if compile_prog "" "$gio_libs" ; then
25
35
+ cat > $TMPC <<EOF
26
#ifdef _WIN32
36
+#include <gio/gio.h>
27
*has_afunix = (fd != (int)INVALID_SOCKET);
37
+int main(void)
28
@@ -XXX,XX +XXX,XX @@ void socket_check_afunix_support(bool *has_afunix)
38
+{
29
*has_afunix = (fd >= 0);
39
+ g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
30
#endif
40
+ return 0;
31
41
+}
32
+ if (*has_afunix) {
42
+EOF
33
+ close(fd);
43
+ if compile_prog "$gio_cflags" "$gio_libs" ; then
34
+ }
44
gio=yes
35
return;
45
else
36
}
46
gio=no
47
--
37
--
48
2.20.1
38
2.34.1
49
50
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
In net_init_af_xdp() we parse the arguments and allocate
2
a buffer of ints into sock_fds. However, although we
3
free this in the error exit path, we don't ever free it
4
in the successful return path. Coverity spots this leak.
2
5
3
Fix Coverity CID 1435957: Memory - illegal accesses (OVERRUN):
6
Switch to g_autofree so we don't need to manually free the
7
array.
4
8
5
>>> Overrunning array "suffixes" of 7 8-byte elements at element
9
Resolves: Coverity CID 1534906
6
index 7 (byte offset 63) using index "idx" (which evaluates to 7).
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Thomas Huth <thuth@redhat.com>
13
Message-id: 20240312183810.557768-4-peter.maydell@linaro.org
14
---
15
net/af-xdp.c | 3 +--
16
1 file changed, 1 insertion(+), 2 deletions(-)
7
17
8
Note, the biggest input value freq_to_str() can accept is UINT64_MAX,
18
diff --git a/net/af-xdp.c b/net/af-xdp.c
9
which is ~18.446 EHz, less than 1000 EHz.
10
11
Reported-by: Eduardo Habkost <ehabkost@redhat.com>
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
15
Reviewed-by: Luc Michel <luc@lmichel.fr>
16
Message-id: 20201101215755.2021421-1-f4bug@amsat.org
17
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
util/cutils.c | 3 ++-
22
1 file changed, 2 insertions(+), 1 deletion(-)
23
24
diff --git a/util/cutils.c b/util/cutils.c
25
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
26
--- a/util/cutils.c
20
--- a/net/af-xdp.c
27
+++ b/util/cutils.c
21
+++ b/net/af-xdp.c
28
@@ -XXX,XX +XXX,XX @@ char *freq_to_str(uint64_t freq_hz)
22
@@ -XXX,XX +XXX,XX @@ int net_init_af_xdp(const Netdev *netdev,
29
double freq = freq_hz;
23
NetClientState *nc, *nc0 = NULL;
30
size_t idx = 0;
24
unsigned int ifindex;
31
25
uint32_t prog_id = 0;
32
- while (freq >= 1000.0 && idx < ARRAY_SIZE(suffixes)) {
26
- int *sock_fds = NULL;
33
+ while (freq >= 1000.0) {
27
+ g_autofree int *sock_fds = NULL;
34
freq /= 1000.0;
28
int64_t i, queues;
35
idx++;
29
Error *err = NULL;
30
AFXDPState *s;
31
@@ -XXX,XX +XXX,XX @@ int net_init_af_xdp(const Netdev *netdev,
32
return 0;
33
34
err:
35
- g_free(sock_fds);
36
if (nc0) {
37
qemu_del_net_client(nc0);
36
}
38
}
37
+ assert(idx < ARRAY_SIZE(suffixes));
38
39
return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]);
40
}
41
--
39
--
42
2.20.1
40
2.34.1
43
44
diff view generated by jsdifflib
1
From: Alistair Francis <alistair.francis@wdc.com>
1
In pca9554_get_pin() and pca9554_set_pin(), we try to detect an
2
incorrect pin value, but we get the condition wrong, using ">"
3
when ">=" was intended.
2
4
3
This patch fixes CID 1432800 by removing an unnecessary check.
5
This has no actual effect, because in pca9554_initfn() we
6
use the correct test when creating the properties and so
7
we'll never be called with an out of range value. However,
8
Coverity complains about the mismatch between the check and
9
the later use of the pin value in a shift operation.
4
10
5
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
11
Use the correct condition.
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
13
Resolves: Coverity CID 1534917
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Thomas Huth <thuth@redhat.com>
17
Message-id: 20240312183810.557768-5-peter.maydell@linaro.org
8
---
18
---
9
hw/core/register.c | 4 ----
19
hw/misc/pca9554.c | 4 ++--
10
1 file changed, 4 deletions(-)
20
1 file changed, 2 insertions(+), 2 deletions(-)
11
21
12
diff --git a/hw/core/register.c b/hw/core/register.c
22
diff --git a/hw/misc/pca9554.c b/hw/misc/pca9554.c
13
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/core/register.c
24
--- a/hw/misc/pca9554.c
15
+++ b/hw/core/register.c
25
+++ b/hw/misc/pca9554.c
16
@@ -XXX,XX +XXX,XX @@ static RegisterInfoArray *register_init_block(DeviceState *owner,
26
@@ -XXX,XX +XXX,XX @@ static void pca9554_get_pin(Object *obj, Visitor *v, const char *name,
17
int index = rae[i].addr / data_size;
27
error_setg(errp, "%s: error reading %s", __func__, name);
18
RegisterInfo *r = &ri[index];
28
return;
19
29
}
20
- if (data + data_size * index == 0 || !&rae[i]) {
30
- if (pin < 0 || pin > PCA9554_PIN_COUNT) {
21
- continue;
31
+ if (pin < 0 || pin >= PCA9554_PIN_COUNT) {
22
- }
32
error_setg(errp, "%s invalid pin %s", __func__, name);
23
-
33
return;
24
/* Init the register, this will zero it. */
34
}
25
object_initialize((void *)r, sizeof(*r), TYPE_REGISTER);
35
@@ -XXX,XX +XXX,XX @@ static void pca9554_set_pin(Object *obj, Visitor *v, const char *name,
26
36
error_setg(errp, "%s: error reading %s", __func__, name);
37
return;
38
}
39
- if (pin < 0 || pin > PCA9554_PIN_COUNT) {
40
+ if (pin < 0 || pin >= PCA9554_PIN_COUNT) {
41
error_setg(errp, "%s invalid pin %s", __func__, name);
42
return;
43
}
27
--
44
--
28
2.20.1
45
2.34.1
29
30
diff view generated by jsdifflib
1
The TMP105 datasheet (https://www.ti.com/lit/gpn/tmp105) says that the
1
There's no way for the macio_nvram device to report failure to write
2
power-up reset values for the T_low and T_high registers are 80 degrees C
2
data, but we can at least report it to the user with error_report()
3
and 75 degrees C, which are 0x500 and 0x4B0 hex according to table 5. These
3
as we do in other devices like xlnx-efuse.
4
values are then shifted right by four bits to give the register reset
5
values, since both registers store the 12 bits of temperature data in bits
6
[15..4] of a 16 bit register.
7
4
8
We were resetting these registers to zero, which is problematic for Linux
5
Spotted by Coverity.
9
guests which enable the alert interrupt and then immediately take an
10
unexpected overtemperature alert because the current temperature is above
11
freezing...
12
6
7
Resolves: Coverity CID 1507628
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20201110150023.25533-2-peter.maydell@linaro.org
10
Reviewed-by: Thomas Huth <thuth@redhat.com>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Message-id: 20240312183810.557768-6-peter.maydell@linaro.org
16
---
13
---
17
hw/misc/tmp105.c | 3 +++
14
hw/nvram/mac_nvram.c | 5 ++++-
18
1 file changed, 3 insertions(+)
15
1 file changed, 4 insertions(+), 1 deletion(-)
19
16
20
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
17
diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
21
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/misc/tmp105.c
19
--- a/hw/nvram/mac_nvram.c
23
+++ b/hw/misc/tmp105.c
20
+++ b/hw/nvram/mac_nvram.c
24
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
21
@@ -XXX,XX +XXX,XX @@ static void macio_nvram_writeb(void *opaque, hwaddr addr,
25
s->faults = tmp105_faultq[(s->config >> 3) & 3];
22
trace_macio_nvram_write(addr, value);
26
s->alarm = 0;
23
s->data[addr] = value;
27
24
if (s->blk) {
28
+ s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
25
- blk_pwrite(s->blk, addr, 1, &s->data[addr], 0);
29
+ s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
26
+ if (blk_pwrite(s->blk, addr, 1, &s->data[addr], 0) < 0) {
30
+
27
+ error_report("%s: write of NVRAM data to backing store failed",
31
tmp105_interrupt_update(s);
28
+ blk_name(s->blk));
29
+ }
30
}
32
}
31
}
33
32
34
--
33
--
35
2.20.1
34
2.34.1
36
35
37
36
diff view generated by jsdifflib
1
In commit 5edab03d4040 we added tracepoints to the ps2 keyboard
1
In test_compute_wait() we do
2
and mouse emulation. However we didn't remove all the debug-by-printf
2
double units = bkt.max / 10;
3
support. In fact there is only one printf() remaining, and it is
3
which does an integer division and then assigns it to a double variable,
4
redundant with the trace_ps2_write_mouse() event next to it.
4
and similarly later on in the expression for an assertion.
5
Remove the printf() and the now-unused DEBUG* macros.
6
5
6
Use 10.0 so that we do a floating point division and calculate the
7
exact value, rather than doing an integer division.
8
9
Spotted by Coverity.
10
11
Resolves: Coverity CID 1432564
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
14
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
Message-id: 20201101133258.4240-1-peter.maydell@linaro.org
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
Message-id: 20240312183810.557768-7-peter.maydell@linaro.org
11
---
17
---
12
hw/input/ps2.c | 9 ---------
18
tests/unit/test-throttle.c | 4 ++--
13
1 file changed, 9 deletions(-)
19
1 file changed, 2 insertions(+), 2 deletions(-)
14
20
15
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
21
diff --git a/tests/unit/test-throttle.c b/tests/unit/test-throttle.c
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/input/ps2.c
23
--- a/tests/unit/test-throttle.c
18
+++ b/hw/input/ps2.c
24
+++ b/tests/unit/test-throttle.c
19
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@ static void test_compute_wait(void)
20
26
bkt.avg = 10;
21
#include "trace.h"
27
bkt.max = 200;
22
28
for (i = 0; i < 22; i++) {
23
-/* debug PC keyboard */
29
- double units = bkt.max / 10;
24
-//#define DEBUG_KBD
30
+ double units = bkt.max / 10.0;
25
-
31
bkt.level += units;
26
-/* debug PC keyboard : only mouse */
32
bkt.burst_level += units;
27
-//#define DEBUG_MOUSE
33
throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 10);
28
-
34
wait = throttle_compute_wait(&bkt);
29
/* Keyboard Commands */
35
g_assert(double_cmp(bkt.burst_level, 0));
30
#define KBD_CMD_SET_LEDS    0xED    /* Set keyboard leds */
36
- g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10));
31
#define KBD_CMD_ECHO     0xEE
37
+ g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10.0));
32
@@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(void *opaque, int val)
38
/* We can do bursts for the 2 seconds we have configured in
33
PS2MouseState *s = (PS2MouseState *)opaque;
39
* burst_length. We have 100 extra milliseconds of burst
34
40
* because bkt.level has been leaking during this time.
35
trace_ps2_write_mouse(opaque, val);
36
-#ifdef DEBUG_MOUSE
37
- printf("kbd: write mouse 0x%02x\n", val);
38
-#endif
39
switch(s->common.write_cmd) {
40
default:
41
case -1:
42
--
41
--
43
2.20.1
42
2.34.1
44
43
45
44
diff view generated by jsdifflib
1
In the mtspr helper we attempt to check for "is the timer disabled"
1
Coverity points out that g_setenv() can fail and we don't
2
with "if (env->ttmr & TIMER_NONE)". This is wrong because TIMER_NONE
2
check for this in qtest_inproc_init(). In practice this will
3
is zero and the condition is always false (Coverity complains about
3
only fail if a memory allocation failed in setenv() or if
4
the dead code.)
4
the caller passed an invalid architecture name (e.g. one
5
with an '=' in it), so rather than requiring the callsite
6
to check for failure, make g_setenv() failure fatal here,
7
similarly to what we did in commit aca68d95c515.
5
8
6
The correct check would be to test whether the TTMR_M field in the
9
Resolves: Coverity CID 1497485
7
register is equal to TIMER_NONE instead. However, the
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
cpu_openrisc_timer_update() function checks whether the timer is
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
enabled (it looks at cpu->env.is_counting, which is set to 0 via
12
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
cpu_openrisc_count_stop() when the TTMR_M field is set to
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
TIMER_NONE), so there's no need to check for "timer disabled" in the
14
Message-id: 20240312183810.557768-8-peter.maydell@linaro.org
12
target/openrisc code. Instead, simply remove the dead code.
15
---
16
tests/qtest/libqtest.c | 6 +++++-
17
1 file changed, 5 insertions(+), 1 deletion(-)
13
18
14
Fixes: Coverity CID 1005812
19
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Acked-by: Stafford Horne <shorne@gmail.com>
17
Message-id: 20201103114654.18540-1-peter.maydell@linaro.org
18
---
19
target/openrisc/sys_helper.c | 3 ---
20
1 file changed, 3 deletions(-)
21
22
diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c
23
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
24
--- a/target/openrisc/sys_helper.c
21
--- a/tests/qtest/libqtest.c
25
+++ b/target/openrisc/sys_helper.c
22
+++ b/tests/qtest/libqtest.c
26
@@ -XXX,XX +XXX,XX @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)
23
@@ -XXX,XX +XXX,XX @@ QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch,
27
24
* way, qtest_get_arch works for inproc qtest.
28
case TO_SPR(10, 1): /* TTCR */
25
*/
29
cpu_openrisc_count_set(cpu, rb);
26
gchar *bin_path = g_strconcat("/qemu-system-", arch, NULL);
30
- if (env->ttmr & TIMER_NONE) {
27
- g_setenv("QTEST_QEMU_BINARY", bin_path, 0);
31
- return;
28
+ if (!g_setenv("QTEST_QEMU_BINARY", bin_path, 0)) {
32
- }
29
+ fprintf(stderr,
33
cpu_openrisc_timer_update(cpu);
30
+ "Could not set environment variable QTEST_QEMU_BINARY\n");
34
break;
31
+ exit(1);
35
#endif
32
+ }
33
g_free(bin_path);
34
35
return qts;
36
--
36
--
37
2.20.1
37
2.34.1
38
38
39
39
diff view generated by jsdifflib