1
Mostly my stuff with a few easy patches from others. I know I have
1
The following changes since commit e670f6d825d4dee248b311197fd4048469d6772b:
2
a few big series in my to-review queue, but I've been too jetlagged
3
to try to tackle those :-(
4
2
5
thanks
3
Merge remote-tracking branch 'remotes/legoater/tags/pull-ppc-20220218' into staging (2022-02-20 15:05:41 +0000)
6
-- PMM
7
4
8
The following changes since commit a26a98dfb9d448d7234d931ae3720feddf6f0651:
5
are available in the Git repository at:
9
6
10
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20171006' into staging (2017-10-06 13:19:03 +0100)
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220221
11
8
12
are available in the git repository at:
9
for you to fetch changes up to d6333e2543fa41aed4d33f77c808168373e39bff:
13
10
14
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20171006
11
ui/cocoa: Fix the leak of qemu_console_get_label (2022-02-21 09:12:18 +0000)
15
16
for you to fetch changes up to 04829ce334bece78d4fa1d0fdbc8bc27dae9b242:
17
18
nvic: Add missing code for writing SHCSR.HARDFAULTPENDED bit (2017-10-06 16:46:49 +0100)
19
12
20
----------------------------------------------------------------
13
----------------------------------------------------------------
21
target-arm:
14
arm, cocoa and misc:
22
* v8M: more preparatory work
15
* MAINTAINERS file updates
23
* nvic: reset properly rather than leaving the nvic in a weird state
16
* Mark remaining global TypeInfo instances as const
24
* xlnx-zynqmp: Mark the "xlnx, zynqmp" device with user_creatable = false
17
* checkpatch: Ensure that TypeInfos are const
25
* sd: fix out-of-bounds check for multi block reads
18
* tests/qtest: add qtests for npcm7xx sdhci
26
* arm: Fix SMC reporting to EL2 when QEMU provides PSCI
19
* arm hvf: Handle unknown ID registers as RES0
20
* Make KVM -cpu max exactly like -cpu host
21
* Fix '-cpu max' for HVF
22
* Support PAuth extension for hvf
23
* Kconfig: Add I2C_DEVICES device group
24
* Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus
25
* hw/arm/armv7m: Handle disconnected clock inputs
26
* osdep.h: pull out various things into new header files
27
* hw/timer: fix a9gtimer vmstate
28
* hw/arm: add initial mori-bmc board
29
* ui/cocoa: Remove allowedFileTypes restriction in SavePanel
30
* ui/cocoa: Do not alert even without block devices
31
* ui/cocoa: Fix the leak of qemu_console_get_label
27
32
28
----------------------------------------------------------------
33
----------------------------------------------------------------
29
Jan Kiszka (1):
34
Akihiko Odaki (3):
30
arm: Fix SMC reporting to EL2 when QEMU provides PSCI
35
MAINTAINERS: Add Akihiko Odaki to macOS-relateds
36
ui/cocoa: Do not alert even without block devices
37
ui/cocoa: Fix the leak of qemu_console_get_label
31
38
32
Michael Olbrich (1):
39
Alexander Graf (2):
33
hw/sd: fix out-of-bounds check for multi block reads
40
hvf: arm: Use macros for sysreg shift/masking
41
hvf: arm: Handle unknown ID registers as RES0
34
42
35
Peter Maydell (17):
43
Ani Sinha (1):
36
nvic: Clear the vector arrays and prigroup on reset
44
MAINTAINERS: Adding myself as a reviewer of some components
37
target/arm: Don't switch to target stack early in v7M exception return
38
target/arm: Prepare for CONTROL.SPSEL being nonzero in Handler mode
39
target/arm: Restore security state on exception return
40
target/arm: Restore SPSEL to correct CONTROL register on exception return
41
target/arm: Check for xPSR mismatch usage faults earlier for v8M
42
target/arm: Warn about restoring to unaligned stack
43
target/arm: Don't warn about exception return with PC low bit set for v8M
44
target/arm: Add new-in-v8M SFSR and SFAR
45
target/arm: Update excret sanity checks for v8M
46
target/arm: Add support for restoring v8M additional state context
47
target/arm: Add v8M support to exception entry code
48
nvic: Implement Security Attribution Unit registers
49
target/arm: Implement security attribute lookups for memory accesses
50
target/arm: Fix calculation of secure mm_idx values
51
target/arm: Factor out "get mmuidx for specified security state"
52
nvic: Add missing code for writing SHCSR.HARDFAULTPENDED bit
53
45
54
Thomas Huth (1):
46
Bernhard Beschow (2):
55
hw/arm/xlnx-zynqmp: Mark the "xlnx, zynqmp" device with user_creatable = false
47
Mark remaining global TypeInfo instances as const
48
checkpatch: Ensure that TypeInfos are const
56
49
57
target/arm/cpu.h | 60 ++++-
50
Patrick Venture (1):
58
target/arm/internals.h | 15 ++
51
hw/arm: add initial mori-bmc board
59
hw/arm/xlnx-zynqmp.c | 2 +
60
hw/intc/armv7m_nvic.c | 158 ++++++++++-
61
hw/sd/sd.c | 12 +-
62
target/arm/cpu.c | 27 ++
63
target/arm/helper.c | 691 +++++++++++++++++++++++++++++++++++++++++++------
64
target/arm/machine.c | 16 ++
65
target/arm/op_helper.c | 27 +-
66
9 files changed, 898 insertions(+), 110 deletions(-)
67
52
53
Pavel Dovgalyuk (1):
54
hw/timer: fix a9gtimer vmstate
55
56
Peter Maydell (14):
57
target/arm: Move '-cpu host' code to cpu64.c
58
target/arm: Use aarch64_cpu_register() for 'host' CPU type
59
target/arm: Make KVM -cpu max exactly like -cpu host
60
target/arm: Unindent unnecessary else-clause
61
target/arm: Fix '-cpu max' for HVF
62
target/arm: Support PAuth extension for hvf
63
Kconfig: Add I2C_DEVICES device group
64
Kconfig: Add 'imply I2C_DEVICES' on boards with available i2c bus
65
hw/arm/armv7m: Handle disconnected clock inputs
66
include: Move qemu_madvise() and related #defines to new qemu/madvise.h
67
include: Move qemu_mprotect_*() to new qemu/mprotect.h
68
include: Move QEMU_MAP_* constants to mmap-alloc.h
69
include: Move qemu_[id]cache_* declarations to new qemu/cacheinfo.h
70
include: Move hardware version declarations to new qemu/hw-version.h
71
72
Philippe Mathieu-Daudé (1):
73
ui/cocoa: Remove allowedFileTypes restriction in SavePanel
74
75
Shengtan Mao (1):
76
tests/qtest: add qtests for npcm7xx sdhci
77
78
docs/devel/kconfig.rst | 8 +-
79
docs/system/arm/nuvoton.rst | 1 +
80
include/qemu/cacheinfo.h | 21 +++
81
include/qemu/hw-version.h | 27 ++++
82
include/qemu/madvise.h | 95 +++++++++++
83
include/qemu/mmap-alloc.h | 23 +++
84
include/qemu/mprotect.h | 14 ++
85
include/qemu/osdep.h | 132 ----------------
86
accel/tcg/translate-all.c | 1 +
87
backends/hostmem-file.c | 1 +
88
backends/hostmem.c | 1 +
89
hw/arm/armv7m.c | 26 ++-
90
hw/arm/npcm7xx_boards.c | 32 ++++
91
hw/arm/nseries.c | 1 +
92
hw/core/generic-loader.c | 2 +-
93
hw/core/guest-loader.c | 2 +-
94
hw/display/bcm2835_fb.c | 2 +-
95
hw/display/i2c-ddc.c | 2 +-
96
hw/display/macfb.c | 4 +-
97
hw/display/virtio-vga.c | 2 +-
98
hw/dma/bcm2835_dma.c | 2 +-
99
hw/i386/pc_piix.c | 2 +-
100
hw/i386/sgx-epc.c | 2 +-
101
hw/ide/core.c | 1 +
102
hw/intc/bcm2835_ic.c | 2 +-
103
hw/intc/bcm2836_control.c | 2 +-
104
hw/ipmi/ipmi.c | 4 +-
105
hw/mem/nvdimm.c | 2 +-
106
hw/mem/pc-dimm.c | 2 +-
107
hw/misc/bcm2835_mbox.c | 2 +-
108
hw/misc/bcm2835_powermgt.c | 2 +-
109
hw/misc/bcm2835_property.c | 2 +-
110
hw/misc/bcm2835_rng.c | 2 +-
111
hw/misc/pvpanic-isa.c | 2 +-
112
hw/misc/pvpanic-pci.c | 2 +-
113
hw/net/fsl_etsec/etsec.c | 2 +-
114
hw/ppc/prep_systemio.c | 2 +-
115
hw/ppc/spapr_iommu.c | 2 +-
116
hw/s390x/s390-pci-bus.c | 2 +-
117
hw/s390x/sclp.c | 2 +-
118
hw/s390x/tod-kvm.c | 2 +-
119
hw/s390x/tod-tcg.c | 2 +-
120
hw/s390x/tod.c | 2 +-
121
hw/scsi/lsi53c895a.c | 2 +-
122
hw/scsi/megasas.c | 1 +
123
hw/scsi/scsi-bus.c | 1 +
124
hw/scsi/scsi-disk.c | 1 +
125
hw/sd/allwinner-sdhost.c | 2 +-
126
hw/sd/aspeed_sdhci.c | 2 +-
127
hw/sd/bcm2835_sdhost.c | 2 +-
128
hw/sd/cadence_sdhci.c | 2 +-
129
hw/sd/npcm7xx_sdhci.c | 2 +-
130
hw/timer/a9gtimer.c | 21 +++
131
hw/usb/dev-mtp.c | 2 +-
132
hw/usb/host-libusb.c | 2 +-
133
hw/vfio/igd.c | 2 +-
134
hw/virtio/virtio-balloon.c | 1 +
135
hw/virtio/virtio-pmem.c | 2 +-
136
migration/postcopy-ram.c | 1 +
137
migration/qemu-file.c | 1 +
138
migration/ram.c | 1 +
139
plugins/loader.c | 1 +
140
qom/object.c | 4 +-
141
softmmu/physmem.c | 1 +
142
softmmu/vl.c | 1 +
143
target/arm/cpu.c | 30 ----
144
target/arm/cpu64.c | 331 +++++++++++++++++++++------------------
145
target/arm/hvf/hvf.c | 83 +++++++---
146
target/i386/cpu.c | 1 +
147
target/s390x/cpu_models.c | 1 +
148
tcg/region.c | 3 +
149
tcg/tcg.c | 1 +
150
tests/qtest/npcm7xx_sdhci-test.c | 215 +++++++++++++++++++++++++
151
util/atomic64.c | 1 +
152
util/cacheflush.c | 1 +
153
util/cacheinfo.c | 1 +
154
util/osdep.c | 3 +
155
util/oslib-posix.c | 1 +
156
MAINTAINERS | 5 +
157
hw/arm/Kconfig | 10 ++
158
hw/i2c/Kconfig | 5 +
159
hw/rtc/Kconfig | 2 +
160
hw/sensor/Kconfig | 5 +
161
scripts/checkpatch.pl | 1 +
162
tests/qtest/meson.build | 1 +
163
ui/cocoa.m | 15 +-
164
86 files changed, 822 insertions(+), 393 deletions(-)
165
create mode 100644 include/qemu/cacheinfo.h
166
create mode 100644 include/qemu/hw-version.h
167
create mode 100644 include/qemu/madvise.h
168
create mode 100644 include/qemu/mprotect.h
169
create mode 100644 tests/qtest/npcm7xx_sdhci-test.c
170
diff view generated by jsdifflib
New patch
1
From: Ani Sinha <ani@anisinha.ca>
1
2
3
Added myself as a reviewer of vmgenid, unimplemented device and empty slot.
4
5
Signed-off-by: Ani Sinha <ani@anisinha.ca>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20220131122001.1476101-1-ani@anisinha.ca
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
MAINTAINERS | 3 +++
11
1 file changed, 3 insertions(+)
12
13
diff --git a/MAINTAINERS b/MAINTAINERS
14
index XXXXXXX..XXXXXXX 100644
15
--- a/MAINTAINERS
16
+++ b/MAINTAINERS
17
@@ -XXX,XX +XXX,XX @@ F: tests/qtest/prom-env-test.c
18
19
VM Generation ID
20
S: Orphan
21
+R: Ani Sinha <ani@anisinha.ca>
22
F: hw/acpi/vmgenid.c
23
F: include/hw/acpi/vmgenid.h
24
F: docs/specs/vmgenid.txt
25
@@ -XXX,XX +XXX,XX @@ F: hw/misc/led.c
26
Unimplemented device
27
M: Peter Maydell <peter.maydell@linaro.org>
28
R: Philippe Mathieu-Daudé <f4bug@amsat.org>
29
+R: Ani Sinha <ani@anisinha.ca>
30
S: Maintained
31
F: include/hw/misc/unimp.h
32
F: hw/misc/unimp.c
33
@@ -XXX,XX +XXX,XX @@ F: hw/misc/unimp.c
34
Empty slot
35
M: Artyom Tarasenko <atar4qemu@gmail.com>
36
R: Philippe Mathieu-Daudé <f4bug@amsat.org>
37
+R: Ani Sinha <ani@anisinha.ca>
38
S: Maintained
39
F: include/hw/misc/empty_slot.h
40
F: hw/misc/empty_slot.c
41
--
42
2.25.1
43
44
diff view generated by jsdifflib
New patch
1
1
From: Shengtan Mao <stmao@google.com>
2
3
Reviewed-by: Hao Wu <wuhaotsh@google.com>
4
Reviewed-by: Chris Rauer <crauer@google.com>
5
Signed-off-by: Shengtan Mao <stmao@google.com>
6
Signed-off-by: Patrick Venture <venture@google.com>
7
Message-id: 20220208181843.4003568-1-venture@google.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
tests/qtest/npcm7xx_sdhci-test.c | 215 +++++++++++++++++++++++++++++++
12
tests/qtest/meson.build | 1 +
13
2 files changed, 216 insertions(+)
14
create mode 100644 tests/qtest/npcm7xx_sdhci-test.c
15
16
diff --git a/tests/qtest/npcm7xx_sdhci-test.c b/tests/qtest/npcm7xx_sdhci-test.c
17
new file mode 100644
18
index XXXXXXX..XXXXXXX
19
--- /dev/null
20
+++ b/tests/qtest/npcm7xx_sdhci-test.c
21
@@ -XXX,XX +XXX,XX @@
22
+/*
23
+ * QTests for NPCM7xx SD-3.0 / MMC-4.51 Host Controller
24
+ *
25
+ * Copyright (c) 2022 Google LLC
26
+ *
27
+ * This program is free software; you can redistribute it and/or modify it
28
+ * under the terms of the GNU General Public License as published by the
29
+ * Free Software Foundation; either version 2 of the License, or
30
+ * (at your option) any later version.
31
+ *
32
+ * This program is distributed in the hope that it will be useful, but WITHOUT
33
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
35
+ * for more details.
36
+ */
37
+
38
+#include "qemu/osdep.h"
39
+#include "hw/sd/npcm7xx_sdhci.h"
40
+
41
+#include "libqos/libqtest.h"
42
+#include "libqtest-single.h"
43
+#include "libqos/sdhci-cmd.h"
44
+
45
+#define NPCM7XX_REG_SIZE 0x100
46
+#define NPCM7XX_MMC_BA 0xF0842000
47
+#define NPCM7XX_BLK_SIZE 512
48
+#define NPCM7XX_TEST_IMAGE_SIZE (1 << 30)
49
+
50
+char *sd_path;
51
+
52
+static QTestState *setup_sd_card(void)
53
+{
54
+ QTestState *qts = qtest_initf(
55
+ "-machine kudo-bmc "
56
+ "-device sd-card,drive=drive0 "
57
+ "-drive id=drive0,if=none,file=%s,format=raw,auto-read-only=off",
58
+ sd_path);
59
+
60
+ qtest_writew(qts, NPCM7XX_MMC_BA + SDHC_SWRST, SDHC_RESET_ALL);
61
+ qtest_writew(qts, NPCM7XX_MMC_BA + SDHC_CLKCON,
62
+ SDHC_CLOCK_SDCLK_EN | SDHC_CLOCK_INT_STABLE |
63
+ SDHC_CLOCK_INT_EN);
64
+ sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_APP_CMD);
65
+ sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0x41200000, 0, (41 << 8));
66
+ sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_ALL_SEND_CID);
67
+ sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0, 0, SDHC_SEND_RELATIVE_ADDR);
68
+ sdhci_cmd_regs(qts, NPCM7XX_MMC_BA, 0, 0, 0x45670000, 0,
69
+ SDHC_SELECT_DESELECT_CARD);
70
+
71
+ return qts;
72
+}
73
+
74
+static void write_sdread(QTestState *qts, const char *msg)
75
+{
76
+ int fd, ret;
77
+ size_t len = strlen(msg);
78
+ char *rmsg = g_malloc(len);
79
+
80
+ /* write message to sd */
81
+ fd = open(sd_path, O_WRONLY);
82
+ g_assert(fd >= 0);
83
+ ret = write(fd, msg, len);
84
+ close(fd);
85
+ g_assert(ret == len);
86
+
87
+ /* read message using sdhci */
88
+ ret = sdhci_read_cmd(qts, NPCM7XX_MMC_BA, rmsg, len);
89
+ g_assert(ret == len);
90
+ g_assert(!strcmp(rmsg, msg));
91
+
92
+ g_free(rmsg);
93
+}
94
+
95
+/* Check MMC can read values from sd */
96
+static void test_read_sd(void)
97
+{
98
+ QTestState *qts = setup_sd_card();
99
+
100
+ write_sdread(qts, "hello world");
101
+ write_sdread(qts, "goodbye");
102
+
103
+ qtest_quit(qts);
104
+}
105
+
106
+static void sdwrite_read(QTestState *qts, const char *msg)
107
+{
108
+ int fd, ret;
109
+ size_t len = strlen(msg);
110
+ char *rmsg = g_malloc(len);
111
+
112
+ /* write message using sdhci */
113
+ sdhci_write_cmd(qts, NPCM7XX_MMC_BA, msg, len, NPCM7XX_BLK_SIZE);
114
+
115
+ /* read message from sd */
116
+ fd = open(sd_path, O_RDONLY);
117
+ g_assert(fd >= 0);
118
+ ret = read(fd, rmsg, len);
119
+ close(fd);
120
+ g_assert(ret == len);
121
+
122
+ g_assert(!strcmp(rmsg, msg));
123
+
124
+ g_free(rmsg);
125
+}
126
+
127
+/* Check MMC can write values to sd */
128
+static void test_write_sd(void)
129
+{
130
+ QTestState *qts = setup_sd_card();
131
+
132
+ sdwrite_read(qts, "hello world");
133
+ sdwrite_read(qts, "goodbye");
134
+
135
+ qtest_quit(qts);
136
+}
137
+
138
+/* Check SDHCI has correct default values. */
139
+static void test_reset(void)
140
+{
141
+ QTestState *qts = qtest_init("-machine kudo-bmc");
142
+ uint64_t addr = NPCM7XX_MMC_BA;
143
+ uint64_t end_addr = addr + NPCM7XX_REG_SIZE;
144
+ uint16_t prstvals_resets[] = {NPCM7XX_PRSTVALS_0_RESET,
145
+ NPCM7XX_PRSTVALS_1_RESET,
146
+ 0,
147
+ NPCM7XX_PRSTVALS_3_RESET,
148
+ 0,
149
+ 0};
150
+ int i;
151
+ uint32_t mask;
152
+
153
+ while (addr < end_addr) {
154
+ switch (addr - NPCM7XX_MMC_BA) {
155
+ case SDHC_PRNSTS:
156
+ /*
157
+ * ignores bits 20 to 24: they are changed when reading registers
158
+ */
159
+ mask = 0x1f00000;
160
+ g_assert_cmphex(qtest_readl(qts, addr) | mask, ==,
161
+ NPCM7XX_PRSNTS_RESET | mask);
162
+ addr += 4;
163
+ break;
164
+ case SDHC_BLKGAP:
165
+ g_assert_cmphex(qtest_readb(qts, addr), ==, NPCM7XX_BLKGAP_RESET);
166
+ addr += 1;
167
+ break;
168
+ case SDHC_CAPAB:
169
+ g_assert_cmphex(qtest_readq(qts, addr), ==, NPCM7XX_CAPAB_RESET);
170
+ addr += 8;
171
+ break;
172
+ case SDHC_MAXCURR:
173
+ g_assert_cmphex(qtest_readq(qts, addr), ==, NPCM7XX_MAXCURR_RESET);
174
+ addr += 8;
175
+ break;
176
+ case SDHC_HCVER:
177
+ g_assert_cmphex(qtest_readw(qts, addr), ==, NPCM7XX_HCVER_RESET);
178
+ addr += 2;
179
+ break;
180
+ case NPCM7XX_PRSTVALS:
181
+ for (i = 0; i < NPCM7XX_PRSTVALS_SIZE; ++i) {
182
+ g_assert_cmphex(qtest_readw(qts, addr + 2 * i), ==,
183
+ prstvals_resets[i]);
184
+ }
185
+ addr += NPCM7XX_PRSTVALS_SIZE * 2;
186
+ break;
187
+ default:
188
+ g_assert_cmphex(qtest_readb(qts, addr), ==, 0);
189
+ addr += 1;
190
+ }
191
+ }
192
+
193
+ qtest_quit(qts);
194
+}
195
+
196
+static void drive_destroy(void)
197
+{
198
+ unlink(sd_path);
199
+ g_free(sd_path);
200
+}
201
+
202
+static void drive_create(void)
203
+{
204
+ int fd, ret;
205
+ GError *error = NULL;
206
+
207
+ /* Create a temporary raw image */
208
+ fd = g_file_open_tmp("sdhci_XXXXXX", &sd_path, &error);
209
+ if (fd == -1) {
210
+ fprintf(stderr, "unable to create sdhci file: %s\n", error->message);
211
+ g_error_free(error);
212
+ }
213
+ g_assert(sd_path != NULL);
214
+
215
+ ret = ftruncate(fd, NPCM7XX_TEST_IMAGE_SIZE);
216
+ g_assert_cmpint(ret, ==, 0);
217
+ g_message("%s", sd_path);
218
+ close(fd);
219
+}
220
+
221
+int main(int argc, char **argv)
222
+{
223
+ int ret;
224
+
225
+ drive_create();
226
+
227
+ g_test_init(&argc, &argv, NULL);
228
+
229
+ qtest_add_func("npcm7xx_sdhci/reset", test_reset);
230
+ qtest_add_func("npcm7xx_sdhci/write_sd", test_write_sd);
231
+ qtest_add_func("npcm7xx_sdhci/read_sd", test_read_sd);
232
+
233
+ ret = g_test_run();
234
+ drive_destroy();
235
+ return ret;
236
+}
237
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
238
index XXXXXXX..XXXXXXX 100644
239
--- a/tests/qtest/meson.build
240
+++ b/tests/qtest/meson.build
241
@@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \
242
'npcm7xx_gpio-test',
243
'npcm7xx_pwm-test',
244
'npcm7xx_rng-test',
245
+ 'npcm7xx_sdhci-test',
246
'npcm7xx_smbus-test',
247
'npcm7xx_timer-test',
248
'npcm7xx_watchdog_timer-test'] + \
249
--
250
2.25.1
251
252
diff view generated by jsdifflib
1
From: Jan Kiszka <jan.kiszka@siemens.com>
1
From: Alexander Graf <agraf@csgraf.de>
2
2
3
This properly forwards SMC events to EL2 when PSCI is provided by QEMU
3
We are parsing the syndrome field for sysregs in multiple places across
4
itself and, thus, ARM_FEATURE_EL3 is off.
4
the hvf code, but repeat shift/mask operations with hard coded constants
5
every time. This is an error prone approach and makes it harder to reason
6
about the correctness of these operations.
5
7
6
Found and tested with the Jailhouse hypervisor. Solution based on
8
Let's introduce macros that allow us to unify the constants used as well
7
suggestions by Peter Maydell.
9
as create new helpers to extract fields from the sysreg value.
8
10
9
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
11
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 4f243068-aaea-776f-d18f-f9e05e7be9cd@siemens.com
12
Signed-off-by: Alexander Graf <agraf@csgraf.de>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Cameron Esfahani <dirty@apple.com <mailto:dirty@apple.com>>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20220209124135.69183-1-agraf@csgraf.de
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
17
---
14
target/arm/helper.c | 9 ++++++++-
18
target/arm/hvf/hvf.c | 69 ++++++++++++++++++++++++++++++--------------
15
target/arm/op_helper.c | 27 +++++++++++++++++----------
19
1 file changed, 47 insertions(+), 22 deletions(-)
16
2 files changed, 25 insertions(+), 11 deletions(-)
17
20
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
19
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.c
23
--- a/target/arm/hvf/hvf.c
21
+++ b/target/arm/helper.c
24
+++ b/target/arm/hvf/hvf.c
22
@@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
25
@@ -XXX,XX +XXX,XX @@
23
26
ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP, crn, crm, op0, op1, op2)
24
if (arm_feature(env, ARM_FEATURE_EL3)) {
27
#define PL1_WRITE_MASK 0x4
25
valid_mask &= ~HCR_HCD;
28
26
- } else {
29
+#define SYSREG_OP0_SHIFT 20
27
+ } else if (cpu->psci_conduit != QEMU_PSCI_CONDUIT_SMC) {
30
+#define SYSREG_OP0_MASK 0x3
28
+ /* Architecturally HCR.TSC is RES0 if EL3 is not implemented.
31
+#define SYSREG_OP0(sysreg) ((sysreg >> SYSREG_OP0_SHIFT) & SYSREG_OP0_MASK)
29
+ * However, if we're using the SMC PSCI conduit then QEMU is
32
+#define SYSREG_OP1_SHIFT 14
30
+ * effectively acting like EL3 firmware and so the guest at
33
+#define SYSREG_OP1_MASK 0x7
31
+ * EL2 should retain the ability to prevent EL1 from being
34
+#define SYSREG_OP1(sysreg) ((sysreg >> SYSREG_OP1_SHIFT) & SYSREG_OP1_MASK)
32
+ * able to make SMC calls into the ersatz firmware, so in
35
+#define SYSREG_CRN_SHIFT 10
33
+ * that case HCR.TSC should be read/write.
36
+#define SYSREG_CRN_MASK 0xf
34
+ */
37
+#define SYSREG_CRN(sysreg) ((sysreg >> SYSREG_CRN_SHIFT) & SYSREG_CRN_MASK)
35
valid_mask &= ~HCR_TSC;
38
+#define SYSREG_CRM_SHIFT 1
39
+#define SYSREG_CRM_MASK 0xf
40
+#define SYSREG_CRM(sysreg) ((sysreg >> SYSREG_CRM_SHIFT) & SYSREG_CRM_MASK)
41
+#define SYSREG_OP2_SHIFT 17
42
+#define SYSREG_OP2_MASK 0x7
43
+#define SYSREG_OP2(sysreg) ((sysreg >> SYSREG_OP2_SHIFT) & SYSREG_OP2_MASK)
44
+
45
#define SYSREG(op0, op1, crn, crm, op2) \
46
- ((op0 << 20) | (op2 << 17) | (op1 << 14) | (crn << 10) | (crm << 1))
47
-#define SYSREG_MASK SYSREG(0x3, 0x7, 0xf, 0xf, 0x7)
48
+ ((op0 << SYSREG_OP0_SHIFT) | \
49
+ (op1 << SYSREG_OP1_SHIFT) | \
50
+ (crn << SYSREG_CRN_SHIFT) | \
51
+ (crm << SYSREG_CRM_SHIFT) | \
52
+ (op2 << SYSREG_OP2_SHIFT))
53
+#define SYSREG_MASK \
54
+ SYSREG(SYSREG_OP0_MASK, \
55
+ SYSREG_OP1_MASK, \
56
+ SYSREG_CRN_MASK, \
57
+ SYSREG_CRM_MASK, \
58
+ SYSREG_OP2_MASK)
59
#define SYSREG_OSLAR_EL1 SYSREG(2, 0, 1, 0, 4)
60
#define SYSREG_OSLSR_EL1 SYSREG(2, 0, 1, 1, 4)
61
#define SYSREG_OSDLR_EL1 SYSREG(2, 0, 1, 3, 4)
62
@@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt)
63
default:
64
cpu_synchronize_state(cpu);
65
trace_hvf_unhandled_sysreg_read(env->pc, reg,
66
- (reg >> 20) & 0x3,
67
- (reg >> 14) & 0x7,
68
- (reg >> 10) & 0xf,
69
- (reg >> 1) & 0xf,
70
- (reg >> 17) & 0x7);
71
+ SYSREG_OP0(reg),
72
+ SYSREG_OP1(reg),
73
+ SYSREG_CRN(reg),
74
+ SYSREG_CRM(reg),
75
+ SYSREG_OP2(reg));
76
hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized());
77
return 1;
36
}
78
}
37
79
38
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
80
trace_hvf_sysreg_read(reg,
39
index XXXXXXX..XXXXXXX 100644
81
- (reg >> 20) & 0x3,
40
--- a/target/arm/op_helper.c
82
- (reg >> 14) & 0x7,
41
+++ b/target/arm/op_helper.c
83
- (reg >> 10) & 0xf,
42
@@ -XXX,XX +XXX,XX @@ void HELPER(pre_smc)(CPUARMState *env, uint32_t syndrome)
84
- (reg >> 1) & 0xf,
43
*/
85
- (reg >> 17) & 0x7,
44
bool undef = arm_feature(env, ARM_FEATURE_AARCH64) ? smd : smd && !secure;
86
+ SYSREG_OP0(reg),
45
87
+ SYSREG_OP1(reg),
46
- if (arm_is_psci_call(cpu, EXCP_SMC)) {
88
+ SYSREG_CRN(reg),
47
- /* If PSCI is enabled and this looks like a valid PSCI call then
89
+ SYSREG_CRM(reg),
48
- * that overrides the architecturally mandated SMC behaviour.
90
+ SYSREG_OP2(reg),
49
+ if (!arm_feature(env, ARM_FEATURE_EL3) &&
91
val);
50
+ cpu->psci_conduit != QEMU_PSCI_CONDUIT_SMC) {
92
hvf_set_reg(cpu, rt, val);
51
+ /* If we have no EL3 then SMC always UNDEFs and can't be
93
52
+ * trapped to EL2. PSCI-via-SMC is a sort of ersatz EL3
94
@@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val)
53
+ * firmware within QEMU, and we want an EL2 guest to be able
95
CPUARMState *env = &arm_cpu->env;
54
+ * to forbid its EL1 from making PSCI calls into QEMU's
96
55
+ * "firmware" via HCR.TSC, so for these purposes treat
97
trace_hvf_sysreg_write(reg,
56
+ * PSCI-via-SMC as implying an EL3.
98
- (reg >> 20) & 0x3,
57
*/
99
- (reg >> 14) & 0x7,
58
- return;
100
- (reg >> 10) & 0xf,
59
- }
101
- (reg >> 1) & 0xf,
60
-
102
- (reg >> 17) & 0x7,
61
- if (!arm_feature(env, ARM_FEATURE_EL3)) {
103
+ SYSREG_OP0(reg),
62
- /* If we have no EL3 then SMC always UNDEFs */
104
+ SYSREG_OP1(reg),
63
undef = true;
105
+ SYSREG_CRN(reg),
64
} else if (!secure && cur_el == 1 && (env->cp15.hcr_el2 & HCR_TSC)) {
106
+ SYSREG_CRM(reg),
65
- /* In NS EL1, HCR controlled routing to EL2 has priority over SMD. */
107
+ SYSREG_OP2(reg),
66
+ /* In NS EL1, HCR controlled routing to EL2 has priority over SMD.
108
val);
67
+ * We also want an EL2 guest to be able to forbid its EL1 from
109
68
+ * making PSCI calls into QEMU's "firmware" via HCR.TSC.
110
switch (reg) {
69
+ */
111
@@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val)
70
raise_exception(env, EXCP_HYP_TRAP, syndrome, 2);
112
default:
71
}
113
cpu_synchronize_state(cpu);
72
114
trace_hvf_unhandled_sysreg_write(env->pc, reg,
73
- if (undef) {
115
- (reg >> 20) & 0x3,
74
+ /* If PSCI is enabled and this looks like a valid PSCI call then
116
- (reg >> 14) & 0x7,
75
+ * suppress the UNDEF -- we'll catch the SMC exception and
117
- (reg >> 10) & 0xf,
76
+ * implement the PSCI call behaviour there.
118
- (reg >> 1) & 0xf,
77
+ */
119
- (reg >> 17) & 0x7);
78
+ if (undef && !arm_is_psci_call(cpu, EXCP_SMC)) {
120
+ SYSREG_OP0(reg),
79
raise_exception(env, EXCP_UDEF, syn_uncategorized(),
121
+ SYSREG_OP1(reg),
80
exception_target_el(env));
122
+ SYSREG_CRN(reg),
123
+ SYSREG_CRM(reg),
124
+ SYSREG_OP2(reg));
125
hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized());
126
return 1;
81
}
127
}
82
--
128
--
83
2.7.4
129
2.25.1
84
130
85
131
diff view generated by jsdifflib
1
Implement the security attribute lookups for memory accesses
1
From: Alexander Graf <agraf@csgraf.de>
2
in the get_phys_addr() functions, causing these to generate
3
various kinds of SecureFault for bad accesses.
4
2
5
The major subtlety in this code relates to handling of the
3
Recent Linux versions added support to read ID_AA64ISAR2_EL1. On M1,
6
case when the security attributes the SAU assigns to the
4
those reads trap into QEMU which handles them as faults.
7
address don't match the current security state of the CPU.
8
5
9
In the ARM ARM pseudocode for validating instruction
6
However, AArch64 ID registers should always read as RES0. Let's
10
accesses, the security attributes of the address determine
7
handle them accordingly.
11
whether the Secure or NonSecure MPU state is used. At face
12
value, handling this would require us to encode the relevant
13
bits of state into mmu_idx for both S and NS at once, which
14
would result in our needing 16 mmu indexes. Fortunately we
15
don't actually need to do this because a mismatch between
16
address attributes and CPU state means either:
17
* some kind of fault (usually a SecureFault, but in theory
18
perhaps a UserFault for unaligned access to Device memory)
19
* execution of the SG instruction in NS state from a
20
Secure & NonSecure code region
21
8
22
The purpose of SG is simply to flip the CPU into Secure
9
This fixes booting Linux 5.17 guests.
23
state, so we can handle it by emulating execution of that
24
instruction directly in arm_v7m_cpu_do_interrupt(), which
25
means we can treat all the mismatch cases as "throw an
26
exception" and we don't need to encode the state of the
27
other MPU bank into our mmu_idx values.
28
10
29
This commit doesn't include the actual emulation of SG;
11
Cc: qemu-stable@nongnu.org
30
it also doesn't include implementation of the IDAU, which
12
Reported-by: Ivan Babrou <ivan@cloudflare.com>
31
is a per-board way to specify hard-coded memory attributes
13
Signed-off-by: Alexander Graf <agraf@csgraf.de>
32
for addresses, which override the CPU-internal SAU if they
14
Message-id: 20220209124135.69183-2-agraf@csgraf.de
33
specify a more secure setting than the SAU is programmed to.
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
target/arm/hvf/hvf.c | 14 ++++++++++++++
19
1 file changed, 14 insertions(+)
34
20
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
36
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
37
Message-id: 1506092407-26985-15-git-send-email-peter.maydell@linaro.org
38
---
39
target/arm/internals.h | 15 ++++
40
target/arm/helper.c | 182 ++++++++++++++++++++++++++++++++++++++++++++++++-
41
2 files changed, 195 insertions(+), 2 deletions(-)
42
43
diff --git a/target/arm/internals.h b/target/arm/internals.h
44
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/internals.h
23
--- a/target/arm/hvf/hvf.c
46
+++ b/target/arm/internals.h
24
+++ b/target/arm/hvf/hvf.c
47
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_EXCRET, DCRS, 5, 1)
25
@@ -XXX,XX +XXX,XX @@ static bool hvf_handle_psci_call(CPUState *cpu)
48
FIELD(V7M_EXCRET, S, 6, 1)
26
return true;
49
FIELD(V7M_EXCRET, RES1, 7, 25) /* including the must-be-1 prefix */
50
51
+/* We use a few fake FSR values for internal purposes in M profile.
52
+ * M profile cores don't have A/R format FSRs, but currently our
53
+ * get_phys_addr() code assumes A/R profile and reports failures via
54
+ * an A/R format FSR value. We then translate that into the proper
55
+ * M profile exception and FSR status bit in arm_v7m_cpu_do_interrupt().
56
+ * Mostly the FSR values we use for this are those defined for v7PMSA,
57
+ * since we share some of that codepath. A few kinds of fault are
58
+ * only for M profile and have no A/R equivalent, though, so we have
59
+ * to pick a value from the reserved range (which we never otherwise
60
+ * generate) to use for these.
61
+ * These values will never be visible to the guest.
62
+ */
63
+#define M_FAKE_FSR_NSC_EXEC 0xf /* NS executing in S&NSC memory */
64
+#define M_FAKE_FSR_SFAULT 0xe /* SecureFault INVTRAN, INVEP or AUVIOL */
65
+
66
/*
67
* For AArch64, map a given EL to an index in the banked_spsr array.
68
* Note that this mapping and the AArch32 mapping defined in bank_number()
69
diff --git a/target/arm/helper.c b/target/arm/helper.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/target/arm/helper.c
72
+++ b/target/arm/helper.c
73
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
74
target_ulong *page_size_ptr, uint32_t *fsr,
75
ARMMMUFaultInfo *fi);
76
77
+/* Security attributes for an address, as returned by v8m_security_lookup. */
78
+typedef struct V8M_SAttributes {
79
+ bool ns;
80
+ bool nsc;
81
+ uint8_t sregion;
82
+ bool srvalid;
83
+ uint8_t iregion;
84
+ bool irvalid;
85
+} V8M_SAttributes;
86
+
87
/* Definitions for the PMCCNTR and PMCR registers */
88
#define PMCRD 0x8
89
#define PMCRC 0x4
90
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
91
* raises the fault, in the A profile short-descriptor format.
92
*/
93
switch (env->exception.fsr & 0xf) {
94
+ case M_FAKE_FSR_NSC_EXEC:
95
+ /* Exception generated when we try to execute code at an address
96
+ * which is marked as Secure & Non-Secure Callable and the CPU
97
+ * is in the Non-Secure state. The only instruction which can
98
+ * be executed like this is SG (and that only if both halves of
99
+ * the SG instruction have the same security attributes.)
100
+ * Everything else must generate an INVEP SecureFault, so we
101
+ * emulate the SG instruction here.
102
+ * TODO: actually emulate SG.
103
+ */
104
+ env->v7m.sfsr |= R_V7M_SFSR_INVEP_MASK;
105
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
106
+ qemu_log_mask(CPU_LOG_INT,
107
+ "...really SecureFault with SFSR.INVEP\n");
108
+ break;
109
+ case M_FAKE_FSR_SFAULT:
110
+ /* Various flavours of SecureFault for attempts to execute or
111
+ * access data in the wrong security state.
112
+ */
113
+ switch (cs->exception_index) {
114
+ case EXCP_PREFETCH_ABORT:
115
+ if (env->v7m.secure) {
116
+ env->v7m.sfsr |= R_V7M_SFSR_INVTRAN_MASK;
117
+ qemu_log_mask(CPU_LOG_INT,
118
+ "...really SecureFault with SFSR.INVTRAN\n");
119
+ } else {
120
+ env->v7m.sfsr |= R_V7M_SFSR_INVEP_MASK;
121
+ qemu_log_mask(CPU_LOG_INT,
122
+ "...really SecureFault with SFSR.INVEP\n");
123
+ }
124
+ break;
125
+ case EXCP_DATA_ABORT:
126
+ /* This must be an NS access to S memory */
127
+ env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK;
128
+ qemu_log_mask(CPU_LOG_INT,
129
+ "...really SecureFault with SFSR.AUVIOL\n");
130
+ break;
131
+ }
132
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
133
+ break;
134
case 0x8: /* External Abort */
135
switch (cs->exception_index) {
136
case EXCP_PREFETCH_ABORT:
137
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
138
return !(*prot & (1 << access_type));
139
}
27
}
140
28
141
+static bool v8m_is_sau_exempt(CPUARMState *env,
29
+static bool is_id_sysreg(uint32_t reg)
142
+ uint32_t address, MMUAccessType access_type)
143
+{
30
+{
144
+ /* The architecture specifies that certain address ranges are
31
+ return SYSREG_OP0(reg) == 3 &&
145
+ * exempt from v8M SAU/IDAU checks.
32
+ SYSREG_OP1(reg) == 0 &&
146
+ */
33
+ SYSREG_CRN(reg) == 0 &&
147
+ return
34
+ SYSREG_CRM(reg) >= 1 &&
148
+ (access_type == MMU_INST_FETCH && m_is_system_region(env, address)) ||
35
+ SYSREG_CRM(reg) < 8;
149
+ (address >= 0xe0000000 && address <= 0xe0002fff) ||
150
+ (address >= 0xe000e000 && address <= 0xe000efff) ||
151
+ (address >= 0xe002e000 && address <= 0xe002efff) ||
152
+ (address >= 0xe0040000 && address <= 0xe0041fff) ||
153
+ (address >= 0xe00ff000 && address <= 0xe00fffff);
154
+}
36
+}
155
+
37
+
156
+static void v8m_security_lookup(CPUARMState *env, uint32_t address,
38
static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt)
157
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
39
{
158
+ V8M_SAttributes *sattrs)
40
ARMCPU *arm_cpu = ARM_CPU(cpu);
159
+{
41
@@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt)
160
+ /* Look up the security attributes for this address. Compare the
42
/* Dummy register */
161
+ * pseudocode SecurityCheck() function.
43
break;
162
+ * We assume the caller has zero-initialized *sattrs.
44
default:
163
+ */
45
+ if (is_id_sysreg(reg)) {
164
+ ARMCPU *cpu = arm_env_get_cpu(env);
46
+ /* ID system registers read as RES0 */
165
+ int r;
47
+ val = 0;
166
+
48
+ break;
167
+ /* TODO: implement IDAU */
168
+
169
+ if (access_type == MMU_INST_FETCH && extract32(address, 28, 4) == 0xf) {
170
+ /* 0xf0000000..0xffffffff is always S for insn fetches */
171
+ return;
172
+ }
173
+
174
+ if (v8m_is_sau_exempt(env, address, access_type)) {
175
+ sattrs->ns = !regime_is_secure(env, mmu_idx);
176
+ return;
177
+ }
178
+
179
+ switch (env->sau.ctrl & 3) {
180
+ case 0: /* SAU.ENABLE == 0, SAU.ALLNS == 0 */
181
+ break;
182
+ case 2: /* SAU.ENABLE == 0, SAU.ALLNS == 1 */
183
+ sattrs->ns = true;
184
+ break;
185
+ default: /* SAU.ENABLE == 1 */
186
+ for (r = 0; r < cpu->sau_sregion; r++) {
187
+ if (env->sau.rlar[r] & 1) {
188
+ uint32_t base = env->sau.rbar[r] & ~0x1f;
189
+ uint32_t limit = env->sau.rlar[r] | 0x1f;
190
+
191
+ if (base <= address && limit >= address) {
192
+ if (sattrs->srvalid) {
193
+ /* If we hit in more than one region then we must report
194
+ * as Secure, not NS-Callable, with no valid region
195
+ * number info.
196
+ */
197
+ sattrs->ns = false;
198
+ sattrs->nsc = false;
199
+ sattrs->sregion = 0;
200
+ sattrs->srvalid = false;
201
+ break;
202
+ } else {
203
+ if (env->sau.rlar[r] & 2) {
204
+ sattrs->nsc = true;
205
+ } else {
206
+ sattrs->ns = true;
207
+ }
208
+ sattrs->srvalid = true;
209
+ sattrs->sregion = r;
210
+ }
211
+ }
212
+ }
213
+ }
49
+ }
214
+
50
cpu_synchronize_state(cpu);
215
+ /* TODO when we support the IDAU then it may override the result here */
51
trace_hvf_unhandled_sysreg_read(env->pc, reg,
216
+ break;
52
SYSREG_OP0(reg),
217
+ }
218
+}
219
+
220
static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
221
MMUAccessType access_type, ARMMMUIdx mmu_idx,
222
- hwaddr *phys_ptr, int *prot, uint32_t *fsr)
223
+ hwaddr *phys_ptr, MemTxAttrs *txattrs,
224
+ int *prot, uint32_t *fsr)
225
{
226
ARMCPU *cpu = arm_env_get_cpu(env);
227
bool is_user = regime_is_user(env, mmu_idx);
228
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
229
int n;
230
int matchregion = -1;
231
bool hit = false;
232
+ V8M_SAttributes sattrs = {};
233
234
*phys_ptr = address;
235
*prot = 0;
236
237
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
238
+ v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs);
239
+ if (access_type == MMU_INST_FETCH) {
240
+ /* Instruction fetches always use the MMU bank and the
241
+ * transaction attribute determined by the fetch address,
242
+ * regardless of CPU state. This is painful for QEMU
243
+ * to handle, because it would mean we need to encode
244
+ * into the mmu_idx not just the (user, negpri) information
245
+ * for the current security state but also that for the
246
+ * other security state, which would balloon the number
247
+ * of mmu_idx values needed alarmingly.
248
+ * Fortunately we can avoid this because it's not actually
249
+ * possible to arbitrarily execute code from memory with
250
+ * the wrong security attribute: it will always generate
251
+ * an exception of some kind or another, apart from the
252
+ * special case of an NS CPU executing an SG instruction
253
+ * in S&NSC memory. So we always just fail the translation
254
+ * here and sort things out in the exception handler
255
+ * (including possibly emulating an SG instruction).
256
+ */
257
+ if (sattrs.ns != !secure) {
258
+ *fsr = sattrs.nsc ? M_FAKE_FSR_NSC_EXEC : M_FAKE_FSR_SFAULT;
259
+ return true;
260
+ }
261
+ } else {
262
+ /* For data accesses we always use the MMU bank indicated
263
+ * by the current CPU state, but the security attributes
264
+ * might downgrade a secure access to nonsecure.
265
+ */
266
+ if (sattrs.ns) {
267
+ txattrs->secure = false;
268
+ } else if (!secure) {
269
+ /* NS access to S memory must fault.
270
+ * Architecturally we should first check whether the
271
+ * MPU information for this address indicates that we
272
+ * are doing an unaligned access to Device memory, which
273
+ * should generate a UsageFault instead. QEMU does not
274
+ * currently check for that kind of unaligned access though.
275
+ * If we added it we would need to do so as a special case
276
+ * for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt().
277
+ */
278
+ *fsr = M_FAKE_FSR_SFAULT;
279
+ return true;
280
+ }
281
+ }
282
+ }
283
+
284
/* Unlike the ARM ARM pseudocode, we don't need to check whether this
285
* was an exception vector read from the vector table (which is always
286
* done using the default system address map), because those accesses
287
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,
288
if (arm_feature(env, ARM_FEATURE_V8)) {
289
/* PMSAv8 */
290
ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx,
291
- phys_ptr, prot, fsr);
292
+ phys_ptr, attrs, prot, fsr);
293
} else if (arm_feature(env, ARM_FEATURE_V7)) {
294
/* PMSAv7 */
295
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
296
--
53
--
297
2.7.4
54
2.25.1
298
55
299
56
diff view generated by jsdifflib
New patch
1
From: Bernhard Beschow <shentey@gmail.com>
1
2
3
More than 1k of TypeInfo instances are already marked as const. Mark the
4
remaining ones, too.
5
6
This commit was created with:
7
git grep -z -l 'static TypeInfo' -- '*.c' | \
8
xargs -0 sed -i 's/static TypeInfo/static const TypeInfo/'
9
10
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
11
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
12
Reviewed-by: Thomas Huth <thuth@redhat.com>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
16
Acked-by: Corey Minyard <cminyard@mvista.com>
17
Message-id: 20220117145805.173070-2-shentey@gmail.com
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
20
hw/core/generic-loader.c | 2 +-
21
hw/core/guest-loader.c | 2 +-
22
hw/display/bcm2835_fb.c | 2 +-
23
hw/display/i2c-ddc.c | 2 +-
24
hw/display/macfb.c | 4 ++--
25
hw/display/virtio-vga.c | 2 +-
26
hw/dma/bcm2835_dma.c | 2 +-
27
hw/i386/pc_piix.c | 2 +-
28
hw/i386/sgx-epc.c | 2 +-
29
hw/intc/bcm2835_ic.c | 2 +-
30
hw/intc/bcm2836_control.c | 2 +-
31
hw/ipmi/ipmi.c | 4 ++--
32
hw/mem/nvdimm.c | 2 +-
33
hw/mem/pc-dimm.c | 2 +-
34
hw/misc/bcm2835_mbox.c | 2 +-
35
hw/misc/bcm2835_powermgt.c | 2 +-
36
hw/misc/bcm2835_property.c | 2 +-
37
hw/misc/bcm2835_rng.c | 2 +-
38
hw/misc/pvpanic-isa.c | 2 +-
39
hw/misc/pvpanic-pci.c | 2 +-
40
hw/net/fsl_etsec/etsec.c | 2 +-
41
hw/ppc/prep_systemio.c | 2 +-
42
hw/ppc/spapr_iommu.c | 2 +-
43
hw/s390x/s390-pci-bus.c | 2 +-
44
hw/s390x/sclp.c | 2 +-
45
hw/s390x/tod-kvm.c | 2 +-
46
hw/s390x/tod-tcg.c | 2 +-
47
hw/s390x/tod.c | 2 +-
48
hw/scsi/lsi53c895a.c | 2 +-
49
hw/sd/allwinner-sdhost.c | 2 +-
50
hw/sd/aspeed_sdhci.c | 2 +-
51
hw/sd/bcm2835_sdhost.c | 2 +-
52
hw/sd/cadence_sdhci.c | 2 +-
53
hw/sd/npcm7xx_sdhci.c | 2 +-
54
hw/usb/dev-mtp.c | 2 +-
55
hw/usb/host-libusb.c | 2 +-
56
hw/vfio/igd.c | 2 +-
57
hw/virtio/virtio-pmem.c | 2 +-
58
qom/object.c | 4 ++--
59
39 files changed, 42 insertions(+), 42 deletions(-)
60
61
diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/core/generic-loader.c
64
+++ b/hw/core/generic-loader.c
65
@@ -XXX,XX +XXX,XX @@ static void generic_loader_class_init(ObjectClass *klass, void *data)
66
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
67
}
68
69
-static TypeInfo generic_loader_info = {
70
+static const TypeInfo generic_loader_info = {
71
.name = TYPE_GENERIC_LOADER,
72
.parent = TYPE_DEVICE,
73
.instance_size = sizeof(GenericLoaderState),
74
diff --git a/hw/core/guest-loader.c b/hw/core/guest-loader.c
75
index XXXXXXX..XXXXXXX 100644
76
--- a/hw/core/guest-loader.c
77
+++ b/hw/core/guest-loader.c
78
@@ -XXX,XX +XXX,XX @@ static void guest_loader_class_init(ObjectClass *klass, void *data)
79
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
80
}
81
82
-static TypeInfo guest_loader_info = {
83
+static const TypeInfo guest_loader_info = {
84
.name = TYPE_GUEST_LOADER,
85
.parent = TYPE_DEVICE,
86
.instance_size = sizeof(GuestLoaderState),
87
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/hw/display/bcm2835_fb.c
90
+++ b/hw/display/bcm2835_fb.c
91
@@ -XXX,XX +XXX,XX @@ static void bcm2835_fb_class_init(ObjectClass *klass, void *data)
92
dc->vmsd = &vmstate_bcm2835_fb;
93
}
94
95
-static TypeInfo bcm2835_fb_info = {
96
+static const TypeInfo bcm2835_fb_info = {
97
.name = TYPE_BCM2835_FB,
98
.parent = TYPE_SYS_BUS_DEVICE,
99
.instance_size = sizeof(BCM2835FBState),
100
diff --git a/hw/display/i2c-ddc.c b/hw/display/i2c-ddc.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/hw/display/i2c-ddc.c
103
+++ b/hw/display/i2c-ddc.c
104
@@ -XXX,XX +XXX,XX @@ static void i2c_ddc_class_init(ObjectClass *oc, void *data)
105
isc->send = i2c_ddc_tx;
106
}
107
108
-static TypeInfo i2c_ddc_info = {
109
+static const TypeInfo i2c_ddc_info = {
110
.name = TYPE_I2CDDC,
111
.parent = TYPE_I2C_SLAVE,
112
.instance_size = sizeof(I2CDDCState),
113
diff --git a/hw/display/macfb.c b/hw/display/macfb.c
114
index XXXXXXX..XXXXXXX 100644
115
--- a/hw/display/macfb.c
116
+++ b/hw/display/macfb.c
117
@@ -XXX,XX +XXX,XX @@ static void macfb_nubus_class_init(ObjectClass *klass, void *data)
118
device_class_set_props(dc, macfb_nubus_properties);
119
}
120
121
-static TypeInfo macfb_sysbus_info = {
122
+static const TypeInfo macfb_sysbus_info = {
123
.name = TYPE_MACFB,
124
.parent = TYPE_SYS_BUS_DEVICE,
125
.instance_size = sizeof(MacfbSysBusState),
126
.class_init = macfb_sysbus_class_init,
127
};
128
129
-static TypeInfo macfb_nubus_info = {
130
+static const TypeInfo macfb_nubus_info = {
131
.name = TYPE_NUBUS_MACFB,
132
.parent = TYPE_NUBUS_DEVICE,
133
.instance_size = sizeof(MacfbNubusState),
134
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
135
index XXXXXXX..XXXXXXX 100644
136
--- a/hw/display/virtio-vga.c
137
+++ b/hw/display/virtio-vga.c
138
@@ -XXX,XX +XXX,XX @@ static void virtio_vga_base_class_init(ObjectClass *klass, void *data)
139
virtio_vga_set_big_endian_fb);
140
}
141
142
-static TypeInfo virtio_vga_base_info = {
143
+static const TypeInfo virtio_vga_base_info = {
144
.name = TYPE_VIRTIO_VGA_BASE,
145
.parent = TYPE_VIRTIO_PCI,
146
.instance_size = sizeof(VirtIOVGABase),
147
diff --git a/hw/dma/bcm2835_dma.c b/hw/dma/bcm2835_dma.c
148
index XXXXXXX..XXXXXXX 100644
149
--- a/hw/dma/bcm2835_dma.c
150
+++ b/hw/dma/bcm2835_dma.c
151
@@ -XXX,XX +XXX,XX @@ static void bcm2835_dma_class_init(ObjectClass *klass, void *data)
152
dc->vmsd = &vmstate_bcm2835_dma;
153
}
154
155
-static TypeInfo bcm2835_dma_info = {
156
+static const TypeInfo bcm2835_dma_info = {
157
.name = TYPE_BCM2835_DMA,
158
.parent = TYPE_SYS_BUS_DEVICE,
159
.instance_size = sizeof(BCM2835DMAState),
160
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
161
index XXXXXXX..XXXXXXX 100644
162
--- a/hw/i386/pc_piix.c
163
+++ b/hw/i386/pc_piix.c
164
@@ -XXX,XX +XXX,XX @@ static void isa_bridge_class_init(ObjectClass *klass, void *data)
165
k->class_id = PCI_CLASS_BRIDGE_ISA;
166
};
167
168
-static TypeInfo isa_bridge_info = {
169
+static const TypeInfo isa_bridge_info = {
170
.name = "igd-passthrough-isa-bridge",
171
.parent = TYPE_PCI_DEVICE,
172
.instance_size = sizeof(PCIDevice),
173
diff --git a/hw/i386/sgx-epc.c b/hw/i386/sgx-epc.c
174
index XXXXXXX..XXXXXXX 100644
175
--- a/hw/i386/sgx-epc.c
176
+++ b/hw/i386/sgx-epc.c
177
@@ -XXX,XX +XXX,XX @@ static void sgx_epc_class_init(ObjectClass *oc, void *data)
178
mdc->fill_device_info = sgx_epc_md_fill_device_info;
179
}
180
181
-static TypeInfo sgx_epc_info = {
182
+static const TypeInfo sgx_epc_info = {
183
.name = TYPE_SGX_EPC,
184
.parent = TYPE_DEVICE,
185
.instance_size = sizeof(SGXEPCDevice),
186
diff --git a/hw/intc/bcm2835_ic.c b/hw/intc/bcm2835_ic.c
187
index XXXXXXX..XXXXXXX 100644
188
--- a/hw/intc/bcm2835_ic.c
189
+++ b/hw/intc/bcm2835_ic.c
190
@@ -XXX,XX +XXX,XX @@ static void bcm2835_ic_class_init(ObjectClass *klass, void *data)
191
dc->vmsd = &vmstate_bcm2835_ic;
192
}
193
194
-static TypeInfo bcm2835_ic_info = {
195
+static const TypeInfo bcm2835_ic_info = {
196
.name = TYPE_BCM2835_IC,
197
.parent = TYPE_SYS_BUS_DEVICE,
198
.instance_size = sizeof(BCM2835ICState),
199
diff --git a/hw/intc/bcm2836_control.c b/hw/intc/bcm2836_control.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/hw/intc/bcm2836_control.c
202
+++ b/hw/intc/bcm2836_control.c
203
@@ -XXX,XX +XXX,XX @@ static void bcm2836_control_class_init(ObjectClass *klass, void *data)
204
dc->vmsd = &vmstate_bcm2836_control;
205
}
206
207
-static TypeInfo bcm2836_control_info = {
208
+static const TypeInfo bcm2836_control_info = {
209
.name = TYPE_BCM2836_CONTROL,
210
.parent = TYPE_SYS_BUS_DEVICE,
211
.instance_size = sizeof(BCM2836ControlState),
212
diff --git a/hw/ipmi/ipmi.c b/hw/ipmi/ipmi.c
213
index XXXXXXX..XXXXXXX 100644
214
--- a/hw/ipmi/ipmi.c
215
+++ b/hw/ipmi/ipmi.c
216
@@ -XXX,XX +XXX,XX @@ static void ipmi_interface_class_init(ObjectClass *class, void *data)
217
ik->do_hw_op = ipmi_do_hw_op;
218
}
219
220
-static TypeInfo ipmi_interface_type_info = {
221
+static const TypeInfo ipmi_interface_type_info = {
222
.name = TYPE_IPMI_INTERFACE,
223
.parent = TYPE_INTERFACE,
224
.class_size = sizeof(IPMIInterfaceClass),
225
@@ -XXX,XX +XXX,XX @@ static void bmc_class_init(ObjectClass *oc, void *data)
226
device_class_set_props(dc, ipmi_bmc_properties);
227
}
228
229
-static TypeInfo ipmi_bmc_type_info = {
230
+static const TypeInfo ipmi_bmc_type_info = {
231
.name = TYPE_IPMI_BMC,
232
.parent = TYPE_DEVICE,
233
.instance_size = sizeof(IPMIBmc),
234
diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c
235
index XXXXXXX..XXXXXXX 100644
236
--- a/hw/mem/nvdimm.c
237
+++ b/hw/mem/nvdimm.c
238
@@ -XXX,XX +XXX,XX @@ static void nvdimm_class_init(ObjectClass *oc, void *data)
239
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
240
}
241
242
-static TypeInfo nvdimm_info = {
243
+static const TypeInfo nvdimm_info = {
244
.name = TYPE_NVDIMM,
245
.parent = TYPE_PC_DIMM,
246
.class_size = sizeof(NVDIMMClass),
247
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
248
index XXXXXXX..XXXXXXX 100644
249
--- a/hw/mem/pc-dimm.c
250
+++ b/hw/mem/pc-dimm.c
251
@@ -XXX,XX +XXX,XX @@ static void pc_dimm_class_init(ObjectClass *oc, void *data)
252
mdc->fill_device_info = pc_dimm_md_fill_device_info;
253
}
254
255
-static TypeInfo pc_dimm_info = {
256
+static const TypeInfo pc_dimm_info = {
257
.name = TYPE_PC_DIMM,
258
.parent = TYPE_DEVICE,
259
.instance_size = sizeof(PCDIMMDevice),
260
diff --git a/hw/misc/bcm2835_mbox.c b/hw/misc/bcm2835_mbox.c
261
index XXXXXXX..XXXXXXX 100644
262
--- a/hw/misc/bcm2835_mbox.c
263
+++ b/hw/misc/bcm2835_mbox.c
264
@@ -XXX,XX +XXX,XX @@ static void bcm2835_mbox_class_init(ObjectClass *klass, void *data)
265
dc->vmsd = &vmstate_bcm2835_mbox;
266
}
267
268
-static TypeInfo bcm2835_mbox_info = {
269
+static const TypeInfo bcm2835_mbox_info = {
270
.name = TYPE_BCM2835_MBOX,
271
.parent = TYPE_SYS_BUS_DEVICE,
272
.instance_size = sizeof(BCM2835MboxState),
273
diff --git a/hw/misc/bcm2835_powermgt.c b/hw/misc/bcm2835_powermgt.c
274
index XXXXXXX..XXXXXXX 100644
275
--- a/hw/misc/bcm2835_powermgt.c
276
+++ b/hw/misc/bcm2835_powermgt.c
277
@@ -XXX,XX +XXX,XX @@ static void bcm2835_powermgt_class_init(ObjectClass *klass, void *data)
278
dc->vmsd = &vmstate_bcm2835_powermgt;
279
}
280
281
-static TypeInfo bcm2835_powermgt_info = {
282
+static const TypeInfo bcm2835_powermgt_info = {
283
.name = TYPE_BCM2835_POWERMGT,
284
.parent = TYPE_SYS_BUS_DEVICE,
285
.instance_size = sizeof(BCM2835PowerMgtState),
286
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
287
index XXXXXXX..XXXXXXX 100644
288
--- a/hw/misc/bcm2835_property.c
289
+++ b/hw/misc/bcm2835_property.c
290
@@ -XXX,XX +XXX,XX @@ static void bcm2835_property_class_init(ObjectClass *klass, void *data)
291
dc->vmsd = &vmstate_bcm2835_property;
292
}
293
294
-static TypeInfo bcm2835_property_info = {
295
+static const TypeInfo bcm2835_property_info = {
296
.name = TYPE_BCM2835_PROPERTY,
297
.parent = TYPE_SYS_BUS_DEVICE,
298
.instance_size = sizeof(BCM2835PropertyState),
299
diff --git a/hw/misc/bcm2835_rng.c b/hw/misc/bcm2835_rng.c
300
index XXXXXXX..XXXXXXX 100644
301
--- a/hw/misc/bcm2835_rng.c
302
+++ b/hw/misc/bcm2835_rng.c
303
@@ -XXX,XX +XXX,XX @@ static void bcm2835_rng_class_init(ObjectClass *klass, void *data)
304
dc->vmsd = &vmstate_bcm2835_rng;
305
}
306
307
-static TypeInfo bcm2835_rng_info = {
308
+static const TypeInfo bcm2835_rng_info = {
309
.name = TYPE_BCM2835_RNG,
310
.parent = TYPE_SYS_BUS_DEVICE,
311
.instance_size = sizeof(BCM2835RngState),
312
diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c
313
index XXXXXXX..XXXXXXX 100644
314
--- a/hw/misc/pvpanic-isa.c
315
+++ b/hw/misc/pvpanic-isa.c
316
@@ -XXX,XX +XXX,XX @@ static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
317
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
318
}
319
320
-static TypeInfo pvpanic_isa_info = {
321
+static const TypeInfo pvpanic_isa_info = {
322
.name = TYPE_PVPANIC_ISA_DEVICE,
323
.parent = TYPE_ISA_DEVICE,
324
.instance_size = sizeof(PVPanicISAState),
325
diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c
326
index XXXXXXX..XXXXXXX 100644
327
--- a/hw/misc/pvpanic-pci.c
328
+++ b/hw/misc/pvpanic-pci.c
329
@@ -XXX,XX +XXX,XX @@ static void pvpanic_pci_class_init(ObjectClass *klass, void *data)
330
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
331
}
332
333
-static TypeInfo pvpanic_pci_info = {
334
+static const TypeInfo pvpanic_pci_info = {
335
.name = TYPE_PVPANIC_PCI_DEVICE,
336
.parent = TYPE_PCI_DEVICE,
337
.instance_size = sizeof(PVPanicPCIState),
338
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
339
index XXXXXXX..XXXXXXX 100644
340
--- a/hw/net/fsl_etsec/etsec.c
341
+++ b/hw/net/fsl_etsec/etsec.c
342
@@ -XXX,XX +XXX,XX @@ static void etsec_class_init(ObjectClass *klass, void *data)
343
dc->user_creatable = true;
344
}
345
346
-static TypeInfo etsec_info = {
347
+static const TypeInfo etsec_info = {
348
.name = TYPE_ETSEC_COMMON,
349
.parent = TYPE_SYS_BUS_DEVICE,
350
.instance_size = sizeof(eTSEC),
351
diff --git a/hw/ppc/prep_systemio.c b/hw/ppc/prep_systemio.c
352
index XXXXXXX..XXXXXXX 100644
353
--- a/hw/ppc/prep_systemio.c
354
+++ b/hw/ppc/prep_systemio.c
355
@@ -XXX,XX +XXX,XX @@ static void prep_systemio_class_initfn(ObjectClass *klass, void *data)
356
device_class_set_props(dc, prep_systemio_properties);
357
}
358
359
-static TypeInfo prep_systemio800_info = {
360
+static const TypeInfo prep_systemio800_info = {
361
.name = TYPE_PREP_SYSTEMIO,
362
.parent = TYPE_ISA_DEVICE,
363
.instance_size = sizeof(PrepSystemIoState),
364
diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
365
index XXXXXXX..XXXXXXX 100644
366
--- a/hw/ppc/spapr_iommu.c
367
+++ b/hw/ppc/spapr_iommu.c
368
@@ -XXX,XX +XXX,XX @@ static void spapr_tce_table_class_init(ObjectClass *klass, void *data)
369
spapr_register_hypercall(H_STUFF_TCE, h_stuff_tce);
370
}
371
372
-static TypeInfo spapr_tce_table_info = {
373
+static const TypeInfo spapr_tce_table_info = {
374
.name = TYPE_SPAPR_TCE_TABLE,
375
.parent = TYPE_DEVICE,
376
.instance_size = sizeof(SpaprTceTable),
377
diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
378
index XXXXXXX..XXXXXXX 100644
379
--- a/hw/s390x/s390-pci-bus.c
380
+++ b/hw/s390x/s390-pci-bus.c
381
@@ -XXX,XX +XXX,XX @@ static const TypeInfo s390_pci_device_info = {
382
.class_init = s390_pci_device_class_init,
383
};
384
385
-static TypeInfo s390_pci_iommu_info = {
386
+static const TypeInfo s390_pci_iommu_info = {
387
.name = TYPE_S390_PCI_IOMMU,
388
.parent = TYPE_OBJECT,
389
.instance_size = sizeof(S390PCIIOMMU),
390
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
391
index XXXXXXX..XXXXXXX 100644
392
--- a/hw/s390x/sclp.c
393
+++ b/hw/s390x/sclp.c
394
@@ -XXX,XX +XXX,XX @@ static void sclp_class_init(ObjectClass *oc, void *data)
395
sc->service_interrupt = service_interrupt;
396
}
397
398
-static TypeInfo sclp_info = {
399
+static const TypeInfo sclp_info = {
400
.name = TYPE_SCLP,
401
.parent = TYPE_DEVICE,
402
.instance_init = sclp_init,
403
diff --git a/hw/s390x/tod-kvm.c b/hw/s390x/tod-kvm.c
404
index XXXXXXX..XXXXXXX 100644
405
--- a/hw/s390x/tod-kvm.c
406
+++ b/hw/s390x/tod-kvm.c
407
@@ -XXX,XX +XXX,XX @@ static void kvm_s390_tod_init(Object *obj)
408
td->stopped = false;
409
}
410
411
-static TypeInfo kvm_s390_tod_info = {
412
+static const TypeInfo kvm_s390_tod_info = {
413
.name = TYPE_KVM_S390_TOD,
414
.parent = TYPE_S390_TOD,
415
.instance_size = sizeof(S390TODState),
416
diff --git a/hw/s390x/tod-tcg.c b/hw/s390x/tod-tcg.c
417
index XXXXXXX..XXXXXXX 100644
418
--- a/hw/s390x/tod-tcg.c
419
+++ b/hw/s390x/tod-tcg.c
420
@@ -XXX,XX +XXX,XX @@ static void qemu_s390_tod_init(Object *obj)
421
}
422
}
423
424
-static TypeInfo qemu_s390_tod_info = {
425
+static const TypeInfo qemu_s390_tod_info = {
426
.name = TYPE_QEMU_S390_TOD,
427
.parent = TYPE_S390_TOD,
428
.instance_size = sizeof(S390TODState),
429
diff --git a/hw/s390x/tod.c b/hw/s390x/tod.c
430
index XXXXXXX..XXXXXXX 100644
431
--- a/hw/s390x/tod.c
432
+++ b/hw/s390x/tod.c
433
@@ -XXX,XX +XXX,XX @@ static void s390_tod_class_init(ObjectClass *oc, void *data)
434
dc->user_creatable = false;
435
}
436
437
-static TypeInfo s390_tod_info = {
438
+static const TypeInfo s390_tod_info = {
439
.name = TYPE_S390_TOD,
440
.parent = TYPE_DEVICE,
441
.instance_size = sizeof(S390TODState),
442
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
443
index XXXXXXX..XXXXXXX 100644
444
--- a/hw/scsi/lsi53c895a.c
445
+++ b/hw/scsi/lsi53c895a.c
446
@@ -XXX,XX +XXX,XX @@ static void lsi53c810_class_init(ObjectClass *klass, void *data)
447
k->device_id = PCI_DEVICE_ID_LSI_53C810;
448
}
449
450
-static TypeInfo lsi53c810_info = {
451
+static const TypeInfo lsi53c810_info = {
452
.name = TYPE_LSI53C810,
453
.parent = TYPE_LSI53C895A,
454
.class_init = lsi53c810_class_init,
455
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
456
index XXXXXXX..XXXXXXX 100644
457
--- a/hw/sd/allwinner-sdhost.c
458
+++ b/hw/sd/allwinner-sdhost.c
459
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_sun5i_class_init(ObjectClass *klass, void *data)
460
sc->max_desc_size = 64 * KiB;
461
}
462
463
-static TypeInfo allwinner_sdhost_info = {
464
+static const TypeInfo allwinner_sdhost_info = {
465
.name = TYPE_AW_SDHOST,
466
.parent = TYPE_SYS_BUS_DEVICE,
467
.instance_init = allwinner_sdhost_init,
468
diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c
469
index XXXXXXX..XXXXXXX 100644
470
--- a/hw/sd/aspeed_sdhci.c
471
+++ b/hw/sd/aspeed_sdhci.c
472
@@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_class_init(ObjectClass *classp, void *data)
473
device_class_set_props(dc, aspeed_sdhci_properties);
474
}
475
476
-static TypeInfo aspeed_sdhci_info = {
477
+static const TypeInfo aspeed_sdhci_info = {
478
.name = TYPE_ASPEED_SDHCI,
479
.parent = TYPE_SYS_BUS_DEVICE,
480
.instance_size = sizeof(AspeedSDHCIState),
481
diff --git a/hw/sd/bcm2835_sdhost.c b/hw/sd/bcm2835_sdhost.c
482
index XXXXXXX..XXXXXXX 100644
483
--- a/hw/sd/bcm2835_sdhost.c
484
+++ b/hw/sd/bcm2835_sdhost.c
485
@@ -XXX,XX +XXX,XX @@ static void bcm2835_sdhost_class_init(ObjectClass *klass, void *data)
486
dc->vmsd = &vmstate_bcm2835_sdhost;
487
}
488
489
-static TypeInfo bcm2835_sdhost_info = {
490
+static const TypeInfo bcm2835_sdhost_info = {
491
.name = TYPE_BCM2835_SDHOST,
492
.parent = TYPE_SYS_BUS_DEVICE,
493
.instance_size = sizeof(BCM2835SDHostState),
494
diff --git a/hw/sd/cadence_sdhci.c b/hw/sd/cadence_sdhci.c
495
index XXXXXXX..XXXXXXX 100644
496
--- a/hw/sd/cadence_sdhci.c
497
+++ b/hw/sd/cadence_sdhci.c
498
@@ -XXX,XX +XXX,XX @@ static void cadence_sdhci_class_init(ObjectClass *classp, void *data)
499
dc->vmsd = &vmstate_cadence_sdhci;
500
}
501
502
-static TypeInfo cadence_sdhci_info = {
503
+static const TypeInfo cadence_sdhci_info = {
504
.name = TYPE_CADENCE_SDHCI,
505
.parent = TYPE_SYS_BUS_DEVICE,
506
.instance_size = sizeof(CadenceSDHCIState),
507
diff --git a/hw/sd/npcm7xx_sdhci.c b/hw/sd/npcm7xx_sdhci.c
508
index XXXXXXX..XXXXXXX 100644
509
--- a/hw/sd/npcm7xx_sdhci.c
510
+++ b/hw/sd/npcm7xx_sdhci.c
511
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_sdhci_instance_init(Object *obj)
512
TYPE_SYSBUS_SDHCI);
513
}
514
515
-static TypeInfo npcm7xx_sdhci_info = {
516
+static const TypeInfo npcm7xx_sdhci_info = {
517
.name = TYPE_NPCM7XX_SDHCI,
518
.parent = TYPE_SYS_BUS_DEVICE,
519
.instance_size = sizeof(NPCM7xxSDHCIState),
520
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
521
index XXXXXXX..XXXXXXX 100644
522
--- a/hw/usb/dev-mtp.c
523
+++ b/hw/usb/dev-mtp.c
524
@@ -XXX,XX +XXX,XX @@ static void usb_mtp_class_initfn(ObjectClass *klass, void *data)
525
device_class_set_props(dc, mtp_properties);
526
}
527
528
-static TypeInfo mtp_info = {
529
+static const TypeInfo mtp_info = {
530
.name = TYPE_USB_MTP,
531
.parent = TYPE_USB_DEVICE,
532
.instance_size = sizeof(MTPState),
533
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
534
index XXXXXXX..XXXXXXX 100644
535
--- a/hw/usb/host-libusb.c
536
+++ b/hw/usb/host-libusb.c
537
@@ -XXX,XX +XXX,XX @@ static void usb_host_class_initfn(ObjectClass *klass, void *data)
538
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
539
}
540
541
-static TypeInfo usb_host_dev_info = {
542
+static const TypeInfo usb_host_dev_info = {
543
.name = TYPE_USB_HOST_DEVICE,
544
.parent = TYPE_USB_DEVICE,
545
.instance_size = sizeof(USBHostDevice),
546
diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c
547
index XXXXXXX..XXXXXXX 100644
548
--- a/hw/vfio/igd.c
549
+++ b/hw/vfio/igd.c
550
@@ -XXX,XX +XXX,XX @@ static void vfio_pci_igd_lpc_bridge_class_init(ObjectClass *klass, void *data)
551
k->class_id = PCI_CLASS_BRIDGE_ISA;
552
}
553
554
-static TypeInfo vfio_pci_igd_lpc_bridge_info = {
555
+static const TypeInfo vfio_pci_igd_lpc_bridge_info = {
556
.name = "vfio-pci-igd-lpc-bridge",
557
.parent = TYPE_PCI_DEVICE,
558
.class_init = vfio_pci_igd_lpc_bridge_class_init,
559
diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c
560
index XXXXXXX..XXXXXXX 100644
561
--- a/hw/virtio/virtio-pmem.c
562
+++ b/hw/virtio/virtio-pmem.c
563
@@ -XXX,XX +XXX,XX @@ static void virtio_pmem_class_init(ObjectClass *klass, void *data)
564
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
565
}
566
567
-static TypeInfo virtio_pmem_info = {
568
+static const TypeInfo virtio_pmem_info = {
569
.name = TYPE_VIRTIO_PMEM,
570
.parent = TYPE_VIRTIO_DEVICE,
571
.class_size = sizeof(VirtIOPMEMClass),
572
diff --git a/qom/object.c b/qom/object.c
573
index XXXXXXX..XXXXXXX 100644
574
--- a/qom/object.c
575
+++ b/qom/object.c
576
@@ -XXX,XX +XXX,XX @@ static void object_class_init(ObjectClass *klass, void *data)
577
578
static void register_types(void)
579
{
580
- static TypeInfo interface_info = {
581
+ static const TypeInfo interface_info = {
582
.name = TYPE_INTERFACE,
583
.class_size = sizeof(InterfaceClass),
584
.abstract = true,
585
};
586
587
- static TypeInfo object_info = {
588
+ static const TypeInfo object_info = {
589
.name = TYPE_OBJECT,
590
.instance_size = sizeof(Object),
591
.class_init = object_class_init,
592
--
593
2.25.1
594
595
diff view generated by jsdifflib
New patch
1
From: Bernhard Beschow <shentey@gmail.com>
1
2
3
Now that all static TypeInfo instances are declared const, prevent that
4
new non-const instances are created.
5
6
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220117145805.173070-3-shentey@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
scripts/checkpatch.pl | 1 +
12
1 file changed, 1 insertion(+)
13
14
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
15
index XXXXXXX..XXXXXXX 100755
16
--- a/scripts/checkpatch.pl
17
+++ b/scripts/checkpatch.pl
18
@@ -XXX,XX +XXX,XX @@ sub process {
19
                SCSIBusInfo|
20
                SCSIReqOps|
21
                Spice[A-Z][a-zA-Z0-9]*Interface|
22
+                TypeInfo|
23
                USBDesc[A-Z][a-zA-Z0-9]*|
24
                VhostOps|
25
                VMStateDescription|
26
--
27
2.25.1
28
29
diff view generated by jsdifflib
1
Implement the register interface for the SAU: SAU_CTRL,
1
Now that KVM has dropped AArch32 host support, the 'host' CPU type is
2
SAU_TYPE, SAU_RNR, SAU_RBAR and SAU_RLAR. None of the
2
always AArch64, and we can move it to cpu64.c. This move will allow
3
actual behaviour is implemented here; registers just
3
us to share code between it and '-cpu max', which should behave
4
read back as written.
4
the same as '-cpu host' when using KVM or HVF.
5
6
When the CPU definition for Cortex-M33 is eventually
7
added, its initfn will set cpu->sau_sregion, in the same
8
way that we currently set cpu->pmsav7_dregion for the
9
M3 and M4.
10
11
Number of SAU regions is typically a configurable
12
CPU parameter, but this patch doesn't provide a
13
QEMU CPU property for it. We can easily add one when
14
we have a board that requires it.
15
5
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Andrew Jones <drjones@redhat.com>
9
Reviewed-by: Alexander Graf <agraf@csgraf.de>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 1506092407-26985-14-git-send-email-peter.maydell@linaro.org
11
Message-id: 20220204165506.2846058-2-peter.maydell@linaro.org
19
---
12
---
20
target/arm/cpu.h | 10 +++++
13
target/arm/cpu.c | 30 ------------------------------
21
hw/intc/armv7m_nvic.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++
14
target/arm/cpu64.c | 30 ++++++++++++++++++++++++++++++
22
target/arm/cpu.c | 27 ++++++++++++
15
2 files changed, 30 insertions(+), 30 deletions(-)
23
target/arm/machine.c | 14 ++++++
24
4 files changed, 167 insertions(+)
25
16
26
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
27
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/cpu.h
29
+++ b/target/arm/cpu.h
30
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
31
uint32_t mair1[M_REG_NUM_BANKS];
32
} pmsav8;
33
34
+ /* v8M SAU */
35
+ struct {
36
+ uint32_t *rbar;
37
+ uint32_t *rlar;
38
+ uint32_t rnr;
39
+ uint32_t ctrl;
40
+ } sau;
41
+
42
void *nvic;
43
const struct arm_boot_info *boot_info;
44
/* Store GICv3CPUState to access from this struct */
45
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
46
bool has_mpu;
47
/* PMSAv7 MPU number of supported regions */
48
uint32_t pmsav7_dregion;
49
+ /* v8M SAU number of supported regions */
50
+ uint32_t sau_sregion;
51
52
/* PSCI conduit used to invoke PSCI methods
53
* 0 - disabled, 1 - smc, 2 - hvc
54
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/intc/armv7m_nvic.c
57
+++ b/hw/intc/armv7m_nvic.c
58
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
59
goto bad_offset;
60
}
61
return cpu->env.pmsav8.mair1[attrs.secure];
62
+ case 0xdd0: /* SAU_CTRL */
63
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
64
+ goto bad_offset;
65
+ }
66
+ if (!attrs.secure) {
67
+ return 0;
68
+ }
69
+ return cpu->env.sau.ctrl;
70
+ case 0xdd4: /* SAU_TYPE */
71
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
72
+ goto bad_offset;
73
+ }
74
+ if (!attrs.secure) {
75
+ return 0;
76
+ }
77
+ return cpu->sau_sregion;
78
+ case 0xdd8: /* SAU_RNR */
79
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
80
+ goto bad_offset;
81
+ }
82
+ if (!attrs.secure) {
83
+ return 0;
84
+ }
85
+ return cpu->env.sau.rnr;
86
+ case 0xddc: /* SAU_RBAR */
87
+ {
88
+ int region = cpu->env.sau.rnr;
89
+
90
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
91
+ goto bad_offset;
92
+ }
93
+ if (!attrs.secure) {
94
+ return 0;
95
+ }
96
+ if (region >= cpu->sau_sregion) {
97
+ return 0;
98
+ }
99
+ return cpu->env.sau.rbar[region];
100
+ }
101
+ case 0xde0: /* SAU_RLAR */
102
+ {
103
+ int region = cpu->env.sau.rnr;
104
+
105
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
106
+ goto bad_offset;
107
+ }
108
+ if (!attrs.secure) {
109
+ return 0;
110
+ }
111
+ if (region >= cpu->sau_sregion) {
112
+ return 0;
113
+ }
114
+ return cpu->env.sau.rlar[region];
115
+ }
116
case 0xde4: /* SFSR */
117
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
118
goto bad_offset;
119
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
120
* only affect cacheability, and we don't implement caching.
121
*/
122
break;
123
+ case 0xdd0: /* SAU_CTRL */
124
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
125
+ goto bad_offset;
126
+ }
127
+ if (!attrs.secure) {
128
+ return;
129
+ }
130
+ cpu->env.sau.ctrl = value & 3;
131
+ case 0xdd4: /* SAU_TYPE */
132
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
133
+ goto bad_offset;
134
+ }
135
+ break;
136
+ case 0xdd8: /* SAU_RNR */
137
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
138
+ goto bad_offset;
139
+ }
140
+ if (!attrs.secure) {
141
+ return;
142
+ }
143
+ if (value >= cpu->sau_sregion) {
144
+ qemu_log_mask(LOG_GUEST_ERROR, "SAU region out of range %"
145
+ PRIu32 "/%" PRIu32 "\n",
146
+ value, cpu->sau_sregion);
147
+ } else {
148
+ cpu->env.sau.rnr = value;
149
+ }
150
+ break;
151
+ case 0xddc: /* SAU_RBAR */
152
+ {
153
+ int region = cpu->env.sau.rnr;
154
+
155
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
156
+ goto bad_offset;
157
+ }
158
+ if (!attrs.secure) {
159
+ return;
160
+ }
161
+ if (region >= cpu->sau_sregion) {
162
+ return;
163
+ }
164
+ cpu->env.sau.rbar[region] = value & ~0x1f;
165
+ tlb_flush(CPU(cpu));
166
+ break;
167
+ }
168
+ case 0xde0: /* SAU_RLAR */
169
+ {
170
+ int region = cpu->env.sau.rnr;
171
+
172
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
173
+ goto bad_offset;
174
+ }
175
+ if (!attrs.secure) {
176
+ return;
177
+ }
178
+ if (region >= cpu->sau_sregion) {
179
+ return;
180
+ }
181
+ cpu->env.sau.rlar[region] = value & ~0x1c;
182
+ tlb_flush(CPU(cpu));
183
+ break;
184
+ }
185
case 0xde4: /* SFSR */
186
if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
187
goto bad_offset;
188
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
17
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
189
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
190
--- a/target/arm/cpu.c
19
--- a/target/arm/cpu.c
191
+++ b/target/arm/cpu.c
20
+++ b/target/arm/cpu.c
192
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s)
21
@@ -XXX,XX +XXX,XX @@
193
env->pmsav8.mair1[M_REG_S] = 0;
22
#include "sysemu/tcg.h"
23
#include "sysemu/hw_accel.h"
24
#include "kvm_arm.h"
25
-#include "hvf_arm.h"
26
#include "disas/capstone.h"
27
#include "fpu/softfloat.h"
28
29
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)
30
#endif /* CONFIG_TCG */
31
}
32
33
-#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
34
-static void arm_host_initfn(Object *obj)
35
-{
36
- ARMCPU *cpu = ARM_CPU(obj);
37
-
38
-#ifdef CONFIG_KVM
39
- kvm_arm_set_cpu_features_from_host(cpu);
40
- if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
41
- aarch64_add_sve_properties(obj);
42
- aarch64_add_pauth_properties(obj);
43
- }
44
-#else
45
- hvf_arm_set_cpu_features_from_host(cpu);
46
-#endif
47
- arm_cpu_post_init(obj);
48
-}
49
-
50
-static const TypeInfo host_arm_cpu_type_info = {
51
- .name = TYPE_ARM_HOST_CPU,
52
- .parent = TYPE_AARCH64_CPU,
53
- .instance_init = arm_host_initfn,
54
-};
55
-
56
-#endif
57
-
58
static void arm_cpu_instance_init(Object *obj)
59
{
60
ARMCPUClass *acc = ARM_CPU_GET_CLASS(obj);
61
@@ -XXX,XX +XXX,XX @@ static const TypeInfo arm_cpu_type_info = {
62
static void arm_cpu_register_types(void)
63
{
64
type_register_static(&arm_cpu_type_info);
65
-
66
-#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
67
- type_register_static(&host_arm_cpu_type_info);
68
-#endif
69
}
70
71
type_init(arm_cpu_register_types)
72
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/target/arm/cpu64.c
75
+++ b/target/arm/cpu64.c
76
@@ -XXX,XX +XXX,XX @@
77
#endif
78
#include "sysemu/kvm.h"
79
#include "kvm_arm.h"
80
+#include "hvf_arm.h"
81
#include "qapi/visitor.h"
82
#include "hw/qdev-properties.h"
83
84
@@ -XXX,XX +XXX,XX @@ void aarch64_add_pauth_properties(Object *obj)
194
}
85
}
195
86
}
196
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
87
197
+ if (cpu->sau_sregion > 0) {
88
+#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
198
+ memset(env->sau.rbar, 0, sizeof(*env->sau.rbar) * cpu->sau_sregion);
89
+static void arm_host_initfn(Object *obj)
199
+ memset(env->sau.rlar, 0, sizeof(*env->sau.rlar) * cpu->sau_sregion);
90
+{
200
+ }
91
+ ARMCPU *cpu = ARM_CPU(obj);
201
+ env->sau.rnr = 0;
92
+
202
+ /* SAU_CTRL reset value is IMPDEF; we choose 0, which is what
93
+#ifdef CONFIG_KVM
203
+ * the Cortex-M33 does.
94
+ kvm_arm_set_cpu_features_from_host(cpu);
204
+ */
95
+ if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
205
+ env->sau.ctrl = 0;
96
+ aarch64_add_sve_properties(obj);
97
+ aarch64_add_pauth_properties(obj);
206
+ }
98
+ }
207
+
99
+#else
208
set_flush_to_zero(1, &env->vfp.standard_fp_status);
100
+ hvf_arm_set_cpu_features_from_host(cpu);
209
set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
101
+#endif
210
set_default_nan_mode(1, &env->vfp.standard_fp_status);
102
+ arm_cpu_post_init(obj);
211
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
212
}
213
}
214
215
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
216
+ uint32_t nr = cpu->sau_sregion;
217
+
218
+ if (nr > 0xff) {
219
+ error_setg(errp, "v8M SAU #regions invalid %" PRIu32, nr);
220
+ return;
221
+ }
222
+
223
+ if (nr) {
224
+ env->sau.rbar = g_new0(uint32_t, nr);
225
+ env->sau.rlar = g_new0(uint32_t, nr);
226
+ }
227
+ }
228
+
229
if (arm_feature(env, ARM_FEATURE_EL3)) {
230
set_feature(env, ARM_FEATURE_VBAR);
231
}
232
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
233
cpu->midr = 0x410fc240; /* r0p0 */
234
cpu->pmsav7_dregion = 8;
235
}
236
+
237
static void arm_v7m_class_init(ObjectClass *oc, void *data)
238
{
239
CPUClass *cc = CPU_CLASS(oc);
240
diff --git a/target/arm/machine.c b/target/arm/machine.c
241
index XXXXXXX..XXXXXXX 100644
242
--- a/target/arm/machine.c
243
+++ b/target/arm/machine.c
244
@@ -XXX,XX +XXX,XX @@ static bool s_rnr_vmstate_validate(void *opaque, int version_id)
245
return cpu->env.pmsav7.rnr[M_REG_S] < cpu->pmsav7_dregion;
246
}
247
248
+static bool sau_rnr_vmstate_validate(void *opaque, int version_id)
249
+{
250
+ ARMCPU *cpu = opaque;
251
+
252
+ return cpu->env.sau.rnr < cpu->sau_sregion;
253
+}
103
+}
254
+
104
+
255
static bool m_security_needed(void *opaque)
105
+static const TypeInfo host_arm_cpu_type_info = {
256
{
106
+ .name = TYPE_ARM_HOST_CPU,
257
ARMCPU *cpu = opaque;
107
+ .parent = TYPE_AARCH64_CPU,
258
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_security = {
108
+ .instance_init = arm_host_initfn,
259
VMSTATE_UINT32(env.v7m.cfsr[M_REG_S], ARMCPU),
109
+};
260
VMSTATE_UINT32(env.v7m.sfsr, ARMCPU),
110
+
261
VMSTATE_UINT32(env.v7m.sfar, ARMCPU),
111
+#endif
262
+ VMSTATE_VARRAY_UINT32(env.sau.rbar, ARMCPU, sau_sregion, 0,
112
+
263
+ vmstate_info_uint32, uint32_t),
113
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
264
+ VMSTATE_VARRAY_UINT32(env.sau.rlar, ARMCPU, sau_sregion, 0,
114
* otherwise, a CPU with as many features enabled as our emulation supports.
265
+ vmstate_info_uint32, uint32_t),
115
* The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
266
+ VMSTATE_UINT32(env.sau.rnr, ARMCPU),
116
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_register_types(void)
267
+ VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate),
117
for (i = 0; i < ARRAY_SIZE(aarch64_cpus); ++i) {
268
+ VMSTATE_UINT32(env.sau.ctrl, ARMCPU),
118
aarch64_cpu_register(&aarch64_cpus[i]);
269
VMSTATE_END_OF_LIST()
270
}
119
}
271
};
120
+
121
+#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
122
+ type_register_static(&host_arm_cpu_type_info);
123
+#endif
124
}
125
126
type_init(aarch64_cpu_register_types)
272
--
127
--
273
2.7.4
128
2.25.1
274
129
275
130
diff view generated by jsdifflib
1
Currently our M profile exception return code switches to the
1
Use the aarch64_cpu_register() machinery to register the 'host' CPU
2
target stack pointer relatively early in the process, before
2
type. This doesn't gain us anything functionally, but it does mean
3
it tries to pop the exception frame off the stack. This is
3
that the code for initializing it looks more like that for the other
4
awkward for v8M for two reasons:
4
CPU types, in that its initfn then doesn't need to call
5
* in v8M the process vs main stack pointer is not selected
5
arm_cpu_post_init() (because aarch64_cpu_instance_init() does that
6
purely by the value of CONTROL.SPSEL, so updating SPSEL
6
for it).
7
and relying on that to switch to the right stack pointer
8
won't work
9
* the stack we should be reading the stack frame from and
10
the stack we will eventually switch to might not be the
11
same if the guest is doing strange things
12
13
Change our exception return code to use a 'frame pointer'
14
to read the exception frame rather than assuming that we
15
can switch the live stack pointer this early.
16
7
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Andrew Jones <drjones@redhat.com>
11
Reviewed-by: Alexander Graf <agraf@csgraf.de>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 1506092407-26985-3-git-send-email-peter.maydell@linaro.org
13
Message-id: 20220204165506.2846058-3-peter.maydell@linaro.org
21
---
14
---
22
target/arm/helper.c | 130 +++++++++++++++++++++++++++++++++++++++-------------
15
target/arm/cpu64.c | 17 ++++-------------
23
1 file changed, 98 insertions(+), 32 deletions(-)
16
1 file changed, 4 insertions(+), 13 deletions(-)
24
17
25
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
26
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/helper.c
20
--- a/target/arm/cpu64.c
28
+++ b/target/arm/helper.c
21
+++ b/target/arm/cpu64.c
29
@@ -XXX,XX +XXX,XX @@ static void v7m_push(CPUARMState *env, uint32_t val)
22
@@ -XXX,XX +XXX,XX @@ void aarch64_add_pauth_properties(Object *obj)
30
stl_phys(cs->as, env->regs[13], val);
31
}
23
}
32
24
33
-static uint32_t v7m_pop(CPUARMState *env)
25
#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
34
-{
26
-static void arm_host_initfn(Object *obj)
35
- CPUState *cs = CPU(arm_env_get_cpu(env));
27
+static void aarch64_host_initfn(Object *obj)
36
- uint32_t val;
28
{
29
ARMCPU *cpu = ARM_CPU(obj);
30
31
@@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj)
32
#else
33
hvf_arm_set_cpu_features_from_host(cpu);
34
#endif
35
- arm_cpu_post_init(obj);
36
}
37
-
37
-
38
- val = ldl_phys(cs->as, env->regs[13]);
38
-static const TypeInfo host_arm_cpu_type_info = {
39
- env->regs[13] += 4;
39
- .name = TYPE_ARM_HOST_CPU,
40
- return val;
40
- .parent = TYPE_AARCH64_CPU,
41
-}
41
- .instance_init = arm_host_initfn,
42
-};
42
-
43
-
43
/* Return true if we're using the process stack pointer (not the MSP) */
44
#endif
44
static bool v7m_using_psp(CPUARMState *env)
45
45
{
46
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
46
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
47
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = {
47
env->regs[15] = dest & ~1;
48
{ .name = "cortex-a72", .initfn = aarch64_a72_initfn },
49
{ .name = "a64fx", .initfn = aarch64_a64fx_initfn },
50
{ .name = "max", .initfn = aarch64_max_initfn },
51
+#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
52
+ { .name = "host", .initfn = aarch64_host_initfn },
53
+#endif
54
};
55
56
static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp)
57
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_register_types(void)
58
for (i = 0; i < ARRAY_SIZE(aarch64_cpus); ++i) {
59
aarch64_cpu_register(&aarch64_cpus[i]);
60
}
61
-
62
-#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
63
- type_register_static(&host_arm_cpu_type_info);
64
-#endif
48
}
65
}
49
66
50
+static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode,
67
type_init(aarch64_cpu_register_types)
51
+ bool spsel)
52
+{
53
+ /* Return a pointer to the location where we currently store the
54
+ * stack pointer for the requested security state and thread mode.
55
+ * This pointer will become invalid if the CPU state is updated
56
+ * such that the stack pointers are switched around (eg changing
57
+ * the SPSEL control bit).
58
+ * Compare the v8M ARM ARM pseudocode LookUpSP_with_security_mode().
59
+ * Unlike that pseudocode, we require the caller to pass us in the
60
+ * SPSEL control bit value; this is because we also use this
61
+ * function in handling of pushing of the callee-saves registers
62
+ * part of the v8M stack frame (pseudocode PushCalleeStack()),
63
+ * and in the tailchain codepath the SPSEL bit comes from the exception
64
+ * return magic LR value from the previous exception. The pseudocode
65
+ * opencodes the stack-selection in PushCalleeStack(), but we prefer
66
+ * to make this utility function generic enough to do the job.
67
+ */
68
+ bool want_psp = threadmode && spsel;
69
+
70
+ if (secure == env->v7m.secure) {
71
+ /* Currently switch_v7m_sp switches SP as it updates SPSEL,
72
+ * so the SP we want is always in regs[13].
73
+ * When we decouple SPSEL from the actually selected SP
74
+ * we need to check want_psp against v7m_using_psp()
75
+ * to see whether we need regs[13] or v7m.other_sp.
76
+ */
77
+ return &env->regs[13];
78
+ } else {
79
+ if (want_psp) {
80
+ return &env->v7m.other_ss_psp;
81
+ } else {
82
+ return &env->v7m.other_ss_msp;
83
+ }
84
+ }
85
+}
86
+
87
static uint32_t arm_v7m_load_vector(ARMCPU *cpu)
88
{
89
CPUState *cs = CPU(cpu);
90
@@ -XXX,XX +XXX,XX @@ static void v7m_push_stack(ARMCPU *cpu)
91
static void do_v7m_exception_exit(ARMCPU *cpu)
92
{
93
CPUARMState *env = &cpu->env;
94
+ CPUState *cs = CPU(cpu);
95
uint32_t excret;
96
uint32_t xpsr;
97
bool ufault = false;
98
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
99
bool return_to_handler = false;
100
bool rettobase = false;
101
bool exc_secure = false;
102
+ bool return_to_secure;
103
104
/* We can only get here from an EXCP_EXCEPTION_EXIT, and
105
* gen_bx_excret() enforces the architectural rule
106
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
107
g_assert_not_reached();
108
}
109
110
+ return_to_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
111
+ (excret & R_V7M_EXCRET_S_MASK);
112
+
113
switch (excret & 0xf) {
114
case 1: /* Return to Handler */
115
return_to_handler = true;
116
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
117
return;
118
}
119
120
- /* Switch to the target stack. */
121
+ /* Set CONTROL.SPSEL from excret.SPSEL. For QEMU this currently
122
+ * causes us to switch the active SP, but we will change this
123
+ * later to not do that so we can support v8M.
124
+ */
125
switch_v7m_sp(env, return_to_sp_process);
126
- /* Pop registers. */
127
- env->regs[0] = v7m_pop(env);
128
- env->regs[1] = v7m_pop(env);
129
- env->regs[2] = v7m_pop(env);
130
- env->regs[3] = v7m_pop(env);
131
- env->regs[12] = v7m_pop(env);
132
- env->regs[14] = v7m_pop(env);
133
- env->regs[15] = v7m_pop(env);
134
- if (env->regs[15] & 1) {
135
- qemu_log_mask(LOG_GUEST_ERROR,
136
- "M profile return from interrupt with misaligned "
137
- "PC is UNPREDICTABLE\n");
138
- /* Actual hardware seems to ignore the lsbit, and there are several
139
- * RTOSes out there which incorrectly assume the r15 in the stack
140
- * frame should be a Thumb-style "lsbit indicates ARM/Thumb" value.
141
+
142
+ {
143
+ /* The stack pointer we should be reading the exception frame from
144
+ * depends on bits in the magic exception return type value (and
145
+ * for v8M isn't necessarily the stack pointer we will eventually
146
+ * end up resuming execution with). Get a pointer to the location
147
+ * in the CPU state struct where the SP we need is currently being
148
+ * stored; we will use and modify it in place.
149
+ * We use this limited C variable scope so we don't accidentally
150
+ * use 'frame_sp_p' after we do something that makes it invalid.
151
+ */
152
+ uint32_t *frame_sp_p = get_v7m_sp_ptr(env,
153
+ return_to_secure,
154
+ !return_to_handler,
155
+ return_to_sp_process);
156
+ uint32_t frameptr = *frame_sp_p;
157
+
158
+ /* Pop registers. TODO: make these accesses use the correct
159
+ * attributes and address space (S/NS, priv/unpriv) and handle
160
+ * memory transaction failures.
161
*/
162
- env->regs[15] &= ~1U;
163
+ env->regs[0] = ldl_phys(cs->as, frameptr);
164
+ env->regs[1] = ldl_phys(cs->as, frameptr + 0x4);
165
+ env->regs[2] = ldl_phys(cs->as, frameptr + 0x8);
166
+ env->regs[3] = ldl_phys(cs->as, frameptr + 0xc);
167
+ env->regs[12] = ldl_phys(cs->as, frameptr + 0x10);
168
+ env->regs[14] = ldl_phys(cs->as, frameptr + 0x14);
169
+ env->regs[15] = ldl_phys(cs->as, frameptr + 0x18);
170
+ if (env->regs[15] & 1) {
171
+ qemu_log_mask(LOG_GUEST_ERROR,
172
+ "M profile return from interrupt with misaligned "
173
+ "PC is UNPREDICTABLE\n");
174
+ /* Actual hardware seems to ignore the lsbit, and there are several
175
+ * RTOSes out there which incorrectly assume the r15 in the stack
176
+ * frame should be a Thumb-style "lsbit indicates ARM/Thumb" value.
177
+ */
178
+ env->regs[15] &= ~1U;
179
+ }
180
+ xpsr = ldl_phys(cs->as, frameptr + 0x1c);
181
+
182
+ /* Commit to consuming the stack frame */
183
+ frameptr += 0x20;
184
+ /* Undo stack alignment (the SPREALIGN bit indicates that the original
185
+ * pre-exception SP was not 8-aligned and we added a padding word to
186
+ * align it, so we undo this by ORing in the bit that increases it
187
+ * from the current 8-aligned value to the 8-unaligned value. (Adding 4
188
+ * would work too but a logical OR is how the pseudocode specifies it.)
189
+ */
190
+ if (xpsr & XPSR_SPREALIGN) {
191
+ frameptr |= 4;
192
+ }
193
+ *frame_sp_p = frameptr;
194
}
195
- xpsr = v7m_pop(env);
196
+ /* This xpsr_write() will invalidate frame_sp_p as it may switch stack */
197
xpsr_write(env, xpsr, ~XPSR_SPREALIGN);
198
- /* Undo stack alignment. */
199
- if (xpsr & XPSR_SPREALIGN) {
200
- env->regs[13] |= 4;
201
- }
202
203
/* The restored xPSR exception field will be zero if we're
204
* resuming in Thread mode. If that doesn't match what the
205
--
68
--
206
2.7.4
69
2.25.1
207
70
208
71
diff view generated by jsdifflib
1
For the SG instruction and secure function return we are going
1
Currently for KVM the intention is that '-cpu max' and '-cpu host'
2
to want to do memory accesses using the MMU index of the CPU
2
are the same thing, but because we did this with two separate
3
in secure state, even though the CPU is currently in non-secure
3
pieces of code they have got a little bit out of sync. Specifically,
4
state. Write arm_v7m_mmu_idx_for_secstate() to do this job,
4
'max' has a 'sve-max-vq' property, and 'host' does not.
5
and use it in cpu_mmu_index().
5
6
Bring the two together by having the initfn for 'max' actually
7
call the initfn for 'host'. This will result in 'max' no longer
8
exposing the 'sve-max-vq' property when using KVM.
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: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Reviewed-by: Andrew Jones <drjones@redhat.com>
13
Reviewed-by: Alexander Graf <agraf@csgraf.de>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 1506092407-26985-17-git-send-email-peter.maydell@linaro.org
15
Message-id: 20220204165506.2846058-4-peter.maydell@linaro.org
11
---
16
---
12
target/arm/cpu.h | 32 +++++++++++++++++++++-----------
17
target/arm/cpu64.c | 14 ++++++++------
13
1 file changed, 21 insertions(+), 11 deletions(-)
18
1 file changed, 8 insertions(+), 6 deletions(-)
14
19
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
20
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.h
22
--- a/target/arm/cpu64.c
18
+++ b/target/arm/cpu.h
23
+++ b/target/arm/cpu64.c
19
@@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
24
@@ -XXX,XX +XXX,XX @@ void aarch64_add_pauth_properties(Object *obj)
20
}
25
}
21
}
26
}
22
27
23
+/* Return the MMU index for a v7M CPU in the specified security state */
28
-#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
24
+static inline ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env,
29
static void aarch64_host_initfn(Object *obj)
25
+ bool secstate)
26
+{
27
+ int el = arm_current_el(env);
28
+ ARMMMUIdx mmu_idx;
29
+
30
+ if (el == 0) {
31
+ mmu_idx = secstate ? ARMMMUIdx_MSUser : ARMMMUIdx_MUser;
32
+ } else {
33
+ mmu_idx = secstate ? ARMMMUIdx_MSPriv : ARMMMUIdx_MPriv;
34
+ }
35
+
36
+ if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) {
37
+ mmu_idx = secstate ? ARMMMUIdx_MSNegPri : ARMMMUIdx_MNegPri;
38
+ }
39
+
40
+ return mmu_idx;
41
+}
42
+
43
/* Determine the current mmu_idx to use for normal loads/stores */
44
static inline int cpu_mmu_index(CPUARMState *env, bool ifetch)
45
{
30
{
46
int el = arm_current_el(env);
31
+#if defined(CONFIG_KVM)
47
32
ARMCPU *cpu = ARM_CPU(obj);
48
if (arm_feature(env, ARM_FEATURE_M)) {
49
- ARMMMUIdx mmu_idx;
50
-
33
-
51
- if (el == 0) {
34
-#ifdef CONFIG_KVM
52
- mmu_idx = env->v7m.secure ? ARMMMUIdx_MSUser : ARMMMUIdx_MUser;
35
kvm_arm_set_cpu_features_from_host(cpu);
53
- } else {
36
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
54
- mmu_idx = env->v7m.secure ? ARMMMUIdx_MSPriv : ARMMMUIdx_MPriv;
37
aarch64_add_sve_properties(obj);
55
- }
38
aarch64_add_pauth_properties(obj);
56
-
57
- if (armv7m_nvic_neg_prio_requested(env->nvic, env->v7m.secure)) {
58
- mmu_idx = env->v7m.secure ? ARMMMUIdx_MSNegPri : ARMMMUIdx_MNegPri;
59
- }
60
+ ARMMMUIdx mmu_idx = arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure);
61
62
return arm_to_core_mmu_idx(mmu_idx);
63
}
39
}
40
-#else
41
+#elif defined(CONFIG_HVF)
42
+ ARMCPU *cpu = ARM_CPU(obj);
43
hvf_arm_set_cpu_features_from_host(cpu);
44
+#else
45
+ g_assert_not_reached();
46
#endif
47
}
48
-#endif
49
50
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
51
* otherwise, a CPU with as many features enabled as our emulation supports.
52
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
53
ARMCPU *cpu = ARM_CPU(obj);
54
55
if (kvm_enabled()) {
56
- kvm_arm_set_cpu_features_from_host(cpu);
57
+ /* With KVM, '-cpu max' is identical to '-cpu host' */
58
+ aarch64_host_initfn(obj);
59
+ return;
60
} else {
61
uint64_t t;
62
uint32_t u;
64
--
63
--
65
2.7.4
64
2.25.1
66
65
67
66
diff view generated by jsdifflib
New patch
1
Now that the if() branch of the condition in aarch64_max_initfn()
2
returns early, we don't need to keep the rest of the code in
3
the function inside an else block. Remove the else, unindenting
4
that code.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Andrew Jones <drjones@redhat.com>
9
Reviewed-by: Alexander Graf <agraf@csgraf.de>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20220204165506.2846058-5-peter.maydell@linaro.org
12
---
13
target/arm/cpu64.c | 289 +++++++++++++++++++++++----------------------
14
1 file changed, 146 insertions(+), 143 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
static void aarch64_max_initfn(Object *obj)
22
{
23
ARMCPU *cpu = ARM_CPU(obj);
24
+ uint64_t t;
25
+ uint32_t u;
26
27
if (kvm_enabled()) {
28
/* With KVM, '-cpu max' is identical to '-cpu host' */
29
aarch64_host_initfn(obj);
30
return;
31
- } else {
32
- uint64_t t;
33
- uint32_t u;
34
- aarch64_a57_initfn(obj);
35
+ }
36
37
- /*
38
- * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real
39
- * one and try to apply errata workarounds or use impdef features we
40
- * don't provide.
41
- * An IMPLEMENTER field of 0 means "reserved for software use";
42
- * ARCHITECTURE must be 0xf indicating "v7 or later, check ID registers
43
- * to see which features are present";
44
- * the VARIANT, PARTNUM and REVISION fields are all implementation
45
- * defined and we choose to define PARTNUM just in case guest
46
- * code needs to distinguish this QEMU CPU from other software
47
- * implementations, though this shouldn't be needed.
48
- */
49
- t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0);
50
- t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf);
51
- t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q');
52
- t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0);
53
- t = FIELD_DP64(t, MIDR_EL1, REVISION, 0);
54
- cpu->midr = t;
55
+ /* '-cpu max' for TCG: we currently do this as "A57 with extra things" */
56
57
- t = cpu->isar.id_aa64isar0;
58
- t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */
59
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);
60
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* SHA512 */
61
- t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);
62
- t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);
63
- t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);
64
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1);
65
- t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1);
66
- t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1);
67
- t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);
68
- t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1);
69
- t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* v8.5-CondM */
70
- t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */
71
- t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1);
72
- cpu->isar.id_aa64isar0 = t;
73
+ aarch64_a57_initfn(obj);
74
75
- t = cpu->isar.id_aa64isar1;
76
- t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2);
77
- t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1);
78
- t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1);
79
- t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1);
80
- t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1);
81
- t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1);
82
- t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1);
83
- t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* ARMv8.4-RCPC */
84
- t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1);
85
- cpu->isar.id_aa64isar1 = t;
86
+ /*
87
+ * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real
88
+ * one and try to apply errata workarounds or use impdef features we
89
+ * don't provide.
90
+ * An IMPLEMENTER field of 0 means "reserved for software use";
91
+ * ARCHITECTURE must be 0xf indicating "v7 or later, check ID registers
92
+ * to see which features are present";
93
+ * the VARIANT, PARTNUM and REVISION fields are all implementation
94
+ * defined and we choose to define PARTNUM just in case guest
95
+ * code needs to distinguish this QEMU CPU from other software
96
+ * implementations, though this shouldn't be needed.
97
+ */
98
+ t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0);
99
+ t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf);
100
+ t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q');
101
+ t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0);
102
+ t = FIELD_DP64(t, MIDR_EL1, REVISION, 0);
103
+ cpu->midr = t;
104
105
- t = cpu->isar.id_aa64pfr0;
106
- t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
107
- t = FIELD_DP64(t, ID_AA64PFR0, FP, 1);
108
- t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1);
109
- t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);
110
- t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1);
111
- cpu->isar.id_aa64pfr0 = t;
112
+ t = cpu->isar.id_aa64isar0;
113
+ t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */
114
+ t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);
115
+ t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* SHA512 */
116
+ t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);
117
+ t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);
118
+ t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);
119
+ t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1);
120
+ t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1);
121
+ t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1);
122
+ t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);
123
+ t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1);
124
+ t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* v8.5-CondM */
125
+ t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */
126
+ t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1);
127
+ cpu->isar.id_aa64isar0 = t;
128
129
- t = cpu->isar.id_aa64pfr1;
130
- t = FIELD_DP64(t, ID_AA64PFR1, BT, 1);
131
- t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2);
132
- /*
133
- * Begin with full support for MTE. This will be downgraded to MTE=0
134
- * during realize if the board provides no tag memory, much like
135
- * we do for EL2 with the virtualization=on property.
136
- */
137
- t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3);
138
- cpu->isar.id_aa64pfr1 = t;
139
+ t = cpu->isar.id_aa64isar1;
140
+ t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2);
141
+ t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1);
142
+ t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1);
143
+ t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1);
144
+ t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1);
145
+ t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1);
146
+ t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1);
147
+ t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* ARMv8.4-RCPC */
148
+ t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1);
149
+ cpu->isar.id_aa64isar1 = t;
150
151
- t = cpu->isar.id_aa64mmfr0;
152
- t = FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 5); /* PARange: 48 bits */
153
- cpu->isar.id_aa64mmfr0 = t;
154
+ t = cpu->isar.id_aa64pfr0;
155
+ t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
156
+ t = FIELD_DP64(t, ID_AA64PFR0, FP, 1);
157
+ t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1);
158
+ t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);
159
+ t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1);
160
+ cpu->isar.id_aa64pfr0 = t;
161
162
- t = cpu->isar.id_aa64mmfr1;
163
- t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */
164
- t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1);
165
- t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1);
166
- t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */
167
- t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */
168
- t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */
169
- cpu->isar.id_aa64mmfr1 = t;
170
+ t = cpu->isar.id_aa64pfr1;
171
+ t = FIELD_DP64(t, ID_AA64PFR1, BT, 1);
172
+ t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2);
173
+ /*
174
+ * Begin with full support for MTE. This will be downgraded to MTE=0
175
+ * during realize if the board provides no tag memory, much like
176
+ * we do for EL2 with the virtualization=on property.
177
+ */
178
+ t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3);
179
+ cpu->isar.id_aa64pfr1 = t;
180
181
- t = cpu->isar.id_aa64mmfr2;
182
- t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1);
183
- t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */
184
- t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */
185
- cpu->isar.id_aa64mmfr2 = t;
186
+ t = cpu->isar.id_aa64mmfr0;
187
+ t = FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 5); /* PARange: 48 bits */
188
+ cpu->isar.id_aa64mmfr0 = t;
189
190
- t = cpu->isar.id_aa64zfr0;
191
- t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1);
192
- t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* PMULL */
193
- t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1);
194
- t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1);
195
- t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1);
196
- t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1);
197
- t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1);
198
- t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1);
199
- t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1);
200
- cpu->isar.id_aa64zfr0 = t;
201
+ t = cpu->isar.id_aa64mmfr1;
202
+ t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */
203
+ t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1);
204
+ t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1);
205
+ t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */
206
+ t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */
207
+ t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */
208
+ cpu->isar.id_aa64mmfr1 = t;
209
210
- /* Replicate the same data to the 32-bit id registers. */
211
- u = cpu->isar.id_isar5;
212
- u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */
213
- u = FIELD_DP32(u, ID_ISAR5, SHA1, 1);
214
- u = FIELD_DP32(u, ID_ISAR5, SHA2, 1);
215
- u = FIELD_DP32(u, ID_ISAR5, CRC32, 1);
216
- u = FIELD_DP32(u, ID_ISAR5, RDM, 1);
217
- u = FIELD_DP32(u, ID_ISAR5, VCMA, 1);
218
- cpu->isar.id_isar5 = u;
219
+ t = cpu->isar.id_aa64mmfr2;
220
+ t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1);
221
+ t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */
222
+ t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */
223
+ cpu->isar.id_aa64mmfr2 = t;
224
225
- u = cpu->isar.id_isar6;
226
- u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1);
227
- u = FIELD_DP32(u, ID_ISAR6, DP, 1);
228
- u = FIELD_DP32(u, ID_ISAR6, FHM, 1);
229
- u = FIELD_DP32(u, ID_ISAR6, SB, 1);
230
- u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1);
231
- u = FIELD_DP32(u, ID_ISAR6, BF16, 1);
232
- u = FIELD_DP32(u, ID_ISAR6, I8MM, 1);
233
- cpu->isar.id_isar6 = u;
234
+ t = cpu->isar.id_aa64zfr0;
235
+ t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1);
236
+ t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* PMULL */
237
+ t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1);
238
+ t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1);
239
+ t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1);
240
+ t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1);
241
+ t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1);
242
+ t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1);
243
+ t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1);
244
+ cpu->isar.id_aa64zfr0 = t;
245
246
- u = cpu->isar.id_pfr0;
247
- u = FIELD_DP32(u, ID_PFR0, DIT, 1);
248
- cpu->isar.id_pfr0 = u;
249
+ /* Replicate the same data to the 32-bit id registers. */
250
+ u = cpu->isar.id_isar5;
251
+ u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */
252
+ u = FIELD_DP32(u, ID_ISAR5, SHA1, 1);
253
+ u = FIELD_DP32(u, ID_ISAR5, SHA2, 1);
254
+ u = FIELD_DP32(u, ID_ISAR5, CRC32, 1);
255
+ u = FIELD_DP32(u, ID_ISAR5, RDM, 1);
256
+ u = FIELD_DP32(u, ID_ISAR5, VCMA, 1);
257
+ cpu->isar.id_isar5 = u;
258
259
- u = cpu->isar.id_pfr2;
260
- u = FIELD_DP32(u, ID_PFR2, SSBS, 1);
261
- cpu->isar.id_pfr2 = u;
262
+ u = cpu->isar.id_isar6;
263
+ u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1);
264
+ u = FIELD_DP32(u, ID_ISAR6, DP, 1);
265
+ u = FIELD_DP32(u, ID_ISAR6, FHM, 1);
266
+ u = FIELD_DP32(u, ID_ISAR6, SB, 1);
267
+ u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1);
268
+ u = FIELD_DP32(u, ID_ISAR6, BF16, 1);
269
+ u = FIELD_DP32(u, ID_ISAR6, I8MM, 1);
270
+ cpu->isar.id_isar6 = u;
271
272
- u = cpu->isar.id_mmfr3;
273
- u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */
274
- cpu->isar.id_mmfr3 = u;
275
+ u = cpu->isar.id_pfr0;
276
+ u = FIELD_DP32(u, ID_PFR0, DIT, 1);
277
+ cpu->isar.id_pfr0 = u;
278
279
- u = cpu->isar.id_mmfr4;
280
- u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */
281
- u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
282
- u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */
283
- u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */
284
- cpu->isar.id_mmfr4 = u;
285
+ u = cpu->isar.id_pfr2;
286
+ u = FIELD_DP32(u, ID_PFR2, SSBS, 1);
287
+ cpu->isar.id_pfr2 = u;
288
289
- t = cpu->isar.id_aa64dfr0;
290
- t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */
291
- cpu->isar.id_aa64dfr0 = t;
292
+ u = cpu->isar.id_mmfr3;
293
+ u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */
294
+ cpu->isar.id_mmfr3 = u;
295
296
- u = cpu->isar.id_dfr0;
297
- u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
298
- cpu->isar.id_dfr0 = u;
299
+ u = cpu->isar.id_mmfr4;
300
+ u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */
301
+ u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
302
+ u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */
303
+ u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */
304
+ cpu->isar.id_mmfr4 = u;
305
306
- u = cpu->isar.mvfr1;
307
- u = FIELD_DP32(u, MVFR1, FPHP, 3); /* v8.2-FP16 */
308
- u = FIELD_DP32(u, MVFR1, SIMDHP, 2); /* v8.2-FP16 */
309
- cpu->isar.mvfr1 = u;
310
+ t = cpu->isar.id_aa64dfr0;
311
+ t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */
312
+ cpu->isar.id_aa64dfr0 = t;
313
+
314
+ u = cpu->isar.id_dfr0;
315
+ u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
316
+ cpu->isar.id_dfr0 = u;
317
+
318
+ u = cpu->isar.mvfr1;
319
+ u = FIELD_DP32(u, MVFR1, FPHP, 3); /* v8.2-FP16 */
320
+ u = FIELD_DP32(u, MVFR1, SIMDHP, 2); /* v8.2-FP16 */
321
+ cpu->isar.mvfr1 = u;
322
323
#ifdef CONFIG_USER_ONLY
324
- /* For usermode -cpu max we can use a larger and more efficient DCZ
325
- * blocksize since we don't have to follow what the hardware does.
326
- */
327
- cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */
328
- cpu->dcz_blocksize = 7; /* 512 bytes */
329
+ /*
330
+ * For usermode -cpu max we can use a larger and more efficient DCZ
331
+ * blocksize since we don't have to follow what the hardware does.
332
+ */
333
+ cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */
334
+ cpu->dcz_blocksize = 7; /* 512 bytes */
335
#endif
336
337
- bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ);
338
- }
339
+ bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ);
340
341
aarch64_add_pauth_properties(obj);
342
aarch64_add_sve_properties(obj);
343
--
344
2.25.1
345
346
diff view generated by jsdifflib
1
Reset for devices does not include an automatic clear of the
1
Currently when using hvf we mishandle '-cpu max': we fall through to
2
device state (unlike CPU state, where most of the state
2
the TCG version of its initfn, which then sets a lot of feature bits
3
structure is cleared to zero). Add some missing initialization
3
that the real host CPU doesn't have. The hvf accelerator code then
4
of NVIC state that meant that the device was left in the wrong
4
exposes these bogus ID register values to the guest because it
5
state if the guest did a warm reset.
5
doesn't check that the host really has the features.
6
6
7
(In particular, since we were resetting the computed state like
7
Make '-cpu host' be like '-cpu max' for hvf, as we do with kvm.
8
s->exception_prio but not all the state it was computed
9
from like s->vectors[x].active, the NVIC wound up in an
10
inconsistent state that could later trigger assertion failures.)
11
8
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Reviewed-by: Andrew Jones <drjones@redhat.com>
12
Reviewed-by: Alexander Graf <agraf@csgraf.de>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Message-id: 20220204165506.2846058-6-peter.maydell@linaro.org
15
Message-id: 1506092407-26985-2-git-send-email-peter.maydell@linaro.org
16
---
15
---
17
hw/intc/armv7m_nvic.c | 5 +++++
16
target/arm/cpu64.c | 5 +++--
18
1 file changed, 5 insertions(+)
17
1 file changed, 3 insertions(+), 2 deletions(-)
19
18
20
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
19
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
21
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/intc/armv7m_nvic.c
21
--- a/target/arm/cpu64.c
23
+++ b/hw/intc/armv7m_nvic.c
22
+++ b/target/arm/cpu64.c
24
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
23
@@ -XXX,XX +XXX,XX @@
25
int resetprio;
24
#include "hw/loader.h"
26
NVICState *s = NVIC(dev);
25
#endif
27
26
#include "sysemu/kvm.h"
28
+ memset(s->vectors, 0, sizeof(s->vectors));
27
+#include "sysemu/hvf.h"
29
+ memset(s->sec_vectors, 0, sizeof(s->sec_vectors));
28
#include "kvm_arm.h"
30
+ s->prigroup[M_REG_NS] = 0;
29
#include "hvf_arm.h"
31
+ s->prigroup[M_REG_S] = 0;
30
#include "qapi/visitor.h"
32
+
31
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
33
s->vectors[ARMV7M_EXCP_NMI].enabled = 1;
32
uint64_t t;
34
/* MEM, BUS, and USAGE are enabled through
33
uint32_t u;
35
* the System Handler Control register
34
35
- if (kvm_enabled()) {
36
- /* With KVM, '-cpu max' is identical to '-cpu host' */
37
+ if (kvm_enabled() || hvf_enabled()) {
38
+ /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */
39
aarch64_host_initfn(obj);
40
return;
41
}
36
--
42
--
37
2.7.4
43
2.25.1
38
44
39
45
diff view generated by jsdifflib
1
For v8M, exceptions from Secure to Non-Secure state will save
1
Currently we don't allow guests under hvf to use the PAuth extension,
2
callee-saved registers to the exception frame as well as the
2
because we didn't have any special code to handle that, and therefore
3
caller-saved registers. Add support for unstacking these
3
in arm_cpu_pauth_finalize() we will sanitize the ID_AA64ISAR1 value
4
registers in exception exit when necessary.
4
the guest sees to clear the PAuth related fields.
5
6
Add support for this in the same way that KVM does it, by defaulting
7
to "PAuth enabled" if the host CPU has it and allowing the user to
8
disable it via '-cpu pauth=no' on the command line.
5
9
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Reviewed-by: Andrew Jones <drjones@redhat.com>
13
Reviewed-by: Alexander Graf <agraf@csgraf.de>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 1506092407-26985-12-git-send-email-peter.maydell@linaro.org
15
Message-id: 20220204165506.2846058-7-peter.maydell@linaro.org
9
---
16
---
10
target/arm/helper.c | 30 ++++++++++++++++++++++++++++++
17
target/arm/cpu64.c | 14 ++++++++++----
11
1 file changed, 30 insertions(+)
18
1 file changed, 10 insertions(+), 4 deletions(-)
12
19
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
20
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
14
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
22
--- a/target/arm/cpu64.c
16
+++ b/target/arm/helper.c
23
+++ b/target/arm/cpu64.c
17
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
24
@@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
18
"for destination state is UNPREDICTABLE\n");
25
uint64_t t;
26
27
/* Exit early if PAuth is enabled, and fall through to disable it */
28
- if (kvm_enabled() && cpu->prop_pauth) {
29
+ if ((kvm_enabled() || hvf_enabled()) && cpu->prop_pauth) {
30
if (!cpu_isar_feature(aa64_pauth, cpu)) {
31
- error_setg(errp, "'pauth' feature not supported by KVM on this host");
32
+ error_setg(errp, "'pauth' feature not supported by %s on this host",
33
+ kvm_enabled() ? "KVM" : "hvf");
19
}
34
}
20
35
21
+ /* Do we need to pop callee-saved registers? */
36
return;
22
+ if (return_to_secure &&
37
@@ -XXX,XX +XXX,XX @@ void aarch64_add_pauth_properties(Object *obj)
23
+ ((excret & R_V7M_EXCRET_ES_MASK) == 0 ||
38
24
+ (excret & R_V7M_EXCRET_DCRS_MASK) == 0)) {
39
/* Default to PAUTH on, with the architected algorithm on TCG. */
25
+ uint32_t expected_sig = 0xfefa125b;
40
qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
26
+ uint32_t actual_sig = ldl_phys(cs->as, frameptr);
41
- if (kvm_enabled()) {
27
+
42
+ if (kvm_enabled() || hvf_enabled()) {
28
+ if (expected_sig != actual_sig) {
43
/*
29
+ /* Take a SecureFault on the current stack */
44
* Mirror PAuth support from the probed sysregs back into the
30
+ env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
45
- * property for KVM. Is it just a bit backward? Yes it is!
31
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
46
+ * property for KVM or hvf. Is it just a bit backward? Yes it is!
32
+ v7m_exception_taken(cpu, excret);
47
+ * Note that prop_pauth is true whether the host CPU supports the
33
+ qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing "
48
+ * architected QARMA5 algorithm or the IMPDEF one. We don't
34
+ "stackframe: failed exception return integrity "
49
+ * provide the separate pauth-impdef property for KVM or hvf,
35
+ "signature check\n");
50
+ * only for TCG.
36
+ return;
51
*/
37
+ }
52
cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu);
38
+
53
} else {
39
+ env->regs[4] = ldl_phys(cs->as, frameptr + 0x8);
54
@@ -XXX,XX +XXX,XX @@ static void aarch64_host_initfn(Object *obj)
40
+ env->regs[5] = ldl_phys(cs->as, frameptr + 0xc);
55
#elif defined(CONFIG_HVF)
41
+ env->regs[6] = ldl_phys(cs->as, frameptr + 0x10);
56
ARMCPU *cpu = ARM_CPU(obj);
42
+ env->regs[7] = ldl_phys(cs->as, frameptr + 0x14);
57
hvf_arm_set_cpu_features_from_host(cpu);
43
+ env->regs[8] = ldl_phys(cs->as, frameptr + 0x18);
58
+ aarch64_add_pauth_properties(obj);
44
+ env->regs[9] = ldl_phys(cs->as, frameptr + 0x1c);
59
#else
45
+ env->regs[10] = ldl_phys(cs->as, frameptr + 0x20);
60
g_assert_not_reached();
46
+ env->regs[11] = ldl_phys(cs->as, frameptr + 0x24);
61
#endif
47
+
48
+ frameptr += 0x28;
49
+ }
50
+
51
/* Pop registers. TODO: make these accesses use the correct
52
* attributes and address space (S/NS, priv/unpriv) and handle
53
* memory transaction failures.
54
--
62
--
55
2.7.4
63
2.25.1
56
64
57
65
diff view generated by jsdifflib
1
Add the new M profile Secure Fault Status Register
1
Currently there is no way for a board model's Kconfig stanza to
2
and Secure Fault Address Register.
2
say "I have an i2c bus which the user can plug an i2c device into,
3
build all the free-standing i2c devices". The Kconfig mechanism
4
for this is the "device group". Add an I2C_DEVICES group along
5
the same lines as the existing PCI_DEVICES. Simple free-standing
6
i2c devices which a user might plausibly want to be able to
7
plug in on the QEMU commandline should have
8
default y if I2C_DEVICES
9
and board models which have an i2c bus that is user-accessible
10
should use
11
imply I2C_DEVICES
12
to cause those pluggable devices to be built.
13
14
In this commit we mark only a fairly conservative set of i2c devices
15
as belonging to the I2C_DEVICES group: the simple sensors and RTCs
16
(not including PMBus devices or devices which need GPIO lines to be
17
connected).
3
18
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
6
Message-id: 1506092407-26985-10-git-send-email-peter.maydell@linaro.org
21
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
22
Reviewed-by: Hao Wu <wuhaotsh@google.com>
23
Message-id: 20220208155911.3408455-2-peter.maydell@linaro.org
7
---
24
---
8
target/arm/cpu.h | 12 ++++++++++++
25
docs/devel/kconfig.rst | 8 ++++++--
9
hw/intc/armv7m_nvic.c | 34 ++++++++++++++++++++++++++++++++++
26
hw/i2c/Kconfig | 5 +++++
10
target/arm/machine.c | 2 ++
27
hw/rtc/Kconfig | 2 ++
11
3 files changed, 48 insertions(+)
28
hw/sensor/Kconfig | 5 +++++
29
4 files changed, 18 insertions(+), 2 deletions(-)
12
30
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
31
diff --git a/docs/devel/kconfig.rst b/docs/devel/kconfig.rst
14
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
33
--- a/docs/devel/kconfig.rst
16
+++ b/target/arm/cpu.h
34
+++ b/docs/devel/kconfig.rst
17
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
35
@@ -XXX,XX +XXX,XX @@ declares its dependencies in different ways:
18
uint32_t cfsr[M_REG_NUM_BANKS]; /* Configurable Fault Status */
36
no directive and are not used in the Makefile either; they only appear
19
uint32_t hfsr; /* HardFault Status */
37
as conditions for ``default y`` directives.
20
uint32_t dfsr; /* Debug Fault Status Register */
38
21
+ uint32_t sfsr; /* Secure Fault Status Register */
39
- QEMU currently has two device groups, ``PCI_DEVICES`` and
22
uint32_t mmfar[M_REG_NUM_BANKS]; /* MemManage Fault Address */
40
- ``TEST_DEVICES``. PCI devices usually have a ``default y if
23
uint32_t bfar; /* BusFault Address */
41
+ QEMU currently has three device groups, ``PCI_DEVICES``, ``I2C_DEVICES``,
24
+ uint32_t sfar; /* Secure Fault Address Register */
42
+ and ``TEST_DEVICES``. PCI devices usually have a ``default y if
25
unsigned mpu_ctrl[M_REG_NUM_BANKS]; /* MPU_CTRL */
43
PCI_DEVICES`` directive rather than just ``default y``. This lets
26
int exception;
44
some boards (notably s390) easily support a subset of PCI devices,
27
uint32_t primask[M_REG_NUM_BANKS];
45
for example only VFIO (passthrough) and virtio-pci devices.
28
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_DFSR, DWTTRAP, 2, 1)
46
+ ``I2C_DEVICES`` is similar to ``PCI_DEVICES``. It contains i2c devices
29
FIELD(V7M_DFSR, VCATCH, 3, 1)
47
+ that users might reasonably want to plug in to an i2c bus on any
30
FIELD(V7M_DFSR, EXTERNAL, 4, 1)
48
+ board (and not ones which are very board-specific or that need
31
49
+ to be wired up in a way that can't be done on the command line).
32
+/* V7M SFSR bits */
50
``TEST_DEVICES`` instead is used for devices that are rarely used on
33
+FIELD(V7M_SFSR, INVEP, 0, 1)
51
production virtual machines, but provide useful hooks to test QEMU
34
+FIELD(V7M_SFSR, INVIS, 1, 1)
52
or KVM.
35
+FIELD(V7M_SFSR, INVER, 2, 1)
53
diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig
36
+FIELD(V7M_SFSR, AUVIOL, 3, 1)
54
index XXXXXXX..XXXXXXX 100644
37
+FIELD(V7M_SFSR, INVTRAN, 4, 1)
55
--- a/hw/i2c/Kconfig
38
+FIELD(V7M_SFSR, LSPERR, 5, 1)
56
+++ b/hw/i2c/Kconfig
39
+FIELD(V7M_SFSR, SFARVALID, 6, 1)
57
@@ -XXX,XX +XXX,XX @@
40
+FIELD(V7M_SFSR, LSERR, 7, 1)
58
config I2C
59
bool
60
61
+config I2C_DEVICES
62
+ # Device group for i2c devices which can reasonably be user-plugged
63
+ # to any board's i2c bus
64
+ bool
41
+
65
+
42
/* v7M MPU_CTRL bits */
66
config SMBUS
43
FIELD(V7M_MPU_CTRL, ENABLE, 0, 1)
67
bool
44
FIELD(V7M_MPU_CTRL, HFNMIENA, 1, 1)
68
select I2C
45
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
69
diff --git a/hw/rtc/Kconfig b/hw/rtc/Kconfig
46
index XXXXXXX..XXXXXXX 100644
70
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/intc/armv7m_nvic.c
71
--- a/hw/rtc/Kconfig
48
+++ b/hw/intc/armv7m_nvic.c
72
+++ b/hw/rtc/Kconfig
49
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
73
@@ -XXX,XX +XXX,XX @@
50
goto bad_offset;
74
config DS1338
51
}
75
bool
52
return cpu->env.pmsav8.mair1[attrs.secure];
76
depends on I2C
53
+ case 0xde4: /* SFSR */
77
+ default y if I2C_DEVICES
54
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
78
55
+ goto bad_offset;
79
config M41T80
56
+ }
80
bool
57
+ if (!attrs.secure) {
81
depends on I2C
58
+ return 0;
82
+ default y if I2C_DEVICES
59
+ }
83
60
+ return cpu->env.v7m.sfsr;
84
config M48T59
61
+ case 0xde8: /* SFAR */
85
bool
62
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
86
diff --git a/hw/sensor/Kconfig b/hw/sensor/Kconfig
63
+ goto bad_offset;
64
+ }
65
+ if (!attrs.secure) {
66
+ return 0;
67
+ }
68
+ return cpu->env.v7m.sfar;
69
default:
70
bad_offset:
71
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
72
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
73
* only affect cacheability, and we don't implement caching.
74
*/
75
break;
76
+ case 0xde4: /* SFSR */
77
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
78
+ goto bad_offset;
79
+ }
80
+ if (!attrs.secure) {
81
+ return;
82
+ }
83
+ cpu->env.v7m.sfsr &= ~value; /* W1C */
84
+ break;
85
+ case 0xde8: /* SFAR */
86
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
87
+ goto bad_offset;
88
+ }
89
+ if (!attrs.secure) {
90
+ return;
91
+ }
92
+ cpu->env.v7m.sfsr = value;
93
+ break;
94
case 0xf00: /* Software Triggered Interrupt Register */
95
{
96
int excnum = (value & 0x1ff) + NVIC_FIRST_IRQ;
97
diff --git a/target/arm/machine.c b/target/arm/machine.c
98
index XXXXXXX..XXXXXXX 100644
87
index XXXXXXX..XXXXXXX 100644
99
--- a/target/arm/machine.c
88
--- a/hw/sensor/Kconfig
100
+++ b/target/arm/machine.c
89
+++ b/hw/sensor/Kconfig
101
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_security = {
90
@@ -XXX,XX +XXX,XX @@
102
VMSTATE_UINT32(env.v7m.ccr[M_REG_S], ARMCPU),
91
config TMP105
103
VMSTATE_UINT32(env.v7m.mmfar[M_REG_S], ARMCPU),
92
bool
104
VMSTATE_UINT32(env.v7m.cfsr[M_REG_S], ARMCPU),
93
depends on I2C
105
+ VMSTATE_UINT32(env.v7m.sfsr, ARMCPU),
94
+ default y if I2C_DEVICES
106
+ VMSTATE_UINT32(env.v7m.sfar, ARMCPU),
95
107
VMSTATE_END_OF_LIST()
96
config TMP421
108
}
97
bool
109
};
98
depends on I2C
99
+ default y if I2C_DEVICES
100
101
config DPS310
102
bool
103
depends on I2C
104
+ default y if I2C_DEVICES
105
106
config EMC141X
107
bool
108
depends on I2C
109
+ default y if I2C_DEVICES
110
111
config ADM1272
112
bool
113
@@ -XXX,XX +XXX,XX @@ config MAX34451
114
config LSM303DLHC_MAG
115
bool
116
depends on I2C
117
+ default y if I2C_DEVICES
110
--
118
--
111
2.7.4
119
2.25.1
112
120
113
121
diff view generated by jsdifflib
1
ARM v8M specifies that the INVPC usage fault for mismatched
1
For arm boards with an i2c bus which a user could reasonably
2
xPSR exception field and handler mode bit should be checked
2
want to plug arbitrary devices, add 'imply I2C_DEVICES' to the
3
before updating the PSR and SP, so that the fault is taken
3
Kconfig stanza.
4
with the existing stack frame rather than by pushing a new one.
5
Perform this check in the right place for v8M.
6
7
Since v7M specifies in its pseudocode that this usage fault
8
check should happen later, we have to retain the original
9
code for that check rather than being able to merge the two.
10
(The distinction is architecturally visible but only in
11
very obscure corner cases like attempting an invalid exception
12
return with an exception frame in read only memory.)
13
4
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
16
Message-id: 1506092407-26985-7-git-send-email-peter.maydell@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Hao Wu <wuhaotsh@google.com>
9
Message-id: 20220208155911.3408455-3-peter.maydell@linaro.org
17
---
10
---
18
target/arm/helper.c | 30 +++++++++++++++++++++++++++---
11
hw/arm/Kconfig | 10 ++++++++++
19
1 file changed, 27 insertions(+), 3 deletions(-)
12
1 file changed, 10 insertions(+)
20
13
21
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
22
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/helper.c
16
--- a/hw/arm/Kconfig
24
+++ b/target/arm/helper.c
17
+++ b/hw/arm/Kconfig
25
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
18
@@ -XXX,XX +XXX,XX @@ config DIGIC
26
}
19
27
xpsr = ldl_phys(cs->as, frameptr + 0x1c);
20
config EXYNOS4
28
21
bool
29
+ if (arm_feature(env, ARM_FEATURE_V8)) {
22
+ imply I2C_DEVICES
30
+ /* For v8M we have to check whether the xPSR exception field
23
select A9MPCORE
31
+ * matches the EXCRET value for return to handler/thread
24
select I2C
32
+ * before we commit to changing the SP and xPSR.
25
select LAN9118
33
+ */
26
@@ -XXX,XX +XXX,XX @@ config REALVIEW
34
+ bool will_be_handler = (xpsr & XPSR_EXCP) != 0;
27
bool
35
+ if (return_to_handler != will_be_handler) {
28
imply PCI_DEVICES
36
+ /* Take an INVPC UsageFault on the current stack.
29
imply PCI_TESTDEV
37
+ * By this point we will have switched to the security state
30
+ imply I2C_DEVICES
38
+ * for the background state, so this UsageFault will target
31
select SMC91C111
39
+ * that state.
32
select LAN9118
40
+ */
33
select A9MPCORE
41
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
34
@@ -XXX,XX +XXX,XX @@ config SABRELITE
42
+ env->v7m.secure);
35
43
+ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK;
36
config STELLARIS
44
+ v7m_exception_taken(cpu, excret);
37
bool
45
+ qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
38
+ imply I2C_DEVICES
46
+ "stackframe: failed exception return integrity "
39
select ARM_V7M
47
+ "check\n");
40
select CMSDK_APB_WATCHDOG
48
+ return;
41
select I2C
49
+ }
42
@@ -XXX,XX +XXX,XX @@ config NPCM7XX
50
+ }
43
51
+
44
config FSL_IMX25
52
/* Commit to consuming the stack frame */
45
bool
53
frameptr += 0x20;
46
+ imply I2C_DEVICES
54
/* Undo stack alignment (the SPREALIGN bit indicates that the original
47
select IMX
55
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
48
select IMX_FEC
56
/* The restored xPSR exception field will be zero if we're
49
select IMX_I2C
57
* resuming in Thread mode. If that doesn't match what the
50
@@ -XXX,XX +XXX,XX @@ config FSL_IMX25
58
* exception return excret specified then this is a UsageFault.
51
59
+ * v7M requires we make this check here; v8M did it earlier.
52
config FSL_IMX31
60
*/
53
bool
61
if (return_to_handler != arm_v7m_is_handler_mode(env)) {
54
+ imply I2C_DEVICES
62
- /* Take an INVPC UsageFault by pushing the stack again.
55
select SERIAL
63
- * TODO: the v8M version of this code should target the
56
select IMX
64
- * background state for this exception.
57
select IMX_I2C
65
+ /* Take an INVPC UsageFault by pushing the stack again;
58
@@ -XXX,XX +XXX,XX @@ config FSL_IMX31
66
+ * we know we're v7M so this is never a Secure UsageFault.
59
67
*/
60
config FSL_IMX6
68
+ assert(!arm_feature(env, ARM_FEATURE_V8));
61
bool
69
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, false);
62
+ imply I2C_DEVICES
70
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK;
63
select A9MPCORE
71
v7m_push_stack(cpu);
64
select IMX
65
select IMX_FEC
66
@@ -XXX,XX +XXX,XX @@ config ASPEED_SOC
67
68
config MPS2
69
bool
70
+ imply I2C_DEVICES
71
select ARMSSE
72
select LAN9118
73
select MPS2_FPGAIO
74
@@ -XXX,XX +XXX,XX @@ config FSL_IMX7
75
bool
76
imply PCI_DEVICES
77
imply TEST_DEVICES
78
+ imply I2C_DEVICES
79
select A15MPCORE
80
select PCI
81
select IMX
82
@@ -XXX,XX +XXX,XX @@ config ARM_SMMUV3
83
84
config FSL_IMX6UL
85
bool
86
+ imply I2C_DEVICES
87
select A15MPCORE
88
select IMX
89
select IMX_FEC
90
@@ -XXX,XX +XXX,XX @@ config MICROBIT
91
92
config NRF51_SOC
93
bool
94
+ imply I2C_DEVICES
95
select I2C
96
select ARM_V7M
97
select UNIMP
72
--
98
--
73
2.7.4
99
2.25.1
74
100
75
101
diff view generated by jsdifflib
1
In v8M, more bits are defined in the exception-return magic
1
In the armv7m object, handle clock inputs that aren't connected.
2
values; update the code that checks these so we accept
2
This is always an error for 'cpuclk'. For 'refclk' it is OK for this
3
the v8M values when the CPU permits them.
3
to be disconnected, but we need to handle it by not trying to connect
4
a sourceless-clock to the systick device.
4
5
6
This fixes a bug where on the mps2-an521 and similar boards (which
7
do not have a refclk) the systick device incorrectly reset with
8
SYST_CSR.CLKSOURCE 0 ("use refclk") rather than 1 ("use CPU clock").
9
10
Cc: qemu-stable@nongnu.org
11
Reported-by: Richard Petri <git@rpls.de>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 1506092407-26985-11-git-send-email-peter.maydell@linaro.org
15
Message-id: 20220208171643.3486277-1-peter.maydell@linaro.org
8
---
16
---
9
target/arm/helper.c | 73 ++++++++++++++++++++++++++++++++++++++++++-----------
17
hw/arm/armv7m.c | 26 ++++++++++++++++++++++----
10
1 file changed, 58 insertions(+), 15 deletions(-)
18
1 file changed, 22 insertions(+), 4 deletions(-)
11
19
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
20
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
13
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
22
--- a/hw/arm/armv7m.c
15
+++ b/target/arm/helper.c
23
+++ b/hw/arm/armv7m.c
16
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
24
@@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp)
17
uint32_t excret;
25
return;
18
uint32_t xpsr;
19
bool ufault = false;
20
- bool return_to_sp_process = false;
21
- bool return_to_handler = false;
22
+ bool sfault = false;
23
+ bool return_to_sp_process;
24
+ bool return_to_handler;
25
bool rettobase = false;
26
bool exc_secure = false;
27
bool return_to_secure;
28
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
29
excret);
30
}
26
}
31
27
32
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
28
+ /* cpuclk must be connected; refclk is optional */
33
+ /* EXC_RETURN.ES validation check (R_SMFL). We must do this before
29
+ if (!clock_has_source(s->cpuclk)) {
34
+ * we pick which FAULTMASK to clear.
30
+ error_setg(errp, "armv7m: cpuclk must be connected");
35
+ */
31
+ return;
36
+ if (!env->v7m.secure &&
37
+ ((excret & R_V7M_EXCRET_ES_MASK) ||
38
+ !(excret & R_V7M_EXCRET_DCRS_MASK))) {
39
+ sfault = 1;
40
+ /* For all other purposes, treat ES as 0 (R_HXSR) */
41
+ excret &= ~R_V7M_EXCRET_ES_MASK;
42
+ }
43
+ }
32
+ }
44
+
33
+
45
if (env->v7m.exception != ARMV7M_EXCP_NMI) {
34
memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1);
46
/* Auto-clear FAULTMASK on return from other than NMI.
35
47
* If the security extension is implemented then this only
36
s->cpu = ARM_CPU(object_new_with_props(s->cpu_type, OBJECT(s), "cpu",
48
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
37
@@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp)
49
g_assert_not_reached();
38
&s->sysreg_ns_mem);
50
}
39
}
51
40
52
+ return_to_handler = !(excret & R_V7M_EXCRET_MODE_MASK);
41
- /* Create and map the systick devices */
53
+ return_to_sp_process = excret & R_V7M_EXCRET_SPSEL_MASK;
42
- qdev_connect_clock_in(DEVICE(&s->systick[M_REG_NS]), "refclk", s->refclk);
54
return_to_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
43
+ /*
55
(excret & R_V7M_EXCRET_S_MASK);
44
+ * Create and map the systick devices. Note that we only connect
56
45
+ * refclk if it has been connected to us; otherwise the systick
57
- switch (excret & 0xf) {
46
+ * device gets the wrong answer for clock_has_source(refclk), because
58
- case 1: /* Return to Handler */
47
+ * it has an immediate source (the ARMv7M's clock object) but not
59
- return_to_handler = true;
48
+ * an ultimate source, and then it won't correctly auto-select the
60
- break;
49
+ * CPU clock as its only possible clock source.
61
- case 13: /* Return to Thread using Process stack */
50
+ */
62
- return_to_sp_process = true;
51
+ if (clock_has_source(s->refclk)) {
63
- /* fall through */
52
+ qdev_connect_clock_in(DEVICE(&s->systick[M_REG_NS]), "refclk",
64
- case 9: /* Return to Thread using Main stack */
53
+ s->refclk);
65
- if (!rettobase &&
54
+ }
66
- !(env->v7m.ccr[env->v7m.secure] & R_V7M_CCR_NONBASETHRDENA_MASK)) {
55
qdev_connect_clock_in(DEVICE(&s->systick[M_REG_NS]), "cpuclk", s->cpuclk);
67
+ if (arm_feature(env, ARM_FEATURE_V8)) {
56
if (!sysbus_realize(SYS_BUS_DEVICE(&s->systick[M_REG_NS]), errp)) {
68
+ if (!arm_feature(env, ARM_FEATURE_M_SECURITY)) {
57
return;
69
+ /* UNPREDICTABLE if S == 1 or DCRS == 0 or ES == 1 (R_XLCP);
58
@@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp)
70
+ * we choose to take the UsageFault.
59
*/
71
+ */
60
object_initialize_child(OBJECT(dev), "systick-reg-s",
72
+ if ((excret & R_V7M_EXCRET_S_MASK) ||
61
&s->systick[M_REG_S], TYPE_SYSTICK);
73
+ (excret & R_V7M_EXCRET_ES_MASK) ||
62
- qdev_connect_clock_in(DEVICE(&s->systick[M_REG_S]), "refclk",
74
+ !(excret & R_V7M_EXCRET_DCRS_MASK)) {
63
- s->refclk);
75
+ ufault = true;
64
+ if (clock_has_source(s->refclk)) {
76
+ }
65
+ qdev_connect_clock_in(DEVICE(&s->systick[M_REG_S]), "refclk",
66
+ s->refclk);
77
+ }
67
+ }
78
+ if (excret & R_V7M_EXCRET_RES0_MASK) {
68
qdev_connect_clock_in(DEVICE(&s->systick[M_REG_S]), "cpuclk",
79
ufault = true;
69
s->cpuclk);
80
}
70
81
- break;
82
- default:
83
- ufault = true;
84
+ } else {
85
+ /* For v7M we only recognize certain combinations of the low bits */
86
+ switch (excret & 0xf) {
87
+ case 1: /* Return to Handler */
88
+ break;
89
+ case 13: /* Return to Thread using Process stack */
90
+ case 9: /* Return to Thread using Main stack */
91
+ /* We only need to check NONBASETHRDENA for v7M, because in
92
+ * v8M this bit does not exist (it is RES1).
93
+ */
94
+ if (!rettobase &&
95
+ !(env->v7m.ccr[env->v7m.secure] &
96
+ R_V7M_CCR_NONBASETHRDENA_MASK)) {
97
+ ufault = true;
98
+ }
99
+ break;
100
+ default:
101
+ ufault = true;
102
+ }
103
+ }
104
+
105
+ if (sfault) {
106
+ env->v7m.sfsr |= R_V7M_SFSR_INVER_MASK;
107
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
108
+ v7m_exception_taken(cpu, excret);
109
+ qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing "
110
+ "stackframe: failed EXC_RETURN.ES validity check\n");
111
+ return;
112
}
113
114
if (ufault) {
115
--
71
--
116
2.7.4
72
2.25.1
117
73
118
74
diff view generated by jsdifflib
1
In the v7M architecture, there is an invariant that if the CPU is
1
The function qemu_madvise() and the QEMU_MADV_* constants associated
2
in Handler mode then the CONTROL.SPSEL bit cannot be nonzero.
2
with it are used in only 10 files. Move them out of osdep.h to a new
3
This in turn means that the current stack pointer is always
3
qemu/madvise.h header that is included where it is needed.
4
indicated by CONTROL.SPSEL, even though Handler mode always uses
5
the Main stack pointer.
6
7
In v8M, this invariant is removed, and CONTROL.SPSEL may now
8
be nonzero in Handler mode (though Handler mode still always
9
uses the Main stack pointer). In preparation for this change,
10
change how we handle this bit: rename switch_v7m_sp() to
11
the now more accurate write_v7m_control_spsel(), and make it
12
check both the handler mode state and the SPSEL bit.
13
14
Note that this implicitly changes the point at which we switch
15
active SP on exception exit from before we pop the exception
16
frame to after it.
17
4
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Message-id: 1506092407-26985-4-git-send-email-peter.maydell@linaro.org
8
Message-id: 20220208200856.3558249-2-peter.maydell@linaro.org
22
---
9
---
23
target/arm/cpu.h | 8 ++++++-
10
include/qemu/madvise.h | 95 ++++++++++++++++++++++++++++++++++++++
24
hw/intc/armv7m_nvic.c | 2 +-
11
include/qemu/osdep.h | 82 --------------------------------
25
target/arm/helper.c | 65 ++++++++++++++++++++++++++++++++++-----------------
12
backends/hostmem-file.c | 1 +
26
3 files changed, 51 insertions(+), 24 deletions(-)
13
backends/hostmem.c | 1 +
14
hw/virtio/virtio-balloon.c | 1 +
15
migration/postcopy-ram.c | 1 +
16
migration/qemu-file.c | 1 +
17
migration/ram.c | 1 +
18
softmmu/physmem.c | 1 +
19
tcg/region.c | 1 +
20
util/osdep.c | 1 +
21
util/oslib-posix.c | 1 +
22
12 files changed, 105 insertions(+), 82 deletions(-)
23
create mode 100644 include/qemu/madvise.h
27
24
28
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
25
diff --git a/include/qemu/madvise.h b/include/qemu/madvise.h
29
index XXXXXXX..XXXXXXX 100644
26
new file mode 100644
30
--- a/target/arm/cpu.h
27
index XXXXXXX..XXXXXXX
31
+++ b/target/arm/cpu.h
28
--- /dev/null
32
@@ -XXX,XX +XXX,XX @@ void pmccntr_sync(CPUARMState *env);
29
+++ b/include/qemu/madvise.h
33
#define PSTATE_MODE_EL1t 4
30
@@ -XXX,XX +XXX,XX @@
34
#define PSTATE_MODE_EL0t 0
31
+/*
35
32
+ * QEMU madvise wrapper functions
36
+/* Write a new value to v7m.exception, thus transitioning into or out
33
+ *
37
+ * of Handler mode; this may result in a change of active stack pointer.
34
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
35
+ * See the COPYING file in the top-level directory.
38
+ */
36
+ */
39
+void write_v7m_exception(CPUARMState *env, uint32_t new_exc);
37
+
40
+
38
+#ifndef QEMU_MADVISE_H
41
/* Map EL and handler into a PSTATE_MODE. */
39
+#define QEMU_MADVISE_H
42
static inline unsigned int aarch64_pstate_mode(unsigned int el, bool handler)
40
+
43
{
41
+#define QEMU_MADV_INVALID -1
44
@@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
42
+
45
env->condexec_bits |= (val >> 8) & 0xfc;
43
+#if defined(CONFIG_MADVISE)
46
}
44
+
47
if (mask & XPSR_EXCP) {
45
+#define QEMU_MADV_WILLNEED MADV_WILLNEED
48
- env->v7m.exception = val & XPSR_EXCP;
46
+#define QEMU_MADV_DONTNEED MADV_DONTNEED
49
+ /* Note that this only happens on exception exit */
47
+#ifdef MADV_DONTFORK
50
+ write_v7m_exception(env, val & XPSR_EXCP);
48
+#define QEMU_MADV_DONTFORK MADV_DONTFORK
51
}
49
+#else
52
}
50
+#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
53
51
+#endif
54
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
52
+#ifdef MADV_MERGEABLE
55
index XXXXXXX..XXXXXXX 100644
53
+#define QEMU_MADV_MERGEABLE MADV_MERGEABLE
56
--- a/hw/intc/armv7m_nvic.c
54
+#else
57
+++ b/hw/intc/armv7m_nvic.c
55
+#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
58
@@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_acknowledge_irq(void *opaque)
56
+#endif
59
vec->active = 1;
57
+#ifdef MADV_UNMERGEABLE
60
vec->pending = 0;
58
+#define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE
61
59
+#else
62
- env->v7m.exception = s->vectpending;
60
+#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
63
+ write_v7m_exception(env, s->vectpending);
61
+#endif
64
62
+#ifdef MADV_DODUMP
65
nvic_irq_update(s);
63
+#define QEMU_MADV_DODUMP MADV_DODUMP
66
64
+#else
67
diff --git a/target/arm/helper.c b/target/arm/helper.c
65
+#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
68
index XXXXXXX..XXXXXXX 100644
66
+#endif
69
--- a/target/arm/helper.c
67
+#ifdef MADV_DONTDUMP
70
+++ b/target/arm/helper.c
68
+#define QEMU_MADV_DONTDUMP MADV_DONTDUMP
71
@@ -XXX,XX +XXX,XX @@ static bool v7m_using_psp(CPUARMState *env)
69
+#else
72
env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK;
70
+#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
73
}
71
+#endif
74
72
+#ifdef MADV_HUGEPAGE
75
-/* Switch to V7M main or process stack pointer. */
73
+#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE
76
-static void switch_v7m_sp(CPUARMState *env, bool new_spsel)
74
+#else
77
+/* Write to v7M CONTROL.SPSEL bit. This may change the current
75
+#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
78
+ * stack pointer between Main and Process stack pointers.
76
+#endif
79
+ */
77
+#ifdef MADV_NOHUGEPAGE
80
+static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
78
+#define QEMU_MADV_NOHUGEPAGE MADV_NOHUGEPAGE
81
{
79
+#else
82
uint32_t tmp;
80
+#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
83
- uint32_t old_control = env->v7m.control[env->v7m.secure];
81
+#endif
84
- bool old_spsel = old_control & R_V7M_CONTROL_SPSEL_MASK;
82
+#ifdef MADV_REMOVE
85
+ bool new_is_psp, old_is_psp = v7m_using_psp(env);
83
+#define QEMU_MADV_REMOVE MADV_REMOVE
86
+
84
+#else
87
+ env->v7m.control[env->v7m.secure] =
85
+#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
88
+ deposit32(env->v7m.control[env->v7m.secure],
86
+#endif
89
+ R_V7M_CONTROL_SPSEL_SHIFT,
87
+#ifdef MADV_POPULATE_WRITE
90
+ R_V7M_CONTROL_SPSEL_LENGTH, new_spsel);
88
+#define QEMU_MADV_POPULATE_WRITE MADV_POPULATE_WRITE
91
+
89
+#else
92
+ new_is_psp = v7m_using_psp(env);
90
+#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
93
91
+#endif
94
- if (old_spsel != new_spsel) {
92
+
95
+ if (old_is_psp != new_is_psp) {
93
+#elif defined(CONFIG_POSIX_MADVISE)
96
tmp = env->v7m.other_sp;
94
+
97
env->v7m.other_sp = env->regs[13];
95
+#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED
98
env->regs[13] = tmp;
96
+#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED
99
+ }
97
+#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
100
+}
98
+#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
101
+
99
+#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
102
+void write_v7m_exception(CPUARMState *env, uint32_t new_exc)
100
+#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
103
+{
101
+#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
104
+ /* Write a new value to v7m.exception, thus transitioning into or out
102
+#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
105
+ * of Handler mode; this may result in a change of active stack pointer.
103
+#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
106
+ */
104
+#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
107
+ bool new_is_psp, old_is_psp = v7m_using_psp(env);
105
+#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
108
+ uint32_t tmp;
106
+
109
107
+#else /* no-op */
110
- env->v7m.control[env->v7m.secure] = deposit32(old_control,
108
+
111
- R_V7M_CONTROL_SPSEL_SHIFT,
109
+#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID
112
- R_V7M_CONTROL_SPSEL_LENGTH, new_spsel);
110
+#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID
113
+ env->v7m.exception = new_exc;
111
+#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
114
+
112
+#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
115
+ new_is_psp = v7m_using_psp(env);
113
+#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
116
+
114
+#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
117
+ if (old_is_psp != new_is_psp) {
115
+#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
118
+ tmp = env->v7m.other_sp;
116
+#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
119
+ env->v7m.other_sp = env->regs[13];
117
+#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
120
+ env->regs[13] = tmp;
118
+#define QEMU_MADV_REMOVE QEMU_MADV_INVALID
121
}
119
+#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
122
}
120
+
123
121
+#endif
124
@@ -XXX,XX +XXX,XX @@ static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode,
122
+
125
bool want_psp = threadmode && spsel;
123
+int qemu_madvise(void *addr, size_t len, int advice);
126
124
+
127
if (secure == env->v7m.secure) {
125
+#endif
128
- /* Currently switch_v7m_sp switches SP as it updates SPSEL,
126
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
129
- * so the SP we want is always in regs[13].
127
index XXXXXXX..XXXXXXX 100644
130
- * When we decouple SPSEL from the actually selected SP
128
--- a/include/qemu/osdep.h
131
- * we need to check want_psp against v7m_using_psp()
129
+++ b/include/qemu/osdep.h
132
- * to see whether we need regs[13] or v7m.other_sp.
130
@@ -XXX,XX +XXX,XX @@ static inline void qemu_cleanup_generic_vfree(void *p)
133
- */
131
#define QEMU_MAP_NORESERVE (1 << 3)
134
- return &env->regs[13];
132
135
+ if (want_psp == v7m_using_psp(env)) {
133
136
+ return &env->regs[13];
134
-#define QEMU_MADV_INVALID -1
137
+ } else {
135
-
138
+ return &env->v7m.other_sp;
136
-#if defined(CONFIG_MADVISE)
139
+ }
137
-
140
} else {
138
-#define QEMU_MADV_WILLNEED MADV_WILLNEED
141
if (want_psp) {
139
-#define QEMU_MADV_DONTNEED MADV_DONTNEED
142
return &env->v7m.other_ss_psp;
140
-#ifdef MADV_DONTFORK
143
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr)
141
-#define QEMU_MADV_DONTFORK MADV_DONTFORK
144
uint32_t addr;
142
-#else
145
143
-#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
146
armv7m_nvic_acknowledge_irq(env->nvic);
144
-#endif
147
- switch_v7m_sp(env, 0);
145
-#ifdef MADV_MERGEABLE
148
+ write_v7m_control_spsel(env, 0);
146
-#define QEMU_MADV_MERGEABLE MADV_MERGEABLE
149
arm_clear_exclusive(env);
147
-#else
150
/* Clear IT bits */
148
-#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
151
env->condexec_bits = 0;
149
-#endif
152
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
150
-#ifdef MADV_UNMERGEABLE
153
return;
151
-#define QEMU_MADV_UNMERGEABLE MADV_UNMERGEABLE
154
}
152
-#else
155
153
-#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
156
- /* Set CONTROL.SPSEL from excret.SPSEL. For QEMU this currently
154
-#endif
157
- * causes us to switch the active SP, but we will change this
155
-#ifdef MADV_DODUMP
158
- * later to not do that so we can support v8M.
156
-#define QEMU_MADV_DODUMP MADV_DODUMP
159
+ /* Set CONTROL.SPSEL from excret.SPSEL. Since we're still in
157
-#else
160
+ * Handler mode (and will be until we write the new XPSR.Interrupt
158
-#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
161
+ * field) this does not switch around the current stack pointer.
159
-#endif
162
*/
160
-#ifdef MADV_DONTDUMP
163
- switch_v7m_sp(env, return_to_sp_process);
161
-#define QEMU_MADV_DONTDUMP MADV_DONTDUMP
164
+ write_v7m_control_spsel(env, return_to_sp_process);
162
-#else
165
163
-#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
166
{
164
-#endif
167
/* The stack pointer we should be reading the exception frame from
165
-#ifdef MADV_HUGEPAGE
168
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
166
-#define QEMU_MADV_HUGEPAGE MADV_HUGEPAGE
169
case 20: /* CONTROL */
167
-#else
170
/* Writing to the SPSEL bit only has an effect if we are in
168
-#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
171
* thread mode; other bits can be updated by any privileged code.
169
-#endif
172
- * switch_v7m_sp() deals with updating the SPSEL bit in
170
-#ifdef MADV_NOHUGEPAGE
173
+ * write_v7m_control_spsel() deals with updating the SPSEL bit in
171
-#define QEMU_MADV_NOHUGEPAGE MADV_NOHUGEPAGE
174
* env->v7m.control, so we only need update the others.
172
-#else
175
*/
173
-#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
176
if (!arm_v7m_is_handler_mode(env)) {
174
-#endif
177
- switch_v7m_sp(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
175
-#ifdef MADV_REMOVE
178
+ write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
176
-#define QEMU_MADV_REMOVE MADV_REMOVE
179
}
177
-#else
180
env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK;
178
-#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
181
env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK;
179
-#endif
180
-#ifdef MADV_POPULATE_WRITE
181
-#define QEMU_MADV_POPULATE_WRITE MADV_POPULATE_WRITE
182
-#else
183
-#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
184
-#endif
185
-
186
-#elif defined(CONFIG_POSIX_MADVISE)
187
-
188
-#define QEMU_MADV_WILLNEED POSIX_MADV_WILLNEED
189
-#define QEMU_MADV_DONTNEED POSIX_MADV_DONTNEED
190
-#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
191
-#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
192
-#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
193
-#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
194
-#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
195
-#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
196
-#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
197
-#define QEMU_MADV_REMOVE QEMU_MADV_DONTNEED
198
-#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
199
-
200
-#else /* no-op */
201
-
202
-#define QEMU_MADV_WILLNEED QEMU_MADV_INVALID
203
-#define QEMU_MADV_DONTNEED QEMU_MADV_INVALID
204
-#define QEMU_MADV_DONTFORK QEMU_MADV_INVALID
205
-#define QEMU_MADV_MERGEABLE QEMU_MADV_INVALID
206
-#define QEMU_MADV_UNMERGEABLE QEMU_MADV_INVALID
207
-#define QEMU_MADV_DODUMP QEMU_MADV_INVALID
208
-#define QEMU_MADV_DONTDUMP QEMU_MADV_INVALID
209
-#define QEMU_MADV_HUGEPAGE QEMU_MADV_INVALID
210
-#define QEMU_MADV_NOHUGEPAGE QEMU_MADV_INVALID
211
-#define QEMU_MADV_REMOVE QEMU_MADV_INVALID
212
-#define QEMU_MADV_POPULATE_WRITE QEMU_MADV_INVALID
213
-
214
-#endif
215
216
#ifdef _WIN32
217
#define HAVE_CHARDEV_SERIAL 1
218
@@ -XXX,XX +XXX,XX @@ void sigaction_invoke(struct sigaction *action,
219
struct qemu_signalfd_siginfo *info);
220
#endif
221
222
-int qemu_madvise(void *addr, size_t len, int advice);
223
int qemu_mprotect_rw(void *addr, size_t size);
224
int qemu_mprotect_rwx(void *addr, size_t size);
225
int qemu_mprotect_none(void *addr, size_t size);
226
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
227
index XXXXXXX..XXXXXXX 100644
228
--- a/backends/hostmem-file.c
229
+++ b/backends/hostmem-file.c
230
@@ -XXX,XX +XXX,XX @@
231
#include "qapi/error.h"
232
#include "qemu/error-report.h"
233
#include "qemu/module.h"
234
+#include "qemu/madvise.h"
235
#include "sysemu/hostmem.h"
236
#include "qom/object_interfaces.h"
237
#include "qom/object.h"
238
diff --git a/backends/hostmem.c b/backends/hostmem.c
239
index XXXXXXX..XXXXXXX 100644
240
--- a/backends/hostmem.c
241
+++ b/backends/hostmem.c
242
@@ -XXX,XX +XXX,XX @@
243
#include "qemu/config-file.h"
244
#include "qom/object_interfaces.h"
245
#include "qemu/mmap-alloc.h"
246
+#include "qemu/madvise.h"
247
248
#ifdef CONFIG_NUMA
249
#include <numaif.h>
250
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
251
index XXXXXXX..XXXXXXX 100644
252
--- a/hw/virtio/virtio-balloon.c
253
+++ b/hw/virtio/virtio-balloon.c
254
@@ -XXX,XX +XXX,XX @@
255
#include "qemu/iov.h"
256
#include "qemu/module.h"
257
#include "qemu/timer.h"
258
+#include "qemu/madvise.h"
259
#include "hw/virtio/virtio.h"
260
#include "hw/mem/pc-dimm.h"
261
#include "hw/qdev-properties.h"
262
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
263
index XXXXXXX..XXXXXXX 100644
264
--- a/migration/postcopy-ram.c
265
+++ b/migration/postcopy-ram.c
266
@@ -XXX,XX +XXX,XX @@
267
268
#include "qemu/osdep.h"
269
#include "qemu/rcu.h"
270
+#include "qemu/madvise.h"
271
#include "exec/target_page.h"
272
#include "migration.h"
273
#include "qemu-file.h"
274
diff --git a/migration/qemu-file.c b/migration/qemu-file.c
275
index XXXXXXX..XXXXXXX 100644
276
--- a/migration/qemu-file.c
277
+++ b/migration/qemu-file.c
278
@@ -XXX,XX +XXX,XX @@
279
*/
280
#include "qemu/osdep.h"
281
#include <zlib.h>
282
+#include "qemu/madvise.h"
283
#include "qemu/error-report.h"
284
#include "qemu/iov.h"
285
#include "migration.h"
286
diff --git a/migration/ram.c b/migration/ram.c
287
index XXXXXXX..XXXXXXX 100644
288
--- a/migration/ram.c
289
+++ b/migration/ram.c
290
@@ -XXX,XX +XXX,XX @@
291
#include "qemu/cutils.h"
292
#include "qemu/bitops.h"
293
#include "qemu/bitmap.h"
294
+#include "qemu/madvise.h"
295
#include "qemu/main-loop.h"
296
#include "xbzrle.h"
297
#include "ram.h"
298
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
299
index XXXXXXX..XXXXXXX 100644
300
--- a/softmmu/physmem.c
301
+++ b/softmmu/physmem.c
302
@@ -XXX,XX +XXX,XX @@
303
304
#include "qemu/cutils.h"
305
#include "qemu/cacheflush.h"
306
+#include "qemu/madvise.h"
307
308
#ifdef CONFIG_TCG
309
#include "hw/core/tcg-cpu-ops.h"
310
diff --git a/tcg/region.c b/tcg/region.c
311
index XXXXXXX..XXXXXXX 100644
312
--- a/tcg/region.c
313
+++ b/tcg/region.c
314
@@ -XXX,XX +XXX,XX @@
315
316
#include "qemu/osdep.h"
317
#include "qemu/units.h"
318
+#include "qemu/madvise.h"
319
#include "qapi/error.h"
320
#include "exec/exec-all.h"
321
#include "tcg/tcg.h"
322
diff --git a/util/osdep.c b/util/osdep.c
323
index XXXXXXX..XXXXXXX 100644
324
--- a/util/osdep.c
325
+++ b/util/osdep.c
326
@@ -XXX,XX +XXX,XX @@ extern int madvise(char *, size_t, int);
327
#include "qemu/cutils.h"
328
#include "qemu/sockets.h"
329
#include "qemu/error-report.h"
330
+#include "qemu/madvise.h"
331
#include "monitor/monitor.h"
332
333
static bool fips_enabled = false;
334
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
335
index XXXXXXX..XXXXXXX 100644
336
--- a/util/oslib-posix.c
337
+++ b/util/oslib-posix.c
338
@@ -XXX,XX +XXX,XX @@
339
#include "trace.h"
340
#include "qapi/error.h"
341
#include "qemu/error-report.h"
342
+#include "qemu/madvise.h"
343
#include "qemu/sockets.h"
344
#include "qemu/thread.h"
345
#include <libgen.h>
182
--
346
--
183
2.7.4
347
2.25.1
184
348
185
349
diff view generated by jsdifflib
1
When we added support for the new SHCSR bits in v8M in commit
1
The qemu_mprotect_*() family of functions are used in very few files;
2
437d59c17e9 the code to support writing to the new HARDFAULTPENDED
2
move them from osdep.h to a new qemu/mprotect.h.
3
bit was accidentally only added for non-secure writes; the
4
secure banked version of the bit should also be writable.
5
3
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 1506092407-26985-21-git-send-email-peter.maydell@linaro.org
7
Message-id: 20220208200856.3558249-3-peter.maydell@linaro.org
10
---
8
---
11
hw/intc/armv7m_nvic.c | 1 +
9
include/qemu/mprotect.h | 14 ++++++++++++++
12
1 file changed, 1 insertion(+)
10
include/qemu/osdep.h | 4 ----
11
tcg/region.c | 1 +
12
util/osdep.c | 1 +
13
4 files changed, 16 insertions(+), 4 deletions(-)
14
create mode 100644 include/qemu/mprotect.h
13
15
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
16
diff --git a/include/qemu/mprotect.h b/include/qemu/mprotect.h
17
new file mode 100644
18
index XXXXXXX..XXXXXXX
19
--- /dev/null
20
+++ b/include/qemu/mprotect.h
21
@@ -XXX,XX +XXX,XX @@
22
+/*
23
+ * QEMU mprotect functions
24
+ *
25
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
26
+ * See the COPYING file in the top-level directory.
27
+ */
28
+#ifndef QEMU_MPROTECT_H
29
+#define QEMU_MPROTECT_H
30
+
31
+int qemu_mprotect_rw(void *addr, size_t size);
32
+int qemu_mprotect_rwx(void *addr, size_t size);
33
+int qemu_mprotect_none(void *addr, size_t size);
34
+
35
+#endif
36
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
15
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
38
--- a/include/qemu/osdep.h
17
+++ b/hw/intc/armv7m_nvic.c
39
+++ b/include/qemu/osdep.h
18
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
40
@@ -XXX,XX +XXX,XX @@ void sigaction_invoke(struct sigaction *action,
19
s->sec_vectors[ARMV7M_EXCP_BUS].enabled = (value & (1 << 17)) != 0;
41
struct qemu_signalfd_siginfo *info);
20
s->sec_vectors[ARMV7M_EXCP_USAGE].enabled =
42
#endif
21
(value & (1 << 18)) != 0;
43
22
+ s->sec_vectors[ARMV7M_EXCP_HARD].pending = (value & (1 << 21)) != 0;
44
-int qemu_mprotect_rw(void *addr, size_t size);
23
/* SecureFault not banked, but RAZ/WI to NS */
45
-int qemu_mprotect_rwx(void *addr, size_t size);
24
s->vectors[ARMV7M_EXCP_SECURE].active = (value & (1 << 4)) != 0;
46
-int qemu_mprotect_none(void *addr, size_t size);
25
s->vectors[ARMV7M_EXCP_SECURE].enabled = (value & (1 << 19)) != 0;
47
-
48
/*
49
* Don't introduce new usage of this function, prefer the following
50
* qemu_open/qemu_create that take an "Error **errp"
51
diff --git a/tcg/region.c b/tcg/region.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/tcg/region.c
54
+++ b/tcg/region.c
55
@@ -XXX,XX +XXX,XX @@
56
#include "qemu/osdep.h"
57
#include "qemu/units.h"
58
#include "qemu/madvise.h"
59
+#include "qemu/mprotect.h"
60
#include "qapi/error.h"
61
#include "exec/exec-all.h"
62
#include "tcg/tcg.h"
63
diff --git a/util/osdep.c b/util/osdep.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/util/osdep.c
66
+++ b/util/osdep.c
67
@@ -XXX,XX +XXX,XX @@ extern int madvise(char *, size_t, int);
68
#include "qemu/sockets.h"
69
#include "qemu/error-report.h"
70
#include "qemu/madvise.h"
71
+#include "qemu/mprotect.h"
72
#include "monitor/monitor.h"
73
74
static bool fips_enabled = false;
26
--
75
--
27
2.7.4
76
2.25.1
28
77
29
78
diff view generated by jsdifflib
1
In cpu_mmu_index() we try to do this:
1
The QEMU_MAP_* constants are used only as arguments to the
2
if (env->v7m.secure) {
2
qemu_ram_mmap() function. Move them to mmap-alloc.h, where that
3
mmu_idx += ARMMMUIdx_MSUser;
3
function's prototype is defined.
4
}
5
but it will give the wrong answer, because ARMMMUIdx_MSUser
6
includes the 0x40 ARM_MMU_IDX_M field, and so does the
7
mmu_idx we're adding to, and we'll end up with 0x8n rather
8
than 0x4n. This error is then nullified by the call to
9
arm_to_core_mmu_idx() which masks out the high part, but
10
we're about to factor out the code that calculates the
11
ARMMMUIdx values so it can be used without passing it through
12
arm_to_core_mmu_idx(), so fix this bug first.
13
4
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 1506092407-26985-16-git-send-email-peter.maydell@linaro.org
8
Message-id: 20220208200856.3558249-4-peter.maydell@linaro.org
18
---
9
---
19
target/arm/cpu.h | 12 +++++++-----
10
include/qemu/mmap-alloc.h | 23 +++++++++++++++++++++++
20
1 file changed, 7 insertions(+), 5 deletions(-)
11
include/qemu/osdep.h | 25 -------------------------
12
2 files changed, 23 insertions(+), 25 deletions(-)
21
13
22
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h
23
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/cpu.h
16
--- a/include/qemu/mmap-alloc.h
25
+++ b/target/arm/cpu.h
17
+++ b/include/qemu/mmap-alloc.h
26
@@ -XXX,XX +XXX,XX @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch)
18
@@ -XXX,XX +XXX,XX @@ void *qemu_ram_mmap(int fd,
27
int el = arm_current_el(env);
19
28
20
void qemu_ram_munmap(int fd, void *ptr, size_t size);
29
if (arm_feature(env, ARM_FEATURE_M)) {
21
30
- ARMMMUIdx mmu_idx = el == 0 ? ARMMMUIdx_MUser : ARMMMUIdx_MPriv;
22
+/*
31
+ ARMMMUIdx mmu_idx;
23
+ * Abstraction of PROT_ and MAP_ flags as passed to mmap(), for example,
32
24
+ * consumed by qemu_ram_mmap().
33
- if (armv7m_nvic_neg_prio_requested(env->nvic, env->v7m.secure)) {
25
+ */
34
- mmu_idx = ARMMMUIdx_MNegPri;
26
+
35
+ if (el == 0) {
27
+/* Map PROT_READ instead of PROT_READ | PROT_WRITE. */
36
+ mmu_idx = env->v7m.secure ? ARMMMUIdx_MSUser : ARMMMUIdx_MUser;
28
+#define QEMU_MAP_READONLY (1 << 0)
37
+ } else {
29
+
38
+ mmu_idx = env->v7m.secure ? ARMMMUIdx_MSPriv : ARMMMUIdx_MPriv;
30
+/* Use MAP_SHARED instead of MAP_PRIVATE. */
39
}
31
+#define QEMU_MAP_SHARED (1 << 1)
40
32
+
41
- if (env->v7m.secure) {
33
+/*
42
- mmu_idx += ARMMMUIdx_MSUser;
34
+ * Use MAP_SYNC | MAP_SHARED_VALIDATE if supported. Ignored without
43
+ if (armv7m_nvic_neg_prio_requested(env->nvic, env->v7m.secure)) {
35
+ * QEMU_MAP_SHARED. If mapping fails, warn and fallback to !QEMU_MAP_SYNC.
44
+ mmu_idx = env->v7m.secure ? ARMMMUIdx_MSNegPri : ARMMMUIdx_MNegPri;
36
+ */
45
}
37
+#define QEMU_MAP_SYNC (1 << 2)
46
38
+
47
return arm_to_core_mmu_idx(mmu_idx);
39
+/*
40
+ * Use MAP_NORESERVE to skip reservation of swap space (or huge pages if
41
+ * applicable). Bail out if not supported/effective.
42
+ */
43
+#define QEMU_MAP_NORESERVE (1 << 3)
44
+
45
#endif
46
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/include/qemu/osdep.h
49
+++ b/include/qemu/osdep.h
50
@@ -XXX,XX +XXX,XX @@ static inline void qemu_cleanup_generic_vfree(void *p)
51
*/
52
#define QEMU_AUTO_VFREE __attribute__((cleanup(qemu_cleanup_generic_vfree)))
53
54
-/*
55
- * Abstraction of PROT_ and MAP_ flags as passed to mmap(), for example,
56
- * consumed by qemu_ram_mmap().
57
- */
58
-
59
-/* Map PROT_READ instead of PROT_READ | PROT_WRITE. */
60
-#define QEMU_MAP_READONLY (1 << 0)
61
-
62
-/* Use MAP_SHARED instead of MAP_PRIVATE. */
63
-#define QEMU_MAP_SHARED (1 << 1)
64
-
65
-/*
66
- * Use MAP_SYNC | MAP_SHARED_VALIDATE if supported. Ignored without
67
- * QEMU_MAP_SHARED. If mapping fails, warn and fallback to !QEMU_MAP_SYNC.
68
- */
69
-#define QEMU_MAP_SYNC (1 << 2)
70
-
71
-/*
72
- * Use MAP_NORESERVE to skip reservation of swap space (or huge pages if
73
- * applicable). Bail out if not supported/effective.
74
- */
75
-#define QEMU_MAP_NORESERVE (1 << 3)
76
-
77
-
78
-
79
#ifdef _WIN32
80
#define HAVE_CHARDEV_SERIAL 1
81
#elif defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
48
--
82
--
49
2.7.4
83
2.25.1
50
84
51
85
diff view generated by jsdifflib
1
In the v8M architecture, return from an exception to a PC which
1
The qemu_icache_linesize, qemu_icache_linesize_log,
2
has bit 0 set is not UNPREDICTABLE; it is defined that bit 0
2
qemu_dcache_linesize, and qemu_dcache_linesize_log variables are not
3
is discarded [R_HRJH]. Restrict our complaint about this to v7M.
3
used in many files. Move them out of osdep.h to a new
4
qemu/cacheinfo.h, and document them.
4
5
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 1506092407-26985-9-git-send-email-peter.maydell@linaro.org
9
Message-id: 20220208200856.3558249-5-peter.maydell@linaro.org
9
---
10
---
10
target/arm/helper.c | 22 +++++++++++++++-------
11
include/qemu/cacheinfo.h | 21 +++++++++++++++++++++
11
1 file changed, 15 insertions(+), 7 deletions(-)
12
include/qemu/osdep.h | 5 -----
13
accel/tcg/translate-all.c | 1 +
14
plugins/loader.c | 1 +
15
tcg/region.c | 1 +
16
tcg/tcg.c | 1 +
17
util/atomic64.c | 1 +
18
util/cacheflush.c | 1 +
19
util/cacheinfo.c | 1 +
20
9 files changed, 28 insertions(+), 5 deletions(-)
21
create mode 100644 include/qemu/cacheinfo.h
12
22
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
23
diff --git a/include/qemu/cacheinfo.h b/include/qemu/cacheinfo.h
24
new file mode 100644
25
index XXXXXXX..XXXXXXX
26
--- /dev/null
27
+++ b/include/qemu/cacheinfo.h
28
@@ -XXX,XX +XXX,XX @@
29
+/*
30
+ * QEMU host cacheinfo information
31
+ *
32
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
33
+ * See the COPYING file in the top-level directory.
34
+ */
35
+#ifndef QEMU_CACHEINFO_H
36
+#define QEMU_CACHEINFO_H
37
+
38
+/*
39
+ * These variables represent our best guess at the host icache and
40
+ * dcache sizes, expressed both as the size in bytes and as the
41
+ * base-2 log of the size in bytes. They are initialized at startup
42
+ * (via an attribute 'constructor' function).
43
+ */
44
+extern int qemu_icache_linesize;
45
+extern int qemu_icache_linesize_log;
46
+extern int qemu_dcache_linesize;
47
+extern int qemu_dcache_linesize_log;
48
+
49
+#endif
50
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
14
index XXXXXXX..XXXXXXX 100644
51
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
52
--- a/include/qemu/osdep.h
16
+++ b/target/arm/helper.c
53
+++ b/include/qemu/osdep.h
17
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
54
@@ -XXX,XX +XXX,XX @@ pid_t qemu_fork(Error **errp);
18
env->regs[12] = ldl_phys(cs->as, frameptr + 0x10);
55
extern uintptr_t qemu_real_host_page_size;
19
env->regs[14] = ldl_phys(cs->as, frameptr + 0x14);
56
extern intptr_t qemu_real_host_page_mask;
20
env->regs[15] = ldl_phys(cs->as, frameptr + 0x18);
57
21
+
58
-extern int qemu_icache_linesize;
22
+ /* Returning from an exception with a PC with bit 0 set is defined
59
-extern int qemu_icache_linesize_log;
23
+ * behaviour on v8M (bit 0 is ignored), but for v7M it was specified
60
-extern int qemu_dcache_linesize;
24
+ * to be UNPREDICTABLE. In practice actual v7M hardware seems to ignore
61
-extern int qemu_dcache_linesize_log;
25
+ * the lsbit, and there are several RTOSes out there which incorrectly
62
-
26
+ * assume the r15 in the stack frame should be a Thumb-style "lsbit
63
/*
27
+ * indicates ARM/Thumb" value, so ignore the bit on v7M as well, but
64
* After using getopt or getopt_long, if you need to parse another set
28
+ * complain about the badly behaved guest.
65
* of options, then you must reset optind. Unfortunately the way to
29
+ */
66
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
30
if (env->regs[15] & 1) {
67
index XXXXXXX..XXXXXXX 100644
31
- qemu_log_mask(LOG_GUEST_ERROR,
68
--- a/accel/tcg/translate-all.c
32
- "M profile return from interrupt with misaligned "
69
+++ b/accel/tcg/translate-all.c
33
- "PC is UNPREDICTABLE\n");
70
@@ -XXX,XX +XXX,XX @@
34
- /* Actual hardware seems to ignore the lsbit, and there are several
71
#include "qemu/qemu-print.h"
35
- * RTOSes out there which incorrectly assume the r15 in the stack
72
#include "qemu/timer.h"
36
- * frame should be a Thumb-style "lsbit indicates ARM/Thumb" value.
73
#include "qemu/main-loop.h"
37
- */
74
+#include "qemu/cacheinfo.h"
38
env->regs[15] &= ~1U;
75
#include "exec/log.h"
39
+ if (!arm_feature(env, ARM_FEATURE_V8)) {
76
#include "sysemu/cpus.h"
40
+ qemu_log_mask(LOG_GUEST_ERROR,
77
#include "sysemu/cpu-timers.h"
41
+ "M profile return from interrupt with misaligned "
78
diff --git a/plugins/loader.c b/plugins/loader.c
42
+ "PC is UNPREDICTABLE on v7M\n");
79
index XXXXXXX..XXXXXXX 100644
43
+ }
80
--- a/plugins/loader.c
44
}
81
+++ b/plugins/loader.c
45
+
82
@@ -XXX,XX +XXX,XX @@
46
xpsr = ldl_phys(cs->as, frameptr + 0x1c);
83
#include "qemu/rcu_queue.h"
47
84
#include "qemu/qht.h"
48
if (arm_feature(env, ARM_FEATURE_V8)) {
85
#include "qemu/bitmap.h"
86
+#include "qemu/cacheinfo.h"
87
#include "qemu/xxhash.h"
88
#include "qemu/plugin.h"
89
#include "hw/core/cpu.h"
90
diff --git a/tcg/region.c b/tcg/region.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/tcg/region.c
93
+++ b/tcg/region.c
94
@@ -XXX,XX +XXX,XX @@
95
#include "qemu/units.h"
96
#include "qemu/madvise.h"
97
#include "qemu/mprotect.h"
98
+#include "qemu/cacheinfo.h"
99
#include "qapi/error.h"
100
#include "exec/exec-all.h"
101
#include "tcg/tcg.h"
102
diff --git a/tcg/tcg.c b/tcg/tcg.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/tcg/tcg.c
105
+++ b/tcg/tcg.c
106
@@ -XXX,XX +XXX,XX @@
107
#include "qemu/qemu-print.h"
108
#include "qemu/timer.h"
109
#include "qemu/cacheflush.h"
110
+#include "qemu/cacheinfo.h"
111
112
/* Note: the long term plan is to reduce the dependencies on the QEMU
113
CPU definitions. Currently they are used for qemu_ld/st
114
diff --git a/util/atomic64.c b/util/atomic64.c
115
index XXXXXXX..XXXXXXX 100644
116
--- a/util/atomic64.c
117
+++ b/util/atomic64.c
118
@@ -XXX,XX +XXX,XX @@
119
#include "qemu/osdep.h"
120
#include "qemu/atomic.h"
121
#include "qemu/thread.h"
122
+#include "qemu/cacheinfo.h"
123
124
#ifdef CONFIG_ATOMIC64
125
#error This file must only be compiled if !CONFIG_ATOMIC64
126
diff --git a/util/cacheflush.c b/util/cacheflush.c
127
index XXXXXXX..XXXXXXX 100644
128
--- a/util/cacheflush.c
129
+++ b/util/cacheflush.c
130
@@ -XXX,XX +XXX,XX @@
131
132
#include "qemu/osdep.h"
133
#include "qemu/cacheflush.h"
134
+#include "qemu/cacheinfo.h"
135
#include "qemu/bitops.h"
136
137
138
diff --git a/util/cacheinfo.c b/util/cacheinfo.c
139
index XXXXXXX..XXXXXXX 100644
140
--- a/util/cacheinfo.c
141
+++ b/util/cacheinfo.c
142
@@ -XXX,XX +XXX,XX @@
143
#include "qemu/osdep.h"
144
#include "qemu/host-utils.h"
145
#include "qemu/atomic.h"
146
+#include "qemu/cacheinfo.h"
147
148
int qemu_icache_linesize = 0;
149
int qemu_icache_linesize_log;
49
--
150
--
50
2.7.4
151
2.25.1
51
152
52
153
diff view generated by jsdifflib
1
Attempting to do an exception return with an exception frame that
1
The "hardware version" machinery (qemu_set_hw_version(),
2
is not 8-aligned is UNPREDICTABLE in v8M; warn about this.
2
qemu_hw_version(), and the QEMU_HW_VERSION define) is used by fewer
3
(It is not UNPREDICTABLE in v7M, and our implementation can
3
than 10 files. Move it out from osdep.h into a new
4
handle the merely-4-aligned case fine, so we don't need to
4
qemu/hw-version.h.
5
do anything except warn.)
6
5
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 1506092407-26985-8-git-send-email-peter.maydell@linaro.org
9
Message-id: 20220208200856.3558249-6-peter.maydell@linaro.org
11
---
10
---
12
target/arm/helper.c | 7 +++++++
11
include/qemu/hw-version.h | 27 +++++++++++++++++++++++++++
13
1 file changed, 7 insertions(+)
12
include/qemu/osdep.h | 16 ----------------
13
hw/arm/nseries.c | 1 +
14
hw/ide/core.c | 1 +
15
hw/scsi/megasas.c | 1 +
16
hw/scsi/scsi-bus.c | 1 +
17
hw/scsi/scsi-disk.c | 1 +
18
softmmu/vl.c | 1 +
19
target/i386/cpu.c | 1 +
20
target/s390x/cpu_models.c | 1 +
21
util/osdep.c | 1 +
22
11 files changed, 36 insertions(+), 16 deletions(-)
23
create mode 100644 include/qemu/hw-version.h
14
24
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
25
diff --git a/include/qemu/hw-version.h b/include/qemu/hw-version.h
26
new file mode 100644
27
index XXXXXXX..XXXXXXX
28
--- /dev/null
29
+++ b/include/qemu/hw-version.h
30
@@ -XXX,XX +XXX,XX @@
31
+/*
32
+ * QEMU "hardware version" machinery
33
+ *
34
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
35
+ * See the COPYING file in the top-level directory.
36
+ */
37
+#ifndef QEMU_HW_VERSION_H
38
+#define QEMU_HW_VERSION_H
39
+
40
+/*
41
+ * Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
42
+ * instead of QEMU_VERSION, so setting hw_version on MachineClass
43
+ * is no longer mandatory.
44
+ *
45
+ * Do NOT change this string, or it will break compatibility on all
46
+ * machine classes that don't set hw_version.
47
+ */
48
+#define QEMU_HW_VERSION "2.5+"
49
+
50
+/* QEMU "hardware version" setting. Used to replace code that exposed
51
+ * QEMU_VERSION to guests in the past and need to keep compatibility.
52
+ * Do not use qemu_hw_version() in new code.
53
+ */
54
+void qemu_set_hw_version(const char *);
55
+const char *qemu_hw_version(void);
56
+
57
+#endif
58
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
16
index XXXXXXX..XXXXXXX 100644
59
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
60
--- a/include/qemu/osdep.h
18
+++ b/target/arm/helper.c
61
+++ b/include/qemu/osdep.h
19
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
62
@@ -XXX,XX +XXX,XX @@ static inline void qemu_timersub(const struct timeval *val1,
20
return_to_sp_process);
63
21
uint32_t frameptr = *frame_sp_p;
64
void qemu_set_cloexec(int fd);
22
65
23
+ if (!QEMU_IS_ALIGNED(frameptr, 8) &&
66
-/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
24
+ arm_feature(env, ARM_FEATURE_V8)) {
67
- * instead of QEMU_VERSION, so setting hw_version on MachineClass
25
+ qemu_log_mask(LOG_GUEST_ERROR,
68
- * is no longer mandatory.
26
+ "M profile exception return with non-8-aligned SP "
69
- *
27
+ "for destination state is UNPREDICTABLE\n");
70
- * Do NOT change this string, or it will break compatibility on all
28
+ }
71
- * machine classes that don't set hw_version.
29
+
72
- */
30
/* Pop registers. TODO: make these accesses use the correct
73
-#define QEMU_HW_VERSION "2.5+"
31
* attributes and address space (S/NS, priv/unpriv) and handle
74
-
32
* memory transaction failures.
75
-/* QEMU "hardware version" setting. Used to replace code that exposed
76
- * QEMU_VERSION to guests in the past and need to keep compatibility.
77
- * Do not use qemu_hw_version() in new code.
78
- */
79
-void qemu_set_hw_version(const char *);
80
-const char *qemu_hw_version(void);
81
-
82
void fips_set_state(bool requested);
83
bool fips_get_state(void);
84
85
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/hw/arm/nseries.c
88
+++ b/hw/arm/nseries.c
89
@@ -XXX,XX +XXX,XX @@
90
#include "chardev/char.h"
91
#include "qemu/cutils.h"
92
#include "qemu/bswap.h"
93
+#include "qemu/hw-version.h"
94
#include "sysemu/reset.h"
95
#include "sysemu/runstate.h"
96
#include "sysemu/sysemu.h"
97
diff --git a/hw/ide/core.c b/hw/ide/core.c
98
index XXXXXXX..XXXXXXX 100644
99
--- a/hw/ide/core.c
100
+++ b/hw/ide/core.c
101
@@ -XXX,XX +XXX,XX @@
102
#include "qemu/error-report.h"
103
#include "qemu/main-loop.h"
104
#include "qemu/timer.h"
105
+#include "qemu/hw-version.h"
106
#include "sysemu/sysemu.h"
107
#include "sysemu/blockdev.h"
108
#include "sysemu/dma.h"
109
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
110
index XXXXXXX..XXXXXXX 100644
111
--- a/hw/scsi/megasas.c
112
+++ b/hw/scsi/megasas.c
113
@@ -XXX,XX +XXX,XX @@
114
#include "hw/pci/msix.h"
115
#include "qemu/iov.h"
116
#include "qemu/module.h"
117
+#include "qemu/hw-version.h"
118
#include "hw/scsi/scsi.h"
119
#include "scsi/constants.h"
120
#include "trace.h"
121
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/hw/scsi/scsi-bus.c
124
+++ b/hw/scsi/scsi-bus.c
125
@@ -XXX,XX +XXX,XX @@
126
#include "qemu/error-report.h"
127
#include "qemu/module.h"
128
#include "qemu/option.h"
129
+#include "qemu/hw-version.h"
130
#include "hw/qdev-properties.h"
131
#include "hw/scsi/scsi.h"
132
#include "migration/qemu-file-types.h"
133
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
134
index XXXXXXX..XXXXXXX 100644
135
--- a/hw/scsi/scsi-disk.c
136
+++ b/hw/scsi/scsi-disk.c
137
@@ -XXX,XX +XXX,XX @@
138
#include "qemu/error-report.h"
139
#include "qemu/main-loop.h"
140
#include "qemu/module.h"
141
+#include "qemu/hw-version.h"
142
#include "hw/scsi/scsi.h"
143
#include "migration/qemu-file-types.h"
144
#include "migration/vmstate.h"
145
diff --git a/softmmu/vl.c b/softmmu/vl.c
146
index XXXXXXX..XXXXXXX 100644
147
--- a/softmmu/vl.c
148
+++ b/softmmu/vl.c
149
@@ -XXX,XX +XXX,XX @@
150
#include "qemu-version.h"
151
#include "qemu/cutils.h"
152
#include "qemu/help_option.h"
153
+#include "qemu/hw-version.h"
154
#include "qemu/uuid.h"
155
#include "sysemu/reset.h"
156
#include "sysemu/runstate.h"
157
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
158
index XXXXXXX..XXXXXXX 100644
159
--- a/target/i386/cpu.c
160
+++ b/target/i386/cpu.c
161
@@ -XXX,XX +XXX,XX @@
162
#include "qemu/units.h"
163
#include "qemu/cutils.h"
164
#include "qemu/qemu-print.h"
165
+#include "qemu/hw-version.h"
166
#include "cpu.h"
167
#include "tcg/helper-tcg.h"
168
#include "sysemu/reset.h"
169
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
170
index XXXXXXX..XXXXXXX 100644
171
--- a/target/s390x/cpu_models.c
172
+++ b/target/s390x/cpu_models.c
173
@@ -XXX,XX +XXX,XX @@
174
#include "qapi/error.h"
175
#include "qapi/visitor.h"
176
#include "qemu/module.h"
177
+#include "qemu/hw-version.h"
178
#include "qemu/qemu-print.h"
179
#ifndef CONFIG_USER_ONLY
180
#include "sysemu/sysemu.h"
181
diff --git a/util/osdep.c b/util/osdep.c
182
index XXXXXXX..XXXXXXX 100644
183
--- a/util/osdep.c
184
+++ b/util/osdep.c
185
@@ -XXX,XX +XXX,XX @@ extern int madvise(char *, size_t, int);
186
#include "qemu/error-report.h"
187
#include "qemu/madvise.h"
188
#include "qemu/mprotect.h"
189
+#include "qemu/hw-version.h"
190
#include "monitor/monitor.h"
191
192
static bool fips_enabled = false;
33
--
193
--
34
2.7.4
194
2.25.1
35
195
36
196
diff view generated by jsdifflib
1
Now that we can handle the CONTROL.SPSEL bit not necessarily being
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
in sync with the current stack pointer, we can restore the correct
3
security state on exception return. This happens before we start
4
to read registers off the stack frame, but after we have taken
5
possible usage faults for bad exception return magic values and
6
updated CONTROL.SPSEL.
7
2
3
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
4
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Message-id: 20220213021215.1974-1-akihiko.odaki@gmail.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 1506092407-26985-5-git-send-email-peter.maydell@linaro.org
11
---
8
---
12
target/arm/helper.c | 2 ++
9
MAINTAINERS | 2 ++
13
1 file changed, 2 insertions(+)
10
1 file changed, 2 insertions(+)
14
11
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
diff --git a/MAINTAINERS b/MAINTAINERS
16
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
14
--- a/MAINTAINERS
18
+++ b/target/arm/helper.c
15
+++ b/MAINTAINERS
19
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
16
@@ -XXX,XX +XXX,XX @@ F: audio/alsaaudio.c
20
*/
17
Core Audio framework backend
21
write_v7m_control_spsel(env, return_to_sp_process);
18
M: Gerd Hoffmann <kraxel@redhat.com>
22
19
R: Christian Schoenebeck <qemu_oss@crudebyte.com>
23
+ switch_v7m_security_state(env, return_to_secure);
20
+R: Akihiko Odaki <akihiko.odaki@gmail.com>
24
+
21
S: Odd Fixes
25
{
22
F: audio/coreaudio.c
26
/* The stack pointer we should be reading the exception frame from
23
27
* depends on bits in the magic exception return type value (and
24
@@ -XXX,XX +XXX,XX @@ F: util/drm.c
25
26
Cocoa graphics
27
M: Peter Maydell <peter.maydell@linaro.org>
28
+R: Akihiko Odaki <akihiko.odaki@gmail.com>
29
S: Odd Fixes
30
F: ui/cocoa.m
31
28
--
32
--
29
2.7.4
33
2.25.1
30
34
31
35
diff view generated by jsdifflib
1
Add support for v8M and in particular the security extension
1
From: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
2
to the exception entry code. This requires changes to:
3
* calculation of the exception-return magic LR value
4
* push the callee-saves registers in certain cases
5
* clear registers when taking non-secure exceptions to avoid
6
leaking information from the interrupted secure code
7
* switch to the correct security state on entry
8
* use the vector table for the security state we're targeting
9
2
3
A9 gtimer includes global control field and number of per-cpu fields.
4
But only per-cpu ones are migrated. This patch adds a subsection for
5
global control field migration.
6
7
Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
8
Message-id: 164422345976.2186660.1104517592452494510.stgit@pasha-ThinkPad-X280
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 1506092407-26985-13-git-send-email-peter.maydell@linaro.org
13
---
11
---
14
target/arm/helper.c | 165 +++++++++++++++++++++++++++++++++++++++++++++-------
12
hw/timer/a9gtimer.c | 21 +++++++++++++++++++++
15
1 file changed, 145 insertions(+), 20 deletions(-)
13
1 file changed, 21 insertions(+)
16
14
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/hw/timer/a9gtimer.c b/hw/timer/a9gtimer.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
17
--- a/hw/timer/a9gtimer.c
20
+++ b/target/arm/helper.c
18
+++ b/hw/timer/a9gtimer.c
21
@@ -XXX,XX +XXX,XX @@ static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode,
19
@@ -XXX,XX +XXX,XX @@ static void a9_gtimer_realize(DeviceState *dev, Error **errp)
22
}
20
}
23
}
21
}
24
22
25
-static uint32_t arm_v7m_load_vector(ARMCPU *cpu)
23
+static bool vmstate_a9_gtimer_control_needed(void *opaque)
26
+static uint32_t arm_v7m_load_vector(ARMCPU *cpu, bool targets_secure)
27
{
28
CPUState *cs = CPU(cpu);
29
CPUARMState *env = &cpu->env;
30
MemTxResult result;
31
- hwaddr vec = env->v7m.vecbase[env->v7m.secure] + env->v7m.exception * 4;
32
+ hwaddr vec = env->v7m.vecbase[targets_secure] + env->v7m.exception * 4;
33
uint32_t addr;
34
35
addr = address_space_ldl(cs->as, vec,
36
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_v7m_load_vector(ARMCPU *cpu)
37
* Since we don't model Lockup, we just report this guest error
38
* via cpu_abort().
39
*/
40
- cpu_abort(cs, "Failed to read from exception vector table "
41
- "entry %08x\n", (unsigned)vec);
42
+ cpu_abort(cs, "Failed to read from %s exception vector table "
43
+ "entry %08x\n", targets_secure ? "secure" : "nonsecure",
44
+ (unsigned)vec);
45
}
46
return addr;
47
}
48
49
-static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr)
50
+static void v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain)
51
+{
24
+{
52
+ /* For v8M, push the callee-saves register part of the stack frame.
25
+ A9GTimerState *s = opaque;
53
+ * Compare the v8M pseudocode PushCalleeStack().
26
+ return s->control != 0;
54
+ * In the tailchaining case this may not be the current stack.
55
+ */
56
+ CPUARMState *env = &cpu->env;
57
+ CPUState *cs = CPU(cpu);
58
+ uint32_t *frame_sp_p;
59
+ uint32_t frameptr;
60
+
61
+ if (dotailchain) {
62
+ frame_sp_p = get_v7m_sp_ptr(env, true,
63
+ lr & R_V7M_EXCRET_MODE_MASK,
64
+ lr & R_V7M_EXCRET_SPSEL_MASK);
65
+ } else {
66
+ frame_sp_p = &env->regs[13];
67
+ }
68
+
69
+ frameptr = *frame_sp_p - 0x28;
70
+
71
+ stl_phys(cs->as, frameptr, 0xfefa125b);
72
+ stl_phys(cs->as, frameptr + 0x8, env->regs[4]);
73
+ stl_phys(cs->as, frameptr + 0xc, env->regs[5]);
74
+ stl_phys(cs->as, frameptr + 0x10, env->regs[6]);
75
+ stl_phys(cs->as, frameptr + 0x14, env->regs[7]);
76
+ stl_phys(cs->as, frameptr + 0x18, env->regs[8]);
77
+ stl_phys(cs->as, frameptr + 0x1c, env->regs[9]);
78
+ stl_phys(cs->as, frameptr + 0x20, env->regs[10]);
79
+ stl_phys(cs->as, frameptr + 0x24, env->regs[11]);
80
+
81
+ *frame_sp_p = frameptr;
82
+}
27
+}
83
+
28
+
84
+static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain)
29
static const VMStateDescription vmstate_a9_gtimer_per_cpu = {
85
{
30
.name = "arm.cortex-a9-global-timer.percpu",
86
/* Do the "take the exception" parts of exception entry,
31
.version_id = 1,
87
* but not the pushing of state to the stack. This is
32
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_a9_gtimer_per_cpu = {
88
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr)
33
}
89
*/
34
};
90
CPUARMState *env = &cpu->env;
35
91
uint32_t addr;
36
+static const VMStateDescription vmstate_a9_gtimer_control = {
92
+ bool targets_secure;
37
+ .name = "arm.cortex-a9-global-timer.control",
38
+ .version_id = 1,
39
+ .minimum_version_id = 1,
40
+ .needed = vmstate_a9_gtimer_control_needed,
41
+ .fields = (VMStateField[]) {
42
+ VMSTATE_UINT32(control, A9GTimerState),
43
+ VMSTATE_END_OF_LIST()
44
+ }
45
+};
93
+
46
+
94
+ targets_secure = armv7m_nvic_acknowledge_irq(env->nvic);
47
static const VMStateDescription vmstate_a9_gtimer = {
95
48
.name = "arm.cortex-a9-global-timer",
96
- armv7m_nvic_acknowledge_irq(env->nvic);
49
.version_id = 1,
97
+ if (arm_feature(env, ARM_FEATURE_V8)) {
50
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_a9_gtimer = {
98
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
51
1, vmstate_a9_gtimer_per_cpu,
99
+ (lr & R_V7M_EXCRET_S_MASK)) {
52
A9GTimerPerCPU),
100
+ /* The background code (the owner of the registers in the
53
VMSTATE_END_OF_LIST()
101
+ * exception frame) is Secure. This means it may either already
54
+ },
102
+ * have or now needs to push callee-saves registers.
55
+ .subsections = (const VMStateDescription*[]) {
103
+ */
56
+ &vmstate_a9_gtimer_control,
104
+ if (targets_secure) {
57
+ NULL
105
+ if (dotailchain && !(lr & R_V7M_EXCRET_ES_MASK)) {
106
+ /* We took an exception from Secure to NonSecure
107
+ * (which means the callee-saved registers got stacked)
108
+ * and are now tailchaining to a Secure exception.
109
+ * Clear DCRS so eventual return from this Secure
110
+ * exception unstacks the callee-saved registers.
111
+ */
112
+ lr &= ~R_V7M_EXCRET_DCRS_MASK;
113
+ }
114
+ } else {
115
+ /* We're going to a non-secure exception; push the
116
+ * callee-saves registers to the stack now, if they're
117
+ * not already saved.
118
+ */
119
+ if (lr & R_V7M_EXCRET_DCRS_MASK &&
120
+ !(dotailchain && (lr & R_V7M_EXCRET_ES_MASK))) {
121
+ v7m_push_callee_stack(cpu, lr, dotailchain);
122
+ }
123
+ lr |= R_V7M_EXCRET_DCRS_MASK;
124
+ }
125
+ }
126
+
127
+ lr &= ~R_V7M_EXCRET_ES_MASK;
128
+ if (targets_secure || !arm_feature(env, ARM_FEATURE_M_SECURITY)) {
129
+ lr |= R_V7M_EXCRET_ES_MASK;
130
+ }
131
+ lr &= ~R_V7M_EXCRET_SPSEL_MASK;
132
+ if (env->v7m.control[targets_secure] & R_V7M_CONTROL_SPSEL_MASK) {
133
+ lr |= R_V7M_EXCRET_SPSEL_MASK;
134
+ }
135
+
136
+ /* Clear registers if necessary to prevent non-secure exception
137
+ * code being able to see register values from secure code.
138
+ * Where register values become architecturally UNKNOWN we leave
139
+ * them with their previous values.
140
+ */
141
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
142
+ if (!targets_secure) {
143
+ /* Always clear the caller-saved registers (they have been
144
+ * pushed to the stack earlier in v7m_push_stack()).
145
+ * Clear callee-saved registers if the background code is
146
+ * Secure (in which case these regs were saved in
147
+ * v7m_push_callee_stack()).
148
+ */
149
+ int i;
150
+
151
+ for (i = 0; i < 13; i++) {
152
+ /* r4..r11 are callee-saves, zero only if EXCRET.S == 1 */
153
+ if (i < 4 || i > 11 || (lr & R_V7M_EXCRET_S_MASK)) {
154
+ env->regs[i] = 0;
155
+ }
156
+ }
157
+ /* Clear EAPSR */
158
+ xpsr_write(env, 0, XPSR_NZCV | XPSR_Q | XPSR_GE | XPSR_IT);
159
+ }
160
+ }
161
+ }
162
+
163
+ /* Switch to target security state -- must do this before writing SPSEL */
164
+ switch_v7m_security_state(env, targets_secure);
165
write_v7m_control_spsel(env, 0);
166
arm_clear_exclusive(env);
167
/* Clear IT bits */
168
env->condexec_bits = 0;
169
env->regs[14] = lr;
170
- addr = arm_v7m_load_vector(cpu);
171
+ addr = arm_v7m_load_vector(cpu, targets_secure);
172
env->regs[15] = addr & 0xfffffffe;
173
env->thumb = addr & 1;
174
}
175
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
176
if (sfault) {
177
env->v7m.sfsr |= R_V7M_SFSR_INVER_MASK;
178
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
179
- v7m_exception_taken(cpu, excret);
180
+ v7m_exception_taken(cpu, excret, true);
181
qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing "
182
"stackframe: failed EXC_RETURN.ES validity check\n");
183
return;
184
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
185
*/
186
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK;
187
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
188
- v7m_exception_taken(cpu, excret);
189
+ v7m_exception_taken(cpu, excret, true);
190
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
191
"stackframe: failed exception return integrity check\n");
192
return;
193
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
194
/* Take a SecureFault on the current stack */
195
env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
196
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
197
- v7m_exception_taken(cpu, excret);
198
+ v7m_exception_taken(cpu, excret, true);
199
qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing "
200
"stackframe: failed exception return integrity "
201
"signature check\n");
202
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
203
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
204
env->v7m.secure);
205
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK;
206
- v7m_exception_taken(cpu, excret);
207
+ v7m_exception_taken(cpu, excret, true);
208
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
209
"stackframe: failed exception return integrity "
210
"check\n");
211
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
212
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, false);
213
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK;
214
v7m_push_stack(cpu);
215
- v7m_exception_taken(cpu, excret);
216
+ v7m_exception_taken(cpu, excret, false);
217
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on new stackframe: "
218
"failed exception return integrity check\n");
219
return;
220
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
221
return; /* Never happens. Keep compiler happy. */
222
}
58
}
223
59
};
224
- lr = R_V7M_EXCRET_RES1_MASK |
225
- R_V7M_EXCRET_S_MASK |
226
- R_V7M_EXCRET_DCRS_MASK |
227
- R_V7M_EXCRET_FTYPE_MASK |
228
- R_V7M_EXCRET_ES_MASK;
229
- if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) {
230
- lr |= R_V7M_EXCRET_SPSEL_MASK;
231
+ if (arm_feature(env, ARM_FEATURE_V8)) {
232
+ lr = R_V7M_EXCRET_RES1_MASK |
233
+ R_V7M_EXCRET_DCRS_MASK |
234
+ R_V7M_EXCRET_FTYPE_MASK;
235
+ /* The S bit indicates whether we should return to Secure
236
+ * or NonSecure (ie our current state).
237
+ * The ES bit indicates whether we're taking this exception
238
+ * to Secure or NonSecure (ie our target state). We set it
239
+ * later, in v7m_exception_taken().
240
+ * The SPSEL bit is also set in v7m_exception_taken() for v8M.
241
+ * This corresponds to the ARM ARM pseudocode for v8M setting
242
+ * some LR bits in PushStack() and some in ExceptionTaken();
243
+ * the distinction matters for the tailchain cases where we
244
+ * can take an exception without pushing the stack.
245
+ */
246
+ if (env->v7m.secure) {
247
+ lr |= R_V7M_EXCRET_S_MASK;
248
+ }
249
+ } else {
250
+ lr = R_V7M_EXCRET_RES1_MASK |
251
+ R_V7M_EXCRET_S_MASK |
252
+ R_V7M_EXCRET_DCRS_MASK |
253
+ R_V7M_EXCRET_FTYPE_MASK |
254
+ R_V7M_EXCRET_ES_MASK;
255
+ if (env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK) {
256
+ lr |= R_V7M_EXCRET_SPSEL_MASK;
257
+ }
258
}
259
if (!arm_v7m_is_handler_mode(env)) {
260
lr |= R_V7M_EXCRET_MODE_MASK;
261
}
262
263
v7m_push_stack(cpu);
264
- v7m_exception_taken(cpu, lr);
265
+ v7m_exception_taken(cpu, lr, false);
266
qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception);
267
}
268
60
269
--
61
--
270
2.7.4
62
2.25.1
271
63
272
64
diff view generated by jsdifflib
1
On exception return for v8M, the SPSEL bit in the EXC_RETURN magic
1
From: Patrick Venture <venture@google.com>
2
value should be restored to the SPSEL bit in the CONTROL register
3
banked specified by the EXC_RETURN.ES bit.
4
2
5
Add write_v7m_control_spsel_for_secstate() which behaves like
3
This is the BMC attached to the OpenBMC Mori board.
6
write_v7m_control_spsel() but allows the caller to specify which
7
CONTROL bank to use, reimplement write_v7m_control_spsel() in
8
terms of it, and use it in exception return.
9
4
5
Signed-off-by: Patrick Venture <venture@google.com>
6
Reviewed-by: Chris Rauer <crauer@google.com>
7
Reviewed-by: Ilkyun Choi <ikchoi@google.com>
8
Message-id: 20220208233104.284425-1-venture@google.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 1506092407-26985-6-git-send-email-peter.maydell@linaro.org
13
---
11
---
14
target/arm/helper.c | 40 +++++++++++++++++++++++++++-------------
12
docs/system/arm/nuvoton.rst | 1 +
15
1 file changed, 27 insertions(+), 13 deletions(-)
13
hw/arm/npcm7xx_boards.c | 32 ++++++++++++++++++++++++++++++++
14
2 files changed, 33 insertions(+)
16
15
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
18
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
18
--- a/docs/system/arm/nuvoton.rst
20
+++ b/target/arm/helper.c
19
+++ b/docs/system/arm/nuvoton.rst
21
@@ -XXX,XX +XXX,XX @@ static bool v7m_using_psp(CPUARMState *env)
20
@@ -XXX,XX +XXX,XX @@ Hyperscale applications. The following machines are based on this chip :
22
env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK;
21
- ``quanta-gbs-bmc`` Quanta GBS server BMC
22
- ``quanta-gsj`` Quanta GSJ server BMC
23
- ``kudo-bmc`` Fii USA Kudo server BMC
24
+- ``mori-bmc`` Fii USA Mori server BMC
25
26
There are also two more SoCs, NPCM710 and NPCM705, which are single-core
27
variants of NPCM750 and NPCM730, respectively. These are currently not
28
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/npcm7xx_boards.c
31
+++ b/hw/arm/npcm7xx_boards.c
32
@@ -XXX,XX +XXX,XX @@
33
#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff
34
#define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff
35
#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff
36
+#define MORI_BMC_POWER_ON_STRAPS 0x00001fff
37
38
static const char npcm7xx_default_bootrom[] = "npcm7xx_bootrom.bin";
39
40
@@ -XXX,XX +XXX,XX @@ static void kudo_bmc_init(MachineState *machine)
41
npcm7xx_load_kernel(machine, soc);
23
}
42
}
24
43
25
-/* Write to v7M CONTROL.SPSEL bit. This may change the current
44
+static void mori_bmc_init(MachineState *machine)
26
- * stack pointer between Main and Process stack pointers.
27
+/* Write to v7M CONTROL.SPSEL bit for the specified security bank.
28
+ * This may change the current stack pointer between Main and Process
29
+ * stack pointers if it is done for the CONTROL register for the current
30
+ * security state.
31
*/
32
-static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
33
+static void write_v7m_control_spsel_for_secstate(CPUARMState *env,
34
+ bool new_spsel,
35
+ bool secstate)
36
{
37
- uint32_t tmp;
38
- bool new_is_psp, old_is_psp = v7m_using_psp(env);
39
+ bool old_is_psp = v7m_using_psp(env);
40
41
- env->v7m.control[env->v7m.secure] =
42
- deposit32(env->v7m.control[env->v7m.secure],
43
+ env->v7m.control[secstate] =
44
+ deposit32(env->v7m.control[secstate],
45
R_V7M_CONTROL_SPSEL_SHIFT,
46
R_V7M_CONTROL_SPSEL_LENGTH, new_spsel);
47
48
- new_is_psp = v7m_using_psp(env);
49
+ if (secstate == env->v7m.secure) {
50
+ bool new_is_psp = v7m_using_psp(env);
51
+ uint32_t tmp;
52
53
- if (old_is_psp != new_is_psp) {
54
- tmp = env->v7m.other_sp;
55
- env->v7m.other_sp = env->regs[13];
56
- env->regs[13] = tmp;
57
+ if (old_is_psp != new_is_psp) {
58
+ tmp = env->v7m.other_sp;
59
+ env->v7m.other_sp = env->regs[13];
60
+ env->regs[13] = tmp;
61
+ }
62
}
63
}
64
65
+/* Write to v7M CONTROL.SPSEL bit. This may change the current
66
+ * stack pointer between Main and Process stack pointers.
67
+ */
68
+static void write_v7m_control_spsel(CPUARMState *env, bool new_spsel)
69
+{
45
+{
70
+ write_v7m_control_spsel_for_secstate(env, new_spsel, env->v7m.secure);
46
+ NPCM7xxState *soc;
47
+
48
+ soc = npcm7xx_create_soc(machine, MORI_BMC_POWER_ON_STRAPS);
49
+ npcm7xx_connect_dram(soc, machine->ram);
50
+ qdev_realize(DEVICE(soc), NULL, &error_fatal);
51
+
52
+ npcm7xx_load_bootrom(machine, soc);
53
+ npcm7xx_connect_flash(&soc->fiu[1], 0, "mx66u51235f",
54
+ drive_get(IF_MTD, 3, 0));
55
+
56
+ npcm7xx_load_kernel(machine, soc);
71
+}
57
+}
72
+
58
+
73
void write_v7m_exception(CPUARMState *env, uint32_t new_exc)
59
static void npcm7xx_set_soc_type(NPCM7xxMachineClass *nmc, const char *type)
74
{
60
{
75
/* Write a new value to v7m.exception, thus transitioning into or out
61
NPCM7xxClass *sc = NPCM7XX_CLASS(object_class_by_name(type));
76
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
62
@@ -XXX,XX +XXX,XX @@ static void kudo_bmc_machine_class_init(ObjectClass *oc, void *data)
77
* Handler mode (and will be until we write the new XPSR.Interrupt
63
mc->default_ram_size = 1 * GiB;
78
* field) this does not switch around the current stack pointer.
64
};
79
*/
65
80
- write_v7m_control_spsel(env, return_to_sp_process);
66
+static void mori_bmc_machine_class_init(ObjectClass *oc, void *data)
81
+ write_v7m_control_spsel_for_secstate(env, return_to_sp_process, exc_secure);
67
+{
82
68
+ NPCM7xxMachineClass *nmc = NPCM7XX_MACHINE_CLASS(oc);
83
switch_v7m_security_state(env, return_to_secure);
69
+ MachineClass *mc = MACHINE_CLASS(oc);
70
+
71
+ npcm7xx_set_soc_type(nmc, TYPE_NPCM730);
72
+
73
+ mc->desc = "Mori BMC (Cortex-A9)";
74
+ mc->init = mori_bmc_init;
75
+ mc->default_ram_size = 1 * GiB;
76
+}
77
+
78
static const TypeInfo npcm7xx_machine_types[] = {
79
{
80
.name = TYPE_NPCM7XX_MACHINE,
81
@@ -XXX,XX +XXX,XX @@ static const TypeInfo npcm7xx_machine_types[] = {
82
.name = MACHINE_TYPE_NAME("kudo-bmc"),
83
.parent = TYPE_NPCM7XX_MACHINE,
84
.class_init = kudo_bmc_machine_class_init,
85
+ }, {
86
+ .name = MACHINE_TYPE_NAME("mori-bmc"),
87
+ .parent = TYPE_NPCM7XX_MACHINE,
88
+ .class_init = mori_bmc_machine_class_init,
89
},
90
};
84
91
85
--
92
--
86
2.7.4
93
2.25.1
87
94
88
95
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
2
3
setAllowedFileTypes is deprecated in macOS 12.
4
5
Per Akihiko Odaki [*]:
6
7
An image file, which is being chosen by the panel, can be a
8
raw file and have a variety of file extensions and many are not
9
covered by the provided list (e.g. "udf"). Other platforms like
10
GTK can provide an option to open a file with an extension not
11
listed, but Cocoa can't. It forces the user to rename the file
12
to give an extension in the list. Moreover, Cocoa does not tell
13
which extensions are in the list so the user needs to read the
14
source code, which is pretty bad.
15
16
Since this code is harming the usability rather than improving it,
17
simply remove the [NSSavePanel allowedFileTypes:] call, fixing:
18
19
[2789/6622] Compiling Objective-C object libcommon.fa.p/ui_cocoa.m.o
20
ui/cocoa.m:1411:16: error: 'setAllowedFileTypes:' is deprecated: first deprecated in macOS 12.0 - Use -allowedContentTypes instead [-Werror,-Wdeprecated-declarations]
21
[openPanel setAllowedFileTypes: supportedImageFileTypes];
22
^
23
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: property 'allowedFileTypes' is declared deprecated here
24
@property (nullable, copy) NSArray<NSString *> *allowedFileTypes API_DEPRECATED("Use -allowedContentTypes instead", macos(10.3,12.0));
25
^
26
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSavePanel.h:215:49: note: 'setAllowedFileTypes:' has been explicitly marked deprecated here
27
FAILED: libcommon.fa.p/ui_cocoa.m.o
28
29
[*] https://lore.kernel.org/qemu-devel/4dde2e66-63cb-4390-9538-c032310db3e3@gmail.com/
30
31
Suggested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
32
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
33
Tested-by: Roman Bolshakov <r.bolshakov@yadro.com>
34
Reviewed-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
35
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
36
Message-id: 20220215080307.69550-11-f4bug@amsat.org
37
Reviewed by: Cameron Esfahani <dirty@apple.com>
38
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
39
Tested-by: Akihiko Odaki <akihiko.odaki@gmail.com>
40
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
41
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
42
---
43
ui/cocoa.m | 6 ------
44
1 file changed, 6 deletions(-)
45
46
diff --git a/ui/cocoa.m b/ui/cocoa.m
47
index XXXXXXX..XXXXXXX 100644
48
--- a/ui/cocoa.m
49
+++ b/ui/cocoa.m
50
@@ -XXX,XX +XXX,XX @@ static int gArgc;
51
static char **gArgv;
52
static bool stretch_video;
53
static NSTextField *pauseLabel;
54
-static NSArray * supportedImageFileTypes;
55
56
static QemuSemaphore display_init_sem;
57
static QemuSemaphore app_started_sem;
58
@@ -XXX,XX +XXX,XX @@ QemuCocoaView *cocoaView;
59
[pauseLabel setTextColor: [NSColor blackColor]];
60
[pauseLabel sizeToFit];
61
62
- // set the supported image file types that can be opened
63
- supportedImageFileTypes = [NSArray arrayWithObjects: @"img", @"iso", @"dmg",
64
- @"qcow", @"qcow2", @"cloop", @"vmdk", @"cdr",
65
- @"toast", nil];
66
[self make_about_window];
67
}
68
return self;
69
@@ -XXX,XX +XXX,XX @@ QemuCocoaView *cocoaView;
70
openPanel = [NSOpenPanel openPanel];
71
[openPanel setCanChooseFiles: YES];
72
[openPanel setAllowsMultipleSelection: NO];
73
- [openPanel setAllowedFileTypes: supportedImageFileTypes];
74
if([openPanel runModal] == NSModalResponseOK) {
75
NSString * file = [[[openPanel URLs] objectAtIndex: 0] path];
76
if(file == nil) {
77
--
78
2.25.1
79
80
diff view generated by jsdifflib
1
From: Michael Olbrich <m.olbrich@pengutronix.de>
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
2
3
The current code checks if the next block exceeds the size of the card.
3
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
4
This generates an error while reading the last block of the card.
4
Message-id: 20220215080307.69550-13-f4bug@amsat.org
5
Do the out-of-bounds check when starting to read a new block to fix this.
5
Message-Id: <20220213021418.2155-1-akihiko.odaki@gmail.com>
6
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
This issue became visible with increased error checking in Linux 4.13.
8
9
Cc: qemu-stable@nongnu.org
10
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
11
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
12
Message-id: 20170916091611.10241-1-m.olbrich@pengutronix.de
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
8
---
15
hw/sd/sd.c | 12 ++++++------
9
ui/cocoa.m | 5 -----
16
1 file changed, 6 insertions(+), 6 deletions(-)
10
1 file changed, 5 deletions(-)
17
11
18
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
12
diff --git a/ui/cocoa.m b/ui/cocoa.m
19
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/sd/sd.c
14
--- a/ui/cocoa.m
21
+++ b/hw/sd/sd.c
15
+++ b/ui/cocoa.m
22
@@ -XXX,XX +XXX,XX @@ uint8_t sd_read_data(SDState *sd)
16
@@ -XXX,XX +XXX,XX @@ static void addRemovableDevicesMenuItems(void)
23
break;
17
24
18
currentDevice = qmp_query_block(NULL);
25
case 18:    /* CMD18: READ_MULTIPLE_BLOCK */
19
pointerToFree = currentDevice;
26
- if (sd->data_offset == 0)
20
- if(currentDevice == NULL) {
27
+ if (sd->data_offset == 0) {
21
- NSBeep();
28
+ if (sd->data_start + io_len > sd->size) {
22
- QEMU_Alert(@"Failed to query for block devices!");
29
+ sd->card_status |= ADDRESS_ERROR;
23
- return;
30
+ return 0x00;
24
- }
31
+ }
25
32
BLK_READ_BLOCK(sd->data_start, io_len);
26
menu = [[[NSApp mainMenu] itemWithTitle:@"Machine"] submenu];
33
+ }
34
ret = sd->data[sd->data_offset ++];
35
36
if (sd->data_offset >= io_len) {
37
@@ -XXX,XX +XXX,XX @@ uint8_t sd_read_data(SDState *sd)
38
break;
39
}
40
}
41
-
42
- if (sd->data_start + io_len > sd->size) {
43
- sd->card_status |= ADDRESS_ERROR;
44
- break;
45
- }
46
}
47
break;
48
27
49
--
28
--
50
2.7.4
29
2.25.1
51
30
52
31
diff view generated by jsdifflib
1
From: Thomas Huth <thuth@redhat.com>
1
From: Akihiko Odaki <akihiko.odaki@gmail.com>
2
2
3
The device uses serial_hds in its realize function and thus can't be
3
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
4
used twice. Apart from that, the comma in its name makes it quite hard
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
to use for the user anyway, since a comma is normally used to separate
5
Message-id: 20220215080307.69550-14-f4bug@amsat.org
6
the device name from its properties when using the "-device" parameter
6
Message-Id: <20220213021329.2066-1-akihiko.odaki@gmail.com>
7
or the "device_add" HMP command.
7
[PMD: Use g_autofree, suggested by Zoltan BALATON]
8
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Thomas Huth <thuth@redhat.com>
10
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
11
Message-id: 1506441116-16627-1-git-send-email-thuth@redhat.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
10
---
14
hw/arm/xlnx-zynqmp.c | 2 ++
11
ui/cocoa.m | 4 +++-
15
1 file changed, 2 insertions(+)
12
1 file changed, 3 insertions(+), 1 deletion(-)
16
13
17
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
14
diff --git a/ui/cocoa.m b/ui/cocoa.m
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/xlnx-zynqmp.c
16
--- a/ui/cocoa.m
20
+++ b/hw/arm/xlnx-zynqmp.c
17
+++ b/ui/cocoa.m
21
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_class_init(ObjectClass *oc, void *data)
18
@@ -XXX,XX +XXX,XX @@ static void create_initial_menus(void)
22
19
/* Returns a name for a given console */
23
dc->props = xlnx_zynqmp_props;
20
static NSString * getConsoleName(QemuConsole * console)
24
dc->realize = xlnx_zynqmp_realize;
21
{
25
+ /* Reason: Uses serial_hds in realize function, thus can't be used twice */
22
- return [NSString stringWithFormat: @"%s", qemu_console_get_label(console)];
26
+ dc->user_creatable = false;
23
+ g_autofree char *label = qemu_console_get_label(console);
24
+
25
+ return [NSString stringWithUTF8String:label];
27
}
26
}
28
27
29
static const TypeInfo xlnx_zynqmp_type_info = {
28
/* Add an entry to the View menu for each console */
30
--
29
--
31
2.7.4
30
2.25.1
32
31
33
32
diff view generated by jsdifflib