1
Arm queue; bugfixes only.
1
Nothing exciting here: two minor bug fixes, some fixes for
2
running on a 32-bit host, and a docs tweak.
2
3
3
thanks
4
thanks
4
-- PMM
5
-- PMM
5
6
6
The following changes since commit 48aa8f0ac536db3550a35c295ff7de94e4c33739:
7
The following changes since commit 6af9d12c88b9720f209912f6e4b01fefe5906d59:
7
8
8
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-11-16' into staging (2020-11-17 11:07:00 +0000)
9
Merge tag 'migration-20240331-pull-request' of https://gitlab.com/peterx/qemu into staging (2024-04-01 13:12:40 +0100)
9
10
10
are available in the Git repository at:
11
are available in the Git repository at:
11
12
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201117
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240402
13
14
14
for you to fetch changes up to ab135622cf478585bdfcb68b85e4a817d74a0c42:
15
for you to fetch changes up to 393770d7a02135e7468018f52da610712f151ec0:
15
16
16
tmp105: Correct handling of temperature limit checks (2020-11-17 12:56:33 +0000)
17
raspi4b: Reduce RAM to 1Gb on 32-bit hosts (2024-04-02 10:13:48 +0100)
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
target-arm queue:
20
target-arm queue:
20
* hw/arm/virt: ARM_VIRT must select ARM_GIC
21
* take HSTR traps of cp15 accesses to EL2, not EL1
21
* exynos: Fix bad printf format specifiers
22
* docs: sbsa: update specs, add dt note
22
* hw/input/ps2.c: Remove remnants of printf debug
23
* hw/intc/arm_gicv3: ICC_HPPIR* return SPURIOUS if int group is disabled
23
* target/openrisc: Remove dead code attempting to check "is timer disabled"
24
* tests/qtest: Fix STM32L4x5 GPIO test on 32-bit
24
* register: Remove unnecessary NULL check
25
* raspi4b: Reduce RAM to 1Gb on 32-bit hosts
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
26
30
----------------------------------------------------------------
27
----------------------------------------------------------------
31
Alex Chen (1):
28
Cédric Le Goater (2):
32
exynos: Fix bad printf format specifiers
29
tests/qtest: Fix STM32L4x5 GPIO test on 32-bit
30
raspi4b: Reduce RAM to 1Gb on 32-bit hosts
33
31
34
Alistair Francis (1):
32
Marcin Juszkiewicz (1):
35
register: Remove unnecessary NULL check
33
docs: sbsa: update specs, add dt note
36
34
37
Andrew Jones (1):
35
Peter Maydell (2):
38
hw/arm/virt: ARM_VIRT must select ARM_GIC
36
target/arm: take HSTR traps of cp15 accesses to EL2, not EL1
37
hw/intc/arm_gicv3: ICC_HPPIR* return SPURIOUS if int group is disabled
39
38
40
Peter Maydell (5):
39
docs/system/arm/sbsa.rst | 35 +++++++++++++++++------
41
hw/input/ps2.c: Remove remnants of printf debug
40
hw/arm/raspi4b.c | 4 +++
42
target/openrisc: Remove dead code attempting to check "is timer disabled"
41
hw/intc/arm_gicv3_cpuif.c | 4 +--
43
configure: Make "does libgio work" test pull in some actual functions
42
target/arm/tcg/translate.c | 2 +-
44
hw/misc/tmp105: reset the T_low and T_High registers
43
tests/qtest/stm32l4x5_gpio-test.c | 59 +++++++++++++++++++++++----------------
45
tmp105: Correct handling of temperature limit checks
44
5 files changed, 68 insertions(+), 36 deletions(-)
46
45
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
1
The TMP105 datasheet (https://www.ti.com/lit/gpn/tmp105) says that the
1
The HSTR_EL2 register allows the hypervisor to trap AArch32 EL1 and
2
power-up reset values for the T_low and T_high registers are 80 degrees C
2
EL0 accesses to cp15 registers. We incorrectly implemented this so
3
and 75 degrees C, which are 0x500 and 0x4B0 hex according to table 5. These
3
they trap to EL1 when we detect the need for a HSTR trap at code
4
values are then shifted right by four bits to give the register reset
4
generation time. (The check in access_check_cp_reg() which we do at
5
values, since both registers store the 12 bits of temperature data in bits
5
runtime to catch traps from EL0 is correctly routing them to EL2.)
6
[15..4] of a 16 bit register.
7
6
8
We were resetting these registers to zero, which is problematic for Linux
7
Use the correct target EL when generating the code to take the trap.
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
8
9
Cc: qemu-stable@nongnu.org
10
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2226
11
Fixes: 049edada5e93df ("target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1")
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20201110150023.25533-2-peter.maydell@linaro.org
14
Message-id: 20240325133116.2075362-1-peter.maydell@linaro.org
16
---
15
---
17
hw/misc/tmp105.c | 3 +++
16
target/arm/tcg/translate.c | 2 +-
18
1 file changed, 3 insertions(+)
17
1 file changed, 1 insertion(+), 1 deletion(-)
19
18
20
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
19
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
21
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/misc/tmp105.c
21
--- a/target/arm/tcg/translate.c
23
+++ b/hw/misc/tmp105.c
22
+++ b/target/arm/tcg/translate.c
24
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
23
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
25
s->faults = tmp105_faultq[(s->config >> 3) & 3];
24
tcg_gen_andi_i32(t, t, 1u << maskbit);
26
s->alarm = 0;
25
tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label);
27
26
28
+ s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
27
- gen_exception_insn(s, 0, EXCP_UDEF, syndrome);
29
+ s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
28
+ gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2);
30
+
29
/*
31
tmp105_interrupt_update(s);
30
* gen_exception_insn() will set is_jmp to DISAS_NORETURN,
32
}
31
* but since we're conditionally branching over it, we want
33
34
--
32
--
35
2.20.1
33
2.34.1
36
37
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
2
2
3
Fix Coverity CID 1435957: Memory - illegal accesses (OVERRUN):
3
Hardware of sbsa-ref board is nowadays defined by both BSA and SBSA
4
specifications. Then BBR defines firmware interface.
4
5
5
>>> Overrunning array "suffixes" of 7 8-byte elements at element
6
Added note about DeviceTree data passed from QEMU to firmware. It is
6
index 7 (byte offset 63) using index "idx" (which evaluates to 7).
7
very minimal and provides only data we use in firmware.
7
8
8
Note, the biggest input value freq_to_str() can accept is UINT64_MAX,
9
Added NUMA information to list of things reported by DeviceTree.
9
which is ~18.446 EHz, less than 1000 EHz.
10
10
11
Reported-by: Eduardo Habkost <ehabkost@redhat.com>
11
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Message-id: 20240328163851.1386176-1-marcin.juszkiewicz@linaro.org
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
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>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
15
---
21
util/cutils.c | 3 ++-
16
docs/system/arm/sbsa.rst | 35 ++++++++++++++++++++++++++---------
22
1 file changed, 2 insertions(+), 1 deletion(-)
17
1 file changed, 26 insertions(+), 9 deletions(-)
23
18
24
diff --git a/util/cutils.c b/util/cutils.c
19
diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst
25
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
26
--- a/util/cutils.c
21
--- a/docs/system/arm/sbsa.rst
27
+++ b/util/cutils.c
22
+++ b/docs/system/arm/sbsa.rst
28
@@ -XXX,XX +XXX,XX @@ char *freq_to_str(uint64_t freq_hz)
23
@@ -XXX,XX +XXX,XX @@
29
double freq = freq_hz;
24
Arm Server Base System Architecture Reference board (``sbsa-ref``)
30
size_t idx = 0;
25
==================================================================
31
26
32
- while (freq >= 1000.0 && idx < ARRAY_SIZE(suffixes)) {
27
-While the ``virt`` board is a generic board platform that doesn't match
33
+ while (freq >= 1000.0) {
28
-any real hardware the ``sbsa-ref`` board intends to look like real
34
freq /= 1000.0;
29
-hardware. The `Server Base System Architecture
35
idx++;
30
-<https://developer.arm.com/documentation/den0029/latest>`_ defines a
36
}
31
-minimum base line of hardware support and importantly how the firmware
37
+ assert(idx < ARRAY_SIZE(suffixes));
32
-reports that to any operating system.
38
33
+The ``sbsa-ref`` board intends to look like real hardware (while the ``virt``
39
return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]);
34
+board is a generic board platform that doesn't match any real hardware).
40
}
35
+
36
+The hardware part is defined by two specifications:
37
+
38
+ - `Base System Architecture <https://developer.arm.com/documentation/den0094/>`__ (BSA)
39
+ - `Server Base System Architecture <https://developer.arm.com/documentation/den0029/>`__ (SBSA)
40
+
41
+The `Arm Base Boot Requirements <https://developer.arm.com/documentation/den0044/>`__ (BBR)
42
+specification defines how the firmware reports that to any operating system.
43
44
It is intended to be a machine for developing firmware and testing
45
standards compliance with operating systems.
46
@@ -XXX,XX +XXX,XX @@ includes both internal hardware and parts affected by the qemu command line
47
(i.e. CPUs and memory). As a result it must have a firmware specifically built
48
to expect a certain hardware layout (as you would in a real machine).
49
50
+Note
51
+''''
52
+
53
+QEMU provides the guest EL3 firmware with minimal information about hardware
54
+platform using minimalistic devicetree. This is not a Linux devicetree. It is
55
+not even a firmware devicetree.
56
+
57
+It is information passed from QEMU to describe the information a hardware
58
+platform would have other mechanisms to discover at runtime, that are affected
59
+by the QEMU command line.
60
+
61
+Ultimately this devicetree may be replaced by IPC calls to an emulated SCP.
62
+
63
DeviceTree information
64
''''''''''''''''''''''
65
66
-The devicetree provided by the board model to the firmware is not intended
67
-to be a complete compliant DT. It currently reports:
68
+The devicetree reports:
69
70
- CPUs
71
- memory
72
- platform version
73
- GIC addresses
74
+ - NUMA node id for CPUs and memory
75
76
Platform version
77
''''''''''''''''
78
@@ -XXX,XX +XXX,XX @@ Platform version changes:
79
GIC ITS information is present in devicetree.
80
81
0.3
82
- The USB controller is an XHCI device, not EHCI
83
+ The USB controller is an XHCI device, not EHCI.
41
--
84
--
42
2.20.1
85
2.34.1
43
44
diff view generated by jsdifflib
1
The TMP105 datasheet says that in Interrupt Mode (when TM==1) the device
1
If the group of the highest priority pending interrupt is disabled
2
signals an alert when the temperature equals or exceeds the T_high value and
2
via ICC_IGRPEN*, the ICC_HPPIR* registers should return
3
then remains high until a device register is read or the device responds to
3
INTID_SPURIOUS, not the interrupt ID. (See the GIC architecture
4
the SMBUS Alert Response address, or the device is put into Shutdown Mode.
4
specification pseudocode functions ICC_HPPIR1_EL1[] and
5
Thereafter the Alert pin will only be re-signalled when temperature falls
5
HighestPriorityPendingInterrupt().)
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
6
11
We were misimplementing this as a simple "always alert if temperature is
7
Make HPPIR reads honour the group disable, the way we already do
12
above T_high or below T_low" condition, which gives a spurious alert on
8
when determining whether to preempt in icc_hppi_can_preempt().
13
startup if using the "T_high = 80 degrees C, T_low = 75 degrees C" reset
14
limit values.
15
9
16
Implement the correct (hysteresis) behaviour by tracking whether we
10
Cc: qemu-stable@nongnu.org
17
are currently looking for the temperature to rise over T_high or
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
for it to fall below T_low. Our implementation of the comparator
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
mode (TM==0) wasn't wrong, but rephrase it to match the way that
13
Message-id: 20240328153333.2522667-1-peter.maydell@linaro.org
20
interrupt mode is now handled for clarity.
14
---
15
hw/intc/arm_gicv3_cpuif.c | 4 ++--
16
1 file changed, 2 insertions(+), 2 deletions(-)
21
17
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
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
19
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/misc/tmp105.h
20
--- a/hw/intc/arm_gicv3_cpuif.c
33
+++ b/hw/misc/tmp105.h
21
+++ b/hw/intc/arm_gicv3_cpuif.c
34
@@ -XXX,XX +XXX,XX @@ struct TMP105State {
22
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_hppir0_value(GICv3CPUState *cs, CPUARMState *env)
35
int16_t limit[2];
23
*/
36
int faults;
24
bool irq_is_secure;
37
uint8_t alarm;
25
38
+ /*
26
- if (cs->hppi.prio == 0xff) {
39
+ * The TMP105 initially looks for a temperature rising above T_high;
27
+ if (icc_no_enabled_hppi(cs)) {
40
+ * once this is detected, the condition it looks for next is the
28
return INTID_SPURIOUS;
41
+ * temperature falling below T_low. This flag is false when initially
42
+ * looking for T_high, true when looking for T_low.
43
+ */
44
+ bool detect_falling;
45
};
46
47
#endif
48
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/misc/tmp105.c
51
+++ b/hw/misc/tmp105.c
52
@@ -XXX,XX +XXX,XX @@ static void tmp105_alarm_update(TMP105State *s)
53
return;
54
}
29
}
55
30
56
- if ((s->config >> 1) & 1) {                    /* TM */
31
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_hppir1_value(GICv3CPUState *cs, CPUARMState *env)
57
- if (s->temperature >= s->limit[1])
32
*/
58
- s->alarm = 1;
33
bool irq_is_secure;
59
- else if (s->temperature < s->limit[0])
34
60
- s->alarm = 1;
35
- if (cs->hppi.prio == 0xff) {
61
+ if (s->config >> 1 & 1) {
36
+ if (icc_no_enabled_hppi(cs)) {
62
+ /*
37
return INTID_SPURIOUS;
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
}
38
}
100
39
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
--
40
--
152
2.20.1
41
2.34.1
153
154
diff view generated by jsdifflib
1
From: Alex Chen <alex.chen@huawei.com>
1
From: Cédric Le Goater <clg@redhat.com>
2
2
3
We should use printf format specifier "%u" instead of "%d" for
3
The test mangles the GPIO address and the pin number in the
4
argument of type "unsigned int".
4
qtest_add_data_func data parameter. Doing so, it assumes that the host
5
pointer size is always 64-bit, which breaks on 32-bit :
5
6
6
Reported-by: Euler Robot <euler.robot@huawei.com>
7
../tests/qtest/stm32l4x5_gpio-test.c: In function ‘test_gpio_output_mode’:
7
Signed-off-by: Alex Chen <alex.chen@huawei.com>
8
../tests/qtest/stm32l4x5_gpio-test.c:272:25: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
8
Message-id: 20201111073651.72804-1-alex.chen@huawei.com
9
272 | unsigned int pin = ((uint64_t)data) & 0xF;
10
| ^
11
../tests/qtest/stm32l4x5_gpio-test.c:273:22: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
12
273 | uint32_t gpio = ((uint64_t)data) >> 32;
13
| ^
14
15
To fix, improve the mangling of the GPIO address and pin number fields
16
by using GPIO_SIZE so that the resulting value fits in a 32-bit pointer.
17
While at it, include some helpers to hide the details.
18
19
Cc: Arnaud Minier <arnaud.minier@telecom-paris.fr>
20
Cc: Inès Varhol <ines.varhol@telecom-paris.fr>
21
Signed-off-by: Cédric Le Goater <clg@redhat.com>
22
Message-id: 20240329092747.298259-1-clg@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
23
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
25
---
12
hw/timer/exynos4210_mct.c | 4 ++--
26
tests/qtest/stm32l4x5_gpio-test.c | 59 ++++++++++++++++++-------------
13
hw/timer/exynos4210_pwm.c | 8 ++++----
27
1 file changed, 35 insertions(+), 24 deletions(-)
14
2 files changed, 6 insertions(+), 6 deletions(-)
15
28
16
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
29
diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c
17
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/timer/exynos4210_mct.c
31
--- a/tests/qtest/stm32l4x5_gpio-test.c
19
+++ b/hw/timer/exynos4210_mct.c
32
+++ b/tests/qtest/stm32l4x5_gpio-test.c
20
@@ -XXX,XX +XXX,XX @@ static void exynos4210_gcomp_raise_irq(void *opaque, uint32_t id)
33
@@ -XXX,XX +XXX,XX @@ const uint32_t idr_reset[NUM_GPIOS] = {
21
/* If CSTAT is pending and IRQ is enabled */
34
0x00000000
22
if ((s->reg.int_cstat & G_INT_CSTAT_COMP(id)) &&
35
};
23
(s->reg.int_enb & G_INT_ENABLE(id))) {
36
24
- DPRINTF("gcmp timer[%d] IRQ\n", id);
37
+#define PIN_MASK 0xF
25
+ DPRINTF("gcmp timer[%u] IRQ\n", id);
38
+#define GPIO_ADDR_MASK (~(GPIO_SIZE - 1))
26
qemu_irq_raise(s->irq[id]);
39
+
27
}
40
+static inline void *test_data(uint32_t gpio_addr, uint8_t pin)
28
}
41
+{
29
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s)
42
+ return (void *)(uintptr_t)((gpio_addr & GPIO_ADDR_MASK) | (pin & PIN_MASK));
30
MCT_CFG_GET_DIVIDER(s->reg_mct_cfg));
43
+}
31
44
+
32
if (freq != s->freq) {
45
+#define test_gpio_addr(data) ((uintptr_t)(data) & GPIO_ADDR_MASK)
33
- DPRINTF("freq=%dHz\n", s->freq);
46
+#define test_pin(data) ((uintptr_t)(data) & PIN_MASK)
34
+ DPRINTF("freq=%uHz\n", s->freq);
47
+
35
48
static uint32_t gpio_readl(unsigned int gpio, unsigned int offset)
36
/* global timer */
49
{
37
tx_ptimer_set_freq(s->g_timer.ptimer_frc, s->freq);
50
return readl(gpio + offset);
38
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
51
@@ -XXX,XX +XXX,XX @@ static void test_gpio_output_mode(const void *data)
39
index XXXXXXX..XXXXXXX 100644
52
* Additionally, it checks that values written to ODR
40
--- a/hw/timer/exynos4210_pwm.c
53
* when not in output mode are stored and not discarded.
41
+++ b/hw/timer/exynos4210_pwm.c
54
*/
42
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_update_freq(Exynos4210PWMState *s, uint32_t id)
55
- unsigned int pin = ((uint64_t)data) & 0xF;
43
56
- uint32_t gpio = ((uint64_t)data) >> 32;
44
if (freq != s->timer[id].freq) {
57
+ unsigned int pin = test_pin(data);
45
ptimer_set_freq(s->timer[id].ptimer, s->timer[id].freq);
58
+ uint32_t gpio = test_gpio_addr(data);
46
- DPRINTF("freq=%dHz\n", s->timer[id].freq);
59
unsigned int gpio_id = get_gpio_id(gpio);
47
+ DPRINTF("freq=%uHz\n", s->timer[id].freq);
60
48
}
61
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
49
}
62
@@ -XXX,XX +XXX,XX @@ static void test_gpio_input_mode(const void *data)
50
63
* corresponding GPIO line high/low : it should set the
51
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
64
* right bit in IDR and send an irq to syscfg.
52
uint32_t id = s->id;
65
*/
53
bool cmp;
66
- unsigned int pin = ((uint64_t)data) & 0xF;
54
67
- uint32_t gpio = ((uint64_t)data) >> 32;
55
- DPRINTF("timer %d tick\n", id);
68
+ unsigned int pin = test_pin(data);
56
+ DPRINTF("timer %u tick\n", id);
69
+ uint32_t gpio = test_gpio_addr(data);
57
70
unsigned int gpio_id = get_gpio_id(gpio);
58
/* set irq status */
71
59
p->reg_tint_cstat |= TINT_CSTAT_STATUS(id);
72
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
60
73
@@ -XXX,XX +XXX,XX @@ static void test_pull_up_pull_down(const void *data)
61
/* raise IRQ */
74
* Test that a floating pin with pull-up sets the pin
62
if (p->reg_tint_cstat & TINT_CSTAT_ENABLE(id)) {
75
* high and vice-versa.
63
- DPRINTF("timer %d IRQ\n", id);
76
*/
64
+ DPRINTF("timer %u IRQ\n", id);
77
- unsigned int pin = ((uint64_t)data) & 0xF;
65
qemu_irq_raise(p->timer[id].irq);
78
- uint32_t gpio = ((uint64_t)data) >> 32;
66
}
79
+ unsigned int pin = test_pin(data);
67
80
+ uint32_t gpio = test_gpio_addr(data);
68
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
81
unsigned int gpio_id = get_gpio_id(gpio);
69
}
82
70
83
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
71
if (cmp) {
84
@@ -XXX,XX +XXX,XX @@ static void test_push_pull(const void *data)
72
- DPRINTF("auto reload timer %d count to %x\n", id,
85
* disconnects the pin, that the pin can't be set or reset
73
+ DPRINTF("auto reload timer %u count to %x\n", id,
86
* externally afterwards.
74
p->timer[id].reg_tcntb);
87
*/
75
ptimer_set_count(p->timer[id].ptimer, p->timer[id].reg_tcntb);
88
- unsigned int pin = ((uint64_t)data) & 0xF;
76
ptimer_run(p->timer[id].ptimer, 1);
89
- uint32_t gpio = ((uint64_t)data) >> 32;
90
+ unsigned int pin = test_pin(data);
91
+ uint32_t gpio = test_gpio_addr(data);
92
uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio);
93
94
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
95
@@ -XXX,XX +XXX,XX @@ static void test_open_drain(const void *data)
96
* However a pin set low externally shouldn't be disconnected,
97
* and it can be set low externally when in open-drain mode.
98
*/
99
- unsigned int pin = ((uint64_t)data) & 0xF;
100
- uint32_t gpio = ((uint64_t)data) >> 32;
101
+ unsigned int pin = test_pin(data);
102
+ uint32_t gpio = test_gpio_addr(data);
103
uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio);
104
105
qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg");
106
@@ -XXX,XX +XXX,XX @@ static void test_bsrr_brr(const void *data)
107
* has the desired effect on ODR.
108
* In BSRR, BSx has priority over BRx.
109
*/
110
- unsigned int pin = ((uint64_t)data) & 0xF;
111
- uint32_t gpio = ((uint64_t)data) >> 32;
112
+ unsigned int pin = test_pin(data);
113
+ uint32_t gpio = test_gpio_addr(data);
114
115
gpio_writel(gpio, BSRR, (1 << pin));
116
g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin));
117
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
118
* is problematic since the pin was already high.
119
*/
120
qtest_add_data_func("stm32l4x5/gpio/test_gpioc5_output_mode",
121
- (void *)((uint64_t)GPIO_C << 32 | 5),
122
+ test_data(GPIO_C, 5),
123
test_gpio_output_mode);
124
qtest_add_data_func("stm32l4x5/gpio/test_gpioh3_output_mode",
125
- (void *)((uint64_t)GPIO_H << 32 | 3),
126
+ test_data(GPIO_H, 3),
127
test_gpio_output_mode);
128
qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode1",
129
- (void *)((uint64_t)GPIO_D << 32 | 6),
130
+ test_data(GPIO_D, 6),
131
test_gpio_input_mode);
132
qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode2",
133
- (void *)((uint64_t)GPIO_C << 32 | 10),
134
+ test_data(GPIO_C, 10),
135
test_gpio_input_mode);
136
qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down1",
137
- (void *)((uint64_t)GPIO_B << 32 | 5),
138
+ test_data(GPIO_B, 5),
139
test_pull_up_pull_down);
140
qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down2",
141
- (void *)((uint64_t)GPIO_F << 32 | 1),
142
+ test_data(GPIO_F, 1),
143
test_pull_up_pull_down);
144
qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull1",
145
- (void *)((uint64_t)GPIO_G << 32 | 6),
146
+ test_data(GPIO_G, 6),
147
test_push_pull);
148
qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull2",
149
- (void *)((uint64_t)GPIO_H << 32 | 3),
150
+ test_data(GPIO_H, 3),
151
test_push_pull);
152
qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain1",
153
- (void *)((uint64_t)GPIO_C << 32 | 4),
154
+ test_data(GPIO_C, 4),
155
test_open_drain);
156
qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain2",
157
- (void *)((uint64_t)GPIO_E << 32 | 11),
158
+ test_data(GPIO_E, 11),
159
test_open_drain);
160
qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr1",
161
- (void *)((uint64_t)GPIO_A << 32 | 12),
162
+ test_data(GPIO_A, 12),
163
test_bsrr_brr);
164
qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr2",
165
- (void *)((uint64_t)GPIO_D << 32 | 0),
166
+ test_data(GPIO_D, 0),
167
test_bsrr_brr);
168
169
qtest_start("-machine b-l475e-iot01a");
77
--
170
--
78
2.20.1
171
2.34.1
79
172
80
173
diff view generated by jsdifflib
Deleted patch
1
In commit 5edab03d4040 we added tracepoints to the ps2 keyboard
2
and mouse emulation. However we didn't remove all the debug-by-printf
3
support. In fact there is only one printf() remaining, and it is
4
redundant with the trace_ps2_write_mouse() event next to it.
5
Remove the printf() and the now-unused DEBUG* macros.
6
1
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
10
Message-id: 20201101133258.4240-1-peter.maydell@linaro.org
11
---
12
hw/input/ps2.c | 9 ---------
13
1 file changed, 9 deletions(-)
14
15
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/input/ps2.c
18
+++ b/hw/input/ps2.c
19
@@ -XXX,XX +XXX,XX @@
20
21
#include "trace.h"
22
23
-/* debug PC keyboard */
24
-//#define DEBUG_KBD
25
-
26
-/* debug PC keyboard : only mouse */
27
-//#define DEBUG_MOUSE
28
-
29
/* Keyboard Commands */
30
#define KBD_CMD_SET_LEDS    0xED    /* Set keyboard leds */
31
#define KBD_CMD_ECHO     0xEE
32
@@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(void *opaque, int val)
33
PS2MouseState *s = (PS2MouseState *)opaque;
34
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
--
43
2.20.1
44
45
diff view generated by jsdifflib
Deleted patch
1
In the mtspr helper we attempt to check for "is the timer disabled"
2
with "if (env->ttmr & TIMER_NONE)". This is wrong because TIMER_NONE
3
is zero and the condition is always false (Coverity complains about
4
the dead code.)
5
1
6
The correct check would be to test whether the TTMR_M field in the
7
register is equal to TIMER_NONE instead. However, the
8
cpu_openrisc_timer_update() function checks whether the timer is
9
enabled (it looks at cpu->env.is_counting, which is set to 0 via
10
cpu_openrisc_count_stop() when the TTMR_M field is set to
11
TIMER_NONE), so there's no need to check for "timer disabled" in the
12
target/openrisc code. Instead, simply remove the dead code.
13
14
Fixes: Coverity CID 1005812
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
24
--- a/target/openrisc/sys_helper.c
25
+++ b/target/openrisc/sys_helper.c
26
@@ -XXX,XX +XXX,XX @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)
27
28
case TO_SPR(10, 1): /* TTCR */
29
cpu_openrisc_count_set(cpu, rb);
30
- if (env->ttmr & TIMER_NONE) {
31
- return;
32
- }
33
cpu_openrisc_timer_update(cpu);
34
break;
35
#endif
36
--
37
2.20.1
38
39
diff view generated by jsdifflib
1
From: Alistair Francis <alistair.francis@wdc.com>
1
From: Cédric Le Goater <clg@redhat.com>
2
2
3
This patch fixes CID 1432800 by removing an unnecessary check.
3
Change the board revision number and RAM size to 1Gb on 32-bit hosts.
4
On these systems, RAM has a 2047 MB limit and this breaks the tests.
4
5
5
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
6
Fixes: 7785e8ea2204 ("hw/arm: Introduce Raspberry PI 4 machine")
7
Signed-off-by: Cédric Le Goater <clg@redhat.com>
8
Message-id: 20240329150155.357043-1-clg@redhat.com
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
11
---
9
hw/core/register.c | 4 ----
12
hw/arm/raspi4b.c | 4 ++++
10
1 file changed, 4 deletions(-)
13
1 file changed, 4 insertions(+)
11
14
12
diff --git a/hw/core/register.c b/hw/core/register.c
15
diff --git a/hw/arm/raspi4b.c b/hw/arm/raspi4b.c
13
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/core/register.c
17
--- a/hw/arm/raspi4b.c
15
+++ b/hw/core/register.c
18
+++ b/hw/arm/raspi4b.c
16
@@ -XXX,XX +XXX,XX @@ static RegisterInfoArray *register_init_block(DeviceState *owner,
19
@@ -XXX,XX +XXX,XX @@ static void raspi4b_machine_class_init(ObjectClass *oc, void *data)
17
int index = rae[i].addr / data_size;
20
MachineClass *mc = MACHINE_CLASS(oc);
18
RegisterInfo *r = &ri[index];
21
RaspiBaseMachineClass *rmc = RASPI_BASE_MACHINE_CLASS(oc);
19
22
20
- if (data + data_size * index == 0 || !&rae[i]) {
23
+#if HOST_LONG_BITS == 32
21
- continue;
24
+ rmc->board_rev = 0xa03111; /* Revision 1.1, 1 Gb RAM */
22
- }
25
+#else
23
-
26
rmc->board_rev = 0xb03115; /* Revision 1.5, 2 Gb RAM */
24
/* Init the register, this will zero it. */
27
+#endif
25
object_initialize((void *)r, sizeof(*r), TYPE_REGISTER);
28
raspi_machine_class_common_init(mc, rmc->board_rev);
26
29
mc->init = raspi4b_machine_init;
30
}
27
--
31
--
28
2.20.1
32
2.34.1
29
33
30
34
diff view generated by jsdifflib
Deleted patch
1
In commit 76346b6264a9b01979 we tried to add a configure check that
2
the libgio pkg-config data was correct, which builds an executable
3
linked against it. Unfortunately this doesn't catch the problem
4
(missing static library dependency info), because a "do nothing" test
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
1
9
(The ineffective test went unnoticed because of a typo that
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
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
20
Message-id: 20201116104617.18333-1-peter.maydell@linaro.org
21
---
22
configure | 11 +++++++++--
23
1 file changed, 9 insertions(+), 2 deletions(-)
24
25
diff --git a/configure b/configure
26
index XXXXXXX..XXXXXXX 100755
27
--- a/configure
28
+++ b/configure
29
@@ -XXX,XX +XXX,XX @@ if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
30
# Check that the libraries actually work -- Ubuntu 18.04 ships
31
# with pkg-config --static --libs data for gio-2.0 that is missing
32
# -lblkid and will give a link error.
33
- write_c_skeleton
34
- if compile_prog "" "$gio_libs" ; then
35
+ cat > $TMPC <<EOF
36
+#include <gio/gio.h>
37
+int main(void)
38
+{
39
+ g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
40
+ return 0;
41
+}
42
+EOF
43
+ if compile_prog "$gio_cflags" "$gio_libs" ; then
44
gio=yes
45
else
46
gio=no
47
--
48
2.20.1
49
50
diff view generated by jsdifflib