1
Arm pullreq: Rémi's ARMv8.4-SEL2 support is the big thing here.
1
The following changes since commit b11728dc3ae67ddedf34b7a4f318170e7092803c:
2
2
3
thanks
3
Merge tag 'pull-riscv-to-apply-20230224' of github.com:palmer-dabbelt/qemu into staging (2023-02-26 20:14:46 +0000)
4
-- PMM
5
6
The following changes since commit f1fcb6851aba6dd9838886dc179717a11e344a1c:
7
8
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2021-01-19' into staging (2021-01-19 11:57:07 +0000)
9
4
10
are available in the Git repository at:
5
are available in the Git repository at:
11
6
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210119
7
https://git.linaro.org/people/pmaydell/qemu-arm.git pull-target-arm-20230227
13
8
14
for you to fetch changes up to 6d39956891b3d1857af84f72f0230a6d99eb3b6a:
9
for you to fetch changes up to e844f0c5d0bd2c4d8d3c1622eb2a88586c9c4677:
15
10
16
docs: Build and install all the docs in a single manual (2021-01-19 14:38:53 +0000)
11
hw: Replace qemu_or_irq typedef by OrIRQState (2023-02-27 13:27:05 +0000)
17
12
18
----------------------------------------------------------------
13
----------------------------------------------------------------
19
target-arm queue:
14
target-arm queue:
20
* Implement IMPDEF pauth algorithm
15
* Various code cleanups
21
* Support ARMv8.4-SEL2
16
* More refactoring working towards allowing a build
22
* Fix bug where we were truncating predicate vector lengths in SVE insns
17
without CONFIG_TCG
23
* Implement new pvpanic-pci device
24
* npcm7xx_adc-test: Fix memleak in adc_qom_set
25
* target/arm/m_helper: Silence GCC 10 maybe-uninitialized error
26
* docs: Build and install all the docs in a single manual
27
18
28
----------------------------------------------------------------
19
----------------------------------------------------------------
29
Gan Qixin (1):
20
Claudio Fontana (2):
30
npcm7xx_adc-test: Fix memleak in adc_qom_set
21
target/arm: move helpers to tcg/
22
target/arm: Move psci.c into the tcg directory
31
23
32
Mihai Carabas (4):
24
Fabiano Rosas (9):
33
hw/misc/pvpanic: split-out generic and bus dependent code
25
target/arm: Wrap breakpoint/watchpoint updates with tcg_enabled
34
hw/misc/pvpanic: add PCI interface support
26
target/arm: Wrap TCG-only code in debug_helper.c
35
pvpanic : update pvpanic spec document
27
target/arm: move translate modules to tcg/
36
tests/qtest: add a test case for pvpanic-pci
28
target/arm: Wrap arm_rebuild_hflags calls with tcg_enabled
29
target/arm: Move hflags code into the tcg directory
30
target/arm: Move regime_using_lpae_format into internal.h
31
target/arm: Don't access TCG code when debugging with KVM
32
cpu-defs.h: Expose CPUTLBEntryFull to non-TCG code
33
tests/avocado: add machine:none tag to version.py
37
34
38
Peter Maydell (1):
35
Philippe Mathieu-Daudé (13):
39
docs: Build and install all the docs in a single manual
36
hw/gpio/max7310: Simplify max7310_realize()
37
hw/char/pl011: Un-inline pl011_create()
38
hw/char/pl011: Open-code pl011_luminary_create()
39
hw/char/xilinx_uartlite: Expose XILINX_UARTLITE QOM type
40
hw/char/xilinx_uartlite: Open-code xilinx_uartlite_create()
41
hw/char/cmsdk-apb-uart: Open-code cmsdk_apb_uart_create()
42
hw/timer/cmsdk-apb-timer: Remove unused 'qdev-properties.h' header
43
hw/intc/armv7m_nvic: Use QOM cast CPU() macro
44
hw/arm/musicpal: Remove unused dummy MemoryRegion
45
iothread: Remove unused IOThreadClass / IOTHREAD_CLASS
46
hw/irq: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE()
47
hw/or-irq: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE()
48
hw: Replace qemu_or_irq typedef by OrIRQState
40
49
41
Philippe Mathieu-Daudé (1):
50
Thomas Huth (1):
42
target/arm/m_helper: Silence GCC 10 maybe-uninitialized error
51
include/hw/arm/allwinner-a10.h: Remove superfluous includes from the header
43
52
44
Richard Henderson (7):
53
MAINTAINERS | 1 +
45
target/arm: Implement an IMPDEF pauth algorithm
54
include/exec/cpu-defs.h | 6 +
46
target/arm: Add cpu properties to control pauth
55
include/hw/arm/allwinner-a10.h | 2 -
47
target/arm: Use object_property_add_bool for "sve" property
56
include/hw/arm/armsse.h | 6 +-
48
target/arm: Introduce PREDDESC field definitions
57
include/hw/arm/bcm2835_peripherals.h | 2 +-
49
target/arm: Update PFIRST, PNEXT for pred_desc
58
include/hw/arm/exynos4210.h | 4 +-
50
target/arm: Update ZIP, UZP, TRN for pred_desc
59
include/hw/arm/stm32f205_soc.h | 2 +-
51
target/arm: Update REV, PUNPK for pred_desc
60
include/hw/arm/stm32f405_soc.h | 2 +-
61
include/hw/arm/xlnx-versal.h | 6 +-
62
include/hw/arm/xlnx-zynqmp.h | 2 +-
63
include/hw/char/cmsdk-apb-uart.h | 34 ---
64
include/hw/char/pl011.h | 36 +--
65
include/hw/char/xilinx_uartlite.h | 22 +-
66
include/hw/or-irq.h | 5 +-
67
include/hw/timer/cmsdk-apb-timer.h | 1 -
68
target/arm/internals.h | 23 +-
69
target/arm/{ => tcg}/translate-a64.h | 0
70
target/arm/{ => tcg}/translate.h | 0
71
target/arm/{ => tcg}/vec_internal.h | 0
72
target/arm/{ => tcg}/a32-uncond.decode | 0
73
target/arm/{ => tcg}/a32.decode | 0
74
target/arm/{ => tcg}/m-nocp.decode | 0
75
target/arm/{ => tcg}/mve.decode | 0
76
target/arm/{ => tcg}/neon-dp.decode | 0
77
target/arm/{ => tcg}/neon-ls.decode | 0
78
target/arm/{ => tcg}/neon-shared.decode | 0
79
target/arm/{ => tcg}/sme-fa64.decode | 0
80
target/arm/{ => tcg}/sme.decode | 0
81
target/arm/{ => tcg}/sve.decode | 0
82
target/arm/{ => tcg}/t16.decode | 0
83
target/arm/{ => tcg}/t32.decode | 0
84
target/arm/{ => tcg}/vfp-uncond.decode | 0
85
target/arm/{ => tcg}/vfp.decode | 0
86
hw/arm/allwinner-a10.c | 1 +
87
hw/arm/boot.c | 6 +-
88
hw/arm/exynos4210.c | 4 +-
89
hw/arm/mps2-tz.c | 2 +-
90
hw/arm/mps2.c | 41 ++-
91
hw/arm/musicpal.c | 4 -
92
hw/arm/stellaris.c | 11 +-
93
hw/char/pl011.c | 17 ++
94
hw/char/xilinx_uartlite.c | 4 +-
95
hw/core/irq.c | 9 +-
96
hw/core/or-irq.c | 18 +-
97
hw/gpio/max7310.c | 5 +-
98
hw/intc/armv7m_nvic.c | 26 +-
99
hw/microblaze/petalogix_s3adsp1800_mmu.c | 7 +-
100
hw/pci-host/raven.c | 2 +-
101
iothread.c | 4 -
102
target/arm/arm-powerctl.c | 7 +-
103
target/arm/cpu.c | 9 +-
104
target/arm/debug_helper.c | 490 ++++++++++++++++---------------
105
target/arm/helper.c | 411 +-------------------------
106
target/arm/machine.c | 12 +-
107
target/arm/ptw.c | 4 +
108
target/arm/tcg-stubs.c | 27 ++
109
target/arm/{ => tcg}/crypto_helper.c | 0
110
target/arm/{ => tcg}/helper-a64.c | 0
111
target/arm/tcg/hflags.c | 403 +++++++++++++++++++++++++
112
target/arm/{ => tcg}/iwmmxt_helper.c | 0
113
target/arm/{ => tcg}/m_helper.c | 0
114
target/arm/{ => tcg}/mte_helper.c | 0
115
target/arm/{ => tcg}/mve_helper.c | 0
116
target/arm/{ => tcg}/neon_helper.c | 0
117
target/arm/{ => tcg}/op_helper.c | 0
118
target/arm/{ => tcg}/pauth_helper.c | 0
119
target/arm/{ => tcg}/psci.c | 0
120
target/arm/{ => tcg}/sme_helper.c | 0
121
target/arm/{ => tcg}/sve_helper.c | 0
122
target/arm/{ => tcg}/tlb_helper.c | 18 --
123
target/arm/{ => tcg}/translate-a64.c | 0
124
target/arm/{ => tcg}/translate-m-nocp.c | 0
125
target/arm/{ => tcg}/translate-mve.c | 0
126
target/arm/{ => tcg}/translate-neon.c | 0
127
target/arm/{ => tcg}/translate-sme.c | 0
128
target/arm/{ => tcg}/translate-sve.c | 0
129
target/arm/{ => tcg}/translate-vfp.c | 0
130
target/arm/{ => tcg}/translate.c | 0
131
target/arm/{ => tcg}/vec_helper.c | 0
132
target/arm/meson.build | 46 +--
133
target/arm/tcg/meson.build | 50 ++++
134
tests/avocado/version.py | 1 +
135
82 files changed, 918 insertions(+), 875 deletions(-)
136
rename target/arm/{ => tcg}/translate-a64.h (100%)
137
rename target/arm/{ => tcg}/translate.h (100%)
138
rename target/arm/{ => tcg}/vec_internal.h (100%)
139
rename target/arm/{ => tcg}/a32-uncond.decode (100%)
140
rename target/arm/{ => tcg}/a32.decode (100%)
141
rename target/arm/{ => tcg}/m-nocp.decode (100%)
142
rename target/arm/{ => tcg}/mve.decode (100%)
143
rename target/arm/{ => tcg}/neon-dp.decode (100%)
144
rename target/arm/{ => tcg}/neon-ls.decode (100%)
145
rename target/arm/{ => tcg}/neon-shared.decode (100%)
146
rename target/arm/{ => tcg}/sme-fa64.decode (100%)
147
rename target/arm/{ => tcg}/sme.decode (100%)
148
rename target/arm/{ => tcg}/sve.decode (100%)
149
rename target/arm/{ => tcg}/t16.decode (100%)
150
rename target/arm/{ => tcg}/t32.decode (100%)
151
rename target/arm/{ => tcg}/vfp-uncond.decode (100%)
152
rename target/arm/{ => tcg}/vfp.decode (100%)
153
create mode 100644 target/arm/tcg-stubs.c
154
rename target/arm/{ => tcg}/crypto_helper.c (100%)
155
rename target/arm/{ => tcg}/helper-a64.c (100%)
156
create mode 100644 target/arm/tcg/hflags.c
157
rename target/arm/{ => tcg}/iwmmxt_helper.c (100%)
158
rename target/arm/{ => tcg}/m_helper.c (100%)
159
rename target/arm/{ => tcg}/mte_helper.c (100%)
160
rename target/arm/{ => tcg}/mve_helper.c (100%)
161
rename target/arm/{ => tcg}/neon_helper.c (100%)
162
rename target/arm/{ => tcg}/op_helper.c (100%)
163
rename target/arm/{ => tcg}/pauth_helper.c (100%)
164
rename target/arm/{ => tcg}/psci.c (100%)
165
rename target/arm/{ => tcg}/sme_helper.c (100%)
166
rename target/arm/{ => tcg}/sve_helper.c (100%)
167
rename target/arm/{ => tcg}/tlb_helper.c (94%)
168
rename target/arm/{ => tcg}/translate-a64.c (100%)
169
rename target/arm/{ => tcg}/translate-m-nocp.c (100%)
170
rename target/arm/{ => tcg}/translate-mve.c (100%)
171
rename target/arm/{ => tcg}/translate-neon.c (100%)
172
rename target/arm/{ => tcg}/translate-sme.c (100%)
173
rename target/arm/{ => tcg}/translate-sve.c (100%)
174
rename target/arm/{ => tcg}/translate-vfp.c (100%)
175
rename target/arm/{ => tcg}/translate.c (100%)
176
rename target/arm/{ => tcg}/vec_helper.c (100%)
177
create mode 100644 target/arm/tcg/meson.build
52
178
53
Rémi Denis-Courmont (19):
54
target/arm: remove redundant tests
55
target/arm: add arm_is_el2_enabled() helper
56
target/arm: use arm_is_el2_enabled() where applicable
57
target/arm: use arm_hcr_el2_eff() where applicable
58
target/arm: factor MDCR_EL2 common handling
59
target/arm: Define isar_feature function to test for presence of SEL2
60
target/arm: add 64-bit S-EL2 to EL exception table
61
target/arm: add MMU stage 1 for Secure EL2
62
target/arm: add ARMv8.4-SEL2 system registers
63
target/arm: handle VMID change in secure state
64
target/arm: do S1_ptw_translate() before address space lookup
65
target/arm: translate NS bit in page-walks
66
target/arm: generalize 2-stage page-walk condition
67
target/arm: secure stage 2 translation regime
68
target/arm: set HPFAR_EL2.NS on secure stage 2 faults
69
target/arm: revector to run-time pick target EL
70
target/arm: Implement SCR_EL2.EEL2
71
target/arm: enable Secure EL2 in max CPU
72
target/arm: refactor vae1_tlbmask()
73
74
docs/conf.py | 46 ++++-
75
docs/devel/conf.py | 15 --
76
docs/index.html.in | 17 --
77
docs/interop/conf.py | 28 ---
78
docs/meson.build | 64 +++---
79
docs/specs/conf.py | 16 --
80
docs/specs/pci-ids.txt | 1 +
81
docs/specs/pvpanic.txt | 13 +-
82
docs/system/arm/cpu-features.rst | 21 ++
83
docs/system/conf.py | 28 ---
84
docs/tools/conf.py | 37 ----
85
docs/user/conf.py | 15 --
86
include/hw/misc/pvpanic.h | 24 ++-
87
include/hw/pci/pci.h | 1 +
88
include/qemu/xxhash.h | 98 +++++++++
89
target/arm/cpu-param.h | 2 +-
90
target/arm/cpu.h | 107 ++++++++--
91
target/arm/internals.h | 45 +++++
92
hw/misc/pvpanic-isa.c | 94 +++++++++
93
hw/misc/pvpanic-pci.c | 95 +++++++++
94
hw/misc/pvpanic.c | 85 +-------
95
target/arm/cpu.c | 23 ++-
96
target/arm/cpu64.c | 65 ++++--
97
target/arm/helper-a64.c | 8 +-
98
target/arm/helper.c | 414 ++++++++++++++++++++++++++-------------
99
target/arm/m_helper.c | 2 +-
100
target/arm/monitor.c | 1 +
101
target/arm/op_helper.c | 4 +-
102
target/arm/pauth_helper.c | 27 ++-
103
target/arm/sve_helper.c | 33 ++--
104
target/arm/tlb_helper.c | 3 +
105
target/arm/translate-a64.c | 4 +
106
target/arm/translate-sve.c | 31 ++-
107
target/arm/translate.c | 36 +++-
108
tests/qtest/arm-cpu-features.c | 13 ++
109
tests/qtest/npcm7xx_adc-test.c | 1 +
110
tests/qtest/pvpanic-pci-test.c | 62 ++++++
111
.gitlab-ci.yml | 4 +-
112
hw/i386/Kconfig | 2 +-
113
hw/misc/Kconfig | 12 +-
114
hw/misc/meson.build | 4 +-
115
tests/qtest/meson.build | 3 +-
116
42 files changed, 1080 insertions(+), 524 deletions(-)
117
delete mode 100644 docs/devel/conf.py
118
delete mode 100644 docs/index.html.in
119
delete mode 100644 docs/interop/conf.py
120
delete mode 100644 docs/specs/conf.py
121
delete mode 100644 docs/system/conf.py
122
delete mode 100644 docs/tools/conf.py
123
delete mode 100644 docs/user/conf.py
124
create mode 100644 hw/misc/pvpanic-isa.c
125
create mode 100644 hw/misc/pvpanic-pci.c
126
create mode 100644 tests/qtest/pvpanic-pci-test.c
127
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
When building with GCC 10.2 configured with --extra-cflags=-Os, we get:
3
pci_device.h is not needed at all in allwinner-a10.h, and serial.h
4
is only needed by the corresponding .c file.
4
5
5
target/arm/m_helper.c: In function ‘arm_v7m_cpu_do_interrupt’:
6
Signed-off-by: Thomas Huth <thuth@redhat.com>
6
target/arm/m_helper.c:1811:16: error: ‘restore_s16_s31’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
1811 | if (restore_s16_s31) {
8
Message-id: 20230215152233.210024-1-thuth@redhat.com
8
| ^
9
target/arm/m_helper.c:1350:10: note: ‘restore_s16_s31’ was declared here
10
1350 | bool restore_s16_s31;
11
| ^~~~~~~~~~~~~~~
12
cc1: all warnings being treated as errors
13
14
Initialize the 'restore_s16_s31' variable to silence the warning.
15
16
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20210119062739.589049-1-f4bug@amsat.org
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
10
---
21
target/arm/m_helper.c | 2 +-
11
include/hw/arm/allwinner-a10.h | 2 --
22
1 file changed, 1 insertion(+), 1 deletion(-)
12
hw/arm/allwinner-a10.c | 1 +
13
2 files changed, 1 insertion(+), 2 deletions(-)
23
14
24
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
15
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
25
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/m_helper.c
17
--- a/include/hw/arm/allwinner-a10.h
27
+++ b/target/arm/m_helper.c
18
+++ b/include/hw/arm/allwinner-a10.h
28
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
19
@@ -XXX,XX +XXX,XX @@
29
bool exc_secure = false;
20
#ifndef HW_ARM_ALLWINNER_A10_H
30
bool return_to_secure;
21
#define HW_ARM_ALLWINNER_A10_H
31
bool ftype;
22
32
- bool restore_s16_s31;
23
-#include "hw/char/serial.h"
33
+ bool restore_s16_s31 = false;
24
#include "hw/arm/boot.h"
34
25
-#include "hw/pci/pci_device.h"
35
/*
26
#include "hw/timer/allwinner-a10-pit.h"
36
* If we're not in Handler mode then jumps to magic exception-exit
27
#include "hw/intc/allwinner-a10-pic.h"
28
#include "hw/net/allwinner_emac.h"
29
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/allwinner-a10.c
32
+++ b/hw/arm/allwinner-a10.c
33
@@ -XXX,XX +XXX,XX @@
34
#include "qemu/osdep.h"
35
#include "qapi/error.h"
36
#include "qemu/module.h"
37
+#include "hw/char/serial.h"
38
#include "hw/sysbus.h"
39
#include "hw/arm/allwinner-a10.h"
40
#include "hw/misc/unimp.h"
37
--
41
--
38
2.20.1
42
2.34.1
39
43
40
44
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
In this context, the HCR value is the effective value, and thus is
3
This is in preparation for restricting compilation of some parts of
4
zero in secure mode. The tests for HCR.{F,I}MO are sufficient.
4
debug_helper.c to TCG only.
5
5
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210112104511.36576-1-remi.denis.courmont@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
9
---
11
target/arm/cpu.c | 8 ++++----
10
target/arm/cpu.c | 6 ++++--
12
target/arm/helper.c | 10 ++++------
11
target/arm/debug_helper.c | 16 ++++++++++++----
13
2 files changed, 8 insertions(+), 10 deletions(-)
12
target/arm/machine.c | 7 +++++--
13
3 files changed, 21 insertions(+), 8 deletions(-)
14
14
15
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
15
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.c
17
--- a/target/arm/cpu.c
18
+++ b/target/arm/cpu.c
18
+++ b/target/arm/cpu.c
19
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj)
20
break;
20
}
21
21
#endif
22
case EXCP_VFIQ:
22
23
- if (secure || !(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) {
23
- hw_breakpoint_update_all(cpu);
24
- /* VFIQs are only taken when hypervized and non-secure. */
24
- hw_watchpoint_update_all(cpu);
25
+ if (!(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) {
25
+ if (tcg_enabled()) {
26
+ /* VFIQs are only taken when hypervized. */
26
+ hw_breakpoint_update_all(cpu);
27
return false;
27
+ hw_watchpoint_update_all(cpu);
28
}
28
+ }
29
return !(env->daif & PSTATE_F);
29
arm_rebuild_hflags(env);
30
case EXCP_VIRQ:
30
}
31
- if (secure || !(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) {
31
32
- /* VIRQs are only taken when hypervized and non-secure. */
32
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
33
+ if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) {
34
+ /* VIRQs are only taken when hypervized. */
35
return false;
36
}
37
return !(env->daif & PSTATE_I);
38
diff --git a/target/arm/helper.c b/target/arm/helper.c
39
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/helper.c
34
--- a/target/arm/debug_helper.c
41
+++ b/target/arm/helper.c
35
+++ b/target/arm/debug_helper.c
42
@@ -XXX,XX +XXX,XX @@ static void csselr_write(CPUARMState *env, const ARMCPRegInfo *ri,
36
@@ -XXX,XX +XXX,XX @@ static void dbgwvr_write(CPUARMState *env, const ARMCPRegInfo *ri,
43
static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
37
value &= ~3ULL;
44
{
38
45
CPUState *cs = env_cpu(env);
39
raw_write(env, ri, value);
46
- uint64_t hcr_el2 = arm_hcr_el2_eff(env);
40
- hw_watchpoint_update(cpu, i);
47
+ bool el1 = arm_current_el(env) == 1;
41
+ if (tcg_enabled()) {
48
+ uint64_t hcr_el2 = el1 ? arm_hcr_el2_eff(env) : 0;
42
+ hw_watchpoint_update(cpu, i);
49
uint64_t ret = 0;
43
+ }
50
- bool allow_virt = (arm_current_el(env) == 1 &&
44
}
51
- (!arm_is_secure_below_el3(env) ||
45
52
- (env->cp15.scr_el3 & SCR_EEL2)));
46
static void dbgwcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
53
47
@@ -XXX,XX +XXX,XX @@ static void dbgwcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
54
- if (allow_virt && (hcr_el2 & HCR_IMO)) {
48
int i = ri->crm;
55
+ if (hcr_el2 & HCR_IMO) {
49
56
if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) {
50
raw_write(env, ri, value);
57
ret |= CPSR_I;
51
- hw_watchpoint_update(cpu, i);
58
}
52
+ if (tcg_enabled()) {
59
@@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
53
+ hw_watchpoint_update(cpu, i);
60
}
54
+ }
55
}
56
57
void hw_breakpoint_update(ARMCPU *cpu, int n)
58
@@ -XXX,XX +XXX,XX @@ static void dbgbvr_write(CPUARMState *env, const ARMCPRegInfo *ri,
59
int i = ri->crm;
60
61
raw_write(env, ri, value);
62
- hw_breakpoint_update(cpu, i);
63
+ if (tcg_enabled()) {
64
+ hw_breakpoint_update(cpu, i);
65
+ }
66
}
67
68
static void dbgbcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
69
@@ -XXX,XX +XXX,XX @@ static void dbgbcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
70
value = deposit64(value, 8, 1, extract64(value, 7, 1));
71
72
raw_write(env, ri, value);
73
- hw_breakpoint_update(cpu, i);
74
+ if (tcg_enabled()) {
75
+ hw_breakpoint_update(cpu, i);
76
+ }
77
}
78
79
void define_debug_regs(ARMCPU *cpu)
80
diff --git a/target/arm/machine.c b/target/arm/machine.c
81
index XXXXXXX..XXXXXXX 100644
82
--- a/target/arm/machine.c
83
+++ b/target/arm/machine.c
84
@@ -XXX,XX +XXX,XX @@
85
#include "cpu.h"
86
#include "qemu/error-report.h"
87
#include "sysemu/kvm.h"
88
+#include "sysemu/tcg.h"
89
#include "kvm_arm.h"
90
#include "internals.h"
91
#include "migration/cpu.h"
92
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
93
return -1;
61
}
94
}
62
95
63
- if (allow_virt && (hcr_el2 & HCR_FMO)) {
96
- hw_breakpoint_update_all(cpu);
64
+ if (hcr_el2 & HCR_FMO) {
97
- hw_watchpoint_update_all(cpu);
65
if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) {
98
+ if (tcg_enabled()) {
66
ret |= CPSR_F;
99
+ hw_breakpoint_update_all(cpu);
67
}
100
+ hw_watchpoint_update_all(cpu);
101
+ }
102
103
/*
104
* TCG gen_update_fp_context() relies on the invariant that
68
--
105
--
69
2.20.1
106
2.34.1
70
71
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Without hardware acceleration, a cryptographically strong
3
The next few patches will move helpers under CONFIG_TCG. We'd prefer
4
algorithm is too expensive for pauth_computepac.
4
to keep the debug helpers and debug registers close together, so
5
rearrange the file a bit to be able to wrap the helpers with a TCG
6
ifdef.
5
7
6
Even with hardware accel, we are not currently expecting
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
to link the linux-user binaries to any crypto libraries,
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
and doing so would generally make the --static build fail.
9
10
So choose XXH64 as a reasonably quick and decent hash.
11
12
Tested-by: Mark Rutland <mark.rutland@arm.com>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20210111235740.462469-2-richard.henderson@linaro.org
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
11
---
18
include/qemu/xxhash.h | 98 +++++++++++++++++++++++++++++++++++++++
12
target/arm/debug_helper.c | 476 +++++++++++++++++++-------------------
19
target/arm/cpu.h | 15 ++++--
13
1 file changed, 239 insertions(+), 237 deletions(-)
20
target/arm/pauth_helper.c | 27 +++++++++--
21
3 files changed, 131 insertions(+), 9 deletions(-)
22
14
23
diff --git a/include/qemu/xxhash.h b/include/qemu/xxhash.h
15
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
24
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
25
--- a/include/qemu/xxhash.h
17
--- a/target/arm/debug_helper.c
26
+++ b/include/qemu/xxhash.h
18
+++ b/target/arm/debug_helper.c
27
@@ -XXX,XX +XXX,XX @@ static inline uint32_t qemu_xxhash6(uint64_t ab, uint64_t cd, uint32_t e,
19
@@ -XXX,XX +XXX,XX @@
28
return qemu_xxhash7(ab, cd, e, f, 0);
20
#include "cpregs.h"
21
#include "exec/exec-all.h"
22
#include "exec/helper-proto.h"
23
+#include "sysemu/tcg.h"
24
25
-
26
+#ifdef CONFIG_TCG
27
/* Return the Exception Level targeted by debug exceptions. */
28
static int arm_debug_target_el(CPUARMState *env)
29
{
30
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_swstep)(CPUARMState *env, uint32_t syndrome)
31
raise_exception_debug(env, EXCP_UDEF, syndrome);
29
}
32
}
30
33
31
+/*
34
+void hw_watchpoint_update(ARMCPU *cpu, int n)
32
+ * Component parts of the XXH64 algorithm from
33
+ * https://github.com/Cyan4973/xxHash/blob/v0.8.0/xxhash.h
34
+ *
35
+ * The complete algorithm looks like
36
+ *
37
+ * i = 0;
38
+ * if (len >= 32) {
39
+ * v1 = seed + XXH_PRIME64_1 + XXH_PRIME64_2;
40
+ * v2 = seed + XXH_PRIME64_2;
41
+ * v3 = seed + 0;
42
+ * v4 = seed - XXH_PRIME64_1;
43
+ * do {
44
+ * v1 = XXH64_round(v1, get64bits(input + i));
45
+ * v2 = XXH64_round(v2, get64bits(input + i + 8));
46
+ * v3 = XXH64_round(v3, get64bits(input + i + 16));
47
+ * v4 = XXH64_round(v4, get64bits(input + i + 24));
48
+ * } while ((i += 32) <= len);
49
+ * h64 = XXH64_mergerounds(v1, v2, v3, v4);
50
+ * } else {
51
+ * h64 = seed + XXH_PRIME64_5;
52
+ * }
53
+ * h64 += len;
54
+ *
55
+ * for (; i + 8 <= len; i += 8) {
56
+ * h64 ^= XXH64_round(0, get64bits(input + i));
57
+ * h64 = rol64(h64, 27) * XXH_PRIME64_1 + XXH_PRIME64_4;
58
+ * }
59
+ * for (; i + 4 <= len; i += 4) {
60
+ * h64 ^= get32bits(input + i) * PRIME64_1;
61
+ * h64 = rol64(h64, 23) * XXH_PRIME64_2 + XXH_PRIME64_3;
62
+ * }
63
+ * for (; i < len; i += 1) {
64
+ * h64 ^= get8bits(input + i) * XXH_PRIME64_5;
65
+ * h64 = rol64(h64, 11) * XXH_PRIME64_1;
66
+ * }
67
+ *
68
+ * return XXH64_avalanche(h64)
69
+ *
70
+ * Exposing the pieces instead allows for simplified usage when
71
+ * the length is a known constant and the inputs are in registers.
72
+ */
73
+#define XXH_PRIME64_1 0x9E3779B185EBCA87ULL
74
+#define XXH_PRIME64_2 0xC2B2AE3D27D4EB4FULL
75
+#define XXH_PRIME64_3 0x165667B19E3779F9ULL
76
+#define XXH_PRIME64_4 0x85EBCA77C2B2AE63ULL
77
+#define XXH_PRIME64_5 0x27D4EB2F165667C5ULL
78
+
79
+static inline uint64_t XXH64_round(uint64_t acc, uint64_t input)
80
+{
35
+{
81
+ return rol64(acc + input * XXH_PRIME64_2, 31) * XXH_PRIME64_1;
36
+ CPUARMState *env = &cpu->env;
37
+ vaddr len = 0;
38
+ vaddr wvr = env->cp15.dbgwvr[n];
39
+ uint64_t wcr = env->cp15.dbgwcr[n];
40
+ int mask;
41
+ int flags = BP_CPU | BP_STOP_BEFORE_ACCESS;
42
+
43
+ if (env->cpu_watchpoint[n]) {
44
+ cpu_watchpoint_remove_by_ref(CPU(cpu), env->cpu_watchpoint[n]);
45
+ env->cpu_watchpoint[n] = NULL;
46
+ }
47
+
48
+ if (!FIELD_EX64(wcr, DBGWCR, E)) {
49
+ /* E bit clear : watchpoint disabled */
50
+ return;
51
+ }
52
+
53
+ switch (FIELD_EX64(wcr, DBGWCR, LSC)) {
54
+ case 0:
55
+ /* LSC 00 is reserved and must behave as if the wp is disabled */
56
+ return;
57
+ case 1:
58
+ flags |= BP_MEM_READ;
59
+ break;
60
+ case 2:
61
+ flags |= BP_MEM_WRITE;
62
+ break;
63
+ case 3:
64
+ flags |= BP_MEM_ACCESS;
65
+ break;
66
+ }
67
+
68
+ /*
69
+ * Attempts to use both MASK and BAS fields simultaneously are
70
+ * CONSTRAINED UNPREDICTABLE; we opt to ignore BAS in this case,
71
+ * thus generating a watchpoint for every byte in the masked region.
72
+ */
73
+ mask = FIELD_EX64(wcr, DBGWCR, MASK);
74
+ if (mask == 1 || mask == 2) {
75
+ /*
76
+ * Reserved values of MASK; we must act as if the mask value was
77
+ * some non-reserved value, or as if the watchpoint were disabled.
78
+ * We choose the latter.
79
+ */
80
+ return;
81
+ } else if (mask) {
82
+ /* Watchpoint covers an aligned area up to 2GB in size */
83
+ len = 1ULL << mask;
84
+ /*
85
+ * If masked bits in WVR are not zero it's CONSTRAINED UNPREDICTABLE
86
+ * whether the watchpoint fires when the unmasked bits match; we opt
87
+ * to generate the exceptions.
88
+ */
89
+ wvr &= ~(len - 1);
90
+ } else {
91
+ /* Watchpoint covers bytes defined by the byte address select bits */
92
+ int bas = FIELD_EX64(wcr, DBGWCR, BAS);
93
+ int basstart;
94
+
95
+ if (extract64(wvr, 2, 1)) {
96
+ /*
97
+ * Deprecated case of an only 4-aligned address. BAS[7:4] are
98
+ * ignored, and BAS[3:0] define which bytes to watch.
99
+ */
100
+ bas &= 0xf;
101
+ }
102
+
103
+ if (bas == 0) {
104
+ /* This must act as if the watchpoint is disabled */
105
+ return;
106
+ }
107
+
108
+ /*
109
+ * The BAS bits are supposed to be programmed to indicate a contiguous
110
+ * range of bytes. Otherwise it is CONSTRAINED UNPREDICTABLE whether
111
+ * we fire for each byte in the word/doubleword addressed by the WVR.
112
+ * We choose to ignore any non-zero bits after the first range of 1s.
113
+ */
114
+ basstart = ctz32(bas);
115
+ len = cto32(bas >> basstart);
116
+ wvr += basstart;
117
+ }
118
+
119
+ cpu_watchpoint_insert(CPU(cpu), wvr, len, flags,
120
+ &env->cpu_watchpoint[n]);
82
+}
121
+}
83
+
122
+
84
+static inline uint64_t XXH64_mergeround(uint64_t acc, uint64_t val)
123
+void hw_watchpoint_update_all(ARMCPU *cpu)
85
+{
124
+{
86
+ return (acc ^ XXH64_round(0, val)) * XXH_PRIME64_1 + XXH_PRIME64_4;
125
+ int i;
126
+ CPUARMState *env = &cpu->env;
127
+
128
+ /*
129
+ * Completely clear out existing QEMU watchpoints and our array, to
130
+ * avoid possible stale entries following migration load.
131
+ */
132
+ cpu_watchpoint_remove_all(CPU(cpu), BP_CPU);
133
+ memset(env->cpu_watchpoint, 0, sizeof(env->cpu_watchpoint));
134
+
135
+ for (i = 0; i < ARRAY_SIZE(cpu->env.cpu_watchpoint); i++) {
136
+ hw_watchpoint_update(cpu, i);
137
+ }
87
+}
138
+}
88
+
139
+
89
+static inline uint64_t XXH64_mergerounds(uint64_t v1, uint64_t v2,
140
+void hw_breakpoint_update(ARMCPU *cpu, int n)
90
+ uint64_t v3, uint64_t v4)
91
+{
141
+{
92
+ uint64_t h64;
142
+ CPUARMState *env = &cpu->env;
93
+
143
+ uint64_t bvr = env->cp15.dbgbvr[n];
94
+ h64 = rol64(v1, 1) + rol64(v2, 7) + rol64(v3, 12) + rol64(v4, 18);
144
+ uint64_t bcr = env->cp15.dbgbcr[n];
95
+ h64 = XXH64_mergeround(h64, v1);
145
+ vaddr addr;
96
+ h64 = XXH64_mergeround(h64, v2);
146
+ int bt;
97
+ h64 = XXH64_mergeround(h64, v3);
147
+ int flags = BP_CPU;
98
+ h64 = XXH64_mergeround(h64, v4);
148
+
99
+
149
+ if (env->cpu_breakpoint[n]) {
100
+ return h64;
150
+ cpu_breakpoint_remove_by_ref(CPU(cpu), env->cpu_breakpoint[n]);
151
+ env->cpu_breakpoint[n] = NULL;
152
+ }
153
+
154
+ if (!extract64(bcr, 0, 1)) {
155
+ /* E bit clear : watchpoint disabled */
156
+ return;
157
+ }
158
+
159
+ bt = extract64(bcr, 20, 4);
160
+
161
+ switch (bt) {
162
+ case 4: /* unlinked address mismatch (reserved if AArch64) */
163
+ case 5: /* linked address mismatch (reserved if AArch64) */
164
+ qemu_log_mask(LOG_UNIMP,
165
+ "arm: address mismatch breakpoint types not implemented\n");
166
+ return;
167
+ case 0: /* unlinked address match */
168
+ case 1: /* linked address match */
169
+ {
170
+ /*
171
+ * Bits [1:0] are RES0.
172
+ *
173
+ * It is IMPLEMENTATION DEFINED whether bits [63:49]
174
+ * ([63:53] for FEAT_LVA) are hardwired to a copy of the sign bit
175
+ * of the VA field ([48] or [52] for FEAT_LVA), or whether the
176
+ * value is read as written. It is CONSTRAINED UNPREDICTABLE
177
+ * whether the RESS bits are ignored when comparing an address.
178
+ * Therefore we are allowed to compare the entire register, which
179
+ * lets us avoid considering whether FEAT_LVA is actually enabled.
180
+ *
181
+ * The BAS field is used to allow setting breakpoints on 16-bit
182
+ * wide instructions; it is CONSTRAINED UNPREDICTABLE whether
183
+ * a bp will fire if the addresses covered by the bp and the addresses
184
+ * covered by the insn overlap but the insn doesn't start at the
185
+ * start of the bp address range. We choose to require the insn and
186
+ * the bp to have the same address. The constraints on writing to
187
+ * BAS enforced in dbgbcr_write mean we have only four cases:
188
+ * 0b0000 => no breakpoint
189
+ * 0b0011 => breakpoint on addr
190
+ * 0b1100 => breakpoint on addr + 2
191
+ * 0b1111 => breakpoint on addr
192
+ * See also figure D2-3 in the v8 ARM ARM (DDI0487A.c).
193
+ */
194
+ int bas = extract64(bcr, 5, 4);
195
+ addr = bvr & ~3ULL;
196
+ if (bas == 0) {
197
+ return;
198
+ }
199
+ if (bas == 0xc) {
200
+ addr += 2;
201
+ }
202
+ break;
203
+ }
204
+ case 2: /* unlinked context ID match */
205
+ case 8: /* unlinked VMID match (reserved if no EL2) */
206
+ case 10: /* unlinked context ID and VMID match (reserved if no EL2) */
207
+ qemu_log_mask(LOG_UNIMP,
208
+ "arm: unlinked context breakpoint types not implemented\n");
209
+ return;
210
+ case 9: /* linked VMID match (reserved if no EL2) */
211
+ case 11: /* linked context ID and VMID match (reserved if no EL2) */
212
+ case 3: /* linked context ID match */
213
+ default:
214
+ /*
215
+ * We must generate no events for Linked context matches (unless
216
+ * they are linked to by some other bp/wp, which is handled in
217
+ * updates for the linking bp/wp). We choose to also generate no events
218
+ * for reserved values.
219
+ */
220
+ return;
221
+ }
222
+
223
+ cpu_breakpoint_insert(CPU(cpu), addr, flags, &env->cpu_breakpoint[n]);
101
+}
224
+}
102
+
225
+
103
+static inline uint64_t XXH64_avalanche(uint64_t h64)
226
+void hw_breakpoint_update_all(ARMCPU *cpu)
104
+{
227
+{
105
+ h64 ^= h64 >> 33;
228
+ int i;
106
+ h64 *= XXH_PRIME64_2;
229
+ CPUARMState *env = &cpu->env;
107
+ h64 ^= h64 >> 29;
230
+
108
+ h64 *= XXH_PRIME64_3;
231
+ /*
109
+ h64 ^= h64 >> 32;
232
+ * Completely clear out existing QEMU breakpoints and our array, to
110
+ return h64;
233
+ * avoid possible stale entries following migration load.
234
+ */
235
+ cpu_breakpoint_remove_all(CPU(cpu), BP_CPU);
236
+ memset(env->cpu_breakpoint, 0, sizeof(env->cpu_breakpoint));
237
+
238
+ for (i = 0; i < ARRAY_SIZE(cpu->env.cpu_breakpoint); i++) {
239
+ hw_breakpoint_update(cpu, i);
240
+ }
111
+}
241
+}
112
+
242
+
113
+static inline uint64_t qemu_xxhash64_4(uint64_t a, uint64_t b,
243
+#if !defined(CONFIG_USER_ONLY)
114
+ uint64_t c, uint64_t d)
244
+
245
+vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len)
115
+{
246
+{
116
+ uint64_t v1 = QEMU_XXHASH_SEED + XXH_PRIME64_1 + XXH_PRIME64_2;
247
+ ARMCPU *cpu = ARM_CPU(cs);
117
+ uint64_t v2 = QEMU_XXHASH_SEED + XXH_PRIME64_2;
248
+ CPUARMState *env = &cpu->env;
118
+ uint64_t v3 = QEMU_XXHASH_SEED + 0;
249
+
119
+ uint64_t v4 = QEMU_XXHASH_SEED - XXH_PRIME64_1;
250
+ /*
120
+
251
+ * In BE32 system mode, target memory is stored byteswapped (on a
121
+ v1 = XXH64_round(v1, a);
252
+ * little-endian host system), and by the time we reach here (via an
122
+ v2 = XXH64_round(v2, b);
253
+ * opcode helper) the addresses of subword accesses have been adjusted
123
+ v3 = XXH64_round(v3, c);
254
+ * to account for that, which means that watchpoints will not match.
124
+ v4 = XXH64_round(v4, d);
255
+ * Undo the adjustment here.
125
+
256
+ */
126
+ return XXH64_avalanche(XXH64_mergerounds(v1, v2, v3, v4));
257
+ if (arm_sctlr_b(env)) {
258
+ if (len == 1) {
259
+ addr ^= 3;
260
+ } else if (len == 2) {
261
+ addr ^= 2;
262
+ }
263
+ }
264
+
265
+ return addr;
127
+}
266
+}
128
+
267
+
129
#endif /* QEMU_XXHASH_H */
268
+#endif /* !CONFIG_USER_ONLY */
130
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
269
+#endif /* CONFIG_TCG */
131
index XXXXXXX..XXXXXXX 100644
270
+
132
--- a/target/arm/cpu.h
271
/*
133
+++ b/target/arm/cpu.h
272
* Check for traps to "powerdown debug" registers, which are controlled
134
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id)
273
* by MDCR.TDOSA
135
static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id)
274
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = {
275
.access = PL0_R, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
276
};
277
278
-void hw_watchpoint_update(ARMCPU *cpu, int n)
279
-{
280
- CPUARMState *env = &cpu->env;
281
- vaddr len = 0;
282
- vaddr wvr = env->cp15.dbgwvr[n];
283
- uint64_t wcr = env->cp15.dbgwcr[n];
284
- int mask;
285
- int flags = BP_CPU | BP_STOP_BEFORE_ACCESS;
286
-
287
- if (env->cpu_watchpoint[n]) {
288
- cpu_watchpoint_remove_by_ref(CPU(cpu), env->cpu_watchpoint[n]);
289
- env->cpu_watchpoint[n] = NULL;
290
- }
291
-
292
- if (!FIELD_EX64(wcr, DBGWCR, E)) {
293
- /* E bit clear : watchpoint disabled */
294
- return;
295
- }
296
-
297
- switch (FIELD_EX64(wcr, DBGWCR, LSC)) {
298
- case 0:
299
- /* LSC 00 is reserved and must behave as if the wp is disabled */
300
- return;
301
- case 1:
302
- flags |= BP_MEM_READ;
303
- break;
304
- case 2:
305
- flags |= BP_MEM_WRITE;
306
- break;
307
- case 3:
308
- flags |= BP_MEM_ACCESS;
309
- break;
310
- }
311
-
312
- /*
313
- * Attempts to use both MASK and BAS fields simultaneously are
314
- * CONSTRAINED UNPREDICTABLE; we opt to ignore BAS in this case,
315
- * thus generating a watchpoint for every byte in the masked region.
316
- */
317
- mask = FIELD_EX64(wcr, DBGWCR, MASK);
318
- if (mask == 1 || mask == 2) {
319
- /*
320
- * Reserved values of MASK; we must act as if the mask value was
321
- * some non-reserved value, or as if the watchpoint were disabled.
322
- * We choose the latter.
323
- */
324
- return;
325
- } else if (mask) {
326
- /* Watchpoint covers an aligned area up to 2GB in size */
327
- len = 1ULL << mask;
328
- /*
329
- * If masked bits in WVR are not zero it's CONSTRAINED UNPREDICTABLE
330
- * whether the watchpoint fires when the unmasked bits match; we opt
331
- * to generate the exceptions.
332
- */
333
- wvr &= ~(len - 1);
334
- } else {
335
- /* Watchpoint covers bytes defined by the byte address select bits */
336
- int bas = FIELD_EX64(wcr, DBGWCR, BAS);
337
- int basstart;
338
-
339
- if (extract64(wvr, 2, 1)) {
340
- /*
341
- * Deprecated case of an only 4-aligned address. BAS[7:4] are
342
- * ignored, and BAS[3:0] define which bytes to watch.
343
- */
344
- bas &= 0xf;
345
- }
346
-
347
- if (bas == 0) {
348
- /* This must act as if the watchpoint is disabled */
349
- return;
350
- }
351
-
352
- /*
353
- * The BAS bits are supposed to be programmed to indicate a contiguous
354
- * range of bytes. Otherwise it is CONSTRAINED UNPREDICTABLE whether
355
- * we fire for each byte in the word/doubleword addressed by the WVR.
356
- * We choose to ignore any non-zero bits after the first range of 1s.
357
- */
358
- basstart = ctz32(bas);
359
- len = cto32(bas >> basstart);
360
- wvr += basstart;
361
- }
362
-
363
- cpu_watchpoint_insert(CPU(cpu), wvr, len, flags,
364
- &env->cpu_watchpoint[n]);
365
-}
366
-
367
-void hw_watchpoint_update_all(ARMCPU *cpu)
368
-{
369
- int i;
370
- CPUARMState *env = &cpu->env;
371
-
372
- /*
373
- * Completely clear out existing QEMU watchpoints and our array, to
374
- * avoid possible stale entries following migration load.
375
- */
376
- cpu_watchpoint_remove_all(CPU(cpu), BP_CPU);
377
- memset(env->cpu_watchpoint, 0, sizeof(env->cpu_watchpoint));
378
-
379
- for (i = 0; i < ARRAY_SIZE(cpu->env.cpu_watchpoint); i++) {
380
- hw_watchpoint_update(cpu, i);
381
- }
382
-}
383
-
384
static void dbgwvr_write(CPUARMState *env, const ARMCPRegInfo *ri,
385
uint64_t value)
136
{
386
{
137
/*
387
@@ -XXX,XX +XXX,XX @@ static void dbgwcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
138
- * Note that while QEMU will only implement the architected algorithm
388
}
139
- * QARMA, and thus APA+GPA, the host cpu for kvm may use implementation
140
- * defined algorithms, and thus API+GPI, and this predicate controls
141
- * migration of the 128-bit keys.
142
+ * Return true if any form of pauth is enabled, as this
143
+ * predicate controls migration of the 128-bit keys.
144
*/
145
return (id->id_aa64isar1 &
146
(FIELD_DP64(0, ID_AA64ISAR1, APA, 0xf) |
147
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id)
148
FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0;
149
}
389
}
150
390
151
+static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id)
391
-void hw_breakpoint_update(ARMCPU *cpu, int n)
152
+{
392
-{
153
+ /*
393
- CPUARMState *env = &cpu->env;
154
+ * Return true if pauth is enabled with the architected QARMA algorithm.
394
- uint64_t bvr = env->cp15.dbgbvr[n];
155
+ * QEMU will always set APA+GPA to the same value.
395
- uint64_t bcr = env->cp15.dbgbcr[n];
156
+ */
396
- vaddr addr;
157
+ return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) != 0;
397
- int bt;
158
+}
398
- int flags = BP_CPU;
159
+
399
-
160
static inline bool isar_feature_aa64_sb(const ARMISARegisters *id)
400
- if (env->cpu_breakpoint[n]) {
401
- cpu_breakpoint_remove_by_ref(CPU(cpu), env->cpu_breakpoint[n]);
402
- env->cpu_breakpoint[n] = NULL;
403
- }
404
-
405
- if (!extract64(bcr, 0, 1)) {
406
- /* E bit clear : watchpoint disabled */
407
- return;
408
- }
409
-
410
- bt = extract64(bcr, 20, 4);
411
-
412
- switch (bt) {
413
- case 4: /* unlinked address mismatch (reserved if AArch64) */
414
- case 5: /* linked address mismatch (reserved if AArch64) */
415
- qemu_log_mask(LOG_UNIMP,
416
- "arm: address mismatch breakpoint types not implemented\n");
417
- return;
418
- case 0: /* unlinked address match */
419
- case 1: /* linked address match */
420
- {
421
- /*
422
- * Bits [1:0] are RES0.
423
- *
424
- * It is IMPLEMENTATION DEFINED whether bits [63:49]
425
- * ([63:53] for FEAT_LVA) are hardwired to a copy of the sign bit
426
- * of the VA field ([48] or [52] for FEAT_LVA), or whether the
427
- * value is read as written. It is CONSTRAINED UNPREDICTABLE
428
- * whether the RESS bits are ignored when comparing an address.
429
- * Therefore we are allowed to compare the entire register, which
430
- * lets us avoid considering whether FEAT_LVA is actually enabled.
431
- *
432
- * The BAS field is used to allow setting breakpoints on 16-bit
433
- * wide instructions; it is CONSTRAINED UNPREDICTABLE whether
434
- * a bp will fire if the addresses covered by the bp and the addresses
435
- * covered by the insn overlap but the insn doesn't start at the
436
- * start of the bp address range. We choose to require the insn and
437
- * the bp to have the same address. The constraints on writing to
438
- * BAS enforced in dbgbcr_write mean we have only four cases:
439
- * 0b0000 => no breakpoint
440
- * 0b0011 => breakpoint on addr
441
- * 0b1100 => breakpoint on addr + 2
442
- * 0b1111 => breakpoint on addr
443
- * See also figure D2-3 in the v8 ARM ARM (DDI0487A.c).
444
- */
445
- int bas = extract64(bcr, 5, 4);
446
- addr = bvr & ~3ULL;
447
- if (bas == 0) {
448
- return;
449
- }
450
- if (bas == 0xc) {
451
- addr += 2;
452
- }
453
- break;
454
- }
455
- case 2: /* unlinked context ID match */
456
- case 8: /* unlinked VMID match (reserved if no EL2) */
457
- case 10: /* unlinked context ID and VMID match (reserved if no EL2) */
458
- qemu_log_mask(LOG_UNIMP,
459
- "arm: unlinked context breakpoint types not implemented\n");
460
- return;
461
- case 9: /* linked VMID match (reserved if no EL2) */
462
- case 11: /* linked context ID and VMID match (reserved if no EL2) */
463
- case 3: /* linked context ID match */
464
- default:
465
- /*
466
- * We must generate no events for Linked context matches (unless
467
- * they are linked to by some other bp/wp, which is handled in
468
- * updates for the linking bp/wp). We choose to also generate no events
469
- * for reserved values.
470
- */
471
- return;
472
- }
473
-
474
- cpu_breakpoint_insert(CPU(cpu), addr, flags, &env->cpu_breakpoint[n]);
475
-}
476
-
477
-void hw_breakpoint_update_all(ARMCPU *cpu)
478
-{
479
- int i;
480
- CPUARMState *env = &cpu->env;
481
-
482
- /*
483
- * Completely clear out existing QEMU breakpoints and our array, to
484
- * avoid possible stale entries following migration load.
485
- */
486
- cpu_breakpoint_remove_all(CPU(cpu), BP_CPU);
487
- memset(env->cpu_breakpoint, 0, sizeof(env->cpu_breakpoint));
488
-
489
- for (i = 0; i < ARRAY_SIZE(cpu->env.cpu_breakpoint); i++) {
490
- hw_breakpoint_update(cpu, i);
491
- }
492
-}
493
-
494
static void dbgbvr_write(CPUARMState *env, const ARMCPRegInfo *ri,
495
uint64_t value)
161
{
496
{
162
return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SB) != 0;
497
@@ -XXX,XX +XXX,XX @@ void define_debug_regs(ARMCPU *cpu)
163
diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c
498
g_free(dbgwcr_el1_name);
164
index XXXXXXX..XXXXXXX 100644
499
}
165
--- a/target/arm/pauth_helper.c
166
+++ b/target/arm/pauth_helper.c
167
@@ -XXX,XX +XXX,XX @@
168
#include "exec/cpu_ldst.h"
169
#include "exec/helper-proto.h"
170
#include "tcg/tcg-gvec-desc.h"
171
+#include "qemu/xxhash.h"
172
173
174
static uint64_t pac_cell_shuffle(uint64_t i)
175
@@ -XXX,XX +XXX,XX @@ static uint64_t tweak_inv_shuffle(uint64_t i)
176
return o;
177
}
500
}
178
501
-
179
-static uint64_t pauth_computepac(uint64_t data, uint64_t modifier,
502
-#if !defined(CONFIG_USER_ONLY)
180
- ARMPACKey key)
503
-
181
+static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier,
504
-vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len)
182
+ ARMPACKey key)
505
-{
183
{
506
- ARMCPU *cpu = ARM_CPU(cs);
184
static const uint64_t RC[5] = {
507
- CPUARMState *env = &cpu->env;
185
0x0000000000000000ull,
508
-
186
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_computepac(uint64_t data, uint64_t modifier,
509
- /*
187
return workingval;
510
- * In BE32 system mode, target memory is stored byteswapped (on a
188
}
511
- * little-endian host system), and by the time we reach here (via an
189
512
- * opcode helper) the addresses of subword accesses have been adjusted
190
+static uint64_t pauth_computepac_impdef(uint64_t data, uint64_t modifier,
513
- * to account for that, which means that watchpoints will not match.
191
+ ARMPACKey key)
514
- * Undo the adjustment here.
192
+{
515
- */
193
+ return qemu_xxhash64_4(data, modifier, key.lo, key.hi);
516
- if (arm_sctlr_b(env)) {
194
+}
517
- if (len == 1) {
195
+
518
- addr ^= 3;
196
+static uint64_t pauth_computepac(CPUARMState *env, uint64_t data,
519
- } else if (len == 2) {
197
+ uint64_t modifier, ARMPACKey key)
520
- addr ^= 2;
198
+{
521
- }
199
+ if (cpu_isar_feature(aa64_pauth_arch, env_archcpu(env))) {
522
- }
200
+ return pauth_computepac_architected(data, modifier, key);
523
-
201
+ } else {
524
- return addr;
202
+ return pauth_computepac_impdef(data, modifier, key);
525
-}
203
+ }
526
-
204
+}
527
-#endif
205
+
206
static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
207
ARMPACKey *key, bool data)
208
{
209
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
210
bot_bit = 64 - param.tsz;
211
ext_ptr = deposit64(ptr, bot_bit, top_bit - bot_bit, ext);
212
213
- pac = pauth_computepac(ext_ptr, modifier, *key);
214
+ pac = pauth_computepac(env, ext_ptr, modifier, *key);
215
216
/*
217
* Check if the ptr has good extension bits and corrupt the
218
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
219
uint64_t pac, orig_ptr, test;
220
221
orig_ptr = pauth_original_ptr(ptr, param);
222
- pac = pauth_computepac(orig_ptr, modifier, *key);
223
+ pac = pauth_computepac(env, orig_ptr, modifier, *key);
224
bot_bit = 64 - param.tsz;
225
top_bit = 64 - 8 * param.tbi;
226
227
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(pacga)(CPUARMState *env, uint64_t x, uint64_t y)
228
uint64_t pac;
229
230
pauth_check_trap(env, arm_current_el(env), GETPC());
231
- pac = pauth_computepac(x, y, env->keys.apga);
232
+ pac = pauth_computepac(env, x, y, env->keys.apga);
233
234
return pac & 0xffffffff00000000ull;
235
}
236
--
528
--
237
2.20.1
529
2.34.1
238
239
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
The adc_qom_set function didn't free "response", which caused an indirect
3
Introduce the target/arm/tcg directory. Its purpose is to hold the TCG
4
memory leak. So use qobject_unref() to fix it.
4
code that is selected by CONFIG_TCG.
5
5
6
ASAN shows memory leak stack:
6
Signed-off-by: Claudio Fontana <cfontana@suse.de>
7
7
Signed-off-by: Fabiano Rosas <farosas@suse.de>
8
Indirect leak of 593280 byte(s) in 144 object(s) allocated from:
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
#0 0x7f9a5e7e8d4e in __interceptor_calloc (/lib64/libasan.so.5+0x112d4e)
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
#1 0x7f9a5e607a50 in g_malloc0 (/lib64/libglib-2.0.so.0+0x55a50)
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
#2 0x55b1bebf636b in qdict_new ../qobject/qdict.c:30
11
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
#3 0x55b1bec09699 in parse_object ../qobject/json-parser.c:318
13
#4 0x55b1bec0b2df in parse_value ../qobject/json-parser.c:546
14
#5 0x55b1bec0b6a9 in json_parser_parse ../qobject/json-parser.c:580
15
#6 0x55b1bec060d1 in json_message_process_token ../qobject/json-streamer.c:92
16
#7 0x55b1bec16a12 in json_lexer_feed_char ../qobject/json-lexer.c:313
17
#8 0x55b1bec16fbd in json_lexer_feed ../qobject/json-lexer.c:350
18
#9 0x55b1bec06453 in json_message_parser_feed ../qobject/json-streamer.c:121
19
#10 0x55b1bebc2d51 in qmp_fd_receive ../tests/qtest/libqtest.c:614
20
#11 0x55b1bebc2f5e in qtest_qmp_receive_dict ../tests/qtest/libqtest.c:636
21
#12 0x55b1bebc2e6c in qtest_qmp_receive ../tests/qtest/libqtest.c:624
22
#13 0x55b1bebc3340 in qtest_vqmp ../tests/qtest/libqtest.c:715
23
#14 0x55b1bebc3942 in qtest_qmp ../tests/qtest/libqtest.c:756
24
#15 0x55b1bebbd64a in adc_qom_set ../tests/qtest/npcm7xx_adc-test.c:127
25
#16 0x55b1bebbd793 in adc_write_input ../tests/qtest/npcm7xx_adc-test.c:140
26
#17 0x55b1bebbdf92 in test_convert_external ../tests/qtest/npcm7xx_adc-test.c:246
27
28
Reported-by: Euler Robot <euler.robot@huawei.com>
29
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
30
Reviewed-by: Hao Wu <wuhaotsh@google.com>
31
Message-id: 20210118065627.79903-1-ganqixin@huawei.com
32
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
33
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
34
---
13
---
35
tests/qtest/npcm7xx_adc-test.c | 1 +
14
MAINTAINERS | 1 +
36
1 file changed, 1 insertion(+)
15
target/arm/{ => tcg}/translate-a64.h | 0
37
16
target/arm/{ => tcg}/translate.h | 0
38
diff --git a/tests/qtest/npcm7xx_adc-test.c b/tests/qtest/npcm7xx_adc-test.c
17
target/arm/{ => tcg}/a32-uncond.decode | 0
18
target/arm/{ => tcg}/a32.decode | 0
19
target/arm/{ => tcg}/m-nocp.decode | 0
20
target/arm/{ => tcg}/mve.decode | 0
21
target/arm/{ => tcg}/neon-dp.decode | 0
22
target/arm/{ => tcg}/neon-ls.decode | 0
23
target/arm/{ => tcg}/neon-shared.decode | 0
24
target/arm/{ => tcg}/sme-fa64.decode | 0
25
target/arm/{ => tcg}/sme.decode | 0
26
target/arm/{ => tcg}/sve.decode | 0
27
target/arm/{ => tcg}/t16.decode | 0
28
target/arm/{ => tcg}/t32.decode | 0
29
target/arm/{ => tcg}/vfp-uncond.decode | 0
30
target/arm/{ => tcg}/vfp.decode | 0
31
target/arm/{ => tcg}/translate-a64.c | 0
32
target/arm/{ => tcg}/translate-m-nocp.c | 0
33
target/arm/{ => tcg}/translate-mve.c | 0
34
target/arm/{ => tcg}/translate-neon.c | 0
35
target/arm/{ => tcg}/translate-sme.c | 0
36
target/arm/{ => tcg}/translate-sve.c | 0
37
target/arm/{ => tcg}/translate-vfp.c | 0
38
target/arm/{ => tcg}/translate.c | 0
39
target/arm/meson.build | 30 +++---------------
40
target/arm/{ => tcg}/meson.build | 41 +------------------------
41
27 files changed, 6 insertions(+), 66 deletions(-)
42
rename target/arm/{ => tcg}/translate-a64.h (100%)
43
rename target/arm/{ => tcg}/translate.h (100%)
44
rename target/arm/{ => tcg}/a32-uncond.decode (100%)
45
rename target/arm/{ => tcg}/a32.decode (100%)
46
rename target/arm/{ => tcg}/m-nocp.decode (100%)
47
rename target/arm/{ => tcg}/mve.decode (100%)
48
rename target/arm/{ => tcg}/neon-dp.decode (100%)
49
rename target/arm/{ => tcg}/neon-ls.decode (100%)
50
rename target/arm/{ => tcg}/neon-shared.decode (100%)
51
rename target/arm/{ => tcg}/sme-fa64.decode (100%)
52
rename target/arm/{ => tcg}/sme.decode (100%)
53
rename target/arm/{ => tcg}/sve.decode (100%)
54
rename target/arm/{ => tcg}/t16.decode (100%)
55
rename target/arm/{ => tcg}/t32.decode (100%)
56
rename target/arm/{ => tcg}/vfp-uncond.decode (100%)
57
rename target/arm/{ => tcg}/vfp.decode (100%)
58
rename target/arm/{ => tcg}/translate-a64.c (100%)
59
rename target/arm/{ => tcg}/translate-m-nocp.c (100%)
60
rename target/arm/{ => tcg}/translate-mve.c (100%)
61
rename target/arm/{ => tcg}/translate-neon.c (100%)
62
rename target/arm/{ => tcg}/translate-sme.c (100%)
63
rename target/arm/{ => tcg}/translate-sve.c (100%)
64
rename target/arm/{ => tcg}/translate-vfp.c (100%)
65
rename target/arm/{ => tcg}/translate.c (100%)
66
copy target/arm/{ => tcg}/meson.build (64%)
67
68
diff --git a/MAINTAINERS b/MAINTAINERS
39
index XXXXXXX..XXXXXXX 100644
69
index XXXXXXX..XXXXXXX 100644
40
--- a/tests/qtest/npcm7xx_adc-test.c
70
--- a/MAINTAINERS
41
+++ b/tests/qtest/npcm7xx_adc-test.c
71
+++ b/MAINTAINERS
42
@@ -XXX,XX +XXX,XX @@ static void adc_qom_set(QTestState *qts, const ADC *adc,
72
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
43
path, name, value);
73
L: qemu-arm@nongnu.org
44
/* The qom set message returns successfully. */
74
S: Maintained
45
g_assert_true(qdict_haskey(response, "return"));
75
F: target/arm/
46
+ qobject_unref(response);
76
+F: target/arm/tcg/
47
}
77
F: tests/tcg/arm/
48
78
F: tests/tcg/aarch64/
49
static void adc_write_input(QTestState *qts, const ADC *adc,
79
F: tests/qtest/arm-cpu-features.c
80
diff --git a/target/arm/translate-a64.h b/target/arm/tcg/translate-a64.h
81
similarity index 100%
82
rename from target/arm/translate-a64.h
83
rename to target/arm/tcg/translate-a64.h
84
diff --git a/target/arm/translate.h b/target/arm/tcg/translate.h
85
similarity index 100%
86
rename from target/arm/translate.h
87
rename to target/arm/tcg/translate.h
88
diff --git a/target/arm/a32-uncond.decode b/target/arm/tcg/a32-uncond.decode
89
similarity index 100%
90
rename from target/arm/a32-uncond.decode
91
rename to target/arm/tcg/a32-uncond.decode
92
diff --git a/target/arm/a32.decode b/target/arm/tcg/a32.decode
93
similarity index 100%
94
rename from target/arm/a32.decode
95
rename to target/arm/tcg/a32.decode
96
diff --git a/target/arm/m-nocp.decode b/target/arm/tcg/m-nocp.decode
97
similarity index 100%
98
rename from target/arm/m-nocp.decode
99
rename to target/arm/tcg/m-nocp.decode
100
diff --git a/target/arm/mve.decode b/target/arm/tcg/mve.decode
101
similarity index 100%
102
rename from target/arm/mve.decode
103
rename to target/arm/tcg/mve.decode
104
diff --git a/target/arm/neon-dp.decode b/target/arm/tcg/neon-dp.decode
105
similarity index 100%
106
rename from target/arm/neon-dp.decode
107
rename to target/arm/tcg/neon-dp.decode
108
diff --git a/target/arm/neon-ls.decode b/target/arm/tcg/neon-ls.decode
109
similarity index 100%
110
rename from target/arm/neon-ls.decode
111
rename to target/arm/tcg/neon-ls.decode
112
diff --git a/target/arm/neon-shared.decode b/target/arm/tcg/neon-shared.decode
113
similarity index 100%
114
rename from target/arm/neon-shared.decode
115
rename to target/arm/tcg/neon-shared.decode
116
diff --git a/target/arm/sme-fa64.decode b/target/arm/tcg/sme-fa64.decode
117
similarity index 100%
118
rename from target/arm/sme-fa64.decode
119
rename to target/arm/tcg/sme-fa64.decode
120
diff --git a/target/arm/sme.decode b/target/arm/tcg/sme.decode
121
similarity index 100%
122
rename from target/arm/sme.decode
123
rename to target/arm/tcg/sme.decode
124
diff --git a/target/arm/sve.decode b/target/arm/tcg/sve.decode
125
similarity index 100%
126
rename from target/arm/sve.decode
127
rename to target/arm/tcg/sve.decode
128
diff --git a/target/arm/t16.decode b/target/arm/tcg/t16.decode
129
similarity index 100%
130
rename from target/arm/t16.decode
131
rename to target/arm/tcg/t16.decode
132
diff --git a/target/arm/t32.decode b/target/arm/tcg/t32.decode
133
similarity index 100%
134
rename from target/arm/t32.decode
135
rename to target/arm/tcg/t32.decode
136
diff --git a/target/arm/vfp-uncond.decode b/target/arm/tcg/vfp-uncond.decode
137
similarity index 100%
138
rename from target/arm/vfp-uncond.decode
139
rename to target/arm/tcg/vfp-uncond.decode
140
diff --git a/target/arm/vfp.decode b/target/arm/tcg/vfp.decode
141
similarity index 100%
142
rename from target/arm/vfp.decode
143
rename to target/arm/tcg/vfp.decode
144
diff --git a/target/arm/translate-a64.c b/target/arm/tcg/translate-a64.c
145
similarity index 100%
146
rename from target/arm/translate-a64.c
147
rename to target/arm/tcg/translate-a64.c
148
diff --git a/target/arm/translate-m-nocp.c b/target/arm/tcg/translate-m-nocp.c
149
similarity index 100%
150
rename from target/arm/translate-m-nocp.c
151
rename to target/arm/tcg/translate-m-nocp.c
152
diff --git a/target/arm/translate-mve.c b/target/arm/tcg/translate-mve.c
153
similarity index 100%
154
rename from target/arm/translate-mve.c
155
rename to target/arm/tcg/translate-mve.c
156
diff --git a/target/arm/translate-neon.c b/target/arm/tcg/translate-neon.c
157
similarity index 100%
158
rename from target/arm/translate-neon.c
159
rename to target/arm/tcg/translate-neon.c
160
diff --git a/target/arm/translate-sme.c b/target/arm/tcg/translate-sme.c
161
similarity index 100%
162
rename from target/arm/translate-sme.c
163
rename to target/arm/tcg/translate-sme.c
164
diff --git a/target/arm/translate-sve.c b/target/arm/tcg/translate-sve.c
165
similarity index 100%
166
rename from target/arm/translate-sve.c
167
rename to target/arm/tcg/translate-sve.c
168
diff --git a/target/arm/translate-vfp.c b/target/arm/tcg/translate-vfp.c
169
similarity index 100%
170
rename from target/arm/translate-vfp.c
171
rename to target/arm/tcg/translate-vfp.c
172
diff --git a/target/arm/translate.c b/target/arm/tcg/translate.c
173
similarity index 100%
174
rename from target/arm/translate.c
175
rename to target/arm/tcg/translate.c
176
diff --git a/target/arm/meson.build b/target/arm/meson.build
177
index XXXXXXX..XXXXXXX 100644
178
--- a/target/arm/meson.build
179
+++ b/target/arm/meson.build
180
@@ -XXX,XX +XXX,XX @@
181
-gen = [
182
- decodetree.process('sve.decode', extra_args: '--decode=disas_sve'),
183
- decodetree.process('sme.decode', extra_args: '--decode=disas_sme'),
184
- decodetree.process('sme-fa64.decode', extra_args: '--static-decode=disas_sme_fa64'),
185
- decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'),
186
- decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'),
187
- decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'),
188
- decodetree.process('vfp.decode', extra_args: '--decode=disas_vfp'),
189
- decodetree.process('vfp-uncond.decode', extra_args: '--decode=disas_vfp_uncond'),
190
- decodetree.process('m-nocp.decode', extra_args: '--decode=disas_m_nocp'),
191
- decodetree.process('mve.decode', extra_args: '--decode=disas_mve'),
192
- decodetree.process('a32.decode', extra_args: '--static-decode=disas_a32'),
193
- decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'),
194
- decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'),
195
- decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']),
196
-]
197
-
198
arm_ss = ss.source_set()
199
-arm_ss.add(gen)
200
arm_ss.add(files(
201
'cpu.c',
202
'crypto_helper.c',
203
@@ -XXX,XX +XXX,XX @@ arm_ss.add(files(
204
'neon_helper.c',
205
'op_helper.c',
206
'tlb_helper.c',
207
- 'translate.c',
208
- 'translate-m-nocp.c',
209
- 'translate-mve.c',
210
- 'translate-neon.c',
211
- 'translate-vfp.c',
212
'vec_helper.c',
213
'vfp_helper.c',
214
'cpu_tcg.c',
215
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
216
'pauth_helper.c',
217
'sve_helper.c',
218
'sme_helper.c',
219
- 'translate-a64.c',
220
- 'translate-sve.c',
221
- 'translate-sme.c',
222
))
223
224
arm_softmmu_ss = ss.source_set()
225
@@ -XXX,XX +XXX,XX @@ arm_softmmu_ss.add(files(
226
227
subdir('hvf')
228
229
+if 'CONFIG_TCG' in config_all
230
+ subdir('tcg')
231
+endif
232
+
233
target_arch += {'arm': arm_ss}
234
target_softmmu_arch += {'arm': arm_softmmu_ss}
235
diff --git a/target/arm/meson.build b/target/arm/tcg/meson.build
236
similarity index 64%
237
copy from target/arm/meson.build
238
copy to target/arm/tcg/meson.build
239
index XXXXXXX..XXXXXXX 100644
240
--- a/target/arm/meson.build
241
+++ b/target/arm/tcg/meson.build
242
@@ -XXX,XX +XXX,XX @@ gen = [
243
decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']),
244
]
245
246
-arm_ss = ss.source_set()
247
arm_ss.add(gen)
248
+
249
arm_ss.add(files(
250
- 'cpu.c',
251
- 'crypto_helper.c',
252
- 'debug_helper.c',
253
- 'gdbstub.c',
254
- 'helper.c',
255
- 'iwmmxt_helper.c',
256
- 'm_helper.c',
257
- 'mve_helper.c',
258
- 'neon_helper.c',
259
- 'op_helper.c',
260
- 'tlb_helper.c',
261
'translate.c',
262
'translate-m-nocp.c',
263
'translate-mve.c',
264
'translate-neon.c',
265
'translate-vfp.c',
266
- 'vec_helper.c',
267
- 'vfp_helper.c',
268
- 'cpu_tcg.c',
269
))
270
-arm_ss.add(zlib)
271
-
272
-arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: files('kvm-stub.c'))
273
274
arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
275
- 'cpu64.c',
276
- 'gdbstub64.c',
277
- 'helper-a64.c',
278
- 'mte_helper.c',
279
- 'pauth_helper.c',
280
- 'sve_helper.c',
281
- 'sme_helper.c',
282
'translate-a64.c',
283
'translate-sve.c',
284
'translate-sme.c',
285
))
286
-
287
-arm_softmmu_ss = ss.source_set()
288
-arm_softmmu_ss.add(files(
289
- 'arch_dump.c',
290
- 'arm-powerctl.c',
291
- 'machine.c',
292
- 'monitor.c',
293
- 'psci.c',
294
- 'ptw.c',
295
-))
296
-
297
-subdir('hvf')
298
-
299
-target_arch += {'arm': arm_ss}
300
-target_softmmu_arch += {'arm': arm_softmmu_ss}
50
--
301
--
51
2.20.1
302
2.34.1
52
303
53
304
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Claudio Fontana <cfontana@suse.de>
2
2
3
Add a test case for pvpanic-pci device. The scenario is the same as pvpapnic
3
Signed-off-by: Claudio Fontana <cfontana@suse.de>
4
ISA device, but is using the PCI bus.
4
Signed-off-by: Fabiano Rosas <farosas@suse.de>
5
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Acked-by: Thomas Huth <thuth@redhat.com>
7
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
9
---
11
tests/qtest/pvpanic-pci-test.c | 62 ++++++++++++++++++++++++++++++++++
10
target/arm/{ => tcg}/vec_internal.h | 0
12
tests/qtest/meson.build | 1 +
11
target/arm/tcg-stubs.c | 23 +++++++++++++++++++++++
13
2 files changed, 63 insertions(+)
12
target/arm/{ => tcg}/crypto_helper.c | 0
14
create mode 100644 tests/qtest/pvpanic-pci-test.c
13
target/arm/{ => tcg}/helper-a64.c | 0
15
14
target/arm/{ => tcg}/iwmmxt_helper.c | 0
16
diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c
15
target/arm/{ => tcg}/m_helper.c | 0
16
target/arm/{ => tcg}/mte_helper.c | 0
17
target/arm/{ => tcg}/mve_helper.c | 0
18
target/arm/{ => tcg}/neon_helper.c | 0
19
target/arm/{ => tcg}/op_helper.c | 0
20
target/arm/{ => tcg}/pauth_helper.c | 0
21
target/arm/{ => tcg}/sme_helper.c | 0
22
target/arm/{ => tcg}/sve_helper.c | 0
23
target/arm/{ => tcg}/tlb_helper.c | 0
24
target/arm/{ => tcg}/vec_helper.c | 0
25
target/arm/meson.build | 15 ++-------------
26
target/arm/tcg/meson.build | 13 +++++++++++++
27
17 files changed, 38 insertions(+), 13 deletions(-)
28
rename target/arm/{ => tcg}/vec_internal.h (100%)
29
create mode 100644 target/arm/tcg-stubs.c
30
rename target/arm/{ => tcg}/crypto_helper.c (100%)
31
rename target/arm/{ => tcg}/helper-a64.c (100%)
32
rename target/arm/{ => tcg}/iwmmxt_helper.c (100%)
33
rename target/arm/{ => tcg}/m_helper.c (100%)
34
rename target/arm/{ => tcg}/mte_helper.c (100%)
35
rename target/arm/{ => tcg}/mve_helper.c (100%)
36
rename target/arm/{ => tcg}/neon_helper.c (100%)
37
rename target/arm/{ => tcg}/op_helper.c (100%)
38
rename target/arm/{ => tcg}/pauth_helper.c (100%)
39
rename target/arm/{ => tcg}/sme_helper.c (100%)
40
rename target/arm/{ => tcg}/sve_helper.c (100%)
41
rename target/arm/{ => tcg}/tlb_helper.c (100%)
42
rename target/arm/{ => tcg}/vec_helper.c (100%)
43
44
diff --git a/target/arm/vec_internal.h b/target/arm/tcg/vec_internal.h
45
similarity index 100%
46
rename from target/arm/vec_internal.h
47
rename to target/arm/tcg/vec_internal.h
48
diff --git a/target/arm/tcg-stubs.c b/target/arm/tcg-stubs.c
17
new file mode 100644
49
new file mode 100644
18
index XXXXXXX..XXXXXXX
50
index XXXXXXX..XXXXXXX
19
--- /dev/null
51
--- /dev/null
20
+++ b/tests/qtest/pvpanic-pci-test.c
52
+++ b/target/arm/tcg-stubs.c
21
@@ -XXX,XX +XXX,XX @@
53
@@ -XXX,XX +XXX,XX @@
22
+/*
54
+/*
23
+ * QTest testcase for PV Panic PCI device
55
+ * QEMU ARM stubs for some TCG helper functions
24
+ *
56
+ *
25
+ * Copyright (C) 2020 Oracle
57
+ * Copyright 2021 SUSE LLC
26
+ *
27
+ * Authors:
28
+ * Mihai Carabas <mihai.carabas@oracle.com>
29
+ *
58
+ *
30
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
59
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
31
+ * See the COPYING file in the top-level directory.
60
+ * See the COPYING file in the top-level directory.
32
+ *
33
+ */
61
+ */
34
+
62
+
35
+#include "qemu/osdep.h"
63
+#include "qemu/osdep.h"
36
+#include "libqos/libqtest.h"
64
+#include "cpu.h"
37
+#include "qapi/qmp/qdict.h"
65
+#include "internals.h"
38
+#include "libqos/pci.h"
39
+#include "libqos/pci-pc.h"
40
+#include "hw/pci/pci_regs.h"
41
+
66
+
42
+static void test_panic(void)
67
+void write_v7m_exception(CPUARMState *env, uint32_t new_exc)
43
+{
68
+{
44
+ uint8_t val;
69
+ g_assert_not_reached();
45
+ QDict *response, *data;
46
+ QTestState *qts;
47
+ QPCIBus *pcibus;
48
+ QPCIDevice *dev;
49
+ QPCIBar bar;
50
+
51
+ qts = qtest_init("-device pvpanic-pci");
52
+ pcibus = qpci_new_pc(qts, NULL);
53
+ dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0));
54
+ qpci_device_enable(dev);
55
+ bar = qpci_iomap(dev, 0, NULL);
56
+
57
+ qpci_memread(dev, bar, 0, &val, sizeof(val));
58
+ g_assert_cmpuint(val, ==, 3);
59
+
60
+ val = 1;
61
+ qpci_memwrite(dev, bar, 0, &val, sizeof(val));
62
+
63
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED");
64
+ g_assert(qdict_haskey(response, "data"));
65
+ data = qdict_get_qdict(response, "data");
66
+ g_assert(qdict_haskey(data, "action"));
67
+ g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
68
+ qobject_unref(response);
69
+
70
+ qtest_quit(qts);
71
+}
70
+}
72
+
71
+
73
+int main(int argc, char **argv)
72
+void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome,
73
+ uint32_t target_el, uintptr_t ra)
74
+{
74
+{
75
+ int ret;
75
+ g_assert_not_reached();
76
+
77
+ g_test_init(&argc, &argv, NULL);
78
+ qtest_add_func("/pvpanic-pci/panic", test_panic);
79
+
80
+ ret = g_test_run();
81
+
82
+ return ret;
83
+}
76
+}
84
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
77
diff --git a/target/arm/crypto_helper.c b/target/arm/tcg/crypto_helper.c
78
similarity index 100%
79
rename from target/arm/crypto_helper.c
80
rename to target/arm/tcg/crypto_helper.c
81
diff --git a/target/arm/helper-a64.c b/target/arm/tcg/helper-a64.c
82
similarity index 100%
83
rename from target/arm/helper-a64.c
84
rename to target/arm/tcg/helper-a64.c
85
diff --git a/target/arm/iwmmxt_helper.c b/target/arm/tcg/iwmmxt_helper.c
86
similarity index 100%
87
rename from target/arm/iwmmxt_helper.c
88
rename to target/arm/tcg/iwmmxt_helper.c
89
diff --git a/target/arm/m_helper.c b/target/arm/tcg/m_helper.c
90
similarity index 100%
91
rename from target/arm/m_helper.c
92
rename to target/arm/tcg/m_helper.c
93
diff --git a/target/arm/mte_helper.c b/target/arm/tcg/mte_helper.c
94
similarity index 100%
95
rename from target/arm/mte_helper.c
96
rename to target/arm/tcg/mte_helper.c
97
diff --git a/target/arm/mve_helper.c b/target/arm/tcg/mve_helper.c
98
similarity index 100%
99
rename from target/arm/mve_helper.c
100
rename to target/arm/tcg/mve_helper.c
101
diff --git a/target/arm/neon_helper.c b/target/arm/tcg/neon_helper.c
102
similarity index 100%
103
rename from target/arm/neon_helper.c
104
rename to target/arm/tcg/neon_helper.c
105
diff --git a/target/arm/op_helper.c b/target/arm/tcg/op_helper.c
106
similarity index 100%
107
rename from target/arm/op_helper.c
108
rename to target/arm/tcg/op_helper.c
109
diff --git a/target/arm/pauth_helper.c b/target/arm/tcg/pauth_helper.c
110
similarity index 100%
111
rename from target/arm/pauth_helper.c
112
rename to target/arm/tcg/pauth_helper.c
113
diff --git a/target/arm/sme_helper.c b/target/arm/tcg/sme_helper.c
114
similarity index 100%
115
rename from target/arm/sme_helper.c
116
rename to target/arm/tcg/sme_helper.c
117
diff --git a/target/arm/sve_helper.c b/target/arm/tcg/sve_helper.c
118
similarity index 100%
119
rename from target/arm/sve_helper.c
120
rename to target/arm/tcg/sve_helper.c
121
diff --git a/target/arm/tlb_helper.c b/target/arm/tcg/tlb_helper.c
122
similarity index 100%
123
rename from target/arm/tlb_helper.c
124
rename to target/arm/tcg/tlb_helper.c
125
diff --git a/target/arm/vec_helper.c b/target/arm/tcg/vec_helper.c
126
similarity index 100%
127
rename from target/arm/vec_helper.c
128
rename to target/arm/tcg/vec_helper.c
129
diff --git a/target/arm/meson.build b/target/arm/meson.build
85
index XXXXXXX..XXXXXXX 100644
130
index XXXXXXX..XXXXXXX 100644
86
--- a/tests/qtest/meson.build
131
--- a/target/arm/meson.build
87
+++ b/tests/qtest/meson.build
132
+++ b/target/arm/meson.build
88
@@ -XXX,XX +XXX,XX @@ endif
133
@@ -XXX,XX +XXX,XX @@
89
134
arm_ss = ss.source_set()
90
qtests_pci = \
135
arm_ss.add(files(
91
(config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) + \
136
'cpu.c',
92
+ (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \
137
- 'crypto_helper.c',
93
(config_all_devices.has_key('CONFIG_IVSHMEM_DEVICE') ? ['ivshmem-test'] : [])
138
'debug_helper.c',
94
139
'gdbstub.c',
95
qtests_i386 = \
140
'helper.c',
141
- 'iwmmxt_helper.c',
142
- 'm_helper.c',
143
- 'mve_helper.c',
144
- 'neon_helper.c',
145
- 'op_helper.c',
146
- 'tlb_helper.c',
147
- 'vec_helper.c',
148
'vfp_helper.c',
149
'cpu_tcg.c',
150
))
151
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: fil
152
arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
153
'cpu64.c',
154
'gdbstub64.c',
155
- 'helper-a64.c',
156
- 'mte_helper.c',
157
- 'pauth_helper.c',
158
- 'sve_helper.c',
159
- 'sme_helper.c',
160
))
161
162
arm_softmmu_ss = ss.source_set()
163
@@ -XXX,XX +XXX,XX @@ subdir('hvf')
164
165
if 'CONFIG_TCG' in config_all
166
subdir('tcg')
167
+else
168
+ arm_ss.add(files('tcg-stubs.c'))
169
endif
170
171
target_arch += {'arm': arm_ss}
172
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
173
index XXXXXXX..XXXXXXX 100644
174
--- a/target/arm/tcg/meson.build
175
+++ b/target/arm/tcg/meson.build
176
@@ -XXX,XX +XXX,XX @@ arm_ss.add(files(
177
'translate-mve.c',
178
'translate-neon.c',
179
'translate-vfp.c',
180
+ 'crypto_helper.c',
181
+ 'iwmmxt_helper.c',
182
+ 'm_helper.c',
183
+ 'mve_helper.c',
184
+ 'neon_helper.c',
185
+ 'op_helper.c',
186
+ 'tlb_helper.c',
187
+ 'vec_helper.c',
188
))
189
190
arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
191
'translate-a64.c',
192
'translate-sve.c',
193
'translate-sme.c',
194
+ 'helper-a64.c',
195
+ 'mte_helper.c',
196
+ 'pauth_helper.c',
197
+ 'sme_helper.c',
198
+ 'sve_helper.c',
199
))
96
--
200
--
97
2.20.1
201
2.34.1
98
202
99
203
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Claudio Fontana <cfontana@suse.de>
2
2
3
Add PCI interface support for PVPANIC device. Create a new file pvpanic-pci.c
3
Signed-off-by: Claudio Fontana <cfontana@suse.de>
4
where the PCI specific routines reside and update the build system with the new
4
Signed-off-by: Fabiano Rosas <farosas@suse.de>
5
files and config structure.
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
7
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
[PMM: wrapped one long line]
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
9
---
13
docs/specs/pci-ids.txt | 1 +
10
target/arm/{ => tcg}/psci.c | 0
14
include/hw/misc/pvpanic.h | 1 +
11
target/arm/meson.build | 1 -
15
include/hw/pci/pci.h | 1 +
12
target/arm/tcg/meson.build | 4 ++++
16
hw/misc/pvpanic-pci.c | 95 +++++++++++++++++++++++++++++++++++++++
13
3 files changed, 4 insertions(+), 1 deletion(-)
17
hw/misc/Kconfig | 6 +++
14
rename target/arm/{ => tcg}/psci.c (100%)
18
hw/misc/meson.build | 1 +
19
6 files changed, 105 insertions(+)
20
create mode 100644 hw/misc/pvpanic-pci.c
21
15
22
diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt
16
diff --git a/target/arm/psci.c b/target/arm/tcg/psci.c
17
similarity index 100%
18
rename from target/arm/psci.c
19
rename to target/arm/tcg/psci.c
20
diff --git a/target/arm/meson.build b/target/arm/meson.build
23
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
24
--- a/docs/specs/pci-ids.txt
22
--- a/target/arm/meson.build
25
+++ b/docs/specs/pci-ids.txt
23
+++ b/target/arm/meson.build
26
@@ -XXX,XX +XXX,XX @@ PCI devices (other than virtio):
24
@@ -XXX,XX +XXX,XX @@ arm_softmmu_ss.add(files(
27
1b36:000d PCI xhci usb host adapter
25
'arm-powerctl.c',
28
1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c
26
'machine.c',
29
1b36:0010 PCIe NVMe device (-device nvme)
27
'monitor.c',
30
+1b36:0011 PCI PVPanic device (-device pvpanic-pci)
28
- 'psci.c',
31
29
'ptw.c',
32
All these devices are documented in docs/specs.
30
))
33
31
34
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
32
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
35
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/misc/pvpanic.h
34
--- a/target/arm/tcg/meson.build
37
+++ b/include/hw/misc/pvpanic.h
35
+++ b/target/arm/tcg/meson.build
38
@@ -XXX,XX +XXX,XX @@
36
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
39
#include "qom/object.h"
37
'sme_helper.c',
40
38
'sve_helper.c',
41
#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"
39
))
42
+#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci"
43
44
#define PVPANIC_IOPORT_PROP "ioport"
45
46
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/include/hw/pci/pci.h
49
+++ b/include/hw/pci/pci.h
50
@@ -XXX,XX +XXX,XX @@ extern bool pci_available;
51
#define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e
52
#define PCI_DEVICE_ID_REDHAT_MDPY 0x000f
53
#define PCI_DEVICE_ID_REDHAT_NVME 0x0010
54
+#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011
55
#define PCI_DEVICE_ID_REDHAT_QXL 0x0100
56
57
#define FMT_PCIBUS PRIx64
58
diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c
59
new file mode 100644
60
index XXXXXXX..XXXXXXX
61
--- /dev/null
62
+++ b/hw/misc/pvpanic-pci.c
63
@@ -XXX,XX +XXX,XX @@
64
+/*
65
+ * QEMU simulated PCI pvpanic device.
66
+ *
67
+ * Copyright (C) 2020 Oracle
68
+ *
69
+ * Authors:
70
+ * Mihai Carabas <mihai.carabas@oracle.com>
71
+ *
72
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
73
+ * See the COPYING file in the top-level directory.
74
+ *
75
+ */
76
+
40
+
77
+#include "qemu/osdep.h"
41
+arm_softmmu_ss.add(files(
78
+#include "qemu/log.h"
42
+ 'psci.c',
79
+#include "qemu/module.h"
43
+))
80
+#include "sysemu/runstate.h"
81
+
82
+#include "hw/nvram/fw_cfg.h"
83
+#include "hw/qdev-properties.h"
84
+#include "migration/vmstate.h"
85
+#include "hw/misc/pvpanic.h"
86
+#include "qom/object.h"
87
+#include "hw/pci/pci.h"
88
+
89
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE)
90
+
91
+/*
92
+ * PVPanicPCIState for PCI device
93
+ */
94
+typedef struct PVPanicPCIState {
95
+ PCIDevice dev;
96
+ PVPanicState pvpanic;
97
+} PVPanicPCIState;
98
+
99
+static const VMStateDescription vmstate_pvpanic_pci = {
100
+ .name = "pvpanic-pci",
101
+ .version_id = 1,
102
+ .minimum_version_id = 1,
103
+ .fields = (VMStateField[]) {
104
+ VMSTATE_PCI_DEVICE(dev, PVPanicPCIState),
105
+ VMSTATE_END_OF_LIST()
106
+ }
107
+};
108
+
109
+static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp)
110
+{
111
+ PVPanicPCIState *s = PVPANIC_PCI_DEVICE(dev);
112
+ PVPanicState *ps = &s->pvpanic;
113
+
114
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), 2);
115
+
116
+ pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &ps->mr);
117
+}
118
+
119
+static Property pvpanic_pci_properties[] = {
120
+ DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events,
121
+ PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
122
+ DEFINE_PROP_END_OF_LIST(),
123
+};
124
+
125
+static void pvpanic_pci_class_init(ObjectClass *klass, void *data)
126
+{
127
+ DeviceClass *dc = DEVICE_CLASS(klass);
128
+ PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
129
+
130
+ device_class_set_props(dc, pvpanic_pci_properties);
131
+
132
+ pc->realize = pvpanic_pci_realizefn;
133
+ pc->vendor_id = PCI_VENDOR_ID_REDHAT;
134
+ pc->device_id = PCI_DEVICE_ID_REDHAT_PVPANIC;
135
+ pc->revision = 1;
136
+ pc->class_id = PCI_CLASS_SYSTEM_OTHER;
137
+ dc->vmsd = &vmstate_pvpanic_pci;
138
+
139
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
140
+}
141
+
142
+static TypeInfo pvpanic_pci_info = {
143
+ .name = TYPE_PVPANIC_PCI_DEVICE,
144
+ .parent = TYPE_PCI_DEVICE,
145
+ .instance_size = sizeof(PVPanicPCIState),
146
+ .class_init = pvpanic_pci_class_init,
147
+ .interfaces = (InterfaceInfo[]) {
148
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
149
+ { }
150
+ }
151
+};
152
+
153
+static void pvpanic_register_types(void)
154
+{
155
+ type_register_static(&pvpanic_pci_info);
156
+}
157
+
158
+type_init(pvpanic_register_types);
159
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
160
index XXXXXXX..XXXXXXX 100644
161
--- a/hw/misc/Kconfig
162
+++ b/hw/misc/Kconfig
163
@@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSINFO
164
config PVPANIC_COMMON
165
bool
166
167
+config PVPANIC_PCI
168
+ bool
169
+ default y if PCI_DEVICES
170
+ depends on PCI
171
+ select PVPANIC_COMMON
172
+
173
config PVPANIC_ISA
174
bool
175
depends on ISA_BUS
176
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
177
index XXXXXXX..XXXXXXX 100644
178
--- a/hw/misc/meson.build
179
+++ b/hw/misc/meson.build
180
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c'))
181
softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
182
183
softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
184
+softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
185
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
186
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
187
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
188
--
44
--
189
2.20.1
45
2.34.1
190
46
191
47
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
This adds handling for the SCR_EL3.EEL2 bit.
3
This is in preparation to moving the hflags code into its own file
4
4
under the tcg/ directory.
5
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
5
6
Message-id: 20210112104511.36576-17-remi.denis.courmont@huawei.com
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
[PMM: Applied fixes for review issues noted by RTH:
8
- check for FEATURE_AARCH64 before checking sel2 isar feature
9
- correct the commit message subject line]
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
target/arm/cpu.h | 8 ++++++--
11
hw/arm/boot.c | 6 +++++-
14
target/arm/cpu.c | 2 +-
12
hw/intc/armv7m_nvic.c | 20 +++++++++++++-------
15
target/arm/helper.c | 19 ++++++++++++++++---
13
target/arm/arm-powerctl.c | 7 +++++--
16
target/arm/translate.c | 15 +++++++++++++--
14
target/arm/cpu.c | 3 ++-
17
4 files changed, 36 insertions(+), 8 deletions(-)
15
target/arm/helper.c | 18 +++++++++++++-----
18
16
target/arm/machine.c | 5 ++++-
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
6 files changed, 42 insertions(+), 17 deletions(-)
20
index XXXXXXX..XXXXXXX 100644
18
21
--- a/target/arm/cpu.h
19
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
22
+++ b/target/arm/cpu.h
20
index XXXXXXX..XXXXXXX 100644
23
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env)
21
--- a/hw/arm/boot.c
24
static inline bool arm_is_el2_enabled(CPUARMState *env)
22
+++ b/hw/arm/boot.c
25
{
23
@@ -XXX,XX +XXX,XX @@
26
if (arm_feature(env, ARM_FEATURE_EL2)) {
24
#include "hw/arm/boot.h"
27
- return !arm_is_secure_below_el3(env);
25
#include "hw/arm/linux-boot-if.h"
28
+ if (arm_is_secure_below_el3(env)) {
26
#include "sysemu/kvm.h"
29
+ return (env->cp15.scr_el3 & SCR_EEL2) != 0;
27
+#include "sysemu/tcg.h"
28
#include "sysemu/sysemu.h"
29
#include "sysemu/numa.h"
30
#include "hw/boards.h"
31
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
32
info->secondary_cpu_reset_hook(cpu, info);
33
}
34
}
35
- arm_rebuild_hflags(env);
36
+
37
+ if (tcg_enabled()) {
38
+ arm_rebuild_hflags(env);
30
+ }
39
+ }
31
+ return true;
40
}
32
}
41
}
33
return false;
42
34
}
43
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
35
@@ -XXX,XX +XXX,XX @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el)
44
index XXXXXXX..XXXXXXX 100644
36
return aa64;
45
--- a/hw/intc/armv7m_nvic.c
37
}
46
+++ b/hw/intc/armv7m_nvic.c
38
47
@@ -XXX,XX +XXX,XX @@
39
- if (arm_feature(env, ARM_FEATURE_EL3)) {
48
#include "hw/intc/armv7m_nvic.h"
40
+ if (arm_feature(env, ARM_FEATURE_EL3) &&
49
#include "hw/irq.h"
41
+ ((env->cp15.scr_el3 & SCR_NS) || !(env->cp15.scr_el3 & SCR_EEL2))) {
50
#include "hw/qdev-properties.h"
42
aa64 = aa64 && (env->cp15.scr_el3 & SCR_RW);
51
+#include "sysemu/tcg.h"
43
}
52
#include "sysemu/runstate.h"
44
53
#include "target/arm/cpu.h"
54
#include "exec/exec-all.h"
55
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
56
/* This is UNPREDICTABLE; treat as RAZ/WI */
57
58
exit_ok:
59
- /* Ensure any changes made are reflected in the cached hflags. */
60
- arm_rebuild_hflags(&s->cpu->env);
61
+ if (tcg_enabled()) {
62
+ /* Ensure any changes made are reflected in the cached hflags. */
63
+ arm_rebuild_hflags(&s->cpu->env);
64
+ }
65
return MEMTX_OK;
66
}
67
68
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
69
}
70
}
71
72
- /*
73
- * We updated state that affects the CPU's MMUidx and thus its hflags;
74
- * and we can't guarantee that we run before the CPU reset function.
75
- */
76
- arm_rebuild_hflags(&s->cpu->env);
77
+ if (tcg_enabled()) {
78
+ /*
79
+ * We updated state that affects the CPU's MMUidx and thus its
80
+ * hflags; and we can't guarantee that we run before the CPU
81
+ * reset function.
82
+ */
83
+ arm_rebuild_hflags(&s->cpu->env);
84
+ }
85
}
86
87
static void nvic_systick_trigger(void *opaque, int n, int level)
88
diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c
89
index XXXXXXX..XXXXXXX 100644
90
--- a/target/arm/arm-powerctl.c
91
+++ b/target/arm/arm-powerctl.c
92
@@ -XXX,XX +XXX,XX @@
93
#include "arm-powerctl.h"
94
#include "qemu/log.h"
95
#include "qemu/main-loop.h"
96
+#include "sysemu/tcg.h"
97
98
#ifndef DEBUG_ARM_POWERCTL
99
#define DEBUG_ARM_POWERCTL 0
100
@@ -XXX,XX +XXX,XX @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state,
101
target_cpu->env.regs[0] = info->context_id;
102
}
103
104
- /* CP15 update requires rebuilding hflags */
105
- arm_rebuild_hflags(&target_cpu->env);
106
+ if (tcg_enabled()) {
107
+ /* CP15 update requires rebuilding hflags */
108
+ arm_rebuild_hflags(&target_cpu->env);
109
+ }
110
111
/* Start the new CPU at the requested address */
112
cpu_set_pc(target_cpu_state, info->entry);
45
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
113
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
46
index XXXXXXX..XXXXXXX 100644
114
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/cpu.c
115
--- a/target/arm/cpu.c
48
+++ b/target/arm/cpu.c
116
+++ b/target/arm/cpu.c
49
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
117
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj)
50
* masked from Secure state. The HCR and SCR settings
118
if (tcg_enabled()) {
51
* don't affect the masking logic, only the interrupt routing.
119
hw_breakpoint_update_all(cpu);
52
*/
120
hw_watchpoint_update_all(cpu);
53
- if (target_el == 3 || !secure) {
121
+
54
+ if (target_el == 3 || !secure || (env->cp15.scr_el3 & SCR_EEL2)) {
122
+ arm_rebuild_hflags(env);
55
unmasked = true;
123
}
56
}
124
- arm_rebuild_hflags(env);
57
} else {
125
}
126
127
#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
58
diff --git a/target/arm/helper.c b/target/arm/helper.c
128
diff --git a/target/arm/helper.c b/target/arm/helper.c
59
index XXXXXXX..XXXXXXX 100644
129
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/helper.c
130
--- a/target/arm/helper.c
61
+++ b/target/arm/helper.c
131
+++ b/target/arm/helper.c
62
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_trap_aa32s_el1(CPUARMState *env,
132
@@ -XXX,XX +XXX,XX @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
63
return CP_ACCESS_OK;
133
/* This may enable/disable the MMU, so do a TLB flush. */
64
}
134
tlb_flush(CPU(cpu));
65
if (arm_is_secure_below_el3(env)) {
135
66
+ if (env->cp15.scr_el3 & SCR_EEL2) {
136
- if (ri->type & ARM_CP_SUPPRESS_TB_END) {
67
+ return CP_ACCESS_TRAP_EL2;
137
+ if (tcg_enabled() && ri->type & ARM_CP_SUPPRESS_TB_END) {
68
+ }
138
/*
69
return CP_ACCESS_TRAP_EL3;
139
* Normally we would always end the TB on an SCTLR write; see the
70
}
140
* comment in ARMCPRegInfo sctlr initialization below for why Xscale
71
/* This will be EL1 NS and EL2 NS, which just UNDEF */
141
@@ -XXX,XX +XXX,XX @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
72
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
142
memset(env->zarray, 0, sizeof(env->zarray));
73
if (cpu_isar_feature(aa64_pauth, cpu)) {
143
}
74
valid_mask |= SCR_API | SCR_APK;
144
75
}
145
- arm_rebuild_hflags(env);
76
+ if (cpu_isar_feature(aa64_sel2, cpu)) {
146
+ if (tcg_enabled()) {
77
+ valid_mask |= SCR_EEL2;
147
+ arm_rebuild_hflags(env);
78
+ }
148
+ }
79
if (cpu_isar_feature(aa64_mte, cpu)) {
149
}
80
valid_mask |= SCR_ATA;
150
81
}
151
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
82
@@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri,
152
@@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
83
bool isread)
153
}
84
{
154
mask &= ~CACHED_CPSR_BITS;
85
if (ri->opc2 & 4) {
155
env->uncached_cpsr = (env->uncached_cpsr & ~mask) | (val & mask);
86
- /* The ATS12NSO* operations must trap to EL3 if executed in
156
- if (rebuild_hflags) {
87
+ /* The ATS12NSO* operations must trap to EL3 or EL2 if executed in
157
+ if (tcg_enabled() && rebuild_hflags) {
88
* Secure EL1 (which can only happen if EL3 is AArch64).
158
arm_rebuild_hflags(env);
89
* They are simply UNDEF if executed from NS EL1.
159
}
90
* They function normally from EL2 or EL3.
160
}
91
*/
161
@@ -XXX,XX +XXX,XX @@ static void take_aarch32_exception(CPUARMState *env, int new_mode,
92
if (arm_current_el(env) == 1) {
162
env->regs[14] = env->regs[15] + offset;
93
if (arm_is_secure_below_el3(env)) {
163
}
94
+ if (env->cp15.scr_el3 & SCR_EEL2) {
164
env->regs[15] = newpc;
95
+ return CP_ACCESS_TRAP_UNCATEGORIZED_EL2;
165
- arm_rebuild_hflags(env);
96
+ }
166
+
97
return CP_ACCESS_TRAP_UNCATEGORIZED_EL3;
167
+ if (tcg_enabled()) {
98
}
168
+ arm_rebuild_hflags(env);
99
return CP_ACCESS_TRAP_UNCATEGORIZED;
169
+ }
100
@@ -XXX,XX +XXX,XX @@ static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri,
170
}
101
static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri,
171
102
bool isread)
172
static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
103
{
173
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
104
- if (arm_current_el(env) == 3 && !(env->cp15.scr_el3 & SCR_NS)) {
174
pstate_write(env, PSTATE_DAIF | new_mode);
105
+ if (arm_current_el(env) == 3 &&
175
env->aarch64 = true;
106
+ !(env->cp15.scr_el3 & (SCR_NS | SCR_EEL2))) {
176
aarch64_restore_sp(env, new_el);
107
return CP_ACCESS_TRAP;
177
- helper_rebuild_hflags_a64(env, new_el);
108
}
178
+
109
return CP_ACCESS_OK;
179
+ if (tcg_enabled()) {
110
@@ -XXX,XX +XXX,XX @@ static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
180
+ helper_rebuild_hflags_a64(env, new_el);
111
bool isread)
181
+ }
112
{
182
113
/* The NSACR is RW at EL3, and RO for NS EL1 and NS EL2.
183
env->pc = addr;
114
- * At Secure EL1 it traps to EL3.
184
115
+ * At Secure EL1 it traps to EL3 or EL2.
185
diff --git a/target/arm/machine.c b/target/arm/machine.c
116
*/
186
index XXXXXXX..XXXXXXX 100644
117
if (arm_current_el(env) == 3) {
187
--- a/target/arm/machine.c
118
return CP_ACCESS_OK;
188
+++ b/target/arm/machine.c
119
}
189
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
120
if (arm_is_secure_below_el3(env)) {
190
if (!kvm_enabled()) {
121
+ if (env->cp15.scr_el3 & SCR_EEL2) {
191
pmu_op_finish(&cpu->env);
122
+ return CP_ACCESS_TRAP_EL2;
192
}
123
+ }
193
- arm_rebuild_hflags(&cpu->env);
124
return CP_ACCESS_TRAP_EL3;
194
+
125
}
195
+ if (tcg_enabled()) {
126
/* Accesses from EL1 NS and EL2 NS are UNDEF for write but allow reads. */
196
+ arm_rebuild_hflags(&cpu->env);
127
diff --git a/target/arm/translate.c b/target/arm/translate.c
197
+ }
128
index XXXXXXX..XXXXXXX 100644
198
129
--- a/target/arm/translate.c
199
return 0;
130
+++ b/target/arm/translate.c
200
}
131
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
132
}
133
if (s->current_el == 1) {
134
/* If we're in Secure EL1 (which implies that EL3 is AArch64)
135
- * then accesses to Mon registers trap to EL3
136
+ * then accesses to Mon registers trap to Secure EL2, if it exists,
137
+ * otherwise EL3.
138
*/
139
- TCGv_i32 tcg_el = tcg_const_i32(3);
140
+ TCGv_i32 tcg_el;
141
+
142
+ if (arm_dc_feature(s, ARM_FEATURE_AARCH64) &&
143
+ dc_isar_feature(aa64_sel2, s)) {
144
+ /* Target EL is EL<3 minus SCR_EL3.EEL2> */
145
+ tcg_el = load_cpu_field(cp15.scr_el3);
146
+ tcg_gen_sextract_i32(tcg_el, tcg_el, ctz32(SCR_EEL2), 1);
147
+ tcg_gen_addi_i32(tcg_el, tcg_el, 3);
148
+ } else {
149
+ tcg_el = tcg_const_i32(3);
150
+ }
151
152
gen_exception_el(s, EXCP_UDEF, syn_uncategorized(), tcg_el);
153
tcg_temp_free_i32(tcg_el);
154
--
201
--
155
2.20.1
202
2.34.1
156
203
157
204
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
The hflags are used only for TCG code, so introduce a new file
4
hflags.c to keep that code.
5
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210112104511.36576-14-remi.denis.courmont@huawei.com
8
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
target/arm/cpu.h | 6 +++-
11
target/arm/internals.h | 2 +
9
target/arm/internals.h | 22 ++++++++++++
12
target/arm/helper.c | 393 +-----------------------------------
10
target/arm/helper.c | 78 +++++++++++++++++++++++++++++-------------
13
target/arm/tcg-stubs.c | 4 +
11
3 files changed, 81 insertions(+), 25 deletions(-)
14
target/arm/tcg/hflags.c | 403 +++++++++++++++++++++++++++++++++++++
15
target/arm/tcg/meson.build | 1 +
16
5 files changed, 411 insertions(+), 392 deletions(-)
17
create mode 100644 target/arm/tcg/hflags.c
12
18
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
16
+++ b/target/arm/cpu.h
17
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
18
ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB,
19
ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB,
20
ARMMMUIdx_Stage1_E1_PAN = 2 | ARM_MMU_IDX_NOTLB,
21
+ ARMMMUIdx_Stage1_SE0 = 3 | ARM_MMU_IDX_NOTLB,
22
+ ARMMMUIdx_Stage1_SE1 = 4 | ARM_MMU_IDX_NOTLB,
23
+ ARMMMUIdx_Stage1_SE1_PAN = 5 | ARM_MMU_IDX_NOTLB,
24
/*
25
* Not allocated a TLB: used only for second stage of an S12 page
26
* table walk, or for descriptor loads during first stage of an S1
27
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
28
* then various TLB flush insns which currently are no-ops or flush
29
* only stage 1 MMU indexes will need to change to flush stage 2.
30
*/
31
- ARMMMUIdx_Stage2 = 3 | ARM_MMU_IDX_NOTLB,
32
+ ARMMMUIdx_Stage2 = 6 | ARM_MMU_IDX_NOTLB,
33
+ ARMMMUIdx_Stage2_S = 7 | ARM_MMU_IDX_NOTLB,
34
35
/*
36
* M-profile.
37
diff --git a/target/arm/internals.h b/target/arm/internals.h
19
diff --git a/target/arm/internals.h b/target/arm/internals.h
38
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/internals.h
21
--- a/target/arm/internals.h
40
+++ b/target/arm/internals.h
22
+++ b/target/arm/internals.h
41
@@ -XXX,XX +XXX,XX @@ static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx)
23
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
42
case ARMMMUIdx_Stage1_E0:
24
43
case ARMMMUIdx_Stage1_E1:
25
int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx);
44
case ARMMMUIdx_Stage1_E1_PAN:
26
int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx);
45
+ case ARMMMUIdx_Stage1_SE0:
27
+int aa64_va_parameter_tcma(uint64_t tcr, ARMMMUIdx mmu_idx);
46
+ case ARMMMUIdx_Stage1_SE1:
28
47
+ case ARMMMUIdx_Stage1_SE1_PAN:
29
/* Determine if allocation tags are available. */
48
case ARMMMUIdx_E10_0:
30
static inline bool allocation_tag_access_enabled(CPUARMState *env, int el,
49
case ARMMMUIdx_E10_1:
31
@@ -XXX,XX +XXX,XX @@ static inline bool arm_fgt_active(CPUARMState *env, int el)
50
case ARMMMUIdx_E10_1_PAN:
32
(!arm_feature(env, ARM_FEATURE_EL3) || (env->cp15.scr_el3 & SCR_FGTEN));
51
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx)
52
case ARMMMUIdx_SE20_0:
53
case ARMMMUIdx_SE20_2:
54
case ARMMMUIdx_SE20_2_PAN:
55
+ case ARMMMUIdx_Stage1_SE0:
56
+ case ARMMMUIdx_Stage1_SE1:
57
+ case ARMMMUIdx_Stage1_SE1_PAN:
58
case ARMMMUIdx_SE2:
59
+ case ARMMMUIdx_Stage2_S:
60
case ARMMMUIdx_MSPrivNegPri:
61
case ARMMMUIdx_MSUserNegPri:
62
case ARMMMUIdx_MSPriv:
63
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx)
64
{
65
switch (mmu_idx) {
66
case ARMMMUIdx_Stage1_E1_PAN:
67
+ case ARMMMUIdx_Stage1_SE1_PAN:
68
case ARMMMUIdx_E10_1_PAN:
69
case ARMMMUIdx_E20_2_PAN:
70
case ARMMMUIdx_SE10_1_PAN:
71
@@ -XXX,XX +XXX,XX @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
72
case ARMMMUIdx_E20_2:
73
case ARMMMUIdx_E20_2_PAN:
74
case ARMMMUIdx_Stage2:
75
+ case ARMMMUIdx_Stage2_S:
76
case ARMMMUIdx_SE2:
77
case ARMMMUIdx_E2:
78
return 2;
79
case ARMMMUIdx_SE3:
80
return 3;
81
case ARMMMUIdx_SE10_0:
82
+ case ARMMMUIdx_Stage1_SE0:
83
return arm_el_is_aa64(env, 3) ? 1 : 3;
84
case ARMMMUIdx_SE10_1:
85
case ARMMMUIdx_SE10_1_PAN:
86
case ARMMMUIdx_Stage1_E0:
87
case ARMMMUIdx_Stage1_E1:
88
case ARMMMUIdx_Stage1_E1_PAN:
89
+ case ARMMMUIdx_Stage1_SE1:
90
+ case ARMMMUIdx_Stage1_SE1_PAN:
91
case ARMMMUIdx_E10_0:
92
case ARMMMUIdx_E10_1:
93
case ARMMMUIdx_E10_1_PAN:
94
@@ -XXX,XX +XXX,XX @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx)
95
if (mmu_idx == ARMMMUIdx_Stage2) {
96
return &env->cp15.vtcr_el2;
97
}
98
+ if (mmu_idx == ARMMMUIdx_Stage2_S) {
99
+ /*
100
+ * Note: Secure stage 2 nominally shares fields from VTCR_EL2, but
101
+ * those are not currently used by QEMU, so just return VSTCR_EL2.
102
+ */
103
+ return &env->cp15.vstcr_el2;
104
+ }
105
return &env->cp15.tcr_el[regime_el(env, mmu_idx)];
106
}
33
}
107
34
108
@@ -XXX,XX +XXX,XX @@ static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx)
35
+void assert_hflags_rebuild_correctly(CPUARMState *env);
109
case ARMMMUIdx_Stage1_E0:
36
#endif
110
case ARMMMUIdx_Stage1_E1:
111
case ARMMMUIdx_Stage1_E1_PAN:
112
+ case ARMMMUIdx_Stage1_SE0:
113
+ case ARMMMUIdx_Stage1_SE1:
114
+ case ARMMMUIdx_Stage1_SE1_PAN:
115
return true;
116
default:
117
return false;
118
diff --git a/target/arm/helper.c b/target/arm/helper.c
37
diff --git a/target/arm/helper.c b/target/arm/helper.c
119
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
120
--- a/target/arm/helper.c
39
--- a/target/arm/helper.c
121
+++ b/target/arm/helper.c
40
+++ b/target/arm/helper.c
122
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
41
@@ -XXX,XX +XXX,XX @@ int sme_exception_el(CPUARMState *env, int el)
123
uint32_t syn, fsr, fsc;
42
return 0;
124
bool take_exc = false;
43
}
125
44
126
- if (fi.s1ptw && current_el == 1 && !arm_is_secure(env)
45
-/* This corresponds to the ARM pseudocode function IsFullA64Enabled(). */
127
+ if (fi.s1ptw && current_el == 1
46
-static bool sme_fa64(CPUARMState *env, int el)
128
&& arm_mmu_idx_is_stage1_of_2(mmu_idx)) {
47
-{
129
/*
48
- if (!cpu_isar_feature(aa64_sme_fa64, env_archcpu(env))) {
130
* Synchronous stage 2 fault on an access made as part of the
49
- return false;
131
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
50
- }
132
/* fall through */
51
-
133
case 1:
52
- if (el <= 1 && !el_is_in_host(env, el)) {
134
if (ri->crm == 9 && (env->uncached_cpsr & CPSR_PAN)) {
53
- if (!FIELD_EX64(env->vfp.smcr_el[1], SMCR, FA64)) {
135
- mmu_idx = (secure ? ARMMMUIdx_SE10_1_PAN
54
- return false;
136
+ mmu_idx = (secure ? ARMMMUIdx_Stage1_SE1_PAN
55
- }
137
: ARMMMUIdx_Stage1_E1_PAN);
56
- }
138
} else {
57
- if (el <= 2 && arm_is_el2_enabled(env)) {
139
- mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1;
58
- if (!FIELD_EX64(env->vfp.smcr_el[2], SMCR, FA64)) {
140
+ mmu_idx = secure ? ARMMMUIdx_Stage1_SE1 : ARMMMUIdx_Stage1_E1;
59
- return false;
141
}
60
- }
142
break;
61
- }
143
default:
62
- if (arm_feature(env, ARM_FEATURE_EL3)) {
144
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
63
- if (!FIELD_EX64(env->vfp.smcr_el[3], SMCR, FA64)) {
145
mmu_idx = ARMMMUIdx_SE10_0;
64
- return false;
146
break;
65
- }
147
case 2:
66
- }
148
+ g_assert(!secure); /* ARMv8.4-SecEL2 is 64-bit only */
67
-
149
mmu_idx = ARMMMUIdx_Stage1_E0;
68
- return true;
150
break;
69
-}
151
case 1:
70
-
152
- mmu_idx = secure ? ARMMMUIdx_SE10_0 : ARMMMUIdx_Stage1_E0;
71
/*
153
+ mmu_idx = secure ? ARMMMUIdx_Stage1_SE0 : ARMMMUIdx_Stage1_E0;
72
* Given that SVE is enabled, return the vector length for EL.
154
break;
73
*/
155
default:
74
@@ -XXX,XX +XXX,XX @@ int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx)
156
g_assert_not_reached();
157
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
158
switch (ri->opc1) {
159
case 0: /* AT S1E1R, AT S1E1W, AT S1E1RP, AT S1E1WP */
160
if (ri->crm == 9 && (env->pstate & PSTATE_PAN)) {
161
- mmu_idx = (secure ? ARMMMUIdx_SE10_1_PAN
162
+ mmu_idx = (secure ? ARMMMUIdx_Stage1_SE1_PAN
163
: ARMMMUIdx_Stage1_E1_PAN);
164
} else {
165
- mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1;
166
+ mmu_idx = secure ? ARMMMUIdx_Stage1_SE1 : ARMMMUIdx_Stage1_E1;
167
}
168
break;
169
case 4: /* AT S1E2R, AT S1E2W */
170
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
171
}
172
break;
173
case 2: /* AT S1E0R, AT S1E0W */
174
- mmu_idx = secure ? ARMMMUIdx_SE10_0 : ARMMMUIdx_Stage1_E0;
175
+ mmu_idx = secure ? ARMMMUIdx_Stage1_SE0 : ARMMMUIdx_Stage1_E0;
176
break;
177
case 4: /* AT S12E1R, AT S12E1W */
178
mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_E10_1;
179
@@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env,
180
181
hcr_el2 = arm_hcr_el2_eff(env);
182
183
- if (mmu_idx == ARMMMUIdx_Stage2) {
184
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
185
/* HCR.DC means HCR.VM behaves as 1 */
186
return (hcr_el2 & (HCR_DC | HCR_VM)) == 0;
187
}
75
}
188
@@ -XXX,XX +XXX,XX @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx,
76
}
189
if (mmu_idx == ARMMMUIdx_Stage2) {
77
190
return env->cp15.vttbr_el2;
78
-static int aa64_va_parameter_tcma(uint64_t tcr, ARMMMUIdx mmu_idx)
191
}
79
+int aa64_va_parameter_tcma(uint64_t tcr, ARMMMUIdx mmu_idx)
192
+ if (mmu_idx == ARMMMUIdx_Stage2_S) {
193
+ return env->cp15.vsttbr_el2;
194
+ }
195
if (ttbrn == 0) {
196
return env->cp15.ttbr0_el[regime_el(env, mmu_idx)];
197
} else {
198
@@ -XXX,XX +XXX,XX @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx,
199
static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx)
200
{
201
switch (mmu_idx) {
202
+ case ARMMMUIdx_SE10_0:
203
+ return ARMMMUIdx_Stage1_SE0;
204
+ case ARMMMUIdx_SE10_1:
205
+ return ARMMMUIdx_Stage1_SE1;
206
+ case ARMMMUIdx_SE10_1_PAN:
207
+ return ARMMMUIdx_Stage1_SE1_PAN;
208
case ARMMMUIdx_E10_0:
209
return ARMMMUIdx_Stage1_E0;
210
case ARMMMUIdx_E10_1:
211
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
212
case ARMMMUIdx_E20_0:
213
case ARMMMUIdx_SE20_0:
214
case ARMMMUIdx_Stage1_E0:
215
+ case ARMMMUIdx_Stage1_SE0:
216
case ARMMMUIdx_MUser:
217
case ARMMMUIdx_MSUser:
218
case ARMMMUIdx_MUserNegPri:
219
@@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64,
220
int wxn = 0;
221
222
assert(mmu_idx != ARMMMUIdx_Stage2);
223
+ assert(mmu_idx != ARMMMUIdx_Stage2_S);
224
225
user_rw = simple_ap_to_rw_prot_is_user(ap, true);
226
if (is_user) {
227
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
228
hwaddr s2pa;
229
int s2prot;
230
int ret;
231
+ ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S
232
+ : ARMMMUIdx_Stage2;
233
ARMCacheAttrs cacheattrs = {};
234
MemTxAttrs txattrs = {};
235
236
- assert(!*is_secure); /* TODO: S-EL2 */
237
-
238
- ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2,
239
- false,
240
+ ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, false,
241
&s2pa, &txattrs, &s2prot, &s2size, fi,
242
&cacheattrs);
243
if (ret) {
244
@@ -XXX,XX +XXX,XX @@ static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx)
245
{
80
{
246
if (regime_has_2_ranges(mmu_idx)) {
81
if (regime_has_2_ranges(mmu_idx)) {
247
return extract64(tcr, 37, 2);
82
return extract64(tcr, 57, 2);
248
- } else if (mmu_idx == ARMMMUIdx_Stage2) {
83
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env)
249
+ } else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
84
return arm_mmu_idx_el(env, arm_current_el(env));
250
return 0; /* VTCR_EL2 */
85
}
251
} else {
86
252
/* Replicate the single TBI bit so we always have 2 bits. */
87
-static inline bool fgt_svc(CPUARMState *env, int el)
253
@@ -XXX,XX +XXX,XX @@ static int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx)
88
-{
89
- /*
90
- * Assuming fine-grained-traps are active, return true if we
91
- * should be trapping on SVC instructions. Only AArch64 can
92
- * trap on an SVC at EL1, but we don't need to special-case this
93
- * because if this is AArch32 EL1 then arm_fgt_active() is false.
94
- * We also know el is 0 or 1.
95
- */
96
- return el == 0 ?
97
- FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL0) :
98
- FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL1);
99
-}
100
-
101
-static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el,
102
- ARMMMUIdx mmu_idx,
103
- CPUARMTBFlags flags)
104
-{
105
- DP_TBFLAG_ANY(flags, FPEXC_EL, fp_el);
106
- DP_TBFLAG_ANY(flags, MMUIDX, arm_to_core_mmu_idx(mmu_idx));
107
-
108
- if (arm_singlestep_active(env)) {
109
- DP_TBFLAG_ANY(flags, SS_ACTIVE, 1);
110
- }
111
-
112
- return flags;
113
-}
114
-
115
-static CPUARMTBFlags rebuild_hflags_common_32(CPUARMState *env, int fp_el,
116
- ARMMMUIdx mmu_idx,
117
- CPUARMTBFlags flags)
118
-{
119
- bool sctlr_b = arm_sctlr_b(env);
120
-
121
- if (sctlr_b) {
122
- DP_TBFLAG_A32(flags, SCTLR__B, 1);
123
- }
124
- if (arm_cpu_data_is_big_endian_a32(env, sctlr_b)) {
125
- DP_TBFLAG_ANY(flags, BE_DATA, 1);
126
- }
127
- DP_TBFLAG_A32(flags, NS, !access_secure_reg(env));
128
-
129
- return rebuild_hflags_common(env, fp_el, mmu_idx, flags);
130
-}
131
-
132
-static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el,
133
- ARMMMUIdx mmu_idx)
134
-{
135
- CPUARMTBFlags flags = {};
136
- uint32_t ccr = env->v7m.ccr[env->v7m.secure];
137
-
138
- /* Without HaveMainExt, CCR.UNALIGN_TRP is RES1. */
139
- if (ccr & R_V7M_CCR_UNALIGN_TRP_MASK) {
140
- DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
141
- }
142
-
143
- if (arm_v7m_is_handler_mode(env)) {
144
- DP_TBFLAG_M32(flags, HANDLER, 1);
145
- }
146
-
147
- /*
148
- * v8M always applies stack limit checks unless CCR.STKOFHFNMIGN
149
- * is suppressing them because the requested execution priority
150
- * is less than 0.
151
- */
152
- if (arm_feature(env, ARM_FEATURE_V8) &&
153
- !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) &&
154
- (ccr & R_V7M_CCR_STKOFHFNMIGN_MASK))) {
155
- DP_TBFLAG_M32(flags, STACKCHECK, 1);
156
- }
157
-
158
- if (arm_feature(env, ARM_FEATURE_M_SECURITY) && env->v7m.secure) {
159
- DP_TBFLAG_M32(flags, SECURE, 1);
160
- }
161
-
162
- return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags);
163
-}
164
-
165
-static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
166
- ARMMMUIdx mmu_idx)
167
-{
168
- CPUARMTBFlags flags = {};
169
- int el = arm_current_el(env);
170
-
171
- if (arm_sctlr(env, el) & SCTLR_A) {
172
- DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
173
- }
174
-
175
- if (arm_el_is_aa64(env, 1)) {
176
- DP_TBFLAG_A32(flags, VFPEN, 1);
177
- }
178
-
179
- if (el < 2 && env->cp15.hstr_el2 && arm_is_el2_enabled(env) &&
180
- (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
181
- DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1);
182
- }
183
-
184
- if (arm_fgt_active(env, el)) {
185
- DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1);
186
- if (fgt_svc(env, el)) {
187
- DP_TBFLAG_ANY(flags, FGT_SVC, 1);
188
- }
189
- }
190
-
191
- if (env->uncached_cpsr & CPSR_IL) {
192
- DP_TBFLAG_ANY(flags, PSTATE__IL, 1);
193
- }
194
-
195
- /*
196
- * The SME exception we are testing for is raised via
197
- * AArch64.CheckFPAdvSIMDEnabled(), as called from
198
- * AArch32.CheckAdvSIMDOrFPEnabled().
199
- */
200
- if (el == 0
201
- && FIELD_EX64(env->svcr, SVCR, SM)
202
- && (!arm_is_el2_enabled(env)
203
- || (arm_el_is_aa64(env, 2) && !(env->cp15.hcr_el2 & HCR_TGE)))
204
- && arm_el_is_aa64(env, 1)
205
- && !sme_fa64(env, el)) {
206
- DP_TBFLAG_A32(flags, SME_TRAP_NONSTREAMING, 1);
207
- }
208
-
209
- return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags);
210
-}
211
-
212
-static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
213
- ARMMMUIdx mmu_idx)
214
-{
215
- CPUARMTBFlags flags = {};
216
- ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx);
217
- uint64_t tcr = regime_tcr(env, mmu_idx);
218
- uint64_t sctlr;
219
- int tbii, tbid;
220
-
221
- DP_TBFLAG_ANY(flags, AARCH64_STATE, 1);
222
-
223
- /* Get control bits for tagged addresses. */
224
- tbid = aa64_va_parameter_tbi(tcr, mmu_idx);
225
- tbii = tbid & ~aa64_va_parameter_tbid(tcr, mmu_idx);
226
-
227
- DP_TBFLAG_A64(flags, TBII, tbii);
228
- DP_TBFLAG_A64(flags, TBID, tbid);
229
-
230
- if (cpu_isar_feature(aa64_sve, env_archcpu(env))) {
231
- int sve_el = sve_exception_el(env, el);
232
-
233
- /*
234
- * If either FP or SVE are disabled, translator does not need len.
235
- * If SVE EL > FP EL, FP exception has precedence, and translator
236
- * does not need SVE EL. Save potential re-translations by forcing
237
- * the unneeded data to zero.
238
- */
239
- if (fp_el != 0) {
240
- if (sve_el > fp_el) {
241
- sve_el = 0;
242
- }
243
- } else if (sve_el == 0) {
244
- DP_TBFLAG_A64(flags, VL, sve_vqm1_for_el(env, el));
245
- }
246
- DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el);
247
- }
248
- if (cpu_isar_feature(aa64_sme, env_archcpu(env))) {
249
- int sme_el = sme_exception_el(env, el);
250
- bool sm = FIELD_EX64(env->svcr, SVCR, SM);
251
-
252
- DP_TBFLAG_A64(flags, SMEEXC_EL, sme_el);
253
- if (sme_el == 0) {
254
- /* Similarly, do not compute SVL if SME is disabled. */
255
- int svl = sve_vqm1_for_el_sm(env, el, true);
256
- DP_TBFLAG_A64(flags, SVL, svl);
257
- if (sm) {
258
- /* If SVE is disabled, we will not have set VL above. */
259
- DP_TBFLAG_A64(flags, VL, svl);
260
- }
261
- }
262
- if (sm) {
263
- DP_TBFLAG_A64(flags, PSTATE_SM, 1);
264
- DP_TBFLAG_A64(flags, SME_TRAP_NONSTREAMING, !sme_fa64(env, el));
265
- }
266
- DP_TBFLAG_A64(flags, PSTATE_ZA, FIELD_EX64(env->svcr, SVCR, ZA));
267
- }
268
-
269
- sctlr = regime_sctlr(env, stage1);
270
-
271
- if (sctlr & SCTLR_A) {
272
- DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
273
- }
274
-
275
- if (arm_cpu_data_is_big_endian_a64(el, sctlr)) {
276
- DP_TBFLAG_ANY(flags, BE_DATA, 1);
277
- }
278
-
279
- if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) {
280
- /*
281
- * In order to save space in flags, we record only whether
282
- * pauth is "inactive", meaning all insns are implemented as
283
- * a nop, or "active" when some action must be performed.
284
- * The decision of which action to take is left to a helper.
285
- */
286
- if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) {
287
- DP_TBFLAG_A64(flags, PAUTH_ACTIVE, 1);
288
- }
289
- }
290
-
291
- if (cpu_isar_feature(aa64_bti, env_archcpu(env))) {
292
- /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */
293
- if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) {
294
- DP_TBFLAG_A64(flags, BT, 1);
295
- }
296
- }
297
-
298
- /* Compute the condition for using AccType_UNPRIV for LDTR et al. */
299
- if (!(env->pstate & PSTATE_UAO)) {
300
- switch (mmu_idx) {
301
- case ARMMMUIdx_E10_1:
302
- case ARMMMUIdx_E10_1_PAN:
303
- /* TODO: ARMv8.3-NV */
304
- DP_TBFLAG_A64(flags, UNPRIV, 1);
305
- break;
306
- case ARMMMUIdx_E20_2:
307
- case ARMMMUIdx_E20_2_PAN:
308
- /*
309
- * Note that EL20_2 is gated by HCR_EL2.E2H == 1, but EL20_0 is
310
- * gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR.
311
- */
312
- if (env->cp15.hcr_el2 & HCR_TGE) {
313
- DP_TBFLAG_A64(flags, UNPRIV, 1);
314
- }
315
- break;
316
- default:
317
- break;
318
- }
319
- }
320
-
321
- if (env->pstate & PSTATE_IL) {
322
- DP_TBFLAG_ANY(flags, PSTATE__IL, 1);
323
- }
324
-
325
- if (arm_fgt_active(env, el)) {
326
- DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1);
327
- if (FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, ERET)) {
328
- DP_TBFLAG_A64(flags, FGT_ERET, 1);
329
- }
330
- if (fgt_svc(env, el)) {
331
- DP_TBFLAG_ANY(flags, FGT_SVC, 1);
332
- }
333
- }
334
-
335
- if (cpu_isar_feature(aa64_mte, env_archcpu(env))) {
336
- /*
337
- * Set MTE_ACTIVE if any access may be Checked, and leave clear
338
- * if all accesses must be Unchecked:
339
- * 1) If no TBI, then there are no tags in the address to check,
340
- * 2) If Tag Check Override, then all accesses are Unchecked,
341
- * 3) If Tag Check Fail == 0, then Checked access have no effect,
342
- * 4) If no Allocation Tag Access, then all accesses are Unchecked.
343
- */
344
- if (allocation_tag_access_enabled(env, el, sctlr)) {
345
- DP_TBFLAG_A64(flags, ATA, 1);
346
- if (tbid
347
- && !(env->pstate & PSTATE_TCO)
348
- && (sctlr & (el == 0 ? SCTLR_TCF0 : SCTLR_TCF))) {
349
- DP_TBFLAG_A64(flags, MTE_ACTIVE, 1);
350
- }
351
- }
352
- /* And again for unprivileged accesses, if required. */
353
- if (EX_TBFLAG_A64(flags, UNPRIV)
354
- && tbid
355
- && !(env->pstate & PSTATE_TCO)
356
- && (sctlr & SCTLR_TCF0)
357
- && allocation_tag_access_enabled(env, 0, sctlr)) {
358
- DP_TBFLAG_A64(flags, MTE0_ACTIVE, 1);
359
- }
360
- /* Cache TCMA as well as TBI. */
361
- DP_TBFLAG_A64(flags, TCMA, aa64_va_parameter_tcma(tcr, mmu_idx));
362
- }
363
-
364
- return rebuild_hflags_common(env, fp_el, mmu_idx, flags);
365
-}
366
-
367
-static CPUARMTBFlags rebuild_hflags_internal(CPUARMState *env)
368
-{
369
- int el = arm_current_el(env);
370
- int fp_el = fp_exception_el(env, el);
371
- ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
372
-
373
- if (is_a64(env)) {
374
- return rebuild_hflags_a64(env, el, fp_el, mmu_idx);
375
- } else if (arm_feature(env, ARM_FEATURE_M)) {
376
- return rebuild_hflags_m32(env, fp_el, mmu_idx);
377
- } else {
378
- return rebuild_hflags_a32(env, fp_el, mmu_idx);
379
- }
380
-}
381
-
382
-void arm_rebuild_hflags(CPUARMState *env)
383
-{
384
- env->hflags = rebuild_hflags_internal(env);
385
-}
386
-
387
-/*
388
- * If we have triggered a EL state change we can't rely on the
389
- * translator having passed it to us, we need to recompute.
390
- */
391
-void HELPER(rebuild_hflags_m32_newel)(CPUARMState *env)
392
-{
393
- int el = arm_current_el(env);
394
- int fp_el = fp_exception_el(env, el);
395
- ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
396
-
397
- env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx);
398
-}
399
-
400
-void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el)
401
-{
402
- int fp_el = fp_exception_el(env, el);
403
- ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
404
-
405
- env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx);
406
-}
407
-
408
-/*
409
- * If we have triggered a EL state change we can't rely on the
410
- * translator having passed it to us, we need to recompute.
411
- */
412
-void HELPER(rebuild_hflags_a32_newel)(CPUARMState *env)
413
-{
414
- int el = arm_current_el(env);
415
- int fp_el = fp_exception_el(env, el);
416
- ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
417
- env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx);
418
-}
419
-
420
-void HELPER(rebuild_hflags_a32)(CPUARMState *env, int el)
421
-{
422
- int fp_el = fp_exception_el(env, el);
423
- ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
424
-
425
- env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx);
426
-}
427
-
428
-void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el)
429
-{
430
- int fp_el = fp_exception_el(env, el);
431
- ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
432
-
433
- env->hflags = rebuild_hflags_a64(env, el, fp_el, mmu_idx);
434
-}
435
-
436
-static inline void assert_hflags_rebuild_correctly(CPUARMState *env)
437
-{
438
-#ifdef CONFIG_DEBUG_TCG
439
- CPUARMTBFlags c = env->hflags;
440
- CPUARMTBFlags r = rebuild_hflags_internal(env);
441
-
442
- if (unlikely(c.flags != r.flags || c.flags2 != r.flags2)) {
443
- fprintf(stderr, "TCG hflags mismatch "
444
- "(current:(0x%08x,0x" TARGET_FMT_lx ")"
445
- " rebuilt:(0x%08x,0x" TARGET_FMT_lx ")\n",
446
- c.flags, c.flags2, r.flags, r.flags2);
447
- abort();
448
- }
449
-#endif
450
-}
451
-
452
static bool mve_no_pred(CPUARMState *env)
254
{
453
{
255
if (regime_has_2_ranges(mmu_idx)) {
454
/*
256
return extract64(tcr, 51, 2);
455
diff --git a/target/arm/tcg-stubs.c b/target/arm/tcg-stubs.c
257
- } else if (mmu_idx == ARMMMUIdx_Stage2) {
456
index XXXXXXX..XXXXXXX 100644
258
+ } else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
457
--- a/target/arm/tcg-stubs.c
259
return 0; /* VTCR_EL2 */
458
+++ b/target/arm/tcg-stubs.c
260
} else {
459
@@ -XXX,XX +XXX,XX @@ void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome,
261
/* Replicate the single TBID bit so we always have 2 bits. */
460
{
262
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
461
g_assert_not_reached();
263
tsz = extract32(tcr, 0, 6);
264
using64k = extract32(tcr, 14, 1);
265
using16k = extract32(tcr, 15, 1);
266
- if (mmu_idx == ARMMMUIdx_Stage2) {
267
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
268
/* VTCR_EL2 */
269
hpd = false;
270
} else {
271
@@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va,
272
int select, tsz;
273
bool epd, hpd;
274
275
+ assert(mmu_idx != ARMMMUIdx_Stage2_S);
276
+
277
if (mmu_idx == ARMMMUIdx_Stage2) {
278
/* VTCR */
279
bool sext = extract32(tcr, 4, 1);
280
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
281
goto do_fault;
282
}
283
284
- if (mmu_idx != ARMMMUIdx_Stage2) {
285
+ if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) {
286
/* The starting level depends on the virtual address size (which can
287
* be up to 48 bits) and the translation granule size. It indicates
288
* the number of strides (stride bits at a time) needed to
289
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
290
attrs = extract64(descriptor, 2, 10)
291
| (extract64(descriptor, 52, 12) << 10);
292
293
- if (mmu_idx == ARMMMUIdx_Stage2) {
294
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
295
/* Stage 2 table descriptors do not include any attribute fields */
296
break;
297
}
298
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
299
300
ap = extract32(attrs, 4, 2);
301
302
- if (mmu_idx == ARMMMUIdx_Stage2) {
303
- ns = true;
304
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
305
+ ns = mmu_idx == ARMMMUIdx_Stage2;
306
xn = extract32(attrs, 11, 2);
307
*prot = get_S2prot(env, ap, xn, s1_is_el0);
308
} else {
309
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
310
arm_tlb_bti_gp(txattrs) = true;
311
}
312
313
- if (mmu_idx == ARMMMUIdx_Stage2) {
314
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
315
cacheattrs->attrs = convert_stage2_attrs(env, extract32(attrs, 0, 4));
316
} else {
317
/* Index into MAIR registers for cache attributes */
318
@@ -XXX,XX +XXX,XX @@ do_fault:
319
fi->type = fault_type;
320
fi->level = level;
321
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
322
- fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2);
323
+ fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 ||
324
+ mmu_idx == ARMMMUIdx_Stage2_S);
325
return true;
326
}
462
}
327
463
+/* Temporarily while cpu_get_tb_cpu_state() is still in common code */
328
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
464
+void assert_hflags_rebuild_correctly(CPUARMState *env)
329
int s2_prot;
465
+{
330
int ret;
466
+}
331
ARMCacheAttrs cacheattrs2 = {};
467
diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c
332
+ ARMMMUIdx s2_mmu_idx;
468
new file mode 100644
333
+ bool is_el0;
469
index XXXXXXX..XXXXXXX
334
470
--- /dev/null
335
ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa,
471
+++ b/target/arm/tcg/hflags.c
336
attrs, prot, page_size, fi, cacheattrs);
472
@@ -XXX,XX +XXX,XX @@
337
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
473
+/*
338
return ret;
474
+ * ARM hflags
339
}
475
+ *
340
476
+ * This code is licensed under the GNU GPL v2 or later.
341
+ s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
477
+ *
342
+ is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0;
478
+ * SPDX-License-Identifier: GPL-2.0-or-later
343
+
479
+ */
344
/* S1 is done. Now do S2 translation. */
480
+#include "qemu/osdep.h"
345
- ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_Stage2,
481
+#include "cpu.h"
346
- mmu_idx == ARMMMUIdx_E10_0,
482
+#include "internals.h"
347
+ ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0,
483
+#include "exec/helper-proto.h"
348
phys_ptr, attrs, &s2_prot,
484
+#include "cpregs.h"
349
page_size, fi, &cacheattrs2);
485
+
350
fi->s2addr = ipa;
486
+static inline bool fgt_svc(CPUARMState *env, int el)
351
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
487
+{
352
cacheattrs->shareability = 0;
488
+ /*
353
}
489
+ * Assuming fine-grained-traps are active, return true if we
354
*cacheattrs = combine_cacheattrs(*cacheattrs, cacheattrs2);
490
+ * should be trapping on SVC instructions. Only AArch64 can
355
+
491
+ * trap on an SVC at EL1, but we don't need to special-case this
356
+ /* Check if IPA translates to secure or non-secure PA space. */
492
+ * because if this is AArch32 EL1 then arm_fgt_active() is false.
357
+ if (arm_is_secure_below_el3(env)) {
493
+ * We also know el is 0 or 1.
358
+ if (attrs->secure) {
494
+ */
359
+ attrs->secure =
495
+ return el == 0 ?
360
+ !(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW));
496
+ FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL0) :
361
+ } else {
497
+ FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL1);
362
+ attrs->secure =
498
+}
363
+ !((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_NSW))
499
+
364
+ || (env->cp15.vstcr_el2.raw_tcr & VSTCR_SA));
500
+static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el,
365
+ }
501
+ ARMMMUIdx mmu_idx,
502
+ CPUARMTBFlags flags)
503
+{
504
+ DP_TBFLAG_ANY(flags, FPEXC_EL, fp_el);
505
+ DP_TBFLAG_ANY(flags, MMUIDX, arm_to_core_mmu_idx(mmu_idx));
506
+
507
+ if (arm_singlestep_active(env)) {
508
+ DP_TBFLAG_ANY(flags, SS_ACTIVE, 1);
509
+ }
510
+
511
+ return flags;
512
+}
513
+
514
+static CPUARMTBFlags rebuild_hflags_common_32(CPUARMState *env, int fp_el,
515
+ ARMMMUIdx mmu_idx,
516
+ CPUARMTBFlags flags)
517
+{
518
+ bool sctlr_b = arm_sctlr_b(env);
519
+
520
+ if (sctlr_b) {
521
+ DP_TBFLAG_A32(flags, SCTLR__B, 1);
522
+ }
523
+ if (arm_cpu_data_is_big_endian_a32(env, sctlr_b)) {
524
+ DP_TBFLAG_ANY(flags, BE_DATA, 1);
525
+ }
526
+ DP_TBFLAG_A32(flags, NS, !access_secure_reg(env));
527
+
528
+ return rebuild_hflags_common(env, fp_el, mmu_idx, flags);
529
+}
530
+
531
+static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el,
532
+ ARMMMUIdx mmu_idx)
533
+{
534
+ CPUARMTBFlags flags = {};
535
+ uint32_t ccr = env->v7m.ccr[env->v7m.secure];
536
+
537
+ /* Without HaveMainExt, CCR.UNALIGN_TRP is RES1. */
538
+ if (ccr & R_V7M_CCR_UNALIGN_TRP_MASK) {
539
+ DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
540
+ }
541
+
542
+ if (arm_v7m_is_handler_mode(env)) {
543
+ DP_TBFLAG_M32(flags, HANDLER, 1);
544
+ }
545
+
546
+ /*
547
+ * v8M always applies stack limit checks unless CCR.STKOFHFNMIGN
548
+ * is suppressing them because the requested execution priority
549
+ * is less than 0.
550
+ */
551
+ if (arm_feature(env, ARM_FEATURE_V8) &&
552
+ !((mmu_idx & ARM_MMU_IDX_M_NEGPRI) &&
553
+ (ccr & R_V7M_CCR_STKOFHFNMIGN_MASK))) {
554
+ DP_TBFLAG_M32(flags, STACKCHECK, 1);
555
+ }
556
+
557
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) && env->v7m.secure) {
558
+ DP_TBFLAG_M32(flags, SECURE, 1);
559
+ }
560
+
561
+ return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags);
562
+}
563
+
564
+/* This corresponds to the ARM pseudocode function IsFullA64Enabled(). */
565
+static bool sme_fa64(CPUARMState *env, int el)
566
+{
567
+ if (!cpu_isar_feature(aa64_sme_fa64, env_archcpu(env))) {
568
+ return false;
569
+ }
570
+
571
+ if (el <= 1 && !el_is_in_host(env, el)) {
572
+ if (!FIELD_EX64(env->vfp.smcr_el[1], SMCR, FA64)) {
573
+ return false;
574
+ }
575
+ }
576
+ if (el <= 2 && arm_is_el2_enabled(env)) {
577
+ if (!FIELD_EX64(env->vfp.smcr_el[2], SMCR, FA64)) {
578
+ return false;
579
+ }
580
+ }
581
+ if (arm_feature(env, ARM_FEATURE_EL3)) {
582
+ if (!FIELD_EX64(env->vfp.smcr_el[3], SMCR, FA64)) {
583
+ return false;
584
+ }
585
+ }
586
+
587
+ return true;
588
+}
589
+
590
+static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
591
+ ARMMMUIdx mmu_idx)
592
+{
593
+ CPUARMTBFlags flags = {};
594
+ int el = arm_current_el(env);
595
+
596
+ if (arm_sctlr(env, el) & SCTLR_A) {
597
+ DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
598
+ }
599
+
600
+ if (arm_el_is_aa64(env, 1)) {
601
+ DP_TBFLAG_A32(flags, VFPEN, 1);
602
+ }
603
+
604
+ if (el < 2 && env->cp15.hstr_el2 && arm_is_el2_enabled(env) &&
605
+ (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
606
+ DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1);
607
+ }
608
+
609
+ if (arm_fgt_active(env, el)) {
610
+ DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1);
611
+ if (fgt_svc(env, el)) {
612
+ DP_TBFLAG_ANY(flags, FGT_SVC, 1);
613
+ }
614
+ }
615
+
616
+ if (env->uncached_cpsr & CPSR_IL) {
617
+ DP_TBFLAG_ANY(flags, PSTATE__IL, 1);
618
+ }
619
+
620
+ /*
621
+ * The SME exception we are testing for is raised via
622
+ * AArch64.CheckFPAdvSIMDEnabled(), as called from
623
+ * AArch32.CheckAdvSIMDOrFPEnabled().
624
+ */
625
+ if (el == 0
626
+ && FIELD_EX64(env->svcr, SVCR, SM)
627
+ && (!arm_is_el2_enabled(env)
628
+ || (arm_el_is_aa64(env, 2) && !(env->cp15.hcr_el2 & HCR_TGE)))
629
+ && arm_el_is_aa64(env, 1)
630
+ && !sme_fa64(env, el)) {
631
+ DP_TBFLAG_A32(flags, SME_TRAP_NONSTREAMING, 1);
632
+ }
633
+
634
+ return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags);
635
+}
636
+
637
+static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
638
+ ARMMMUIdx mmu_idx)
639
+{
640
+ CPUARMTBFlags flags = {};
641
+ ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx);
642
+ uint64_t tcr = regime_tcr(env, mmu_idx);
643
+ uint64_t sctlr;
644
+ int tbii, tbid;
645
+
646
+ DP_TBFLAG_ANY(flags, AARCH64_STATE, 1);
647
+
648
+ /* Get control bits for tagged addresses. */
649
+ tbid = aa64_va_parameter_tbi(tcr, mmu_idx);
650
+ tbii = tbid & ~aa64_va_parameter_tbid(tcr, mmu_idx);
651
+
652
+ DP_TBFLAG_A64(flags, TBII, tbii);
653
+ DP_TBFLAG_A64(flags, TBID, tbid);
654
+
655
+ if (cpu_isar_feature(aa64_sve, env_archcpu(env))) {
656
+ int sve_el = sve_exception_el(env, el);
657
+
658
+ /*
659
+ * If either FP or SVE are disabled, translator does not need len.
660
+ * If SVE EL > FP EL, FP exception has precedence, and translator
661
+ * does not need SVE EL. Save potential re-translations by forcing
662
+ * the unneeded data to zero.
663
+ */
664
+ if (fp_el != 0) {
665
+ if (sve_el > fp_el) {
666
+ sve_el = 0;
366
+ }
667
+ }
367
return 0;
668
+ } else if (sve_el == 0) {
368
} else {
669
+ DP_TBFLAG_A64(flags, VL, sve_vqm1_for_el(env, el));
369
/*
670
+ }
370
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
671
+ DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el);
371
* MMU disabled. S1 addresses within aa64 translation regimes are
672
+ }
372
* still checked for bounds -- see AArch64.TranslateAddressS1Off.
673
+ if (cpu_isar_feature(aa64_sme, env_archcpu(env))) {
373
*/
674
+ int sme_el = sme_exception_el(env, el);
374
- if (mmu_idx != ARMMMUIdx_Stage2) {
675
+ bool sm = FIELD_EX64(env->svcr, SVCR, SM);
375
+ if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) {
676
+
376
int r_el = regime_el(env, mmu_idx);
677
+ DP_TBFLAG_A64(flags, SMEEXC_EL, sme_el);
377
if (arm_el_is_aa64(env, r_el)) {
678
+ if (sme_el == 0) {
378
int pamax = arm_pamax(env_archcpu(env));
679
+ /* Similarly, do not compute SVL if SME is disabled. */
680
+ int svl = sve_vqm1_for_el_sm(env, el, true);
681
+ DP_TBFLAG_A64(flags, SVL, svl);
682
+ if (sm) {
683
+ /* If SVE is disabled, we will not have set VL above. */
684
+ DP_TBFLAG_A64(flags, VL, svl);
685
+ }
686
+ }
687
+ if (sm) {
688
+ DP_TBFLAG_A64(flags, PSTATE_SM, 1);
689
+ DP_TBFLAG_A64(flags, SME_TRAP_NONSTREAMING, !sme_fa64(env, el));
690
+ }
691
+ DP_TBFLAG_A64(flags, PSTATE_ZA, FIELD_EX64(env->svcr, SVCR, ZA));
692
+ }
693
+
694
+ sctlr = regime_sctlr(env, stage1);
695
+
696
+ if (sctlr & SCTLR_A) {
697
+ DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
698
+ }
699
+
700
+ if (arm_cpu_data_is_big_endian_a64(el, sctlr)) {
701
+ DP_TBFLAG_ANY(flags, BE_DATA, 1);
702
+ }
703
+
704
+ if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) {
705
+ /*
706
+ * In order to save space in flags, we record only whether
707
+ * pauth is "inactive", meaning all insns are implemented as
708
+ * a nop, or "active" when some action must be performed.
709
+ * The decision of which action to take is left to a helper.
710
+ */
711
+ if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) {
712
+ DP_TBFLAG_A64(flags, PAUTH_ACTIVE, 1);
713
+ }
714
+ }
715
+
716
+ if (cpu_isar_feature(aa64_bti, env_archcpu(env))) {
717
+ /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */
718
+ if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) {
719
+ DP_TBFLAG_A64(flags, BT, 1);
720
+ }
721
+ }
722
+
723
+ /* Compute the condition for using AccType_UNPRIV for LDTR et al. */
724
+ if (!(env->pstate & PSTATE_UAO)) {
725
+ switch (mmu_idx) {
726
+ case ARMMMUIdx_E10_1:
727
+ case ARMMMUIdx_E10_1_PAN:
728
+ /* TODO: ARMv8.3-NV */
729
+ DP_TBFLAG_A64(flags, UNPRIV, 1);
730
+ break;
731
+ case ARMMMUIdx_E20_2:
732
+ case ARMMMUIdx_E20_2_PAN:
733
+ /*
734
+ * Note that EL20_2 is gated by HCR_EL2.E2H == 1, but EL20_0 is
735
+ * gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR.
736
+ */
737
+ if (env->cp15.hcr_el2 & HCR_TGE) {
738
+ DP_TBFLAG_A64(flags, UNPRIV, 1);
739
+ }
740
+ break;
741
+ default:
742
+ break;
743
+ }
744
+ }
745
+
746
+ if (env->pstate & PSTATE_IL) {
747
+ DP_TBFLAG_ANY(flags, PSTATE__IL, 1);
748
+ }
749
+
750
+ if (arm_fgt_active(env, el)) {
751
+ DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1);
752
+ if (FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, ERET)) {
753
+ DP_TBFLAG_A64(flags, FGT_ERET, 1);
754
+ }
755
+ if (fgt_svc(env, el)) {
756
+ DP_TBFLAG_ANY(flags, FGT_SVC, 1);
757
+ }
758
+ }
759
+
760
+ if (cpu_isar_feature(aa64_mte, env_archcpu(env))) {
761
+ /*
762
+ * Set MTE_ACTIVE if any access may be Checked, and leave clear
763
+ * if all accesses must be Unchecked:
764
+ * 1) If no TBI, then there are no tags in the address to check,
765
+ * 2) If Tag Check Override, then all accesses are Unchecked,
766
+ * 3) If Tag Check Fail == 0, then Checked access have no effect,
767
+ * 4) If no Allocation Tag Access, then all accesses are Unchecked.
768
+ */
769
+ if (allocation_tag_access_enabled(env, el, sctlr)) {
770
+ DP_TBFLAG_A64(flags, ATA, 1);
771
+ if (tbid
772
+ && !(env->pstate & PSTATE_TCO)
773
+ && (sctlr & (el == 0 ? SCTLR_TCF0 : SCTLR_TCF))) {
774
+ DP_TBFLAG_A64(flags, MTE_ACTIVE, 1);
775
+ }
776
+ }
777
+ /* And again for unprivileged accesses, if required. */
778
+ if (EX_TBFLAG_A64(flags, UNPRIV)
779
+ && tbid
780
+ && !(env->pstate & PSTATE_TCO)
781
+ && (sctlr & SCTLR_TCF0)
782
+ && allocation_tag_access_enabled(env, 0, sctlr)) {
783
+ DP_TBFLAG_A64(flags, MTE0_ACTIVE, 1);
784
+ }
785
+ /* Cache TCMA as well as TBI. */
786
+ DP_TBFLAG_A64(flags, TCMA, aa64_va_parameter_tcma(tcr, mmu_idx));
787
+ }
788
+
789
+ return rebuild_hflags_common(env, fp_el, mmu_idx, flags);
790
+}
791
+
792
+static CPUARMTBFlags rebuild_hflags_internal(CPUARMState *env)
793
+{
794
+ int el = arm_current_el(env);
795
+ int fp_el = fp_exception_el(env, el);
796
+ ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
797
+
798
+ if (is_a64(env)) {
799
+ return rebuild_hflags_a64(env, el, fp_el, mmu_idx);
800
+ } else if (arm_feature(env, ARM_FEATURE_M)) {
801
+ return rebuild_hflags_m32(env, fp_el, mmu_idx);
802
+ } else {
803
+ return rebuild_hflags_a32(env, fp_el, mmu_idx);
804
+ }
805
+}
806
+
807
+void arm_rebuild_hflags(CPUARMState *env)
808
+{
809
+ env->hflags = rebuild_hflags_internal(env);
810
+}
811
+
812
+/*
813
+ * If we have triggered a EL state change we can't rely on the
814
+ * translator having passed it to us, we need to recompute.
815
+ */
816
+void HELPER(rebuild_hflags_m32_newel)(CPUARMState *env)
817
+{
818
+ int el = arm_current_el(env);
819
+ int fp_el = fp_exception_el(env, el);
820
+ ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
821
+
822
+ env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx);
823
+}
824
+
825
+void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el)
826
+{
827
+ int fp_el = fp_exception_el(env, el);
828
+ ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
829
+
830
+ env->hflags = rebuild_hflags_m32(env, fp_el, mmu_idx);
831
+}
832
+
833
+/*
834
+ * If we have triggered a EL state change we can't rely on the
835
+ * translator having passed it to us, we need to recompute.
836
+ */
837
+void HELPER(rebuild_hflags_a32_newel)(CPUARMState *env)
838
+{
839
+ int el = arm_current_el(env);
840
+ int fp_el = fp_exception_el(env, el);
841
+ ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
842
+ env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx);
843
+}
844
+
845
+void HELPER(rebuild_hflags_a32)(CPUARMState *env, int el)
846
+{
847
+ int fp_el = fp_exception_el(env, el);
848
+ ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
849
+
850
+ env->hflags = rebuild_hflags_a32(env, fp_el, mmu_idx);
851
+}
852
+
853
+void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el)
854
+{
855
+ int fp_el = fp_exception_el(env, el);
856
+ ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, el);
857
+
858
+ env->hflags = rebuild_hflags_a64(env, el, fp_el, mmu_idx);
859
+}
860
+
861
+void assert_hflags_rebuild_correctly(CPUARMState *env)
862
+{
863
+#ifdef CONFIG_DEBUG_TCG
864
+ CPUARMTBFlags c = env->hflags;
865
+ CPUARMTBFlags r = rebuild_hflags_internal(env);
866
+
867
+ if (unlikely(c.flags != r.flags || c.flags2 != r.flags2)) {
868
+ fprintf(stderr, "TCG hflags mismatch "
869
+ "(current:(0x%08x,0x" TARGET_FMT_lx ")"
870
+ " rebuilt:(0x%08x,0x" TARGET_FMT_lx ")\n",
871
+ c.flags, c.flags2, r.flags, r.flags2);
872
+ abort();
873
+ }
874
+#endif
875
+}
876
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
877
index XXXXXXX..XXXXXXX 100644
878
--- a/target/arm/tcg/meson.build
879
+++ b/target/arm/tcg/meson.build
880
@@ -XXX,XX +XXX,XX @@ arm_ss.add(files(
881
'translate-neon.c',
882
'translate-vfp.c',
883
'crypto_helper.c',
884
+ 'hflags.c',
885
'iwmmxt_helper.c',
886
'm_helper.c',
887
'mve_helper.c',
379
--
888
--
380
2.20.1
889
2.34.1
381
890
382
891
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
SVE predicate operations cannot use the "usual" simd_desc
3
This function is needed by common code (ptw.c), so move it along with
4
encoding, because the lengths are not a multiple of 8.
4
the other regime_* functions in internal.h. When we enable the build
5
But we were abusing the SIMD_* fields to store values anyway.
5
without TCG, the tlb_helper.c file will not be present.
6
This abuse broke when SIMD_OPRSZ_BITS was modified in e2e7168a214.
7
6
8
Introduce a new set of field definitions for exclusive use
7
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
of predicates, so that it is obvious what kind of predicate
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
we are manipulating. To be used in future patches.
9
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
12
Cc: qemu-stable@nongnu.org
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20210113062650.593824-2-richard.henderson@linaro.org
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
11
---
18
target/arm/internals.h | 9 +++++++++
12
target/arm/internals.h | 21 ++++++++++++++++++---
19
1 file changed, 9 insertions(+)
13
target/arm/tcg/tlb_helper.c | 18 ------------------
14
2 files changed, 18 insertions(+), 21 deletions(-)
20
15
21
diff --git a/target/arm/internals.h b/target/arm/internals.h
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
22
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/internals.h
18
--- a/target/arm/internals.h
24
+++ b/target/arm/internals.h
19
+++ b/target/arm/internals.h
25
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx);
20
@@ -XXX,XX +XXX,XX @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx);
26
#define LOG2_TAG_GRANULE 4
21
/* Return the MMU index for a v7M CPU in the specified security state */
27
#define TAG_GRANULE (1 << LOG2_TAG_GRANULE)
22
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
28
23
29
+/*
24
-/* Return true if the translation regime is using LPAE format page tables */
30
+ * SVE predicates are 1/8 the size of SVE vectors, and cannot use
25
-bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx);
31
+ * the same simd_desc() encoding due to restrictions on size.
26
-
32
+ * Use these instead.
27
/*
33
+ */
28
* Return true if the stage 1 translation regime is using LPAE
34
+FIELD(PREDDESC, OPRSZ, 0, 6)
29
* format page tables
35
+FIELD(PREDDESC, ESZ, 6, 2)
30
@@ -XXX,XX +XXX,XX @@ static inline uint64_t regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx)
36
+FIELD(PREDDESC, DATA, 8, 24)
31
return env->cp15.tcr_el[regime_el(env, mmu_idx)];
32
}
33
34
+/* Return true if the translation regime is using LPAE format page tables */
35
+static inline bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx)
36
+{
37
+ int el = regime_el(env, mmu_idx);
38
+ if (el == 2 || arm_el_is_aa64(env, el)) {
39
+ return true;
40
+ }
41
+ if (arm_feature(env, ARM_FEATURE_PMSA) &&
42
+ arm_feature(env, ARM_FEATURE_V8)) {
43
+ return true;
44
+ }
45
+ if (arm_feature(env, ARM_FEATURE_LPAE)
46
+ && (regime_tcr(env, mmu_idx) & TTBCR_EAE)) {
47
+ return true;
48
+ }
49
+ return false;
50
+}
37
+
51
+
52
/**
53
* arm_num_brps: Return number of implemented breakpoints.
54
* Note that the ID register BRPS field is "number of bps - 1",
55
diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/target/arm/tcg/tlb_helper.c
58
+++ b/target/arm/tcg/tlb_helper.c
59
@@ -XXX,XX +XXX,XX @@
60
#include "exec/helper-proto.h"
61
62
63
-/* Return true if the translation regime is using LPAE format page tables */
64
-bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx)
65
-{
66
- int el = regime_el(env, mmu_idx);
67
- if (el == 2 || arm_el_is_aa64(env, el)) {
68
- return true;
69
- }
70
- if (arm_feature(env, ARM_FEATURE_PMSA) &&
71
- arm_feature(env, ARM_FEATURE_V8)) {
72
- return true;
73
- }
74
- if (arm_feature(env, ARM_FEATURE_LPAE)
75
- && (regime_tcr(env, mmu_idx) & TTBCR_EAE)) {
76
- return true;
77
- }
78
- return false;
79
-}
80
-
38
/*
81
/*
39
* The SVE simd_data field, for memory ops, contains either
82
* Returns true if the stage 1 translation regime is using LPAE format page
40
* rd (5 bits) or a shift count (2 bits).
83
* tables. Used when raising alignment exceptions, whose FSR changes depending
41
--
84
--
42
2.20.1
85
2.34.1
43
86
44
87
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Do not assume that EL2 is available in and only in non-secure context.
3
When TCG is disabled this part of the code should not be reachable, so
4
That equivalence is broken by ARMv8.4-SEL2.
4
wrap it with an ifdef for now.
5
5
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210112104511.36576-3-remi.denis.courmont@huawei.com
8
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
target/arm/cpu.h | 4 ++--
11
target/arm/ptw.c | 4 ++++
12
target/arm/helper-a64.c | 8 +-------
12
1 file changed, 4 insertions(+)
13
target/arm/helper.c | 33 +++++++++++++--------------------
14
3 files changed, 16 insertions(+), 29 deletions(-)
15
13
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
16
--- a/target/arm/ptw.c
19
+++ b/target/arm/cpu.h
17
+++ b/target/arm/ptw.c
20
@@ -XXX,XX +XXX,XX @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el)
18
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
21
return aa64;
19
ptw->out_host = NULL;
20
ptw->out_rw = false;
21
} else {
22
+#ifdef CONFIG_TCG
23
CPUTLBEntryFull *full;
24
int flags;
25
26
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
27
ptw->out_rw = full->prot & PAGE_WRITE;
28
pte_attrs = full->pte_attrs;
29
pte_secure = full->attrs.secure;
30
+#else
31
+ g_assert_not_reached();
32
+#endif
22
}
33
}
23
34
24
- if (arm_feature(env, ARM_FEATURE_EL2) && !arm_is_secure_below_el3(env)) {
35
if (regime_is_stage2(s2_mmu_idx)) {
25
+ if (arm_is_el2_enabled(env)) {
26
aa64 = aa64 && (env->cp15.hcr_el2 & HCR_RW);
27
}
28
29
@@ -XXX,XX +XXX,XX @@ static inline int arm_debug_target_el(CPUARMState *env)
30
bool secure = arm_is_secure(env);
31
bool route_to_el2 = false;
32
33
- if (arm_feature(env, ARM_FEATURE_EL2) && !secure) {
34
+ if (arm_is_el2_enabled(env)) {
35
route_to_el2 = env->cp15.hcr_el2 & HCR_TGE ||
36
env->cp15.mdcr_el2 & MDCR_TDE;
37
}
38
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/helper-a64.c
41
+++ b/target/arm/helper-a64.c
42
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
43
if (new_el == -1) {
44
goto illegal_return;
45
}
46
- if (new_el > cur_el
47
- || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) {
48
+ if (new_el > cur_el || (new_el == 2 && !arm_is_el2_enabled(env))) {
49
/* Disallow return to an EL which is unimplemented or higher
50
* than the current one.
51
*/
52
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
53
goto illegal_return;
54
}
55
56
- if (new_el == 2 && arm_is_secure_below_el3(env)) {
57
- /* Return to the non-existent secure-EL2 */
58
- goto illegal_return;
59
- }
60
-
61
if (new_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) {
62
goto illegal_return;
63
}
64
diff --git a/target/arm/helper.c b/target/arm/helper.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/arm/helper.c
67
+++ b/target/arm/helper.c
68
@@ -XXX,XX +XXX,XX @@ static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
69
{
70
if (arm_feature(env, ARM_FEATURE_V8)) {
71
/* Check if CPACR accesses are to be trapped to EL2 */
72
- if (arm_current_el(env) == 1 &&
73
- (env->cp15.cptr_el[2] & CPTR_TCPAC) && !arm_is_secure(env)) {
74
+ if (arm_current_el(env) == 1 && arm_is_el2_enabled(env) &&
75
+ (env->cp15.cptr_el[2] & CPTR_TCPAC)) {
76
return CP_ACCESS_TRAP_EL2;
77
/* Check if CPACR accesses are to be trapped to EL3 */
78
} else if (arm_current_el(env) < 3 &&
79
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
80
bool isread)
81
{
82
unsigned int cur_el = arm_current_el(env);
83
- bool secure = arm_is_secure(env);
84
+ bool has_el2 = arm_is_el2_enabled(env);
85
uint64_t hcr = arm_hcr_el2_eff(env);
86
87
switch (cur_el) {
88
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
89
}
90
} else {
91
/* If HCR_EL2.<E2H> == 0: check CNTHCTL_EL2.EL1PCEN. */
92
- if (arm_feature(env, ARM_FEATURE_EL2) &&
93
- timeridx == GTIMER_PHYS && !secure &&
94
+ if (has_el2 && timeridx == GTIMER_PHYS &&
95
!extract32(env->cp15.cnthctl_el2, 1, 1)) {
96
return CP_ACCESS_TRAP_EL2;
97
}
98
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
99
100
case 1:
101
/* Check CNTHCTL_EL2.EL1PCTEN, which changes location based on E2H. */
102
- if (arm_feature(env, ARM_FEATURE_EL2) &&
103
- timeridx == GTIMER_PHYS && !secure &&
104
+ if (has_el2 && timeridx == GTIMER_PHYS &&
105
(hcr & HCR_E2H
106
? !extract32(env->cp15.cnthctl_el2, 10, 1)
107
: !extract32(env->cp15.cnthctl_el2, 0, 1))) {
108
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx,
109
bool isread)
110
{
111
unsigned int cur_el = arm_current_el(env);
112
- bool secure = arm_is_secure(env);
113
+ bool has_el2 = arm_is_el2_enabled(env);
114
uint64_t hcr = arm_hcr_el2_eff(env);
115
116
switch (cur_el) {
117
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx,
118
/* fall through */
119
120
case 1:
121
- if (arm_feature(env, ARM_FEATURE_EL2) &&
122
- timeridx == GTIMER_PHYS && !secure) {
123
+ if (has_el2 && timeridx == GTIMER_PHYS) {
124
if (hcr & HCR_E2H) {
125
/* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PTEN. */
126
if (!extract32(env->cp15.cnthctl_el2, 11, 1)) {
127
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo strongarm_cp_reginfo[] = {
128
129
static uint64_t midr_read(CPUARMState *env, const ARMCPRegInfo *ri)
130
{
131
- ARMCPU *cpu = env_archcpu(env);
132
unsigned int cur_el = arm_current_el(env);
133
- bool secure = arm_is_secure(env);
134
135
- if (arm_feature(&cpu->env, ARM_FEATURE_EL2) && !secure && cur_el == 1) {
136
+ if (arm_is_el2_enabled(env) && cur_el == 1) {
137
return env->cp15.vpidr_el2;
138
}
139
return raw_read(env, ri);
140
@@ -XXX,XX +XXX,XX @@ static uint64_t mpidr_read_val(CPUARMState *env)
141
static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri)
142
{
143
unsigned int cur_el = arm_current_el(env);
144
- bool secure = arm_is_secure(env);
145
146
- if (arm_feature(env, ARM_FEATURE_EL2) && !secure && cur_el == 1) {
147
+ if (arm_is_el2_enabled(env) && cur_el == 1) {
148
return env->cp15.vmpidr_el2;
149
}
150
return mpidr_read_val(env);
151
@@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff(CPUARMState *env)
152
{
153
uint64_t ret = env->cp15.hcr_el2;
154
155
- if (arm_is_secure_below_el3(env)) {
156
+ if (!arm_is_el2_enabled(env)) {
157
/*
158
* "This register has no effect if EL2 is not enabled in the
159
* current Security state". This is ARMv8.4-SecEL2 speak for
160
@@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el)
161
/* CPTR_EL2. Since TZ and TFP are positive,
162
* they will be zero when EL2 is not present.
163
*/
164
- if (el <= 2 && !arm_is_secure_below_el3(env)) {
165
+ if (el <= 2 && arm_is_el2_enabled(env)) {
166
if (env->cp15.cptr_el[2] & CPTR_TZ) {
167
return 2;
168
}
169
@@ -XXX,XX +XXX,XX @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type)
170
}
171
return 0;
172
case ARM_CPU_MODE_HYP:
173
- return !arm_feature(env, ARM_FEATURE_EL2)
174
- || arm_current_el(env) < 2 || arm_is_secure_below_el3(env);
175
+ return !arm_is_el2_enabled(env) || arm_current_el(env) < 2;
176
case ARM_CPU_MODE_MON:
177
return arm_current_el(env) < 3;
178
default:
179
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
180
181
/* CPTR_EL2 : present in v7VE or v8 */
182
if (cur_el <= 2 && extract32(env->cp15.cptr_el[2], 10, 1)
183
- && !arm_is_secure_below_el3(env)) {
184
+ && arm_is_el2_enabled(env)) {
185
/* Trap FP ops at EL2, NS-EL1 or NS-EL0 to EL2 */
186
return 2;
187
}
188
--
36
--
189
2.20.1
37
2.34.1
190
38
191
39
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Update all users of do_perm_pred2 for the new
3
This struct has no dependencies on TCG code and it is being used in
4
predicate descriptor field definitions.
4
target/arm/ptw.c to simplify the passing around of page table walk
5
results. Those routines can be reached by KVM code via the gdbstub
6
breakpoint code, so take the structure out of CONFIG_TCG to make it
7
visible when building with --disable-tcg.
5
8
6
Cc: qemu-stable@nongnu.org
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
Buglink: https://bugs.launchpad.net/bugs/1908551
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Message-id: 20210113062650.593824-5-richard.henderson@linaro.org
12
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
14
---
13
target/arm/sve_helper.c | 8 ++++----
15
include/exec/cpu-defs.h | 6 ++++++
14
target/arm/translate-sve.c | 13 ++++---------
16
1 file changed, 6 insertions(+)
15
2 files changed, 8 insertions(+), 13 deletions(-)
16
17
17
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
18
diff --git a/include/exec/cpu-defs.h b/include/exec/cpu-defs.h
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/sve_helper.c
20
--- a/include/exec/cpu-defs.h
20
+++ b/target/arm/sve_helper.c
21
+++ b/include/exec/cpu-defs.h
21
@@ -XXX,XX +XXX,XX @@ static uint8_t reverse_bits_8(uint8_t x, int n)
22
@@ -XXX,XX +XXX,XX @@ typedef struct CPUTLBEntry {
22
23
23
void HELPER(sve_rev_p)(void *vd, void *vn, uint32_t pred_desc)
24
QEMU_BUILD_BUG_ON(sizeof(CPUTLBEntry) != (1 << CPU_TLB_ENTRY_BITS));
24
{
25
25
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
26
+
26
- int esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
27
+#endif /* !CONFIG_USER_ONLY && CONFIG_TCG */
27
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
28
+
28
+ int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
29
+#if !defined(CONFIG_USER_ONLY)
29
intptr_t i, oprsz_2 = oprsz / 2;
30
/*
30
31
* The full TLB entry, which is not accessed by generated TCG code,
31
if (oprsz <= 8) {
32
* so the layout is not as critical as that of CPUTLBEntry. This is
32
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_rev_p)(void *vd, void *vn, uint32_t pred_desc)
33
@@ -XXX,XX +XXX,XX @@ typedef struct CPUTLBEntryFull {
33
34
TARGET_PAGE_ENTRY_EXTRA
34
void HELPER(sve_punpk_p)(void *vd, void *vn, uint32_t pred_desc)
35
#endif
35
{
36
} CPUTLBEntryFull;
36
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
37
+#endif /* !CONFIG_USER_ONLY */
37
- intptr_t high = extract32(pred_desc, SIMD_DATA_SHIFT + 2, 1);
38
38
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
39
+#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
39
+ intptr_t high = FIELD_EX32(pred_desc, PREDDESC, DATA);
40
/*
40
uint64_t *d = vd;
41
* Data elements that are per MMU mode, minus the bits accessed by
41
intptr_t i;
42
* the TCG fast path.
42
43
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/translate-sve.c
46
+++ b/target/arm/translate-sve.c
47
@@ -XXX,XX +XXX,XX @@ static bool do_perm_pred2(DisasContext *s, arg_rr_esz *a, bool high_odd,
48
TCGv_ptr t_d = tcg_temp_new_ptr();
49
TCGv_ptr t_n = tcg_temp_new_ptr();
50
TCGv_i32 t_desc;
51
- int desc;
52
+ uint32_t desc = 0;
53
54
tcg_gen_addi_ptr(t_d, cpu_env, pred_full_reg_offset(s, a->rd));
55
tcg_gen_addi_ptr(t_n, cpu_env, pred_full_reg_offset(s, a->rn));
56
57
- /* Predicate sizes may be smaller and cannot use simd_desc.
58
- We cannot round up, as we do elsewhere, because we need
59
- the exact size for ZIP2 and REV. We retain the style for
60
- the other helpers for consistency. */
61
-
62
- desc = vsz - 2;
63
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz);
64
- desc = deposit32(desc, SIMD_DATA_SHIFT + 2, 2, high_odd);
65
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz);
66
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz);
67
+ desc = FIELD_DP32(desc, PREDDESC, DATA, high_odd);
68
t_desc = tcg_const_i32(desc);
69
70
fn(t_d, t_n, t_desc);
71
--
43
--
72
2.20.1
44
2.34.1
73
45
74
46
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
This test currently fails when run on a host for which the QEMU target
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
has no default machine set:
5
Message-id: 20210112104511.36576-18-remi.denis.courmont@huawei.com
5
6
ERROR| Output: qemu-system-aarch64: No machine specified, and there is
7
no default
8
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
12
---
8
target/arm/cpu64.c | 1 +
13
tests/avocado/version.py | 1 +
9
1 file changed, 1 insertion(+)
14
1 file changed, 1 insertion(+)
10
15
11
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
16
diff --git a/tests/avocado/version.py b/tests/avocado/version.py
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/cpu64.c
18
--- a/tests/avocado/version.py
14
+++ b/target/arm/cpu64.c
19
+++ b/tests/avocado/version.py
15
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
20
@@ -XXX,XX +XXX,XX @@
16
t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
21
class Version(QemuSystemTest):
17
t = FIELD_DP64(t, ID_AA64PFR0, FP, 1);
22
"""
18
t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1);
23
:avocado: tags=quick
19
+ t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);
24
+ :avocado: tags=machine:none
20
cpu->isar.id_aa64pfr0 = t;
25
"""
21
26
def test_qmp_human_info_version(self):
22
t = cpu->isar.id_aa64pfr1;
27
self.vm.add_args('-nodefaults')
23
--
28
--
24
2.20.1
29
2.34.1
25
30
26
31
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
These two were odd, in that do_pfirst_pnext passed the
3
Since &I2C_SLAVE(dev)->qdev == dev, no need to go back and
4
count of 64-bit words rather than bytes. Change to pass
4
forth with QOM type casting. Directly use 'dev'.
5
the standard pred_full_reg_size to avoid confusion.
6
5
7
Cc: qemu-stable@nongnu.org
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210113062650.593824-3-richard.henderson@linaro.org
8
Message-id: 20230220115114.25237-2-philmd@linaro.org
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
target/arm/sve_helper.c | 7 ++++---
11
hw/gpio/max7310.c | 5 ++---
14
target/arm/translate-sve.c | 6 +++---
12
1 file changed, 2 insertions(+), 3 deletions(-)
15
2 files changed, 7 insertions(+), 6 deletions(-)
16
13
17
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
14
diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/sve_helper.c
16
--- a/hw/gpio/max7310.c
20
+++ b/target/arm/sve_helper.c
17
+++ b/hw/gpio/max7310.c
21
@@ -XXX,XX +XXX,XX @@ static intptr_t last_active_element(uint64_t *g, intptr_t words, intptr_t esz)
18
@@ -XXX,XX +XXX,XX @@ static void max7310_gpio_set(void *opaque, int line, int level)
22
return (intptr_t)-1 << esz;
19
* but also accepts sequences that are not SMBus so return an I2C device. */
20
static void max7310_realize(DeviceState *dev, Error **errp)
21
{
22
- I2CSlave *i2c = I2C_SLAVE(dev);
23
MAX7310State *s = MAX7310(dev);
24
25
- qdev_init_gpio_in(&i2c->qdev, max7310_gpio_set, 8);
26
- qdev_init_gpio_out(&i2c->qdev, s->handler, 8);
27
+ qdev_init_gpio_in(dev, max7310_gpio_set, ARRAY_SIZE(s->handler));
28
+ qdev_init_gpio_out(dev, s->handler, ARRAY_SIZE(s->handler));
23
}
29
}
24
30
25
-uint32_t HELPER(sve_pfirst)(void *vd, void *vg, uint32_t words)
31
static void max7310_class_init(ObjectClass *klass, void *data)
26
+uint32_t HELPER(sve_pfirst)(void *vd, void *vg, uint32_t pred_desc)
27
{
28
+ intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8);
29
uint32_t flags = PREDTEST_INIT;
30
uint64_t *d = vd, *g = vg;
31
intptr_t i = 0;
32
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_pfirst)(void *vd, void *vg, uint32_t words)
33
34
uint32_t HELPER(sve_pnext)(void *vd, void *vg, uint32_t pred_desc)
35
{
36
- intptr_t words = extract32(pred_desc, 0, SIMD_OPRSZ_BITS);
37
- intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
38
+ intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8);
39
+ intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
40
uint32_t flags = PREDTEST_INIT;
41
uint64_t *d = vd, *g = vg, esz_mask;
42
intptr_t i, next;
43
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/translate-sve.c
46
+++ b/target/arm/translate-sve.c
47
@@ -XXX,XX +XXX,XX @@ static bool do_pfirst_pnext(DisasContext *s, arg_rr_esz *a,
48
TCGv_ptr t_pd = tcg_temp_new_ptr();
49
TCGv_ptr t_pg = tcg_temp_new_ptr();
50
TCGv_i32 t;
51
- unsigned desc;
52
+ unsigned desc = 0;
53
54
- desc = DIV_ROUND_UP(pred_full_reg_size(s), 8);
55
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz);
56
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, pred_full_reg_size(s));
57
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz);
58
59
tcg_gen_addi_ptr(t_pd, cpu_env, pred_full_reg_offset(s, a->rd));
60
tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, a->rn));
61
--
32
--
62
2.20.1
33
2.34.1
63
34
64
35
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
On ARMv8-A, accesses by 32-bit secure EL1 to monitor registers trap to
3
pl011_create() is only used in DeviceRealize handlers,
4
the upper (64-bit) EL. With Secure EL2 support, we can no longer assume
4
not a hot-path. Inlining is not justified.
5
that that is always EL3, so make room for the value to be computed at
6
run-time.
7
5
8
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20210112104511.36576-16-remi.denis.courmont@huawei.com
9
Message-id: 20230220115114.25237-3-philmd@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
target/arm/translate.c | 23 +++++++++++++++++++++--
12
include/hw/char/pl011.h | 19 +------------------
14
1 file changed, 21 insertions(+), 2 deletions(-)
13
hw/char/pl011.c | 17 +++++++++++++++++
14
2 files changed, 18 insertions(+), 18 deletions(-)
15
15
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
16
diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
18
--- a/include/hw/char/pl011.h
19
+++ b/target/arm/translate.c
19
+++ b/include/hw/char/pl011.h
20
@@ -XXX,XX +XXX,XX @@ static void unallocated_encoding(DisasContext *s)
20
@@ -XXX,XX +XXX,XX @@
21
default_exception_el(s));
21
#ifndef HW_PL011_H
22
}
22
#define HW_PL011_H
23
23
24
+static void gen_exception_el(DisasContext *s, int excp, uint32_t syn,
24
-#include "hw/qdev-properties.h"
25
+ TCGv_i32 tcg_el)
25
#include "hw/sysbus.h"
26
#include "chardev/char-fe.h"
27
-#include "qapi/error.h"
28
#include "qom/object.h"
29
30
#define TYPE_PL011 "pl011"
31
@@ -XXX,XX +XXX,XX @@ struct PL011State {
32
const unsigned char *id;
33
};
34
35
-static inline DeviceState *pl011_create(hwaddr addr,
36
- qemu_irq irq,
37
- Chardev *chr)
38
-{
39
- DeviceState *dev;
40
- SysBusDevice *s;
41
-
42
- dev = qdev_new("pl011");
43
- s = SYS_BUS_DEVICE(dev);
44
- qdev_prop_set_chr(dev, "chardev", chr);
45
- sysbus_realize_and_unref(s, &error_fatal);
46
- sysbus_mmio_map(s, 0, addr);
47
- sysbus_connect_irq(s, 0, irq);
48
-
49
- return dev;
50
-}
51
+DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr);
52
53
static inline DeviceState *pl011_luminary_create(hwaddr addr,
54
qemu_irq irq,
55
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/char/pl011.c
58
+++ b/hw/char/pl011.c
59
@@ -XXX,XX +XXX,XX @@
60
*/
61
62
#include "qemu/osdep.h"
63
+#include "qapi/error.h"
64
#include "hw/char/pl011.h"
65
#include "hw/irq.h"
66
#include "hw/sysbus.h"
67
#include "hw/qdev-clock.h"
68
+#include "hw/qdev-properties.h"
69
#include "hw/qdev-properties-system.h"
70
#include "migration/vmstate.h"
71
#include "chardev/char-fe.h"
72
@@ -XXX,XX +XXX,XX @@
73
#include "qemu/module.h"
74
#include "trace.h"
75
76
+DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr)
26
+{
77
+{
27
+ TCGv_i32 tcg_excp;
78
+ DeviceState *dev;
28
+ TCGv_i32 tcg_syn;
79
+ SysBusDevice *s;
29
+
80
+
30
+ gen_set_condexec(s);
81
+ dev = qdev_new("pl011");
31
+ gen_set_pc_im(s, s->pc_curr);
82
+ s = SYS_BUS_DEVICE(dev);
32
+ tcg_excp = tcg_const_i32(excp);
83
+ qdev_prop_set_chr(dev, "chardev", chr);
33
+ tcg_syn = tcg_const_i32(syn);
84
+ sysbus_realize_and_unref(s, &error_fatal);
34
+ gen_helper_exception_with_syndrome(cpu_env, tcg_excp, tcg_syn, tcg_el);
85
+ sysbus_mmio_map(s, 0, addr);
35
+ tcg_temp_free_i32(tcg_syn);
86
+ sysbus_connect_irq(s, 0, irq);
36
+ tcg_temp_free_i32(tcg_excp);
87
+
37
+ s->base.is_jmp = DISAS_NORETURN;
88
+ return dev;
38
+}
89
+}
39
+
90
+
40
/* Force a TB lookup after an instruction that changes the CPU state. */
91
#define PL011_INT_TX 0x20
41
static inline void gen_lookup_tb(DisasContext *s)
92
#define PL011_INT_RX 0x10
42
{
93
43
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
44
/* If we're in Secure EL1 (which implies that EL3 is AArch64)
45
* then accesses to Mon registers trap to EL3
46
*/
47
- exc_target = 3;
48
- goto undef;
49
+ TCGv_i32 tcg_el = tcg_const_i32(3);
50
+
51
+ gen_exception_el(s, EXCP_UDEF, syn_uncategorized(), tcg_el);
52
+ tcg_temp_free_i32(tcg_el);
53
+ return false;
54
}
55
break;
56
case ARM_CPU_MODE_HYP:
57
--
94
--
58
2.20.1
95
2.34.1
59
96
60
97
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
This will simplify accessing HCR conditionally in secure state.
3
pl011_luminary_create() is only used for the Stellaris board,
4
open-code it.
4
5
5
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20210112104511.36576-4-remi.denis.courmont@huawei.com
9
Message-id: 20230220115114.25237-4-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
11
---
10
target/arm/helper.c | 31 ++++++++++++++++++-------------
12
include/hw/char/pl011.h | 17 -----------------
11
1 file changed, 18 insertions(+), 13 deletions(-)
13
hw/arm/stellaris.c | 11 ++++++++---
14
2 files changed, 8 insertions(+), 20 deletions(-)
12
15
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
18
--- a/include/hw/char/pl011.h
16
+++ b/target/arm/helper.c
19
+++ b/include/hw/char/pl011.h
17
@@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env,
20
@@ -XXX,XX +XXX,XX @@ struct PL011State {
18
21
19
static int vae1_tlbmask(CPUARMState *env)
22
DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr);
20
{
23
21
- /* Since we exclude secure first, we may read HCR_EL2 directly. */
24
-static inline DeviceState *pl011_luminary_create(hwaddr addr,
22
- if (arm_is_secure_below_el3(env)) {
25
- qemu_irq irq,
23
- return ARMMMUIdxBit_SE10_1 |
26
- Chardev *chr)
24
- ARMMMUIdxBit_SE10_1_PAN |
27
-{
25
- ARMMMUIdxBit_SE10_0;
28
- DeviceState *dev;
26
- } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE))
29
- SysBusDevice *s;
27
- == (HCR_E2H | HCR_TGE)) {
30
-
28
+ uint64_t hcr = arm_hcr_el2_eff(env);
31
- dev = qdev_new("pl011_luminary");
32
- s = SYS_BUS_DEVICE(dev);
33
- qdev_prop_set_chr(dev, "chardev", chr);
34
- sysbus_realize_and_unref(s, &error_fatal);
35
- sysbus_mmio_map(s, 0, addr);
36
- sysbus_connect_irq(s, 0, irq);
37
-
38
- return dev;
39
-}
40
-
41
#endif
42
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/arm/stellaris.c
45
+++ b/hw/arm/stellaris.c
46
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
47
48
for (i = 0; i < 4; i++) {
49
if (board->dc2 & (1 << i)) {
50
- pl011_luminary_create(0x4000c000 + i * 0x1000,
51
- qdev_get_gpio_in(nvic, uart_irq[i]),
52
- serial_hd(i));
53
+ SysBusDevice *sbd;
29
+
54
+
30
+ if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
55
+ dev = qdev_new("pl011_luminary");
31
return ARMMMUIdxBit_E20_2 |
56
+ sbd = SYS_BUS_DEVICE(dev);
32
ARMMMUIdxBit_E20_2_PAN |
57
+ qdev_prop_set_chr(dev, "chardev", serial_hd(i));
33
ARMMMUIdxBit_E20_0;
58
+ sysbus_realize_and_unref(sbd, &error_fatal);
34
+ } else if (arm_is_secure_below_el3(env)) {
59
+ sysbus_mmio_map(sbd, 0, 0x4000c000 + i * 0x1000);
35
+ return ARMMMUIdxBit_SE10_1 |
60
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(nvic, uart_irq[i]));
36
+ ARMMMUIdxBit_SE10_1_PAN |
37
+ ARMMMUIdxBit_SE10_0;
38
} else {
39
return ARMMMUIdxBit_E10_1 |
40
ARMMMUIdxBit_E10_1_PAN |
41
@@ -XXX,XX +XXX,XX @@ static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx)
42
static inline bool regime_translation_disabled(CPUARMState *env,
43
ARMMMUIdx mmu_idx)
44
{
45
+ uint64_t hcr_el2;
46
+
47
if (arm_feature(env, ARM_FEATURE_M)) {
48
switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] &
49
(R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) {
50
@@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env,
51
}
61
}
52
}
62
}
53
63
if (board->dc2 & (1 << 4)) {
54
+ hcr_el2 = arm_hcr_el2_eff(env);
55
+
56
if (mmu_idx == ARMMMUIdx_Stage2) {
57
/* HCR.DC means HCR.VM behaves as 1 */
58
- return (env->cp15.hcr_el2 & (HCR_DC | HCR_VM)) == 0;
59
+ return (hcr_el2 & (HCR_DC | HCR_VM)) == 0;
60
}
61
62
- if (env->cp15.hcr_el2 & HCR_TGE) {
63
+ if (hcr_el2 & HCR_TGE) {
64
/* TGE means that NS EL0/1 act as if SCTLR_EL1.M is zero */
65
if (!regime_is_secure(env, mmu_idx) && regime_el(env, mmu_idx) == 1) {
66
return true;
67
}
68
}
69
70
- if ((env->cp15.hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) {
71
+ if ((hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) {
72
/* HCR.DC means SCTLR_EL1.M behaves as 0 */
73
return true;
74
}
75
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
76
fi->s1ptw = true;
77
return ~0;
78
}
79
- if ((env->cp15.hcr_el2 & HCR_PTW) && (cacheattrs.attrs & 0xf0) == 0) {
80
+ if ((arm_hcr_el2_eff(env) & HCR_PTW) &&
81
+ (cacheattrs.attrs & 0xf0) == 0) {
82
/*
83
* PTW set and S1 walk touched S2 Device memory:
84
* generate Permission fault.
85
@@ -XXX,XX +XXX,XX @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs)
86
uint8_t hihint = 0, lohint = 0;
87
88
if (hiattr != 0) { /* normal memory */
89
- if ((env->cp15.hcr_el2 & HCR_CD) != 0) { /* cache disabled */
90
+ if (arm_hcr_el2_eff(env) & HCR_CD) { /* cache disabled */
91
hiattr = loattr = 1; /* non-cacheable */
92
} else {
93
if (hiattr != 1) { /* Write-through or write-back */
94
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
95
}
96
97
/* Combine the S1 and S2 cache attributes. */
98
- if (env->cp15.hcr_el2 & HCR_DC) {
99
+ if (arm_hcr_el2_eff(env) & HCR_DC) {
100
/*
101
* HCR.DC forces the first stage attributes to
102
* Normal Non-Shareable,
103
--
64
--
104
2.20.1
65
2.34.1
105
66
106
67
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Add pvpanic PCI device support details in docs/specs/pvpanic.txt.
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
[fixed s/device/bus/ error]
6
Message-id: 20230220115114.25237-5-philmd@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
8
---
10
docs/specs/pvpanic.txt | 13 ++++++++++++-
9
include/hw/char/xilinx_uartlite.h | 6 +++++-
11
1 file changed, 12 insertions(+), 1 deletion(-)
10
hw/char/xilinx_uartlite.c | 4 +---
11
2 files changed, 6 insertions(+), 4 deletions(-)
12
12
13
diff --git a/docs/specs/pvpanic.txt b/docs/specs/pvpanic.txt
13
diff --git a/include/hw/char/xilinx_uartlite.h b/include/hw/char/xilinx_uartlite.h
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/docs/specs/pvpanic.txt
15
--- a/include/hw/char/xilinx_uartlite.h
16
+++ b/docs/specs/pvpanic.txt
16
+++ b/include/hw/char/xilinx_uartlite.h
17
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@
18
PVPANIC DEVICE
18
#include "hw/qdev-properties.h"
19
==============
19
#include "hw/sysbus.h"
20
20
#include "qapi/error.h"
21
-pvpanic device is a simulated ISA device, through which a guest panic
21
+#include "qom/object.h"
22
+pvpanic device is a simulated device, through which a guest panic
23
event is sent to qemu, and a QMP event is generated. This allows
24
management apps (e.g. libvirt) to be notified and respond to the event.
25
26
@@ -XXX,XX +XXX,XX @@ The management app has the option of waiting for GUEST_PANICKED events,
27
and/or polling for guest-panicked RunState, to learn when the pvpanic
28
device has fired a panic event.
29
30
+The pvpanic device can be implemented as an ISA device (using IOPORT) or as a
31
+PCI device.
32
+
22
+
33
ISA Interface
23
+#define TYPE_XILINX_UARTLITE "xlnx.xps-uartlite"
34
-------------
24
+OBJECT_DECLARE_SIMPLE_TYPE(XilinxUARTLite, XILINX_UARTLITE)
35
25
36
@@ -XXX,XX +XXX,XX @@ bit 1: a guest panic has happened and will be handled by the guest;
26
static inline DeviceState *xilinx_uartlite_create(hwaddr addr,
37
the host should record it or report it, but should not affect
27
qemu_irq irq,
38
the execution of the guest.
28
@@ -XXX,XX +XXX,XX @@ static inline DeviceState *xilinx_uartlite_create(hwaddr addr,
39
29
DeviceState *dev;
40
+PCI Interface
30
SysBusDevice *s;
41
+-------------
31
42
+
32
- dev = qdev_new("xlnx.xps-uartlite");
43
+The PCI interface is similar to the ISA interface except that it uses an MMIO
33
+ dev = qdev_new(TYPE_XILINX_UARTLITE);
44
+address space provided by its BAR0, 1 byte long. Any machine with a PCI bus
34
s = SYS_BUS_DEVICE(dev);
45
+can enable a pvpanic device by adding '-device pvpanic-pci' to the command
35
qdev_prop_set_chr(dev, "chardev", chr);
46
+line.
36
sysbus_realize_and_unref(s, &error_fatal);
47
+
37
diff --git a/hw/char/xilinx_uartlite.c b/hw/char/xilinx_uartlite.c
48
ACPI Interface
38
index XXXXXXX..XXXXXXX 100644
49
--------------
39
--- a/hw/char/xilinx_uartlite.c
40
+++ b/hw/char/xilinx_uartlite.c
41
@@ -XXX,XX +XXX,XX @@
42
43
#include "qemu/osdep.h"
44
#include "qemu/log.h"
45
+#include "hw/char/xilinx_uartlite.h"
46
#include "hw/irq.h"
47
#include "hw/qdev-properties.h"
48
#include "hw/qdev-properties-system.h"
49
@@ -XXX,XX +XXX,XX @@
50
#define CONTROL_RST_RX 0x02
51
#define CONTROL_IE 0x10
52
53
-#define TYPE_XILINX_UARTLITE "xlnx.xps-uartlite"
54
-OBJECT_DECLARE_SIMPLE_TYPE(XilinxUARTLite, XILINX_UARTLITE)
55
-
56
struct XilinxUARTLite {
57
SysBusDevice parent_obj;
50
58
51
--
59
--
52
2.20.1
60
2.34.1
53
61
54
62
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
To ease the PCI device addition in next patches, split the code as follows:
3
Open-code the single use of xilinx_uartlite_create().
4
- generic code (read/write/setup) is being kept in pvpanic.c
5
- ISA dependent code moved to pvpanic-isa.c
6
4
7
Also, rename:
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
- ISA_PVPANIC_DEVICE -> PVPANIC_ISA_DEVICE.
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
- TYPE_PVPANIC -> TYPE_PVPANIC_ISA.
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
- MemoryRegion io -> mr.
8
Message-id: 20230220115114.25237-6-philmd@linaro.org
11
- pvpanic_ioport_* in pvpanic_*.
12
13
Update the build system with the new files and config structure.
14
15
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
10
---
19
include/hw/misc/pvpanic.h | 23 +++++++++-
11
include/hw/char/xilinx_uartlite.h | 20 --------------------
20
hw/misc/pvpanic-isa.c | 94 +++++++++++++++++++++++++++++++++++++++
12
hw/microblaze/petalogix_s3adsp1800_mmu.c | 7 +++++--
21
hw/misc/pvpanic.c | 85 +++--------------------------------
13
2 files changed, 5 insertions(+), 22 deletions(-)
22
hw/i386/Kconfig | 2 +-
23
hw/misc/Kconfig | 6 ++-
24
hw/misc/meson.build | 3 +-
25
tests/qtest/meson.build | 2 +-
26
7 files changed, 130 insertions(+), 85 deletions(-)
27
create mode 100644 hw/misc/pvpanic-isa.c
28
14
29
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
15
diff --git a/include/hw/char/xilinx_uartlite.h b/include/hw/char/xilinx_uartlite.h
30
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
31
--- a/include/hw/misc/pvpanic.h
17
--- a/include/hw/char/xilinx_uartlite.h
32
+++ b/include/hw/misc/pvpanic.h
18
+++ b/include/hw/char/xilinx_uartlite.h
33
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
34
20
#ifndef XILINX_UARTLITE_H
21
#define XILINX_UARTLITE_H
22
23
-#include "hw/qdev-properties.h"
24
-#include "hw/sysbus.h"
25
-#include "qapi/error.h"
35
#include "qom/object.h"
26
#include "qom/object.h"
36
27
37
-#define TYPE_PVPANIC "pvpanic"
28
#define TYPE_XILINX_UARTLITE "xlnx.xps-uartlite"
38
+#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"
29
OBJECT_DECLARE_SIMPLE_TYPE(XilinxUARTLite, XILINX_UARTLITE)
39
30
40
#define PVPANIC_IOPORT_PROP "ioport"
31
-static inline DeviceState *xilinx_uartlite_create(hwaddr addr,
41
32
- qemu_irq irq,
42
+/* The bit of supported pv event, TODO: include uapi header and remove this */
33
- Chardev *chr)
43
+#define PVPANIC_F_PANICKED 0
34
-{
44
+#define PVPANIC_F_CRASHLOADED 1
35
- DeviceState *dev;
45
+
36
- SysBusDevice *s;
46
+/* The pv event value */
47
+#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED)
48
+#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
49
+
50
+/*
51
+ * PVPanicState for any device type
52
+ */
53
+typedef struct PVPanicState PVPanicState;
54
+struct PVPanicState {
55
+ MemoryRegion mr;
56
+ uint8_t events;
57
+};
58
+
59
+void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
60
+
61
static inline uint16_t pvpanic_port(void)
62
{
63
- Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL);
64
+ Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
65
if (!o) {
66
return 0;
67
}
68
diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c
69
new file mode 100644
70
index XXXXXXX..XXXXXXX
71
--- /dev/null
72
+++ b/hw/misc/pvpanic-isa.c
73
@@ -XXX,XX +XXX,XX @@
74
+/*
75
+ * QEMU simulated pvpanic device.
76
+ *
77
+ * Copyright Fujitsu, Corp. 2013
78
+ *
79
+ * Authors:
80
+ * Wen Congyang <wency@cn.fujitsu.com>
81
+ * Hu Tao <hutao@cn.fujitsu.com>
82
+ *
83
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
84
+ * See the COPYING file in the top-level directory.
85
+ *
86
+ */
87
+
88
+#include "qemu/osdep.h"
89
+#include "qemu/log.h"
90
+#include "qemu/module.h"
91
+#include "sysemu/runstate.h"
92
+
93
+#include "hw/nvram/fw_cfg.h"
94
+#include "hw/qdev-properties.h"
95
+#include "hw/misc/pvpanic.h"
96
+#include "qom/object.h"
97
+#include "hw/isa/isa.h"
98
+
99
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
100
+
101
+/*
102
+ * PVPanicISAState for ISA device and
103
+ * use ioport.
104
+ */
105
+struct PVPanicISAState {
106
+ ISADevice parent_obj;
107
+
108
+ uint16_t ioport;
109
+ PVPanicState pvpanic;
110
+};
111
+
112
+static void pvpanic_isa_initfn(Object *obj)
113
+{
114
+ PVPanicISAState *s = PVPANIC_ISA_DEVICE(obj);
115
+
116
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), 1);
117
+}
118
+
119
+static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
120
+{
121
+ ISADevice *d = ISA_DEVICE(dev);
122
+ PVPanicISAState *s = PVPANIC_ISA_DEVICE(dev);
123
+ PVPanicState *ps = &s->pvpanic;
124
+ FWCfgState *fw_cfg = fw_cfg_find();
125
+ uint16_t *pvpanic_port;
126
+
127
+ if (!fw_cfg) {
128
+ return;
129
+ }
130
+
131
+ pvpanic_port = g_malloc(sizeof(*pvpanic_port));
132
+ *pvpanic_port = cpu_to_le16(s->ioport);
133
+ fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
134
+ sizeof(*pvpanic_port));
135
+
136
+ isa_register_ioport(d, &ps->mr, s->ioport);
137
+}
138
+
139
+static Property pvpanic_isa_properties[] = {
140
+ DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505),
141
+ DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
142
+ DEFINE_PROP_END_OF_LIST(),
143
+};
144
+
145
+static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
146
+{
147
+ DeviceClass *dc = DEVICE_CLASS(klass);
148
+
149
+ dc->realize = pvpanic_isa_realizefn;
150
+ device_class_set_props(dc, pvpanic_isa_properties);
151
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
152
+}
153
+
154
+static TypeInfo pvpanic_isa_info = {
155
+ .name = TYPE_PVPANIC_ISA_DEVICE,
156
+ .parent = TYPE_ISA_DEVICE,
157
+ .instance_size = sizeof(PVPanicISAState),
158
+ .instance_init = pvpanic_isa_initfn,
159
+ .class_init = pvpanic_isa_class_init,
160
+};
161
+
162
+static void pvpanic_register_types(void)
163
+{
164
+ type_register_static(&pvpanic_isa_info);
165
+}
166
+
167
+type_init(pvpanic_register_types)
168
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
169
index XXXXXXX..XXXXXXX 100644
170
--- a/hw/misc/pvpanic.c
171
+++ b/hw/misc/pvpanic.c
172
@@ -XXX,XX +XXX,XX @@
173
#include "hw/misc/pvpanic.h"
174
#include "qom/object.h"
175
176
-/* The bit of supported pv event, TODO: include uapi header and remove this */
177
-#define PVPANIC_F_PANICKED 0
178
-#define PVPANIC_F_CRASHLOADED 1
179
-
37
-
180
-/* The pv event value */
38
- dev = qdev_new(TYPE_XILINX_UARTLITE);
181
-#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED)
39
- s = SYS_BUS_DEVICE(dev);
182
-#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
40
- qdev_prop_set_chr(dev, "chardev", chr);
41
- sysbus_realize_and_unref(s, &error_fatal);
42
- sysbus_mmio_map(s, 0, addr);
43
- sysbus_connect_irq(s, 0, irq);
183
-
44
-
184
-typedef struct PVPanicState PVPanicState;
45
- return dev;
185
-DECLARE_INSTANCE_CHECKER(PVPanicState, ISA_PVPANIC_DEVICE,
186
- TYPE_PVPANIC)
187
-
188
static void handle_event(int event)
189
{
190
static bool logged;
191
@@ -XXX,XX +XXX,XX @@ static void handle_event(int event)
192
}
193
}
194
195
-#include "hw/isa/isa.h"
196
-
197
-struct PVPanicState {
198
- ISADevice parent_obj;
199
-
200
- MemoryRegion io;
201
- uint16_t ioport;
202
- uint8_t events;
203
-};
204
-
205
/* return supported events on read */
206
-static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size)
207
+static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
208
{
209
PVPanicState *pvp = opaque;
210
return pvp->events;
211
}
212
213
-static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val,
214
+static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
215
unsigned size)
216
{
217
handle_event(val);
218
}
219
220
static const MemoryRegionOps pvpanic_ops = {
221
- .read = pvpanic_ioport_read,
222
- .write = pvpanic_ioport_write,
223
+ .read = pvpanic_read,
224
+ .write = pvpanic_write,
225
.impl = {
226
.min_access_size = 1,
227
.max_access_size = 1,
228
},
229
};
230
231
-static void pvpanic_isa_initfn(Object *obj)
232
+void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size)
233
{
234
- PVPanicState *s = ISA_PVPANIC_DEVICE(obj);
235
-
236
- memory_region_init_io(&s->io, OBJECT(s), &pvpanic_ops, s, "pvpanic", 1);
237
+ memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size);
238
}
239
-
240
-static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
241
-{
242
- ISADevice *d = ISA_DEVICE(dev);
243
- PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
244
- FWCfgState *fw_cfg = fw_cfg_find();
245
- uint16_t *pvpanic_port;
246
-
247
- if (!fw_cfg) {
248
- return;
249
- }
250
-
251
- pvpanic_port = g_malloc(sizeof(*pvpanic_port));
252
- *pvpanic_port = cpu_to_le16(s->ioport);
253
- fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
254
- sizeof(*pvpanic_port));
255
-
256
- isa_register_ioport(d, &s->io, s->ioport);
257
-}
46
-}
258
-
47
-
259
-static Property pvpanic_isa_properties[] = {
48
#endif
260
- DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505),
49
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
261
- DEFINE_PROP_UINT8("events", PVPanicState, events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
262
- DEFINE_PROP_END_OF_LIST(),
263
-};
264
-
265
-static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
266
-{
267
- DeviceClass *dc = DEVICE_CLASS(klass);
268
-
269
- dc->realize = pvpanic_isa_realizefn;
270
- device_class_set_props(dc, pvpanic_isa_properties);
271
- set_bit(DEVICE_CATEGORY_MISC, dc->categories);
272
-}
273
-
274
-static TypeInfo pvpanic_isa_info = {
275
- .name = TYPE_PVPANIC,
276
- .parent = TYPE_ISA_DEVICE,
277
- .instance_size = sizeof(PVPanicState),
278
- .instance_init = pvpanic_isa_initfn,
279
- .class_init = pvpanic_isa_class_init,
280
-};
281
-
282
-static void pvpanic_register_types(void)
283
-{
284
- type_register_static(&pvpanic_isa_info);
285
-}
286
-
287
-type_init(pvpanic_register_types)
288
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
289
index XXXXXXX..XXXXXXX 100644
50
index XXXXXXX..XXXXXXX 100644
290
--- a/hw/i386/Kconfig
51
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
291
+++ b/hw/i386/Kconfig
52
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
292
@@ -XXX,XX +XXX,XX @@ config PC
53
@@ -XXX,XX +XXX,XX @@ petalogix_s3adsp1800_init(MachineState *machine)
293
imply ISA_DEBUG
54
irq[i] = qdev_get_gpio_in(dev, i);
294
imply PARALLEL
55
}
295
imply PCI_DEVICES
56
296
- imply PVPANIC
57
- xilinx_uartlite_create(UARTLITE_BASEADDR, irq[UARTLITE_IRQ],
297
+ imply PVPANIC_ISA
58
- serial_hd(0));
298
imply QXL
59
+ dev = qdev_new(TYPE_XILINX_UARTLITE);
299
imply SEV
60
+ qdev_prop_set_chr(dev, "chardev", serial_hd(0));
300
imply SGA
61
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
301
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
62
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, UARTLITE_BASEADDR);
302
index XXXXXXX..XXXXXXX 100644
63
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[UARTLITE_IRQ]);
303
--- a/hw/misc/Kconfig
64
304
+++ b/hw/misc/Kconfig
65
/* 2 timers at irq 2 @ 62 Mhz. */
305
@@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSCTL
66
dev = qdev_new("xlnx.xps-timer");
306
config IOTKIT_SYSINFO
307
bool
308
309
-config PVPANIC
310
+config PVPANIC_COMMON
311
+ bool
312
+
313
+config PVPANIC_ISA
314
bool
315
depends on ISA_BUS
316
+ select PVPANIC_COMMON
317
318
config AUX
319
bool
320
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
321
index XXXXXXX..XXXXXXX 100644
322
--- a/hw/misc/meson.build
323
+++ b/hw/misc/meson.build
324
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c'))
325
softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c'))
326
softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c'))
327
softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c'))
328
+softmmu_ss.add(when: 'CONFIG_PVPANIC_COMMON', if_true: files('pvpanic.c'))
329
330
# ARM devices
331
softmmu_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c'))
332
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c')
333
softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c'))
334
softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
335
336
-softmmu_ss.add(when: 'CONFIG_PVPANIC', if_true: files('pvpanic.c'))
337
+softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
338
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
339
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
340
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
341
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
342
index XXXXXXX..XXXXXXX 100644
343
--- a/tests/qtest/meson.build
344
+++ b/tests/qtest/meson.build
345
@@ -XXX,XX +XXX,XX @@ qtests_i386 = \
346
(config_host.has_key('CONFIG_LINUX') and \
347
config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \
348
(config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \
349
- (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \
350
+ (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \
351
(config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \
352
(config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \
353
(config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
354
--
67
--
355
2.20.1
68
2.34.1
356
69
357
70
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
In the secure stage 2 translation regime, the VSTCR.SW and VTCR.NSW
3
cmsdk_apb_uart_create() is only used twice in the same
4
bits can invert the secure flag for pagetable walks. This patchset
4
file. Open-code it.
5
allows S1_ptw_translate() to change the non-secure bit.
6
5
7
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20210112104511.36576-11-remi.denis.courmont@huawei.com
8
Message-id: 20230220115114.25237-7-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
target/arm/helper.c | 9 ++++++---
11
include/hw/char/cmsdk-apb-uart.h | 34 --------------------------
13
1 file changed, 6 insertions(+), 3 deletions(-)
12
hw/arm/mps2.c | 41 +++++++++++++++++++++-----------
13
2 files changed, 27 insertions(+), 48 deletions(-)
14
14
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/include/hw/char/cmsdk-apb-uart.h b/include/hw/char/cmsdk-apb-uart.h
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
17
--- a/include/hw/char/cmsdk-apb-uart.h
18
+++ b/target/arm/helper.c
18
+++ b/include/hw/char/cmsdk-apb-uart.h
19
@@ -XXX,XX +XXX,XX @@ static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx,
19
@@ -XXX,XX +XXX,XX @@
20
20
#ifndef CMSDK_APB_UART_H
21
/* Translate a S1 pagetable walk through S2 if needed. */
21
#define CMSDK_APB_UART_H
22
static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
22
23
- hwaddr addr, MemTxAttrs txattrs,
23
-#include "hw/qdev-properties.h"
24
+ hwaddr addr, bool *is_secure,
24
#include "hw/sysbus.h"
25
ARMMMUFaultInfo *fi)
25
#include "chardev/char-fe.h"
26
{
26
-#include "qapi/error.h"
27
if (arm_mmu_idx_is_stage1_of_2(mmu_idx) &&
27
#include "qom/object.h"
28
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
28
29
int s2prot;
29
#define TYPE_CMSDK_APB_UART "cmsdk-apb-uart"
30
int ret;
30
@@ -XXX,XX +XXX,XX @@ struct CMSDKAPBUART {
31
ARMCacheAttrs cacheattrs = {};
31
uint8_t rxbuf;
32
+ MemTxAttrs txattrs = {};
32
};
33
34
-/**
35
- * cmsdk_apb_uart_create - convenience function to create TYPE_CMSDK_APB_UART
36
- * @addr: location in system memory to map registers
37
- * @chr: Chardev backend to connect UART to, or NULL if no backend
38
- * @pclk_frq: frequency in Hz of the PCLK clock (used for calculating baud rate)
39
- */
40
-static inline DeviceState *cmsdk_apb_uart_create(hwaddr addr,
41
- qemu_irq txint,
42
- qemu_irq rxint,
43
- qemu_irq txovrint,
44
- qemu_irq rxovrint,
45
- qemu_irq uartint,
46
- Chardev *chr,
47
- uint32_t pclk_frq)
48
-{
49
- DeviceState *dev;
50
- SysBusDevice *s;
51
-
52
- dev = qdev_new(TYPE_CMSDK_APB_UART);
53
- s = SYS_BUS_DEVICE(dev);
54
- qdev_prop_set_chr(dev, "chardev", chr);
55
- qdev_prop_set_uint32(dev, "pclk-frq", pclk_frq);
56
- sysbus_realize_and_unref(s, &error_fatal);
57
- sysbus_mmio_map(s, 0, addr);
58
- sysbus_connect_irq(s, 0, txint);
59
- sysbus_connect_irq(s, 1, rxint);
60
- sysbus_connect_irq(s, 2, txovrint);
61
- sysbus_connect_irq(s, 3, rxovrint);
62
- sysbus_connect_irq(s, 4, uartint);
63
- return dev;
64
-}
65
-
66
#endif
67
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/hw/arm/mps2.c
70
+++ b/hw/arm/mps2.c
71
@@ -XXX,XX +XXX,XX @@
72
#include "hw/boards.h"
73
#include "exec/address-spaces.h"
74
#include "sysemu/sysemu.h"
75
+#include "hw/qdev-properties.h"
76
#include "hw/misc/unimp.h"
77
#include "hw/char/cmsdk-apb-uart.h"
78
#include "hw/timer/cmsdk-apb-timer.h"
79
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
80
qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
81
82
for (i = 0; i < 5; i++) {
83
+ DeviceState *dev;
84
+ SysBusDevice *s;
33
+
85
+
34
+ assert(!*is_secure); /* TODO: S-EL2 */
86
static const hwaddr uartbase[] = {0x40004000, 0x40005000,
35
87
0x40006000, 0x40007000,
36
ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2,
88
0x40009000};
37
false,
89
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
38
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure,
90
rxovrint = qdev_get_gpio_in(orgate_dev, i * 2 + 1);
39
AddressSpace *as;
91
}
40
uint32_t data;
92
41
93
- cmsdk_apb_uart_create(uartbase[i],
42
+ addr = S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi);
94
- qdev_get_gpio_in(armv7m, uartirq[i] + 1),
43
attrs.secure = is_secure;
95
- qdev_get_gpio_in(armv7m, uartirq[i]),
44
as = arm_addressspace(cs, attrs);
96
- txovrint, rxovrint,
45
- addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi);
97
- NULL,
46
if (fi->s1ptw) {
98
- serial_hd(i), SYSCLK_FRQ);
47
return 0;
99
+ dev = qdev_new(TYPE_CMSDK_APB_UART);
100
+ s = SYS_BUS_DEVICE(dev);
101
+ qdev_prop_set_chr(dev, "chardev", serial_hd(i));
102
+ qdev_prop_set_uint32(dev, "pclk-frq", SYSCLK_FRQ);
103
+ sysbus_realize_and_unref(s, &error_fatal);
104
+ sysbus_mmio_map(s, 0, uartbase[i]);
105
+ sysbus_connect_irq(s, 0, qdev_get_gpio_in(armv7m, uartirq[i] + 1));
106
+ sysbus_connect_irq(s, 1, qdev_get_gpio_in(armv7m, uartirq[i]));
107
+ sysbus_connect_irq(s, 2, txovrint);
108
+ sysbus_connect_irq(s, 3, rxovrint);
109
}
110
break;
48
}
111
}
49
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,
112
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
50
AddressSpace *as;
113
0x4002c000, 0x4002d000,
51
uint64_t data;
114
0x4002e000};
52
115
Object *txrx_orgate;
53
+ addr = S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi);
116
- DeviceState *txrx_orgate_dev;
54
attrs.secure = is_secure;
117
+ DeviceState *txrx_orgate_dev, *dev;
55
as = arm_addressspace(cs, attrs);
118
+ SysBusDevice *s;
56
- addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi);
119
57
if (fi->s1ptw) {
120
txrx_orgate = object_new(TYPE_OR_IRQ);
58
return 0;
121
object_property_set_int(txrx_orgate, "num-lines", 2, &error_fatal);
122
@@ -XXX,XX +XXX,XX @@ static void mps2_common_init(MachineState *machine)
123
txrx_orgate_dev = DEVICE(txrx_orgate);
124
qdev_connect_gpio_out(txrx_orgate_dev, 0,
125
qdev_get_gpio_in(armv7m, uart_txrx_irqno[i]));
126
- cmsdk_apb_uart_create(uartbase[i],
127
- qdev_get_gpio_in(txrx_orgate_dev, 0),
128
- qdev_get_gpio_in(txrx_orgate_dev, 1),
129
- qdev_get_gpio_in(orgate_dev, i * 2),
130
- qdev_get_gpio_in(orgate_dev, i * 2 + 1),
131
- NULL,
132
- serial_hd(i), SYSCLK_FRQ);
133
+
134
+ dev = qdev_new(TYPE_CMSDK_APB_UART);
135
+ s = SYS_BUS_DEVICE(dev);
136
+ qdev_prop_set_chr(dev, "chardev", serial_hd(i));
137
+ qdev_prop_set_uint32(dev, "pclk-frq", SYSCLK_FRQ);
138
+ sysbus_realize_and_unref(s, &error_fatal);
139
+ sysbus_mmio_map(s, 0, uartbase[i]);
140
+ sysbus_connect_irq(s, 0, qdev_get_gpio_in(txrx_orgate_dev, 0));
141
+ sysbus_connect_irq(s, 1, qdev_get_gpio_in(txrx_orgate_dev, 1));
142
+ sysbus_connect_irq(s, 2, qdev_get_gpio_in(orgate_dev, i * 2));
143
+ sysbus_connect_irq(s, 3, qdev_get_gpio_in(orgate_dev, i * 2 + 1));
144
}
145
break;
59
}
146
}
60
--
147
--
61
2.20.1
148
2.34.1
62
149
63
150
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Update all users of do_perm_pred3 for the new
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
predicate descriptor field definitions.
4
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
5
Message-id: 20230220115114.25237-8-philmd@linaro.org
6
Cc: qemu-stable@nongnu.org
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210113062650.593824-4-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
7
---
12
target/arm/sve_helper.c | 18 +++++++++---------
8
include/hw/timer/cmsdk-apb-timer.h | 1 -
13
target/arm/translate-sve.c | 12 ++++--------
9
1 file changed, 1 deletion(-)
14
2 files changed, 13 insertions(+), 17 deletions(-)
15
10
16
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
11
diff --git a/include/hw/timer/cmsdk-apb-timer.h b/include/hw/timer/cmsdk-apb-timer.h
17
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/sve_helper.c
13
--- a/include/hw/timer/cmsdk-apb-timer.h
19
+++ b/target/arm/sve_helper.c
14
+++ b/include/hw/timer/cmsdk-apb-timer.h
20
@@ -XXX,XX +XXX,XX @@ static uint64_t compress_bits(uint64_t x, int n)
15
@@ -XXX,XX +XXX,XX @@
21
16
#ifndef CMSDK_APB_TIMER_H
22
void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
17
#define CMSDK_APB_TIMER_H
23
{
18
24
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
19
-#include "hw/qdev-properties.h"
25
- int esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
20
#include "hw/sysbus.h"
26
- intptr_t high = extract32(pred_desc, SIMD_DATA_SHIFT + 2, 1);
21
#include "hw/ptimer.h"
27
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
22
#include "hw/clock.h"
28
+ int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
29
+ intptr_t high = FIELD_EX32(pred_desc, PREDDESC, DATA);
30
uint64_t *d = vd;
31
intptr_t i;
32
33
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
34
35
void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
36
{
37
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
38
- int esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
39
- int odd = extract32(pred_desc, SIMD_DATA_SHIFT + 2, 1) << esz;
40
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
41
+ int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
42
+ int odd = FIELD_EX32(pred_desc, PREDDESC, DATA) << esz;
43
uint64_t *d = vd, *n = vn, *m = vm;
44
uint64_t l, h;
45
intptr_t i;
46
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
47
48
void HELPER(sve_trn_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
49
{
50
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
51
- uintptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
52
- bool odd = extract32(pred_desc, SIMD_DATA_SHIFT + 2, 1);
53
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
54
+ int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
55
+ int odd = FIELD_EX32(pred_desc, PREDDESC, DATA);
56
uint64_t *d = vd, *n = vn, *m = vm;
57
uint64_t mask;
58
int shr, shl;
59
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/target/arm/translate-sve.c
62
+++ b/target/arm/translate-sve.c
63
@@ -XXX,XX +XXX,XX @@ static bool do_perm_pred3(DisasContext *s, arg_rrr_esz *a, bool high_odd,
64
65
unsigned vsz = pred_full_reg_size(s);
66
67
- /* Predicate sizes may be smaller and cannot use simd_desc.
68
- We cannot round up, as we do elsewhere, because we need
69
- the exact size for ZIP2 and REV. We retain the style for
70
- the other helpers for consistency. */
71
TCGv_ptr t_d = tcg_temp_new_ptr();
72
TCGv_ptr t_n = tcg_temp_new_ptr();
73
TCGv_ptr t_m = tcg_temp_new_ptr();
74
TCGv_i32 t_desc;
75
- int desc;
76
+ uint32_t desc = 0;
77
78
- desc = vsz - 2;
79
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz);
80
- desc = deposit32(desc, SIMD_DATA_SHIFT + 2, 2, high_odd);
81
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz);
82
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz);
83
+ desc = FIELD_DP32(desc, PREDDESC, DATA, high_odd);
84
85
tcg_gen_addi_ptr(t_d, cpu_env, pred_full_reg_offset(s, a->rd));
86
tcg_gen_addi_ptr(t_n, cpu_env, pred_full_reg_offset(s, a->rn));
87
--
23
--
88
2.20.1
24
2.34.1
89
25
90
26
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
This adds the MMU indices for EL2 stage 1 in secure state.
3
Avoid accessing 'parent_obj' directly.
4
4
5
To keep code contained, which is largelly identical between secure and
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
non-secure modes, the MMU indices are reassigned. The new assignments
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
provide a systematic pattern with a non-secure bit.
7
Message-id: 20230220115114.25237-9-philmd@linaro.org
8
9
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20210112104511.36576-8-remi.denis.courmont@huawei.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
9
---
14
target/arm/cpu-param.h | 2 +-
10
hw/intc/armv7m_nvic.c | 6 +++---
15
target/arm/cpu.h | 35 ++++++----
11
1 file changed, 3 insertions(+), 3 deletions(-)
16
target/arm/internals.h | 12 ++++
17
target/arm/helper.c | 127 ++++++++++++++++++++++++-------------
18
target/arm/translate-a64.c | 4 ++
19
5 files changed, 123 insertions(+), 57 deletions(-)
20
12
21
diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h
13
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
22
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/cpu-param.h
15
--- a/hw/intc/armv7m_nvic.c
24
+++ b/target/arm/cpu-param.h
16
+++ b/hw/intc/armv7m_nvic.c
25
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static void do_armv7m_nvic_set_pending(void *opaque, int irq, bool secure,
26
# define TARGET_PAGE_BITS_MIN 10
18
* which saves having to have an extra argument is_terminal
27
#endif
19
* that we'd only use in one place.
28
20
*/
29
-#define NB_MMU_MODES 11
21
- cpu_abort(&s->cpu->parent_obj,
30
+#define NB_MMU_MODES 15
22
+ cpu_abort(CPU(s->cpu),
31
23
"Lockup: can't take terminal derived exception "
32
#endif
24
"(original exception priority %d)\n",
33
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
25
s->vectpending_prio);
34
index XXXXXXX..XXXXXXX 100644
26
@@ -XXX,XX +XXX,XX @@ static void do_armv7m_nvic_set_pending(void *opaque, int irq, bool secure,
35
--- a/target/arm/cpu.h
27
* Lockup condition due to a guest bug. We don't model
36
+++ b/target/arm/cpu.h
28
* Lockup, so report via cpu_abort() instead.
37
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
29
*/
38
#define ARM_MMU_IDX_NOTLB 0x20 /* does not have a TLB */
30
- cpu_abort(&s->cpu->parent_obj,
39
#define ARM_MMU_IDX_M 0x40 /* M profile */
31
+ cpu_abort(CPU(s->cpu),
40
32
"Lockup: can't escalate %d to HardFault "
41
+/* Meanings of the bits for A profile mmu idx values */
33
"(current priority %d)\n", irq, running);
42
+#define ARM_MMU_IDX_A_NS 0x8
43
+
44
/* Meanings of the bits for M profile mmu idx values */
45
#define ARM_MMU_IDX_M_PRIV 0x1
46
#define ARM_MMU_IDX_M_NEGPRI 0x2
47
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
48
/*
49
* A-profile.
50
*/
51
- ARMMMUIdx_E10_0 = 0 | ARM_MMU_IDX_A,
52
- ARMMMUIdx_E20_0 = 1 | ARM_MMU_IDX_A,
53
+ ARMMMUIdx_SE10_0 = 0 | ARM_MMU_IDX_A,
54
+ ARMMMUIdx_SE20_0 = 1 | ARM_MMU_IDX_A,
55
+ ARMMMUIdx_SE10_1 = 2 | ARM_MMU_IDX_A,
56
+ ARMMMUIdx_SE20_2 = 3 | ARM_MMU_IDX_A,
57
+ ARMMMUIdx_SE10_1_PAN = 4 | ARM_MMU_IDX_A,
58
+ ARMMMUIdx_SE20_2_PAN = 5 | ARM_MMU_IDX_A,
59
+ ARMMMUIdx_SE2 = 6 | ARM_MMU_IDX_A,
60
+ ARMMMUIdx_SE3 = 7 | ARM_MMU_IDX_A,
61
62
- ARMMMUIdx_E10_1 = 2 | ARM_MMU_IDX_A,
63
- ARMMMUIdx_E10_1_PAN = 3 | ARM_MMU_IDX_A,
64
-
65
- ARMMMUIdx_E2 = 4 | ARM_MMU_IDX_A,
66
- ARMMMUIdx_E20_2 = 5 | ARM_MMU_IDX_A,
67
- ARMMMUIdx_E20_2_PAN = 6 | ARM_MMU_IDX_A,
68
-
69
- ARMMMUIdx_SE10_0 = 7 | ARM_MMU_IDX_A,
70
- ARMMMUIdx_SE10_1 = 8 | ARM_MMU_IDX_A,
71
- ARMMMUIdx_SE10_1_PAN = 9 | ARM_MMU_IDX_A,
72
- ARMMMUIdx_SE3 = 10 | ARM_MMU_IDX_A,
73
+ ARMMMUIdx_E10_0 = ARMMMUIdx_SE10_0 | ARM_MMU_IDX_A_NS,
74
+ ARMMMUIdx_E20_0 = ARMMMUIdx_SE20_0 | ARM_MMU_IDX_A_NS,
75
+ ARMMMUIdx_E10_1 = ARMMMUIdx_SE10_1 | ARM_MMU_IDX_A_NS,
76
+ ARMMMUIdx_E20_2 = ARMMMUIdx_SE20_2 | ARM_MMU_IDX_A_NS,
77
+ ARMMMUIdx_E10_1_PAN = ARMMMUIdx_SE10_1_PAN | ARM_MMU_IDX_A_NS,
78
+ ARMMMUIdx_E20_2_PAN = ARMMMUIdx_SE20_2_PAN | ARM_MMU_IDX_A_NS,
79
+ ARMMMUIdx_E2 = ARMMMUIdx_SE2 | ARM_MMU_IDX_A_NS,
80
81
/*
82
* These are not allocated TLBs and are used only for AT system
83
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdxBit {
84
TO_CORE_BIT(E20_2),
85
TO_CORE_BIT(E20_2_PAN),
86
TO_CORE_BIT(SE10_0),
87
+ TO_CORE_BIT(SE20_0),
88
TO_CORE_BIT(SE10_1),
89
+ TO_CORE_BIT(SE20_2),
90
TO_CORE_BIT(SE10_1_PAN),
91
+ TO_CORE_BIT(SE20_2_PAN),
92
+ TO_CORE_BIT(SE2),
93
TO_CORE_BIT(SE3),
94
95
TO_CORE_BIT(MUser),
96
diff --git a/target/arm/internals.h b/target/arm/internals.h
97
index XXXXXXX..XXXXXXX 100644
98
--- a/target/arm/internals.h
99
+++ b/target/arm/internals.h
100
@@ -XXX,XX +XXX,XX @@ static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx)
101
case ARMMMUIdx_SE10_0:
102
case ARMMMUIdx_SE10_1:
103
case ARMMMUIdx_SE10_1_PAN:
104
+ case ARMMMUIdx_SE20_0:
105
+ case ARMMMUIdx_SE20_2:
106
+ case ARMMMUIdx_SE20_2_PAN:
107
return true;
108
default:
109
return false;
110
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx)
111
case ARMMMUIdx_SE10_0:
112
case ARMMMUIdx_SE10_1:
113
case ARMMMUIdx_SE10_1_PAN:
114
+ case ARMMMUIdx_SE20_0:
115
+ case ARMMMUIdx_SE20_2:
116
+ case ARMMMUIdx_SE20_2_PAN:
117
+ case ARMMMUIdx_SE2:
118
case ARMMMUIdx_MSPrivNegPri:
119
case ARMMMUIdx_MSUserNegPri:
120
case ARMMMUIdx_MSPriv:
121
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx)
122
case ARMMMUIdx_E10_1_PAN:
123
case ARMMMUIdx_E20_2_PAN:
124
case ARMMMUIdx_SE10_1_PAN:
125
+ case ARMMMUIdx_SE20_2_PAN:
126
return true;
127
default:
128
return false;
129
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx)
130
static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
131
{
132
switch (mmu_idx) {
133
+ case ARMMMUIdx_SE20_0:
134
+ case ARMMMUIdx_SE20_2:
135
+ case ARMMMUIdx_SE20_2_PAN:
136
case ARMMMUIdx_E20_0:
137
case ARMMMUIdx_E20_2:
138
case ARMMMUIdx_E20_2_PAN:
139
case ARMMMUIdx_Stage2:
140
+ case ARMMMUIdx_SE2:
141
case ARMMMUIdx_E2:
142
return 2;
143
case ARMMMUIdx_SE3:
144
diff --git a/target/arm/helper.c b/target/arm/helper.c
145
index XXXXXXX..XXXXXXX 100644
146
--- a/target/arm/helper.c
147
+++ b/target/arm/helper.c
148
@@ -XXX,XX +XXX,XX @@ static int gt_phys_redir_timeridx(CPUARMState *env)
149
case ARMMMUIdx_E20_0:
150
case ARMMMUIdx_E20_2:
151
case ARMMMUIdx_E20_2_PAN:
152
+ case ARMMMUIdx_SE20_0:
153
+ case ARMMMUIdx_SE20_2:
154
+ case ARMMMUIdx_SE20_2_PAN:
155
return GTIMER_HYP;
156
default:
157
return GTIMER_PHYS;
158
@@ -XXX,XX +XXX,XX @@ static int gt_virt_redir_timeridx(CPUARMState *env)
159
case ARMMMUIdx_E20_0:
160
case ARMMMUIdx_E20_2:
161
case ARMMMUIdx_E20_2_PAN:
162
+ case ARMMMUIdx_SE20_0:
163
+ case ARMMMUIdx_SE20_2:
164
+ case ARMMMUIdx_SE20_2_PAN:
165
return GTIMER_HYPVIRT;
166
default:
167
return GTIMER_VIRT;
168
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
169
mmu_idx = ARMMMUIdx_SE3;
170
break;
171
case 2:
172
- g_assert(!secure); /* TODO: ARMv8.4-SecEL2 */
173
+ g_assert(!secure); /* ARMv8.4-SecEL2 is 64-bit only */
174
/* fall through */
175
case 1:
176
if (ri->crm == 9 && (env->uncached_cpsr & CPSR_PAN)) {
177
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
178
}
34
}
179
break;
35
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure)
180
case 4: /* AT S1E2R, AT S1E2W */
36
* We want to escalate to HardFault but the context the
181
- mmu_idx = ARMMMUIdx_E2;
37
* FP state belongs to prevents the exception pre-empting.
182
+ mmu_idx = secure ? ARMMMUIdx_SE2 : ARMMMUIdx_E2;
38
*/
183
break;
39
- cpu_abort(&s->cpu->parent_obj,
184
case 6: /* AT S1E3R, AT S1E3W */
40
+ cpu_abort(CPU(s->cpu),
185
mmu_idx = ARMMMUIdx_SE3;
41
"Lockup: can't escalate to HardFault during "
186
@@ -XXX,XX +XXX,XX @@ static void vmsa_tcr_ttbr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri,
42
"lazy FP register stacking\n");
187
*/
188
if (extract64(raw_read(env, ri) ^ value, 48, 16) &&
189
(arm_hcr_el2_eff(env) & HCR_E2H)) {
190
- tlb_flush_by_mmuidx(env_cpu(env),
191
- ARMMMUIdxBit_E20_2 |
192
- ARMMMUIdxBit_E20_2_PAN |
193
- ARMMMUIdxBit_E20_0);
194
+ uint16_t mask = ARMMMUIdxBit_E20_2 |
195
+ ARMMMUIdxBit_E20_2_PAN |
196
+ ARMMMUIdxBit_E20_0;
197
+
198
+ if (arm_is_secure_below_el3(env)) {
199
+ mask >>= ARM_MMU_IDX_A_NS;
200
+ }
201
+
202
+ tlb_flush_by_mmuidx(env_cpu(env), mask);
203
}
204
raw_write(env, ri, value);
205
}
206
@@ -XXX,XX +XXX,XX @@ static int vae1_tlbmask(CPUARMState *env)
207
uint64_t hcr = arm_hcr_el2_eff(env);
208
209
if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
210
- return ARMMMUIdxBit_E20_2 |
211
- ARMMMUIdxBit_E20_2_PAN |
212
- ARMMMUIdxBit_E20_0;
213
+ uint16_t mask = ARMMMUIdxBit_E20_2 |
214
+ ARMMMUIdxBit_E20_2_PAN |
215
+ ARMMMUIdxBit_E20_0;
216
+
217
+ if (arm_is_secure_below_el3(env)) {
218
+ mask >>= ARM_MMU_IDX_A_NS;
219
+ }
220
+
221
+ return mask;
222
} else if (arm_is_secure_below_el3(env)) {
223
return ARMMMUIdxBit_SE10_1 |
224
ARMMMUIdxBit_SE10_1_PAN |
225
@@ -XXX,XX +XXX,XX @@ static int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx,
226
227
static int vae1_tlbbits(CPUARMState *env, uint64_t addr)
228
{
229
+ uint64_t hcr = arm_hcr_el2_eff(env);
230
ARMMMUIdx mmu_idx;
231
232
/* Only the regime of the mmu_idx below is significant. */
233
- if (arm_is_secure_below_el3(env)) {
234
- mmu_idx = ARMMMUIdx_SE10_0;
235
- } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE))
236
- == (HCR_E2H | HCR_TGE)) {
237
+ if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
238
mmu_idx = ARMMMUIdx_E20_0;
239
} else {
240
mmu_idx = ARMMMUIdx_E10_0;
241
}
242
+
243
+ if (arm_is_secure_below_el3(env)) {
244
+ mmu_idx &= ~ARM_MMU_IDX_A_NS;
245
+ }
246
+
247
return tlbbits_for_regime(env, mmu_idx, addr);
248
}
249
250
@@ -XXX,XX +XXX,XX @@ static int alle1_tlbmask(CPUARMState *env)
251
252
static int e2_tlbmask(CPUARMState *env)
253
{
254
- /* TODO: ARMv8.4-SecEL2 */
255
- return ARMMMUIdxBit_E20_0 |
256
- ARMMMUIdxBit_E20_2 |
257
- ARMMMUIdxBit_E20_2_PAN |
258
- ARMMMUIdxBit_E2;
259
+ if (arm_is_secure_below_el3(env)) {
260
+ return ARMMMUIdxBit_SE20_0 |
261
+ ARMMMUIdxBit_SE20_2 |
262
+ ARMMMUIdxBit_SE20_2_PAN |
263
+ ARMMMUIdxBit_SE2;
264
+ } else {
265
+ return ARMMMUIdxBit_E20_0 |
266
+ ARMMMUIdxBit_E20_2 |
267
+ ARMMMUIdxBit_E20_2_PAN |
268
+ ARMMMUIdxBit_E2;
269
+ }
270
}
271
272
static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri,
273
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
274
{
275
CPUState *cs = env_cpu(env);
276
uint64_t pageaddr = sextract64(value << 12, 0, 56);
277
- int bits = tlbbits_for_regime(env, ARMMMUIdx_E2, pageaddr);
278
+ bool secure = arm_is_secure_below_el3(env);
279
+ int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
280
+ int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
281
+ pageaddr);
282
283
- tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr,
284
- ARMMMUIdxBit_E2, bits);
285
+ tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits);
286
}
287
288
static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
289
@@ -XXX,XX +XXX,XX @@ uint64_t arm_sctlr(CPUARMState *env, int el)
290
/* Only EL0 needs to be adjusted for EL1&0 or EL2&0. */
291
if (el == 0) {
292
ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, 0);
293
- el = (mmu_idx == ARMMMUIdx_E20_0 ? 2 : 1);
294
+ el = (mmu_idx == ARMMMUIdx_E20_0 || mmu_idx == ARMMMUIdx_SE20_0)
295
+ ? 2 : 1;
296
}
297
return env->cp15.sctlr_el[el];
298
}
299
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
300
switch (mmu_idx) {
301
case ARMMMUIdx_SE10_0:
302
case ARMMMUIdx_E20_0:
303
+ case ARMMMUIdx_SE20_0:
304
case ARMMMUIdx_Stage1_E0:
305
case ARMMMUIdx_MUser:
306
case ARMMMUIdx_MSUser:
307
@@ -XXX,XX +XXX,XX @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
308
case ARMMMUIdx_E10_0:
309
case ARMMMUIdx_E20_0:
310
case ARMMMUIdx_SE10_0:
311
+ case ARMMMUIdx_SE20_0:
312
return 0;
313
case ARMMMUIdx_E10_1:
314
case ARMMMUIdx_E10_1_PAN:
315
@@ -XXX,XX +XXX,XX @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
316
case ARMMMUIdx_E2:
317
case ARMMMUIdx_E20_2:
318
case ARMMMUIdx_E20_2_PAN:
319
+ case ARMMMUIdx_SE2:
320
+ case ARMMMUIdx_SE20_2:
321
+ case ARMMMUIdx_SE20_2_PAN:
322
return 2;
323
case ARMMMUIdx_SE3:
324
return 3;
325
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
326
327
ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el)
328
{
329
+ ARMMMUIdx idx;
330
+ uint64_t hcr;
331
+
332
if (arm_feature(env, ARM_FEATURE_M)) {
333
return arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure);
334
}
335
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el)
336
/* See ARM pseudo-function ELIsInHost. */
337
switch (el) {
338
case 0:
339
- if (arm_is_secure_below_el3(env)) {
340
- return ARMMMUIdx_SE10_0;
341
+ hcr = arm_hcr_el2_eff(env);
342
+ if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
343
+ idx = ARMMMUIdx_E20_0;
344
+ } else {
345
+ idx = ARMMMUIdx_E10_0;
346
}
347
- if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)
348
- && arm_el_is_aa64(env, 2)) {
349
- return ARMMMUIdx_E20_0;
350
- }
351
- return ARMMMUIdx_E10_0;
352
+ break;
353
case 1:
354
- if (arm_is_secure_below_el3(env)) {
355
- if (env->pstate & PSTATE_PAN) {
356
- return ARMMMUIdx_SE10_1_PAN;
357
- }
358
- return ARMMMUIdx_SE10_1;
359
- }
360
if (env->pstate & PSTATE_PAN) {
361
- return ARMMMUIdx_E10_1_PAN;
362
+ idx = ARMMMUIdx_E10_1_PAN;
363
+ } else {
364
+ idx = ARMMMUIdx_E10_1;
365
}
366
- return ARMMMUIdx_E10_1;
367
+ break;
368
case 2:
369
- /* TODO: ARMv8.4-SecEL2 */
370
/* Note that TGE does not apply at EL2. */
371
- if ((env->cp15.hcr_el2 & HCR_E2H) && arm_el_is_aa64(env, 2)) {
372
+ if (arm_hcr_el2_eff(env) & HCR_E2H) {
373
if (env->pstate & PSTATE_PAN) {
374
- return ARMMMUIdx_E20_2_PAN;
375
+ idx = ARMMMUIdx_E20_2_PAN;
376
+ } else {
377
+ idx = ARMMMUIdx_E20_2;
378
}
379
- return ARMMMUIdx_E20_2;
380
+ } else {
381
+ idx = ARMMMUIdx_E2;
382
}
383
- return ARMMMUIdx_E2;
384
+ break;
385
case 3:
386
return ARMMMUIdx_SE3;
387
default:
388
g_assert_not_reached();
389
}
390
+
391
+ if (arm_is_secure_below_el3(env)) {
392
+ idx &= ~ARM_MMU_IDX_A_NS;
393
+ }
394
+
395
+ return idx;
396
}
397
398
ARMMMUIdx arm_mmu_idx(CPUARMState *env)
399
@@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
400
break;
401
case ARMMMUIdx_E20_2:
402
case ARMMMUIdx_E20_2_PAN:
403
- /* TODO: ARMv8.4-SecEL2 */
404
+ case ARMMMUIdx_SE20_2:
405
+ case ARMMMUIdx_SE20_2_PAN:
406
/*
407
* Note that EL20_2 is gated by HCR_EL2.E2H == 1, but EL20_0 is
408
* gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR.
409
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
410
index XXXXXXX..XXXXXXX 100644
411
--- a/target/arm/translate-a64.c
412
+++ b/target/arm/translate-a64.c
413
@@ -XXX,XX +XXX,XX @@ static int get_a64_user_mem_index(DisasContext *s)
414
case ARMMMUIdx_SE10_1_PAN:
415
useridx = ARMMMUIdx_SE10_0;
416
break;
417
+ case ARMMMUIdx_SE20_2:
418
+ case ARMMMUIdx_SE20_2_PAN:
419
+ useridx = ARMMMUIdx_SE20_0;
420
+ break;
421
default:
422
g_assert_not_reached();
423
}
43
}
424
--
44
--
425
2.20.1
45
2.34.1
426
46
427
47
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210112104511.36576-15-remi.denis.courmont@huawei.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
6
---
8
target/arm/cpu.h | 2 ++
7
hw/arm/musicpal.c | 4 ----
9
target/arm/internals.h | 2 ++
8
1 file changed, 4 deletions(-)
10
target/arm/helper.c | 6 ++++++
11
target/arm/tlb_helper.c | 3 +++
12
4 files changed, 13 insertions(+)
13
9
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
10
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
15
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
12
--- a/hw/arm/musicpal.c
17
+++ b/target/arm/cpu.h
13
+++ b/hw/arm/musicpal.c
18
@@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
14
@@ -XXX,XX +XXX,XX @@ struct musicpal_key_state {
19
#define HCR_TWEDEN (1ULL << 59)
15
SysBusDevice parent_obj;
20
#define HCR_TWEDEL MAKE_64BIT_MASK(60, 4)
16
/*< public >*/
21
17
22
+#define HPFAR_NS (1ULL << 63)
18
- MemoryRegion iomem;
23
+
19
uint32_t kbd_extended;
24
#define SCR_NS (1U << 0)
20
uint32_t pressed_keys;
25
#define SCR_IRQ (1U << 1)
21
qemu_irq out[8];
26
#define SCR_FIQ (1U << 2)
22
@@ -XXX,XX +XXX,XX @@ static void musicpal_key_init(Object *obj)
27
diff --git a/target/arm/internals.h b/target/arm/internals.h
23
DeviceState *dev = DEVICE(sbd);
28
index XXXXXXX..XXXXXXX 100644
24
musicpal_key_state *s = MUSICPAL_KEY(dev);
29
--- a/target/arm/internals.h
25
30
+++ b/target/arm/internals.h
26
- memory_region_init(&s->iomem, obj, "dummy", 0);
31
@@ -XXX,XX +XXX,XX @@ typedef enum ARMFaultType {
27
- sysbus_init_mmio(sbd, &s->iomem);
32
* @s2addr: Address that caused a fault at stage 2
28
-
33
* @stage2: True if we faulted at stage 2
29
s->kbd_extended = 0;
34
* @s1ptw: True if we faulted at stage 2 while doing a stage 1 page-table walk
30
s->pressed_keys = 0;
35
+ * @s1ns: True if we faulted on a non-secure IPA while in secure state
36
* @ea: True if we should set the EA (external abort type) bit in syndrome
37
*/
38
typedef struct ARMMMUFaultInfo ARMMMUFaultInfo;
39
@@ -XXX,XX +XXX,XX @@ struct ARMMMUFaultInfo {
40
int domain;
41
bool stage2;
42
bool s1ptw;
43
+ bool s1ns;
44
bool ea;
45
};
46
47
diff --git a/target/arm/helper.c b/target/arm/helper.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/helper.c
50
+++ b/target/arm/helper.c
51
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
52
target_el = 3;
53
} else {
54
env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4;
55
+ if (arm_is_secure_below_el3(env) && fi.s1ns) {
56
+ env->cp15.hpfar_el2 |= HPFAR_NS;
57
+ }
58
target_el = 2;
59
}
60
take_exc = true;
61
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
62
fi->s2addr = addr;
63
fi->stage2 = true;
64
fi->s1ptw = true;
65
+ fi->s1ns = !*is_secure;
66
return ~0;
67
}
68
if ((arm_hcr_el2_eff(env) & HCR_PTW) &&
69
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
70
fi->s2addr = addr;
71
fi->stage2 = true;
72
fi->s1ptw = true;
73
+ fi->s1ns = !*is_secure;
74
return ~0;
75
}
76
77
@@ -XXX,XX +XXX,XX @@ do_fault:
78
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
79
fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 ||
80
mmu_idx == ARMMMUIdx_Stage2_S);
81
+ fi->s1ns = mmu_idx == ARMMMUIdx_Stage2;
82
return true;
83
}
84
85
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/target/arm/tlb_helper.c
88
+++ b/target/arm/tlb_helper.c
89
@@ -XXX,XX +XXX,XX @@ static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr,
90
if (fi->stage2) {
91
target_el = 2;
92
env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4;
93
+ if (arm_is_secure_below_el3(env) && fi->s1ns) {
94
+ env->cp15.hpfar_el2 |= HPFAR_NS;
95
+ }
96
}
97
same_el = (arm_current_el(env) == target_el);
98
31
99
--
32
--
100
2.20.1
33
2.34.1
101
34
102
35
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
Since commit be8d853766 ("iothread: add I/O thread object") we
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
never used IOThreadClass / IOTHREAD_CLASS() / IOTHREAD_GET_CLASS(),
5
Message-id: 20210112104511.36576-19-remi.denis.courmont@huawei.com
5
remove these definitions.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-id: 20230113200138.52869-2-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
12
---
8
target/arm/helper.c | 25 +++++++++++--------------
13
iothread.c | 4 ----
9
1 file changed, 11 insertions(+), 14 deletions(-)
14
1 file changed, 4 deletions(-)
10
15
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
diff --git a/iothread.c b/iothread.c
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
18
--- a/iothread.c
14
+++ b/target/arm/helper.c
19
+++ b/iothread.c
15
@@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env,
20
@@ -XXX,XX +XXX,XX @@
16
static int vae1_tlbmask(CPUARMState *env)
21
#include "qemu/rcu.h"
17
{
22
#include "qemu/main-loop.h"
18
uint64_t hcr = arm_hcr_el2_eff(env);
23
19
+ uint16_t mask;
24
-typedef ObjectClass IOThreadClass;
20
21
if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
22
- uint16_t mask = ARMMMUIdxBit_E20_2 |
23
- ARMMMUIdxBit_E20_2_PAN |
24
- ARMMMUIdxBit_E20_0;
25
-
25
-
26
- if (arm_is_secure_below_el3(env)) {
26
-DECLARE_CLASS_CHECKERS(IOThreadClass, IOTHREAD,
27
- mask >>= ARM_MMU_IDX_A_NS;
27
- TYPE_IOTHREAD)
28
- }
28
29
-
29
#ifdef CONFIG_POSIX
30
- return mask;
30
/* Benchmark results from 2016 on NVMe SSD drives show max polling times around
31
- } else if (arm_is_secure_below_el3(env)) {
32
- return ARMMMUIdxBit_SE10_1 |
33
- ARMMMUIdxBit_SE10_1_PAN |
34
- ARMMMUIdxBit_SE10_0;
35
+ mask = ARMMMUIdxBit_E20_2 |
36
+ ARMMMUIdxBit_E20_2_PAN |
37
+ ARMMMUIdxBit_E20_0;
38
} else {
39
- return ARMMMUIdxBit_E10_1 |
40
+ mask = ARMMMUIdxBit_E10_1 |
41
ARMMMUIdxBit_E10_1_PAN |
42
ARMMMUIdxBit_E10_0;
43
}
44
+
45
+ if (arm_is_secure_below_el3(env)) {
46
+ mask >>= ARM_MMU_IDX_A_NS;
47
+ }
48
+
49
+ return mask;
50
}
51
52
/* Return 56 if TBI is enabled, 64 otherwise. */
53
--
31
--
54
2.20.1
32
2.34.1
55
33
56
34
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
QOM *DECLARE* macros expect a typedef as first argument,
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
not a structure. Replace 'struct IRQState' by 'IRQState'
5
Message-id: 20210112104511.36576-9-remi.denis.courmont@huawei.com
5
to avoid when modifying the macros:
6
7
../hw/core/irq.c:29:1: error: declaration of anonymous struct must be a definition
8
DECLARE_INSTANCE_CHECKER(struct IRQState, IRQ,
9
^
10
11
Use OBJECT_DECLARE_SIMPLE_TYPE instead of DECLARE_INSTANCE_CHECKER.
12
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
15
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
16
Message-id: 20230113200138.52869-3-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
18
---
8
target/arm/cpu.h | 7 +++++++
19
hw/core/irq.c | 9 ++++-----
9
target/arm/helper.c | 24 ++++++++++++++++++++++++
20
1 file changed, 4 insertions(+), 5 deletions(-)
10
2 files changed, 31 insertions(+)
11
21
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
22
diff --git a/hw/core/irq.c b/hw/core/irq.c
13
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.h
24
--- a/hw/core/irq.c
15
+++ b/target/arm/cpu.h
25
+++ b/hw/core/irq.c
16
@@ -XXX,XX +XXX,XX @@ typedef struct {
26
@@ -XXX,XX +XXX,XX @@
17
uint32_t base_mask;
27
#include "hw/irq.h"
18
} TCR;
28
#include "qom/object.h"
19
29
20
+#define VTCR_NSW (1u << 29)
30
-DECLARE_INSTANCE_CHECKER(struct IRQState, IRQ,
21
+#define VTCR_NSA (1u << 30)
31
- TYPE_IRQ)
22
+#define VSTCR_SW VTCR_NSW
32
+OBJECT_DECLARE_SIMPLE_TYPE(IRQState, IRQ)
23
+#define VSTCR_SA VTCR_NSA
33
24
+
34
struct IRQState {
25
/* Define a maximum sized vector register.
35
Object parent_obj;
26
* For 32-bit, this is a 128-bit NEON/AdvSIMD register.
36
@@ -XXX,XX +XXX,XX @@ qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n)
27
* For 64-bit, this is a 2048-bit SVE register.
37
28
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
38
qemu_irq qemu_allocate_irq(qemu_irq_handler handler, void *opaque, int n)
29
uint64_t ttbr1_el[4];
39
{
30
};
40
- struct IRQState *irq;
31
uint64_t vttbr_el2; /* Virtualization Translation Table Base. */
41
+ IRQState *irq;
32
+ uint64_t vsttbr_el2; /* Secure Virtualization Translation Table. */
42
33
/* MMU translation table base control. */
43
irq = IRQ(object_new(TYPE_IRQ));
34
TCR tcr_el[4];
44
irq->handler = handler;
35
TCR vtcr_el2; /* Virtualization Translation Control. */
45
@@ -XXX,XX +XXX,XX @@ void qemu_free_irq(qemu_irq irq)
36
+ TCR vstcr_el2; /* Secure Virtualization Translation Control. */
46
37
uint32_t c2_data; /* MPU data cacheable bits. */
47
static void qemu_notirq(void *opaque, int line, int level)
38
uint32_t c2_insn; /* MPU instruction cacheable bits. */
48
{
39
union { /* MMU domain access control register
49
- struct IRQState *irq = opaque;
40
diff --git a/target/arm/helper.c b/target/arm/helper.c
50
+ IRQState *irq = opaque;
41
index XXXXXXX..XXXXXXX 100644
51
42
--- a/target/arm/helper.c
52
irq->handler(irq->opaque, irq->n, !level);
43
+++ b/target/arm/helper.c
53
}
44
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
54
@@ -XXX,XX +XXX,XX @@ void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n)
45
REGINFO_SENTINEL
55
static const TypeInfo irq_type_info = {
56
.name = TYPE_IRQ,
57
.parent = TYPE_OBJECT,
58
- .instance_size = sizeof(struct IRQState),
59
+ .instance_size = sizeof(IRQState),
46
};
60
};
47
61
48
+static CPAccessResult sel2_access(CPUARMState *env, const ARMCPRegInfo *ri,
62
static void irq_register_types(void)
49
+ bool isread)
50
+{
51
+ if (arm_current_el(env) == 3 || arm_is_secure_below_el3(env)) {
52
+ return CP_ACCESS_OK;
53
+ }
54
+ return CP_ACCESS_TRAP_UNCATEGORIZED;
55
+}
56
+
57
+static const ARMCPRegInfo el2_sec_cp_reginfo[] = {
58
+ { .name = "VSTTBR_EL2", .state = ARM_CP_STATE_AA64,
59
+ .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 0,
60
+ .access = PL2_RW, .accessfn = sel2_access,
61
+ .fieldoffset = offsetof(CPUARMState, cp15.vsttbr_el2) },
62
+ { .name = "VSTCR_EL2", .state = ARM_CP_STATE_AA64,
63
+ .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 2,
64
+ .access = PL2_RW, .accessfn = sel2_access,
65
+ .fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) },
66
+ REGINFO_SENTINEL
67
+};
68
+
69
static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
70
bool isread)
71
{
72
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
73
if (arm_feature(env, ARM_FEATURE_V8)) {
74
define_arm_cp_regs(cpu, el2_v8_cp_reginfo);
75
}
76
+ if (cpu_isar_feature(aa64_sel2, cpu)) {
77
+ define_arm_cp_regs(cpu, el2_sec_cp_reginfo);
78
+ }
79
/* RVBAR_EL2 is only implemented if EL2 is the highest EL */
80
if (!arm_feature(env, ARM_FEATURE_EL3)) {
81
ARMCPRegInfo rvbar = {
82
--
63
--
83
2.20.1
64
2.34.1
84
65
85
66
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The stage_1_mmu_idx() already effectively keeps track of which
3
Missed during automatic conversion from commit 8063396bf3
4
translation regimes have two stages. Don't hard-code another test.
4
("Use OBJECT_DECLARE_SIMPLE_TYPE when possible").
5
5
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8
Message-id: 20210112104511.36576-13-remi.denis.courmont@huawei.com
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Message-id: 20230113200138.52869-4-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
target/arm/helper.c | 13 ++++++-------
12
include/hw/or-irq.h | 3 +--
12
1 file changed, 6 insertions(+), 7 deletions(-)
13
1 file changed, 1 insertion(+), 2 deletions(-)
13
14
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/include/hw/or-irq.h b/include/hw/or-irq.h
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
17
--- a/include/hw/or-irq.h
17
+++ b/target/arm/helper.c
18
+++ b/include/hw/or-irq.h
18
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
19
@@ -XXX,XX +XXX,XX @@
19
target_ulong *page_size,
20
20
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
21
typedef struct OrIRQState qemu_or_irq;
21
{
22
22
- if (mmu_idx == ARMMMUIdx_E10_0 ||
23
-DECLARE_INSTANCE_CHECKER(qemu_or_irq, OR_IRQ,
23
- mmu_idx == ARMMMUIdx_E10_1 ||
24
- TYPE_OR_IRQ)
24
- mmu_idx == ARMMMUIdx_E10_1_PAN) {
25
+OBJECT_DECLARE_SIMPLE_TYPE(OrIRQState, OR_IRQ)
25
+ ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx);
26
26
+
27
struct OrIRQState {
27
+ if (mmu_idx != s1_mmu_idx) {
28
DeviceState parent_obj;
28
/* Call ourselves recursively to do the stage 1 and then stage 2
29
- * translations.
30
+ * translations if mmu_idx is a two-stage regime.
31
*/
32
if (arm_feature(env, ARM_FEATURE_EL2)) {
33
hwaddr ipa;
34
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
35
int ret;
36
ARMCacheAttrs cacheattrs2 = {};
37
38
- ret = get_phys_addr(env, address, access_type,
39
- stage_1_mmu_idx(mmu_idx), &ipa, attrs,
40
- prot, page_size, fi, cacheattrs);
41
+ ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa,
42
+ attrs, prot, page_size, fi, cacheattrs);
43
44
/* If S1 fails or S2 is disabled, return early. */
45
if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2)) {
46
--
29
--
47
2.20.1
30
2.34.1
48
31
49
32
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The crypto overhead of emulating pauth can be significant for
3
OBJECT_DECLARE_SIMPLE_TYPE() macro provides the OrIRQState
4
some workloads. Add two boolean properties that allows the
4
declaration for free. Besides, the QOM code style is to use
5
feature to be turned off, on with the architected algorithm,
5
the structure name as typedef, and QEMU style is to use Camel
6
or on with an implementation defined algorithm.
6
Case, so rename qemu_or_irq as OrIRQState.
7
7
8
We need two intermediate booleans to control the state while
8
Mechanical change using:
9
parsing properties lest we clobber ID_AA64ISAR1 into an invalid
9
10
intermediate state.
10
$ sed -i -e 's/qemu_or_irq/OrIRQState/g' $(git grep -l qemu_or_irq)
11
11
12
Tested-by: Mark Rutland <mark.rutland@arm.com>
12
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Reviewed-by: Andrew Jones <drjones@redhat.com>
13
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
14
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
Message-id: 20210111235740.462469-3-richard.henderson@linaro.org
15
Message-id: 20230113200138.52869-5-philmd@linaro.org
16
[PMM: fixed docs typo, tweaked text to clarify that the impdef
17
algorithm is specific to QEMU]
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
17
---
20
docs/system/arm/cpu-features.rst | 21 +++++++++++++++++
18
include/hw/arm/armsse.h | 6 +++---
21
target/arm/cpu.h | 10 ++++++++
19
include/hw/arm/bcm2835_peripherals.h | 2 +-
22
target/arm/cpu.c | 13 +++++++++++
20
include/hw/arm/exynos4210.h | 4 ++--
23
target/arm/cpu64.c | 40 ++++++++++++++++++++++++++++----
21
include/hw/arm/stm32f205_soc.h | 2 +-
24
target/arm/monitor.c | 1 +
22
include/hw/arm/stm32f405_soc.h | 2 +-
25
tests/qtest/arm-cpu-features.c | 13 +++++++++++
23
include/hw/arm/xlnx-versal.h | 6 +++---
26
6 files changed, 94 insertions(+), 4 deletions(-)
24
include/hw/arm/xlnx-zynqmp.h | 2 +-
27
25
include/hw/or-irq.h | 2 --
28
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
26
hw/arm/exynos4210.c | 4 ++--
29
index XXXXXXX..XXXXXXX 100644
27
hw/arm/mps2-tz.c | 2 +-
30
--- a/docs/system/arm/cpu-features.rst
28
hw/core/or-irq.c | 18 +++++++++---------
31
+++ b/docs/system/arm/cpu-features.rst
29
hw/pci-host/raven.c | 2 +-
32
@@ -XXX,XX +XXX,XX @@ the list of KVM VCPU features and their descriptions.
30
12 files changed, 25 insertions(+), 27 deletions(-)
33
influence the guest scheduler behavior and/or be
31
34
exposed to the guest userspace.
32
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
35
33
index XXXXXXX..XXXXXXX 100644
36
+TCG VCPU Features
34
--- a/include/hw/arm/armsse.h
37
+=================
35
+++ b/include/hw/arm/armsse.h
38
+
36
@@ -XXX,XX +XXX,XX @@ struct ARMSSE {
39
+TCG VCPU features are CPU features that are specific to TCG.
37
TZPPC apb_ppc[NUM_INTERNAL_PPCS];
40
+Below is the list of TCG VCPU features and their descriptions.
38
TZMPC mpc[IOTS_NUM_MPC];
41
+
39
CMSDKAPBTimer timer[3];
42
+ pauth Enable or disable `FEAT_Pauth`, pointer
40
- qemu_or_irq ppc_irq_orgate;
43
+ authentication. By default, the feature is
41
+ OrIRQState ppc_irq_orgate;
44
+ enabled with `-cpu max`.
42
SplitIRQ sec_resp_splitter;
45
+
43
SplitIRQ ppc_irq_splitter[NUM_PPCS];
46
+ pauth-impdef When `FEAT_Pauth` is enabled, either the
44
SplitIRQ mpc_irq_splitter[IOTS_NUM_EXP_MPC + IOTS_NUM_MPC];
47
+ *impdef* (Implementation Defined) algorithm
45
- qemu_or_irq mpc_irq_orgate;
48
+ is enabled or the *architected* QARMA algorithm
46
- qemu_or_irq nmi_orgate;
49
+ is enabled. By default the impdef algorithm
47
+ OrIRQState mpc_irq_orgate;
50
+ is disabled, and QARMA is enabled.
48
+ OrIRQState nmi_orgate;
51
+
49
52
+ The architected QARMA algorithm has good
50
SplitIRQ cpu_irq_splitter[NUM_SSE_IRQS];
53
+ cryptographic properties, but can be quite slow
51
54
+ to emulate. The impdef algorithm used by QEMU
52
diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h
55
+ is non-cryptographic but significantly faster.
53
index XXXXXXX..XXXXXXX 100644
56
+
54
--- a/include/hw/arm/bcm2835_peripherals.h
57
SVE CPU Properties
55
+++ b/include/hw/arm/bcm2835_peripherals.h
58
==================
56
@@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState {
59
57
BCM2835AuxState aux;
60
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
58
BCM2835FBState fb;
61
index XXXXXXX..XXXXXXX 100644
59
BCM2835DMAState dma;
62
--- a/target/arm/cpu.h
60
- qemu_or_irq orgated_dma_irq;
63
+++ b/target/arm/cpu.h
61
+ OrIRQState orgated_dma_irq;
64
@@ -XXX,XX +XXX,XX @@ typedef struct {
62
BCM2835ICState ic;
65
#ifdef TARGET_AARCH64
63
BCM2835PropertyState property;
66
# define ARM_MAX_VQ 16
64
BCM2835RngState rng;
67
void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp);
65
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
68
+void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp);
66
index XXXXXXX..XXXXXXX 100644
69
#else
67
--- a/include/hw/arm/exynos4210.h
70
# define ARM_MAX_VQ 1
68
+++ b/include/hw/arm/exynos4210.h
71
static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { }
69
@@ -XXX,XX +XXX,XX @@ struct Exynos4210State {
72
+static inline void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { }
70
MemoryRegion boot_secondary;
73
#endif
71
MemoryRegion bootreg_mem;
74
72
I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER];
75
typedef struct ARMVectorReg {
73
- qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA];
76
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
74
- qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS];
77
uint64_t reset_cbar;
75
+ OrIRQState pl330_irq_orgate[EXYNOS4210_NUM_DMA];
78
uint32_t reset_auxcr;
76
+ OrIRQState cpu_irq_orgate[EXYNOS4210_NCPUS];
79
bool reset_hivecs;
77
A9MPPrivState a9mpcore;
80
+
78
Exynos4210GicState ext_gic;
81
+ /*
79
Exynos4210CombinerState int_combiner;
82
+ * Intermediate values used during property parsing.
80
diff --git a/include/hw/arm/stm32f205_soc.h b/include/hw/arm/stm32f205_soc.h
83
+ * Once finalized, the values should be read from ID_AA64ISAR1.
81
index XXXXXXX..XXXXXXX 100644
84
+ */
82
--- a/include/hw/arm/stm32f205_soc.h
85
+ bool prop_pauth;
83
+++ b/include/hw/arm/stm32f205_soc.h
86
+ bool prop_pauth_impdef;
84
@@ -XXX,XX +XXX,XX @@ struct STM32F205State {
87
+
85
STM32F2XXADCState adc[STM_NUM_ADCS];
88
/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */
86
STM32F2XXSPIState spi[STM_NUM_SPIS];
89
uint32_t dcz_blocksize;
87
90
uint64_t rvbar;
88
- qemu_or_irq *adc_irqs;
91
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
89
+ OrIRQState *adc_irqs;
92
index XXXXXXX..XXXXXXX 100644
90
93
--- a/target/arm/cpu.c
91
MemoryRegion sram;
94
+++ b/target/arm/cpu.c
92
MemoryRegion flash;
95
@@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
93
diff --git a/include/hw/arm/stm32f405_soc.h b/include/hw/arm/stm32f405_soc.h
96
error_propagate(errp, local_err);
94
index XXXXXXX..XXXXXXX 100644
97
return;
95
--- a/include/hw/arm/stm32f405_soc.h
98
}
96
+++ b/include/hw/arm/stm32f405_soc.h
99
+
97
@@ -XXX,XX +XXX,XX @@ struct STM32F405State {
100
+ /*
98
STM32F4xxExtiState exti;
101
+ * KVM does not support modifications to this feature.
99
STM32F2XXUsartState usart[STM_NUM_USARTS];
102
+ * We have not registered the cpu properties when KVM
100
STM32F2XXTimerState timer[STM_NUM_TIMERS];
103
+ * is in use, so the user will not be able to set them.
101
- qemu_or_irq adc_irqs;
104
+ */
102
+ OrIRQState adc_irqs;
105
+ if (!kvm_enabled()) {
103
STM32F2XXADCState adc[STM_NUM_ADCS];
106
+ arm_cpu_pauth_finalize(cpu, &local_err);
104
STM32F2XXSPIState spi[STM_NUM_SPIS];
107
+ if (local_err != NULL) {
105
108
+ error_propagate(errp, local_err);
106
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
109
+ return;
107
index XXXXXXX..XXXXXXX 100644
110
+ }
108
--- a/include/hw/arm/xlnx-versal.h
111
+ }
109
+++ b/include/hw/arm/xlnx-versal.h
112
}
110
@@ -XXX,XX +XXX,XX @@ struct Versal {
113
111
} rpu;
114
if (kvm_enabled()) {
112
115
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
113
struct {
116
index XXXXXXX..XXXXXXX 100644
114
- qemu_or_irq irq_orgate;
117
--- a/target/arm/cpu64.c
115
+ OrIRQState irq_orgate;
118
+++ b/target/arm/cpu64.c
116
XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM];
117
} xram;
118
119
@@ -XXX,XX +XXX,XX @@ struct Versal {
120
XlnxCSUDMA dma_src;
121
XlnxCSUDMA dma_dst;
122
MemoryRegion linear_mr;
123
- qemu_or_irq irq_orgate;
124
+ OrIRQState irq_orgate;
125
} ospi;
126
} iou;
127
128
@@ -XXX,XX +XXX,XX @@ struct Versal {
129
XlnxVersalEFuseCtrl efuse_ctrl;
130
XlnxVersalEFuseCache efuse_cache;
131
132
- qemu_or_irq apb_irq_orgate;
133
+ OrIRQState apb_irq_orgate;
134
} pmc;
135
136
struct {
137
diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h
138
index XXXXXXX..XXXXXXX 100644
139
--- a/include/hw/arm/xlnx-zynqmp.h
140
+++ b/include/hw/arm/xlnx-zynqmp.h
141
@@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState {
142
XlnxZDMA gdma[XLNX_ZYNQMP_NUM_GDMA_CH];
143
XlnxZDMA adma[XLNX_ZYNQMP_NUM_ADMA_CH];
144
XlnxCSUDMA qspi_dma;
145
- qemu_or_irq qspi_irq_orgate;
146
+ OrIRQState qspi_irq_orgate;
147
XlnxZynqMPAPUCtrl apu_ctrl;
148
XlnxZynqMPCRF crf;
149
CadenceTTCState ttc[XLNX_ZYNQMP_NUM_TTC];
150
diff --git a/include/hw/or-irq.h b/include/hw/or-irq.h
151
index XXXXXXX..XXXXXXX 100644
152
--- a/include/hw/or-irq.h
153
+++ b/include/hw/or-irq.h
119
@@ -XXX,XX +XXX,XX @@
154
@@ -XXX,XX +XXX,XX @@
120
#include "sysemu/kvm.h"
155
*/
121
#include "kvm_arm.h"
156
#define MAX_OR_LINES 48
122
#include "qapi/visitor.h"
157
123
+#include "hw/qdev-properties.h"
158
-typedef struct OrIRQState qemu_or_irq;
124
+
159
-
125
160
OBJECT_DECLARE_SIMPLE_TYPE(OrIRQState, OR_IRQ)
126
#ifndef CONFIG_USER_ONLY
161
127
static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
162
struct OrIRQState {
128
@@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj)
163
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
129
}
164
index XXXXXXX..XXXXXXX 100644
165
--- a/hw/arm/exynos4210.c
166
+++ b/hw/arm/exynos4210.c
167
@@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_calc_affinity(int cpu)
168
return (0x9 << ARM_AFF1_SHIFT) | cpu;
130
}
169
}
131
170
132
+void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
171
-static DeviceState *pl330_create(uint32_t base, qemu_or_irq *orgate,
133
+{
172
+static DeviceState *pl330_create(uint32_t base, OrIRQState *orgate,
134
+ int arch_val = 0, impdef_val = 0;
173
qemu_irq irq, int nreq, int nevents, int width)
135
+ uint64_t t;
174
{
136
+
175
SysBusDevice *busdev;
137
+ /* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */
176
@@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj)
138
+ if (cpu->prop_pauth) {
177
139
+ if (cpu->prop_pauth_impdef) {
178
for (i = 0; i < ARRAY_SIZE(s->pl330_irq_orgate); i++) {
140
+ impdef_val = 1;
179
char *name = g_strdup_printf("pl330-irq-orgate%d", i);
141
+ } else {
180
- qemu_or_irq *orgate = &s->pl330_irq_orgate[i];
142
+ arch_val = 1;
181
+ OrIRQState *orgate = &s->pl330_irq_orgate[i];
143
+ }
182
144
+ } else if (cpu->prop_pauth_impdef) {
183
object_initialize_child(obj, name, orgate, TYPE_OR_IRQ);
145
+ error_setg(errp, "cannot enable pauth-impdef without pauth");
184
g_free(name);
146
+ error_append_hint(errp, "Add pauth=on to the CPU property list.\n");
185
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
147
+ }
186
index XXXXXXX..XXXXXXX 100644
148
+
187
--- a/hw/arm/mps2-tz.c
149
+ t = cpu->isar.id_aa64isar1;
188
+++ b/hw/arm/mps2-tz.c
150
+ t = FIELD_DP64(t, ID_AA64ISAR1, APA, arch_val);
189
@@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState {
151
+ t = FIELD_DP64(t, ID_AA64ISAR1, GPA, arch_val);
190
TZMSC msc[4];
152
+ t = FIELD_DP64(t, ID_AA64ISAR1, API, impdef_val);
191
CMSDKAPBUART uart[6];
153
+ t = FIELD_DP64(t, ID_AA64ISAR1, GPI, impdef_val);
192
SplitIRQ sec_resp_splitter;
154
+ cpu->isar.id_aa64isar1 = t;
193
- qemu_or_irq uart_irq_orgate;
155
+}
194
+ OrIRQState uart_irq_orgate;
156
+
195
DeviceState *lan9118;
157
+static Property arm_cpu_pauth_property =
196
SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ_MAX];
158
+ DEFINE_PROP_BOOL("pauth", ARMCPU, prop_pauth, true);
197
Clock *sysclk;
159
+static Property arm_cpu_pauth_impdef_property =
198
diff --git a/hw/core/or-irq.c b/hw/core/or-irq.c
160
+ DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
199
index XXXXXXX..XXXXXXX 100644
161
+
200
--- a/hw/core/or-irq.c
162
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
201
+++ b/hw/core/or-irq.c
163
* otherwise, a CPU with as many features enabled as our emulation supports.
202
@@ -XXX,XX +XXX,XX @@
164
* The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
203
165
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
204
static void or_irq_handler(void *opaque, int n, int level)
166
t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2);
205
{
167
t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1);
206
- qemu_or_irq *s = OR_IRQ(opaque);
168
t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1);
207
+ OrIRQState *s = OR_IRQ(opaque);
169
- t = FIELD_DP64(t, ID_AA64ISAR1, APA, 1); /* PAuth, architected only */
208
int or_level = 0;
170
- t = FIELD_DP64(t, ID_AA64ISAR1, API, 0);
209
int i;
171
- t = FIELD_DP64(t, ID_AA64ISAR1, GPA, 1);
210
172
- t = FIELD_DP64(t, ID_AA64ISAR1, GPI, 0);
211
@@ -XXX,XX +XXX,XX @@ static void or_irq_handler(void *opaque, int n, int level)
173
t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1);
212
174
t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1);
213
static void or_irq_reset(DeviceState *dev)
175
t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1);
214
{
176
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
215
- qemu_or_irq *s = OR_IRQ(dev);
177
cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */
216
+ OrIRQState *s = OR_IRQ(dev);
178
cpu->dcz_blocksize = 7; /* 512 bytes */
217
int i;
179
#endif
218
180
+
219
for (i = 0; i < MAX_OR_LINES; i++) {
181
+ /* Default to PAUTH on, with the architected algorithm. */
220
@@ -XXX,XX +XXX,XX @@ static void or_irq_reset(DeviceState *dev)
182
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
221
183
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
222
static void or_irq_realize(DeviceState *dev, Error **errp)
184
}
223
{
185
224
- qemu_or_irq *s = OR_IRQ(dev);
186
aarch64_add_sve_properties(obj);
225
+ OrIRQState *s = OR_IRQ(dev);
187
diff --git a/target/arm/monitor.c b/target/arm/monitor.c
226
188
index XXXXXXX..XXXXXXX 100644
227
assert(s->num_lines <= MAX_OR_LINES);
189
--- a/target/arm/monitor.c
228
190
+++ b/target/arm/monitor.c
229
@@ -XXX,XX +XXX,XX @@ static void or_irq_realize(DeviceState *dev, Error **errp)
191
@@ -XXX,XX +XXX,XX @@ static const char *cpu_model_advertised_features[] = {
230
192
"sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280",
231
static void or_irq_init(Object *obj)
193
"sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048",
232
{
194
"kvm-no-adjvtime", "kvm-steal-time",
233
- qemu_or_irq *s = OR_IRQ(obj);
195
+ "pauth", "pauth-impdef",
234
+ OrIRQState *s = OR_IRQ(obj);
196
NULL
235
236
qdev_init_gpio_out(DEVICE(obj), &s->out_irq, 1);
237
}
238
@@ -XXX,XX +XXX,XX @@ static void or_irq_init(Object *obj)
239
240
static bool vmstate_extras_needed(void *opaque)
241
{
242
- qemu_or_irq *s = OR_IRQ(opaque);
243
+ OrIRQState *s = OR_IRQ(opaque);
244
245
return s->num_lines >= OLD_MAX_OR_LINES;
246
}
247
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_or_irq_extras = {
248
.minimum_version_id = 1,
249
.needed = vmstate_extras_needed,
250
.fields = (VMStateField[]) {
251
- VMSTATE_VARRAY_UINT16_UNSAFE(levels, qemu_or_irq, num_lines, 0,
252
+ VMSTATE_VARRAY_UINT16_UNSAFE(levels, OrIRQState, num_lines, 0,
253
vmstate_info_bool, bool),
254
VMSTATE_END_OF_LIST(),
255
},
256
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_or_irq = {
257
.version_id = 1,
258
.minimum_version_id = 1,
259
.fields = (VMStateField[]) {
260
- VMSTATE_BOOL_SUB_ARRAY(levels, qemu_or_irq, 0, OLD_MAX_OR_LINES),
261
+ VMSTATE_BOOL_SUB_ARRAY(levels, OrIRQState, 0, OLD_MAX_OR_LINES),
262
VMSTATE_END_OF_LIST(),
263
},
264
.subsections = (const VMStateDescription*[]) {
265
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_or_irq = {
197
};
266
};
198
267
199
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
268
static Property or_irq_properties[] = {
200
index XXXXXXX..XXXXXXX 100644
269
- DEFINE_PROP_UINT16("num-lines", qemu_or_irq, num_lines, 1),
201
--- a/tests/qtest/arm-cpu-features.c
270
+ DEFINE_PROP_UINT16("num-lines", OrIRQState, num_lines, 1),
202
+++ b/tests/qtest/arm-cpu-features.c
271
DEFINE_PROP_END_OF_LIST(),
203
@@ -XXX,XX +XXX,XX @@ static void sve_tests_sve_off_kvm(const void *data)
272
};
204
qtest_quit(qts);
273
205
}
274
@@ -XXX,XX +XXX,XX @@ static void or_irq_class_init(ObjectClass *klass, void *data)
206
275
static const TypeInfo or_irq_type_info = {
207
+static void pauth_tests_default(QTestState *qts, const char *cpu_type)
276
.name = TYPE_OR_IRQ,
208
+{
277
.parent = TYPE_DEVICE,
209
+ assert_has_feature_enabled(qts, cpu_type, "pauth");
278
- .instance_size = sizeof(qemu_or_irq),
210
+ assert_has_feature_disabled(qts, cpu_type, "pauth-impdef");
279
+ .instance_size = sizeof(OrIRQState),
211
+ assert_set_feature(qts, cpu_type, "pauth", false);
280
.instance_init = or_irq_init,
212
+ assert_set_feature(qts, cpu_type, "pauth", true);
281
.class_init = or_irq_class_init,
213
+ assert_set_feature(qts, cpu_type, "pauth-impdef", true);
282
};
214
+ assert_set_feature(qts, cpu_type, "pauth-impdef", false);
283
diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
215
+ assert_error(qts, cpu_type, "cannot enable pauth-impdef without pauth",
284
index XXXXXXX..XXXXXXX 100644
216
+ "{ 'pauth': false, 'pauth-impdef': true }");
285
--- a/hw/pci-host/raven.c
217
+}
286
+++ b/hw/pci-host/raven.c
218
+
287
@@ -XXX,XX +XXX,XX @@ DECLARE_INSTANCE_CHECKER(PREPPCIState, RAVEN_PCI_HOST_BRIDGE,
219
static void test_query_cpu_model_expansion(const void *data)
288
struct PRePPCIState {
220
{
289
PCIHostState parent_obj;
221
QTestState *qts;
290
222
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data)
291
- qemu_or_irq *or_irq;
223
assert_has_feature_enabled(qts, "cortex-a57", "aarch64");
292
+ OrIRQState *or_irq;
224
293
qemu_irq pci_irqs[PCI_NUM_PINS];
225
sve_tests_default(qts, "max");
294
PCIBus pci_bus;
226
+ pauth_tests_default(qts, "max");
295
AddressSpace pci_io_as;
227
228
/* Test that features that depend on KVM generate errors without. */
229
assert_error(qts, "max",
230
--
296
--
231
2.20.1
297
2.34.1
232
298
233
299
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
The interface for object_property_add_bool is simpler,
4
making the code easier to understand.
5
6
Reviewed-by: Andrew Jones <drjones@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210111235740.462469-4-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/cpu64.c | 24 ++++++++++--------------
12
1 file changed, 10 insertions(+), 14 deletions(-)
13
14
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu64.c
17
+++ b/target/arm/cpu64.c
18
@@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name,
19
cpu->sve_max_vq = max_vq;
20
}
21
22
+/*
23
+ * Note that cpu_arm_get/set_sve_vq cannot use the simpler
24
+ * object_property_add_bool interface because they make use
25
+ * of the contents of "name" to determine which bit on which
26
+ * to operate.
27
+ */
28
static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name,
29
void *opaque, Error **errp)
30
{
31
@@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name,
32
set_bit(vq - 1, cpu->sve_vq_init);
33
}
34
35
-static void cpu_arm_get_sve(Object *obj, Visitor *v, const char *name,
36
- void *opaque, Error **errp)
37
+static bool cpu_arm_get_sve(Object *obj, Error **errp)
38
{
39
ARMCPU *cpu = ARM_CPU(obj);
40
- bool value = cpu_isar_feature(aa64_sve, cpu);
41
-
42
- visit_type_bool(v, name, &value, errp);
43
+ return cpu_isar_feature(aa64_sve, cpu);
44
}
45
46
-static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name,
47
- void *opaque, Error **errp)
48
+static void cpu_arm_set_sve(Object *obj, bool value, Error **errp)
49
{
50
ARMCPU *cpu = ARM_CPU(obj);
51
- bool value;
52
uint64_t t;
53
54
- if (!visit_type_bool(v, name, &value, errp)) {
55
- return;
56
- }
57
-
58
if (value && kvm_enabled() && !kvm_arm_sve_supported()) {
59
error_setg(errp, "'sve' feature not supported by KVM on this host");
60
return;
61
@@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj)
62
{
63
uint32_t vq;
64
65
- object_property_add(obj, "sve", "bool", cpu_arm_get_sve,
66
- cpu_arm_set_sve, NULL, NULL);
67
+ object_property_add_bool(obj, "sve", cpu_arm_get_sve, cpu_arm_set_sve);
68
69
for (vq = 1; vq <= ARM_MAX_VQ; ++vq) {
70
char name[8];
71
--
72
2.20.1
73
74
diff view generated by jsdifflib
Deleted patch
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
2
1
3
This checks if EL2 is enabled (meaning EL2 registers take effects) in
4
the current security context.
5
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210112104511.36576-2-remi.denis.courmont@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/cpu.h | 17 +++++++++++++++++
12
1 file changed, 17 insertions(+)
13
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
17
+++ b/target/arm/cpu.h
18
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env)
19
return arm_is_secure_below_el3(env);
20
}
21
22
+/*
23
+ * Return true if the current security state has AArch64 EL2 or AArch32 Hyp.
24
+ * This corresponds to the pseudocode EL2Enabled()
25
+ */
26
+static inline bool arm_is_el2_enabled(CPUARMState *env)
27
+{
28
+ if (arm_feature(env, ARM_FEATURE_EL2)) {
29
+ return !arm_is_secure_below_el3(env);
30
+ }
31
+ return false;
32
+}
33
+
34
#else
35
static inline bool arm_is_secure_below_el3(CPUARMState *env)
36
{
37
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env)
38
{
39
return false;
40
}
41
+
42
+static inline bool arm_is_el2_enabled(CPUARMState *env)
43
+{
44
+ return false;
45
+}
46
#endif
47
48
/**
49
--
50
2.20.1
51
52
diff view generated by jsdifflib
Deleted patch
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
2
1
3
This adds a common helper to compute the effective value of MDCR_EL2.
4
That is the actual value if EL2 is enabled in the current security
5
context, or 0 elsewise.
6
7
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210112104511.36576-5-remi.denis.courmont@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/helper.c | 38 ++++++++++++++++++++++----------------
13
1 file changed, 22 insertions(+), 16 deletions(-)
14
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
18
+++ b/target/arm/helper.c
19
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_trap_aa32s_el1(CPUARMState *env,
20
return CP_ACCESS_TRAP_UNCATEGORIZED;
21
}
22
23
+static uint64_t arm_mdcr_el2_eff(CPUARMState *env)
24
+{
25
+ return arm_is_el2_enabled(env) ? env->cp15.mdcr_el2 : 0;
26
+}
27
+
28
/* Check for traps to "powerdown debug" registers, which are controlled
29
* by MDCR.TDOSA
30
*/
31
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tdosa(CPUARMState *env, const ARMCPRegInfo *ri,
32
bool isread)
33
{
34
int el = arm_current_el(env);
35
- bool mdcr_el2_tdosa = (env->cp15.mdcr_el2 & MDCR_TDOSA) ||
36
- (env->cp15.mdcr_el2 & MDCR_TDE) ||
37
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
38
+ bool mdcr_el2_tdosa = (mdcr_el2 & MDCR_TDOSA) || (mdcr_el2 & MDCR_TDE) ||
39
(arm_hcr_el2_eff(env) & HCR_TGE);
40
41
- if (el < 2 && mdcr_el2_tdosa && !arm_is_secure_below_el3(env)) {
42
+ if (el < 2 && mdcr_el2_tdosa) {
43
return CP_ACCESS_TRAP_EL2;
44
}
45
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TDOSA)) {
46
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tdra(CPUARMState *env, const ARMCPRegInfo *ri,
47
bool isread)
48
{
49
int el = arm_current_el(env);
50
- bool mdcr_el2_tdra = (env->cp15.mdcr_el2 & MDCR_TDRA) ||
51
- (env->cp15.mdcr_el2 & MDCR_TDE) ||
52
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
53
+ bool mdcr_el2_tdra = (mdcr_el2 & MDCR_TDRA) || (mdcr_el2 & MDCR_TDE) ||
54
(arm_hcr_el2_eff(env) & HCR_TGE);
55
56
- if (el < 2 && mdcr_el2_tdra && !arm_is_secure_below_el3(env)) {
57
+ if (el < 2 && mdcr_el2_tdra) {
58
return CP_ACCESS_TRAP_EL2;
59
}
60
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TDA)) {
61
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tda(CPUARMState *env, const ARMCPRegInfo *ri,
62
bool isread)
63
{
64
int el = arm_current_el(env);
65
- bool mdcr_el2_tda = (env->cp15.mdcr_el2 & MDCR_TDA) ||
66
- (env->cp15.mdcr_el2 & MDCR_TDE) ||
67
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
68
+ bool mdcr_el2_tda = (mdcr_el2 & MDCR_TDA) || (mdcr_el2 & MDCR_TDE) ||
69
(arm_hcr_el2_eff(env) & HCR_TGE);
70
71
- if (el < 2 && mdcr_el2_tda && !arm_is_secure_below_el3(env)) {
72
+ if (el < 2 && mdcr_el2_tda) {
73
return CP_ACCESS_TRAP_EL2;
74
}
75
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TDA)) {
76
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri,
77
bool isread)
78
{
79
int el = arm_current_el(env);
80
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
81
82
- if (el < 2 && (env->cp15.mdcr_el2 & MDCR_TPM)
83
- && !arm_is_secure_below_el3(env)) {
84
+ if (el < 2 && (mdcr_el2 & MDCR_TPM)) {
85
return CP_ACCESS_TRAP_EL2;
86
}
87
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TPM)) {
88
@@ -XXX,XX +XXX,XX @@ static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri,
89
* trapping to EL2 or EL3 for other accesses.
90
*/
91
int el = arm_current_el(env);
92
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
93
94
if (el == 0 && !(env->cp15.c9_pmuserenr & 1)) {
95
return CP_ACCESS_TRAP;
96
}
97
- if (el < 2 && (env->cp15.mdcr_el2 & MDCR_TPM)
98
- && !arm_is_secure_below_el3(env)) {
99
+ if (el < 2 && (mdcr_el2 & MDCR_TPM)) {
100
return CP_ACCESS_TRAP_EL2;
101
}
102
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TPM)) {
103
@@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)
104
bool enabled, prohibited, filtered;
105
bool secure = arm_is_secure(env);
106
int el = arm_current_el(env);
107
- uint8_t hpmn = env->cp15.mdcr_el2 & MDCR_HPMN;
108
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
109
+ uint8_t hpmn = mdcr_el2 & MDCR_HPMN;
110
111
if (!arm_feature(env, ARM_FEATURE_PMU)) {
112
return false;
113
@@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)
114
(counter < hpmn || counter == 31)) {
115
e = env->cp15.c9_pmcr & PMCRE;
116
} else {
117
- e = env->cp15.mdcr_el2 & MDCR_HPME;
118
+ e = mdcr_el2 & MDCR_HPME;
119
}
120
enabled = e && (env->cp15.c9_pmcnten & (1 << counter));
121
122
if (!secure) {
123
if (el == 2 && (counter < hpmn || counter == 31)) {
124
- prohibited = env->cp15.mdcr_el2 & MDCR_HPMD;
125
+ prohibited = mdcr_el2 & MDCR_HPMD;
126
} else {
127
prohibited = false;
128
}
129
--
130
2.20.1
131
132
diff view generated by jsdifflib
Deleted patch
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
2
1
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210112104511.36576-6-remi.denis.courmont@huawei.com
6
[PMM: tweaked commit message to match reduced scope of patch
7
following rebase]
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/cpu.h | 5 +++++
11
1 file changed, 5 insertions(+)
12
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
16
+++ b/target/arm/cpu.h
17
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sve(const ARMISARegisters *id)
18
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0;
19
}
20
21
+static inline bool isar_feature_aa64_sel2(const ARMISARegisters *id)
22
+{
23
+ return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SEL2) != 0;
24
+}
25
+
26
static inline bool isar_feature_aa64_vh(const ARMISARegisters *id)
27
{
28
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0;
29
--
30
2.20.1
31
32
diff view generated by jsdifflib
Deleted patch
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
2
1
3
With the ARMv8.4-SEL2 extension, EL2 is a legal exception level in
4
secure mode, though it can only be AArch64.
5
6
This patch adds the target EL for exceptions from 64-bit S-EL2.
7
8
It also fixes the target EL to EL2 when HCR.{A,F,I}MO are set in secure
9
mode. Those values were never used in practice as the effective value of
10
HCR was always 0 in secure mode.
11
12
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20210112104511.36576-7-remi.denis.courmont@huawei.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
target/arm/helper.c | 10 +++++-----
18
target/arm/op_helper.c | 4 ++--
19
2 files changed, 7 insertions(+), 7 deletions(-)
20
21
diff --git a/target/arm/helper.c b/target/arm/helper.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/helper.c
24
+++ b/target/arm/helper.c
25
@@ -XXX,XX +XXX,XX @@ static const int8_t target_el_table[2][2][2][2][2][4] = {
26
{{/* 0 1 1 0 */{ 3, 3, 3, -1 },{ 3, -1, -1, 3 },},
27
{/* 0 1 1 1 */{ 3, 3, 3, -1 },{ 3, -1, -1, 3 },},},},},
28
{{{{/* 1 0 0 0 */{ 1, 1, 2, -1 },{ 1, 1, -1, 1 },},
29
- {/* 1 0 0 1 */{ 2, 2, 2, -1 },{ 1, 1, -1, 1 },},},
30
- {{/* 1 0 1 0 */{ 1, 1, 1, -1 },{ 1, 1, -1, 1 },},
31
- {/* 1 0 1 1 */{ 2, 2, 2, -1 },{ 1, 1, -1, 1 },},},},
32
+ {/* 1 0 0 1 */{ 2, 2, 2, -1 },{ 2, 2, -1, 1 },},},
33
+ {{/* 1 0 1 0 */{ 1, 1, 1, -1 },{ 1, 1, 1, 1 },},
34
+ {/* 1 0 1 1 */{ 2, 2, 2, -1 },{ 2, 2, 2, 1 },},},},
35
{{{/* 1 1 0 0 */{ 3, 3, 3, -1 },{ 3, 3, -1, 3 },},
36
{/* 1 1 0 1 */{ 3, 3, 3, -1 },{ 3, 3, -1, 3 },},},
37
- {{/* 1 1 1 0 */{ 3, 3, 3, -1 },{ 3, 3, -1, 3 },},
38
- {/* 1 1 1 1 */{ 3, 3, 3, -1 },{ 3, 3, -1, 3 },},},},},
39
+ {{/* 1 1 1 0 */{ 3, 3, 3, -1 },{ 3, 3, 3, 3 },},
40
+ {/* 1 1 1 1 */{ 3, 3, 3, -1 },{ 3, 3, 3, 3 },},},},},
41
};
42
43
/*
44
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/op_helper.c
47
+++ b/target/arm/op_helper.c
48
@@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
49
target_el = exception_target_el(env);
50
break;
51
case CP_ACCESS_TRAP_EL2:
52
- /* Requesting a trap to EL2 when we're in EL3 or S-EL0/1 is
53
+ /* Requesting a trap to EL2 when we're in EL3 is
54
* a bug in the access function.
55
*/
56
- assert(!arm_is_secure(env) && arm_current_el(env) != 3);
57
+ assert(arm_current_el(env) != 3);
58
target_el = 2;
59
break;
60
case CP_ACCESS_TRAP_EL3:
61
--
62
2.20.1
63
64
diff view generated by jsdifflib
Deleted patch
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
2
1
3
The VTTBR write callback so far assumes that the underlying VM lies in
4
non-secure state. This handles the secure state scenario.
5
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210112104511.36576-10-remi.denis.courmont@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/helper.c | 13 +++++++++----
12
1 file changed, 9 insertions(+), 4 deletions(-)
13
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,
19
* the combined stage 1&2 tlbs (EL10_1 and EL10_0).
20
*/
21
if (raw_read(env, ri) != value) {
22
- tlb_flush_by_mmuidx(cs,
23
- ARMMMUIdxBit_E10_1 |
24
- ARMMMUIdxBit_E10_1_PAN |
25
- ARMMMUIdxBit_E10_0);
26
+ uint16_t mask = ARMMMUIdxBit_E10_1 |
27
+ ARMMMUIdxBit_E10_1_PAN |
28
+ ARMMMUIdxBit_E10_0;
29
+
30
+ if (arm_is_secure_below_el3(env)) {
31
+ mask >>= ARM_MMU_IDX_A_NS;
32
+ }
33
+
34
+ tlb_flush_by_mmuidx(cs, mask);
35
raw_write(env, ri, value);
36
}
37
}
38
--
39
2.20.1
40
41
diff view generated by jsdifflib
Deleted patch
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
2
1
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210112104511.36576-12-remi.denis.courmont@huawei.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/helper.c | 12 ++++++++++++
9
1 file changed, 12 insertions(+)
10
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
16
fi->s1ptw = true;
17
return ~0;
18
}
19
+
20
+ if (arm_is_secure_below_el3(env)) {
21
+ /* Check if page table walk is to secure or non-secure PA space. */
22
+ if (*is_secure) {
23
+ *is_secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW);
24
+ } else {
25
+ *is_secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW);
26
+ }
27
+ } else {
28
+ assert(!*is_secure);
29
+ }
30
+
31
addr = s2pa;
32
}
33
return addr;
34
--
35
2.20.1
36
37
diff view generated by jsdifflib
Deleted patch
1
When we first converted our documentation to Sphinx, we split it into
2
multiple manuals (system, interop, tools, etc), which are all built
3
separately. The primary driver for this was wanting to be able to
4
avoid shipping the 'devel' manual to end-users. However, this is
5
working against the grain of the way Sphinx wants to be used and
6
causes some annoyances:
7
* Cross-references between documents become much harder or
8
possibly impossible
9
* There is no single index to the whole documentation
10
* Within one manual there's no links or table-of-contents info
11
that lets you easily navigate to the others
12
* The devel manual doesn't get published on the QEMU website
13
(it would be nice to able to refer to it there)
14
1
15
Merely hiding our developer documentation from end users seems like
16
it's not enough benefit for these costs. Combine all the
17
documentation into a single manual (the same way that the readthedocs
18
site builds it) and install the whole thing. The previous manual
19
divisions remain as the new top level sections in the manual.
20
21
* The per-manual conf.py files are no longer needed
22
* The man_pages[] specifications previously in each per-manual
23
conf.py move to the top level conf.py
24
* docs/meson.build logic is simplified as we now only need to run
25
Sphinx once for the HTML and then once for the manpages5B
26
* The old index.html.in that produced the top-level page with
27
links to each manual is no longer needed
28
29
Unfortunately this means that we now have to build the HTML
30
documentation into docs/manual in the build tree rather than directly
31
into docs/; otherwise it is too awkward to ensure we install only the
32
built manual and not also the dependency info, stamp file, etc. The
33
manual still ends up in the same place in the final installed
34
directory, but anybody who was consulting documentation from within
35
the build tree will have to adjust where they're looking.
36
37
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
38
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
39
Message-id: 20210115154449.4801-1-peter.maydell@linaro.org
40
---
41
docs/conf.py | 46 ++++++++++++++++++++++++++++++-
42
docs/devel/conf.py | 15 -----------
43
docs/index.html.in | 17 ------------
44
docs/interop/conf.py | 28 -------------------
45
docs/meson.build | 64 +++++++++++++++++---------------------------
46
docs/specs/conf.py | 16 -----------
47
docs/system/conf.py | 28 -------------------
48
docs/tools/conf.py | 37 -------------------------
49
docs/user/conf.py | 15 -----------
50
.gitlab-ci.yml | 4 +--
51
10 files changed, 72 insertions(+), 198 deletions(-)
52
delete mode 100644 docs/devel/conf.py
53
delete mode 100644 docs/index.html.in
54
delete mode 100644 docs/interop/conf.py
55
delete mode 100644 docs/specs/conf.py
56
delete mode 100644 docs/system/conf.py
57
delete mode 100644 docs/tools/conf.py
58
delete mode 100644 docs/user/conf.py
59
60
diff --git a/docs/conf.py b/docs/conf.py
61
index XXXXXXX..XXXXXXX 100644
62
--- a/docs/conf.py
63
+++ b/docs/conf.py
64
@@ -XXX,XX +XXX,XX @@ latex_documents = [
65
66
# -- Options for manual page output ---------------------------------------
67
# Individual manual/conf.py can override this to create man pages
68
-man_pages = []
69
+man_pages = [
70
+ ('interop/qemu-ga', 'qemu-ga',
71
+ 'QEMU Guest Agent',
72
+ ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8),
73
+ ('interop/qemu-ga-ref', 'qemu-ga-ref',
74
+ 'QEMU Guest Agent Protocol Reference',
75
+ [], 7),
76
+ ('interop/qemu-qmp-ref', 'qemu-qmp-ref',
77
+ 'QEMU QMP Reference Manual',
78
+ [], 7),
79
+ ('interop/qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
80
+ 'QEMU Storage Daemon QMP Reference Manual',
81
+ [], 7),
82
+ ('system/qemu-manpage', 'qemu',
83
+ 'QEMU User Documentation',
84
+ ['Fabrice Bellard'], 1),
85
+ ('system/qemu-block-drivers', 'qemu-block-drivers',
86
+ 'QEMU block drivers reference',
87
+ ['Fabrice Bellard and the QEMU Project developers'], 7),
88
+ ('system/qemu-cpu-models', 'qemu-cpu-models',
89
+ 'QEMU CPU Models',
90
+ ['The QEMU Project developers'], 7),
91
+ ('tools/qemu-img', 'qemu-img',
92
+ 'QEMU disk image utility',
93
+ ['Fabrice Bellard'], 1),
94
+ ('tools/qemu-nbd', 'qemu-nbd',
95
+ 'QEMU Disk Network Block Device Server',
96
+ ['Anthony Liguori <anthony@codemonkey.ws>'], 8),
97
+ ('tools/qemu-pr-helper', 'qemu-pr-helper',
98
+ 'QEMU persistent reservation helper',
99
+ [], 8),
100
+ ('tools/qemu-storage-daemon', 'qemu-storage-daemon',
101
+ 'QEMU storage daemon',
102
+ [], 1),
103
+ ('tools/qemu-trace-stap', 'qemu-trace-stap',
104
+ 'QEMU SystemTap trace tool',
105
+ [], 1),
106
+ ('tools/virtfs-proxy-helper', 'virtfs-proxy-helper',
107
+ 'QEMU 9p virtfs proxy filesystem helper',
108
+ ['M. Mohan Kumar'], 1),
109
+ ('tools/virtiofsd', 'virtiofsd',
110
+ 'QEMU virtio-fs shared file system daemon',
111
+ ['Stefan Hajnoczi <stefanha@redhat.com>',
112
+ 'Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>'], 1),
113
+]
114
115
# -- Options for Texinfo output -------------------------------------------
116
117
diff --git a/docs/devel/conf.py b/docs/devel/conf.py
118
deleted file mode 100644
119
index XXXXXXX..XXXXXXX
120
--- a/docs/devel/conf.py
121
+++ /dev/null
122
@@ -XXX,XX +XXX,XX @@
123
-# -*- coding: utf-8 -*-
124
-#
125
-# QEMU documentation build configuration file for the 'devel' manual.
126
-#
127
-# This includes the top level conf file and then makes any necessary tweaks.
128
-import sys
129
-import os
130
-
131
-qemu_docdir = os.path.abspath("..")
132
-parent_config = os.path.join(qemu_docdir, "conf.py")
133
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
134
-
135
-# This slightly misuses the 'description', but is the best way to get
136
-# the manual title to appear in the sidebar.
137
-html_theme_options['description'] = u'Developer''s Guide'
138
diff --git a/docs/index.html.in b/docs/index.html.in
139
deleted file mode 100644
140
index XXXXXXX..XXXXXXX
141
--- a/docs/index.html.in
142
+++ /dev/null
143
@@ -XXX,XX +XXX,XX @@
144
-<!DOCTYPE html>
145
-<html lang="en">
146
- <head>
147
- <meta charset="UTF-8">
148
- <title>QEMU @VERSION@ Documentation</title>
149
- </head>
150
- <body>
151
- <h1>QEMU @VERSION@ Documentation</h1>
152
- <ul>
153
- <li><a href="system/index.html">System Emulation User's Guide</a></li>
154
- <li><a href="user/index.html">User Mode Emulation User's Guide</a></li>
155
- <li><a href="tools/index.html">Tools Guide</a></li>
156
- <li><a href="interop/index.html">System Emulation Management and Interoperability Guide</a></li>
157
- <li><a href="specs/index.html">System Emulation Guest Hardware Specifications</a></li>
158
- </ul>
159
- </body>
160
-</html>
161
diff --git a/docs/interop/conf.py b/docs/interop/conf.py
162
deleted file mode 100644
163
index XXXXXXX..XXXXXXX
164
--- a/docs/interop/conf.py
165
+++ /dev/null
166
@@ -XXX,XX +XXX,XX @@
167
-# -*- coding: utf-8 -*-
168
-#
169
-# QEMU documentation build configuration file for the 'interop' manual.
170
-#
171
-# This includes the top level conf file and then makes any necessary tweaks.
172
-import sys
173
-import os
174
-
175
-qemu_docdir = os.path.abspath("..")
176
-parent_config = os.path.join(qemu_docdir, "conf.py")
177
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
178
-
179
-# This slightly misuses the 'description', but is the best way to get
180
-# the manual title to appear in the sidebar.
181
-html_theme_options['description'] = u'System Emulation Management and Interoperability Guide'
182
-
183
-# One entry per manual page. List of tuples
184
-# (source start file, name, description, authors, manual section).
185
-man_pages = [
186
- ('qemu-ga', 'qemu-ga', u'QEMU Guest Agent',
187
- ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8),
188
- ('qemu-ga-ref', 'qemu-ga-ref', 'QEMU Guest Agent Protocol Reference',
189
- [], 7),
190
- ('qemu-qmp-ref', 'qemu-qmp-ref', 'QEMU QMP Reference Manual',
191
- [], 7),
192
- ('qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
193
- 'QEMU Storage Daemon QMP Reference Manual', [], 7),
194
-]
195
diff --git a/docs/meson.build b/docs/meson.build
196
index XXXXXXX..XXXXXXX 100644
197
--- a/docs/meson.build
198
+++ b/docs/meson.build
199
@@ -XXX,XX +XXX,XX @@ if build_docs
200
meson.source_root() / 'docs/sphinx/qmp_lexer.py',
201
qapi_gen_depends ]
202
203
- configure_file(output: 'index.html',
204
- input: files('index.html.in'),
205
- configuration: {'VERSION': meson.project_version()},
206
- install_dir: qemu_docdir)
207
- manuals = [ 'devel', 'interop', 'tools', 'specs', 'system', 'user' ]
208
man_pages = {
209
- 'interop' : {
210
'qemu-ga.8': (have_tools ? 'man8' : ''),
211
'qemu-ga-ref.7': 'man7',
212
'qemu-qmp-ref.7': 'man7',
213
'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''),
214
- },
215
- 'tools': {
216
'qemu-img.1': (have_tools ? 'man1' : ''),
217
'qemu-nbd.8': (have_tools ? 'man8' : ''),
218
'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
219
@@ -XXX,XX +XXX,XX @@ if build_docs
220
'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
221
'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
222
'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
223
- },
224
- 'system': {
225
'qemu.1': 'man1',
226
'qemu-block-drivers.7': 'man7',
227
'qemu-cpu-models.7': 'man7'
228
- },
229
}
230
231
sphinxdocs = []
232
sphinxmans = []
233
- foreach manual : manuals
234
- private_dir = meson.current_build_dir() / (manual + '.p')
235
- output_dir = meson.current_build_dir() / manual
236
- input_dir = meson.current_source_dir() / manual
237
238
- this_manual = custom_target(manual + ' manual',
239
+ private_dir = meson.current_build_dir() / 'manual.p'
240
+ output_dir = meson.current_build_dir() / 'manual'
241
+ input_dir = meson.current_source_dir()
242
+
243
+ this_manual = custom_target('QEMU manual',
244
build_by_default: build_docs,
245
- output: [manual + '.stamp'],
246
- input: [files('conf.py'), files(manual / 'conf.py')],
247
- depfile: manual + '.d',
248
+ output: 'docs.stamp',
249
+ input: files('conf.py'),
250
+ depfile: 'docs.d',
251
depend_files: sphinx_extn_depends,
252
command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
253
'-Ddepfile_stamp=@OUTPUT0@',
254
'-b', 'html', '-d', private_dir,
255
input_dir, output_dir])
256
- sphinxdocs += this_manual
257
- if build_docs and manual != 'devel'
258
- install_subdir(output_dir, install_dir: qemu_docdir)
259
- endif
260
+ sphinxdocs += this_manual
261
+ install_subdir(output_dir, install_dir: qemu_docdir, strip_directory: true)
262
263
- these_man_pages = []
264
- install_dirs = []
265
- foreach page, section : man_pages.get(manual, {})
266
- these_man_pages += page
267
- install_dirs += section == '' ? false : get_option('mandir') / section
268
- endforeach
269
- if these_man_pages.length() > 0
270
- sphinxmans += custom_target(manual + ' man pages',
271
- build_by_default: build_docs,
272
- output: these_man_pages,
273
- input: this_manual,
274
- install: build_docs,
275
- install_dir: install_dirs,
276
- command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
277
- input_dir, meson.current_build_dir()])
278
- endif
279
+ these_man_pages = []
280
+ install_dirs = []
281
+ foreach page, section : man_pages
282
+ these_man_pages += page
283
+ install_dirs += section == '' ? false : get_option('mandir') / section
284
endforeach
285
+
286
+ sphinxmans += custom_target('QEMU man pages',
287
+ build_by_default: build_docs,
288
+ output: these_man_pages,
289
+ input: this_manual,
290
+ install: build_docs,
291
+ install_dir: install_dirs,
292
+ command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
293
+ input_dir, meson.current_build_dir()])
294
+
295
alias_target('sphinxdocs', sphinxdocs)
296
alias_target('html', sphinxdocs)
297
alias_target('man', sphinxmans)
298
diff --git a/docs/specs/conf.py b/docs/specs/conf.py
299
deleted file mode 100644
300
index XXXXXXX..XXXXXXX
301
--- a/docs/specs/conf.py
302
+++ /dev/null
303
@@ -XXX,XX +XXX,XX @@
304
-# -*- coding: utf-8 -*-
305
-#
306
-# QEMU documentation build configuration file for the 'specs' manual.
307
-#
308
-# This includes the top level conf file and then makes any necessary tweaks.
309
-import sys
310
-import os
311
-
312
-qemu_docdir = os.path.abspath("..")
313
-parent_config = os.path.join(qemu_docdir, "conf.py")
314
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
315
-
316
-# This slightly misuses the 'description', but is the best way to get
317
-# the manual title to appear in the sidebar.
318
-html_theme_options['description'] = \
319
- u'System Emulation Guest Hardware Specifications'
320
diff --git a/docs/system/conf.py b/docs/system/conf.py
321
deleted file mode 100644
322
index XXXXXXX..XXXXXXX
323
--- a/docs/system/conf.py
324
+++ /dev/null
325
@@ -XXX,XX +XXX,XX @@
326
-# -*- coding: utf-8 -*-
327
-#
328
-# QEMU documentation build configuration file for the 'system' manual.
329
-#
330
-# This includes the top level conf file and then makes any necessary tweaks.
331
-import sys
332
-import os
333
-
334
-qemu_docdir = os.path.abspath("..")
335
-parent_config = os.path.join(qemu_docdir, "conf.py")
336
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
337
-
338
-# This slightly misuses the 'description', but is the best way to get
339
-# the manual title to appear in the sidebar.
340
-html_theme_options['description'] = u'System Emulation User''s Guide'
341
-
342
-# One entry per manual page. List of tuples
343
-# (source start file, name, description, authors, manual section).
344
-man_pages = [
345
- ('qemu-manpage', 'qemu', u'QEMU User Documentation',
346
- ['Fabrice Bellard'], 1),
347
- ('qemu-block-drivers', 'qemu-block-drivers',
348
- u'QEMU block drivers reference',
349
- ['Fabrice Bellard and the QEMU Project developers'], 7),
350
- ('qemu-cpu-models', 'qemu-cpu-models',
351
- u'QEMU CPU Models',
352
- ['The QEMU Project developers'], 7)
353
-]
354
diff --git a/docs/tools/conf.py b/docs/tools/conf.py
355
deleted file mode 100644
356
index XXXXXXX..XXXXXXX
357
--- a/docs/tools/conf.py
358
+++ /dev/null
359
@@ -XXX,XX +XXX,XX @@
360
-# -*- coding: utf-8 -*-
361
-#
362
-# QEMU documentation build configuration file for the 'tools' manual.
363
-#
364
-# This includes the top level conf file and then makes any necessary tweaks.
365
-import sys
366
-import os
367
-
368
-qemu_docdir = os.path.abspath("..")
369
-parent_config = os.path.join(qemu_docdir, "conf.py")
370
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
371
-
372
-# This slightly misuses the 'description', but is the best way to get
373
-# the manual title to appear in the sidebar.
374
-html_theme_options['description'] = \
375
- u'Tools Guide'
376
-
377
-# One entry per manual page. List of tuples
378
-# (source start file, name, description, authors, manual section).
379
-man_pages = [
380
- ('qemu-img', 'qemu-img', u'QEMU disk image utility',
381
- ['Fabrice Bellard'], 1),
382
- ('qemu-storage-daemon', 'qemu-storage-daemon', u'QEMU storage daemon',
383
- [], 1),
384
- ('qemu-nbd', 'qemu-nbd', u'QEMU Disk Network Block Device Server',
385
- ['Anthony Liguori <anthony@codemonkey.ws>'], 8),
386
- ('qemu-pr-helper', 'qemu-pr-helper', 'QEMU persistent reservation helper',
387
- [], 8),
388
- ('qemu-trace-stap', 'qemu-trace-stap', u'QEMU SystemTap trace tool',
389
- [], 1),
390
- ('virtfs-proxy-helper', 'virtfs-proxy-helper',
391
- u'QEMU 9p virtfs proxy filesystem helper',
392
- ['M. Mohan Kumar'], 1),
393
- ('virtiofsd', 'virtiofsd', u'QEMU virtio-fs shared file system daemon',
394
- ['Stefan Hajnoczi <stefanha@redhat.com>',
395
- 'Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>'], 1),
396
-]
397
diff --git a/docs/user/conf.py b/docs/user/conf.py
398
deleted file mode 100644
399
index XXXXXXX..XXXXXXX
400
--- a/docs/user/conf.py
401
+++ /dev/null
402
@@ -XXX,XX +XXX,XX @@
403
-# -*- coding: utf-8 -*-
404
-#
405
-# QEMU documentation build configuration file for the 'user' manual.
406
-#
407
-# This includes the top level conf file and then makes any necessary tweaks.
408
-import sys
409
-import os
410
-
411
-qemu_docdir = os.path.abspath("..")
412
-parent_config = os.path.join(qemu_docdir, "conf.py")
413
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
414
-
415
-# This slightly misuses the 'description', but is the best way to get
416
-# the manual title to appear in the sidebar.
417
-html_theme_options['description'] = u'User Mode Emulation User''s Guide'
418
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
419
index XXXXXXX..XXXXXXX 100644
420
--- a/.gitlab-ci.yml
421
+++ b/.gitlab-ci.yml
422
@@ -XXX,XX +XXX,XX @@ pages:
423
-t "Welcome to the QEMU sourcecode"
424
- mv HTML public/src
425
# Project documentation
426
- - mv build/docs/index.html public/
427
- - for i in devel interop specs system tools user ; do mv build/docs/$i public/ ; done
428
+ - make -C build install DESTDIR=$(pwd)/temp-install
429
+ - mv temp-install/usr/local/share/doc/qemu/* public/
430
artifacts:
431
paths:
432
- public
433
--
434
2.20.1
435
436
diff view generated by jsdifflib