1
Ten arm-related bug fixes for 2.12...
1
The following changes since commit b10d00d8811fa4eed4862963273d7353ce310c82:
2
2
3
thanks
3
Merge remote-tracking branch 'remotes/kraxel/tags/seabios-20220118-pull-request' into staging (2022-01-19 18:46:28 +0000)
4
-- PMM
5
6
The following changes since commit 4c2c1015905fa1d616750dfe024b4c0b35875950:
7
8
Merge remote-tracking branch 'remotes/borntraeger/tags/s390x-20180323' into staging (2018-03-23 10:20:54 +0000)
9
4
10
are available in the Git repository at:
5
are available in the Git repository at:
11
6
12
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180323
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220120
13
8
14
for you to fetch changes up to 548f514cf89dd9ab39c0cb4c063097bccf141fdd:
9
for you to fetch changes up to 9705e3c1dcff96b0b3c7e594b6cd68d27d6c4ced:
15
10
16
target/arm: Always set FAR to a known unknown value for debug exceptions (2018-03-23 18:26:46 +0000)
11
hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR (2022-01-20 11:47:54 +0000)
17
12
18
----------------------------------------------------------------
13
----------------------------------------------------------------
19
target-arm queue:
14
target-arm:
20
* arm/translate-a64: don't lose interrupts after unmasking via write to DAIF
15
* hw/intc/arm_gicv3_its: Fix various minor bugs
21
* sdhci: fix incorrect use of Error *
16
* hw/arm/aspeed: Add the i3c device to the AST2600 SoC
22
* hw/intc/arm_gicv3: Fix secure-GIC NS ICC_PMR and ICC_RPR accesses
17
* hw/arm: kudo: add lm75s behind bus 1 switch at 75
23
* hw/arm/bcm2836: Use the Cortex-A7 instead of Cortex-A15
18
* hw/arm/virt: Fix support for running guests on hosts
24
* i.MX: Support serial RS-232 break properly
19
with restricted IPA ranges
25
* mach-virt: Set VM's SMBIOS system version to mc->name
20
* hw/intc/arm_gic: Allow reset of the running priority
26
* target/arm: Honour MDCR_EL2.TDE when routing exceptions due to BKPT/BRK
21
* hw/intc/arm_gic: Implement read of GICC_IIDR
27
* target/arm: Factor out code to calculate FSR for debug exceptions
22
* hw/arm/virt: Support for virtio-mem-pci
28
* target/arm: Set FSR for BKPT, BRK when raising exception
23
* hw/arm/virt: Support CPU cluster on ARM virt machine
29
* target/arm: Always set FAR to a known unknown value for debug exceptions
24
* docs/can: convert to restructuredText
25
* hw/net: Move MV88W8618 network device out of hw/arm/ directory
26
* hw/arm/virt: KVM: Enable PAuth when supported by the host
30
27
31
----------------------------------------------------------------
28
----------------------------------------------------------------
32
Paolo Bonzini (1):
29
Gavin Shan (2):
33
sdhci: fix incorrect use of Error *
30
virtio-mem: Correct default THP size for ARM64
31
hw/arm/virt: Support for virtio-mem-pci
34
32
35
Peter Maydell (6):
33
Lucas Ramage (1):
36
hw/intc/arm_gicv3: Fix secure-GIC NS ICC_PMR and ICC_RPR accesses
34
docs/can: convert to restructuredText
37
hw/arm/bcm2836: Use the Cortex-A7 instead of Cortex-A15
38
target/arm: Honour MDCR_EL2.TDE when routing exceptions due to BKPT/BRK
39
target/arm: Factor out code to calculate FSR for debug exceptions
40
target/arm: Set FSR for BKPT, BRK when raising exception
41
target/arm: Always set FAR to a known unknown value for debug exceptions
42
35
43
Trent Piepho (1):
36
Marc Zyngier (7):
44
i.MX: Support serial RS-232 break properly
37
hw/arm/virt: KVM: Enable PAuth when supported by the host
38
hw/arm/virt: Add a control for the the highmem PCIe MMIO
39
hw/arm/virt: Add a control for the the highmem redistributors
40
hw/arm/virt: Honor highmem setting when computing the memory map
41
hw/arm/virt: Use the PA range to compute the memory map
42
hw/arm/virt: Disable highmem devices that don't fit in the PA range
43
hw/arm/virt: Drop superfluous checks against highmem
45
44
46
Victor Kamensky (1):
45
Patrick Venture (1):
47
arm/translate-a64: treat DISAS_UPDATE as variant of DISAS_EXIT
46
hw/arm: kudo add lm75s behind bus 1 switch at 75
48
47
49
Wei Huang (1):
48
Peter Maydell (13):
50
mach-virt: Set VM's SMBIOS system version to mc->name
49
hw/intc/arm_gicv3_its: Fix event ID bounds checks
50
hw/intc/arm_gicv3_its: Convert int ID check to num_intids convention
51
hw/intc/arm_gicv3_its: Fix handling of process_its_cmd() return value
52
hw/intc/arm_gicv3_its: Don't use data if reading command failed
53
hw/intc/arm_gicv3_its: Use enum for return value of process_* functions
54
hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd()
55
hw/intc/arm_gicv3_its: Refactor process_its_cmd() to reduce nesting
56
hw/intc/arm_gicv3_its: Fix return codes in process_mapti()
57
hw/intc/arm_gicv3_its: Fix return codes in process_mapc()
58
hw/intc/arm_gicv3_its: Fix return codes in process_mapd()
59
hw/intc/arm_gicv3_its: Factor out "find address of table entry" code
60
hw/intc/arm_gicv3_its: Check indexes before use, not after
61
hw/intc/arm_gicv3_its: Range-check ICID before indexing into collection table
51
62
52
include/hw/arm/virt.h | 1 +
63
Petr Pavlu (2):
53
include/hw/char/imx_serial.h | 1 +
64
hw/intc/arm_gic: Implement read of GICC_IIDR
54
target/arm/helper.h | 1 +
65
hw/intc/arm_gic: Allow reset of the running priority
55
target/arm/internals.h | 25 +++++++++++++++++++++++++
56
hw/arm/bcm2836.c | 2 +-
57
hw/arm/raspi.c | 2 +-
58
hw/arm/virt.c | 8 +++++++-
59
hw/char/imx_serial.c | 5 ++++-
60
hw/intc/arm_gicv3_cpuif.c | 6 +++---
61
hw/sd/sdhci.c | 4 ++--
62
target/arm/helper.c | 1 -
63
target/arm/op_helper.c | 33 ++++++++++++++++++++++-----------
64
target/arm/translate-a64.c | 21 ++++++++++++++++-----
65
target/arm/translate.c | 19 ++++++++++++++-----
66
14 files changed, 98 insertions(+), 31 deletions(-)
67
66
67
Philippe Mathieu-Daudé (4):
68
hw: Move MARVELL_88W8618 Kconfig from audio/ to arm/
69
hw/arm/musicpal: Fix coding style of code related to MV88W8618 device
70
hw/net: Move MV88W8618 network device out of hw/arm/ directory
71
hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR
72
73
Troy Lee (2):
74
hw/misc/aspeed_i3c.c: Introduce a dummy AST2600 I3C model.
75
hw/arm/aspeed: Add the i3c device to the AST2600 SoC
76
77
Yanan Wang (6):
78
hw/arm/virt: Support CPU cluster on ARM virt machine
79
hw/arm/virt: Support cluster level in DT cpu-map
80
hw/acpi/aml-build: Improve scalability of PPTT generation
81
tests/acpi/bios-tables-test: Allow changes to virt/PPTT file
82
hw/acpi/aml-build: Support cluster level in PPTT generation
83
tests/acpi/bios-table-test: Update expected virt/PPTT file
84
85
docs/system/arm/cpu-features.rst | 4 -
86
docs/system/device-emulation.rst | 1 +
87
docs/{can.txt => system/devices/can.rst} | 90 +++---
88
include/hw/arm/aspeed_soc.h | 3 +
89
include/hw/arm/virt.h | 5 +-
90
include/hw/misc/aspeed_i3c.h | 48 +++
91
include/hw/net/mv88w8618_eth.h | 12 +
92
target/arm/cpu.h | 1 +
93
hw/acpi/aml-build.c | 68 +++--
94
hw/arm/aspeed_ast2600.c | 16 +
95
hw/arm/musicpal.c | 381 +-----------------------
96
hw/arm/npcm7xx_boards.c | 10 +-
97
hw/arm/virt-acpi-build.c | 10 +-
98
hw/arm/virt.c | 184 ++++++++++--
99
hw/intc/arm_gic.c | 11 +
100
hw/intc/arm_gicv3_its.c | 492 ++++++++++++++-----------------
101
hw/intc/arm_gicv3_redist.c | 4 +-
102
hw/misc/aspeed_i3c.c | 381 ++++++++++++++++++++++++
103
hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++
104
hw/virtio/virtio-mem.c | 36 ++-
105
target/arm/cpu.c | 16 +-
106
target/arm/cpu64.c | 31 +-
107
target/arm/kvm64.c | 21 ++
108
MAINTAINERS | 2 +
109
hw/arm/Kconfig | 4 +
110
hw/audio/Kconfig | 3 -
111
hw/misc/meson.build | 1 +
112
hw/misc/trace-events | 6 +
113
hw/net/meson.build | 1 +
114
qemu-options.hx | 10 +
115
tests/data/acpi/virt/PPTT | Bin 76 -> 96 bytes
116
31 files changed, 1473 insertions(+), 782 deletions(-)
117
rename docs/{can.txt => system/devices/can.rst} (68%)
118
create mode 100644 include/hw/misc/aspeed_i3c.h
119
create mode 100644 include/hw/net/mv88w8618_eth.h
120
create mode 100644 hw/misc/aspeed_i3c.c
121
create mode 100644 hw/net/mv88w8618_eth.c
122
diff view generated by jsdifflib
New patch
1
1
From: Marc Zyngier <maz@kernel.org>
2
3
Add basic support for Pointer Authentication when running a KVM
4
guest and that the host supports it, loosely based on the SVE
5
support.
6
7
Although the feature is enabled by default when the host advertises
8
it, it is possible to disable it by setting the 'pauth=off' CPU
9
property. The 'pauth' comment is removed from cpu-features.rst,
10
as it is now common to both TCG and KVM.
11
12
Tested on an Apple M1 running 5.16-rc6.
13
14
Cc: Eric Auger <eric.auger@redhat.com>
15
Cc: Richard Henderson <richard.henderson@linaro.org>
16
Cc: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Andrew Jones <drjones@redhat.com>
18
Signed-off-by: Marc Zyngier <maz@kernel.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20220107150154.2490308-1-maz@kernel.org
21
[PMM: fixed indentation]
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
24
docs/system/arm/cpu-features.rst | 4 ----
25
target/arm/cpu.h | 1 +
26
target/arm/cpu.c | 16 +++++-----------
27
target/arm/cpu64.c | 31 +++++++++++++++++++++++++++----
28
target/arm/kvm64.c | 21 +++++++++++++++++++++
29
5 files changed, 54 insertions(+), 19 deletions(-)
30
31
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
32
index XXXXXXX..XXXXXXX 100644
33
--- a/docs/system/arm/cpu-features.rst
34
+++ b/docs/system/arm/cpu-features.rst
35
@@ -XXX,XX +XXX,XX @@ TCG VCPU Features
36
TCG VCPU features are CPU features that are specific to TCG.
37
Below is the list of TCG VCPU features and their descriptions.
38
39
- pauth Enable or disable ``FEAT_Pauth``, pointer
40
- authentication. By default, the feature is
41
- enabled with ``-cpu max``.
42
-
43
pauth-impdef When ``FEAT_Pauth`` is enabled, either the
44
*impdef* (Implementation Defined) algorithm
45
is enabled or the *architected* QARMA algorithm
46
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/cpu.h
49
+++ b/target/arm/cpu.h
50
@@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
51
void aarch64_sve_change_el(CPUARMState *env, int old_el,
52
int new_el, bool el0_a64);
53
void aarch64_add_sve_properties(Object *obj);
54
+void aarch64_add_pauth_properties(Object *obj);
55
56
/*
57
* SVE registers are encoded in KVM's memory in an endianness-invariant format.
58
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/cpu.c
61
+++ b/target/arm/cpu.c
62
@@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
63
return;
64
}
65
66
- /*
67
- * KVM does not support modifications to this feature.
68
- * We have not registered the cpu properties when KVM
69
- * is in use, so the user will not be able to set them.
70
- */
71
- if (!kvm_enabled()) {
72
- arm_cpu_pauth_finalize(cpu, &local_err);
73
- if (local_err != NULL) {
74
- error_propagate(errp, local_err);
75
- return;
76
- }
77
+ arm_cpu_pauth_finalize(cpu, &local_err);
78
+ if (local_err != NULL) {
79
+ error_propagate(errp, local_err);
80
+ return;
81
}
82
}
83
84
@@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj)
85
kvm_arm_set_cpu_features_from_host(cpu);
86
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
87
aarch64_add_sve_properties(obj);
88
+ aarch64_add_pauth_properties(obj);
89
}
90
#else
91
hvf_arm_set_cpu_features_from_host(cpu);
92
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/target/arm/cpu64.c
95
+++ b/target/arm/cpu64.c
96
@@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
97
int arch_val = 0, impdef_val = 0;
98
uint64_t t;
99
100
+ /* Exit early if PAuth is enabled, and fall through to disable it */
101
+ if (kvm_enabled() && cpu->prop_pauth) {
102
+ if (!cpu_isar_feature(aa64_pauth, cpu)) {
103
+ error_setg(errp, "'pauth' feature not supported by KVM on this host");
104
+ }
105
+
106
+ return;
107
+ }
108
+
109
/* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */
110
if (cpu->prop_pauth) {
111
if (cpu->prop_pauth_impdef) {
112
@@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pauth_property =
113
static Property arm_cpu_pauth_impdef_property =
114
DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
115
116
+void aarch64_add_pauth_properties(Object *obj)
117
+{
118
+ ARMCPU *cpu = ARM_CPU(obj);
119
+
120
+ /* Default to PAUTH on, with the architected algorithm on TCG. */
121
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
122
+ if (kvm_enabled()) {
123
+ /*
124
+ * Mirror PAuth support from the probed sysregs back into the
125
+ * property for KVM. Is it just a bit backward? Yes it is!
126
+ */
127
+ cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu);
128
+ } else {
129
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
130
+ }
131
+}
132
+
133
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
134
* otherwise, a CPU with as many features enabled as our emulation supports.
135
* The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
136
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
137
cpu->dcz_blocksize = 7; /* 512 bytes */
138
#endif
139
140
- /* Default to PAUTH on, with the architected algorithm. */
141
- qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
142
- qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
143
-
144
bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ);
145
}
146
147
+ aarch64_add_pauth_properties(obj);
148
aarch64_add_sve_properties(obj);
149
object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq,
150
cpu_max_set_sve_max_vq, NULL, NULL);
151
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
152
index XXXXXXX..XXXXXXX 100644
153
--- a/target/arm/kvm64.c
154
+++ b/target/arm/kvm64.c
155
@@ -XXX,XX +XXX,XX @@ static int read_sys_reg64(int fd, uint64_t *pret, uint64_t id)
156
return ioctl(fd, KVM_GET_ONE_REG, &idreg);
157
}
158
159
+static bool kvm_arm_pauth_supported(void)
160
+{
161
+ return (kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_ADDRESS) &&
162
+ kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC));
163
+}
164
+
165
bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
166
{
167
/* Identify the feature bits corresponding to the host CPU, and
168
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
169
*/
170
struct kvm_vcpu_init init = { .target = -1, };
171
172
+ /*
173
+ * Ask for Pointer Authentication if supported. We can't play the
174
+ * SVE trick of synthesising the ID reg as KVM won't tell us
175
+ * whether we have the architected or IMPDEF version of PAuth, so
176
+ * we have to use the actual ID regs.
177
+ */
178
+ if (kvm_arm_pauth_supported()) {
179
+ init.features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
180
+ 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
181
+ }
182
+
183
if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) {
184
return false;
185
}
186
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
187
assert(kvm_arm_sve_supported());
188
cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE;
189
}
190
+ if (cpu_isar_feature(aa64_pauth, cpu)) {
191
+ cpu->kvm_init_features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
192
+ 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
193
+ }
194
195
/* Do KVM_ARM_VCPU_INIT ioctl */
196
ret = kvm_arm_vcpu_init(cs);
197
--
198
2.25.1
199
200
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
2
3
The Marvell 88W8618 is a system-on-chip with an ARM core.
4
We implement its audio codecs and network interface.
5
Homogeneous SoC Kconfig are usually defined in the hw/$ARCH
6
directory. Move it there.
7
8
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20220107184429.423572-2-f4bug@amsat.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/arm/Kconfig | 3 +++
15
hw/audio/Kconfig | 3 ---
16
2 files changed, 3 insertions(+), 3 deletions(-)
17
18
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/Kconfig
21
+++ b/hw/arm/Kconfig
22
@@ -XXX,XX +XXX,XX @@ config MUSCA
23
select SPLIT_IRQ
24
select UNIMP
25
26
+config MARVELL_88W8618
27
+ bool
28
+
29
config MUSICPAL
30
bool
31
select OR_IRQ
32
diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/audio/Kconfig
35
+++ b/hw/audio/Kconfig
36
@@ -XXX,XX +XXX,XX @@ config PL041
37
38
config CS4231
39
bool
40
-
41
-config MARVELL_88W8618
42
- bool
43
--
44
2.25.1
45
46
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
2
3
We are going to move this code, so fix its style first to avoid:
4
5
ERROR: spaces required around that '/' (ctx:VxV)
6
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20220107184429.423572-3-f4bug@amsat.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/musicpal.c | 14 +++++++-------
13
1 file changed, 7 insertions(+), 7 deletions(-)
14
15
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/musicpal.c
18
+++ b/hw/arm/musicpal.c
19
@@ -XXX,XX +XXX,XX @@ static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
20
return s->imr;
21
22
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
23
- return s->frx_queue[(offset - MP_ETH_FRDP0)/4];
24
+ return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
25
26
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
27
- return s->rx_queue[(offset - MP_ETH_CRDP0)/4];
28
+ return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
29
30
case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
31
- return s->tx_queue[(offset - MP_ETH_CTDP0)/4];
32
+ return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
33
34
default:
35
return 0;
36
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_eth_write(void *opaque, hwaddr offset,
37
break;
38
39
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
40
- s->frx_queue[(offset - MP_ETH_FRDP0)/4] = value;
41
+ s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
42
break;
43
44
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
45
- s->rx_queue[(offset - MP_ETH_CRDP0)/4] =
46
- s->cur_rx[(offset - MP_ETH_CRDP0)/4] = value;
47
+ s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
48
+ s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
49
break;
50
51
case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
52
- s->tx_queue[(offset - MP_ETH_CTDP0)/4] = value;
53
+ s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
54
break;
55
}
56
}
57
--
58
2.25.1
59
60
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
2
3
The Marvell 88W8618 network device is hidden in the Musicpal
4
machine. Move it into a new unit file under the hw/net/ directory.
5
6
Acked-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220107184429.423572-4-f4bug@amsat.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/net/mv88w8618_eth.h | 12 +
13
hw/arm/musicpal.c | 381 +------------------------------
14
hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++++++++++
15
MAINTAINERS | 2 +
16
hw/net/meson.build | 1 +
17
5 files changed, 419 insertions(+), 380 deletions(-)
18
create mode 100644 include/hw/net/mv88w8618_eth.h
19
create mode 100644 hw/net/mv88w8618_eth.c
20
21
diff --git a/include/hw/net/mv88w8618_eth.h b/include/hw/net/mv88w8618_eth.h
22
new file mode 100644
23
index XXXXXXX..XXXXXXX
24
--- /dev/null
25
+++ b/include/hw/net/mv88w8618_eth.h
26
@@ -XXX,XX +XXX,XX @@
27
+/* SPDX-License-Identifier: GPL-2.0-or-later */
28
+/*
29
+ * Marvell MV88W8618 / Freecom MusicPal emulation.
30
+ *
31
+ * Copyright (c) 2008-2021 QEMU contributors
32
+ */
33
+#ifndef HW_NET_MV88W8618_H
34
+#define HW_NET_MV88W8618_H
35
+
36
+#define TYPE_MV88W8618_ETH "mv88w8618_eth"
37
+
38
+#endif
39
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/arm/musicpal.c
42
+++ b/hw/arm/musicpal.c
43
@@ -XXX,XX +XXX,XX @@
44
#include "ui/pixel_ops.h"
45
#include "qemu/cutils.h"
46
#include "qom/object.h"
47
+#include "hw/net/mv88w8618_eth.h"
48
49
#define MP_MISC_BASE 0x80002000
50
#define MP_MISC_SIZE 0x00001000
51
52
#define MP_ETH_BASE 0x80008000
53
-#define MP_ETH_SIZE 0x00001000
54
55
#define MP_WLAN_BASE 0x8000C000
56
#define MP_WLAN_SIZE 0x00000800
57
@@ -XXX,XX +XXX,XX @@
58
/* Wolfson 8750 I2C address */
59
#define MP_WM_ADDR 0x1A
60
61
-/* Ethernet register offsets */
62
-#define MP_ETH_SMIR 0x010
63
-#define MP_ETH_PCXR 0x408
64
-#define MP_ETH_SDCMR 0x448
65
-#define MP_ETH_ICR 0x450
66
-#define MP_ETH_IMR 0x458
67
-#define MP_ETH_FRDP0 0x480
68
-#define MP_ETH_FRDP1 0x484
69
-#define MP_ETH_FRDP2 0x488
70
-#define MP_ETH_FRDP3 0x48C
71
-#define MP_ETH_CRDP0 0x4A0
72
-#define MP_ETH_CRDP1 0x4A4
73
-#define MP_ETH_CRDP2 0x4A8
74
-#define MP_ETH_CRDP3 0x4AC
75
-#define MP_ETH_CTDP0 0x4E0
76
-#define MP_ETH_CTDP1 0x4E4
77
-
78
-/* MII PHY access */
79
-#define MP_ETH_SMIR_DATA 0x0000FFFF
80
-#define MP_ETH_SMIR_ADDR 0x03FF0000
81
-#define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */
82
-#define MP_ETH_SMIR_RDVALID (1 << 27)
83
-
84
-/* PHY registers */
85
-#define MP_ETH_PHY1_BMSR 0x00210000
86
-#define MP_ETH_PHY1_PHYSID1 0x00410000
87
-#define MP_ETH_PHY1_PHYSID2 0x00610000
88
-
89
-#define MP_PHY_BMSR_LINK 0x0004
90
-#define MP_PHY_BMSR_AUTONEG 0x0008
91
-
92
-#define MP_PHY_88E3015 0x01410E20
93
-
94
-/* TX descriptor status */
95
-#define MP_ETH_TX_OWN (1U << 31)
96
-
97
-/* RX descriptor status */
98
-#define MP_ETH_RX_OWN (1U << 31)
99
-
100
-/* Interrupt cause/mask bits */
101
-#define MP_ETH_IRQ_RX_BIT 0
102
-#define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT)
103
-#define MP_ETH_IRQ_TXHI_BIT 2
104
-#define MP_ETH_IRQ_TXLO_BIT 3
105
-
106
-/* Port config bits */
107
-#define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */
108
-
109
-/* SDMA command bits */
110
-#define MP_ETH_CMD_TXHI (1 << 23)
111
-#define MP_ETH_CMD_TXLO (1 << 22)
112
-
113
-typedef struct mv88w8618_tx_desc {
114
- uint32_t cmdstat;
115
- uint16_t res;
116
- uint16_t bytes;
117
- uint32_t buffer;
118
- uint32_t next;
119
-} mv88w8618_tx_desc;
120
-
121
-typedef struct mv88w8618_rx_desc {
122
- uint32_t cmdstat;
123
- uint16_t bytes;
124
- uint16_t buffer_size;
125
- uint32_t buffer;
126
- uint32_t next;
127
-} mv88w8618_rx_desc;
128
-
129
-#define TYPE_MV88W8618_ETH "mv88w8618_eth"
130
-OBJECT_DECLARE_SIMPLE_TYPE(mv88w8618_eth_state, MV88W8618_ETH)
131
-
132
-struct mv88w8618_eth_state {
133
- /*< private >*/
134
- SysBusDevice parent_obj;
135
- /*< public >*/
136
-
137
- MemoryRegion iomem;
138
- qemu_irq irq;
139
- MemoryRegion *dma_mr;
140
- AddressSpace dma_as;
141
- uint32_t smir;
142
- uint32_t icr;
143
- uint32_t imr;
144
- int mmio_index;
145
- uint32_t vlan_header;
146
- uint32_t tx_queue[2];
147
- uint32_t rx_queue[4];
148
- uint32_t frx_queue[4];
149
- uint32_t cur_rx[4];
150
- NICState *nic;
151
- NICConf conf;
152
-};
153
-
154
-static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr,
155
- mv88w8618_rx_desc *desc)
156
-{
157
- cpu_to_le32s(&desc->cmdstat);
158
- cpu_to_le16s(&desc->bytes);
159
- cpu_to_le16s(&desc->buffer_size);
160
- cpu_to_le32s(&desc->buffer);
161
- cpu_to_le32s(&desc->next);
162
- dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
163
-}
164
-
165
-static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
166
- mv88w8618_rx_desc *desc)
167
-{
168
- dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
169
- le32_to_cpus(&desc->cmdstat);
170
- le16_to_cpus(&desc->bytes);
171
- le16_to_cpus(&desc->buffer_size);
172
- le32_to_cpus(&desc->buffer);
173
- le32_to_cpus(&desc->next);
174
-}
175
-
176
-static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
177
-{
178
- mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
179
- uint32_t desc_addr;
180
- mv88w8618_rx_desc desc;
181
- int i;
182
-
183
- for (i = 0; i < 4; i++) {
184
- desc_addr = s->cur_rx[i];
185
- if (!desc_addr) {
186
- continue;
187
- }
188
- do {
189
- eth_rx_desc_get(&s->dma_as, desc_addr, &desc);
190
- if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
191
- dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header,
192
- buf, size, MEMTXATTRS_UNSPECIFIED);
193
- desc.bytes = size + s->vlan_header;
194
- desc.cmdstat &= ~MP_ETH_RX_OWN;
195
- s->cur_rx[i] = desc.next;
196
-
197
- s->icr |= MP_ETH_IRQ_RX;
198
- if (s->icr & s->imr) {
199
- qemu_irq_raise(s->irq);
200
- }
201
- eth_rx_desc_put(&s->dma_as, desc_addr, &desc);
202
- return size;
203
- }
204
- desc_addr = desc.next;
205
- } while (desc_addr != s->rx_queue[i]);
206
- }
207
- return size;
208
-}
209
-
210
-static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr,
211
- mv88w8618_tx_desc *desc)
212
-{
213
- cpu_to_le32s(&desc->cmdstat);
214
- cpu_to_le16s(&desc->res);
215
- cpu_to_le16s(&desc->bytes);
216
- cpu_to_le32s(&desc->buffer);
217
- cpu_to_le32s(&desc->next);
218
- dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
219
-}
220
-
221
-static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr,
222
- mv88w8618_tx_desc *desc)
223
-{
224
- dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
225
- le32_to_cpus(&desc->cmdstat);
226
- le16_to_cpus(&desc->res);
227
- le16_to_cpus(&desc->bytes);
228
- le32_to_cpus(&desc->buffer);
229
- le32_to_cpus(&desc->next);
230
-}
231
-
232
-static void eth_send(mv88w8618_eth_state *s, int queue_index)
233
-{
234
- uint32_t desc_addr = s->tx_queue[queue_index];
235
- mv88w8618_tx_desc desc;
236
- uint32_t next_desc;
237
- uint8_t buf[2048];
238
- int len;
239
-
240
- do {
241
- eth_tx_desc_get(&s->dma_as, desc_addr, &desc);
242
- next_desc = desc.next;
243
- if (desc.cmdstat & MP_ETH_TX_OWN) {
244
- len = desc.bytes;
245
- if (len < 2048) {
246
- dma_memory_read(&s->dma_as, desc.buffer, buf, len,
247
- MEMTXATTRS_UNSPECIFIED);
248
- qemu_send_packet(qemu_get_queue(s->nic), buf, len);
249
- }
250
- desc.cmdstat &= ~MP_ETH_TX_OWN;
251
- s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
252
- eth_tx_desc_put(&s->dma_as, desc_addr, &desc);
253
- }
254
- desc_addr = next_desc;
255
- } while (desc_addr != s->tx_queue[queue_index]);
256
-}
257
-
258
-static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
259
- unsigned size)
260
-{
261
- mv88w8618_eth_state *s = opaque;
262
-
263
- switch (offset) {
264
- case MP_ETH_SMIR:
265
- if (s->smir & MP_ETH_SMIR_OPCODE) {
266
- switch (s->smir & MP_ETH_SMIR_ADDR) {
267
- case MP_ETH_PHY1_BMSR:
268
- return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
269
- MP_ETH_SMIR_RDVALID;
270
- case MP_ETH_PHY1_PHYSID1:
271
- return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
272
- case MP_ETH_PHY1_PHYSID2:
273
- return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
274
- default:
275
- return MP_ETH_SMIR_RDVALID;
276
- }
277
- }
278
- return 0;
279
-
280
- case MP_ETH_ICR:
281
- return s->icr;
282
-
283
- case MP_ETH_IMR:
284
- return s->imr;
285
-
286
- case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
287
- return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
288
-
289
- case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
290
- return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
291
-
292
- case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
293
- return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
294
-
295
- default:
296
- return 0;
297
- }
298
-}
299
-
300
-static void mv88w8618_eth_write(void *opaque, hwaddr offset,
301
- uint64_t value, unsigned size)
302
-{
303
- mv88w8618_eth_state *s = opaque;
304
-
305
- switch (offset) {
306
- case MP_ETH_SMIR:
307
- s->smir = value;
308
- break;
309
-
310
- case MP_ETH_PCXR:
311
- s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2;
312
- break;
313
-
314
- case MP_ETH_SDCMR:
315
- if (value & MP_ETH_CMD_TXHI) {
316
- eth_send(s, 1);
317
- }
318
- if (value & MP_ETH_CMD_TXLO) {
319
- eth_send(s, 0);
320
- }
321
- if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) {
322
- qemu_irq_raise(s->irq);
323
- }
324
- break;
325
-
326
- case MP_ETH_ICR:
327
- s->icr &= value;
328
- break;
329
-
330
- case MP_ETH_IMR:
331
- s->imr = value;
332
- if (s->icr & s->imr) {
333
- qemu_irq_raise(s->irq);
334
- }
335
- break;
336
-
337
- case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
338
- s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
339
- break;
340
-
341
- case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
342
- s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
343
- s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
344
- break;
345
-
346
- case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
347
- s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
348
- break;
349
- }
350
-}
351
-
352
-static const MemoryRegionOps mv88w8618_eth_ops = {
353
- .read = mv88w8618_eth_read,
354
- .write = mv88w8618_eth_write,
355
- .endianness = DEVICE_NATIVE_ENDIAN,
356
-};
357
-
358
-static void eth_cleanup(NetClientState *nc)
359
-{
360
- mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
361
-
362
- s->nic = NULL;
363
-}
364
-
365
-static NetClientInfo net_mv88w8618_info = {
366
- .type = NET_CLIENT_DRIVER_NIC,
367
- .size = sizeof(NICState),
368
- .receive = eth_receive,
369
- .cleanup = eth_cleanup,
370
-};
371
-
372
-static void mv88w8618_eth_init(Object *obj)
373
-{
374
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
375
- DeviceState *dev = DEVICE(sbd);
376
- mv88w8618_eth_state *s = MV88W8618_ETH(dev);
377
-
378
- sysbus_init_irq(sbd, &s->irq);
379
- memory_region_init_io(&s->iomem, obj, &mv88w8618_eth_ops, s,
380
- "mv88w8618-eth", MP_ETH_SIZE);
381
- sysbus_init_mmio(sbd, &s->iomem);
382
-}
383
-
384
-static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
385
-{
386
- mv88w8618_eth_state *s = MV88W8618_ETH(dev);
387
-
388
- if (!s->dma_mr) {
389
- error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set");
390
- return;
391
- }
392
-
393
- address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
394
- s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
395
- object_get_typename(OBJECT(dev)), dev->id, s);
396
-}
397
-
398
-static const VMStateDescription mv88w8618_eth_vmsd = {
399
- .name = "mv88w8618_eth",
400
- .version_id = 1,
401
- .minimum_version_id = 1,
402
- .fields = (VMStateField[]) {
403
- VMSTATE_UINT32(smir, mv88w8618_eth_state),
404
- VMSTATE_UINT32(icr, mv88w8618_eth_state),
405
- VMSTATE_UINT32(imr, mv88w8618_eth_state),
406
- VMSTATE_UINT32(vlan_header, mv88w8618_eth_state),
407
- VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2),
408
- VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4),
409
- VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4),
410
- VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4),
411
- VMSTATE_END_OF_LIST()
412
- }
413
-};
414
-
415
-static Property mv88w8618_eth_properties[] = {
416
- DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
417
- DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr,
418
- TYPE_MEMORY_REGION, MemoryRegion *),
419
- DEFINE_PROP_END_OF_LIST(),
420
-};
421
-
422
-static void mv88w8618_eth_class_init(ObjectClass *klass, void *data)
423
-{
424
- DeviceClass *dc = DEVICE_CLASS(klass);
425
-
426
- dc->vmsd = &mv88w8618_eth_vmsd;
427
- device_class_set_props(dc, mv88w8618_eth_properties);
428
- dc->realize = mv88w8618_eth_realize;
429
-}
430
-
431
-static const TypeInfo mv88w8618_eth_info = {
432
- .name = TYPE_MV88W8618_ETH,
433
- .parent = TYPE_SYS_BUS_DEVICE,
434
- .instance_size = sizeof(mv88w8618_eth_state),
435
- .instance_init = mv88w8618_eth_init,
436
- .class_init = mv88w8618_eth_class_init,
437
-};
438
-
439
/* LCD register offsets */
440
#define MP_LCD_IRQCTRL 0x180
441
#define MP_LCD_IRQSTAT 0x184
442
@@ -XXX,XX +XXX,XX @@ static void musicpal_register_types(void)
443
type_register_static(&mv88w8618_pic_info);
444
type_register_static(&mv88w8618_pit_info);
445
type_register_static(&mv88w8618_flashcfg_info);
446
- type_register_static(&mv88w8618_eth_info);
447
type_register_static(&mv88w8618_wlan_info);
448
type_register_static(&musicpal_lcd_info);
449
type_register_static(&musicpal_gpio_info);
450
diff --git a/hw/net/mv88w8618_eth.c b/hw/net/mv88w8618_eth.c
451
new file mode 100644
452
index XXXXXXX..XXXXXXX
453
--- /dev/null
454
+++ b/hw/net/mv88w8618_eth.c
455
@@ -XXX,XX +XXX,XX @@
456
+/* SPDX-License-Identifier: GPL-2.0-or-later */
457
+/*
458
+ * Marvell MV88W8618 / Freecom MusicPal emulation.
459
+ *
460
+ * Copyright (c) 2008 Jan Kiszka
461
+ */
462
+
463
+#include "qemu/osdep.h"
464
+#include "qapi/error.h"
465
+#include "hw/qdev-properties.h"
466
+#include "hw/sysbus.h"
467
+#include "hw/irq.h"
468
+#include "hw/net/mv88w8618_eth.h"
469
+#include "migration/vmstate.h"
470
+#include "sysemu/dma.h"
471
+#include "net/net.h"
472
+
473
+#define MP_ETH_SIZE 0x00001000
474
+
475
+/* Ethernet register offsets */
476
+#define MP_ETH_SMIR 0x010
477
+#define MP_ETH_PCXR 0x408
478
+#define MP_ETH_SDCMR 0x448
479
+#define MP_ETH_ICR 0x450
480
+#define MP_ETH_IMR 0x458
481
+#define MP_ETH_FRDP0 0x480
482
+#define MP_ETH_FRDP1 0x484
483
+#define MP_ETH_FRDP2 0x488
484
+#define MP_ETH_FRDP3 0x48C
485
+#define MP_ETH_CRDP0 0x4A0
486
+#define MP_ETH_CRDP1 0x4A4
487
+#define MP_ETH_CRDP2 0x4A8
488
+#define MP_ETH_CRDP3 0x4AC
489
+#define MP_ETH_CTDP0 0x4E0
490
+#define MP_ETH_CTDP1 0x4E4
491
+
492
+/* MII PHY access */
493
+#define MP_ETH_SMIR_DATA 0x0000FFFF
494
+#define MP_ETH_SMIR_ADDR 0x03FF0000
495
+#define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */
496
+#define MP_ETH_SMIR_RDVALID (1 << 27)
497
+
498
+/* PHY registers */
499
+#define MP_ETH_PHY1_BMSR 0x00210000
500
+#define MP_ETH_PHY1_PHYSID1 0x00410000
501
+#define MP_ETH_PHY1_PHYSID2 0x00610000
502
+
503
+#define MP_PHY_BMSR_LINK 0x0004
504
+#define MP_PHY_BMSR_AUTONEG 0x0008
505
+
506
+#define MP_PHY_88E3015 0x01410E20
507
+
508
+/* TX descriptor status */
509
+#define MP_ETH_TX_OWN (1U << 31)
510
+
511
+/* RX descriptor status */
512
+#define MP_ETH_RX_OWN (1U << 31)
513
+
514
+/* Interrupt cause/mask bits */
515
+#define MP_ETH_IRQ_RX_BIT 0
516
+#define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT)
517
+#define MP_ETH_IRQ_TXHI_BIT 2
518
+#define MP_ETH_IRQ_TXLO_BIT 3
519
+
520
+/* Port config bits */
521
+#define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */
522
+
523
+/* SDMA command bits */
524
+#define MP_ETH_CMD_TXHI (1 << 23)
525
+#define MP_ETH_CMD_TXLO (1 << 22)
526
+
527
+typedef struct mv88w8618_tx_desc {
528
+ uint32_t cmdstat;
529
+ uint16_t res;
530
+ uint16_t bytes;
531
+ uint32_t buffer;
532
+ uint32_t next;
533
+} mv88w8618_tx_desc;
534
+
535
+typedef struct mv88w8618_rx_desc {
536
+ uint32_t cmdstat;
537
+ uint16_t bytes;
538
+ uint16_t buffer_size;
539
+ uint32_t buffer;
540
+ uint32_t next;
541
+} mv88w8618_rx_desc;
542
+
543
+OBJECT_DECLARE_SIMPLE_TYPE(mv88w8618_eth_state, MV88W8618_ETH)
544
+
545
+struct mv88w8618_eth_state {
546
+ /*< private >*/
547
+ SysBusDevice parent_obj;
548
+ /*< public >*/
549
+
550
+ MemoryRegion iomem;
551
+ qemu_irq irq;
552
+ MemoryRegion *dma_mr;
553
+ AddressSpace dma_as;
554
+ uint32_t smir;
555
+ uint32_t icr;
556
+ uint32_t imr;
557
+ int mmio_index;
558
+ uint32_t vlan_header;
559
+ uint32_t tx_queue[2];
560
+ uint32_t rx_queue[4];
561
+ uint32_t frx_queue[4];
562
+ uint32_t cur_rx[4];
563
+ NICState *nic;
564
+ NICConf conf;
565
+};
566
+
567
+static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr,
568
+ mv88w8618_rx_desc *desc)
569
+{
570
+ cpu_to_le32s(&desc->cmdstat);
571
+ cpu_to_le16s(&desc->bytes);
572
+ cpu_to_le16s(&desc->buffer_size);
573
+ cpu_to_le32s(&desc->buffer);
574
+ cpu_to_le32s(&desc->next);
575
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
576
+}
577
+
578
+static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
579
+ mv88w8618_rx_desc *desc)
580
+{
581
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
582
+ le32_to_cpus(&desc->cmdstat);
583
+ le16_to_cpus(&desc->bytes);
584
+ le16_to_cpus(&desc->buffer_size);
585
+ le32_to_cpus(&desc->buffer);
586
+ le32_to_cpus(&desc->next);
587
+}
588
+
589
+static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
590
+{
591
+ mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
592
+ uint32_t desc_addr;
593
+ mv88w8618_rx_desc desc;
594
+ int i;
595
+
596
+ for (i = 0; i < 4; i++) {
597
+ desc_addr = s->cur_rx[i];
598
+ if (!desc_addr) {
599
+ continue;
600
+ }
601
+ do {
602
+ eth_rx_desc_get(&s->dma_as, desc_addr, &desc);
603
+ if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
604
+ dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header,
605
+ buf, size, MEMTXATTRS_UNSPECIFIED);
606
+ desc.bytes = size + s->vlan_header;
607
+ desc.cmdstat &= ~MP_ETH_RX_OWN;
608
+ s->cur_rx[i] = desc.next;
609
+
610
+ s->icr |= MP_ETH_IRQ_RX;
611
+ if (s->icr & s->imr) {
612
+ qemu_irq_raise(s->irq);
613
+ }
614
+ eth_rx_desc_put(&s->dma_as, desc_addr, &desc);
615
+ return size;
616
+ }
617
+ desc_addr = desc.next;
618
+ } while (desc_addr != s->rx_queue[i]);
619
+ }
620
+ return size;
621
+}
622
+
623
+static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr,
624
+ mv88w8618_tx_desc *desc)
625
+{
626
+ cpu_to_le32s(&desc->cmdstat);
627
+ cpu_to_le16s(&desc->res);
628
+ cpu_to_le16s(&desc->bytes);
629
+ cpu_to_le32s(&desc->buffer);
630
+ cpu_to_le32s(&desc->next);
631
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
632
+}
633
+
634
+static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr,
635
+ mv88w8618_tx_desc *desc)
636
+{
637
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
638
+ le32_to_cpus(&desc->cmdstat);
639
+ le16_to_cpus(&desc->res);
640
+ le16_to_cpus(&desc->bytes);
641
+ le32_to_cpus(&desc->buffer);
642
+ le32_to_cpus(&desc->next);
643
+}
644
+
645
+static void eth_send(mv88w8618_eth_state *s, int queue_index)
646
+{
647
+ uint32_t desc_addr = s->tx_queue[queue_index];
648
+ mv88w8618_tx_desc desc;
649
+ uint32_t next_desc;
650
+ uint8_t buf[2048];
651
+ int len;
652
+
653
+ do {
654
+ eth_tx_desc_get(&s->dma_as, desc_addr, &desc);
655
+ next_desc = desc.next;
656
+ if (desc.cmdstat & MP_ETH_TX_OWN) {
657
+ len = desc.bytes;
658
+ if (len < 2048) {
659
+ dma_memory_read(&s->dma_as, desc.buffer, buf, len,
660
+ MEMTXATTRS_UNSPECIFIED);
661
+ qemu_send_packet(qemu_get_queue(s->nic), buf, len);
662
+ }
663
+ desc.cmdstat &= ~MP_ETH_TX_OWN;
664
+ s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
665
+ eth_tx_desc_put(&s->dma_as, desc_addr, &desc);
666
+ }
667
+ desc_addr = next_desc;
668
+ } while (desc_addr != s->tx_queue[queue_index]);
669
+}
670
+
671
+static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
672
+ unsigned size)
673
+{
674
+ mv88w8618_eth_state *s = opaque;
675
+
676
+ switch (offset) {
677
+ case MP_ETH_SMIR:
678
+ if (s->smir & MP_ETH_SMIR_OPCODE) {
679
+ switch (s->smir & MP_ETH_SMIR_ADDR) {
680
+ case MP_ETH_PHY1_BMSR:
681
+ return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
682
+ MP_ETH_SMIR_RDVALID;
683
+ case MP_ETH_PHY1_PHYSID1:
684
+ return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
685
+ case MP_ETH_PHY1_PHYSID2:
686
+ return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
687
+ default:
688
+ return MP_ETH_SMIR_RDVALID;
689
+ }
690
+ }
691
+ return 0;
692
+
693
+ case MP_ETH_ICR:
694
+ return s->icr;
695
+
696
+ case MP_ETH_IMR:
697
+ return s->imr;
698
+
699
+ case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
700
+ return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
701
+
702
+ case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
703
+ return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
704
+
705
+ case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
706
+ return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
707
+
708
+ default:
709
+ return 0;
710
+ }
711
+}
712
+
713
+static void mv88w8618_eth_write(void *opaque, hwaddr offset,
714
+ uint64_t value, unsigned size)
715
+{
716
+ mv88w8618_eth_state *s = opaque;
717
+
718
+ switch (offset) {
719
+ case MP_ETH_SMIR:
720
+ s->smir = value;
721
+ break;
722
+
723
+ case MP_ETH_PCXR:
724
+ s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2;
725
+ break;
726
+
727
+ case MP_ETH_SDCMR:
728
+ if (value & MP_ETH_CMD_TXHI) {
729
+ eth_send(s, 1);
730
+ }
731
+ if (value & MP_ETH_CMD_TXLO) {
732
+ eth_send(s, 0);
733
+ }
734
+ if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) {
735
+ qemu_irq_raise(s->irq);
736
+ }
737
+ break;
738
+
739
+ case MP_ETH_ICR:
740
+ s->icr &= value;
741
+ break;
742
+
743
+ case MP_ETH_IMR:
744
+ s->imr = value;
745
+ if (s->icr & s->imr) {
746
+ qemu_irq_raise(s->irq);
747
+ }
748
+ break;
749
+
750
+ case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
751
+ s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
752
+ break;
753
+
754
+ case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
755
+ s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
756
+ s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
757
+ break;
758
+
759
+ case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
760
+ s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
761
+ break;
762
+ }
763
+}
764
+
765
+static const MemoryRegionOps mv88w8618_eth_ops = {
766
+ .read = mv88w8618_eth_read,
767
+ .write = mv88w8618_eth_write,
768
+ .endianness = DEVICE_NATIVE_ENDIAN,
769
+};
770
+
771
+static void eth_cleanup(NetClientState *nc)
772
+{
773
+ mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
774
+
775
+ s->nic = NULL;
776
+}
777
+
778
+static NetClientInfo net_mv88w8618_info = {
779
+ .type = NET_CLIENT_DRIVER_NIC,
780
+ .size = sizeof(NICState),
781
+ .receive = eth_receive,
782
+ .cleanup = eth_cleanup,
783
+};
784
+
785
+static void mv88w8618_eth_init(Object *obj)
786
+{
787
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
788
+ DeviceState *dev = DEVICE(sbd);
789
+ mv88w8618_eth_state *s = MV88W8618_ETH(dev);
790
+
791
+ sysbus_init_irq(sbd, &s->irq);
792
+ memory_region_init_io(&s->iomem, obj, &mv88w8618_eth_ops, s,
793
+ "mv88w8618-eth", MP_ETH_SIZE);
794
+ sysbus_init_mmio(sbd, &s->iomem);
795
+}
796
+
797
+static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
798
+{
799
+ mv88w8618_eth_state *s = MV88W8618_ETH(dev);
800
+
801
+ if (!s->dma_mr) {
802
+ error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set");
803
+ return;
804
+ }
805
+
806
+ address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
807
+ s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
808
+ object_get_typename(OBJECT(dev)), dev->id, s);
809
+}
810
+
811
+static const VMStateDescription mv88w8618_eth_vmsd = {
812
+ .name = "mv88w8618_eth",
813
+ .version_id = 1,
814
+ .minimum_version_id = 1,
815
+ .fields = (VMStateField[]) {
816
+ VMSTATE_UINT32(smir, mv88w8618_eth_state),
817
+ VMSTATE_UINT32(icr, mv88w8618_eth_state),
818
+ VMSTATE_UINT32(imr, mv88w8618_eth_state),
819
+ VMSTATE_UINT32(vlan_header, mv88w8618_eth_state),
820
+ VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2),
821
+ VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4),
822
+ VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4),
823
+ VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4),
824
+ VMSTATE_END_OF_LIST()
825
+ }
826
+};
827
+
828
+static Property mv88w8618_eth_properties[] = {
829
+ DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
830
+ DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr,
831
+ TYPE_MEMORY_REGION, MemoryRegion *),
832
+ DEFINE_PROP_END_OF_LIST(),
833
+};
834
+
835
+static void mv88w8618_eth_class_init(ObjectClass *klass, void *data)
836
+{
837
+ DeviceClass *dc = DEVICE_CLASS(klass);
838
+
839
+ dc->vmsd = &mv88w8618_eth_vmsd;
840
+ device_class_set_props(dc, mv88w8618_eth_properties);
841
+ dc->realize = mv88w8618_eth_realize;
842
+}
843
+
844
+static const TypeInfo mv88w8618_eth_info = {
845
+ .name = TYPE_MV88W8618_ETH,
846
+ .parent = TYPE_SYS_BUS_DEVICE,
847
+ .instance_size = sizeof(mv88w8618_eth_state),
848
+ .instance_init = mv88w8618_eth_init,
849
+ .class_init = mv88w8618_eth_class_init,
850
+};
851
+
852
+static void musicpal_register_types(void)
853
+{
854
+ type_register_static(&mv88w8618_eth_info);
855
+}
856
+
857
+type_init(musicpal_register_types)
858
+
859
diff --git a/MAINTAINERS b/MAINTAINERS
860
index XXXXXXX..XXXXXXX 100644
861
--- a/MAINTAINERS
862
+++ b/MAINTAINERS
863
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
864
L: qemu-arm@nongnu.org
865
S: Odd Fixes
866
F: hw/arm/musicpal.c
867
+F: hw/net/mv88w8618_eth.c
868
+F: include/hw/net/mv88w8618_eth.h
869
F: docs/system/arm/musicpal.rst
870
871
Nuvoton NPCM7xx
872
diff --git a/hw/net/meson.build b/hw/net/meson.build
873
index XXXXXXX..XXXXXXX 100644
874
--- a/hw/net/meson.build
875
+++ b/hw/net/meson.build
876
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ALLWINNER_EMAC', if_true: files('allwinner_emac.c')
877
softmmu_ss.add(when: 'CONFIG_ALLWINNER_SUN8I_EMAC', if_true: files('allwinner-sun8i-emac.c'))
878
softmmu_ss.add(when: 'CONFIG_IMX_FEC', if_true: files('imx_fec.c'))
879
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-emac.c'))
880
+softmmu_ss.add(when: 'CONFIG_MARVELL_88W8618', if_true: files('mv88w8618_eth.c'))
881
882
softmmu_ss.add(when: 'CONFIG_CADENCE', if_true: files('cadence_gem.c'))
883
softmmu_ss.add(when: 'CONFIG_STELLARIS_ENET', if_true: files('stellaris_enet.c'))
884
--
885
2.25.1
886
887
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
ARM64 machines like Kunpeng Family Server Chips have a level
4
of hardware topology in which a group of CPU cores share L3
5
cache tag or L2 cache. For example, Kunpeng 920 typically
6
has 6 or 8 clusters in each NUMA node (also represent range
7
of CPU die), and each cluster has 4 CPU cores. All clusters
8
share L3 cache data, but CPU cores in each cluster share a
9
local L3 tag.
10
11
Running a guest kernel with Cluster-Aware Scheduling on the
12
Hosts which have physical clusters, if we can design a vCPU
13
topology with cluster level for guest kernel and then have
14
a dedicated vCPU pinning, the guest will gain scheduling
15
performance improvement from cache affinity of CPU cluster.
16
17
So let's enable the support for this new parameter on ARM
18
virt machines. After this patch, we can define a 4-level
19
CPU hierarchy like: cpus=*,maxcpus=*,sockets=*,clusters=*,
20
cores=*,threads=*.
21
22
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
23
Reviewed-by: Andrew Jones <drjones@redhat.com>
24
Message-id: 20220107083232.16256-2-wangyanan55@huawei.com
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
27
hw/arm/virt.c | 1 +
28
qemu-options.hx | 10 ++++++++++
29
2 files changed, 11 insertions(+)
30
31
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/virt.c
34
+++ b/hw/arm/virt.c
35
@@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
36
hc->unplug_request = virt_machine_device_unplug_request_cb;
37
hc->unplug = virt_machine_device_unplug_cb;
38
mc->nvdimm_supported = true;
39
+ mc->smp_props.clusters_supported = true;
40
mc->auto_enable_numa_with_memhp = true;
41
mc->auto_enable_numa_with_memdev = true;
42
mc->default_ram_id = "mach-virt.ram";
43
diff --git a/qemu-options.hx b/qemu-options.hx
44
index XXXXXXX..XXXXXXX 100644
45
--- a/qemu-options.hx
46
+++ b/qemu-options.hx
47
@@ -XXX,XX +XXX,XX @@ SRST
48
49
-smp 16,sockets=2,dies=2,cores=2,threads=2,maxcpus=16
50
51
+ The following sub-option defines a CPU topology hierarchy (2 sockets
52
+ totally on the machine, 2 clusters per socket, 2 cores per cluster,
53
+ 2 threads per core) for ARM virt machines which support sockets/clusters
54
+ /cores/threads. Some members of the option can be omitted but their values
55
+ will be automatically computed:
56
+
57
+ ::
58
+
59
+ -smp 16,sockets=2,clusters=2,cores=2,threads=2,maxcpus=16
60
+
61
Historically preference was given to the coarsest topology parameters
62
when computing missing values (ie sockets preferred over cores, which
63
were preferred over threads), however, this behaviour is considered
64
--
65
2.25.1
66
67
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
Support one cluster level between core and physical package in the
4
cpu-map of Arm/virt devicetree. This is also consistent with Linux
5
Doc "Documentation/devicetree/bindings/cpu/cpu-topology.txt".
6
7
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
8
Reviewed-by: Andrew Jones <drjones@redhat.com>
9
Message-id: 20220107083232.16256-3-wangyanan55@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/virt.c | 15 ++++++++-------
13
1 file changed, 8 insertions(+), 7 deletions(-)
14
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
18
+++ b/hw/arm/virt.c
19
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
20
* can contain several layers of clustering within a single physical
21
* package and cluster nodes can be contained in parent cluster nodes.
22
*
23
- * Given that cluster is not yet supported in the vCPU topology,
24
- * we currently generate one cluster node within each socket node
25
- * by default.
26
+ * Note: currently we only support one layer of clustering within
27
+ * each physical package.
28
*/
29
qemu_fdt_add_subnode(ms->fdt, "/cpus/cpu-map");
30
31
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
32
33
if (ms->smp.threads > 1) {
34
map_path = g_strdup_printf(
35
- "/cpus/cpu-map/socket%d/cluster0/core%d/thread%d",
36
- cpu / (ms->smp.cores * ms->smp.threads),
37
+ "/cpus/cpu-map/socket%d/cluster%d/core%d/thread%d",
38
+ cpu / (ms->smp.clusters * ms->smp.cores * ms->smp.threads),
39
+ (cpu / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters,
40
(cpu / ms->smp.threads) % ms->smp.cores,
41
cpu % ms->smp.threads);
42
} else {
43
map_path = g_strdup_printf(
44
- "/cpus/cpu-map/socket%d/cluster0/core%d",
45
- cpu / ms->smp.cores,
46
+ "/cpus/cpu-map/socket%d/cluster%d/core%d",
47
+ cpu / (ms->smp.clusters * ms->smp.cores),
48
+ (cpu / ms->smp.cores) % ms->smp.clusters,
49
cpu % ms->smp.cores);
50
}
51
qemu_fdt_add_path(ms->fdt, map_path);
52
--
53
2.25.1
54
55
diff view generated by jsdifflib
1
Now that we have a helper function specifically for the BRK and
1
From: Yanan Wang <wangyanan55@huawei.com>
2
BKPT instructions, we can set the exception.fsr there rather
3
than in arm_cpu_do_interrupt_aarch32(). This allows us to
4
use our new arm_debug_exception_fsr() helper.
5
2
6
In particular this fixes a bug where we were hardcoding the
3
Use g_queue APIs to reduce the nested loops and code indentation
7
short-form IFSR value, which is wrong if the target exception
4
with the processor hierarchy levels increasing. Consenquently,
8
level has LPAE enabled.
5
it's more scalable to add new topology level to build_pptt.
9
6
10
Fixes: https://bugs.launchpad.net/qemu/+bug/1756927
7
No functional change intended.
8
9
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
10
Reviewed-by: Andrew Jones <drjones@redhat.com>
11
Message-id: 20220107083232.16256-4-wangyanan55@huawei.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20180320134114.30418-4-peter.maydell@linaro.org
14
---
13
---
15
target/arm/helper.c | 1 -
14
hw/acpi/aml-build.c | 50 +++++++++++++++++++++++++++++----------------
16
target/arm/op_helper.c | 2 ++
15
1 file changed, 32 insertions(+), 18 deletions(-)
17
2 files changed, 2 insertions(+), 1 deletion(-)
18
16
19
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/helper.c
19
--- a/hw/acpi/aml-build.c
22
+++ b/target/arm/helper.c
20
+++ b/hw/acpi/aml-build.c
23
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
21
@@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
24
offset = 0;
22
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
25
break;
23
const char *oem_id, const char *oem_table_id)
26
case EXCP_BKPT:
27
- env->exception.fsr = 2;
28
/* Fall through to prefetch abort. */
29
case EXCP_PREFETCH_ABORT:
30
A32_BANKED_CURRENT_REG_SET(env, ifsr, env->exception.fsr);
31
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/op_helper.c
34
+++ b/target/arm/op_helper.c
35
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_with_syndrome)(CPUARMState *env, uint32_t excp,
36
*/
37
void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome)
38
{
24
{
39
+ /* FSR will only be used if the debug target EL is AArch32. */
25
- int pptt_start = table_data->len;
40
+ env->exception.fsr = arm_debug_exception_fsr(env);
26
+ GQueue *list = g_queue_new();
41
raise_exception(env, EXCP_BKPT, syndrome, arm_debug_target_el(env));
27
+ guint pptt_start = table_data->len;
28
+ guint parent_offset;
29
+ guint length, i;
30
int uid = 0;
31
int socket;
32
AcpiTable table = { .sig = "PPTT", .rev = 2,
33
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
34
acpi_table_begin(&table, table_data);
35
36
for (socket = 0; socket < ms->smp.sockets; socket++) {
37
- uint32_t socket_offset = table_data->len - pptt_start;
38
- int core;
39
-
40
+ g_queue_push_tail(list,
41
+ GUINT_TO_POINTER(table_data->len - pptt_start));
42
build_processor_hierarchy_node(
43
table_data,
44
/*
45
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
46
*/
47
(1 << 0),
48
0, socket, NULL, 0);
49
+ }
50
51
+ length = g_queue_get_length(list);
52
+ for (i = 0; i < length; i++) {
53
+ int core;
54
+
55
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
56
for (core = 0; core < ms->smp.cores; core++) {
57
- uint32_t core_offset = table_data->len - pptt_start;
58
- int thread;
59
-
60
if (ms->smp.threads > 1) {
61
+ g_queue_push_tail(list,
62
+ GUINT_TO_POINTER(table_data->len - pptt_start));
63
build_processor_hierarchy_node(
64
table_data,
65
(0 << 0), /* not a physical package */
66
- socket_offset, core, NULL, 0);
67
-
68
- for (thread = 0; thread < ms->smp.threads; thread++) {
69
- build_processor_hierarchy_node(
70
- table_data,
71
- (1 << 1) | /* ACPI Processor ID valid */
72
- (1 << 2) | /* Processor is a Thread */
73
- (1 << 3), /* Node is a Leaf */
74
- core_offset, uid++, NULL, 0);
75
- }
76
+ parent_offset, core, NULL, 0);
77
} else {
78
build_processor_hierarchy_node(
79
table_data,
80
(1 << 1) | /* ACPI Processor ID valid */
81
(1 << 3), /* Node is a Leaf */
82
- socket_offset, uid++, NULL, 0);
83
+ parent_offset, uid++, NULL, 0);
84
}
85
}
86
}
87
88
+ length = g_queue_get_length(list);
89
+ for (i = 0; i < length; i++) {
90
+ int thread;
91
+
92
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
93
+ for (thread = 0; thread < ms->smp.threads; thread++) {
94
+ build_processor_hierarchy_node(
95
+ table_data,
96
+ (1 << 1) | /* ACPI Processor ID valid */
97
+ (1 << 2) | /* Processor is a Thread */
98
+ (1 << 3), /* Node is a Leaf */
99
+ parent_offset, uid++, NULL, 0);
100
+ }
101
+ }
102
+
103
+ g_queue_free(list);
104
acpi_table_end(linker, &table);
42
}
105
}
43
106
44
--
107
--
45
2.16.2
108
2.25.1
46
109
47
110
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
List test/data/acpi/virt/PPTT as the expected files allowed to
4
be changed in tests/qtest/bios-tables-test-allowed-diff.h
5
6
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
7
Acked-by: Ani Sinha <ani@anisinha.ca>
8
Message-id: 20220107083232.16256-5-wangyanan55@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
tests/qtest/bios-tables-test-allowed-diff.h | 1 +
12
1 file changed, 1 insertion(+)
13
14
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/bios-tables-test-allowed-diff.h
17
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
18
@@ -1 +1,2 @@
19
/* List of comma-separated changed AML files to ignore */
20
+"tests/data/acpi/virt/PPTT",
21
--
22
2.25.1
23
24
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
Support CPU cluster topology level in generation of ACPI
4
Processor Properties Topology Table (PPTT).
5
6
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
7
Reviewed-by: Andrew Jones <drjones@redhat.com>
8
Message-id: 20220107083232.16256-6-wangyanan55@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/acpi/aml-build.c | 18 ++++++++++++++++++
12
1 file changed, 18 insertions(+)
13
14
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/acpi/aml-build.c
17
+++ b/hw/acpi/aml-build.c
18
@@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
19
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
20
const char *oem_id, const char *oem_table_id)
21
{
22
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
23
GQueue *list = g_queue_new();
24
guint pptt_start = table_data->len;
25
guint parent_offset;
26
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
27
0, socket, NULL, 0);
28
}
29
30
+ if (mc->smp_props.clusters_supported) {
31
+ length = g_queue_get_length(list);
32
+ for (i = 0; i < length; i++) {
33
+ int cluster;
34
+
35
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
36
+ for (cluster = 0; cluster < ms->smp.clusters; cluster++) {
37
+ g_queue_push_tail(list,
38
+ GUINT_TO_POINTER(table_data->len - pptt_start));
39
+ build_processor_hierarchy_node(
40
+ table_data,
41
+ (0 << 0), /* not a physical package */
42
+ parent_offset, cluster, NULL, 0);
43
+ }
44
+ }
45
+ }
46
+
47
length = g_queue_get_length(list);
48
for (i = 0; i < length; i++) {
49
int core;
50
--
51
2.25.1
52
53
diff view generated by jsdifflib
New patch
1
From: Yanan Wang <wangyanan55@huawei.com>
1
2
3
Run ./tests/data/acpi/rebuild-expected-aml.sh from build directory
4
to update PPTT binary. Also empty bios-tables-test-allowed-diff.h.
5
6
The disassembled differences between actual and expected PPTT:
7
8
/*
9
* Intel ACPI Component Architecture
10
* AML/ASL+ Disassembler version 20200528 (64-bit version)
11
* Copyright (c) 2000 - 2020 Intel Corporation
12
*
13
- * Disassembly of tests/data/acpi/virt/PPTT, Tue Jan 4 12:51:11 2022
14
+ * Disassembly of /tmp/aml-2ZGOF1, Tue Jan 4 12:51:11 2022
15
*
16
* ACPI Data Table [PPTT]
17
*
18
* Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue
19
*/
20
21
[000h 0000 4] Signature : "PPTT" [Processor Properties Topology Table]
22
-[004h 0004 4] Table Length : 0000004C
23
+[004h 0004 4] Table Length : 00000060
24
[008h 0008 1] Revision : 02
25
-[009h 0009 1] Checksum : A8
26
+[009h 0009 1] Checksum : 48
27
[00Ah 0010 6] Oem ID : "BOCHS "
28
[010h 0016 8] Oem Table ID : "BXPC "
29
[018h 0024 4] Oem Revision : 00000001
30
[01Ch 0028 4] Asl Compiler ID : "BXPC"
31
[020h 0032 4] Asl Compiler Revision : 00000001
32
33
[024h 0036 1] Subtable Type : 00 [Processor Hierarchy Node]
34
[025h 0037 1] Length : 14
35
[026h 0038 2] Reserved : 0000
36
[028h 0040 4] Flags (decoded below) : 00000001
37
Physical package : 1
38
ACPI Processor ID valid : 0
39
Processor is a thread : 0
40
Node is a leaf : 0
41
Identical Implementation : 0
42
[02Ch 0044 4] Parent : 00000000
43
[030h 0048 4] ACPI Processor ID : 00000000
44
[034h 0052 4] Private Resource Number : 00000000
45
46
[038h 0056 1] Subtable Type : 00 [Processor Hierarchy Node]
47
[039h 0057 1] Length : 14
48
[03Ah 0058 2] Reserved : 0000
49
-[03Ch 0060 4] Flags (decoded below) : 0000000A
50
+[03Ch 0060 4] Flags (decoded below) : 00000000
51
Physical package : 0
52
- ACPI Processor ID valid : 1
53
+ ACPI Processor ID valid : 0
54
Processor is a thread : 0
55
- Node is a leaf : 1
56
+ Node is a leaf : 0
57
Identical Implementation : 0
58
[040h 0064 4] Parent : 00000024
59
[044h 0068 4] ACPI Processor ID : 00000000
60
[048h 0072 4] Private Resource Number : 00000000
61
62
-Raw Table Data: Length 76 (0x4C)
63
+[04Ch 0076 1] Subtable Type : 00 [Processor Hierarchy Node]
64
+[04Dh 0077 1] Length : 14
65
+[04Eh 0078 2] Reserved : 0000
66
+[050h 0080 4] Flags (decoded below) : 0000000A
67
+ Physical package : 0
68
+ ACPI Processor ID valid : 1
69
+ Processor is a thread : 0
70
+ Node is a leaf : 1
71
+ Identical Implementation : 0
72
+[054h 0084 4] Parent : 00000038
73
+[058h 0088 4] ACPI Processor ID : 00000000
74
+[05Ch 0092 4] Private Resource Number : 00000000
75
+
76
+Raw Table Data: Length 96 (0x60)
77
78
- 0000: 50 50 54 54 4C 00 00 00 02 A8 42 4F 43 48 53 20 // PPTTL.....BOCHS
79
+ 0000: 50 50 54 54 60 00 00 00 02 48 42 4F 43 48 53 20 // PPTT`....HBOCHS
80
0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC
81
0020: 01 00 00 00 00 14 00 00 01 00 00 00 00 00 00 00 // ................
82
- 0030: 00 00 00 00 00 00 00 00 00 14 00 00 0A 00 00 00 // ................
83
- 0040: 24 00 00 00 00 00 00 00 00 00 00 00 // $...........
84
+ 0030: 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 // ................
85
+ 0040: 24 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 // $...............
86
+ 0050: 0A 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 // ....8...........
87
88
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
89
Reviewed-by: Ani Sinha <ani@anisinha.ca>
90
Message-id: 20220107083232.16256-7-wangyanan55@huawei.com
91
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
92
---
93
tests/qtest/bios-tables-test-allowed-diff.h | 1 -
94
tests/data/acpi/virt/PPTT | Bin 76 -> 96 bytes
95
2 files changed, 1 deletion(-)
96
97
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
98
index XXXXXXX..XXXXXXX 100644
99
--- a/tests/qtest/bios-tables-test-allowed-diff.h
100
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
101
@@ -1,2 +1 @@
102
/* List of comma-separated changed AML files to ignore */
103
-"tests/data/acpi/virt/PPTT",
104
diff --git a/tests/data/acpi/virt/PPTT b/tests/data/acpi/virt/PPTT
105
index XXXXXXX..XXXXXXX 100644
106
GIT binary patch
107
delta 53
108
pcmeZC;0g!`2}xjJU|{l?$YrDgWH5jU5Ca567#O&Klm(arApowi1QY-O
109
110
delta 32
111
fcmYfB;R*-{3GrcIU|?D?k;`ae01J-_kOKn%ZFdCM
112
113
--
114
2.25.1
115
116
diff view generated by jsdifflib
New patch
1
1
From: Lucas Ramage <lucas.ramage@infinite-omicron.com>
2
3
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/527
4
Signed-off-by: Lucas Ramage <lucas.ramage@infinite-omicron.com>
5
Message-id: 20220105205628.5491-1-oxr463@gmx.us
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
[PMM: Move to docs/system/devices/ rather than top-level;
8
fix a pre-existing typo in passing]
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
docs/system/device-emulation.rst | 1 +
12
docs/{can.txt => system/devices/can.rst} | 90 +++++++++++-------------
13
2 files changed, 41 insertions(+), 50 deletions(-)
14
rename docs/{can.txt => system/devices/can.rst} (68%)
15
16
diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst
17
index XXXXXXX..XXXXXXX 100644
18
--- a/docs/system/device-emulation.rst
19
+++ b/docs/system/device-emulation.rst
20
@@ -XXX,XX +XXX,XX @@ Emulated Devices
21
.. toctree::
22
:maxdepth: 1
23
24
+ devices/can.rst
25
devices/ivshmem.rst
26
devices/net.rst
27
devices/nvme.rst
28
diff --git a/docs/can.txt b/docs/system/devices/can.rst
29
similarity index 68%
30
rename from docs/can.txt
31
rename to docs/system/devices/can.rst
32
index XXXXXXX..XXXXXXX 100644
33
--- a/docs/can.txt
34
+++ b/docs/system/devices/can.rst
35
@@ -XXX,XX +XXX,XX @@
36
-QEMU CAN bus emulation support
37
-==============================
38
-
39
+CAN Bus Emulation Support
40
+=========================
41
The CAN bus emulation provides mechanism to connect multiple
42
emulated CAN controller chips together by one or multiple CAN busses
43
(the controller device "canbus" parameter). The individual busses
44
@@ -XXX,XX +XXX,XX @@ emulated environment for testing and RTEMS GSoC slot has been donated
45
to work on CAN hardware emulation on QEMU.
46
47
Examples how to use CAN emulation for SJA1000 based boards
48
-==========================================================
49
-
50
+----------------------------------------------------------
51
When QEMU with CAN PCI support is compiled then one of the next
52
CAN boards can be selected
53
54
- (1) CAN bus Kvaser PCI CAN-S (single SJA1000 channel) boad. QEMU startup options
55
+(1) CAN bus Kvaser PCI CAN-S (single SJA1000 channel) board. QEMU startup options::
56
+
57
-object can-bus,id=canbus0
58
-device kvaser_pci,canbus=canbus0
59
- Add "can-host-socketcan" object to connect device to host system CAN bus
60
+
61
+Add "can-host-socketcan" object to connect device to host system CAN bus::
62
+
63
-object can-host-socketcan,id=canhost0,if=can0,canbus=canbus0
64
65
- (2) CAN bus PCM-3680I PCI (dual SJA1000 channel) emulation
66
+(2) CAN bus PCM-3680I PCI (dual SJA1000 channel) emulation::
67
+
68
-object can-bus,id=canbus0
69
-device pcm3680_pci,canbus0=canbus0,canbus1=canbus0
70
71
- another example:
72
+Another example::
73
+
74
-object can-bus,id=canbus0
75
-object can-bus,id=canbus1
76
-device pcm3680_pci,canbus0=canbus0,canbus1=canbus1
77
78
- (3) CAN bus MIOe-3680 PCI (dual SJA1000 channel) emulation
79
+(3) CAN bus MIOe-3680 PCI (dual SJA1000 channel) emulation::
80
+
81
-device mioe3680_pci,canbus0=canbus0
82
83
-
84
The ''kvaser_pci'' board/device model is compatible with and has been tested with
85
-''kvaser_pci'' driver included in mainline Linux kernel.
86
+the ''kvaser_pci'' driver included in mainline Linux kernel.
87
The tested setup was Linux 4.9 kernel on the host and guest side.
88
-Example for qemu-system-x86_64:
89
+
90
+Example for qemu-system-x86_64::
91
92
qemu-system-x86_64 -accel kvm -kernel /boot/vmlinuz-4.9.0-4-amd64 \
93
-initrd ramdisk.cpio \
94
@@ -XXX,XX +XXX,XX @@ Example for qemu-system-x86_64:
95
-device kvaser_pci,canbus=canbus0 \
96
-nographic -append "console=ttyS0"
97
98
-Example for qemu-system-arm:
99
+Example for qemu-system-arm::
100
101
qemu-system-arm -cpu arm1176 -m 256 -M versatilepb \
102
-kernel kernel-qemu-arm1176-versatilepb \
103
@@ -XXX,XX +XXX,XX @@ Example for qemu-system-arm:
104
The CAN interface of the host system has to be configured for proper
105
bitrate and set up. Configuration is not propagated from emulated
106
devices through bus to the physical host device. Example configuration
107
-for 1 Mbit/s
108
+for 1 Mbit/s::
109
110
ip link set can0 type can bitrate 1000000
111
ip link set can0 up
112
113
Virtual (host local only) can interface can be used on the host
114
-side instead of physical interface
115
+side instead of physical interface::
116
117
ip link add dev can0 type vcan
118
119
The CAN interface on the host side can be used to analyze CAN
120
-traffic with "candump" command which is included in "can-utils".
121
+traffic with "candump" command which is included in "can-utils"::
122
123
candump can0
124
125
CTU CAN FD support examples
126
-===========================
127
-
128
+---------------------------
129
This open-source core provides CAN FD support. CAN FD drames are
130
delivered even to the host systems when SocketCAN interface is found
131
CAN FD capable.
132
@@ -XXX,XX +XXX,XX @@ on the board.
133
Example how to connect the canbus0-bus (virtual wire) to the host
134
Linux system (SocketCAN used) and to both CTU CAN FD cores emulated
135
on the corresponding PCI card expects that host system CAN bus
136
-is setup according to the previous SJA1000 section.
137
+is setup according to the previous SJA1000 section::
138
139
qemu-system-x86_64 -enable-kvm -kernel /boot/vmlinuz-4.19.52+ \
140
-initrd ramdisk.cpio \
141
@@ -XXX,XX +XXX,XX @@ is setup according to the previous SJA1000 section.
142
-device ctucan_pci,canbus0=canbus0-bus,canbus1=canbus0-bus \
143
-nographic
144
145
-Setup of CTU CAN FD controller in a guest Linux system
146
+Setup of CTU CAN FD controller in a guest Linux system::
147
148
insmod ctucanfd.ko || modprobe ctucanfd
149
insmod ctucanfd_pci.ko || modprobe ctucanfd_pci
150
@@ -XXX,XX +XXX,XX @@ Setup of CTU CAN FD controller in a guest Linux system
151
/bin/ip link set $ifc up
152
done
153
154
-The test can run for example
155
+The test can run for example::
156
157
candump can1
158
159
-in the guest system and next commands in the host system for basic CAN
160
+in the guest system and next commands in the host system for basic CAN::
161
162
cangen can0
163
164
-for CAN FD without bitrate switch
165
+for CAN FD without bitrate switch::
166
167
cangen can0 -f
168
169
-and with bitrate switch
170
+and with bitrate switch::
171
172
cangen can0 -b
173
174
@@ -XXX,XX +XXX,XX @@ The test can be run viceversa, generate messages in the guest system and capture
175
in the host one and much more combinations.
176
177
Links to other resources
178
-========================
179
+------------------------
180
181
- (1) CAN related projects at Czech Technical University, Faculty of Electrical Engineering
182
- http://canbus.pages.fel.cvut.cz/
183
- (2) Repository with development can-pci branch at Czech Technical University
184
- https://gitlab.fel.cvut.cz/canbus/qemu-canbus
185
- (3) RTEMS page describing project
186
- https://devel.rtems.org/wiki/Developer/Simulators/QEMU/CANEmulation
187
- (4) RTLWS 2015 article about the project and its use with CANopen emulation
188
- http://cmp.felk.cvut.cz/~pisa/can/doc/rtlws-17-pisa-qemu-can.pdf
189
- (5) GNU/Linux, CAN and CANopen in Real-time Control Applications
190
- Slides from LinuxDays 2017 (include updated RTLWS 2015 content)
191
- https://www.linuxdays.cz/2017/video/Pavel_Pisa-CAN_canopen.pdf
192
- (6) Linux SocketCAN utilities
193
- https://github.com/linux-can/can-utils/
194
- (7) CTU CAN FD project including core VHDL design, Linux driver,
195
- test utilities etc.
196
- https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core
197
- (8) CTU CAN FD Core Datasheet Documentation
198
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/Progdokum.pdf
199
- (9) CTU CAN FD Core System Architecture Documentation
200
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/ctu_can_fd_architecture.pdf
201
- (10) CTU CAN FD Driver Documentation
202
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/driver_doc/ctucanfd-driver.html
203
- (11) Integration with PCIe interfacing for Intel/Altera Cyclone IV based board
204
- https://gitlab.fel.cvut.cz/canbus/pcie-ctu_can_fd
205
+ (1) `CAN related projects at Czech Technical University, Faculty of Electrical Engineering <http://canbus.pages.fel.cvut.cz>`_
206
+ (2) `Repository with development can-pci branch at Czech Technical University <https://gitlab.fel.cvut.cz/canbus/qemu-canbus>`_
207
+ (3) `RTEMS page describing project <https://devel.rtems.org/wiki/Developer/Simulators/QEMU/CANEmulation>`_
208
+ (4) `RTLWS 2015 article about the project and its use with CANopen emulation <http://cmp.felk.cvut.cz/~pisa/can/doc/rtlws-17-pisa-qemu-can.pdf>`_
209
+ (5) `GNU/Linux, CAN and CANopen in Real-time Control Applications Slides from LinuxDays 2017 (include updated RTLWS 2015 content) <https://www.linuxdays.cz/2017/video/Pavel_Pisa-CAN_canopen.pdf>`_
210
+ (6) `Linux SocketCAN utilities <https://github.com/linux-can/can-utils>`_
211
+ (7) `CTU CAN FD project including core VHDL design, Linux driver, test utilities etc. <https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core>`_
212
+ (8) `CTU CAN FD Core Datasheet Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/Progdokum.pdf>`_
213
+ (9) `CTU CAN FD Core System Architecture Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/ctu_can_fd_architecture.pdf>`_
214
+ (10) `CTU CAN FD Driver Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/driver_doc/ctucanfd-driver.html>`_
215
+ (11) `Integration with PCIe interfacing for Intel/Altera Cyclone IV based board <https://gitlab.fel.cvut.cz/canbus/pcie-ctu_can_fd>`_
216
--
217
2.25.1
218
219
diff view generated by jsdifflib
New patch
1
From: Gavin Shan <gshan@redhat.com>
1
2
3
The default block size is same as to the THP size, which is either
4
retrieved from "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size"
5
or hardcoded to 2MB. There are flaws in both mechanisms and this
6
intends to fix them up.
7
8
* When "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size" is
9
used to getting the THP size, 32MB and 512MB are valid values
10
when we have 16KB and 64KB page size on ARM64.
11
12
* When the hardcoded THP size is used, 2MB, 32MB and 512MB are
13
valid values when we have 4KB, 16KB and 64KB page sizes on
14
ARM64.
15
16
Co-developed-by: David Hildenbrand <david@redhat.com>
17
Signed-off-by: Gavin Shan <gshan@redhat.com>
18
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
19
Reviewed-by: David Hildenbrand <david@redhat.com>
20
Message-id: 20220111063329.74447-2-gshan@redhat.com
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
hw/virtio/virtio-mem.c | 32 ++++++++++++++++++++------------
24
1 file changed, 20 insertions(+), 12 deletions(-)
25
26
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
27
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/virtio/virtio-mem.c
29
+++ b/hw/virtio/virtio-mem.c
30
@@ -XXX,XX +XXX,XX @@
31
*/
32
#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)(1 * MiB))
33
34
-#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
35
- defined(__powerpc64__)
36
-#define VIRTIO_MEM_DEFAULT_THP_SIZE ((uint32_t)(2 * MiB))
37
-#else
38
- /* fallback to 1 MiB (e.g., the THP size on s390x) */
39
-#define VIRTIO_MEM_DEFAULT_THP_SIZE VIRTIO_MEM_MIN_BLOCK_SIZE
40
+static uint32_t virtio_mem_default_thp_size(void)
41
+{
42
+ uint32_t default_thp_size = VIRTIO_MEM_MIN_BLOCK_SIZE;
43
+
44
+#if defined(__x86_64__) || defined(__arm__) || defined(__powerpc64__)
45
+ default_thp_size = 2 * MiB;
46
+#elif defined(__aarch64__)
47
+ if (qemu_real_host_page_size == 4 * KiB) {
48
+ default_thp_size = 2 * MiB;
49
+ } else if (qemu_real_host_page_size == 16 * KiB) {
50
+ default_thp_size = 32 * MiB;
51
+ } else if (qemu_real_host_page_size == 64 * KiB) {
52
+ default_thp_size = 512 * MiB;
53
+ }
54
#endif
55
56
+ return default_thp_size;
57
+}
58
+
59
/*
60
* We want to have a reasonable default block size such that
61
* 1. We avoid splitting THPs when unplugging memory, which degrades
62
@@ -XXX,XX +XXX,XX @@ static uint32_t virtio_mem_thp_size(void)
63
if (g_file_get_contents(HPAGE_PMD_SIZE_PATH, &content, NULL, NULL) &&
64
!qemu_strtou64(content, &endptr, 0, &tmp) &&
65
(!endptr || *endptr == '\n')) {
66
- /*
67
- * Sanity-check the value, if it's too big (e.g., aarch64 with 64k base
68
- * pages) or weird, fallback to something smaller.
69
- */
70
- if (!tmp || !is_power_of_2(tmp) || tmp > 16 * MiB) {
71
+ /* Sanity-check the value and fallback to something reasonable. */
72
+ if (!tmp || !is_power_of_2(tmp)) {
73
warn_report("Read unsupported THP size: %" PRIx64, tmp);
74
} else {
75
thp_size = tmp;
76
@@ -XXX,XX +XXX,XX @@ static uint32_t virtio_mem_thp_size(void)
77
}
78
79
if (!thp_size) {
80
- thp_size = VIRTIO_MEM_DEFAULT_THP_SIZE;
81
+ thp_size = virtio_mem_default_thp_size();
82
warn_report("Could not detect THP size, falling back to %" PRIx64
83
" MiB.", thp_size / MiB);
84
}
85
--
86
2.25.1
87
88
diff view generated by jsdifflib
1
The MDCR_EL2.TDE bit allows the exception level targeted by debug
1
From: Gavin Shan <gshan@redhat.com>
2
exceptions to be set to EL2 for code executing at EL0. We handle
3
this in the arm_debug_target_el() function, but this is only used for
4
hardware breakpoint and watchpoint exceptions, not for the exception
5
generated when the guest executes an AArch32 BKPT or AArch64 BRK
6
instruction. We don't have enough information for a translate-time
7
equivalent of arm_debug_target_el(), so instead make BKPT and BRK
8
call a special purpose helper which can do the routing, rather than
9
the generic exception_with_syndrome helper.
10
2
3
This supports virtio-mem-pci device on "virt" platform, by simply
4
following the implementation on x86.
5
6
* This implements the hotplug handlers to support virtio-mem-pci
7
device hot-add, while the hot-remove isn't supported as we have
8
on x86.
9
10
* The block size is 512MB on ARM64 instead of 128MB on x86.
11
12
* It has been passing the tests with various combinations like 64KB
13
and 4KB page sizes on host and guest, different memory device
14
backends like normal, transparent huge page and HugeTLB, plus
15
migration.
16
17
Co-developed-by: David Hildenbrand <david@redhat.com>
18
Co-developed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
19
Signed-off-by: Gavin Shan <gshan@redhat.com>
20
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
21
Reviewed-by: David Hildenbrand <david@redhat.com>
22
Message-id: 20220111063329.74447-3-gshan@redhat.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Message-id: 20180320134114.30418-2-peter.maydell@linaro.org
14
---
24
---
15
target/arm/helper.h | 1 +
25
hw/arm/virt.c | 70 ++++++++++++++++++++++++++++++++++++++++++
16
target/arm/op_helper.c | 8 ++++++++
26
hw/virtio/virtio-mem.c | 4 ++-
17
target/arm/translate-a64.c | 15 +++++++++++++--
27
hw/arm/Kconfig | 1 +
18
target/arm/translate.c | 19 ++++++++++++++-----
28
3 files changed, 74 insertions(+), 1 deletion(-)
19
4 files changed, 36 insertions(+), 7 deletions(-)
20
29
21
diff --git a/target/arm/helper.h b/target/arm/helper.h
30
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
22
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/helper.h
32
--- a/hw/arm/virt.c
24
+++ b/target/arm/helper.h
33
+++ b/hw/arm/virt.c
25
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE,
34
@@ -XXX,XX +XXX,XX @@
26
i32, i32, i32, i32)
35
#include "hw/arm/smmuv3.h"
27
DEF_HELPER_2(exception_internal, void, env, i32)
36
#include "hw/acpi/acpi.h"
28
DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32)
37
#include "target/arm/internals.h"
29
+DEF_HELPER_2(exception_bkpt_insn, void, env, i32)
38
+#include "hw/mem/memory-device.h"
30
DEF_HELPER_1(setend, void, env)
39
#include "hw/mem/pc-dimm.h"
31
DEF_HELPER_2(wfi, void, env, i32)
40
#include "hw/mem/nvdimm.h"
32
DEF_HELPER_1(wfe, void, env)
41
#include "hw/acpi/generic_event_device.h"
33
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
42
+#include "hw/virtio/virtio-mem-pci.h"
34
index XXXXXXX..XXXXXXX 100644
43
#include "hw/virtio/virtio-iommu.h"
35
--- a/target/arm/op_helper.c
44
#include "hw/char/pl011.h"
36
+++ b/target/arm/op_helper.c
45
#include "qemu/guest-random.h"
37
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_with_syndrome)(CPUARMState *env, uint32_t excp,
46
@@ -XXX,XX +XXX,XX @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
38
raise_exception(env, excp, syndrome, target_el);
47
dev, &error_abort);
39
}
48
}
40
49
41
+/* Raise an EXCP_BKPT with the specified syndrome register value,
50
+static void virt_virtio_md_pci_pre_plug(HotplugHandler *hotplug_dev,
42
+ * targeting the correct exception level for debug exceptions.
51
+ DeviceState *dev, Error **errp)
43
+ */
44
+void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome)
45
+{
52
+{
46
+ raise_exception(env, EXCP_BKPT, syndrome, arm_debug_target_el(env));
53
+ HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
54
+ Error *local_err = NULL;
55
+
56
+ if (!hotplug_dev2 && dev->hotplugged) {
57
+ /*
58
+ * Without a bus hotplug handler, we cannot control the plug/unplug
59
+ * order. We should never reach this point when hotplugging on ARM.
60
+ * However, it's nice to add a safety net, similar to what we have
61
+ * on x86.
62
+ */
63
+ error_setg(errp, "hotplug of virtio based memory devices not supported"
64
+ " on this bus.");
65
+ return;
66
+ }
67
+ /*
68
+ * First, see if we can plug this memory device at all. If that
69
+ * succeeds, branch of to the actual hotplug handler.
70
+ */
71
+ memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), NULL,
72
+ &local_err);
73
+ if (!local_err && hotplug_dev2) {
74
+ hotplug_handler_pre_plug(hotplug_dev2, dev, &local_err);
75
+ }
76
+ error_propagate(errp, local_err);
47
+}
77
+}
48
+
78
+
49
uint32_t HELPER(cpsr_read)(CPUARMState *env)
79
+static void virt_virtio_md_pci_plug(HotplugHandler *hotplug_dev,
50
{
80
+ DeviceState *dev, Error **errp)
51
return cpsr_read(env) & ~(CPSR_EXEC | CPSR_RESERVED);
52
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/translate-a64.c
55
+++ b/target/arm/translate-a64.c
56
@@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, int offset, int excp,
57
s->base.is_jmp = DISAS_NORETURN;
58
}
59
60
+static void gen_exception_bkpt_insn(DisasContext *s, int offset,
61
+ uint32_t syndrome)
62
+{
81
+{
63
+ TCGv_i32 tcg_syn;
82
+ HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
83
+ Error *local_err = NULL;
64
+
84
+
65
+ gen_a64_set_pc_im(s->pc - offset);
85
+ /*
66
+ tcg_syn = tcg_const_i32(syndrome);
86
+ * Plug the memory device first and then branch off to the actual
67
+ gen_helper_exception_bkpt_insn(cpu_env, tcg_syn);
87
+ * hotplug handler. If that one fails, we can easily undo the memory
68
+ tcg_temp_free_i32(tcg_syn);
88
+ * device bits.
69
+ s->base.is_jmp = DISAS_NORETURN;
89
+ */
90
+ memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
91
+ if (hotplug_dev2) {
92
+ hotplug_handler_plug(hotplug_dev2, dev, &local_err);
93
+ if (local_err) {
94
+ memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
95
+ }
96
+ }
97
+ error_propagate(errp, local_err);
70
+}
98
+}
71
+
99
+
72
static void gen_ss_advance(DisasContext *s)
100
+static void virt_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev,
73
{
101
+ DeviceState *dev, Error **errp)
74
/* If the singlestep state is Active-not-pending, advance to
75
@@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn)
76
break;
77
}
78
/* BRK */
79
- gen_exception_insn(s, 4, EXCP_BKPT, syn_aa64_bkpt(imm16),
80
- default_exception_el(s));
81
+ gen_exception_bkpt_insn(s, 4, syn_aa64_bkpt(imm16));
82
break;
83
case 2:
84
if (op2_ll != 0) {
85
diff --git a/target/arm/translate.c b/target/arm/translate.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/target/arm/translate.c
88
+++ b/target/arm/translate.c
89
@@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, int offset, int excp,
90
s->base.is_jmp = DISAS_NORETURN;
91
}
92
93
+static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn)
94
+{
102
+{
95
+ TCGv_i32 tcg_syn;
103
+ /* We don't support hot unplug of virtio based memory devices */
96
+
104
+ error_setg(errp, "virtio based memory devices cannot be unplugged.");
97
+ gen_set_condexec(s);
98
+ gen_set_pc_im(s, s->pc - offset);
99
+ tcg_syn = tcg_const_i32(syn);
100
+ gen_helper_exception_bkpt_insn(cpu_env, tcg_syn);
101
+ tcg_temp_free_i32(tcg_syn);
102
+ s->base.is_jmp = DISAS_NORETURN;
103
+}
105
+}
104
+
106
+
105
/* Force a TB lookup after an instruction that changes the CPU state. */
107
+
106
static inline void gen_lookup_tb(DisasContext *s)
108
static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
109
DeviceState *dev, Error **errp)
107
{
110
{
108
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
111
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
109
case 1:
112
110
/* bkpt */
113
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
111
ARCH(5);
114
virt_memory_pre_plug(hotplug_dev, dev, errp);
112
- gen_exception_insn(s, 4, EXCP_BKPT,
115
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
113
- syn_aa32_bkpt(imm16, false),
116
+ virt_virtio_md_pci_pre_plug(hotplug_dev, dev, errp);
114
- default_exception_el(s));
117
} else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
115
+ gen_exception_bkpt_insn(s, 4, syn_aa32_bkpt(imm16, false));
118
hwaddr db_start = 0, db_end = 0;
116
break;
119
char *resv_prop_str;
117
case 2:
120
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
118
/* Hypervisor call (v7) */
121
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
119
@@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn)
122
virt_memory_plug(hotplug_dev, dev, errp);
120
{
123
}
121
int imm8 = extract32(insn, 0, 8);
124
+
122
ARCH(5);
125
+ if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
123
- gen_exception_insn(s, 2, EXCP_BKPT, syn_aa32_bkpt(imm8, true),
126
+ virt_virtio_md_pci_plug(hotplug_dev, dev, errp);
124
- default_exception_el(s));
127
+ }
125
+ gen_exception_bkpt_insn(s, 2, syn_aa32_bkpt(imm8, true));
128
+
126
break;
129
if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
127
}
130
PCIDevice *pdev = PCI_DEVICE(dev);
128
131
132
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
133
{
134
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
135
virt_dimm_unplug_request(hotplug_dev, dev, errp);
136
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
137
+ virt_virtio_md_pci_unplug_request(hotplug_dev, dev, errp);
138
} else {
139
error_setg(errp, "device unplug request for unsupported device"
140
" type: %s", object_get_typename(OBJECT(dev)));
141
@@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
142
143
if (device_is_dynamic_sysbus(mc, dev) ||
144
object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
145
+ object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) ||
146
object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
147
return HOTPLUG_HANDLER(machine);
148
}
149
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
150
index XXXXXXX..XXXXXXX 100644
151
--- a/hw/virtio/virtio-mem.c
152
+++ b/hw/virtio/virtio-mem.c
153
@@ -XXX,XX +XXX,XX @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
154
* The memory block size corresponds mostly to the section size.
155
*
156
* This allows e.g., to add 20MB with a section size of 128MB on x86_64, and
157
- * a section size of 1GB on arm64 (as long as the start address is properly
158
+ * a section size of 512MB on arm64 (as long as the start address is properly
159
* aligned, similar to ordinary DIMMs).
160
*
161
* We can change this at any time and maybe even make it configurable if
162
@@ -XXX,XX +XXX,XX @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
163
*/
164
#if defined(TARGET_X86_64) || defined(TARGET_I386)
165
#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB))
166
+#elif defined(TARGET_ARM)
167
+#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB))
168
#else
169
#error VIRTIO_MEM_USABLE_EXTENT not defined
170
#endif
171
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
172
index XXXXXXX..XXXXXXX 100644
173
--- a/hw/arm/Kconfig
174
+++ b/hw/arm/Kconfig
175
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
176
select ACPI_HW_REDUCED
177
select ACPI_APEI
178
select ACPI_VIOT
179
+ select VIRTIO_MEM_SUPPORTED
180
181
config CHEETAH
182
bool
129
--
183
--
130
2.16.2
184
2.25.1
131
185
132
186
diff view generated by jsdifflib
New patch
1
From: Petr Pavlu <petr.pavlu@suse.com>
1
2
3
Implement support for reading GICC_IIDR. This register is used by the
4
Linux kernel to recognize that GICv2 with GICC_APRn is present.
5
6
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
7
Message-id: 20220113151916.17978-2-ppavlu@suse.cz
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/intc/arm_gic.c | 9 +++++++++
12
1 file changed, 9 insertions(+)
13
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/arm_gic.c
17
+++ b/hw/intc/arm_gic.c
18
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_read(GICState *s, int cpu, int offset,
19
}
20
break;
21
}
22
+ case 0xfc:
23
+ if (s->revision == REV_11MPCORE) {
24
+ /* Reserved on 11MPCore */
25
+ *data = 0;
26
+ } else {
27
+ /* GICv1 or v2; Arm implementation */
28
+ *data = (s->revision << 16) | 0x43b;
29
+ }
30
+ break;
31
default:
32
qemu_log_mask(LOG_GUEST_ERROR,
33
"gic_cpu_read: Bad offset %x\n", (int)offset);
34
--
35
2.25.1
36
37
diff view generated by jsdifflib
New patch
1
From: Petr Pavlu <petr.pavlu@suse.com>
1
2
3
When running Linux on a machine with GICv2, the kernel can crash while
4
processing an interrupt and can subsequently start a kdump kernel from
5
the active interrupt handler. In such a case, the crashed kernel might
6
not gracefully signal the end of interrupt to the GICv2 hardware. The
7
kdump kernel will however try to reset the GIC state on startup to get
8
the controller into a sane state, in particular the kernel writes ones
9
to GICD_ICACTIVERn and wipes out GICC_APRn to make sure that no
10
interrupt is active.
11
12
The patch adds a logic to recalculate the running priority when
13
GICC_APRn/GICC_NSAPRn is written which makes sure that the mentioned
14
reset works with the GICv2 emulation in QEMU too and the kdump kernel
15
starts receiving interrupts.
16
17
The described scenario can be reproduced on an AArch64 QEMU virt machine
18
with a kdump-enabled Linux system by using the softdog module. The kdump
19
kernel will hang at some point because QEMU still thinks the running
20
priority is that of the timer interrupt and asserts no new interrupts to
21
the system:
22
$ modprobe softdog soft_margin=10 soft_panic=1
23
$ cat > /dev/watchdog
24
[Press Enter to start the watchdog, wait for its timeout and observe
25
that the kdump kernel hangs on startup.]
26
27
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
28
Message-id: 20220113151916.17978-3-ppavlu@suse.cz
29
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
---
32
hw/intc/arm_gic.c | 2 ++
33
1 file changed, 2 insertions(+)
34
35
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/intc/arm_gic.c
38
+++ b/hw/intc/arm_gic.c
39
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,
40
} else {
41
s->apr[regno][cpu] = value;
42
}
43
+ s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu);
44
break;
45
}
46
case 0xe0: case 0xe4: case 0xe8: case 0xec:
47
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,
48
return MEMTX_OK;
49
}
50
s->nsapr[regno][cpu] = value;
51
+ s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu);
52
break;
53
}
54
case 0x1000:
55
--
56
2.25.1
57
58
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
Just like we can control the enablement of the highmem PCIe ECAM
4
region using highmem_ecam, let's add a control for the highmem
5
PCIe MMIO region.
6
7
Similarily to highmem_ecam, this region is disabled when highmem
8
is off.
9
10
Signed-off-by: Marc Zyngier <maz@kernel.org>
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
Message-id: 20220114140741.1358263-2-maz@kernel.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
include/hw/arm/virt.h | 1 +
16
hw/arm/virt-acpi-build.c | 10 ++++------
17
hw/arm/virt.c | 7 +++++--
18
3 files changed, 10 insertions(+), 8 deletions(-)
19
20
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/arm/virt.h
23
+++ b/include/hw/arm/virt.h
24
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
25
bool secure;
26
bool highmem;
27
bool highmem_ecam;
28
+ bool highmem_mmio;
29
bool its;
30
bool tcg_its;
31
bool virt;
32
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/virt-acpi-build.c
35
+++ b/hw/arm/virt-acpi-build.c
36
@@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_virtio(Aml *scope,
37
}
38
39
static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
40
- uint32_t irq, bool use_highmem, bool highmem_ecam,
41
- VirtMachineState *vms)
42
+ uint32_t irq, VirtMachineState *vms)
43
{
44
- int ecam_id = VIRT_ECAM_ID(highmem_ecam);
45
+ int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
46
struct GPEXConfig cfg = {
47
.mmio32 = memmap[VIRT_PCIE_MMIO],
48
.pio = memmap[VIRT_PCIE_PIO],
49
@@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
50
.bus = vms->bus,
51
};
52
53
- if (use_highmem) {
54
+ if (vms->highmem_mmio) {
55
cfg.mmio64 = memmap[VIRT_HIGH_PCIE_MMIO];
56
}
57
58
@@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
59
acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
60
acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
61
(irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
62
- acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
63
- vms->highmem, vms->highmem_ecam, vms);
64
+ acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms);
65
if (vms->acpi_dev) {
66
build_ged_aml(scope, "\\_SB."GED_DEVICE,
67
HOTPLUG_HANDLER(vms->acpi_dev),
68
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/arm/virt.c
71
+++ b/hw/arm/virt.c
72
@@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms)
73
mmio_reg, base_mmio, size_mmio);
74
memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);
75
76
- if (vms->highmem) {
77
+ if (vms->highmem_mmio) {
78
/* Map high MMIO space */
79
MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1);
80
81
@@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms)
82
qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg",
83
2, base_ecam, 2, size_ecam);
84
85
- if (vms->highmem) {
86
+ if (vms->highmem_mmio) {
87
qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "ranges",
88
1, FDT_PCI_RANGE_IOPORT, 2, 0,
89
2, base_pio, 2, size_pio,
90
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
91
92
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
93
94
+ vms->highmem_mmio &= vms->highmem;
95
+
96
create_gic(vms, sysmem);
97
98
virt_cpu_post_init(vms, sysmem);
99
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
100
vms->gic_version = VIRT_GIC_VERSION_NOSEL;
101
102
vms->highmem_ecam = !vmc->no_highmem_ecam;
103
+ vms->highmem_mmio = true;
104
105
if (vmc->no_its) {
106
vms->its = false;
107
--
108
2.25.1
109
110
diff view generated by jsdifflib
1
From: Wei Huang <wei@redhat.com>
1
From: Marc Zyngier <maz@kernel.org>
2
2
3
Instead of using "1.0" as the system version of SMBIOS, we should use
3
Just like we can control the enablement of the highmem PCIe region
4
mc->name for mach-virt machine type to be consistent other architectures.
4
using highmem_ecam, let's add a control for the highmem GICv3
5
With this patch, "dmidecode -t 1" (e.g., "-M virt-2.12,accel=kvm") will
5
redistributor region.
6
show:
7
6
8
Handle 0x0100, DMI type 1, 27 bytes
7
Similarily to highmem_ecam, these redistributors are disabled when
9
System Information
8
highmem is off.
10
Manufacturer: QEMU
11
Product Name: KVM Virtual Machine
12
Version: virt-2.12
13
Serial Number: Not Specified
14
...
15
9
16
instead of:
17
18
Handle 0x0100, DMI type 1, 27 bytes
19
System Information
20
Manufacturer: QEMU
21
Product Name: KVM Virtual Machine
22
Version: 1.0
23
Serial Number: Not Specified
24
...
25
26
For backward compatibility, we allow older machine types to keep "1.0"
27
as the default system version.
28
29
Signed-off-by: Wei Huang <wei@redhat.com>
30
Reviewed-by: Andrew Jones <drjones@redhat.com>
10
Reviewed-by: Andrew Jones <drjones@redhat.com>
31
Message-id: 20180322212318.7182-1-wei@redhat.com
11
Signed-off-by: Marc Zyngier <maz@kernel.org>
12
Reviewed-by: Eric Auger <eric.auger@redhat.com>
13
Message-id: 20220114140741.1358263-3-maz@kernel.org
32
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
33
---
15
---
34
include/hw/arm/virt.h | 1 +
16
include/hw/arm/virt.h | 4 +++-
35
hw/arm/virt.c | 8 +++++++-
17
hw/arm/virt-acpi-build.c | 2 ++
36
2 files changed, 8 insertions(+), 1 deletion(-)
18
hw/arm/virt.c | 2 ++
19
3 files changed, 7 insertions(+), 1 deletion(-)
37
20
38
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
21
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
39
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
40
--- a/include/hw/arm/virt.h
23
--- a/include/hw/arm/virt.h
41
+++ b/include/hw/arm/virt.h
24
+++ b/include/hw/arm/virt.h
42
@@ -XXX,XX +XXX,XX @@ typedef struct {
25
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
43
bool no_its;
26
bool highmem;
44
bool no_pmu;
27
bool highmem_ecam;
45
bool claim_edge_triggered_timers;
28
bool highmem_mmio;
46
+ bool smbios_old_sys_ver;
29
+ bool highmem_redists;
47
} VirtMachineClass;
30
bool its;
48
31
bool tcg_its;
49
typedef struct {
32
bool virt;
33
@@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
34
35
assert(vms->gic_version == VIRT_GIC_VERSION_3);
36
37
- return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1;
38
+ return (MACHINE(vms)->smp.cpus > redist0_capacity &&
39
+ vms->highmem_redists) ? 2 : 1;
40
}
41
42
#endif /* QEMU_ARM_VIRT_H */
43
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/arm/virt-acpi-build.c
46
+++ b/hw/arm/virt-acpi-build.c
47
@@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
48
acpi_add_table(table_offsets, tables_blob);
49
build_fadt_rev5(tables_blob, tables->linker, vms, dsdt);
50
51
+ vms->highmem_redists &= vms->highmem;
52
+
53
acpi_add_table(table_offsets, tables_blob);
54
build_madt(tables_blob, tables->linker, vms);
55
50
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
56
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
51
index XXXXXXX..XXXXXXX 100644
57
index XXXXXXX..XXXXXXX 100644
52
--- a/hw/arm/virt.c
58
--- a/hw/arm/virt.c
53
+++ b/hw/arm/virt.c
59
+++ b/hw/arm/virt.c
54
@@ -XXX,XX +XXX,XX @@ static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
60
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
55
61
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
56
static void virt_build_smbios(VirtMachineState *vms)
62
57
{
63
vms->highmem_mmio &= vms->highmem;
58
+ MachineClass *mc = MACHINE_GET_CLASS(vms);
64
+ vms->highmem_redists &= vms->highmem;
59
+ VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
65
60
uint8_t *smbios_tables, *smbios_anchor;
66
create_gic(vms, sysmem);
61
size_t smbios_tables_len, smbios_anchor_len;
67
62
const char *product = "QEMU Virtual Machine";
68
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
63
@@ -XXX,XX +XXX,XX @@ static void virt_build_smbios(VirtMachineState *vms)
69
64
}
70
vms->highmem_ecam = !vmc->no_highmem_ecam;
65
71
vms->highmem_mmio = true;
66
smbios_set_defaults("QEMU", product,
72
+ vms->highmem_redists = true;
67
- "1.0", false, true, SMBIOS_ENTRY_POINT_30);
73
68
+ vmc->smbios_old_sys_ver ? "1.0" : mc->name, false,
74
if (vmc->no_its) {
69
+ true, SMBIOS_ENTRY_POINT_30);
75
vms->its = false;
70
71
smbios_get_tables(NULL, 0, &smbios_tables, &smbios_tables_len,
72
&smbios_anchor, &smbios_anchor_len);
73
@@ -XXX,XX +XXX,XX @@ static void virt_2_11_instance_init(Object *obj)
74
75
static void virt_machine_2_11_options(MachineClass *mc)
76
{
77
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
78
+
79
virt_machine_2_12_options(mc);
80
SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_11);
81
+ vmc->smbios_old_sys_ver = true;
82
}
83
DEFINE_VIRT_MACHINE(2, 11)
84
85
--
76
--
86
2.16.2
77
2.25.1
87
78
88
79
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
Even when the VM is configured with highmem=off, the highest_gpa
4
field includes devices that are above the 4GiB limit.
5
Similarily, nothing seem to check that the memory is within
6
the limit set by the highmem=off option.
7
8
This leads to failures in virt_kvm_type() on systems that have
9
a crippled IPA range, as the reported IPA space is larger than
10
what it should be.
11
12
Instead, honor the user-specified limit to only use the devices
13
at the lowest end of the spectrum, and fail if we have memory
14
crossing the 4GiB limit.
15
16
Reviewed-by: Andrew Jones <drjones@redhat.com>
17
Reviewed-by: Eric Auger <eric.auger@redhat.com>
18
Signed-off-by: Marc Zyngier <maz@kernel.org>
19
Message-id: 20220114140741.1358263-4-maz@kernel.org
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
22
hw/arm/virt.c | 10 +++++++---
23
1 file changed, 7 insertions(+), 3 deletions(-)
24
25
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/arm/virt.c
28
+++ b/hw/arm/virt.c
29
@@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
30
static void virt_set_memmap(VirtMachineState *vms)
31
{
32
MachineState *ms = MACHINE(vms);
33
- hwaddr base, device_memory_base, device_memory_size;
34
+ hwaddr base, device_memory_base, device_memory_size, memtop;
35
int i;
36
37
vms->memmap = extended_memmap;
38
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
39
device_memory_size = ms->maxram_size - ms->ram_size + ms->ram_slots * GiB;
40
41
/* Base address of the high IO region */
42
- base = device_memory_base + ROUND_UP(device_memory_size, GiB);
43
+ memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
44
+ if (!vms->highmem && memtop > 4 * GiB) {
45
+ error_report("highmem=off, but memory crosses the 4GiB limit\n");
46
+ exit(EXIT_FAILURE);
47
+ }
48
if (base < device_memory_base) {
49
error_report("maxmem/slots too huge");
50
exit(EXIT_FAILURE);
51
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
52
vms->memmap[i].size = size;
53
base += size;
54
}
55
- vms->highest_gpa = base - 1;
56
+ vms->highest_gpa = (vms->highmem ? base : memtop) - 1;
57
if (device_memory_size > 0) {
58
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
59
ms->device_memory->base = device_memory_base;
60
--
61
2.25.1
62
63
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
The highmem attribute is nothing but another way to express the
4
PA range of a VM. To support HW that has a smaller PA range then
5
what QEMU assumes, pass this PA range to the virt_set_memmap()
6
function, allowing it to correctly exclude highmem devices
7
if they are outside of the PA range.
8
9
Signed-off-by: Marc Zyngier <maz@kernel.org>
10
Reviewed-by: Eric Auger <eric.auger@redhat.com>
11
Message-id: 20220114140741.1358263-5-maz@kernel.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/arm/virt.c | 64 +++++++++++++++++++++++++++++++++++++++++----------
15
1 file changed, 52 insertions(+), 12 deletions(-)
16
17
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/virt.c
20
+++ b/hw/arm/virt.c
21
@@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
22
return arm_cpu_mp_affinity(idx, clustersz);
23
}
24
25
-static void virt_set_memmap(VirtMachineState *vms)
26
+static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
27
{
28
MachineState *ms = MACHINE(vms);
29
hwaddr base, device_memory_base, device_memory_size, memtop;
30
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
31
exit(EXIT_FAILURE);
32
}
33
34
+ /*
35
+ * !highmem is exactly the same as limiting the PA space to 32bit,
36
+ * irrespective of the underlying capabilities of the HW.
37
+ */
38
+ if (!vms->highmem) {
39
+ pa_bits = 32;
40
+ }
41
+
42
/*
43
* We compute the base of the high IO region depending on the
44
* amount of initial and device memory. The device memory start/size
45
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
46
47
/* Base address of the high IO region */
48
memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
49
- if (!vms->highmem && memtop > 4 * GiB) {
50
- error_report("highmem=off, but memory crosses the 4GiB limit\n");
51
+ if (memtop > BIT_ULL(pa_bits)) {
52
+     error_report("Addressing limited to %d bits, but memory exceeds it by %llu bytes\n",
53
+             pa_bits, memtop - BIT_ULL(pa_bits));
54
exit(EXIT_FAILURE);
55
}
56
if (base < device_memory_base) {
57
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
58
vms->memmap[i].size = size;
59
base += size;
60
}
61
- vms->highest_gpa = (vms->highmem ? base : memtop) - 1;
62
+
63
+ /*
64
+ * If base fits within pa_bits, all good. If it doesn't, limit it
65
+ * to the end of RAM, which is guaranteed to fit within pa_bits.
66
+ */
67
+ vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1;
68
+
69
if (device_memory_size > 0) {
70
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
71
ms->device_memory->base = device_memory_base;
72
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
73
unsigned int smp_cpus = machine->smp.cpus;
74
unsigned int max_cpus = machine->smp.max_cpus;
75
76
+ if (!cpu_type_valid(machine->cpu_type)) {
77
+ error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
78
+ exit(1);
79
+ }
80
+
81
+ possible_cpus = mc->possible_cpu_arch_ids(machine);
82
+
83
/*
84
* In accelerated mode, the memory map is computed earlier in kvm_type()
85
* to create a VM with the right number of IPA bits.
86
*/
87
if (!vms->memmap) {
88
- virt_set_memmap(vms);
89
+ Object *cpuobj;
90
+ ARMCPU *armcpu;
91
+ int pa_bits;
92
+
93
+ /*
94
+ * Instanciate a temporary CPU object to find out about what
95
+ * we are about to deal with. Once this is done, get rid of
96
+ * the object.
97
+ */
98
+ cpuobj = object_new(possible_cpus->cpus[0].type);
99
+ armcpu = ARM_CPU(cpuobj);
100
+
101
+ if (object_property_get_bool(cpuobj, "aarch64", NULL)) {
102
+ pa_bits = arm_pamax(armcpu);
103
+ } else if (arm_feature(&armcpu->env, ARM_FEATURE_LPAE)) {
104
+ /* v7 with LPAE */
105
+ pa_bits = 40;
106
+ } else {
107
+ /* Anything else */
108
+ pa_bits = 32;
109
+ }
110
+
111
+ object_unref(cpuobj);
112
+
113
+ virt_set_memmap(vms, pa_bits);
114
}
115
116
/* We can probe only here because during property set
117
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
118
*/
119
finalize_gic_version(vms);
120
121
- if (!cpu_type_valid(machine->cpu_type)) {
122
- error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
123
- exit(1);
124
- }
125
-
126
if (vms->secure) {
127
/*
128
* The Secure view of the world is the same as the NonSecure,
129
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
130
131
create_fdt(vms);
132
133
- possible_cpus = mc->possible_cpu_arch_ids(machine);
134
assert(possible_cpus->len == max_cpus);
135
for (n = 0; n < possible_cpus->len; n++) {
136
Object *cpuobj;
137
@@ -XXX,XX +XXX,XX @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
138
max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa);
139
140
/* we freeze the memory map to compute the highest gpa */
141
- virt_set_memmap(vms);
142
+ virt_set_memmap(vms, max_vm_pa_size);
143
144
requested_pa_size = 64 - clz64(vms->highest_gpa);
145
146
--
147
2.25.1
148
149
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
In order to only keep the highmem devices that actually fit in
4
the PA range, check their location against the range and update
5
highest_gpa if they fit. If they don't, mark them as disabled.
6
7
Signed-off-by: Marc Zyngier <maz@kernel.org>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Message-id: 20220114140741.1358263-6-maz@kernel.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/virt.c | 34 ++++++++++++++++++++++++++++------
13
1 file changed, 28 insertions(+), 6 deletions(-)
14
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
18
+++ b/hw/arm/virt.c
19
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
20
base = vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES;
21
}
22
23
+ /* We know for sure that at least the memory fits in the PA space */
24
+ vms->highest_gpa = memtop - 1;
25
+
26
for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
27
hwaddr size = extended_memmap[i].size;
28
+ bool fits;
29
30
base = ROUND_UP(base, size);
31
vms->memmap[i].base = base;
32
vms->memmap[i].size = size;
33
+
34
+ /*
35
+ * Check each device to see if they fit in the PA space,
36
+ * moving highest_gpa as we go.
37
+ *
38
+ * For each device that doesn't fit, disable it.
39
+ */
40
+ fits = (base + size) <= BIT_ULL(pa_bits);
41
+ if (fits) {
42
+ vms->highest_gpa = base + size - 1;
43
+ }
44
+
45
+ switch (i) {
46
+ case VIRT_HIGH_GIC_REDIST2:
47
+ vms->highmem_redists &= fits;
48
+ break;
49
+ case VIRT_HIGH_PCIE_ECAM:
50
+ vms->highmem_ecam &= fits;
51
+ break;
52
+ case VIRT_HIGH_PCIE_MMIO:
53
+ vms->highmem_mmio &= fits;
54
+ break;
55
+ }
56
+
57
base += size;
58
}
59
60
- /*
61
- * If base fits within pa_bits, all good. If it doesn't, limit it
62
- * to the end of RAM, which is guaranteed to fit within pa_bits.
63
- */
64
- vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1;
65
-
66
if (device_memory_size > 0) {
67
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
68
ms->device_memory->base = device_memory_base;
69
--
70
2.25.1
71
72
diff view generated by jsdifflib
New patch
1
From: Marc Zyngier <maz@kernel.org>
1
2
3
Now that the devices present in the extended memory map are checked
4
against the available PA space and disabled when they don't fit,
5
there is no need to keep the same checks against highmem, as
6
highmem really is a shortcut for the PA space being 32bit.
7
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Marc Zyngier <maz@kernel.org>
10
Message-id: 20220114140741.1358263-7-maz@kernel.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
hw/arm/virt-acpi-build.c | 2 --
14
hw/arm/virt.c | 5 +----
15
2 files changed, 1 insertion(+), 6 deletions(-)
16
17
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/virt-acpi-build.c
20
+++ b/hw/arm/virt-acpi-build.c
21
@@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
22
acpi_add_table(table_offsets, tables_blob);
23
build_fadt_rev5(tables_blob, tables->linker, vms, dsdt);
24
25
- vms->highmem_redists &= vms->highmem;
26
-
27
acpi_add_table(table_offsets, tables_blob);
28
build_madt(tables_blob, tables->linker, vms);
29
30
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/arm/virt.c
33
+++ b/hw/arm/virt.c
34
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
35
36
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
37
38
- vms->highmem_mmio &= vms->highmem;
39
- vms->highmem_redists &= vms->highmem;
40
-
41
create_gic(vms, sysmem);
42
43
virt_cpu_post_init(vms, sysmem);
44
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
45
machine->ram_size, "mach-virt.tag");
46
}
47
48
- vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64);
49
+ vms->highmem_ecam &= (!firmware_loaded || aarch64);
50
51
create_rtc(vms);
52
53
--
54
2.25.1
55
56
diff view generated by jsdifflib
New patch
1
From: Patrick Venture <venture@google.com>
1
2
3
Reviewed-by: Hao Wu <wuhaotsh@google.com>
4
Signed-off-by: Patrick Venture <venture@google.com>
5
Message-id: 20220111172338.1525587-1-venture@google.com
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
hw/arm/npcm7xx_boards.c | 10 +++++++++-
10
1 file changed, 9 insertions(+), 1 deletion(-)
11
12
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/arm/npcm7xx_boards.c
15
+++ b/hw/arm/npcm7xx_boards.c
16
@@ -XXX,XX +XXX,XX @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
17
{
18
I2CSlave *i2c_mux;
19
20
- i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x75);
21
+ i2c_mux = i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1),
22
+ TYPE_PCA9548, 0x75);
23
+
24
+ /* tmp105 is compatible with the lm75 */
25
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x5c);
26
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x5c);
27
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 6), "tmp105", 0x5c);
28
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 7), "tmp105", 0x5c);
29
+
30
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x77);
31
32
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77);
33
--
34
2.25.1
35
36
diff view generated by jsdifflib
1
From: Trent Piepho <tpiepho@impinj.com>
1
From: Troy Lee <troy_lee@aspeedtech.com>
2
2
3
Linux does not detect a break from this IMX serial driver as a magic
3
Aspeed 2600 SDK enables I3C support by default. The I3C driver will try
4
sysrq. Nor does it note a break in the port error counts.
4
to reset the device controller and set it up through device address table
5
register. This dummy model responds to these registers with default values
6
as listed in the ast2600v10 datasheet chapter 54.2.
5
7
6
The former is because the Linux driver uses the BRCD bit in the USR2
8
This avoids a guest machine kernel panic due to referencing an
7
register to trigger the RS-232 break handler in the kernel, which is
9
invalid kernel address if the device address table register isn't
8
where sysrq hooks in. The emulated UART was not setting this status
10
set correctly.
9
bit.
10
11
11
The latter is because the Linux driver expects, in addition to the BRK
12
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
12
bit, that the ERR bit is set when a break is read in the FIFO. A break
13
Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com>
13
should also count as a frame error, so add that bit too.
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
14
15
Tested-by: Graeme Gregory <quic_ggregory@quicinc.com>
15
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
16
Message-id: 20220111084546.4145785-2-troy_lee@aspeedtech.com
16
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
17
[PMM: tidied commit message]
17
Message-id: 20180320013657.25038-1-tpiepho@impinj.com
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
19
---
21
include/hw/char/imx_serial.h | 1 +
20
include/hw/misc/aspeed_i3c.h | 48 +++++
22
hw/char/imx_serial.c | 5 ++++-
21
hw/misc/aspeed_i3c.c | 381 +++++++++++++++++++++++++++++++++++
23
2 files changed, 5 insertions(+), 1 deletion(-)
22
hw/misc/meson.build | 1 +
23
hw/misc/trace-events | 6 +
24
4 files changed, 436 insertions(+)
25
create mode 100644 include/hw/misc/aspeed_i3c.h
26
create mode 100644 hw/misc/aspeed_i3c.c
24
27
25
diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h
28
diff --git a/include/hw/misc/aspeed_i3c.h b/include/hw/misc/aspeed_i3c.h
29
new file mode 100644
30
index XXXXXXX..XXXXXXX
31
--- /dev/null
32
+++ b/include/hw/misc/aspeed_i3c.h
33
@@ -XXX,XX +XXX,XX @@
34
+/*
35
+ * ASPEED I3C Controller
36
+ *
37
+ * Copyright (C) 2021 ASPEED Technology Inc.
38
+ *
39
+ * This code is licensed under the GPL version 2 or later. See
40
+ * the COPYING file in the top-level directory.
41
+ */
42
+
43
+#ifndef ASPEED_I3C_H
44
+#define ASPEED_I3C_H
45
+
46
+#include "hw/sysbus.h"
47
+
48
+#define TYPE_ASPEED_I3C "aspeed.i3c"
49
+#define TYPE_ASPEED_I3C_DEVICE "aspeed.i3c.device"
50
+OBJECT_DECLARE_TYPE(AspeedI3CState, AspeedI3CClass, ASPEED_I3C)
51
+
52
+#define ASPEED_I3C_NR_REGS (0x70 >> 2)
53
+#define ASPEED_I3C_DEVICE_NR_REGS (0x300 >> 2)
54
+#define ASPEED_I3C_NR_DEVICES 6
55
+
56
+OBJECT_DECLARE_SIMPLE_TYPE(AspeedI3CDevice, ASPEED_I3C_DEVICE)
57
+typedef struct AspeedI3CDevice {
58
+ /* <private> */
59
+ SysBusDevice parent;
60
+
61
+ /* <public> */
62
+ MemoryRegion mr;
63
+ qemu_irq irq;
64
+
65
+ uint8_t id;
66
+ uint32_t regs[ASPEED_I3C_DEVICE_NR_REGS];
67
+} AspeedI3CDevice;
68
+
69
+typedef struct AspeedI3CState {
70
+ /* <private> */
71
+ SysBusDevice parent;
72
+
73
+ /* <public> */
74
+ MemoryRegion iomem;
75
+ MemoryRegion iomem_container;
76
+ qemu_irq irq;
77
+
78
+ uint32_t regs[ASPEED_I3C_NR_REGS];
79
+ AspeedI3CDevice devices[ASPEED_I3C_NR_DEVICES];
80
+} AspeedI3CState;
81
+#endif /* ASPEED_I3C_H */
82
diff --git a/hw/misc/aspeed_i3c.c b/hw/misc/aspeed_i3c.c
83
new file mode 100644
84
index XXXXXXX..XXXXXXX
85
--- /dev/null
86
+++ b/hw/misc/aspeed_i3c.c
87
@@ -XXX,XX +XXX,XX @@
88
+/*
89
+ * ASPEED I3C Controller
90
+ *
91
+ * Copyright (C) 2021 ASPEED Technology Inc.
92
+ *
93
+ * This code is licensed under the GPL version 2 or later. See
94
+ * the COPYING file in the top-level directory.
95
+ */
96
+
97
+#include "qemu/osdep.h"
98
+#include "qemu/log.h"
99
+#include "qemu/error-report.h"
100
+#include "hw/misc/aspeed_i3c.h"
101
+#include "hw/registerfields.h"
102
+#include "hw/qdev-properties.h"
103
+#include "qapi/error.h"
104
+#include "migration/vmstate.h"
105
+#include "trace.h"
106
+
107
+/* I3C Controller Registers */
108
+REG32(I3C1_REG0, 0x10)
109
+REG32(I3C1_REG1, 0x14)
110
+ FIELD(I3C1_REG1, I2C_MODE, 0, 1)
111
+ FIELD(I3C1_REG1, SA_EN, 15, 1)
112
+REG32(I3C2_REG0, 0x20)
113
+REG32(I3C2_REG1, 0x24)
114
+ FIELD(I3C2_REG1, I2C_MODE, 0, 1)
115
+ FIELD(I3C2_REG1, SA_EN, 15, 1)
116
+REG32(I3C3_REG0, 0x30)
117
+REG32(I3C3_REG1, 0x34)
118
+ FIELD(I3C3_REG1, I2C_MODE, 0, 1)
119
+ FIELD(I3C3_REG1, SA_EN, 15, 1)
120
+REG32(I3C4_REG0, 0x40)
121
+REG32(I3C4_REG1, 0x44)
122
+ FIELD(I3C4_REG1, I2C_MODE, 0, 1)
123
+ FIELD(I3C4_REG1, SA_EN, 15, 1)
124
+REG32(I3C5_REG0, 0x50)
125
+REG32(I3C5_REG1, 0x54)
126
+ FIELD(I3C5_REG1, I2C_MODE, 0, 1)
127
+ FIELD(I3C5_REG1, SA_EN, 15, 1)
128
+REG32(I3C6_REG0, 0x60)
129
+REG32(I3C6_REG1, 0x64)
130
+ FIELD(I3C6_REG1, I2C_MODE, 0, 1)
131
+ FIELD(I3C6_REG1, SA_EN, 15, 1)
132
+
133
+/* I3C Device Registers */
134
+REG32(DEVICE_CTRL, 0x00)
135
+REG32(DEVICE_ADDR, 0x04)
136
+REG32(HW_CAPABILITY, 0x08)
137
+REG32(COMMAND_QUEUE_PORT, 0x0c)
138
+REG32(RESPONSE_QUEUE_PORT, 0x10)
139
+REG32(RX_TX_DATA_PORT, 0x14)
140
+REG32(IBI_QUEUE_STATUS, 0x18)
141
+REG32(IBI_QUEUE_DATA, 0x18)
142
+REG32(QUEUE_THLD_CTRL, 0x1c)
143
+REG32(DATA_BUFFER_THLD_CTRL, 0x20)
144
+REG32(IBI_QUEUE_CTRL, 0x24)
145
+REG32(IBI_MR_REQ_REJECT, 0x2c)
146
+REG32(IBI_SIR_REQ_REJECT, 0x30)
147
+REG32(RESET_CTRL, 0x34)
148
+REG32(SLV_EVENT_CTRL, 0x38)
149
+REG32(INTR_STATUS, 0x3c)
150
+REG32(INTR_STATUS_EN, 0x40)
151
+REG32(INTR_SIGNAL_EN, 0x44)
152
+REG32(INTR_FORCE, 0x48)
153
+REG32(QUEUE_STATUS_LEVEL, 0x4c)
154
+REG32(DATA_BUFFER_STATUS_LEVEL, 0x50)
155
+REG32(PRESENT_STATE, 0x54)
156
+REG32(CCC_DEVICE_STATUS, 0x58)
157
+REG32(DEVICE_ADDR_TABLE_POINTER, 0x5c)
158
+ FIELD(DEVICE_ADDR_TABLE_POINTER, DEPTH, 16, 16)
159
+ FIELD(DEVICE_ADDR_TABLE_POINTER, ADDR, 0, 16)
160
+REG32(DEV_CHAR_TABLE_POINTER, 0x60)
161
+REG32(VENDOR_SPECIFIC_REG_POINTER, 0x6c)
162
+REG32(SLV_MIPI_PID_VALUE, 0x70)
163
+REG32(SLV_PID_VALUE, 0x74)
164
+REG32(SLV_CHAR_CTRL, 0x78)
165
+REG32(SLV_MAX_LEN, 0x7c)
166
+REG32(MAX_READ_TURNAROUND, 0x80)
167
+REG32(MAX_DATA_SPEED, 0x84)
168
+REG32(SLV_DEBUG_STATUS, 0x88)
169
+REG32(SLV_INTR_REQ, 0x8c)
170
+REG32(DEVICE_CTRL_EXTENDED, 0xb0)
171
+REG32(SCL_I3C_OD_TIMING, 0xb4)
172
+REG32(SCL_I3C_PP_TIMING, 0xb8)
173
+REG32(SCL_I2C_FM_TIMING, 0xbc)
174
+REG32(SCL_I2C_FMP_TIMING, 0xc0)
175
+REG32(SCL_EXT_LCNT_TIMING, 0xc8)
176
+REG32(SCL_EXT_TERMN_LCNT_TIMING, 0xcc)
177
+REG32(BUS_FREE_TIMING, 0xd4)
178
+REG32(BUS_IDLE_TIMING, 0xd8)
179
+REG32(I3C_VER_ID, 0xe0)
180
+REG32(I3C_VER_TYPE, 0xe4)
181
+REG32(EXTENDED_CAPABILITY, 0xe8)
182
+REG32(SLAVE_CONFIG, 0xec)
183
+
184
+static const uint32_t ast2600_i3c_device_resets[ASPEED_I3C_DEVICE_NR_REGS] = {
185
+ [R_HW_CAPABILITY] = 0x000e00bf,
186
+ [R_QUEUE_THLD_CTRL] = 0x01000101,
187
+ [R_I3C_VER_ID] = 0x3130302a,
188
+ [R_I3C_VER_TYPE] = 0x6c633033,
189
+ [R_DEVICE_ADDR_TABLE_POINTER] = 0x00080280,
190
+ [R_DEV_CHAR_TABLE_POINTER] = 0x00020200,
191
+ [A_VENDOR_SPECIFIC_REG_POINTER] = 0x000000b0,
192
+ [R_SLV_MAX_LEN] = 0x00ff00ff,
193
+};
194
+
195
+static uint64_t aspeed_i3c_device_read(void *opaque, hwaddr offset,
196
+ unsigned size)
197
+{
198
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(opaque);
199
+ uint32_t addr = offset >> 2;
200
+ uint64_t value;
201
+
202
+ switch (addr) {
203
+ case R_COMMAND_QUEUE_PORT:
204
+ value = 0;
205
+ break;
206
+ default:
207
+ value = s->regs[addr];
208
+ break;
209
+ }
210
+
211
+ trace_aspeed_i3c_device_read(s->id, offset, value);
212
+
213
+ return value;
214
+}
215
+
216
+static void aspeed_i3c_device_write(void *opaque, hwaddr offset,
217
+ uint64_t value, unsigned size)
218
+{
219
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(opaque);
220
+ uint32_t addr = offset >> 2;
221
+
222
+ trace_aspeed_i3c_device_write(s->id, offset, value);
223
+
224
+ switch (addr) {
225
+ case R_HW_CAPABILITY:
226
+ case R_RESPONSE_QUEUE_PORT:
227
+ case R_IBI_QUEUE_DATA:
228
+ case R_QUEUE_STATUS_LEVEL:
229
+ case R_PRESENT_STATE:
230
+ case R_CCC_DEVICE_STATUS:
231
+ case R_DEVICE_ADDR_TABLE_POINTER:
232
+ case R_VENDOR_SPECIFIC_REG_POINTER:
233
+ case R_SLV_CHAR_CTRL:
234
+ case R_SLV_MAX_LEN:
235
+ case R_MAX_READ_TURNAROUND:
236
+ case R_I3C_VER_ID:
237
+ case R_I3C_VER_TYPE:
238
+ case R_EXTENDED_CAPABILITY:
239
+ qemu_log_mask(LOG_GUEST_ERROR,
240
+ "%s: write to readonly register[%02lx] = %08lx\n",
241
+ __func__, offset, value);
242
+ break;
243
+ case R_RX_TX_DATA_PORT:
244
+ break;
245
+ case R_RESET_CTRL:
246
+ break;
247
+ default:
248
+ s->regs[addr] = value;
249
+ break;
250
+ }
251
+}
252
+
253
+static const VMStateDescription aspeed_i3c_device_vmstate = {
254
+ .name = TYPE_ASPEED_I3C,
255
+ .version_id = 1,
256
+ .minimum_version_id = 1,
257
+ .fields = (VMStateField[]){
258
+ VMSTATE_UINT32_ARRAY(regs, AspeedI3CDevice, ASPEED_I3C_DEVICE_NR_REGS),
259
+ VMSTATE_END_OF_LIST(),
260
+ }
261
+};
262
+
263
+static const MemoryRegionOps aspeed_i3c_device_ops = {
264
+ .read = aspeed_i3c_device_read,
265
+ .write = aspeed_i3c_device_write,
266
+ .endianness = DEVICE_LITTLE_ENDIAN,
267
+};
268
+
269
+static void aspeed_i3c_device_reset(DeviceState *dev)
270
+{
271
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(dev);
272
+
273
+ memcpy(s->regs, ast2600_i3c_device_resets, sizeof(s->regs));
274
+}
275
+
276
+static void aspeed_i3c_device_realize(DeviceState *dev, Error **errp)
277
+{
278
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(dev);
279
+ g_autofree char *name = g_strdup_printf(TYPE_ASPEED_I3C_DEVICE ".%d",
280
+ s->id);
281
+
282
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
283
+
284
+ memory_region_init_io(&s->mr, OBJECT(s), &aspeed_i3c_device_ops,
285
+ s, name, ASPEED_I3C_DEVICE_NR_REGS << 2);
286
+}
287
+
288
+static uint64_t aspeed_i3c_read(void *opaque, hwaddr addr, unsigned int size)
289
+{
290
+ AspeedI3CState *s = ASPEED_I3C(opaque);
291
+ uint64_t val = 0;
292
+
293
+ val = s->regs[addr >> 2];
294
+
295
+ trace_aspeed_i3c_read(addr, val);
296
+
297
+ return val;
298
+}
299
+
300
+static void aspeed_i3c_write(void *opaque,
301
+ hwaddr addr,
302
+ uint64_t data,
303
+ unsigned int size)
304
+{
305
+ AspeedI3CState *s = ASPEED_I3C(opaque);
306
+
307
+ trace_aspeed_i3c_write(addr, data);
308
+
309
+ addr >>= 2;
310
+
311
+ /* I3C controller register */
312
+ switch (addr) {
313
+ case R_I3C1_REG1:
314
+ case R_I3C2_REG1:
315
+ case R_I3C3_REG1:
316
+ case R_I3C4_REG1:
317
+ case R_I3C5_REG1:
318
+ case R_I3C6_REG1:
319
+ if (data & R_I3C1_REG1_I2C_MODE_MASK) {
320
+ qemu_log_mask(LOG_UNIMP,
321
+ "%s: Not support I2C mode [%08lx]=%08lx",
322
+ __func__, addr << 2, data);
323
+ break;
324
+ }
325
+ if (data & R_I3C1_REG1_SA_EN_MASK) {
326
+ qemu_log_mask(LOG_UNIMP,
327
+ "%s: Not support slave mode [%08lx]=%08lx",
328
+ __func__, addr << 2, data);
329
+ break;
330
+ }
331
+ s->regs[addr] = data;
332
+ break;
333
+ default:
334
+ s->regs[addr] = data;
335
+ break;
336
+ }
337
+}
338
+
339
+static const MemoryRegionOps aspeed_i3c_ops = {
340
+ .read = aspeed_i3c_read,
341
+ .write = aspeed_i3c_write,
342
+ .endianness = DEVICE_LITTLE_ENDIAN,
343
+ .valid = {
344
+ .min_access_size = 1,
345
+ .max_access_size = 4,
346
+ }
347
+};
348
+
349
+static void aspeed_i3c_reset(DeviceState *dev)
350
+{
351
+ AspeedI3CState *s = ASPEED_I3C(dev);
352
+ memset(s->regs, 0, sizeof(s->regs));
353
+}
354
+
355
+static void aspeed_i3c_instance_init(Object *obj)
356
+{
357
+ AspeedI3CState *s = ASPEED_I3C(obj);
358
+ int i;
359
+
360
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) {
361
+ object_initialize_child(obj, "device[*]", &s->devices[i],
362
+ TYPE_ASPEED_I3C_DEVICE);
363
+ }
364
+}
365
+
366
+static void aspeed_i3c_realize(DeviceState *dev, Error **errp)
367
+{
368
+ int i;
369
+ AspeedI3CState *s = ASPEED_I3C(dev);
370
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
371
+
372
+ memory_region_init(&s->iomem_container, OBJECT(s),
373
+ TYPE_ASPEED_I3C ".container", 0x8000);
374
+
375
+ sysbus_init_mmio(sbd, &s->iomem_container);
376
+
377
+ memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_i3c_ops, s,
378
+ TYPE_ASPEED_I3C ".regs", ASPEED_I3C_NR_REGS << 2);
379
+
380
+ memory_region_add_subregion(&s->iomem_container, 0x0, &s->iomem);
381
+
382
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) {
383
+ Object *dev = OBJECT(&s->devices[i]);
384
+
385
+ if (!object_property_set_uint(dev, "device-id", i, errp)) {
386
+ return;
387
+ }
388
+
389
+ if (!sysbus_realize(SYS_BUS_DEVICE(dev), errp)) {
390
+ return;
391
+ }
392
+
393
+ /*
394
+ * Register Address of I3CX Device =
395
+ * (Base Address of Global Register) + (Offset of I3CX) + Offset
396
+ * X = 0, 1, 2, 3, 4, 5
397
+ * Offset of I3C0 = 0x2000
398
+ * Offset of I3C1 = 0x3000
399
+ * Offset of I3C2 = 0x4000
400
+ * Offset of I3C3 = 0x5000
401
+ * Offset of I3C4 = 0x6000
402
+ * Offset of I3C5 = 0x7000
403
+ */
404
+ memory_region_add_subregion(&s->iomem_container,
405
+ 0x2000 + i * 0x1000, &s->devices[i].mr);
406
+ }
407
+
408
+}
409
+
410
+static Property aspeed_i3c_device_properties[] = {
411
+ DEFINE_PROP_UINT8("device-id", AspeedI3CDevice, id, 0),
412
+ DEFINE_PROP_END_OF_LIST(),
413
+};
414
+
415
+static void aspeed_i3c_device_class_init(ObjectClass *klass, void *data)
416
+{
417
+ DeviceClass *dc = DEVICE_CLASS(klass);
418
+
419
+ dc->desc = "Aspeed I3C Device";
420
+ dc->realize = aspeed_i3c_device_realize;
421
+ dc->reset = aspeed_i3c_device_reset;
422
+ device_class_set_props(dc, aspeed_i3c_device_properties);
423
+}
424
+
425
+static const TypeInfo aspeed_i3c_device_info = {
426
+ .name = TYPE_ASPEED_I3C_DEVICE,
427
+ .parent = TYPE_SYS_BUS_DEVICE,
428
+ .instance_size = sizeof(AspeedI3CDevice),
429
+ .class_init = aspeed_i3c_device_class_init,
430
+};
431
+
432
+static const VMStateDescription vmstate_aspeed_i3c = {
433
+ .name = TYPE_ASPEED_I3C,
434
+ .version_id = 1,
435
+ .minimum_version_id = 1,
436
+ .fields = (VMStateField[]) {
437
+ VMSTATE_UINT32_ARRAY(regs, AspeedI3CState, ASPEED_I3C_NR_REGS),
438
+ VMSTATE_STRUCT_ARRAY(devices, AspeedI3CState, ASPEED_I3C_NR_DEVICES, 1,
439
+ aspeed_i3c_device_vmstate, AspeedI3CDevice),
440
+ VMSTATE_END_OF_LIST(),
441
+ }
442
+};
443
+
444
+static void aspeed_i3c_class_init(ObjectClass *klass, void *data)
445
+{
446
+ DeviceClass *dc = DEVICE_CLASS(klass);
447
+
448
+ dc->realize = aspeed_i3c_realize;
449
+ dc->reset = aspeed_i3c_reset;
450
+ dc->desc = "Aspeed I3C Controller";
451
+ dc->vmsd = &vmstate_aspeed_i3c;
452
+}
453
+
454
+static const TypeInfo aspeed_i3c_info = {
455
+ .name = TYPE_ASPEED_I3C,
456
+ .parent = TYPE_SYS_BUS_DEVICE,
457
+ .instance_init = aspeed_i3c_instance_init,
458
+ .instance_size = sizeof(AspeedI3CState),
459
+ .class_init = aspeed_i3c_class_init,
460
+};
461
+
462
+static void aspeed_i3c_register_types(void)
463
+{
464
+ type_register_static(&aspeed_i3c_device_info);
465
+ type_register_static(&aspeed_i3c_info);
466
+}
467
+
468
+type_init(aspeed_i3c_register_types);
469
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
26
index XXXXXXX..XXXXXXX 100644
470
index XXXXXXX..XXXXXXX 100644
27
--- a/include/hw/char/imx_serial.h
471
--- a/hw/misc/meson.build
28
+++ b/include/hw/char/imx_serial.h
472
+++ b/hw/misc/meson.build
29
@@ -XXX,XX +XXX,XX @@
473
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
30
474
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
31
#define URXD_CHARRDY (1<<15) /* character read is valid */
475
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
32
#define URXD_ERR (1<<14) /* Character has error */
476
'aspeed_hace.c',
33
+#define URXD_FRMERR (1<<12) /* Character has frame error */
477
+ 'aspeed_i3c.c',
34
#define URXD_BRK (1<<11) /* Break received */
478
'aspeed_lpc.c',
35
479
'aspeed_scu.c',
36
#define USR1_PARTYER (1<<15) /* Parity Error */
480
'aspeed_sdmc.c',
37
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
481
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
38
index XXXXXXX..XXXXXXX 100644
482
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/char/imx_serial.c
483
--- a/hw/misc/trace-events
40
+++ b/hw/char/imx_serial.c
484
+++ b/hw/misc/trace-events
41
@@ -XXX,XX +XXX,XX @@ static void imx_put_data(void *opaque, uint32_t value)
485
@@ -XXX,XX +XXX,XX @@ armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU wri
42
s->usr2 |= USR2_RDR;
486
# aspeed_xdma.c
43
s->uts1 &= ~UTS1_RXEMPTY;
487
aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64
44
s->readbuff = value;
488
45
+ if (value & URXD_BRK) {
489
+# aspeed_i3c.c
46
+ s->usr2 |= USR2_BRCD;
490
+aspeed_i3c_read(uint64_t offset, uint64_t data) "I3C read: offset 0x%" PRIx64 " data 0x%" PRIx64
47
+ }
491
+aspeed_i3c_write(uint64_t offset, uint64_t data) "I3C write: offset 0x%" PRIx64 " data 0x%" PRIx64
48
imx_update(s);
492
+aspeed_i3c_device_read(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] read: offset 0x%" PRIx64 " data 0x%" PRIx64
49
}
493
+aspeed_i3c_device_write(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] write: offset 0x%" PRIx64 " data 0x%" PRIx64
50
494
+
51
@@ -XXX,XX +XXX,XX @@ static void imx_receive(void *opaque, const uint8_t *buf, int size)
495
# bcm2835_property.c
52
static void imx_event(void *opaque, int event)
496
bcm2835_mbox_property(uint32_t tag, uint32_t bufsize, size_t resplen) "mbox property tag:0x%08x in_sz:%u out_sz:%zu"
53
{
54
if (event == CHR_EVENT_BREAK) {
55
- imx_put_data(opaque, URXD_BRK);
56
+ imx_put_data(opaque, URXD_BRK | URXD_FRMERR | URXD_ERR);
57
}
58
}
59
497
60
--
498
--
61
2.16.2
499
2.25.1
62
500
63
501
diff view generated by jsdifflib
1
From: Victor Kamensky <kamensky@cisco.com>
1
From: Troy Lee <troy_lee@aspeedtech.com>
2
2
3
In OE project 4.15 linux kernel boot hang was observed under
3
Add the new i3c device to the AST2600 SoC.
4
single cpu aarch64 qemu. Kernel code was in a loop waiting for
5
vtimer arrival, spinning in TC generated blocks, while interrupt
6
was pending unprocessed. This happened because when qemu tried to
7
handle vtimer interrupt target had interrupts disabled, as
8
result flag indicating TCG exit, cpu->icount_decr.u16.high,
9
was cleared but arm_cpu_exec_interrupt function did not call
10
arm_cpu_do_interrupt to process interrupt. Later when target
11
reenabled interrupts, it happened without exit into main loop, so
12
following code that waited for result of interrupt execution
13
run in infinite loop.
14
4
15
To solve the problem instructions that operate on CPU sys state
5
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
16
(i.e enable/disable interrupt), and marked as DISAS_UPDATE,
6
Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com>
17
should be considered as DISAS_EXIT variant, and should be
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
18
forced to exit back to main loop so qemu will have a chance
8
Tested-by: Graeme Gregory <quic_ggregory@quicinc.com>
19
processing pending CPU state updates, including pending
9
Message-id: 20220111084546.4145785-3-troy_lee@aspeedtech.com
20
interrupts.
10
[PMM: tidied commit message]
21
22
This change brings consistency with how DISAS_UPDATE is treated
23
in aarch32 case.
24
25
CC: Peter Maydell <peter.maydell@linaro.org>
26
CC: Alex Bennée <alex.bennee@linaro.org>
27
CC: qemu-stable@nongnu.org
28
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
29
Signed-off-by: Victor Kamensky <kamensky@cisco.com>
30
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
31
Message-id: 1521526368-1996-1-git-send-email-kamensky@cisco.com
32
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
33
---
12
---
34
target/arm/translate-a64.c | 6 +++---
13
include/hw/arm/aspeed_soc.h | 3 +++
35
1 file changed, 3 insertions(+), 3 deletions(-)
14
hw/arm/aspeed_ast2600.c | 16 ++++++++++++++++
15
2 files changed, 19 insertions(+)
36
16
37
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
17
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
38
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/translate-a64.c
19
--- a/include/hw/arm/aspeed_soc.h
40
+++ b/target/arm/translate-a64.c
20
+++ b/include/hw/arm/aspeed_soc.h
41
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
21
@@ -XXX,XX +XXX,XX @@
42
case DISAS_UPDATE:
22
#include "hw/timer/aspeed_timer.h"
43
gen_a64_set_pc_im(dc->pc);
23
#include "hw/rtc/aspeed_rtc.h"
44
/* fall through */
24
#include "hw/i2c/aspeed_i2c.h"
45
- case DISAS_JUMP:
25
+#include "hw/misc/aspeed_i3c.h"
46
- tcg_gen_lookup_and_goto_ptr();
26
#include "hw/ssi/aspeed_smc.h"
47
- break;
27
#include "hw/misc/aspeed_hace.h"
48
case DISAS_EXIT:
28
#include "hw/watchdog/wdt_aspeed.h"
49
tcg_gen_exit_tb(0);
29
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
50
break;
30
AspeedRtcState rtc;
51
+ case DISAS_JUMP:
31
AspeedTimerCtrlState timerctrl;
52
+ tcg_gen_lookup_and_goto_ptr();
32
AspeedI2CState i2c;
53
+ break;
33
+ AspeedI3CState i3c;
54
case DISAS_NORETURN:
34
AspeedSCUState scu;
55
case DISAS_SWI:
35
AspeedHACEState hace;
56
break;
36
AspeedXDMAState xdma;
37
@@ -XXX,XX +XXX,XX @@ enum {
38
ASPEED_DEV_HACE,
39
ASPEED_DEV_DPMCU,
40
ASPEED_DEV_DP,
41
+ ASPEED_DEV_I3C,
42
};
43
44
#endif /* ASPEED_SOC_H */
45
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/arm/aspeed_ast2600.c
48
+++ b/hw/arm/aspeed_ast2600.c
49
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
50
[ASPEED_DEV_UART1] = 0x1E783000,
51
[ASPEED_DEV_UART5] = 0x1E784000,
52
[ASPEED_DEV_VUART] = 0x1E787000,
53
+ [ASPEED_DEV_I3C] = 0x1E7A0000,
54
[ASPEED_DEV_SDRAM] = 0x80000000,
55
};
56
57
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
58
[ASPEED_DEV_ETH4] = 33,
59
[ASPEED_DEV_KCS] = 138, /* 138 -> 142 */
60
[ASPEED_DEV_DP] = 62,
61
+ [ASPEED_DEV_I3C] = 102, /* 102 -> 107 */
62
};
63
64
static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)
65
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
66
67
snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname);
68
object_initialize_child(obj, "hace", &s->hace, typename);
69
+
70
+ object_initialize_child(obj, "i3c", &s->i3c, TYPE_ASPEED_I3C);
71
}
72
73
/*
74
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
75
sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]);
76
sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
77
aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
78
+
79
+ /* I3C */
80
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i3c), errp)) {
81
+ return;
82
+ }
83
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]);
84
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) {
85
+ qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
86
+ sc->irqmap[ASPEED_DEV_I3C] + i);
87
+ /* The AST2600 I3C controller has one IRQ per bus. */
88
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq);
89
+ }
90
}
91
92
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
57
--
93
--
58
2.16.2
94
2.25.1
59
95
60
96
diff view generated by jsdifflib
New patch
1
In process_its_cmd() and process_mapti() we must check the
2
event ID against a limit defined by the size field in the DTE,
3
which specifies the number of ID bits minus one. Convert
4
this code to our num_foo convention:
5
* change the variable names
6
* use uint64_t and 1ULL when calculating the number
7
of valid event IDs, because DTE.SIZE is 5 bits and
8
so num_eventids may be up to 2^32
9
* fix the off-by-one error in the comparison
1
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Message-id: 20220111171048.3545974-2-peter.maydell@linaro.org
14
---
15
hw/intc/arm_gicv3_its.c | 18 ++++++++++--------
16
1 file changed, 10 insertions(+), 8 deletions(-)
17
18
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/intc/arm_gicv3_its.c
21
+++ b/hw/intc/arm_gicv3_its.c
22
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
23
MemTxResult res = MEMTX_OK;
24
bool dte_valid;
25
uint64_t dte = 0;
26
- uint32_t max_eventid;
27
+ uint64_t num_eventids;
28
uint16_t icid = 0;
29
uint32_t pIntid = 0;
30
bool ite_valid = false;
31
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
32
dte_valid = FIELD_EX64(dte, DTE, VALID);
33
34
if (dte_valid) {
35
- max_eventid = 1UL << (FIELD_EX64(dte, DTE, SIZE) + 1);
36
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
37
38
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
39
40
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
41
dte_valid ? "valid" : "invalid",
42
ite_valid ? "valid" : "invalid",
43
cte_valid ? "valid" : "invalid");
44
- } else if (eventid > max_eventid) {
45
+ } else if (eventid >= num_eventids) {
46
qemu_log_mask(LOG_GUEST_ERROR,
47
- "%s: invalid command attributes: eventid %d > %d\n",
48
- __func__, eventid, max_eventid);
49
+ "%s: invalid command attributes: eventid %d >= %"
50
+ PRId64 "\n",
51
+ __func__, eventid, num_eventids);
52
} else {
53
/*
54
* Current implementation only supports rdbase == procnum
55
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
56
AddressSpace *as = &s->gicv3->dma_as;
57
uint32_t devid, eventid;
58
uint32_t pIntid = 0;
59
- uint32_t max_eventid, max_Intid;
60
+ uint64_t num_eventids;
61
+ uint32_t max_Intid;
62
bool dte_valid;
63
MemTxResult res = MEMTX_OK;
64
uint16_t icid = 0;
65
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
66
return result;
67
}
68
dte_valid = FIELD_EX64(dte, DTE, VALID);
69
- max_eventid = 1UL << (FIELD_EX64(dte, DTE, SIZE) + 1);
70
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
71
max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1;
72
73
if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
74
- || !dte_valid || (eventid > max_eventid) ||
75
+ || !dte_valid || (eventid >= num_eventids) ||
76
(((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) &&
77
(pIntid != INTID_SPURIOUS))) {
78
qemu_log_mask(LOG_GUEST_ERROR,
79
--
80
2.25.1
81
82
diff view generated by jsdifflib
1
If the GIC has the security extension support enabled, then a
1
The bounds check on the number of interrupt IDs is correct, but
2
non-secure access to ICC_PMR must take account of the non-secure
2
doesn't match our convention; change the variable name, initialize it
3
view of interrupt priorities, where real priorities 0x00..0x7f
3
to the 2^n value rather than (2^n)-1, and use >= instead of > in the
4
are secure-only and not visible to the non-secure guest, and
4
comparison.
5
priorities 0x80..0xff are shown to the guest as if they were
6
0x00..0xff. We had the logic here wrong:
7
* on reads, the priority is in the secure range if bit 7
8
is clear, not if it is set
9
* on writes, we want to set bit 7, not mask everything else
10
5
11
Our ICC_RPR read code had the same error as ICC_PMR.
12
13
(Compare the GICv3 spec pseudocode functions ICC_RPR_EL1
14
and ICC_PMR_EL1.)
15
16
Fixes: https://bugs.launchpad.net/qemu/+bug/1748434
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Andrew Jones <drjones@redhat.com>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
19
Message-id: 20180315133441.24149-1-peter.maydell@linaro.org
8
Message-id: 20220111171048.3545974-3-peter.maydell@linaro.org
20
---
9
---
21
hw/intc/arm_gicv3_cpuif.c | 6 +++---
10
hw/intc/arm_gicv3_its.c | 6 +++---
22
1 file changed, 3 insertions(+), 3 deletions(-)
11
1 file changed, 3 insertions(+), 3 deletions(-)
23
12
24
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
25
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/intc/arm_gicv3_cpuif.c
15
--- a/hw/intc/arm_gicv3_its.c
27
+++ b/hw/intc/arm_gicv3_cpuif.c
16
+++ b/hw/intc/arm_gicv3_its.c
28
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_pmr_read(CPUARMState *env, const ARMCPRegInfo *ri)
17
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
29
/* NS access and Group 0 is inaccessible to NS: return the
18
uint32_t devid, eventid;
30
* NS view of the current priority
19
uint32_t pIntid = 0;
31
*/
20
uint64_t num_eventids;
32
- if (value & 0x80) {
21
- uint32_t max_Intid;
33
+ if ((value & 0x80) == 0) {
22
+ uint32_t num_intids;
34
/* Secure priorities not visible to NS */
23
bool dte_valid;
35
value = 0;
24
MemTxResult res = MEMTX_OK;
36
} else if (value != 0xff) {
25
uint16_t icid = 0;
37
@@ -XXX,XX +XXX,XX @@ static void icc_pmr_write(CPUARMState *env, const ARMCPRegInfo *ri,
26
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
38
/* Current PMR in the secure range, don't allow NS to change it */
39
return;
40
}
41
- value = (value >> 1) & 0x80;
42
+ value = (value >> 1) | 0x80;
43
}
27
}
44
cs->icc_pmr_el1 = value;
28
dte_valid = FIELD_EX64(dte, DTE, VALID);
45
gicv3_cpuif_update(cs);
29
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
46
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri)
30
- max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1;
47
if (arm_feature(env, ARM_FEATURE_EL3) &&
31
+ num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);
48
!arm_is_secure(env) && (env->cp15.scr_el3 & SCR_FIQ)) {
32
49
/* NS GIC access and Group 0 is inaccessible to NS */
33
if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
50
- if (prio & 0x80) {
34
|| !dte_valid || (eventid >= num_eventids) ||
51
+ if ((prio & 0x80) == 0) {
35
- (((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) &&
52
/* NS mustn't see priorities in the Secure half of the range */
36
+ (((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) &&
53
prio = 0;
37
(pIntid != INTID_SPURIOUS))) {
54
} else if (prio != 0xff) {
38
qemu_log_mask(LOG_GUEST_ERROR,
39
"%s: invalid command attributes "
55
--
40
--
56
2.16.2
41
2.25.1
57
42
58
43
diff view generated by jsdifflib
New patch
1
process_its_cmd() returns a bool, like all the other process_ functions.
2
However we were putting its return value into 'res', not 'result',
3
which meant we would ignore it when deciding whether to continue
4
or stall the command queue. Fix the typo.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20220111171048.3545974-4-peter.maydell@linaro.org
11
---
12
hw/intc/arm_gicv3_its.c | 4 ++--
13
1 file changed, 2 insertions(+), 2 deletions(-)
14
15
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/arm_gicv3_its.c
18
+++ b/hw/intc/arm_gicv3_its.c
19
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
20
21
switch (cmd) {
22
case GITS_CMD_INT:
23
- res = process_its_cmd(s, data, cq_offset, INTERRUPT);
24
+ result = process_its_cmd(s, data, cq_offset, INTERRUPT);
25
break;
26
case GITS_CMD_CLEAR:
27
- res = process_its_cmd(s, data, cq_offset, CLEAR);
28
+ result = process_its_cmd(s, data, cq_offset, CLEAR);
29
break;
30
case GITS_CMD_SYNC:
31
/*
32
--
33
2.25.1
34
35
diff view generated by jsdifflib
New patch
1
In process_cmdq(), we read 64 bits of the command packet, which
2
contain the command identifier, which we then switch() on to dispatch
3
to an appropriate sub-function. However, if address_space_ldq_le()
4
reports a memory transaction failure, we still read the command
5
identifier out of the data and switch() on it. Restructure the code
6
so that we stop immediately (stalling the command queue) in this
7
case.
1
8
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20220111171048.3545974-5-peter.maydell@linaro.org
13
---
14
hw/intc/arm_gicv3_its.c | 7 ++++++-
15
1 file changed, 6 insertions(+), 1 deletion(-)
16
17
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/intc/arm_gicv3_its.c
20
+++ b/hw/intc/arm_gicv3_its.c
21
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
22
data = address_space_ldq_le(as, s->cq.base_addr + cq_offset,
23
MEMTXATTRS_UNSPECIFIED, &res);
24
if (res != MEMTX_OK) {
25
- result = false;
26
+ s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1);
27
+ qemu_log_mask(LOG_GUEST_ERROR,
28
+ "%s: could not read command at 0x%" PRIx64 "\n",
29
+ __func__, s->cq.base_addr + cq_offset);
30
+ break;
31
}
32
+
33
cmd = (data & CMD_MASK);
34
35
switch (cmd) {
36
--
37
2.25.1
38
39
diff view generated by jsdifflib
New patch
1
1
When an ITS detects an error in a command, it has an
2
implementation-defined (CONSTRAINED UNPREDICTABLE) choice of whether
3
to ignore the command, proceeding to the next one in the queue, or to
4
stall the ITS command queue, processing nothing further. The
5
behaviour required when the read of the command packet from memory
6
fails is less clearly documented, but the same set of choices as for
7
command errors seem reasonable.
8
9
The intention of the QEMU implementation, as documented in the
10
comments, is that if we encounter a memory error reading the command
11
packet or one of the various data tables then we should stall, but
12
for command parameter errors we should ignore the queue and continue.
13
However, we don't actually do this. To get the desired behaviour,
14
the various process_* functions need to return true to cause
15
process_cmdq() to advance to the next command and keep processing,
16
and false to stall command processing. What they mostly do is return
17
false for any kind of error.
18
19
To make the code clearer, replace the 'bool' return from the process_
20
functions with an enum which may be either CMD_STALL or CMD_CONTINUE.
21
In this commit no behaviour changes; in subsequent commits we will
22
adjust the error-return paths for the process_ functions one by one.
23
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
27
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
28
Message-id: 20220111171048.3545974-6-peter.maydell@linaro.org
29
---
30
hw/intc/arm_gicv3_its.c | 59 ++++++++++++++++++++++++++---------------
31
1 file changed, 38 insertions(+), 21 deletions(-)
32
33
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/intc/arm_gicv3_its.c
36
+++ b/hw/intc/arm_gicv3_its.c
37
@@ -XXX,XX +XXX,XX @@ typedef struct {
38
uint64_t itel;
39
} IteEntry;
40
41
+/*
42
+ * The ITS spec permits a range of CONSTRAINED UNPREDICTABLE options
43
+ * if a command parameter is not correct. These include both "stall
44
+ * processing of the command queue" and "ignore this command, and
45
+ * keep processing the queue". In our implementation we choose that
46
+ * memory transaction errors reading the command packet provoke a
47
+ * stall, but errors in parameters cause us to ignore the command
48
+ * and continue processing.
49
+ * The process_* functions which handle individual ITS commands all
50
+ * return an ItsCmdResult which tells process_cmdq() whether it should
51
+ * stall or keep going.
52
+ */
53
+typedef enum ItsCmdResult {
54
+ CMD_STALL = 0,
55
+ CMD_CONTINUE = 1,
56
+} ItsCmdResult;
57
+
58
static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
59
{
60
uint64_t result = 0;
61
@@ -XXX,XX +XXX,XX @@ static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res)
62
* 3. handling of ITS CLEAR command
63
* 4. handling of ITS DISCARD command
64
*/
65
-static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
66
- ItsCmdType cmd)
67
+static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
68
+ uint32_t offset, ItsCmdType cmd)
69
{
70
AddressSpace *as = &s->gicv3->dma_as;
71
uint32_t devid, eventid;
72
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
73
bool ite_valid = false;
74
uint64_t cte = 0;
75
bool cte_valid = false;
76
- bool result = false;
77
+ ItsCmdResult result = CMD_STALL;
78
uint64_t rdbase;
79
80
if (cmd == NONE) {
81
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
82
if (cmd == DISCARD) {
83
IteEntry ite = {};
84
/* remove mapping from interrupt translation table */
85
- result = update_ite(s, eventid, dte, ite);
86
+ result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
87
}
88
}
89
90
return result;
91
}
92
93
-static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
94
- bool ignore_pInt)
95
+static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
96
+ uint32_t offset, bool ignore_pInt)
97
{
98
AddressSpace *as = &s->gicv3->dma_as;
99
uint32_t devid, eventid;
100
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
101
MemTxResult res = MEMTX_OK;
102
uint16_t icid = 0;
103
uint64_t dte = 0;
104
- bool result = false;
105
+ ItsCmdResult result = CMD_STALL;
106
107
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
108
offset += NUM_BYTES_IN_DW;
109
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
110
ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
111
ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
112
113
- result = update_ite(s, eventid, dte, ite);
114
+ result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
115
}
116
117
return result;
118
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
119
}
120
}
121
122
-static bool process_mapc(GICv3ITSState *s, uint32_t offset)
123
+static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
124
{
125
AddressSpace *as = &s->gicv3->dma_as;
126
uint16_t icid;
127
uint64_t rdbase;
128
bool valid;
129
MemTxResult res = MEMTX_OK;
130
- bool result = false;
131
+ ItsCmdResult result = CMD_STALL;
132
uint64_t value;
133
134
offset += NUM_BYTES_IN_DW;
135
@@ -XXX,XX +XXX,XX @@ static bool process_mapc(GICv3ITSState *s, uint32_t offset)
136
* command in the queue
137
*/
138
} else {
139
- result = update_cte(s, icid, valid, rdbase);
140
+ result = update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
141
}
142
143
return result;
144
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
145
}
146
}
147
148
-static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
149
+static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
150
+ uint32_t offset)
151
{
152
AddressSpace *as = &s->gicv3->dma_as;
153
uint32_t devid;
154
@@ -XXX,XX +XXX,XX @@ static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
155
uint64_t itt_addr;
156
bool valid;
157
MemTxResult res = MEMTX_OK;
158
- bool result = false;
159
+ ItsCmdResult result = CMD_STALL;
160
161
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
162
163
@@ -XXX,XX +XXX,XX @@ static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
164
* command in the queue
165
*/
166
} else {
167
- result = update_dte(s, devid, valid, size, itt_addr);
168
+ result = update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
169
}
170
171
return result;
172
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
173
uint64_t data;
174
AddressSpace *as = &s->gicv3->dma_as;
175
MemTxResult res = MEMTX_OK;
176
- bool result = true;
177
uint8_t cmd;
178
int i;
179
180
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
181
}
182
183
while (wr_offset != rd_offset) {
184
+ ItsCmdResult result = CMD_CONTINUE;
185
+
186
cq_offset = (rd_offset * GITS_CMDQ_ENTRY_SIZE);
187
data = address_space_ldq_le(as, s->cq.base_addr + cq_offset,
188
MEMTXATTRS_UNSPECIFIED, &res);
189
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
190
default:
191
break;
192
}
193
- if (result) {
194
+ if (result == CMD_CONTINUE) {
195
rd_offset++;
196
rd_offset %= s->cq.num_entries;
197
s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, OFFSET, rd_offset);
198
} else {
199
- /*
200
- * in this implementation, in case of dma read/write error
201
- * we stall the command processing
202
- */
203
+ /* CMD_STALL */
204
s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1);
205
qemu_log_mask(LOG_GUEST_ERROR,
206
- "%s: %x cmd processing failed\n", __func__, cmd);
207
+ "%s: 0x%x cmd processing failed, stalling\n",
208
+ __func__, cmd);
209
break;
210
}
211
}
212
--
213
2.25.1
214
215
diff view generated by jsdifflib
New patch
1
Fix process_its_cmd() to consistently return CMD_STALL for
2
memory errors and CMD_CONTINUE for parameter errors, as
3
we claim in the comments that we do.
1
4
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-7-peter.maydell@linaro.org
9
---
10
hw/intc/arm_gicv3_its.c | 22 +++++++++++-----------
11
1 file changed, 11 insertions(+), 11 deletions(-)
12
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
16
+++ b/hw/intc/arm_gicv3_its.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
18
bool ite_valid = false;
19
uint64_t cte = 0;
20
bool cte_valid = false;
21
- ItsCmdResult result = CMD_STALL;
22
uint64_t rdbase;
23
24
if (cmd == NONE) {
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
26
}
27
28
if (res != MEMTX_OK) {
29
- return result;
30
+ return CMD_STALL;
31
}
32
33
eventid = (value & EVENTID_MASK);
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
35
dte = get_dte(s, devid, &res);
36
37
if (res != MEMTX_OK) {
38
- return result;
39
+ return CMD_STALL;
40
}
41
dte_valid = FIELD_EX64(dte, DTE, VALID);
42
43
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
44
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
45
46
if (res != MEMTX_OK) {
47
- return result;
48
+ return CMD_STALL;
49
}
50
51
if (ite_valid) {
52
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
53
}
54
55
if (res != MEMTX_OK) {
56
- return result;
57
+ return CMD_STALL;
58
}
59
} else {
60
qemu_log_mask(LOG_GUEST_ERROR,
61
"%s: invalid command attributes: "
62
"invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n",
63
__func__, dte, devid, res);
64
- return result;
65
+ return CMD_CONTINUE;
66
}
67
68
69
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
70
qemu_log_mask(LOG_GUEST_ERROR,
71
"%s: invalid command attributes: devid %d>=%d",
72
__func__, devid, s->dt.num_ids);
73
-
74
+ return CMD_CONTINUE;
75
} else if (!dte_valid || !ite_valid || !cte_valid) {
76
qemu_log_mask(LOG_GUEST_ERROR,
77
"%s: invalid command attributes: "
78
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
79
dte_valid ? "valid" : "invalid",
80
ite_valid ? "valid" : "invalid",
81
cte_valid ? "valid" : "invalid");
82
+ return CMD_CONTINUE;
83
} else if (eventid >= num_eventids) {
84
qemu_log_mask(LOG_GUEST_ERROR,
85
"%s: invalid command attributes: eventid %d >= %"
86
PRId64 "\n",
87
__func__, eventid, num_eventids);
88
+ return CMD_CONTINUE;
89
} else {
90
/*
91
* Current implementation only supports rdbase == procnum
92
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
93
rdbase = FIELD_EX64(cte, CTE, RDBASE);
94
95
if (rdbase >= s->gicv3->num_cpu) {
96
- return result;
97
+ return CMD_CONTINUE;
98
}
99
100
if ((cmd == CLEAR) || (cmd == DISCARD)) {
101
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
102
if (cmd == DISCARD) {
103
IteEntry ite = {};
104
/* remove mapping from interrupt translation table */
105
- result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
106
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
107
}
108
+ return CMD_CONTINUE;
109
}
110
-
111
- return result;
112
}
113
114
static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
115
--
116
2.25.1
117
118
diff view generated by jsdifflib
New patch
1
Refactor process_its_cmd() so that it consistently uses
2
the structure
3
do thing;
4
if (error condition) {
5
return early;
6
}
7
do next thing;
1
8
9
rather than doing some of the work nested inside if (not error)
10
code blocks.
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20220111171048.3545974-8-peter.maydell@linaro.org
16
---
17
hw/intc/arm_gicv3_its.c | 103 +++++++++++++++++++---------------------
18
1 file changed, 50 insertions(+), 53 deletions(-)
19
20
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/intc/arm_gicv3_its.c
23
+++ b/hw/intc/arm_gicv3_its.c
24
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
25
}
26
dte_valid = FIELD_EX64(dte, DTE, VALID);
27
28
- if (dte_valid) {
29
- num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
30
-
31
- ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
32
-
33
- if (res != MEMTX_OK) {
34
- return CMD_STALL;
35
- }
36
-
37
- if (ite_valid) {
38
- cte_valid = get_cte(s, icid, &cte, &res);
39
- }
40
-
41
- if (res != MEMTX_OK) {
42
- return CMD_STALL;
43
- }
44
- } else {
45
+ if (!dte_valid) {
46
qemu_log_mask(LOG_GUEST_ERROR,
47
"%s: invalid command attributes: "
48
- "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n",
49
- __func__, dte, devid, res);
50
+ "invalid dte: %"PRIx64" for %d\n",
51
+ __func__, dte, devid);
52
return CMD_CONTINUE;
53
}
54
55
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
56
+
57
+ ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
58
+ if (res != MEMTX_OK) {
59
+ return CMD_STALL;
60
+ }
61
+
62
+ if (!ite_valid) {
63
+ qemu_log_mask(LOG_GUEST_ERROR,
64
+ "%s: invalid command attributes: invalid ITE\n",
65
+ __func__);
66
+ return CMD_CONTINUE;
67
+ }
68
+
69
+ cte_valid = get_cte(s, icid, &cte, &res);
70
+ if (res != MEMTX_OK) {
71
+ return CMD_STALL;
72
+ }
73
+ if (!cte_valid) {
74
+ qemu_log_mask(LOG_GUEST_ERROR,
75
+ "%s: invalid command attributes: "
76
+ "invalid cte: %"PRIx64"\n",
77
+ __func__, cte);
78
+ return CMD_CONTINUE;
79
+ }
80
81
- /*
82
- * In this implementation, in case of guest errors we ignore the
83
- * command and move onto the next command in the queue.
84
- */
85
if (devid >= s->dt.num_ids) {
86
qemu_log_mask(LOG_GUEST_ERROR,
87
"%s: invalid command attributes: devid %d>=%d",
88
__func__, devid, s->dt.num_ids);
89
return CMD_CONTINUE;
90
- } else if (!dte_valid || !ite_valid || !cte_valid) {
91
- qemu_log_mask(LOG_GUEST_ERROR,
92
- "%s: invalid command attributes: "
93
- "dte: %s, ite: %s, cte: %s\n",
94
- __func__,
95
- dte_valid ? "valid" : "invalid",
96
- ite_valid ? "valid" : "invalid",
97
- cte_valid ? "valid" : "invalid");
98
- return CMD_CONTINUE;
99
- } else if (eventid >= num_eventids) {
100
+ }
101
+ if (eventid >= num_eventids) {
102
qemu_log_mask(LOG_GUEST_ERROR,
103
"%s: invalid command attributes: eventid %d >= %"
104
PRId64 "\n",
105
__func__, eventid, num_eventids);
106
return CMD_CONTINUE;
107
- } else {
108
- /*
109
- * Current implementation only supports rdbase == procnum
110
- * Hence rdbase physical address is ignored
111
- */
112
- rdbase = FIELD_EX64(cte, CTE, RDBASE);
113
+ }
114
115
- if (rdbase >= s->gicv3->num_cpu) {
116
- return CMD_CONTINUE;
117
- }
118
+ /*
119
+ * Current implementation only supports rdbase == procnum
120
+ * Hence rdbase physical address is ignored
121
+ */
122
+ rdbase = FIELD_EX64(cte, CTE, RDBASE);
123
124
- if ((cmd == CLEAR) || (cmd == DISCARD)) {
125
- gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0);
126
- } else {
127
- gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1);
128
- }
129
-
130
- if (cmd == DISCARD) {
131
- IteEntry ite = {};
132
- /* remove mapping from interrupt translation table */
133
- return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
134
- }
135
+ if (rdbase >= s->gicv3->num_cpu) {
136
return CMD_CONTINUE;
137
}
138
+
139
+ if ((cmd == CLEAR) || (cmd == DISCARD)) {
140
+ gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0);
141
+ } else {
142
+ gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1);
143
+ }
144
+
145
+ if (cmd == DISCARD) {
146
+ IteEntry ite = {};
147
+ /* remove mapping from interrupt translation table */
148
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
149
+ }
150
+ return CMD_CONTINUE;
151
}
152
153
static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
154
--
155
2.25.1
156
157
diff view generated by jsdifflib
New patch
1
Fix process_mapti() to consistently return CMD_STALL for memory
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
comments that we do.
1
4
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-9-peter.maydell@linaro.org
9
---
10
hw/intc/arm_gicv3_its.c | 28 +++++++++++++---------------
11
1 file changed, 13 insertions(+), 15 deletions(-)
12
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
16
+++ b/hw/intc/arm_gicv3_its.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
18
MemTxResult res = MEMTX_OK;
19
uint16_t icid = 0;
20
uint64_t dte = 0;
21
- ItsCmdResult result = CMD_STALL;
22
+ IteEntry ite = {};
23
24
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
25
offset += NUM_BYTES_IN_DW;
26
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
27
MEMTXATTRS_UNSPECIFIED, &res);
28
29
if (res != MEMTX_OK) {
30
- return result;
31
+ return CMD_STALL;
32
}
33
34
eventid = (value & EVENTID_MASK);
35
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
36
MEMTXATTRS_UNSPECIFIED, &res);
37
38
if (res != MEMTX_OK) {
39
- return result;
40
+ return CMD_STALL;
41
}
42
43
icid = value & ICID_MASK;
44
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
45
dte = get_dte(s, devid, &res);
46
47
if (res != MEMTX_OK) {
48
- return result;
49
+ return CMD_STALL;
50
}
51
dte_valid = FIELD_EX64(dte, DTE, VALID);
52
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
53
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
54
* we ignore this command and move onto the next
55
* command in the queue
56
*/
57
- } else {
58
- /* add ite entry to interrupt translation table */
59
- IteEntry ite = {};
60
- ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid);
61
- ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL);
62
- ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid);
63
- ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
64
- ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
65
-
66
- result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
67
+ return CMD_CONTINUE;
68
}
69
70
- return result;
71
+ /* add ite entry to interrupt translation table */
72
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid);
73
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL);
74
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid);
75
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
76
+ ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
77
+
78
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
79
}
80
81
static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
82
--
83
2.25.1
84
85
diff view generated by jsdifflib
New patch
1
Fix process_mapc() to consistently return CMD_STALL for memory
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
comments that we do.
1
4
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-10-peter.maydell@linaro.org
9
---
10
hw/intc/arm_gicv3_its.c | 8 +++-----
11
1 file changed, 3 insertions(+), 5 deletions(-)
12
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
16
+++ b/hw/intc/arm_gicv3_its.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
18
uint64_t rdbase;
19
bool valid;
20
MemTxResult res = MEMTX_OK;
21
- ItsCmdResult result = CMD_STALL;
22
uint64_t value;
23
24
offset += NUM_BYTES_IN_DW;
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
26
MEMTXATTRS_UNSPECIFIED, &res);
27
28
if (res != MEMTX_OK) {
29
- return result;
30
+ return CMD_STALL;
31
}
32
33
icid = value & ICID_MASK;
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
35
* we ignore this command and move onto the next
36
* command in the queue
37
*/
38
- } else {
39
- result = update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
40
+ return CMD_CONTINUE;
41
}
42
43
- return result;
44
+ return update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
45
}
46
47
static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
48
--
49
2.25.1
50
51
diff view generated by jsdifflib
1
For debug exceptions due to breakpoints or the BKPT instruction which
1
Fix process_mapd() to consistently return CMD_STALL for memory
2
are taken to AArch32, the Fault Address Register is architecturally
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
UNKNOWN. We were using that as license to simply not set
3
comments that we do.
4
env->exception.vaddress, but this isn't correct, because it will
5
expose to the guest whatever old value was in that field when
6
arm_cpu_do_interrupt_aarch32() writes it to the guest IFSR. That old
7
value might be a FAR for a previous guest EL2 or secure exception, in
8
which case we shouldn't show it to an EL1 or non-secure exception
9
handler. It might also be a non-deterministic value, which is bad
10
for record-and-replay.
11
12
Clear env->exception.vaddress before taking breakpoint debug
13
exceptions, to avoid this minor information leak.
14
4
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
17
Message-id: 20180320134114.30418-5-peter.maydell@linaro.org
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-11-peter.maydell@linaro.org
18
---
9
---
19
target/arm/op_helper.c | 11 ++++++++++-
10
hw/intc/arm_gicv3_its.c | 10 ++++------
20
1 file changed, 10 insertions(+), 1 deletion(-)
11
1 file changed, 4 insertions(+), 6 deletions(-)
21
12
22
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
23
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/op_helper.c
15
--- a/hw/intc/arm_gicv3_its.c
25
+++ b/target/arm/op_helper.c
16
+++ b/hw/intc/arm_gicv3_its.c
26
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome)
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
27
{
18
uint64_t itt_addr;
28
/* FSR will only be used if the debug target EL is AArch32. */
19
bool valid;
29
env->exception.fsr = arm_debug_exception_fsr(env);
20
MemTxResult res = MEMTX_OK;
30
+ /* FAR is UNKNOWN: clear vaddress to avoid potentially exposing
21
- ItsCmdResult result = CMD_STALL;
31
+ * values to the guest that it shouldn't be able to see at its
22
32
+ * exception/security level.
23
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
33
+ */
24
34
+ env->exception.vaddress = 0;
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
35
raise_exception(env, EXCP_BKPT, syndrome, arm_debug_target_el(env));
26
MEMTXATTRS_UNSPECIFIED, &res);
27
28
if (res != MEMTX_OK) {
29
- return result;
30
+ return CMD_STALL;
31
}
32
33
size = (value & SIZE_MASK);
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
35
MEMTXATTRS_UNSPECIFIED, &res);
36
37
if (res != MEMTX_OK) {
38
- return result;
39
+ return CMD_STALL;
40
}
41
42
itt_addr = (value & ITTADDR_MASK) >> ITTADDR_SHIFT;
43
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
44
* we ignore this command and move onto the next
45
* command in the queue
46
*/
47
- } else {
48
- result = update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
49
+ return CMD_CONTINUE;
50
}
51
52
- return result;
53
+ return update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
36
}
54
}
37
55
38
@@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs)
56
/*
39
}
40
41
env->exception.fsr = arm_debug_exception_fsr(env);
42
- /* FAR is UNKNOWN, so doesn't need setting */
43
+ /* FAR is UNKNOWN: clear vaddress to avoid potentially exposing
44
+ * values to the guest that it shouldn't be able to see at its
45
+ * exception/security level.
46
+ */
47
+ env->exception.vaddress = 0;
48
raise_exception(env, EXCP_PREFETCH_ABORT,
49
syn_breakpoint(same_el),
50
arm_debug_target_el(env));
51
--
57
--
52
2.16.2
58
2.25.1
53
59
54
60
diff view generated by jsdifflib
New patch
1
1
The ITS has several tables which all share a similar format,
2
described by the TableDesc struct: the guest may configure them
3
to be a single-level table or a two-level table. Currently we
4
open-code the process of finding the table entry in all the
5
functions which read or write the device table or the collection
6
table. Factor out the "get the address of the table entry"
7
logic into a new function, so that the code which needs to
8
read or write a table entry only needs to call table_entry_addr()
9
and then perform a suitable load or store to that address.
10
11
Note that the error handling is slightly complicated because
12
we want to handle two cases differently:
13
* failure to read the L1 table entry should end up causing
14
a command stall, like other kinds of DMA error
15
* an L1 table entry that says there is no L2 table for this
16
index (ie whose valid bit is 0) must result in us treating
17
the table entry as not-valid on read, and discarding
18
writes (this is mandated by the spec)
19
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
23
Message-id: 20220111171048.3545974-12-peter.maydell@linaro.org
24
---
25
hw/intc/arm_gicv3_its.c | 212 +++++++++++++---------------------------
26
1 file changed, 70 insertions(+), 142 deletions(-)
27
28
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/intc/arm_gicv3_its.c
31
+++ b/hw/intc/arm_gicv3_its.c
32
@@ -XXX,XX +XXX,XX @@ static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
33
return result;
34
}
35
36
+static uint64_t table_entry_addr(GICv3ITSState *s, TableDesc *td,
37
+ uint32_t idx, MemTxResult *res)
38
+{
39
+ /*
40
+ * Given a TableDesc describing one of the ITS in-guest-memory
41
+ * tables and an index into it, return the guest address
42
+ * corresponding to that table entry.
43
+ * If there was a memory error reading the L1 table of an
44
+ * indirect table, *res is set accordingly, and we return -1.
45
+ * If the L1 table entry is marked not valid, we return -1 with
46
+ * *res set to MEMTX_OK.
47
+ *
48
+ * The specification defines the format of level 1 entries of a
49
+ * 2-level table, but the format of level 2 entries and the format
50
+ * of flat-mapped tables is IMPDEF.
51
+ */
52
+ AddressSpace *as = &s->gicv3->dma_as;
53
+ uint32_t l2idx;
54
+ uint64_t l2;
55
+ uint32_t num_l2_entries;
56
+
57
+ *res = MEMTX_OK;
58
+
59
+ if (!td->indirect) {
60
+ /* Single level table */
61
+ return td->base_addr + idx * td->entry_sz;
62
+ }
63
+
64
+ /* Two level table */
65
+ l2idx = idx / (td->page_sz / L1TABLE_ENTRY_SIZE);
66
+
67
+ l2 = address_space_ldq_le(as,
68
+ td->base_addr + (l2idx * L1TABLE_ENTRY_SIZE),
69
+ MEMTXATTRS_UNSPECIFIED, res);
70
+ if (*res != MEMTX_OK) {
71
+ return -1;
72
+ }
73
+ if (!(l2 & L2_TABLE_VALID_MASK)) {
74
+ return -1;
75
+ }
76
+
77
+ num_l2_entries = td->page_sz / td->entry_sz;
78
+ return (l2 & ((1ULL << 51) - 1)) + (idx % num_l2_entries) * td->entry_sz;
79
+}
80
+
81
static bool get_cte(GICv3ITSState *s, uint16_t icid, uint64_t *cte,
82
MemTxResult *res)
83
{
84
AddressSpace *as = &s->gicv3->dma_as;
85
- uint64_t l2t_addr;
86
- uint64_t value;
87
- bool valid_l2t;
88
- uint32_t l2t_id;
89
- uint32_t num_l2_entries;
90
+ uint64_t entry_addr = table_entry_addr(s, &s->ct, icid, res);
91
92
- if (s->ct.indirect) {
93
- l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE);
94
-
95
- value = address_space_ldq_le(as,
96
- s->ct.base_addr +
97
- (l2t_id * L1TABLE_ENTRY_SIZE),
98
- MEMTXATTRS_UNSPECIFIED, res);
99
-
100
- if (*res == MEMTX_OK) {
101
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
102
-
103
- if (valid_l2t) {
104
- num_l2_entries = s->ct.page_sz / s->ct.entry_sz;
105
-
106
- l2t_addr = value & ((1ULL << 51) - 1);
107
-
108
- *cte = address_space_ldq_le(as, l2t_addr +
109
- ((icid % num_l2_entries) * GITS_CTE_SIZE),
110
- MEMTXATTRS_UNSPECIFIED, res);
111
- }
112
- }
113
- } else {
114
- /* Flat level table */
115
- *cte = address_space_ldq_le(as, s->ct.base_addr +
116
- (icid * GITS_CTE_SIZE),
117
- MEMTXATTRS_UNSPECIFIED, res);
118
+ if (entry_addr == -1) {
119
+ return false; /* not valid */
120
}
121
122
+ *cte = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res);
123
return FIELD_EX64(*cte, CTE, VALID);
124
}
125
126
@@ -XXX,XX +XXX,XX @@ static bool get_ite(GICv3ITSState *s, uint32_t eventid, uint64_t dte,
127
static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res)
128
{
129
AddressSpace *as = &s->gicv3->dma_as;
130
- uint64_t l2t_addr;
131
- uint64_t value;
132
- bool valid_l2t;
133
- uint32_t l2t_id;
134
- uint32_t num_l2_entries;
135
+ uint64_t entry_addr = table_entry_addr(s, &s->dt, devid, res);
136
137
- if (s->dt.indirect) {
138
- l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE);
139
-
140
- value = address_space_ldq_le(as,
141
- s->dt.base_addr +
142
- (l2t_id * L1TABLE_ENTRY_SIZE),
143
- MEMTXATTRS_UNSPECIFIED, res);
144
-
145
- if (*res == MEMTX_OK) {
146
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
147
-
148
- if (valid_l2t) {
149
- num_l2_entries = s->dt.page_sz / s->dt.entry_sz;
150
-
151
- l2t_addr = value & ((1ULL << 51) - 1);
152
-
153
- value = address_space_ldq_le(as, l2t_addr +
154
- ((devid % num_l2_entries) * GITS_DTE_SIZE),
155
- MEMTXATTRS_UNSPECIFIED, res);
156
- }
157
- }
158
- } else {
159
- /* Flat level table */
160
- value = address_space_ldq_le(as, s->dt.base_addr +
161
- (devid * GITS_DTE_SIZE),
162
- MEMTXATTRS_UNSPECIFIED, res);
163
+ if (entry_addr == -1) {
164
+ return 0; /* a DTE entry with the Valid bit clear */
165
}
166
-
167
- return value;
168
+ return address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res);
169
}
170
171
/*
172
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
173
uint64_t rdbase)
174
{
175
AddressSpace *as = &s->gicv3->dma_as;
176
- uint64_t value;
177
- uint64_t l2t_addr;
178
- bool valid_l2t;
179
- uint32_t l2t_id;
180
- uint32_t num_l2_entries;
181
+ uint64_t entry_addr;
182
uint64_t cte = 0;
183
MemTxResult res = MEMTX_OK;
184
185
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
186
cte = FIELD_DP64(cte, CTE, RDBASE, rdbase);
187
}
188
189
- /*
190
- * The specification defines the format of level 1 entries of a
191
- * 2-level table, but the format of level 2 entries and the format
192
- * of flat-mapped tables is IMPDEF.
193
- */
194
- if (s->ct.indirect) {
195
- l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE);
196
-
197
- value = address_space_ldq_le(as,
198
- s->ct.base_addr +
199
- (l2t_id * L1TABLE_ENTRY_SIZE),
200
- MEMTXATTRS_UNSPECIFIED, &res);
201
-
202
- if (res != MEMTX_OK) {
203
- return false;
204
- }
205
-
206
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
207
-
208
- if (valid_l2t) {
209
- num_l2_entries = s->ct.page_sz / s->ct.entry_sz;
210
-
211
- l2t_addr = value & ((1ULL << 51) - 1);
212
-
213
- address_space_stq_le(as, l2t_addr +
214
- ((icid % num_l2_entries) * GITS_CTE_SIZE),
215
- cte, MEMTXATTRS_UNSPECIFIED, &res);
216
- }
217
- } else {
218
- /* Flat level table */
219
- address_space_stq_le(as, s->ct.base_addr + (icid * GITS_CTE_SIZE),
220
- cte, MEMTXATTRS_UNSPECIFIED, &res);
221
- }
222
+ entry_addr = table_entry_addr(s, &s->ct, icid, &res);
223
if (res != MEMTX_OK) {
224
+ /* memory access error: stall */
225
return false;
226
- } else {
227
+ }
228
+ if (entry_addr == -1) {
229
+ /* No L2 table for this index: discard write and continue */
230
return true;
231
}
232
+
233
+ address_space_stq_le(as, entry_addr, cte, MEMTXATTRS_UNSPECIFIED, &res);
234
+ return res == MEMTX_OK;
235
}
236
237
static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
238
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
239
uint8_t size, uint64_t itt_addr)
240
{
241
AddressSpace *as = &s->gicv3->dma_as;
242
- uint64_t value;
243
- uint64_t l2t_addr;
244
- bool valid_l2t;
245
- uint32_t l2t_id;
246
- uint32_t num_l2_entries;
247
+ uint64_t entry_addr;
248
uint64_t dte = 0;
249
MemTxResult res = MEMTX_OK;
250
251
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
252
return true;
253
}
254
255
- /*
256
- * The specification defines the format of level 1 entries of a
257
- * 2-level table, but the format of level 2 entries and the format
258
- * of flat-mapped tables is IMPDEF.
259
- */
260
- if (s->dt.indirect) {
261
- l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE);
262
-
263
- value = address_space_ldq_le(as,
264
- s->dt.base_addr +
265
- (l2t_id * L1TABLE_ENTRY_SIZE),
266
- MEMTXATTRS_UNSPECIFIED, &res);
267
-
268
- if (res != MEMTX_OK) {
269
- return false;
270
- }
271
-
272
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
273
-
274
- if (valid_l2t) {
275
- num_l2_entries = s->dt.page_sz / s->dt.entry_sz;
276
-
277
- l2t_addr = value & ((1ULL << 51) - 1);
278
-
279
- address_space_stq_le(as, l2t_addr +
280
- ((devid % num_l2_entries) * GITS_DTE_SIZE),
281
- dte, MEMTXATTRS_UNSPECIFIED, &res);
282
- }
283
- } else {
284
- /* Flat level table */
285
- address_space_stq_le(as, s->dt.base_addr + (devid * GITS_DTE_SIZE),
286
- dte, MEMTXATTRS_UNSPECIFIED, &res);
287
- }
288
+ entry_addr = table_entry_addr(s, &s->dt, devid, &res);
289
if (res != MEMTX_OK) {
290
+ /* memory access error: stall */
291
return false;
292
- } else {
293
+ }
294
+ if (entry_addr == -1) {
295
+ /* No L2 table for this index: discard write and continue */
296
return true;
297
}
298
+ address_space_stq_le(as, entry_addr, dte, MEMTXATTRS_UNSPECIFIED, &res);
299
+ return res == MEMTX_OK;
300
}
301
302
static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
303
--
304
2.25.1
305
306
diff view generated by jsdifflib
1
The BCM2836 uses a Cortex-A7, not a Cortex-A15. Update the device to
1
In a few places in the ITS command handling functions, we were
2
use the correct CPU.
2
doing the range-check of an event ID or device ID only after using
3
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf
3
it as a table index; move the checks to before the uses.
4
4
5
When the BCM2836 was introduced (bad5623690b) the Cortex-A7 was not
5
This misordering wouldn't have very bad effects because the
6
available, so the very similar Cortex-A15 was used. Since dcf578ed8ce
6
tables are in guest memory anyway.
7
we can model the correct core.
8
7
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Alistair Francis <alistair@alistair23.me>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20220111171048.3545974-13-peter.maydell@linaro.org
12
Message-id: 20180319110215.16755-1-peter.maydell@linaro.org
13
---
11
---
14
hw/arm/bcm2836.c | 2 +-
12
hw/intc/arm_gicv3_its.c | 42 ++++++++++++++++++++++++-----------------
15
hw/arm/raspi.c | 2 +-
13
1 file changed, 25 insertions(+), 17 deletions(-)
16
2 files changed, 2 insertions(+), 2 deletions(-)
17
14
18
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
15
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/bcm2836.c
17
--- a/hw/intc/arm_gicv3_its.c
21
+++ b/hw/arm/bcm2836.c
18
+++ b/hw/intc/arm_gicv3_its.c
22
@@ -XXX,XX +XXX,XX @@ struct BCM283XInfo {
19
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
23
static const BCM283XInfo bcm283x_socs[] = {
20
24
{
21
eventid = (value & EVENTID_MASK);
25
.name = TYPE_BCM2836,
22
26
- .cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"),
23
+ if (devid >= s->dt.num_ids) {
27
+ .cpu_type = ARM_CPU_TYPE_NAME("cortex-a7"),
24
+ qemu_log_mask(LOG_GUEST_ERROR,
28
.clusterid = 0xf,
25
+ "%s: invalid command attributes: devid %d>=%d",
29
},
26
+ __func__, devid, s->dt.num_ids);
30
#ifdef TARGET_AARCH64
27
+ return CMD_CONTINUE;
31
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
28
+ }
32
index XXXXXXX..XXXXXXX 100644
29
+
33
--- a/hw/arm/raspi.c
30
dte = get_dte(s, devid, &res);
34
+++ b/hw/arm/raspi.c
31
35
@@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc)
32
if (res != MEMTX_OK) {
36
mc->no_parallel = 1;
33
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
37
mc->no_floppy = 1;
34
38
mc->no_cdrom = 1;
35
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
39
- mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
36
40
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a7");
37
+ if (eventid >= num_eventids) {
41
mc->max_cpus = BCM283X_NCPUS;
38
+ qemu_log_mask(LOG_GUEST_ERROR,
42
mc->min_cpus = BCM283X_NCPUS;
39
+ "%s: invalid command attributes: eventid %d >= %"
43
mc->default_cpus = BCM283X_NCPUS;
40
+ PRId64 "\n",
41
+ __func__, eventid, num_eventids);
42
+ return CMD_CONTINUE;
43
+ }
44
+
45
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
46
if (res != MEMTX_OK) {
47
return CMD_STALL;
48
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
49
return CMD_CONTINUE;
50
}
51
52
- if (devid >= s->dt.num_ids) {
53
- qemu_log_mask(LOG_GUEST_ERROR,
54
- "%s: invalid command attributes: devid %d>=%d",
55
- __func__, devid, s->dt.num_ids);
56
- return CMD_CONTINUE;
57
- }
58
- if (eventid >= num_eventids) {
59
- qemu_log_mask(LOG_GUEST_ERROR,
60
- "%s: invalid command attributes: eventid %d >= %"
61
- PRId64 "\n",
62
- __func__, eventid, num_eventids);
63
- return CMD_CONTINUE;
64
- }
65
-
66
/*
67
* Current implementation only supports rdbase == procnum
68
* Hence rdbase physical address is ignored
69
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
70
71
icid = value & ICID_MASK;
72
73
+ if (devid >= s->dt.num_ids) {
74
+ qemu_log_mask(LOG_GUEST_ERROR,
75
+ "%s: invalid command attributes: devid %d>=%d",
76
+ __func__, devid, s->dt.num_ids);
77
+ return CMD_CONTINUE;
78
+ }
79
+
80
dte = get_dte(s, devid, &res);
81
82
if (res != MEMTX_OK) {
83
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
84
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
85
num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);
86
87
- if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
88
+ if ((icid >= s->ct.num_ids)
89
|| !dte_valid || (eventid >= num_eventids) ||
90
(((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) &&
91
(pIntid != INTID_SPURIOUS))) {
92
qemu_log_mask(LOG_GUEST_ERROR,
93
"%s: invalid command attributes "
94
- "devid %d or icid %d or eventid %d or pIntid %d or"
95
- "unmapped dte %d\n", __func__, devid, icid, eventid,
96
+ "icid %d or eventid %d or pIntid %d or"
97
+ "unmapped dte %d\n", __func__, icid, eventid,
98
pIntid, dte_valid);
99
/*
100
* in this implementation, in case of error
44
--
101
--
45
2.16.2
102
2.25.1
46
103
47
104
diff view generated by jsdifflib
1
When a debug exception is taken to AArch32, it appears as a Prefetch
1
In process_its_cmd(), we read an ICID out of the interrupt table
2
Abort, and the Instruction Fault Status Register (IFSR) must be set.
2
entry, and then use it as an index into the collection table. Add a
3
The IFSR has two possible formats, depending on whether LPAE is in
3
check that it is within range for the collection table first.
4
use. Factor out the code in arm_debug_excp_handler() which picks
5
an FSR value into its own utility function, update it to use
6
arm_fi_to_lfsc() and arm_fi_to_sfsc() rather than hard-coded constants,
7
and use the correct condition to select long or short format.
8
4
9
In particular this fixes a bug where we could select the short
5
This check is not strictly necessary, because:
10
format because we're at EL0 and the EL1 translation regime is
6
* we range check the ICID from the guest before writing it into
11
not using LPAE, but then route the debug exception to EL2 because
7
the interrupt table entry, so the the only way to get an
12
of MDCR_EL2.TDE and hand EL2 the wrong format FSR.
8
out of range ICID in process_its_cmd() is if a badly-behaved
9
guest is writing directly to the interrupt table memory
10
* the collection table is in guest memory, so QEMU won't fall
11
over if we read off the end of it
12
13
However, it seems clearer to include the check.
13
14
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
16
Message-id: 20180320134114.30418-3-peter.maydell@linaro.org
17
Message-id: 20220111171048.3545974-14-peter.maydell@linaro.org
17
---
18
---
18
target/arm/internals.h | 25 +++++++++++++++++++++++++
19
hw/intc/arm_gicv3_its.c | 7 +++++++
19
target/arm/op_helper.c | 12 ++----------
20
1 file changed, 7 insertions(+)
20
2 files changed, 27 insertions(+), 10 deletions(-)
21
21
22
diff --git a/target/arm/internals.h b/target/arm/internals.h
22
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
23
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/internals.h
24
--- a/hw/intc/arm_gicv3_its.c
25
+++ b/target/arm/internals.h
25
+++ b/hw/intc/arm_gicv3_its.c
26
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx)
26
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
27
return CMD_CONTINUE;
27
}
28
}
28
}
29
29
30
+ if (icid >= s->ct.num_ids) {
30
+/* Return the FSR value for a debug exception (watchpoint, hardware
31
+ qemu_log_mask(LOG_GUEST_ERROR,
31
+ * breakpoint or BKPT insn) targeting the specified exception level.
32
+ "%s: invalid ICID 0x%x in ITE (table corrupted?)\n",
32
+ */
33
+ __func__, icid);
33
+static inline uint32_t arm_debug_exception_fsr(CPUARMState *env)
34
+ return CMD_CONTINUE;
34
+{
35
+ ARMMMUFaultInfo fi = { .type = ARMFault_Debug };
36
+ int target_el = arm_debug_target_el(env);
37
+ bool using_lpae = false;
38
+
39
+ if (target_el == 2 || arm_el_is_aa64(env, target_el)) {
40
+ using_lpae = true;
41
+ } else {
42
+ if (arm_feature(env, ARM_FEATURE_LPAE) &&
43
+ (env->cp15.tcr_el[target_el].raw_tcr & TTBCR_EAE)) {
44
+ using_lpae = true;
45
+ }
46
+ }
35
+ }
47
+
36
+
48
+ if (using_lpae) {
37
cte_valid = get_cte(s, icid, &cte, &res);
49
+ return arm_fi_to_lfsc(&fi);
38
if (res != MEMTX_OK) {
50
+ } else {
39
return CMD_STALL;
51
+ return arm_fi_to_sfsc(&fi);
52
+ }
53
+}
54
+
55
#endif
56
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/target/arm/op_helper.c
59
+++ b/target/arm/op_helper.c
60
@@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs)
61
62
cs->watchpoint_hit = NULL;
63
64
- if (extended_addresses_enabled(env)) {
65
- env->exception.fsr = (1 << 9) | 0x22;
66
- } else {
67
- env->exception.fsr = 0x2;
68
- }
69
+ env->exception.fsr = arm_debug_exception_fsr(env);
70
env->exception.vaddress = wp_hit->hitaddr;
71
raise_exception(env, EXCP_DATA_ABORT,
72
syn_watchpoint(same_el, 0, wnr),
73
@@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs)
74
return;
75
}
76
77
- if (extended_addresses_enabled(env)) {
78
- env->exception.fsr = (1 << 9) | 0x22;
79
- } else {
80
- env->exception.fsr = 0x2;
81
- }
82
+ env->exception.fsr = arm_debug_exception_fsr(env);
83
/* FAR is UNKNOWN, so doesn't need setting */
84
raise_exception(env, EXCP_PREFETCH_ABORT,
85
syn_breakpoint(same_el),
86
--
40
--
87
2.16.2
41
2.25.1
88
42
89
43
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Detected by Coverity (CID 1386072, 1386073, 1386076, 1386077). local_err
3
Quoting Peter Maydell:
4
was unused, and this made the static analyzer unhappy.
5
4
6
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
5
"These MEMTX_* aren't from the memory transaction
7
Message-id: 20180320151355.25854-1-pbonzini@redhat.com
6
API functions; they're just being used by gicd_readl() and
7
friends as a way to indicate a success/failure so that the
8
actual MemoryRegionOps read/write fns like gicv3_dist_read()
9
can log a guest error."
10
11
We are going to introduce more MemTxResult bits, so it is
12
safer to check for !MEMTX_OK rather than MEMTX_ERROR.
13
14
Reviewed-by: Peter Xu <peterx@redhat.com>
15
Reviewed-by: David Hildenbrand <david@redhat.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
18
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
20
---
11
hw/sd/sdhci.c | 4 ++--
21
hw/intc/arm_gicv3_redist.c | 4 ++--
12
1 file changed, 2 insertions(+), 2 deletions(-)
22
1 file changed, 2 insertions(+), 2 deletions(-)
13
23
14
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
24
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
15
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/sd/sdhci.c
26
--- a/hw/intc/arm_gicv3_redist.c
17
+++ b/hw/sd/sdhci.c
27
+++ b/hw/intc/arm_gicv3_redist.c
18
@@ -XXX,XX +XXX,XX @@ static void sdhci_pci_realize(PCIDevice *dev, Error **errp)
28
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data,
19
Error *local_err = NULL;
29
break;
20
30
}
21
sdhci_initfn(s);
31
22
- sdhci_common_realize(s, errp);
32
- if (r == MEMTX_ERROR) {
23
+ sdhci_common_realize(s, &local_err);
33
+ if (r != MEMTX_OK) {
24
if (local_err) {
34
qemu_log_mask(LOG_GUEST_ERROR,
25
error_propagate(errp, local_err);
35
"%s: invalid guest read at offset " TARGET_FMT_plx
26
return;
36
" size %u\n", __func__, offset, size);
27
@@ -XXX,XX +XXX,XX @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)
37
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data,
28
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
38
break;
29
Error *local_err = NULL;
39
}
30
40
31
- sdhci_common_realize(s, errp);
41
- if (r == MEMTX_ERROR) {
32
+ sdhci_common_realize(s, &local_err);
42
+ if (r != MEMTX_OK) {
33
if (local_err) {
43
qemu_log_mask(LOG_GUEST_ERROR,
34
error_propagate(errp, local_err);
44
"%s: invalid guest write at offset " TARGET_FMT_plx
35
return;
45
" size %u\n", __func__, offset, size);
36
--
46
--
37
2.16.2
47
2.25.1
38
48
39
49
diff view generated by jsdifflib