1
Two small bugfixes, plus most of RTH's refactoring of cpregs
1
Hi; this pullreq contains mainly a chunk of RTH's refactoring
2
handling.
2
of the Arm pagetable walk code, plus a series from me fixing
3
configure checkpatch warnings, and some old patches to various
4
files all over the tree getting rid of dynamic stack allocation.
3
5
6
thanks
4
-- PMM
7
-- PMM
5
8
6
The following changes since commit 1fba9dc71a170b3a05b9d3272dd8ecfe7f26e215:
9
The following changes since commit 6338c30111d596d955e6bc933a82184a0b910c43:
7
10
8
Merge tag 'pull-request-2022-05-04' of https://gitlab.com/thuth/qemu into staging (2022-05-04 08:07:02 -0700)
11
Merge tag 'm68k-for-7.2-pull-request' of https://github.com/vivier/qemu-m68k into staging (2022-09-21 13:12:36 -0400)
9
12
10
are available in the Git repository at:
13
are available in the Git repository at:
11
14
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220505
15
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220922
13
16
14
for you to fetch changes up to 99a50d1a67c602126fc2b3a4812d3000eba9bf34:
17
for you to fetch changes up to b3b5472db0ab7a53499441c1fe1dedec05b1e285:
15
18
16
target/arm: read access to performance counters from EL0 (2022-05-05 09:36:22 +0100)
19
configure: Avoid use of 'local' as it is non-POSIX (2022-09-22 16:38:29 +0100)
17
20
18
----------------------------------------------------------------
21
----------------------------------------------------------------
19
target-arm queue:
22
target-arm queue:
20
* Enable read access to performance counters from EL0
23
* hw/net/can: fix Xilinx ZynqMP CAN RX FIFO logic
21
* Enable SCTLR_EL1.BT0 for aarch64-linux-user
24
* Fix alignment for Neon VLD4.32
22
* Refactoring of cpreg handling
25
* Refactoring of page-table-walk code
26
* hw/acpi: Add ospm_status hook implementation for acpi-ged
27
* hw/net/lan9118: Signal TSFL_INT flag when TX FIFO reaches specified level
28
* chardev/baum: avoid variable-length arrays
29
* io/channel-websock: avoid variable-length arrays
30
* hw/net/e1000e_core: Use definition to avoid dynamic stack allocation
31
* hw/ppc/pnv: Avoid dynamic stack allocation
32
* hw/intc/xics: Avoid dynamic stack allocation
33
* hw/i386/multiboot: Avoid dynamic stack allocation
34
* hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation
35
* ui/curses: Avoid dynamic stack allocation
36
* tests/unit/test-vmstate: Avoid dynamic stack allocation
37
* configure: fix various shellcheck-spotted issues and nits
23
38
24
----------------------------------------------------------------
39
----------------------------------------------------------------
25
Alex Zuepke (1):
40
Anton Kochkov (1):
26
target/arm: read access to performance counters from EL0
41
hw/net/can: fix Xilinx ZynqMP CAN RX FIFO logic
27
42
28
Richard Henderson (22):
43
Clément Chigot (1):
29
target/arm: Enable SCTLR_EL1.BT0 for aarch64-linux-user
44
target/arm: Fix alignment for VLD4.32
30
target/arm: Split out cpregs.h
31
target/arm: Reorg CPAccessResult and access_check_cp_reg
32
target/arm: Replace sentinels with ARRAY_SIZE in cpregs.h
33
target/arm: Make some more cpreg data static const
34
target/arm: Reorg ARMCPRegInfo type field bits
35
target/arm: Avoid bare abort() or assert(0)
36
target/arm: Change cpreg access permissions to enum
37
target/arm: Name CPState type
38
target/arm: Name CPSecureState type
39
target/arm: Drop always-true test in define_arm_vh_e2h_redirects_aliases
40
target/arm: Store cpregs key in the hash table directly
41
target/arm: Merge allocation of the cpreg and its name
42
target/arm: Hoist computation of key in add_cpreg_to_hashtable
43
target/arm: Consolidate cpreg updates in add_cpreg_to_hashtable
44
target/arm: Use bool for is64 and ns in add_cpreg_to_hashtable
45
target/arm: Hoist isbanked computation in add_cpreg_to_hashtable
46
target/arm: Perform override check early in add_cpreg_to_hashtable
47
target/arm: Reformat comments in add_cpreg_to_hashtable
48
target/arm: Remove HOST_BIG_ENDIAN ifdef in add_cpreg_to_hashtable
49
target/arm: Add isar predicates for FEAT_Debugv8p2
50
target/arm: Add isar_feature_{aa64,any}_ras
51
45
52
target/arm/cpregs.h | 453 ++++++++++++++++++++++++++++++++++++++
46
Keqian Zhu (1):
53
target/arm/cpu.h | 393 +++------------------------------
47
hw/acpi: Add ospm_status hook implementation for acpi-ged
54
hw/arm/pxa2xx.c | 2 +-
48
55
hw/arm/pxa2xx_pic.c | 2 +-
49
Lucas Dietrich (1):
56
hw/intc/arm_gicv3_cpuif.c | 6 +-
50
hw/net/lan9118: Signal TSFL_INT flag when TX FIFO reaches specified level
57
hw/intc/arm_gicv3_kvm.c | 3 +-
51
58
target/arm/cpu.c | 25 +--
52
Peter Maydell (7):
59
target/arm/cpu64.c | 2 +-
53
configure: Remove unused python_version variable
60
target/arm/cpu_tcg.c | 5 +-
54
configure: Remove unused meson_args variable
61
target/arm/gdbstub.c | 5 +-
55
configure: Add missing quoting for some easy cases
62
target/arm/helper.c | 358 +++++++++++++-----------------
56
configure: Add './' on front of glob of */config-devices.mak.d
63
target/arm/hvf/hvf.c | 2 +-
57
configure: Remove use of backtick `...` syntax
64
target/arm/kvm-stub.c | 4 +-
58
configure: Check mkdir result directly, not via $?
65
target/arm/kvm.c | 4 +-
59
configure: Avoid use of 'local' as it is non-POSIX
66
target/arm/machine.c | 4 +-
60
67
target/arm/op_helper.c | 57 ++---
61
Philippe Mathieu-Daudé (11):
68
target/arm/translate-a64.c | 14 +-
62
chardev/baum: Replace magic values by X_MAX / Y_MAX definitions
69
target/arm/translate-neon.c | 2 +-
63
chardev/baum: Use definitions to avoid dynamic stack allocation
70
target/arm/translate.c | 13 +-
64
chardev/baum: Avoid dynamic stack allocation
71
tests/tcg/aarch64/bti-3.c | 42 ++++
65
io/channel-websock: Replace strlen(const_str) by sizeof(const_str) - 1
72
tests/tcg/aarch64/Makefile.target | 6 +-
66
hw/net/e1000e_core: Use definition to avoid dynamic stack allocation
73
21 files changed, 738 insertions(+), 664 deletions(-)
67
hw/ppc/pnv: Avoid dynamic stack allocation
74
create mode 100644 target/arm/cpregs.h
68
hw/intc/xics: Avoid dynamic stack allocation
75
create mode 100644 tests/tcg/aarch64/bti-3.c
69
hw/i386/multiboot: Avoid dynamic stack allocation
70
hw/usb/hcd-ohci: Use definition to avoid dynamic stack allocation
71
ui/curses: Avoid dynamic stack allocation
72
tests/unit/test-vmstate: Avoid dynamic stack allocation
73
74
Richard Henderson (17):
75
target/arm: Create GetPhysAddrResult
76
target/arm: Use GetPhysAddrResult in get_phys_addr_lpae
77
target/arm: Use GetPhysAddrResult in get_phys_addr_v6
78
target/arm: Use GetPhysAddrResult in get_phys_addr_v5
79
target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav5
80
target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav7
81
target/arm: Use GetPhysAddrResult in get_phys_addr_pmsav8
82
target/arm: Use GetPhysAddrResult in pmsav8_mpu_lookup
83
target/arm: Remove is_subpage argument to pmsav8_mpu_lookup
84
target/arm: Add is_secure parameter to v8m_security_lookup
85
target/arm: Add secure parameter to pmsav8_mpu_lookup
86
target/arm: Add is_secure parameter to get_phys_addr_v5
87
target/arm: Add is_secure parameter to get_phys_addr_v6
88
target/arm: Add secure parameter to get_phys_addr_pmsav8
89
target/arm: Add is_secure parameter to pmsav7_use_background_region
90
target/arm: Add secure parameter to get_phys_addr_pmsav7
91
target/arm: Add is_secure parameter to get_phys_addr_pmsav5
92
93
configure | 82 +++++-----
94
target/arm/internals.h | 26 +--
95
chardev/baum.c | 22 ++-
96
hw/acpi/generic_event_device.c | 8 +
97
hw/i386/multiboot.c | 5 +-
98
hw/intc/xics.c | 2 +-
99
hw/net/can/xlnx-zynqmp-can.c | 32 ++--
100
hw/net/e1000e_core.c | 7 +-
101
hw/net/lan9118.c | 8 +
102
hw/ppc/pnv.c | 4 +-
103
hw/ppc/spapr.c | 8 +-
104
hw/ppc/spapr_pci_nvlink2.c | 2 +-
105
hw/usb/hcd-ohci.c | 7 +-
106
io/channel-websock.c | 2 +-
107
target/arm/helper.c | 27 ++-
108
target/arm/m_helper.c | 78 ++++-----
109
target/arm/ptw.c | 364 +++++++++++++++++++----------------------
110
target/arm/tlb_helper.c | 22 +--
111
target/arm/translate-neon.c | 6 +-
112
tests/unit/test-vmstate.c | 7 +-
113
ui/curses.c | 2 +-
114
21 files changed, 347 insertions(+), 374 deletions(-)
115
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Anton Kochkov <anton.kochkov@proton.me>
2
2
3
Computing isbanked only once makes the code
3
For consistency, function "update_rx_fifo()" should use the RX FIFO
4
a bit easier to read.
4
register field names, not the TX FIFO ones, even if they refer to the
5
same bit positions in the register.
5
6
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Anton Kochkov <anton.kochkov@proton.me>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Message-id: 20220501055028.646596-17-richard.henderson@linaro.org
9
Message-id: 20220817141754.2105981-1-anton.kochkov@proton.me
10
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1123
11
[PMM: tweaked commit message]
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
target/arm/helper.c | 6 ++++--
14
hw/net/can/xlnx-zynqmp-can.c | 32 ++++++++++++++++----------------
12
1 file changed, 4 insertions(+), 2 deletions(-)
15
1 file changed, 16 insertions(+), 16 deletions(-)
13
16
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c
15
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
19
--- a/hw/net/can/xlnx-zynqmp-can.c
17
+++ b/target/arm/helper.c
20
+++ b/hw/net/can/xlnx-zynqmp-can.c
18
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
21
@@ -XXX,XX +XXX,XX @@ static void update_rx_fifo(XlnxZynqMPCANState *s, const qemu_can_frame *frame)
19
bool is64 = r->type & ARM_CP_64BIT;
22
timestamp));
20
bool ns = secstate & ARM_CP_SECSTATE_NS;
23
21
int cp = r->cp;
24
/* First 32 bit of the data. */
22
+ bool isbanked;
25
- fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA1_DB3_SHIFT,
23
size_t name_len;
26
- R_TXFIFO_DATA1_DB3_LENGTH,
24
27
+ fifo32_push(&s->rx_fifo, deposit32(0, R_RXFIFO_DATA1_DB3_SHIFT,
25
switch (state) {
28
+ R_RXFIFO_DATA1_DB3_LENGTH,
26
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
29
frame->data[0]) |
27
r2->opaque = opaque;
30
- deposit32(0, R_TXFIFO_DATA1_DB2_SHIFT,
28
}
31
- R_TXFIFO_DATA1_DB2_LENGTH,
29
32
+ deposit32(0, R_RXFIFO_DATA1_DB2_SHIFT,
30
- if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) {
33
+ R_RXFIFO_DATA1_DB2_LENGTH,
31
+ isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1];
34
frame->data[1]) |
32
+ if (isbanked) {
35
- deposit32(0, R_TXFIFO_DATA1_DB1_SHIFT,
33
/* Register is banked (using both entries in array).
36
- R_TXFIFO_DATA1_DB1_LENGTH,
34
* Overwriting fieldoffset as the array is only used to define
37
+ deposit32(0, R_RXFIFO_DATA1_DB1_SHIFT,
35
* banked registers but later only fieldoffset is used.
38
+ R_RXFIFO_DATA1_DB1_LENGTH,
36
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
39
frame->data[2]) |
37
}
40
- deposit32(0, R_TXFIFO_DATA1_DB0_SHIFT,
38
41
- R_TXFIFO_DATA1_DB0_LENGTH,
39
if (state == ARM_CP_STATE_AA32) {
42
+ deposit32(0, R_RXFIFO_DATA1_DB0_SHIFT,
40
- if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) {
43
+ R_RXFIFO_DATA1_DB0_LENGTH,
41
+ if (isbanked) {
44
frame->data[3]));
42
/* If the register is banked then we don't need to migrate or
45
/* Last 32 bit of the data. */
43
* reset the 32-bit instance in certain cases:
46
- fifo32_push(&s->rx_fifo, deposit32(0, R_TXFIFO_DATA2_DB7_SHIFT,
44
*
47
- R_TXFIFO_DATA2_DB7_LENGTH,
48
+ fifo32_push(&s->rx_fifo, deposit32(0, R_RXFIFO_DATA2_DB7_SHIFT,
49
+ R_RXFIFO_DATA2_DB7_LENGTH,
50
frame->data[4]) |
51
- deposit32(0, R_TXFIFO_DATA2_DB6_SHIFT,
52
- R_TXFIFO_DATA2_DB6_LENGTH,
53
+ deposit32(0, R_RXFIFO_DATA2_DB6_SHIFT,
54
+ R_RXFIFO_DATA2_DB6_LENGTH,
55
frame->data[5]) |
56
- deposit32(0, R_TXFIFO_DATA2_DB5_SHIFT,
57
- R_TXFIFO_DATA2_DB5_LENGTH,
58
+ deposit32(0, R_RXFIFO_DATA2_DB5_SHIFT,
59
+ R_RXFIFO_DATA2_DB5_LENGTH,
60
frame->data[6]) |
61
- deposit32(0, R_TXFIFO_DATA2_DB4_SHIFT,
62
- R_TXFIFO_DATA2_DB4_LENGTH,
63
+ deposit32(0, R_RXFIFO_DATA2_DB4_SHIFT,
64
+ R_RXFIFO_DATA2_DB4_LENGTH,
65
frame->data[7]));
66
67
ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOK, 1);
45
--
68
--
46
2.25.1
69
2.25.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Clément Chigot <chigot@adacore.com>
2
2
3
Standardize on g_assert_not_reached() for "should not happen".
3
When requested, the alignment for VLD4.32 is 8 and not 16.
4
Retain abort() when preceeded by fprintf or error_report.
5
4
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
See ARM documentation about VLD4 encoding:
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
ebytes = 1 << UInt(size);
8
Message-id: 20220501055028.646596-7-richard.henderson@linaro.org
7
if size == '10' then
8
alignment = if a == '0' then 1 else 8;
9
else
10
alignment = if a == '0' then 1 else 4*ebytes;
11
12
Signed-off-by: Clément Chigot <chigot@adacore.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20220914105058.2787404-1-chigot@adacore.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
16
---
11
target/arm/helper.c | 7 +++----
17
target/arm/translate-neon.c | 6 +++++-
12
target/arm/hvf/hvf.c | 2 +-
18
1 file changed, 5 insertions(+), 1 deletion(-)
13
target/arm/kvm-stub.c | 4 ++--
14
target/arm/kvm.c | 4 ++--
15
target/arm/machine.c | 4 ++--
16
target/arm/translate-a64.c | 4 ++--
17
target/arm/translate-neon.c | 2 +-
18
target/arm/translate.c | 4 ++--
19
8 files changed, 15 insertions(+), 16 deletions(-)
20
19
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 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
26
break;
27
default:
28
/* broken reginfo with out-of-range opc1 */
29
- assert(false);
30
- break;
31
+ g_assert_not_reached();
32
}
33
/* assert our permissions are not too lax (stricter is fine) */
34
assert((r->access & ~mask) == 0);
35
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
36
break;
37
default:
38
/* Never happens, but compiler isn't smart enough to tell. */
39
- abort();
40
+ g_assert_not_reached();
41
}
42
}
43
*prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
44
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
45
break;
46
default:
47
/* Never happens, but compiler isn't smart enough to tell. */
48
- abort();
49
+ g_assert_not_reached();
50
}
51
}
52
if (domain_prot == 3) {
53
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/target/arm/hvf/hvf.c
56
+++ b/target/arm/hvf/hvf.c
57
@@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu)
58
/* we got kicked, no exit to process */
59
return 0;
60
default:
61
- assert(0);
62
+ g_assert_not_reached();
63
}
64
65
hvf_sync_vtimer(cpu);
66
diff --git a/target/arm/kvm-stub.c b/target/arm/kvm-stub.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/kvm-stub.c
69
+++ b/target/arm/kvm-stub.c
70
@@ -XXX,XX +XXX,XX @@
71
72
bool write_kvmstate_to_list(ARMCPU *cpu)
73
{
74
- abort();
75
+ g_assert_not_reached();
76
}
77
78
bool write_list_to_kvmstate(ARMCPU *cpu, int level)
79
{
80
- abort();
81
+ g_assert_not_reached();
82
}
83
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/target/arm/kvm.c
86
+++ b/target/arm/kvm.c
87
@@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu)
88
ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r);
89
break;
90
default:
91
- abort();
92
+ g_assert_not_reached();
93
}
94
if (ret) {
95
ok = false;
96
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
97
r.addr = (uintptr_t)(cpu->cpreg_values + i);
98
break;
99
default:
100
- abort();
101
+ g_assert_not_reached();
102
}
103
ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r);
104
if (ret) {
105
diff --git a/target/arm/machine.c b/target/arm/machine.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/target/arm/machine.c
108
+++ b/target/arm/machine.c
109
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
110
if (kvm_enabled()) {
111
if (!write_kvmstate_to_list(cpu)) {
112
/* This should never fail */
113
- abort();
114
+ g_assert_not_reached();
115
}
116
117
/*
118
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
119
} else {
120
if (!write_cpustate_to_list(cpu, false)) {
121
/* This should never fail. */
122
- abort();
123
+ g_assert_not_reached();
124
}
125
}
126
127
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
128
index XXXXXXX..XXXXXXX 100644
129
--- a/target/arm/translate-a64.c
130
+++ b/target/arm/translate-a64.c
131
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn)
132
gen_helper_advsimd_rinth(tcg_res, tcg_op, fpst);
133
break;
134
default:
135
- abort();
136
+ g_assert_not_reached();
137
}
138
139
write_fp_sreg(s, rd, tcg_res);
140
@@ -XXX,XX +XXX,XX @@ static void handle_fp_fcvt(DisasContext *s, int opcode,
141
break;
142
}
143
default:
144
- abort();
145
+ g_assert_not_reached();
146
}
147
}
148
149
diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c
20
diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c
150
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
151
--- a/target/arm/translate-neon.c
22
--- a/target/arm/translate-neon.c
152
+++ b/target/arm/translate-neon.c
23
+++ b/target/arm/translate-neon.c
153
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
24
@@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a)
154
}
25
case 3:
155
break;
26
return false;
156
default:
27
case 4:
157
- abort();
28
- align = pow2_align(size + 2);
158
+ g_assert_not_reached();
29
+ if (size == 2) {
159
}
30
+ align = pow2_align(3);
160
if ((vd + a->stride * (nregs - 1)) > 31) {
31
+ } else {
161
/*
32
+ align = pow2_align(size + 2);
162
diff --git a/target/arm/translate.c b/target/arm/translate.c
33
+ }
163
index XXXXXXX..XXXXXXX 100644
164
--- a/target/arm/translate.c
165
+++ b/target/arm/translate.c
166
@@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s,
167
offset = 4;
168
break;
169
default:
170
- abort();
171
+ g_assert_not_reached();
172
}
173
tcg_gen_addi_i32(addr, addr, offset);
174
tmp = load_reg(s, 14);
175
@@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s,
176
offset = 0;
177
break;
34
break;
178
default:
35
default:
179
- abort();
36
g_assert_not_reached();
180
+ g_assert_not_reached();
181
}
182
tcg_gen_addi_i32(addr, addr, offset);
183
gen_helper_set_r13_banked(cpu_env, tcg_constant_i32(mode), addr);
184
--
37
--
185
2.25.1
38
2.25.1
39
40
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Simplify freeing cp_regs hash table entries by using a single
3
Combine 5 output pointer arguments from get_phys_addr
4
allocation for the entire value.
4
into a single struct. Adjust all callers.
5
6
This fixes a theoretical bug if we were to ever free the entire
7
hash table, because we've been installing string literal constants
8
into the cpreg structure in define_arm_vh_e2h_redirects_aliases.
9
However, at present we only free entries created for AArch32
10
wildcard cpregs which get overwritten by more specific cpregs,
11
so this bug is never exposed.
12
5
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220822152741.1617527-2-richard.henderson@linaro.org
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Message-id: 20220501055028.646596-13-richard.henderson@linaro.org
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
10
---
18
target/arm/cpu.c | 16 +---------------
11
target/arm/internals.h | 13 ++++-
19
target/arm/helper.c | 10 ++++++++--
12
target/arm/helper.c | 27 ++++-----
20
2 files changed, 9 insertions(+), 17 deletions(-)
13
target/arm/m_helper.c | 52 ++++++-----------
14
target/arm/ptw.c | 120 +++++++++++++++++++++-------------------
15
target/arm/tlb_helper.c | 22 +++-----
16
5 files changed, 109 insertions(+), 125 deletions(-)
21
17
22
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
23
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/cpu.c
20
--- a/target/arm/internals.h
25
+++ b/target/arm/cpu.c
21
+++ b/target/arm/internals.h
26
@@ -XXX,XX +XXX,XX @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz)
22
@@ -XXX,XX +XXX,XX @@ typedef struct ARMCacheAttrs {
27
return (Aff1 << ARM_AFF1_SHIFT) | Aff0;
23
bool is_s2_format:1;
28
}
24
} ARMCacheAttrs;
29
25
30
-static void cpreg_hashtable_data_destroy(gpointer data)
26
+/* Fields that are valid upon success. */
31
-{
27
+typedef struct GetPhysAddrResult {
32
- /*
28
+ hwaddr phys;
33
- * Destroy function for cpu->cp_regs hashtable data entries.
29
+ target_ulong page_size;
34
- * We must free the name string because it was g_strdup()ed in
30
+ int prot;
35
- * add_cpreg_to_hashtable(). It's OK to cast away the 'const'
31
+ MemTxAttrs attrs;
36
- * from r->name because we know we definitely allocated it.
32
+ ARMCacheAttrs cacheattrs;
37
- */
33
+} GetPhysAddrResult;
38
- ARMCPRegInfo *r = data;
34
+
39
-
35
bool get_phys_addr(CPUARMState *env, target_ulong address,
40
- g_free((void *)r->name);
36
MMUAccessType access_type, ARMMMUIdx mmu_idx,
41
- g_free(r);
37
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
42
-}
38
- target_ulong *page_size,
43
-
39
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
44
static void arm_cpu_initfn(Object *obj)
40
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
45
{
41
__attribute__((nonnull));
46
ARMCPU *cpu = ARM_CPU(obj);
42
47
43
void arm_log_exception(CPUState *cs);
48
cpu_set_cpustate_pointers(cpu);
49
cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal,
50
- NULL, cpreg_hashtable_data_destroy);
51
+ NULL, g_free);
52
53
QLIST_INIT(&cpu->pre_el_change_hooks);
54
QLIST_INIT(&cpu->el_change_hooks);
55
diff --git a/target/arm/helper.c b/target/arm/helper.c
44
diff --git a/target/arm/helper.c b/target/arm/helper.c
56
index XXXXXXX..XXXXXXX 100644
45
index XXXXXXX..XXXXXXX 100644
57
--- a/target/arm/helper.c
46
--- a/target/arm/helper.c
58
+++ b/target/arm/helper.c
47
+++ b/target/arm/helper.c
59
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
48
@@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri,
60
* add a single reginfo struct to the hash table.
49
static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
50
MMUAccessType access_type, ARMMMUIdx mmu_idx)
51
{
52
- hwaddr phys_addr;
53
- target_ulong page_size;
54
- int prot;
55
bool ret;
56
uint64_t par64;
57
bool format64 = false;
58
- MemTxAttrs attrs = {};
59
ARMMMUFaultInfo fi = {};
60
- ARMCacheAttrs cacheattrs = {};
61
+ GetPhysAddrResult res = {};
62
63
- ret = get_phys_addr(env, value, access_type, mmu_idx, &phys_addr, &attrs,
64
- &prot, &page_size, &fi, &cacheattrs);
65
+ ret = get_phys_addr(env, value, access_type, mmu_idx, &res, &fi);
66
67
/*
68
* ATS operations only do S1 or S1+S2 translations, so we never
69
* have to deal with the ARMCacheAttrs format for S2 only.
61
*/
70
*/
62
uint32_t key;
71
- assert(!cacheattrs.is_s2_format);
63
- ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo));
72
+ assert(!res.cacheattrs.is_s2_format);
64
+ ARMCPRegInfo *r2;
73
65
int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
74
if (ret) {
66
int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0;
75
/*
67
+ size_t name_len;
76
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
77
/* Create a 64-bit PAR */
78
par64 = (1 << 11); /* LPAE bit always set */
79
if (!ret) {
80
- par64 |= phys_addr & ~0xfffULL;
81
- if (!attrs.secure) {
82
+ par64 |= res.phys & ~0xfffULL;
83
+ if (!res.attrs.secure) {
84
par64 |= (1 << 9); /* NS */
85
}
86
- par64 |= (uint64_t)cacheattrs.attrs << 56; /* ATTR */
87
- par64 |= cacheattrs.shareability << 7; /* SH */
88
+ par64 |= (uint64_t)res.cacheattrs.attrs << 56; /* ATTR */
89
+ par64 |= res.cacheattrs.shareability << 7; /* SH */
90
} else {
91
uint32_t fsr = arm_fi_to_lfsc(&fi);
92
93
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
94
*/
95
if (!ret) {
96
/* We do not set any attribute bits in the PAR */
97
- if (page_size == (1 << 24)
98
+ if (res.page_size == (1 << 24)
99
&& arm_feature(env, ARM_FEATURE_V7)) {
100
- par64 = (phys_addr & 0xff000000) | (1 << 1);
101
+ par64 = (res.phys & 0xff000000) | (1 << 1);
102
} else {
103
- par64 = phys_addr & 0xfffff000;
104
+ par64 = res.phys & 0xfffff000;
105
}
106
- if (!attrs.secure) {
107
+ if (!res.attrs.secure) {
108
par64 |= (1 << 9); /* NS */
109
}
110
} else {
111
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
112
index XXXXXXX..XXXXXXX 100644
113
--- a/target/arm/m_helper.c
114
+++ b/target/arm/m_helper.c
115
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
116
{
117
CPUState *cs = CPU(cpu);
118
CPUARMState *env = &cpu->env;
119
- MemTxAttrs attrs = {};
120
MemTxResult txres;
121
- target_ulong page_size;
122
- hwaddr physaddr;
123
- int prot;
124
+ GetPhysAddrResult res = {};
125
ARMMMUFaultInfo fi = {};
126
- ARMCacheAttrs cacheattrs = {};
127
bool secure = mmu_idx & ARM_MMU_IDX_M_S;
128
int exc;
129
bool exc_secure;
130
131
- if (get_phys_addr(env, addr, MMU_DATA_STORE, mmu_idx, &physaddr,
132
- &attrs, &prot, &page_size, &fi, &cacheattrs)) {
133
+ if (get_phys_addr(env, addr, MMU_DATA_STORE, mmu_idx, &res, &fi)) {
134
/* MPU/SAU lookup failed */
135
if (fi.type == ARMFault_QEMU_SFault) {
136
if (mode == STACK_LAZYFP) {
137
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
138
}
139
goto pend_fault;
140
}
141
- address_space_stl_le(arm_addressspace(cs, attrs), physaddr, value,
142
- attrs, &txres);
143
+ address_space_stl_le(arm_addressspace(cs, res.attrs), res.phys, value,
144
+ res.attrs, &txres);
145
if (txres != MEMTX_OK) {
146
/* BusFault trying to write the data */
147
if (mode == STACK_LAZYFP) {
148
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,
149
{
150
CPUState *cs = CPU(cpu);
151
CPUARMState *env = &cpu->env;
152
- MemTxAttrs attrs = {};
153
MemTxResult txres;
154
- target_ulong page_size;
155
- hwaddr physaddr;
156
- int prot;
157
+ GetPhysAddrResult res = {};
158
ARMMMUFaultInfo fi = {};
159
- ARMCacheAttrs cacheattrs = {};
160
bool secure = mmu_idx & ARM_MMU_IDX_M_S;
161
int exc;
162
bool exc_secure;
163
uint32_t value;
164
165
- if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &physaddr,
166
- &attrs, &prot, &page_size, &fi, &cacheattrs)) {
167
+ if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) {
168
/* MPU/SAU lookup failed */
169
if (fi.type == ARMFault_QEMU_SFault) {
170
qemu_log_mask(CPU_LOG_INT,
171
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,
172
goto pend_fault;
173
}
174
175
- value = address_space_ldl(arm_addressspace(cs, attrs), physaddr,
176
- attrs, &txres);
177
+ value = address_space_ldl(arm_addressspace(cs, res.attrs), res.phys,
178
+ res.attrs, &txres);
179
if (txres != MEMTX_OK) {
180
/* BusFault trying to read the data */
181
qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.UNSTKERR\n");
182
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
183
CPUState *cs = CPU(cpu);
184
CPUARMState *env = &cpu->env;
185
V8M_SAttributes sattrs = {};
186
- MemTxAttrs attrs = {};
187
+ GetPhysAddrResult res = {};
188
ARMMMUFaultInfo fi = {};
189
- ARMCacheAttrs cacheattrs = {};
190
MemTxResult txres;
191
- target_ulong page_size;
192
- hwaddr physaddr;
193
- int prot;
194
195
v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs);
196
if (!sattrs.nsc || sattrs.ns) {
197
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
198
"...really SecureFault with SFSR.INVEP\n");
199
return false;
200
}
201
- if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, &physaddr,
202
- &attrs, &prot, &page_size, &fi, &cacheattrs)) {
203
+ if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, &res, &fi)) {
204
/* the MPU lookup failed */
205
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK;
206
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, env->v7m.secure);
207
qemu_log_mask(CPU_LOG_INT, "...really MemManage with CFSR.IACCVIOL\n");
208
return false;
209
}
210
- *insn = address_space_lduw_le(arm_addressspace(cs, attrs), physaddr,
211
- attrs, &txres);
212
+ *insn = address_space_lduw_le(arm_addressspace(cs, res.attrs), res.phys,
213
+ res.attrs, &txres);
214
if (txres != MEMTX_OK) {
215
env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK;
216
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
217
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx,
218
*/
219
CPUState *cs = CPU(cpu);
220
CPUARMState *env = &cpu->env;
221
- MemTxAttrs attrs = {};
222
MemTxResult txres;
223
- target_ulong page_size;
224
- hwaddr physaddr;
225
- int prot;
226
+ GetPhysAddrResult res = {};
227
ARMMMUFaultInfo fi = {};
228
- ARMCacheAttrs cacheattrs = {};
229
uint32_t value;
230
231
- if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &physaddr,
232
- &attrs, &prot, &page_size, &fi, &cacheattrs)) {
233
+ if (get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi)) {
234
/* MPU/SAU lookup failed */
235
if (fi.type == ARMFault_QEMU_SFault) {
236
qemu_log_mask(CPU_LOG_INT,
237
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_sg_stack_word(ARMCPU *cpu, ARMMMUIdx mmu_idx,
238
}
239
return false;
240
}
241
- value = address_space_ldl(arm_addressspace(cs, attrs), physaddr,
242
- attrs, &txres);
243
+ value = address_space_ldl(arm_addressspace(cs, res.attrs), res.phys,
244
+ res.attrs, &txres);
245
if (txres != MEMTX_OK) {
246
/* BusFault trying to read the data */
247
qemu_log_mask(CPU_LOG_INT,
248
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
249
index XXXXXXX..XXXXXXX 100644
250
--- a/target/arm/ptw.c
251
+++ b/target/arm/ptw.c
252
@@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(CPUARMState *env,
253
* @address: virtual address to get physical address for
254
* @access_type: 0 for read, 1 for write, 2 for execute
255
* @mmu_idx: MMU index indicating required translation regime
256
- * @phys_ptr: set to the physical address corresponding to the virtual address
257
- * @attrs: set to the memory transaction attributes to use
258
- * @prot: set to the permissions for the page containing phys_ptr
259
- * @page_size: set to the size of the page containing phys_ptr
260
+ * @result: set on translation success.
261
* @fi: set to fault info if the translation fails
262
- * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
263
*/
264
bool get_phys_addr(CPUARMState *env, target_ulong address,
265
MMUAccessType access_type, ARMMMUIdx mmu_idx,
266
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
267
- target_ulong *page_size,
268
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
269
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
270
{
271
ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx);
272
273
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
274
*/
275
if (arm_feature(env, ARM_FEATURE_EL2)) {
276
hwaddr ipa;
277
- int s2_prot;
278
+ int s1_prot;
279
int ret;
280
bool ipa_secure;
281
- ARMCacheAttrs cacheattrs2 = {};
282
+ ARMCacheAttrs cacheattrs1;
283
ARMMMUIdx s2_mmu_idx;
284
bool is_el0;
285
286
- ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa,
287
- attrs, prot, page_size, fi, cacheattrs);
288
+ ret = get_phys_addr(env, address, access_type, s1_mmu_idx,
289
+ result, fi);
290
291
/* If S1 fails or S2 is disabled, return early. */
292
if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2)) {
293
- *phys_ptr = ipa;
294
return ret;
295
}
296
297
- ipa_secure = attrs->secure;
298
+ ipa = result->phys;
299
+ ipa_secure = result->attrs.secure;
300
if (arm_is_secure_below_el3(env)) {
301
if (ipa_secure) {
302
- attrs->secure = !(env->cp15.vstcr_el2 & VSTCR_SW);
303
+ result->attrs.secure = !(env->cp15.vstcr_el2 & VSTCR_SW);
304
} else {
305
- attrs->secure = !(env->cp15.vtcr_el2 & VTCR_NSW);
306
+ result->attrs.secure = !(env->cp15.vtcr_el2 & VTCR_NSW);
307
}
308
} else {
309
assert(!ipa_secure);
310
}
311
312
- s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
313
+ s2_mmu_idx = (result->attrs.secure
314
+ ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2);
315
is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0;
316
317
- /* S1 is done. Now do S2 translation. */
318
+ /*
319
+ * S1 is done, now do S2 translation.
320
+ * Save the stage1 results so that we may merge
321
+ * prot and cacheattrs later.
322
+ */
323
+ s1_prot = result->prot;
324
+ cacheattrs1 = result->cacheattrs;
325
+ memset(result, 0, sizeof(*result));
68
+
326
+
69
+ /* Combine cpreg and name into one allocation. */
327
ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0,
70
+ name_len = strlen(name) + 1;
328
- phys_ptr, attrs, &s2_prot,
71
+ r2 = g_malloc(sizeof(*r2) + name_len);
329
- page_size, fi, &cacheattrs2);
72
+ *r2 = *r;
330
+ &result->phys, &result->attrs,
73
+ r2->name = memcpy(r2 + 1, name, name_len);
331
+ &result->prot, &result->page_size,
74
332
+ fi, &result->cacheattrs);
75
- r2->name = g_strdup(name);
333
fi->s2addr = ipa;
76
/* Reset the secure state to the specific incoming state. This is
334
+
77
* necessary as the register may have been defined with both states.
335
/* Combine the S1 and S2 perms. */
336
- *prot &= s2_prot;
337
+ result->prot &= s1_prot;
338
339
/* If S2 fails, return early. */
340
if (ret) {
341
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
342
* Outer Write-Back Read-Allocate Write-Allocate.
343
* Do not overwrite Tagged within attrs.
344
*/
345
- if (cacheattrs->attrs != 0xf0) {
346
- cacheattrs->attrs = 0xff;
347
+ if (cacheattrs1.attrs != 0xf0) {
348
+ cacheattrs1.attrs = 0xff;
349
}
350
- cacheattrs->shareability = 0;
351
+ cacheattrs1.shareability = 0;
352
}
353
- *cacheattrs = combine_cacheattrs(env, *cacheattrs, cacheattrs2);
354
+ result->cacheattrs = combine_cacheattrs(env, cacheattrs1,
355
+ result->cacheattrs);
356
357
/* Check if IPA translates to secure or non-secure PA space. */
358
if (arm_is_secure_below_el3(env)) {
359
if (ipa_secure) {
360
- attrs->secure =
361
+ result->attrs.secure =
362
!(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW));
363
} else {
364
- attrs->secure =
365
+ result->attrs.secure =
366
!((env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))
367
|| (env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)));
368
}
369
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
370
* cannot upgrade an non-secure translation regime's attributes
371
* to secure.
78
*/
372
*/
373
- attrs->secure = regime_is_secure(env, mmu_idx);
374
- attrs->user = regime_is_user(env, mmu_idx);
375
+ result->attrs.secure = regime_is_secure(env, mmu_idx);
376
+ result->attrs.user = regime_is_user(env, mmu_idx);
377
378
/*
379
* Fast Context Switch Extension. This doesn't exist at all in v8.
380
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
381
382
if (arm_feature(env, ARM_FEATURE_PMSA)) {
383
bool ret;
384
- *page_size = TARGET_PAGE_SIZE;
385
+ result->page_size = TARGET_PAGE_SIZE;
386
387
if (arm_feature(env, ARM_FEATURE_V8)) {
388
/* PMSAv8 */
389
ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx,
390
- phys_ptr, attrs, prot, page_size, fi);
391
+ &result->phys, &result->attrs,
392
+ &result->prot, &result->page_size, fi);
393
} else if (arm_feature(env, ARM_FEATURE_V7)) {
394
/* PMSAv7 */
395
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
396
- phys_ptr, prot, page_size, fi);
397
+ &result->phys, &result->prot,
398
+ &result->page_size, fi);
399
} else {
400
/* Pre-v7 MPU */
401
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
402
- phys_ptr, prot, fi);
403
+ &result->phys, &result->prot, fi);
404
}
405
qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32
406
" mmu_idx %u -> %s (prot %c%c%c)\n",
407
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
408
(access_type == MMU_DATA_STORE ? "writing" : "execute"),
409
(uint32_t)address, mmu_idx,
410
ret ? "Miss" : "Hit",
411
- *prot & PAGE_READ ? 'r' : '-',
412
- *prot & PAGE_WRITE ? 'w' : '-',
413
- *prot & PAGE_EXEC ? 'x' : '-');
414
+ result->prot & PAGE_READ ? 'r' : '-',
415
+ result->prot & PAGE_WRITE ? 'w' : '-',
416
+ result->prot & PAGE_EXEC ? 'x' : '-');
417
418
return ret;
419
}
420
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
421
address = extract64(address, 0, 52);
422
}
423
}
424
- *phys_ptr = address;
425
- *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
426
- *page_size = TARGET_PAGE_SIZE;
427
+ result->phys = address;
428
+ result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
429
+ result->page_size = TARGET_PAGE_SIZE;
430
431
/* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */
432
hcr = arm_hcr_el2_eff(env);
433
- cacheattrs->shareability = 0;
434
- cacheattrs->is_s2_format = false;
435
+ result->cacheattrs.shareability = 0;
436
+ result->cacheattrs.is_s2_format = false;
437
if (hcr & HCR_DC) {
438
if (hcr & HCR_DCT) {
439
memattr = 0xf0; /* Tagged, Normal, WB, RWA */
440
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
441
} else {
442
memattr = 0x44; /* Normal, NC, No */
443
}
444
- cacheattrs->shareability = 2; /* outer sharable */
445
+ result->cacheattrs.shareability = 2; /* outer sharable */
446
} else {
447
memattr = 0x00; /* Device, nGnRnE */
448
}
449
- cacheattrs->attrs = memattr;
450
+ result->cacheattrs.attrs = memattr;
451
return 0;
452
}
453
454
if (regime_using_lpae_format(env, mmu_idx)) {
455
return get_phys_addr_lpae(env, address, access_type, mmu_idx, false,
456
- phys_ptr, attrs, prot, page_size,
457
- fi, cacheattrs);
458
+ &result->phys, &result->attrs,
459
+ &result->prot, &result->page_size,
460
+ fi, &result->cacheattrs);
461
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
462
return get_phys_addr_v6(env, address, access_type, mmu_idx,
463
- phys_ptr, attrs, prot, page_size, fi);
464
+ &result->phys, &result->attrs,
465
+ &result->prot, &result->page_size, fi);
466
} else {
467
return get_phys_addr_v5(env, address, access_type, mmu_idx,
468
- phys_ptr, prot, page_size, fi);
469
+ &result->phys, &result->prot,
470
+ &result->page_size, fi);
471
}
472
}
473
474
@@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
475
{
476
ARMCPU *cpu = ARM_CPU(cs);
477
CPUARMState *env = &cpu->env;
478
- hwaddr phys_addr;
479
- target_ulong page_size;
480
- int prot;
481
- bool ret;
482
+ GetPhysAddrResult res = {};
483
ARMMMUFaultInfo fi = {};
484
ARMMMUIdx mmu_idx = arm_mmu_idx(env);
485
- ARMCacheAttrs cacheattrs = {};
486
+ bool ret;
487
488
- *attrs = (MemTxAttrs) {};
489
-
490
- ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &phys_addr,
491
- attrs, &prot, &page_size, &fi, &cacheattrs);
492
+ ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi);
493
+ *attrs = res.attrs;
494
495
if (ret) {
496
return -1;
497
}
498
- return phys_addr;
499
+ return res.phys;
500
}
501
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
502
index XXXXXXX..XXXXXXX 100644
503
--- a/target/arm/tlb_helper.c
504
+++ b/target/arm/tlb_helper.c
505
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
506
{
507
ARMCPU *cpu = ARM_CPU(cs);
508
ARMMMUFaultInfo fi = {};
509
- hwaddr phys_addr;
510
- target_ulong page_size;
511
- int prot, ret;
512
- MemTxAttrs attrs = {};
513
- ARMCacheAttrs cacheattrs = {};
514
+ GetPhysAddrResult res = {};
515
+ int ret;
516
517
/*
518
* Walk the page table and (if the mapping exists) add the page
519
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
520
*/
521
ret = get_phys_addr(&cpu->env, address, access_type,
522
core_to_arm_mmu_idx(&cpu->env, mmu_idx),
523
- &phys_addr, &attrs, &prot, &page_size,
524
- &fi, &cacheattrs);
525
+ &res, &fi);
526
if (likely(!ret)) {
527
/*
528
* Map a single [sub]page. Regions smaller than our declared
529
* target page size are handled specially, so for those we
530
* pass in the exact addresses.
531
*/
532
- if (page_size >= TARGET_PAGE_SIZE) {
533
- phys_addr &= TARGET_PAGE_MASK;
534
+ if (res.page_size >= TARGET_PAGE_SIZE) {
535
+ res.phys &= TARGET_PAGE_MASK;
536
address &= TARGET_PAGE_MASK;
537
}
538
/* Notice and record tagged memory. */
539
- if (cpu_isar_feature(aa64_mte, cpu) && cacheattrs.attrs == 0xf0) {
540
- arm_tlb_mte_tagged(&attrs) = true;
541
+ if (cpu_isar_feature(aa64_mte, cpu) && res.cacheattrs.attrs == 0xf0) {
542
+ arm_tlb_mte_tagged(&res.attrs) = true;
543
}
544
545
- tlb_set_page_with_attrs(cs, address, phys_addr, attrs,
546
- prot, mmu_idx, page_size);
547
+ tlb_set_page_with_attrs(cs, address, res.phys, res.attrs,
548
+ res.prot, mmu_idx, res.page_size);
549
return true;
550
} else if (probe) {
551
return false;
79
--
552
--
80
2.25.1
553
2.25.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Instead of defining ARM_CP_FLAG_MASK to remove flags,
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
define ARM_CP_SPECIAL_MASK to isolate special cases.
5
Sort the specials to the low bits. Use an enum.
6
7
Split the large comment block so as to document each
8
value separately.
9
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-4-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20220501055028.646596-6-richard.henderson@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
8
---
15
target/arm/cpregs.h | 130 +++++++++++++++++++++++--------------
9
target/arm/ptw.c | 69 ++++++++++++++++++------------------------------
16
target/arm/cpu.c | 4 +-
10
1 file changed, 26 insertions(+), 43 deletions(-)
17
target/arm/helper.c | 4 +-
18
target/arm/translate-a64.c | 6 +-
19
target/arm/translate.c | 6 +-
20
5 files changed, 92 insertions(+), 58 deletions(-)
21
11
22
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
23
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/cpregs.h
14
--- a/target/arm/ptw.c
25
+++ b/target/arm/cpregs.h
15
+++ b/target/arm/ptw.c
26
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@
27
#define TARGET_ARM_CPREGS_H
17
28
18
static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
29
/*
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
30
- * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a
20
- bool s1_is_el0, hwaddr *phys_ptr,
31
- * special-behaviour cp reg and bits [11..8] indicate what behaviour
21
- MemTxAttrs *txattrs, int *prot,
32
- * it has. Otherwise it is a simple cp reg, where CONST indicates that
22
- target_ulong *page_size_ptr,
33
- * TCG can assume the value to be constant (ie load at translate time)
23
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
34
- * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END
24
+ bool s1_is_el0, GetPhysAddrResult *result,
35
- * indicates that the TB should not be ended after a write to this register
25
+ ARMMMUFaultInfo *fi)
36
- * (the default is that the TB ends after cp writes). OVERRIDE permits
26
__attribute__((nonnull));
37
- * a register definition to override a previous definition for the
27
38
- * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the
28
/* This mapping is common between ID_AA64MMFR0.PARANGE and TCR_ELx.{I}PS. */
39
- * old must have the OVERRIDE bit set.
29
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
40
- * ALIAS indicates that this register is an alias view of some underlying
30
{
41
- * state which is also visible via another register, and that the other
31
if (arm_mmu_idx_is_stage1_of_2(mmu_idx) &&
42
- * register is handling migration and reset; registers marked ALIAS will not be
32
!regime_translation_disabled(env, ARMMMUIdx_Stage2)) {
43
- * migrated but may have their state set by syncing of register state from KVM.
33
- target_ulong s2size;
44
- * NO_RAW indicates that this register has no underlying state and does not
34
- hwaddr s2pa;
45
- * support raw access for state saving/loading; it will not be used for either
35
- int s2prot;
46
- * migration or KVM state synchronization. (Typically this is for "registers"
36
- int ret;
47
- * which are actually used as instructions for cache maintenance and so on.)
37
ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S
48
- * IO indicates that this register does I/O and therefore its accesses
38
: ARMMMUIdx_Stage2;
49
- * need to be marked with gen_io_start() and also end the TB. In particular,
39
- ARMCacheAttrs cacheattrs = {};
50
- * registers which implement clocks or timers require this.
40
- MemTxAttrs txattrs = {};
51
- * RAISES_EXC is for when the read or write hook might raise an exception;
41
+ GetPhysAddrResult s2 = {};
52
- * the generated code will synchronize the CPU state before calling the hook
42
+ int ret;
53
- * so that it is safe for the hook to call raise_exception().
43
54
- * NEWEL is for writes to registers that might change the exception
44
ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, false,
55
- * level - typically on older ARM chips. For those cases we need to
45
- &s2pa, &txattrs, &s2prot, &s2size, fi,
56
- * re-read the new el when recomputing the translation flags.
46
- &cacheattrs);
57
+ * ARMCPRegInfo type field bits:
47
+ &s2, fi);
48
if (ret) {
49
assert(fi->type != ARMFault_None);
50
fi->s2addr = addr;
51
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
52
return ~0;
53
}
54
if ((arm_hcr_el2_eff(env) & HCR_PTW) &&
55
- ptw_attrs_are_device(env, cacheattrs)) {
56
+ ptw_attrs_are_device(env, s2.cacheattrs)) {
57
/*
58
* PTW set and S1 walk touched S2 Device memory:
59
* generate Permission fault.
60
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
61
assert(!*is_secure);
62
}
63
64
- addr = s2pa;
65
+ addr = s2.phys;
66
}
67
return addr;
68
}
69
@@ -XXX,XX +XXX,XX @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level,
70
* table walk), must be true if this is stage 2 of a stage 1+2
71
* walk for an EL0 access. If @mmu_idx is anything else,
72
* @s1_is_el0 is ignored.
73
- * @phys_ptr: set to the physical address corresponding to the virtual address
74
- * @attrs: set to the memory transaction attributes to use
75
- * @prot: set to the permissions for the page containing phys_ptr
76
- * @page_size_ptr: set to the size of the page containing phys_ptr
77
+ * @result: set on translation success,
78
* @fi: set to fault info if the translation fails
79
- * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
58
*/
80
*/
59
-#define ARM_CP_SPECIAL 0x0001
81
static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
60
-#define ARM_CP_CONST 0x0002
82
MMUAccessType access_type, ARMMMUIdx mmu_idx,
61
-#define ARM_CP_64BIT 0x0004
83
- bool s1_is_el0, hwaddr *phys_ptr,
62
-#define ARM_CP_SUPPRESS_TB_END 0x0008
84
- MemTxAttrs *txattrs, int *prot,
63
-#define ARM_CP_OVERRIDE 0x0010
85
- target_ulong *page_size_ptr,
64
-#define ARM_CP_ALIAS 0x0020
86
- ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
65
-#define ARM_CP_IO 0x0040
87
+ bool s1_is_el0, GetPhysAddrResult *result,
66
-#define ARM_CP_NO_RAW 0x0080
88
+ ARMMMUFaultInfo *fi)
67
-#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100)
89
{
68
-#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200)
90
ARMCPU *cpu = env_archcpu(env);
69
-#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300)
91
/* Read an LPAE long-descriptor translation table. */
70
-#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400)
92
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
71
-#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500)
93
if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
72
-#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600)
94
ns = mmu_idx == ARMMMUIdx_Stage2;
73
-#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700)
95
xn = extract32(attrs, 11, 2);
74
-#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA
96
- *prot = get_S2prot(env, ap, xn, s1_is_el0);
75
-#define ARM_CP_FPU 0x1000
97
+ result->prot = get_S2prot(env, ap, xn, s1_is_el0);
76
-#define ARM_CP_SVE 0x2000
98
} else {
77
-#define ARM_CP_NO_GDB 0x4000
99
ns = extract32(attrs, 3, 1);
78
-#define ARM_CP_RAISES_EXC 0x8000
100
xn = extract32(attrs, 12, 1);
79
-#define ARM_CP_NEWEL 0x10000
101
pxn = extract32(attrs, 11, 1);
80
-/* Mask of only the flag bits in a type field */
102
- *prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
81
-#define ARM_CP_FLAG_MASK 0x1f0ff
103
+ result->prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
82
+enum {
83
+ /*
84
+ * Register must be handled specially during translation.
85
+ * The method is one of the values below:
86
+ */
87
+ ARM_CP_SPECIAL_MASK = 0x000f,
88
+ /* Special: no change to PE state: writes ignored, reads ignored. */
89
+ ARM_CP_NOP = 0x0001,
90
+ /* Special: sysreg is WFI, for v5 and v6. */
91
+ ARM_CP_WFI = 0x0002,
92
+ /* Special: sysreg is NZCV. */
93
+ ARM_CP_NZCV = 0x0003,
94
+ /* Special: sysreg is CURRENTEL. */
95
+ ARM_CP_CURRENTEL = 0x0004,
96
+ /* Special: sysreg is DC ZVA or similar. */
97
+ ARM_CP_DC_ZVA = 0x0005,
98
+ ARM_CP_DC_GVA = 0x0006,
99
+ ARM_CP_DC_GZVA = 0x0007,
100
+
101
+ /* Flag: reads produce resetvalue; writes ignored. */
102
+ ARM_CP_CONST = 1 << 4,
103
+ /* Flag: For ARM_CP_STATE_AA32, sysreg is 64-bit. */
104
+ ARM_CP_64BIT = 1 << 5,
105
+ /*
106
+ * Flag: TB should not be ended after a write to this register
107
+ * (the default is that the TB ends after cp writes).
108
+ */
109
+ ARM_CP_SUPPRESS_TB_END = 1 << 6,
110
+ /*
111
+ * Flag: Permit a register definition to override a previous definition
112
+ * for the same (cp, is64, crn, crm, opc1, opc2) tuple: either the new
113
+ * or the old must have the ARM_CP_OVERRIDE bit set.
114
+ */
115
+ ARM_CP_OVERRIDE = 1 << 7,
116
+ /*
117
+ * Flag: Register is an alias view of some underlying state which is also
118
+ * visible via another register, and that the other register is handling
119
+ * migration and reset; registers marked ARM_CP_ALIAS will not be migrated
120
+ * but may have their state set by syncing of register state from KVM.
121
+ */
122
+ ARM_CP_ALIAS = 1 << 8,
123
+ /*
124
+ * Flag: Register does I/O and therefore its accesses need to be marked
125
+ * with gen_io_start() and also end the TB. In particular, registers which
126
+ * implement clocks or timers require this.
127
+ */
128
+ ARM_CP_IO = 1 << 9,
129
+ /*
130
+ * Flag: Register has no underlying state and does not support raw access
131
+ * for state saving/loading; it will not be used for either migration or
132
+ * KVM state synchronization. Typically this is for "registers" which are
133
+ * actually used as instructions for cache maintenance and so on.
134
+ */
135
+ ARM_CP_NO_RAW = 1 << 10,
136
+ /*
137
+ * Flag: The read or write hook might raise an exception; the generated
138
+ * code will synchronize the CPU state before calling the hook so that it
139
+ * is safe for the hook to call raise_exception().
140
+ */
141
+ ARM_CP_RAISES_EXC = 1 << 11,
142
+ /*
143
+ * Flag: Writes to the sysreg might change the exception level - typically
144
+ * on older ARM chips. For those cases we need to re-read the new el when
145
+ * recomputing the translation flags.
146
+ */
147
+ ARM_CP_NEWEL = 1 << 12,
148
+ /*
149
+ * Flag: Access check for this sysreg is identical to accessing FPU state
150
+ * from an instruction: use translation fp_access_check().
151
+ */
152
+ ARM_CP_FPU = 1 << 13,
153
+ /*
154
+ * Flag: Access check for this sysreg is identical to accessing SVE state
155
+ * from an instruction: use translation sve_access_check().
156
+ */
157
+ ARM_CP_SVE = 1 << 14,
158
+ /* Flag: Do not expose in gdb sysreg xml. */
159
+ ARM_CP_NO_GDB = 1 << 15,
160
+};
161
162
/*
163
* Valid values for ARMCPRegInfo state field, indicating which of
164
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
165
index XXXXXXX..XXXXXXX 100644
166
--- a/target/arm/cpu.c
167
+++ b/target/arm/cpu.c
168
@@ -XXX,XX +XXX,XX @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
169
ARMCPRegInfo *ri = value;
170
ARMCPU *cpu = opaque;
171
172
- if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS)) {
173
+ if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS)) {
174
return;
175
}
104
}
176
105
177
@@ -XXX,XX +XXX,XX @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque)
106
fault_type = ARMFault_Permission;
178
ARMCPU *cpu = opaque;
107
- if (!(*prot & (1 << access_type))) {
179
uint64_t oldvalue, newvalue;
108
+ if (!(result->prot & (1 << access_type))) {
180
109
goto do_fault;
181
- if (ri->type & (ARM_CP_SPECIAL | ARM_CP_ALIAS | ARM_CP_NO_RAW)) {
182
+ if (ri->type & (ARM_CP_SPECIAL_MASK | ARM_CP_ALIAS | ARM_CP_NO_RAW)) {
183
return;
184
}
110
}
185
111
186
diff --git a/target/arm/helper.c b/target/arm/helper.c
112
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
187
index XXXXXXX..XXXXXXX 100644
113
* the CPU doesn't support TZ or this is a non-secure translation
188
--- a/target/arm/helper.c
114
* regime, because the attribute will already be non-secure.
189
+++ b/target/arm/helper.c
115
*/
190
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
116
- txattrs->secure = false;
191
* multiple times. Special registers (ie NOP/WFI) are
117
+ result->attrs.secure = false;
192
* never migratable and not even raw-accessible.
118
}
119
/* When in aarch64 mode, and BTI is enabled, remember GP in the IOTLB. */
120
if (aarch64 && guarded && cpu_isar_feature(aa64_bti, cpu)) {
121
- arm_tlb_bti_gp(txattrs) = true;
122
+ arm_tlb_bti_gp(&result->attrs) = true;
123
}
124
125
if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
126
- cacheattrs->is_s2_format = true;
127
- cacheattrs->attrs = extract32(attrs, 0, 4);
128
+ result->cacheattrs.is_s2_format = true;
129
+ result->cacheattrs.attrs = extract32(attrs, 0, 4);
130
} else {
131
/* Index into MAIR registers for cache attributes */
132
uint8_t attrindx = extract32(attrs, 0, 3);
133
uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)];
134
assert(attrindx <= 7);
135
- cacheattrs->is_s2_format = false;
136
- cacheattrs->attrs = extract64(mair, attrindx * 8, 8);
137
+ result->cacheattrs.is_s2_format = false;
138
+ result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8);
139
}
140
141
/*
142
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
143
* that case comes from TCR_ELx, which we extracted earlier.
193
*/
144
*/
194
- if ((r->type & ARM_CP_SPECIAL)) {
145
if (param.ds) {
195
+ if (r->type & ARM_CP_SPECIAL_MASK) {
146
- cacheattrs->shareability = param.sh;
196
r2->type |= ARM_CP_NO_RAW;
147
+ result->cacheattrs.shareability = param.sh;
148
} else {
149
- cacheattrs->shareability = extract32(attrs, 6, 2);
150
+ result->cacheattrs.shareability = extract32(attrs, 6, 2);
197
}
151
}
198
if (((r->crm == CP_ANY) && crm != 0) ||
152
199
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
153
- *phys_ptr = descaddr;
200
/* Check that the register definition has enough info to handle
154
- *page_size_ptr = page_size;
201
* reads and writes if they are permitted.
155
+ result->phys = descaddr;
202
*/
156
+ result->page_size = page_size;
203
- if (!(r->type & (ARM_CP_SPECIAL|ARM_CP_CONST))) {
157
return false;
204
+ if (!(r->type & (ARM_CP_SPECIAL_MASK | ARM_CP_CONST))) {
158
205
if (r->access & PL3_R) {
159
do_fault:
206
assert((r->fieldoffset ||
160
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
207
(r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1])) ||
161
cacheattrs1 = result->cacheattrs;
208
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
162
memset(result, 0, sizeof(*result));
209
index XXXXXXX..XXXXXXX 100644
163
210
--- a/target/arm/translate-a64.c
164
- ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0,
211
+++ b/target/arm/translate-a64.c
165
- &result->phys, &result->attrs,
212
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
166
- &result->prot, &result->page_size,
213
}
167
- fi, &result->cacheattrs);
214
168
+ ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx,
215
/* Handle special cases first */
169
+ is_el0, result, fi);
216
- switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) {
170
fi->s2addr = ipa;
217
+ switch (ri->type & ARM_CP_SPECIAL_MASK) {
171
218
+ case 0:
172
/* Combine the S1 and S2 perms. */
219
+ break;
173
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
220
case ARM_CP_NOP:
174
221
return;
175
if (regime_using_lpae_format(env, mmu_idx)) {
222
case ARM_CP_NZCV:
176
return get_phys_addr_lpae(env, address, access_type, mmu_idx, false,
223
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
177
- &result->phys, &result->attrs,
224
}
178
- &result->prot, &result->page_size,
225
return;
179
- fi, &result->cacheattrs);
226
default:
180
+ result, fi);
227
- break;
181
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
228
+ g_assert_not_reached();
182
return get_phys_addr_v6(env, address, access_type, mmu_idx,
229
}
183
&result->phys, &result->attrs,
230
if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) {
231
return;
232
diff --git a/target/arm/translate.c b/target/arm/translate.c
233
index XXXXXXX..XXXXXXX 100644
234
--- a/target/arm/translate.c
235
+++ b/target/arm/translate.c
236
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
237
}
238
239
/* Handle special cases first */
240
- switch (ri->type & ~(ARM_CP_FLAG_MASK & ~ARM_CP_SPECIAL)) {
241
+ switch (ri->type & ARM_CP_SPECIAL_MASK) {
242
+ case 0:
243
+ break;
244
case ARM_CP_NOP:
245
return;
246
case ARM_CP_WFI:
247
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
248
s->base.is_jmp = DISAS_WFI;
249
return;
250
default:
251
- break;
252
+ g_assert_not_reached();
253
}
254
255
if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) {
256
--
184
--
257
2.25.1
185
2.25.1
186
187
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Put most of the value writeback to the same place,
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
and improve the comment that goes with them.
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-5-richard.henderson@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20220501055028.646596-15-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
8
---
11
target/arm/helper.c | 28 ++++++++++++----------------
9
target/arm/ptw.c | 30 ++++++++++++++----------------
12
1 file changed, 12 insertions(+), 16 deletions(-)
10
1 file changed, 14 insertions(+), 16 deletions(-)
13
11
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
15
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
14
--- a/target/arm/ptw.c
17
+++ b/target/arm/helper.c
15
+++ b/target/arm/ptw.c
18
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
16
@@ -XXX,XX +XXX,XX @@ do_fault:
19
*r2 = *r;
17
20
r2->name = memcpy(r2 + 1, name, name_len);
18
static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
21
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
22
- /* Reset the secure state to the specific incoming state. This is
20
- hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
23
- * necessary as the register may have been defined with both states.
21
- target_ulong *page_size, ARMMMUFaultInfo *fi)
24
+ /*
22
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
25
+ * Update fields to match the instantiation, overwiting wildcards
23
{
26
+ * such as CP_ANY, ARM_CP_STATE_BOTH, or ARM_CP_SECSTATE_BOTH.
24
ARMCPU *cpu = env_archcpu(env);
27
*/
25
int level = 1;
28
+ r2->cp = cp;
26
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
29
+ r2->crm = crm;
27
phys_addr = (desc & 0xff000000) | (address & 0x00ffffff);
30
+ r2->opc1 = opc1;
28
phys_addr |= (uint64_t)extract32(desc, 20, 4) << 32;
31
+ r2->opc2 = opc2;
29
phys_addr |= (uint64_t)extract32(desc, 5, 4) << 36;
32
+ r2->state = state;
30
- *page_size = 0x1000000;
33
r2->secure = secstate;
31
+ result->page_size = 0x1000000;
34
+ if (opaque) {
32
} else {
35
+ r2->opaque = opaque;
33
/* Section. */
36
+ }
34
phys_addr = (desc & 0xfff00000) | (address & 0x000fffff);
37
35
- *page_size = 0x100000;
38
if (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]) {
36
+ result->page_size = 0x100000;
39
/* Register is banked (using both entries in array).
37
}
40
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
38
ap = ((desc >> 10) & 3) | ((desc >> 13) & 4);
41
#endif
39
xn = desc & (1 << 4);
40
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
41
case 1: /* 64k page. */
42
phys_addr = (desc & 0xffff0000) | (address & 0xffff);
43
xn = desc & (1 << 15);
44
- *page_size = 0x10000;
45
+ result->page_size = 0x10000;
46
break;
47
case 2: case 3: /* 4k page. */
48
phys_addr = (desc & 0xfffff000) | (address & 0xfff);
49
xn = desc & 1;
50
- *page_size = 0x1000;
51
+ result->page_size = 0x1000;
52
break;
53
default:
54
/* Never happens, but compiler isn't smart enough to tell. */
55
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
42
}
56
}
43
}
57
}
44
- if (opaque) {
58
if (domain_prot == 3) {
45
- r2->opaque = opaque;
59
- *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
46
- }
60
+ result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
47
- /* reginfo passed to helpers is correct for the actual access,
61
} else {
48
- * and is never ARM_CP_STATE_BOTH:
62
if (pxn && !regime_is_user(env, mmu_idx)) {
49
- */
63
xn = 1;
50
- r2->state = state;
64
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
51
- /* Make sure reginfo passed to helpers for wildcarded regs
65
fi->type = ARMFault_AccessFlag;
52
- * has the correct crm/opc1/opc2 for this reg, not CP_ANY:
66
goto do_fault;
53
- */
67
}
54
- r2->cp = cp;
68
- *prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1);
55
- r2->crm = crm;
69
+ result->prot = simple_ap_to_rw_prot(env, mmu_idx, ap >> 1);
56
- r2->opc1 = opc1;
70
} else {
57
- r2->opc2 = opc2;
71
- *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
58
+
72
+ result->prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
59
/* By convention, for wildcarded registers only the first
73
}
60
* entry is used for migration; the others are marked as
74
- if (*prot && !xn) {
61
* ALIAS so we don't try to transfer the register
75
- *prot |= PAGE_EXEC;
76
+ if (result->prot && !xn) {
77
+ result->prot |= PAGE_EXEC;
78
}
79
- if (!(*prot & (1 << access_type))) {
80
+ if (!(result->prot & (1 << access_type))) {
81
/* Access permission fault. */
82
fi->type = ARMFault_Permission;
83
goto do_fault;
84
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
85
* the CPU doesn't support TZ or this is a non-secure translation
86
* regime, because the attribute will already be non-secure.
87
*/
88
- attrs->secure = false;
89
+ result->attrs.secure = false;
90
}
91
- *phys_ptr = phys_addr;
92
+ result->phys = phys_addr;
93
return false;
94
do_fault:
95
fi->domain = domain;
96
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
97
result, fi);
98
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
99
return get_phys_addr_v6(env, address, access_type, mmu_idx,
100
- &result->phys, &result->attrs,
101
- &result->prot, &result->page_size, fi);
102
+ result, fi);
103
} else {
104
return get_phys_addr_v5(env, address, access_type, mmu_idx,
105
&result->phys, &result->prot,
62
--
106
--
63
2.25.1
107
2.25.1
108
109
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Remove a possible source of error by removing REGINFO_SENTINEL
4
and using ARRAY_SIZE (convinently hidden inside a macro) to
5
find the end of the set of regs being registered or modified.
6
7
The space saved by not having the extra array element reduces
8
the executable's .data.rel.ro section by about 9k.
9
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-6-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20220501055028.646596-4-richard.henderson@linaro.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
8
---
16
target/arm/cpregs.h | 53 +++++++++---------
9
target/arm/ptw.c | 25 +++++++++++--------------
17
hw/arm/pxa2xx.c | 1 -
10
1 file changed, 11 insertions(+), 14 deletions(-)
18
hw/arm/pxa2xx_pic.c | 1 -
19
hw/intc/arm_gicv3_cpuif.c | 5 --
20
hw/intc/arm_gicv3_kvm.c | 1 -
21
target/arm/cpu64.c | 1 -
22
target/arm/cpu_tcg.c | 4 --
23
target/arm/helper.c | 111 ++++++++------------------------------
24
8 files changed, 48 insertions(+), 129 deletions(-)
25
11
26
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
27
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/cpregs.h
14
--- a/target/arm/ptw.c
29
+++ b/target/arm/cpregs.h
15
+++ b/target/arm/ptw.c
30
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)
31
#define ARM_CP_NO_GDB 0x4000
17
32
#define ARM_CP_RAISES_EXC 0x8000
18
static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
33
#define ARM_CP_NEWEL 0x10000
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
34
-/* Used only as a terminator for ARMCPRegInfo lists */
20
- hwaddr *phys_ptr, int *prot,
35
-#define ARM_CP_SENTINEL 0xfffff
21
- target_ulong *page_size,
36
/* Mask of only the flag bits in a type field */
22
- ARMMMUFaultInfo *fi)
37
#define ARM_CP_FLAG_MASK 0x1f0ff
23
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
38
39
@@ -XXX,XX +XXX,XX @@ enum {
40
ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */
41
};
42
43
-/*
44
- * Return true if cptype is a valid type field. This is used to try to
45
- * catch errors where the sentinel has been accidentally left off the end
46
- * of a list of registers.
47
- */
48
-static inline bool cptype_valid(int cptype)
49
-{
50
- return ((cptype & ~ARM_CP_FLAG_MASK) == 0)
51
- || ((cptype & ARM_CP_SPECIAL) &&
52
- ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL));
53
-}
54
-
55
/*
56
* Access rights:
57
* We define bits for Read and Write access for what rev C of the v7-AR ARM ARM
58
@@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo {
59
#define CPREG_FIELD64(env, ri) \
60
(*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
61
62
-#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL }
63
+void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *reg,
64
+ void *opaque);
65
66
-void define_arm_cp_regs_with_opaque(ARMCPU *cpu,
67
- const ARMCPRegInfo *regs, void *opaque);
68
-void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
69
- const ARMCPRegInfo *regs, void *opaque);
70
-static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs)
71
-{
72
- define_arm_cp_regs_with_opaque(cpu, regs, 0);
73
-}
74
static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs)
75
{
24
{
76
- define_one_arm_cp_reg_with_opaque(cpu, regs, 0);
25
int level = 1;
77
+ define_one_arm_cp_reg_with_opaque(cpu, regs, NULL);
26
uint32_t table;
78
}
27
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
79
+
28
/* 1Mb section. */
80
+void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs,
29
phys_addr = (desc & 0xfff00000) | (address & 0x000fffff);
81
+ void *opaque, size_t len);
30
ap = (desc >> 10) & 3;
82
+
31
- *page_size = 1024 * 1024;
83
+#define define_arm_cp_regs_with_opaque(CPU, REGS, OPAQUE) \
32
+ result->page_size = 1024 * 1024;
84
+ do { \
33
} else {
85
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \
34
/* Lookup l2 entry. */
86
+ define_arm_cp_regs_with_opaque_len(CPU, REGS, OPAQUE, \
35
if (type == 1) {
87
+ ARRAY_SIZE(REGS)); \
36
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
88
+ } while (0)
37
case 1: /* 64k page. */
89
+
38
phys_addr = (desc & 0xffff0000) | (address & 0xffff);
90
+#define define_arm_cp_regs(CPU, REGS) \
39
ap = (desc >> (4 + ((address >> 13) & 6))) & 3;
91
+ define_arm_cp_regs_with_opaque(CPU, REGS, NULL)
40
- *page_size = 0x10000;
92
+
41
+ result->page_size = 0x10000;
93
const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp);
42
break;
94
43
case 2: /* 4k page. */
95
/*
44
phys_addr = (desc & 0xfffff000) | (address & 0xfff);
96
@@ -XXX,XX +XXX,XX @@ typedef struct ARMCPRegUserSpaceInfo {
45
ap = (desc >> (4 + ((address >> 9) & 6))) & 3;
97
uint64_t fixed_bits;
46
- *page_size = 0x1000;
98
} ARMCPRegUserSpaceInfo;
47
+ result->page_size = 0x1000;
99
48
break;
100
-#define REGUSERINFO_SENTINEL { .name = NULL }
49
case 3: /* 1k page, or ARMv6/XScale "extended small (4k) page" */
101
+void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len,
50
if (type == 1) {
102
+ const ARMCPRegUserSpaceInfo *mods,
51
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
103
+ size_t mods_len);
52
if (arm_feature(env, ARM_FEATURE_XSCALE)
104
53
|| arm_feature(env, ARM_FEATURE_V6)) {
105
-void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods);
54
phys_addr = (desc & 0xfffff000) | (address & 0xfff);
106
+#define modify_arm_cp_regs(REGS, MODS) \
55
- *page_size = 0x1000;
107
+ do { \
56
+ result->page_size = 0x1000;
108
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \
57
} else {
109
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(MODS) == 0); \
58
/*
110
+ modify_arm_cp_regs_with_len(REGS, ARRAY_SIZE(REGS), \
59
* UNPREDICTABLE in ARMv5; we choose to take a
111
+ MODS, ARRAY_SIZE(MODS)); \
60
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
112
+ } while (0)
61
}
113
62
} else {
114
/* CPWriteFn that can be used to implement writes-ignored behaviour */
63
phys_addr = (desc & 0xfffffc00) | (address & 0x3ff);
115
void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,
64
- *page_size = 0x400;
116
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
65
+ result->page_size = 0x400;
117
index XXXXXXX..XXXXXXX 100644
118
--- a/hw/arm/pxa2xx.c
119
+++ b/hw/arm/pxa2xx.c
120
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_cp_reginfo[] = {
121
{ .name = "PWRMODE", .cp = 14, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 0,
122
.access = PL1_RW, .type = ARM_CP_IO,
123
.readfn = arm_cp_read_zero, .writefn = pxa2xx_pwrmode_write },
124
- REGINFO_SENTINEL
125
};
126
127
static void pxa2xx_setup_cp14(PXA2xxState *s)
128
diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c
129
index XXXXXXX..XXXXXXX 100644
130
--- a/hw/arm/pxa2xx_pic.c
131
+++ b/hw/arm/pxa2xx_pic.c
132
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pxa_pic_cp_reginfo[] = {
133
REGINFO_FOR_PIC_CP("ICLR2", 8),
134
REGINFO_FOR_PIC_CP("ICFP2", 9),
135
REGINFO_FOR_PIC_CP("ICPR2", 0xa),
136
- REGINFO_SENTINEL
137
};
138
139
static const MemoryRegionOps pxa2xx_pic_ops = {
140
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
141
index XXXXXXX..XXXXXXX 100644
142
--- a/hw/intc/arm_gicv3_cpuif.c
143
+++ b/hw/intc/arm_gicv3_cpuif.c
144
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = {
145
.readfn = icc_igrpen1_el3_read,
146
.writefn = icc_igrpen1_el3_write,
147
},
148
- REGINFO_SENTINEL
149
};
150
151
static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
152
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_hcr_reginfo[] = {
153
.readfn = ich_vmcr_read,
154
.writefn = ich_vmcr_write,
155
},
156
- REGINFO_SENTINEL
157
};
158
159
static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = {
160
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr1_reginfo[] = {
161
.readfn = ich_ap_read,
162
.writefn = ich_ap_write,
163
},
164
- REGINFO_SENTINEL
165
};
166
167
static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = {
168
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_ich_apxr23_reginfo[] = {
169
.readfn = ich_ap_read,
170
.writefn = ich_ap_write,
171
},
172
- REGINFO_SENTINEL
173
};
174
175
static void gicv3_cpuif_el_change_hook(ARMCPU *cpu, void *opaque)
176
@@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s)
177
.readfn = ich_lr_read,
178
.writefn = ich_lr_write,
179
},
180
- REGINFO_SENTINEL
181
};
182
define_arm_cp_regs(cpu, lr_regset);
183
}
66
}
184
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
67
ap = (desc >> 4) & 3;
185
index XXXXXXX..XXXXXXX 100644
68
break;
186
--- a/hw/intc/arm_gicv3_kvm.c
69
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
187
+++ b/hw/intc/arm_gicv3_kvm.c
70
g_assert_not_reached();
188
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = {
189
*/
190
.resetfn = arm_gicv3_icc_reset,
191
},
192
- REGINFO_SENTINEL
193
};
194
195
/**
196
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
197
index XXXXXXX..XXXXXXX 100644
198
--- a/target/arm/cpu64.c
199
+++ b/target/arm/cpu64.c
200
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = {
201
{ .name = "L2MERRSR",
202
.cp = 15, .opc1 = 3, .crm = 15,
203
.access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
204
- REGINFO_SENTINEL
205
};
206
207
static void aarch64_a57_initfn(Object *obj)
208
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
209
index XXXXXXX..XXXXXXX 100644
210
--- a/target/arm/cpu_tcg.c
211
+++ b/target/arm/cpu_tcg.c
212
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] = {
213
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
214
{ .name = "L2AUXCR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 2,
215
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
216
- REGINFO_SENTINEL
217
};
218
219
static void cortex_a8_initfn(Object *obj)
220
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] = {
221
.access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
222
{ .name = "TLB_ATTR", .cp = 15, .crn = 15, .crm = 7, .opc1 = 5, .opc2 = 2,
223
.access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST },
224
- REGINFO_SENTINEL
225
};
226
227
static void cortex_a9_initfn(Object *obj)
228
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = {
229
#endif
230
{ .name = "L2ECTLR", .cp = 15, .crn = 9, .crm = 0, .opc1 = 1, .opc2 = 3,
231
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
232
- REGINFO_SENTINEL
233
};
234
235
static void cortex_a7_initfn(Object *obj)
236
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
237
.access = PL1_RW, .type = ARM_CP_CONST },
238
{ .name = "DCACHE_INVAL", .cp = 15, .opc1 = 0, .crn = 15, .crm = 5,
239
.opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP },
240
- REGINFO_SENTINEL
241
};
242
243
static void cortex_r5_initfn(Object *obj)
244
diff --git a/target/arm/helper.c b/target/arm/helper.c
245
index XXXXXXX..XXXXXXX 100644
246
--- a/target/arm/helper.c
247
+++ b/target/arm/helper.c
248
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = {
249
.secure = ARM_CP_SECSTATE_S,
250
.fieldoffset = offsetof(CPUARMState, cp15.contextidr_s),
251
.resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, },
252
- REGINFO_SENTINEL
253
};
254
255
static const ARMCPRegInfo not_v8_cp_reginfo[] = {
256
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = {
257
{ .name = "CACHEMAINT", .cp = 15, .crn = 7, .crm = CP_ANY,
258
.opc1 = 0, .opc2 = CP_ANY, .access = PL1_W,
259
.type = ARM_CP_NOP | ARM_CP_OVERRIDE },
260
- REGINFO_SENTINEL
261
};
262
263
static const ARMCPRegInfo not_v6_cp_reginfo[] = {
264
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v6_cp_reginfo[] = {
265
*/
266
{ .name = "WFI_v5", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = 2,
267
.access = PL1_W, .type = ARM_CP_WFI },
268
- REGINFO_SENTINEL
269
};
270
271
static const ARMCPRegInfo not_v7_cp_reginfo[] = {
272
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = {
273
.opc1 = 0, .opc2 = 0, .access = PL1_RW, .type = ARM_CP_NOP },
274
{ .name = "NMRR", .cp = 15, .crn = 10, .crm = 2,
275
.opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_NOP },
276
- REGINFO_SENTINEL
277
};
278
279
static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri,
280
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = {
281
.crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access,
282
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1),
283
.resetfn = cpacr_reset, .writefn = cpacr_write, .readfn = cpacr_read },
284
- REGINFO_SENTINEL
285
};
286
287
typedef struct pm_event {
288
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
289
{ .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3,
290
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
291
.writefn = tlbimvaa_write },
292
- REGINFO_SENTINEL
293
};
294
295
static const ARMCPRegInfo v7mp_cp_reginfo[] = {
296
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7mp_cp_reginfo[] = {
297
{ .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3,
298
.type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb,
299
.writefn = tlbimvaa_is_write },
300
- REGINFO_SENTINEL
301
};
302
303
static const ARMCPRegInfo pmovsset_cp_reginfo[] = {
304
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = {
305
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr),
306
.writefn = pmovsset_write,
307
.raw_writefn = raw_write },
308
- REGINFO_SENTINEL
309
};
310
311
static void teecr_write(CPUARMState *env, const ARMCPRegInfo *ri,
312
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo t2ee_cp_reginfo[] = {
313
{ .name = "TEEHBR", .cp = 14, .crn = 1, .crm = 0, .opc1 = 6, .opc2 = 0,
314
.access = PL0_RW, .fieldoffset = offsetof(CPUARMState, teehbr),
315
.accessfn = teehbr_access, .resetvalue = 0 },
316
- REGINFO_SENTINEL
317
};
318
319
static const ARMCPRegInfo v6k_cp_reginfo[] = {
320
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = {
321
.bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidrprw_s),
322
offsetoflow32(CPUARMState, cp15.tpidrprw_ns) },
323
.resetvalue = 0 },
324
- REGINFO_SENTINEL
325
};
326
327
#ifndef CONFIG_USER_ONLY
328
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
329
.fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_SEC].cval),
330
.writefn = gt_sec_cval_write, .raw_writefn = raw_write,
331
},
332
- REGINFO_SENTINEL
333
};
334
335
static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri,
336
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
337
.access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO,
338
.readfn = gt_virt_cnt_read,
339
},
340
- REGINFO_SENTINEL
341
};
342
343
#endif
344
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vapa_cp_reginfo[] = {
345
.access = PL1_W, .accessfn = ats_access,
346
.writefn = ats_write, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC },
347
#endif
348
- REGINFO_SENTINEL
349
};
350
351
/* Return basic MPU access permission bits. */
352
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav7_cp_reginfo[] = {
353
.fieldoffset = offsetof(CPUARMState, pmsav7.rnr[M_REG_NS]),
354
.writefn = pmsav7_rgnr_write,
355
.resetfn = arm_cp_reset_ignore },
356
- REGINFO_SENTINEL
357
};
358
359
static const ARMCPRegInfo pmsav5_cp_reginfo[] = {
360
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav5_cp_reginfo[] = {
361
{ .name = "946_PRBS7", .cp = 15, .crn = 6, .crm = 7, .opc1 = 0,
362
.opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
363
.fieldoffset = offsetof(CPUARMState, cp15.c6_region[7]) },
364
- REGINFO_SENTINEL
365
};
366
367
static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri,
368
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = {
369
.access = PL1_RW, .accessfn = access_tvm_trvm,
370
.fieldoffset = offsetof(CPUARMState, cp15.far_el[1]),
371
.resetvalue = 0, },
372
- REGINFO_SENTINEL
373
};
374
375
static const ARMCPRegInfo vmsa_cp_reginfo[] = {
376
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
377
/* No offsetoflow32 -- pass the entire TCR to writefn/raw_writefn. */
378
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.tcr_el[3]),
379
offsetof(CPUARMState, cp15.tcr_el[1])} },
380
- REGINFO_SENTINEL
381
};
382
383
/* Note that unlike TTBCR, writing to TTBCR2 does not require flushing
384
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo omap_cp_reginfo[] = {
385
{ .name = "C9", .cp = 15, .crn = 9,
386
.crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_RW,
387
.type = ARM_CP_CONST | ARM_CP_OVERRIDE, .resetvalue = 0 },
388
- REGINFO_SENTINEL
389
};
390
391
static void xscale_cpar_write(CPUARMState *env, const ARMCPRegInfo *ri,
392
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = {
393
{ .name = "XSCALE_UNLOCK_DCACHE",
394
.cp = 15, .opc1 = 0, .crn = 9, .crm = 2, .opc2 = 1,
395
.access = PL1_W, .type = ARM_CP_NOP },
396
- REGINFO_SENTINEL
397
};
398
399
static const ARMCPRegInfo dummy_c15_cp_reginfo[] = {
400
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dummy_c15_cp_reginfo[] = {
401
.access = PL1_RW,
402
.type = ARM_CP_CONST | ARM_CP_NO_RAW | ARM_CP_OVERRIDE,
403
.resetvalue = 0 },
404
- REGINFO_SENTINEL
405
};
406
407
static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = {
408
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_dirty_status_cp_reginfo[] = {
409
{ .name = "CDSR", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 6,
410
.access = PL1_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW,
411
.resetvalue = 0 },
412
- REGINFO_SENTINEL
413
};
414
415
static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = {
416
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = {
417
.access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT },
418
{ .name = "CIDCR", .cp = 15, .crm = 14, .opc1 = 0,
419
.access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT },
420
- REGINFO_SENTINEL
421
};
422
423
static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = {
424
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = {
425
{ .name = "TCI_DCACHE", .cp = 15, .crn = 7, .crm = 14, .opc1 = 0, .opc2 = 3,
426
.access = PL0_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW,
427
.resetvalue = (1 << 30) },
428
- REGINFO_SENTINEL
429
};
430
431
static const ARMCPRegInfo strongarm_cp_reginfo[] = {
432
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo strongarm_cp_reginfo[] = {
433
.crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY,
434
.access = PL1_RW, .resetvalue = 0,
435
.type = ARM_CP_CONST | ARM_CP_OVERRIDE | ARM_CP_NO_RAW },
436
- REGINFO_SENTINEL
437
};
438
439
static uint64_t midr_read(CPUARMState *env, const ARMCPRegInfo *ri)
440
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = {
441
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s),
442
offsetof(CPUARMState, cp15.ttbr1_ns) },
443
.writefn = vmsa_ttbr_write, },
444
- REGINFO_SENTINEL
445
};
446
447
static uint64_t aa64_fpcr_read(CPUARMState *env, const ARMCPRegInfo *ri)
448
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
449
.access = PL1_RW, .accessfn = access_trap_aa32s_el1,
450
.writefn = sdcr_write,
451
.fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) },
452
- REGINFO_SENTINEL
453
};
454
455
/* Used to describe the behaviour of EL2 regs when EL2 does not exist. */
456
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
457
.type = ARM_CP_CONST,
458
.cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2,
459
.access = PL2_RW, .resetvalue = 0 },
460
- REGINFO_SENTINEL
461
};
462
463
/* Ditto, but for registers which exist in ARMv8 but not v7 */
464
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = {
465
.cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
466
.access = PL2_RW,
467
.type = ARM_CP_CONST, .resetvalue = 0 },
468
- REGINFO_SENTINEL
469
};
470
471
static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
472
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
473
.cp = 15, .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3,
474
.access = PL2_RW,
475
.fieldoffset = offsetof(CPUARMState, cp15.hstr_el2) },
476
- REGINFO_SENTINEL
477
};
478
479
static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
480
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
481
.access = PL2_RW,
482
.fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2),
483
.writefn = hcr_writehigh },
484
- REGINFO_SENTINEL
485
};
486
487
static CPAccessResult sel2_access(CPUARMState *env, const ARMCPRegInfo *ri,
488
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_sec_cp_reginfo[] = {
489
.opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 2,
490
.access = PL2_RW, .accessfn = sel2_access,
491
.fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) },
492
- REGINFO_SENTINEL
493
};
494
495
static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
496
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = {
497
.opc0 = 1, .opc1 = 6, .crn = 8, .crm = 7, .opc2 = 5,
498
.access = PL3_W, .type = ARM_CP_NO_RAW,
499
.writefn = tlbi_aa64_vae3_write },
500
- REGINFO_SENTINEL
501
};
502
503
#ifndef CONFIG_USER_ONLY
504
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
505
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0,
506
.access = PL1_RW, .accessfn = access_tda,
507
.type = ARM_CP_NOP },
508
- REGINFO_SENTINEL
509
};
510
511
static const ARMCPRegInfo debug_lpae_cp_reginfo[] = {
512
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = {
513
.access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 },
514
{ .name = "DBGDSAR", .cp = 14, .crm = 2, .opc1 = 0,
515
.access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 },
516
- REGINFO_SENTINEL
517
};
518
519
/* Return the exception level to which exceptions should be taken
520
@@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu)
521
.fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]),
522
.writefn = dbgbcr_write, .raw_writefn = raw_write
523
},
524
- REGINFO_SENTINEL
525
};
526
define_arm_cp_regs(cpu, dbgregs);
527
}
528
@@ -XXX,XX +XXX,XX @@ static void define_debug_regs(ARMCPU *cpu)
529
.fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]),
530
.writefn = dbgwcr_write, .raw_writefn = raw_write
531
},
532
- REGINFO_SENTINEL
533
};
534
define_arm_cp_regs(cpu, dbgregs);
535
}
536
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
537
.type = ARM_CP_IO,
538
.readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn,
539
.raw_writefn = pmevtyper_rawwrite },
540
- REGINFO_SENTINEL
541
};
542
define_arm_cp_regs(cpu, pmev_regs);
543
g_free(pmevcntr_name);
544
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
545
.cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5,
546
.access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
547
.resetvalue = extract64(cpu->pmceid1, 32, 32) },
548
- REGINFO_SENTINEL
549
};
550
define_arm_cp_regs(cpu, v81_pmu_regs);
551
}
552
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = {
553
.opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7,
554
.access = PL1_R, .accessfn = access_lor_ns,
555
.type = ARM_CP_CONST, .resetvalue = 0 },
556
- REGINFO_SENTINEL
557
};
558
559
#ifdef TARGET_AARCH64
560
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = {
561
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3,
562
.access = PL1_RW, .accessfn = access_pauth,
563
.fieldoffset = offsetof(CPUARMState, keys.apib.hi) },
564
- REGINFO_SENTINEL
565
};
566
567
static const ARMCPRegInfo tlbirange_reginfo[] = {
568
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = {
569
.opc0 = 1, .opc1 = 6, .crn = 8, .crm = 6, .opc2 = 5,
570
.access = PL3_W, .type = ARM_CP_NO_RAW,
571
.writefn = tlbi_aa64_rvae3_write },
572
- REGINFO_SENTINEL
573
};
574
575
static const ARMCPRegInfo tlbios_reginfo[] = {
576
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = {
577
.opc0 = 1, .opc1 = 6, .crn = 8, .crm = 1, .opc2 = 5,
578
.access = PL3_W, .type = ARM_CP_NO_RAW,
579
.writefn = tlbi_aa64_vae3is_write },
580
- REGINFO_SENTINEL
581
};
582
583
static uint64_t rndr_readfn(CPUARMState *env, const ARMCPRegInfo *ri)
584
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rndr_reginfo[] = {
585
.type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END | ARM_CP_IO,
586
.opc0 = 3, .opc1 = 3, .crn = 2, .crm = 4, .opc2 = 1,
587
.access = PL0_R, .readfn = rndr_readfn },
588
- REGINFO_SENTINEL
589
};
590
591
#ifndef CONFIG_USER_ONLY
592
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpop_reg[] = {
593
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1,
594
.access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END,
595
.accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn },
596
- REGINFO_SENTINEL
597
};
598
599
static const ARMCPRegInfo dcpodp_reg[] = {
600
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpodp_reg[] = {
601
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1,
602
.access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END,
603
.accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn },
604
- REGINFO_SENTINEL
605
};
606
#endif /*CONFIG_USER_ONLY*/
607
608
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = {
609
{ .name = "DC_CIGDSW", .state = ARM_CP_STATE_AA64,
610
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 6,
611
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw },
612
- REGINFO_SENTINEL
613
};
614
615
static const ARMCPRegInfo mte_tco_ro_reginfo[] = {
616
{ .name = "TCO", .state = ARM_CP_STATE_AA64,
617
.opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7,
618
.type = ARM_CP_CONST, .access = PL0_RW, },
619
- REGINFO_SENTINEL
620
};
621
622
static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = {
623
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = {
624
.accessfn = aa64_zva_access,
625
#endif
626
},
627
- REGINFO_SENTINEL
628
};
629
630
#endif
631
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo predinv_reginfo[] = {
632
{ .name = "CPPRCTX", .state = ARM_CP_STATE_AA32,
633
.cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7,
634
.type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv },
635
- REGINFO_SENTINEL
636
};
637
638
static uint64_t ccsidr2_read(CPUARMState *env, const ARMCPRegInfo *ri)
639
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ccsidr2_reginfo[] = {
640
.access = PL1_R,
641
.accessfn = access_aa64_tid2,
642
.readfn = ccsidr2_read, .type = ARM_CP_NO_RAW },
643
- REGINFO_SENTINEL
644
};
645
646
static CPAccessResult access_aa64_tid3(CPUARMState *env, const ARMCPRegInfo *ri,
647
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = {
648
.cp = 14, .crn = 2, .crm = 0, .opc1 = 7, .opc2 = 0,
649
.accessfn = access_joscr_jmcr,
650
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
651
- REGINFO_SENTINEL
652
};
653
654
static const ARMCPRegInfo vhe_reginfo[] = {
655
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = {
656
.access = PL2_RW, .accessfn = e2h_access,
657
.writefn = gt_virt_cval_write, .raw_writefn = raw_write },
658
#endif
659
- REGINFO_SENTINEL
660
};
661
662
#ifndef CONFIG_USER_ONLY
663
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1e1_reginfo[] = {
664
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1,
665
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
666
.writefn = ats_write64 },
667
- REGINFO_SENTINEL
668
};
669
670
static const ARMCPRegInfo ats1cp_reginfo[] = {
671
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1cp_reginfo[] = {
672
.cp = 15, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1,
673
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
674
.writefn = ats_write },
675
- REGINFO_SENTINEL
676
};
677
#endif
678
679
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = {
680
.cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3,
681
.access = PL2_RW, .type = ARM_CP_CONST,
682
.resetvalue = 0 },
683
- REGINFO_SENTINEL
684
};
685
686
void register_cp_regs_for_features(ARMCPU *cpu)
687
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
688
.access = PL1_R, .type = ARM_CP_CONST,
689
.accessfn = access_aa32_tid3,
690
.resetvalue = cpu->isar.id_isar6 },
691
- REGINFO_SENTINEL
692
};
693
define_arm_cp_regs(cpu, v6_idregs);
694
define_arm_cp_regs(cpu, v6_cp_reginfo);
695
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
696
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7,
697
.access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
698
.resetvalue = cpu->pmceid1 },
699
- REGINFO_SENTINEL
700
};
701
#ifdef CONFIG_USER_ONLY
702
ARMCPRegUserSpaceInfo v8_user_idregs[] = {
703
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
704
.exported_bits = 0x000000f0ffffffff },
705
{ .name = "ID_AA64ISAR*_EL1_RESERVED",
706
.is_glob = true },
707
- REGUSERINFO_SENTINEL
708
};
709
modify_arm_cp_regs(v8_idregs, v8_user_idregs);
710
#endif
711
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
712
.access = PL2_RW,
713
.resetvalue = vmpidr_def,
714
.fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) },
715
- REGINFO_SENTINEL
716
};
717
define_arm_cp_regs(cpu, vpidr_regs);
718
define_arm_cp_regs(cpu, el2_cp_reginfo);
719
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
720
.access = PL2_RW, .accessfn = access_el3_aa32ns,
721
.type = ARM_CP_NO_RAW,
722
.writefn = arm_cp_write_ignore, .readfn = mpidr_read },
723
- REGINFO_SENTINEL
724
};
725
define_arm_cp_regs(cpu, vpidr_regs);
726
define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo);
727
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
728
.raw_writefn = raw_write, .writefn = sctlr_write,
729
.fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]),
730
.resetvalue = cpu->reset_sctlr },
731
- REGINFO_SENTINEL
732
};
733
734
define_arm_cp_regs(cpu, el3_regs);
735
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
736
{ .name = "DUMMY",
737
.cp = 15, .crn = 0, .crm = 7, .opc1 = 0, .opc2 = CP_ANY,
738
.access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
739
- REGINFO_SENTINEL
740
};
741
ARMCPRegInfo id_v8_midr_cp_reginfo[] = {
742
{ .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH,
743
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
744
.access = PL1_R,
745
.accessfn = access_aa64_tid1,
746
.type = ARM_CP_CONST, .resetvalue = cpu->revidr },
747
- REGINFO_SENTINEL
748
};
749
ARMCPRegInfo id_cp_reginfo[] = {
750
/* These are common to v8 and pre-v8 */
751
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
752
.access = PL1_R,
753
.accessfn = access_aa32_tid1,
754
.type = ARM_CP_CONST, .resetvalue = 0 },
755
- REGINFO_SENTINEL
756
};
757
/* TLBTR is specific to VMSA */
758
ARMCPRegInfo id_tlbtr_reginfo = {
759
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
760
{ .name = "MIDR_EL1",
761
.exported_bits = 0x00000000ffffffff },
762
{ .name = "REVIDR_EL1" },
763
- REGUSERINFO_SENTINEL
764
};
765
modify_arm_cp_regs(id_v8_midr_cp_reginfo, id_v8_user_midr_cp_reginfo);
766
#endif
767
if (arm_feature(env, ARM_FEATURE_OMAPCP) ||
768
arm_feature(env, ARM_FEATURE_STRONGARM)) {
769
- ARMCPRegInfo *r;
770
+ size_t i;
771
/* Register the blanket "writes ignored" value first to cover the
772
* whole space. Then update the specific ID registers to allow write
773
* access, so that they ignore writes rather than causing them to
774
* UNDEF.
775
*/
776
define_one_arm_cp_reg(cpu, &crn0_wi_reginfo);
777
- for (r = id_pre_v8_midr_cp_reginfo;
778
- r->type != ARM_CP_SENTINEL; r++) {
779
- r->access = PL1_RW;
780
+ for (i = 0; i < ARRAY_SIZE(id_pre_v8_midr_cp_reginfo); ++i) {
781
+ id_pre_v8_midr_cp_reginfo[i].access = PL1_RW;
782
}
783
- for (r = id_cp_reginfo; r->type != ARM_CP_SENTINEL; r++) {
784
- r->access = PL1_RW;
785
+ for (i = 0; i < ARRAY_SIZE(id_cp_reginfo); ++i) {
786
+ id_cp_reginfo[i].access = PL1_RW;
787
}
788
id_mpuir_reginfo.access = PL1_RW;
789
id_tlbtr_reginfo.access = PL1_RW;
790
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
791
{ .name = "MPIDR_EL1", .state = ARM_CP_STATE_BOTH,
792
.opc0 = 3, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 5,
793
.access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW },
794
- REGINFO_SENTINEL
795
};
796
#ifdef CONFIG_USER_ONLY
797
ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = {
798
{ .name = "MPIDR_EL1",
799
.fixed_bits = 0x0000000080000000 },
800
- REGUSERINFO_SENTINEL
801
};
802
modify_arm_cp_regs(mpidr_cp_reginfo, mpidr_user_cp_reginfo);
803
#endif
804
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
805
.opc0 = 3, .opc1 = 6, .crn = 1, .crm = 0, .opc2 = 1,
806
.access = PL3_RW, .type = ARM_CP_CONST,
807
.resetvalue = 0 },
808
- REGINFO_SENTINEL
809
};
810
define_arm_cp_regs(cpu, auxcr_reginfo);
811
if (cpu_isar_feature(aa32_ac2, cpu)) {
812
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
813
.type = ARM_CP_CONST,
814
.opc0 = 3, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 0,
815
.access = PL1_R, .resetvalue = cpu->reset_cbar },
816
- REGINFO_SENTINEL
817
};
818
/* We don't implement a r/w 64 bit CBAR currently */
819
assert(arm_feature(env, ARM_FEATURE_CBAR_RO));
820
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
821
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s),
822
offsetof(CPUARMState, cp15.vbar_ns) },
823
.resetvalue = 0 },
824
- REGINFO_SENTINEL
825
};
826
define_arm_cp_regs(cpu, vbar_cp_reginfo);
827
}
828
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
829
r->writefn);
830
}
71
}
831
}
72
}
832
- /* Bad type field probably means missing sentinel at end of reg list */
73
- *prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
833
- assert(cptype_valid(r->type));
74
- *prot |= *prot ? PAGE_EXEC : 0;
834
+
75
- if (!(*prot & (1 << access_type))) {
835
for (crm = crmmin; crm <= crmmax; crm++) {
76
+ result->prot = ap_to_rw_prot(env, mmu_idx, ap, domain_prot);
836
for (opc1 = opc1min; opc1 <= opc1max; opc1++) {
77
+ result->prot |= result->prot ? PAGE_EXEC : 0;
837
for (opc2 = opc2min; opc2 <= opc2max; opc2++) {
78
+ if (!(result->prot & (1 << access_type))) {
838
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
79
/* Access permission fault. */
80
fi->type = ARMFault_Permission;
81
goto do_fault;
82
}
83
- *phys_ptr = phys_addr;
84
+ result->phys = phys_addr;
85
return false;
86
do_fault:
87
fi->domain = domain;
88
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
89
result, fi);
90
} else {
91
return get_phys_addr_v5(env, address, access_type, mmu_idx,
92
- &result->phys, &result->prot,
93
- &result->page_size, fi);
94
+ result, fi);
839
}
95
}
840
}
96
}
841
97
842
-void define_arm_cp_regs_with_opaque(ARMCPU *cpu,
843
- const ARMCPRegInfo *regs, void *opaque)
844
+/* Define a whole list of registers */
845
+void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs,
846
+ void *opaque, size_t len)
847
{
848
- /* Define a whole list of registers */
849
- const ARMCPRegInfo *r;
850
- for (r = regs; r->type != ARM_CP_SENTINEL; r++) {
851
- define_one_arm_cp_reg_with_opaque(cpu, r, opaque);
852
+ size_t i;
853
+ for (i = 0; i < len; ++i) {
854
+ define_one_arm_cp_reg_with_opaque(cpu, regs + i, opaque);
855
}
856
}
857
858
@@ -XXX,XX +XXX,XX @@ void define_arm_cp_regs_with_opaque(ARMCPU *cpu,
859
* user-space cannot alter any values and dynamic values pertaining to
860
* execution state are hidden from user space view anyway.
861
*/
862
-void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods)
863
+void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len,
864
+ const ARMCPRegUserSpaceInfo *mods,
865
+ size_t mods_len)
866
{
867
- const ARMCPRegUserSpaceInfo *m;
868
- ARMCPRegInfo *r;
869
-
870
- for (m = mods; m->name; m++) {
871
+ for (size_t mi = 0; mi < mods_len; ++mi) {
872
+ const ARMCPRegUserSpaceInfo *m = mods + mi;
873
GPatternSpec *pat = NULL;
874
+
875
if (m->is_glob) {
876
pat = g_pattern_spec_new(m->name);
877
}
878
- for (r = regs; r->type != ARM_CP_SENTINEL; r++) {
879
+ for (size_t ri = 0; ri < regs_len; ++ri) {
880
+ ARMCPRegInfo *r = regs + ri;
881
+
882
if (pat && g_pattern_match_string(pat, r->name)) {
883
r->type = ARM_CP_CONST;
884
r->access = PL0U_R;
885
--
98
--
886
2.25.1
99
2.25.1
887
100
888
101
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-7-richard.henderson@linaro.org
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220501055028.646596-24-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
---
8
target/arm/cpu.h | 15 +++++++++++++++
9
target/arm/ptw.c | 24 ++++++++++++------------
9
1 file changed, 15 insertions(+)
10
1 file changed, 12 insertions(+), 12 deletions(-)
10
11
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
12
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/cpu.h
14
--- a/target/arm/ptw.c
14
+++ b/target/arm/cpu.h
15
+++ b/target/arm/ptw.c
15
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_ssbs(const ARMISARegisters *id)
16
@@ -XXX,XX +XXX,XX @@ do_fault:
16
return FIELD_EX32(id->id_pfr2, ID_PFR2, SSBS) != 0;
17
18
static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
20
- hwaddr *phys_ptr, int *prot,
21
+ GetPhysAddrResult *result,
22
ARMMMUFaultInfo *fi)
23
{
24
int n;
25
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
26
27
if (regime_translation_disabled(env, mmu_idx)) {
28
/* MPU disabled. */
29
- *phys_ptr = address;
30
- *prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
31
+ result->phys = address;
32
+ result->prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
33
return false;
34
}
35
36
- *phys_ptr = address;
37
+ result->phys = address;
38
for (n = 7; n >= 0; n--) {
39
base = env->cp15.c6_region[n];
40
if ((base & 1) == 0) {
41
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
42
fi->level = 1;
43
return true;
44
}
45
- *prot = PAGE_READ | PAGE_WRITE;
46
+ result->prot = PAGE_READ | PAGE_WRITE;
47
break;
48
case 2:
49
- *prot = PAGE_READ;
50
+ result->prot = PAGE_READ;
51
if (!is_user) {
52
- *prot |= PAGE_WRITE;
53
+ result->prot |= PAGE_WRITE;
54
}
55
break;
56
case 3:
57
- *prot = PAGE_READ | PAGE_WRITE;
58
+ result->prot = PAGE_READ | PAGE_WRITE;
59
break;
60
case 5:
61
if (is_user) {
62
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
63
fi->level = 1;
64
return true;
65
}
66
- *prot = PAGE_READ;
67
+ result->prot = PAGE_READ;
68
break;
69
case 6:
70
- *prot = PAGE_READ;
71
+ result->prot = PAGE_READ;
72
break;
73
default:
74
/* Bad permission. */
75
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
76
fi->level = 1;
77
return true;
78
}
79
- *prot |= PAGE_EXEC;
80
+ result->prot |= PAGE_EXEC;
81
return false;
17
}
82
}
18
83
19
+static inline bool isar_feature_aa32_debugv8p2(const ARMISARegisters *id)
84
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
20
+{
85
} else {
21
+ return FIELD_EX32(id->id_dfr0, ID_DFR0, COPDBG) >= 8;
86
/* Pre-v7 MPU */
22
+}
87
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
23
+
88
- &result->phys, &result->prot, fi);
24
/*
89
+ result, fi);
25
* 64-bit feature tests via id registers.
90
}
26
*/
91
qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32
27
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id)
92
" mmu_idx %u -> %s (prot %c%c%c)\n",
28
return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0;
29
}
30
31
+static inline bool isar_feature_aa64_debugv8p2(const ARMISARegisters *id)
32
+{
33
+ return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, DEBUGVER) >= 8;
34
+}
35
+
36
static inline bool isar_feature_aa64_sve2(const ARMISARegisters *id)
37
{
38
return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SVEVER) != 0;
39
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id)
40
return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id);
41
}
42
43
+static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id)
44
+{
45
+ return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id);
46
+}
47
+
48
/*
49
* Forward to the above feature tests given an ARMCPU pointer.
50
*/
51
--
93
--
52
2.25.1
94
2.25.1
95
96
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Since e03b56863d2bc, our host endian indicator is unconditionally
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
set, which means that we can use a normal C condition.
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-8-richard.henderson@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20220501055028.646596-20-richard.henderson@linaro.org
9
[PMM: quote correct git hash in commit message]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
8
---
12
target/arm/helper.c | 9 +++------
9
target/arm/ptw.c | 36 +++++++++++++++++-------------------
13
1 file changed, 3 insertions(+), 6 deletions(-)
10
1 file changed, 17 insertions(+), 19 deletions(-)
14
11
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
14
--- a/target/arm/ptw.c
18
+++ b/target/arm/helper.c
15
+++ b/target/arm/ptw.c
19
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
16
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
20
r2->type |= ARM_CP_ALIAS;
17
18
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
20
- hwaddr *phys_ptr, int *prot,
21
- target_ulong *page_size,
22
+ GetPhysAddrResult *result,
23
ARMMMUFaultInfo *fi)
24
{
25
ARMCPU *cpu = env_archcpu(env);
26
int n;
27
bool is_user = regime_is_user(env, mmu_idx);
28
29
- *phys_ptr = address;
30
- *page_size = TARGET_PAGE_SIZE;
31
- *prot = 0;
32
+ result->phys = address;
33
+ result->page_size = TARGET_PAGE_SIZE;
34
+ result->prot = 0;
35
36
if (regime_translation_disabled(env, mmu_idx) ||
37
m_is_ppb_region(env, address)) {
38
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
39
* which always does a direct read using address_space_ldl(), rather
40
* than going via this function, so we don't need to check that here.
41
*/
42
- get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
43
+ get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
44
} else { /* MPU enabled */
45
for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
46
/* region search */
47
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
48
if (ranges_overlap(base, rmask,
49
address & TARGET_PAGE_MASK,
50
TARGET_PAGE_SIZE)) {
51
- *page_size = 1;
52
+ result->page_size = 1;
53
}
54
continue;
55
}
56
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
57
continue;
58
}
59
if (rsize < TARGET_PAGE_BITS) {
60
- *page_size = 1 << rsize;
61
+ result->page_size = 1 << rsize;
62
}
63
break;
21
}
64
}
22
65
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
23
- if (r->state == ARM_CP_STATE_BOTH) {
66
fi->type = ARMFault_Background;
24
-#if HOST_BIG_ENDIAN
67
return true;
25
- if (r2->fieldoffset) {
68
}
26
- r2->fieldoffset += sizeof(uint32_t);
69
- get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
27
- }
70
+ get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
28
-#endif
71
} else { /* a MPU hit! */
29
+ if (HOST_BIG_ENDIAN &&
72
uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3);
30
+ r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) {
73
uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1);
31
+ r2->fieldoffset += sizeof(uint32_t);
74
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
75
case 5:
76
break; /* no access */
77
case 3:
78
- *prot |= PAGE_WRITE;
79
+ result->prot |= PAGE_WRITE;
80
/* fall through */
81
case 2:
82
case 6:
83
- *prot |= PAGE_READ | PAGE_EXEC;
84
+ result->prot |= PAGE_READ | PAGE_EXEC;
85
break;
86
case 7:
87
/* for v7M, same as 6; for R profile a reserved value */
88
if (arm_feature(env, ARM_FEATURE_M)) {
89
- *prot |= PAGE_READ | PAGE_EXEC;
90
+ result->prot |= PAGE_READ | PAGE_EXEC;
91
break;
92
}
93
/* fall through */
94
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
95
case 1:
96
case 2:
97
case 3:
98
- *prot |= PAGE_WRITE;
99
+ result->prot |= PAGE_WRITE;
100
/* fall through */
101
case 5:
102
case 6:
103
- *prot |= PAGE_READ | PAGE_EXEC;
104
+ result->prot |= PAGE_READ | PAGE_EXEC;
105
break;
106
case 7:
107
/* for v7M, same as 6; for R profile a reserved value */
108
if (arm_feature(env, ARM_FEATURE_M)) {
109
- *prot |= PAGE_READ | PAGE_EXEC;
110
+ result->prot |= PAGE_READ | PAGE_EXEC;
111
break;
112
}
113
/* fall through */
114
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
115
116
/* execute never */
117
if (xn) {
118
- *prot &= ~PAGE_EXEC;
119
+ result->prot &= ~PAGE_EXEC;
120
}
32
}
121
}
33
}
122
}
34
123
124
fi->type = ARMFault_Permission;
125
fi->level = 1;
126
- return !(*prot & (1 << access_type));
127
+ return !(result->prot & (1 << access_type));
128
}
129
130
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
131
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
132
} else if (arm_feature(env, ARM_FEATURE_V7)) {
133
/* PMSAv7 */
134
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
135
- &result->phys, &result->prot,
136
- &result->page_size, fi);
137
+ result, fi);
138
} else {
139
/* Pre-v7 MPU */
140
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
35
--
141
--
36
2.25.1
142
2.25.1
143
144
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Move the computation of key to the top of the function.
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Hoist the resolution of cp as well, as an input to the
5
computation of key.
6
7
This will be required by a subsequent patch.
8
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-9-richard.henderson@linaro.org
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20220501055028.646596-14-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
8
---
14
target/arm/helper.c | 49 +++++++++++++++++++++++++--------------------
9
target/arm/ptw.c | 28 ++++++++++++++--------------
15
1 file changed, 27 insertions(+), 22 deletions(-)
10
1 file changed, 14 insertions(+), 14 deletions(-)
16
11
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
18
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
14
--- a/target/arm/ptw.c
20
+++ b/target/arm/helper.c
15
+++ b/target/arm/ptw.c
21
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
16
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
22
ARMCPRegInfo *r2;
17
23
int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
18
static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
24
int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0;
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
25
+ int cp = r->cp;
20
- hwaddr *phys_ptr, MemTxAttrs *txattrs,
26
size_t name_len;
21
- int *prot, target_ulong *page_size,
27
22
+ GetPhysAddrResult *result,
28
+ switch (state) {
23
ARMMMUFaultInfo *fi)
29
+ case ARM_CP_STATE_AA32:
24
{
30
+ /* We assume it is a cp15 register if the .cp field is left unset. */
25
uint32_t secure = regime_is_secure(env, mmu_idx);
31
+ if (cp == 0 && r->state == ARM_CP_STATE_BOTH) {
26
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
32
+ cp = 15;
27
} else {
33
+ }
28
fi->type = ARMFault_QEMU_SFault;
34
+ key = ENCODE_CP_REG(cp, is64, ns, r->crn, crm, opc1, opc2);
29
}
35
+ break;
30
- *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE;
36
+ case ARM_CP_STATE_AA64:
31
- *phys_ptr = address;
37
+ /*
32
- *prot = 0;
38
+ * To allow abbreviation of ARMCPRegInfo definitions, we treat
33
+ result->page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE;
39
+ * cp == 0 as equivalent to the value for "standard guest-visible
34
+ result->phys = address;
40
+ * sysreg". STATE_BOTH definitions are also always "standard sysreg"
35
+ result->prot = 0;
41
+ * in their AArch64 view (the .cp value may be non-zero for the
36
return true;
42
+ * benefit of the AArch32 view).
37
}
43
+ */
38
} else {
44
+ if (cp == 0 || r->state == ARM_CP_STATE_BOTH) {
39
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
45
+ cp = CP_REG_ARM64_SYSREG_CP;
40
* might downgrade a secure access to nonsecure.
46
+ }
41
*/
47
+ key = ENCODE_AA64_CP_REG(cp, r->crn, crm, r->opc0, opc1, opc2);
42
if (sattrs.ns) {
48
+ break;
43
- txattrs->secure = false;
49
+ default:
44
+ result->attrs.secure = false;
50
+ g_assert_not_reached();
45
} else if (!secure) {
51
+ }
46
/*
52
+
47
* NS access to S memory must fault.
53
/* Combine cpreg and name into one allocation. */
48
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
54
name_len = strlen(name) + 1;
49
* for M_FAKE_FSR_SFAULT in arm_v7m_cpu_do_interrupt().
55
r2 = g_malloc(sizeof(*r2) + name_len);
50
*/
56
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
51
fi->type = ARMFault_QEMU_SFault;
57
}
52
- *page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE;
58
53
- *phys_ptr = address;
59
if (r->state == ARM_CP_STATE_BOTH) {
54
- *prot = 0;
60
- /* We assume it is a cp15 register if the .cp field is left unset.
55
+ result->page_size = sattrs.subpage ? 1 : TARGET_PAGE_SIZE;
61
- */
56
+ result->phys = address;
62
- if (r2->cp == 0) {
57
+ result->prot = 0;
63
- r2->cp = 15;
58
return true;
64
- }
59
}
65
-
66
#if HOST_BIG_ENDIAN
67
if (r2->fieldoffset) {
68
r2->fieldoffset += sizeof(uint32_t);
69
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
70
#endif
71
}
60
}
72
}
61
}
73
- if (state == ARM_CP_STATE_AA64) {
62
74
- /* To allow abbreviation of ARMCPRegInfo
63
- ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr,
75
- * definitions, we treat cp == 0 as equivalent to
64
- txattrs, prot, &mpu_is_subpage, fi, NULL);
76
- * the value for "standard guest-visible sysreg".
65
- *page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
77
- * STATE_BOTH definitions are also always "standard
66
+ ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
78
- * sysreg" in their AArch64 view (the .cp value may
67
+ &result->phys, &result->attrs, &result->prot,
79
- * be non-zero for the benefit of the AArch32 view).
68
+ &mpu_is_subpage, fi, NULL);
80
- */
69
+ result->page_size =
81
- if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) {
70
+ sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
82
- r2->cp = CP_REG_ARM64_SYSREG_CP;
71
return ret;
83
- }
72
}
84
- key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm,
73
85
- r2->opc0, opc1, opc2);
74
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
86
- } else {
75
if (arm_feature(env, ARM_FEATURE_V8)) {
87
- key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2);
76
/* PMSAv8 */
88
- }
77
ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx,
89
if (opaque) {
78
- &result->phys, &result->attrs,
90
r2->opaque = opaque;
79
- &result->prot, &result->page_size, fi);
91
}
80
+ result, fi);
92
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
81
} else if (arm_feature(env, ARM_FEATURE_V7)) {
93
/* Make sure reginfo passed to helpers for wildcarded regs
82
/* PMSAv7 */
94
* has the correct crm/opc1/opc2 for this reg, not CP_ANY:
83
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
95
*/
96
+ r2->cp = cp;
97
r2->crm = crm;
98
r2->opc1 = opc1;
99
r2->opc2 = opc2;
100
--
84
--
101
2.25.1
85
2.25.1
86
87
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Cast the uint32_t key into a gpointer directly, which
3
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
allows us to avoid allocating storage for each key.
5
6
Use g_hash_table_lookup when we already have a gpointer
7
(e.g. for callbacks like count_cpreg), or when using
8
get_arm_cp_reginfo would require casting away const.
9
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220822152741.1617527-10-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20220501055028.646596-12-richard.henderson@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
8
---
15
target/arm/cpu.c | 4 ++--
9
target/arm/internals.h | 11 +++++------
16
target/arm/gdbstub.c | 2 +-
10
target/arm/m_helper.c | 16 +++++++---------
17
target/arm/helper.c | 41 ++++++++++++++++++-----------------------
11
target/arm/ptw.c | 20 +++++++++-----------
18
3 files changed, 21 insertions(+), 26 deletions(-)
12
3 files changed, 21 insertions(+), 26 deletions(-)
19
13
20
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
14
diff --git a/target/arm/internals.h b/target/arm/internals.h
21
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.c
16
--- a/target/arm/internals.h
23
+++ b/target/arm/cpu.c
17
+++ b/target/arm/internals.h
24
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj)
18
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
25
ARMCPU *cpu = ARM_CPU(obj);
19
MMUAccessType access_type, ARMMMUIdx mmu_idx,
26
20
V8M_SAttributes *sattrs);
27
cpu_set_cpustate_pointers(cpu);
21
28
- cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
22
-bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
29
- g_free, cpreg_hashtable_data_destroy);
23
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
30
+ cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal,
24
- hwaddr *phys_ptr, MemTxAttrs *txattrs,
31
+ NULL, cpreg_hashtable_data_destroy);
25
- int *prot, bool *is_subpage,
32
26
- ARMMMUFaultInfo *fi, uint32_t *mregion);
33
QLIST_INIT(&cpu->pre_el_change_hooks);
27
-
34
QLIST_INIT(&cpu->el_change_hooks);
28
/* Cacheability and shareability attributes for a memory access */
35
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
29
typedef struct ARMCacheAttrs {
30
/*
31
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
32
GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
33
__attribute__((nonnull));
34
35
+bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
36
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
37
+ GetPhysAddrResult *result, bool *is_subpage,
38
+ ARMMMUFaultInfo *fi, uint32_t *mregion);
39
+
40
void arm_log_exception(CPUState *cs);
41
42
#endif /* !CONFIG_USER_ONLY */
43
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
36
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/gdbstub.c
45
--- a/target/arm/m_helper.c
38
+++ b/target/arm/gdbstub.c
46
+++ b/target/arm/m_helper.c
39
@@ -XXX,XX +XXX,XX @@ static void arm_gen_one_xml_sysreg_tag(GString *s, DynamicGDBXMLInfo *dyn_xml,
47
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
40
static void arm_register_sysreg_for_xml(gpointer key, gpointer value,
48
V8M_SAttributes sattrs = {};
41
gpointer p)
49
uint32_t tt_resp;
50
bool r, rw, nsr, nsrw, mrvalid;
51
- int prot;
52
- ARMMMUFaultInfo fi = {};
53
- MemTxAttrs attrs = {};
54
- hwaddr phys_addr;
55
ARMMMUIdx mmu_idx;
56
uint32_t mregion;
57
bool targetpriv;
58
bool targetsec = env->v7m.secure;
59
- bool is_subpage;
60
61
/*
62
* Work out what the security state and privilege level we're
63
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
64
* inspecting the other MPU state.
65
*/
66
if (arm_current_el(env) != 0 || alt) {
67
+ GetPhysAddrResult res = {};
68
+ ARMMMUFaultInfo fi = {};
69
+ bool is_subpage;
70
+
71
/* We can ignore the return value as prot is always set */
72
pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
73
- &phys_addr, &attrs, &prot, &is_subpage,
74
- &fi, &mregion);
75
+ &res, &is_subpage, &fi, &mregion);
76
if (mregion == -1) {
77
mrvalid = false;
78
mregion = 0;
79
} else {
80
mrvalid = true;
81
}
82
- r = prot & PAGE_READ;
83
- rw = prot & PAGE_WRITE;
84
+ r = res.prot & PAGE_READ;
85
+ rw = res.prot & PAGE_WRITE;
86
} else {
87
r = false;
88
rw = false;
89
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
90
index XXXXXXX..XXXXXXX 100644
91
--- a/target/arm/ptw.c
92
+++ b/target/arm/ptw.c
93
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
94
95
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
96
MMUAccessType access_type, ARMMMUIdx mmu_idx,
97
- hwaddr *phys_ptr, MemTxAttrs *txattrs,
98
- int *prot, bool *is_subpage,
99
+ GetPhysAddrResult *result, bool *is_subpage,
100
ARMMMUFaultInfo *fi, uint32_t *mregion)
42
{
101
{
43
- uint32_t ri_key = *(uint32_t *)key;
102
/*
44
+ uint32_t ri_key = (uintptr_t)key;
103
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
45
ARMCPRegInfo *ri = value;
104
uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1);
46
RegisterSysregXmlParam *param = (RegisterSysregXmlParam *)p;
105
47
GString *s = param->s;
106
*is_subpage = false;
48
diff --git a/target/arm/helper.c b/target/arm/helper.c
107
- *phys_ptr = address;
49
index XXXXXXX..XXXXXXX 100644
108
- *prot = 0;
50
--- a/target/arm/helper.c
109
+ result->phys = address;
51
+++ b/target/arm/helper.c
110
+ result->prot = 0;
52
@@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu)
111
if (mregion) {
53
static void add_cpreg_to_list(gpointer key, gpointer opaque)
112
*mregion = -1;
54
{
113
}
55
ARMCPU *cpu = opaque;
114
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
56
- uint64_t regidx;
115
57
- const ARMCPRegInfo *ri;
116
if (matchregion == -1) {
58
-
117
/* hit using the background region */
59
- regidx = *(uint32_t *)key;
118
- get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
60
- ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
119
+ get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->prot);
61
+ uint32_t regidx = (uintptr_t)key;
120
} else {
62
+ const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
121
uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2);
63
122
uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1);
64
if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) {
123
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
65
cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx);
124
xn = 1;
66
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_list(gpointer key, gpointer opaque)
67
static void count_cpreg(gpointer key, gpointer opaque)
68
{
69
ARMCPU *cpu = opaque;
70
- uint64_t regidx;
71
const ARMCPRegInfo *ri;
72
73
- regidx = *(uint32_t *)key;
74
- ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
75
+ ri = g_hash_table_lookup(cpu->cp_regs, key);
76
77
if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) {
78
cpu->cpreg_array_len++;
79
@@ -XXX,XX +XXX,XX @@ static void count_cpreg(gpointer key, gpointer opaque)
80
81
static gint cpreg_key_compare(gconstpointer a, gconstpointer b)
82
{
83
- uint64_t aidx = cpreg_to_kvm_id(*(uint32_t *)a);
84
- uint64_t bidx = cpreg_to_kvm_id(*(uint32_t *)b);
85
+ uint64_t aidx = cpreg_to_kvm_id((uintptr_t)a);
86
+ uint64_t bidx = cpreg_to_kvm_id((uintptr_t)b);
87
88
if (aidx > bidx) {
89
return 1;
90
@@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu)
91
for (i = 0; i < ARRAY_SIZE(aliases); i++) {
92
const struct E2HAlias *a = &aliases[i];
93
ARMCPRegInfo *src_reg, *dst_reg, *new_reg;
94
- uint32_t *new_key;
95
bool ok;
96
97
if (a->feature && !a->feature(&cpu->isar)) {
98
continue;
99
}
125
}
100
126
101
- src_reg = g_hash_table_lookup(cpu->cp_regs, &a->src_key);
127
- *prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
102
- dst_reg = g_hash_table_lookup(cpu->cp_regs, &a->dst_key);
128
- if (*prot && !xn && !(pxn && !is_user)) {
103
+ src_reg = g_hash_table_lookup(cpu->cp_regs,
129
- *prot |= PAGE_EXEC;
104
+ (gpointer)(uintptr_t)a->src_key);
130
+ result->prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
105
+ dst_reg = g_hash_table_lookup(cpu->cp_regs,
131
+ if (result->prot && !xn && !(pxn && !is_user)) {
106
+ (gpointer)(uintptr_t)a->dst_key);
132
+ result->prot |= PAGE_EXEC;
107
g_assert(src_reg != NULL);
108
g_assert(dst_reg != NULL);
109
110
@@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu)
111
112
/* Create alias before redirection so we dup the right data. */
113
new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo));
114
- new_key = g_memdup(&a->new_key, sizeof(uint32_t));
115
116
new_reg->name = a->new_name;
117
new_reg->type |= ARM_CP_ALIAS;
118
/* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */
119
new_reg->access &= PL2_RW | PL3_RW;
120
121
- ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg);
122
+ ok = g_hash_table_insert(cpu->cp_regs,
123
+ (gpointer)(uintptr_t)a->new_key, new_reg);
124
g_assert(ok);
125
126
src_reg->opaque = dst_reg;
127
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
128
/* Private utility function for define_one_arm_cp_reg_with_opaque():
129
* add a single reginfo struct to the hash table.
130
*/
131
- uint32_t *key = g_new(uint32_t, 1);
132
+ uint32_t key;
133
ARMCPRegInfo *r2 = g_memdup(r, sizeof(ARMCPRegInfo));
134
int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
135
int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0;
136
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
137
if (r->cp == 0 || r->state == ARM_CP_STATE_BOTH) {
138
r2->cp = CP_REG_ARM64_SYSREG_CP;
139
}
133
}
140
- *key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm,
134
/*
141
- r2->opc0, opc1, opc2);
135
* We don't need to look the attribute up in the MAIR0/MAIR1
142
+ key = ENCODE_AA64_CP_REG(r2->cp, r2->crn, crm,
136
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
143
+ r2->opc0, opc1, opc2);
137
144
} else {
138
fi->type = ARMFault_Permission;
145
- *key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2);
139
fi->level = 1;
146
+ key = ENCODE_CP_REG(r2->cp, is64, ns, r2->crn, crm, opc1, opc2);
140
- return !(*prot & (1 << access_type));
141
+ return !(result->prot & (1 << access_type));
142
}
143
144
static bool v8m_is_sau_exempt(CPUARMState *env,
145
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
147
}
146
}
148
if (opaque) {
147
149
r2->opaque = opaque;
148
ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
150
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
149
- &result->phys, &result->attrs, &result->prot,
151
* requested.
150
- &mpu_is_subpage, fi, NULL);
152
*/
151
+ result, &mpu_is_subpage, fi, NULL);
153
if (!(r->type & ARM_CP_OVERRIDE)) {
152
result->page_size =
154
- ARMCPRegInfo *oldreg;
153
sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
155
- oldreg = g_hash_table_lookup(cpu->cp_regs, key);
154
return ret;
156
+ const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key);
157
if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {
158
fprintf(stderr, "Register redefined: cp=%d %d bit "
159
"crn=%d crm=%d opc1=%d opc2=%d, "
160
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
161
g_assert_not_reached();
162
}
163
}
164
- g_hash_table_insert(cpu->cp_regs, key, r2);
165
+ g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2);
166
}
167
168
169
@@ -XXX,XX +XXX,XX @@ void modify_arm_cp_regs_with_len(ARMCPRegInfo *regs, size_t regs_len,
170
171
const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp)
172
{
173
- return g_hash_table_lookup(cpregs, &encoded_cp);
174
+ return g_hash_table_lookup(cpregs, (gpointer)(uintptr_t)encoded_cp);
175
}
176
177
void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,
178
--
155
--
179
2.25.1
156
2.25.1
157
158
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Perform the override check early, so that it is still done
3
This can be made redundant with result->page_size, by moving the basic
4
even when we decide to discard an unreachable cpreg.
4
set of page_size from get_phys_addr_pmsav8. We still need to overwrite
5
5
page_size when v8m_security_lookup signals a subpage.
6
Use assert not printf+abort.
7
6
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-11-richard.henderson@linaro.org
9
[PMM: Update a comment that used to refer to is_subpage]
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20220501055028.646596-18-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
12
---
13
target/arm/helper.c | 22 ++++++++--------------
13
target/arm/internals.h | 4 ++--
14
1 file changed, 8 insertions(+), 14 deletions(-)
14
target/arm/m_helper.c | 3 +--
15
target/arm/ptw.c | 23 ++++++++++++-----------
16
3 files changed, 15 insertions(+), 15 deletions(-)
15
17
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper.c
20
--- a/target/arm/internals.h
19
+++ b/target/arm/helper.c
21
+++ b/target/arm/internals.h
20
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
22
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
21
g_assert_not_reached();
23
24
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
25
MMUAccessType access_type, ARMMMUIdx mmu_idx,
26
- GetPhysAddrResult *result, bool *is_subpage,
27
- ARMMMUFaultInfo *fi, uint32_t *mregion);
28
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi,
29
+ uint32_t *mregion);
30
31
void arm_log_exception(CPUState *cs);
32
33
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/m_helper.c
36
+++ b/target/arm/m_helper.c
37
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
38
if (arm_current_el(env) != 0 || alt) {
39
GetPhysAddrResult res = {};
40
ARMMMUFaultInfo fi = {};
41
- bool is_subpage;
42
43
/* We can ignore the return value as prot is always set */
44
pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
45
- &res, &is_subpage, &fi, &mregion);
46
+ &res, &fi, &mregion);
47
if (mregion == -1) {
48
mrvalid = false;
49
mregion = 0;
50
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/ptw.c
53
+++ b/target/arm/ptw.c
54
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
55
56
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
57
MMUAccessType access_type, ARMMMUIdx mmu_idx,
58
- GetPhysAddrResult *result, bool *is_subpage,
59
- ARMMMUFaultInfo *fi, uint32_t *mregion)
60
+ GetPhysAddrResult *result, ARMMMUFaultInfo *fi,
61
+ uint32_t *mregion)
62
{
63
/*
64
* Perform a PMSAv8 MPU lookup (without also doing the SAU check
65
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
66
* mregion is (if not NULL) set to the region number which matched,
67
* or -1 if no region number is returned (MPU off, address did not
68
* hit a region, address hit in multiple regions).
69
- * We set is_subpage to true if the region hit doesn't cover the
70
- * entire TARGET_PAGE the address is within.
71
+ * If the region hit doesn't cover the entire TARGET_PAGE the address
72
+ * is within, then we set the result page_size to 1 to force the
73
+ * memory system to use a subpage.
74
*/
75
ARMCPU *cpu = env_archcpu(env);
76
bool is_user = regime_is_user(env, mmu_idx);
77
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
78
uint32_t addr_page_base = address & TARGET_PAGE_MASK;
79
uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1);
80
81
- *is_subpage = false;
82
+ result->page_size = TARGET_PAGE_SIZE;
83
result->phys = address;
84
result->prot = 0;
85
if (mregion) {
86
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
87
ranges_overlap(base, limit - base + 1,
88
addr_page_base,
89
TARGET_PAGE_SIZE)) {
90
- *is_subpage = true;
91
+ result->page_size = 1;
92
}
93
continue;
94
}
95
96
if (base > addr_page_base || limit < addr_page_limit) {
97
- *is_subpage = true;
98
+ result->page_size = 1;
99
}
100
101
if (matchregion != -1) {
102
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
103
uint32_t secure = regime_is_secure(env, mmu_idx);
104
V8M_SAttributes sattrs = {};
105
bool ret;
106
- bool mpu_is_subpage;
107
108
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
109
v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs);
110
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
22
}
111
}
23
112
24
+ /* Overriding of an existing definition must be explicitly requested. */
113
ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
25
+ if (!(r->type & ARM_CP_OVERRIDE)) {
114
- result, &mpu_is_subpage, fi, NULL);
26
+ const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key);
115
- result->page_size =
27
+ if (oldreg) {
116
- sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
28
+ assert(oldreg->type & ARM_CP_OVERRIDE);
117
+ result, fi, NULL);
29
+ }
118
+ if (sattrs.subpage) {
119
+ result->page_size = 1;
30
+ }
120
+ }
31
+
121
return ret;
32
/* Combine cpreg and name into one allocation. */
33
name_len = strlen(name) + 1;
34
r2 = g_malloc(sizeof(*r2) + name_len);
35
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
36
assert(!raw_accessors_invalid(r2));
37
}
38
39
- /* Overriding of an existing definition must be explicitly
40
- * requested.
41
- */
42
- if (!(r->type & ARM_CP_OVERRIDE)) {
43
- const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key);
44
- if (oldreg && !(oldreg->type & ARM_CP_OVERRIDE)) {
45
- fprintf(stderr, "Register redefined: cp=%d %d bit "
46
- "crn=%d crm=%d opc1=%d opc2=%d, "
47
- "was %s, now %s\n", r2->cp, 32 + 32 * is64,
48
- r2->crn, r2->crm, r2->opc1, r2->opc2,
49
- oldreg->name, r2->name);
50
- g_assert_not_reached();
51
- }
52
- }
53
g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2);
54
}
122
}
55
123
56
--
124
--
57
2.25.1
125
2.25.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Rearrange the values of the enumerators of CPAccessResult
3
Remove the use of regime_is_secure from v8m_security_lookup,
4
so that we may directly extract the target el. For the two
4
passing the new parameter to the lookup instead.
5
special cases in access_check_cp_reg, use CPAccessResult.
6
5
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-12-richard.henderson@linaro.org
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220501055028.646596-3-richard.henderson@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/cpregs.h | 26 ++++++++++++--------
12
target/arm/internals.h | 2 +-
14
target/arm/op_helper.c | 56 +++++++++++++++++++++---------------------
13
target/arm/m_helper.c | 9 ++++++---
15
2 files changed, 44 insertions(+), 38 deletions(-)
14
target/arm/ptw.c | 9 +++++----
15
3 files changed, 12 insertions(+), 8 deletions(-)
16
16
17
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
17
diff --git a/target/arm/internals.h b/target/arm/internals.h
18
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpregs.h
19
--- a/target/arm/internals.h
20
+++ b/target/arm/cpregs.h
20
+++ b/target/arm/internals.h
21
@@ -XXX,XX +XXX,XX @@ static inline bool cptype_valid(int cptype)
21
@@ -XXX,XX +XXX,XX @@ typedef struct V8M_SAttributes {
22
typedef enum CPAccessResult {
22
23
/* Access is permitted */
23
void v8m_security_lookup(CPUARMState *env, uint32_t address,
24
CP_ACCESS_OK = 0,
24
MMUAccessType access_type, ARMMMUIdx mmu_idx,
25
+
25
- V8M_SAttributes *sattrs);
26
+ /*
26
+ bool secure, V8M_SAttributes *sattrs);
27
+ * Combined with one of the following, the low 2 bits indicate the
27
28
+ * target exception level. If 0, the exception is taken to the usual
28
/* Cacheability and shareability attributes for a memory access */
29
+ * target EL (EL1 or PL1 if in EL0, otherwise to the current EL).
29
typedef struct ARMCacheAttrs {
30
+ */
30
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
31
+ CP_ACCESS_EL_MASK = 3,
31
index XXXXXXX..XXXXXXX 100644
32
+
32
--- a/target/arm/m_helper.c
33
+++ b/target/arm/m_helper.c
34
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
35
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
36
V8M_SAttributes sattrs = {};
37
38
- v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, &sattrs);
39
+ v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
40
+ targets_secure, &sattrs);
41
if (sattrs.ns) {
42
attrs.secure = false;
43
} else if (!targets_secure) {
44
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
45
ARMMMUFaultInfo fi = {};
46
MemTxResult txres;
47
48
- v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs);
49
+ v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx,
50
+ regime_is_secure(env, mmu_idx), &sattrs);
51
if (!sattrs.nsc || sattrs.ns) {
52
/*
53
* This must be the second half of the insn, and it straddles a
54
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
55
}
56
57
if (env->v7m.secure) {
58
- v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, &sattrs);
59
+ v8m_security_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
60
+ targetsec, &sattrs);
61
nsr = sattrs.ns && r;
62
nsrw = sattrs.ns && rw;
63
} else {
64
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/arm/ptw.c
67
+++ b/target/arm/ptw.c
68
@@ -XXX,XX +XXX,XX @@ static bool v8m_is_sau_exempt(CPUARMState *env,
69
}
70
71
void v8m_security_lookup(CPUARMState *env, uint32_t address,
72
- MMUAccessType access_type, ARMMMUIdx mmu_idx,
73
- V8M_SAttributes *sattrs)
74
+ MMUAccessType access_type, ARMMMUIdx mmu_idx,
75
+ bool is_secure, V8M_SAttributes *sattrs)
76
{
33
/*
77
/*
34
* Access fails due to a configurable trap or enable which would
78
* Look up the security attributes for this address. Compare the
35
* result in a categorized exception syndrome giving information about
79
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
36
* the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6,
37
- * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or
38
- * PL1 if in EL0, otherwise to the current EL).
39
+ * 0xc or 0x18).
40
*/
41
- CP_ACCESS_TRAP = 1,
42
+ CP_ACCESS_TRAP = (1 << 2),
43
+ CP_ACCESS_TRAP_EL2 = CP_ACCESS_TRAP | 2,
44
+ CP_ACCESS_TRAP_EL3 = CP_ACCESS_TRAP | 3,
45
+
46
/*
47
* Access fails and results in an exception syndrome 0x0 ("uncategorized").
48
* Note that this is not a catch-all case -- the set of cases which may
49
* result in this failure is specifically defined by the architecture.
50
*/
51
- CP_ACCESS_TRAP_UNCATEGORIZED = 2,
52
- /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */
53
- CP_ACCESS_TRAP_EL2 = 3,
54
- CP_ACCESS_TRAP_EL3 = 4,
55
- /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */
56
- CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5,
57
- CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6,
58
+ CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2),
59
+ CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = CP_ACCESS_TRAP_UNCATEGORIZED | 2,
60
+ CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = CP_ACCESS_TRAP_UNCATEGORIZED | 3,
61
} CPAccessResult;
62
63
typedef struct ARMCPRegInfo ARMCPRegInfo;
64
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/arm/op_helper.c
67
+++ b/target/arm/op_helper.c
68
@@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
69
uint32_t isread)
70
{
71
const ARMCPRegInfo *ri = rip;
72
+ CPAccessResult res = CP_ACCESS_OK;
73
int target_el;
74
75
if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14
76
&& extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) {
77
- raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env));
78
+ res = CP_ACCESS_TRAP;
79
+ goto fail;
80
}
80
}
81
81
82
/*
82
if (idau_exempt || v8m_is_sau_exempt(env, address, access_type)) {
83
@@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
83
- sattrs->ns = !regime_is_secure(env, mmu_idx);
84
mask &= ~((1 << 4) | (1 << 14));
84
+ sattrs->ns = !is_secure;
85
86
if (env->cp15.hstr_el2 & mask) {
87
- target_el = 2;
88
- goto exept;
89
+ res = CP_ACCESS_TRAP_EL2;
90
+ goto fail;
91
}
92
}
93
94
- if (!ri->accessfn) {
95
+ if (ri->accessfn) {
96
+ res = ri->accessfn(env, ri, isread);
97
+ }
98
+ if (likely(res == CP_ACCESS_OK)) {
99
return;
85
return;
100
}
86
}
101
87
102
- switch (ri->accessfn(env, ri, isread)) {
88
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
103
- case CP_ACCESS_OK:
89
bool ret;
104
- return;
90
105
+ fail:
91
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
106
+ switch (res & ~CP_ACCESS_EL_MASK) {
92
- v8m_security_lookup(env, address, access_type, mmu_idx, &sattrs);
107
case CP_ACCESS_TRAP:
93
+ v8m_security_lookup(env, address, access_type, mmu_idx,
108
- target_el = exception_target_el(env);
94
+ secure, &sattrs);
109
- break;
95
if (access_type == MMU_INST_FETCH) {
110
- case CP_ACCESS_TRAP_EL2:
96
/*
111
- /* Requesting a trap to EL2 when we're in EL3 is
97
* Instruction fetches always use the MMU bank and the
112
- * a bug in the access function.
113
- */
114
- assert(arm_current_el(env) != 3);
115
- target_el = 2;
116
- break;
117
- case CP_ACCESS_TRAP_EL3:
118
- target_el = 3;
119
break;
120
case CP_ACCESS_TRAP_UNCATEGORIZED:
121
- target_el = exception_target_el(env);
122
- syndrome = syn_uncategorized();
123
- break;
124
- case CP_ACCESS_TRAP_UNCATEGORIZED_EL2:
125
- target_el = 2;
126
- syndrome = syn_uncategorized();
127
- break;
128
- case CP_ACCESS_TRAP_UNCATEGORIZED_EL3:
129
- target_el = 3;
130
syndrome = syn_uncategorized();
131
break;
132
default:
133
g_assert_not_reached();
134
}
135
136
-exept:
137
+ target_el = res & CP_ACCESS_EL_MASK;
138
+ switch (target_el) {
139
+ case 0:
140
+ target_el = exception_target_el(env);
141
+ break;
142
+ case 2:
143
+ assert(arm_current_el(env) != 3);
144
+ assert(arm_is_el2_enabled(env));
145
+ break;
146
+ case 3:
147
+ assert(arm_feature(env, ARM_FEATURE_EL3));
148
+ break;
149
+ default:
150
+ /* No "direct" traps to EL1 */
151
+ g_assert_not_reached();
152
+ }
153
+
154
raise_exception(env, EXCP_UDEF, syndrome, target_el);
155
}
156
157
--
98
--
158
2.25.1
99
2.25.1
159
100
160
101
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
These particular data structures are not modified at runtime.
3
Remove the use of regime_is_secure from pmsav8_mpu_lookup,
4
passing the new parameter to the lookup instead.
4
5
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-13-richard.henderson@linaro.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220501055028.646596-5-richard.henderson@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 | 16 ++++++++--------
12
target/arm/internals.h | 4 ++--
12
1 file changed, 8 insertions(+), 8 deletions(-)
13
target/arm/m_helper.c | 2 +-
14
target/arm/ptw.c | 7 +++----
15
3 files changed, 6 insertions(+), 7 deletions(-)
13
16
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
diff --git a/target/arm/internals.h b/target/arm/internals.h
15
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
19
--- a/target/arm/internals.h
17
+++ b/target/arm/helper.c
20
+++ b/target/arm/internals.h
18
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
21
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
19
.resetvalue = cpu->pmceid1 },
22
20
};
23
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
21
#ifdef CONFIG_USER_ONLY
24
MMUAccessType access_type, ARMMMUIdx mmu_idx,
22
- ARMCPRegUserSpaceInfo v8_user_idregs[] = {
25
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi,
23
+ static const ARMCPRegUserSpaceInfo v8_user_idregs[] = {
26
- uint32_t *mregion);
24
{ .name = "ID_AA64PFR0_EL1",
27
+ bool is_secure, GetPhysAddrResult *result,
25
.exported_bits = 0x000f000f00ff0000,
28
+ ARMMMUFaultInfo *fi, uint32_t *mregion);
26
.fixed_bits = 0x0000000000000011 },
29
27
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
30
void arm_log_exception(CPUState *cs);
31
32
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/m_helper.c
35
+++ b/target/arm/m_helper.c
36
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
37
ARMMMUFaultInfo fi = {};
38
39
/* We can ignore the return value as prot is always set */
40
- pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx,
41
+ pmsav8_mpu_lookup(env, addr, MMU_DATA_LOAD, mmu_idx, targetsec,
42
&res, &fi, &mregion);
43
if (mregion == -1) {
44
mrvalid = false;
45
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/ptw.c
48
+++ b/target/arm/ptw.c
49
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
50
51
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
52
MMUAccessType access_type, ARMMMUIdx mmu_idx,
53
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi,
54
- uint32_t *mregion)
55
+ bool secure, GetPhysAddrResult *result,
56
+ ARMMMUFaultInfo *fi, uint32_t *mregion)
57
{
58
/*
59
* Perform a PMSAv8 MPU lookup (without also doing the SAU check
60
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
28
*/
61
*/
29
if (arm_feature(env, ARM_FEATURE_EL3)) {
62
ARMCPU *cpu = env_archcpu(env);
30
if (arm_feature(env, ARM_FEATURE_AARCH64)) {
63
bool is_user = regime_is_user(env, mmu_idx);
31
- ARMCPRegInfo nsacr = {
64
- uint32_t secure = regime_is_secure(env, mmu_idx);
32
+ static const ARMCPRegInfo nsacr = {
65
int n;
33
.name = "NSACR", .type = ARM_CP_CONST,
66
int matchregion = -1;
34
.cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2,
67
bool hit = false;
35
.access = PL1_RW, .accessfn = nsacr_access,
68
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
36
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
37
};
38
define_one_arm_cp_reg(cpu, &nsacr);
39
} else {
40
- ARMCPRegInfo nsacr = {
41
+ static const ARMCPRegInfo nsacr = {
42
.name = "NSACR",
43
.cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2,
44
.access = PL3_RW | PL1_R,
45
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
46
}
69
}
47
} else {
48
if (arm_feature(env, ARM_FEATURE_V8)) {
49
- ARMCPRegInfo nsacr = {
50
+ static const ARMCPRegInfo nsacr = {
51
.name = "NSACR", .type = ARM_CP_CONST,
52
.cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 2,
53
.access = PL1_R,
54
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
55
.access = PL1_R, .type = ARM_CP_CONST,
56
.resetvalue = cpu->pmsav7_dregion << 8
57
};
58
- ARMCPRegInfo crn0_wi_reginfo = {
59
+ static const ARMCPRegInfo crn0_wi_reginfo = {
60
.name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY,
61
.opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W,
62
.type = ARM_CP_NOP | ARM_CP_OVERRIDE
63
};
64
#ifdef CONFIG_USER_ONLY
65
- ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = {
66
+ static const ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = {
67
{ .name = "MIDR_EL1",
68
.exported_bits = 0x00000000ffffffff },
69
{ .name = "REVIDR_EL1" },
70
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
71
.access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW },
72
};
73
#ifdef CONFIG_USER_ONLY
74
- ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = {
75
+ static const ARMCPRegUserSpaceInfo mpidr_user_cp_reginfo[] = {
76
{ .name = "MPIDR_EL1",
77
.fixed_bits = 0x0000000080000000 },
78
};
79
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
80
}
70
}
81
71
82
if (arm_feature(env, ARM_FEATURE_VBAR)) {
72
- ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx,
83
- ARMCPRegInfo vbar_cp_reginfo[] = {
73
+ ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, secure,
84
+ static const ARMCPRegInfo vbar_cp_reginfo[] = {
74
result, fi, NULL);
85
{ .name = "VBAR", .state = ARM_CP_STATE_BOTH,
75
if (sattrs.subpage) {
86
.opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0,
76
result->page_size = 1;
87
.access = PL1_RW, .writefn = vbar_write,
88
--
77
--
89
2.25.1
78
2.25.1
90
79
91
80
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Move ARMCPRegInfo and all related declarations to a new
3
Remove the use of regime_is_secure from get_phys_addr_v5,
4
internal header, out of the public cpu.h.
4
passing the new parameter to the lookup instead.
5
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
[PMM: Folded in definition of local is_secure in get_phys_addr(),
9
since I dropped the earlier patch that would have provided it]
10
Message-id: 20220822152741.1617527-14-richard.henderson@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220501055028.646596-2-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
13
---
12
target/arm/cpregs.h | 413 +++++++++++++++++++++++++++++++++++++
14
target/arm/ptw.c | 14 +++++++-------
13
target/arm/cpu.h | 368 ---------------------------------
15
1 file changed, 7 insertions(+), 7 deletions(-)
14
hw/arm/pxa2xx.c | 1 +
15
hw/arm/pxa2xx_pic.c | 1 +
16
hw/intc/arm_gicv3_cpuif.c | 1 +
17
hw/intc/arm_gicv3_kvm.c | 2 +
18
target/arm/cpu.c | 1 +
19
target/arm/cpu64.c | 1 +
20
target/arm/cpu_tcg.c | 1 +
21
target/arm/gdbstub.c | 3 +-
22
target/arm/helper.c | 1 +
23
target/arm/op_helper.c | 1 +
24
target/arm/translate-a64.c | 4 +-
25
target/arm/translate.c | 3 +-
26
14 files changed, 427 insertions(+), 374 deletions(-)
27
create mode 100644 target/arm/cpregs.h
28
16
29
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
17
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
30
new file mode 100644
31
index XXXXXXX..XXXXXXX
32
--- /dev/null
33
+++ b/target/arm/cpregs.h
34
@@ -XXX,XX +XXX,XX @@
35
+/*
36
+ * QEMU ARM CP Register access and descriptions
37
+ *
38
+ * Copyright (c) 2022 Linaro Ltd
39
+ *
40
+ * This program is free software; you can redistribute it and/or
41
+ * modify it under the terms of the GNU General Public License
42
+ * as published by the Free Software Foundation; either version 2
43
+ * of the License, or (at your option) any later version.
44
+ *
45
+ * This program is distributed in the hope that it will be useful,
46
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
47
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48
+ * GNU General Public License for more details.
49
+ *
50
+ * You should have received a copy of the GNU General Public License
51
+ * along with this program; if not, see
52
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
53
+ */
54
+
55
+#ifndef TARGET_ARM_CPREGS_H
56
+#define TARGET_ARM_CPREGS_H
57
+
58
+/*
59
+ * ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a
60
+ * special-behaviour cp reg and bits [11..8] indicate what behaviour
61
+ * it has. Otherwise it is a simple cp reg, where CONST indicates that
62
+ * TCG can assume the value to be constant (ie load at translate time)
63
+ * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END
64
+ * indicates that the TB should not be ended after a write to this register
65
+ * (the default is that the TB ends after cp writes). OVERRIDE permits
66
+ * a register definition to override a previous definition for the
67
+ * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the
68
+ * old must have the OVERRIDE bit set.
69
+ * ALIAS indicates that this register is an alias view of some underlying
70
+ * state which is also visible via another register, and that the other
71
+ * register is handling migration and reset; registers marked ALIAS will not be
72
+ * migrated but may have their state set by syncing of register state from KVM.
73
+ * NO_RAW indicates that this register has no underlying state and does not
74
+ * support raw access for state saving/loading; it will not be used for either
75
+ * migration or KVM state synchronization. (Typically this is for "registers"
76
+ * which are actually used as instructions for cache maintenance and so on.)
77
+ * IO indicates that this register does I/O and therefore its accesses
78
+ * need to be marked with gen_io_start() and also end the TB. In particular,
79
+ * registers which implement clocks or timers require this.
80
+ * RAISES_EXC is for when the read or write hook might raise an exception;
81
+ * the generated code will synchronize the CPU state before calling the hook
82
+ * so that it is safe for the hook to call raise_exception().
83
+ * NEWEL is for writes to registers that might change the exception
84
+ * level - typically on older ARM chips. For those cases we need to
85
+ * re-read the new el when recomputing the translation flags.
86
+ */
87
+#define ARM_CP_SPECIAL 0x0001
88
+#define ARM_CP_CONST 0x0002
89
+#define ARM_CP_64BIT 0x0004
90
+#define ARM_CP_SUPPRESS_TB_END 0x0008
91
+#define ARM_CP_OVERRIDE 0x0010
92
+#define ARM_CP_ALIAS 0x0020
93
+#define ARM_CP_IO 0x0040
94
+#define ARM_CP_NO_RAW 0x0080
95
+#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100)
96
+#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200)
97
+#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300)
98
+#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400)
99
+#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500)
100
+#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600)
101
+#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700)
102
+#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA
103
+#define ARM_CP_FPU 0x1000
104
+#define ARM_CP_SVE 0x2000
105
+#define ARM_CP_NO_GDB 0x4000
106
+#define ARM_CP_RAISES_EXC 0x8000
107
+#define ARM_CP_NEWEL 0x10000
108
+/* Used only as a terminator for ARMCPRegInfo lists */
109
+#define ARM_CP_SENTINEL 0xfffff
110
+/* Mask of only the flag bits in a type field */
111
+#define ARM_CP_FLAG_MASK 0x1f0ff
112
+
113
+/*
114
+ * Valid values for ARMCPRegInfo state field, indicating which of
115
+ * the AArch32 and AArch64 execution states this register is visible in.
116
+ * If the reginfo doesn't explicitly specify then it is AArch32 only.
117
+ * If the reginfo is declared to be visible in both states then a second
118
+ * reginfo is synthesised for the AArch32 view of the AArch64 register,
119
+ * such that the AArch32 view is the lower 32 bits of the AArch64 one.
120
+ * Note that we rely on the values of these enums as we iterate through
121
+ * the various states in some places.
122
+ */
123
+enum {
124
+ ARM_CP_STATE_AA32 = 0,
125
+ ARM_CP_STATE_AA64 = 1,
126
+ ARM_CP_STATE_BOTH = 2,
127
+};
128
+
129
+/*
130
+ * ARM CP register secure state flags. These flags identify security state
131
+ * attributes for a given CP register entry.
132
+ * The existence of both or neither secure and non-secure flags indicates that
133
+ * the register has both a secure and non-secure hash entry. A single one of
134
+ * these flags causes the register to only be hashed for the specified
135
+ * security state.
136
+ * Although definitions may have any combination of the S/NS bits, each
137
+ * registered entry will only have one to identify whether the entry is secure
138
+ * or non-secure.
139
+ */
140
+enum {
141
+ ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */
142
+ ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */
143
+};
144
+
145
+/*
146
+ * Return true if cptype is a valid type field. This is used to try to
147
+ * catch errors where the sentinel has been accidentally left off the end
148
+ * of a list of registers.
149
+ */
150
+static inline bool cptype_valid(int cptype)
151
+{
152
+ return ((cptype & ~ARM_CP_FLAG_MASK) == 0)
153
+ || ((cptype & ARM_CP_SPECIAL) &&
154
+ ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL));
155
+}
156
+
157
+/*
158
+ * Access rights:
159
+ * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM
160
+ * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and
161
+ * PL2 (hyp). The other level which has Read and Write bits is Secure PL1
162
+ * (ie any of the privileged modes in Secure state, or Monitor mode).
163
+ * If a register is accessible in one privilege level it's always accessible
164
+ * in higher privilege levels too. Since "Secure PL1" also follows this rule
165
+ * (ie anything visible in PL2 is visible in S-PL1, some things are only
166
+ * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the
167
+ * terminology a little and call this PL3.
168
+ * In AArch64 things are somewhat simpler as the PLx bits line up exactly
169
+ * with the ELx exception levels.
170
+ *
171
+ * If access permissions for a register are more complex than can be
172
+ * described with these bits, then use a laxer set of restrictions, and
173
+ * do the more restrictive/complex check inside a helper function.
174
+ */
175
+#define PL3_R 0x80
176
+#define PL3_W 0x40
177
+#define PL2_R (0x20 | PL3_R)
178
+#define PL2_W (0x10 | PL3_W)
179
+#define PL1_R (0x08 | PL2_R)
180
+#define PL1_W (0x04 | PL2_W)
181
+#define PL0_R (0x02 | PL1_R)
182
+#define PL0_W (0x01 | PL1_W)
183
+
184
+/*
185
+ * For user-mode some registers are accessible to EL0 via a kernel
186
+ * trap-and-emulate ABI. In this case we define the read permissions
187
+ * as actually being PL0_R. However some bits of any given register
188
+ * may still be masked.
189
+ */
190
+#ifdef CONFIG_USER_ONLY
191
+#define PL0U_R PL0_R
192
+#else
193
+#define PL0U_R PL1_R
194
+#endif
195
+
196
+#define PL3_RW (PL3_R | PL3_W)
197
+#define PL2_RW (PL2_R | PL2_W)
198
+#define PL1_RW (PL1_R | PL1_W)
199
+#define PL0_RW (PL0_R | PL0_W)
200
+
201
+typedef enum CPAccessResult {
202
+ /* Access is permitted */
203
+ CP_ACCESS_OK = 0,
204
+ /*
205
+ * Access fails due to a configurable trap or enable which would
206
+ * result in a categorized exception syndrome giving information about
207
+ * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6,
208
+ * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or
209
+ * PL1 if in EL0, otherwise to the current EL).
210
+ */
211
+ CP_ACCESS_TRAP = 1,
212
+ /*
213
+ * Access fails and results in an exception syndrome 0x0 ("uncategorized").
214
+ * Note that this is not a catch-all case -- the set of cases which may
215
+ * result in this failure is specifically defined by the architecture.
216
+ */
217
+ CP_ACCESS_TRAP_UNCATEGORIZED = 2,
218
+ /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */
219
+ CP_ACCESS_TRAP_EL2 = 3,
220
+ CP_ACCESS_TRAP_EL3 = 4,
221
+ /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */
222
+ CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5,
223
+ CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6,
224
+} CPAccessResult;
225
+
226
+typedef struct ARMCPRegInfo ARMCPRegInfo;
227
+
228
+/*
229
+ * Access functions for coprocessor registers. These cannot fail and
230
+ * may not raise exceptions.
231
+ */
232
+typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque);
233
+typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque,
234
+ uint64_t value);
235
+/* Access permission check functions for coprocessor registers. */
236
+typedef CPAccessResult CPAccessFn(CPUARMState *env,
237
+ const ARMCPRegInfo *opaque,
238
+ bool isread);
239
+/* Hook function for register reset */
240
+typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque);
241
+
242
+#define CP_ANY 0xff
243
+
244
+/* Definition of an ARM coprocessor register */
245
+struct ARMCPRegInfo {
246
+ /* Name of register (useful mainly for debugging, need not be unique) */
247
+ const char *name;
248
+ /*
249
+ * Location of register: coprocessor number and (crn,crm,opc1,opc2)
250
+ * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a
251
+ * 'wildcard' field -- any value of that field in the MRC/MCR insn
252
+ * will be decoded to this register. The register read and write
253
+ * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2
254
+ * used by the program, so it is possible to register a wildcard and
255
+ * then behave differently on read/write if necessary.
256
+ * For 64 bit registers, only crm and opc1 are relevant; crn and opc2
257
+ * must both be zero.
258
+ * For AArch64-visible registers, opc0 is also used.
259
+ * Since there are no "coprocessors" in AArch64, cp is purely used as a
260
+ * way to distinguish (for KVM's benefit) guest-visible system registers
261
+ * from demuxed ones provided to preserve the "no side effects on
262
+ * KVM register read/write from QEMU" semantics. cp==0x13 is guest
263
+ * visible (to match KVM's encoding); cp==0 will be converted to
264
+ * cp==0x13 when the ARMCPRegInfo is registered, for convenience.
265
+ */
266
+ uint8_t cp;
267
+ uint8_t crn;
268
+ uint8_t crm;
269
+ uint8_t opc0;
270
+ uint8_t opc1;
271
+ uint8_t opc2;
272
+ /* Execution state in which this register is visible: ARM_CP_STATE_* */
273
+ int state;
274
+ /* Register type: ARM_CP_* bits/values */
275
+ int type;
276
+ /* Access rights: PL*_[RW] */
277
+ int access;
278
+ /* Security state: ARM_CP_SECSTATE_* bits/values */
279
+ int secure;
280
+ /*
281
+ * The opaque pointer passed to define_arm_cp_regs_with_opaque() when
282
+ * this register was defined: can be used to hand data through to the
283
+ * register read/write functions, since they are passed the ARMCPRegInfo*.
284
+ */
285
+ void *opaque;
286
+ /*
287
+ * Value of this register, if it is ARM_CP_CONST. Otherwise, if
288
+ * fieldoffset is non-zero, the reset value of the register.
289
+ */
290
+ uint64_t resetvalue;
291
+ /*
292
+ * Offset of the field in CPUARMState for this register.
293
+ * This is not needed if either:
294
+ * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs
295
+ * 2. both readfn and writefn are specified
296
+ */
297
+ ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */
298
+
299
+ /*
300
+ * Offsets of the secure and non-secure fields in CPUARMState for the
301
+ * register if it is banked. These fields are only used during the static
302
+ * registration of a register. During hashing the bank associated
303
+ * with a given security state is copied to fieldoffset which is used from
304
+ * there on out.
305
+ *
306
+ * It is expected that register definitions use either fieldoffset or
307
+ * bank_fieldoffsets in the definition but not both. It is also expected
308
+ * that both bank offsets are set when defining a banked register. This
309
+ * use indicates that a register is banked.
310
+ */
311
+ ptrdiff_t bank_fieldoffsets[2];
312
+
313
+ /*
314
+ * Function for making any access checks for this register in addition to
315
+ * those specified by the 'access' permissions bits. If NULL, no extra
316
+ * checks required. The access check is performed at runtime, not at
317
+ * translate time.
318
+ */
319
+ CPAccessFn *accessfn;
320
+ /*
321
+ * Function for handling reads of this register. If NULL, then reads
322
+ * will be done by loading from the offset into CPUARMState specified
323
+ * by fieldoffset.
324
+ */
325
+ CPReadFn *readfn;
326
+ /*
327
+ * Function for handling writes of this register. If NULL, then writes
328
+ * will be done by writing to the offset into CPUARMState specified
329
+ * by fieldoffset.
330
+ */
331
+ CPWriteFn *writefn;
332
+ /*
333
+ * Function for doing a "raw" read; used when we need to copy
334
+ * coprocessor state to the kernel for KVM or out for
335
+ * migration. This only needs to be provided if there is also a
336
+ * readfn and it has side effects (for instance clear-on-read bits).
337
+ */
338
+ CPReadFn *raw_readfn;
339
+ /*
340
+ * Function for doing a "raw" write; used when we need to copy KVM
341
+ * kernel coprocessor state into userspace, or for inbound
342
+ * migration. This only needs to be provided if there is also a
343
+ * writefn and it masks out "unwritable" bits or has write-one-to-clear
344
+ * or similar behaviour.
345
+ */
346
+ CPWriteFn *raw_writefn;
347
+ /*
348
+ * Function for resetting the register. If NULL, then reset will be done
349
+ * by writing resetvalue to the field specified in fieldoffset. If
350
+ * fieldoffset is 0 then no reset will be done.
351
+ */
352
+ CPResetFn *resetfn;
353
+
354
+ /*
355
+ * "Original" writefn and readfn.
356
+ * For ARMv8.1-VHE register aliases, we overwrite the read/write
357
+ * accessor functions of various EL1/EL0 to perform the runtime
358
+ * check for which sysreg should actually be modified, and then
359
+ * forwards the operation. Before overwriting the accessors,
360
+ * the original function is copied here, so that accesses that
361
+ * really do go to the EL1/EL0 version proceed normally.
362
+ * (The corresponding EL2 register is linked via opaque.)
363
+ */
364
+ CPReadFn *orig_readfn;
365
+ CPWriteFn *orig_writefn;
366
+};
367
+
368
+/*
369
+ * Macros which are lvalues for the field in CPUARMState for the
370
+ * ARMCPRegInfo *ri.
371
+ */
372
+#define CPREG_FIELD32(env, ri) \
373
+ (*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
374
+#define CPREG_FIELD64(env, ri) \
375
+ (*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
376
+
377
+#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL }
378
+
379
+void define_arm_cp_regs_with_opaque(ARMCPU *cpu,
380
+ const ARMCPRegInfo *regs, void *opaque);
381
+void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
382
+ const ARMCPRegInfo *regs, void *opaque);
383
+static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs)
384
+{
385
+ define_arm_cp_regs_with_opaque(cpu, regs, 0);
386
+}
387
+static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs)
388
+{
389
+ define_one_arm_cp_reg_with_opaque(cpu, regs, 0);
390
+}
391
+const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp);
392
+
393
+/*
394
+ * Definition of an ARM co-processor register as viewed from
395
+ * userspace. This is used for presenting sanitised versions of
396
+ * registers to userspace when emulating the Linux AArch64 CPU
397
+ * ID/feature ABI (advertised as HWCAP_CPUID).
398
+ */
399
+typedef struct ARMCPRegUserSpaceInfo {
400
+ /* Name of register */
401
+ const char *name;
402
+
403
+ /* Is the name actually a glob pattern */
404
+ bool is_glob;
405
+
406
+ /* Only some bits are exported to user space */
407
+ uint64_t exported_bits;
408
+
409
+ /* Fixed bits are applied after the mask */
410
+ uint64_t fixed_bits;
411
+} ARMCPRegUserSpaceInfo;
412
+
413
+#define REGUSERINFO_SENTINEL { .name = NULL }
414
+
415
+void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods);
416
+
417
+/* CPWriteFn that can be used to implement writes-ignored behaviour */
418
+void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,
419
+ uint64_t value);
420
+/* CPReadFn that can be used for read-as-zero behaviour */
421
+uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri);
422
+
423
+/*
424
+ * CPResetFn that does nothing, for use if no reset is required even
425
+ * if fieldoffset is non zero.
426
+ */
427
+void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque);
428
+
429
+/*
430
+ * Return true if this reginfo struct's field in the cpu state struct
431
+ * is 64 bits wide.
432
+ */
433
+static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri)
434
+{
435
+ return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT);
436
+}
437
+
438
+static inline bool cp_access_ok(int current_el,
439
+ const ARMCPRegInfo *ri, int isread)
440
+{
441
+ return (ri->access >> ((current_el * 2) + isread)) & 1;
442
+}
443
+
444
+/* Raw read of a coprocessor register (as needed for migration, etc) */
445
+uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri);
446
+
447
+#endif /* TARGET_ARM_CPREGS_H */
448
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
449
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
450
--- a/target/arm/cpu.h
19
--- a/target/arm/ptw.c
451
+++ b/target/arm/cpu.h
20
+++ b/target/arm/ptw.c
452
@@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
21
@@ -XXX,XX +XXX,XX @@ static int simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)
453
return kvmid;
22
454
}
23
static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
455
24
MMUAccessType access_type, ARMMMUIdx mmu_idx,
456
-/* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a
25
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
457
- * special-behaviour cp reg and bits [11..8] indicate what behaviour
26
+ bool is_secure, GetPhysAddrResult *result,
458
- * it has. Otherwise it is a simple cp reg, where CONST indicates that
27
+ ARMMMUFaultInfo *fi)
459
- * TCG can assume the value to be constant (ie load at translate time)
460
- * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END
461
- * indicates that the TB should not be ended after a write to this register
462
- * (the default is that the TB ends after cp writes). OVERRIDE permits
463
- * a register definition to override a previous definition for the
464
- * same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the
465
- * old must have the OVERRIDE bit set.
466
- * ALIAS indicates that this register is an alias view of some underlying
467
- * state which is also visible via another register, and that the other
468
- * register is handling migration and reset; registers marked ALIAS will not be
469
- * migrated but may have their state set by syncing of register state from KVM.
470
- * NO_RAW indicates that this register has no underlying state and does not
471
- * support raw access for state saving/loading; it will not be used for either
472
- * migration or KVM state synchronization. (Typically this is for "registers"
473
- * which are actually used as instructions for cache maintenance and so on.)
474
- * IO indicates that this register does I/O and therefore its accesses
475
- * need to be marked with gen_io_start() and also end the TB. In particular,
476
- * registers which implement clocks or timers require this.
477
- * RAISES_EXC is for when the read or write hook might raise an exception;
478
- * the generated code will synchronize the CPU state before calling the hook
479
- * so that it is safe for the hook to call raise_exception().
480
- * NEWEL is for writes to registers that might change the exception
481
- * level - typically on older ARM chips. For those cases we need to
482
- * re-read the new el when recomputing the translation flags.
483
- */
484
-#define ARM_CP_SPECIAL 0x0001
485
-#define ARM_CP_CONST 0x0002
486
-#define ARM_CP_64BIT 0x0004
487
-#define ARM_CP_SUPPRESS_TB_END 0x0008
488
-#define ARM_CP_OVERRIDE 0x0010
489
-#define ARM_CP_ALIAS 0x0020
490
-#define ARM_CP_IO 0x0040
491
-#define ARM_CP_NO_RAW 0x0080
492
-#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100)
493
-#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200)
494
-#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300)
495
-#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400)
496
-#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500)
497
-#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600)
498
-#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700)
499
-#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA
500
-#define ARM_CP_FPU 0x1000
501
-#define ARM_CP_SVE 0x2000
502
-#define ARM_CP_NO_GDB 0x4000
503
-#define ARM_CP_RAISES_EXC 0x8000
504
-#define ARM_CP_NEWEL 0x10000
505
-/* Used only as a terminator for ARMCPRegInfo lists */
506
-#define ARM_CP_SENTINEL 0xfffff
507
-/* Mask of only the flag bits in a type field */
508
-#define ARM_CP_FLAG_MASK 0x1f0ff
509
-
510
-/* Valid values for ARMCPRegInfo state field, indicating which of
511
- * the AArch32 and AArch64 execution states this register is visible in.
512
- * If the reginfo doesn't explicitly specify then it is AArch32 only.
513
- * If the reginfo is declared to be visible in both states then a second
514
- * reginfo is synthesised for the AArch32 view of the AArch64 register,
515
- * such that the AArch32 view is the lower 32 bits of the AArch64 one.
516
- * Note that we rely on the values of these enums as we iterate through
517
- * the various states in some places.
518
- */
519
-enum {
520
- ARM_CP_STATE_AA32 = 0,
521
- ARM_CP_STATE_AA64 = 1,
522
- ARM_CP_STATE_BOTH = 2,
523
-};
524
-
525
-/* ARM CP register secure state flags. These flags identify security state
526
- * attributes for a given CP register entry.
527
- * The existence of both or neither secure and non-secure flags indicates that
528
- * the register has both a secure and non-secure hash entry. A single one of
529
- * these flags causes the register to only be hashed for the specified
530
- * security state.
531
- * Although definitions may have any combination of the S/NS bits, each
532
- * registered entry will only have one to identify whether the entry is secure
533
- * or non-secure.
534
- */
535
-enum {
536
- ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */
537
- ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */
538
-};
539
-
540
-/* Return true if cptype is a valid type field. This is used to try to
541
- * catch errors where the sentinel has been accidentally left off the end
542
- * of a list of registers.
543
- */
544
-static inline bool cptype_valid(int cptype)
545
-{
546
- return ((cptype & ~ARM_CP_FLAG_MASK) == 0)
547
- || ((cptype & ARM_CP_SPECIAL) &&
548
- ((cptype & ~ARM_CP_FLAG_MASK) <= ARM_LAST_SPECIAL));
549
-}
550
-
551
-/* Access rights:
552
- * We define bits for Read and Write access for what rev C of the v7-AR ARM ARM
553
- * defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and
554
- * PL2 (hyp). The other level which has Read and Write bits is Secure PL1
555
- * (ie any of the privileged modes in Secure state, or Monitor mode).
556
- * If a register is accessible in one privilege level it's always accessible
557
- * in higher privilege levels too. Since "Secure PL1" also follows this rule
558
- * (ie anything visible in PL2 is visible in S-PL1, some things are only
559
- * visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the
560
- * terminology a little and call this PL3.
561
- * In AArch64 things are somewhat simpler as the PLx bits line up exactly
562
- * with the ELx exception levels.
563
- *
564
- * If access permissions for a register are more complex than can be
565
- * described with these bits, then use a laxer set of restrictions, and
566
- * do the more restrictive/complex check inside a helper function.
567
- */
568
-#define PL3_R 0x80
569
-#define PL3_W 0x40
570
-#define PL2_R (0x20 | PL3_R)
571
-#define PL2_W (0x10 | PL3_W)
572
-#define PL1_R (0x08 | PL2_R)
573
-#define PL1_W (0x04 | PL2_W)
574
-#define PL0_R (0x02 | PL1_R)
575
-#define PL0_W (0x01 | PL1_W)
576
-
577
-/*
578
- * For user-mode some registers are accessible to EL0 via a kernel
579
- * trap-and-emulate ABI. In this case we define the read permissions
580
- * as actually being PL0_R. However some bits of any given register
581
- * may still be masked.
582
- */
583
-#ifdef CONFIG_USER_ONLY
584
-#define PL0U_R PL0_R
585
-#else
586
-#define PL0U_R PL1_R
587
-#endif
588
-
589
-#define PL3_RW (PL3_R | PL3_W)
590
-#define PL2_RW (PL2_R | PL2_W)
591
-#define PL1_RW (PL1_R | PL1_W)
592
-#define PL0_RW (PL0_R | PL0_W)
593
-
594
/* Return the highest implemented Exception Level */
595
static inline int arm_highest_el(CPUARMState *env)
596
{
28
{
597
@@ -XXX,XX +XXX,XX @@ static inline int arm_current_el(CPUARMState *env)
29
int level = 1;
30
uint32_t table;
31
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
32
fi->type = ARMFault_Translation;
33
goto do_fault;
34
}
35
- desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx),
36
- mmu_idx, fi);
37
+ desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi);
38
if (fi->type != ARMFault_None) {
39
goto do_fault;
40
}
41
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address,
42
/* Fine pagetable. */
43
table = (desc & 0xfffff000) | ((address >> 8) & 0xffc);
44
}
45
- desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx),
46
- mmu_idx, fi);
47
+ desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi);
48
if (fi->type != ARMFault_None) {
49
goto do_fault;
50
}
51
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
52
GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
53
{
54
ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx);
55
+ bool is_secure = regime_is_secure(env, mmu_idx);
56
57
if (mmu_idx != s1_mmu_idx) {
58
/*
59
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
60
* cannot upgrade an non-secure translation regime's attributes
61
* to secure.
62
*/
63
- result->attrs.secure = regime_is_secure(env, mmu_idx);
64
+ result->attrs.secure = is_secure;
65
result->attrs.user = regime_is_user(env, mmu_idx);
66
67
/*
68
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
69
result, fi);
70
} else {
71
return get_phys_addr_v5(env, address, access_type, mmu_idx,
72
- result, fi);
73
+ is_secure, result, fi);
598
}
74
}
599
}
75
}
600
76
601
-typedef struct ARMCPRegInfo ARMCPRegInfo;
602
-
603
-typedef enum CPAccessResult {
604
- /* Access is permitted */
605
- CP_ACCESS_OK = 0,
606
- /* Access fails due to a configurable trap or enable which would
607
- * result in a categorized exception syndrome giving information about
608
- * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6,
609
- * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or
610
- * PL1 if in EL0, otherwise to the current EL).
611
- */
612
- CP_ACCESS_TRAP = 1,
613
- /* Access fails and results in an exception syndrome 0x0 ("uncategorized").
614
- * Note that this is not a catch-all case -- the set of cases which may
615
- * result in this failure is specifically defined by the architecture.
616
- */
617
- CP_ACCESS_TRAP_UNCATEGORIZED = 2,
618
- /* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */
619
- CP_ACCESS_TRAP_EL2 = 3,
620
- CP_ACCESS_TRAP_EL3 = 4,
621
- /* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */
622
- CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = 5,
623
- CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = 6,
624
-} CPAccessResult;
625
-
626
-/* Access functions for coprocessor registers. These cannot fail and
627
- * may not raise exceptions.
628
- */
629
-typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque);
630
-typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque,
631
- uint64_t value);
632
-/* Access permission check functions for coprocessor registers. */
633
-typedef CPAccessResult CPAccessFn(CPUARMState *env,
634
- const ARMCPRegInfo *opaque,
635
- bool isread);
636
-/* Hook function for register reset */
637
-typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque);
638
-
639
-#define CP_ANY 0xff
640
-
641
-/* Definition of an ARM coprocessor register */
642
-struct ARMCPRegInfo {
643
- /* Name of register (useful mainly for debugging, need not be unique) */
644
- const char *name;
645
- /* Location of register: coprocessor number and (crn,crm,opc1,opc2)
646
- * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a
647
- * 'wildcard' field -- any value of that field in the MRC/MCR insn
648
- * will be decoded to this register. The register read and write
649
- * callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2
650
- * used by the program, so it is possible to register a wildcard and
651
- * then behave differently on read/write if necessary.
652
- * For 64 bit registers, only crm and opc1 are relevant; crn and opc2
653
- * must both be zero.
654
- * For AArch64-visible registers, opc0 is also used.
655
- * Since there are no "coprocessors" in AArch64, cp is purely used as a
656
- * way to distinguish (for KVM's benefit) guest-visible system registers
657
- * from demuxed ones provided to preserve the "no side effects on
658
- * KVM register read/write from QEMU" semantics. cp==0x13 is guest
659
- * visible (to match KVM's encoding); cp==0 will be converted to
660
- * cp==0x13 when the ARMCPRegInfo is registered, for convenience.
661
- */
662
- uint8_t cp;
663
- uint8_t crn;
664
- uint8_t crm;
665
- uint8_t opc0;
666
- uint8_t opc1;
667
- uint8_t opc2;
668
- /* Execution state in which this register is visible: ARM_CP_STATE_* */
669
- int state;
670
- /* Register type: ARM_CP_* bits/values */
671
- int type;
672
- /* Access rights: PL*_[RW] */
673
- int access;
674
- /* Security state: ARM_CP_SECSTATE_* bits/values */
675
- int secure;
676
- /* The opaque pointer passed to define_arm_cp_regs_with_opaque() when
677
- * this register was defined: can be used to hand data through to the
678
- * register read/write functions, since they are passed the ARMCPRegInfo*.
679
- */
680
- void *opaque;
681
- /* Value of this register, if it is ARM_CP_CONST. Otherwise, if
682
- * fieldoffset is non-zero, the reset value of the register.
683
- */
684
- uint64_t resetvalue;
685
- /* Offset of the field in CPUARMState for this register.
686
- *
687
- * This is not needed if either:
688
- * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs
689
- * 2. both readfn and writefn are specified
690
- */
691
- ptrdiff_t fieldoffset; /* offsetof(CPUARMState, field) */
692
-
693
- /* Offsets of the secure and non-secure fields in CPUARMState for the
694
- * register if it is banked. These fields are only used during the static
695
- * registration of a register. During hashing the bank associated
696
- * with a given security state is copied to fieldoffset which is used from
697
- * there on out.
698
- *
699
- * It is expected that register definitions use either fieldoffset or
700
- * bank_fieldoffsets in the definition but not both. It is also expected
701
- * that both bank offsets are set when defining a banked register. This
702
- * use indicates that a register is banked.
703
- */
704
- ptrdiff_t bank_fieldoffsets[2];
705
-
706
- /* Function for making any access checks for this register in addition to
707
- * those specified by the 'access' permissions bits. If NULL, no extra
708
- * checks required. The access check is performed at runtime, not at
709
- * translate time.
710
- */
711
- CPAccessFn *accessfn;
712
- /* Function for handling reads of this register. If NULL, then reads
713
- * will be done by loading from the offset into CPUARMState specified
714
- * by fieldoffset.
715
- */
716
- CPReadFn *readfn;
717
- /* Function for handling writes of this register. If NULL, then writes
718
- * will be done by writing to the offset into CPUARMState specified
719
- * by fieldoffset.
720
- */
721
- CPWriteFn *writefn;
722
- /* Function for doing a "raw" read; used when we need to copy
723
- * coprocessor state to the kernel for KVM or out for
724
- * migration. This only needs to be provided if there is also a
725
- * readfn and it has side effects (for instance clear-on-read bits).
726
- */
727
- CPReadFn *raw_readfn;
728
- /* Function for doing a "raw" write; used when we need to copy KVM
729
- * kernel coprocessor state into userspace, or for inbound
730
- * migration. This only needs to be provided if there is also a
731
- * writefn and it masks out "unwritable" bits or has write-one-to-clear
732
- * or similar behaviour.
733
- */
734
- CPWriteFn *raw_writefn;
735
- /* Function for resetting the register. If NULL, then reset will be done
736
- * by writing resetvalue to the field specified in fieldoffset. If
737
- * fieldoffset is 0 then no reset will be done.
738
- */
739
- CPResetFn *resetfn;
740
-
741
- /*
742
- * "Original" writefn and readfn.
743
- * For ARMv8.1-VHE register aliases, we overwrite the read/write
744
- * accessor functions of various EL1/EL0 to perform the runtime
745
- * check for which sysreg should actually be modified, and then
746
- * forwards the operation. Before overwriting the accessors,
747
- * the original function is copied here, so that accesses that
748
- * really do go to the EL1/EL0 version proceed normally.
749
- * (The corresponding EL2 register is linked via opaque.)
750
- */
751
- CPReadFn *orig_readfn;
752
- CPWriteFn *orig_writefn;
753
-};
754
-
755
-/* Macros which are lvalues for the field in CPUARMState for the
756
- * ARMCPRegInfo *ri.
757
- */
758
-#define CPREG_FIELD32(env, ri) \
759
- (*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
760
-#define CPREG_FIELD64(env, ri) \
761
- (*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
762
-
763
-#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL }
764
-
765
-void define_arm_cp_regs_with_opaque(ARMCPU *cpu,
766
- const ARMCPRegInfo *regs, void *opaque);
767
-void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
768
- const ARMCPRegInfo *regs, void *opaque);
769
-static inline void define_arm_cp_regs(ARMCPU *cpu, const ARMCPRegInfo *regs)
770
-{
771
- define_arm_cp_regs_with_opaque(cpu, regs, 0);
772
-}
773
-static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs)
774
-{
775
- define_one_arm_cp_reg_with_opaque(cpu, regs, 0);
776
-}
777
-const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp);
778
-
779
-/*
780
- * Definition of an ARM co-processor register as viewed from
781
- * userspace. This is used for presenting sanitised versions of
782
- * registers to userspace when emulating the Linux AArch64 CPU
783
- * ID/feature ABI (advertised as HWCAP_CPUID).
784
- */
785
-typedef struct ARMCPRegUserSpaceInfo {
786
- /* Name of register */
787
- const char *name;
788
-
789
- /* Is the name actually a glob pattern */
790
- bool is_glob;
791
-
792
- /* Only some bits are exported to user space */
793
- uint64_t exported_bits;
794
-
795
- /* Fixed bits are applied after the mask */
796
- uint64_t fixed_bits;
797
-} ARMCPRegUserSpaceInfo;
798
-
799
-#define REGUSERINFO_SENTINEL { .name = NULL }
800
-
801
-void modify_arm_cp_regs(ARMCPRegInfo *regs, const ARMCPRegUserSpaceInfo *mods);
802
-
803
-/* CPWriteFn that can be used to implement writes-ignored behaviour */
804
-void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,
805
- uint64_t value);
806
-/* CPReadFn that can be used for read-as-zero behaviour */
807
-uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri);
808
-
809
-/* CPResetFn that does nothing, for use if no reset is required even
810
- * if fieldoffset is non zero.
811
- */
812
-void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque);
813
-
814
-/* Return true if this reginfo struct's field in the cpu state struct
815
- * is 64 bits wide.
816
- */
817
-static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri)
818
-{
819
- return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT);
820
-}
821
-
822
-static inline bool cp_access_ok(int current_el,
823
- const ARMCPRegInfo *ri, int isread)
824
-{
825
- return (ri->access >> ((current_el * 2) + isread)) & 1;
826
-}
827
-
828
-/* Raw read of a coprocessor register (as needed for migration, etc) */
829
-uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri);
830
-
831
/**
832
* write_list_to_cpustate
833
* @cpu: ARMCPU
834
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
835
index XXXXXXX..XXXXXXX 100644
836
--- a/hw/arm/pxa2xx.c
837
+++ b/hw/arm/pxa2xx.c
838
@@ -XXX,XX +XXX,XX @@
839
#include "qemu/cutils.h"
840
#include "qemu/log.h"
841
#include "qom/object.h"
842
+#include "target/arm/cpregs.h"
843
844
static struct {
845
hwaddr io_base;
846
diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c
847
index XXXXXXX..XXXXXXX 100644
848
--- a/hw/arm/pxa2xx_pic.c
849
+++ b/hw/arm/pxa2xx_pic.c
850
@@ -XXX,XX +XXX,XX @@
851
#include "hw/sysbus.h"
852
#include "migration/vmstate.h"
853
#include "qom/object.h"
854
+#include "target/arm/cpregs.h"
855
856
#define ICIP    0x00    /* Interrupt Controller IRQ Pending register */
857
#define ICMR    0x04    /* Interrupt Controller Mask register */
858
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
859
index XXXXXXX..XXXXXXX 100644
860
--- a/hw/intc/arm_gicv3_cpuif.c
861
+++ b/hw/intc/arm_gicv3_cpuif.c
862
@@ -XXX,XX +XXX,XX @@
863
#include "gicv3_internal.h"
864
#include "hw/irq.h"
865
#include "cpu.h"
866
+#include "target/arm/cpregs.h"
867
868
/*
869
* Special case return value from hppvi_index(); must be larger than
870
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
871
index XXXXXXX..XXXXXXX 100644
872
--- a/hw/intc/arm_gicv3_kvm.c
873
+++ b/hw/intc/arm_gicv3_kvm.c
874
@@ -XXX,XX +XXX,XX @@
875
#include "vgic_common.h"
876
#include "migration/blocker.h"
877
#include "qom/object.h"
878
+#include "target/arm/cpregs.h"
879
+
880
881
#ifdef DEBUG_GICV3_KVM
882
#define DPRINTF(fmt, ...) \
883
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
884
index XXXXXXX..XXXXXXX 100644
885
--- a/target/arm/cpu.c
886
+++ b/target/arm/cpu.c
887
@@ -XXX,XX +XXX,XX @@
888
#include "kvm_arm.h"
889
#include "disas/capstone.h"
890
#include "fpu/softfloat.h"
891
+#include "cpregs.h"
892
893
static void arm_cpu_set_pc(CPUState *cs, vaddr value)
894
{
895
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
896
index XXXXXXX..XXXXXXX 100644
897
--- a/target/arm/cpu64.c
898
+++ b/target/arm/cpu64.c
899
@@ -XXX,XX +XXX,XX @@
900
#include "hvf_arm.h"
901
#include "qapi/visitor.h"
902
#include "hw/qdev-properties.h"
903
+#include "cpregs.h"
904
905
906
#ifndef CONFIG_USER_ONLY
907
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
908
index XXXXXXX..XXXXXXX 100644
909
--- a/target/arm/cpu_tcg.c
910
+++ b/target/arm/cpu_tcg.c
911
@@ -XXX,XX +XXX,XX @@
912
#if !defined(CONFIG_USER_ONLY)
913
#include "hw/boards.h"
914
#endif
915
+#include "cpregs.h"
916
917
/* CPU models. These are not needed for the AArch64 linux-user build. */
918
#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
919
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
920
index XXXXXXX..XXXXXXX 100644
921
--- a/target/arm/gdbstub.c
922
+++ b/target/arm/gdbstub.c
923
@@ -XXX,XX +XXX,XX @@
924
*/
925
#include "qemu/osdep.h"
926
#include "cpu.h"
927
-#include "internals.h"
928
#include "exec/gdbstub.h"
929
+#include "internals.h"
930
+#include "cpregs.h"
931
932
typedef struct RegisterSysregXmlParam {
933
CPUState *cs;
934
diff --git a/target/arm/helper.c b/target/arm/helper.c
935
index XXXXXXX..XXXXXXX 100644
936
--- a/target/arm/helper.c
937
+++ b/target/arm/helper.c
938
@@ -XXX,XX +XXX,XX @@
939
#include "exec/cpu_ldst.h"
940
#include "semihosting/common-semi.h"
941
#endif
942
+#include "cpregs.h"
943
944
#define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */
945
#define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */
946
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
947
index XXXXXXX..XXXXXXX 100644
948
--- a/target/arm/op_helper.c
949
+++ b/target/arm/op_helper.c
950
@@ -XXX,XX +XXX,XX @@
951
#include "internals.h"
952
#include "exec/exec-all.h"
953
#include "exec/cpu_ldst.h"
954
+#include "cpregs.h"
955
956
#define SIGNBIT (uint32_t)0x80000000
957
#define SIGNBIT64 ((uint64_t)1 << 63)
958
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
959
index XXXXXXX..XXXXXXX 100644
960
--- a/target/arm/translate-a64.c
961
+++ b/target/arm/translate-a64.c
962
@@ -XXX,XX +XXX,XX @@
963
#include "translate.h"
964
#include "internals.h"
965
#include "qemu/host-utils.h"
966
-
967
#include "semihosting/semihost.h"
968
#include "exec/gen-icount.h"
969
-
970
#include "exec/helper-proto.h"
971
#include "exec/helper-gen.h"
972
#include "exec/log.h"
973
-
974
+#include "cpregs.h"
975
#include "translate-a64.h"
976
#include "qemu/atomic128.h"
977
978
diff --git a/target/arm/translate.c b/target/arm/translate.c
979
index XXXXXXX..XXXXXXX 100644
980
--- a/target/arm/translate.c
981
+++ b/target/arm/translate.c
982
@@ -XXX,XX +XXX,XX @@
983
#include "qemu/bitops.h"
984
#include "arm_ldst.h"
985
#include "semihosting/semihost.h"
986
-
987
#include "exec/helper-proto.h"
988
#include "exec/helper-gen.h"
989
-
990
#include "exec/log.h"
991
+#include "cpregs.h"
992
993
994
#define ENABLE_ARCH_4T arm_dc_feature(s, ARM_FEATURE_V4T)
995
--
77
--
996
2.25.1
78
2.25.1
997
79
998
80
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The new_key field is always non-zero -- drop the if.
3
Remove the use of regime_is_secure from get_phys_addr_v6,
4
passing the new parameter to the lookup instead.
4
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-15-richard.henderson@linaro.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20220501055028.646596-11-richard.henderson@linaro.org
8
[PMM: reinstated dropped PL3_RW mask]
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 | 23 +++++++++++------------
12
target/arm/ptw.c | 11 +++++------
12
1 file changed, 11 insertions(+), 12 deletions(-)
13
1 file changed, 5 insertions(+), 6 deletions(-)
13
14
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
17
--- a/target/arm/ptw.c
17
+++ b/target/arm/helper.c
18
+++ b/target/arm/ptw.c
18
@@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu)
19
@@ -XXX,XX +XXX,XX @@ do_fault:
19
20
20
for (i = 0; i < ARRAY_SIZE(aliases); i++) {
21
static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
21
const struct E2HAlias *a = &aliases[i];
22
MMUAccessType access_type, ARMMMUIdx mmu_idx,
22
- ARMCPRegInfo *src_reg, *dst_reg;
23
- GetPhysAddrResult *result, ARMMMUFaultInfo *fi)
23
+ ARMCPRegInfo *src_reg, *dst_reg, *new_reg;
24
+ bool is_secure, GetPhysAddrResult *result,
24
+ uint32_t *new_key;
25
+ ARMMMUFaultInfo *fi)
25
+ bool ok;
26
{
26
27
ARMCPU *cpu = env_archcpu(env);
27
if (a->feature && !a->feature(&cpu->isar)) {
28
int level = 1;
28
continue;
29
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
29
@@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu)
30
fi->type = ARMFault_Translation;
30
g_assert(src_reg->opaque == NULL);
31
goto do_fault;
31
32
}
32
/* Create alias before redirection so we dup the right data. */
33
- desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx),
33
- if (a->new_key) {
34
- mmu_idx, fi);
34
- ARMCPRegInfo *new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo));
35
+ desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi);
35
- uint32_t *new_key = g_memdup(&a->new_key, sizeof(uint32_t));
36
if (fi->type != ARMFault_None) {
36
- bool ok;
37
goto do_fault;
37
+ new_reg = g_memdup(src_reg, sizeof(ARMCPRegInfo));
38
}
38
+ new_key = g_memdup(&a->new_key, sizeof(uint32_t));
39
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address,
39
40
ns = extract32(desc, 3, 1);
40
- new_reg->name = a->new_name;
41
/* Lookup l2 entry. */
41
- new_reg->type |= ARM_CP_ALIAS;
42
table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc);
42
- /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */
43
- desc = arm_ldl_ptw(env, table, regime_is_secure(env, mmu_idx),
43
- new_reg->access &= PL2_RW | PL3_RW;
44
- mmu_idx, fi);
44
+ new_reg->name = a->new_name;
45
+ desc = arm_ldl_ptw(env, table, is_secure, mmu_idx, fi);
45
+ new_reg->type |= ARM_CP_ALIAS;
46
if (fi->type != ARMFault_None) {
46
+ /* Remove PL1/PL0 access, leaving PL2/PL3 R/W in place. */
47
goto do_fault;
47
+ new_reg->access &= PL2_RW | PL3_RW;
48
}
48
49
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
49
- ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg);
50
result, fi);
50
- g_assert(ok);
51
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
51
- }
52
return get_phys_addr_v6(env, address, access_type, mmu_idx,
52
+ ok = g_hash_table_insert(cpu->cp_regs, new_key, new_reg);
53
- result, fi);
53
+ g_assert(ok);
54
+ is_secure, result, fi);
54
55
} else {
55
src_reg->opaque = dst_reg;
56
return get_phys_addr_v5(env, address, access_type, mmu_idx,
56
src_reg->orig_readfn = src_reg->readfn ?: raw_read;
57
is_secure, result, fi);
57
--
58
--
58
2.25.1
59
2.25.1
60
61
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This controls whether the PACI{A,B}SP instructions trap with BTYPE=3
3
Remove the use of regime_is_secure from get_phys_addr_pmsav8.
4
(indirect branch from register other than x16/x17). The linux kernel
4
Since we already had a local variable named secure, use that.
5
sets this in bti_enable().
6
5
7
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/998
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-16-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20220427042312.294300-1-richard.henderson@linaro.org
11
[PMM: remove stray change to makefile comment]
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
11
---
14
target/arm/cpu.c | 2 ++
12
target/arm/ptw.c | 5 ++---
15
tests/tcg/aarch64/bti-3.c | 42 +++++++++++++++++++++++++++++++
13
1 file changed, 2 insertions(+), 3 deletions(-)
16
tests/tcg/aarch64/Makefile.target | 6 ++---
17
3 files changed, 47 insertions(+), 3 deletions(-)
18
create mode 100644 tests/tcg/aarch64/bti-3.c
19
14
20
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.c
17
--- a/target/arm/ptw.c
23
+++ b/target/arm/cpu.c
18
+++ b/target/arm/ptw.c
24
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev)
19
@@ -XXX,XX +XXX,XX @@ void v8m_security_lookup(CPUARMState *env, uint32_t address,
25
/* Enable all PAC keys. */
20
26
env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB |
21
static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
27
SCTLR_EnDA | SCTLR_EnDB);
22
MMUAccessType access_type, ARMMMUIdx mmu_idx,
28
+ /* Trap on btype=3 for PACIxSP. */
23
- GetPhysAddrResult *result,
29
+ env->cp15.sctlr_el[1] |= SCTLR_BT0;
24
+ bool secure, GetPhysAddrResult *result,
30
/* and to the FP/Neon instructions */
25
ARMMMUFaultInfo *fi)
31
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3);
26
{
32
/* and to the SVE instructions */
27
- uint32_t secure = regime_is_secure(env, mmu_idx);
33
diff --git a/tests/tcg/aarch64/bti-3.c b/tests/tcg/aarch64/bti-3.c
28
V8M_SAttributes sattrs = {};
34
new file mode 100644
29
bool ret;
35
index XXXXXXX..XXXXXXX
30
36
--- /dev/null
31
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
37
+++ b/tests/tcg/aarch64/bti-3.c
32
if (arm_feature(env, ARM_FEATURE_V8)) {
38
@@ -XXX,XX +XXX,XX @@
33
/* PMSAv8 */
39
+/*
34
ret = get_phys_addr_pmsav8(env, address, access_type, mmu_idx,
40
+ * BTI vs PACIASP
35
- result, fi);
41
+ */
36
+ is_secure, result, fi);
42
+
37
} else if (arm_feature(env, ARM_FEATURE_V7)) {
43
+#include "bti-crt.inc.c"
38
/* PMSAv7 */
44
+
39
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
45
+static void skip2_sigill(int sig, siginfo_t *info, ucontext_t *uc)
46
+{
47
+ uc->uc_mcontext.pc += 8;
48
+ uc->uc_mcontext.pstate = 1;
49
+}
50
+
51
+#define BTYPE_1() \
52
+ asm("mov %0,#1; adr x16, 1f; br x16; 1: hint #25; mov %0,#0" \
53
+ : "=r"(skipped) : : "x16", "x30")
54
+
55
+#define BTYPE_2() \
56
+ asm("mov %0,#1; adr x16, 1f; blr x16; 1: hint #25; mov %0,#0" \
57
+ : "=r"(skipped) : : "x16", "x30")
58
+
59
+#define BTYPE_3() \
60
+ asm("mov %0,#1; adr x15, 1f; br x15; 1: hint #25; mov %0,#0" \
61
+ : "=r"(skipped) : : "x15", "x30")
62
+
63
+#define TEST(WHICH, EXPECT) \
64
+ do { WHICH(); fail += skipped ^ EXPECT; } while (0)
65
+
66
+int main()
67
+{
68
+ int fail = 0;
69
+ int skipped;
70
+
71
+ /* Signal-like with SA_SIGINFO. */
72
+ signal_info(SIGILL, skip2_sigill);
73
+
74
+ /* With SCTLR_EL1.BT0 set, PACIASP is not compatible with type=3. */
75
+ TEST(BTYPE_1, 0);
76
+ TEST(BTYPE_2, 0);
77
+ TEST(BTYPE_3, 1);
78
+
79
+ return fail;
80
+}
81
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
82
index XXXXXXX..XXXXXXX 100644
83
--- a/tests/tcg/aarch64/Makefile.target
84
+++ b/tests/tcg/aarch64/Makefile.target
85
@@ -XXX,XX +XXX,XX @@ endif
86
# BTI Tests
87
# bti-1 tests the elf notes, so we require special compiler support.
88
ifneq ($(CROSS_CC_HAS_ARMV8_BTI),)
89
-AARCH64_TESTS += bti-1
90
-bti-1: CFLAGS += -mbranch-protection=standard
91
-bti-1: LDFLAGS += -nostdlib
92
+AARCH64_TESTS += bti-1 bti-3
93
+bti-1 bti-3: CFLAGS += -mbranch-protection=standard
94
+bti-1 bti-3: LDFLAGS += -nostdlib
95
endif
96
# bti-2 tests PROT_BTI, so no special compiler support required.
97
AARCH64_TESTS += bti-2
98
--
40
--
99
2.25.1
41
2.25.1
42
43
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Give this enum a name and use in ARMCPRegInfo,
3
Remove the use of regime_is_secure from pmsav7_use_background_region,
4
add_cpreg_to_hashtable and define_one_arm_cp_reg_with_opaque.
4
using the new parameter instead.
5
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-17-richard.henderson@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220501055028.646596-9-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
target/arm/cpregs.h | 6 +++---
12
target/arm/ptw.c | 10 +++++-----
13
target/arm/helper.c | 6 ++++--
13
1 file changed, 5 insertions(+), 5 deletions(-)
14
2 files changed, 7 insertions(+), 5 deletions(-)
15
14
16
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpregs.h
17
--- a/target/arm/ptw.c
19
+++ b/target/arm/cpregs.h
18
+++ b/target/arm/ptw.c
20
@@ -XXX,XX +XXX,XX @@ enum {
19
@@ -XXX,XX +XXX,XX @@ static bool m_is_system_region(CPUARMState *env, uint32_t address)
21
* Note that we rely on the values of these enums as we iterate through
22
* the various states in some places.
23
*/
24
-enum {
25
+typedef enum {
26
ARM_CP_STATE_AA32 = 0,
27
ARM_CP_STATE_AA64 = 1,
28
ARM_CP_STATE_BOTH = 2,
29
-};
30
+} CPState;
31
32
/*
33
* ARM CP register secure state flags. These flags identify security state
34
@@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo {
35
uint8_t opc1;
36
uint8_t opc2;
37
/* Execution state in which this register is visible: ARM_CP_STATE_* */
38
- int state;
39
+ CPState state;
40
/* Register type: ARM_CP_* bits/values */
41
int type;
42
/* Access rights: PL*_[RW] */
43
diff --git a/target/arm/helper.c b/target/arm/helper.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/helper.c
46
+++ b/target/arm/helper.c
47
@@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
48
}
20
}
49
21
50
static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
22
static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
51
- void *opaque, int state, int secstate,
23
- bool is_user)
52
+ void *opaque, CPState state, int secstate,
24
+ bool is_secure, bool is_user)
53
int crm, int opc1, int opc2,
54
const char *name)
55
{
25
{
56
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
26
/*
57
* bits; the ARM_CP_64BIT* flag applies only to the AArch32 view of
27
* Return true if we should use the default memory map as a
58
* the register, if any.
28
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
59
*/
29
}
60
- int crm, opc1, opc2, state;
30
61
+ int crm, opc1, opc2;
31
if (arm_feature(env, ARM_FEATURE_M)) {
62
int crmmin = (r->crm == CP_ANY) ? 0 : r->crm;
32
- return env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)]
63
int crmmax = (r->crm == CP_ANY) ? 15 : r->crm;
33
- & R_V7M_MPU_CTRL_PRIVDEFENA_MASK;
64
int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1;
34
+ return env->v7m.mpu_ctrl[is_secure] & R_V7M_MPU_CTRL_PRIVDEFENA_MASK;
65
int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1;
35
} else {
66
int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2;
36
return regime_sctlr(env, mmu_idx) & SCTLR_BR;
67
int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2;
37
}
68
+ CPState state;
38
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
69
+
39
{
70
/* 64 bit registers have only CRm and Opc1 fields */
40
ARMCPU *cpu = env_archcpu(env);
71
assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn)));
41
int n;
72
/* op0 only exists in the AArch64 encodings */
42
+ bool secure = regime_is_secure(env, mmu_idx);
43
bool is_user = regime_is_user(env, mmu_idx);
44
45
result->phys = address;
46
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
47
}
48
49
if (n == -1) { /* no hits */
50
- if (!pmsav7_use_background_region(cpu, mmu_idx, is_user)) {
51
+ if (!pmsav7_use_background_region(cpu, mmu_idx, secure, is_user)) {
52
/* background fault */
53
fi->type = ARMFault_Background;
54
return true;
55
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
56
} else if (m_is_ppb_region(env, address)) {
57
hit = true;
58
} else {
59
- if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) {
60
+ if (pmsav7_use_background_region(cpu, mmu_idx, secure, is_user)) {
61
hit = true;
62
}
63
73
--
64
--
74
2.25.1
65
2.25.1
75
66
76
67
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Create a typedef as well, and use it in ARMCPRegInfo.
3
Remove the use of regime_is_secure from get_phys_addr_pmsav7,
4
This won't be perfect for debugging, but it'll nicely
4
using the new parameter instead.
5
display the most common cases.
6
5
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220822152741.1617527-19-richard.henderson@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220501055028.646596-8-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
target/arm/cpregs.h | 44 +++++++++++++++++++++++---------------------
12
target/arm/ptw.c | 5 ++---
13
target/arm/helper.c | 2 +-
13
1 file changed, 2 insertions(+), 3 deletions(-)
14
2 files changed, 24 insertions(+), 22 deletions(-)
15
14
16
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
15
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpregs.h
17
--- a/target/arm/ptw.c
19
+++ b/target/arm/cpregs.h
18
+++ b/target/arm/ptw.c
20
@@ -XXX,XX +XXX,XX @@ enum {
19
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
21
* described with these bits, then use a laxer set of restrictions, and
20
22
* do the more restrictive/complex check inside a helper function.
21
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
23
*/
22
MMUAccessType access_type, ARMMMUIdx mmu_idx,
24
-#define PL3_R 0x80
23
- GetPhysAddrResult *result,
25
-#define PL3_W 0x40
24
+ bool secure, GetPhysAddrResult *result,
26
-#define PL2_R (0x20 | PL3_R)
25
ARMMMUFaultInfo *fi)
27
-#define PL2_W (0x10 | PL3_W)
26
{
28
-#define PL1_R (0x08 | PL2_R)
27
ARMCPU *cpu = env_archcpu(env);
29
-#define PL1_W (0x04 | PL2_W)
28
int n;
30
-#define PL0_R (0x02 | PL1_R)
29
- bool secure = regime_is_secure(env, mmu_idx);
31
-#define PL0_W (0x01 | PL1_W)
30
bool is_user = regime_is_user(env, mmu_idx);
32
+typedef enum {
31
33
+ PL3_R = 0x80,
32
result->phys = address;
34
+ PL3_W = 0x40,
33
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
35
+ PL2_R = 0x20 | PL3_R,
34
} else if (arm_feature(env, ARM_FEATURE_V7)) {
36
+ PL2_W = 0x10 | PL3_W,
35
/* PMSAv7 */
37
+ PL1_R = 0x08 | PL2_R,
36
ret = get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
38
+ PL1_W = 0x04 | PL2_W,
37
- result, fi);
39
+ PL0_R = 0x02 | PL1_R,
38
+ is_secure, result, fi);
40
+ PL0_W = 0x01 | PL1_W,
39
} else {
41
40
/* Pre-v7 MPU */
42
-/*
41
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
43
- * For user-mode some registers are accessible to EL0 via a kernel
44
- * trap-and-emulate ABI. In this case we define the read permissions
45
- * as actually being PL0_R. However some bits of any given register
46
- * may still be masked.
47
- */
48
+ /*
49
+ * For user-mode some registers are accessible to EL0 via a kernel
50
+ * trap-and-emulate ABI. In this case we define the read permissions
51
+ * as actually being PL0_R. However some bits of any given register
52
+ * may still be masked.
53
+ */
54
#ifdef CONFIG_USER_ONLY
55
-#define PL0U_R PL0_R
56
+ PL0U_R = PL0_R,
57
#else
58
-#define PL0U_R PL1_R
59
+ PL0U_R = PL1_R,
60
#endif
61
62
-#define PL3_RW (PL3_R | PL3_W)
63
-#define PL2_RW (PL2_R | PL2_W)
64
-#define PL1_RW (PL1_R | PL1_W)
65
-#define PL0_RW (PL0_R | PL0_W)
66
+ PL3_RW = PL3_R | PL3_W,
67
+ PL2_RW = PL2_R | PL2_W,
68
+ PL1_RW = PL1_R | PL1_W,
69
+ PL0_RW = PL0_R | PL0_W,
70
+} CPAccessRights;
71
72
typedef enum CPAccessResult {
73
/* Access is permitted */
74
@@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo {
75
/* Register type: ARM_CP_* bits/values */
76
int type;
77
/* Access rights: PL*_[RW] */
78
- int access;
79
+ CPAccessRights access;
80
/* Security state: ARM_CP_SECSTATE_* bits/values */
81
int secure;
82
/*
83
diff --git a/target/arm/helper.c b/target/arm/helper.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/target/arm/helper.c
86
+++ b/target/arm/helper.c
87
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
88
* to encompass the generic architectural permission check.
89
*/
90
if (r->state != ARM_CP_STATE_AA32) {
91
- int mask = 0;
92
+ CPAccessRights mask;
93
switch (r->opc1) {
94
case 0:
95
/* min_EL EL1, but some accessible to EL0 via kernel ABI */
96
--
42
--
97
2.25.1
43
2.25.1
44
45
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Bool is a more appropriate type for these variables.
3
Remove the use of regime_is_secure from get_phys_addr_pmsav5.
4
4
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220822152741.1617527-21-richard.henderson@linaro.org
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20220501055028.646596-16-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
---
10
target/arm/helper.c | 4 ++--
11
target/arm/ptw.c | 4 ++--
11
1 file changed, 2 insertions(+), 2 deletions(-)
12
1 file changed, 2 insertions(+), 2 deletions(-)
12
13
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
--- a/target/arm/ptw.c
16
+++ b/target/arm/helper.c
17
+++ b/target/arm/ptw.c
17
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
18
@@ -XXX,XX +XXX,XX @@ do_fault:
18
*/
19
19
uint32_t key;
20
static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
20
ARMCPRegInfo *r2;
21
MMUAccessType access_type, ARMMMUIdx mmu_idx,
21
- int is64 = (r->type & ARM_CP_64BIT) ? 1 : 0;
22
- GetPhysAddrResult *result,
22
- int ns = (secstate & ARM_CP_SECSTATE_NS) ? 1 : 0;
23
+ bool is_secure, GetPhysAddrResult *result,
23
+ bool is64 = r->type & ARM_CP_64BIT;
24
ARMMMUFaultInfo *fi)
24
+ bool ns = secstate & ARM_CP_SECSTATE_NS;
25
{
25
int cp = r->cp;
26
int n;
26
size_t name_len;
27
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
27
28
} else {
29
/* Pre-v7 MPU */
30
ret = get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
31
- result, fi);
32
+ is_secure, result, fi);
33
}
34
qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32
35
" mmu_idx %u -> %s (prot %c%c%c)\n",
28
--
36
--
29
2.25.1
37
2.25.1
38
39
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Keqian Zhu <zhukeqian1@huawei.com>
2
2
3
Add the aa64 predicate for detecting RAS support from id registers.
3
Setup an ARM virtual machine of machine virt and execute qmp "query-acpi-ospm-status"
4
We already have the aa32 version from the M-profile work.
4
causes segmentation fault with following dumpstack:
5
Add the 'any' predicate for testing both aa64 and aa32.
5
#1 0x0000aaaaab64235c in qmp_query_acpi_ospm_status (errp=errp@entry=0xfffffffff030) at ../monitor/qmp-cmds.c:312
6
#2 0x0000aaaaabfc4e20 in qmp_marshal_query_acpi_ospm_status (args=<optimized out>, ret=0xffffea4ffe90, errp=0xffffea4ffe88) at qapi/qapi-commands-acpi.c:63
7
#3 0x0000aaaaabff8ba0 in do_qmp_dispatch_bh (opaque=0xffffea4ffe98) at ../qapi/qmp-dispatch.c:128
8
#4 0x0000aaaaac02e594 in aio_bh_call (bh=0xffffe0004d80) at ../util/async.c:150
9
#5 aio_bh_poll (ctx=ctx@entry=0xaaaaad0f6040) at ../util/async.c:178
10
#6 0x0000aaaaac00bd40 in aio_dispatch (ctx=ctx@entry=0xaaaaad0f6040) at ../util/aio-posix.c:421
11
#7 0x0000aaaaac02e010 in aio_ctx_dispatch (source=0xaaaaad0f6040, callback=<optimized out>, user_data=<optimized out>) at ../util/async.c:320
12
#8 0x0000fffff76f6884 in g_main_context_dispatch () at /usr/lib64/libglib-2.0.so.0
13
#9 0x0000aaaaac0452d4 in glib_pollfds_poll () at ../util/main-loop.c:297
14
#10 os_host_main_loop_wait (timeout=0) at ../util/main-loop.c:320
15
#11 main_loop_wait (nonblocking=nonblocking@entry=0) at ../util/main-loop.c:596
16
#12 0x0000aaaaab5c9e50 in qemu_main_loop () at ../softmmu/runstate.c:734
17
#13 0x0000aaaaab185370 in qemu_main (argc=argc@entry=47, argv=argv@entry=0xfffffffff518, envp=envp@entry=0x0) at ../softmmu/main.c:38
18
#14 0x0000aaaaab16f99c in main (argc=47, argv=0xfffffffff518) at ../softmmu/main.c:47
6
19
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
Fixes: ebb62075021a ("hw/acpi: Add ACPI Generic Event Device Support")
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
21
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
9
Message-id: 20220501055028.646596-34-richard.henderson@linaro.org
22
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
23
Message-id: 20220816094957.31700-1-zhukeqian1@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
25
---
12
target/arm/cpu.h | 10 ++++++++++
26
hw/acpi/generic_event_device.c | 8 ++++++++
13
1 file changed, 10 insertions(+)
27
1 file changed, 8 insertions(+)
14
28
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
29
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
16
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.h
31
--- a/hw/acpi/generic_event_device.c
18
+++ b/target/arm/cpu.h
32
+++ b/hw/acpi/generic_event_device.c
19
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id)
33
@@ -XXX,XX +XXX,XX @@ static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev,
20
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2;
34
}
21
}
35
}
22
36
23
+static inline bool isar_feature_aa64_ras(const ARMISARegisters *id)
37
+static void acpi_ged_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
24
+{
38
+{
25
+ return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0;
39
+ AcpiGedState *s = ACPI_GED(adev);
40
+
41
+ acpi_memory_ospm_status(&s->memhp_state, list);
26
+}
42
+}
27
+
43
+
28
static inline bool isar_feature_aa64_sve(const ARMISARegisters *id)
44
static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
29
{
45
{
30
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0;
46
AcpiGedState *s = ACPI_GED(adev);
31
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_debugv8p2(const ARMISARegisters *id)
47
@@ -XXX,XX +XXX,XX @@ static void acpi_ged_class_init(ObjectClass *class, void *data)
32
return isar_feature_aa64_debugv8p2(id) || isar_feature_aa32_debugv8p2(id);
48
hc->unplug_request = acpi_ged_unplug_request_cb;
49
hc->unplug = acpi_ged_unplug_cb;
50
51
+ adevc->ospm_status = acpi_ged_ospm_status;
52
adevc->send_event = acpi_ged_send_event;
33
}
53
}
34
54
35
+static inline bool isar_feature_any_ras(const ARMISARegisters *id)
36
+{
37
+ return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id);
38
+}
39
+
40
/*
41
* Forward to the above feature tests given an ARMCPU pointer.
42
*/
43
--
55
--
44
2.25.1
56
2.25.1
diff view generated by jsdifflib
1
From: Alex Zuepke <alex.zuepke@tum.de>
1
From: Lucas Dietrich <ld.adecy@gmail.com>
2
2
3
The ARMv8 manual defines that PMUSERENR_EL0.ER enables read-access
3
The LAN9118 allows the guest to specify a level for both the TX and
4
to both PMXEVCNTR_EL0 and PMEVCNTR<n>_EL0 registers, however,
4
RX FIFOs at which an interrupt will be generated. We implement the
5
we only use it for PMXEVCNTR_EL0. Extend to PMEVCNTR<n>_EL0 as well.
5
RSFL_INT interrupt for the RX FIFO but are missing the handling of
6
the equivalent TSFL_INT for the TX FIFO. Add the missing test to set
7
the interrupt if the TX FIFO has exceeded the guest-specified level.
6
8
7
Signed-off-by: Alex Zuepke <alex.zuepke@tum.de>
9
This flag is required for Micrium lan911x ethernet driver to work.
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
9
Message-id: 20220428132717.84190-1-alex.zuepke@tum.de
11
Signed-off-by: Lucas Dietrich <ld.adecy@gmail.com>
12
[PMM: Tweaked commit message and comment]
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
15
---
12
target/arm/helper.c | 4 ++--
16
hw/net/lan9118.c | 8 ++++++++
13
1 file changed, 2 insertions(+), 2 deletions(-)
17
1 file changed, 8 insertions(+)
14
18
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
19
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
21
--- a/hw/net/lan9118.c
18
+++ b/target/arm/helper.c
22
+++ b/hw/net/lan9118.c
19
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
23
@@ -XXX,XX +XXX,XX @@ static void do_tx_packet(lan9118_state *s)
20
.crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7,
24
n = (s->tx_status_fifo_head + s->tx_status_fifo_used) & 511;
21
.access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS,
25
s->tx_status_fifo[n] = status;
22
.readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn,
26
s->tx_status_fifo_used++;
23
- .accessfn = pmreg_access },
27
+
24
+ .accessfn = pmreg_access_xevcntr },
28
+ /*
25
{ .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64,
29
+ * Generate TSFL interrupt if TX FIFO level exceeds the level
26
.opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)),
30
+ * specified in the FIFO_INT TX Status Level field.
27
- .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access,
31
+ */
28
+ .opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access_xevcntr,
32
+ if (s->tx_status_fifo_used > ((s->fifo_int >> 16) & 0xff)) {
29
.type = ARM_CP_IO,
33
+ s->int_sts |= TSFL_INT;
30
.readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn,
34
+ }
31
.raw_readfn = pmevcntr_rawread,
35
if (s->tx_status_fifo_used == 512) {
36
s->int_sts |= TSFF_INT;
37
/* TODO: Stop transmission. */
32
--
38
--
33
2.25.1
39
2.25.1
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Replace '84' magic value by the X_MAX definition, and '1' by Y_MAX.
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-2-peter.maydell@linaro.org
10
---
11
chardev/baum.c | 11 +++++++----
12
1 file changed, 7 insertions(+), 4 deletions(-)
13
14
diff --git a/chardev/baum.c b/chardev/baum.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/chardev/baum.c
17
+++ b/chardev/baum.c
18
@@ -XXX,XX +XXX,XX @@
19
20
#define BUF_SIZE 256
21
22
+#define X_MAX 84
23
+#define Y_MAX 1
24
+
25
struct BaumChardev {
26
Chardev parent;
27
28
@@ -XXX,XX +XXX,XX @@ static int baum_deferred_init(BaumChardev *baum)
29
brlapi_perror("baum: brlapi__getDisplaySize");
30
return 0;
31
}
32
- if (baum->y > 1) {
33
- baum->y = 1;
34
+ if (baum->y > Y_MAX) {
35
+ baum->y = Y_MAX;
36
}
37
- if (baum->x > 84) {
38
- baum->x = 84;
39
+ if (baum->x > X_MAX) {
40
+ baum->x = X_MAX;
41
}
42
43
con = qemu_console_lookup_by_index(0);
44
--
45
2.25.1
46
47
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
We know 'x * y' will be at most 'X_MAX * Y_MAX' (which is not
4
a big value, it is actually 84). Instead of having the compiler
5
use variable-length array, declare an array able to hold the
6
maximum 'x * y'.
7
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
10
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20220819153931.3147384-3-peter.maydell@linaro.org
13
---
14
chardev/baum.c | 8 ++++----
15
1 file changed, 4 insertions(+), 4 deletions(-)
16
17
diff --git a/chardev/baum.c b/chardev/baum.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/chardev/baum.c
20
+++ b/chardev/baum.c
21
@@ -XXX,XX +XXX,XX @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
22
switch (req) {
23
case BAUM_REQ_DisplayData:
24
{
25
- uint8_t cells[baum->x * baum->y], c;
26
- uint8_t text[baum->x * baum->y];
27
- uint8_t zero[baum->x * baum->y];
28
+ uint8_t cells[X_MAX * Y_MAX], c;
29
+ uint8_t text[X_MAX * Y_MAX];
30
+ uint8_t zero[X_MAX * Y_MAX];
31
int cursor = BRLAPI_CURSOR_OFF;
32
int i;
33
34
@@ -XXX,XX +XXX,XX @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
35
}
36
timer_del(baum->cellCount_timer);
37
38
- memset(zero, 0, sizeof(zero));
39
+ memset(zero, 0, baum->x * baum->y);
40
41
brlapi_writeArguments_t wa = {
42
.displayNumber = BRLAPI_DISPLAY_DEFAULT,
43
--
44
2.25.1
45
46
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20220819153931.3147384-4-peter.maydell@linaro.org
11
---
12
chardev/baum.c | 3 ++-
13
1 file changed, 2 insertions(+), 1 deletion(-)
14
15
diff --git a/chardev/baum.c b/chardev/baum.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/chardev/baum.c
18
+++ b/chardev/baum.c
19
@@ -XXX,XX +XXX,XX @@ static void baum_chr_accept_input(struct Chardev *chr)
20
static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len)
21
{
22
Chardev *chr = CHARDEV(baum);
23
- uint8_t io_buf[1 + 2 * len], *cur = io_buf;
24
+ g_autofree uint8_t *io_buf = g_malloc(1 + 2 * len);
25
+ uint8_t *cur = io_buf;
26
int room;
27
*cur++ = ESC;
28
while (len--)
29
--
30
2.25.1
31
32
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
The combined_key[... QIO_CHANNEL_WEBSOCK_GUID_LEN ...] array in
4
qio_channel_websock_handshake_send_res_ok() expands to a call
5
to strlen(QIO_CHANNEL_WEBSOCK_GUID), and the compiler doesn't
6
realize the string is const, so consider combined_key[] being
7
a variable-length array.
8
9
To remove the variable-length array, we provide it a hint to
10
the compiler by using sizeof() - 1 instead of strlen().
11
12
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Message-id: 20220819153931.3147384-5-peter.maydell@linaro.org
16
---
17
io/channel-websock.c | 2 +-
18
1 file changed, 1 insertion(+), 1 deletion(-)
19
20
diff --git a/io/channel-websock.c b/io/channel-websock.c
21
index XXXXXXX..XXXXXXX 100644
22
--- a/io/channel-websock.c
23
+++ b/io/channel-websock.c
24
@@ -XXX,XX +XXX,XX @@
25
26
#define QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN 24
27
#define QIO_CHANNEL_WEBSOCK_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
28
-#define QIO_CHANNEL_WEBSOCK_GUID_LEN strlen(QIO_CHANNEL_WEBSOCK_GUID)
29
+#define QIO_CHANNEL_WEBSOCK_GUID_LEN (sizeof(QIO_CHANNEL_WEBSOCK_GUID) - 1)
30
31
#define QIO_CHANNEL_WEBSOCK_HEADER_PROTOCOL "sec-websocket-protocol"
32
#define QIO_CHANNEL_WEBSOCK_HEADER_VERSION "sec-websocket-version"
33
--
34
2.25.1
35
36
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
The compiler isn't clever enough to figure 'min_buf_size'
4
is a constant, so help it by using a definitions instead.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Acked-by: Jason Wang <jasowang@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20220819153931.3147384-6-peter.maydell@linaro.org
11
---
12
hw/net/e1000e_core.c | 7 ++++---
13
1 file changed, 4 insertions(+), 3 deletions(-)
14
15
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/net/e1000e_core.c
18
+++ b/hw/net/e1000e_core.c
19
@@ -XXX,XX +XXX,XX @@ e1000e_rx_fix_l4_csum(E1000ECore *core, struct NetRxPkt *pkt)
20
}
21
}
22
23
+/* Min. octets in an ethernet frame sans FCS */
24
+#define MIN_BUF_SIZE 60
25
+
26
ssize_t
27
e1000e_receive_iov(E1000ECore *core, const struct iovec *iov, int iovcnt)
28
{
29
static const int maximum_ethernet_hdr_len = (14 + 4);
30
- /* Min. octets in an ethernet frame sans FCS */
31
- static const int min_buf_size = 60;
32
33
uint32_t n = 0;
34
- uint8_t min_buf[min_buf_size];
35
+ uint8_t min_buf[MIN_BUF_SIZE];
36
struct iovec min_iov;
37
uint8_t *filter_buf;
38
size_t size, orig_size;
39
--
40
2.25.1
41
42
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Acked-by: David Gibson <david@gibson.dropbear.id.au>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
11
Message-id: 20220819153931.3147384-7-peter.maydell@linaro.org
12
---
13
hw/ppc/pnv.c | 4 ++--
14
hw/ppc/spapr.c | 8 ++++----
15
hw/ppc/spapr_pci_nvlink2.c | 2 +-
16
3 files changed, 7 insertions(+), 7 deletions(-)
17
18
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/ppc/pnv.c
21
+++ b/hw/ppc/pnv.c
22
@@ -XXX,XX +XXX,XX @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt)
23
int smt_threads = CPU_CORE(pc)->nr_threads;
24
CPUPPCState *env = &cpu->env;
25
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);
26
- uint32_t servers_prop[smt_threads];
27
+ g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads);
28
int i;
29
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
30
0xffffffff, 0xffffffff};
31
@@ -XXX,XX +XXX,XX @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt)
32
servers_prop[i] = cpu_to_be32(pc->pir + i);
33
}
34
_FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
35
- servers_prop, sizeof(servers_prop))));
36
+ servers_prop, sizeof(*servers_prop) * smt_threads)));
37
}
38
39
static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,
40
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/ppc/spapr.c
43
+++ b/hw/ppc/spapr.c
44
@@ -XXX,XX +XXX,XX @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
45
int smt_threads)
46
{
47
int i, ret = 0;
48
- uint32_t servers_prop[smt_threads];
49
- uint32_t gservers_prop[smt_threads * 2];
50
+ g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads);
51
+ g_autofree uint32_t *gservers_prop = g_new(uint32_t, smt_threads * 2);
52
int index = spapr_get_vcpu_id(cpu);
53
54
if (cpu->compat_pvr) {
55
@@ -XXX,XX +XXX,XX @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
56
gservers_prop[i*2 + 1] = 0;
57
}
58
ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
59
- servers_prop, sizeof(servers_prop));
60
+ servers_prop, sizeof(*servers_prop) * smt_threads);
61
if (ret < 0) {
62
return ret;
63
}
64
ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s",
65
- gservers_prop, sizeof(gservers_prop));
66
+ gservers_prop, sizeof(*gservers_prop) * smt_threads * 2);
67
68
return ret;
69
}
70
diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/ppc/spapr_pci_nvlink2.c
73
+++ b/hw/ppc/spapr_pci_nvlink2.c
74
@@ -XXX,XX +XXX,XX @@ void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int offset,
75
continue;
76
}
77
if (dev == nvslot->gpdev) {
78
- uint32_t npus[nvslot->linknum];
79
+ g_autofree uint32_t *npus = g_new(uint32_t, nvslot->linknum);
80
81
for (j = 0; j < nvslot->linknum; ++j) {
82
PCIDevice *npdev = nvslot->links[j].npdev;
83
--
84
2.25.1
85
86
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Acked-by: David Gibson <david@gibson.dropbear.id.au>
8
Reviewed-by: Greg Kurz <groug@kaod.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20220819153931.3147384-8-peter.maydell@linaro.org
11
---
12
hw/intc/xics.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/xics.c
18
+++ b/hw/intc/xics.c
19
@@ -XXX,XX +XXX,XX @@ static void ics_reset_irq(ICSIRQState *irq)
20
static void ics_reset(DeviceState *dev)
21
{
22
ICSState *ics = ICS(dev);
23
+ g_autofree uint8_t *flags = g_malloc(ics->nr_irqs);
24
int i;
25
- uint8_t flags[ics->nr_irqs];
26
27
for (i = 0; i < ics->nr_irqs; i++) {
28
flags[i] = ics->irqs[i].flags;
29
--
30
2.25.1
31
32
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length array on
4
the stack. Replace the snprintf() call by g_strdup_printf().
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-9-peter.maydell@linaro.org
10
---
11
hw/i386/multiboot.c | 5 ++---
12
1 file changed, 2 insertions(+), 3 deletions(-)
13
14
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/i386/multiboot.c
17
+++ b/hw/i386/multiboot.c
18
@@ -XXX,XX +XXX,XX @@ int load_multiboot(X86MachineState *x86ms,
19
uint8_t *mb_bootinfo_data;
20
uint32_t cmdline_len;
21
GList *mods = NULL;
22
+ g_autofree char *kcmdline = NULL;
23
24
/* Ok, let's see if it is a multiboot image.
25
The header is 12x32bit long, so the latest entry may be 8192 - 48. */
26
@@ -XXX,XX +XXX,XX @@ int load_multiboot(X86MachineState *x86ms,
27
}
28
29
/* Commandline support */
30
- char kcmdline[strlen(kernel_filename) + strlen(kernel_cmdline) + 2];
31
- snprintf(kcmdline, sizeof(kcmdline), "%s %s",
32
- kernel_filename, kernel_cmdline);
33
+ kcmdline = g_strdup_printf("%s %s", kernel_filename, kernel_cmdline);
34
stl_p(bootinfo + MBI_CMDLINE, mb_add_cmdline(&mbs, kcmdline));
35
36
stl_p(bootinfo + MBI_BOOTLOADER, mb_add_bootloader(&mbs, bootloader_name));
37
--
38
2.25.1
39
40
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Put the block comments into the current coding style.
3
The compiler isn't clever enough to figure 'width' is a constant,
4
so help it by using a definitions instead.
4
5
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220501055028.646596-19-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-10-peter.maydell@linaro.org
9
---
10
---
10
target/arm/helper.c | 24 +++++++++++++++---------
11
hw/usb/hcd-ohci.c | 7 ++++---
11
1 file changed, 15 insertions(+), 9 deletions(-)
12
1 file changed, 4 insertions(+), 3 deletions(-)
12
13
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
--- a/hw/usb/hcd-ohci.c
16
+++ b/target/arm/helper.c
17
+++ b/hw/usb/hcd-ohci.c
17
@@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
18
@@ -XXX,XX +XXX,XX @@ static int ohci_service_iso_td(OHCIState *ohci, struct ohci_ed *ed)
18
return cpu_list;
19
return 1;
19
}
20
}
20
21
21
+/*
22
+#define HEX_CHAR_PER_LINE 16
22
+ * Private utility function for define_one_arm_cp_reg_with_opaque():
23
+
23
+ * add a single reginfo struct to the hash table.
24
static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
24
+ */
25
static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
26
void *opaque, CPState state,
27
CPSecureState secstate,
28
int crm, int opc1, int opc2,
29
const char *name)
30
{
25
{
31
- /* Private utility function for define_one_arm_cp_reg_with_opaque():
26
bool print16;
32
- * add a single reginfo struct to the hash table.
27
bool printall;
33
- */
28
- const int width = 16;
34
uint32_t key;
29
int i;
35
ARMCPRegInfo *r2;
30
- char tmp[3 * width + 1];
36
bool is64 = r->type & ARM_CP_64BIT;
31
+ char tmp[3 * HEX_CHAR_PER_LINE + 1];
37
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
32
char *p = tmp;
38
33
39
isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1];
34
print16 = !!trace_event_get_state_backends(TRACE_USB_OHCI_TD_PKT_SHORT);
40
if (isbanked) {
35
@@ -XXX,XX +XXX,XX @@ static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
41
- /* Register is banked (using both entries in array).
42
+ /*
43
+ * Register is banked (using both entries in array).
44
* Overwriting fieldoffset as the array is only used to define
45
* banked registers but later only fieldoffset is used.
46
*/
47
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
48
49
if (state == ARM_CP_STATE_AA32) {
50
if (isbanked) {
51
- /* If the register is banked then we don't need to migrate or
52
+ /*
53
+ * If the register is banked then we don't need to migrate or
54
* reset the 32-bit instance in certain cases:
55
*
56
* 1) If the register has both 32-bit and 64-bit instances then we
57
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
58
r2->type |= ARM_CP_ALIAS;
59
}
60
} else if ((secstate != r->secure) && !ns) {
61
- /* The register is not banked so we only want to allow migration of
62
- * the non-secure instance.
63
+ /*
64
+ * The register is not banked so we only want to allow migration
65
+ * of the non-secure instance.
66
*/
67
r2->type |= ARM_CP_ALIAS;
68
}
69
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
70
}
71
}
36
}
72
37
73
- /* By convention, for wildcarded registers only the first
38
for (i = 0; ; i++) {
74
+ /*
39
- if (i && (!(i % width) || (i == len))) {
75
+ * By convention, for wildcarded registers only the first
40
+ if (i && (!(i % HEX_CHAR_PER_LINE) || (i == len))) {
76
* entry is used for migration; the others are marked as
41
if (!printall) {
77
* ALIAS so we don't try to transfer the register
42
trace_usb_ohci_td_pkt_short(msg, tmp);
78
* multiple times. Special registers (ie NOP/WFI) are
43
break;
79
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
80
r2->type |= ARM_CP_ALIAS | ARM_CP_NO_GDB;
81
}
82
83
- /* Check that raw accesses are either forbidden or handled. Note that
84
+ /*
85
+ * Check that raw accesses are either forbidden or handled. Note that
86
* we can't assert this earlier because the setup of fieldoffset for
87
* banked registers has to be done first.
88
*/
89
--
44
--
90
2.25.1
45
2.25.1
46
47
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-11-peter.maydell@linaro.org
10
---
11
ui/curses.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/ui/curses.c b/ui/curses.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/ui/curses.c
17
+++ b/ui/curses.c
18
@@ -XXX,XX +XXX,XX @@ static void curses_update(DisplayChangeListener *dcl,
19
int x, int y, int w, int h)
20
{
21
console_ch_t *line;
22
- cchar_t curses_line[width];
23
+ g_autofree cchar_t *curses_line = g_new(cchar_t, width);
24
wchar_t wch[CCHARW_MAX];
25
attr_t attrs;
26
short colors;
27
--
28
2.25.1
29
30
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Use autofree heap allocation instead of variable-length
4
array on the stack.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20220819153931.3147384-12-peter.maydell@linaro.org
10
---
11
tests/unit/test-vmstate.c | 7 +++----
12
1 file changed, 3 insertions(+), 4 deletions(-)
13
14
diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/unit/test-vmstate.c
17
+++ b/tests/unit/test-vmstate.c
18
@@ -XXX,XX +XXX,XX @@ static void save_buffer(const uint8_t *buf, size_t buf_size)
19
static void compare_vmstate(const uint8_t *wire, size_t size)
20
{
21
QEMUFile *f = open_test_file(false);
22
- uint8_t result[size];
23
+ g_autofree uint8_t *result = g_malloc(size);
24
25
/* read back as binary */
26
27
- g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==,
28
- sizeof(result));
29
+ g_assert_cmpint(qemu_get_buffer(f, result, size), ==, size);
30
g_assert(!qemu_file_get_error(f));
31
32
/* Compare that what is on the file is the same that what we
33
expected to be there */
34
- SUCCESS(memcmp(result, wire, sizeof(result)));
35
+ SUCCESS(memcmp(result, wire, size));
36
37
/* Must reach EOF */
38
qemu_get_byte(f);
39
--
40
2.25.1
41
42
diff view generated by jsdifflib
New patch
1
Shellcheck correctly reports that we set python_version and never use
2
it. This is a leftover from commit f9332757898a7: we used to use
3
python_version purely to as part of the summary information printed
4
at the end of a configure run, and that commit changed to printing
5
the information from meson (which looks up the python version
6
itself). Remove the unused variable.
1
7
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20220825150703.4074125-2-peter.maydell@linaro.org
12
---
13
configure | 3 ---
14
1 file changed, 3 deletions(-)
15
16
diff --git a/configure b/configure
17
index XXXXXXX..XXXXXXX 100755
18
--- a/configure
19
+++ b/configure
20
@@ -XXX,XX +XXX,XX @@ if ! $python -c 'import sys; sys.exit(sys.version_info < (3,6))'; then
21
"Use --python=/path/to/python to specify a supported Python."
22
fi
23
24
-# Preserve python version since some functionality is dependent on it
25
-python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0], sys.version_info[1], sys.version_info[2]))' 2>/dev/null)
26
-
27
# Suppress writing compiled files
28
python="$python -B"
29
30
--
31
2.25.1
32
33
diff view generated by jsdifflib
New patch
1
The meson_args variable was added in commit 3b4da13293482134b, but
2
was not used in that commit and isn't used today. Delete the
3
unnecessary assignment.
1
4
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220825150703.4074125-3-peter.maydell@linaro.org
9
---
10
configure | 1 -
11
1 file changed, 1 deletion(-)
12
13
diff --git a/configure b/configure
14
index XXXXXXX..XXXXXXX 100755
15
--- a/configure
16
+++ b/configure
17
@@ -XXX,XX +XXX,XX @@ pie=""
18
coroutine=""
19
plugins="$default_feature"
20
meson=""
21
-meson_args=""
22
ninja=""
23
bindir="bin"
24
skip_meson=no
25
--
26
2.25.1
27
28
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
This commit adds quotes in some places which:
2
2
* are spotted by shellcheck
3
Give this enum a name and use in ARMCPRegInfo and add_cpreg_to_hashtable.
3
* are obviously incorrect
4
Add the enumerator ARM_CP_SECSTATE_BOTH to clarify how 0
4
* are easy to fix just by adding the quotes
5
is handled in define_one_arm_cp_reg_with_opaque.
5
6
6
It doesn't attempt fix all of the places shellcheck finds errors,
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
or even all the ones which are easy to fix. It's just a random
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
sampling which is hopefully easy to review and which cuts
9
Message-id: 20220501055028.646596-10-richard.henderson@linaro.org
9
down the size of the problem for next time somebody wants to
10
try to look at shellcheck errors.
11
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20220825150703.4074125-4-peter.maydell@linaro.org
11
---
16
---
12
target/arm/cpregs.h | 7 ++++---
17
configure | 64 +++++++++++++++++++++++++++----------------------------
13
target/arm/helper.c | 7 +++++--
18
1 file changed, 32 insertions(+), 32 deletions(-)
14
2 files changed, 9 insertions(+), 5 deletions(-)
19
15
20
diff --git a/configure b/configure
16
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
21
index XXXXXXX..XXXXXXX 100755
17
index XXXXXXX..XXXXXXX 100644
22
--- a/configure
18
--- a/target/arm/cpregs.h
23
+++ b/configure
19
+++ b/target/arm/cpregs.h
24
@@ -XXX,XX +XXX,XX @@ GNUmakefile: ;
20
@@ -XXX,XX +XXX,XX @@ typedef enum {
25
21
* registered entry will only have one to identify whether the entry is secure
26
EOF
22
* or non-secure.
27
cd build
23
*/
28
- exec $source_path/configure "$@"
24
-enum {
29
+ exec "$source_path/configure" "$@"
25
+typedef enum {
30
fi
26
+ ARM_CP_SECSTATE_BOTH = 0, /* define one cpreg for each secstate */
31
27
ARM_CP_SECSTATE_S = (1 << 0), /* bit[0]: Secure state register */
32
# Temporary directory used for files created while
28
ARM_CP_SECSTATE_NS = (1 << 1), /* bit[1]: Non-secure state register */
33
@@ -XXX,XX +XXX,XX @@ meson_option_build_array() {
29
-};
34
printf ']\n'
30
+} CPSecureState;
31
32
/*
33
* Access rights:
34
@@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo {
35
/* Access rights: PL*_[RW] */
36
CPAccessRights access;
37
/* Security state: ARM_CP_SECSTATE_* bits/values */
38
- int secure;
39
+ CPSecureState secure;
40
/*
41
* The opaque pointer passed to define_arm_cp_regs_with_opaque() when
42
* this register was defined: can be used to hand data through to the
43
diff --git a/target/arm/helper.c b/target/arm/helper.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/helper.c
46
+++ b/target/arm/helper.c
47
@@ -XXX,XX +XXX,XX @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
48
}
35
}
49
36
50
static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
37
-. $source_path/scripts/meson-buildoptions.sh
51
- void *opaque, CPState state, int secstate,
38
+. "$source_path/scripts/meson-buildoptions.sh"
52
+ void *opaque, CPState state,
39
53
+ CPSecureState secstate,
40
meson_options=
54
int crm, int opc1, int opc2,
41
meson_option_add() {
55
const char *name)
42
@@ -XXX,XX +XXX,XX @@ for opt do
56
{
43
case "$opt" in
57
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
44
--help|-h) show_help=yes
58
r->secure, crm, opc1, opc2,
45
;;
59
r->name);
46
- --version|-V) exec cat $source_path/VERSION
60
break;
47
+ --version|-V) exec cat "$source_path/VERSION"
61
- default:
48
;;
62
+ case ARM_CP_SECSTATE_BOTH:
49
--prefix=*) prefix="$optarg"
63
name = g_strdup_printf("%s_S", r->name);
50
;;
64
add_cpreg_to_hashtable(cpu, r, opaque, state,
51
@@ -XXX,XX +XXX,XX @@ default_target_list=""
65
ARM_CP_SECSTATE_S,
52
mak_wilds=""
66
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
53
67
ARM_CP_SECSTATE_NS,
54
if [ "$linux_user" != no ]; then
68
crm, opc1, opc2, r->name);
55
- if [ "$targetos" = linux ] && [ -d $source_path/linux-user/include/host/$cpu ]; then
69
break;
56
+ if [ "$targetos" = linux ] && [ -d "$source_path/linux-user/include/host/$cpu" ]; then
70
+ default:
57
linux_user=yes
71
+ g_assert_not_reached();
58
elif [ "$linux_user" = yes ]; then
72
}
59
error_exit "linux-user not supported on this architecture"
73
} else {
60
@@ -XXX,XX +XXX,XX @@ if [ "$bsd_user" != no ]; then
74
/* AArch64 registers get mapped to non-secure instance
61
if [ "$bsd_user" = "" ]; then
62
test $targetos = freebsd && bsd_user=yes
63
fi
64
- if [ "$bsd_user" = yes ] && ! [ -d $source_path/bsd-user/$targetos ]; then
65
+ if [ "$bsd_user" = yes ] && ! [ -d "$source_path/bsd-user/$targetos" ]; then
66
error_exit "bsd-user not supported on this host OS"
67
fi
68
fi
69
@@ -XXX,XX +XXX,XX @@ python="$python -B"
70
if test -z "$meson"; then
71
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.59.3; then
72
meson=meson
73
- elif test $git_submodules_action != 'ignore' ; then
74
+ elif test "$git_submodules_action" != 'ignore' ; then
75
meson=git
76
elif test -e "${source_path}/meson/meson.py" ; then
77
meson=internal
78
@@ -XXX,XX +XXX,XX @@ esac
79
container="no"
80
if test $use_containers = "yes"; then
81
if has "docker" || has "podman"; then
82
- container=$($python $source_path/tests/docker/docker.py probe)
83
+ container=$($python "$source_path"/tests/docker/docker.py probe)
84
fi
85
fi
86
87
@@ -XXX,XX +XXX,XX @@ if test "$QEMU_GA_DISTRO" = ""; then
88
QEMU_GA_DISTRO=Linux
89
fi
90
if test "$QEMU_GA_VERSION" = ""; then
91
- QEMU_GA_VERSION=$(cat $source_path/VERSION)
92
+ QEMU_GA_VERSION=$(cat "$source_path"/VERSION)
93
fi
94
95
96
@@ -XXX,XX +XXX,XX @@ fi
97
for target in $target_list; do
98
target_dir="$target"
99
target_name=$(echo $target | cut -d '-' -f 1)$EXESUF
100
- mkdir -p $target_dir
101
+ mkdir -p "$target_dir"
102
case $target in
103
*-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;;
104
*) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;;
105
@@ -XXX,XX +XXX,XX @@ for target in $target_list; do
106
config_target_mak=tests/tcg/config-$target.mak
107
108
echo "# Automatically generated by configure - do not modify" > $config_target_mak
109
- echo "TARGET_NAME=$arch" >> $config_target_mak
110
+ echo "TARGET_NAME=$arch" >> "$config_target_mak"
111
case $target in
112
xtensa*-linux-user)
113
# the toolchain is not complete with headers, only build softmmu tests
114
continue
115
;;
116
*-softmmu)
117
- test -f $source_path/tests/tcg/$arch/Makefile.softmmu-target || continue
118
+ test -f "$source_path/tests/tcg/$arch/Makefile.softmmu-target" || continue
119
qemu="qemu-system-$arch"
120
;;
121
*-linux-user|*-bsd-user)
122
@@ -XXX,XX +XXX,XX @@ for target in $target_list; do
123
# compilers is a requirememt for adding a new test that needs a
124
# compiler feature.
125
126
- echo "BUILD_STATIC=$build_static" >> $config_target_mak
127
- write_target_makefile >> $config_target_mak
128
+ echo "BUILD_STATIC=$build_static" >> "$config_target_mak"
129
+ write_target_makefile >> "$config_target_mak"
130
case $target in
131
aarch64-*)
132
if do_compiler "$target_cc" $target_cflags \
133
-march=armv8.1-a+sve -o $TMPE $TMPC; then
134
- echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak
135
+ echo "CROSS_CC_HAS_SVE=y" >> "$config_target_mak"
136
fi
137
if do_compiler "$target_cc" $target_cflags \
138
-march=armv8.1-a+sve2 -o $TMPE $TMPC; then
139
- echo "CROSS_CC_HAS_SVE2=y" >> $config_target_mak
140
+ echo "CROSS_CC_HAS_SVE2=y" >> "$config_target_mak"
141
fi
142
if do_compiler "$target_cc" $target_cflags \
143
-march=armv8.3-a -o $TMPE $TMPC; then
144
- echo "CROSS_CC_HAS_ARMV8_3=y" >> $config_target_mak
145
+ echo "CROSS_CC_HAS_ARMV8_3=y" >> "$config_target_mak"
146
fi
147
if do_compiler "$target_cc" $target_cflags \
148
-mbranch-protection=standard -o $TMPE $TMPC; then
149
- echo "CROSS_CC_HAS_ARMV8_BTI=y" >> $config_target_mak
150
+ echo "CROSS_CC_HAS_ARMV8_BTI=y" >> "$config_target_mak"
151
fi
152
if do_compiler "$target_cc" $target_cflags \
153
-march=armv8.5-a+memtag -o $TMPE $TMPC; then
154
- echo "CROSS_CC_HAS_ARMV8_MTE=y" >> $config_target_mak
155
+ echo "CROSS_CC_HAS_ARMV8_MTE=y" >> "$config_target_mak"
156
fi
157
;;
158
ppc*)
159
if do_compiler "$target_cc" $target_cflags \
160
-mpower8-vector -o $TMPE $TMPC; then
161
- echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak
162
+ echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> "$config_target_mak"
163
fi
164
if do_compiler "$target_cc" $target_cflags \
165
-mpower10 -o $TMPE $TMPC; then
166
- echo "CROSS_CC_HAS_POWER10=y" >> $config_target_mak
167
+ echo "CROSS_CC_HAS_POWER10=y" >> "$config_target_mak"
168
fi
169
;;
170
i386-linux-user)
171
if do_compiler "$target_cc" $target_cflags \
172
-Werror -fno-pie -o $TMPE $TMPC; then
173
- echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak
174
+ echo "CROSS_CC_HAS_I386_NOPIE=y" >> "$config_target_mak"
175
fi
176
;;
177
esac
178
elif test -n "$container_image"; then
179
echo "build-tcg-tests-$target: docker-image-$container_image" >> $makefile
180
- echo "BUILD_STATIC=y" >> $config_target_mak
181
- write_container_target_makefile >> $config_target_mak
182
+ echo "BUILD_STATIC=y" >> "$config_target_mak"
183
+ write_container_target_makefile >> "$config_target_mak"
184
case $target in
185
aarch64-*)
186
- echo "CROSS_CC_HAS_SVE=y" >> $config_target_mak
187
- echo "CROSS_CC_HAS_SVE2=y" >> $config_target_mak
188
- echo "CROSS_CC_HAS_ARMV8_3=y" >> $config_target_mak
189
- echo "CROSS_CC_HAS_ARMV8_BTI=y" >> $config_target_mak
190
- echo "CROSS_CC_HAS_ARMV8_MTE=y" >> $config_target_mak
191
+ echo "CROSS_CC_HAS_SVE=y" >> "$config_target_mak"
192
+ echo "CROSS_CC_HAS_SVE2=y" >> "$config_target_mak"
193
+ echo "CROSS_CC_HAS_ARMV8_3=y" >> "$config_target_mak"
194
+ echo "CROSS_CC_HAS_ARMV8_BTI=y" >> "$config_target_mak"
195
+ echo "CROSS_CC_HAS_ARMV8_MTE=y" >> "$config_target_mak"
196
;;
197
ppc*)
198
- echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> $config_target_mak
199
- echo "CROSS_CC_HAS_POWER10=y" >> $config_target_mak
200
+ echo "CROSS_CC_HAS_POWER8_VECTOR=y" >> "$config_target_mak"
201
+ echo "CROSS_CC_HAS_POWER10=y" >> "$config_target_mak"
202
;;
203
i386-linux-user)
204
- echo "CROSS_CC_HAS_I386_NOPIE=y" >> $config_target_mak
205
+ echo "CROSS_CC_HAS_I386_NOPIE=y" >> "$config_target_mak"
206
;;
207
esac
208
got_cross_cc=yes
209
fi
210
if test $got_cross_cc = yes; then
211
mkdir -p tests/tcg/$target
212
- echo "QEMU=$PWD/$qemu" >> $config_target_mak
213
+ echo "QEMU=$PWD/$qemu" >> "$config_target_mak"
214
echo "run-tcg-tests-$target: $qemu\$(EXESUF)" >> $makefile
215
tcg_tests_targets="$tcg_tests_targets $target"
216
fi
75
--
217
--
76
2.25.1
218
2.25.1
219
220
diff view generated by jsdifflib
New patch
1
Shellcheck warns that in
2
rm -f */config-devices.mak.d
3
the glob might expand to something with a '-' in it, which would
4
then be misinterpreted as an option to rm. Fix this by adding './'.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20220825150703.4074125-5-peter.maydell@linaro.org
10
---
11
configure | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
14
diff --git a/configure b/configure
15
index XXXXXXX..XXXXXXX 100755
16
--- a/configure
17
+++ b/configure
18
@@ -XXX,XX +XXX,XX @@ exit 0
19
fi
20
21
# Remove old dependency files to make sure that they get properly regenerated
22
-rm -f */config-devices.mak.d
23
+rm -f ./*/config-devices.mak.d
24
25
if test -z "$python"
26
then
27
--
28
2.25.1
29
30
diff view generated by jsdifflib
New patch
1
There's only one place in configure where we use `...` to execute a
2
command and capture the result. Switch to $() to match the rest of
3
the script. This silences a shellcheck warning.
1
4
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220825150703.4074125-6-peter.maydell@linaro.org
9
---
10
configure | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
12
13
diff --git a/configure b/configure
14
index XXXXXXX..XXXXXXX 100755
15
--- a/configure
16
+++ b/configure
17
@@ -XXX,XX +XXX,XX @@ LINKS="$LINKS python"
18
LINKS="$LINKS contrib/plugins/Makefile "
19
for f in $LINKS ; do
20
if [ -e "$source_path/$f" ]; then
21
- mkdir -p `dirname ./$f`
22
+ mkdir -p "$(dirname ./"$f")"
23
symlink "$source_path/$f" "$f"
24
fi
25
done
26
--
27
2.25.1
28
29
diff view generated by jsdifflib
New patch
1
Shellcheck warns that we have one place where we run a command and
2
then check if it failed using $?; this is better written to simply
3
check the command in the 'if' statement directly.
1
4
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220825150703.4074125-7-peter.maydell@linaro.org
9
---
10
configure | 3 +--
11
1 file changed, 1 insertion(+), 2 deletions(-)
12
13
diff --git a/configure b/configure
14
index XXXXXXX..XXXXXXX 100755
15
--- a/configure
16
+++ b/configure
17
@@ -XXX,XX +XXX,XX @@ fi
18
# it when configure exits.)
19
TMPDIR1="config-temp"
20
rm -rf "${TMPDIR1}"
21
-mkdir -p "${TMPDIR1}"
22
-if [ $? -ne 0 ]; then
23
+if ! mkdir -p "${TMPDIR1}"; then
24
echo "ERROR: failed to create temporary directory"
25
exit 1
26
fi
27
--
28
2.25.1
29
30
diff view generated by jsdifflib
New patch
1
We use the non-POSIX 'local' keyword in just two places in configure;
2
rewrite to avoid it.
1
3
4
In do_compiler(), just drop the 'local' keyword. The variable
5
'compiler' is only used elsewhere in the do_compiler_werror()
6
function, which already uses the variable as a normal non-local one.
7
8
In probe_target_compiler(), $try and $t are both local; make them
9
normal variables and use a more obviously distinct variable name
10
for $t.
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20220825150703.4074125-8-peter.maydell@linaro.org
16
---
17
configure | 7 +++----
18
1 file changed, 3 insertions(+), 4 deletions(-)
19
20
diff --git a/configure b/configure
21
index XXXXXXX..XXXXXXX 100755
22
--- a/configure
23
+++ b/configure
24
@@ -XXX,XX +XXX,XX @@ error_exit() {
25
do_compiler() {
26
# Run the compiler, capturing its output to the log. First argument
27
# is compiler binary to execute.
28
- local compiler="$1"
29
+ compiler="$1"
30
shift
31
if test -n "$BASH_VERSION"; then eval '
32
echo >>config.log "
33
@@ -XXX,XX +XXX,XX @@ probe_target_compiler() {
34
: ${container_cross_strip:=${container_cross_prefix}strip}
35
done
36
37
- local t try
38
try=cross
39
case "$target_arch:$cpu" in
40
aarch64_be:aarch64 | \
41
@@ -XXX,XX +XXX,XX @@ probe_target_compiler() {
42
try='native cross' ;;
43
esac
44
eval "target_cflags=\${cross_cc_cflags_$target_arch}"
45
- for t in $try; do
46
- case $t in
47
+ for thistry in $try; do
48
+ case $thistry in
49
native)
50
target_cc=$cc
51
target_ccas=$ccas
52
--
53
2.25.1
54
55
diff view generated by jsdifflib