1
The following changes since commit 6eeea6725a70e6fcb5abba0764496bdab07ddfb3:
1
Arm queue; bugfixes only.
2
2
3
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-10-06' into staging (2020-10-06 21:13:34 +0100)
3
thanks
4
-- PMM
5
6
The following changes since commit 48aa8f0ac536db3550a35c295ff7de94e4c33739:
7
8
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-11-16' into staging (2020-11-17 11:07:00 +0000)
4
9
5
are available in the Git repository at:
10
are available in the Git repository at:
6
11
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201008
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201117
8
13
9
for you to fetch changes up to ba118c26e16a97e6ff6de8184057d3420ce16a23:
14
for you to fetch changes up to ab135622cf478585bdfcb68b85e4a817d74a0c42:
10
15
11
target/arm: Make '-cpu max' have a 48-bit PA (2020-10-08 15:24:32 +0100)
16
tmp105: Correct handling of temperature limit checks (2020-11-17 12:56:33 +0000)
12
17
13
----------------------------------------------------------------
18
----------------------------------------------------------------
14
target-arm queue:
19
target-arm queue:
15
* hw/ssi/npcm7xx_fiu: Fix handling of unsigned integer
20
* hw/arm/virt: ARM_VIRT must select ARM_GIC
16
* hw/arm/fsl-imx25: Fix a typo
21
* exynos: Fix bad printf format specifiers
17
* hw/arm/sbsa-ref : Fix SMMUv3 Initialisation
22
* hw/input/ps2.c: Remove remnants of printf debug
18
* hw/arm/sbsa-ref : allocate IRQs for SMMUv3
23
* target/openrisc: Remove dead code attempting to check "is timer disabled"
19
* hw/char/bcm2835_aux: Allow less than 32-bit accesses
24
* register: Remove unnecessary NULL check
20
* hw/arm/virt: Implement kvm-steal-time
25
* util/cutils: Fix Coverity array overrun in freq_to_str()
21
* target/arm: Make '-cpu max' have a 48-bit PA
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
22
29
23
----------------------------------------------------------------
30
----------------------------------------------------------------
24
Andrew Jones (6):
31
Alex Chen (1):
25
linux headers: sync to 5.9-rc7
32
exynos: Fix bad printf format specifiers
26
target/arm/kvm: Make uncalled stubs explicitly unreachable
27
hw/arm/virt: Move post cpu realize check into its own function
28
hw/arm/virt: Move kvm pmu setup to virt_cpu_post_init
29
tests/qtest: Restore aarch64 arm-cpu-features test
30
hw/arm/virt: Implement kvm-steal-time
31
33
32
Graeme Gregory (2):
34
Alistair Francis (1):
33
hw/arm/sbsa-ref : Fix SMMUv3 Initialisation
35
register: Remove unnecessary NULL check
34
hw/arm/sbsa-ref : allocate IRQs for SMMUv3
35
36
36
Peter Maydell (1):
37
Andrew Jones (1):
37
target/arm: Make '-cpu max' have a 48-bit PA
38
hw/arm/virt: ARM_VIRT must select ARM_GIC
38
39
39
Philippe Mathieu-Daudé (3):
40
Peter Maydell (5):
40
hw/ssi/npcm7xx_fiu: Fix handling of unsigned integer
41
hw/input/ps2.c: Remove remnants of printf debug
41
hw/arm/fsl-imx25: Fix a typo
42
target/openrisc: Remove dead code attempting to check "is timer disabled"
42
hw/char/bcm2835_aux: Allow less than 32-bit accesses
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
43
46
44
docs/system/arm/cpu-features.rst | 11 ++++
47
Philippe Mathieu-Daudé (1):
45
include/hw/arm/fsl-imx25.h | 2 +-
48
util/cutils: Fix Coverity array overrun in freq_to_str()
46
include/hw/arm/virt.h | 5 ++
47
linux-headers/linux/kvm.h | 6 ++-
48
target/arm/cpu.h | 4 ++
49
target/arm/kvm_arm.h | 94 ++++++++++++++++++++++++++-------
50
hw/arm/sbsa-ref.c | 3 +-
51
hw/arm/virt.c | 110 ++++++++++++++++++++++++++++-----------
52
hw/char/bcm2835_aux.c | 4 +-
53
hw/ssi/npcm7xx_fiu.c | 12 ++---
54
target/arm/cpu.c | 8 +++
55
target/arm/cpu64.c | 4 ++
56
target/arm/kvm.c | 16 ++++++
57
target/arm/kvm64.c | 64 +++++++++++++++++++++--
58
target/arm/monitor.c | 2 +-
59
tests/qtest/arm-cpu-features.c | 25 +++++++--
60
hw/ssi/trace-events | 2 +-
61
tests/qtest/meson.build | 3 +-
62
18 files changed, 303 insertions(+), 72 deletions(-)
63
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: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
3
Fix integer handling issues handling issue reported by Coverity:
4
5
hw/ssi/npcm7xx_fiu.c: 162 in npcm7xx_fiu_flash_read()
6
>>> CID 1432730: Integer handling issues (NEGATIVE_RETURNS)
7
>>> "npcm7xx_fiu_cs_index(fiu, f)" is passed to a parameter that cannot be negative.
8
162 npcm7xx_fiu_select(fiu, npcm7xx_fiu_cs_index(fiu, f));
9
10
hw/ssi/npcm7xx_fiu.c: 221 in npcm7xx_fiu_flash_write()
11
218 cs_id = npcm7xx_fiu_cs_index(fiu, f);
12
219 trace_npcm7xx_fiu_flash_write(DEVICE(fiu)->canonical_path, cs_id, addr,
13
220 size, v);
14
>>> CID 1432729: Integer handling issues (NEGATIVE_RETURNS)
15
>>> "cs_id" is passed to a parameter that cannot be negative.
16
221 npcm7xx_fiu_select(fiu, cs_id);
17
18
Since the index of the flash can not be negative, return an
19
unsigned type.
20
21
Reported-by: Coverity (CID 1432729 & 1432730: NEGATIVE_RETURNS)
22
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
23
Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
24
Message-id: 20200919132435.310527-1-f4bug@amsat.org
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
27
hw/ssi/npcm7xx_fiu.c | 12 ++++++------
28
hw/ssi/trace-events | 2 +-
29
2 files changed, 7 insertions(+), 7 deletions(-)
30
31
diff --git a/hw/ssi/npcm7xx_fiu.c b/hw/ssi/npcm7xx_fiu.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/ssi/npcm7xx_fiu.c
34
+++ b/hw/ssi/npcm7xx_fiu.c
35
@@ -XXX,XX +XXX,XX @@ enum NPCM7xxFIURegister {
36
* Returns the index of flash in the fiu->flash array. This corresponds to the
37
* chip select ID of the flash.
38
*/
39
-static int npcm7xx_fiu_cs_index(NPCM7xxFIUState *fiu, NPCM7xxFIUFlash *flash)
40
+static unsigned npcm7xx_fiu_cs_index(NPCM7xxFIUState *fiu,
41
+ NPCM7xxFIUFlash *flash)
42
{
43
int index = flash - fiu->flash;
44
45
@@ -XXX,XX +XXX,XX @@ static int npcm7xx_fiu_cs_index(NPCM7xxFIUState *fiu, NPCM7xxFIUFlash *flash)
46
}
47
48
/* Assert the chip select specified in the UMA Control/Status Register. */
49
-static void npcm7xx_fiu_select(NPCM7xxFIUState *s, int cs_id)
50
+static void npcm7xx_fiu_select(NPCM7xxFIUState *s, unsigned cs_id)
51
{
52
trace_npcm7xx_fiu_select(DEVICE(s)->canonical_path, cs_id);
53
54
if (cs_id < s->cs_count) {
55
qemu_irq_lower(s->cs_lines[cs_id]);
56
+ s->active_cs = cs_id;
57
} else {
58
qemu_log_mask(LOG_GUEST_ERROR,
59
"%s: UMA to CS%d; this module has only %d chip selects",
60
DEVICE(s)->canonical_path, cs_id, s->cs_count);
61
- cs_id = -1;
62
+ s->active_cs = -1;
63
}
64
-
65
- s->active_cs = cs_id;
66
}
67
68
/* Deassert the currently active chip select. */
69
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_fiu_flash_write(void *opaque, hwaddr addr, uint64_t v,
70
NPCM7xxFIUFlash *f = opaque;
71
NPCM7xxFIUState *fiu = f->fiu;
72
uint32_t dwr_cfg;
73
- int cs_id;
74
+ unsigned cs_id;
75
int i;
76
77
if (fiu->active_cs != -1) {
78
diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/ssi/trace-events
81
+++ b/hw/ssi/trace-events
82
@@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_deselect(const char *id, int cs) "%s deselect CS%d"
83
npcm7xx_fiu_ctrl_read(const char *id, uint64_t addr, uint32_t data) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx32
84
npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx32
85
npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64
86
-npcm7xx_fiu_flash_write(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64
87
+npcm7xx_fiu_flash_write(const char *id, unsigned cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64
88
--
89
2.20.1
90
91
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Andrew Jones <drjones@redhat.com>
2
2
3
arm-cpu-features got dropped from the AArch64 tests during the meson
3
The removal of the selection of A15MPCORE from ARM_VIRT also
4
conversion shuffle.
4
removed what A15MPCORE selects, ARM_GIC. We still need ARM_GIC.
5
5
6
Fixes: bec3c97e0cf9 ("hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals")
7
Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
6
Signed-off-by: Andrew Jones <drjones@redhat.com>
8
Signed-off-by: Andrew Jones <drjones@redhat.com>
7
Message-id: 20201001061718.101915-6-drjones@redhat.com
9
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20201111143440.112763-1-drjones@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
tests/qtest/meson.build | 3 ++-
14
hw/arm/Kconfig | 1 +
12
1 file changed, 2 insertions(+), 1 deletion(-)
15
1 file changed, 1 insertion(+)
13
16
14
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
17
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
15
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/meson.build
19
--- a/hw/arm/Kconfig
17
+++ b/tests/qtest/meson.build
20
+++ b/hw/arm/Kconfig
18
@@ -XXX,XX +XXX,XX @@ qtests_aarch64 = \
21
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
19
(cpu != 'arm' ? ['bios-tables-test'] : []) + \
22
imply VFIO_PLATFORM
20
(config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \
23
imply VFIO_XGMAC
21
(config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \
24
imply TPM_TIS_SYSBUS
22
- ['numa-test',
25
+ select ARM_GIC
23
+ ['arm-cpu-features',
26
select ACPI
24
+ 'numa-test',
27
select ARM_SMMUV3
25
'boot-serial-test',
28
select GPIO_KEY
26
'migration-test']
27
28
--
29
--
29
2.20.1
30
2.20.1
30
31
31
32
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Alex Chen <alex.chen@huawei.com>
2
2
3
We add the kvm-steal-time CPU property and implement it for machvirt.
3
We should use printf format specifier "%u" instead of "%d" for
4
A tiny bit of refactoring was also done to allow pmu and pvtime to
4
argument of type "unsigned int".
5
use the same vcpu device helper functions.
6
5
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
6
Reported-by: Euler Robot <euler.robot@huawei.com>
8
Signed-off-by: Andrew Jones <drjones@redhat.com>
7
Signed-off-by: Alex Chen <alex.chen@huawei.com>
9
Message-id: 20201001061718.101915-7-drjones@redhat.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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
docs/system/arm/cpu-features.rst | 11 ++++++
12
hw/timer/exynos4210_mct.c | 4 ++--
13
include/hw/arm/virt.h | 5 +++
13
hw/timer/exynos4210_pwm.c | 8 ++++----
14
target/arm/cpu.h | 4 ++
14
2 files changed, 6 insertions(+), 6 deletions(-)
15
target/arm/kvm_arm.h | 43 +++++++++++++++++++++
16
hw/arm/virt.c | 43 +++++++++++++++++++--
17
target/arm/cpu.c | 8 ++++
18
target/arm/kvm.c | 16 ++++++++
19
target/arm/kvm64.c | 64 +++++++++++++++++++++++++++++---
20
target/arm/monitor.c | 2 +-
21
tests/qtest/arm-cpu-features.c | 25 +++++++++++--
22
10 files changed, 208 insertions(+), 13 deletions(-)
23
15
24
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
16
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
25
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
26
--- a/docs/system/arm/cpu-features.rst
18
--- a/hw/timer/exynos4210_mct.c
27
+++ b/docs/system/arm/cpu-features.rst
19
+++ b/hw/timer/exynos4210_mct.c
28
@@ -XXX,XX +XXX,XX @@ the list of KVM VCPU features and their descriptions.
20
@@ -XXX,XX +XXX,XX @@ static void exynos4210_gcomp_raise_irq(void *opaque, uint32_t id)
29
adjustment, also restoring the legacy (pre-5.0)
21
/* If CSTAT is pending and IRQ is enabled */
30
behavior.
22
if ((s->reg.int_cstat & G_INT_CSTAT_COMP(id)) &&
31
23
(s->reg.int_enb & G_INT_ENABLE(id))) {
32
+ kvm-steal-time Since v5.2, kvm-steal-time is enabled by
24
- DPRINTF("gcmp timer[%d] IRQ\n", id);
33
+ default when KVM is enabled, the feature is
25
+ DPRINTF("gcmp timer[%u] IRQ\n", id);
34
+ supported, and the guest is 64-bit.
26
qemu_irq_raise(s->irq[id]);
35
+
36
+ When kvm-steal-time is enabled a 64-bit guest
37
+ can account for time its CPUs were not running
38
+ due to the host not scheduling the corresponding
39
+ VCPU threads. The accounting statistics may
40
+ influence the guest scheduler behavior and/or be
41
+ exposed to the guest userspace.
42
+
43
SVE CPU Properties
44
==================
45
46
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/include/hw/arm/virt.h
49
+++ b/include/hw/arm/virt.h
50
@@ -XXX,XX +XXX,XX @@
51
52
#define PPI(irq) ((irq) + 16)
53
54
+/* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */
55
+#define PVTIME_SIZE_PER_CPU 64
56
+
57
enum {
58
VIRT_FLASH,
59
VIRT_MEM,
60
@@ -XXX,XX +XXX,XX @@ enum {
61
VIRT_PCDIMM_ACPI,
62
VIRT_ACPI_GED,
63
VIRT_NVDIMM_ACPI,
64
+ VIRT_PVTIME,
65
VIRT_LOWMEMMAP_LAST,
66
};
67
68
@@ -XXX,XX +XXX,XX @@ struct VirtMachineClass {
69
bool no_highmem_ecam;
70
bool no_ged; /* Machines < 4.2 has no support for ACPI GED device */
71
bool kvm_no_adjvtime;
72
+ bool no_kvm_steal_time;
73
bool acpi_expose_flash;
74
};
75
76
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
77
index XXXXXXX..XXXXXXX 100644
78
--- a/target/arm/cpu.h
79
+++ b/target/arm/cpu.h
80
@@ -XXX,XX +XXX,XX @@
81
#include "hw/registerfields.h"
82
#include "cpu-qom.h"
83
#include "exec/cpu-defs.h"
84
+#include "qapi/qapi-types-common.h"
85
86
/* ARM processors have a weak memory model */
87
#define TCG_GUEST_DEFAULT_MO (0)
88
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
89
bool kvm_vtime_dirty;
90
uint64_t kvm_vtime;
91
92
+ /* KVM steal time */
93
+ OnOffAuto kvm_steal_time;
94
+
95
/* Uniprocessor system with MP extensions */
96
bool mp_is_up;
97
98
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
99
index XXXXXXX..XXXXXXX 100644
100
--- a/target/arm/kvm_arm.h
101
+++ b/target/arm/kvm_arm.h
102
@@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu);
103
*/
104
void kvm_arm_add_vcpu_properties(Object *obj);
105
106
+/**
107
+ * kvm_arm_steal_time_finalize:
108
+ * @cpu: ARMCPU for which to finalize kvm-steal-time
109
+ * @errp: Pointer to Error* for error propagation
110
+ *
111
+ * Validate the kvm-steal-time property selection and set its default
112
+ * based on KVM support and guest configuration.
113
+ */
114
+void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp);
115
+
116
+/**
117
+ * kvm_arm_steal_time_supported:
118
+ *
119
+ * Returns: true if KVM can enable steal time reporting
120
+ * and false otherwise.
121
+ */
122
+bool kvm_arm_steal_time_supported(void);
123
+
124
/**
125
* kvm_arm_aarch32_supported:
126
*
127
@@ -XXX,XX +XXX,XX @@ int kvm_arm_vgic_probe(void);
128
129
void kvm_arm_pmu_set_irq(CPUState *cs, int irq);
130
void kvm_arm_pmu_init(CPUState *cs);
131
+
132
+/**
133
+ * kvm_arm_pvtime_init:
134
+ * @cs: CPUState
135
+ * @ipa: Per-vcpu guest physical base address of the pvtime structures
136
+ *
137
+ * Initializes PVTIME for the VCPU, setting the PVTIME IPA to @ipa.
138
+ */
139
+void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa);
140
+
141
int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
142
143
#else
144
@@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_sve_supported(void)
145
return false;
146
}
147
148
+static inline bool kvm_arm_steal_time_supported(void)
149
+{
150
+ return false;
151
+}
152
+
153
/*
154
* These functions should never actually be called without KVM support.
155
*/
156
@@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_pmu_init(CPUState *cs)
157
g_assert_not_reached();
158
}
159
160
+static inline void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa)
161
+{
162
+ g_assert_not_reached();
163
+}
164
+
165
+static inline void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp)
166
+{
167
+ g_assert_not_reached();
168
+}
169
+
170
static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map)
171
{
172
g_assert_not_reached();
173
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
174
index XXXXXXX..XXXXXXX 100644
175
--- a/hw/arm/virt.c
176
+++ b/hw/arm/virt.c
177
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry base_memmap[] = {
178
[VIRT_PCDIMM_ACPI] = { 0x09070000, MEMORY_HOTPLUG_IO_LEN },
179
[VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN },
180
[VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN},
181
+ [VIRT_PVTIME] = { 0x090a0000, 0x00010000 },
182
[VIRT_MMIO] = { 0x0a000000, 0x00000200 },
183
/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
184
[VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 },
185
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
186
* virt_cpu_post_init() must be called after the CPUs have
187
* been realized and the GIC has been created.
188
*/
189
-static void virt_cpu_post_init(VirtMachineState *vms)
190
+static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus,
191
+ MemoryRegion *sysmem)
192
{
193
- bool aarch64, pmu;
194
+ bool aarch64, pmu, steal_time;
195
CPUState *cpu;
196
197
aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
198
pmu = object_property_get_bool(OBJECT(first_cpu), "pmu", NULL);
199
+ steal_time = object_property_get_bool(OBJECT(first_cpu),
200
+ "kvm-steal-time", NULL);
201
202
if (kvm_enabled()) {
203
+ hwaddr pvtime_reg_base = vms->memmap[VIRT_PVTIME].base;
204
+ hwaddr pvtime_reg_size = vms->memmap[VIRT_PVTIME].size;
205
+
206
+ if (steal_time) {
207
+ MemoryRegion *pvtime = g_new(MemoryRegion, 1);
208
+ hwaddr pvtime_size = max_cpus * PVTIME_SIZE_PER_CPU;
209
+
210
+ /* The memory region size must be a multiple of host page size. */
211
+ pvtime_size = REAL_HOST_PAGE_ALIGN(pvtime_size);
212
+
213
+ if (pvtime_size > pvtime_reg_size) {
214
+ error_report("pvtime requires a %ld byte memory region for "
215
+ "%d CPUs, but only %ld has been reserved",
216
+ pvtime_size, max_cpus, pvtime_reg_size);
217
+ exit(1);
218
+ }
219
+
220
+ memory_region_init_ram(pvtime, NULL, "pvtime", pvtime_size, NULL);
221
+ memory_region_add_subregion(sysmem, pvtime_reg_base, pvtime);
222
+ }
223
+
224
CPU_FOREACH(cpu) {
225
if (pmu) {
226
assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU));
227
@@ -XXX,XX +XXX,XX @@ static void virt_cpu_post_init(VirtMachineState *vms)
228
}
229
kvm_arm_pmu_init(cpu);
230
}
231
+ if (steal_time) {
232
+ kvm_arm_pvtime_init(cpu, pvtime_reg_base +
233
+ cpu->cpu_index * PVTIME_SIZE_PER_CPU);
234
+ }
235
}
236
} else {
237
if (aarch64 && vms->highmem) {
238
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
239
object_property_set_bool(cpuobj, "kvm-no-adjvtime", true, NULL);
240
}
241
242
+ if (vmc->no_kvm_steal_time &&
243
+ object_property_find(cpuobj, "kvm-steal-time")) {
244
+ object_property_set_bool(cpuobj, "kvm-steal-time", false, NULL);
245
+ }
246
+
247
if (vmc->no_pmu && object_property_find(cpuobj, "pmu")) {
248
object_property_set_bool(cpuobj, "pmu", false, NULL);
249
}
250
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
251
252
create_gic(vms);
253
254
- virt_cpu_post_init(vms);
255
+ virt_cpu_post_init(vms, possible_cpus->len, sysmem);
256
257
fdt_add_pmu_nodes(vms);
258
259
@@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 2)
260
261
static void virt_machine_5_1_options(MachineClass *mc)
262
{
263
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
264
+
265
virt_machine_5_2_options(mc);
266
compat_props_add(mc->compat_props, hw_compat_5_1, hw_compat_5_1_len);
267
+ vmc->no_kvm_steal_time = true;
268
}
269
DEFINE_VIRT_MACHINE(5, 1)
270
271
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
272
index XXXXXXX..XXXXXXX 100644
273
--- a/target/arm/cpu.c
274
+++ b/target/arm/cpu.c
275
@@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
276
return;
277
}
278
}
279
+
280
+ if (kvm_enabled()) {
281
+ kvm_arm_steal_time_finalize(cpu, &local_err);
282
+ if (local_err != NULL) {
283
+ error_propagate(errp, local_err);
284
+ return;
285
+ }
286
+ }
287
}
288
289
static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
290
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
291
index XXXXXXX..XXXXXXX 100644
292
--- a/target/arm/kvm.c
293
+++ b/target/arm/kvm.c
294
@@ -XXX,XX +XXX,XX @@ static void kvm_no_adjvtime_set(Object *obj, bool value, Error **errp)
295
ARM_CPU(obj)->kvm_adjvtime = !value;
296
}
297
298
+static bool kvm_steal_time_get(Object *obj, Error **errp)
299
+{
300
+ return ARM_CPU(obj)->kvm_steal_time != ON_OFF_AUTO_OFF;
301
+}
302
+
303
+static void kvm_steal_time_set(Object *obj, bool value, Error **errp)
304
+{
305
+ ARM_CPU(obj)->kvm_steal_time = value ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
306
+}
307
+
308
/* KVM VCPU properties should be prefixed with "kvm-". */
309
void kvm_arm_add_vcpu_properties(Object *obj)
310
{
311
@@ -XXX,XX +XXX,XX @@ void kvm_arm_add_vcpu_properties(Object *obj)
312
"the virtual counter. VM stopped time "
313
"will be counted.");
314
}
315
+
316
+ cpu->kvm_steal_time = ON_OFF_AUTO_AUTO;
317
+ object_property_add_bool(obj, "kvm-steal-time", kvm_steal_time_get,
318
+ kvm_steal_time_set);
319
+ object_property_set_description(obj, "kvm-steal-time",
320
+ "Set off to disable KVM steal time.");
321
}
322
323
bool kvm_arm_pmu_supported(void)
324
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
325
index XXXXXXX..XXXXXXX 100644
326
--- a/target/arm/kvm64.c
327
+++ b/target/arm/kvm64.c
328
@@ -XXX,XX +XXX,XX @@
329
#include <linux/kvm.h>
330
331
#include "qemu-common.h"
332
+#include "qapi/error.h"
333
#include "cpu.h"
334
#include "qemu/timer.h"
335
#include "qemu/error-report.h"
336
@@ -XXX,XX +XXX,XX @@ static CPUWatchpoint *find_hw_watchpoint(CPUState *cpu, target_ulong addr)
337
return NULL;
338
}
339
340
-static bool kvm_arm_pmu_set_attr(CPUState *cs, struct kvm_device_attr *attr)
341
+static bool kvm_arm_set_device_attr(CPUState *cs, struct kvm_device_attr *attr,
342
+ const char *name)
343
{
344
int err;
345
346
err = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr);
347
if (err != 0) {
348
- error_report("PMU: KVM_HAS_DEVICE_ATTR: %s", strerror(-err));
349
+ error_report("%s: KVM_HAS_DEVICE_ATTR: %s", name, strerror(-err));
350
return false;
351
}
352
353
err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr);
354
if (err != 0) {
355
- error_report("PMU: KVM_SET_DEVICE_ATTR: %s", strerror(-err));
356
+ error_report("%s: KVM_SET_DEVICE_ATTR: %s", name, strerror(-err));
357
return false;
358
}
359
360
@@ -XXX,XX +XXX,XX @@ void kvm_arm_pmu_init(CPUState *cs)
361
if (!ARM_CPU(cs)->has_pmu) {
362
return;
363
}
364
- if (!kvm_arm_pmu_set_attr(cs, &attr)) {
365
+ if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) {
366
error_report("failed to init PMU");
367
abort();
368
}
369
@@ -XXX,XX +XXX,XX @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq)
370
if (!ARM_CPU(cs)->has_pmu) {
371
return;
372
}
373
- if (!kvm_arm_pmu_set_attr(cs, &attr)) {
374
+ if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) {
375
error_report("failed to set irq for PMU");
376
abort();
377
}
27
}
378
}
28
}
379
29
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s)
380
+void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa)
30
MCT_CFG_GET_DIVIDER(s->reg_mct_cfg));
381
+{
31
382
+ struct kvm_device_attr attr = {
32
if (freq != s->freq) {
383
+ .group = KVM_ARM_VCPU_PVTIME_CTRL,
33
- DPRINTF("freq=%dHz\n", s->freq);
384
+ .attr = KVM_ARM_VCPU_PVTIME_IPA,
34
+ DPRINTF("freq=%uHz\n", s->freq);
385
+ .addr = (uint64_t)&ipa,
35
386
+ };
36
/* global timer */
387
+
37
tx_ptimer_set_freq(s->g_timer.ptimer_frc, s->freq);
388
+ if (ARM_CPU(cs)->kvm_steal_time == ON_OFF_AUTO_OFF) {
38
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
389
+ return;
39
index XXXXXXX..XXXXXXX 100644
390
+ }
40
--- a/hw/timer/exynos4210_pwm.c
391
+ if (!kvm_arm_set_device_attr(cs, &attr, "PVTIME IPA")) {
41
+++ b/hw/timer/exynos4210_pwm.c
392
+ error_report("failed to init PVTIME IPA");
42
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_update_freq(Exynos4210PWMState *s, uint32_t id)
393
+ abort();
43
394
+ }
44
if (freq != s->timer[id].freq) {
395
+}
45
ptimer_set_freq(s->timer[id].ptimer, s->timer[id].freq);
396
+
46
- DPRINTF("freq=%dHz\n", s->timer[id].freq);
397
static int read_sys_reg32(int fd, uint32_t *pret, uint64_t id)
47
+ DPRINTF("freq=%uHz\n", s->timer[id].freq);
398
{
48
}
399
uint64_t ret;
400
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
401
return true;
402
}
49
}
403
50
404
+void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp)
51
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
405
+{
52
uint32_t id = s->id;
406
+ bool has_steal_time = kvm_arm_steal_time_supported();
53
bool cmp;
407
+
54
408
+ if (cpu->kvm_steal_time == ON_OFF_AUTO_AUTO) {
55
- DPRINTF("timer %d tick\n", id);
409
+ if (!has_steal_time || !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
56
+ DPRINTF("timer %u tick\n", id);
410
+ cpu->kvm_steal_time = ON_OFF_AUTO_OFF;
57
411
+ } else {
58
/* set irq status */
412
+ cpu->kvm_steal_time = ON_OFF_AUTO_ON;
59
p->reg_tint_cstat |= TINT_CSTAT_STATUS(id);
413
+ }
60
414
+ } else if (cpu->kvm_steal_time == ON_OFF_AUTO_ON) {
61
/* raise IRQ */
415
+ if (!has_steal_time) {
62
if (p->reg_tint_cstat & TINT_CSTAT_ENABLE(id)) {
416
+ error_setg(errp, "'kvm-steal-time' cannot be enabled "
63
- DPRINTF("timer %d IRQ\n", id);
417
+ "on this host");
64
+ DPRINTF("timer %u IRQ\n", id);
418
+ return;
65
qemu_irq_raise(p->timer[id].irq);
419
+ } else if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
420
+ /*
421
+ * DEN0057A chapter 2 says "This specification only covers
422
+ * systems in which the Execution state of the hypervisor
423
+ * as well as EL1 of virtual machines is AArch64.". And,
424
+ * to ensure that, the smc/hvc calls are only specified as
425
+ * smc64/hvc64.
426
+ */
427
+ error_setg(errp, "'kvm-steal-time' cannot be enabled "
428
+ "for AArch32 guests");
429
+ return;
430
+ }
431
+ }
432
+}
433
+
434
bool kvm_arm_aarch32_supported(void)
435
{
436
return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL1_32BIT);
437
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_sve_supported(void)
438
return kvm_check_extension(kvm_state, KVM_CAP_ARM_SVE);
439
}
440
441
+bool kvm_arm_steal_time_supported(void)
442
+{
443
+ return kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME);
444
+}
445
+
446
QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1);
447
448
void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map)
449
diff --git a/target/arm/monitor.c b/target/arm/monitor.c
450
index XXXXXXX..XXXXXXX 100644
451
--- a/target/arm/monitor.c
452
+++ b/target/arm/monitor.c
453
@@ -XXX,XX +XXX,XX @@ static const char *cpu_model_advertised_features[] = {
454
"sve128", "sve256", "sve384", "sve512",
455
"sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280",
456
"sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048",
457
- "kvm-no-adjvtime",
458
+ "kvm-no-adjvtime", "kvm-steal-time",
459
NULL
460
};
461
462
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
463
index XXXXXXX..XXXXXXX 100644
464
--- a/tests/qtest/arm-cpu-features.c
465
+++ b/tests/qtest/arm-cpu-features.c
466
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data)
467
assert_set_feature(qts, "max", "pmu", true);
468
469
assert_has_not_feature(qts, "max", "kvm-no-adjvtime");
470
+ assert_has_not_feature(qts, "max", "kvm-steal-time");
471
472
if (g_str_equal(qtest_get_arch(), "aarch64")) {
473
assert_has_feature_enabled(qts, "max", "aarch64");
474
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
475
assert_set_feature(qts, "host", "kvm-no-adjvtime", false);
476
477
if (g_str_equal(qtest_get_arch(), "aarch64")) {
478
+ bool kvm_supports_steal_time;
479
bool kvm_supports_sve;
480
char max_name[8], name[8];
481
uint32_t max_vq, vq;
482
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
483
QDict *resp;
484
char *error;
485
486
+ assert_error(qts, "cortex-a15",
487
+ "We cannot guarantee the CPU type 'cortex-a15' works "
488
+ "with KVM on this host", NULL);
489
+
490
assert_has_feature_enabled(qts, "host", "aarch64");
491
492
/* Enabling and disabling pmu should always work. */
493
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
494
assert_set_feature(qts, "host", "pmu", false);
495
assert_set_feature(qts, "host", "pmu", true);
496
497
- assert_error(qts, "cortex-a15",
498
- "We cannot guarantee the CPU type 'cortex-a15' works "
499
- "with KVM on this host", NULL);
500
-
501
+ /*
502
+ * Some features would be enabled by default, but they're disabled
503
+ * because this instance of KVM doesn't support them. Test that the
504
+ * features are present, and, when enabled, issue further tests.
505
+ */
506
+ assert_has_feature(qts, "host", "kvm-steal-time");
507
assert_has_feature(qts, "host", "sve");
508
+
509
resp = do_query_no_props(qts, "host");
510
+ kvm_supports_steal_time = resp_get_feature(resp, "kvm-steal-time");
511
kvm_supports_sve = resp_get_feature(resp, "sve");
512
vls = resp_get_sve_vls(resp);
513
qobject_unref(resp);
514
515
+ if (kvm_supports_steal_time) {
516
+ /* If we have steal-time then we should be able to toggle it. */
517
+ assert_set_feature(qts, "host", "kvm-steal-time", false);
518
+ assert_set_feature(qts, "host", "kvm-steal-time", true);
519
+ }
520
+
521
if (kvm_supports_sve) {
522
g_assert(vls != 0);
523
max_vq = 64 - __builtin_clzll(vls);
524
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
525
assert_has_not_feature(qts, "host", "aarch64");
526
assert_has_not_feature(qts, "host", "pmu");
527
assert_has_not_feature(qts, "host", "sve");
528
+ assert_has_not_feature(qts, "host", "kvm-steal-time");
529
}
66
}
530
67
531
qtest_quit(qts);
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);
532
--
77
--
533
2.20.1
78
2.20.1
534
79
535
80
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
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.
2
6
3
We'll add more to this new function in coming patches so we also
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
state the gic must be created and call it below create_gic().
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(-)
5
14
6
No functional change intended.
15
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
7
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Andrew Jones <drjones@redhat.com>
11
Message-id: 20201001061718.101915-4-drjones@redhat.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/arm/virt.c | 43 +++++++++++++++++++++++++++----------------
15
1 file changed, 27 insertions(+), 16 deletions(-)
16
17
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/virt.c
17
--- a/hw/input/ps2.c
20
+++ b/hw/arm/virt.c
18
+++ b/hw/input/ps2.c
21
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
19
@@ -XXX,XX +XXX,XX @@
22
}
20
23
}
21
#include "trace.h"
24
22
25
+/*
23
-/* debug PC keyboard */
26
+ * virt_cpu_post_init() must be called after the CPUs have
24
-//#define DEBUG_KBD
27
+ * been realized and the GIC has been created.
28
+ */
29
+static void virt_cpu_post_init(VirtMachineState *vms)
30
+{
31
+ bool aarch64;
32
+
33
+ aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
34
+
35
+ if (!kvm_enabled()) {
36
+ if (aarch64 && vms->highmem) {
37
+ int requested_pa_size = 64 - clz64(vms->highest_gpa);
38
+ int pamax = arm_pamax(ARM_CPU(first_cpu));
39
+
40
+ if (pamax < requested_pa_size) {
41
+ error_report("VCPU supports less PA bits (%d) than "
42
+ "requested by the memory map (%d)",
43
+ pamax, requested_pa_size);
44
+ exit(1);
45
+ }
46
+ }
47
+ }
48
+}
49
+
50
static void machvirt_init(MachineState *machine)
51
{
52
VirtMachineState *vms = VIRT_MACHINE(machine);
53
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
54
fdt_add_timer_nodes(vms);
55
fdt_add_cpu_nodes(vms);
56
57
- if (!kvm_enabled()) {
58
- ARMCPU *cpu = ARM_CPU(first_cpu);
59
- bool aarch64 = object_property_get_bool(OBJECT(cpu), "aarch64", NULL);
60
-
25
-
61
- if (aarch64 && vms->highmem) {
26
-/* debug PC keyboard : only mouse */
62
- int requested_pa_size, pamax = arm_pamax(cpu);
27
-//#define DEBUG_MOUSE
63
-
28
-
64
- requested_pa_size = 64 - clz64(vms->highest_gpa);
29
/* Keyboard Commands */
65
- if (pamax < requested_pa_size) {
30
#define KBD_CMD_SET_LEDS    0xED    /* Set keyboard leds */
66
- error_report("VCPU supports less PA bits (%d) than requested "
31
#define KBD_CMD_ECHO     0xEE
67
- "by the memory map (%d)", pamax, requested_pa_size);
32
@@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(void *opaque, int val)
68
- exit(1);
33
PS2MouseState *s = (PS2MouseState *)opaque;
69
- }
34
70
- }
35
trace_ps2_write_mouse(opaque, val);
71
- }
36
-#ifdef DEBUG_MOUSE
72
-
37
- printf("kbd: write mouse 0x%02x\n", val);
73
memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base,
38
-#endif
74
machine->ram);
39
switch(s->common.write_cmd) {
75
if (machine->device_memory) {
40
default:
76
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
41
case -1:
77
78
create_gic(vms);
79
80
+ virt_cpu_post_init(vms);
81
+
82
fdt_add_pmu_nodes(vms);
83
84
create_uart(vms, VIRT_UART, sysmem, serial_hd(0));
85
--
42
--
86
2.20.1
43
2.20.1
87
44
88
45
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
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.)
2
5
3
Move the KVM PMU setup part of fdt_add_pmu_nodes() to
6
The correct check would be to test whether the TTMR_M field in the
4
virt_cpu_post_init(), which is a more appropriate location. Now
7
register is equal to TIMER_NONE instead. However, the
5
fdt_add_pmu_nodes() is also named more appropriately, because it
8
cpu_openrisc_timer_update() function checks whether the timer is
6
no longer does anything but fdt node creation.
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.
7
13
8
No functional change intended.
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(-)
9
21
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
22
diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
Signed-off-by: Andrew Jones <drjones@redhat.com>
13
Message-id: 20201001061718.101915-5-drjones@redhat.com
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
hw/arm/virt.c | 34 ++++++++++++++++++----------------
17
1 file changed, 18 insertions(+), 16 deletions(-)
18
19
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
20
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/arm/virt.c
24
--- a/target/openrisc/sys_helper.c
22
+++ b/hw/arm/virt.c
25
+++ b/target/openrisc/sys_helper.c
23
@@ -XXX,XX +XXX,XX @@ static void fdt_add_gic_node(VirtMachineState *vms)
26
@@ -XXX,XX +XXX,XX @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)
24
27
25
static void fdt_add_pmu_nodes(const VirtMachineState *vms)
28
case TO_SPR(10, 1): /* TTCR */
26
{
29
cpu_openrisc_count_set(cpu, rb);
27
- CPUState *cpu;
30
- if (env->ttmr & TIMER_NONE) {
28
- ARMCPU *armcpu;
29
+ ARMCPU *armcpu = ARM_CPU(first_cpu);
30
uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI;
31
32
- CPU_FOREACH(cpu) {
33
- armcpu = ARM_CPU(cpu);
34
- if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) {
35
- return;
31
- return;
36
- }
32
- }
37
- if (kvm_enabled()) {
33
cpu_openrisc_timer_update(cpu);
38
- if (kvm_irqchip_in_kernel()) {
34
break;
39
- kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ));
35
#endif
40
- }
41
- kvm_arm_pmu_init(cpu);
42
- }
43
+ if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) {
44
+ assert(!object_property_get_bool(OBJECT(armcpu), "pmu", NULL));
45
+ return;
46
}
47
48
if (vms->gic_version == VIRT_GIC_VERSION_2) {
49
@@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
50
(1 << vms->smp_cpus) - 1);
51
}
52
53
- armcpu = ARM_CPU(qemu_get_cpu(0));
54
qemu_fdt_add_subnode(vms->fdt, "/pmu");
55
if (arm_feature(&armcpu->env, ARM_FEATURE_V8)) {
56
const char compat[] = "arm,armv8-pmuv3";
57
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
58
*/
59
static void virt_cpu_post_init(VirtMachineState *vms)
60
{
61
- bool aarch64;
62
+ bool aarch64, pmu;
63
+ CPUState *cpu;
64
65
aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL);
66
+ pmu = object_property_get_bool(OBJECT(first_cpu), "pmu", NULL);
67
68
- if (!kvm_enabled()) {
69
+ if (kvm_enabled()) {
70
+ CPU_FOREACH(cpu) {
71
+ if (pmu) {
72
+ assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU));
73
+ if (kvm_irqchip_in_kernel()) {
74
+ kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ));
75
+ }
76
+ kvm_arm_pmu_init(cpu);
77
+ }
78
+ }
79
+ } else {
80
if (aarch64 && vms->highmem) {
81
int requested_pa_size = 64 - clz64(vms->highest_gpa);
82
int pamax = arm_pamax(ARM_CPU(first_cpu));
83
--
36
--
84
2.20.1
37
2.20.1
85
38
86
39
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
The "BCM2835 ARM Peripherals" datasheet [*] chapter 2
3
This patch fixes CID 1432800 by removing an unnecessary check.
4
("Auxiliaries: UART1 & SPI1, SPI2"), list the register
5
sizes as 3/8/16/32 bits. We assume this means this
6
peripheral allows 8-bit accesses.
7
4
8
This was not an issue until commit 5d971f9e67 which reverted
5
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
9
("memory: accept mismatching sizes in memory_region_access_valid").
10
11
The model is implemented as 32-bit accesses (see commit 97398d900c,
12
all registers are 32-bit) so replace MemoryRegionOps.valid as
13
MemoryRegionOps.impl, and re-introduce MemoryRegionOps.valid
14
with a 8/32-bit range.
15
16
[*] https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
17
18
Fixes: 97398d900c ("bcm2835_aux: add emulation of BCM2835 AUX (aka UART1) block")
19
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
Message-id: 20201002181032.1899463-1-f4bug@amsat.org
21
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
8
---
24
hw/char/bcm2835_aux.c | 4 +++-
9
hw/core/register.c | 4 ----
25
1 file changed, 3 insertions(+), 1 deletion(-)
10
1 file changed, 4 deletions(-)
26
11
27
diff --git a/hw/char/bcm2835_aux.c b/hw/char/bcm2835_aux.c
12
diff --git a/hw/core/register.c b/hw/core/register.c
28
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/char/bcm2835_aux.c
14
--- a/hw/core/register.c
30
+++ b/hw/char/bcm2835_aux.c
15
+++ b/hw/core/register.c
31
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps bcm2835_aux_ops = {
16
@@ -XXX,XX +XXX,XX @@ static RegisterInfoArray *register_init_block(DeviceState *owner,
32
.read = bcm2835_aux_read,
17
int index = rae[i].addr / data_size;
33
.write = bcm2835_aux_write,
18
RegisterInfo *r = &ri[index];
34
.endianness = DEVICE_NATIVE_ENDIAN,
19
35
- .valid.min_access_size = 4,
20
- if (data + data_size * index == 0 || !&rae[i]) {
36
+ .impl.min_access_size = 4,
21
- continue;
37
+ .impl.max_access_size = 4,
22
- }
38
+ .valid.min_access_size = 1,
23
-
39
.valid.max_access_size = 4,
24
/* Init the register, this will zero it. */
40
};
25
object_initialize((void *)r, sizeof(*r), TYPE_REGISTER);
41
26
42
--
27
--
43
2.20.1
28
2.20.1
44
29
45
30
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Fix Coverity CID 1435957: Memory - illegal accesses (OVERRUN):
4
5
>>> Overrunning array "suffixes" of 7 8-byte elements at element
6
index 7 (byte offset 63) using index "idx" (which evaluates to 7).
7
8
Note, the biggest input value freq_to_str() can accept is UINT64_MAX,
9
which is ~18.446 EHz, less than 1000 EHz.
10
11
Reported-by: Eduardo Habkost <ehabkost@redhat.com>
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
4
Message-id: 20201002080935.1660005-1-f4bug@amsat.org
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.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>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
20
---
8
include/hw/arm/fsl-imx25.h | 2 +-
21
util/cutils.c | 3 ++-
9
1 file changed, 1 insertion(+), 1 deletion(-)
22
1 file changed, 2 insertions(+), 1 deletion(-)
10
23
11
diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h
24
diff --git a/util/cutils.c b/util/cutils.c
12
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
13
--- a/include/hw/arm/fsl-imx25.h
26
--- a/util/cutils.c
14
+++ b/include/hw/arm/fsl-imx25.h
27
+++ b/util/cutils.c
15
@@ -XXX,XX +XXX,XX @@ struct FslIMX25State {
28
@@ -XXX,XX +XXX,XX @@ char *freq_to_str(uint64_t freq_hz)
16
* 0xBB00_0000 0xBB00_0FFF 4 Kbytes NAND flash main area buffer
29
double freq = freq_hz;
17
* 0xBB00_1000 0xBB00_11FF 512 B NAND flash spare area buffer
30
size_t idx = 0;
18
* 0xBB00_1200 0xBB00_1DFF 3 Kbytes Reserved
31
19
- * 0xBB00_1E00 0xBB00_1FFF 512 B NAND flash control regisers
32
- while (freq >= 1000.0 && idx < ARRAY_SIZE(suffixes)) {
20
+ * 0xBB00_1E00 0xBB00_1FFF 512 B NAND flash control registers
33
+ while (freq >= 1000.0) {
21
* 0xBB01_2000 0xBFFF_FFFF 96 Mbytes (minus 8 Kbytes) Reserved
34
freq /= 1000.0;
22
* 0xC000_0000 0xFFFF_FFFF 1024 Mbytes Reserved
35
idx++;
23
*/
36
}
37
+ assert(idx < ARRAY_SIZE(suffixes));
38
39
return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]);
40
}
24
--
41
--
25
2.20.1
42
2.20.1
26
43
27
44
diff view generated by jsdifflib
1
QEMU supports a 48-bit physical address range, but we don't currently
1
In commit 76346b6264a9b01979 we tried to add a configure check that
2
expose it in the '-cpu max' ID registers (you get the same range as
2
the libgio pkg-config data was correct, which builds an executable
3
Cortex-A57, which is 44 bits).
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.
4
8
5
Set the ID_AA64MMFR0.PARange field to indicate 48 bits.
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).
6
17
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
9
Message-id: 20201001160116.18095-1-peter.maydell@linaro.org
20
Message-id: 20201116104617.18333-1-peter.maydell@linaro.org
10
---
21
---
11
target/arm/cpu64.c | 4 ++++
22
configure | 11 +++++++++--
12
1 file changed, 4 insertions(+)
23
1 file changed, 9 insertions(+), 2 deletions(-)
13
24
14
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
25
diff --git a/configure b/configure
15
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100755
16
--- a/target/arm/cpu64.c
27
--- a/configure
17
+++ b/target/arm/cpu64.c
28
+++ b/configure
18
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
29
@@ -XXX,XX +XXX,XX @@ if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
19
t = FIELD_DP64(t, ID_AA64PFR1, MTE, 2);
30
# Check that the libraries actually work -- Ubuntu 18.04 ships
20
cpu->isar.id_aa64pfr1 = t;
31
# with pkg-config --static --libs data for gio-2.0 that is missing
21
32
# -lblkid and will give a link error.
22
+ t = cpu->isar.id_aa64mmfr0;
33
- write_c_skeleton
23
+ t = FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 5); /* PARange: 48 bits */
34
- if compile_prog "" "$gio_libs" ; then
24
+ cpu->isar.id_aa64mmfr0 = t;
35
+ cat > $TMPC <<EOF
25
+
36
+#include <gio/gio.h>
26
t = cpu->isar.id_aa64mmfr1;
37
+int main(void)
27
t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */
38
+{
28
t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1);
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
29
--
47
--
30
2.20.1
48
2.20.1
31
49
32
50
diff view generated by jsdifflib
1
From: Graeme Gregory <graeme@nuviainc.com>
1
The TMP105 datasheet (https://www.ti.com/lit/gpn/tmp105) says that the
2
power-up reset values for the T_low and T_high registers are 80 degrees C
3
and 75 degrees C, which are 0x500 and 0x4B0 hex according to table 5. These
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.
2
7
3
SMMUv3 has an error in a previous patch where an i was transposed to a 1
8
We were resetting these registers to zero, which is problematic for Linux
4
meaning interrupts would not have been correctly assigned to the SMMUv3
9
guests which enable the alert interrupt and then immediately take an
5
instance.
10
unexpected overtemperature alert because the current temperature is above
11
freezing...
6
12
7
Fixes: 48ba18e6d3f3 ("hw/arm/sbsa-ref: Simplify by moving the gic in the machine state")
8
Signed-off-by: Graeme Gregory <graeme@nuviainc.com>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Eric Auger <eric.auger@redhat.com>
11
Message-id: 20201007100732.4103790-2-graeme@nuviainc.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Message-id: 20201110150023.25533-2-peter.maydell@linaro.org
13
---
16
---
14
hw/arm/sbsa-ref.c | 2 +-
17
hw/misc/tmp105.c | 3 +++
15
1 file changed, 1 insertion(+), 1 deletion(-)
18
1 file changed, 3 insertions(+)
16
19
17
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
20
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
18
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/sbsa-ref.c
22
--- a/hw/misc/tmp105.c
20
+++ b/hw/arm/sbsa-ref.c
23
+++ b/hw/misc/tmp105.c
21
@@ -XXX,XX +XXX,XX @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
24
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
22
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
25
s->faults = tmp105_faultq[(s->config >> 3) & 3];
23
for (i = 0; i < NUM_SMMU_IRQS; i++) {
26
s->alarm = 0;
24
sysbus_connect_irq(SYS_BUS_DEVICE(dev), i,
27
25
- qdev_get_gpio_in(sms->gic, irq + 1));
28
+ s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
26
+ qdev_get_gpio_in(sms->gic, irq + i));
29
+ s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
27
}
30
+
31
tmp105_interrupt_update(s);
28
}
32
}
29
33
30
--
34
--
31
2.20.1
35
2.20.1
32
36
33
37
diff view generated by jsdifflib
Deleted patch
1
From: Graeme Gregory <graeme@nuviainc.com>
2
1
3
Original commit did not allocate IRQs for the SMMUv3 in the irqmap
4
effectively using irq 0->3 (shared with other devices). Assuming
5
original intent was to allocate unique IRQs then add an allocation
6
to the irqmap.
7
8
Fixes: e9fdf453240 ("hw/arm: Add arm SBSA reference machine, devices part")
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Signed-off-by: Graeme Gregory <graeme@nuviainc.com>
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
Message-id: 20201007100732.4103790-3-graeme@nuviainc.com
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
hw/arm/sbsa-ref.c | 1 +
16
1 file changed, 1 insertion(+)
17
18
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/sbsa-ref.c
21
+++ b/hw/arm/sbsa-ref.c
22
@@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = {
23
[SBSA_SECURE_UART_MM] = 9,
24
[SBSA_AHCI] = 10,
25
[SBSA_EHCI] = 11,
26
+ [SBSA_SMMU] = 12, /* ... to 15 */
27
};
28
29
static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx)
30
--
31
2.20.1
32
33
diff view generated by jsdifflib
Deleted patch
1
From: Andrew Jones <drjones@redhat.com>
2
1
3
Update against Linux 5.9-rc7.
4
5
Cc: Paolo Bonzini <pbonzini@redhat.com>
6
Signed-off-by: Andrew Jones <drjones@redhat.com>
7
Message-id: 20201001061718.101915-2-drjones@redhat.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
linux-headers/linux/kvm.h | 6 ++++--
11
1 file changed, 4 insertions(+), 2 deletions(-)
12
13
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/linux-headers/linux/kvm.h
16
+++ b/linux-headers/linux/kvm.h
17
@@ -XXX,XX +XXX,XX @@ struct kvm_ppc_resize_hpt {
18
#define KVM_VM_PPC_HV 1
19
#define KVM_VM_PPC_PR 2
20
21
-/* on MIPS, 0 forces trap & emulate, 1 forces VZ ASE */
22
-#define KVM_VM_MIPS_TE        0
23
+/* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */
24
+#define KVM_VM_MIPS_AUTO    0
25
#define KVM_VM_MIPS_VZ        1
26
+#define KVM_VM_MIPS_TE        2
27
28
#define KVM_S390_SIE_PAGE_OFFSET 1
29
30
@@ -XXX,XX +XXX,XX @@ struct kvm_ppc_resize_hpt {
31
#define KVM_CAP_LAST_CPU 184
32
#define KVM_CAP_SMALLER_MAXPHYADDR 185
33
#define KVM_CAP_S390_DIAG318 186
34
+#define KVM_CAP_STEAL_TIME 187
35
36
#ifdef KVM_CAP_IRQ_ROUTING
37
38
--
39
2.20.1
40
41
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
The TMP105 datasheet says that in Interrupt Mode (when TM==1) the device
2
signals an alert when the temperature equals or exceeds the T_high value and
3
then remains high until a device register is read or the device responds to
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 .)
2
10
3
When we compile without KVM support !defined(CONFIG_KVM) we generate
11
We were misimplementing this as a simple "always alert if temperature is
4
stubs for functions that the linker will still encounter. Sometimes
12
above T_high or below T_low" condition, which gives a spurious alert on
5
these stubs can be executed safely and are placed in paths where they
13
startup if using the "T_high = 80 degrees C, T_low = 75 degrees C" reset
6
get executed with or without KVM. Other functions should never be
14
limit values.
7
called without KVM. Those functions should be guarded by kvm_enabled(),
8
but should also be robust to refactoring mistakes. Putting a
9
g_assert_not_reached() in the function should help. Additionally,
10
the g_assert_not_reached() calls may actually help the linker remove
11
some code.
12
15
13
We remove the stubs for kvm_arm_get/put_virtual_time(), as they aren't
16
Implement the correct (hysteresis) behaviour by tracking whether we
14
necessary at all - the only caller is in kvm.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.
15
21
16
Reviewed-by: Eric Auger <eric.auger@redhat.com>
17
Signed-off-by: Andrew Jones <drjones@redhat.com>
18
Message-id: 20201001061718.101915-3-drjones@redhat.com
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
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
20
---
25
---
21
target/arm/kvm_arm.h | 51 +++++++++++++++++++++++++++-----------------
26
hw/misc/tmp105.h | 7 +++++
22
1 file changed, 32 insertions(+), 19 deletions(-)
27
hw/misc/tmp105.c | 70 +++++++++++++++++++++++++++++++++++++++++-------
28
2 files changed, 68 insertions(+), 9 deletions(-)
23
29
24
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
30
diff --git a/hw/misc/tmp105.h b/hw/misc/tmp105.h
25
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/kvm_arm.h
32
--- a/hw/misc/tmp105.h
27
+++ b/target/arm/kvm_arm.h
33
+++ b/hw/misc/tmp105.h
28
@@ -XXX,XX +XXX,XX @@ int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
34
@@ -XXX,XX +XXX,XX @@ struct TMP105State {
29
35
int16_t limit[2];
30
#else
36
int faults;
31
37
uint8_t alarm;
32
-static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
38
+ /*
33
-{
39
+ * The TMP105 initially looks for a temperature rising above T_high;
34
- /*
40
+ * once this is detected, the condition it looks for next is the
35
- * This should never actually be called in the "not KVM" case,
41
+ * temperature falling below T_low. This flag is false when initially
36
- * but set up the fields to indicate an error anyway.
42
+ * looking for T_high, true when looking for T_low.
37
- */
43
+ */
38
- cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
44
+ bool detect_falling;
39
- cpu->host_cpu_probe_failed = true;
45
};
40
-}
46
41
-
47
#endif
42
-static inline void kvm_arm_add_vcpu_properties(Object *obj) {}
48
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
43
-
49
index XXXXXXX..XXXXXXX 100644
44
+/*
50
--- a/hw/misc/tmp105.c
45
+ * It's safe to call these functions without KVM support.
51
+++ b/hw/misc/tmp105.c
46
+ * They should either do nothing or return "not supported".
52
@@ -XXX,XX +XXX,XX @@ static void tmp105_alarm_update(TMP105State *s)
47
+ */
53
return;
48
static inline bool kvm_arm_aarch32_supported(void)
54
}
49
{
55
50
return false;
56
- if ((s->config >> 1) & 1) {                    /* TM */
51
@@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_sve_supported(void)
57
- if (s->temperature >= s->limit[1])
52
return false;
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;
53
}
104
}
54
105
55
+/*
106
+static bool detect_falling_needed(void *opaque)
56
+ * These functions should never actually be called without KVM support.
57
+ */
58
+static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
59
+{
107
+{
60
+ g_assert_not_reached();
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;
61
+}
116
+}
62
+
117
+
63
+static inline void kvm_arm_add_vcpu_properties(Object *obj)
118
+static const VMStateDescription vmstate_tmp105_detect_falling = {
64
+{
119
+ .name = "TMP105/detect-falling",
65
+ g_assert_not_reached();
120
+ .version_id = 1,
66
+}
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
+};
67
+
128
+
68
static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
129
static const VMStateDescription vmstate_tmp105 = {
69
{
130
.name = "TMP105",
70
- return -ENOENT;
131
.version_id = 0,
71
+ g_assert_not_reached();
132
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_tmp105 = {
72
}
133
VMSTATE_UINT8(alarm, TMP105State),
73
134
VMSTATE_I2C_SLAVE(i2c, TMP105State),
74
static inline int kvm_arm_vgic_probe(void)
135
VMSTATE_END_OF_LIST()
75
{
136
+ },
76
- return 0;
137
+ .subsections = (const VMStateDescription*[]) {
77
+ g_assert_not_reached();
138
+ &vmstate_tmp105_detect_falling,
78
}
139
+ NULL
79
140
}
80
-static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {}
141
};
81
-static inline void kvm_arm_pmu_init(CPUState *cs) {}
142
82
+static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq)
143
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
83
+{
144
s->config = 0;
84
+ g_assert_not_reached();
145
s->faults = tmp105_faultq[(s->config >> 3) & 3];
85
+}
146
s->alarm = 0;
86
147
+ s->detect_falling = false;
87
-static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {}
148
88
+static inline void kvm_arm_pmu_init(CPUState *cs)
149
s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
89
+{
150
s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
90
+ g_assert_not_reached();
91
+}
92
+
93
+static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map)
94
+{
95
+ g_assert_not_reached();
96
+}
97
98
-static inline void kvm_arm_get_virtual_time(CPUState *cs) {}
99
-static inline void kvm_arm_put_virtual_time(CPUState *cs) {}
100
#endif
101
102
static inline const char *gic_class_name(void)
103
--
151
--
104
2.20.1
152
2.20.1
105
153
106
154
diff view generated by jsdifflib