1
The following changes since commit b10d00d8811fa4eed4862963273d7353ce310c82:
1
Hi; here's a target-arm pullreq for rc0; these are all bugfixes
2
and similar minor stuff.
2
3
3
Merge remote-tracking branch 'remotes/kraxel/tags/seabios-20220118-pull-request' into staging (2022-01-19 18:46:28 +0000)
4
thanks
5
-- PMM
6
7
The following changes since commit 0462a32b4f63b2448b4a196381138afd50719dc4:
8
9
Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging (2025-03-14 09:31:13 +0800)
4
10
5
are available in the Git repository at:
11
are available in the Git repository at:
6
12
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220120
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20250314-1
8
14
9
for you to fetch changes up to 9705e3c1dcff96b0b3c7e594b6cd68d27d6c4ced:
15
for you to fetch changes up to a019e15edfd62beae1e2f6adc0fa7415ba20b14c:
10
16
11
hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR (2022-01-20 11:47:54 +0000)
17
meson.build: Set RUST_BACKTRACE for all tests (2025-03-14 12:54:33 +0000)
12
18
13
----------------------------------------------------------------
19
----------------------------------------------------------------
14
target-arm:
20
target-arm queue:
15
* hw/intc/arm_gicv3_its: Fix various minor bugs
21
* Correctly handle corner cases of guest attempting an exception
16
* hw/arm/aspeed: Add the i3c device to the AST2600 SoC
22
return to AArch32 when target EL is AArch64 only
17
* hw/arm: kudo: add lm75s behind bus 1 switch at 75
23
* MAINTAINERS: Fix status for Arm boards I "maintain"
18
* hw/arm/virt: Fix support for running guests on hosts
24
* tests/functional: Bump up arm_replay timeout
19
with restricted IPA ranges
25
* Revert "hw/char/pl011: Warn when using disabled receiver"
20
* hw/intc/arm_gic: Allow reset of the running priority
26
* util/cacheflush: Make first DSB unconditional on aarch64
21
* hw/intc/arm_gic: Implement read of GICC_IIDR
27
* target/arm: Fix SVE/SME access check logic
22
* hw/arm/virt: Support for virtio-mem-pci
28
* meson.build: Set RUST_BACKTRACE for all tests
23
* hw/arm/virt: Support CPU cluster on ARM virt machine
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
27
29
28
----------------------------------------------------------------
30
----------------------------------------------------------------
29
Gavin Shan (2):
31
Joe Komlodi (1):
30
virtio-mem: Correct default THP size for ARM64
32
util/cacheflush: Make first DSB unconditional on aarch64
31
hw/arm/virt: Support for virtio-mem-pci
32
33
33
Lucas Ramage (1):
34
Paolo Bonzini (1):
34
docs/can: convert to restructuredText
35
Revert "hw/char/pl011: Warn when using disabled receiver"
35
36
Marc Zyngier (7):
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
44
45
Patrick Venture (1):
46
hw/arm: kudo add lm75s behind bus 1 switch at 75
47
36
48
Peter Maydell (13):
37
Peter Maydell (13):
49
hw/intc/arm_gicv3_its: Fix event ID bounds checks
38
target/arm: Move A32_BANKED_REG_{GET,SET} macros to cpregs.h
50
hw/intc/arm_gicv3_its: Convert int ID check to num_intids convention
39
target/arm: Un-inline access_secure_reg()
51
hw/intc/arm_gicv3_its: Fix handling of process_its_cmd() return value
40
linux-user/aarch64: Remove unused get/put_user macros
52
hw/intc/arm_gicv3_its: Don't use data if reading command failed
41
linux-user/arm: Remove unused get_put_user macros
53
hw/intc/arm_gicv3_its: Use enum for return value of process_* functions
42
target/arm: Move arm_cpu_data_is_big_endian() etc to internals.h
54
hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd()
43
target/arm: Move arm_current_el() and arm_el_is_aa64() to internals.h
55
hw/intc/arm_gicv3_its: Refactor process_its_cmd() to reduce nesting
44
target/arm: SCR_EL3.RW should be treated as 1 if EL2 doesn't support AArch32
56
hw/intc/arm_gicv3_its: Fix return codes in process_mapti()
45
target/arm: HCR_EL2.RW should be RAO/WI if EL1 doesn't support AArch32
57
hw/intc/arm_gicv3_its: Fix return codes in process_mapc()
46
target/arm: Add cpu local variable to exception_return helper
58
hw/intc/arm_gicv3_its: Fix return codes in process_mapd()
47
target/arm: Forbid return to AArch32 when CPU is AArch64-only
59
hw/intc/arm_gicv3_its: Factor out "find address of table entry" code
48
MAINTAINERS: Fix status for Arm boards I "maintain"
60
hw/intc/arm_gicv3_its: Check indexes before use, not after
49
tests/functional: Bump up arm_replay timeout
61
hw/intc/arm_gicv3_its: Range-check ICID before indexing into collection table
50
meson.build: Set RUST_BACKTRACE for all tests
62
51
63
Petr Pavlu (2):
52
Richard Henderson (2):
64
hw/intc/arm_gic: Implement read of GICC_IIDR
53
target/arm: Make DisasContext.{fp, sve}_access_checked tristate
65
hw/intc/arm_gic: Allow reset of the running priority
54
target/arm: Simplify pstate_sm check in sve_access_check
66
55
67
Philippe Mathieu-Daudé (4):
56
MAINTAINERS | 14 ++--
68
hw: Move MARVELL_88W8618 Kconfig from audio/ to arm/
57
meson.build | 9 ++-
69
hw/arm/musicpal: Fix coding style of code related to MV88W8618 device
58
target/arm/cpregs.h | 28 +++++++
70
hw/net: Move MV88W8618 network device out of hw/arm/ directory
59
target/arm/cpu.h | 153 +-----------------------------------
71
hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR
60
target/arm/internals.h | 135 +++++++++++++++++++++++++++++++
72
61
target/arm/tcg/translate-a64.h | 2 +-
73
Troy Lee (2):
62
target/arm/tcg/translate.h | 10 ++-
74
hw/misc/aspeed_i3c.c: Introduce a dummy AST2600 I3C model.
63
hw/char/pl011.c | 19 ++---
75
hw/arm/aspeed: Add the i3c device to the AST2600 SoC
64
hw/intc/arm_gicv3_cpuif.c | 1 +
76
65
linux-user/aarch64/cpu_loop.c | 48 -----------
77
Yanan Wang (6):
66
linux-user/arm/cpu_loop.c | 43 +---------
78
hw/arm/virt: Support CPU cluster on ARM virt machine
67
target/arm/arch_dump.c | 1 +
79
hw/arm/virt: Support cluster level in DT cpu-map
68
target/arm/helper.c | 16 +++-
80
hw/acpi/aml-build: Improve scalability of PPTT generation
69
target/arm/tcg/helper-a64.c | 12 ++-
81
tests/acpi/bios-tables-test: Allow changes to virt/PPTT file
70
target/arm/tcg/hflags.c | 9 +++
82
hw/acpi/aml-build: Support cluster level in PPTT generation
71
target/arm/tcg/translate-a64.c | 37 ++++-----
83
tests/acpi/bios-table-test: Update expected virt/PPTT file
72
util/cacheflush.c | 4 +-
84
73
.gitlab-ci.d/buildtest-template.yml | 1 -
85
docs/system/arm/cpu-features.rst | 4 -
74
18 files changed, 257 insertions(+), 285 deletions(-)
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
1
Fix process_mapc() to consistently return CMD_STALL for memory
1
The A32_BANKED_REG_{GET,SET} macros are only used inside target/arm;
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
2
move their definitions to cpregs.h. There's no need to have them
3
comments that we do.
3
defined in all the code that includes cpu.h.
4
4
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
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>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-10-peter.maydell@linaro.org
9
---
7
---
10
hw/intc/arm_gicv3_its.c | 8 +++-----
8
target/arm/cpregs.h | 28 ++++++++++++++++++++++++++++
11
1 file changed, 3 insertions(+), 5 deletions(-)
9
target/arm/cpu.h | 27 ---------------------------
10
2 files changed, 28 insertions(+), 27 deletions(-)
12
11
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
12
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
14
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
14
--- a/target/arm/cpregs.h
16
+++ b/hw/intc/arm_gicv3_its.c
15
+++ b/target/arm/cpregs.h
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
16
@@ -XXX,XX +XXX,XX @@ static inline bool arm_cpreg_traps_in_nv(const ARMCPRegInfo *ri)
18
uint64_t rdbase;
17
return ri->opc1 == 4 || ri->opc1 == 5;
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
}
18
}
46
19
47
static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
20
+/* Macros for accessing a specified CP register bank */
21
+#define A32_BANKED_REG_GET(_env, _regname, _secure) \
22
+ ((_secure) ? (_env)->cp15._regname##_s : (_env)->cp15._regname##_ns)
23
+
24
+#define A32_BANKED_REG_SET(_env, _regname, _secure, _val) \
25
+ do { \
26
+ if (_secure) { \
27
+ (_env)->cp15._regname##_s = (_val); \
28
+ } else { \
29
+ (_env)->cp15._regname##_ns = (_val); \
30
+ } \
31
+ } while (0)
32
+
33
+/*
34
+ * Macros for automatically accessing a specific CP register bank depending on
35
+ * the current secure state of the system. These macros are not intended for
36
+ * supporting instruction translation reads/writes as these are dependent
37
+ * solely on the SCR.NS bit and not the mode.
38
+ */
39
+#define A32_BANKED_CURRENT_REG_GET(_env, _regname) \
40
+ A32_BANKED_REG_GET((_env), _regname, \
41
+ (arm_is_secure(_env) && !arm_el_is_aa64((_env), 3)))
42
+
43
+#define A32_BANKED_CURRENT_REG_SET(_env, _regname, _val) \
44
+ A32_BANKED_REG_SET((_env), _regname, \
45
+ (arm_is_secure(_env) && !arm_el_is_aa64((_env), 3)), \
46
+ (_val))
47
+
48
#endif /* TARGET_ARM_CPREGS_H */
49
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
50
index XXXXXXX..XXXXXXX 100644
51
--- a/target/arm/cpu.h
52
+++ b/target/arm/cpu.h
53
@@ -XXX,XX +XXX,XX @@ static inline bool access_secure_reg(CPUARMState *env)
54
return ret;
55
}
56
57
-/* Macros for accessing a specified CP register bank */
58
-#define A32_BANKED_REG_GET(_env, _regname, _secure) \
59
- ((_secure) ? (_env)->cp15._regname##_s : (_env)->cp15._regname##_ns)
60
-
61
-#define A32_BANKED_REG_SET(_env, _regname, _secure, _val) \
62
- do { \
63
- if (_secure) { \
64
- (_env)->cp15._regname##_s = (_val); \
65
- } else { \
66
- (_env)->cp15._regname##_ns = (_val); \
67
- } \
68
- } while (0)
69
-
70
-/* Macros for automatically accessing a specific CP register bank depending on
71
- * the current secure state of the system. These macros are not intended for
72
- * supporting instruction translation reads/writes as these are dependent
73
- * solely on the SCR.NS bit and not the mode.
74
- */
75
-#define A32_BANKED_CURRENT_REG_GET(_env, _regname) \
76
- A32_BANKED_REG_GET((_env), _regname, \
77
- (arm_is_secure(_env) && !arm_el_is_aa64((_env), 3)))
78
-
79
-#define A32_BANKED_CURRENT_REG_SET(_env, _regname, _val) \
80
- A32_BANKED_REG_SET((_env), _regname, \
81
- (arm_is_secure(_env) && !arm_el_is_aa64((_env), 3)), \
82
- (_val))
83
-
84
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
85
uint32_t cur_el, bool secure);
86
48
--
87
--
49
2.25.1
88
2.43.0
50
51
diff view generated by jsdifflib
1
From: Gavin Shan <gshan@redhat.com>
1
We would like to move arm_el_is_aa64() to internals.h; however, it is
2
used by access_secure_reg(). Make that function not be inline, so
3
that it can stay in cpu.h.
2
4
3
This supports virtio-mem-pci device on "virt" platform, by simply
5
access_secure_reg() is used only in two places:
4
following the implementation on x86.
6
* in hflags.c
7
* in the user-mode arm emulators, to decide whether to store
8
the TLS value in the secure or non-secure banked field
5
9
6
* This implements the hotplug handlers to support virtio-mem-pci
10
The second of these is not on a super-hot path that would care about
7
device hot-add, while the hot-remove isn't supported as we have
11
the inlining (and incidentally will always use the NS banked field
8
on x86.
12
because our user-mode CPUs never set ARM_FEATURE_EL3); put the
13
definition of access_secure_reg() in hflags.c, near its only use
14
inside target/arm.
9
15
10
* The block size is 512MB on ARM64 instead of 128MB on x86.
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
---
19
target/arm/cpu.h | 12 +++---------
20
target/arm/tcg/hflags.c | 9 +++++++++
21
2 files changed, 12 insertions(+), 9 deletions(-)
11
22
12
* It has been passing the tests with various combinations like 64KB
23
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
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
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
25
hw/arm/virt.c | 70 ++++++++++++++++++++++++++++++++++++++++++
26
hw/virtio/virtio-mem.c | 4 ++-
27
hw/arm/Kconfig | 1 +
28
3 files changed, 74 insertions(+), 1 deletion(-)
29
30
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
31
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/arm/virt.c
25
--- a/target/arm/cpu.h
33
+++ b/hw/arm/virt.c
26
+++ b/target/arm/cpu.h
34
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el)
35
#include "hw/arm/smmuv3.h"
28
return aa64;
36
#include "hw/acpi/acpi.h"
37
#include "target/arm/internals.h"
38
+#include "hw/mem/memory-device.h"
39
#include "hw/mem/pc-dimm.h"
40
#include "hw/mem/nvdimm.h"
41
#include "hw/acpi/generic_event_device.h"
42
+#include "hw/virtio/virtio-mem-pci.h"
43
#include "hw/virtio/virtio-iommu.h"
44
#include "hw/char/pl011.h"
45
#include "qemu/guest-random.h"
46
@@ -XXX,XX +XXX,XX @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
47
dev, &error_abort);
48
}
29
}
49
30
50
+static void virt_virtio_md_pci_pre_plug(HotplugHandler *hotplug_dev,
31
-/* Function for determining whether guest cp register reads and writes should
51
+ DeviceState *dev, Error **errp)
32
+/*
33
+ * Function for determining whether guest cp register reads and writes should
34
* access the secure or non-secure bank of a cp register. When EL3 is
35
* operating in AArch32 state, the NS-bit determines whether the secure
36
* instance of a cp register should be used. When EL3 is AArch64 (or if
37
* it doesn't exist at all) then there is no register banking, and all
38
* accesses are to the non-secure version.
39
*/
40
-static inline bool access_secure_reg(CPUARMState *env)
41
-{
42
- bool ret = (arm_feature(env, ARM_FEATURE_EL3) &&
43
- !arm_el_is_aa64(env, 3) &&
44
- !(env->cp15.scr_el3 & SCR_NS));
45
-
46
- return ret;
47
-}
48
+bool access_secure_reg(CPUARMState *env);
49
50
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
51
uint32_t cur_el, bool secure);
52
diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/tcg/hflags.c
55
+++ b/target/arm/tcg/hflags.c
56
@@ -XXX,XX +XXX,XX @@ static bool aprofile_require_alignment(CPUARMState *env, int el, uint64_t sctlr)
57
#endif
58
}
59
60
+bool access_secure_reg(CPUARMState *env)
52
+{
61
+{
53
+ HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
62
+ bool ret = (arm_feature(env, ARM_FEATURE_EL3) &&
54
+ Error *local_err = NULL;
63
+ !arm_el_is_aa64(env, 3) &&
64
+ !(env->cp15.scr_el3 & SCR_NS));
55
+
65
+
56
+ if (!hotplug_dev2 && dev->hotplugged) {
66
+ return ret;
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);
77
+}
67
+}
78
+
68
+
79
+static void virt_virtio_md_pci_plug(HotplugHandler *hotplug_dev,
69
static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el,
80
+ DeviceState *dev, Error **errp)
70
ARMMMUIdx mmu_idx,
81
+{
71
CPUARMTBFlags flags)
82
+ HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
83
+ Error *local_err = NULL;
84
+
85
+ /*
86
+ * Plug the memory device first and then branch off to the actual
87
+ * hotplug handler. If that one fails, we can easily undo the memory
88
+ * device bits.
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);
98
+}
99
+
100
+static void virt_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev,
101
+ DeviceState *dev, Error **errp)
102
+{
103
+ /* We don't support hot unplug of virtio based memory devices */
104
+ error_setg(errp, "virtio based memory devices cannot be unplugged.");
105
+}
106
+
107
+
108
static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
109
DeviceState *dev, Error **errp)
110
{
111
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
112
113
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
114
virt_memory_pre_plug(hotplug_dev, dev, errp);
115
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
116
+ virt_virtio_md_pci_pre_plug(hotplug_dev, dev, errp);
117
} else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
118
hwaddr db_start = 0, db_end = 0;
119
char *resv_prop_str;
120
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
121
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
122
virt_memory_plug(hotplug_dev, dev, errp);
123
}
124
+
125
+ if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
126
+ virt_virtio_md_pci_plug(hotplug_dev, dev, errp);
127
+ }
128
+
129
if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
130
PCIDevice *pdev = PCI_DEVICE(dev);
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
183
--
72
--
184
2.25.1
73
2.43.0
185
186
diff view generated by jsdifflib
1
In a few places in the ITS command handling functions, we were
1
At the top of linux-user/aarch64/cpu_loop.c we define a set of
2
doing the range-check of an event ID or device ID only after using
2
macros for reading and writing data and code words, but we never
3
it as a table index; move the checks to before the uses.
3
use these macros. Delete them.
4
5
This misordering wouldn't have very bad effects because the
6
tables are in guest memory anyway.
7
4
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220111171048.3545974-13-peter.maydell@linaro.org
11
---
7
---
12
hw/intc/arm_gicv3_its.c | 42 ++++++++++++++++++++++++-----------------
8
linux-user/aarch64/cpu_loop.c | 48 -----------------------------------
13
1 file changed, 25 insertions(+), 17 deletions(-)
9
1 file changed, 48 deletions(-)
14
10
15
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
11
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/arm_gicv3_its.c
13
--- a/linux-user/aarch64/cpu_loop.c
18
+++ b/hw/intc/arm_gicv3_its.c
14
+++ b/linux-user/aarch64/cpu_loop.c
19
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
15
@@ -XXX,XX +XXX,XX @@
20
16
#include "target/arm/syndrome.h"
21
eventid = (value & EVENTID_MASK);
17
#include "target/arm/cpu-features.h"
22
18
23
+ if (devid >= s->dt.num_ids) {
19
-#define get_user_code_u32(x, gaddr, env) \
24
+ qemu_log_mask(LOG_GUEST_ERROR,
20
- ({ abi_long __r = get_user_u32((x), (gaddr)); \
25
+ "%s: invalid command attributes: devid %d>=%d",
21
- if (!__r && bswap_code(arm_sctlr_b(env))) { \
26
+ __func__, devid, s->dt.num_ids);
22
- (x) = bswap32(x); \
27
+ return CMD_CONTINUE;
23
- } \
28
+ }
24
- __r; \
29
+
25
- })
30
dte = get_dte(s, devid, &res);
31
32
if (res != MEMTX_OK) {
33
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
34
35
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
36
37
+ if (eventid >= num_eventids) {
38
+ qemu_log_mask(LOG_GUEST_ERROR,
39
+ "%s: invalid command attributes: eventid %d >= %"
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
-
26
-
66
/*
27
-#define get_user_code_u16(x, gaddr, env) \
67
* Current implementation only supports rdbase == procnum
28
- ({ abi_long __r = get_user_u16((x), (gaddr)); \
68
* Hence rdbase physical address is ignored
29
- if (!__r && bswap_code(arm_sctlr_b(env))) { \
69
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
30
- (x) = bswap16(x); \
70
31
- } \
71
icid = value & ICID_MASK;
32
- __r; \
72
33
- })
73
+ if (devid >= s->dt.num_ids) {
34
-
74
+ qemu_log_mask(LOG_GUEST_ERROR,
35
-#define get_user_data_u32(x, gaddr, env) \
75
+ "%s: invalid command attributes: devid %d>=%d",
36
- ({ abi_long __r = get_user_u32((x), (gaddr)); \
76
+ __func__, devid, s->dt.num_ids);
37
- if (!__r && arm_cpu_bswap_data(env)) { \
77
+ return CMD_CONTINUE;
38
- (x) = bswap32(x); \
78
+ }
39
- } \
79
+
40
- __r; \
80
dte = get_dte(s, devid, &res);
41
- })
81
42
-
82
if (res != MEMTX_OK) {
43
-#define get_user_data_u16(x, gaddr, env) \
83
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
44
- ({ abi_long __r = get_user_u16((x), (gaddr)); \
84
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
45
- if (!__r && arm_cpu_bswap_data(env)) { \
85
num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);
46
- (x) = bswap16(x); \
86
47
- } \
87
- if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
48
- __r; \
88
+ if ((icid >= s->ct.num_ids)
49
- })
89
|| !dte_valid || (eventid >= num_eventids) ||
50
-
90
(((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) &&
51
-#define put_user_data_u32(x, gaddr, env) \
91
(pIntid != INTID_SPURIOUS))) {
52
- ({ typeof(x) __x = (x); \
92
qemu_log_mask(LOG_GUEST_ERROR,
53
- if (arm_cpu_bswap_data(env)) { \
93
"%s: invalid command attributes "
54
- __x = bswap32(__x); \
94
- "devid %d or icid %d or eventid %d or pIntid %d or"
55
- } \
95
- "unmapped dte %d\n", __func__, devid, icid, eventid,
56
- put_user_u32(__x, (gaddr)); \
96
+ "icid %d or eventid %d or pIntid %d or"
57
- })
97
+ "unmapped dte %d\n", __func__, icid, eventid,
58
-
98
pIntid, dte_valid);
59
-#define put_user_data_u16(x, gaddr, env) \
99
/*
60
- ({ typeof(x) __x = (x); \
100
* in this implementation, in case of error
61
- if (arm_cpu_bswap_data(env)) { \
62
- __x = bswap16(__x); \
63
- } \
64
- put_user_u16(__x, (gaddr)); \
65
- })
66
-
67
/* AArch64 main loop */
68
void cpu_loop(CPUARMState *env)
69
{
101
--
70
--
102
2.25.1
71
2.43.0
103
104
diff view generated by jsdifflib
1
Fix process_mapti() to consistently return CMD_STALL for memory
1
In linux-user/arm/cpu_loop.c we define a full set of get/put
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
2
macros for both code and data (since the endianness handling
3
comments that we do.
3
is different between the two). However the only one we actually
4
use is get_user_code_u32(). Remove the rest.
5
6
We leave a comment noting how data-side accesses should be handled
7
for big-endian, because that's a subtle point and we just removed the
8
macros that were effectively documenting it.
4
9
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
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>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-9-peter.maydell@linaro.org
9
---
12
---
10
hw/intc/arm_gicv3_its.c | 28 +++++++++++++---------------
13
linux-user/arm/cpu_loop.c | 43 ++++-----------------------------------
11
1 file changed, 13 insertions(+), 15 deletions(-)
14
1 file changed, 4 insertions(+), 39 deletions(-)
12
15
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
16
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
18
--- a/linux-user/arm/cpu_loop.c
16
+++ b/hw/intc/arm_gicv3_its.c
19
+++ b/linux-user/arm/cpu_loop.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
20
@@ -XXX,XX +XXX,XX @@
18
MemTxResult res = MEMTX_OK;
21
__r; \
19
uint16_t icid = 0;
22
})
20
uint64_t dte = 0;
23
21
- ItsCmdResult result = CMD_STALL;
24
-#define get_user_code_u16(x, gaddr, env) \
22
+ IteEntry ite = {};
25
- ({ abi_long __r = get_user_u16((x), (gaddr)); \
23
26
- if (!__r && bswap_code(arm_sctlr_b(env))) { \
24
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
27
- (x) = bswap16(x); \
25
offset += NUM_BYTES_IN_DW;
28
- } \
26
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
29
- __r; \
27
MEMTXATTRS_UNSPECIFIED, &res);
30
- })
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
-
31
-
66
- result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
32
-#define get_user_data_u32(x, gaddr, env) \
67
+ return CMD_CONTINUE;
33
- ({ abi_long __r = get_user_u32((x), (gaddr)); \
68
}
34
- if (!__r && arm_cpu_bswap_data(env)) { \
69
35
- (x) = bswap32(x); \
70
- return result;
36
- } \
71
+ /* add ite entry to interrupt translation table */
37
- __r; \
72
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid);
38
- })
73
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL);
39
-
74
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid);
40
-#define get_user_data_u16(x, gaddr, env) \
75
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
41
- ({ abi_long __r = get_user_u16((x), (gaddr)); \
76
+ ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
42
- if (!__r && arm_cpu_bswap_data(env)) { \
77
+
43
- (x) = bswap16(x); \
78
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
44
- } \
79
}
45
- __r; \
80
46
- })
81
static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
47
-
48
-#define put_user_data_u32(x, gaddr, env) \
49
- ({ typeof(x) __x = (x); \
50
- if (arm_cpu_bswap_data(env)) { \
51
- __x = bswap32(__x); \
52
- } \
53
- put_user_u32(__x, (gaddr)); \
54
- })
55
-
56
-#define put_user_data_u16(x, gaddr, env) \
57
- ({ typeof(x) __x = (x); \
58
- if (arm_cpu_bswap_data(env)) { \
59
- __x = bswap16(__x); \
60
- } \
61
- put_user_u16(__x, (gaddr)); \
62
- })
63
+/*
64
+ * Note that if we need to do data accesses here, they should do a
65
+ * bswap if arm_cpu_bswap_data() returns true.
66
+ */
67
68
/*
69
* Similar to code in accel/tcg/user-exec.c, but outside the execution loop.
82
--
70
--
83
2.25.1
71
2.43.0
84
85
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
The arm_cpu_data_is_big_endian() and related functions are now used
2
only in target/arm; they can be moved to internals.h.
2
3
3
The Marvell 88W8618 network device is hidden in the Musicpal
4
The motivation here is that we would like to move arm_current_el()
4
machine. Move it into a new unit file under the hw/net/ directory.
5
to internals.h.
5
6
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>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
---
9
---
12
include/hw/net/mv88w8618_eth.h | 12 +
10
target/arm/cpu.h | 48 ------------------------------------------
13
hw/arm/musicpal.c | 381 +------------------------------
11
target/arm/internals.h | 48 ++++++++++++++++++++++++++++++++++++++++++
14
hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++++++++++
12
2 files changed, 48 insertions(+), 48 deletions(-)
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
13
21
diff --git a/include/hw/net/mv88w8618_eth.h b/include/hw/net/mv88w8618_eth.h
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.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
15
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/arm/musicpal.c
16
--- a/target/arm/cpu.h
42
+++ b/hw/arm/musicpal.c
17
+++ b/target/arm/cpu.h
43
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static inline bool arm_sctlr_b(CPUARMState *env)
44
#include "ui/pixel_ops.h"
19
45
#include "qemu/cutils.h"
20
uint64_t arm_sctlr(CPUARMState *env, int el);
46
#include "qom/object.h"
21
47
+#include "hw/net/mv88w8618_eth.h"
22
-static inline bool arm_cpu_data_is_big_endian_a32(CPUARMState *env,
48
23
- bool sctlr_b)
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
-{
24
-{
157
- cpu_to_le32s(&desc->cmdstat);
25
-#ifdef CONFIG_USER_ONLY
158
- cpu_to_le16s(&desc->bytes);
26
- /*
159
- cpu_to_le16s(&desc->buffer_size);
27
- * In system mode, BE32 is modelled in line with the
160
- cpu_to_le32s(&desc->buffer);
28
- * architecture (as word-invariant big-endianness), where loads
161
- cpu_to_le32s(&desc->next);
29
- * and stores are done little endian but from addresses which
162
- dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
30
- * are adjusted by XORing with the appropriate constant. So the
31
- * endianness to use for the raw data access is not affected by
32
- * SCTLR.B.
33
- * In user mode, however, we model BE32 as byte-invariant
34
- * big-endianness (because user-only code cannot tell the
35
- * difference), and so we need to use a data access endianness
36
- * that depends on SCTLR.B.
37
- */
38
- if (sctlr_b) {
39
- return true;
40
- }
41
-#endif
42
- /* In 32bit endianness is determined by looking at CPSR's E bit */
43
- return env->uncached_cpsr & CPSR_E;
163
-}
44
-}
164
-
45
-
165
-static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
46
-static inline bool arm_cpu_data_is_big_endian_a64(int el, uint64_t sctlr)
166
- mv88w8618_rx_desc *desc)
167
-{
47
-{
168
- dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
48
- return sctlr & (el ? SCTLR_EE : SCTLR_E0E);
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
-}
49
-}
175
-
50
-
176
-static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
51
-/* Return true if the processor is in big-endian mode. */
52
-static inline bool arm_cpu_data_is_big_endian(CPUARMState *env)
177
-{
53
-{
178
- mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
54
- if (!is_a64(env)) {
179
- uint32_t desc_addr;
55
- return arm_cpu_data_is_big_endian_a32(env, arm_sctlr_b(env));
180
- mv88w8618_rx_desc desc;
56
- } else {
181
- int i;
57
- int cur_el = arm_current_el(env);
182
-
58
- uint64_t sctlr = arm_sctlr(env, cur_el);
183
- for (i = 0; i < 4; i++) {
59
- return arm_cpu_data_is_big_endian_a64(cur_el, sctlr);
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
- }
60
- }
298
-}
61
-}
299
-
62
-
300
-static void mv88w8618_eth_write(void *opaque, hwaddr offset,
63
#include "exec/cpu-all.h"
301
- uint64_t value, unsigned size)
64
65
/*
66
@@ -XXX,XX +XXX,XX @@ static inline bool bswap_code(bool sctlr_b)
67
#endif
68
}
69
70
-#ifdef CONFIG_USER_ONLY
71
-static inline bool arm_cpu_bswap_data(CPUARMState *env)
302
-{
72
-{
303
- mv88w8618_eth_state *s = opaque;
73
- return TARGET_BIG_ENDIAN ^ arm_cpu_data_is_big_endian(env);
74
-}
75
-#endif
304
-
76
-
305
- switch (offset) {
77
void cpu_get_tb_cpu_state(CPUARMState *env, vaddr *pc,
306
- case MP_ETH_SMIR:
78
uint64_t *cs_base, uint32_t *flags);
307
- s->smir = value;
79
308
- break;
80
diff --git a/target/arm/internals.h b/target/arm/internals.h
309
-
81
index XXXXXXX..XXXXXXX 100644
310
- case MP_ETH_PCXR:
82
--- a/target/arm/internals.h
311
- s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2;
83
+++ b/target/arm/internals.h
312
- break;
84
@@ -XXX,XX +XXX,XX @@ static inline FloatRoundMode arm_rmode_to_sf(ARMFPRounding rmode)
313
-
85
return arm_rmode_to_sf_map[rmode];
314
- case MP_ETH_SDCMR:
86
}
315
- if (value & MP_ETH_CMD_TXHI) {
87
316
- eth_send(s, 1);
88
+static inline bool arm_cpu_data_is_big_endian_a32(CPUARMState *env,
317
- }
89
+ bool sctlr_b)
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
+{
90
+{
570
+ cpu_to_le32s(&desc->cmdstat);
91
+#ifdef CONFIG_USER_ONLY
571
+ cpu_to_le16s(&desc->bytes);
92
+ /*
572
+ cpu_to_le16s(&desc->buffer_size);
93
+ * In system mode, BE32 is modelled in line with the
573
+ cpu_to_le32s(&desc->buffer);
94
+ * architecture (as word-invariant big-endianness), where loads
574
+ cpu_to_le32s(&desc->next);
95
+ * and stores are done little endian but from addresses which
575
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
96
+ * are adjusted by XORing with the appropriate constant. So the
97
+ * endianness to use for the raw data access is not affected by
98
+ * SCTLR.B.
99
+ * In user mode, however, we model BE32 as byte-invariant
100
+ * big-endianness (because user-only code cannot tell the
101
+ * difference), and so we need to use a data access endianness
102
+ * that depends on SCTLR.B.
103
+ */
104
+ if (sctlr_b) {
105
+ return true;
106
+ }
107
+#endif
108
+ /* In 32bit endianness is determined by looking at CPSR's E bit */
109
+ return env->uncached_cpsr & CPSR_E;
576
+}
110
+}
577
+
111
+
578
+static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
112
+static inline bool arm_cpu_data_is_big_endian_a64(int el, uint64_t sctlr)
579
+ mv88w8618_rx_desc *desc)
580
+{
113
+{
581
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
114
+ return sctlr & (el ? SCTLR_EE : SCTLR_E0E);
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
+}
115
+}
588
+
116
+
589
+static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
117
+/* Return true if the processor is in big-endian mode. */
118
+static inline bool arm_cpu_data_is_big_endian(CPUARMState *env)
590
+{
119
+{
591
+ mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
120
+ if (!is_a64(env)) {
592
+ uint32_t desc_addr;
121
+ return arm_cpu_data_is_big_endian_a32(env, arm_sctlr_b(env));
593
+ mv88w8618_rx_desc desc;
122
+ } else {
594
+ int i;
123
+ int cur_el = arm_current_el(env);
595
+
124
+ uint64_t sctlr = arm_sctlr(env, cur_el);
596
+ for (i = 0; i < 4; i++) {
125
+ return arm_cpu_data_is_big_endian_a64(cur_el, sctlr);
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
+ }
126
+ }
711
+}
127
+}
712
+
128
+
713
+static void mv88w8618_eth_write(void *opaque, hwaddr offset,
129
+#ifdef CONFIG_USER_ONLY
714
+ uint64_t value, unsigned size)
130
+static inline bool arm_cpu_bswap_data(CPUARMState *env)
715
+{
131
+{
716
+ mv88w8618_eth_state *s = opaque;
132
+ return TARGET_BIG_ENDIAN ^ arm_cpu_data_is_big_endian(env);
133
+}
134
+#endif
717
+
135
+
718
+ switch (offset) {
136
static inline void aarch64_save_sp(CPUARMState *env, int el)
719
+ case MP_ETH_SMIR:
137
{
720
+ s->smir = value;
138
if (env->pstate & PSTATE_SP) {
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
--
139
--
885
2.25.1
140
2.43.0
886
887
diff view generated by jsdifflib
1
From: Marc Zyngier <maz@kernel.org>
1
The functions arm_current_el() and arm_el_is_aa64() are used only in
2
2
target/arm and in hw/intc/arm_gicv3_cpuif.c. They're functions that
3
Add basic support for Pointer Authentication when running a KVM
3
query internal state of the CPU. Move them out of cpu.h and into
4
guest and that the host supports it, loosely based on the SVE
4
internals.h.
5
support.
5
6
6
This means we need to include internals.h in arm_gicv3_cpuif.c, but
7
Although the feature is enabled by default when the host advertises
7
this is justifiable because that file is implementing the GICv3 CPU
8
it, it is possible to disable it by setting the 'pauth=off' CPU
8
interface, which really is part of the CPU proper; we just ended up
9
property. The 'pauth' comment is removed from cpu-features.rst,
9
implementing it in code in hw/intc/ for historical reasons.
10
as it is now common to both TCG and KVM.
10
11
11
The motivation for this move is that we'd like to change
12
Tested on an Apple M1 running 5.16-rc6.
12
arm_el_is_aa64() to add a condition that uses cpu_isar_feature();
13
13
but we don't want to include cpu-features.h in cpu.h.
14
Cc: Eric Auger <eric.auger@redhat.com>
14
15
Cc: Richard Henderson <richard.henderson@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@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>
16
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
---
17
---
24
docs/system/arm/cpu-features.rst | 4 ----
18
target/arm/cpu.h | 66 --------------------------------------
25
target/arm/cpu.h | 1 +
19
target/arm/internals.h | 67 +++++++++++++++++++++++++++++++++++++++
26
target/arm/cpu.c | 16 +++++-----------
20
hw/intc/arm_gicv3_cpuif.c | 1 +
27
target/arm/cpu64.c | 31 +++++++++++++++++++++++++++----
21
target/arm/arch_dump.c | 1 +
28
target/arm/kvm64.c | 21 +++++++++++++++++++++
22
4 files changed, 69 insertions(+), 66 deletions(-)
29
5 files changed, 54 insertions(+), 19 deletions(-)
23
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
24
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
47
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/cpu.h
26
--- a/target/arm/cpu.h
49
+++ b/target/arm/cpu.h
27
+++ b/target/arm/cpu.h
50
@@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
28
@@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, ARMSecuritySpace space);
51
void aarch64_sve_change_el(CPUARMState *env, int old_el,
29
uint64_t arm_hcr_el2_eff(CPUARMState *env);
52
int new_el, bool el0_a64);
30
uint64_t arm_hcrx_el2_eff(CPUARMState *env);
53
void aarch64_add_sve_properties(Object *obj);
31
54
+void aarch64_add_pauth_properties(Object *obj);
32
-/* Return true if the specified exception level is running in AArch64 state. */
55
33
-static inline bool arm_el_is_aa64(CPUARMState *env, int el)
34
-{
35
- /* This isn't valid for EL0 (if we're in EL0, is_a64() is what you want,
36
- * and if we're not in EL0 then the state of EL0 isn't well defined.)
37
- */
38
- assert(el >= 1 && el <= 3);
39
- bool aa64 = arm_feature(env, ARM_FEATURE_AARCH64);
40
-
41
- /* The highest exception level is always at the maximum supported
42
- * register width, and then lower levels have a register width controlled
43
- * by bits in the SCR or HCR registers.
44
- */
45
- if (el == 3) {
46
- return aa64;
47
- }
48
-
49
- if (arm_feature(env, ARM_FEATURE_EL3) &&
50
- ((env->cp15.scr_el3 & SCR_NS) || !(env->cp15.scr_el3 & SCR_EEL2))) {
51
- aa64 = aa64 && (env->cp15.scr_el3 & SCR_RW);
52
- }
53
-
54
- if (el == 2) {
55
- return aa64;
56
- }
57
-
58
- if (arm_is_el2_enabled(env)) {
59
- aa64 = aa64 && (env->cp15.hcr_el2 & HCR_RW);
60
- }
61
-
62
- return aa64;
63
-}
64
-
56
/*
65
/*
57
* SVE registers are encoded in KVM's memory in an endianness-invariant format.
66
* Function for determining whether guest cp register reads and writes should
58
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
67
* access the secure or non-secure bank of a cp register. When EL3 is
59
index XXXXXXX..XXXXXXX 100644
68
@@ -XXX,XX +XXX,XX @@ static inline bool arm_v7m_is_handler_mode(CPUARMState *env)
60
--- a/target/arm/cpu.c
69
return env->v7m.exception != 0;
61
+++ b/target/arm/cpu.c
70
}
62
@@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
71
63
return;
72
-/* Return the current Exception Level (as per ARMv8; note that this differs
64
}
73
- * from the ARMv7 Privilege Level).
65
74
- */
66
- /*
75
-static inline int arm_current_el(CPUARMState *env)
67
- * KVM does not support modifications to this feature.
76
-{
68
- * We have not registered the cpu properties when KVM
77
- if (arm_feature(env, ARM_FEATURE_M)) {
69
- * is in use, so the user will not be able to set them.
78
- return arm_v7m_is_handler_mode(env) ||
70
- */
79
- !(env->v7m.control[env->v7m.secure] & 1);
71
- if (!kvm_enabled()) {
80
- }
72
- arm_cpu_pauth_finalize(cpu, &local_err);
81
-
73
- if (local_err != NULL) {
82
- if (is_a64(env)) {
74
- error_propagate(errp, local_err);
83
- return extract32(env->pstate, 2, 2);
75
- return;
84
- }
76
- }
85
-
77
+ arm_cpu_pauth_finalize(cpu, &local_err);
86
- switch (env->uncached_cpsr & 0x1f) {
78
+ if (local_err != NULL) {
87
- case ARM_CPU_MODE_USR:
79
+ error_propagate(errp, local_err);
88
- return 0;
80
+ return;
89
- case ARM_CPU_MODE_HYP:
81
}
90
- return 2;
82
}
91
- case ARM_CPU_MODE_MON:
83
92
- return 3;
84
@@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj)
93
- default:
85
kvm_arm_set_cpu_features_from_host(cpu);
94
- if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) {
86
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
95
- /* If EL3 is 32-bit then all secure privileged modes run in
87
aarch64_add_sve_properties(obj);
96
- * EL3
88
+ aarch64_add_pauth_properties(obj);
97
- */
89
}
98
- return 3;
90
#else
99
- }
91
hvf_arm_set_cpu_features_from_host(cpu);
100
-
92
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
101
- return 1;
93
index XXXXXXX..XXXXXXX 100644
102
- }
94
--- a/target/arm/cpu64.c
103
-}
95
+++ b/target/arm/cpu64.c
104
-
96
@@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
105
/**
97
int arch_val = 0, impdef_val = 0;
106
* write_list_to_cpustate
98
uint64_t t;
107
* @cpu: ARMCPU
99
108
diff --git a/target/arm/internals.h b/target/arm/internals.h
100
+ /* Exit early if PAuth is enabled, and fall through to disable it */
109
index XXXXXXX..XXXXXXX 100644
101
+ if (kvm_enabled() && cpu->prop_pauth) {
110
--- a/target/arm/internals.h
102
+ if (!cpu_isar_feature(aa64_pauth, cpu)) {
111
+++ b/target/arm/internals.h
103
+ error_setg(errp, "'pauth' feature not supported by KVM on this host");
112
@@ -XXX,XX +XXX,XX @@ static inline FloatRoundMode arm_rmode_to_sf(ARMFPRounding rmode)
113
return arm_rmode_to_sf_map[rmode];
114
}
115
116
+/* Return true if the specified exception level is running in AArch64 state. */
117
+static inline bool arm_el_is_aa64(CPUARMState *env, int el)
118
+{
119
+ /*
120
+ * This isn't valid for EL0 (if we're in EL0, is_a64() is what you want,
121
+ * and if we're not in EL0 then the state of EL0 isn't well defined.)
122
+ */
123
+ assert(el >= 1 && el <= 3);
124
+ bool aa64 = arm_feature(env, ARM_FEATURE_AARCH64);
125
+
126
+ /*
127
+ * The highest exception level is always at the maximum supported
128
+ * register width, and then lower levels have a register width controlled
129
+ * by bits in the SCR or HCR registers.
130
+ */
131
+ if (el == 3) {
132
+ return aa64;
133
+ }
134
+
135
+ if (arm_feature(env, ARM_FEATURE_EL3) &&
136
+ ((env->cp15.scr_el3 & SCR_NS) || !(env->cp15.scr_el3 & SCR_EEL2))) {
137
+ aa64 = aa64 && (env->cp15.scr_el3 & SCR_RW);
138
+ }
139
+
140
+ if (el == 2) {
141
+ return aa64;
142
+ }
143
+
144
+ if (arm_is_el2_enabled(env)) {
145
+ aa64 = aa64 && (env->cp15.hcr_el2 & HCR_RW);
146
+ }
147
+
148
+ return aa64;
149
+}
150
+
151
+/*
152
+ * Return the current Exception Level (as per ARMv8; note that this differs
153
+ * from the ARMv7 Privilege Level).
154
+ */
155
+static inline int arm_current_el(CPUARMState *env)
156
+{
157
+ if (arm_feature(env, ARM_FEATURE_M)) {
158
+ return arm_v7m_is_handler_mode(env) ||
159
+ !(env->v7m.control[env->v7m.secure] & 1);
160
+ }
161
+
162
+ if (is_a64(env)) {
163
+ return extract32(env->pstate, 2, 2);
164
+ }
165
+
166
+ switch (env->uncached_cpsr & 0x1f) {
167
+ case ARM_CPU_MODE_USR:
168
+ return 0;
169
+ case ARM_CPU_MODE_HYP:
170
+ return 2;
171
+ case ARM_CPU_MODE_MON:
172
+ return 3;
173
+ default:
174
+ if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) {
175
+ /* If EL3 is 32-bit then all secure privileged modes run in EL3 */
176
+ return 3;
104
+ }
177
+ }
105
+
178
+
106
+ return;
179
+ return 1;
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
+ }
180
+ }
131
+}
181
+}
132
+
182
+
133
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
183
static inline bool arm_cpu_data_is_big_endian_a32(CPUARMState *env,
134
* otherwise, a CPU with as many features enabled as our emulation supports.
184
bool sctlr_b)
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
{
185
{
167
/* Identify the feature bits corresponding to the host CPU, and
186
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
168
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
187
index XXXXXXX..XXXXXXX 100644
169
*/
188
--- a/hw/intc/arm_gicv3_cpuif.c
170
struct kvm_vcpu_init init = { .target = -1, };
189
+++ b/hw/intc/arm_gicv3_cpuif.c
171
190
@@ -XXX,XX +XXX,XX @@
172
+ /*
191
#include "cpu.h"
173
+ * Ask for Pointer Authentication if supported. We can't play the
192
#include "target/arm/cpregs.h"
174
+ * SVE trick of synthesising the ID reg as KVM won't tell us
193
#include "target/arm/cpu-features.h"
175
+ * whether we have the architected or IMPDEF version of PAuth, so
194
+#include "target/arm/internals.h"
176
+ * we have to use the actual ID regs.
195
#include "system/tcg.h"
177
+ */
196
#include "system/qtest.h"
178
+ if (kvm_arm_pauth_supported()) {
197
179
+ init.features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
198
diff --git a/target/arm/arch_dump.c b/target/arm/arch_dump.c
180
+ 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
199
index XXXXXXX..XXXXXXX 100644
181
+ }
200
--- a/target/arm/arch_dump.c
182
+
201
+++ b/target/arm/arch_dump.c
183
if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) {
202
@@ -XXX,XX +XXX,XX @@
184
return false;
203
#include "elf.h"
185
}
204
#include "system/dump.h"
186
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
205
#include "cpu-features.h"
187
assert(kvm_arm_sve_supported());
206
+#include "internals.h"
188
cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE;
207
189
}
208
/* struct user_pt_regs from arch/arm64/include/uapi/asm/ptrace.h */
190
+ if (cpu_isar_feature(aa64_pauth, cpu)) {
209
struct aarch64_user_regs {
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
--
210
--
198
2.25.1
211
2.43.0
199
200
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
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
Deleted patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
1
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
Deleted patch
1
From: Yanan Wang <wangyanan55@huawei.com>
2
1
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
Deleted patch
1
From: Yanan Wang <wangyanan55@huawei.com>
2
1
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
The ITS has several tables which all share a similar format,
1
The definition of SCR_EL3.RW says that its effective value is 1 if:
2
described by the TableDesc struct: the guest may configure them
2
- EL2 is implemented and does not support AArch32, and SCR_EL3.NS is 1
3
to be a single-level table or a two-level table. Currently we
3
- the effective value of SCR_EL3.{EEL2,NS} is {1,0} (i.e. we are
4
open-code the process of finding the table entry in all the
4
Secure and Secure EL2 is disabled)
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
5
11
Note that the error handling is slightly complicated because
6
We implement the second of these in arm_el_is_aa64(), but forgot the
12
we want to handle two cases differently:
7
first.
13
* failure to read the L1 table entry should end up causing
8
14
a command stall, like other kinds of DMA error
9
Provide a new function arm_scr_rw_eff() to return the effective
15
* an L1 table entry that says there is no L2 table for this
10
value of SCR_EL3.RW, and use it in arm_el_is_aa64() and the other
16
index (ie whose valid bit is 0) must result in us treating
11
places that currently look directly at the bit value.
17
the table entry as not-valid on read, and discarding
12
18
writes (this is mandated by the spec)
13
(scr_write() enforces that the RW bit is RAO/WI if neither EL1 nor
14
EL2 have AArch32 support, but if EL1 does but EL2 does not then the
15
bit must still be writeable.)
16
17
This will mean that if code at EL3 attempts to perform an exception
18
return to AArch32 EL2 when EL2 is AArch64-only we will correctly
19
handle this as an illegal exception return: it will be caught by the
20
"return to an EL which is configured for a different register width"
21
check in HELPER(exception_return).
22
23
We do already have some CPU types which don't implement AArch32
24
above EL0, so this is technically a bug; it doesn't seem worth
25
backporting to stable because no sensible guest code will be
26
deliberately attempting to set the RW bit to a value corresponding
27
to an unimplemented execution state and then checking that we
28
did the right thing.
19
29
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
31
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
---
32
---
25
hw/intc/arm_gicv3_its.c | 212 +++++++++++++---------------------------
33
target/arm/internals.h | 26 +++++++++++++++++++++++---
26
1 file changed, 70 insertions(+), 142 deletions(-)
34
target/arm/helper.c | 4 ++--
35
2 files changed, 25 insertions(+), 5 deletions(-)
27
36
28
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
37
diff --git a/target/arm/internals.h b/target/arm/internals.h
29
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/intc/arm_gicv3_its.c
39
--- a/target/arm/internals.h
31
+++ b/hw/intc/arm_gicv3_its.c
40
+++ b/target/arm/internals.h
32
@@ -XXX,XX +XXX,XX @@ static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
41
@@ -XXX,XX +XXX,XX @@ static inline FloatRoundMode arm_rmode_to_sf(ARMFPRounding rmode)
33
return result;
42
return arm_rmode_to_sf_map[rmode];
34
}
43
}
35
44
36
+static uint64_t table_entry_addr(GICv3ITSState *s, TableDesc *td,
45
+/* Return the effective value of SCR_EL3.RW */
37
+ uint32_t idx, MemTxResult *res)
46
+static inline bool arm_scr_rw_eff(CPUARMState *env)
38
+{
47
+{
39
+ /*
48
+ /*
40
+ * Given a TableDesc describing one of the ITS in-guest-memory
49
+ * SCR_EL3.RW has an effective value of 1 if:
41
+ * tables and an index into it, return the guest address
50
+ * - we are NS and EL2 is implemented but doesn't support AArch32
42
+ * corresponding to that table entry.
51
+ * - we are S and EL2 is enabled (in which case it must be AArch64)
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
+ */
52
+ AddressSpace *as = &s->gicv3->dma_as;
53
+ ARMCPU *cpu = env_archcpu(env);
53
+ uint32_t l2idx;
54
+ uint64_t l2;
55
+ uint32_t num_l2_entries;
56
+
54
+
57
+ *res = MEMTX_OK;
55
+ if (env->cp15.scr_el3 & SCR_RW) {
58
+
56
+ return true;
59
+ if (!td->indirect) {
60
+ /* Single level table */
61
+ return td->base_addr + idx * td->entry_sz;
62
+ }
57
+ }
63
+
58
+ if (env->cp15.scr_el3 & SCR_NS) {
64
+ /* Two level table */
59
+ return arm_feature(env, ARM_FEATURE_EL2) &&
65
+ l2idx = idx / (td->page_sz / L1TABLE_ENTRY_SIZE);
60
+ !cpu_isar_feature(aa64_aa32_el2, cpu);
66
+
61
+ } else {
67
+ l2 = address_space_ldq_le(as,
62
+ return env->cp15.scr_el3 & SCR_EEL2;
68
+ td->base_addr + (l2idx * L1TABLE_ENTRY_SIZE),
69
+ MEMTXATTRS_UNSPECIFIED, res);
70
+ if (*res != MEMTX_OK) {
71
+ return -1;
72
+ }
63
+ }
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
+}
64
+}
80
+
65
+
81
static bool get_cte(GICv3ITSState *s, uint16_t icid, uint64_t *cte,
66
/* Return true if the specified exception level is running in AArch64 state. */
82
MemTxResult *res)
67
static inline bool arm_el_is_aa64(CPUARMState *env, int el)
83
{
68
{
84
AddressSpace *as = &s->gicv3->dma_as;
69
@@ -XXX,XX +XXX,XX @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el)
85
- uint64_t l2t_addr;
70
return aa64;
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
}
71
}
121
72
122
+ *cte = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res);
73
- if (arm_feature(env, ARM_FEATURE_EL3) &&
123
return FIELD_EX64(*cte, CTE, VALID);
74
- ((env->cp15.scr_el3 & SCR_NS) || !(env->cp15.scr_el3 & SCR_EEL2))) {
124
}
75
- aa64 = aa64 && (env->cp15.scr_el3 & SCR_RW);
125
76
+ if (arm_feature(env, ARM_FEATURE_EL3)) {
126
@@ -XXX,XX +XXX,XX @@ static bool get_ite(GICv3ITSState *s, uint32_t eventid, uint64_t dte,
77
+ aa64 = aa64 && arm_scr_rw_eff(env);
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
}
78
}
166
-
79
167
- return value;
80
if (el == 2) {
168
+ return address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res);
81
diff --git a/target/arm/helper.c b/target/arm/helper.c
169
}
82
index XXXXXXX..XXXXXXX 100644
170
83
--- a/target/arm/helper.c
171
/*
84
+++ b/target/arm/helper.c
172
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
85
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
173
uint64_t rdbase)
86
uint64_t hcr_el2;
174
{
87
175
AddressSpace *as = &s->gicv3->dma_as;
88
if (arm_feature(env, ARM_FEATURE_EL3)) {
176
- uint64_t value;
89
- rw = ((env->cp15.scr_el3 & SCR_RW) == SCR_RW);
177
- uint64_t l2t_addr;
90
+ rw = arm_scr_rw_eff(env);
178
- bool valid_l2t;
91
} else {
179
- uint32_t l2t_id;
92
/*
180
- uint32_t num_l2_entries;
93
* Either EL2 is the highest EL (and so the EL2 register width
181
+ uint64_t entry_addr;
94
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
182
uint64_t cte = 0;
95
183
MemTxResult res = MEMTX_OK;
96
switch (new_el) {
184
97
case 3:
185
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
98
- is_aa64 = (env->cp15.scr_el3 & SCR_RW) != 0;
186
cte = FIELD_DP64(cte, CTE, RDBASE, rdbase);
99
+ is_aa64 = arm_scr_rw_eff(env);
187
}
100
break;
188
101
case 2:
189
- /*
102
hcr = arm_hcr_el2_eff(env);
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
--
103
--
304
2.25.1
104
2.43.0
305
306
diff view generated by jsdifflib
1
Refactor process_its_cmd() so that it consistently uses
1
When EL1 doesn't support AArch32, the HCR_EL2.RW bit is supposed to
2
the structure
2
be RAO/WI. Enforce the RAO/WI behaviour.
3
do thing;
4
if (error condition) {
5
return early;
6
}
7
do next thing;
8
3
9
rather than doing some of the work nested inside if (not error)
4
Note that we handle "reset value should honour RES1 bits" in the same
10
code blocks.
5
way that SCR_EL3 does, via a reset function.
6
7
We do already have some CPU types which don't implement AArch32
8
above EL0, so this is technically a bug; it doesn't seem worth
9
backporting to stable because no sensible guest code will be
10
deliberately attempting to set the RW bit to a value corresponding
11
to an unimplemented execution state and then checking that we
12
did the right thing.
11
13
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
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
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20220111171048.3545974-8-peter.maydell@linaro.org
16
---
16
---
17
hw/intc/arm_gicv3_its.c | 103 +++++++++++++++++++---------------------
17
target/arm/helper.c | 12 ++++++++++++
18
1 file changed, 50 insertions(+), 53 deletions(-)
18
1 file changed, 12 insertions(+)
19
19
20
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
20
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/intc/arm_gicv3_its.c
22
--- a/target/arm/helper.c
23
+++ b/hw/intc/arm_gicv3_its.c
23
+++ b/target/arm/helper.c
24
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
24
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
25
}
25
/* Clear RES0 bits. */
26
dte_valid = FIELD_EX64(dte, DTE, VALID);
26
value &= valid_mask;
27
27
28
- if (dte_valid) {
28
+ /* RW is RAO/WI if EL1 is AArch64 only */
29
- num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
29
+ if (!cpu_isar_feature(aa64_aa32_el1, cpu)) {
30
-
30
+ value |= HCR_RW;
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
+ }
31
+ }
61
+
32
+
62
+ if (!ite_valid) {
33
/*
63
+ qemu_log_mask(LOG_GUEST_ERROR,
34
* These bits change the MMU setup:
64
+ "%s: invalid command attributes: invalid ITE\n",
35
* HCR_VM enables stage 2 translation
65
+ __func__);
36
@@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri,
66
+ return CMD_CONTINUE;
37
do_hcr_write(env, value, MAKE_64BIT_MASK(32, 32));
67
+ }
38
}
39
40
+static void hcr_reset(CPUARMState *env, const ARMCPRegInfo *ri)
41
+{
42
+ /* hcr_write will set the RES1 bits on an AArch64-only CPU */
43
+ hcr_write(env, ri, 0);
44
+}
68
+
45
+
69
+ cte_valid = get_cte(s, icid, &cte, &res);
46
/*
70
+ if (res != MEMTX_OK) {
47
* Return the effective value of HCR_EL2, at the given security state.
71
+ return CMD_STALL;
48
* Bits that are not included here:
72
+ }
49
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
73
+ if (!cte_valid) {
50
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
74
+ qemu_log_mask(LOG_GUEST_ERROR,
51
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
75
+ "%s: invalid command attributes: "
52
.nv2_redirect_offset = 0x78,
76
+ "invalid cte: %"PRIx64"\n",
53
+ .resetfn = hcr_reset,
77
+ __func__, cte);
54
.writefn = hcr_write, .raw_writefn = raw_write },
78
+ return CMD_CONTINUE;
55
{ .name = "HCR", .state = ARM_CP_STATE_AA32,
79
+ }
56
.type = ARM_CP_ALIAS | ARM_CP_IO,
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
--
57
--
155
2.25.1
58
2.43.0
156
157
diff view generated by jsdifflib
1
Fix process_its_cmd() to consistently return CMD_STALL for
1
We already call env_archcpu() multiple times within the
2
memory errors and CMD_CONTINUE for parameter errors, as
2
exception_return helper function, and we're about to want to
3
we claim in the comments that we do.
3
add another use of the ARMCPU pointer. Add a local variable
4
cpu so we can call env_archcpu() just once.
4
5
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
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>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-7-peter.maydell@linaro.org
9
---
8
---
10
hw/intc/arm_gicv3_its.c | 22 +++++++++++-----------
9
target/arm/tcg/helper-a64.c | 7 ++++---
11
1 file changed, 11 insertions(+), 11 deletions(-)
10
1 file changed, 4 insertions(+), 3 deletions(-)
12
11
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
12
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
14
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
14
--- a/target/arm/tcg/helper-a64.c
16
+++ b/hw/intc/arm_gicv3_its.c
15
+++ b/target/arm/tcg/helper-a64.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
16
@@ -XXX,XX +XXX,XX @@ static void cpsr_write_from_spsr_elx(CPUARMState *env,
18
bool ite_valid = false;
17
19
uint64_t cte = 0;
18
void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
20
bool cte_valid = false;
19
{
21
- ItsCmdResult result = CMD_STALL;
20
+ ARMCPU *cpu = env_archcpu(env);
22
uint64_t rdbase;
21
int cur_el = arm_current_el(env);
23
22
unsigned int spsr_idx = aarch64_banked_spsr_index(cur_el);
24
if (cmd == NONE) {
23
uint32_t spsr = env->banked_spsr[spsr_idx];
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
24
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
26
}
25
}
27
26
28
if (res != MEMTX_OK) {
27
bql_lock();
29
- return result;
28
- arm_call_pre_el_change_hook(env_archcpu(env));
30
+ return CMD_STALL;
29
+ arm_call_pre_el_change_hook(cpu);
31
}
30
bql_unlock();
32
31
33
eventid = (value & EVENTID_MASK);
32
if (!return_to_aa64) {
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
33
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
35
dte = get_dte(s, devid, &res);
34
int tbii;
36
35
37
if (res != MEMTX_OK) {
36
env->aarch64 = true;
38
- return result;
37
- spsr &= aarch64_pstate_valid_mask(&env_archcpu(env)->isar);
39
+ return CMD_STALL;
38
+ spsr &= aarch64_pstate_valid_mask(&cpu->isar);
40
}
39
pstate_write(env, spsr);
41
dte_valid = FIELD_EX64(dte, DTE, VALID);
40
if (!arm_singlestep_active(env)) {
42
41
env->pstate &= ~PSTATE_SS;
43
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
42
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
44
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
43
aarch64_sve_change_el(env, cur_el, new_el, return_to_aa64);
45
44
46
if (res != MEMTX_OK) {
45
bql_lock();
47
- return result;
46
- arm_call_el_change_hook(env_archcpu(env));
48
+ return CMD_STALL;
47
+ arm_call_el_change_hook(cpu);
49
}
48
bql_unlock();
50
49
51
if (ite_valid) {
50
return;
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
--
51
--
116
2.25.1
52
2.43.0
117
118
diff view generated by jsdifflib
1
In process_its_cmd(), we read an ICID out of the interrupt table
1
In the Arm ARM, rule R_TYTWB states that returning to AArch32
2
entry, and then use it as an index into the collection table. Add a
2
is an illegal exception return if:
3
check that it is within range for the collection table first.
3
* AArch32 is not supported at any exception level
4
* the target EL is configured for AArch64 via SCR_EL3.RW
5
or HCR_EL2.RW or via CPU state at reset
4
6
5
This check is not strictly necessary, because:
7
We check the second of these, but not the first (which can only be
6
* we range check the ICID from the guest before writing it into
8
relevant for the case of a return to EL0, because if AArch32 is not
7
the interrupt table entry, so the the only way to get an
9
supported at one of the higher ELs then the RW bits will have an
8
out of range ICID in process_its_cmd() is if a badly-behaved
10
effective value of 1 and the the "configured for AArch64" condition
9
guest is writing directly to the interrupt table memory
11
will hold also).
10
* the collection table is in guest memory, so QEMU won't fall
11
over if we read off the end of it
12
12
13
However, it seems clearer to include the check.
13
Add the missing condition. Although this is technically a bug
14
(because we have one AArch64-only CPU: a64fx) it isn't worth
15
backporting to stable because no sensible guest code will
16
deliberately try to return to a nonexistent execution state
17
to check that it gets an illegal exception return.
14
18
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20220111171048.3545974-14-peter.maydell@linaro.org
18
---
21
---
19
hw/intc/arm_gicv3_its.c | 7 +++++++
22
target/arm/tcg/helper-a64.c | 5 +++++
20
1 file changed, 7 insertions(+)
23
1 file changed, 5 insertions(+)
21
24
22
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
25
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
23
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
24
--- a/hw/intc/arm_gicv3_its.c
27
--- a/target/arm/tcg/helper-a64.c
25
+++ b/hw/intc/arm_gicv3_its.c
28
+++ b/target/arm/tcg/helper-a64.c
26
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
29
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
27
return CMD_CONTINUE;
30
goto illegal_return;
28
}
31
}
29
32
30
+ if (icid >= s->ct.num_ids) {
33
+ if (!return_to_aa64 && !cpu_isar_feature(aa64_aa32, cpu)) {
31
+ qemu_log_mask(LOG_GUEST_ERROR,
34
+ /* Return to AArch32 when CPU is AArch64-only */
32
+ "%s: invalid ICID 0x%x in ITE (table corrupted?)\n",
35
+ goto illegal_return;
33
+ __func__, icid);
34
+ return CMD_CONTINUE;
35
+ }
36
+ }
36
+
37
+
37
cte_valid = get_cte(s, icid, &cte, &res);
38
if (new_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) {
38
if (res != MEMTX_OK) {
39
goto illegal_return;
39
return CMD_STALL;
40
}
40
--
41
--
41
2.25.1
42
2.43.0
42
43
diff view generated by jsdifflib
1
When an ITS detects an error in a command, it has an
1
I'm down as the only listed maintainer for quite a lot of Arm SoC and
2
implementation-defined (CONSTRAINED UNPREDICTABLE) choice of whether
2
board types. In some cases this is only as the "maintainer of last
3
to ignore the command, proceeding to the next one in the queue, or to
3
resort" and I'm not in practice doing anything beyond patch review
4
stall the ITS command queue, processing nothing further. The
4
and the odd bit of tidyup.
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
5
9
The intention of the QEMU implementation, as documented in the
6
Move these entries in MAINTAINERS from "Maintained" to "Odd Fixes",
10
comments, is that if we encounter a memory error reading the command
7
to better represent reality. Entries for other boards and SoCs where
11
packet or one of the various data tables then we should stall, but
8
I do more actively care (or where there is a listed co-maintainer)
12
for command parameter errors we should ignore the queue and continue.
9
remain as they are.
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
10
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20250307152838.3226398-1-peter.maydell@linaro.org
27
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
28
Message-id: 20220111171048.3545974-6-peter.maydell@linaro.org
29
---
14
---
30
hw/intc/arm_gicv3_its.c | 59 ++++++++++++++++++++++++++---------------
15
MAINTAINERS | 14 +++++++-------
31
1 file changed, 38 insertions(+), 21 deletions(-)
16
1 file changed, 7 insertions(+), 7 deletions(-)
32
17
33
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
18
diff --git a/MAINTAINERS b/MAINTAINERS
34
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/intc/arm_gicv3_its.c
20
--- a/MAINTAINERS
36
+++ b/hw/intc/arm_gicv3_its.c
21
+++ b/MAINTAINERS
37
@@ -XXX,XX +XXX,XX @@ typedef struct {
22
@@ -XXX,XX +XXX,XX @@ F: docs/system/arm/kzm.rst
38
uint64_t itel;
23
Integrator CP
39
} IteEntry;
24
M: Peter Maydell <peter.maydell@linaro.org>
40
25
L: qemu-arm@nongnu.org
41
+/*
26
-S: Maintained
42
+ * The ITS spec permits a range of CONSTRAINED UNPREDICTABLE options
27
+S: Odd Fixes
43
+ * if a command parameter is not correct. These include both "stall
28
F: hw/arm/integratorcp.c
44
+ * processing of the command queue" and "ignore this command, and
29
F: hw/misc/arm_integrator_debug.c
45
+ * keep processing the queue". In our implementation we choose that
30
F: include/hw/misc/arm_integrator_debug.h
46
+ * memory transaction errors reading the command packet provoke a
31
@@ -XXX,XX +XXX,XX @@ F: docs/system/arm/mps2.rst
47
+ * stall, but errors in parameters cause us to ignore the command
32
Musca
48
+ * and continue processing.
33
M: Peter Maydell <peter.maydell@linaro.org>
49
+ * The process_* functions which handle individual ITS commands all
34
L: qemu-arm@nongnu.org
50
+ * return an ItsCmdResult which tells process_cmdq() whether it should
35
-S: Maintained
51
+ * stall or keep going.
36
+S: Odd Fixes
52
+ */
37
F: hw/arm/musca.c
53
+typedef enum ItsCmdResult {
38
F: docs/system/arm/musca.rst
54
+ CMD_STALL = 0,
39
55
+ CMD_CONTINUE = 1,
40
@@ -XXX,XX +XXX,XX @@ F: tests/functional/test_aarch64_raspi4.py
56
+} ItsCmdResult;
41
Real View
57
+
42
M: Peter Maydell <peter.maydell@linaro.org>
58
static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
43
L: qemu-arm@nongnu.org
59
{
44
-S: Maintained
60
uint64_t result = 0;
45
+S: Odd Fixes
61
@@ -XXX,XX +XXX,XX @@ static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res)
46
F: hw/arm/realview*
62
* 3. handling of ITS CLEAR command
47
F: hw/cpu/realview_mpcore.c
63
* 4. handling of ITS DISCARD command
48
F: hw/intc/realview_gic.c
64
*/
49
@@ -XXX,XX +XXX,XX @@ F: tests/functional/test_arm_collie.py
65
-static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
50
Stellaris
66
- ItsCmdType cmd)
51
M: Peter Maydell <peter.maydell@linaro.org>
67
+static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
52
L: qemu-arm@nongnu.org
68
+ uint32_t offset, ItsCmdType cmd)
53
-S: Maintained
69
{
54
+S: Odd Fixes
70
AddressSpace *as = &s->gicv3->dma_as;
55
F: hw/*/stellaris*
71
uint32_t devid, eventid;
56
F: hw/display/ssd03*
72
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
57
F: include/hw/input/gamepad.h
73
bool ite_valid = false;
58
@@ -XXX,XX +XXX,XX @@ F: docs/system/arm/stm32.rst
74
uint64_t cte = 0;
59
Versatile Express
75
bool cte_valid = false;
60
M: Peter Maydell <peter.maydell@linaro.org>
76
- bool result = false;
61
L: qemu-arm@nongnu.org
77
+ ItsCmdResult result = CMD_STALL;
62
-S: Maintained
78
uint64_t rdbase;
63
+S: Odd Fixes
79
64
F: hw/arm/vexpress.c
80
if (cmd == NONE) {
65
F: hw/display/sii9022.c
81
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
66
F: docs/system/arm/vexpress.rst
82
if (cmd == DISCARD) {
67
@@ -XXX,XX +XXX,XX @@ F: tests/functional/test_arm_vexpress.py
83
IteEntry ite = {};
68
Versatile PB
84
/* remove mapping from interrupt translation table */
69
M: Peter Maydell <peter.maydell@linaro.org>
85
- result = update_ite(s, eventid, dte, ite);
70
L: qemu-arm@nongnu.org
86
+ result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
71
-S: Maintained
87
}
72
+S: Odd Fixes
88
}
73
F: hw/*/versatile*
89
74
F: hw/i2c/arm_sbcon_i2c.c
90
return result;
75
F: include/hw/i2c/arm_sbcon_i2c.h
91
}
76
@@ -XXX,XX +XXX,XX @@ F: include/hw/hyperv/vmbus*.h
92
77
OMAP
93
-static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
78
M: Peter Maydell <peter.maydell@linaro.org>
94
- bool ignore_pInt)
79
L: qemu-arm@nongnu.org
95
+static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
80
-S: Maintained
96
+ uint32_t offset, bool ignore_pInt)
81
+S: Odd Fixes
97
{
82
F: hw/*/omap*
98
AddressSpace *as = &s->gicv3->dma_as;
83
F: include/hw/arm/omap.h
99
uint32_t devid, eventid;
84
F: docs/system/arm/sx1.rst
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
--
85
--
213
2.25.1
86
2.43.0
214
87
215
88
diff view generated by jsdifflib
1
From: Yanan Wang <wangyanan55@huawei.com>
1
From: Paolo Bonzini <pbonzini@redhat.com>
2
2
3
Use g_queue APIs to reduce the nested loops and code indentation
3
The guest does not control whether characters are sent on the UART.
4
with the processor hierarchy levels increasing. Consenquently,
4
Sending them before the guest happens to boot will now result in a
5
it's more scalable to add new topology level to build_pptt.
5
"guest error" log entry that is only because of timing, even if the
6
guest _would_ later setup the receiver correctly.
6
7
7
No functional change intended.
8
This reverts the bulk of commit abf2b6a028670bd2890bb3aee7e103fe53e4b0df,
9
and instead adds a comment about why we don't check the enable bits.
8
10
9
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
11
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Andrew Jones <drjones@redhat.com>
12
Cc: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20220107083232.16256-4-wangyanan55@huawei.com
13
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
14
Message-id: 20250311153717.206129-1-pbonzini@redhat.com
15
[PMM: expanded comment]
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
18
---
14
hw/acpi/aml-build.c | 50 +++++++++++++++++++++++++++++----------------
19
hw/char/pl011.c | 19 ++++++++++---------
15
1 file changed, 32 insertions(+), 18 deletions(-)
20
1 file changed, 10 insertions(+), 9 deletions(-)
16
21
17
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
22
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
18
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/acpi/aml-build.c
24
--- a/hw/char/pl011.c
20
+++ b/hw/acpi/aml-build.c
25
+++ b/hw/char/pl011.c
21
@@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
26
@@ -XXX,XX +XXX,XX @@ static int pl011_can_receive(void *opaque)
22
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
27
unsigned fifo_depth = pl011_get_fifo_depth(s);
23
const char *oem_id, const char *oem_table_id)
28
unsigned fifo_available = fifo_depth - s->read_count;
24
{
29
25
- int pptt_start = table_data->len;
30
- if (!(s->cr & CR_UARTEN)) {
26
+ GQueue *list = g_queue_new();
31
- qemu_log_mask(LOG_GUEST_ERROR,
27
+ guint pptt_start = table_data->len;
32
- "PL011 receiving data on disabled UART\n");
28
+ guint parent_offset;
33
- }
29
+ guint length, i;
34
- if (!(s->cr & CR_RXE)) {
30
int uid = 0;
35
- qemu_log_mask(LOG_GUEST_ERROR,
31
int socket;
36
- "PL011 receiving data on disabled RX UART\n");
32
AcpiTable table = { .sig = "PPTT", .rev = 2,
37
- }
33
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
38
- trace_pl011_can_receive(s->lcr, s->read_count, fifo_depth, fifo_available);
34
acpi_table_begin(&table, table_data);
39
+ /*
35
40
+ * In theory we should check the UART and RX enable bits here and
36
for (socket = 0; socket < ms->smp.sockets; socket++) {
41
+ * return 0 if they are not set (so the guest can't receive data
37
- uint32_t socket_offset = table_data->len - pptt_start;
42
+ * until you have enabled the UART). In practice we suspect there
38
- int core;
43
+ * is at least some guest code out there which has been tested only
39
-
44
+ * on QEMU and which never bothers to enable the UART because we
40
+ g_queue_push_tail(list,
45
+ * historically never enforced that. So we effectively keep the
41
+ GUINT_TO_POINTER(table_data->len - pptt_start));
46
+ * UART continuously enabled regardless of the enable bits.
42
build_processor_hierarchy_node(
47
+ */
43
table_data,
48
44
/*
49
+ trace_pl011_can_receive(s->lcr, s->read_count, fifo_depth, fifo_available);
45
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
50
return fifo_available;
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);
105
}
51
}
106
52
107
--
53
--
108
2.25.1
54
2.43.0
109
55
110
56
diff view generated by jsdifflib
Deleted patch
1
From: Yanan Wang <wangyanan55@huawei.com>
2
1
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
Deleted patch
1
From: Yanan Wang <wangyanan55@huawei.com>
2
1
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
Deleted patch
1
From: Yanan Wang <wangyanan55@huawei.com>
2
1
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
Deleted patch
1
From: Lucas Ramage <lucas.ramage@infinite-omicron.com>
2
1
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
Deleted patch
1
From: Gavin Shan <gshan@redhat.com>
2
1
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
Deleted patch
1
From: Petr Pavlu <petr.pavlu@suse.com>
2
1
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
Deleted patch
1
From: Petr Pavlu <petr.pavlu@suse.com>
2
1
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
Deleted patch
1
From: Marc Zyngier <maz@kernel.org>
2
1
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
Deleted patch
1
From: Marc Zyngier <maz@kernel.org>
2
1
3
Just like we can control the enablement of the highmem PCIe region
4
using highmem_ecam, let's add a control for the highmem GICv3
5
redistributor region.
6
7
Similarily to highmem_ecam, these redistributors are disabled when
8
highmem is off.
9
10
Reviewed-by: Andrew Jones <drjones@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
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
include/hw/arm/virt.h | 4 +++-
17
hw/arm/virt-acpi-build.c | 2 ++
18
hw/arm/virt.c | 2 ++
19
3 files changed, 7 insertions(+), 1 deletion(-)
20
21
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/virt.h
24
+++ b/include/hw/arm/virt.h
25
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
26
bool highmem;
27
bool highmem_ecam;
28
bool highmem_mmio;
29
+ bool highmem_redists;
30
bool its;
31
bool tcg_its;
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
56
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/arm/virt.c
59
+++ b/hw/arm/virt.c
60
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
61
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
62
63
vms->highmem_mmio &= vms->highmem;
64
+ vms->highmem_redists &= vms->highmem;
65
66
create_gic(vms, sysmem);
67
68
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
69
70
vms->highmem_ecam = !vmc->no_highmem_ecam;
71
vms->highmem_mmio = true;
72
+ vms->highmem_redists = true;
73
74
if (vmc->no_its) {
75
vms->its = false;
76
--
77
2.25.1
78
79
diff view generated by jsdifflib
Deleted patch
1
From: Marc Zyngier <maz@kernel.org>
2
1
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
1
From: Marc Zyngier <maz@kernel.org>
1
From: Joe Komlodi <komlodi@google.com>
2
2
3
The highmem attribute is nothing but another way to express the
3
On ARM hosts with CTR_EL0.DIC and CTR_EL0.IDC set, this would only cause
4
PA range of a VM. To support HW that has a smaller PA range then
4
an ISB to be executed during cache maintenance, which could lead to QEMU
5
what QEMU assumes, pass this PA range to the virt_set_memmap()
5
executing TBs containing garbage instructions.
6
function, allowing it to correctly exclude highmem devices
7
if they are outside of the PA range.
8
6
9
Signed-off-by: Marc Zyngier <maz@kernel.org>
7
This seems to be because the ISB finishes executing instructions and
10
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
flushes the pipeline, but the ISB doesn't guarantee that writes from the
11
Message-id: 20220114140741.1358263-5-maz@kernel.org
9
executed instructions are committed. If a small enough TB is created, it's
10
possible that the writes setting up the TB aren't committed by the time the
11
TB is executed.
12
13
This function is intended to be a port of the gcc implementation
14
(https://github.com/gcc-mirror/gcc/blob/85b46d0795ac76bc192cb8f88b646a647acf98c1/libgcc/config/aarch64/sync-cache.c#L67)
15
which makes the first DSB unconditional, so we can fix the synchronization
16
issue by doing that as well.
17
18
Cc: qemu-stable@nongnu.org
19
Fixes: 664a79735e4deb1 ("util: Specialize flush_idcache_range for aarch64")
20
Signed-off-by: Joe Komlodi <komlodi@google.com>
21
Message-id: 20250310203622.1827940-2-komlodi@google.com
22
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
23
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
25
---
14
hw/arm/virt.c | 64 +++++++++++++++++++++++++++++++++++++++++----------
26
util/cacheflush.c | 4 +++-
15
1 file changed, 52 insertions(+), 12 deletions(-)
27
1 file changed, 3 insertions(+), 1 deletion(-)
16
28
17
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
29
diff --git a/util/cacheflush.c b/util/cacheflush.c
18
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/virt.c
31
--- a/util/cacheflush.c
20
+++ b/hw/arm/virt.c
32
+++ b/util/cacheflush.c
21
@@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
33
@@ -XXX,XX +XXX,XX @@ void flush_idcache_range(uintptr_t rx, uintptr_t rw, size_t len)
22
return arm_cpu_mp_affinity(idx, clustersz);
34
for (p = rw & -dcache_lsize; p < rw + len; p += dcache_lsize) {
23
}
35
asm volatile("dc\tcvau, %0" : : "r" (p) : "memory");
24
36
}
25
-static void virt_set_memmap(VirtMachineState *vms)
37
- asm volatile("dsb\tish" : : : "memory");
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
}
38
}
33
39
34
+ /*
40
+ /* DSB unconditionally to ensure any outstanding writes are committed. */
35
+ * !highmem is exactly the same as limiting the PA space to 32bit,
41
+ asm volatile("dsb\tish" : : : "memory");
36
+ * irrespective of the underlying capabilities of the HW.
37
+ */
38
+ if (!vms->highmem) {
39
+ pa_bits = 32;
40
+ }
41
+
42
+
42
/*
43
/*
43
* We compute the base of the high IO region depending on the
44
* If CTR_EL0.DIC is enabled, Instruction cache cleaning to the Point
44
* amount of initial and device memory. The device memory start/size
45
* of Unification is not required for instruction to data coherence.
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
--
46
--
147
2.25.1
47
2.43.0
148
149
diff view generated by jsdifflib
Deleted patch
1
From: Marc Zyngier <maz@kernel.org>
2
1
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
Deleted patch
1
From: Marc Zyngier <maz@kernel.org>
2
1
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
Deleted patch
1
From: Patrick Venture <venture@google.com>
2
1
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
Deleted patch
1
From: Troy Lee <troy_lee@aspeedtech.com>
2
1
3
Aspeed 2600 SDK enables I3C support by default. The I3C driver will try
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.
7
8
This avoids a guest machine kernel panic due to referencing an
9
invalid kernel address if the device address table register isn't
10
set correctly.
11
12
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
13
Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Tested-by: Graeme Gregory <quic_ggregory@quicinc.com>
16
Message-id: 20220111084546.4145785-2-troy_lee@aspeedtech.com
17
[PMM: tidied commit message]
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
20
include/hw/misc/aspeed_i3c.h | 48 +++++
21
hw/misc/aspeed_i3c.c | 381 +++++++++++++++++++++++++++++++++++
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
27
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
470
index XXXXXXX..XXXXXXX 100644
471
--- a/hw/misc/meson.build
472
+++ b/hw/misc/meson.build
473
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
474
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
475
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
476
'aspeed_hace.c',
477
+ 'aspeed_i3c.c',
478
'aspeed_lpc.c',
479
'aspeed_scu.c',
480
'aspeed_sdmc.c',
481
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
482
index XXXXXXX..XXXXXXX 100644
483
--- a/hw/misc/trace-events
484
+++ b/hw/misc/trace-events
485
@@ -XXX,XX +XXX,XX @@ armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU wri
486
# aspeed_xdma.c
487
aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64
488
489
+# aspeed_i3c.c
490
+aspeed_i3c_read(uint64_t offset, uint64_t data) "I3C read: offset 0x%" PRIx64 " data 0x%" PRIx64
491
+aspeed_i3c_write(uint64_t offset, uint64_t data) "I3C write: offset 0x%" PRIx64 " data 0x%" PRIx64
492
+aspeed_i3c_device_read(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] read: offset 0x%" PRIx64 " data 0x%" PRIx64
493
+aspeed_i3c_device_write(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] write: offset 0x%" PRIx64 " data 0x%" PRIx64
494
+
495
# bcm2835_property.c
496
bcm2835_mbox_property(uint32_t tag, uint32_t bufsize, size_t resplen) "mbox property tag:0x%08x in_sz:%u out_sz:%zu"
497
498
--
499
2.25.1
500
501
diff view generated by jsdifflib
1
From: Troy Lee <troy_lee@aspeedtech.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Add the new i3c device to the AST2600 SoC.
3
The check for fp_excp_el in assert_fp_access_checked is
4
incorrect. For SME, with StreamingMode enabled, the access
5
is really against the streaming mode vectors, and access
6
to the normal fp registers is allowed to be disabled.
7
C.f. sme_enabled_check.
4
8
5
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
9
Convert sve_access_checked to match, even though we don't
6
Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com>
10
currently check the exception state.
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
11
8
Tested-by: Graeme Gregory <quic_ggregory@quicinc.com>
12
Cc: qemu-stable@nongnu.org
9
Message-id: 20220111084546.4145785-3-troy_lee@aspeedtech.com
13
Fixes: 3d74825f4d6 ("target/arm: Add SME enablement checks")
10
[PMM: tidied commit message]
14
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20250307190415.982049-2-richard.henderson@linaro.org
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
18
---
13
include/hw/arm/aspeed_soc.h | 3 +++
19
target/arm/tcg/translate-a64.h | 2 +-
14
hw/arm/aspeed_ast2600.c | 16 ++++++++++++++++
20
target/arm/tcg/translate.h | 10 +++++++---
15
2 files changed, 19 insertions(+)
21
target/arm/tcg/translate-a64.c | 17 +++++++++--------
22
3 files changed, 17 insertions(+), 12 deletions(-)
16
23
17
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
24
diff --git a/target/arm/tcg/translate-a64.h b/target/arm/tcg/translate-a64.h
18
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/aspeed_soc.h
26
--- a/target/arm/tcg/translate-a64.h
20
+++ b/include/hw/arm/aspeed_soc.h
27
+++ b/target/arm/tcg/translate-a64.h
21
@@ -XXX,XX +XXX,XX @@
28
@@ -XXX,XX +XXX,XX @@ TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write,
22
#include "hw/timer/aspeed_timer.h"
29
static inline void assert_fp_access_checked(DisasContext *s)
23
#include "hw/rtc/aspeed_rtc.h"
30
{
24
#include "hw/i2c/aspeed_i2c.h"
31
#ifdef CONFIG_DEBUG_TCG
25
+#include "hw/misc/aspeed_i3c.h"
32
- if (unlikely(!s->fp_access_checked || s->fp_excp_el)) {
26
#include "hw/ssi/aspeed_smc.h"
33
+ if (unlikely(s->fp_access_checked <= 0)) {
27
#include "hw/misc/aspeed_hace.h"
34
fprintf(stderr, "target-arm: FP access check missing for "
28
#include "hw/watchdog/wdt_aspeed.h"
35
"instruction 0x%08x\n", s->insn);
29
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
36
abort();
30
AspeedRtcState rtc;
37
diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h
31
AspeedTimerCtrlState timerctrl;
32
AspeedI2CState i2c;
33
+ AspeedI3CState i3c;
34
AspeedSCUState scu;
35
AspeedHACEState hace;
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
38
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/arm/aspeed_ast2600.c
39
--- a/target/arm/tcg/translate.h
48
+++ b/hw/arm/aspeed_ast2600.c
40
+++ b/target/arm/tcg/translate.h
49
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
41
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
50
[ASPEED_DEV_UART1] = 0x1E783000,
42
bool aarch64;
51
[ASPEED_DEV_UART5] = 0x1E784000,
43
bool thumb;
52
[ASPEED_DEV_VUART] = 0x1E787000,
44
bool lse2;
53
+ [ASPEED_DEV_I3C] = 0x1E7A0000,
45
- /* Because unallocated encodings generate different exception syndrome
54
[ASPEED_DEV_SDRAM] = 0x80000000,
46
+ /*
55
};
47
+ * Because unallocated encodings generate different exception syndrome
56
48
* information from traps due to FP being disabled, we can't do a single
57
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
49
* "is fp access disabled" check at a high level in the decode tree.
58
[ASPEED_DEV_ETH4] = 33,
50
* To help in catching bugs where the access check was forgotten in some
59
[ASPEED_DEV_KCS] = 138, /* 138 -> 142 */
51
* code path, we set this flag when the access check is done, and assert
60
[ASPEED_DEV_DP] = 62,
52
* that it is set at the point where we actually touch the FP regs.
61
+ [ASPEED_DEV_I3C] = 102, /* 102 -> 107 */
53
+ * 0: not checked,
62
};
54
+ * 1: checked, access ok
63
55
+ * -1: checked, access denied
64
static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)
56
*/
65
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
57
- bool fp_access_checked;
66
58
- bool sve_access_checked;
67
snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname);
59
+ int8_t fp_access_checked;
68
object_initialize_child(obj, "hace", &s->hace, typename);
60
+ int8_t sve_access_checked;
69
+
61
/* ARMv8 single-step state (this is distinct from the QEMU gdbstub
70
+ object_initialize_child(obj, "i3c", &s->i3c, TYPE_ASPEED_I3C);
62
* single-step support).
63
*/
64
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/arm/tcg/translate-a64.c
67
+++ b/target/arm/tcg/translate-a64.c
68
@@ -XXX,XX +XXX,XX @@ static bool fp_access_check_only(DisasContext *s)
69
{
70
if (s->fp_excp_el) {
71
assert(!s->fp_access_checked);
72
- s->fp_access_checked = true;
73
+ s->fp_access_checked = -1;
74
75
gen_exception_insn_el(s, 0, EXCP_UDEF,
76
syn_fp_access_trap(1, 0xe, false, 0),
77
s->fp_excp_el);
78
return false;
79
}
80
- s->fp_access_checked = true;
81
+ s->fp_access_checked = 1;
82
return true;
71
}
83
}
72
84
73
/*
85
@@ -XXX,XX +XXX,XX @@ bool sve_access_check(DisasContext *s)
74
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
86
syn_sve_access_trap(), s->sve_excp_el);
75
sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]);
87
goto fail_exit;
76
sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
88
}
77
aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
89
- s->sve_access_checked = true;
78
+
90
+ s->sve_access_checked = 1;
79
+ /* I3C */
91
return fp_access_check(s);
80
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i3c), errp)) {
92
81
+ return;
93
fail_exit:
82
+ }
94
/* Assert that we only raise one exception per instruction. */
83
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]);
95
assert(!s->sve_access_checked);
84
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) {
96
- s->sve_access_checked = true;
85
+ qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
97
+ s->sve_access_checked = -1;
86
+ sc->irqmap[ASPEED_DEV_I3C] + i);
98
return false;
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
}
99
}
91
100
92
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
101
@@ -XXX,XX +XXX,XX @@ bool sme_enabled_check(DisasContext *s)
102
* sme_excp_el by itself for cpregs access checks.
103
*/
104
if (!s->fp_excp_el || s->sme_excp_el < s->fp_excp_el) {
105
- s->fp_access_checked = true;
106
- return sme_access_check(s);
107
+ bool ret = sme_access_check(s);
108
+ s->fp_access_checked = (ret ? 1 : -1);
109
+ return ret;
110
}
111
return fp_access_check_only(s);
112
}
113
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
114
s->insn = insn;
115
s->base.pc_next = pc + 4;
116
117
- s->fp_access_checked = false;
118
- s->sve_access_checked = false;
119
+ s->fp_access_checked = 0;
120
+ s->sve_access_checked = 0;
121
122
if (s->pstate_il) {
123
/*
93
--
124
--
94
2.25.1
125
2.43.0
95
96
diff view generated by jsdifflib
Deleted 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
10
1
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
Deleted patch
1
The bounds check on the number of interrupt IDs is correct, but
2
doesn't match our convention; change the variable name, initialize it
3
to the 2^n value rather than (2^n)-1, and use >= instead of > in the
4
comparison.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Message-id: 20220111171048.3545974-3-peter.maydell@linaro.org
9
---
10
hw/intc/arm_gicv3_its.c | 6 +++---
11
1 file changed, 3 insertions(+), 3 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 bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
18
uint32_t devid, eventid;
19
uint32_t pIntid = 0;
20
uint64_t num_eventids;
21
- uint32_t max_Intid;
22
+ uint32_t num_intids;
23
bool dte_valid;
24
MemTxResult res = MEMTX_OK;
25
uint16_t icid = 0;
26
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
27
}
28
dte_valid = FIELD_EX64(dte, DTE, VALID);
29
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
30
- max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1;
31
+ num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);
32
33
if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
34
|| !dte_valid || (eventid >= num_eventids) ||
35
- (((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) &&
36
+ (((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) &&
37
(pIntid != INTID_SPURIOUS))) {
38
qemu_log_mask(LOG_GUEST_ERROR,
39
"%s: invalid command attributes "
40
--
41
2.25.1
42
43
diff view generated by jsdifflib
Deleted 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.
5
1
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
1
Fix process_mapd() to consistently return CMD_STALL for memory
1
From: Richard Henderson <richard.henderson@linaro.org>
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
comments that we do.
4
2
3
In StreamingMode, fp_access_checked is handled already.
4
We cannot fall through to fp_access_check lest we fall
5
foul of the double-check assertion.
6
7
Cc: qemu-stable@nongnu.org
8
Fixes: 285b1d5fcef ("target/arm: Handle SME in sve_access_check")
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20250307190415.982049-3-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
[PMM: move declaration of 'ret' to top of block]
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
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-11-peter.maydell@linaro.org
9
---
14
---
10
hw/intc/arm_gicv3_its.c | 10 ++++------
15
target/arm/tcg/translate-a64.c | 22 +++++++++++-----------
11
1 file changed, 4 insertions(+), 6 deletions(-)
16
1 file changed, 11 insertions(+), 11 deletions(-)
12
17
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
18
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
14
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
20
--- a/target/arm/tcg/translate-a64.c
16
+++ b/hw/intc/arm_gicv3_its.c
21
+++ b/target/arm/tcg/translate-a64.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
22
@@ -XXX,XX +XXX,XX @@ static int fp_access_check_vector_hsd(DisasContext *s, bool is_q, MemOp esz)
18
uint64_t itt_addr;
23
bool sve_access_check(DisasContext *s)
19
bool valid;
24
{
20
MemTxResult res = MEMTX_OK;
25
if (s->pstate_sm || !dc_isar_feature(aa64_sve, s)) {
21
- ItsCmdResult result = CMD_STALL;
26
+ bool ret;
22
27
+
23
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
28
assert(dc_isar_feature(aa64_sme, s));
24
29
- if (!sme_sm_enabled_check(s)) {
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
30
- goto fail_exit;
26
MEMTXATTRS_UNSPECIFIED, &res);
31
- }
27
32
- } else if (s->sve_excp_el) {
28
if (res != MEMTX_OK) {
33
+ ret = sme_sm_enabled_check(s);
29
- return result;
34
+ s->sve_access_checked = (ret ? 1 : -1);
30
+ return CMD_STALL;
35
+ return ret;
36
+ }
37
+ if (s->sve_excp_el) {
38
+ /* Assert that we only raise one exception per instruction. */
39
+ assert(!s->sve_access_checked);
40
gen_exception_insn_el(s, 0, EXCP_UDEF,
41
syn_sve_access_trap(), s->sve_excp_el);
42
- goto fail_exit;
43
+ s->sve_access_checked = -1;
44
+ return false;
31
}
45
}
32
46
s->sve_access_checked = 1;
33
size = (value & SIZE_MASK);
47
return fp_access_check(s);
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
48
-
35
MEMTXATTRS_UNSPECIFIED, &res);
49
- fail_exit:
36
50
- /* Assert that we only raise one exception per instruction. */
37
if (res != MEMTX_OK) {
51
- assert(!s->sve_access_checked);
38
- return result;
52
- s->sve_access_checked = -1;
39
+ return CMD_STALL;
53
- return false;
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;
54
}
54
}
55
55
56
/*
56
/*
57
--
57
--
58
2.25.1
58
2.43.0
59
60
diff view generated by jsdifflib
1
In process_cmdq(), we read 64 bits of the command packet, which
1
We want to capture potential Rust backtraces on panics in our test
2
contain the command identifier, which we then switch() on to dispatch
2
logs, which isn't Rust's default behaviour. Set RUST_BACKTRACE=1 in
3
to an appropriate sub-function. However, if address_space_ldq_le()
3
the add_test_setup environments, so that all our tests get run with
4
reports a memory transaction failure, we still read the command
4
this environment variable set.
5
identifier out of the data and switch() on it. Restructure the code
5
6
so that we stop immediately (stalling the command queue) in this
6
This makes the setting of that variable in the gitlab CI template
7
case.
7
redundant, so we can remove it.
8
8
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Message-id: 20220111171048.3545974-5-peter.maydell@linaro.org
12
Message-id: 20250310102950.3752908-1-peter.maydell@linaro.org
13
---
13
---
14
hw/intc/arm_gicv3_its.c | 7 ++++++-
14
meson.build | 9 ++++++---
15
1 file changed, 6 insertions(+), 1 deletion(-)
15
.gitlab-ci.d/buildtest-template.yml | 1 -
16
2 files changed, 6 insertions(+), 4 deletions(-)
16
17
17
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
18
diff --git a/meson.build b/meson.build
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/intc/arm_gicv3_its.c
20
--- a/meson.build
20
+++ b/hw/intc/arm_gicv3_its.c
21
+++ b/meson.build
21
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
22
@@ -XXX,XX +XXX,XX @@ project('qemu', ['c'], meson_version: '>=1.5.0',
22
data = address_space_ldq_le(as, s->cq.base_addr + cq_offset,
23
23
MEMTXATTRS_UNSPECIFIED, &res);
24
meson.add_devenv({ 'MESON_BUILD_ROOT' : meson.project_build_root() })
24
if (res != MEMTX_OK) {
25
25
- result = false;
26
-add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)
26
+ s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1);
27
-add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow'])
27
+ qemu_log_mask(LOG_GUEST_ERROR,
28
-add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
28
+ "%s: could not read command at 0x%" PRIx64 "\n",
29
+add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true,
29
+ __func__, s->cq.base_addr + cq_offset);
30
+ env: ['RUST_BACKTRACE=1'])
30
+ break;
31
+add_test_setup('slow', exclude_suites: ['thorough'],
31
}
32
+ env: ['G_TEST_SLOW=1', 'SPEED=slow', 'RUST_BACKTRACE=1'])
32
+
33
+add_test_setup('thorough',
33
cmd = (data & CMD_MASK);
34
+ env: ['G_TEST_SLOW=1', 'SPEED=thorough', 'RUST_BACKTRACE=1'])
34
35
35
switch (cmd) {
36
meson.add_postconf_script(find_program('scripts/symlink-install-tree.py'))
37
38
diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml
39
index XXXXXXX..XXXXXXX 100644
40
--- a/.gitlab-ci.d/buildtest-template.yml
41
+++ b/.gitlab-ci.d/buildtest-template.yml
42
@@ -XXX,XX +XXX,XX @@
43
stage: test
44
image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
45
script:
46
- - export RUST_BACKTRACE=1
47
- source scripts/ci/gitlab-ci-section
48
- section_start buildenv "Setting up to run tests"
49
- scripts/git-submodule.sh update roms/SLOF
36
--
50
--
37
2.25.1
51
2.43.0
38
52
39
53
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Quoting Peter Maydell:
4
5
"These MEMTX_* aren't from the memory transaction
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>
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>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
hw/intc/arm_gicv3_redist.c | 4 ++--
22
1 file changed, 2 insertions(+), 2 deletions(-)
23
24
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/intc/arm_gicv3_redist.c
27
+++ b/hw/intc/arm_gicv3_redist.c
28
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data,
29
break;
30
}
31
32
- if (r == MEMTX_ERROR) {
33
+ if (r != MEMTX_OK) {
34
qemu_log_mask(LOG_GUEST_ERROR,
35
"%s: invalid guest read at offset " TARGET_FMT_plx
36
" size %u\n", __func__, offset, size);
37
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data,
38
break;
39
}
40
41
- if (r == MEMTX_ERROR) {
42
+ if (r != MEMTX_OK) {
43
qemu_log_mask(LOG_GUEST_ERROR,
44
"%s: invalid guest write at offset " TARGET_FMT_plx
45
" size %u\n", __func__, offset, size);
46
--
47
2.25.1
48
49
diff view generated by jsdifflib