1
ARM queue for 2.10 soft freeze...
1
Hi; here's an arm pullreq. The big bits here are Fabiano's
2
CONFIG_TCG=n patches and my set that deprecate -singlestep;
3
other than that there's a collection of smaller bugfixes.
2
4
3
thanks
5
thanks
4
-- PMM
6
-- PMM
5
7
6
The following changes since commit 6632f6ff96f0537fc34cdc00c760656fc62e23c5:
8
The following changes since commit 7c18f2d663521f1b31b821a13358ce38075eaf7d:
7
9
8
Merge remote-tracking branch 'remotes/famz/tags/block-and-testing-pull-request' into staging (2017-07-17 11:46:36 +0100)
10
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-04-29 23:07:17 +0100)
9
11
10
are available in the git repository at:
12
are available in the Git repository at:
11
13
12
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170717
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230502-1
13
15
14
for you to fetch changes up to e5a6a6e64e82a132cebef023d867085b0a2993d7:
16
for you to fetch changes up to 0ab99e4252f21550f2c16f859cbcdd3cced9f8bf:
15
17
16
MAINTAINERS: Add entries for MPS2 board (2017-07-17 13:36:09 +0100)
18
hw/net/allwinner-sun8i-emac: Correctly byteswap descriptor fields (2023-05-02 13:10:42 +0100)
17
19
18
----------------------------------------------------------------
20
----------------------------------------------------------------
19
target-arm queue:
21
* Support building Arm targets with CONFIG_TCG=no (ie KVM only)
20
* new model of the ARM MPS2/MPS2+ FPGA based development board
22
* hw/net: npcm7xx_emc: set MAC in register space
21
* clean up DISAS_* exit conditions and fix various regressions
23
* hw/arm/bcm2835_property: Implement "get command line" message
22
since commits e75449a346 8a6b28c7b5 (in particular including
24
* Deprecate the '-singlestep' command line option in favour of
23
ones which broke OP-TEE guests)
25
'-one-insn-per-tb' and '-accel one-insn-per-tb=on'
24
* make Cortex-M3 and M4 correctly default to 8 PMSA regions
26
* Deprecate 'singlestep' member of QMP StatusInfo struct
27
* docs/about/deprecated.rst: Add "since 7.1" tag to dtb-kaslr-seed deprecation
28
* hw/net/msf2-emac: Don't modify descriptor in-place in emac_store_desc()
29
* raspi, aspeed: Write bootloader code correctly on big-endian hosts
30
* hw/intc/allwinner-a10-pic: Fix bug on big-endian hosts
31
* Fix bug in A32 ERET on big-endian hosts that caused guest crash
32
* hw/sd/allwinner-sdhost: Correctly byteswap descriptor fields
33
* hw/net/allwinner-sun8i-emac: Correctly byteswap descriptor fields
25
34
26
----------------------------------------------------------------
35
----------------------------------------------------------------
27
Alex Bennée (6):
36
Claudio Fontana (1):
28
include/exec/exec-all: document common exit conditions
37
target/arm: move cpu_tcg to tcg/cpu32.c
29
target/arm/translate: make DISAS_UPDATE match declared semantics
30
target/arm/translate.h: expand comment on DISAS_EXIT
31
target/arm/translate: ensure gen_goto_tb sets exit flags
32
target/arm: use gen_goto_tb for ISB handling
33
target/arm: use DISAS_EXIT for eret handling
34
38
35
Peter Maydell (12):
39
Cédric Le Goater (2):
36
qdev-properties.h: Explicitly set the default value for arraylen properties
40
hw/arm/boot: Make write_bootloader() public as arm_write_bootloader()
37
qdev: support properties which don't set a default value
41
hw/arm/aspeed: Use arm_write_bootloader() to write the bootloader
38
target/arm: Make Cortex-M3 and M4 default to 8 PMSA regions
39
hw/arm/mps2: Implement skeleton mps2-an385 and mps2-an511 board models
40
hw/char/cmsdk-apb-uart.c: Implement CMSDK APB UART
41
hw/arm/mps2: Add UARTs
42
hw/char/cmsdk-apb-timer: Implement CMSDK APB timer device
43
hw/arm/mps2: Add timers
44
hw/misc/mps2_scc: Implement MPS2 Serial Communication Controller
45
hw/arm/mps2: Add SCC
46
hw/arm/mps2: Add ethernet
47
MAINTAINERS: Add entries for MPS2 board
48
42
49
hw/arm/Makefile.objs | 1 +
43
Daniel Bertalan (1):
50
hw/char/Makefile.objs | 1 +
44
hw/arm/bcm2835_property: Implement "get command line" message
51
hw/misc/Makefile.objs | 1 +
52
hw/timer/Makefile.objs | 1 +
53
include/exec/exec-all.h | 29 ++-
54
include/hw/char/cmsdk-apb-uart.h | 78 +++++++
55
include/hw/misc/mps2-scc.h | 43 ++++
56
include/hw/qdev-core.h | 10 +
57
include/hw/qdev-properties.h | 21 ++
58
include/hw/timer/cmsdk-apb-timer.h | 59 ++++++
59
target/arm/translate.h | 5 +-
60
hw/arm/mps2.c | 385 +++++++++++++++++++++++++++++++++++
61
hw/char/cmsdk-apb-uart.c | 403 +++++++++++++++++++++++++++++++++++++
62
hw/core/qdev.c | 2 +-
63
hw/misc/mps2-scc.c | 310 ++++++++++++++++++++++++++++
64
hw/timer/cmsdk-apb-timer.c | 253 +++++++++++++++++++++++
65
target/arm/cpu.c | 12 +-
66
target/arm/translate-a64.c | 19 +-
67
target/arm/translate.c | 22 +-
68
MAINTAINERS | 14 +-
69
default-configs/arm-softmmu.mak | 6 +
70
hw/char/trace-events | 9 +
71
hw/misc/trace-events | 8 +
72
hw/timer/trace-events | 5 +
73
24 files changed, 1673 insertions(+), 24 deletions(-)
74
create mode 100644 include/hw/char/cmsdk-apb-uart.h
75
create mode 100644 include/hw/misc/mps2-scc.h
76
create mode 100644 include/hw/timer/cmsdk-apb-timer.h
77
create mode 100644 hw/arm/mps2.c
78
create mode 100644 hw/char/cmsdk-apb-uart.c
79
create mode 100644 hw/misc/mps2-scc.c
80
create mode 100644 hw/timer/cmsdk-apb-timer.c
81
45
46
Fabiano Rosas (11):
47
target/arm: Move cortex sysregs into a separate file
48
target/arm: Remove dead code from cpu_max_set_sve_max_vq
49
target/arm: Extract TCG -cpu max code into a function
50
target/arm: Do not expose all -cpu max features to qtests
51
target/arm: Move 64-bit TCG CPUs into tcg/
52
tests/qtest: Adjust and document query-cpu-model-expansion test for arm
53
tests/qtest: Fix tests when no KVM or TCG are present
54
tests/avocado: Pass parameters to migration test
55
arm/Kconfig: Always select SEMIHOSTING when TCG is present
56
arm/Kconfig: Do not build TCG-only boards on a KVM-only build
57
tests/qtest: Restrict tpm-tis-i2c-test to CONFIG_TCG
58
59
Patrick Venture (1):
60
hw/net: npcm7xx_emc: set MAC in register space
61
62
Peter Maydell (18):
63
make one-insn-per-tb an accel option
64
softmmu: Don't use 'singlestep' global in QMP and HMP commands
65
accel/tcg: Use one_insn_per_tb global instead of old singlestep global
66
linux-user: Add '-one-insn-per-tb' option equivalent to '-singlestep'
67
bsd-user: Add '-one-insn-per-tb' option equivalent to '-singlestep'
68
Document that -singlestep command line option is deprecated
69
accel/tcg: Report one-insn-per-tb in 'info jit', not 'info status'
70
hmp: Add 'one-insn-per-tb' command equivalent to 'singlestep'
71
qapi/run-state.json: Fix missing newline at end of file
72
qmp: Deprecate 'singlestep' member of StatusInfo
73
docs/about/deprecated.rst: Add "since 7.1" tag to dtb-kaslr-seed deprecation
74
hw/net/msf2-emac: Don't modify descriptor in-place in emac_store_desc()
75
hw/arm/raspi: Use arm_write_bootloader() to write boot code
76
hw/intc/allwinner-a10-pic: Don't use set_bit()/clear_bit()
77
target/arm: Define and use new load_cpu_field_low32()
78
target/arm: Add compile time asserts to load/store_cpu_field macros
79
hw/sd/allwinner-sdhost: Correctly byteswap descriptor fields
80
hw/net/allwinner-sun8i-emac: Correctly byteswap descriptor fields
81
82
Philippe Mathieu-Daudé (1):
83
gitlab-ci: Check building KVM-only aarch64 target
84
85
docs/about/deprecated.rst | 43 +-
86
docs/user/main.rst | 14 +-
87
configs/devices/aarch64-softmmu/default.mak | 4 -
88
configs/devices/arm-softmmu/default.mak | 39 --
89
qapi/run-state.json | 16 +-
90
accel/tcg/internal.h | 2 +
91
include/exec/cpu-common.h | 2 -
92
include/hw/arm/boot.h | 49 ++
93
include/hw/misc/bcm2835_property.h | 1 +
94
include/monitor/hmp.h | 2 +-
95
target/arm/cpregs.h | 6 +
96
target/arm/internals.h | 10 +-
97
target/arm/translate-a32.h | 24 +-
98
accel/tcg/cpu-exec.c | 2 +-
99
accel/tcg/monitor.c | 14 +
100
accel/tcg/tcg-all.c | 23 +
101
bsd-user/main.c | 14 +-
102
hw/arm/aspeed.c | 38 +-
103
hw/arm/bcm2835_peripherals.c | 2 +
104
hw/arm/bcm2836.c | 2 +
105
hw/arm/boot.c | 35 +-
106
hw/arm/raspi.c | 66 +-
107
hw/arm/virt.c | 6 +-
108
hw/intc/allwinner-a10-pic.c | 7 +-
109
hw/misc/bcm2835_property.c | 13 +-
110
hw/net/allwinner-sun8i-emac.c | 22 +-
111
hw/net/msf2-emac.c | 16 +-
112
hw/net/npcm7xx_emc.c | 32 +-
113
hw/sd/allwinner-sdhost.c | 31 +-
114
linux-user/main.c | 18 +-
115
softmmu/globals.c | 1 -
116
softmmu/runstate-hmp-cmds.c | 25 +-
117
softmmu/runstate.c | 10 +-
118
softmmu/vl.c | 17 +-
119
target/arm/cortex-regs.c | 69 ++
120
target/arm/cpu64.c | 702 +-------------------
121
target/arm/{cpu_tcg.c => tcg/cpu32.c} | 72 +-
122
target/arm/tcg/cpu64.c | 723 +++++++++++++++++++++
123
target/arm/tcg/translate.c | 4 +-
124
tests/qtest/arm-cpu-features.c | 20 +-
125
tests/qtest/bios-tables-test.c | 11 +-
126
tests/qtest/boot-serial-test.c | 5 +
127
tests/qtest/migration-test.c | 9 +-
128
tests/qtest/pxe-test.c | 8 +-
129
tests/qtest/test-hmp.c | 1 +
130
tests/qtest/vmgenid-test.c | 9 +-
131
.gitlab-ci.d/crossbuilds.yml | 11 +
132
.../custom-runners/ubuntu-22.04-aarch64.yml | 4 -
133
hmp-commands.hx | 25 +-
134
hw/arm/Kconfig | 43 +-
135
qemu-options.hx | 12 +-
136
target/arm/Kconfig | 7 +
137
target/arm/meson.build | 2 +-
138
target/arm/tcg/meson.build | 2 +
139
tcg/tci/README | 2 +-
140
tests/avocado/migration.py | 83 ++-
141
tests/qtest/meson.build | 3 +-
142
57 files changed, 1449 insertions(+), 984 deletions(-)
143
create mode 100644 target/arm/cortex-regs.c
144
rename target/arm/{cpu_tcg.c => tcg/cpu32.c} (93%)
145
create mode 100644 target/arm/tcg/cpu64.c
146
diff view generated by jsdifflib
1
Model the ARM MPS2/MPS2+ FPGA based development board.
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
The MPS2 and MPS2+ dev boards are FPGA based (the 2+ has a bigger
3
The file cpu_tcg.c is about to be moved into the tcg/ directory, so
4
FPGA but is otherwise the same as the 2). Since the CPU itself
4
move the register definitions into a new file.
5
and most of the devices are in the FPGA, the details of the board
5
6
as seen by the guest depend significantly on the FPGA image.
6
Also move the function declaration to the more appropriate cpregs.h.
7
7
8
We model the following FPGA images:
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
"mps2_an385" -- Cortex-M3 as documented in ARM Application Note AN385
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
"mps2_an511" -- Cortex-M3 'DesignStart' as documented in AN511
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
11
Message-id: 20230426180013.14814-2-farosas@suse.de
12
They are fairly similar but differ in the details for some
13
peripherals.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Message-id: 1500029487-14822-2-git-send-email-peter.maydell@linaro.org
17
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
18
---
13
---
19
hw/arm/Makefile.objs | 1 +
14
target/arm/cpregs.h | 6 ++++
20
hw/arm/mps2.c | 270 ++++++++++++++++++++++++++++++++++++++++
15
target/arm/internals.h | 6 ----
21
default-configs/arm-softmmu.mak | 1 +
16
target/arm/cortex-regs.c | 69 ++++++++++++++++++++++++++++++++++++++++
22
3 files changed, 272 insertions(+)
17
target/arm/cpu64.c | 1 +
23
create mode 100644 hw/arm/mps2.c
18
target/arm/cpu_tcg.c | 59 ----------------------------------
24
19
target/arm/meson.build | 1 +
25
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
20
6 files changed, 77 insertions(+), 65 deletions(-)
26
index XXXXXXX..XXXXXXX 100644
21
create mode 100644 target/arm/cortex-regs.c
27
--- a/hw/arm/Makefile.objs
22
28
+++ b/hw/arm/Makefile.objs
23
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
29
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
24
index XXXXXXX..XXXXXXX 100644
30
obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
25
--- a/target/arm/cpregs.h
31
obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
26
+++ b/target/arm/cpregs.h
32
obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o
27
@@ -XXX,XX +XXX,XX @@ static inline bool arm_cpreg_in_idspace(const ARMCPRegInfo *ri)
33
+obj-$(CONFIG_MPS2) += mps2.o
28
ri->crn, ri->crm);
34
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
29
}
30
31
+#ifdef CONFIG_USER_ONLY
32
+static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { }
33
+#else
34
+void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu);
35
+#endif
36
+
37
#endif /* TARGET_ARM_CPREGS_H */
38
diff --git a/target/arm/internals.h b/target/arm/internals.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/internals.h
41
+++ b/target/arm/internals.h
42
@@ -XXX,XX +XXX,XX @@ uint32_t arm_v7m_mrs_control(CPUARMState *env, uint32_t secure);
43
uint32_t *arm_v7m_get_sp_ptr(CPUARMState *env, bool secure,
44
bool threadmode, bool spsel);
45
46
-#ifdef CONFIG_USER_ONLY
47
-static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { }
48
-#else
49
-void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu);
50
-#endif
51
-
52
bool el_is_in_host(CPUARMState *env, int el);
53
54
void aa32_max_features(ARMCPU *cpu);
55
diff --git a/target/arm/cortex-regs.c b/target/arm/cortex-regs.c
35
new file mode 100644
56
new file mode 100644
36
index XXXXXXX..XXXXXXX
57
index XXXXXXX..XXXXXXX
37
--- /dev/null
58
--- /dev/null
38
+++ b/hw/arm/mps2.c
59
+++ b/target/arm/cortex-regs.c
39
@@ -XXX,XX +XXX,XX @@
60
@@ -XXX,XX +XXX,XX @@
40
+/*
61
+/*
41
+ * ARM V2M MPS2 board emulation.
62
+ * ARM Cortex-A registers
42
+ *
63
+ *
43
+ * Copyright (c) 2017 Linaro Limited
64
+ * This code is licensed under the GNU GPL v2 or later.
44
+ * Written by Peter Maydell
45
+ *
65
+ *
46
+ * This program is free software; you can redistribute it and/or modify
66
+ * SPDX-License-Identifier: GPL-2.0-or-later
47
+ * it under the terms of the GNU General Public License version 2 or
48
+ * (at your option) any later version.
49
+ */
67
+ */
50
+
68
+
51
+/* The MPS2 and MPS2+ dev boards are FPGA based (the 2+ has a bigger
52
+ * FPGA but is otherwise the same as the 2). Since the CPU itself
53
+ * and most of the devices are in the FPGA, the details of the board
54
+ * as seen by the guest depend significantly on the FPGA image.
55
+ * We model the following FPGA images:
56
+ * "mps2-an385" -- Cortex-M3 as documented in ARM Application Note AN385
57
+ * "mps2-an511" -- Cortex-M3 'DesignStart' as documented in AN511
58
+ *
59
+ * Links to the TRM for the board itself and to the various Application
60
+ * Notes which document the FPGA images can be found here:
61
+ * https://developer.arm.com/products/system-design/development-boards/cortex-m-prototyping-system
62
+ */
63
+
64
+#include "qemu/osdep.h"
69
+#include "qemu/osdep.h"
65
+#include "qapi/error.h"
70
+#include "cpu.h"
66
+#include "qemu/error-report.h"
71
+#include "cpregs.h"
67
+#include "hw/arm/arm.h"
72
+
68
+#include "hw/arm/armv7m.h"
73
+
69
+#include "hw/boards.h"
74
+static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
70
+#include "exec/address-spaces.h"
71
+#include "hw/misc/unimp.h"
72
+
73
+typedef enum MPS2FPGAType {
74
+ FPGA_AN385,
75
+ FPGA_AN511,
76
+} MPS2FPGAType;
77
+
78
+typedef struct {
79
+ MachineClass parent;
80
+ MPS2FPGAType fpga_type;
81
+ const char *cpu_model;
82
+} MPS2MachineClass;
83
+
84
+typedef struct {
85
+ MachineState parent;
86
+
87
+ ARMv7MState armv7m;
88
+ MemoryRegion psram;
89
+ MemoryRegion ssram1;
90
+ MemoryRegion ssram1_m;
91
+ MemoryRegion ssram23;
92
+ MemoryRegion ssram23_m;
93
+ MemoryRegion blockram;
94
+ MemoryRegion blockram_m1;
95
+ MemoryRegion blockram_m2;
96
+ MemoryRegion blockram_m3;
97
+ MemoryRegion sram;
98
+} MPS2MachineState;
99
+
100
+#define TYPE_MPS2_MACHINE "mps2"
101
+#define TYPE_MPS2_AN385_MACHINE MACHINE_TYPE_NAME("mps2-an385")
102
+#define TYPE_MPS2_AN511_MACHINE MACHINE_TYPE_NAME("mps2-an511")
103
+
104
+#define MPS2_MACHINE(obj) \
105
+ OBJECT_CHECK(MPS2MachineState, obj, TYPE_MPS2_MACHINE)
106
+#define MPS2_MACHINE_GET_CLASS(obj) \
107
+ OBJECT_GET_CLASS(MPS2MachineClass, obj, TYPE_MPS2_MACHINE)
108
+#define MPS2_MACHINE_CLASS(klass) \
109
+ OBJECT_CLASS_CHECK(MPS2MachineClass, klass, TYPE_MPS2_MACHINE)
110
+
111
+/* Main SYSCLK frequency in Hz */
112
+#define SYSCLK_FRQ 25000000
113
+
114
+/* Initialize the auxiliary RAM region @mr and map it into
115
+ * the memory map at @base.
116
+ */
117
+static void make_ram(MemoryRegion *mr, const char *name,
118
+ hwaddr base, hwaddr size)
119
+{
75
+{
120
+ memory_region_init_ram(mr, NULL, name, size, &error_fatal);
76
+ ARMCPU *cpu = env_archcpu(env);
121
+ memory_region_add_subregion(get_system_memory(), base, mr);
77
+
78
+ /* Number of cores is in [25:24]; otherwise we RAZ */
79
+ return (cpu->core_count - 1) << 24;
122
+}
80
+}
123
+
81
+
124
+/* Create an alias of an entire original MemoryRegion @orig
82
+static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = {
125
+ * located at @base in the memory map.
83
+ { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64,
126
+ */
84
+ .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2,
127
+static void make_ram_alias(MemoryRegion *mr, const char *name,
85
+ .access = PL1_RW, .readfn = l2ctlr_read,
128
+ MemoryRegion *orig, hwaddr base)
86
+ .writefn = arm_cp_write_ignore },
87
+ { .name = "L2CTLR",
88
+ .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2,
89
+ .access = PL1_RW, .readfn = l2ctlr_read,
90
+ .writefn = arm_cp_write_ignore },
91
+ { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64,
92
+ .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3,
93
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
94
+ { .name = "L2ECTLR",
95
+ .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3,
96
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
97
+ { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH,
98
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0,
99
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
100
+ { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64,
101
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0,
102
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
103
+ { .name = "CPUACTLR",
104
+ .cp = 15, .opc1 = 0, .crm = 15,
105
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
106
+ { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64,
107
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1,
108
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
109
+ { .name = "CPUECTLR",
110
+ .cp = 15, .opc1 = 1, .crm = 15,
111
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
112
+ { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64,
113
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2,
114
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
115
+ { .name = "CPUMERRSR",
116
+ .cp = 15, .opc1 = 2, .crm = 15,
117
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
118
+ { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64,
119
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3,
120
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
121
+ { .name = "L2MERRSR",
122
+ .cp = 15, .opc1 = 3, .crm = 15,
123
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
124
+};
125
+
126
+void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu)
129
+{
127
+{
130
+ memory_region_init_alias(mr, NULL, name, orig, 0,
128
+ define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
131
+ memory_region_size(orig));
132
+ memory_region_add_subregion(get_system_memory(), base, mr);
133
+}
129
+}
134
+
130
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
135
+static void mps2_common_init(MachineState *machine)
131
index XXXXXXX..XXXXXXX 100644
136
+{
132
--- a/target/arm/cpu64.c
137
+ MPS2MachineState *mms = MPS2_MACHINE(machine);
133
+++ b/target/arm/cpu64.c
138
+ MPS2MachineClass *mmc = MPS2_MACHINE_GET_CLASS(machine);
134
@@ -XXX,XX +XXX,XX @@
139
+ MemoryRegion *system_memory = get_system_memory();
135
#include "qapi/visitor.h"
140
+ DeviceState *armv7m;
136
#include "hw/qdev-properties.h"
141
+
137
#include "internals.h"
142
+ if (!machine->cpu_model) {
138
+#include "cpregs.h"
143
+ machine->cpu_model = mmc->cpu_model;
139
144
+ }
140
static void aarch64_a35_initfn(Object *obj)
145
+
141
{
146
+ if (strcmp(machine->cpu_model, mmc->cpu_model) != 0) {
142
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
147
+ error_report("This board can only be used with CPU %s", mmc->cpu_model);
143
index XXXXXXX..XXXXXXX 100644
148
+ exit(1);
144
--- a/target/arm/cpu_tcg.c
149
+ }
145
+++ b/target/arm/cpu_tcg.c
150
+
146
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
151
+ /* The FPGA images have an odd combination of different RAMs,
147
cpu->isar.id_dfr0 = t;
152
+ * because in hardware they are different implementations and
148
}
153
+ * connected to different buses, giving varying performance/size
149
154
+ * tradeoffs. For QEMU they're all just RAM, though. We arbitrarily
150
-#ifndef CONFIG_USER_ONLY
155
+ * call the 16MB our "system memory", as it's the largest lump.
151
-static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
156
+ *
152
-{
157
+ * Common to both boards:
153
- ARMCPU *cpu = env_archcpu(env);
158
+ * 0x21000000..0x21ffffff : PSRAM (16MB)
154
-
159
+ * AN385 only:
155
- /* Number of cores is in [25:24]; otherwise we RAZ */
160
+ * 0x00000000 .. 0x003fffff : ZBT SSRAM1
156
- return (cpu->core_count - 1) << 24;
161
+ * 0x00400000 .. 0x007fffff : mirror of ZBT SSRAM1
157
-}
162
+ * 0x20000000 .. 0x203fffff : ZBT SSRAM 2&3
158
-
163
+ * 0x20400000 .. 0x207fffff : mirror of ZBT SSRAM 2&3
159
-static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = {
164
+ * 0x01000000 .. 0x01003fff : block RAM (16K)
160
- { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64,
165
+ * 0x01004000 .. 0x01007fff : mirror of above
161
- .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2,
166
+ * 0x01008000 .. 0x0100bfff : mirror of above
162
- .access = PL1_RW, .readfn = l2ctlr_read,
167
+ * 0x0100c000 .. 0x0100ffff : mirror of above
163
- .writefn = arm_cp_write_ignore },
168
+ * AN511 only:
164
- { .name = "L2CTLR",
169
+ * 0x00000000 .. 0x0003ffff : FPGA block RAM
165
- .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2,
170
+ * 0x00400000 .. 0x007fffff : ZBT SSRAM1
166
- .access = PL1_RW, .readfn = l2ctlr_read,
171
+ * 0x20000000 .. 0x2001ffff : SRAM
167
- .writefn = arm_cp_write_ignore },
172
+ * 0x20400000 .. 0x207fffff : ZBT SSRAM 2&3
168
- { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64,
173
+ *
169
- .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3,
174
+ * The AN385 has a feature where the lowest 16K can be mapped
170
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
175
+ * either to the bottom of the ZBT SSRAM1 or to the block RAM.
171
- { .name = "L2ECTLR",
176
+ * This is of no use for QEMU so we don't implement it (as if
172
- .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3,
177
+ * zbt_boot_ctrl is always zero).
173
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
178
+ */
174
- { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH,
179
+ memory_region_allocate_system_memory(&mms->psram,
175
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0,
180
+ NULL, "mps.ram", 0x1000000);
176
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
181
+ memory_region_add_subregion(system_memory, 0x21000000, &mms->psram);
177
- { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64,
182
+
178
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0,
183
+ switch (mmc->fpga_type) {
179
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
184
+ case FPGA_AN385:
180
- { .name = "CPUACTLR",
185
+ make_ram(&mms->ssram1, "mps.ssram1", 0x0, 0x400000);
181
- .cp = 15, .opc1 = 0, .crm = 15,
186
+ make_ram_alias(&mms->ssram1_m, "mps.ssram1_m", &mms->ssram1, 0x400000);
182
- .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
187
+ make_ram(&mms->ssram23, "mps.ssram23", 0x20000000, 0x400000);
183
- { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64,
188
+ make_ram_alias(&mms->ssram23_m, "mps.ssram23_m",
184
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1,
189
+ &mms->ssram23, 0x20400000);
185
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
190
+ make_ram(&mms->blockram, "mps.blockram", 0x01000000, 0x4000);
186
- { .name = "CPUECTLR",
191
+ make_ram_alias(&mms->blockram_m1, "mps.blockram_m1",
187
- .cp = 15, .opc1 = 1, .crm = 15,
192
+ &mms->blockram, 0x01004000);
188
- .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
193
+ make_ram_alias(&mms->blockram_m2, "mps.blockram_m2",
189
- { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64,
194
+ &mms->blockram, 0x01008000);
190
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2,
195
+ make_ram_alias(&mms->blockram_m3, "mps.blockram_m3",
191
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
196
+ &mms->blockram, 0x0100c000);
192
- { .name = "CPUMERRSR",
197
+ break;
193
- .cp = 15, .opc1 = 2, .crm = 15,
198
+ case FPGA_AN511:
194
- .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
199
+ make_ram(&mms->blockram, "mps.blockram", 0x0, 0x40000);
195
- { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64,
200
+ make_ram(&mms->ssram1, "mps.ssram1", 0x00400000, 0x00800000);
196
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3,
201
+ make_ram(&mms->sram, "mps.sram", 0x20000000, 0x20000);
197
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
202
+ make_ram(&mms->ssram23, "mps.ssram23", 0x20400000, 0x400000);
198
- { .name = "L2MERRSR",
203
+ break;
199
- .cp = 15, .opc1 = 3, .crm = 15,
204
+ default:
200
- .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
205
+ g_assert_not_reached();
201
-};
206
+ }
202
-
207
+
203
-void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu)
208
+ object_initialize(&mms->armv7m, sizeof(mms->armv7m), TYPE_ARMV7M);
204
-{
209
+ armv7m = DEVICE(&mms->armv7m);
205
- define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
210
+ qdev_set_parent_bus(armv7m, sysbus_get_default());
206
-}
211
+ switch (mmc->fpga_type) {
207
-#endif /* !CONFIG_USER_ONLY */
212
+ case FPGA_AN385:
208
-
213
+ qdev_prop_set_uint32(armv7m, "num-irq", 32);
209
/* CPU models. These are not needed for the AArch64 linux-user build. */
214
+ break;
210
#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
215
+ case FPGA_AN511:
211
216
+ qdev_prop_set_uint32(armv7m, "num-irq", 64);
212
diff --git a/target/arm/meson.build b/target/arm/meson.build
217
+ break;
213
index XXXXXXX..XXXXXXX 100644
218
+ default:
214
--- a/target/arm/meson.build
219
+ g_assert_not_reached();
215
+++ b/target/arm/meson.build
220
+ }
216
@@ -XXX,XX +XXX,XX @@ arm_softmmu_ss.add(files(
221
+ qdev_prop_set_string(armv7m, "cpu-model", machine->cpu_model);
217
'arch_dump.c',
222
+ object_property_set_link(OBJECT(&mms->armv7m), OBJECT(system_memory),
218
'arm-powerctl.c',
223
+ "memory", &error_abort);
219
'arm-qmp-cmds.c',
224
+ object_property_set_bool(OBJECT(&mms->armv7m), true, "realized",
220
+ 'cortex-regs.c',
225
+ &error_fatal);
221
'machine.c',
226
+
222
'ptw.c',
227
+ create_unimplemented_device("zbtsmram mirror", 0x00400000, 0x00400000);
223
))
228
+ create_unimplemented_device("RESERVED 1", 0x00800000, 0x00800000);
229
+ create_unimplemented_device("Block RAM", 0x01000000, 0x00010000);
230
+ create_unimplemented_device("RESERVED 2", 0x01010000, 0x1EFF0000);
231
+ create_unimplemented_device("RESERVED 3", 0x20800000, 0x00800000);
232
+ create_unimplemented_device("PSRAM", 0x21000000, 0x01000000);
233
+ /* These three ranges all cover multiple devices; we may implement
234
+ * some of them below (in which case the real device takes precedence
235
+ * over the unimplemented-region mapping).
236
+ */
237
+ create_unimplemented_device("CMSDK APB peripheral region @0x40000000",
238
+ 0x40000000, 0x00010000);
239
+ create_unimplemented_device("CMSDK peripheral region @0x40010000",
240
+ 0x40010000, 0x00010000);
241
+ create_unimplemented_device("Extra peripheral region @0x40020000",
242
+ 0x40020000, 0x00010000);
243
+ create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000);
244
+ create_unimplemented_device("Ethernet", 0x40200000, 0x00100000);
245
+ create_unimplemented_device("VGA", 0x41000000, 0x0200000);
246
+
247
+ system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
248
+
249
+ armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
250
+ 0x400000);
251
+}
252
+
253
+static void mps2_class_init(ObjectClass *oc, void *data)
254
+{
255
+ MachineClass *mc = MACHINE_CLASS(oc);
256
+
257
+ mc->init = mps2_common_init;
258
+ mc->max_cpus = 1;
259
+}
260
+
261
+static void mps2_an385_class_init(ObjectClass *oc, void *data)
262
+{
263
+ MachineClass *mc = MACHINE_CLASS(oc);
264
+ MPS2MachineClass *mmc = MPS2_MACHINE_CLASS(oc);
265
+
266
+ mc->desc = "ARM MPS2 with AN385 FPGA image for Cortex-M3";
267
+ mmc->fpga_type = FPGA_AN385;
268
+ mmc->cpu_model = "cortex-m3";
269
+}
270
+
271
+static void mps2_an511_class_init(ObjectClass *oc, void *data)
272
+{
273
+ MachineClass *mc = MACHINE_CLASS(oc);
274
+ MPS2MachineClass *mmc = MPS2_MACHINE_CLASS(oc);
275
+
276
+ mc->desc = "ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3";
277
+ mmc->fpga_type = FPGA_AN511;
278
+ mmc->cpu_model = "cortex-m3";
279
+}
280
+
281
+static const TypeInfo mps2_info = {
282
+ .name = TYPE_MPS2_MACHINE,
283
+ .parent = TYPE_MACHINE,
284
+ .abstract = true,
285
+ .instance_size = sizeof(MPS2MachineState),
286
+ .class_size = sizeof(MPS2MachineClass),
287
+ .class_init = mps2_class_init,
288
+};
289
+
290
+static const TypeInfo mps2_an385_info = {
291
+ .name = TYPE_MPS2_AN385_MACHINE,
292
+ .parent = TYPE_MPS2_MACHINE,
293
+ .class_init = mps2_an385_class_init,
294
+};
295
+
296
+static const TypeInfo mps2_an511_info = {
297
+ .name = TYPE_MPS2_AN511_MACHINE,
298
+ .parent = TYPE_MPS2_MACHINE,
299
+ .class_init = mps2_an511_class_init,
300
+};
301
+
302
+static void mps2_machine_init(void)
303
+{
304
+ type_register_static(&mps2_info);
305
+ type_register_static(&mps2_an385_info);
306
+ type_register_static(&mps2_an511_info);
307
+}
308
+
309
+type_init(mps2_machine_init);
310
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
311
index XXXXXXX..XXXXXXX 100644
312
--- a/default-configs/arm-softmmu.mak
313
+++ b/default-configs/arm-softmmu.mak
314
@@ -XXX,XX +XXX,XX @@ CONFIG_ONENAND=y
315
CONFIG_TUSB6010=y
316
CONFIG_IMX=y
317
CONFIG_MAINSTONE=y
318
+CONFIG_MPS2=y
319
CONFIG_NSERIES=y
320
CONFIG_RASPI=y
321
CONFIG_REALVIEW=y
322
--
224
--
323
2.7.4
225
2.34.1
324
226
325
227
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
The sve-max-vq property has been removed from the -cpu max used with
4
KVM, so code under kvm_enabled in cpu_max_set_sve_max_vq is not
5
reachable.
6
7
Fixes: 0baa21be49 ("target/arm: Make KVM -cpu max exactly like -cpu host")
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
11
Message-id: 20230426180013.14814-3-farosas@suse.de
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/cpu64.c | 6 ------
15
1 file changed, 6 deletions(-)
16
17
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu64.c
20
+++ b/target/arm/cpu64.c
21
@@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name,
22
return;
23
}
24
25
- if (kvm_enabled() && !kvm_arm_sve_supported()) {
26
- error_setg(errp, "cannot set sve-max-vq");
27
- error_append_hint(errp, "SVE not supported by KVM on this host\n");
28
- return;
29
- }
30
-
31
if (max_vq == 0 || max_vq > ARM_MAX_VQ) {
32
error_setg(errp, "unsupported SVE vector length");
33
error_append_hint(errp, "Valid sve-max-vq in range [1-%d]\n",
34
--
35
2.34.1
36
37
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
Introduce aarch64_max_tcg_initfn that contains the TCG-only part of
4
-cpu max configuration. We'll need that to be able to restrict this
5
code to a TCG-only config in the next patches.
6
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
Message-id: 20230426180013.14814-4-farosas@suse.de
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/cpu64.c | 32 ++++++++++++++++++--------------
14
1 file changed, 18 insertions(+), 14 deletions(-)
15
16
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu64.c
19
+++ b/target/arm/cpu64.c
20
@@ -XXX,XX +XXX,XX @@ static void aarch64_host_initfn(Object *obj)
21
#endif
22
}
23
24
-/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
25
- * otherwise, a CPU with as many features enabled as our emulation supports.
26
- * The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
27
+/*
28
+ * -cpu max: a CPU with as many features enabled as our emulation supports.
29
+ * The version of '-cpu max' for qemu-system-arm is defined in cpu_tcg.c;
30
* this only needs to handle 64 bits.
31
*/
32
-static void aarch64_max_initfn(Object *obj)
33
+static void aarch64_max_tcg_initfn(Object *obj)
34
{
35
ARMCPU *cpu = ARM_CPU(obj);
36
uint64_t t;
37
uint32_t u;
38
39
- if (kvm_enabled() || hvf_enabled()) {
40
- /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */
41
- aarch64_host_initfn(obj);
42
- return;
43
- }
44
-
45
- /* '-cpu max' for TCG: we currently do this as "A57 with extra things" */
46
-
47
- aarch64_a57_initfn(obj);
48
-
49
/*
50
* Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real
51
* one and try to apply errata workarounds or use impdef features we
52
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
53
qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property);
54
}
55
56
+static void aarch64_max_initfn(Object *obj)
57
+{
58
+ if (kvm_enabled() || hvf_enabled()) {
59
+ /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */
60
+ aarch64_host_initfn(obj);
61
+ return;
62
+ }
63
+
64
+ /* '-cpu max' for TCG: we currently do this as "A57 with extra things" */
65
+
66
+ aarch64_a57_initfn(obj);
67
+ aarch64_max_tcg_initfn(obj);
68
+}
69
+
70
static const ARMCPUInfo aarch64_cpus[] = {
71
{ .name = "cortex-a35", .initfn = aarch64_a35_initfn },
72
{ .name = "cortex-a57", .initfn = aarch64_a57_initfn },
73
--
74
2.34.1
75
76
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
We're about to move the TCG-only -cpu max configuration code under
4
CONFIG_TCG. To be able to do that we need to make sure the qtests
5
still have some cpu configured even when no other accelerator is
6
available.
7
8
Delineate now what is used with TCG-only and what is also used with
9
qtests to make the subsequent patches cleaner.
10
11
Signed-off-by: Fabiano Rosas <farosas@suse.de>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Message-id: 20230426180013.14814-5-farosas@suse.de
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
target/arm/cpu64.c | 12 +++++++++---
18
1 file changed, 9 insertions(+), 3 deletions(-)
19
20
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu64.c
23
+++ b/target/arm/cpu64.c
24
@@ -XXX,XX +XXX,XX @@
25
#include "qemu/module.h"
26
#include "sysemu/kvm.h"
27
#include "sysemu/hvf.h"
28
+#include "sysemu/qtest.h"
29
+#include "sysemu/tcg.h"
30
#include "kvm_arm.h"
31
#include "hvf_arm.h"
32
#include "qapi/visitor.h"
33
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
34
return;
35
}
36
37
- /* '-cpu max' for TCG: we currently do this as "A57 with extra things" */
38
+ if (tcg_enabled() || qtest_enabled()) {
39
+ aarch64_a57_initfn(obj);
40
+ }
41
42
- aarch64_a57_initfn(obj);
43
- aarch64_max_tcg_initfn(obj);
44
+ /* '-cpu max' for TCG: we currently do this as "A57 with extra things" */
45
+ if (tcg_enabled()) {
46
+ aarch64_max_tcg_initfn(obj);
47
+ }
48
}
49
50
static const ARMCPUInfo aarch64_cpus[] = {
51
--
52
2.34.1
53
54
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
As the gen_goto_tb function can do both static and dynamic jumps it
3
Move the 64-bit CPUs that are TCG-only:
4
should also set the is_jmp field. This matches the behaviour of the
4
- cortex-a35
5
a64 code.
5
- cortex-a55
6
- cortex-a72
7
- cortex-a76
8
- a64fx
9
- neoverse-n1
6
10
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
11
Keep the CPUs that can be used with KVM:
8
Reviewed-by: Richard Henderson <rth@twiddle.net>
12
- cortex-a57
9
Message-id: 20170713141928.25419-5-alex.bennee@linaro.org
13
- cortex-a53
10
[tweak to multiline comment formatting]
14
- max
15
- host
16
17
Signed-off-by: Fabiano Rosas <farosas@suse.de>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
20
Message-id: 20230426180013.14814-6-farosas@suse.de
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
22
---
13
target/arm/translate.c | 6 +++++-
23
target/arm/internals.h | 4 +
14
1 file changed, 5 insertions(+), 1 deletion(-)
24
hw/arm/virt.c | 6 +-
25
target/arm/cpu64.c | 687 +-----------------------------
26
target/arm/{ => tcg}/cpu64.c | 782 +----------------------------------
27
target/arm/tcg/meson.build | 1 +
28
5 files changed, 14 insertions(+), 1466 deletions(-)
29
copy target/arm/{ => tcg}/cpu64.c (51%)
15
30
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
31
diff --git a/target/arm/internals.h b/target/arm/internals.h
17
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
33
--- a/target/arm/internals.h
19
+++ b/target/arm/translate.c
34
+++ b/target/arm/internals.h
20
@@ -XXX,XX +XXX,XX @@ static void gen_goto_ptr(void)
35
@@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp);
21
tcg_temp_free(addr);
36
void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp);
37
void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp);
38
void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp);
39
+void aarch64_max_tcg_initfn(Object *obj);
40
+void aarch64_add_pauth_properties(Object *obj);
41
+void aarch64_add_sve_properties(Object *obj);
42
+void aarch64_add_sme_properties(Object *obj);
43
#endif
44
45
/* Read the CONTROL register as the MRS instruction would. */
46
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/hw/arm/virt.c
49
+++ b/hw/arm/virt.c
50
@@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = {
51
ARM_CPU_TYPE_NAME("cortex-a7"),
52
#endif
53
ARM_CPU_TYPE_NAME("cortex-a15"),
54
+#ifdef CONFIG_TCG
55
ARM_CPU_TYPE_NAME("cortex-a35"),
56
- ARM_CPU_TYPE_NAME("cortex-a53"),
57
ARM_CPU_TYPE_NAME("cortex-a55"),
58
- ARM_CPU_TYPE_NAME("cortex-a57"),
59
ARM_CPU_TYPE_NAME("cortex-a72"),
60
ARM_CPU_TYPE_NAME("cortex-a76"),
61
ARM_CPU_TYPE_NAME("a64fx"),
62
ARM_CPU_TYPE_NAME("neoverse-n1"),
63
+#endif
64
+ ARM_CPU_TYPE_NAME("cortex-a53"),
65
+ ARM_CPU_TYPE_NAME("cortex-a57"),
66
ARM_CPU_TYPE_NAME("host"),
67
ARM_CPU_TYPE_NAME("max"),
68
};
69
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/target/arm/cpu64.c
72
+++ b/target/arm/cpu64.c
73
@@ -XXX,XX +XXX,XX @@
74
#include "internals.h"
75
#include "cpregs.h"
76
77
-static void aarch64_a35_initfn(Object *obj)
78
-{
79
- ARMCPU *cpu = ARM_CPU(obj);
80
-
81
- cpu->dtb_compatible = "arm,cortex-a35";
82
- set_feature(&cpu->env, ARM_FEATURE_V8);
83
- set_feature(&cpu->env, ARM_FEATURE_NEON);
84
- set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
85
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
86
- set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
87
- set_feature(&cpu->env, ARM_FEATURE_EL2);
88
- set_feature(&cpu->env, ARM_FEATURE_EL3);
89
- set_feature(&cpu->env, ARM_FEATURE_PMU);
90
-
91
- /* From B2.2 AArch64 identification registers. */
92
- cpu->midr = 0x411fd040;
93
- cpu->revidr = 0;
94
- cpu->ctr = 0x84448004;
95
- cpu->isar.id_pfr0 = 0x00000131;
96
- cpu->isar.id_pfr1 = 0x00011011;
97
- cpu->isar.id_dfr0 = 0x03010066;
98
- cpu->id_afr0 = 0;
99
- cpu->isar.id_mmfr0 = 0x10201105;
100
- cpu->isar.id_mmfr1 = 0x40000000;
101
- cpu->isar.id_mmfr2 = 0x01260000;
102
- cpu->isar.id_mmfr3 = 0x02102211;
103
- cpu->isar.id_isar0 = 0x02101110;
104
- cpu->isar.id_isar1 = 0x13112111;
105
- cpu->isar.id_isar2 = 0x21232042;
106
- cpu->isar.id_isar3 = 0x01112131;
107
- cpu->isar.id_isar4 = 0x00011142;
108
- cpu->isar.id_isar5 = 0x00011121;
109
- cpu->isar.id_aa64pfr0 = 0x00002222;
110
- cpu->isar.id_aa64pfr1 = 0;
111
- cpu->isar.id_aa64dfr0 = 0x10305106;
112
- cpu->isar.id_aa64dfr1 = 0;
113
- cpu->isar.id_aa64isar0 = 0x00011120;
114
- cpu->isar.id_aa64isar1 = 0;
115
- cpu->isar.id_aa64mmfr0 = 0x00101122;
116
- cpu->isar.id_aa64mmfr1 = 0;
117
- cpu->clidr = 0x0a200023;
118
- cpu->dcz_blocksize = 4;
119
-
120
- /* From B2.4 AArch64 Virtual Memory control registers */
121
- cpu->reset_sctlr = 0x00c50838;
122
-
123
- /* From B2.10 AArch64 performance monitor registers */
124
- cpu->isar.reset_pmcr_el0 = 0x410a3000;
125
-
126
- /* From B2.29 Cache ID registers */
127
- cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */
128
- cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */
129
- cpu->ccsidr[2] = 0x703fe03a; /* 512KB L2 cache */
130
-
131
- /* From B3.5 VGIC Type register */
132
- cpu->gic_num_lrs = 4;
133
- cpu->gic_vpribits = 5;
134
- cpu->gic_vprebits = 5;
135
- cpu->gic_pribits = 5;
136
-
137
- /* From C6.4 Debug ID Register */
138
- cpu->isar.dbgdidr = 0x3516d000;
139
- /* From C6.5 Debug Device ID Register */
140
- cpu->isar.dbgdevid = 0x00110f13;
141
- /* From C6.6 Debug Device ID Register 1 */
142
- cpu->isar.dbgdevid1 = 0x2;
143
-
144
- /* From Cortex-A35 SIMD and Floating-point Support r1p0 */
145
- /* From 3.2 AArch32 register summary */
146
- cpu->reset_fpsid = 0x41034043;
147
-
148
- /* From 2.2 AArch64 register summary */
149
- cpu->isar.mvfr0 = 0x10110222;
150
- cpu->isar.mvfr1 = 0x12111111;
151
- cpu->isar.mvfr2 = 0x00000043;
152
-
153
- /* These values are the same with A53/A57/A72. */
154
- define_cortex_a72_a57_a53_cp_reginfo(cpu);
155
-}
156
-
157
void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
158
{
159
/*
160
@@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
161
cpu->sve_vq.map = vq_map;
22
}
162
}
23
163
24
+/* This will end the TB but doesn't guarantee we'll return to
164
-static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name,
25
+ * cpu_loop_exec. Any live exit_requests will be processed as we
165
- void *opaque, Error **errp)
26
+ * enter the next TB.
166
-{
27
+ */
167
- ARMCPU *cpu = ARM_CPU(obj);
28
static void gen_goto_tb(DisasContext *s, int n, target_ulong dest)
168
- uint32_t value;
169
-
170
- /* All vector lengths are disabled when SVE is off. */
171
- if (!cpu_isar_feature(aa64_sve, cpu)) {
172
- value = 0;
173
- } else {
174
- value = cpu->sve_max_vq;
175
- }
176
- visit_type_uint32(v, name, &value, errp);
177
-}
178
-
179
-static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name,
180
- void *opaque, Error **errp)
181
-{
182
- ARMCPU *cpu = ARM_CPU(obj);
183
- uint32_t max_vq;
184
-
185
- if (!visit_type_uint32(v, name, &max_vq, errp)) {
186
- return;
187
- }
188
-
189
- if (max_vq == 0 || max_vq > ARM_MAX_VQ) {
190
- error_setg(errp, "unsupported SVE vector length");
191
- error_append_hint(errp, "Valid sve-max-vq in range [1-%d]\n",
192
- ARM_MAX_VQ);
193
- return;
194
- }
195
-
196
- cpu->sve_max_vq = max_vq;
197
-}
198
-
199
/*
200
* Note that cpu_arm_{get,set}_vq cannot use the simpler
201
* object_property_add_bool interface because they make use of the
202
@@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_default_vec_len(Object *obj, Visitor *v,
203
}
204
#endif
205
206
-static void aarch64_add_sve_properties(Object *obj)
207
+void aarch64_add_sve_properties(Object *obj)
29
{
208
{
30
if (use_goto_tb(s, dest)) {
209
ARMCPU *cpu = ARM_CPU(obj);
31
@@ -XXX,XX +XXX,XX @@ static void gen_goto_tb(DisasContext *s, int n, target_ulong dest)
210
uint32_t vq;
32
gen_set_pc_im(s, dest);
211
@@ -XXX,XX +XXX,XX @@ static void aarch64_add_sve_properties(Object *obj)
33
gen_goto_ptr();
212
#endif
34
}
35
+ s->is_jmp = DISAS_TB_JUMP;
36
}
213
}
37
214
38
static inline void gen_jmp (DisasContext *s, uint32_t dest)
215
-static void aarch64_add_sme_properties(Object *obj)
39
@@ -XXX,XX +XXX,XX @@ static inline void gen_jmp (DisasContext *s, uint32_t dest)
216
+void aarch64_add_sme_properties(Object *obj)
40
gen_bx_im(s, dest);
217
{
41
} else {
218
ARMCPU *cpu = ARM_CPU(obj);
42
gen_goto_tb(s, 0, dest);
219
uint32_t vq;
43
- s->is_jmp = DISAS_TB_JUMP;
220
@@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pauth_property =
221
static Property arm_cpu_pauth_impdef_property =
222
DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
223
224
-static void aarch64_add_pauth_properties(Object *obj)
225
+void aarch64_add_pauth_properties(Object *obj)
226
{
227
ARMCPU *cpu = ARM_CPU(obj);
228
229
@@ -XXX,XX +XXX,XX @@ static void aarch64_add_pauth_properties(Object *obj)
44
}
230
}
45
}
231
}
46
232
233
-static Property arm_cpu_lpa2_property =
234
- DEFINE_PROP_BOOL("lpa2", ARMCPU, prop_lpa2, true);
235
-
236
void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp)
237
{
238
uint64_t t;
239
@@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj)
240
define_cortex_a72_a57_a53_cp_reginfo(cpu);
241
}
242
243
-static void aarch64_a55_initfn(Object *obj)
244
-{
245
- ARMCPU *cpu = ARM_CPU(obj);
246
-
247
- cpu->dtb_compatible = "arm,cortex-a55";
248
- set_feature(&cpu->env, ARM_FEATURE_V8);
249
- set_feature(&cpu->env, ARM_FEATURE_NEON);
250
- set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
251
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
252
- set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
253
- set_feature(&cpu->env, ARM_FEATURE_EL2);
254
- set_feature(&cpu->env, ARM_FEATURE_EL3);
255
- set_feature(&cpu->env, ARM_FEATURE_PMU);
256
-
257
- /* Ordered by B2.4 AArch64 registers by functional group */
258
- cpu->clidr = 0x82000023;
259
- cpu->ctr = 0x84448004; /* L1Ip = VIPT */
260
- cpu->dcz_blocksize = 4; /* 64 bytes */
261
- cpu->isar.id_aa64dfr0 = 0x0000000010305408ull;
262
- cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
263
- cpu->isar.id_aa64isar1 = 0x0000000000100001ull;
264
- cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull;
265
- cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull;
266
- cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull;
267
- cpu->isar.id_aa64pfr0 = 0x0000000010112222ull;
268
- cpu->isar.id_aa64pfr1 = 0x0000000000000010ull;
269
- cpu->id_afr0 = 0x00000000;
270
- cpu->isar.id_dfr0 = 0x04010088;
271
- cpu->isar.id_isar0 = 0x02101110;
272
- cpu->isar.id_isar1 = 0x13112111;
273
- cpu->isar.id_isar2 = 0x21232042;
274
- cpu->isar.id_isar3 = 0x01112131;
275
- cpu->isar.id_isar4 = 0x00011142;
276
- cpu->isar.id_isar5 = 0x01011121;
277
- cpu->isar.id_isar6 = 0x00000010;
278
- cpu->isar.id_mmfr0 = 0x10201105;
279
- cpu->isar.id_mmfr1 = 0x40000000;
280
- cpu->isar.id_mmfr2 = 0x01260000;
281
- cpu->isar.id_mmfr3 = 0x02122211;
282
- cpu->isar.id_mmfr4 = 0x00021110;
283
- cpu->isar.id_pfr0 = 0x10010131;
284
- cpu->isar.id_pfr1 = 0x00011011;
285
- cpu->isar.id_pfr2 = 0x00000011;
286
- cpu->midr = 0x412FD050; /* r2p0 */
287
- cpu->revidr = 0;
288
-
289
- /* From B2.23 CCSIDR_EL1 */
290
- cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */
291
- cpu->ccsidr[1] = 0x200fe01a; /* 32KB L1 icache */
292
- cpu->ccsidr[2] = 0x703fe07a; /* 512KB L2 cache */
293
-
294
- /* From B2.96 SCTLR_EL3 */
295
- cpu->reset_sctlr = 0x30c50838;
296
-
297
- /* From B4.45 ICH_VTR_EL2 */
298
- cpu->gic_num_lrs = 4;
299
- cpu->gic_vpribits = 5;
300
- cpu->gic_vprebits = 5;
301
- cpu->gic_pribits = 5;
302
-
303
- cpu->isar.mvfr0 = 0x10110222;
304
- cpu->isar.mvfr1 = 0x13211111;
305
- cpu->isar.mvfr2 = 0x00000043;
306
-
307
- /* From D5.4 AArch64 PMU register summary */
308
- cpu->isar.reset_pmcr_el0 = 0x410b3000;
309
-}
310
-
311
-static void aarch64_a72_initfn(Object *obj)
312
-{
313
- ARMCPU *cpu = ARM_CPU(obj);
314
-
315
- cpu->dtb_compatible = "arm,cortex-a72";
316
- set_feature(&cpu->env, ARM_FEATURE_V8);
317
- set_feature(&cpu->env, ARM_FEATURE_NEON);
318
- set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
319
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
320
- set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
321
- set_feature(&cpu->env, ARM_FEATURE_EL2);
322
- set_feature(&cpu->env, ARM_FEATURE_EL3);
323
- set_feature(&cpu->env, ARM_FEATURE_PMU);
324
- cpu->midr = 0x410fd083;
325
- cpu->revidr = 0x00000000;
326
- cpu->reset_fpsid = 0x41034080;
327
- cpu->isar.mvfr0 = 0x10110222;
328
- cpu->isar.mvfr1 = 0x12111111;
329
- cpu->isar.mvfr2 = 0x00000043;
330
- cpu->ctr = 0x8444c004;
331
- cpu->reset_sctlr = 0x00c50838;
332
- cpu->isar.id_pfr0 = 0x00000131;
333
- cpu->isar.id_pfr1 = 0x00011011;
334
- cpu->isar.id_dfr0 = 0x03010066;
335
- cpu->id_afr0 = 0x00000000;
336
- cpu->isar.id_mmfr0 = 0x10201105;
337
- cpu->isar.id_mmfr1 = 0x40000000;
338
- cpu->isar.id_mmfr2 = 0x01260000;
339
- cpu->isar.id_mmfr3 = 0x02102211;
340
- cpu->isar.id_isar0 = 0x02101110;
341
- cpu->isar.id_isar1 = 0x13112111;
342
- cpu->isar.id_isar2 = 0x21232042;
343
- cpu->isar.id_isar3 = 0x01112131;
344
- cpu->isar.id_isar4 = 0x00011142;
345
- cpu->isar.id_isar5 = 0x00011121;
346
- cpu->isar.id_aa64pfr0 = 0x00002222;
347
- cpu->isar.id_aa64dfr0 = 0x10305106;
348
- cpu->isar.id_aa64isar0 = 0x00011120;
349
- cpu->isar.id_aa64mmfr0 = 0x00001124;
350
- cpu->isar.dbgdidr = 0x3516d000;
351
- cpu->isar.dbgdevid = 0x01110f13;
352
- cpu->isar.dbgdevid1 = 0x2;
353
- cpu->isar.reset_pmcr_el0 = 0x41023000;
354
- cpu->clidr = 0x0a200023;
355
- cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */
356
- cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */
357
- cpu->ccsidr[2] = 0x707fe07a; /* 1MB L2 cache */
358
- cpu->dcz_blocksize = 4; /* 64 bytes */
359
- cpu->gic_num_lrs = 4;
360
- cpu->gic_vpribits = 5;
361
- cpu->gic_vprebits = 5;
362
- cpu->gic_pribits = 5;
363
- define_cortex_a72_a57_a53_cp_reginfo(cpu);
364
-}
365
-
366
-static void aarch64_a76_initfn(Object *obj)
367
-{
368
- ARMCPU *cpu = ARM_CPU(obj);
369
-
370
- cpu->dtb_compatible = "arm,cortex-a76";
371
- set_feature(&cpu->env, ARM_FEATURE_V8);
372
- set_feature(&cpu->env, ARM_FEATURE_NEON);
373
- set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
374
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
375
- set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
376
- set_feature(&cpu->env, ARM_FEATURE_EL2);
377
- set_feature(&cpu->env, ARM_FEATURE_EL3);
378
- set_feature(&cpu->env, ARM_FEATURE_PMU);
379
-
380
- /* Ordered by B2.4 AArch64 registers by functional group */
381
- cpu->clidr = 0x82000023;
382
- cpu->ctr = 0x8444C004;
383
- cpu->dcz_blocksize = 4;
384
- cpu->isar.id_aa64dfr0 = 0x0000000010305408ull;
385
- cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
386
- cpu->isar.id_aa64isar1 = 0x0000000000100001ull;
387
- cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull;
388
- cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull;
389
- cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull;
390
- cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */
391
- cpu->isar.id_aa64pfr1 = 0x0000000000000010ull;
392
- cpu->id_afr0 = 0x00000000;
393
- cpu->isar.id_dfr0 = 0x04010088;
394
- cpu->isar.id_isar0 = 0x02101110;
395
- cpu->isar.id_isar1 = 0x13112111;
396
- cpu->isar.id_isar2 = 0x21232042;
397
- cpu->isar.id_isar3 = 0x01112131;
398
- cpu->isar.id_isar4 = 0x00010142;
399
- cpu->isar.id_isar5 = 0x01011121;
400
- cpu->isar.id_isar6 = 0x00000010;
401
- cpu->isar.id_mmfr0 = 0x10201105;
402
- cpu->isar.id_mmfr1 = 0x40000000;
403
- cpu->isar.id_mmfr2 = 0x01260000;
404
- cpu->isar.id_mmfr3 = 0x02122211;
405
- cpu->isar.id_mmfr4 = 0x00021110;
406
- cpu->isar.id_pfr0 = 0x10010131;
407
- cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */
408
- cpu->isar.id_pfr2 = 0x00000011;
409
- cpu->midr = 0x414fd0b1; /* r4p1 */
410
- cpu->revidr = 0;
411
-
412
- /* From B2.18 CCSIDR_EL1 */
413
- cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */
414
- cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */
415
- cpu->ccsidr[2] = 0x707fe03a; /* 512KB L2 cache */
416
-
417
- /* From B2.93 SCTLR_EL3 */
418
- cpu->reset_sctlr = 0x30c50838;
419
-
420
- /* From B4.23 ICH_VTR_EL2 */
421
- cpu->gic_num_lrs = 4;
422
- cpu->gic_vpribits = 5;
423
- cpu->gic_vprebits = 5;
424
- cpu->gic_pribits = 5;
425
-
426
- /* From B5.1 AdvSIMD AArch64 register summary */
427
- cpu->isar.mvfr0 = 0x10110222;
428
- cpu->isar.mvfr1 = 0x13211111;
429
- cpu->isar.mvfr2 = 0x00000043;
430
-
431
- /* From D5.1 AArch64 PMU register summary */
432
- cpu->isar.reset_pmcr_el0 = 0x410b3000;
433
-}
434
-
435
-static void aarch64_a64fx_initfn(Object *obj)
436
-{
437
- ARMCPU *cpu = ARM_CPU(obj);
438
-
439
- cpu->dtb_compatible = "arm,a64fx";
440
- set_feature(&cpu->env, ARM_FEATURE_V8);
441
- set_feature(&cpu->env, ARM_FEATURE_NEON);
442
- set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
443
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
444
- set_feature(&cpu->env, ARM_FEATURE_EL2);
445
- set_feature(&cpu->env, ARM_FEATURE_EL3);
446
- set_feature(&cpu->env, ARM_FEATURE_PMU);
447
- cpu->midr = 0x461f0010;
448
- cpu->revidr = 0x00000000;
449
- cpu->ctr = 0x86668006;
450
- cpu->reset_sctlr = 0x30000180;
451
- cpu->isar.id_aa64pfr0 = 0x0000000101111111; /* No RAS Extensions */
452
- cpu->isar.id_aa64pfr1 = 0x0000000000000000;
453
- cpu->isar.id_aa64dfr0 = 0x0000000010305408;
454
- cpu->isar.id_aa64dfr1 = 0x0000000000000000;
455
- cpu->id_aa64afr0 = 0x0000000000000000;
456
- cpu->id_aa64afr1 = 0x0000000000000000;
457
- cpu->isar.id_aa64mmfr0 = 0x0000000000001122;
458
- cpu->isar.id_aa64mmfr1 = 0x0000000011212100;
459
- cpu->isar.id_aa64mmfr2 = 0x0000000000001011;
460
- cpu->isar.id_aa64isar0 = 0x0000000010211120;
461
- cpu->isar.id_aa64isar1 = 0x0000000000010001;
462
- cpu->isar.id_aa64zfr0 = 0x0000000000000000;
463
- cpu->clidr = 0x0000000080000023;
464
- cpu->ccsidr[0] = 0x7007e01c; /* 64KB L1 dcache */
465
- cpu->ccsidr[1] = 0x2007e01c; /* 64KB L1 icache */
466
- cpu->ccsidr[2] = 0x70ffe07c; /* 8MB L2 cache */
467
- cpu->dcz_blocksize = 6; /* 256 bytes */
468
- cpu->gic_num_lrs = 4;
469
- cpu->gic_vpribits = 5;
470
- cpu->gic_vprebits = 5;
471
- cpu->gic_pribits = 5;
472
-
473
- /* The A64FX supports only 128, 256 and 512 bit vector lengths */
474
- aarch64_add_sve_properties(obj);
475
- cpu->sve_vq.supported = (1 << 0) /* 128bit */
476
- | (1 << 1) /* 256bit */
477
- | (1 << 3); /* 512bit */
478
-
479
- cpu->isar.reset_pmcr_el0 = 0x46014040;
480
-
481
- /* TODO: Add A64FX specific HPC extension registers */
482
-}
483
-
484
-static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = {
485
- { .name = "ATCR_EL1", .state = ARM_CP_STATE_AA64,
486
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 7, .opc2 = 0,
487
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
488
- { .name = "ATCR_EL2", .state = ARM_CP_STATE_AA64,
489
- .opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 0,
490
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
491
- { .name = "ATCR_EL3", .state = ARM_CP_STATE_AA64,
492
- .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 7, .opc2 = 0,
493
- .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
494
- { .name = "ATCR_EL12", .state = ARM_CP_STATE_AA64,
495
- .opc0 = 3, .opc1 = 5, .crn = 15, .crm = 7, .opc2 = 0,
496
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
497
- { .name = "AVTCR_EL2", .state = ARM_CP_STATE_AA64,
498
- .opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 1,
499
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
500
- { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64,
501
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 0,
502
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
503
- { .name = "CPUACTLR2_EL1", .state = ARM_CP_STATE_AA64,
504
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 1,
505
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
506
- { .name = "CPUACTLR3_EL1", .state = ARM_CP_STATE_AA64,
507
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 2,
508
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
509
- /*
510
- * Report CPUCFR_EL1.SCU as 1, as we do not implement the DSU
511
- * (and in particular its system registers).
512
- */
513
- { .name = "CPUCFR_EL1", .state = ARM_CP_STATE_AA64,
514
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 0,
515
- .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 4 },
516
- { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64,
517
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 4,
518
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010 },
519
- { .name = "CPUPCR_EL3", .state = ARM_CP_STATE_AA64,
520
- .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 1,
521
- .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
522
- { .name = "CPUPMR_EL3", .state = ARM_CP_STATE_AA64,
523
- .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 3,
524
- .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
525
- { .name = "CPUPOR_EL3", .state = ARM_CP_STATE_AA64,
526
- .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 2,
527
- .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
528
- { .name = "CPUPSELR_EL3", .state = ARM_CP_STATE_AA64,
529
- .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 0,
530
- .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
531
- { .name = "CPUPWRCTLR_EL1", .state = ARM_CP_STATE_AA64,
532
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7,
533
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
534
- { .name = "ERXPFGCDN_EL1", .state = ARM_CP_STATE_AA64,
535
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 2,
536
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
537
- { .name = "ERXPFGCTL_EL1", .state = ARM_CP_STATE_AA64,
538
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 1,
539
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
540
- { .name = "ERXPFGF_EL1", .state = ARM_CP_STATE_AA64,
541
- .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0,
542
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
543
-};
544
-
545
-static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu)
546
-{
547
- define_arm_cp_regs(cpu, neoverse_n1_cp_reginfo);
548
-}
549
-
550
-static void aarch64_neoverse_n1_initfn(Object *obj)
551
-{
552
- ARMCPU *cpu = ARM_CPU(obj);
553
-
554
- cpu->dtb_compatible = "arm,neoverse-n1";
555
- set_feature(&cpu->env, ARM_FEATURE_V8);
556
- set_feature(&cpu->env, ARM_FEATURE_NEON);
557
- set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
558
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
559
- set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
560
- set_feature(&cpu->env, ARM_FEATURE_EL2);
561
- set_feature(&cpu->env, ARM_FEATURE_EL3);
562
- set_feature(&cpu->env, ARM_FEATURE_PMU);
563
-
564
- /* Ordered by B2.4 AArch64 registers by functional group */
565
- cpu->clidr = 0x82000023;
566
- cpu->ctr = 0x8444c004;
567
- cpu->dcz_blocksize = 4;
568
- cpu->isar.id_aa64dfr0 = 0x0000000110305408ull;
569
- cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
570
- cpu->isar.id_aa64isar1 = 0x0000000000100001ull;
571
- cpu->isar.id_aa64mmfr0 = 0x0000000000101125ull;
572
- cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull;
573
- cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull;
574
- cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */
575
- cpu->isar.id_aa64pfr1 = 0x0000000000000020ull;
576
- cpu->id_afr0 = 0x00000000;
577
- cpu->isar.id_dfr0 = 0x04010088;
578
- cpu->isar.id_isar0 = 0x02101110;
579
- cpu->isar.id_isar1 = 0x13112111;
580
- cpu->isar.id_isar2 = 0x21232042;
581
- cpu->isar.id_isar3 = 0x01112131;
582
- cpu->isar.id_isar4 = 0x00010142;
583
- cpu->isar.id_isar5 = 0x01011121;
584
- cpu->isar.id_isar6 = 0x00000010;
585
- cpu->isar.id_mmfr0 = 0x10201105;
586
- cpu->isar.id_mmfr1 = 0x40000000;
587
- cpu->isar.id_mmfr2 = 0x01260000;
588
- cpu->isar.id_mmfr3 = 0x02122211;
589
- cpu->isar.id_mmfr4 = 0x00021110;
590
- cpu->isar.id_pfr0 = 0x10010131;
591
- cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */
592
- cpu->isar.id_pfr2 = 0x00000011;
593
- cpu->midr = 0x414fd0c1; /* r4p1 */
594
- cpu->revidr = 0;
595
-
596
- /* From B2.23 CCSIDR_EL1 */
597
- cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */
598
- cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */
599
- cpu->ccsidr[2] = 0x70ffe03a; /* 1MB L2 cache */
600
-
601
- /* From B2.98 SCTLR_EL3 */
602
- cpu->reset_sctlr = 0x30c50838;
603
-
604
- /* From B4.23 ICH_VTR_EL2 */
605
- cpu->gic_num_lrs = 4;
606
- cpu->gic_vpribits = 5;
607
- cpu->gic_vprebits = 5;
608
- cpu->gic_pribits = 5;
609
-
610
- /* From B5.1 AdvSIMD AArch64 register summary */
611
- cpu->isar.mvfr0 = 0x10110222;
612
- cpu->isar.mvfr1 = 0x13211111;
613
- cpu->isar.mvfr2 = 0x00000043;
614
-
615
- /* From D5.1 AArch64 PMU register summary */
616
- cpu->isar.reset_pmcr_el0 = 0x410c3000;
617
-
618
- define_neoverse_n1_cp_reginfo(cpu);
619
-}
620
-
621
static void aarch64_host_initfn(Object *obj)
622
{
623
#if defined(CONFIG_KVM)
624
@@ -XXX,XX +XXX,XX @@ static void aarch64_host_initfn(Object *obj)
625
#endif
626
}
627
628
-/*
629
- * -cpu max: a CPU with as many features enabled as our emulation supports.
630
- * The version of '-cpu max' for qemu-system-arm is defined in cpu_tcg.c;
631
- * this only needs to handle 64 bits.
632
- */
633
-static void aarch64_max_tcg_initfn(Object *obj)
634
-{
635
- ARMCPU *cpu = ARM_CPU(obj);
636
- uint64_t t;
637
- uint32_t u;
638
-
639
- /*
640
- * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real
641
- * one and try to apply errata workarounds or use impdef features we
642
- * don't provide.
643
- * An IMPLEMENTER field of 0 means "reserved for software use";
644
- * ARCHITECTURE must be 0xf indicating "v7 or later, check ID registers
645
- * to see which features are present";
646
- * the VARIANT, PARTNUM and REVISION fields are all implementation
647
- * defined and we choose to define PARTNUM just in case guest
648
- * code needs to distinguish this QEMU CPU from other software
649
- * implementations, though this shouldn't be needed.
650
- */
651
- t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0);
652
- t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf);
653
- t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q');
654
- t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0);
655
- t = FIELD_DP64(t, MIDR_EL1, REVISION, 0);
656
- cpu->midr = t;
657
-
658
- /*
659
- * We're going to set FEAT_S2FWB, which mandates that CLIDR_EL1.{LoUU,LoUIS}
660
- * are zero.
661
- */
662
- u = cpu->clidr;
663
- u = FIELD_DP32(u, CLIDR_EL1, LOUIS, 0);
664
- u = FIELD_DP32(u, CLIDR_EL1, LOUU, 0);
665
- cpu->clidr = u;
666
-
667
- t = cpu->isar.id_aa64isar0;
668
- t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */
669
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */
670
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */
671
- t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);
672
- t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */
673
- t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */
674
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */
675
- t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); /* FEAT_SM3 */
676
- t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); /* FEAT_SM4 */
677
- t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); /* FEAT_DotProd */
678
- t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); /* FEAT_FHM */
679
- t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* FEAT_FlagM2 */
680
- t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */
681
- t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); /* FEAT_RNG */
682
- cpu->isar.id_aa64isar0 = t;
683
-
684
- t = cpu->isar.id_aa64isar1;
685
- t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */
686
- t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */
687
- t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); /* FEAT_FCMA */
688
- t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* FEAT_LRCPC2 */
689
- t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); /* FEAT_FRINTTS */
690
- t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */
691
- t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */
692
- t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */
693
- t = FIELD_DP64(t, ID_AA64ISAR1, DGH, 1); /* FEAT_DGH */
694
- t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */
695
- cpu->isar.id_aa64isar1 = t;
696
-
697
- t = cpu->isar.id_aa64pfr0;
698
- t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */
699
- t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */
700
- t = FIELD_DP64(t, ID_AA64PFR0, RAS, 2); /* FEAT_RASv1p1 + FEAT_DoubleFault */
701
- t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
702
- t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */
703
- t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */
704
- t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */
705
- t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */
706
- cpu->isar.id_aa64pfr0 = t;
707
-
708
- t = cpu->isar.id_aa64pfr1;
709
- t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); /* FEAT_BTI */
710
- t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); /* FEAT_SSBS2 */
711
- /*
712
- * Begin with full support for MTE. This will be downgraded to MTE=0
713
- * during realize if the board provides no tag memory, much like
714
- * we do for EL2 with the virtualization=on property.
715
- */
716
- t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */
717
- t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */
718
- t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */
719
- t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */
720
- cpu->isar.id_aa64pfr1 = t;
721
-
722
- t = cpu->isar.id_aa64mmfr0;
723
- t = FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 6); /* FEAT_LPA: 52 bits */
724
- t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16, 1); /* 16k pages supported */
725
- t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 2); /* 16k stage2 supported */
726
- t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 supported */
727
- t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 supported */
728
- t = FIELD_DP64(t, ID_AA64MMFR0, FGT, 1); /* FEAT_FGT */
729
- cpu->isar.id_aa64mmfr0 = t;
730
-
731
- t = cpu->isar.id_aa64mmfr1;
732
- t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */
733
- t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */
734
- t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */
735
- t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */
736
- t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */
737
- t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 3); /* FEAT_PAN3 */
738
- t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */
739
- t = FIELD_DP64(t, ID_AA64MMFR1, ETS, 1); /* FEAT_ETS */
740
- t = FIELD_DP64(t, ID_AA64MMFR1, HCX, 1); /* FEAT_HCX */
741
- cpu->isar.id_aa64mmfr1 = t;
742
-
743
- t = cpu->isar.id_aa64mmfr2;
744
- t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */
745
- t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */
746
- t = FIELD_DP64(t, ID_AA64MMFR2, IESB, 1); /* FEAT_IESB */
747
- t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */
748
- t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */
749
- t = FIELD_DP64(t, ID_AA64MMFR2, IDS, 1); /* FEAT_IDST */
750
- t = FIELD_DP64(t, ID_AA64MMFR2, FWB, 1); /* FEAT_S2FWB */
751
- t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */
752
- t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */
753
- t = FIELD_DP64(t, ID_AA64MMFR2, EVT, 2); /* FEAT_EVT */
754
- t = FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */
755
- cpu->isar.id_aa64mmfr2 = t;
756
-
757
- t = cpu->isar.id_aa64zfr0;
758
- t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1);
759
- t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* FEAT_SVE_PMULL128 */
760
- t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); /* FEAT_SVE_BitPerm */
761
- t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); /* FEAT_BF16 */
762
- t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); /* FEAT_SVE_SHA3 */
763
- t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); /* FEAT_SVE_SM4 */
764
- t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); /* FEAT_I8MM */
765
- t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); /* FEAT_F32MM */
766
- t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); /* FEAT_F64MM */
767
- cpu->isar.id_aa64zfr0 = t;
768
-
769
- t = cpu->isar.id_aa64dfr0;
770
- t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */
771
- t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */
772
- cpu->isar.id_aa64dfr0 = t;
773
-
774
- t = cpu->isar.id_aa64smfr0;
775
- t = FIELD_DP64(t, ID_AA64SMFR0, F32F32, 1); /* FEAT_SME */
776
- t = FIELD_DP64(t, ID_AA64SMFR0, B16F32, 1); /* FEAT_SME */
777
- t = FIELD_DP64(t, ID_AA64SMFR0, F16F32, 1); /* FEAT_SME */
778
- t = FIELD_DP64(t, ID_AA64SMFR0, I8I32, 0xf); /* FEAT_SME */
779
- t = FIELD_DP64(t, ID_AA64SMFR0, F64F64, 1); /* FEAT_SME_F64F64 */
780
- t = FIELD_DP64(t, ID_AA64SMFR0, I16I64, 0xf); /* FEAT_SME_I16I64 */
781
- t = FIELD_DP64(t, ID_AA64SMFR0, FA64, 1); /* FEAT_SME_FA64 */
782
- cpu->isar.id_aa64smfr0 = t;
783
-
784
- /* Replicate the same data to the 32-bit id registers. */
785
- aa32_max_features(cpu);
786
-
787
-#ifdef CONFIG_USER_ONLY
788
- /*
789
- * For usermode -cpu max we can use a larger and more efficient DCZ
790
- * blocksize since we don't have to follow what the hardware does.
791
- */
792
- cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */
793
- cpu->dcz_blocksize = 7; /* 512 bytes */
794
-#endif
795
-
796
- cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ);
797
- cpu->sme_vq.supported = SVE_VQ_POW2_MAP;
798
-
799
- aarch64_add_pauth_properties(obj);
800
- aarch64_add_sve_properties(obj);
801
- aarch64_add_sme_properties(obj);
802
- object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq,
803
- cpu_max_set_sve_max_vq, NULL, NULL);
804
- qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property);
805
-}
806
-
807
static void aarch64_max_initfn(Object *obj)
808
{
809
if (kvm_enabled() || hvf_enabled()) {
810
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
811
}
812
813
static const ARMCPUInfo aarch64_cpus[] = {
814
- { .name = "cortex-a35", .initfn = aarch64_a35_initfn },
815
{ .name = "cortex-a57", .initfn = aarch64_a57_initfn },
816
{ .name = "cortex-a53", .initfn = aarch64_a53_initfn },
817
- { .name = "cortex-a55", .initfn = aarch64_a55_initfn },
818
- { .name = "cortex-a72", .initfn = aarch64_a72_initfn },
819
- { .name = "cortex-a76", .initfn = aarch64_a76_initfn },
820
- { .name = "a64fx", .initfn = aarch64_a64fx_initfn },
821
- { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn },
822
{ .name = "max", .initfn = aarch64_max_initfn },
823
#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
824
{ .name = "host", .initfn = aarch64_host_initfn },
825
diff --git a/target/arm/cpu64.c b/target/arm/tcg/cpu64.c
826
similarity index 51%
827
copy from target/arm/cpu64.c
828
copy to target/arm/tcg/cpu64.c
829
index XXXXXXX..XXXXXXX 100644
830
--- a/target/arm/cpu64.c
831
+++ b/target/arm/tcg/cpu64.c
832
@@ -XXX,XX +XXX,XX @@
833
/*
834
- * QEMU AArch64 CPU
835
+ * QEMU AArch64 TCG CPUs
836
*
837
* Copyright (c) 2013 Linaro Ltd
838
*
839
@@ -XXX,XX +XXX,XX @@
840
#include "qemu/osdep.h"
841
#include "qapi/error.h"
842
#include "cpu.h"
843
-#include "cpregs.h"
844
#include "qemu/module.h"
845
-#include "sysemu/kvm.h"
846
-#include "sysemu/hvf.h"
847
-#include "sysemu/qtest.h"
848
-#include "sysemu/tcg.h"
849
-#include "kvm_arm.h"
850
-#include "hvf_arm.h"
851
#include "qapi/visitor.h"
852
#include "hw/qdev-properties.h"
853
#include "internals.h"
854
@@ -XXX,XX +XXX,XX @@ static void aarch64_a35_initfn(Object *obj)
855
define_cortex_a72_a57_a53_cp_reginfo(cpu);
856
}
857
858
-void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
859
-{
860
- /*
861
- * If any vector lengths are explicitly enabled with sve<N> properties,
862
- * then all other lengths are implicitly disabled. If sve-max-vq is
863
- * specified then it is the same as explicitly enabling all lengths
864
- * up to and including the specified maximum, which means all larger
865
- * lengths will be implicitly disabled. If no sve<N> properties
866
- * are enabled and sve-max-vq is not specified, then all lengths not
867
- * explicitly disabled will be enabled. Additionally, all power-of-two
868
- * vector lengths less than the maximum enabled length will be
869
- * automatically enabled and all vector lengths larger than the largest
870
- * disabled power-of-two vector length will be automatically disabled.
871
- * Errors are generated if the user provided input that interferes with
872
- * any of the above. Finally, if SVE is not disabled, then at least one
873
- * vector length must be enabled.
874
- */
875
- uint32_t vq_map = cpu->sve_vq.map;
876
- uint32_t vq_init = cpu->sve_vq.init;
877
- uint32_t vq_supported;
878
- uint32_t vq_mask = 0;
879
- uint32_t tmp, vq, max_vq = 0;
880
-
881
- /*
882
- * CPU models specify a set of supported vector lengths which are
883
- * enabled by default. Attempting to enable any vector length not set
884
- * in the supported bitmap results in an error. When KVM is enabled we
885
- * fetch the supported bitmap from the host.
886
- */
887
- if (kvm_enabled()) {
888
- if (kvm_arm_sve_supported()) {
889
- cpu->sve_vq.supported = kvm_arm_sve_get_vls(CPU(cpu));
890
- vq_supported = cpu->sve_vq.supported;
891
- } else {
892
- assert(!cpu_isar_feature(aa64_sve, cpu));
893
- vq_supported = 0;
894
- }
895
- } else {
896
- vq_supported = cpu->sve_vq.supported;
897
- }
898
-
899
- /*
900
- * Process explicit sve<N> properties.
901
- * From the properties, sve_vq_map<N> implies sve_vq_init<N>.
902
- * Check first for any sve<N> enabled.
903
- */
904
- if (vq_map != 0) {
905
- max_vq = 32 - clz32(vq_map);
906
- vq_mask = MAKE_64BIT_MASK(0, max_vq);
907
-
908
- if (cpu->sve_max_vq && max_vq > cpu->sve_max_vq) {
909
- error_setg(errp, "cannot enable sve%d", max_vq * 128);
910
- error_append_hint(errp, "sve%d is larger than the maximum vector "
911
- "length, sve-max-vq=%d (%d bits)\n",
912
- max_vq * 128, cpu->sve_max_vq,
913
- cpu->sve_max_vq * 128);
914
- return;
915
- }
916
-
917
- if (kvm_enabled()) {
918
- /*
919
- * For KVM we have to automatically enable all supported unitialized
920
- * lengths, even when the smaller lengths are not all powers-of-two.
921
- */
922
- vq_map |= vq_supported & ~vq_init & vq_mask;
923
- } else {
924
- /* Propagate enabled bits down through required powers-of-two. */
925
- vq_map |= SVE_VQ_POW2_MAP & ~vq_init & vq_mask;
926
- }
927
- } else if (cpu->sve_max_vq == 0) {
928
- /*
929
- * No explicit bits enabled, and no implicit bits from sve-max-vq.
930
- */
931
- if (!cpu_isar_feature(aa64_sve, cpu)) {
932
- /* SVE is disabled and so are all vector lengths. Good. */
933
- return;
934
- }
935
-
936
- if (kvm_enabled()) {
937
- /* Disabling a supported length disables all larger lengths. */
938
- tmp = vq_init & vq_supported;
939
- } else {
940
- /* Disabling a power-of-two disables all larger lengths. */
941
- tmp = vq_init & SVE_VQ_POW2_MAP;
942
- }
943
- vq = ctz32(tmp) + 1;
944
-
945
- max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ;
946
- vq_mask = MAKE_64BIT_MASK(0, max_vq);
947
- vq_map = vq_supported & ~vq_init & vq_mask;
948
-
949
- if (max_vq == 0 || vq_map == 0) {
950
- error_setg(errp, "cannot disable sve%d", vq * 128);
951
- error_append_hint(errp, "Disabling sve%d results in all "
952
- "vector lengths being disabled.\n",
953
- vq * 128);
954
- error_append_hint(errp, "With SVE enabled, at least one "
955
- "vector length must be enabled.\n");
956
- return;
957
- }
958
-
959
- max_vq = 32 - clz32(vq_map);
960
- vq_mask = MAKE_64BIT_MASK(0, max_vq);
961
- }
962
-
963
- /*
964
- * Process the sve-max-vq property.
965
- * Note that we know from the above that no bit above
966
- * sve-max-vq is currently set.
967
- */
968
- if (cpu->sve_max_vq != 0) {
969
- max_vq = cpu->sve_max_vq;
970
- vq_mask = MAKE_64BIT_MASK(0, max_vq);
971
-
972
- if (vq_init & ~vq_map & (1 << (max_vq - 1))) {
973
- error_setg(errp, "cannot disable sve%d", max_vq * 128);
974
- error_append_hint(errp, "The maximum vector length must be "
975
- "enabled, sve-max-vq=%d (%d bits)\n",
976
- max_vq, max_vq * 128);
977
- return;
978
- }
979
-
980
- /* Set all bits not explicitly set within sve-max-vq. */
981
- vq_map |= ~vq_init & vq_mask;
982
- }
983
-
984
- /*
985
- * We should know what max-vq is now. Also, as we're done
986
- * manipulating sve-vq-map, we ensure any bits above max-vq
987
- * are clear, just in case anybody looks.
988
- */
989
- assert(max_vq != 0);
990
- assert(vq_mask != 0);
991
- vq_map &= vq_mask;
992
-
993
- /* Ensure the set of lengths matches what is supported. */
994
- tmp = vq_map ^ (vq_supported & vq_mask);
995
- if (tmp) {
996
- vq = 32 - clz32(tmp);
997
- if (vq_map & (1 << (vq - 1))) {
998
- if (cpu->sve_max_vq) {
999
- error_setg(errp, "cannot set sve-max-vq=%d", cpu->sve_max_vq);
1000
- error_append_hint(errp, "This CPU does not support "
1001
- "the vector length %d-bits.\n", vq * 128);
1002
- error_append_hint(errp, "It may not be possible to use "
1003
- "sve-max-vq with this CPU. Try "
1004
- "using only sve<N> properties.\n");
1005
- } else {
1006
- error_setg(errp, "cannot enable sve%d", vq * 128);
1007
- if (vq_supported) {
1008
- error_append_hint(errp, "This CPU does not support "
1009
- "the vector length %d-bits.\n", vq * 128);
1010
- } else {
1011
- error_append_hint(errp, "SVE not supported by KVM "
1012
- "on this host\n");
1013
- }
1014
- }
1015
- return;
1016
- } else {
1017
- if (kvm_enabled()) {
1018
- error_setg(errp, "cannot disable sve%d", vq * 128);
1019
- error_append_hint(errp, "The KVM host requires all "
1020
- "supported vector lengths smaller "
1021
- "than %d bits to also be enabled.\n",
1022
- max_vq * 128);
1023
- return;
1024
- } else {
1025
- /* Ensure all required powers-of-two are enabled. */
1026
- tmp = SVE_VQ_POW2_MAP & vq_mask & ~vq_map;
1027
- if (tmp) {
1028
- vq = 32 - clz32(tmp);
1029
- error_setg(errp, "cannot disable sve%d", vq * 128);
1030
- error_append_hint(errp, "sve%d is required as it "
1031
- "is a power-of-two length smaller "
1032
- "than the maximum, sve%d\n",
1033
- vq * 128, max_vq * 128);
1034
- return;
1035
- }
1036
- }
1037
- }
1038
- }
1039
-
1040
- /*
1041
- * Now that we validated all our vector lengths, the only question
1042
- * left to answer is if we even want SVE at all.
1043
- */
1044
- if (!cpu_isar_feature(aa64_sve, cpu)) {
1045
- error_setg(errp, "cannot enable sve%d", max_vq * 128);
1046
- error_append_hint(errp, "SVE must be enabled to enable vector "
1047
- "lengths.\n");
1048
- error_append_hint(errp, "Add sve=on to the CPU property list.\n");
1049
- return;
1050
- }
1051
-
1052
- /* From now on sve_max_vq is the actual maximum supported length. */
1053
- cpu->sve_max_vq = max_vq;
1054
- cpu->sve_vq.map = vq_map;
1055
-}
1056
-
1057
static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name,
1058
void *opaque, Error **errp)
1059
{
1060
@@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name,
1061
cpu->sve_max_vq = max_vq;
1062
}
1063
1064
-/*
1065
- * Note that cpu_arm_{get,set}_vq cannot use the simpler
1066
- * object_property_add_bool interface because they make use of the
1067
- * contents of "name" to determine which bit on which to operate.
1068
- */
1069
-static void cpu_arm_get_vq(Object *obj, Visitor *v, const char *name,
1070
- void *opaque, Error **errp)
1071
-{
1072
- ARMCPU *cpu = ARM_CPU(obj);
1073
- ARMVQMap *vq_map = opaque;
1074
- uint32_t vq = atoi(&name[3]) / 128;
1075
- bool sve = vq_map == &cpu->sve_vq;
1076
- bool value;
1077
-
1078
- /* All vector lengths are disabled when feature is off. */
1079
- if (sve
1080
- ? !cpu_isar_feature(aa64_sve, cpu)
1081
- : !cpu_isar_feature(aa64_sme, cpu)) {
1082
- value = false;
1083
- } else {
1084
- value = extract32(vq_map->map, vq - 1, 1);
1085
- }
1086
- visit_type_bool(v, name, &value, errp);
1087
-}
1088
-
1089
-static void cpu_arm_set_vq(Object *obj, Visitor *v, const char *name,
1090
- void *opaque, Error **errp)
1091
-{
1092
- ARMVQMap *vq_map = opaque;
1093
- uint32_t vq = atoi(&name[3]) / 128;
1094
- bool value;
1095
-
1096
- if (!visit_type_bool(v, name, &value, errp)) {
1097
- return;
1098
- }
1099
-
1100
- vq_map->map = deposit32(vq_map->map, vq - 1, 1, value);
1101
- vq_map->init |= 1 << (vq - 1);
1102
-}
1103
-
1104
-static bool cpu_arm_get_sve(Object *obj, Error **errp)
1105
-{
1106
- ARMCPU *cpu = ARM_CPU(obj);
1107
- return cpu_isar_feature(aa64_sve, cpu);
1108
-}
1109
-
1110
-static void cpu_arm_set_sve(Object *obj, bool value, Error **errp)
1111
-{
1112
- ARMCPU *cpu = ARM_CPU(obj);
1113
- uint64_t t;
1114
-
1115
- if (value && kvm_enabled() && !kvm_arm_sve_supported()) {
1116
- error_setg(errp, "'sve' feature not supported by KVM on this host");
1117
- return;
1118
- }
1119
-
1120
- t = cpu->isar.id_aa64pfr0;
1121
- t = FIELD_DP64(t, ID_AA64PFR0, SVE, value);
1122
- cpu->isar.id_aa64pfr0 = t;
1123
-}
1124
-
1125
-void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp)
1126
-{
1127
- uint32_t vq_map = cpu->sme_vq.map;
1128
- uint32_t vq_init = cpu->sme_vq.init;
1129
- uint32_t vq_supported = cpu->sme_vq.supported;
1130
- uint32_t vq;
1131
-
1132
- if (vq_map == 0) {
1133
- if (!cpu_isar_feature(aa64_sme, cpu)) {
1134
- cpu->isar.id_aa64smfr0 = 0;
1135
- return;
1136
- }
1137
-
1138
- /* TODO: KVM will require limitations via SMCR_EL2. */
1139
- vq_map = vq_supported & ~vq_init;
1140
-
1141
- if (vq_map == 0) {
1142
- vq = ctz32(vq_supported) + 1;
1143
- error_setg(errp, "cannot disable sme%d", vq * 128);
1144
- error_append_hint(errp, "All SME vector lengths are disabled.\n");
1145
- error_append_hint(errp, "With SME enabled, at least one "
1146
- "vector length must be enabled.\n");
1147
- return;
1148
- }
1149
- } else {
1150
- if (!cpu_isar_feature(aa64_sme, cpu)) {
1151
- vq = 32 - clz32(vq_map);
1152
- error_setg(errp, "cannot enable sme%d", vq * 128);
1153
- error_append_hint(errp, "SME must be enabled to enable "
1154
- "vector lengths.\n");
1155
- error_append_hint(errp, "Add sme=on to the CPU property list.\n");
1156
- return;
1157
- }
1158
- /* TODO: KVM will require limitations via SMCR_EL2. */
1159
- }
1160
-
1161
- cpu->sme_vq.map = vq_map;
1162
-}
1163
-
1164
-static bool cpu_arm_get_sme(Object *obj, Error **errp)
1165
-{
1166
- ARMCPU *cpu = ARM_CPU(obj);
1167
- return cpu_isar_feature(aa64_sme, cpu);
1168
-}
1169
-
1170
-static void cpu_arm_set_sme(Object *obj, bool value, Error **errp)
1171
-{
1172
- ARMCPU *cpu = ARM_CPU(obj);
1173
- uint64_t t;
1174
-
1175
- t = cpu->isar.id_aa64pfr1;
1176
- t = FIELD_DP64(t, ID_AA64PFR1, SME, value);
1177
- cpu->isar.id_aa64pfr1 = t;
1178
-}
1179
-
1180
-static bool cpu_arm_get_sme_fa64(Object *obj, Error **errp)
1181
-{
1182
- ARMCPU *cpu = ARM_CPU(obj);
1183
- return cpu_isar_feature(aa64_sme, cpu) &&
1184
- cpu_isar_feature(aa64_sme_fa64, cpu);
1185
-}
1186
-
1187
-static void cpu_arm_set_sme_fa64(Object *obj, bool value, Error **errp)
1188
-{
1189
- ARMCPU *cpu = ARM_CPU(obj);
1190
- uint64_t t;
1191
-
1192
- t = cpu->isar.id_aa64smfr0;
1193
- t = FIELD_DP64(t, ID_AA64SMFR0, FA64, value);
1194
- cpu->isar.id_aa64smfr0 = t;
1195
-}
1196
-
1197
-#ifdef CONFIG_USER_ONLY
1198
-/* Mirror linux /proc/sys/abi/{sve,sme}_default_vector_length. */
1199
-static void cpu_arm_set_default_vec_len(Object *obj, Visitor *v,
1200
- const char *name, void *opaque,
1201
- Error **errp)
1202
-{
1203
- uint32_t *ptr_default_vq = opaque;
1204
- int32_t default_len, default_vq, remainder;
1205
-
1206
- if (!visit_type_int32(v, name, &default_len, errp)) {
1207
- return;
1208
- }
1209
-
1210
- /* Undocumented, but the kernel allows -1 to indicate "maximum". */
1211
- if (default_len == -1) {
1212
- *ptr_default_vq = ARM_MAX_VQ;
1213
- return;
1214
- }
1215
-
1216
- default_vq = default_len / 16;
1217
- remainder = default_len % 16;
1218
-
1219
- /*
1220
- * Note that the 512 max comes from include/uapi/asm/sve_context.h
1221
- * and is the maximum architectural width of ZCR_ELx.LEN.
1222
- */
1223
- if (remainder || default_vq < 1 || default_vq > 512) {
1224
- ARMCPU *cpu = ARM_CPU(obj);
1225
- const char *which =
1226
- (ptr_default_vq == &cpu->sve_default_vq ? "sve" : "sme");
1227
-
1228
- error_setg(errp, "cannot set %s-default-vector-length", which);
1229
- if (remainder) {
1230
- error_append_hint(errp, "Vector length not a multiple of 16\n");
1231
- } else if (default_vq < 1) {
1232
- error_append_hint(errp, "Vector length smaller than 16\n");
1233
- } else {
1234
- error_append_hint(errp, "Vector length larger than %d\n",
1235
- 512 * 16);
1236
- }
1237
- return;
1238
- }
1239
-
1240
- *ptr_default_vq = default_vq;
1241
-}
1242
-
1243
-static void cpu_arm_get_default_vec_len(Object *obj, Visitor *v,
1244
- const char *name, void *opaque,
1245
- Error **errp)
1246
-{
1247
- uint32_t *ptr_default_vq = opaque;
1248
- int32_t value = *ptr_default_vq * 16;
1249
-
1250
- visit_type_int32(v, name, &value, errp);
1251
-}
1252
-#endif
1253
-
1254
-static void aarch64_add_sve_properties(Object *obj)
1255
-{
1256
- ARMCPU *cpu = ARM_CPU(obj);
1257
- uint32_t vq;
1258
-
1259
- object_property_add_bool(obj, "sve", cpu_arm_get_sve, cpu_arm_set_sve);
1260
-
1261
- for (vq = 1; vq <= ARM_MAX_VQ; ++vq) {
1262
- char name[8];
1263
- sprintf(name, "sve%d", vq * 128);
1264
- object_property_add(obj, name, "bool", cpu_arm_get_vq,
1265
- cpu_arm_set_vq, NULL, &cpu->sve_vq);
1266
- }
1267
-
1268
-#ifdef CONFIG_USER_ONLY
1269
- /* Mirror linux /proc/sys/abi/sve_default_vector_length. */
1270
- object_property_add(obj, "sve-default-vector-length", "int32",
1271
- cpu_arm_get_default_vec_len,
1272
- cpu_arm_set_default_vec_len, NULL,
1273
- &cpu->sve_default_vq);
1274
-#endif
1275
-}
1276
-
1277
-static void aarch64_add_sme_properties(Object *obj)
1278
-{
1279
- ARMCPU *cpu = ARM_CPU(obj);
1280
- uint32_t vq;
1281
-
1282
- object_property_add_bool(obj, "sme", cpu_arm_get_sme, cpu_arm_set_sme);
1283
- object_property_add_bool(obj, "sme_fa64", cpu_arm_get_sme_fa64,
1284
- cpu_arm_set_sme_fa64);
1285
-
1286
- for (vq = 1; vq <= ARM_MAX_VQ; vq <<= 1) {
1287
- char name[8];
1288
- sprintf(name, "sme%d", vq * 128);
1289
- object_property_add(obj, name, "bool", cpu_arm_get_vq,
1290
- cpu_arm_set_vq, NULL, &cpu->sme_vq);
1291
- }
1292
-
1293
-#ifdef CONFIG_USER_ONLY
1294
- /* Mirror linux /proc/sys/abi/sme_default_vector_length. */
1295
- object_property_add(obj, "sme-default-vector-length", "int32",
1296
- cpu_arm_get_default_vec_len,
1297
- cpu_arm_set_default_vec_len, NULL,
1298
- &cpu->sme_default_vq);
1299
-#endif
1300
-}
1301
-
1302
-void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
1303
-{
1304
- int arch_val = 0, impdef_val = 0;
1305
- uint64_t t;
1306
-
1307
- /* Exit early if PAuth is enabled, and fall through to disable it */
1308
- if ((kvm_enabled() || hvf_enabled()) && cpu->prop_pauth) {
1309
- if (!cpu_isar_feature(aa64_pauth, cpu)) {
1310
- error_setg(errp, "'pauth' feature not supported by %s on this host",
1311
- kvm_enabled() ? "KVM" : "hvf");
1312
- }
1313
-
1314
- return;
1315
- }
1316
-
1317
- /* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */
1318
- if (cpu->prop_pauth) {
1319
- if (cpu->prop_pauth_impdef) {
1320
- impdef_val = 1;
1321
- } else {
1322
- arch_val = 1;
1323
- }
1324
- } else if (cpu->prop_pauth_impdef) {
1325
- error_setg(errp, "cannot enable pauth-impdef without pauth");
1326
- error_append_hint(errp, "Add pauth=on to the CPU property list.\n");
1327
- }
1328
-
1329
- t = cpu->isar.id_aa64isar1;
1330
- t = FIELD_DP64(t, ID_AA64ISAR1, APA, arch_val);
1331
- t = FIELD_DP64(t, ID_AA64ISAR1, GPA, arch_val);
1332
- t = FIELD_DP64(t, ID_AA64ISAR1, API, impdef_val);
1333
- t = FIELD_DP64(t, ID_AA64ISAR1, GPI, impdef_val);
1334
- cpu->isar.id_aa64isar1 = t;
1335
-}
1336
-
1337
-static Property arm_cpu_pauth_property =
1338
- DEFINE_PROP_BOOL("pauth", ARMCPU, prop_pauth, true);
1339
-static Property arm_cpu_pauth_impdef_property =
1340
- DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
1341
-
1342
-static void aarch64_add_pauth_properties(Object *obj)
1343
-{
1344
- ARMCPU *cpu = ARM_CPU(obj);
1345
-
1346
- /* Default to PAUTH on, with the architected algorithm on TCG. */
1347
- qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
1348
- if (kvm_enabled() || hvf_enabled()) {
1349
- /*
1350
- * Mirror PAuth support from the probed sysregs back into the
1351
- * property for KVM or hvf. Is it just a bit backward? Yes it is!
1352
- * Note that prop_pauth is true whether the host CPU supports the
1353
- * architected QARMA5 algorithm or the IMPDEF one. We don't
1354
- * provide the separate pauth-impdef property for KVM or hvf,
1355
- * only for TCG.
1356
- */
1357
- cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu);
1358
- } else {
1359
- qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
1360
- }
1361
-}
1362
-
1363
static Property arm_cpu_lpa2_property =
1364
DEFINE_PROP_BOOL("lpa2", ARMCPU, prop_lpa2, true);
1365
1366
-void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp)
1367
-{
1368
- uint64_t t;
1369
-
1370
- /*
1371
- * We only install the property for tcg -cpu max; this is the
1372
- * only situation in which the cpu field can be true.
1373
- */
1374
- if (!cpu->prop_lpa2) {
1375
- return;
1376
- }
1377
-
1378
- t = cpu->isar.id_aa64mmfr0;
1379
- t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16, 2); /* 16k pages w/ LPA2 */
1380
- t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4, 1); /* 4k pages w/ LPA2 */
1381
- t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 3); /* 16k stage2 w/ LPA2 */
1382
- t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 3); /* 4k stage2 w/ LPA2 */
1383
- cpu->isar.id_aa64mmfr0 = t;
1384
-}
1385
-
1386
-static void aarch64_a57_initfn(Object *obj)
1387
-{
1388
- ARMCPU *cpu = ARM_CPU(obj);
1389
-
1390
- cpu->dtb_compatible = "arm,cortex-a57";
1391
- set_feature(&cpu->env, ARM_FEATURE_V8);
1392
- set_feature(&cpu->env, ARM_FEATURE_NEON);
1393
- set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
1394
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
1395
- set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
1396
- set_feature(&cpu->env, ARM_FEATURE_EL2);
1397
- set_feature(&cpu->env, ARM_FEATURE_EL3);
1398
- set_feature(&cpu->env, ARM_FEATURE_PMU);
1399
- cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A57;
1400
- cpu->midr = 0x411fd070;
1401
- cpu->revidr = 0x00000000;
1402
- cpu->reset_fpsid = 0x41034070;
1403
- cpu->isar.mvfr0 = 0x10110222;
1404
- cpu->isar.mvfr1 = 0x12111111;
1405
- cpu->isar.mvfr2 = 0x00000043;
1406
- cpu->ctr = 0x8444c004;
1407
- cpu->reset_sctlr = 0x00c50838;
1408
- cpu->isar.id_pfr0 = 0x00000131;
1409
- cpu->isar.id_pfr1 = 0x00011011;
1410
- cpu->isar.id_dfr0 = 0x03010066;
1411
- cpu->id_afr0 = 0x00000000;
1412
- cpu->isar.id_mmfr0 = 0x10101105;
1413
- cpu->isar.id_mmfr1 = 0x40000000;
1414
- cpu->isar.id_mmfr2 = 0x01260000;
1415
- cpu->isar.id_mmfr3 = 0x02102211;
1416
- cpu->isar.id_isar0 = 0x02101110;
1417
- cpu->isar.id_isar1 = 0x13112111;
1418
- cpu->isar.id_isar2 = 0x21232042;
1419
- cpu->isar.id_isar3 = 0x01112131;
1420
- cpu->isar.id_isar4 = 0x00011142;
1421
- cpu->isar.id_isar5 = 0x00011121;
1422
- cpu->isar.id_isar6 = 0;
1423
- cpu->isar.id_aa64pfr0 = 0x00002222;
1424
- cpu->isar.id_aa64dfr0 = 0x10305106;
1425
- cpu->isar.id_aa64isar0 = 0x00011120;
1426
- cpu->isar.id_aa64mmfr0 = 0x00001124;
1427
- cpu->isar.dbgdidr = 0x3516d000;
1428
- cpu->isar.dbgdevid = 0x01110f13;
1429
- cpu->isar.dbgdevid1 = 0x2;
1430
- cpu->isar.reset_pmcr_el0 = 0x41013000;
1431
- cpu->clidr = 0x0a200023;
1432
- cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */
1433
- cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */
1434
- cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */
1435
- cpu->dcz_blocksize = 4; /* 64 bytes */
1436
- cpu->gic_num_lrs = 4;
1437
- cpu->gic_vpribits = 5;
1438
- cpu->gic_vprebits = 5;
1439
- cpu->gic_pribits = 5;
1440
- define_cortex_a72_a57_a53_cp_reginfo(cpu);
1441
-}
1442
-
1443
-static void aarch64_a53_initfn(Object *obj)
1444
-{
1445
- ARMCPU *cpu = ARM_CPU(obj);
1446
-
1447
- cpu->dtb_compatible = "arm,cortex-a53";
1448
- set_feature(&cpu->env, ARM_FEATURE_V8);
1449
- set_feature(&cpu->env, ARM_FEATURE_NEON);
1450
- set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
1451
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
1452
- set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
1453
- set_feature(&cpu->env, ARM_FEATURE_EL2);
1454
- set_feature(&cpu->env, ARM_FEATURE_EL3);
1455
- set_feature(&cpu->env, ARM_FEATURE_PMU);
1456
- cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A53;
1457
- cpu->midr = 0x410fd034;
1458
- cpu->revidr = 0x00000000;
1459
- cpu->reset_fpsid = 0x41034070;
1460
- cpu->isar.mvfr0 = 0x10110222;
1461
- cpu->isar.mvfr1 = 0x12111111;
1462
- cpu->isar.mvfr2 = 0x00000043;
1463
- cpu->ctr = 0x84448004; /* L1Ip = VIPT */
1464
- cpu->reset_sctlr = 0x00c50838;
1465
- cpu->isar.id_pfr0 = 0x00000131;
1466
- cpu->isar.id_pfr1 = 0x00011011;
1467
- cpu->isar.id_dfr0 = 0x03010066;
1468
- cpu->id_afr0 = 0x00000000;
1469
- cpu->isar.id_mmfr0 = 0x10101105;
1470
- cpu->isar.id_mmfr1 = 0x40000000;
1471
- cpu->isar.id_mmfr2 = 0x01260000;
1472
- cpu->isar.id_mmfr3 = 0x02102211;
1473
- cpu->isar.id_isar0 = 0x02101110;
1474
- cpu->isar.id_isar1 = 0x13112111;
1475
- cpu->isar.id_isar2 = 0x21232042;
1476
- cpu->isar.id_isar3 = 0x01112131;
1477
- cpu->isar.id_isar4 = 0x00011142;
1478
- cpu->isar.id_isar5 = 0x00011121;
1479
- cpu->isar.id_isar6 = 0;
1480
- cpu->isar.id_aa64pfr0 = 0x00002222;
1481
- cpu->isar.id_aa64dfr0 = 0x10305106;
1482
- cpu->isar.id_aa64isar0 = 0x00011120;
1483
- cpu->isar.id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */
1484
- cpu->isar.dbgdidr = 0x3516d000;
1485
- cpu->isar.dbgdevid = 0x00110f13;
1486
- cpu->isar.dbgdevid1 = 0x1;
1487
- cpu->isar.reset_pmcr_el0 = 0x41033000;
1488
- cpu->clidr = 0x0a200023;
1489
- cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */
1490
- cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */
1491
- cpu->ccsidr[2] = 0x707fe07a; /* 1024KB L2 cache */
1492
- cpu->dcz_blocksize = 4; /* 64 bytes */
1493
- cpu->gic_num_lrs = 4;
1494
- cpu->gic_vpribits = 5;
1495
- cpu->gic_vprebits = 5;
1496
- cpu->gic_pribits = 5;
1497
- define_cortex_a72_a57_a53_cp_reginfo(cpu);
1498
-}
1499
-
1500
static void aarch64_a55_initfn(Object *obj)
1501
{
1502
ARMCPU *cpu = ARM_CPU(obj);
1503
@@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n1_initfn(Object *obj)
1504
define_neoverse_n1_cp_reginfo(cpu);
1505
}
1506
1507
-static void aarch64_host_initfn(Object *obj)
1508
-{
1509
-#if defined(CONFIG_KVM)
1510
- ARMCPU *cpu = ARM_CPU(obj);
1511
- kvm_arm_set_cpu_features_from_host(cpu);
1512
- if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
1513
- aarch64_add_sve_properties(obj);
1514
- aarch64_add_pauth_properties(obj);
1515
- }
1516
-#elif defined(CONFIG_HVF)
1517
- ARMCPU *cpu = ARM_CPU(obj);
1518
- hvf_arm_set_cpu_features_from_host(cpu);
1519
- aarch64_add_pauth_properties(obj);
1520
-#else
1521
- g_assert_not_reached();
1522
-#endif
1523
-}
1524
-
1525
/*
1526
* -cpu max: a CPU with as many features enabled as our emulation supports.
1527
* The version of '-cpu max' for qemu-system-arm is defined in cpu_tcg.c;
1528
* this only needs to handle 64 bits.
1529
*/
1530
-static void aarch64_max_tcg_initfn(Object *obj)
1531
+void aarch64_max_tcg_initfn(Object *obj)
1532
{
1533
ARMCPU *cpu = ARM_CPU(obj);
1534
uint64_t t;
1535
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_tcg_initfn(Object *obj)
1536
qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property);
1537
}
1538
1539
-static void aarch64_max_initfn(Object *obj)
1540
-{
1541
- if (kvm_enabled() || hvf_enabled()) {
1542
- /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */
1543
- aarch64_host_initfn(obj);
1544
- return;
1545
- }
1546
-
1547
- if (tcg_enabled() || qtest_enabled()) {
1548
- aarch64_a57_initfn(obj);
1549
- }
1550
-
1551
- /* '-cpu max' for TCG: we currently do this as "A57 with extra things" */
1552
- if (tcg_enabled()) {
1553
- aarch64_max_tcg_initfn(obj);
1554
- }
1555
-}
1556
-
1557
static const ARMCPUInfo aarch64_cpus[] = {
1558
{ .name = "cortex-a35", .initfn = aarch64_a35_initfn },
1559
- { .name = "cortex-a57", .initfn = aarch64_a57_initfn },
1560
- { .name = "cortex-a53", .initfn = aarch64_a53_initfn },
1561
{ .name = "cortex-a55", .initfn = aarch64_a55_initfn },
1562
{ .name = "cortex-a72", .initfn = aarch64_a72_initfn },
1563
{ .name = "cortex-a76", .initfn = aarch64_a76_initfn },
1564
{ .name = "a64fx", .initfn = aarch64_a64fx_initfn },
1565
{ .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn },
1566
- { .name = "max", .initfn = aarch64_max_initfn },
1567
-#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
1568
- { .name = "host", .initfn = aarch64_host_initfn },
1569
-#endif
1570
-};
1571
-
1572
-static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp)
1573
-{
1574
- ARMCPU *cpu = ARM_CPU(obj);
1575
-
1576
- return arm_feature(&cpu->env, ARM_FEATURE_AARCH64);
1577
-}
1578
-
1579
-static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp)
1580
-{
1581
- ARMCPU *cpu = ARM_CPU(obj);
1582
-
1583
- /* At this time, this property is only allowed if KVM is enabled. This
1584
- * restriction allows us to avoid fixing up functionality that assumes a
1585
- * uniform execution state like do_interrupt.
1586
- */
1587
- if (value == false) {
1588
- if (!kvm_enabled() || !kvm_arm_aarch32_supported()) {
1589
- error_setg(errp, "'aarch64' feature cannot be disabled "
1590
- "unless KVM is enabled and 32-bit EL1 "
1591
- "is supported");
1592
- return;
1593
- }
1594
- unset_feature(&cpu->env, ARM_FEATURE_AARCH64);
1595
- } else {
1596
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
1597
- }
1598
-}
1599
-
1600
-static void aarch64_cpu_finalizefn(Object *obj)
1601
-{
1602
-}
1603
-
1604
-static gchar *aarch64_gdb_arch_name(CPUState *cs)
1605
-{
1606
- return g_strdup("aarch64");
1607
-}
1608
-
1609
-static void aarch64_cpu_class_init(ObjectClass *oc, void *data)
1610
-{
1611
- CPUClass *cc = CPU_CLASS(oc);
1612
-
1613
- cc->gdb_read_register = aarch64_cpu_gdb_read_register;
1614
- cc->gdb_write_register = aarch64_cpu_gdb_write_register;
1615
- cc->gdb_num_core_regs = 34;
1616
- cc->gdb_core_xml_file = "aarch64-core.xml";
1617
- cc->gdb_arch_name = aarch64_gdb_arch_name;
1618
-
1619
- object_class_property_add_bool(oc, "aarch64", aarch64_cpu_get_aarch64,
1620
- aarch64_cpu_set_aarch64);
1621
- object_class_property_set_description(oc, "aarch64",
1622
- "Set on/off to enable/disable aarch64 "
1623
- "execution state ");
1624
-}
1625
-
1626
-static void aarch64_cpu_instance_init(Object *obj)
1627
-{
1628
- ARMCPUClass *acc = ARM_CPU_GET_CLASS(obj);
1629
-
1630
- acc->info->initfn(obj);
1631
- arm_cpu_post_init(obj);
1632
-}
1633
-
1634
-static void cpu_register_class_init(ObjectClass *oc, void *data)
1635
-{
1636
- ARMCPUClass *acc = ARM_CPU_CLASS(oc);
1637
-
1638
- acc->info = data;
1639
-}
1640
-
1641
-void aarch64_cpu_register(const ARMCPUInfo *info)
1642
-{
1643
- TypeInfo type_info = {
1644
- .parent = TYPE_AARCH64_CPU,
1645
- .instance_size = sizeof(ARMCPU),
1646
- .instance_init = aarch64_cpu_instance_init,
1647
- .class_size = sizeof(ARMCPUClass),
1648
- .class_init = info->class_init ?: cpu_register_class_init,
1649
- .class_data = (void *)info,
1650
- };
1651
-
1652
- type_info.name = g_strdup_printf("%s-" TYPE_ARM_CPU, info->name);
1653
- type_register(&type_info);
1654
- g_free((void *)type_info.name);
1655
-}
1656
-
1657
-static const TypeInfo aarch64_cpu_type_info = {
1658
- .name = TYPE_AARCH64_CPU,
1659
- .parent = TYPE_ARM_CPU,
1660
- .instance_size = sizeof(ARMCPU),
1661
- .instance_finalize = aarch64_cpu_finalizefn,
1662
- .abstract = true,
1663
- .class_size = sizeof(AArch64CPUClass),
1664
- .class_init = aarch64_cpu_class_init,
1665
};
1666
1667
static void aarch64_cpu_register_types(void)
1668
{
1669
size_t i;
1670
1671
- type_register_static(&aarch64_cpu_type_info);
1672
-
1673
for (i = 0; i < ARRAY_SIZE(aarch64_cpus); ++i) {
1674
aarch64_cpu_register(&aarch64_cpus[i]);
1675
}
1676
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
1677
index XXXXXXX..XXXXXXX 100644
1678
--- a/target/arm/tcg/meson.build
1679
+++ b/target/arm/tcg/meson.build
1680
@@ -XXX,XX +XXX,XX @@ arm_ss.add(files(
1681
))
1682
1683
arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
1684
+ 'cpu64.c',
1685
'translate-a64.c',
1686
'translate-sve.c',
1687
'translate-sme.c',
47
--
1688
--
48
2.7.4
1689
2.34.1
49
1690
50
1691
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
We already have an exit condition, DISAS_UPDATE which will exit the
3
We're about to move the 32-bit CPUs under CONFIG_TCG, so adjust the
4
run-loop. Expand on the difference with DISAS_EXIT in the comments.
4
query-cpu-model-expansion test to check against the cortex-a7, which
5
is already under CONFIG_TCG. That allows the next patch to contain
6
only code movement. (All the test cares about is that the CPU type
7
it's checking is one which definitely doesn't work under KVM.)
5
8
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
9
While here add comments clarifying what we're testing.
7
Reviewed-by: Richard Henderson <rth@twiddle.net>
10
8
Message-id: 20170713141928.25419-4-alex.bennee@linaro.org
11
Signed-off-by: Fabiano Rosas <farosas@suse.de>
12
Acked-by: Thomas Huth <thuth@redhat.com>
13
Message-id: 20230426180013.14814-7-farosas@suse.de
14
Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
17
---
11
target/arm/translate.h | 5 ++++-
18
tests/qtest/arm-cpu-features.c | 20 +++++++++++++++++---
12
1 file changed, 4 insertions(+), 1 deletion(-)
19
1 file changed, 17 insertions(+), 3 deletions(-)
13
20
14
diff --git a/target/arm/translate.h b/target/arm/translate.h
21
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
15
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.h
23
--- a/tests/qtest/arm-cpu-features.c
17
+++ b/target/arm/translate.h
24
+++ b/tests/qtest/arm-cpu-features.c
18
@@ -XXX,XX +XXX,XX @@ static void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)
25
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion_kvm(const void *data)
19
*/
26
QDict *resp;
20
#define DISAS_BX_EXCRET 11
27
char *error;
21
/* For instructions which want an immediate exit to the main loop,
28
22
- * as opposed to attempting to use lookup_and_goto_ptr.
29
- assert_error(qts, "cortex-a15",
23
+ * as opposed to attempting to use lookup_and_goto_ptr. Unlike
30
- "We cannot guarantee the CPU type 'cortex-a15' works "
24
+ * DISAS_UPDATE this doesn't write the PC on exiting the translation
31
- "with KVM on this host", NULL);
25
+ * loop so you need to ensure something (gen_a64_set_pc_im or runtime
32
+ /*
26
+ * helper) has done so before we reach return from cpu_tb_exec.
33
+ * When using KVM, only the 'host' and 'max' CPU models are
27
*/
34
+ * supported. Test that we're emitting a suitable error for
28
#define DISAS_EXIT 12
35
+ * unsupported CPU models.
36
+ */
37
+ if (qtest_has_accel("tcg")) {
38
+ assert_error(qts, "cortex-a7",
39
+ "We cannot guarantee the CPU type 'cortex-a7' works "
40
+ "with KVM on this host", NULL);
41
+ } else {
42
+ /*
43
+ * With a KVM-only build the 32-bit CPUs are not present.
44
+ */
45
+ assert_error(qts, "cortex-a7",
46
+ "The CPU type 'cortex-a7' is not a "
47
+ "recognized ARM CPU type", NULL);
48
+ }
49
50
assert_has_feature_enabled(qts, "host", "aarch64");
29
51
30
--
52
--
31
2.7.4
53
2.34.1
32
54
33
55
diff view generated by jsdifflib
New patch
1
From: Claudio Fontana <cfontana@suse.de>
1
2
3
move the module containing cpu models definitions
4
for 32bit TCG-only CPUs to tcg/ and rename it for clarity.
5
6
Signed-off-by: Claudio Fontana <cfontana@suse.de>
7
Signed-off-by: Fabiano Rosas <farosas@suse.de>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Acked-by: Thomas Huth <thuth@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20230426180013.14814-8-farosas@suse.de
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
hw/arm/virt.c | 2 --
15
target/arm/{cpu_tcg.c => tcg/cpu32.c} | 13 +++----------
16
target/arm/tcg/cpu64.c | 2 +-
17
target/arm/meson.build | 1 -
18
target/arm/tcg/meson.build | 1 +
19
5 files changed, 5 insertions(+), 14 deletions(-)
20
rename target/arm/{cpu_tcg.c => tcg/cpu32.c} (99%)
21
22
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
23
index XXXXXXX..XXXXXXX 100644
24
--- a/hw/arm/virt.c
25
+++ b/hw/arm/virt.c
26
@@ -XXX,XX +XXX,XX @@ static const int a15irqmap[] = {
27
static const char *valid_cpus[] = {
28
#ifdef CONFIG_TCG
29
ARM_CPU_TYPE_NAME("cortex-a7"),
30
-#endif
31
ARM_CPU_TYPE_NAME("cortex-a15"),
32
-#ifdef CONFIG_TCG
33
ARM_CPU_TYPE_NAME("cortex-a35"),
34
ARM_CPU_TYPE_NAME("cortex-a55"),
35
ARM_CPU_TYPE_NAME("cortex-a72"),
36
diff --git a/target/arm/cpu_tcg.c b/target/arm/tcg/cpu32.c
37
similarity index 99%
38
rename from target/arm/cpu_tcg.c
39
rename to target/arm/tcg/cpu32.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/cpu_tcg.c
42
+++ b/target/arm/tcg/cpu32.c
43
@@ -XXX,XX +XXX,XX @@
44
/*
45
- * QEMU ARM TCG CPUs.
46
+ * QEMU ARM TCG-only CPUs.
47
*
48
* Copyright (c) 2012 SUSE LINUX Products GmbH
49
*
50
@@ -XXX,XX +XXX,XX @@
51
52
#include "qemu/osdep.h"
53
#include "cpu.h"
54
-#ifdef CONFIG_TCG
55
#include "hw/core/tcg-cpu-ops.h"
56
-#endif /* CONFIG_TCG */
57
#include "internals.h"
58
#include "target/arm/idau.h"
59
#if !defined(CONFIG_USER_ONLY)
60
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
61
/* CPU models. These are not needed for the AArch64 linux-user build. */
62
#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
63
64
-#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
65
+#if !defined(CONFIG_USER_ONLY)
66
static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
67
{
68
CPUClass *cc = CPU_GET_CLASS(cs);
69
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
70
}
71
return ret;
72
}
73
-#endif /* !CONFIG_USER_ONLY && CONFIG_TCG */
74
+#endif /* !CONFIG_USER_ONLY */
75
76
static void arm926_initfn(Object *obj)
77
{
78
@@ -XXX,XX +XXX,XX @@ static void pxa270c5_initfn(Object *obj)
79
cpu->reset_sctlr = 0x00000078;
80
}
81
82
-#ifdef CONFIG_TCG
83
static const struct TCGCPUOps arm_v7m_tcg_ops = {
84
.initialize = arm_translate_init,
85
.synchronize_from_tb = arm_cpu_synchronize_from_tb,
86
@@ -XXX,XX +XXX,XX @@ static const struct TCGCPUOps arm_v7m_tcg_ops = {
87
.debug_check_breakpoint = arm_debug_check_breakpoint,
88
#endif /* !CONFIG_USER_ONLY */
89
};
90
-#endif /* CONFIG_TCG */
91
92
static void arm_v7m_class_init(ObjectClass *oc, void *data)
93
{
94
@@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
95
CPUClass *cc = CPU_CLASS(oc);
96
97
acc->info = data;
98
-#ifdef CONFIG_TCG
99
cc->tcg_ops = &arm_v7m_tcg_ops;
100
-#endif /* CONFIG_TCG */
101
-
102
cc->gdb_core_xml_file = "arm-m-profile.xml";
103
}
104
105
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/target/arm/tcg/cpu64.c
108
+++ b/target/arm/tcg/cpu64.c
109
@@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n1_initfn(Object *obj)
110
111
/*
112
* -cpu max: a CPU with as many features enabled as our emulation supports.
113
- * The version of '-cpu max' for qemu-system-arm is defined in cpu_tcg.c;
114
+ * The version of '-cpu max' for qemu-system-arm is defined in cpu32.c;
115
* this only needs to handle 64 bits.
116
*/
117
void aarch64_max_tcg_initfn(Object *obj)
118
diff --git a/target/arm/meson.build b/target/arm/meson.build
119
index XXXXXXX..XXXXXXX 100644
120
--- a/target/arm/meson.build
121
+++ b/target/arm/meson.build
122
@@ -XXX,XX +XXX,XX @@ arm_ss.add(files(
123
'gdbstub.c',
124
'helper.c',
125
'vfp_helper.c',
126
- 'cpu_tcg.c',
127
))
128
arm_ss.add(zlib)
129
130
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
131
index XXXXXXX..XXXXXXX 100644
132
--- a/target/arm/tcg/meson.build
133
+++ b/target/arm/tcg/meson.build
134
@@ -XXX,XX +XXX,XX @@ gen = [
135
arm_ss.add(gen)
136
137
arm_ss.add(files(
138
+ 'cpu32.c',
139
'translate.c',
140
'translate-m-nocp.c',
141
'translate-mve.c',
142
--
143
2.34.1
144
145
diff view generated by jsdifflib
1
Implement a model of the simple "APB UART" provided in
1
From: Fabiano Rosas <farosas@suse.de>
2
the Cortex-M System Design Kit (CMSDK).
3
2
3
It is possible to have a build with both TCG and KVM disabled due to
4
Xen requiring the i386 and x86_64 binaries to be present in an aarch64
5
host.
6
7
If we build with --disable-tcg on the aarch64 host, we will end-up
8
with a QEMU binary (x86) that does not support TCG nor KVM.
9
10
Skip tests that crash or hang in the above scenario. Do not include
11
any test cases if TCG and KVM are missing.
12
13
Make sure that calls to qtest_has_accel are placed after g_test_init
14
in similar fashion to commit ae4b01b349 ("tests: Ensure TAP version is
15
printed before other messages") to avoid TAP parsing errors.
16
17
Reviewed-by: Juan Quintela <quintela@redhat.com>
18
Reviewed-by: Thomas Huth <thuth@redhat.com>
19
Signed-off-by: Fabiano Rosas <farosas@suse.de>
20
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
23
Message-id: 20230426180013.14814-9-farosas@suse.de
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 1500029487-14822-3-git-send-email-peter.maydell@linaro.org
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
---
25
---
8
hw/char/Makefile.objs | 1 +
26
tests/qtest/bios-tables-test.c | 11 +++++++++--
9
include/hw/char/cmsdk-apb-uart.h | 78 ++++++++
27
tests/qtest/boot-serial-test.c | 5 +++++
10
hw/char/cmsdk-apb-uart.c | 403 +++++++++++++++++++++++++++++++++++++++
28
tests/qtest/migration-test.c | 9 ++++++++-
11
default-configs/arm-softmmu.mak | 2 +
29
tests/qtest/pxe-test.c | 8 +++++++-
12
hw/char/trace-events | 9 +
30
tests/qtest/vmgenid-test.c | 9 +++++++--
13
5 files changed, 493 insertions(+)
31
5 files changed, 36 insertions(+), 6 deletions(-)
14
create mode 100644 include/hw/char/cmsdk-apb-uart.h
15
create mode 100644 hw/char/cmsdk-apb-uart.c
16
32
17
diff --git a/hw/char/Makefile.objs b/hw/char/Makefile.objs
33
diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
18
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/char/Makefile.objs
35
--- a/tests/qtest/bios-tables-test.c
20
+++ b/hw/char/Makefile.objs
36
+++ b/tests/qtest/bios-tables-test.c
21
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_DIGIC) += digic-uart.o
37
@@ -XXX,XX +XXX,XX @@ static void test_acpi_virt_oem_fields(void)
22
obj-$(CONFIG_STM32F2XX_USART) += stm32f2xx_usart.o
38
int main(int argc, char *argv[])
23
obj-$(CONFIG_RASPI) += bcm2835_aux.o
39
{
24
40
const char *arch = qtest_get_arch();
25
+common-obj-$(CONFIG_CMSDK_APB_UART) += cmsdk-apb-uart.o
41
- const bool has_kvm = qtest_has_accel("kvm");
26
common-obj-$(CONFIG_ETRAXFS) += etraxfs_ser.o
42
- const bool has_tcg = qtest_has_accel("tcg");
27
common-obj-$(CONFIG_ISA_DEBUG) += debugcon.o
43
+ bool has_kvm, has_tcg;
28
common-obj-$(CONFIG_GRLIB) += grlib_apbuart.o
44
char *v_env = getenv("V");
29
diff --git a/include/hw/char/cmsdk-apb-uart.h b/include/hw/char/cmsdk-apb-uart.h
45
int ret;
30
new file mode 100644
46
31
index XXXXXXX..XXXXXXX
47
@@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[])
32
--- /dev/null
48
33
+++ b/include/hw/char/cmsdk-apb-uart.h
49
g_test_init(&argc, &argv, NULL);
34
@@ -XXX,XX +XXX,XX @@
50
35
+/*
51
+ has_kvm = qtest_has_accel("kvm");
36
+ * ARM CMSDK APB UART emulation
52
+ has_tcg = qtest_has_accel("tcg");
37
+ *
38
+ * Copyright (c) 2017 Linaro Limited
39
+ * Written by Peter Maydell
40
+ *
41
+ * This program is free software; you can redistribute it and/or modify
42
+ * it under the terms of the GNU General Public License version 2 or
43
+ * (at your option) any later version.
44
+ */
45
+
53
+
46
+#ifndef CMSDK_APB_UART_H
54
+ if (!has_tcg && !has_kvm) {
47
+#define CMSDK_APB_UART_H
55
+ g_test_skip("No KVM or TCG accelerator available");
48
+
56
+ return 0;
49
+#include "hw/sysbus.h"
50
+#include "chardev/char-fe.h"
51
+
52
+#define TYPE_CMSDK_APB_UART "cmsdk-apb-uart"
53
+#define CMSDK_APB_UART(obj) OBJECT_CHECK(CMSDKAPBUART, (obj), \
54
+ TYPE_CMSDK_APB_UART)
55
+
56
+typedef struct {
57
+ /*< private >*/
58
+ SysBusDevice parent_obj;
59
+
60
+ /*< public >*/
61
+ MemoryRegion iomem;
62
+ CharBackend chr;
63
+ qemu_irq txint;
64
+ qemu_irq rxint;
65
+ qemu_irq txovrint;
66
+ qemu_irq rxovrint;
67
+ qemu_irq uartint;
68
+ guint watch_tag;
69
+ uint32_t pclk_frq;
70
+
71
+ uint32_t state;
72
+ uint32_t ctrl;
73
+ uint32_t intstatus;
74
+ uint32_t bauddiv;
75
+ /* This UART has no FIFO, only a 1-character buffer for each of Tx and Rx */
76
+ uint8_t txbuf;
77
+ uint8_t rxbuf;
78
+} CMSDKAPBUART;
79
+
80
+/**
81
+ * cmsdk_apb_uart_create - convenience function to create TYPE_CMSDK_APB_UART
82
+ * @addr: location in system memory to map registers
83
+ * @chr: Chardev backend to connect UART to, or NULL if no backend
84
+ * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate)
85
+ */
86
+static inline DeviceState *cmsdk_apb_uart_create(hwaddr addr,
87
+ qemu_irq txint,
88
+ qemu_irq rxint,
89
+ qemu_irq txovrint,
90
+ qemu_irq rxovrint,
91
+ qemu_irq uartint,
92
+ Chardev *chr,
93
+ uint32_t pclk_frq)
94
+{
95
+ DeviceState *dev;
96
+ SysBusDevice *s;
97
+
98
+ dev = qdev_create(NULL, TYPE_CMSDK_APB_UART);
99
+ s = SYS_BUS_DEVICE(dev);
100
+ qdev_prop_set_chr(dev, "chardev", chr);
101
+ qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq);
102
+ qdev_init_nofail(dev);
103
+ sysbus_mmio_map(s, 0, addr);
104
+ sysbus_connect_irq(s, 0, txint);
105
+ sysbus_connect_irq(s, 1, rxint);
106
+ sysbus_connect_irq(s, 2, txovrint);
107
+ sysbus_connect_irq(s, 3, rxovrint);
108
+ sysbus_connect_irq(s, 4, uartint);
109
+ return dev;
110
+}
111
+
112
+#endif
113
diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c
114
new file mode 100644
115
index XXXXXXX..XXXXXXX
116
--- /dev/null
117
+++ b/hw/char/cmsdk-apb-uart.c
118
@@ -XXX,XX +XXX,XX @@
119
+/*
120
+ * ARM CMSDK APB UART emulation
121
+ *
122
+ * Copyright (c) 2017 Linaro Limited
123
+ * Written by Peter Maydell
124
+ *
125
+ * This program is free software; you can redistribute it and/or modify
126
+ * it under the terms of the GNU General Public License version 2 or
127
+ * (at your option) any later version.
128
+ */
129
+
130
+/* This is a model of the "APB UART" which is part of the Cortex-M
131
+ * System Design Kit (CMSDK) and documented in the Cortex-M System
132
+ * Design Kit Technical Reference Manual (ARM DDI0479C):
133
+ * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
134
+ */
135
+
136
+#include "qemu/osdep.h"
137
+#include "qemu/log.h"
138
+#include "qapi/error.h"
139
+#include "trace.h"
140
+#include "hw/sysbus.h"
141
+#include "hw/registerfields.h"
142
+#include "chardev/char-fe.h"
143
+#include "chardev/char-serial.h"
144
+#include "hw/char/cmsdk-apb-uart.h"
145
+
146
+REG32(DATA, 0)
147
+REG32(STATE, 4)
148
+ FIELD(STATE, TXFULL, 0, 1)
149
+ FIELD(STATE, RXFULL, 1, 1)
150
+ FIELD(STATE, TXOVERRUN, 2, 1)
151
+ FIELD(STATE, RXOVERRUN, 3, 1)
152
+REG32(CTRL, 8)
153
+ FIELD(CTRL, TX_EN, 0, 1)
154
+ FIELD(CTRL, RX_EN, 1, 1)
155
+ FIELD(CTRL, TX_INTEN, 2, 1)
156
+ FIELD(CTRL, RX_INTEN, 3, 1)
157
+ FIELD(CTRL, TXO_INTEN, 4, 1)
158
+ FIELD(CTRL, RXO_INTEN, 5, 1)
159
+ FIELD(CTRL, HSTEST, 6, 1)
160
+REG32(INTSTATUS, 0xc)
161
+ FIELD(INTSTATUS, TX, 0, 1)
162
+ FIELD(INTSTATUS, RX, 1, 1)
163
+ FIELD(INTSTATUS, TXO, 2, 1)
164
+ FIELD(INTSTATUS, RXO, 3, 1)
165
+REG32(BAUDDIV, 0x10)
166
+REG32(PID4, 0xFD0)
167
+REG32(PID5, 0xFD4)
168
+REG32(PID6, 0xFD8)
169
+REG32(PID7, 0xFDC)
170
+REG32(PID0, 0xFE0)
171
+REG32(PID1, 0xFE4)
172
+REG32(PID2, 0xFE8)
173
+REG32(PID3, 0xFEC)
174
+REG32(CID0, 0xFF0)
175
+REG32(CID1, 0xFF4)
176
+REG32(CID2, 0xFF8)
177
+REG32(CID3, 0xFFC)
178
+
179
+/* PID/CID values */
180
+static const int uart_id[] = {
181
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
182
+ 0x21, 0xb8, 0x1b, 0x00, /* PID0..PID3 */
183
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
184
+};
185
+
186
+static bool uart_baudrate_ok(CMSDKAPBUART *s)
187
+{
188
+ /* The minimum permitted bauddiv setting is 16, so we just ignore
189
+ * settings below that (usually this means the device has just
190
+ * been reset and not yet programmed).
191
+ */
192
+ return s->bauddiv >= 16 && s->bauddiv <= s->pclk_frq;
193
+}
194
+
195
+static void uart_update_parameters(CMSDKAPBUART *s)
196
+{
197
+ QEMUSerialSetParams ssp;
198
+
199
+ /* This UART is always 8N1 but the baud rate is programmable. */
200
+ if (!uart_baudrate_ok(s)) {
201
+ return;
202
+ }
57
+ }
203
+
58
+
204
+ ssp.data_bits = 8;
59
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
205
+ ssp.parity = 'N';
60
ret = boot_sector_init(disk);
206
+ ssp.stop_bits = 1;
61
if (ret) {
207
+ ssp.speed = s->pclk_frq / s->bauddiv;
62
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
208
+ qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
63
index XXXXXXX..XXXXXXX 100644
209
+ trace_cmsdk_apb_uart_set_params(ssp.speed);
64
--- a/tests/qtest/boot-serial-test.c
210
+}
65
+++ b/tests/qtest/boot-serial-test.c
211
+
66
@@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[])
212
+static void cmsdk_apb_uart_update(CMSDKAPBUART *s)
67
213
+{
68
g_test_init(&argc, &argv, NULL);
214
+ /* update outbound irqs, including handling the way the rxo and txo
69
215
+ * interrupt status bits are just logical AND of the overrun bit in
70
+ if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
216
+ * STATE and the overrun interrupt enable bit in CTRL.
71
+ g_test_skip("No KVM or TCG accelerator available");
217
+ */
72
+ return 0;
218
+ uint32_t omask = (R_INTSTATUS_RXO_MASK | R_INTSTATUS_TXO_MASK);
219
+ s->intstatus &= ~omask;
220
+ s->intstatus |= (s->state & (s->ctrl >> 2) & omask);
221
+
222
+ qemu_set_irq(s->txint, !!(s->intstatus & R_INTSTATUS_TX_MASK));
223
+ qemu_set_irq(s->rxint, !!(s->intstatus & R_INTSTATUS_RX_MASK));
224
+ qemu_set_irq(s->txovrint, !!(s->intstatus & R_INTSTATUS_TXO_MASK));
225
+ qemu_set_irq(s->rxovrint, !!(s->intstatus & R_INTSTATUS_RXO_MASK));
226
+ qemu_set_irq(s->uartint, !!(s->intstatus));
227
+}
228
+
229
+static int uart_can_receive(void *opaque)
230
+{
231
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
232
+
233
+ /* We can take a char if RX is enabled and the buffer is empty */
234
+ if (s->ctrl & R_CTRL_RX_EN_MASK && !(s->state & R_STATE_RXFULL_MASK)) {
235
+ return 1;
236
+ }
237
+ return 0;
238
+}
239
+
240
+static void uart_receive(void *opaque, const uint8_t *buf, int size)
241
+{
242
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
243
+
244
+ trace_cmsdk_apb_uart_receive(*buf);
245
+
246
+ /* In fact uart_can_receive() ensures that we can't be
247
+ * called unless RX is enabled and the buffer is empty,
248
+ * but we include this logic as documentation of what the
249
+ * hardware does if a character arrives in these circumstances.
250
+ */
251
+ if (!(s->ctrl & R_CTRL_RX_EN_MASK)) {
252
+ /* Just drop the character on the floor */
253
+ return;
254
+ }
73
+ }
255
+
74
+
256
+ if (s->state & R_STATE_RXFULL_MASK) {
75
for (i = 0; tests[i].arch != NULL; i++) {
257
+ s->state |= R_STATE_RXOVERRUN_MASK;
76
if (g_str_equal(arch, tests[i].arch) &&
77
qtest_has_machine(tests[i].machine)) {
78
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
79
index XXXXXXX..XXXXXXX 100644
80
--- a/tests/qtest/migration-test.c
81
+++ b/tests/qtest/migration-test.c
82
@@ -XXX,XX +XXX,XX @@ static bool kvm_dirty_ring_supported(void)
83
84
int main(int argc, char **argv)
85
{
86
- bool has_kvm;
87
+ bool has_kvm, has_tcg;
88
bool has_uffd;
89
const char *arch;
90
g_autoptr(GError) err = NULL;
91
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
92
g_test_init(&argc, &argv, NULL);
93
94
has_kvm = qtest_has_accel("kvm");
95
+ has_tcg = qtest_has_accel("tcg");
96
+
97
+ if (!has_tcg && !has_kvm) {
98
+ g_test_skip("No KVM or TCG accelerator available");
99
+ return 0;
258
+ }
100
+ }
259
+
101
+
260
+ s->rxbuf = *buf;
102
has_uffd = ufd_version_check();
261
+ s->state |= R_STATE_RXFULL_MASK;
103
arch = qtest_get_arch();
262
+ if (s->ctrl & R_CTRL_RX_INTEN_MASK) {
104
263
+ s->intstatus |= R_INTSTATUS_RX_MASK;
105
diff --git a/tests/qtest/pxe-test.c b/tests/qtest/pxe-test.c
264
+ }
106
index XXXXXXX..XXXXXXX 100644
265
+ cmsdk_apb_uart_update(s);
107
--- a/tests/qtest/pxe-test.c
266
+}
108
+++ b/tests/qtest/pxe-test.c
109
@@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[])
110
int ret;
111
const char *arch = qtest_get_arch();
112
113
+ g_test_init(&argc, &argv, NULL);
267
+
114
+
268
+static uint64_t uart_read(void *opaque, hwaddr offset, unsigned size)
115
+ if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
269
+{
116
+ g_test_skip("No KVM or TCG accelerator available");
270
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
117
+ return 0;
271
+ uint64_t r;
272
+
273
+ switch (offset) {
274
+ case A_DATA:
275
+ r = s->rxbuf;
276
+ s->state &= ~R_STATE_RXFULL_MASK;
277
+ cmsdk_apb_uart_update(s);
278
+ break;
279
+ case A_STATE:
280
+ r = s->state;
281
+ break;
282
+ case A_CTRL:
283
+ r = s->ctrl;
284
+ break;
285
+ case A_INTSTATUS:
286
+ r = s->intstatus;
287
+ break;
288
+ case A_BAUDDIV:
289
+ r = s->bauddiv;
290
+ break;
291
+ case A_PID4 ... A_CID3:
292
+ r = uart_id[(offset - A_PID4) / 4];
293
+ break;
294
+ default:
295
+ qemu_log_mask(LOG_GUEST_ERROR,
296
+ "CMSDK APB UART read: bad offset %x\n", (int) offset);
297
+ r = 0;
298
+ break;
299
+ }
300
+ trace_cmsdk_apb_uart_read(offset, r, size);
301
+ return r;
302
+}
303
+
304
+/* Try to send tx data, and arrange to be called back later if
305
+ * we can't (ie the char backend is busy/blocking).
306
+ */
307
+static gboolean uart_transmit(GIOChannel *chan, GIOCondition cond, void *opaque)
308
+{
309
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
310
+ int ret;
311
+
312
+ s->watch_tag = 0;
313
+
314
+ if (!(s->ctrl & R_CTRL_TX_EN_MASK) || !(s->state & R_STATE_TXFULL_MASK)) {
315
+ return FALSE;
316
+ }
118
+ }
317
+
119
+
318
+ ret = qemu_chr_fe_write(&s->chr, &s->txbuf, 1);
120
ret = boot_sector_init(disk);
319
+ if (ret <= 0) {
121
if(ret)
320
+ s->watch_tag = qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP,
122
return ret;
321
+ uart_transmit, s);
123
322
+ if (!s->watch_tag) {
124
- g_test_init(&argc, &argv, NULL);
323
+ /* Most common reason to be here is "no chardev backend":
125
324
+ * just insta-drain the buffer, so the serial output
126
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
325
+ * goes into a void, rather than blocking the guest.
127
test_batch(x86_tests, false);
326
+ */
128
diff --git a/tests/qtest/vmgenid-test.c b/tests/qtest/vmgenid-test.c
327
+ goto buffer_drained;
129
index XXXXXXX..XXXXXXX 100644
328
+ }
130
--- a/tests/qtest/vmgenid-test.c
329
+ /* Transmit pending */
131
+++ b/tests/qtest/vmgenid-test.c
330
+ trace_cmsdk_apb_uart_tx_pending();
132
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
331
+ return FALSE;
133
{
134
int ret;
135
136
+ g_test_init(&argc, &argv, NULL);
137
+
138
+ if (!qtest_has_accel("tcg") && !qtest_has_accel("kvm")) {
139
+ g_test_skip("No KVM or TCG accelerator available");
140
+ return 0;
332
+ }
141
+ }
333
+
142
+
334
+buffer_drained:
143
ret = boot_sector_init(disk);
335
+ /* Character successfully sent */
144
if (ret) {
336
+ trace_cmsdk_apb_uart_tx(s->txbuf);
145
return ret;
337
+ s->state &= ~R_STATE_TXFULL_MASK;
146
}
338
+ /* Going from TXFULL set to clear triggers the tx interrupt */
147
339
+ if (s->ctrl & R_CTRL_TX_INTEN_MASK) {
148
- g_test_init(&argc, &argv, NULL);
340
+ s->intstatus |= R_INTSTATUS_TX_MASK;
149
-
341
+ }
150
qtest_add_func("/vmgenid/vmgenid/set-guid",
342
+ cmsdk_apb_uart_update(s);
151
vmgenid_set_guid_test);
343
+ return FALSE;
152
qtest_add_func("/vmgenid/vmgenid/set-guid-auto",
344
+}
345
+
346
+static void uart_cancel_transmit(CMSDKAPBUART *s)
347
+{
348
+ if (s->watch_tag) {
349
+ g_source_remove(s->watch_tag);
350
+ s->watch_tag = 0;
351
+ }
352
+}
353
+
354
+static void uart_write(void *opaque, hwaddr offset, uint64_t value,
355
+ unsigned size)
356
+{
357
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
358
+
359
+ trace_cmsdk_apb_uart_write(offset, value, size);
360
+
361
+ switch (offset) {
362
+ case A_DATA:
363
+ s->txbuf = value;
364
+ if (s->state & R_STATE_TXFULL_MASK) {
365
+ /* Buffer already full -- note the overrun and let the
366
+ * existing pending transmit callback handle the new char.
367
+ */
368
+ s->state |= R_STATE_TXOVERRUN_MASK;
369
+ cmsdk_apb_uart_update(s);
370
+ } else {
371
+ s->state |= R_STATE_TXFULL_MASK;
372
+ uart_transmit(NULL, G_IO_OUT, s);
373
+ }
374
+ break;
375
+ case A_STATE:
376
+ /* Bits 0 and 1 are read only; bits 2 and 3 are W1C */
377
+ s->state &= ~(value &
378
+ (R_STATE_TXOVERRUN_MASK | R_STATE_RXOVERRUN_MASK));
379
+ cmsdk_apb_uart_update(s);
380
+ break;
381
+ case A_CTRL:
382
+ s->ctrl = value & 0x7f;
383
+ if ((s->ctrl & R_CTRL_TX_EN_MASK) && !uart_baudrate_ok(s)) {
384
+ qemu_log_mask(LOG_GUEST_ERROR,
385
+ "CMSDK APB UART: Tx enabled with invalid baudrate\n");
386
+ }
387
+ cmsdk_apb_uart_update(s);
388
+ break;
389
+ case A_INTSTATUS:
390
+ /* All bits are W1C. Clearing the overrun interrupt bits really
391
+ * clears the overrun status bits in the STATE register (which
392
+ * is then reflected into the intstatus value by the update function).
393
+ */
394
+ s->state &= ~(value & (R_INTSTATUS_TXO_MASK | R_INTSTATUS_RXO_MASK));
395
+ cmsdk_apb_uart_update(s);
396
+ break;
397
+ case A_BAUDDIV:
398
+ s->bauddiv = value & 0xFFFFF;
399
+ uart_update_parameters(s);
400
+ break;
401
+ case A_PID4 ... A_CID3:
402
+ qemu_log_mask(LOG_GUEST_ERROR,
403
+ "CMSDK APB UART write: write to RO offset 0x%x\n",
404
+ (int)offset);
405
+ break;
406
+ default:
407
+ qemu_log_mask(LOG_GUEST_ERROR,
408
+ "CMSDK APB UART write: bad offset 0x%x\n", (int) offset);
409
+ break;
410
+ }
411
+}
412
+
413
+static const MemoryRegionOps uart_ops = {
414
+ .read = uart_read,
415
+ .write = uart_write,
416
+ .endianness = DEVICE_LITTLE_ENDIAN,
417
+};
418
+
419
+static void cmsdk_apb_uart_reset(DeviceState *dev)
420
+{
421
+ CMSDKAPBUART *s = CMSDK_APB_UART(dev);
422
+
423
+ trace_cmsdk_apb_uart_reset();
424
+ uart_cancel_transmit(s);
425
+ s->state = 0;
426
+ s->ctrl = 0;
427
+ s->intstatus = 0;
428
+ s->bauddiv = 0;
429
+ s->txbuf = 0;
430
+ s->rxbuf = 0;
431
+}
432
+
433
+static void cmsdk_apb_uart_init(Object *obj)
434
+{
435
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
436
+ CMSDKAPBUART *s = CMSDK_APB_UART(obj);
437
+
438
+ memory_region_init_io(&s->iomem, obj, &uart_ops, s, "uart", 0x1000);
439
+ sysbus_init_mmio(sbd, &s->iomem);
440
+ sysbus_init_irq(sbd, &s->txint);
441
+ sysbus_init_irq(sbd, &s->rxint);
442
+ sysbus_init_irq(sbd, &s->txovrint);
443
+ sysbus_init_irq(sbd, &s->rxovrint);
444
+ sysbus_init_irq(sbd, &s->uartint);
445
+}
446
+
447
+static void cmsdk_apb_uart_realize(DeviceState *dev, Error **errp)
448
+{
449
+ CMSDKAPBUART *s = CMSDK_APB_UART(dev);
450
+
451
+ if (s->pclk_frq == 0) {
452
+ error_setg(errp, "CMSDK APB UART: pclk-frq property must be set");
453
+ return;
454
+ }
455
+
456
+ /* This UART has no flow control, so we do not need to register
457
+ * an event handler to deal with CHR_EVENT_BREAK.
458
+ */
459
+ qemu_chr_fe_set_handlers(&s->chr, uart_can_receive, uart_receive,
460
+ NULL, s, NULL, true);
461
+}
462
+
463
+static int cmsdk_apb_uart_post_load(void *opaque, int version_id)
464
+{
465
+ CMSDKAPBUART *s = CMSDK_APB_UART(opaque);
466
+
467
+ /* If we have a pending character, arrange to resend it. */
468
+ if (s->state & R_STATE_TXFULL_MASK) {
469
+ s->watch_tag = qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP,
470
+ uart_transmit, s);
471
+ }
472
+ uart_update_parameters(s);
473
+ return 0;
474
+}
475
+
476
+static const VMStateDescription cmsdk_apb_uart_vmstate = {
477
+ .name = "cmsdk-apb-uart",
478
+ .version_id = 1,
479
+ .minimum_version_id = 1,
480
+ .post_load = cmsdk_apb_uart_post_load,
481
+ .fields = (VMStateField[]) {
482
+ VMSTATE_UINT32(state, CMSDKAPBUART),
483
+ VMSTATE_UINT32(ctrl, CMSDKAPBUART),
484
+ VMSTATE_UINT32(intstatus, CMSDKAPBUART),
485
+ VMSTATE_UINT32(bauddiv, CMSDKAPBUART),
486
+ VMSTATE_UINT8(txbuf, CMSDKAPBUART),
487
+ VMSTATE_UINT8(rxbuf, CMSDKAPBUART),
488
+ VMSTATE_END_OF_LIST()
489
+ }
490
+};
491
+
492
+static Property cmsdk_apb_uart_properties[] = {
493
+ DEFINE_PROP_CHR("chardev", CMSDKAPBUART, chr),
494
+ DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBUART, pclk_frq, 0),
495
+ DEFINE_PROP_END_OF_LIST(),
496
+};
497
+
498
+static void cmsdk_apb_uart_class_init(ObjectClass *klass, void *data)
499
+{
500
+ DeviceClass *dc = DEVICE_CLASS(klass);
501
+
502
+ dc->realize = cmsdk_apb_uart_realize;
503
+ dc->vmsd = &cmsdk_apb_uart_vmstate;
504
+ dc->reset = cmsdk_apb_uart_reset;
505
+ dc->props = cmsdk_apb_uart_properties;
506
+}
507
+
508
+static const TypeInfo cmsdk_apb_uart_info = {
509
+ .name = TYPE_CMSDK_APB_UART,
510
+ .parent = TYPE_SYS_BUS_DEVICE,
511
+ .instance_size = sizeof(CMSDKAPBUART),
512
+ .instance_init = cmsdk_apb_uart_init,
513
+ .class_init = cmsdk_apb_uart_class_init,
514
+};
515
+
516
+static void cmsdk_apb_uart_register_types(void)
517
+{
518
+ type_register_static(&cmsdk_apb_uart_info);
519
+}
520
+
521
+type_init(cmsdk_apb_uart_register_types);
522
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
523
index XXXXXXX..XXXXXXX 100644
524
--- a/default-configs/arm-softmmu.mak
525
+++ b/default-configs/arm-softmmu.mak
526
@@ -XXX,XX +XXX,XX @@ CONFIG_STM32F2XX_ADC=y
527
CONFIG_STM32F2XX_SPI=y
528
CONFIG_STM32F205_SOC=y
529
530
+CONFIG_CMSDK_APB_UART=y
531
+
532
CONFIG_VERSATILE_PCI=y
533
CONFIG_VERSATILE_I2C=y
534
535
diff --git a/hw/char/trace-events b/hw/char/trace-events
536
index XXXXXXX..XXXXXXX 100644
537
--- a/hw/char/trace-events
538
+++ b/hw/char/trace-events
539
@@ -XXX,XX +XXX,XX @@ pl011_write(uint32_t addr, uint32_t value) "addr 0x%08x value 0x%08x"
540
pl011_can_receive(uint32_t lcr, int read_count, int r) "LCR %08x read_count %d returning %d"
541
pl011_put_fifo(uint32_t c, int read_count) "new char 0x%x read_count now %d"
542
pl011_put_fifo_full(void) "FIFO now full, RXFF set"
543
+
544
+# hw/char/cmsdk_apb_uart.c
545
+cmsdk_apb_uart_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB UART read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
546
+cmsdk_apb_uart_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB UART write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
547
+cmsdk_apb_uart_reset(void) "CMSDK APB UART: reset"
548
+cmsdk_apb_uart_receive(uint8_t c) "CMSDK APB UART: got character 0x%x from backend"
549
+cmsdk_apb_uart_tx_pending(void) "CMSDK APB UART: character send to backend pending"
550
+cmsdk_apb_uart_tx(uint8_t c) "CMSDK APB UART: character 0x%x sent to backend"
551
+cmsdk_apb_uart_set_params(int speed) "CMSDK APB UART: params set to %d 8N1"
552
--
153
--
553
2.7.4
154
2.34.1
554
155
555
156
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
The migration tests are currently broken for an aarch64 host because
4
the tests pass no 'machine' and 'cpu' options on the QEMU command
5
line.
6
7
Add a separate class to each architecture so that we can specify
8
'machine' and 'cpu' options instead of relying on defaults.
9
10
Add a skip decorator to keep the current behavior of only running
11
migration tests when the qemu target matches the host architecture.
12
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Signed-off-by: Fabiano Rosas <farosas@suse.de>
15
Message-id: 20230426180013.14814-10-farosas@suse.de
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
tests/avocado/migration.py | 83 +++++++++++++++++++++++++++++++++++---
19
1 file changed, 78 insertions(+), 5 deletions(-)
20
21
diff --git a/tests/avocado/migration.py b/tests/avocado/migration.py
22
index XXXXXXX..XXXXXXX 100644
23
--- a/tests/avocado/migration.py
24
+++ b/tests/avocado/migration.py
25
@@ -XXX,XX +XXX,XX @@
26
27
28
import tempfile
29
+import os
30
+
31
from avocado_qemu import QemuSystemTest
32
from avocado import skipUnless
33
34
@@ -XXX,XX +XXX,XX @@
35
from avocado.utils.path import find_command
36
37
38
-class Migration(QemuSystemTest):
39
+class MigrationTest(QemuSystemTest):
40
"""
41
:avocado: tags=migration
42
"""
43
@@ -XXX,XX +XXX,XX @@ def _get_free_port(self):
44
self.cancel('Failed to find a free port')
45
return port
46
47
-
48
- def test_migration_with_tcp_localhost(self):
49
+ def migration_with_tcp_localhost(self):
50
dest_uri = 'tcp:localhost:%u' % self._get_free_port()
51
self.do_migrate(dest_uri)
52
53
- def test_migration_with_unix(self):
54
+ def migration_with_unix(self):
55
with tempfile.TemporaryDirectory(prefix='socket_') as socket_path:
56
dest_uri = 'unix:%s/qemu-test.sock' % socket_path
57
self.do_migrate(dest_uri)
58
59
@skipUnless(find_command('nc', default=False), "'nc' command not found")
60
- def test_migration_with_exec(self):
61
+ def migration_with_exec(self):
62
"""The test works for both netcat-traditional and netcat-openbsd packages."""
63
free_port = self._get_free_port()
64
dest_uri = 'exec:nc -l localhost %u' % free_port
65
src_uri = 'exec:nc localhost %u' % free_port
66
self.do_migrate(dest_uri, src_uri)
67
+
68
+
69
+@skipUnless('aarch64' in os.uname()[4], "host != target")
70
+class Aarch64(MigrationTest):
71
+ """
72
+ :avocado: tags=arch:aarch64
73
+ :avocado: tags=machine:virt
74
+ :avocado: tags=cpu:max
75
+ """
76
+
77
+ def test_migration_with_tcp_localhost(self):
78
+ self.migration_with_tcp_localhost()
79
+
80
+ def test_migration_with_unix(self):
81
+ self.migration_with_unix()
82
+
83
+ def test_migration_with_exec(self):
84
+ self.migration_with_exec()
85
+
86
+
87
+@skipUnless('x86_64' in os.uname()[4], "host != target")
88
+class X86_64(MigrationTest):
89
+ """
90
+ :avocado: tags=arch:x86_64
91
+ :avocado: tags=machine:pc
92
+ :avocado: tags=cpu:qemu64
93
+ """
94
+
95
+ def test_migration_with_tcp_localhost(self):
96
+ self.migration_with_tcp_localhost()
97
+
98
+ def test_migration_with_unix(self):
99
+ self.migration_with_unix()
100
+
101
+ def test_migration_with_exec(self):
102
+ self.migration_with_exec()
103
+
104
+
105
+@skipUnless('ppc64le' in os.uname()[4], "host != target")
106
+class PPC64(MigrationTest):
107
+ """
108
+ :avocado: tags=arch:ppc64
109
+ :avocado: tags=machine:pseries
110
+ :avocado: tags=cpu:power9_v2.0
111
+ """
112
+
113
+ def test_migration_with_tcp_localhost(self):
114
+ self.migration_with_tcp_localhost()
115
+
116
+ def test_migration_with_unix(self):
117
+ self.migration_with_unix()
118
+
119
+ def test_migration_with_exec(self):
120
+ self.migration_with_exec()
121
+
122
+
123
+@skipUnless('s390x' in os.uname()[4], "host != target")
124
+class S390X(MigrationTest):
125
+ """
126
+ :avocado: tags=arch:s390x
127
+ :avocado: tags=machine:s390-ccw-virtio
128
+ :avocado: tags=cpu:qemu
129
+ """
130
+
131
+ def test_migration_with_tcp_localhost(self):
132
+ self.migration_with_tcp_localhost()
133
+
134
+ def test_migration_with_unix(self):
135
+ self.migration_with_unix()
136
+
137
+ def test_migration_with_exec(self):
138
+ self.migration_with_exec()
139
--
140
2.34.1
141
142
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
We are about to enable the build without TCG, so CONFIG_SEMIHOSTING
4
and CONFIG_ARM_COMPATIBLE_SEMIHOSTING cannot be unconditionally set in
5
default.mak anymore. So reflect the change in a Kconfig.
6
7
Instead of using semihosting/Kconfig, use a target-specific file, so
8
that the change doesn't affect other architectures which might
9
implement semihosting in a way compatible with KVM.
10
11
The selection from ARM_v7M needs to be removed to avoid a cycle during
12
parsing.
13
14
Signed-off-by: Fabiano Rosas <farosas@suse.de>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 20230426180013.14814-11-farosas@suse.de
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
19
configs/devices/arm-softmmu/default.mak | 2 --
20
hw/arm/Kconfig | 1 -
21
target/arm/Kconfig | 7 +++++++
22
3 files changed, 7 insertions(+), 3 deletions(-)
23
24
diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak
25
index XXXXXXX..XXXXXXX 100644
26
--- a/configs/devices/arm-softmmu/default.mak
27
+++ b/configs/devices/arm-softmmu/default.mak
28
@@ -XXX,XX +XXX,XX @@ CONFIG_MICROBIT=y
29
CONFIG_FSL_IMX25=y
30
CONFIG_FSL_IMX7=y
31
CONFIG_FSL_IMX6UL=y
32
-CONFIG_SEMIHOSTING=y
33
-CONFIG_ARM_COMPATIBLE_SEMIHOSTING=y
34
CONFIG_ALLWINNER_H3=y
35
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
36
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/arm/Kconfig
38
+++ b/hw/arm/Kconfig
39
@@ -XXX,XX +XXX,XX @@ config ARM_V7M
40
# currently v7M must be included in a TCG build due to translate.c
41
default y if TCG && (ARM || AARCH64)
42
select PTIMER
43
- select ARM_COMPATIBLE_SEMIHOSTING
44
45
config ALLWINNER_A10
46
bool
47
diff --git a/target/arm/Kconfig b/target/arm/Kconfig
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/Kconfig
50
+++ b/target/arm/Kconfig
51
@@ -XXX,XX +XXX,XX @@ config ARM
52
config AARCH64
53
bool
54
select ARM
55
+
56
+# This config exists just so we can make SEMIHOSTING default when TCG
57
+# is selected without also changing it for other architectures.
58
+config ARM_SEMIHOSTING
59
+ bool
60
+ default y if TCG && ARM
61
+ select ARM_COMPATIBLE_SEMIHOSTING
62
--
63
2.34.1
diff view generated by jsdifflib
New patch
1
1
From: Fabiano Rosas <farosas@suse.de>
2
3
Move all the CONFIG_FOO=y from default.mak into "default y if TCG"
4
statements in Kconfig. That way they won't be selected when
5
CONFIG_TCG=n.
6
7
I'm leaving CONFIG_ARM_VIRT in default.mak because it allows us to
8
keep the two default.mak files not empty and keep aarch64-default.mak
9
including arm-default.mak. That way we don't surprise anyone that's
10
used to altering these files.
11
12
With this change we can start building with --disable-tcg.
13
14
Signed-off-by: Fabiano Rosas <farosas@suse.de>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 20230426180013.14814-12-farosas@suse.de
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
19
configs/devices/aarch64-softmmu/default.mak | 4 --
20
configs/devices/arm-softmmu/default.mak | 37 ------------------
21
hw/arm/Kconfig | 42 ++++++++++++++++++++-
22
3 files changed, 41 insertions(+), 42 deletions(-)
23
24
diff --git a/configs/devices/aarch64-softmmu/default.mak b/configs/devices/aarch64-softmmu/default.mak
25
index XXXXXXX..XXXXXXX 100644
26
--- a/configs/devices/aarch64-softmmu/default.mak
27
+++ b/configs/devices/aarch64-softmmu/default.mak
28
@@ -XXX,XX +XXX,XX @@
29
30
# We support all the 32 bit boards so need all their config
31
include ../arm-softmmu/default.mak
32
-
33
-CONFIG_XLNX_ZYNQMP_ARM=y
34
-CONFIG_XLNX_VERSAL=y
35
-CONFIG_SBSA_REF=y
36
diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak
37
index XXXXXXX..XXXXXXX 100644
38
--- a/configs/devices/arm-softmmu/default.mak
39
+++ b/configs/devices/arm-softmmu/default.mak
40
@@ -XXX,XX +XXX,XX @@
41
# CONFIG_TEST_DEVICES=n
42
43
CONFIG_ARM_VIRT=y
44
-CONFIG_CUBIEBOARD=y
45
-CONFIG_EXYNOS4=y
46
-CONFIG_HIGHBANK=y
47
-CONFIG_INTEGRATOR=y
48
-CONFIG_FSL_IMX31=y
49
-CONFIG_MUSICPAL=y
50
-CONFIG_MUSCA=y
51
-CONFIG_CHEETAH=y
52
-CONFIG_SX1=y
53
-CONFIG_NSERIES=y
54
-CONFIG_STELLARIS=y
55
-CONFIG_STM32VLDISCOVERY=y
56
-CONFIG_REALVIEW=y
57
-CONFIG_VERSATILE=y
58
-CONFIG_VEXPRESS=y
59
-CONFIG_ZYNQ=y
60
-CONFIG_MAINSTONE=y
61
-CONFIG_GUMSTIX=y
62
-CONFIG_SPITZ=y
63
-CONFIG_TOSA=y
64
-CONFIG_Z2=y
65
-CONFIG_NPCM7XX=y
66
-CONFIG_COLLIE=y
67
-CONFIG_ASPEED_SOC=y
68
-CONFIG_NETDUINO2=y
69
-CONFIG_NETDUINOPLUS2=y
70
-CONFIG_OLIMEX_STM32_H405=y
71
-CONFIG_MPS2=y
72
-CONFIG_RASPI=y
73
-CONFIG_DIGIC=y
74
-CONFIG_SABRELITE=y
75
-CONFIG_EMCRAFT_SF2=y
76
-CONFIG_MICROBIT=y
77
-CONFIG_FSL_IMX25=y
78
-CONFIG_FSL_IMX7=y
79
-CONFIG_FSL_IMX6UL=y
80
-CONFIG_ALLWINNER_H3=y
81
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
82
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/arm/Kconfig
84
+++ b/hw/arm/Kconfig
85
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
86
87
config CHEETAH
88
bool
89
+ default y if TCG && ARM
90
select OMAP
91
select TSC210X
92
93
config CUBIEBOARD
94
bool
95
+ default y if TCG && ARM
96
select ALLWINNER_A10
97
98
config DIGIC
99
bool
100
+ default y if TCG && ARM
101
select PTIMER
102
select PFLASH_CFI02
103
104
config EXYNOS4
105
bool
106
+ default y if TCG && ARM
107
imply I2C_DEVICES
108
select A9MPCORE
109
select I2C
110
@@ -XXX,XX +XXX,XX @@ config EXYNOS4
111
112
config HIGHBANK
113
bool
114
+ default y if TCG && ARM
115
select A9MPCORE
116
select A15MPCORE
117
select AHCI
118
@@ -XXX,XX +XXX,XX @@ config HIGHBANK
119
120
config INTEGRATOR
121
bool
122
+ default y if TCG && ARM
123
select ARM_TIMER
124
select INTEGRATOR_DEBUG
125
select PL011 # UART
126
@@ -XXX,XX +XXX,XX @@ config INTEGRATOR
127
128
config MAINSTONE
129
bool
130
+ default y if TCG && ARM
131
select PXA2XX
132
select PFLASH_CFI01
133
select SMC91C111
134
135
config MUSCA
136
bool
137
+ default y if TCG && ARM
138
select ARMSSE
139
select PL011
140
select PL031
141
@@ -XXX,XX +XXX,XX @@ config MARVELL_88W8618
142
143
config MUSICPAL
144
bool
145
+ default y if TCG && ARM
146
select OR_IRQ
147
select BITBANG_I2C
148
select MARVELL_88W8618
149
@@ -XXX,XX +XXX,XX @@ config MUSICPAL
150
151
config NETDUINO2
152
bool
153
+ default y if TCG && ARM
154
select STM32F205_SOC
155
156
config NETDUINOPLUS2
157
bool
158
+ default y if TCG && ARM
159
select STM32F405_SOC
160
161
config OLIMEX_STM32_H405
162
bool
163
+ default y if TCG && ARM
164
select STM32F405_SOC
165
166
config NSERIES
167
bool
168
+ default y if TCG && ARM
169
select OMAP
170
select TMP105 # temperature sensor
171
select BLIZZARD # LCD/TV controller
172
@@ -XXX,XX +XXX,XX @@ config PXA2XX
173
174
config GUMSTIX
175
bool
176
+ default y if TCG && ARM
177
select PFLASH_CFI01
178
select SMC91C111
179
select PXA2XX
180
181
config TOSA
182
bool
183
+ default y if TCG && ARM
184
select ZAURUS # scoop
185
select MICRODRIVE
186
select PXA2XX
187
@@ -XXX,XX +XXX,XX @@ config TOSA
188
189
config SPITZ
190
bool
191
+ default y if TCG && ARM
192
select ADS7846 # touch-screen controller
193
select MAX111X # A/D converter
194
select WM8750 # audio codec
195
@@ -XXX,XX +XXX,XX @@ config SPITZ
196
197
config Z2
198
bool
199
+ default y if TCG && ARM
200
select PFLASH_CFI01
201
select WM8750
202
select PL011 # UART
203
@@ -XXX,XX +XXX,XX @@ config Z2
204
205
config REALVIEW
206
bool
207
+ default y if TCG && ARM
208
imply PCI_DEVICES
209
imply PCI_TESTDEV
210
imply I2C_DEVICES
211
@@ -XXX,XX +XXX,XX @@ config REALVIEW
212
213
config SBSA_REF
214
bool
215
+ default y if TCG && AARCH64
216
imply PCI_DEVICES
217
select AHCI
218
select ARM_SMMUV3
219
@@ -XXX,XX +XXX,XX @@ config SBSA_REF
220
221
config SABRELITE
222
bool
223
+ default y if TCG && ARM
224
select FSL_IMX6
225
select SSI_M25P80
226
227
config STELLARIS
228
bool
229
+ default y if TCG && ARM
230
imply I2C_DEVICES
231
select ARM_V7M
232
select CMSDK_APB_WATCHDOG
233
@@ -XXX,XX +XXX,XX @@ config STELLARIS
234
235
config STM32VLDISCOVERY
236
bool
237
+ default y if TCG && ARM
238
select STM32F100_SOC
239
240
config STRONGARM
241
@@ -XXX,XX +XXX,XX @@ config STRONGARM
242
243
config COLLIE
244
bool
245
+ default y if TCG && ARM
246
select PFLASH_CFI01
247
select ZAURUS # scoop
248
select STRONGARM
249
250
config SX1
251
bool
252
+ default y if TCG && ARM
253
select OMAP
254
255
config VERSATILE
256
bool
257
+ default y if TCG && ARM
258
select ARM_TIMER # sp804
259
select PFLASH_CFI01
260
select LSI_SCSI_PCI
261
@@ -XXX,XX +XXX,XX @@ config VERSATILE
262
263
config VEXPRESS
264
bool
265
+ default y if TCG && ARM
266
select A9MPCORE
267
select A15MPCORE
268
select ARM_MPTIMER
269
@@ -XXX,XX +XXX,XX @@ config VEXPRESS
270
271
config ZYNQ
272
bool
273
+ default y if TCG && ARM
274
select A9MPCORE
275
select CADENCE # UART
276
select PFLASH_CFI02
277
@@ -XXX,XX +XXX,XX @@ config ZYNQ
278
config ARM_V7M
279
bool
280
# currently v7M must be included in a TCG build due to translate.c
281
- default y if TCG && (ARM || AARCH64)
282
+ default y if TCG && ARM
283
select PTIMER
284
285
config ALLWINNER_A10
286
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
287
288
config ALLWINNER_H3
289
bool
290
+ default y if TCG && ARM
291
select ALLWINNER_A10_PIT
292
select ALLWINNER_SUN8I_EMAC
293
select ALLWINNER_I2C
294
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_H3
295
296
config RASPI
297
bool
298
+ default y if TCG && ARM
299
select FRAMEBUFFER
300
select PL011 # UART
301
select SDHCI
302
@@ -XXX,XX +XXX,XX @@ config STM32F405_SOC
303
304
config XLNX_ZYNQMP_ARM
305
bool
306
+ default y if TCG && AARCH64
307
select AHCI
308
select ARM_GIC
309
select CADENCE
310
@@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM
311
312
config XLNX_VERSAL
313
bool
314
+ default y if TCG && AARCH64
315
select ARM_GIC
316
select PL011
317
select CADENCE
318
@@ -XXX,XX +XXX,XX @@ config XLNX_VERSAL
319
320
config NPCM7XX
321
bool
322
+ default y if TCG && ARM
323
select A9MPCORE
324
select ADM1272
325
select ARM_GIC
326
@@ -XXX,XX +XXX,XX @@ config NPCM7XX
327
328
config FSL_IMX25
329
bool
330
+ default y if TCG && ARM
331
imply I2C_DEVICES
332
select IMX
333
select IMX_FEC
334
@@ -XXX,XX +XXX,XX @@ config FSL_IMX25
335
336
config FSL_IMX31
337
bool
338
+ default y if TCG && ARM
339
imply I2C_DEVICES
340
select SERIAL
341
select IMX
342
@@ -XXX,XX +XXX,XX @@ config FSL_IMX6
343
344
config ASPEED_SOC
345
bool
346
+ default y if TCG && ARM
347
select DS1338
348
select FTGMAC100
349
select I2C
350
@@ -XXX,XX +XXX,XX @@ config ASPEED_SOC
351
352
config MPS2
353
bool
354
+ default y if TCG && ARM
355
imply I2C_DEVICES
356
select ARMSSE
357
select LAN9118
358
@@ -XXX,XX +XXX,XX @@ config MPS2
359
360
config FSL_IMX7
361
bool
362
+ default y if TCG && ARM
363
imply PCI_DEVICES
364
imply TEST_DEVICES
365
imply I2C_DEVICES
366
@@ -XXX,XX +XXX,XX @@ config ARM_SMMUV3
367
368
config FSL_IMX6UL
369
bool
370
+ default y if TCG && ARM
371
imply I2C_DEVICES
372
select A15MPCORE
373
select IMX
374
@@ -XXX,XX +XXX,XX @@ config FSL_IMX6UL
375
376
config MICROBIT
377
bool
378
+ default y if TCG && ARM
379
select NRF51_SOC
380
381
config NRF51_SOC
382
@@ -XXX,XX +XXX,XX @@ config NRF51_SOC
383
384
config EMCRAFT_SF2
385
bool
386
+ default y if TCG && ARM
387
select MSF2
388
select SSI_M25P80
389
390
--
391
2.34.1
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
The test set -accel tcg, so restrict it to when TCG is present.
4
5
Signed-off-by: Fabiano Rosas <farosas@suse.de>
6
Reviewed-by: Thomas Huth <thuth@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230426180013.14814-13-farosas@suse.de
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
tests/qtest/meson.build | 3 ++-
12
1 file changed, 2 insertions(+), 1 deletion(-)
13
14
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/meson.build
17
+++ b/tests/qtest/meson.build
18
@@ -XXX,XX +XXX,XX @@ qtests_aarch64 = \
19
['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \
20
(config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
21
(config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \
22
- (config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
23
+ (config_all.has_key('CONFIG_TCG') and \
24
+ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \
25
['arm-cpu-features',
26
'numa-test',
27
'boot-serial-test',
28
--
29
2.34.1
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
Add a manual new job to cross-build the aarch64 target with
4
only the KVM accelerator enabled (in particular, no TCG).
5
6
Re-enable running the similar job on the project Aarch64
7
custom runner.
8
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
11
Reviewed-by: Thomas Huth <thuth@redhat.com>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20230426180013.14814-14-farosas@suse.de
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
16
.gitlab-ci.d/crossbuilds.yml | 11 +++++++++++
17
.gitlab-ci.d/custom-runners/ubuntu-22.04-aarch64.yml | 4 ----
18
2 files changed, 11 insertions(+), 4 deletions(-)
19
20
diff --git a/.gitlab-ci.d/crossbuilds.yml b/.gitlab-ci.d/crossbuilds.yml
21
index XXXXXXX..XXXXXXX 100644
22
--- a/.gitlab-ci.d/crossbuilds.yml
23
+++ b/.gitlab-ci.d/crossbuilds.yml
24
@@ -XXX,XX +XXX,XX @@ cross-arm64-xen-only:
25
IMAGE: debian-arm64-cross
26
ACCEL: xen
27
EXTRA_CONFIGURE_OPTS: --disable-tcg --disable-kvm
28
+
29
+# Similar job is run by qemu-project's custom runner by default
30
+cross-arm64-kvm-only:
31
+ extends: .cross_accel_build_job
32
+ needs:
33
+ job: arm64-debian-cross-container
34
+ variables:
35
+ QEMU_JOB_OPTIONAL: 1
36
+ IMAGE: debian-arm64-cross
37
+ ACCEL: kvm
38
+ EXTRA_CONFIGURE_OPTS: --disable-tcg --disable-xen --without-default-devices
39
diff --git a/.gitlab-ci.d/custom-runners/ubuntu-22.04-aarch64.yml b/.gitlab-ci.d/custom-runners/ubuntu-22.04-aarch64.yml
40
index XXXXXXX..XXXXXXX 100644
41
--- a/.gitlab-ci.d/custom-runners/ubuntu-22.04-aarch64.yml
42
+++ b/.gitlab-ci.d/custom-runners/ubuntu-22.04-aarch64.yml
43
@@ -XXX,XX +XXX,XX @@ ubuntu-22.04-aarch64-notcg:
44
- aarch64
45
rules:
46
- if: '$CI_PROJECT_NAMESPACE == "qemu-project" && $CI_COMMIT_BRANCH =~ /^staging/'
47
- when: manual
48
- allow_failure: true
49
- if: "$AARCH64_RUNNER_AVAILABLE"
50
- when: manual
51
- allow_failure: true
52
script:
53
- mkdir build
54
- cd build
55
--
56
2.34.1
57
58
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Patrick Venture <venture@google.com>
2
2
3
While an ISB will ensure any raised IRQs happen on the next
3
The MAC address set from Qemu wasn't being saved into the register space.
4
instruction it doesn't cause any to get raised by itself. We can
5
therefore use a simple tb exit for ISB instructions and rely on the
6
exit_request check at the top of each TB to deal with exiting if
7
needed.
8
4
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
Reviewed-by: Hao Wu <wuhaotsh@google.com>
10
Reviewed-by: Richard Henderson <rth@twiddle.net>
6
Signed-off-by: Patrick Venture <venture@google.com>
11
Message-id: 20170713141928.25419-6-alex.bennee@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
[PMM: moved variable declaration to top of function]
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
11
---
14
target/arm/translate-a64.c | 2 +-
12
hw/net/npcm7xx_emc.c | 32 +++++++++++++++++++++++++-------
15
target/arm/translate.c | 4 ++--
13
1 file changed, 25 insertions(+), 7 deletions(-)
16
2 files changed, 3 insertions(+), 3 deletions(-)
17
14
18
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
15
diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate-a64.c
17
--- a/hw/net/npcm7xx_emc.c
21
+++ b/target/arm/translate-a64.c
18
+++ b/hw/net/npcm7xx_emc.c
22
@@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn,
19
@@ -XXX,XX +XXX,XX @@ static const char *emc_reg_name(int regno)
23
* a self-modified code correctly and also to take
20
24
* any pending interrupts immediately.
21
static void emc_reset(NPCM7xxEMCState *emc)
25
*/
22
{
26
- s->is_jmp = DISAS_UPDATE;
23
+ uint32_t value;
27
+ gen_goto_tb(s, 0, s->pc);
24
+
28
return;
25
trace_npcm7xx_emc_reset(emc->emc_num);
29
default:
26
30
unallocated_encoding(s);
27
memset(&emc->regs[0], 0, sizeof(emc->regs));
31
diff --git a/target/arm/translate.c b/target/arm/translate.c
28
@@ -XXX,XX +XXX,XX @@ static void emc_reset(NPCM7xxEMCState *emc)
32
index XXXXXXX..XXXXXXX 100644
29
33
--- a/target/arm/translate.c
30
emc->tx_active = false;
34
+++ b/target/arm/translate.c
31
emc->rx_active = false;
35
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
32
+
36
* self-modifying code correctly and also to take
33
+ /* Set the MAC address in the register space. */
37
* any pending interrupts immediately.
34
+ value = (emc->conf.macaddr.a[0] << 24) |
38
*/
35
+ (emc->conf.macaddr.a[1] << 16) |
39
- gen_lookup_tb(s);
36
+ (emc->conf.macaddr.a[2] << 8) |
40
+ gen_goto_tb(s, 0, s->pc & ~1);
37
+ emc->conf.macaddr.a[3];
41
return;
38
+ emc->regs[REG_CAMM_BASE] = value;
42
default:
39
+
43
goto illegal_op;
40
+ value = (emc->conf.macaddr.a[4] << 24) | (emc->conf.macaddr.a[5] << 16);
44
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
41
+ emc->regs[REG_CAML_BASE] = value;
45
* and also to take any pending interrupts
42
}
46
* immediately.
43
47
*/
44
static void npcm7xx_emc_reset(DeviceState *dev)
48
- gen_lookup_tb(s);
45
@@ -XXX,XX +XXX,XX @@ static bool emc_receive_filter1(NPCM7xxEMCState *emc, const uint8_t *buf,
49
+ gen_goto_tb(s, 0, s->pc & ~1);
46
}
50
break;
47
case ETH_PKT_UCAST: {
51
default:
48
bool matches;
52
goto illegal_op;
49
+ uint32_t value;
50
+ struct MACAddr mac;
51
if (emc->regs[REG_CAMCMR] & REG_CAMCMR_AUP) {
52
return true;
53
}
54
+
55
+ value = emc->regs[REG_CAMM_BASE];
56
+ mac.a[0] = value >> 24;
57
+ mac.a[1] = value >> 16;
58
+ mac.a[2] = value >> 8;
59
+ mac.a[3] = value >> 0;
60
+ value = emc->regs[REG_CAML_BASE];
61
+ mac.a[4] = value >> 24;
62
+ mac.a[5] = value >> 16;
63
+
64
matches = ((emc->regs[REG_CAMCMR] & REG_CAMCMR_ECMP) &&
65
/* We only support one CAM register, CAM0. */
66
(emc->regs[REG_CAMEN] & (1 << 0)) &&
67
- memcmp(buf, emc->conf.macaddr.a, ETH_ALEN) == 0);
68
+ memcmp(buf, mac.a, ETH_ALEN) == 0);
69
if (emc->regs[REG_CAMCMR] & REG_CAMCMR_CCAM) {
70
*fail_reason = "MACADDR matched, comparison complemented";
71
return !matches;
72
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset,
73
break;
74
case REG_CAMM_BASE + 0:
75
emc->regs[reg] = value;
76
- emc->conf.macaddr.a[0] = value >> 24;
77
- emc->conf.macaddr.a[1] = value >> 16;
78
- emc->conf.macaddr.a[2] = value >> 8;
79
- emc->conf.macaddr.a[3] = value >> 0;
80
break;
81
case REG_CAML_BASE + 0:
82
emc->regs[reg] = value;
83
- emc->conf.macaddr.a[4] = value >> 24;
84
- emc->conf.macaddr.a[5] = value >> 16;
85
break;
86
case REG_MCMDR: {
87
uint32_t prev;
53
--
88
--
54
2.7.4
89
2.34.1
55
90
56
91
diff view generated by jsdifflib
New patch
1
From: Daniel Bertalan <dani@danielbertalan.dev>
1
2
3
This query copies the kernel command line into the message buffer. It
4
was previously stubbed out to return empty, this commit makes it reflect
5
the arguments specified with `-append`.
6
7
I observed the following peculiarities on my Pi 3B+:
8
- If the buffer is shorter than the string, the response header gives
9
the full length, but no data is actually copied.
10
- No NUL terminator is added: even if the buffer is long enough to fit
11
one, the buffer's original contents are preserved past the string's
12
end.
13
- The VC firmware adds the following extra parameters beside the
14
user-supplied ones (via /boot/cmdline.txt): `video`, `vc_mem.mem_base`
15
and `vc_mem.mem_size`. This is currently not implemented in qemu.
16
17
Signed-off-by: Daniel Bertalan <dani@danielbertalan.dev>
18
Message-id: 20230425103250.56653-1-dani@danielbertalan.dev
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
[PMM: added comment about NUL and short-buffer behaviour]
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
include/hw/misc/bcm2835_property.h | 1 +
24
hw/arm/bcm2835_peripherals.c | 2 ++
25
hw/arm/bcm2836.c | 2 ++
26
hw/arm/raspi.c | 2 ++
27
hw/misc/bcm2835_property.c | 13 ++++++++++++-
28
5 files changed, 19 insertions(+), 1 deletion(-)
29
30
diff --git a/include/hw/misc/bcm2835_property.h b/include/hw/misc/bcm2835_property.h
31
index XXXXXXX..XXXXXXX 100644
32
--- a/include/hw/misc/bcm2835_property.h
33
+++ b/include/hw/misc/bcm2835_property.h
34
@@ -XXX,XX +XXX,XX @@ struct BCM2835PropertyState {
35
MACAddr macaddr;
36
uint32_t board_rev;
37
uint32_t addr;
38
+ char *command_line;
39
bool pending;
40
};
41
42
diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/arm/bcm2835_peripherals.c
45
+++ b/hw/arm/bcm2835_peripherals.c
46
@@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj)
47
TYPE_BCM2835_PROPERTY);
48
object_property_add_alias(obj, "board-rev", OBJECT(&s->property),
49
"board-rev");
50
+ object_property_add_alias(obj, "command-line", OBJECT(&s->property),
51
+ "command-line");
52
53
object_property_add_const_link(OBJECT(&s->property), "fb",
54
OBJECT(&s->fb));
55
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/arm/bcm2836.c
58
+++ b/hw/arm/bcm2836.c
59
@@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj)
60
TYPE_BCM2835_PERIPHERALS);
61
object_property_add_alias(obj, "board-rev", OBJECT(&s->peripherals),
62
"board-rev");
63
+ object_property_add_alias(obj, "command-line", OBJECT(&s->peripherals),
64
+ "command-line");
65
object_property_add_alias(obj, "vcram-size", OBJECT(&s->peripherals),
66
"vcram-size");
67
}
68
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/arm/raspi.c
71
+++ b/hw/arm/raspi.c
72
@@ -XXX,XX +XXX,XX @@ static void raspi_machine_init(MachineState *machine)
73
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(machine->ram));
74
object_property_set_int(OBJECT(&s->soc), "board-rev", board_rev,
75
&error_abort);
76
+ object_property_set_str(OBJECT(&s->soc), "command-line",
77
+ machine->kernel_cmdline, &error_abort);
78
qdev_realize(DEVICE(&s->soc), NULL, &error_fatal);
79
80
/* Create and plug in the SD cards */
81
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/misc/bcm2835_property.c
84
+++ b/hw/misc/bcm2835_property.c
85
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value)
86
break;
87
88
case 0x00050001: /* Get command line */
89
- resplen = 0;
90
+ /*
91
+ * We follow the firmware behaviour: no NUL terminator is
92
+ * written to the buffer, and if the buffer is too short
93
+ * we report the required length in the response header
94
+ * and copy nothing to the buffer.
95
+ */
96
+ resplen = strlen(s->command_line);
97
+ if (bufsize >= resplen)
98
+ address_space_write(&s->dma_as, value + 12,
99
+ MEMTXATTRS_UNSPECIFIED, s->command_line,
100
+ resplen);
101
break;
102
103
default:
104
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_realize(DeviceState *dev, Error **errp)
105
106
static Property bcm2835_property_props[] = {
107
DEFINE_PROP_UINT32("board-rev", BCM2835PropertyState, board_rev, 0),
108
+ DEFINE_PROP_STRING("command-line", BCM2835PropertyState, command_line),
109
DEFINE_PROP_END_OF_LIST()
110
};
111
112
--
113
2.34.1
diff view generated by jsdifflib
New patch
1
1
This commit adds 'one-insn-per-tb' as a property on the TCG
2
accelerator object, so you can enable it with
3
-accel tcg,one-insn-per-tb=on
4
5
It has the same behaviour as the existing '-singlestep' command line
6
option. We use a different name because 'singlestep' has always been
7
a confusing choice, because it doesn't have anything to do with
8
single-stepping the CPU. What it does do is force TCG emulation to
9
put one guest instruction in each TB, which can be useful in some
10
situations (such as analysing debug logs).
11
12
The existing '-singlestep' commandline options are decoupled from the
13
global 'singlestep' variable and instead now are syntactic sugar for
14
setting the accel property. (These can then go away after a
15
deprecation period.)
16
17
The global variable remains for the moment as:
18
* what the TCG code looks at to change its behaviour
19
* what HMP and QMP use to query and set the behaviour
20
21
In the following commits we'll clean those up to not directly
22
look at the global variable.
23
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
26
Message-id: 20230417164041.684562-2-peter.maydell@linaro.org
27
---
28
accel/tcg/tcg-all.c | 21 +++++++++++++++++++++
29
bsd-user/main.c | 8 ++++++--
30
linux-user/main.c | 8 ++++++--
31
softmmu/vl.c | 17 +++++++++++++++--
32
qemu-options.hx | 7 +++++++
33
5 files changed, 55 insertions(+), 6 deletions(-)
34
35
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/accel/tcg/tcg-all.c
38
+++ b/accel/tcg/tcg-all.c
39
@@ -XXX,XX +XXX,XX @@ struct TCGState {
40
AccelState parent_obj;
41
42
bool mttcg_enabled;
43
+ bool one_insn_per_tb;
44
int splitwx_enabled;
45
unsigned long tb_size;
46
};
47
@@ -XXX,XX +XXX,XX @@ static void tcg_set_splitwx(Object *obj, bool value, Error **errp)
48
s->splitwx_enabled = value;
49
}
50
51
+static bool tcg_get_one_insn_per_tb(Object *obj, Error **errp)
52
+{
53
+ TCGState *s = TCG_STATE(obj);
54
+ return s->one_insn_per_tb;
55
+}
56
+
57
+static void tcg_set_one_insn_per_tb(Object *obj, bool value, Error **errp)
58
+{
59
+ TCGState *s = TCG_STATE(obj);
60
+ s->one_insn_per_tb = value;
61
+ /* For the moment, set the global also: this changes the behaviour */
62
+ singlestep = value;
63
+}
64
+
65
static int tcg_gdbstub_supported_sstep_flags(void)
66
{
67
/*
68
@@ -XXX,XX +XXX,XX @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
69
tcg_get_splitwx, tcg_set_splitwx);
70
object_class_property_set_description(oc, "split-wx",
71
"Map jit pages into separate RW and RX regions");
72
+
73
+ object_class_property_add_bool(oc, "one-insn-per-tb",
74
+ tcg_get_one_insn_per_tb,
75
+ tcg_set_one_insn_per_tb);
76
+ object_class_property_set_description(oc, "one-insn-per-tb",
77
+ "Only put one guest insn in each translation block");
78
}
79
80
static const TypeInfo tcg_accel_type = {
81
diff --git a/bsd-user/main.c b/bsd-user/main.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/bsd-user/main.c
84
+++ b/bsd-user/main.c
85
@@ -XXX,XX +XXX,XX @@
86
#include "target_arch_cpu.h"
87
88
int singlestep;
89
+static bool opt_one_insn_per_tb;
90
uintptr_t guest_base;
91
bool have_guest_base;
92
/*
93
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
94
} else if (!strcmp(r, "seed")) {
95
seed_optarg = optarg;
96
} else if (!strcmp(r, "singlestep")) {
97
- singlestep = 1;
98
+ opt_one_insn_per_tb = true;
99
} else if (!strcmp(r, "strace")) {
100
do_strace = 1;
101
} else if (!strcmp(r, "trace")) {
102
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
103
104
/* init tcg before creating CPUs and to get qemu_host_page_size */
105
{
106
- AccelClass *ac = ACCEL_GET_CLASS(current_accel());
107
+ AccelState *accel = current_accel();
108
+ AccelClass *ac = ACCEL_GET_CLASS(accel);
109
110
accel_init_interfaces(ac);
111
+ object_property_set_bool(OBJECT(accel), "one-insn-per-tb",
112
+ opt_one_insn_per_tb, &error_abort);
113
ac->init_machine(NULL);
114
}
115
cpu = cpu_create(cpu_type);
116
diff --git a/linux-user/main.c b/linux-user/main.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/linux-user/main.c
119
+++ b/linux-user/main.c
120
@@ -XXX,XX +XXX,XX @@ char *exec_path;
121
char real_exec_path[PATH_MAX];
122
123
int singlestep;
124
+static bool opt_one_insn_per_tb;
125
static const char *argv0;
126
static const char *gdbstub;
127
static envlist_t *envlist;
128
@@ -XXX,XX +XXX,XX @@ static void handle_arg_reserved_va(const char *arg)
129
130
static void handle_arg_singlestep(const char *arg)
131
{
132
- singlestep = 1;
133
+ opt_one_insn_per_tb = true;
134
}
135
136
static void handle_arg_strace(const char *arg)
137
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp)
138
139
/* init tcg before creating CPUs and to get qemu_host_page_size */
140
{
141
- AccelClass *ac = ACCEL_GET_CLASS(current_accel());
142
+ AccelState *accel = current_accel();
143
+ AccelClass *ac = ACCEL_GET_CLASS(accel);
144
145
accel_init_interfaces(ac);
146
+ object_property_set_bool(OBJECT(accel), "one-insn-per-tb",
147
+ opt_one_insn_per_tb, &error_abort);
148
ac->init_machine(NULL);
149
}
150
cpu = cpu_create(cpu_type);
151
diff --git a/softmmu/vl.c b/softmmu/vl.c
152
index XXXXXXX..XXXXXXX 100644
153
--- a/softmmu/vl.c
154
+++ b/softmmu/vl.c
155
@@ -XXX,XX +XXX,XX @@ static const char *log_file;
156
static bool list_data_dirs;
157
static const char *qtest_chrdev;
158
static const char *qtest_log;
159
+static bool opt_one_insn_per_tb;
160
161
static int has_defaults = 1;
162
static int default_serial = 1;
163
@@ -XXX,XX +XXX,XX @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp)
164
qemu_opt_foreach(opts, accelerator_set_property,
165
accel,
166
&error_fatal);
167
-
168
+ /*
169
+ * If legacy -singlestep option is set, honour it for TCG and
170
+ * silently ignore for any other accelerator (which is how this
171
+ * option has always behaved).
172
+ */
173
+ if (opt_one_insn_per_tb) {
174
+ /*
175
+ * This will always succeed for TCG, and we want to ignore
176
+ * the error from trying to set a nonexistent property
177
+ * on any other accelerator.
178
+ */
179
+ object_property_set_bool(OBJECT(accel), "one-insn-per-tb", true, NULL);
180
+ }
181
ret = accel_init_machine(accel, current_machine);
182
if (ret < 0) {
183
if (!qtest_with_kvm || ret != -ENOENT) {
184
@@ -XXX,XX +XXX,XX @@ void qemu_init(int argc, char **argv)
185
qdict_put_str(machine_opts_dict, "firmware", optarg);
186
break;
187
case QEMU_OPTION_singlestep:
188
- singlestep = 1;
189
+ opt_one_insn_per_tb = true;
190
break;
191
case QEMU_OPTION_S:
192
autostart = 0;
193
diff --git a/qemu-options.hx b/qemu-options.hx
194
index XXXXXXX..XXXXXXX 100644
195
--- a/qemu-options.hx
196
+++ b/qemu-options.hx
197
@@ -XXX,XX +XXX,XX @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel,
198
" igd-passthru=on|off (enable Xen integrated Intel graphics passthrough, default=off)\n"
199
" kernel-irqchip=on|off|split controls accelerated irqchip support (default=on)\n"
200
" kvm-shadow-mem=size of KVM shadow MMU in bytes\n"
201
+ " one-insn-per-tb=on|off (one guest instruction per TCG translation block)\n"
202
" split-wx=on|off (enable TCG split w^x mapping)\n"
203
" tb-size=n (TCG translation block cache size)\n"
204
" dirty-ring-size=n (KVM dirty ring GFN count, default 0)\n"
205
@@ -XXX,XX +XXX,XX @@ SRST
206
``kvm-shadow-mem=size``
207
Defines the size of the KVM shadow MMU.
208
209
+ ``one-insn-per-tb=on|off``
210
+ Makes the TCG accelerator put only one guest instruction into
211
+ each translation block. This slows down emulation a lot, but
212
+ can be useful in some situations, such as when trying to analyse
213
+ the logs produced by the ``-d`` option.
214
+
215
``split-wx=on|off``
216
Controls the use of split w^x mapping for the TCG code generation
217
buffer. Some operating systems require this to be enabled, and in
218
--
219
2.34.1
diff view generated by jsdifflib
1
Implement a model of the simple timer device found in the CMSDK.
1
The HMP 'singlestep' command, the QMP 'query-status' command and the
2
HMP 'info status' command (which is just wrapping the QMP command
3
implementation) look at the 'singlestep' global variable. Make them
4
access the new TCG accelerator 'one-insn-per-tb' property instead.
5
6
This leaves the HMP and QMP command/field names and output strings
7
unchanged; we will clean that up later.
2
8
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 1500029487-14822-5-git-send-email-peter.maydell@linaro.org
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Message-id: 20230417164041.684562-3-peter.maydell@linaro.org
6
---
13
---
7
hw/timer/Makefile.objs | 1 +
14
softmmu/runstate-hmp-cmds.c | 18 ++++++++++++++++--
8
include/hw/timer/cmsdk-apb-timer.h | 59 +++++++++
15
softmmu/runstate.c | 10 +++++++++-
9
hw/timer/cmsdk-apb-timer.c | 253 +++++++++++++++++++++++++++++++++++++
16
2 files changed, 25 insertions(+), 3 deletions(-)
10
default-configs/arm-softmmu.mak | 1 +
11
hw/timer/trace-events | 5 +
12
5 files changed, 319 insertions(+)
13
create mode 100644 include/hw/timer/cmsdk-apb-timer.h
14
create mode 100644 hw/timer/cmsdk-apb-timer.c
15
17
16
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
18
diff --git a/softmmu/runstate-hmp-cmds.c b/softmmu/runstate-hmp-cmds.c
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/timer/Makefile.objs
20
--- a/softmmu/runstate-hmp-cmds.c
19
+++ b/hw/timer/Makefile.objs
21
+++ b/softmmu/runstate-hmp-cmds.c
20
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_STM32F2XX_TIMER) += stm32f2xx_timer.o
21
common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
22
23
common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
24
+common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
25
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
26
new file mode 100644
27
index XXXXXXX..XXXXXXX
28
--- /dev/null
29
+++ b/include/hw/timer/cmsdk-apb-timer.h
30
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@
31
+/*
23
#include "qapi/error.h"
32
+ * ARM CMSDK APB timer emulation
24
#include "qapi/qapi-commands-run-state.h"
33
+ *
25
#include "qapi/qmp/qdict.h"
34
+ * Copyright (c) 2017 Linaro Limited
26
+#include "qemu/accel.h"
35
+ * Written by Peter Maydell
27
36
+ *
28
void hmp_info_status(Monitor *mon, const QDict *qdict)
37
+ * This program is free software; you can redistribute it and/or modify
29
{
38
+ * it under the terms of the GNU General Public License version 2 or
30
@@ -XXX,XX +XXX,XX @@ void hmp_info_status(Monitor *mon, const QDict *qdict)
39
+ * (at your option) any later version.
31
void hmp_singlestep(Monitor *mon, const QDict *qdict)
40
+ */
32
{
33
const char *option = qdict_get_try_str(qdict, "option");
34
+ AccelState *accel = current_accel();
35
+ bool newval;
41
+
36
+
42
+#ifndef CMSDK_APB_TIMER_H
37
+ if (!object_property_find(OBJECT(accel), "one-insn-per-tb")) {
43
+#define CMSDK_APB_TIMER_H
38
+ monitor_printf(mon,
44
+
39
+ "This accelerator does not support setting one-insn-per-tb\n");
45
+#include "hw/sysbus.h"
46
+#include "hw/ptimer.h"
47
+
48
+#define TYPE_CMSDK_APB_TIMER "cmsdk-apb-timer"
49
+#define CMSDK_APB_TIMER(obj) OBJECT_CHECK(CMSDKAPBTIMER, (obj), \
50
+ TYPE_CMSDK_APB_TIMER)
51
+
52
+typedef struct {
53
+ /*< private >*/
54
+ SysBusDevice parent_obj;
55
+
56
+ /*< public >*/
57
+ MemoryRegion iomem;
58
+ qemu_irq timerint;
59
+ uint32_t pclk_frq;
60
+ struct ptimer_state *timer;
61
+
62
+ uint32_t ctrl;
63
+ uint32_t value;
64
+ uint32_t reload;
65
+ uint32_t intstatus;
66
+} CMSDKAPBTIMER;
67
+
68
+/**
69
+ * cmsdk_apb_timer_create - convenience function to create TYPE_CMSDK_APB_TIMER
70
+ * @addr: location in system memory to map registers
71
+ * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate)
72
+ */
73
+static inline DeviceState *cmsdk_apb_timer_create(hwaddr addr,
74
+ qemu_irq timerint,
75
+ uint32_t pclk_frq)
76
+{
77
+ DeviceState *dev;
78
+ SysBusDevice *s;
79
+
80
+ dev = qdev_create(NULL, TYPE_CMSDK_APB_TIMER);
81
+ s = SYS_BUS_DEVICE(dev);
82
+ qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq);
83
+ qdev_init_nofail(dev);
84
+ sysbus_mmio_map(s, 0, addr);
85
+ sysbus_connect_irq(s, 0, timerint);
86
+ return dev;
87
+}
88
+
89
+#endif
90
diff --git a/hw/timer/cmsdk-apb-timer.c b/hw/timer/cmsdk-apb-timer.c
91
new file mode 100644
92
index XXXXXXX..XXXXXXX
93
--- /dev/null
94
+++ b/hw/timer/cmsdk-apb-timer.c
95
@@ -XXX,XX +XXX,XX @@
96
+/*
97
+ * ARM CMSDK APB timer emulation
98
+ *
99
+ * Copyright (c) 2017 Linaro Limited
100
+ * Written by Peter Maydell
101
+ *
102
+ * This program is free software; you can redistribute it and/or modify
103
+ * it under the terms of the GNU General Public License version 2 or
104
+ * (at your option) any later version.
105
+ */
106
+
107
+/* This is a model of the "APB timer" which is part of the Cortex-M
108
+ * System Design Kit (CMSDK) and documented in the Cortex-M System
109
+ * Design Kit Technical Reference Manual (ARM DDI0479C):
110
+ * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit
111
+ *
112
+ * The hardware has an EXTIN input wire, which can be configured
113
+ * by the guest to act either as a 'timer enable' (timer does not run
114
+ * when EXTIN is low), or as a 'timer clock' (timer runs at frequency
115
+ * of EXTIN clock, not PCLK frequency). We don't model this.
116
+ *
117
+ * The documentation is not very clear about the exact behaviour;
118
+ * we choose to implement that the interrupt is triggered when
119
+ * the counter goes from 1 to 0, that the counter then holds at 0
120
+ * for one clock cycle before reloading from the RELOAD register,
121
+ * and that if the RELOAD register is 0 this does not cause an
122
+ * interrupt (as there is no further 1->0 transition).
123
+ */
124
+
125
+#include "qemu/osdep.h"
126
+#include "qemu/log.h"
127
+#include "qemu/main-loop.h"
128
+#include "qapi/error.h"
129
+#include "trace.h"
130
+#include "hw/sysbus.h"
131
+#include "hw/registerfields.h"
132
+#include "hw/timer/cmsdk-apb-timer.h"
133
+
134
+REG32(CTRL, 0)
135
+ FIELD(CTRL, EN, 0, 1)
136
+ FIELD(CTRL, SELEXTEN, 1, 1)
137
+ FIELD(CTRL, SELEXTCLK, 2, 1)
138
+ FIELD(CTRL, IRQEN, 3, 1)
139
+REG32(VALUE, 4)
140
+REG32(RELOAD, 8)
141
+REG32(INTSTATUS, 0xc)
142
+ FIELD(INTSTATUS, IRQ, 0, 1)
143
+REG32(PID4, 0xFD0)
144
+REG32(PID5, 0xFD4)
145
+REG32(PID6, 0xFD8)
146
+REG32(PID7, 0xFDC)
147
+REG32(PID0, 0xFE0)
148
+REG32(PID1, 0xFE4)
149
+REG32(PID2, 0xFE8)
150
+REG32(PID3, 0xFEC)
151
+REG32(CID0, 0xFF0)
152
+REG32(CID1, 0xFF4)
153
+REG32(CID2, 0xFF8)
154
+REG32(CID3, 0xFFC)
155
+
156
+/* PID/CID values */
157
+static const int timer_id[] = {
158
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
159
+ 0x22, 0xb8, 0x1b, 0x00, /* PID0..PID3 */
160
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
161
+};
162
+
163
+static void cmsdk_apb_timer_update(CMSDKAPBTIMER *s)
164
+{
165
+ qemu_set_irq(s->timerint, !!(s->intstatus & R_INTSTATUS_IRQ_MASK));
166
+}
167
+
168
+static uint64_t cmsdk_apb_timer_read(void *opaque, hwaddr offset, unsigned size)
169
+{
170
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
171
+ uint64_t r;
172
+
173
+ switch (offset) {
174
+ case A_CTRL:
175
+ r = s->ctrl;
176
+ break;
177
+ case A_VALUE:
178
+ r = ptimer_get_count(s->timer);
179
+ break;
180
+ case A_RELOAD:
181
+ r = ptimer_get_limit(s->timer);
182
+ break;
183
+ case A_INTSTATUS:
184
+ r = s->intstatus;
185
+ break;
186
+ case A_PID4 ... A_CID3:
187
+ r = timer_id[(offset - A_PID4) / 4];
188
+ break;
189
+ default:
190
+ qemu_log_mask(LOG_GUEST_ERROR,
191
+ "CMSDK APB timer read: bad offset %x\n", (int) offset);
192
+ r = 0;
193
+ break;
194
+ }
195
+ trace_cmsdk_apb_timer_read(offset, r, size);
196
+ return r;
197
+}
198
+
199
+static void cmsdk_apb_timer_write(void *opaque, hwaddr offset, uint64_t value,
200
+ unsigned size)
201
+{
202
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
203
+
204
+ trace_cmsdk_apb_timer_write(offset, value, size);
205
+
206
+ switch (offset) {
207
+ case A_CTRL:
208
+ if (value & 6) {
209
+ /* Bits [1] and [2] enable using EXTIN as either clock or
210
+ * an enable line. We don't model this.
211
+ */
212
+ qemu_log_mask(LOG_UNIMP,
213
+ "CMSDK APB timer: EXTIN input not supported\n");
214
+ }
215
+ s->ctrl = value & 0xf;
216
+ if (s->ctrl & R_CTRL_EN_MASK) {
217
+ ptimer_run(s->timer, 0);
218
+ } else {
219
+ ptimer_stop(s->timer);
220
+ }
221
+ break;
222
+ case A_RELOAD:
223
+ /* Writing to reload also sets the current timer value */
224
+ ptimer_set_limit(s->timer, value, 1);
225
+ break;
226
+ case A_VALUE:
227
+ ptimer_set_count(s->timer, value);
228
+ break;
229
+ case A_INTSTATUS:
230
+ /* Just one bit, which is W1C. */
231
+ value &= 1;
232
+ s->intstatus &= ~value;
233
+ cmsdk_apb_timer_update(s);
234
+ break;
235
+ case A_PID4 ... A_CID3:
236
+ qemu_log_mask(LOG_GUEST_ERROR,
237
+ "CMSDK APB timer write: write to RO offset 0x%x\n",
238
+ (int)offset);
239
+ break;
240
+ default:
241
+ qemu_log_mask(LOG_GUEST_ERROR,
242
+ "CMSDK APB timer write: bad offset 0x%x\n", (int) offset);
243
+ break;
244
+ }
245
+}
246
+
247
+static const MemoryRegionOps cmsdk_apb_timer_ops = {
248
+ .read = cmsdk_apb_timer_read,
249
+ .write = cmsdk_apb_timer_write,
250
+ .endianness = DEVICE_LITTLE_ENDIAN,
251
+};
252
+
253
+static void cmsdk_apb_timer_tick(void *opaque)
254
+{
255
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(opaque);
256
+
257
+ if (s->ctrl & R_CTRL_IRQEN_MASK) {
258
+ s->intstatus |= R_INTSTATUS_IRQ_MASK;
259
+ cmsdk_apb_timer_update(s);
260
+ }
261
+}
262
+
263
+static void cmsdk_apb_timer_reset(DeviceState *dev)
264
+{
265
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
266
+
267
+ trace_cmsdk_apb_timer_reset();
268
+ s->ctrl = 0;
269
+ s->intstatus = 0;
270
+ ptimer_stop(s->timer);
271
+ /* Set the limit and the count */
272
+ ptimer_set_limit(s->timer, 0, 1);
273
+}
274
+
275
+static void cmsdk_apb_timer_init(Object *obj)
276
+{
277
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
278
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(obj);
279
+
280
+ memory_region_init_io(&s->iomem, obj, &cmsdk_apb_timer_ops,
281
+ s, "cmsdk-apb-timer", 0x1000);
282
+ sysbus_init_mmio(sbd, &s->iomem);
283
+ sysbus_init_irq(sbd, &s->timerint);
284
+}
285
+
286
+static void cmsdk_apb_timer_realize(DeviceState *dev, Error **errp)
287
+{
288
+ CMSDKAPBTIMER *s = CMSDK_APB_TIMER(dev);
289
+ QEMUBH *bh;
290
+
291
+ if (s->pclk_frq == 0) {
292
+ error_setg(errp, "CMSDK APB timer: pclk-frq property must be set");
293
+ return;
40
+ return;
294
+ }
41
+ }
295
+
42
+
296
+ bh = qemu_bh_new(cmsdk_apb_timer_tick, s);
43
if (!option || !strcmp(option, "on")) {
297
+ s->timer = ptimer_init(bh,
44
- singlestep = 1;
298
+ PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD |
45
+ newval = true;
299
+ PTIMER_POLICY_NO_IMMEDIATE_TRIGGER |
46
} else if (!strcmp(option, "off")) {
300
+ PTIMER_POLICY_NO_IMMEDIATE_RELOAD |
47
- singlestep = 0;
301
+ PTIMER_POLICY_NO_COUNTER_ROUND_DOWN);
48
+ newval = false;
302
+
49
} else {
303
+ ptimer_set_freq(s->timer, s->pclk_frq);
50
monitor_printf(mon, "unexpected option %s\n", option);
304
+}
51
+ return;
305
+
52
}
306
+static const VMStateDescription cmsdk_apb_timer_vmstate = {
53
+ /* If the property exists then setting it can never fail */
307
+ .name = "cmsdk-apb-timer",
54
+ object_property_set_bool(OBJECT(accel), "one-insn-per-tb",
308
+ .version_id = 1,
55
+ newval, &error_abort);
309
+ .minimum_version_id = 1,
56
}
310
+ .fields = (VMStateField[]) {
57
311
+ VMSTATE_PTIMER(timer, CMSDKAPBTIMER),
58
void hmp_watchdog_action(Monitor *mon, const QDict *qdict)
312
+ VMSTATE_UINT32(ctrl, CMSDKAPBTIMER),
59
diff --git a/softmmu/runstate.c b/softmmu/runstate.c
313
+ VMSTATE_UINT32(value, CMSDKAPBTIMER),
314
+ VMSTATE_UINT32(reload, CMSDKAPBTIMER),
315
+ VMSTATE_UINT32(intstatus, CMSDKAPBTIMER),
316
+ VMSTATE_END_OF_LIST()
317
+ }
318
+};
319
+
320
+static Property cmsdk_apb_timer_properties[] = {
321
+ DEFINE_PROP_UINT32("pclk-frq", CMSDKAPBTIMER, pclk_frq, 0),
322
+ DEFINE_PROP_END_OF_LIST(),
323
+};
324
+
325
+static void cmsdk_apb_timer_class_init(ObjectClass *klass, void *data)
326
+{
327
+ DeviceClass *dc = DEVICE_CLASS(klass);
328
+
329
+ dc->realize = cmsdk_apb_timer_realize;
330
+ dc->vmsd = &cmsdk_apb_timer_vmstate;
331
+ dc->reset = cmsdk_apb_timer_reset;
332
+ dc->props = cmsdk_apb_timer_properties;
333
+}
334
+
335
+static const TypeInfo cmsdk_apb_timer_info = {
336
+ .name = TYPE_CMSDK_APB_TIMER,
337
+ .parent = TYPE_SYS_BUS_DEVICE,
338
+ .instance_size = sizeof(CMSDKAPBTIMER),
339
+ .instance_init = cmsdk_apb_timer_init,
340
+ .class_init = cmsdk_apb_timer_class_init,
341
+};
342
+
343
+static void cmsdk_apb_timer_register_types(void)
344
+{
345
+ type_register_static(&cmsdk_apb_timer_info);
346
+}
347
+
348
+type_init(cmsdk_apb_timer_register_types);
349
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
350
index XXXXXXX..XXXXXXX 100644
60
index XXXXXXX..XXXXXXX 100644
351
--- a/default-configs/arm-softmmu.mak
61
--- a/softmmu/runstate.c
352
+++ b/default-configs/arm-softmmu.mak
62
+++ b/softmmu/runstate.c
353
@@ -XXX,XX +XXX,XX @@ CONFIG_STM32F2XX_ADC=y
63
@@ -XXX,XX +XXX,XX @@
354
CONFIG_STM32F2XX_SPI=y
64
#include "qapi/error.h"
355
CONFIG_STM32F205_SOC=y
65
#include "qapi/qapi-commands-run-state.h"
356
66
#include "qapi/qapi-events-run-state.h"
357
+CONFIG_CMSDK_APB_TIMER=y
67
+#include "qemu/accel.h"
358
CONFIG_CMSDK_APB_UART=y
68
#include "qemu/error-report.h"
359
69
#include "qemu/job.h"
360
CONFIG_VERSATILE_PCI=y
70
#include "qemu/log.h"
361
diff --git a/hw/timer/trace-events b/hw/timer/trace-events
71
@@ -XXX,XX +XXX,XX @@ bool runstate_needs_reset(void)
362
index XXXXXXX..XXXXXXX 100644
72
StatusInfo *qmp_query_status(Error **errp)
363
--- a/hw/timer/trace-events
73
{
364
+++ b/hw/timer/trace-events
74
StatusInfo *info = g_malloc0(sizeof(*info));
365
@@ -XXX,XX +XXX,XX @@ systick_reload(void) "systick reload"
75
+ AccelState *accel = current_accel();
366
systick_timer_tick(void) "systick reload"
76
367
systick_read(uint64_t addr, uint32_t value, unsigned size) "systick read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
77
+ /*
368
systick_write(uint64_t addr, uint32_t value, unsigned size) "systick write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
78
+ * We ignore errors, which will happen if the accelerator
369
+
79
+ * is not TCG. "singlestep" is meaningless for other accelerators,
370
+# hw/char/cmsdk_apb_timer.c
80
+ * so we will set the StatusInfo field to false for those.
371
+cmsdk_apb_timer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB timer read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
81
+ */
372
+cmsdk_apb_timer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB timer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
82
+ info->singlestep = object_property_get_bool(OBJECT(accel),
373
+cmsdk_apb_timer_reset(void) "CMSDK APB timer: reset"
83
+ "one-insn-per-tb", NULL);
84
info->running = runstate_is_running();
85
- info->singlestep = singlestep;
86
info->status = current_run_state;
87
88
return info;
374
--
89
--
375
2.7.4
90
2.34.1
376
91
377
92
diff view generated by jsdifflib
1
Add the SCC to the MPS2 board models.
1
The only place left that looks at the old 'singlestep' global
2
variable is the TCG curr_cflags() function. Replace the old global
3
with a new 'one_insn_per_tb' which is defined in tcg-all.c and
4
declared in accel/tcg/internal.h. This keeps it restricted to the
5
TCG code, unlike 'singlestep' which was available to every file in
6
the system and defined in multiple different places for softmmu vs
7
linux-user vs bsd-user.
8
9
While we're making this change, use qatomic_read() and qatomic_set()
10
on the accesses to the new global, because TCG will read it without
11
holding a lock.
2
12
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 1500029487-14822-8-git-send-email-peter.maydell@linaro.org
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
Message-id: 20230417164041.684562-4-peter.maydell@linaro.org
6
---
17
---
7
hw/arm/mps2.c | 17 ++++++++++++++++-
18
accel/tcg/internal.h | 2 ++
8
1 file changed, 16 insertions(+), 1 deletion(-)
19
include/exec/cpu-common.h | 2 --
20
accel/tcg/cpu-exec.c | 2 +-
21
accel/tcg/tcg-all.c | 6 ++++--
22
bsd-user/main.c | 1 -
23
linux-user/main.c | 1 -
24
softmmu/globals.c | 1 -
25
7 files changed, 7 insertions(+), 8 deletions(-)
9
26
10
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
27
diff --git a/accel/tcg/internal.h b/accel/tcg/internal.h
11
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/arm/mps2.c
29
--- a/accel/tcg/internal.h
13
+++ b/hw/arm/mps2.c
30
+++ b/accel/tcg/internal.h
31
@@ -XXX,XX +XXX,XX @@ static inline target_ulong log_pc(CPUState *cpu, const TranslationBlock *tb)
32
extern int64_t max_delay;
33
extern int64_t max_advance;
34
35
+extern bool one_insn_per_tb;
36
+
37
#endif /* ACCEL_TCG_INTERNAL_H */
38
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/include/exec/cpu-common.h
41
+++ b/include/exec/cpu-common.h
42
@@ -XXX,XX +XXX,XX @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
43
void *ptr, size_t len, bool is_write);
44
45
/* vl.c */
46
-extern int singlestep;
47
-
48
void list_cpus(void);
49
50
#endif /* CPU_COMMON_H */
51
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/accel/tcg/cpu-exec.c
54
+++ b/accel/tcg/cpu-exec.c
55
@@ -XXX,XX +XXX,XX @@ uint32_t curr_cflags(CPUState *cpu)
56
*/
57
if (unlikely(cpu->singlestep_enabled)) {
58
cflags |= CF_NO_GOTO_TB | CF_NO_GOTO_PTR | CF_SINGLE_STEP | 1;
59
- } else if (singlestep) {
60
+ } else if (qatomic_read(&one_insn_per_tb)) {
61
cflags |= CF_NO_GOTO_TB | 1;
62
} else if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
63
cflags |= CF_NO_GOTO_TB;
64
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/accel/tcg/tcg-all.c
67
+++ b/accel/tcg/tcg-all.c
14
@@ -XXX,XX +XXX,XX @@
68
@@ -XXX,XX +XXX,XX @@
15
#include "hw/misc/unimp.h"
69
#include "qapi/error.h"
16
#include "hw/char/cmsdk-apb-uart.h"
70
#include "qemu/error-report.h"
17
#include "hw/timer/cmsdk-apb-timer.h"
71
#include "qemu/accel.h"
18
+#include "hw/misc/mps2-scc.h"
72
+#include "qemu/atomic.h"
19
73
#include "qapi/qapi-builtin-visit.h"
20
typedef enum MPS2FPGAType {
74
#include "qemu/units.h"
21
FPGA_AN385,
75
#if !defined(CONFIG_USER_ONLY)
22
@@ -XXX,XX +XXX,XX @@ typedef struct {
76
@@ -XXX,XX +XXX,XX @@ static void tcg_accel_instance_init(Object *obj)
23
MachineClass parent;
24
MPS2FPGAType fpga_type;
25
const char *cpu_model;
26
+ uint32_t scc_id;
27
} MPS2MachineClass;
28
29
typedef struct {
30
@@ -XXX,XX +XXX,XX @@ typedef struct {
31
MemoryRegion blockram_m2;
32
MemoryRegion blockram_m3;
33
MemoryRegion sram;
34
+ MPS2SCC scc;
35
} MPS2MachineState;
36
37
#define TYPE_MPS2_MACHINE "mps2"
38
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
39
MPS2MachineState *mms = MPS2_MACHINE(machine);
40
MPS2MachineClass *mmc = MPS2_MACHINE_GET_CLASS(machine);
41
MemoryRegion *system_memory = get_system_memory();
42
- DeviceState *armv7m;
43
+ DeviceState *armv7m, *sccdev;
44
45
if (!machine->cpu_model) {
46
machine->cpu_model = mmc->cpu_model;
47
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
48
cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
49
cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
50
51
+ object_initialize(&mms->scc, sizeof(mms->scc), TYPE_MPS2_SCC);
52
+ sccdev = DEVICE(&mms->scc);
53
+ qdev_set_parent_bus(armv7m, sysbus_get_default());
54
+ qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2);
55
+ qdev_prop_set_uint32(sccdev, "scc-aid", 0x02000008);
56
+ qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id);
57
+ object_property_set_bool(OBJECT(&mms->scc), true, "realized",
58
+ &error_fatal);
59
+ sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
60
+
61
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
62
63
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
64
@@ -XXX,XX +XXX,XX @@ static void mps2_an385_class_init(ObjectClass *oc, void *data)
65
mc->desc = "ARM MPS2 with AN385 FPGA image for Cortex-M3";
66
mmc->fpga_type = FPGA_AN385;
67
mmc->cpu_model = "cortex-m3";
68
+ mmc->scc_id = 0x41040000 | (385 << 4);
69
}
77
}
70
78
71
static void mps2_an511_class_init(ObjectClass *oc, void *data)
79
bool mttcg_enabled;
72
@@ -XXX,XX +XXX,XX @@ static void mps2_an511_class_init(ObjectClass *oc, void *data)
80
+bool one_insn_per_tb;
73
mc->desc = "ARM MPS2 with AN511 DesignStart FPGA image for Cortex-M3";
81
74
mmc->fpga_type = FPGA_AN511;
82
static int tcg_init_machine(MachineState *ms)
75
mmc->cpu_model = "cortex-m3";
83
{
76
+ mmc->scc_id = 0x4104000 | (511 << 4);
84
@@ -XXX,XX +XXX,XX @@ static void tcg_set_one_insn_per_tb(Object *obj, bool value, Error **errp)
85
{
86
TCGState *s = TCG_STATE(obj);
87
s->one_insn_per_tb = value;
88
- /* For the moment, set the global also: this changes the behaviour */
89
- singlestep = value;
90
+ /* Set the global also: this changes the behaviour */
91
+ qatomic_set(&one_insn_per_tb, value);
77
}
92
}
78
93
79
static const TypeInfo mps2_info = {
94
static int tcg_gdbstub_supported_sstep_flags(void)
95
diff --git a/bsd-user/main.c b/bsd-user/main.c
96
index XXXXXXX..XXXXXXX 100644
97
--- a/bsd-user/main.c
98
+++ b/bsd-user/main.c
99
@@ -XXX,XX +XXX,XX @@
100
#include "host-os.h"
101
#include "target_arch_cpu.h"
102
103
-int singlestep;
104
static bool opt_one_insn_per_tb;
105
uintptr_t guest_base;
106
bool have_guest_base;
107
diff --git a/linux-user/main.c b/linux-user/main.c
108
index XXXXXXX..XXXXXXX 100644
109
--- a/linux-user/main.c
110
+++ b/linux-user/main.c
111
@@ -XXX,XX +XXX,XX @@
112
char *exec_path;
113
char real_exec_path[PATH_MAX];
114
115
-int singlestep;
116
static bool opt_one_insn_per_tb;
117
static const char *argv0;
118
static const char *gdbstub;
119
diff --git a/softmmu/globals.c b/softmmu/globals.c
120
index XXXXXXX..XXXXXXX 100644
121
--- a/softmmu/globals.c
122
+++ b/softmmu/globals.c
123
@@ -XXX,XX +XXX,XX @@ int vga_interface_type = VGA_NONE;
124
bool vga_interface_created;
125
Chardev *parallel_hds[MAX_PARALLEL_PORTS];
126
int win2k_install_hack;
127
-int singlestep;
128
int fd_bootchk = 1;
129
int graphic_rotate;
130
QEMUOptionRom option_rom[MAX_OPTION_ROMS];
80
--
131
--
81
2.7.4
132
2.34.1
82
133
83
134
diff view generated by jsdifflib
1
Add the UARTs to the MPS2 board models.
1
The '-singlestep' option is confusing, because it doesn't actually
2
have anything to do with single-stepping the CPU. What it does do
3
is force TCG emulation to put one guest instruction in each TB,
4
which can be useful in some situations.
2
5
3
Unfortunately the details of the wiring of the interrupts through
6
Create a new command line argument -one-insn-per-tb, so we can
4
various OR gates differ between AN511 and AN385 so this can't
7
document that -singlestep is just a deprecated synonym for it,
5
be purely a data-driven difference.
8
and eventually perhaps drop it.
6
9
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 1500029487-14822-4-git-send-email-peter.maydell@linaro.org
12
Reviewed-by: Warner Losh <imp@bsdimp.com>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Message-id: 20230417164041.684562-5-peter.maydell@linaro.org
10
---
15
---
11
hw/arm/mps2.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
16
docs/user/main.rst | 7 ++++++-
12
hw/char/cmsdk-apb-uart.c | 2 +-
17
linux-user/main.c | 9 ++++++---
13
2 files changed, 89 insertions(+), 1 deletion(-)
18
2 files changed, 12 insertions(+), 4 deletions(-)
14
19
15
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
20
diff --git a/docs/user/main.rst b/docs/user/main.rst
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/mps2.c
22
--- a/docs/user/main.rst
18
+++ b/hw/arm/mps2.c
23
+++ b/docs/user/main.rst
19
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@ Debug options:
20
#include "qemu/error-report.h"
25
``-g port``
21
#include "hw/arm/arm.h"
26
Wait gdb connection to port
22
#include "hw/arm/armv7m.h"
27
23
+#include "hw/or-irq.h"
28
+``-one-insn-per-tb``
24
#include "hw/boards.h"
29
+ Run the emulation with one guest instruction per translation block.
25
#include "exec/address-spaces.h"
30
+ This slows down emulation a lot, but can be useful in some situations,
26
+#include "sysemu/sysemu.h"
31
+ such as when trying to analyse the logs produced by the ``-d`` option.
27
#include "hw/misc/unimp.h"
28
+#include "hw/char/cmsdk-apb-uart.h"
29
30
typedef enum MPS2FPGAType {
31
FPGA_AN385,
32
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
33
create_unimplemented_device("Ethernet", 0x40200000, 0x00100000);
34
create_unimplemented_device("VGA", 0x41000000, 0x0200000);
35
36
+ switch (mmc->fpga_type) {
37
+ case FPGA_AN385:
38
+ {
39
+ /* The overflow IRQs for UARTs 0, 1 and 2 are ORed together.
40
+ * Overflow for UARTs 4 and 5 doesn't trigger any interrupt.
41
+ */
42
+ Object *orgate;
43
+ DeviceState *orgate_dev;
44
+ int i;
45
+
32
+
46
+ orgate = object_new(TYPE_OR_IRQ);
33
``-singlestep``
47
+ object_property_set_int(orgate, 6, "num-lines", &error_fatal);
34
- Run the emulation in single step mode.
48
+ object_property_set_bool(orgate, true, "realized", &error_fatal);
35
+ This is a deprecated synonym for the ``-one-insn-per-tb`` option.
49
+ orgate_dev = DEVICE(orgate);
36
50
+ qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
37
Environment variables:
51
+
38
52
+ for (i = 0; i < 5; i++) {
39
diff --git a/linux-user/main.c b/linux-user/main.c
53
+ static const hwaddr uartbase[] = {0x40004000, 0x40005000,
54
+ 0x40006000, 0x40007000,
55
+ 0x40009000};
56
+ Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL;
57
+ /* RX irq number; TX irq is always one greater */
58
+ static const int uartirq[] = {0, 2, 4, 18, 20};
59
+ qemu_irq txovrint = NULL, rxovrint = NULL;
60
+
61
+ if (i < 3) {
62
+ txovrint = qdev_get_gpio_in(orgate_dev, i * 2);
63
+ rxovrint = qdev_get_gpio_in(orgate_dev, i * 2 + 1);
64
+ }
65
+
66
+ cmsdk_apb_uart_create(uartbase[i],
67
+ qdev_get_gpio_in(armv7m, uartirq[i] + 1),
68
+ qdev_get_gpio_in(armv7m, uartirq[i]),
69
+ txovrint, rxovrint,
70
+ NULL,
71
+ uartchr, SYSCLK_FRQ);
72
+ }
73
+ break;
74
+ }
75
+ case FPGA_AN511:
76
+ {
77
+ /* The overflow IRQs for all UARTs are ORed together.
78
+ * Tx and Rx IRQs for each UART are ORed together.
79
+ */
80
+ Object *orgate;
81
+ DeviceState *orgate_dev;
82
+ int i;
83
+
84
+ orgate = object_new(TYPE_OR_IRQ);
85
+ object_property_set_int(orgate, 10, "num-lines", &error_fatal);
86
+ object_property_set_bool(orgate, true, "realized", &error_fatal);
87
+ orgate_dev = DEVICE(orgate);
88
+ qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
89
+
90
+ for (i = 0; i < 5; i++) {
91
+ /* system irq numbers for the combined tx/rx for each UART */
92
+ static const int uart_txrx_irqno[] = {0, 2, 45, 46, 56};
93
+ static const hwaddr uartbase[] = {0x40004000, 0x40005000,
94
+ 0x4002c000, 0x4002d000,
95
+ 0x4002e000};
96
+ Chardev *uartchr = i < MAX_SERIAL_PORTS ? serial_hds[i] : NULL;
97
+ Object *txrx_orgate;
98
+ DeviceState *txrx_orgate_dev;
99
+
100
+ txrx_orgate = object_new(TYPE_OR_IRQ);
101
+ object_property_set_int(txrx_orgate, 2, "num-lines", &error_fatal);
102
+ object_property_set_bool(txrx_orgate, true, "realized",
103
+ &error_fatal);
104
+ txrx_orgate_dev = DEVICE(txrx_orgate);
105
+ qdev_connect_gpio_out(txrx_orgate_dev, 0,
106
+ qdev_get_gpio_in(armv7m, uart_txrx_irqno[i]));
107
+ cmsdk_apb_uart_create(uartbase[i],
108
+ qdev_get_gpio_in(txrx_orgate_dev, 0),
109
+ qdev_get_gpio_in(txrx_orgate_dev, 1),
110
+ qdev_get_gpio_in(orgate_dev, 0),
111
+ qdev_get_gpio_in(orgate_dev, 1),
112
+ NULL,
113
+ uartchr, SYSCLK_FRQ);
114
+ }
115
+ break;
116
+ }
117
+ default:
118
+ g_assert_not_reached();
119
+ }
120
+
121
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
122
123
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
124
diff --git a/hw/char/cmsdk-apb-uart.c b/hw/char/cmsdk-apb-uart.c
125
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
126
--- a/hw/char/cmsdk-apb-uart.c
41
--- a/linux-user/main.c
127
+++ b/hw/char/cmsdk-apb-uart.c
42
+++ b/linux-user/main.c
128
@@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_uart_realize(DeviceState *dev, Error **errp)
43
@@ -XXX,XX +XXX,XX @@ static void handle_arg_reserved_va(const char *arg)
129
* an event handler to deal with CHR_EVENT_BREAK.
44
reserved_va = val ? val - 1 : 0;
130
*/
131
qemu_chr_fe_set_handlers(&s->chr, uart_can_receive, uart_receive,
132
- NULL, s, NULL, true);
133
+ NULL, NULL, s, NULL, true);
134
}
45
}
135
46
136
static int cmsdk_apb_uart_post_load(void *opaque, int version_id)
47
-static void handle_arg_singlestep(const char *arg)
48
+static void handle_arg_one_insn_per_tb(const char *arg)
49
{
50
opt_one_insn_per_tb = true;
51
}
52
@@ -XXX,XX +XXX,XX @@ static const struct qemu_argument arg_table[] = {
53
"logfile", "write logs to 'logfile' (default stderr)"},
54
{"p", "QEMU_PAGESIZE", true, handle_arg_pagesize,
55
"pagesize", "set the host page size to 'pagesize'"},
56
- {"singlestep", "QEMU_SINGLESTEP", false, handle_arg_singlestep,
57
- "", "run in singlestep mode"},
58
+ {"one-insn-per-tb",
59
+ "QEMU_ONE_INSN_PER_TB", false, handle_arg_one_insn_per_tb,
60
+ "", "run with one guest instruction per emulated TB"},
61
+ {"singlestep", "QEMU_SINGLESTEP", false, handle_arg_one_insn_per_tb,
62
+ "", "deprecated synonym for -one-insn-per-tb"},
63
{"strace", "QEMU_STRACE", false, handle_arg_strace,
64
"", "log system calls"},
65
{"seed", "QEMU_RAND_SEED", true, handle_arg_seed,
137
--
66
--
138
2.7.4
67
2.34.1
139
68
140
69
diff view generated by jsdifflib
New patch
1
The '-singlestep' option is confusing, because it doesn't actually
2
have anything to do with single-stepping the CPU. What it does do
3
is force TCG emulation to put one guest instruction in each TB,
4
which can be useful in some situations.
1
5
6
Create a new command line argument -one-insn-per-tb, so we can
7
document that -singlestep is just a deprecated synonym for it,
8
and eventually perhaps drop it.
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Warner Losh <imp@bsdimp.com>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Message-id: 20230417164041.684562-6-peter.maydell@linaro.org
15
---
16
docs/user/main.rst | 7 ++++++-
17
bsd-user/main.c | 5 +++--
18
2 files changed, 9 insertions(+), 3 deletions(-)
19
20
diff --git a/docs/user/main.rst b/docs/user/main.rst
21
index XXXXXXX..XXXXXXX 100644
22
--- a/docs/user/main.rst
23
+++ b/docs/user/main.rst
24
@@ -XXX,XX +XXX,XX @@ Debug options:
25
``-p pagesize``
26
Act as if the host page size was 'pagesize' bytes
27
28
+``-one-insn-per-tb``
29
+ Run the emulation with one guest instruction per translation block.
30
+ This slows down emulation a lot, but can be useful in some situations,
31
+ such as when trying to analyse the logs produced by the ``-d`` option.
32
+
33
``-singlestep``
34
- Run the emulation in single step mode.
35
+ This is a deprecated synonym for the ``-one-insn-per-tb`` option.
36
diff --git a/bsd-user/main.c b/bsd-user/main.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/bsd-user/main.c
39
+++ b/bsd-user/main.c
40
@@ -XXX,XX +XXX,XX @@ static void usage(void)
41
"-d item1[,...] enable logging of specified items\n"
42
" (use '-d help' for a list of log items)\n"
43
"-D logfile write logs to 'logfile' (default stderr)\n"
44
- "-singlestep always run in singlestep mode\n"
45
+ "-one-insn-per-tb run with one guest instruction per emulated TB\n"
46
+ "-singlestep deprecated synonym for -one-insn-per-tb\n"
47
"-strace log system calls\n"
48
"-trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
49
" specify tracing options\n"
50
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
51
(void) envlist_unsetenv(envlist, "LD_PRELOAD");
52
} else if (!strcmp(r, "seed")) {
53
seed_optarg = optarg;
54
- } else if (!strcmp(r, "singlestep")) {
55
+ } else if (!strcmp(r, "singlestep") || !strcmp(r, "one-insn-per-tb")) {
56
opt_one_insn_per_tb = true;
57
} else if (!strcmp(r, "strace")) {
58
do_strace = 1;
59
--
60
2.34.1
61
62
diff view generated by jsdifflib
New patch
1
Document that the -singlestep command line option is now
2
deprecated, as it is replaced by either the TCG accelerator
3
property 'one-insn-per-tb' for system emulation or the new
4
'-one-insn-per-tb' option for usermode emulation, and remove
5
the only use of the deprecated syntax from a README.
1
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Message-id: 20230417164041.684562-7-peter.maydell@linaro.org
11
---
12
docs/about/deprecated.rst | 16 ++++++++++++++++
13
qemu-options.hx | 5 +++--
14
tcg/tci/README | 2 +-
15
3 files changed, 20 insertions(+), 3 deletions(-)
16
17
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
18
index XXXXXXX..XXXXXXX 100644
19
--- a/docs/about/deprecated.rst
20
+++ b/docs/about/deprecated.rst
21
@@ -XXX,XX +XXX,XX @@ Use ``-machine acpi=off`` instead.
22
The HAXM project has been retired (see https://github.com/intel/haxm#status).
23
Use "whpx" (on Windows) or "hvf" (on macOS) instead.
24
25
+``-singlestep`` (since 8.1)
26
+'''''''''''''''''''''''''''
27
+
28
+The ``-singlestep`` option has been turned into an accelerator property,
29
+and given a name that better reflects what it actually does.
30
+Use ``-accel tcg,one-insn-per-tb=on`` instead.
31
+
32
+User-mode emulator command line arguments
33
+-----------------------------------------
34
+
35
+``-singlestep`` (since 8.1)
36
+'''''''''''''''''''''''''''
37
+
38
+The ``-singlestep`` option has been given a name that better reflects
39
+what it actually does. For both linux-user and bsd-user, use the
40
+new ``-one-insn-per-tb`` option instead.
41
42
QEMU Machine Protocol (QMP) commands
43
------------------------------------
44
diff --git a/qemu-options.hx b/qemu-options.hx
45
index XXXXXXX..XXXXXXX 100644
46
--- a/qemu-options.hx
47
+++ b/qemu-options.hx
48
@@ -XXX,XX +XXX,XX @@ SRST
49
ERST
50
51
DEF("singlestep", 0, QEMU_OPTION_singlestep, \
52
- "-singlestep always run in singlestep mode\n", QEMU_ARCH_ALL)
53
+ "-singlestep deprecated synonym for -accel tcg,one-insn-per-tb=on\n", QEMU_ARCH_ALL)
54
SRST
55
``-singlestep``
56
- Run the emulation in single step mode.
57
+ This is a deprecated synonym for the TCG accelerator property
58
+ ``one-insn-per-tb``.
59
ERST
60
61
DEF("preconfig", 0, QEMU_OPTION_preconfig, \
62
diff --git a/tcg/tci/README b/tcg/tci/README
63
index XXXXXXX..XXXXXXX 100644
64
--- a/tcg/tci/README
65
+++ b/tcg/tci/README
66
@@ -XXX,XX +XXX,XX @@ The only difference from running QEMU with TCI to running without TCI
67
should be speed. Especially during development of TCI, it was very
68
useful to compare runs with and without TCI. Create /tmp/qemu.log by
69
70
- qemu-system-i386 -d in_asm,op_opt,cpu -D /tmp/qemu.log -singlestep
71
+ qemu-system-i386 -d in_asm,op_opt,cpu -D /tmp/qemu.log -accel tcg,one-insn-per-tb=on
72
73
once with interpreter and once without interpreter and compare the resulting
74
qemu.log files. This is also useful to see the effects of additional
75
--
76
2.34.1
77
78
diff view generated by jsdifflib
New patch
1
Currently we report whether the TCG accelerator is in
2
'one-insn-per-tb' mode in the 'info status' output. This is a pretty
3
minor piece of TCG specific information, and we want to deprecate the
4
'singlestep' field of the associated QMP command. Move the
5
'one-insn-per-tb' reporting to 'info jit'.
1
6
7
We don't need a deprecate-and-drop period for this because the
8
HMP interface has no stability guarantees.
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Message-id: 20230417164041.684562-8-peter.maydell@linaro.org
14
---
15
accel/tcg/monitor.c | 14 ++++++++++++++
16
softmmu/runstate-hmp-cmds.c | 5 ++---
17
2 files changed, 16 insertions(+), 3 deletions(-)
18
19
diff --git a/accel/tcg/monitor.c b/accel/tcg/monitor.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/accel/tcg/monitor.c
22
+++ b/accel/tcg/monitor.c
23
@@ -XXX,XX +XXX,XX @@
24
*/
25
26
#include "qemu/osdep.h"
27
+#include "qemu/accel.h"
28
#include "qapi/error.h"
29
#include "qapi/type-helpers.h"
30
#include "qapi/qapi-commands-machine.h"
31
@@ -XXX,XX +XXX,XX @@ static void dump_drift_info(GString *buf)
32
}
33
}
34
35
+static void dump_accel_info(GString *buf)
36
+{
37
+ AccelState *accel = current_accel();
38
+ bool one_insn_per_tb = object_property_get_bool(OBJECT(accel),
39
+ "one-insn-per-tb",
40
+ &error_fatal);
41
+
42
+ g_string_append_printf(buf, "Accelerator settings:\n");
43
+ g_string_append_printf(buf, "one-insn-per-tb: %s\n\n",
44
+ one_insn_per_tb ? "on" : "off");
45
+}
46
+
47
HumanReadableText *qmp_x_query_jit(Error **errp)
48
{
49
g_autoptr(GString) buf = g_string_new("");
50
@@ -XXX,XX +XXX,XX @@ HumanReadableText *qmp_x_query_jit(Error **errp)
51
return NULL;
52
}
53
54
+ dump_accel_info(buf);
55
dump_exec_info(buf);
56
dump_drift_info(buf);
57
58
diff --git a/softmmu/runstate-hmp-cmds.c b/softmmu/runstate-hmp-cmds.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/softmmu/runstate-hmp-cmds.c
61
+++ b/softmmu/runstate-hmp-cmds.c
62
@@ -XXX,XX +XXX,XX @@ void hmp_info_status(Monitor *mon, const QDict *qdict)
63
64
info = qmp_query_status(NULL);
65
66
- monitor_printf(mon, "VM status: %s%s",
67
- info->running ? "running" : "paused",
68
- info->singlestep ? " (single step mode)" : "");
69
+ monitor_printf(mon, "VM status: %s",
70
+ info->running ? "running" : "paused");
71
72
if (!info->running && info->status != RUN_STATE_PAUSED) {
73
monitor_printf(mon, " (%s)", RunState_str(info->status));
74
--
75
2.34.1
76
77
diff view generated by jsdifflib
1
Add entries to the MAINTAINERS file for the new MPS2
1
The 'singlestep' HMP command is confusing, because it doesn't
2
board and devices.
2
actually have anything to do with single-stepping the CPU. What it
3
does do is force TCG emulation to put one guest instruction in each
4
TB, which can be useful in some situations.
3
5
4
Since the CMSDK devices are not specific to the MPS2 board,
6
Create a new HMP command 'one-insn-per-tb', so we can document that
5
extend the existing 'PrimeCell' section to cover CMSDK
7
'singlestep' is just a deprecated synonym for it, and eventually
6
devices as well; in both cases these are devices implemented
8
perhaps drop it.
7
by ARM and provided as RTL that may be used in multiple
9
8
SoCs and boards.
10
We aren't obliged to do deprecate-and-drop for HMP commands,
11
but it's easy enough to do so, so we do.
9
12
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 1500029487-14822-10-git-send-email-peter.maydell@linaro.org
14
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
12
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
17
Message-id: 20230417164041.684562-9-peter.maydell@linaro.org
14
---
18
---
15
MAINTAINERS | 14 +++++++++++++-
19
docs/about/deprecated.rst | 9 +++++++++
16
1 file changed, 13 insertions(+), 1 deletion(-)
20
include/monitor/hmp.h | 2 +-
21
softmmu/runstate-hmp-cmds.c | 2 +-
22
tests/qtest/test-hmp.c | 1 +
23
hmp-commands.hx | 25 +++++++++++++++++++++----
24
5 files changed, 33 insertions(+), 6 deletions(-)
17
25
18
diff --git a/MAINTAINERS b/MAINTAINERS
26
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
19
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
20
--- a/MAINTAINERS
28
--- a/docs/about/deprecated.rst
21
+++ b/MAINTAINERS
29
+++ b/docs/about/deprecated.rst
22
@@ -XXX,XX +XXX,XX @@ F: hw/*/allwinner*
30
@@ -XXX,XX +XXX,XX @@ accepted incorrect commands will return an error. Users should make sure that
23
F: include/hw/*/allwinner*
31
all arguments passed to ``device_add`` are consistent with the documented
24
F: hw/arm/cubieboard.c
32
property types.
25
33
26
-ARM PrimeCell
34
+Human Monitor Protocol (HMP) commands
27
+ARM PrimeCell and CMSDK devices
35
+-------------------------------------
28
M: Peter Maydell <peter.maydell@linaro.org>
29
L: qemu-arm@nongnu.org
30
S: Maintained
31
@@ -XXX,XX +XXX,XX @@ F: hw/intc/pl190.c
32
F: hw/sd/pl181.c
33
F: hw/timer/pl031.c
34
F: include/hw/arm/primecell.h
35
+F: hw/timer/cmsdk-apb-timer.c
36
+F: include/hw/timer/cmsdk-apb-timer.h
37
+F: hw/char/cmsdk-apb-uart.c
38
+F: include/hw/char/cmsdk-apb-uart.h
39
40
ARM cores
41
M: Peter Maydell <peter.maydell@linaro.org>
42
@@ -XXX,XX +XXX,XX @@ S: Maintained
43
F: hw/arm/integratorcp.c
44
F: hw/misc/arm_integrator_debug.c
45
46
+MPS2
47
+M: Peter Maydell <peter.maydell@linaro.org>
48
+L: qemu-arm@nongnu.org
49
+S: Maintained
50
+F: hw/arm/mps2.c
51
+F: hw/misc/mps2-scc.c
52
+F: include/hw/misc/mps2-scc.h
53
+
36
+
54
Musicpal
37
+``singlestep`` (since 8.1)
55
M: Jan Kiszka <jan.kiszka@web.de>
38
+''''''''''''''''''''''''''
56
L: qemu-arm@nongnu.org
39
+
40
+The ``singlestep`` command has been replaced by the ``one-insn-per-tb``
41
+command, which has the same behaviour but a less misleading name.
42
+
43
Host Architectures
44
------------------
45
46
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/include/monitor/hmp.h
49
+++ b/include/monitor/hmp.h
50
@@ -XXX,XX +XXX,XX @@ void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict);
51
void hmp_human_readable_text_helper(Monitor *mon,
52
HumanReadableText *(*qmp_handler)(Error **));
53
void hmp_info_stats(Monitor *mon, const QDict *qdict);
54
-void hmp_singlestep(Monitor *mon, const QDict *qdict);
55
+void hmp_one_insn_per_tb(Monitor *mon, const QDict *qdict);
56
void hmp_watchdog_action(Monitor *mon, const QDict *qdict);
57
void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict);
58
void hmp_info_capture(Monitor *mon, const QDict *qdict);
59
diff --git a/softmmu/runstate-hmp-cmds.c b/softmmu/runstate-hmp-cmds.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/softmmu/runstate-hmp-cmds.c
62
+++ b/softmmu/runstate-hmp-cmds.c
63
@@ -XXX,XX +XXX,XX @@ void hmp_info_status(Monitor *mon, const QDict *qdict)
64
qapi_free_StatusInfo(info);
65
}
66
67
-void hmp_singlestep(Monitor *mon, const QDict *qdict)
68
+void hmp_one_insn_per_tb(Monitor *mon, const QDict *qdict)
69
{
70
const char *option = qdict_get_try_str(qdict, "option");
71
AccelState *accel = current_accel();
72
diff --git a/tests/qtest/test-hmp.c b/tests/qtest/test-hmp.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/tests/qtest/test-hmp.c
75
+++ b/tests/qtest/test-hmp.c
76
@@ -XXX,XX +XXX,XX @@ static const char *hmp_cmds[] = {
77
"o /w 0 0x1234",
78
"object_add memory-backend-ram,id=mem1,size=256M",
79
"object_del mem1",
80
+ "one-insn-per-tb on",
81
"pmemsave 0 4096 \"/dev/null\"",
82
"p $pc + 8",
83
"qom-list /",
84
diff --git a/hmp-commands.hx b/hmp-commands.hx
85
index XXXXXXX..XXXXXXX 100644
86
--- a/hmp-commands.hx
87
+++ b/hmp-commands.hx
88
@@ -XXX,XX +XXX,XX @@ SRST
89
only *tag* as parameter.
90
ERST
91
92
+ {
93
+ .name = "one-insn-per-tb",
94
+ .args_type = "option:s?",
95
+ .params = "[on|off]",
96
+ .help = "run emulation with one guest instruction per translation block",
97
+ .cmd = hmp_one_insn_per_tb,
98
+ },
99
+
100
+SRST
101
+``one-insn-per-tb [off]``
102
+ Run the emulation with one guest instruction per translation block.
103
+ This slows down emulation a lot, but can be useful in some situations,
104
+ such as when trying to analyse the logs produced by the ``-d`` option.
105
+ This only has an effect when using TCG, not with KVM or other accelerators.
106
+
107
+ If called with option off, the emulation returns to normal mode.
108
+ERST
109
+
110
{
111
.name = "singlestep",
112
.args_type = "option:s?",
113
.params = "[on|off]",
114
- .help = "run emulation in singlestep mode or switch to normal mode",
115
- .cmd = hmp_singlestep,
116
+ .help = "deprecated synonym for one-insn-per-tb",
117
+ .cmd = hmp_one_insn_per_tb,
118
},
119
120
SRST
121
``singlestep [off]``
122
- Run the emulation in single step mode.
123
- If called with option off, the emulation returns to normal mode.
124
+ This is a deprecated synonym for the one-insn-per-tb command.
125
ERST
126
127
{
57
--
128
--
58
2.7.4
129
2.34.1
59
130
60
131
diff view generated by jsdifflib
1
The MPS2 FPGA images support ethernet via a LAN9220. We use
1
The run-state.json file is missing a trailing newline; add it.
2
QEMU's LAN9118 model, which is software compatible except
3
that it is missing the checksum-offload feature.
4
2
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 1500029487-14822-9-git-send-email-peter.maydell@linaro.org
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Message-id: 20230417164041.684562-10-peter.maydell@linaro.org
9
---
7
---
10
hw/arm/mps2.c | 10 +++++++++-
8
qapi/run-state.json | 2 +-
11
1 file changed, 9 insertions(+), 1 deletion(-)
9
1 file changed, 1 insertion(+), 1 deletion(-)
12
10
13
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
11
diff --git a/qapi/run-state.json b/qapi/run-state.json
14
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/mps2.c
13
--- a/qapi/run-state.json
16
+++ b/hw/arm/mps2.c
14
+++ b/qapi/run-state.json
17
@@ -XXX,XX +XXX,XX @@
15
@@ -XXX,XX +XXX,XX @@
18
#include "hw/char/cmsdk-apb-uart.h"
16
# Since: 7.2
19
#include "hw/timer/cmsdk-apb-timer.h"
17
##
20
#include "hw/misc/mps2-scc.h"
18
{ 'enum': 'NotifyVmexitOption',
21
+#include "hw/devices.h"
19
- 'data': [ 'run', 'internal-error', 'disable' ] }
22
+#include "net/net.h"
20
\ No newline at end of file
23
21
+ 'data': [ 'run', 'internal-error', 'disable' ] }
24
typedef enum MPS2FPGAType {
25
FPGA_AN385,
26
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
27
create_unimplemented_device("Extra peripheral region @0x40020000",
28
0x40020000, 0x00010000);
29
create_unimplemented_device("RESERVED 4", 0x40030000, 0x001D0000);
30
- create_unimplemented_device("Ethernet", 0x40200000, 0x00100000);
31
create_unimplemented_device("VGA", 0x41000000, 0x0200000);
32
33
switch (mmc->fpga_type) {
34
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
35
&error_fatal);
36
sysbus_mmio_map(SYS_BUS_DEVICE(sccdev), 0, 0x4002f000);
37
38
+ /* In hardware this is a LAN9220; the LAN9118 is software compatible
39
+ * except that it doesn't support the checksum-offload feature.
40
+ */
41
+ lan9118_init(&nd_table[0], 0x40200000,
42
+ qdev_get_gpio_in(armv7m,
43
+ mmc->fpga_type == FPGA_AN385 ? 13 : 47));
44
+
45
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
46
47
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
48
--
22
--
49
2.7.4
23
2.34.1
50
24
51
25
diff view generated by jsdifflib
1
Add the CMSDK APB timers to the MPS2 board.
1
The 'singlestep' member of StatusInfo has never done what the QMP
2
documentation claims it does. What it actually reports is whether
3
TCG is working in "one guest instruction per translation block" mode.
4
5
We no longer need this field for the HMP 'info status' command, as
6
we've moved that information to 'info jit'. It seems unlikely that
7
anybody is monitoring the state of this obscure TCG setting via QMP,
8
especially since QMP provides no means for changing the setting. So
9
simply deprecate the field, without providing any replacement.
10
11
Until we do eventually delete the member, correct the misstatements
12
in the QAPI documentation about it.
13
14
If we do find that there are users for this, then the most likely way
15
we would provide replacement access to the information would be to
16
put the accelerator QOM object at a well-known path such as
17
/machine/accel, which could then be used with the existing qom-set
18
and qom-get commands.
2
19
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 1500029487-14822-6-git-send-email-peter.maydell@linaro.org
22
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
23
Reviewed-by: Markus Armbruster <armbru@redhat.com>
24
Message-id: 20230417164041.684562-11-peter.maydell@linaro.org
6
---
25
---
7
hw/arm/mps2.c | 4 ++++
26
docs/about/deprecated.rst | 14 ++++++++++++++
8
1 file changed, 4 insertions(+)
27
qapi/run-state.json | 14 +++++++++++---
28
2 files changed, 25 insertions(+), 3 deletions(-)
9
29
10
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
30
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
11
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/arm/mps2.c
32
--- a/docs/about/deprecated.rst
13
+++ b/hw/arm/mps2.c
33
+++ b/docs/about/deprecated.rst
34
@@ -XXX,XX +XXX,XX @@ accepted incorrect commands will return an error. Users should make sure that
35
all arguments passed to ``device_add`` are consistent with the documented
36
property types.
37
38
+``StatusInfo`` member ``singlestep`` (since 8.1)
39
+''''''''''''''''''''''''''''''''''''''''''''''''
40
+
41
+The ``singlestep`` member of the ``StatusInfo`` returned from the
42
+``query-status`` command is deprecated. This member has a confusing
43
+name and it never did what the documentation claimed or what its name
44
+suggests. We do not believe that anybody is actually using the
45
+information provided in this member.
46
+
47
+The information it reports is whether the TCG JIT is in "one
48
+instruction per translated block" mode (which can be set on the
49
+command line or via the HMP, but not via QMP). The information remains
50
+available via the HMP 'info jit' command.
51
+
52
Human Monitor Protocol (HMP) commands
53
-------------------------------------
54
55
diff --git a/qapi/run-state.json b/qapi/run-state.json
56
index XXXXXXX..XXXXXXX 100644
57
--- a/qapi/run-state.json
58
+++ b/qapi/run-state.json
14
@@ -XXX,XX +XXX,XX @@
59
@@ -XXX,XX +XXX,XX @@
15
#include "sysemu/sysemu.h"
60
#
16
#include "hw/misc/unimp.h"
61
# @running: true if all VCPUs are runnable, false if not runnable
17
#include "hw/char/cmsdk-apb-uart.h"
62
#
18
+#include "hw/timer/cmsdk-apb-timer.h"
63
-# @singlestep: true if VCPUs are in single-step mode
19
64
+# @singlestep: true if using TCG with one guest instruction
20
typedef enum MPS2FPGAType {
65
+# per translation block
21
FPGA_AN385,
66
#
22
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
67
# @status: the virtual machine @RunState
23
g_assert_not_reached();
68
#
24
}
69
+# Features:
25
70
+# @deprecated: Member 'singlestep' is deprecated (with no replacement).
26
+ cmsdk_apb_timer_create(0x40000000, qdev_get_gpio_in(armv7m, 8), SYSCLK_FRQ);
71
+#
27
+ cmsdk_apb_timer_create(0x40001000, qdev_get_gpio_in(armv7m, 9), SYSCLK_FRQ);
72
# Since: 0.14
28
+
73
#
29
system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
74
-# Notes: @singlestep is enabled through the GDB stub
30
75
+# Notes: @singlestep is enabled on the command line with
31
armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
76
+# '-accel tcg,one-insn-per-tb=on', or with the HMP
77
+# 'one-insn-per-tb' command.
78
##
79
{ 'struct': 'StatusInfo',
80
- 'data': {'running': 'bool', 'singlestep': 'bool', 'status': 'RunState'} }
81
+ 'data': {'running': 'bool',
82
+ 'singlestep': { 'type': 'bool', 'features': [ 'deprecated' ]},
83
+ 'status': 'RunState'} }
84
85
##
86
# @query-status:
32
--
87
--
33
2.7.4
88
2.34.1
34
89
35
90
diff view generated by jsdifflib
1
In DEFINE_PROP_ARRAY, because we use a PropertyInfo (qdev_prop_arraylen)
1
In commit 5242876f37ca we deprecated the dtb-kaslr-seed property of
2
which has a .set_default_value member we will set the field to a default
2
the virt board, but forgot the "since n.n" tag in the documentation
3
value. That default value will be zero, by the C rule that struct
3
of this in deprecated.rst.
4
initialization sets unmentioned members to zero if at least one member
4
5
is initialized. However it's clearer to state it explicitly.
5
This deprecation note first appeared in the 7.1 release, so
6
retrospectively add the correct "since 7.1" annotation to it.
6
7
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Message-id: 1499788408-10096-2-git-send-email-peter.maydell@linaro.org
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Message-id: 20230420122256.1023709-1-peter.maydell@linaro.org
10
---
12
---
11
include/hw/qdev-properties.h | 1 +
13
docs/about/deprecated.rst | 4 ++--
12
1 file changed, 1 insertion(+)
14
1 file changed, 2 insertions(+), 2 deletions(-)
13
15
14
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
16
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/qdev-properties.h
18
--- a/docs/about/deprecated.rst
17
+++ b/include/hw/qdev-properties.h
19
+++ b/docs/about/deprecated.rst
18
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
20
@@ -XXX,XX +XXX,XX @@ Use the more generic event ``DEVICE_UNPLUG_GUEST_ERROR`` instead.
19
_arrayfield, _arrayprop, _arraytype) { \
21
System emulator machines
20
.name = (PROP_ARRAY_LEN_PREFIX _name), \
22
------------------------
21
.info = &(qdev_prop_arraylen), \
23
22
+ .defval.u = 0, \
24
-Arm ``virt`` machine ``dtb-kaslr-seed`` property
23
.offset = offsetof(_state, _field) \
25
-''''''''''''''''''''''''''''''''''''''''''''''''
24
+ type_check(uint32_t, typeof_field(_state, _field)), \
26
+Arm ``virt`` machine ``dtb-kaslr-seed`` property (since 7.1)
25
.arrayinfo = &(_arrayprop), \
27
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
28
29
The ``dtb-kaslr-seed`` property on the ``virt`` board has been
30
deprecated; use the new name ``dtb-randomness`` instead. The new name
26
--
31
--
27
2.7.4
32
2.34.1
28
33
29
34
diff view generated by jsdifflib
New patch
1
The msf2-emac ethernet controller has functions emac_load_desc() and
2
emac_store_desc() which read and write the in-memory descriptor
3
blocks and handle conversion between guest and host endianness.
1
4
5
As currently written, emac_store_desc() does the endianness
6
conversion in-place; this means that it effectively consumes the
7
input EmacDesc struct, because on a big-endian host the fields will
8
be overwritten with the little-endian versions of their values.
9
Unfortunately, in all the callsites the code continues to access
10
fields in the EmacDesc struct after it has called emac_store_desc()
11
-- specifically, it looks at the d.next field.
12
13
The effect of this is that on a big-endian host networking doesn't
14
work because the address of the next descriptor is corrupted.
15
16
We could fix this by making the callsite avoid using the struct; but
17
it's more robust to have emac_store_desc() leave its input alone.
18
19
(emac_load_desc() also does an in-place conversion, but here this is
20
fine, because the function is supposed to be initializing the
21
struct.)
22
23
Cc: qemu-stable@nongnu.org
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Thomas Huth <thuth@redhat.com>
26
Message-id: 20230424151919.1333299-1-peter.maydell@linaro.org
27
---
28
hw/net/msf2-emac.c | 16 ++++++++++------
29
1 file changed, 10 insertions(+), 6 deletions(-)
30
31
diff --git a/hw/net/msf2-emac.c b/hw/net/msf2-emac.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/net/msf2-emac.c
34
+++ b/hw/net/msf2-emac.c
35
@@ -XXX,XX +XXX,XX @@ static void emac_load_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc)
36
d->next = le32_to_cpu(d->next);
37
}
38
39
-static void emac_store_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc)
40
+static void emac_store_desc(MSF2EmacState *s, const EmacDesc *d, hwaddr desc)
41
{
42
- /* Convert from host endianness into LE. */
43
- d->pktaddr = cpu_to_le32(d->pktaddr);
44
- d->pktsize = cpu_to_le32(d->pktsize);
45
- d->next = cpu_to_le32(d->next);
46
+ EmacDesc outd;
47
+ /*
48
+ * Convert from host endianness into LE. We use a local struct because
49
+ * calling code may still want to look at the fields afterwards.
50
+ */
51
+ outd.pktaddr = cpu_to_le32(d->pktaddr);
52
+ outd.pktsize = cpu_to_le32(d->pktsize);
53
+ outd.next = cpu_to_le32(d->next);
54
55
- address_space_write(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, d, sizeof *d);
56
+ address_space_write(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, &outd, sizeof outd);
57
}
58
59
static void msf2_dma_tx(MSF2EmacState *s)
60
--
61
2.34.1
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Cédric Le Goater <clg@kaod.org>
2
2
3
DISAS_UPDATE should be used when the wider CPU state other than just
3
The arm boot.c code includes a utility function write_bootloader()
4
the PC has been updated and we should therefore exit the TCG runtime
4
which assists in writing a boot-code fragment into guest memory,
5
and return to the main execution loop rather assuming DISAS_JUMP would
5
including handling endianness and fixing it up with entry point
6
do that.
6
addresses and similar things. This is useful not just for the boot.c
7
code but also in board model code, so rename it to
8
arm_write_bootloader() and make it globally visible.
7
9
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
Since we are making it public, make its API a little neater: move the
9
Reviewed-by: Richard Henderson <rth@twiddle.net>
11
AddressSpace* argument to be next to the hwaddr argument, and allow
10
Message-id: 20170713141928.25419-3-alex.bennee@linaro.org
12
the fixupcontext array to be const, since we never modify it in this
13
function.
14
15
Cc: qemu-stable@nongnu.org
16
Signed-off-by: Cédric Le Goater <clg@kaod.org>
17
Tested-by: Cédric Le Goater <clg@kaod.org>
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Message-id: 20230424152717.1333930-2-peter.maydell@linaro.org
21
[PMM: Split out from another patch by Cédric, added doc comment]
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
23
---
13
target/arm/translate-a64.c | 14 +++++++-------
24
include/hw/arm/boot.h | 49 +++++++++++++++++++++++++++++++++++++++++++
14
target/arm/translate.c | 6 +++---
25
hw/arm/boot.c | 35 +++++++------------------------
15
2 files changed, 10 insertions(+), 10 deletions(-)
26
2 files changed, 57 insertions(+), 27 deletions(-)
16
27
17
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
28
diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h
18
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/translate-a64.c
30
--- a/include/hw/arm/boot.h
20
+++ b/target/arm/translate-a64.c
31
+++ b/include/hw/arm/boot.h
21
@@ -XXX,XX +XXX,XX @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb)
32
@@ -XXX,XX +XXX,XX @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
22
case DISAS_NEXT:
33
const struct arm_boot_info *info,
23
gen_goto_tb(dc, 1, dc->pc);
34
hwaddr mvbar_addr);
24
break;
35
25
- default:
36
+typedef enum {
26
- case DISAS_UPDATE:
37
+ FIXUP_NONE = 0, /* do nothing */
27
- gen_a64_set_pc_im(dc->pc);
38
+ FIXUP_TERMINATOR, /* end of insns */
28
- /* fall through */
39
+ FIXUP_BOARDID, /* overwrite with board ID number */
29
case DISAS_JUMP:
40
+ FIXUP_BOARD_SETUP, /* overwrite with board specific setup code address */
30
tcg_gen_lookup_and_goto_ptr(cpu_pc);
41
+ FIXUP_ARGPTR_LO, /* overwrite with pointer to kernel args */
31
break;
42
+ FIXUP_ARGPTR_HI, /* overwrite with pointer to kernel args (high half) */
32
- case DISAS_EXIT:
43
+ FIXUP_ENTRYPOINT_LO, /* overwrite with kernel entry point */
33
- tcg_gen_exit_tb(0);
44
+ FIXUP_ENTRYPOINT_HI, /* overwrite with kernel entry point (high half) */
34
- break;
45
+ FIXUP_GIC_CPU_IF, /* overwrite with GIC CPU interface address */
35
case DISAS_TB_JUMP:
46
+ FIXUP_BOOTREG, /* overwrite with boot register address */
36
case DISAS_EXC:
47
+ FIXUP_DSB, /* overwrite with correct DSB insn for cpu */
37
case DISAS_SWI:
48
+ FIXUP_MAX,
38
@@ -XXX,XX +XXX,XX @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb)
49
+} FixupType;
39
*/
50
+
40
tcg_gen_exit_tb(0);
51
+typedef struct ARMInsnFixup {
41
break;
52
+ uint32_t insn;
42
+ case DISAS_UPDATE:
53
+ FixupType fixup;
43
+ gen_a64_set_pc_im(dc->pc);
54
+} ARMInsnFixup;
44
+ /* fall through */
55
+
45
+ case DISAS_EXIT:
56
+/**
46
+ default:
57
+ * arm_write_bootloader - write a bootloader to guest memory
47
+ tcg_gen_exit_tb(0);
58
+ * @name: name of the bootloader blob
48
+ break;
59
+ * @as: AddressSpace to write the bootloader
49
}
60
+ * @addr: guest address to write it
61
+ * @insns: the blob to be loaded
62
+ * @fixupcontext: context to be used for any fixups in @insns
63
+ *
64
+ * Write a bootloader to guest memory at address @addr in the address
65
+ * space @as. @name is the name to use for the resulting ROM blob, so
66
+ * it should be unique in the system and reasonably identifiable for debugging.
67
+ *
68
+ * @insns must be an array of ARMInsnFixup structs, each of which has
69
+ * one 32-bit value to be written to the guest memory, and a fixup to be
70
+ * applied to the value. FIXUP_NONE (do nothing) is value 0, so effectively
71
+ * the fixup is optional when writing a struct initializer.
72
+ * The final entry in the array must be { 0, FIXUP_TERMINATOR }.
73
+ *
74
+ * All other supported fixup types have the semantics "ignore insn
75
+ * and instead use the value from the array element @fixupcontext[fixup]".
76
+ * The caller should therefore provide @fixupcontext as an array of
77
+ * size FIXUP_MAX whose elements have been initialized for at least
78
+ * the entries that @insns refers to.
79
+ */
80
+void arm_write_bootloader(const char *name,
81
+ AddressSpace *as, hwaddr addr,
82
+ const ARMInsnFixup *insns,
83
+ const uint32_t *fixupcontext);
84
+
85
#endif /* HW_ARM_BOOT_H */
86
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
87
index XXXXXXX..XXXXXXX 100644
88
--- a/hw/arm/boot.c
89
+++ b/hw/arm/boot.c
90
@@ -XXX,XX +XXX,XX @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu,
91
return cpu_get_address_space(cs, asidx);
92
}
93
94
-typedef enum {
95
- FIXUP_NONE = 0, /* do nothing */
96
- FIXUP_TERMINATOR, /* end of insns */
97
- FIXUP_BOARDID, /* overwrite with board ID number */
98
- FIXUP_BOARD_SETUP, /* overwrite with board specific setup code address */
99
- FIXUP_ARGPTR_LO, /* overwrite with pointer to kernel args */
100
- FIXUP_ARGPTR_HI, /* overwrite with pointer to kernel args (high half) */
101
- FIXUP_ENTRYPOINT_LO, /* overwrite with kernel entry point */
102
- FIXUP_ENTRYPOINT_HI, /* overwrite with kernel entry point (high half) */
103
- FIXUP_GIC_CPU_IF, /* overwrite with GIC CPU interface address */
104
- FIXUP_BOOTREG, /* overwrite with boot register address */
105
- FIXUP_DSB, /* overwrite with correct DSB insn for cpu */
106
- FIXUP_MAX,
107
-} FixupType;
108
-
109
-typedef struct ARMInsnFixup {
110
- uint32_t insn;
111
- FixupType fixup;
112
-} ARMInsnFixup;
113
-
114
static const ARMInsnFixup bootloader_aarch64[] = {
115
{ 0x580000c0 }, /* ldr x0, arg ; Load the lower 32-bits of DTB */
116
{ 0xaa1f03e1 }, /* mov x1, xzr */
117
@@ -XXX,XX +XXX,XX @@ static const ARMInsnFixup smpboot[] = {
118
{ 0, FIXUP_TERMINATOR }
119
};
120
121
-static void write_bootloader(const char *name, hwaddr addr,
122
- const ARMInsnFixup *insns, uint32_t *fixupcontext,
123
- AddressSpace *as)
124
+void arm_write_bootloader(const char *name,
125
+ AddressSpace *as, hwaddr addr,
126
+ const ARMInsnFixup *insns,
127
+ const uint32_t *fixupcontext)
128
{
129
/* Fix up the specified bootloader fragment and write it into
130
* guest memory using rom_add_blob_fixed(). fixupcontext is
131
@@ -XXX,XX +XXX,XX @@ static void default_write_secondary(ARMCPU *cpu,
132
fixupcontext[FIXUP_DSB] = CP15_DSB_INSN;
50
}
133
}
51
134
52
diff --git a/target/arm/translate.c b/target/arm/translate.c
135
- write_bootloader("smpboot", info->smp_loader_start,
53
index XXXXXXX..XXXXXXX 100644
136
- smpboot, fixupcontext, as);
54
--- a/target/arm/translate.c
137
+ arm_write_bootloader("smpboot", as, info->smp_loader_start,
55
+++ b/target/arm/translate.c
138
+ smpboot, fixupcontext);
56
@@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
139
}
57
case DISAS_NEXT:
140
58
gen_goto_tb(dc, 1, dc->pc);
141
void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
59
break;
142
@@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
60
- case DISAS_UPDATE:
143
fixupcontext[FIXUP_ENTRYPOINT_LO] = entry;
61
- gen_set_pc_im(dc, dc->pc);
144
fixupcontext[FIXUP_ENTRYPOINT_HI] = entry >> 32;
62
- /* fall through */
145
63
case DISAS_JUMP:
146
- write_bootloader("bootloader", info->loader_start,
64
gen_goto_ptr();
147
- primary_loader, fixupcontext, as);
65
break;
148
+ arm_write_bootloader("bootloader", as, info->loader_start,
66
+ case DISAS_UPDATE:
149
+ primary_loader, fixupcontext);
67
+ gen_set_pc_im(dc, dc->pc);
150
68
+ /* fall through */
151
if (info->write_board_setup) {
69
default:
152
info->write_board_setup(cpu, info);
70
/* indicate that the hash table must be used to find the next TB */
71
tcg_gen_exit_tb(0);
72
--
153
--
73
2.7.4
154
2.34.1
74
155
75
156
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Cédric Le Goater <clg@kaod.org>
2
2
3
Previously DISAS_JUMP did ensure this but with the optimisation of
3
When writing the secondary-CPU stub boot loader code to the guest,
4
8a6b28c7 (optimize indirect branches) we might not leave the loop.
4
use arm_write_bootloader() instead of directly calling
5
This means if any pending interrupts are cleared by changing IRQ flags
5
rom_add_blob_fixed(). This fixes a bug on big-endian hosts, because
6
we might never get around to servicing them. You usually notice this
6
arm_write_bootloader() will correctly byte-swap the host-byte-order
7
by seeing the lookup_tb_ptr() helper gainfully chaining TBs together
7
array values into the guest-byte-order to write into the guest
8
while cpu->interrupt_request remains high and the exit_request has not
8
memory.
9
been set.
10
9
11
This breaks amongst other things the OPTEE test suite which executes
10
Cc: qemu-stable@nongnu.org
12
an eret from the secure world after a non-secure world IRQ has gone
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
13
pending which then never gets serviced.
12
Tested-by: Cédric Le Goater <clg@kaod.org>
14
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Instead of using the previously implied semantics of DISAS_JUMP we use
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
DISAS_EXIT which will always exit the run-loop.
15
Message-id: 20230424152717.1333930-3-peter.maydell@linaro.org
17
16
[PMM: Moved the "make arm_write_bootloader() function public" part
18
CC: Etienne Carriere <etienne.carriere@linaro.org>
17
to its own patch; updated commit message to note that this fixes
19
CC: Joakim Bech <joakim.bech@linaro.org>
18
an actual bug; adjust to the API changes noted in previous commit]
20
CC: Jaroslaw Pelczar <j.pelczar@samsung.com>
21
CC: Peter Maydell <peter.maydell@linaro.org>
22
CC: Emilio G. Cota <cota@braap.org>
23
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
24
Reviewed-by: Richard Henderson <rth@twiddle.net>
25
Message-id: 20170713141928.25419-7-alex.bennee@linaro.org
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
---
20
---
28
target/arm/translate-a64.c | 3 ++-
21
hw/arm/aspeed.c | 38 ++++++++++++++++++++------------------
29
target/arm/translate.c | 6 ++++--
22
1 file changed, 20 insertions(+), 18 deletions(-)
30
2 files changed, 6 insertions(+), 3 deletions(-)
31
23
32
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
24
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
33
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/translate-a64.c
26
--- a/hw/arm/aspeed.c
35
+++ b/target/arm/translate-a64.c
27
+++ b/hw/arm/aspeed.c
36
@@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
28
@@ -XXX,XX +XXX,XX @@ struct AspeedMachineState {
37
return;
29
static void aspeed_write_smpboot(ARMCPU *cpu,
38
}
30
const struct arm_boot_info *info)
39
gen_helper_exception_return(cpu_env);
31
{
40
- s->is_jmp = DISAS_JUMP;
32
- static const uint32_t poll_mailbox_ready[] = {
41
+ /* Must exit loop to check un-masked IRQs */
33
+ AddressSpace *as = arm_boot_address_space(cpu, info);
42
+ s->is_jmp = DISAS_EXIT;
34
+ static const ARMInsnFixup poll_mailbox_ready[] = {
43
return;
35
/*
44
case 5: /* DRPS */
36
* r2 = per-cpu go sign value
45
if (rn != 0x1f) {
37
* r1 = AST_SMP_MBOX_FIELD_ENTRY
46
diff --git a/target/arm/translate.c b/target/arm/translate.c
38
* r0 = AST_SMP_MBOX_FIELD_GOSIGN
47
index XXXXXXX..XXXXXXX 100644
39
*/
48
--- a/target/arm/translate.c
40
- 0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5 */
49
+++ b/target/arm/translate.c
41
- 0xe21000ff, /* ands r0, r0, #255 */
50
@@ -XXX,XX +XXX,XX @@ static void gen_rfe(DisasContext *s, TCGv_i32 pc, TCGv_i32 cpsr)
42
- 0xe59f201c, /* ldr r2, [pc, #28] */
51
*/
43
- 0xe1822000, /* orr r2, r2, r0 */
52
gen_helper_cpsr_write_eret(cpu_env, cpsr);
44
+ { 0xee100fb0 }, /* mrc p15, 0, r0, c0, c0, 5 */
53
tcg_temp_free_i32(cpsr);
45
+ { 0xe21000ff }, /* ands r0, r0, #255 */
54
- s->is_jmp = DISAS_JUMP;
46
+ { 0xe59f201c }, /* ldr r2, [pc, #28] */
55
+ /* Must exit loop to check un-masked IRQs */
47
+ { 0xe1822000 }, /* orr r2, r2, r0 */
56
+ s->is_jmp = DISAS_EXIT;
48
49
- 0xe59f1018, /* ldr r1, [pc, #24] */
50
- 0xe59f0018, /* ldr r0, [pc, #24] */
51
+ { 0xe59f1018 }, /* ldr r1, [pc, #24] */
52
+ { 0xe59f0018 }, /* ldr r0, [pc, #24] */
53
54
- 0xe320f002, /* wfe */
55
- 0xe5904000, /* ldr r4, [r0] */
56
- 0xe1520004, /* cmp r2, r4 */
57
- 0x1afffffb, /* bne <wfe> */
58
- 0xe591f000, /* ldr pc, [r1] */
59
- AST_SMP_MBOX_GOSIGN,
60
- AST_SMP_MBOX_FIELD_ENTRY,
61
- AST_SMP_MBOX_FIELD_GOSIGN,
62
+ { 0xe320f002 }, /* wfe */
63
+ { 0xe5904000 }, /* ldr r4, [r0] */
64
+ { 0xe1520004 }, /* cmp r2, r4 */
65
+ { 0x1afffffb }, /* bne <wfe> */
66
+ { 0xe591f000 }, /* ldr pc, [r1] */
67
+ { AST_SMP_MBOX_GOSIGN },
68
+ { AST_SMP_MBOX_FIELD_ENTRY },
69
+ { AST_SMP_MBOX_FIELD_GOSIGN },
70
+ { 0, FIXUP_TERMINATOR }
71
};
72
+ static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
73
74
- rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready,
75
- sizeof(poll_mailbox_ready),
76
- info->smp_loader_start);
77
+ arm_write_bootloader("aspeed.smpboot", as, info->smp_loader_start,
78
+ poll_mailbox_ready, fixupcontext);
57
}
79
}
58
80
59
/* Generate an old-style exception return. Marks pc as dead. */
81
static void aspeed_reset_secondary(ARMCPU *cpu,
60
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
61
tmp = load_cpu_field(spsr);
62
gen_helper_cpsr_write_eret(cpu_env, tmp);
63
tcg_temp_free_i32(tmp);
64
- s->is_jmp = DISAS_JUMP;
65
+ /* Must exit loop to check un-masked IRQs */
66
+ s->is_jmp = DISAS_EXIT;
67
}
68
}
69
break;
70
--
82
--
71
2.7.4
83
2.34.1
72
84
73
85
diff view generated by jsdifflib
1
In some situations it's useful to have a qdev property which doesn't
1
When writing the secondary-CPU stub boot loader code to the guest,
2
automatically set its default value when qdev_property_add_static is
2
use arm_write_bootloader() instead of directly calling
3
called (for instance when the default value is not constant).
3
rom_add_blob_fixed(). This fixes a bug on big-endian hosts, because
4
arm_write_bootloader() will correctly byte-swap the host-byte-order
5
array values into the guest-byte-order to write into the guest
6
memory.
4
7
5
Support this by adding a flag to the Property struct indicating
8
Cc: qemu-stable@nongnu.org
6
whether to set the default value. This replaces the existing test
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
for whether the PropertyInfo set_default_value function pointer is
10
Tested-by: Cédric Le Goater <clg@kaod.org>
8
NULL, and we set the .set_default field to true for all those cases
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
of struct Property which use a PropertyInfo with a non-NULL
12
Message-id: 20230424152717.1333930-4-peter.maydell@linaro.org
10
set_default_value, so behaviour remains the same as before.
13
---
14
hw/arm/raspi.c | 64 +++++++++++++++++++++++++++-----------------------
15
1 file changed, 34 insertions(+), 30 deletions(-)
11
16
12
This gives us the semantics of:
17
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
13
* if .set_default is true, then .info->set_default_value must
14
be not NULL, and .defval is used as the the default value of
15
the property
16
* otherwise, the property system does not set any default, and
17
the field will retain whatever initial value it was given by
18
the device's .instance_init method
19
20
We define two new macros DEFINE_PROP_SIGNED_NODEFAULT and
21
DEFINE_PROP_UNSIGNED_NODEFAULT, to cover the most plausible use cases
22
of wanting to set an integer property with no default value.
23
24
Suggested-by: Markus Armbruster <armbru@redhat.com>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
27
Reviewed-by: Markus Armbruster <armbru@redhat.com>
28
Message-id: 1499788408-10096-3-git-send-email-peter.maydell@linaro.org
29
---
30
include/hw/qdev-core.h | 10 ++++++++++
31
include/hw/qdev-properties.h | 20 ++++++++++++++++++++
32
hw/core/qdev.c | 2 +-
33
3 files changed, 31 insertions(+), 1 deletion(-)
34
35
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
36
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
37
--- a/include/hw/qdev-core.h
19
--- a/hw/arm/raspi.c
38
+++ b/include/hw/qdev-core.h
20
+++ b/hw/arm/raspi.c
39
@@ -XXX,XX +XXX,XX @@ struct BusState {
21
@@ -XXX,XX +XXX,XX @@
40
QLIST_ENTRY(BusState) sibling;
22
#include "qemu/units.h"
41
};
23
#include "qemu/cutils.h"
42
24
#include "qapi/error.h"
43
+/**
25
+#include "hw/arm/boot.h"
44
+ * Property:
26
#include "hw/arm/bcm2836.h"
45
+ * @set_default: true if the default value should be set from @defval,
27
#include "hw/registerfields.h"
46
+ * in which case @info->set_default_value must not be NULL
28
#include "qemu/error-report.h"
47
+ * (if false then no default value is set by the property system
29
@@ -XXX,XX +XXX,XX @@ static const char *board_type(uint32_t board_rev)
48
+ * and the field retains whatever value it was given by instance_init).
30
49
+ * @defval: default value for the property. This is used only if @set_default
31
static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
50
+ * is true.
32
{
51
+ */
33
- static const uint32_t smpboot[] = {
52
struct Property {
34
- 0xe1a0e00f, /* mov lr, pc */
53
const char *name;
35
- 0xe3a0fe00 + (BOARDSETUP_ADDR >> 4), /* mov pc, BOARDSETUP_ADDR */
54
const PropertyInfo *info;
36
- 0xee100fb0, /* mrc p15, 0, r0, c0, c0, 5;get core ID */
55
ptrdiff_t offset;
37
- 0xe7e10050, /* ubfx r0, r0, #0, #2 ;extract LSB */
56
uint8_t bitnr;
38
- 0xe59f5014, /* ldr r5, =0x400000CC ;load mbox base */
57
+ bool set_default;
39
- 0xe320f001, /* 1: yield */
58
union {
40
- 0xe7953200, /* ldr r3, [r5, r0, lsl #4] ;read mbox for our core*/
59
int64_t i;
41
- 0xe3530000, /* cmp r3, #0 ;spin while zero */
60
uint64_t u;
42
- 0x0afffffb, /* beq 1b */
61
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
43
- 0xe7853200, /* str r3, [r5, r0, lsl #4] ;clear mbox */
62
index XXXXXXX..XXXXXXX 100644
44
- 0xe12fff13, /* bx r3 ;jump to target */
63
--- a/include/hw/qdev-properties.h
45
- 0x400000cc, /* (constant: mailbox 3 read/clear base) */
64
+++ b/include/hw/qdev-properties.h
46
+ static const ARMInsnFixup smpboot[] = {
65
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
47
+ { 0xe1a0e00f }, /* mov lr, pc */
66
.info = &(_prop), \
48
+ { 0xe3a0fe00 + (BOARDSETUP_ADDR >> 4) }, /* mov pc, BOARDSETUP_ADDR */
67
.offset = offsetof(_state, _field) \
49
+ { 0xee100fb0 }, /* mrc p15, 0, r0, c0, c0, 5;get core ID */
68
+ type_check(_type,typeof_field(_state, _field)), \
50
+ { 0xe7e10050 }, /* ubfx r0, r0, #0, #2 ;extract LSB */
69
+ .set_default = true, \
51
+ { 0xe59f5014 }, /* ldr r5, =0x400000CC ;load mbox base */
70
.defval.i = (_type)_defval, \
52
+ { 0xe320f001 }, /* 1: yield */
71
}
53
+ { 0xe7953200 }, /* ldr r3, [r5, r0, lsl #4] ;read mbox for our core */
72
54
+ { 0xe3530000 }, /* cmp r3, #0 ;spin while zero */
73
+#define DEFINE_PROP_SIGNED_NODEFAULT(_name, _state, _field, _prop, _type) { \
55
+ { 0x0afffffb }, /* beq 1b */
74
+ .name = (_name), \
56
+ { 0xe7853200 }, /* str r3, [r5, r0, lsl #4] ;clear mbox */
75
+ .info = &(_prop), \
57
+ { 0xe12fff13 }, /* bx r3 ;jump to target */
76
+ .offset = offsetof(_state, _field) \
58
+ { 0x400000cc }, /* (constant: mailbox 3 read/clear base) */
77
+ + type_check(_type, typeof_field(_state, _field)), \
59
+ { 0, FIXUP_TERMINATOR }
78
+ }
60
};
79
+
61
+ static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
80
#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
62
81
.name = (_name), \
63
/* check that we don't overrun board setup vectors */
82
.info = &(qdev_prop_bit), \
64
QEMU_BUILD_BUG_ON(SMPBOOT_ADDR + sizeof(smpboot) > MVBAR_ADDR);
83
.bitnr = (_bit), \
65
@@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
84
.offset = offsetof(_state, _field) \
66
QEMU_BUILD_BUG_ON((BOARDSETUP_ADDR & 0xf) != 0
85
+ type_check(uint32_t,typeof_field(_state, _field)), \
67
|| (BOARDSETUP_ADDR >> 4) >= 0x100);
86
+ .set_default = true, \
68
87
.defval.u = (bool)_defval, \
69
- rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot),
88
}
70
- info->smp_loader_start,
89
71
- arm_boot_address_space(cpu, info));
90
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
72
+ arm_write_bootloader("raspi_smpboot", arm_boot_address_space(cpu, info),
91
.info = &(_prop), \
73
+ info->smp_loader_start, smpboot, fixupcontext);
92
.offset = offsetof(_state, _field) \
74
}
93
+ type_check(_type, typeof_field(_state, _field)), \
75
94
+ .set_default = true, \
76
static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
95
.defval.u = (_type)_defval, \
77
@@ -XXX,XX +XXX,XX @@ static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
96
}
78
* the primary CPU goes into the kernel. We put these variables inside
97
79
* a rom blob, so that the reset for ROM contents zeroes them for us.
98
+#define DEFINE_PROP_UNSIGNED_NODEFAULT(_name, _state, _field, _prop, _type) { \
80
*/
99
+ .name = (_name), \
81
- static const uint32_t smpboot[] = {
100
+ .info = &(_prop), \
82
- 0xd2801b05, /* mov x5, 0xd8 */
101
+ .offset = offsetof(_state, _field) \
83
- 0xd53800a6, /* mrs x6, mpidr_el1 */
102
+ + type_check(_type, typeof_field(_state, _field)), \
84
- 0x924004c6, /* and x6, x6, #0x3 */
103
+ }
85
- 0xd503205f, /* spin: wfe */
104
+
86
- 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */
105
#define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \
87
- 0xb4ffffc4, /* cbz x4, spin */
106
.name = (_name), \
88
- 0xd2800000, /* mov x0, #0x0 */
107
.info = &(qdev_prop_bit64), \
89
- 0xd2800001, /* mov x1, #0x0 */
108
.bitnr = (_bit), \
90
- 0xd2800002, /* mov x2, #0x0 */
109
.offset = offsetof(_state, _field) \
91
- 0xd2800003, /* mov x3, #0x0 */
110
+ type_check(uint64_t, typeof_field(_state, _field)), \
92
- 0xd61f0080, /* br x4 */
111
+ .set_default = true, \
93
+ static const ARMInsnFixup smpboot[] = {
112
.defval.u = (bool)_defval, \
94
+ { 0xd2801b05 }, /* mov x5, 0xd8 */
113
}
95
+ { 0xd53800a6 }, /* mrs x6, mpidr_el1 */
114
96
+ { 0x924004c6 }, /* and x6, x6, #0x3 */
115
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
97
+ { 0xd503205f }, /* spin: wfe */
116
.info = &(qdev_prop_bool), \
98
+ { 0xf86678a4 }, /* ldr x4, [x5,x6,lsl #3] */
117
.offset = offsetof(_state, _field) \
99
+ { 0xb4ffffc4 }, /* cbz x4, spin */
118
+ type_check(bool, typeof_field(_state, _field)), \
100
+ { 0xd2800000 }, /* mov x0, #0x0 */
119
+ .set_default = true, \
101
+ { 0xd2800001 }, /* mov x1, #0x0 */
120
.defval.u = (bool)_defval, \
102
+ { 0xd2800002 }, /* mov x2, #0x0 */
121
}
103
+ { 0xd2800003 }, /* mov x3, #0x0 */
122
104
+ { 0xd61f0080 }, /* br x4 */
123
@@ -XXX,XX +XXX,XX @@ extern const PropertyInfo qdev_prop_link;
105
+ { 0, FIXUP_TERMINATOR }
124
_arrayfield, _arrayprop, _arraytype) { \
106
};
125
.name = (PROP_ARRAY_LEN_PREFIX _name), \
107
+ static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
126
.info = &(qdev_prop_arraylen), \
108
127
+ .set_default = true, \
109
static const uint64_t spintables[] = {
128
.defval.u = 0, \
110
0, 0, 0, 0
129
.offset = offsetof(_state, _field) \
111
};
130
+ type_check(uint32_t, typeof_field(_state, _field)), \
112
131
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
113
- rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot),
132
index XXXXXXX..XXXXXXX 100644
114
- info->smp_loader_start, as);
133
--- a/hw/core/qdev.c
115
+ arm_write_bootloader("raspi_smpboot", as, info->smp_loader_start,
134
+++ b/hw/core/qdev.c
116
+ smpboot, fixupcontext);
135
@@ -XXX,XX +XXX,XX @@ void qdev_property_add_static(DeviceState *dev, Property *prop,
117
rom_add_blob_fixed_as("raspi_spintables", spintables, sizeof(spintables),
136
prop->info->description,
118
SPINTABLE_ADDR, as);
137
&error_abort);
138
139
- if (prop->info->set_default_value) {
140
+ if (prop->set_default) {
141
prop->info->set_default_value(obj, prop);
142
}
143
}
119
}
144
--
120
--
145
2.7.4
121
2.34.1
146
122
147
123
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
The Allwinner PIC model uses set_bit() and clear_bit() to update the
2
values in its irq_pending[] array when an interrupt arrives. However
3
it is using these functions wrongly: they work on an array of type
4
'long', and it is passing an array of type 'uint32_t'. Because the
5
code manually figures out the right array element, this works on
6
little-endian hosts and on 32-bit big-endian hosts, where bits 0..31
7
in a 'long' are in the same place as they are in a 'uint32_t'.
8
However it breaks on 64-bit big-endian hosts.
2
9
3
As a precursor to later patches attempt to come up with a more
10
Remove the use of set_bit() and clear_bit() in favour of using
4
concrete wording for what each of the common exit cases would be.
11
deposit32() on the array element. This fixes a bug where on
12
big-endian 64-bit hosts the guest kernel would hang early on in
13
bootup.
5
14
6
CC: Emilio G. Cota <cota@braap.org>
15
Cc: qemu-stable@nongnu.org
7
CC: Richard Henderson <rth@twiddle.net>
8
CC: Lluís Vilanova <vilanova@ac.upc.edu>
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Richard Henderson <rth@twiddle.net>
11
Message-id: 20170713141928.25419-2-alex.bennee@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Thomas Huth <thuth@redhat.com>
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
19
Message-id: 20230424152833.1334136-1-peter.maydell@linaro.org
13
---
20
---
14
include/exec/exec-all.h | 29 ++++++++++++++++++++++++++---
21
hw/intc/allwinner-a10-pic.c | 7 ++-----
15
1 file changed, 26 insertions(+), 3 deletions(-)
22
1 file changed, 2 insertions(+), 5 deletions(-)
16
23
17
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
24
diff --git a/hw/intc/allwinner-a10-pic.c b/hw/intc/allwinner-a10-pic.c
18
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
19
--- a/include/exec/exec-all.h
26
--- a/hw/intc/allwinner-a10-pic.c
20
+++ b/include/exec/exec-all.h
27
+++ b/hw/intc/allwinner-a10-pic.c
21
@@ -XXX,XX +XXX,XX @@ typedef abi_ulong tb_page_addr_t;
28
@@ -XXX,XX +XXX,XX @@ static void aw_a10_pic_update(AwA10PICState *s)
22
typedef ram_addr_t tb_page_addr_t;
29
static void aw_a10_pic_set_irq(void *opaque, int irq, int level)
23
#endif
30
{
24
31
AwA10PICState *s = opaque;
25
-/* is_jmp field values */
32
+ uint32_t *pending_reg = &s->irq_pending[irq / 32];
26
+/* DisasContext is_jmp field values
33
27
+ *
34
- if (level) {
28
+ * is_jmp starts as DISAS_NEXT. The translator will keep processing
35
- set_bit(irq % 32, (void *)&s->irq_pending[irq / 32]);
29
+ * instructions until an exit condition is reached. If we reach the
36
- } else {
30
+ * exit condition and is_jmp is still DISAS_NEXT (because of some
37
- clear_bit(irq % 32, (void *)&s->irq_pending[irq / 32]);
31
+ * other condition) we simply "jump" to the next address.
38
- }
32
+ * The remaining exit cases are:
39
+ *pending_reg = deposit32(*pending_reg, irq % 32, 1, level);
33
+ *
40
aw_a10_pic_update(s);
34
+ * DISAS_JUMP - Only the PC was modified dynamically (e.g computed)
41
}
35
+ * DISAS_TB_JUMP - Only the PC was modified statically (e.g. branch)
36
+ *
37
+ * In these cases as long as the PC is updated we can chain to the
38
+ * next TB either by exiting the loop or looking up the next TB via
39
+ * the loookup helper.
40
+ *
41
+ * DISAS_UPDATE - CPU State was modified dynamically
42
+ *
43
+ * This covers any other CPU state which necessities us exiting the
44
+ * TCG code to the main run-loop. Typically this includes anything
45
+ * that might change the interrupt state.
46
+ *
47
+ * Individual translators may define additional exit cases to deal
48
+ * with per-target special conditions.
49
+ */
50
#define DISAS_NEXT 0 /* next instruction can be analyzed */
51
#define DISAS_JUMP 1 /* only pc was modified dynamically */
52
-#define DISAS_UPDATE 2 /* cpu state was modified dynamically */
53
-#define DISAS_TB_JUMP 3 /* only pc was modified statically */
54
+#define DISAS_TB_JUMP 2 /* only pc was modified statically */
55
+#define DISAS_UPDATE 3 /* cpu state was modified dynamically */
56
57
#include "qemu/log.h"
58
42
59
--
43
--
60
2.7.4
44
2.34.1
61
45
62
46
diff view generated by jsdifflib
New patch
1
In several places in the 32-bit Arm translate.c, we try to use
2
load_cpu_field() to load from a CPUARMState field into a TCGv_i32
3
where the field is actually 64-bit. This works on little-endian
4
hosts, but gives the wrong half of the register on big-endian.
1
5
6
Add a new load_cpu_field_low32() which loads the low 32 bits
7
of a 64-bit field into a TCGv_i32. The new macro includes a
8
compile-time check against accidentally using it on a field
9
of the wrong size. Use it to fix the two places in the code
10
where we were using load_cpu_field() on a 64-bit field.
11
12
This fixes a bug where on big-endian hosts the guest would
13
crash after executing an ERET instruction, and a more corner
14
case one where some UNDEFs for attempted accesses to MSR
15
banked registers from Secure EL1 might go to the wrong EL.
16
17
Cc: qemu-stable@nongnu.org
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20230424153909.1419369-2-peter.maydell@linaro.org
21
---
22
target/arm/translate-a32.h | 7 +++++++
23
target/arm/tcg/translate.c | 4 ++--
24
2 files changed, 9 insertions(+), 2 deletions(-)
25
26
diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h
27
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/translate-a32.h
29
+++ b/target/arm/translate-a32.h
30
@@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_cpu_offset(int offset)
31
32
#define load_cpu_field(name) load_cpu_offset(offsetof(CPUARMState, name))
33
34
+/* Load from the low half of a 64-bit field to a TCGv_i32 */
35
+#define load_cpu_field_low32(name) \
36
+ ({ \
37
+ QEMU_BUILD_BUG_ON(sizeof_field(CPUARMState, name) != 8); \
38
+ load_cpu_offset(offsetoflow32(CPUARMState, name)); \
39
+ })
40
+
41
void store_cpu_offset(TCGv_i32 var, int offset, int size);
42
43
#define store_cpu_field(var, name) \
44
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/tcg/translate.c
47
+++ b/target/arm/tcg/translate.c
48
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
49
if (arm_dc_feature(s, ARM_FEATURE_AARCH64) &&
50
dc_isar_feature(aa64_sel2, s)) {
51
/* Target EL is EL<3 minus SCR_EL3.EEL2> */
52
- tcg_el = load_cpu_field(cp15.scr_el3);
53
+ tcg_el = load_cpu_field_low32(cp15.scr_el3);
54
tcg_gen_sextract_i32(tcg_el, tcg_el, ctz32(SCR_EEL2), 1);
55
tcg_gen_addi_i32(tcg_el, tcg_el, 3);
56
} else {
57
@@ -XXX,XX +XXX,XX @@ static bool trans_ERET(DisasContext *s, arg_ERET *a)
58
}
59
if (s->current_el == 2) {
60
/* ERET from Hyp uses ELR_Hyp, not LR */
61
- tmp = load_cpu_field(elr_el[2]);
62
+ tmp = load_cpu_field_low32(elr_el[2]);
63
} else {
64
tmp = load_reg(s, 14);
65
}
66
--
67
2.34.1
diff view generated by jsdifflib
New patch
1
Add some compile-time asserts to the load_cpu_field() and store_cpu_field()
2
macros that the struct field being accessed is the expected size. This
3
lets us catch cases where we incorrectly tried to do a 32-bit load
4
from a 64-bit struct field.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230424153909.1419369-3-peter.maydell@linaro.org
9
---
10
target/arm/translate-a32.h | 17 +++++++++++++----
11
1 file changed, 13 insertions(+), 4 deletions(-)
12
13
diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-a32.h
16
+++ b/target/arm/translate-a32.h
17
@@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_cpu_offset(int offset)
18
return tmp;
19
}
20
21
-#define load_cpu_field(name) load_cpu_offset(offsetof(CPUARMState, name))
22
+/* Load from a 32-bit field to a TCGv_i32 */
23
+#define load_cpu_field(name) \
24
+ ({ \
25
+ QEMU_BUILD_BUG_ON(sizeof_field(CPUARMState, name) != 4); \
26
+ load_cpu_offset(offsetof(CPUARMState, name)); \
27
+ })
28
29
/* Load from the low half of a 64-bit field to a TCGv_i32 */
30
#define load_cpu_field_low32(name) \
31
@@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_cpu_offset(int offset)
32
33
void store_cpu_offset(TCGv_i32 var, int offset, int size);
34
35
-#define store_cpu_field(var, name) \
36
- store_cpu_offset(var, offsetof(CPUARMState, name), \
37
- sizeof_field(CPUARMState, name))
38
+#define store_cpu_field(val, name) \
39
+ ({ \
40
+ QEMU_BUILD_BUG_ON(sizeof_field(CPUARMState, name) != 4 \
41
+ && sizeof_field(CPUARMState, name) != 1); \
42
+ store_cpu_offset(val, offsetof(CPUARMState, name), \
43
+ sizeof_field(CPUARMState, name)); \
44
+ })
45
46
#define store_cpu_field_constant(val, name) \
47
store_cpu_field(tcg_constant_i32(val), name)
48
--
49
2.34.1
diff view generated by jsdifflib
1
Implement a model of the Serial Communication Controller (SCC) found
1
In allwinner_sdhost_process_desc() we just read directly from
2
in MPS2 FPGA images.
2
guest memory into a host TransferDescriptor struct and back.
3
This only works on little-endian hosts. Abstract the reading
4
and writing of descriptors into functions that handle the
5
byte-swapping so that TransferDescriptor structs as seen by
6
the rest of the code are always in host-order.
3
7
4
The primary purpose of this device is to communicate with the
8
This fixes a failure of one of the avocado tests on s390.
5
Motherboard Configuration Controller (MCC) which is located on
6
the MPS board itself, outside the FPGA image. This is used
7
for programming the MPS clock generators. The SCC also has
8
some basic ID registers and an output for the board LEDs.
9
9
10
Cc: qemu-stable@nongnu.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Reviewed-by: Thomas Huth <thuth@redhat.com>
12
Message-id: 1500029487-14822-7-git-send-email-peter.maydell@linaro.org
13
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Message-id: 20230424165053.1428857-2-peter.maydell@linaro.org
13
---
16
---
14
hw/misc/Makefile.objs | 1 +
17
hw/sd/allwinner-sdhost.c | 31 ++++++++++++++++++++++++++-----
15
include/hw/misc/mps2-scc.h | 43 ++++++
18
1 file changed, 26 insertions(+), 5 deletions(-)
16
hw/misc/mps2-scc.c | 310 ++++++++++++++++++++++++++++++++++++++++
17
default-configs/arm-softmmu.mak | 2 +
18
hw/misc/trace-events | 8 ++
19
5 files changed, 364 insertions(+)
20
create mode 100644 include/hw/misc/mps2-scc.h
21
create mode 100644 hw/misc/mps2-scc.c
22
19
23
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
20
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
24
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/misc/Makefile.objs
22
--- a/hw/sd/allwinner-sdhost.c
26
+++ b/hw/misc/Makefile.objs
23
+++ b/hw/sd/allwinner-sdhost.c
27
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_STM32F2XX_SYSCFG) += stm32f2xx_syscfg.o
24
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_auto_stop(AwSdHostState *s)
28
obj-$(CONFIG_MIPS_CPS) += mips_cmgcr.o
25
}
29
obj-$(CONFIG_MIPS_CPS) += mips_cpc.o
26
}
30
obj-$(CONFIG_MIPS_ITU) += mips_itu.o
27
31
+obj-$(CONFIG_MPS2_SCC) += mps2-scc.o
28
+static void read_descriptor(AwSdHostState *s, hwaddr desc_addr,
32
29
+ TransferDescriptor *desc)
33
obj-$(CONFIG_PVPANIC) += pvpanic.o
34
obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
35
diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h
36
new file mode 100644
37
index XXXXXXX..XXXXXXX
38
--- /dev/null
39
+++ b/include/hw/misc/mps2-scc.h
40
@@ -XXX,XX +XXX,XX @@
41
+/*
42
+ * ARM MPS2 SCC emulation
43
+ *
44
+ * Copyright (c) 2017 Linaro Limited
45
+ * Written by Peter Maydell
46
+ *
47
+ * This program is free software; you can redistribute it and/or modify
48
+ * it under the terms of the GNU General Public License version 2 or
49
+ * (at your option) any later version.
50
+ */
51
+
52
+#ifndef MPS2_SCC_H
53
+#define MPS2_SCC_H
54
+
55
+#include "hw/sysbus.h"
56
+
57
+#define TYPE_MPS2_SCC "mps2-scc"
58
+#define MPS2_SCC(obj) OBJECT_CHECK(MPS2SCC, (obj), TYPE_MPS2_SCC)
59
+
60
+#define NUM_OSCCLK 3
61
+
62
+typedef struct {
63
+ /*< private >*/
64
+ SysBusDevice parent_obj;
65
+
66
+ /*< public >*/
67
+ MemoryRegion iomem;
68
+
69
+ uint32_t cfg0;
70
+ uint32_t cfg1;
71
+ uint32_t cfg4;
72
+ uint32_t cfgdata_rtn;
73
+ uint32_t cfgdata_out;
74
+ uint32_t cfgctrl;
75
+ uint32_t cfgstat;
76
+ uint32_t dll;
77
+ uint32_t aid;
78
+ uint32_t id;
79
+ uint32_t oscclk[NUM_OSCCLK];
80
+ uint32_t oscclk_reset[NUM_OSCCLK];
81
+} MPS2SCC;
82
+
83
+#endif
84
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
85
new file mode 100644
86
index XXXXXXX..XXXXXXX
87
--- /dev/null
88
+++ b/hw/misc/mps2-scc.c
89
@@ -XXX,XX +XXX,XX @@
90
+/*
91
+ * ARM MPS2 SCC emulation
92
+ *
93
+ * Copyright (c) 2017 Linaro Limited
94
+ * Written by Peter Maydell
95
+ *
96
+ * This program is free software; you can redistribute it and/or modify
97
+ * it under the terms of the GNU General Public License version 2 or
98
+ * (at your option) any later version.
99
+ */
100
+
101
+/* This is a model of the SCC (Serial Communication Controller)
102
+ * found in the FPGA images of MPS2 development boards.
103
+ *
104
+ * Documentation of it can be found in the MPS2 TRM:
105
+ * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.100112_0100_03_en/index.html
106
+ * and also in the Application Notes documenting individual FPGA images.
107
+ */
108
+
109
+#include "qemu/osdep.h"
110
+#include "qemu/log.h"
111
+#include "qapi/error.h"
112
+#include "trace.h"
113
+#include "hw/sysbus.h"
114
+#include "hw/registerfields.h"
115
+#include "hw/misc/mps2-scc.h"
116
+
117
+REG32(CFG0, 0)
118
+REG32(CFG1, 4)
119
+REG32(CFG3, 0xc)
120
+REG32(CFG4, 0x10)
121
+REG32(CFGDATA_RTN, 0xa0)
122
+REG32(CFGDATA_OUT, 0xa4)
123
+REG32(CFGCTRL, 0xa8)
124
+ FIELD(CFGCTRL, DEVICE, 0, 12)
125
+ FIELD(CFGCTRL, RES1, 12, 8)
126
+ FIELD(CFGCTRL, FUNCTION, 20, 6)
127
+ FIELD(CFGCTRL, RES2, 26, 4)
128
+ FIELD(CFGCTRL, WRITE, 30, 1)
129
+ FIELD(CFGCTRL, START, 31, 1)
130
+REG32(CFGSTAT, 0xac)
131
+ FIELD(CFGSTAT, DONE, 0, 1)
132
+ FIELD(CFGSTAT, ERROR, 1, 1)
133
+REG32(DLL, 0x100)
134
+REG32(AID, 0xFF8)
135
+REG32(ID, 0xFFC)
136
+
137
+/* Handle a write via the SYS_CFG channel to the specified function/device.
138
+ * Return false on error (reported to guest via SYS_CFGCTRL ERROR bit).
139
+ */
140
+static bool scc_cfg_write(MPS2SCC *s, unsigned function,
141
+ unsigned device, uint32_t value)
142
+{
30
+{
143
+ trace_mps2_scc_cfg_write(function, device, value);
31
+ uint32_t desc_words[4];
144
+
32
+ dma_memory_read(&s->dma_as, desc_addr, &desc_words, sizeof(desc_words),
145
+ if (function != 1 || device >= NUM_OSCCLK) {
33
+ MEMTXATTRS_UNSPECIFIED);
146
+ qemu_log_mask(LOG_GUEST_ERROR,
34
+ desc->status = le32_to_cpu(desc_words[0]);
147
+ "MPS2 SCC config write: bad function %d device %d\n",
35
+ desc->size = le32_to_cpu(desc_words[1]);
148
+ function, device);
36
+ desc->addr = le32_to_cpu(desc_words[2]);
149
+ return false;
37
+ desc->next = le32_to_cpu(desc_words[3]);
150
+ }
151
+
152
+ s->oscclk[device] = value;
153
+ return true;
154
+}
38
+}
155
+
39
+
156
+/* Handle a read via the SYS_CFG channel to the specified function/device.
40
+static void write_descriptor(AwSdHostState *s, hwaddr desc_addr,
157
+ * Return false on error (reported to guest via SYS_CFGCTRL ERROR bit),
41
+ const TransferDescriptor *desc)
158
+ * or set *value on success.
159
+ */
160
+static bool scc_cfg_read(MPS2SCC *s, unsigned function,
161
+ unsigned device, uint32_t *value)
162
+{
42
+{
163
+ if (function != 1 || device >= NUM_OSCCLK) {
43
+ uint32_t desc_words[4];
164
+ qemu_log_mask(LOG_GUEST_ERROR,
44
+ desc_words[0] = cpu_to_le32(desc->status);
165
+ "MPS2 SCC config read: bad function %d device %d\n",
45
+ desc_words[1] = cpu_to_le32(desc->size);
166
+ function, device);
46
+ desc_words[2] = cpu_to_le32(desc->addr);
167
+ return false;
47
+ desc_words[3] = cpu_to_le32(desc->next);
168
+ }
48
+ dma_memory_write(&s->dma_as, desc_addr, &desc_words, sizeof(desc_words),
169
+
49
+ MEMTXATTRS_UNSPECIFIED);
170
+ *value = s->oscclk[device];
171
+
172
+ trace_mps2_scc_cfg_read(function, device, *value);
173
+ return true;
174
+}
50
+}
175
+
51
+
176
+static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size)
52
static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
177
+{
53
hwaddr desc_addr,
178
+ MPS2SCC *s = MPS2_SCC(opaque);
54
TransferDescriptor *desc,
179
+ uint64_t r;
55
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
180
+
56
uint32_t num_bytes = max_bytes;
181
+ switch (offset) {
57
uint8_t buf[1024];
182
+ case A_CFG0:
58
183
+ r = s->cfg0;
59
- /* Read descriptor */
184
+ break;
60
- dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc),
185
+ case A_CFG1:
61
- MEMTXATTRS_UNSPECIFIED);
186
+ r = s->cfg1;
62
+ read_descriptor(s, desc_addr, desc);
187
+ break;
63
if (desc->size == 0) {
188
+ case A_CFG3:
64
desc->size = klass->max_desc_size;
189
+ /* These are user-settable DIP switches on the board. We don't
65
} else if (desc->size > klass->max_desc_size) {
190
+ * model that, so just return zeroes.
66
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
191
+ */
67
192
+ r = 0;
68
/* Clear hold flag and flush descriptor */
193
+ break;
69
desc->status &= ~DESC_STATUS_HOLD;
194
+ case A_CFG4:
70
- dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc),
195
+ r = s->cfg4;
71
- MEMTXATTRS_UNSPECIFIED);
196
+ break;
72
+ write_descriptor(s, desc_addr, desc);
197
+ case A_CFGDATA_RTN:
73
198
+ r = s->cfgdata_rtn;
74
return num_done;
199
+ break;
75
}
200
+ case A_CFGDATA_OUT:
201
+ r = s->cfgdata_out;
202
+ break;
203
+ case A_CFGCTRL:
204
+ r = s->cfgctrl;
205
+ break;
206
+ case A_CFGSTAT:
207
+ r = s->cfgstat;
208
+ break;
209
+ case A_DLL:
210
+ r = s->dll;
211
+ break;
212
+ case A_AID:
213
+ r = s->aid;
214
+ break;
215
+ case A_ID:
216
+ r = s->id;
217
+ break;
218
+ default:
219
+ qemu_log_mask(LOG_GUEST_ERROR,
220
+ "MPS2 SCC read: bad offset %x\n", (int) offset);
221
+ r = 0;
222
+ break;
223
+ }
224
+
225
+ trace_mps2_scc_read(offset, r, size);
226
+ return r;
227
+}
228
+
229
+static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value,
230
+ unsigned size)
231
+{
232
+ MPS2SCC *s = MPS2_SCC(opaque);
233
+
234
+ trace_mps2_scc_write(offset, value, size);
235
+
236
+ switch (offset) {
237
+ case A_CFG0:
238
+ /* TODO on some boards bit 0 controls RAM remapping */
239
+ s->cfg0 = value;
240
+ break;
241
+ case A_CFG1:
242
+ /* CFG1 bits [7:0] control the board LEDs. We don't currently have
243
+ * a mechanism for displaying this graphically, so use a trace event.
244
+ */
245
+ trace_mps2_scc_leds(value & 0x80 ? '*' : '.',
246
+ value & 0x40 ? '*' : '.',
247
+ value & 0x20 ? '*' : '.',
248
+ value & 0x10 ? '*' : '.',
249
+ value & 0x08 ? '*' : '.',
250
+ value & 0x04 ? '*' : '.',
251
+ value & 0x02 ? '*' : '.',
252
+ value & 0x01 ? '*' : '.');
253
+ s->cfg1 = value;
254
+ break;
255
+ case A_CFGDATA_OUT:
256
+ s->cfgdata_out = value;
257
+ break;
258
+ case A_CFGCTRL:
259
+ /* Writing to CFGCTRL clears SYS_CFGSTAT */
260
+ s->cfgstat = 0;
261
+ s->cfgctrl = value & ~(R_CFGCTRL_RES1_MASK |
262
+ R_CFGCTRL_RES2_MASK |
263
+ R_CFGCTRL_START_MASK);
264
+
265
+ if (value & R_CFGCTRL_START_MASK) {
266
+ /* Start bit set -- do a read or write (instantaneously) */
267
+ int device = extract32(s->cfgctrl, R_CFGCTRL_DEVICE_SHIFT,
268
+ R_CFGCTRL_DEVICE_LENGTH);
269
+ int function = extract32(s->cfgctrl, R_CFGCTRL_FUNCTION_SHIFT,
270
+ R_CFGCTRL_FUNCTION_LENGTH);
271
+
272
+ s->cfgstat = R_CFGSTAT_DONE_MASK;
273
+ if (s->cfgctrl & R_CFGCTRL_WRITE_MASK) {
274
+ if (!scc_cfg_write(s, function, device, s->cfgdata_out)) {
275
+ s->cfgstat |= R_CFGSTAT_ERROR_MASK;
276
+ }
277
+ } else {
278
+ uint32_t result;
279
+ if (!scc_cfg_read(s, function, device, &result)) {
280
+ s->cfgstat |= R_CFGSTAT_ERROR_MASK;
281
+ } else {
282
+ s->cfgdata_rtn = result;
283
+ }
284
+ }
285
+ }
286
+ break;
287
+ case A_DLL:
288
+ /* DLL stands for Digital Locked Loop.
289
+ * Bits [31:24] (DLL_LOCK_MASK) are writable, and indicate a
290
+ * mask of which of the DLL_LOCKED bits [16:23] should be ORed
291
+ * together to determine the ALL_UNMASKED_DLLS_LOCKED bit [0].
292
+ * For QEMU, our DLLs are always locked, so we can leave bit 0
293
+ * as 1 always and don't need to recalculate it.
294
+ */
295
+ s->dll = deposit32(s->dll, 24, 8, extract32(value, 24, 8));
296
+ break;
297
+ default:
298
+ qemu_log_mask(LOG_GUEST_ERROR,
299
+ "MPS2 SCC write: bad offset 0x%x\n", (int) offset);
300
+ break;
301
+ }
302
+}
303
+
304
+static const MemoryRegionOps mps2_scc_ops = {
305
+ .read = mps2_scc_read,
306
+ .write = mps2_scc_write,
307
+ .endianness = DEVICE_LITTLE_ENDIAN,
308
+};
309
+
310
+static void mps2_scc_reset(DeviceState *dev)
311
+{
312
+ MPS2SCC *s = MPS2_SCC(dev);
313
+ int i;
314
+
315
+ trace_mps2_scc_reset();
316
+ s->cfg0 = 0;
317
+ s->cfg1 = 0;
318
+ s->cfgdata_rtn = 0;
319
+ s->cfgdata_out = 0;
320
+ s->cfgctrl = 0x100000;
321
+ s->cfgstat = 0;
322
+ s->dll = 0xffff0001;
323
+ for (i = 0; i < NUM_OSCCLK; i++) {
324
+ s->oscclk[i] = s->oscclk_reset[i];
325
+ }
326
+}
327
+
328
+static void mps2_scc_init(Object *obj)
329
+{
330
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
331
+ MPS2SCC *s = MPS2_SCC(obj);
332
+
333
+ memory_region_init_io(&s->iomem, obj, &mps2_scc_ops, s, "mps2-scc", 0x1000);
334
+ sysbus_init_mmio(sbd, &s->iomem);
335
+}
336
+
337
+static void mps2_scc_realize(DeviceState *dev, Error **errp)
338
+{
339
+}
340
+
341
+static const VMStateDescription mps2_scc_vmstate = {
342
+ .name = "mps2-scc",
343
+ .version_id = 1,
344
+ .minimum_version_id = 1,
345
+ .fields = (VMStateField[]) {
346
+ VMSTATE_UINT32(cfg0, MPS2SCC),
347
+ VMSTATE_UINT32(cfg1, MPS2SCC),
348
+ VMSTATE_UINT32(cfgdata_rtn, MPS2SCC),
349
+ VMSTATE_UINT32(cfgdata_out, MPS2SCC),
350
+ VMSTATE_UINT32(cfgctrl, MPS2SCC),
351
+ VMSTATE_UINT32(cfgstat, MPS2SCC),
352
+ VMSTATE_UINT32(dll, MPS2SCC),
353
+ VMSTATE_UINT32_ARRAY(oscclk, MPS2SCC, NUM_OSCCLK),
354
+ VMSTATE_END_OF_LIST()
355
+ }
356
+};
357
+
358
+static Property mps2_scc_properties[] = {
359
+ /* Values for various read-only ID registers (which are specific
360
+ * to the board model or FPGA image)
361
+ */
362
+ DEFINE_PROP_UINT32("scc-cfg4", MPS2SCC, aid, 0),
363
+ DEFINE_PROP_UINT32("scc-aid", MPS2SCC, aid, 0),
364
+ DEFINE_PROP_UINT32("scc-id", MPS2SCC, aid, 0),
365
+ /* These are the initial settings for the source clocks on the board.
366
+ * In hardware they can be configured via a config file read by the
367
+ * motherboard configuration controller to suit the FPGA image.
368
+ * These default values are used by most of the standard FPGA images.
369
+ */
370
+ DEFINE_PROP_UINT32("oscclk0", MPS2SCC, oscclk_reset[0], 50000000),
371
+ DEFINE_PROP_UINT32("oscclk1", MPS2SCC, oscclk_reset[1], 24576000),
372
+ DEFINE_PROP_UINT32("oscclk2", MPS2SCC, oscclk_reset[2], 25000000),
373
+ DEFINE_PROP_END_OF_LIST(),
374
+};
375
+
376
+static void mps2_scc_class_init(ObjectClass *klass, void *data)
377
+{
378
+ DeviceClass *dc = DEVICE_CLASS(klass);
379
+
380
+ dc->realize = mps2_scc_realize;
381
+ dc->vmsd = &mps2_scc_vmstate;
382
+ dc->reset = mps2_scc_reset;
383
+ dc->props = mps2_scc_properties;
384
+}
385
+
386
+static const TypeInfo mps2_scc_info = {
387
+ .name = TYPE_MPS2_SCC,
388
+ .parent = TYPE_SYS_BUS_DEVICE,
389
+ .instance_size = sizeof(MPS2SCC),
390
+ .instance_init = mps2_scc_init,
391
+ .class_init = mps2_scc_class_init,
392
+};
393
+
394
+static void mps2_scc_register_types(void)
395
+{
396
+ type_register_static(&mps2_scc_info);
397
+}
398
+
399
+type_init(mps2_scc_register_types);
400
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
401
index XXXXXXX..XXXXXXX 100644
402
--- a/default-configs/arm-softmmu.mak
403
+++ b/default-configs/arm-softmmu.mak
404
@@ -XXX,XX +XXX,XX @@ CONFIG_STM32F205_SOC=y
405
CONFIG_CMSDK_APB_TIMER=y
406
CONFIG_CMSDK_APB_UART=y
407
408
+CONFIG_MPS2_SCC=y
409
+
410
CONFIG_VERSATILE_PCI=y
411
CONFIG_VERSATILE_I2C=y
412
413
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
414
index XXXXXXX..XXXXXXX 100644
415
--- a/hw/misc/trace-events
416
+++ b/hw/misc/trace-events
417
@@ -XXX,XX +XXX,XX @@ milkymist_pfpu_pulse_irq(void) "Pulse IRQ"
418
419
# hw/misc/aspeed_scu.c
420
aspeed_scu_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32
421
+
422
+# hw/misc/mps2_scc.c
423
+mps2_scc_read(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
424
+mps2_scc_write(uint64_t offset, uint64_t data, unsigned size) "MPS2 SCC write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
425
+mps2_scc_reset(void) "MPS2 SCC: reset"
426
+mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, char led1, char led0) "MPS2 SCC LEDs: %c%c%c%c%c%c%c%c"
427
+mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config write: function %d device %d data 0x%" PRIx32
428
+mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config read: function %d device %d data 0x%" PRIx32
429
--
76
--
430
2.7.4
77
2.34.1
431
78
432
79
diff view generated by jsdifflib
1
The Cortex-M3 and M4 CPUs always have 8 PMSA MPU regions (this isn't
1
In allwinner-sun8i-emac we just read directly from guest memory into
2
a configurable option for the hardware). Make the default value of
2
a host FrameDescriptor struct and back. This only works on
3
the pmsav7-dregion property be set per-cpu, so we don't need to have
3
little-endian hosts. Reading and writing of descriptors is already
4
every user of these CPUs set it manually. (The existing default of
4
abstracted into functions; make those functions also handle the
5
16 is correct for the other PMSAv7 core, the Cortex-R5.)
5
byte-swapping so that TransferDescriptor structs as seen by the rest
6
of the code are always in host-order, and fix two places that were
7
doing ad-hoc descriptor reading without using the functions.
6
8
7
This fixes a bug where we were creating the M3 and M4 with
9
Cc: qemu-stable@nongnu.org
8
too many regions; most guest software would not notice or
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
care, though, since it would just not use the registers
11
Reviewed-by: Thomas Huth <thuth@redhat.com>
10
associated with the unexpected extra regions.
12
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Message-id: 20230424165053.1428857-3-peter.maydell@linaro.org
15
---
16
hw/net/allwinner-sun8i-emac.c | 22 +++++++++++++++-------
17
1 file changed, 15 insertions(+), 7 deletions(-)
11
18
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
13
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
14
Message-id: 1499788408-10096-4-git-send-email-peter.maydell@linaro.org
15
---
16
target/arm/cpu.c | 12 +++++++++++-
17
1 file changed, 11 insertions(+), 1 deletion(-)
18
19
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
20
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.c
21
--- a/hw/net/allwinner-sun8i-emac.c
22
+++ b/target/arm/cpu.c
22
+++ b/hw/net/allwinner-sun8i-emac.c
23
@@ -XXX,XX +XXX,XX @@ static Property arm_cpu_has_pmu_property =
23
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
24
static Property arm_cpu_has_mpu_property =
24
FrameDescriptor *desc,
25
DEFINE_PROP_BOOL("has-mpu", ARMCPU, has_mpu, true);
25
uint32_t phys_addr)
26
27
+/* This is like DEFINE_PROP_UINT32 but it doesn't set the default value,
28
+ * because the CPU initfn will have already set cpu->pmsav7_dregion to
29
+ * the right value for that particular CPU type, and we don't want
30
+ * to override that with an incorrect constant value.
31
+ */
32
static Property arm_cpu_pmsav7_dregion_property =
33
- DEFINE_PROP_UINT32("pmsav7-dregion", ARMCPU, pmsav7_dregion, 16);
34
+ DEFINE_PROP_UNSIGNED_NODEFAULT("pmsav7-dregion", ARMCPU,
35
+ pmsav7_dregion,
36
+ qdev_prop_uint32, uint32_t);
37
38
static void arm_cpu_post_init(Object *obj)
39
{
26
{
40
@@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj)
27
- dma_memory_read(&s->dma_as, phys_addr, desc, sizeof(*desc),
41
set_feature(&cpu->env, ARM_FEATURE_V7);
28
+ uint32_t desc_words[4];
42
set_feature(&cpu->env, ARM_FEATURE_M);
29
+ dma_memory_read(&s->dma_as, phys_addr, &desc_words, sizeof(desc_words),
43
cpu->midr = 0x410fc231;
30
MEMTXATTRS_UNSPECIFIED);
44
+ cpu->pmsav7_dregion = 8;
31
+ desc->status = le32_to_cpu(desc_words[0]);
32
+ desc->status2 = le32_to_cpu(desc_words[1]);
33
+ desc->addr = le32_to_cpu(desc_words[2]);
34
+ desc->next = le32_to_cpu(desc_words[3]);
45
}
35
}
46
36
47
static void cortex_m4_initfn(Object *obj)
37
static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
48
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
38
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
49
set_feature(&cpu->env, ARM_FEATURE_M);
50
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
51
cpu->midr = 0x410fc240; /* r0p0 */
52
+ cpu->pmsav7_dregion = 8;
53
}
39
}
54
static void arm_v7m_class_init(ObjectClass *oc, void *data)
40
41
static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
42
- FrameDescriptor *desc,
43
+ const FrameDescriptor *desc,
44
uint32_t phys_addr)
55
{
45
{
56
@@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj)
46
- dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc),
57
cpu->id_isar4 = 0x0010142;
47
+ uint32_t desc_words[4];
58
cpu->id_isar5 = 0x0;
48
+ desc_words[0] = cpu_to_le32(desc->status);
59
cpu->mp_is_up = true;
49
+ desc_words[1] = cpu_to_le32(desc->status2);
60
+ cpu->pmsav7_dregion = 16;
50
+ desc_words[2] = cpu_to_le32(desc->addr);
61
define_arm_cp_regs(cpu, cortexr5_cp_reginfo);
51
+ desc_words[3] = cpu_to_le32(desc->next);
52
+ dma_memory_write(&s->dma_as, phys_addr, &desc_words, sizeof(desc_words),
53
MEMTXATTRS_UNSPECIFIED);
62
}
54
}
63
55
56
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
57
break;
58
case REG_TX_CUR_BUF: /* Transmit Current Buffer */
59
if (s->tx_desc_curr != 0) {
60
- dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(desc),
61
- MEMTXATTRS_UNSPECIFIED);
62
+ allwinner_sun8i_emac_get_desc(s, &desc, s->tx_desc_curr);
63
value = desc.addr;
64
} else {
65
value = 0;
66
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
67
break;
68
case REG_RX_CUR_BUF: /* Receive Current Buffer */
69
if (s->rx_desc_curr != 0) {
70
- dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(desc),
71
- MEMTXATTRS_UNSPECIFIED);
72
+ allwinner_sun8i_emac_get_desc(s, &desc, s->rx_desc_curr);
73
value = desc.addr;
74
} else {
75
value = 0;
64
--
76
--
65
2.7.4
77
2.34.1
66
78
67
79
diff view generated by jsdifflib