1 | target-arm queue: mostly just cleanup/minor stuff, but this does | 1 | The following changes since commit ad1b4ec39caa5b3f17cbd8160283a03a3dcfe2ae: |
---|---|---|---|
2 | include the raspi3 board model. | ||
3 | 2 | ||
4 | -- PMM | 3 | Merge remote-tracking branch 'remotes/kraxel/tags/input-20180515-pull-request' into staging (2018-05-15 12:50:06 +0100) |
5 | |||
6 | The following changes since commit 9f9c53368b219a9115eddb39f0ff5ad19c977134: | ||
7 | |||
8 | Merge remote-tracking branch 'remotes/vivier/tags/m68k-for-2.12-pull-request' into staging (2018-02-15 10:14:11 +0000) | ||
9 | 4 | ||
10 | are available in the Git repository at: | 5 | are available in the Git repository at: |
11 | 6 | ||
12 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180215 | 7 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180515 |
13 | 8 | ||
14 | for you to fetch changes up to e545f0f9be1f9e60951017c1e6558216732cc14e: | 9 | for you to fetch changes up to ae7651804748c6b479d5ae09aeac4edb9c44f76e: |
15 | 10 | ||
16 | target/arm: Implement v8M MSPLIM and PSPLIM registers (2018-02-15 13:48:11 +0000) | 11 | tcg: Optionally log FPU state in TCG -d cpu logging (2018-05-15 14:58:44 +0100) |
17 | 12 | ||
18 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
19 | target-arm queue: | 14 | target-arm queue: |
20 | * aspeed: code cleanup to use unimplemented_device | 15 | * Fix coverity nit in int_to_float code |
21 | * add 'raspi3' RaspberryPi 3 machine model | 16 | * Don't set Invalid for float-to-int(MAXINT) |
22 | * more SVE prep work | 17 | * Fix fp_status_f16 tininess before rounding |
23 | * v8M: add minor missing registers | 18 | * Add various missing insns from the v8.2-FP16 extension |
24 | * v7M: fix bug where we weren't migrating v7m.other_sp | 19 | * Fix sqrt_f16 exception raising |
25 | * v7M: fix bugs in handling of interrupt registers for | 20 | * sdcard: Correct CRC16 offset in sd_function_switch() |
26 | external interrupts beyond 32 | 21 | * tcg: Optionally log FPU state in TCG -d cpu logging |
27 | 22 | ||
28 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
29 | Pekka Enberg (3): | 24 | Alex Bennée (5): |
30 | bcm2836: Make CPU type configurable | 25 | fpu/softfloat: int_to_float ensure r fully initialised |
31 | raspi: Raspberry Pi 3 support | 26 | target/arm: Implement FCMP for fp16 |
32 | raspi: Add "raspi3" machine type | 27 | target/arm: Implement FCSEL for fp16 |
28 | target/arm: Implement FMOV (immediate) for fp16 | ||
29 | target/arm: Fix sqrt_f16 exception raising | ||
33 | 30 | ||
34 | Peter Maydell (11): | 31 | Peter Maydell (3): |
35 | hw/intc/armv7m_nvic: Don't hardcode M profile ID registers in NVIC | 32 | fpu/softfloat: Don't set Invalid for float-to-int(MAXINT) |
36 | hw/intc/armv7m_nvic: Fix ICSR PENDNMISET/CLR handling | 33 | target/arm: Fix fp_status_f16 tininess before rounding |
37 | hw/intc/armv7m_nvic: Implement M profile cache maintenance ops | 34 | tcg: Optionally log FPU state in TCG -d cpu logging |
38 | hw/intc/armv7m_nvic: Implement v8M CPPWR register | ||
39 | hw/intc/armv7m_nvic: Implement cache ID registers | ||
40 | hw/intc/armv7m_nvic: Implement SCR | ||
41 | target/arm: Implement writing to CONTROL_NS for v8M | ||
42 | hw/intc/armv7m_nvic: Fix byte-to-interrupt number conversions | ||
43 | target/arm: Add AIRCR to vmstate struct | ||
44 | target/arm: Migrate v7m.other_sp | ||
45 | target/arm: Implement v8M MSPLIM and PSPLIM registers | ||
46 | 35 | ||
47 | Philippe Mathieu-Daudé (2): | 36 | Philippe Mathieu-Daudé (1): |
48 | hw/arm/aspeed: directly map the serial device to the system address space | 37 | sdcard: Correct CRC16 offset in sd_function_switch() |
49 | hw/arm/aspeed: simplify using the 'unimplemented device' for aspeed_soc.io | ||
50 | 38 | ||
51 | Richard Henderson (5): | 39 | Richard Henderson (7): |
52 | target/arm: Remove ARM_CP_64BIT from ZCR_EL registers | 40 | target/arm: Implement FMOV (general) for fp16 |
53 | target/arm: Enforce FP access to FPCR/FPSR | 41 | target/arm: Early exit after unallocated_encoding in disas_fp_int_conv |
54 | target/arm: Suppress TB end for FPCR/FPSR | 42 | target/arm: Implement FCVT (scalar, integer) for fp16 |
55 | target/arm: Enforce access to ZCR_EL at translation | 43 | target/arm: Implement FCVT (scalar, fixed-point) for fp16 |
56 | target/arm: Handle SVE registers when using clear_vec_high | 44 | target/arm: Introduce and use read_fp_hreg |
45 | target/arm: Implement FP data-processing (2 source) for fp16 | ||
46 | target/arm: Implement FP data-processing (3 source) for fp16 | ||
57 | 47 | ||
58 | include/hw/arm/aspeed_soc.h | 1 - | 48 | include/qemu/log.h | 1 + |
59 | include/hw/arm/bcm2836.h | 1 + | 49 | target/arm/helper-a64.h | 2 + |
60 | target/arm/cpu.h | 71 ++++++++++++----- | 50 | target/arm/helper.h | 6 + |
61 | target/arm/internals.h | 6 ++ | 51 | accel/tcg/cpu-exec.c | 9 +- |
62 | hw/arm/aspeed_soc.c | 35 ++------- | 52 | fpu/softfloat.c | 6 +- |
63 | hw/arm/bcm2836.c | 17 +++-- | 53 | hw/sd/sd.c | 2 +- |
64 | hw/arm/raspi.c | 57 +++++++++++--- | 54 | target/arm/cpu.c | 2 + |
65 | hw/intc/armv7m_nvic.c | 98 ++++++++++++++++++------ | 55 | target/arm/helper-a64.c | 10 ++ |
66 | target/arm/cpu.c | 28 +++++++ | 56 | target/arm/helper.c | 38 +++- |
67 | target/arm/helper.c | 84 +++++++++++++++----- | 57 | target/arm/translate-a64.c | 421 ++++++++++++++++++++++++++++++++++++++------- |
68 | target/arm/machine.c | 84 ++++++++++++++++++++ | 58 | util/log.c | 2 + |
69 | target/arm/translate-a64.c | 181 ++++++++++++++++++++------------------------ | 59 | 11 files changed, 428 insertions(+), 71 deletions(-) |
70 | 12 files changed, 452 insertions(+), 211 deletions(-) | ||
71 | 60 | diff view generated by jsdifflib |
1 | The v8M architecture includes hardware support for enforcing | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | stack pointer limits. We don't implement this behaviour yet, | ||
3 | but provide the MSPLIM and PSPLIM stack pointer limit registers | ||
4 | as reads-as-written, so that when we do implement the checks | ||
5 | in future this won't break guest migration. | ||
6 | 2 | ||
3 | Reported by Coverity (CID1390635). We ensure this for uint_to_float | ||
4 | later on so we might as well mirror that. | ||
5 | |||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180209165810.6668-12-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/cpu.h | 2 ++ | 11 | fpu/softfloat.c | 2 +- |
12 | target/arm/helper.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | target/arm/machine.c | 21 +++++++++++++++++++++ | ||
14 | 3 files changed, 69 insertions(+) | ||
15 | 13 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 16 | --- a/fpu/softfloat.c |
19 | +++ b/target/arm/cpu.h | 17 | +++ b/fpu/softfloat.c |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 18 | @@ -XXX,XX +XXX,XX @@ FLOAT_TO_UINT(64, 64) |
21 | uint32_t secure; /* Is CPU in Secure state? (not guest visible) */ | 19 | |
22 | uint32_t csselr[M_REG_NUM_BANKS]; | 20 | static FloatParts int_to_float(int64_t a, float_status *status) |
23 | uint32_t scr[M_REG_NUM_BANKS]; | 21 | { |
24 | + uint32_t msplim[M_REG_NUM_BANKS]; | 22 | - FloatParts r; |
25 | + uint32_t psplim[M_REG_NUM_BANKS]; | 23 | + FloatParts r = {}; |
26 | } v7m; | 24 | if (a == 0) { |
27 | 25 | r.cls = float_class_zero; | |
28 | /* Information associated with an exception about to be taken: | 26 | r.sign = false; |
29 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/helper.c | ||
32 | +++ b/target/arm/helper.c | ||
33 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
34 | return 0; | ||
35 | } | ||
36 | return env->v7m.other_ss_psp; | ||
37 | + case 0x8a: /* MSPLIM_NS */ | ||
38 | + if (!env->v7m.secure) { | ||
39 | + return 0; | ||
40 | + } | ||
41 | + return env->v7m.msplim[M_REG_NS]; | ||
42 | + case 0x8b: /* PSPLIM_NS */ | ||
43 | + if (!env->v7m.secure) { | ||
44 | + return 0; | ||
45 | + } | ||
46 | + return env->v7m.psplim[M_REG_NS]; | ||
47 | case 0x90: /* PRIMASK_NS */ | ||
48 | if (!env->v7m.secure) { | ||
49 | return 0; | ||
50 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
51 | return v7m_using_psp(env) ? env->v7m.other_sp : env->regs[13]; | ||
52 | case 9: /* PSP */ | ||
53 | return v7m_using_psp(env) ? env->regs[13] : env->v7m.other_sp; | ||
54 | + case 10: /* MSPLIM */ | ||
55 | + if (!arm_feature(env, ARM_FEATURE_V8)) { | ||
56 | + goto bad_reg; | ||
57 | + } | ||
58 | + return env->v7m.msplim[env->v7m.secure]; | ||
59 | + case 11: /* PSPLIM */ | ||
60 | + if (!arm_feature(env, ARM_FEATURE_V8)) { | ||
61 | + goto bad_reg; | ||
62 | + } | ||
63 | + return env->v7m.psplim[env->v7m.secure]; | ||
64 | case 16: /* PRIMASK */ | ||
65 | return env->v7m.primask[env->v7m.secure]; | ||
66 | case 17: /* BASEPRI */ | ||
67 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) | ||
68 | case 19: /* FAULTMASK */ | ||
69 | return env->v7m.faultmask[env->v7m.secure]; | ||
70 | default: | ||
71 | + bad_reg: | ||
72 | qemu_log_mask(LOG_GUEST_ERROR, "Attempt to read unknown special" | ||
73 | " register %d\n", reg); | ||
74 | return 0; | ||
75 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
76 | } | ||
77 | env->v7m.other_ss_psp = val; | ||
78 | return; | ||
79 | + case 0x8a: /* MSPLIM_NS */ | ||
80 | + if (!env->v7m.secure) { | ||
81 | + return; | ||
82 | + } | ||
83 | + env->v7m.msplim[M_REG_NS] = val & ~7; | ||
84 | + return; | ||
85 | + case 0x8b: /* PSPLIM_NS */ | ||
86 | + if (!env->v7m.secure) { | ||
87 | + return; | ||
88 | + } | ||
89 | + env->v7m.psplim[M_REG_NS] = val & ~7; | ||
90 | + return; | ||
91 | case 0x90: /* PRIMASK_NS */ | ||
92 | if (!env->v7m.secure) { | ||
93 | return; | ||
94 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
95 | env->v7m.other_sp = val; | ||
96 | } | ||
97 | break; | ||
98 | + case 10: /* MSPLIM */ | ||
99 | + if (!arm_feature(env, ARM_FEATURE_V8)) { | ||
100 | + goto bad_reg; | ||
101 | + } | ||
102 | + env->v7m.msplim[env->v7m.secure] = val & ~7; | ||
103 | + break; | ||
104 | + case 11: /* PSPLIM */ | ||
105 | + if (!arm_feature(env, ARM_FEATURE_V8)) { | ||
106 | + goto bad_reg; | ||
107 | + } | ||
108 | + env->v7m.psplim[env->v7m.secure] = val & ~7; | ||
109 | + break; | ||
110 | case 16: /* PRIMASK */ | ||
111 | env->v7m.primask[env->v7m.secure] = val & 1; | ||
112 | break; | ||
113 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
114 | env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK; | ||
115 | break; | ||
116 | default: | ||
117 | + bad_reg: | ||
118 | qemu_log_mask(LOG_GUEST_ERROR, "Attempt to write unknown special" | ||
119 | " register %d\n", reg); | ||
120 | return; | ||
121 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/target/arm/machine.c | ||
124 | +++ b/target/arm/machine.c | ||
125 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_other_sp = { | ||
126 | } | ||
127 | }; | ||
128 | |||
129 | +static bool m_v8m_needed(void *opaque) | ||
130 | +{ | ||
131 | + ARMCPU *cpu = opaque; | ||
132 | + CPUARMState *env = &cpu->env; | ||
133 | + | ||
134 | + return arm_feature(env, ARM_FEATURE_M) && arm_feature(env, ARM_FEATURE_V8); | ||
135 | +} | ||
136 | + | ||
137 | +static const VMStateDescription vmstate_m_v8m = { | ||
138 | + .name = "cpu/m/v8m", | ||
139 | + .version_id = 1, | ||
140 | + .minimum_version_id = 1, | ||
141 | + .needed = m_v8m_needed, | ||
142 | + .fields = (VMStateField[]) { | ||
143 | + VMSTATE_UINT32_ARRAY(env.v7m.msplim, ARMCPU, M_REG_NUM_BANKS), | ||
144 | + VMSTATE_UINT32_ARRAY(env.v7m.psplim, ARMCPU, M_REG_NUM_BANKS), | ||
145 | + VMSTATE_END_OF_LIST() | ||
146 | + } | ||
147 | +}; | ||
148 | + | ||
149 | static const VMStateDescription vmstate_m = { | ||
150 | .name = "cpu/m", | ||
151 | .version_id = 4, | ||
152 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | ||
153 | &vmstate_m_csselr, | ||
154 | &vmstate_m_scr, | ||
155 | &vmstate_m_other_sp, | ||
156 | + &vmstate_m_v8m, | ||
157 | NULL | ||
158 | } | ||
159 | }; | ||
160 | -- | 27 | -- |
161 | 2.16.1 | 28 | 2.17.0 |
162 | 29 | ||
163 | 30 | diff view generated by jsdifflib |
1 | In commit abc24d86cc0364f we accidentally broke migration of | 1 | In float-to-integer conversion, if the floating point input |
---|---|---|---|
2 | the stack pointer value for the mode (process, handler) the CPU | 2 | converts exactly to the largest or smallest integer that |
3 | is not currently running as. (The commit correctly removed the | 3 | fits in to the result type, this is not an overflow. |
4 | no-longer-used v7m.current_sp flag from the VMState but also | 4 | In this situation we were producing the correct result value, |
5 | deleted the still very much in use v7m.other_sp SP value field.) | 5 | but were incorrectly setting the Invalid flag. |
6 | For example for Arm A64, "FCVTAS w0, d0" on an input of | ||
7 | 0x41dfffffffc00000 should produce 0x7fffffff and set no flags. | ||
6 | 8 | ||
7 | Add a subsection to migrate it again. (We don't need to care | 9 | Fix the boundary case to take the right half of the if() |
8 | about trying to retain compatibility with pre-abc24d86cc0364f | 10 | statements. |
9 | versions of QEMU, because that commit bumped the version_id | ||
10 | and we've since bumped it again a couple of times.) | ||
11 | 11 | ||
12 | This fixes a regression from 2.11 introduced by the softfloat | ||
13 | refactoring. | ||
14 | |||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Fixes: ab52f973a50 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20180209165810.6668-11-peter.maydell@linaro.org | 19 | Message-id: 20180510140141.12120-1-peter.maydell@linaro.org |
15 | --- | 20 | --- |
16 | target/arm/machine.c | 11 +++++++++++ | 21 | fpu/softfloat.c | 4 ++-- |
17 | 1 file changed, 11 insertions(+) | 22 | 1 file changed, 2 insertions(+), 2 deletions(-) |
18 | 23 | ||
19 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 24 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c |
20 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/machine.c | 26 | --- a/fpu/softfloat.c |
22 | +++ b/target/arm/machine.c | 27 | +++ b/fpu/softfloat.c |
23 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_scr = { | 28 | @@ -XXX,XX +XXX,XX @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode, |
24 | } | 29 | r = UINT64_MAX; |
25 | }; | 30 | } |
26 | 31 | if (p.sign) { | |
27 | +static const VMStateDescription vmstate_m_other_sp = { | 32 | - if (r < -(uint64_t) min) { |
28 | + .name = "cpu/m/other-sp", | 33 | + if (r <= -(uint64_t) min) { |
29 | + .version_id = 1, | 34 | return -r; |
30 | + .minimum_version_id = 1, | 35 | } else { |
31 | + .fields = (VMStateField[]) { | 36 | s->float_exception_flags = orig_flags | float_flag_invalid; |
32 | + VMSTATE_UINT32(env.v7m.other_sp, ARMCPU), | 37 | return min; |
33 | + VMSTATE_END_OF_LIST() | 38 | } |
34 | + } | 39 | } else { |
35 | +}; | 40 | - if (r < max) { |
36 | + | 41 | + if (r <= max) { |
37 | static const VMStateDescription vmstate_m = { | 42 | return r; |
38 | .name = "cpu/m", | 43 | } else { |
39 | .version_id = 4, | 44 | s->float_exception_flags = orig_flags | float_flag_invalid; |
40 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | ||
41 | &vmstate_m_faultmask_primask, | ||
42 | &vmstate_m_csselr, | ||
43 | &vmstate_m_scr, | ||
44 | + &vmstate_m_other_sp, | ||
45 | NULL | ||
46 | } | ||
47 | }; | ||
48 | -- | 45 | -- |
49 | 2.16.1 | 46 | 2.17.0 |
50 | 47 | ||
51 | 48 | diff view generated by jsdifflib |
1 | Instead of hardcoding the values of M profile ID registers in the | 1 | In commit d81ce0ef2c4f105 we added an extra float_status field |
---|---|---|---|
2 | NVIC, use the fields in the CPU struct. This will allow us to | 2 | fp_status_fp16 for Arm, but forgot to initialize it correctly |
3 | give different M profile CPU types different ID register values. | 3 | by setting it to float_tininess_before_rounding. This currently |
4 | will only cause problems for the new V8_FP16 feature, since the | ||
5 | float-to-float conversion code doesn't use it yet. The effect | ||
6 | would be that we failed to set the Underflow IEEE exception flag | ||
7 | in all the cases where we should. | ||
4 | 8 | ||
5 | This commit includes the addition of the missing ID_ISAR5, | 9 | Add the missing initialization. |
6 | which exists as RES0 in both v7M and v8M. | ||
7 | 10 | ||
8 | (The values of the ID registers might be wrong for the M4 -- | 11 | Fixes: d81ce0ef2c4f105 |
9 | this commit leaves the behaviour there unchanged.) | 12 | Cc: qemu-stable@nongnu.org |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Message-id: 20180512004311.9299-16-richard.henderson@linaro.org | ||
17 | --- | ||
18 | target/arm/cpu.c | 2 ++ | ||
19 | 1 file changed, 2 insertions(+) | ||
10 | 20 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20180209165810.6668-2-peter.maydell@linaro.org | ||
15 | --- | ||
16 | hw/intc/armv7m_nvic.c | 30 ++++++++++++++++-------------- | ||
17 | target/arm/cpu.c | 28 ++++++++++++++++++++++++++++ | ||
18 | 2 files changed, 44 insertions(+), 14 deletions(-) | ||
19 | |||
20 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/intc/armv7m_nvic.c | ||
23 | +++ b/hw/intc/armv7m_nvic.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
25 | "Aux Fault status registers unimplemented\n"); | ||
26 | return 0; | ||
27 | case 0xd40: /* PFR0. */ | ||
28 | - return 0x00000030; | ||
29 | - case 0xd44: /* PRF1. */ | ||
30 | - return 0x00000200; | ||
31 | + return cpu->id_pfr0; | ||
32 | + case 0xd44: /* PFR1. */ | ||
33 | + return cpu->id_pfr1; | ||
34 | case 0xd48: /* DFR0. */ | ||
35 | - return 0x00100000; | ||
36 | + return cpu->id_dfr0; | ||
37 | case 0xd4c: /* AFR0. */ | ||
38 | - return 0x00000000; | ||
39 | + return cpu->id_afr0; | ||
40 | case 0xd50: /* MMFR0. */ | ||
41 | - return 0x00000030; | ||
42 | + return cpu->id_mmfr0; | ||
43 | case 0xd54: /* MMFR1. */ | ||
44 | - return 0x00000000; | ||
45 | + return cpu->id_mmfr1; | ||
46 | case 0xd58: /* MMFR2. */ | ||
47 | - return 0x00000000; | ||
48 | + return cpu->id_mmfr2; | ||
49 | case 0xd5c: /* MMFR3. */ | ||
50 | - return 0x00000000; | ||
51 | + return cpu->id_mmfr3; | ||
52 | case 0xd60: /* ISAR0. */ | ||
53 | - return 0x01141110; | ||
54 | + return cpu->id_isar0; | ||
55 | case 0xd64: /* ISAR1. */ | ||
56 | - return 0x02111000; | ||
57 | + return cpu->id_isar1; | ||
58 | case 0xd68: /* ISAR2. */ | ||
59 | - return 0x21112231; | ||
60 | + return cpu->id_isar2; | ||
61 | case 0xd6c: /* ISAR3. */ | ||
62 | - return 0x01111110; | ||
63 | + return cpu->id_isar3; | ||
64 | case 0xd70: /* ISAR4. */ | ||
65 | - return 0x01310102; | ||
66 | + return cpu->id_isar4; | ||
67 | + case 0xd74: /* ISAR5. */ | ||
68 | + return cpu->id_isar5; | ||
69 | /* TODO: Implement debug registers. */ | ||
70 | case 0xd90: /* MPU_TYPE */ | ||
71 | /* Unified MPU; if the MPU is not present this value is zero */ | ||
72 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 21 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
73 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
74 | --- a/target/arm/cpu.c | 23 | --- a/target/arm/cpu.c |
75 | +++ b/target/arm/cpu.c | 24 | +++ b/target/arm/cpu.c |
76 | @@ -XXX,XX +XXX,XX @@ static void cortex_m3_initfn(Object *obj) | 25 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) |
77 | set_feature(&cpu->env, ARM_FEATURE_M); | 26 | &env->vfp.fp_status); |
78 | cpu->midr = 0x410fc231; | 27 | set_float_detect_tininess(float_tininess_before_rounding, |
79 | cpu->pmsav7_dregion = 8; | 28 | &env->vfp.standard_fp_status); |
80 | + cpu->id_pfr0 = 0x00000030; | 29 | + set_float_detect_tininess(float_tininess_before_rounding, |
81 | + cpu->id_pfr1 = 0x00000200; | 30 | + &env->vfp.fp_status_f16); |
82 | + cpu->id_dfr0 = 0x00100000; | 31 | #ifndef CONFIG_USER_ONLY |
83 | + cpu->id_afr0 = 0x00000000; | 32 | if (kvm_enabled()) { |
84 | + cpu->id_mmfr0 = 0x00000030; | 33 | kvm_arm_reset_vcpu(cpu); |
85 | + cpu->id_mmfr1 = 0x00000000; | ||
86 | + cpu->id_mmfr2 = 0x00000000; | ||
87 | + cpu->id_mmfr3 = 0x00000000; | ||
88 | + cpu->id_isar0 = 0x01141110; | ||
89 | + cpu->id_isar1 = 0x02111000; | ||
90 | + cpu->id_isar2 = 0x21112231; | ||
91 | + cpu->id_isar3 = 0x01111110; | ||
92 | + cpu->id_isar4 = 0x01310102; | ||
93 | + cpu->id_isar5 = 0x00000000; | ||
94 | } | ||
95 | |||
96 | static void cortex_m4_initfn(Object *obj) | ||
97 | @@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj) | ||
98 | set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
99 | cpu->midr = 0x410fc240; /* r0p0 */ | ||
100 | cpu->pmsav7_dregion = 8; | ||
101 | + cpu->id_pfr0 = 0x00000030; | ||
102 | + cpu->id_pfr1 = 0x00000200; | ||
103 | + cpu->id_dfr0 = 0x00100000; | ||
104 | + cpu->id_afr0 = 0x00000000; | ||
105 | + cpu->id_mmfr0 = 0x00000030; | ||
106 | + cpu->id_mmfr1 = 0x00000000; | ||
107 | + cpu->id_mmfr2 = 0x00000000; | ||
108 | + cpu->id_mmfr3 = 0x00000000; | ||
109 | + cpu->id_isar0 = 0x01141110; | ||
110 | + cpu->id_isar1 = 0x02111000; | ||
111 | + cpu->id_isar2 = 0x21112231; | ||
112 | + cpu->id_isar3 = 0x01111110; | ||
113 | + cpu->id_isar4 = 0x01310102; | ||
114 | + cpu->id_isar5 = 0x00000000; | ||
115 | } | ||
116 | |||
117 | static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
118 | -- | 34 | -- |
119 | 2.16.1 | 35 | 2.17.0 |
120 | 36 | ||
121 | 37 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Nothing in either register affects the TB. | 3 | Adding the fp16 moves to/from general registers. |
4 | 4 | ||
5 | Cc: qemu-stable@nongnu.org | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20180211205848.4568-4-richard.henderson@linaro.org | 7 | Tested-by: Alex Bennée <alex.bennee@linaro.org> |
8 | Message-id: 20180512003217.9105-2-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: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | target/arm/helper.c | 4 ++-- | 12 | target/arm/translate-a64.c | 21 +++++++++++++++++++++ |
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 21 insertions(+) |
12 | 14 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 17 | --- a/target/arm/translate-a64.c |
16 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/translate-a64.c |
17 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | 19 | @@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) |
18 | .writefn = aa64_daif_write, .resetfn = arm_cp_reset_ignore }, | 20 | tcg_gen_st_i64(tcg_rn, cpu_env, fp_reg_hi_offset(s, rd)); |
19 | { .name = "FPCR", .state = ARM_CP_STATE_AA64, | 21 | clear_vec_high(s, true, rd); |
20 | .opc0 = 3, .opc1 = 3, .opc2 = 0, .crn = 4, .crm = 4, | 22 | break; |
21 | - .access = PL0_RW, .type = ARM_CP_FPU, | 23 | + case 3: |
22 | + .access = PL0_RW, .type = ARM_CP_FPU | ARM_CP_SUPPRESS_TB_END, | 24 | + /* 16 bit */ |
23 | .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write }, | 25 | + tmp = tcg_temp_new_i64(); |
24 | { .name = "FPSR", .state = ARM_CP_STATE_AA64, | 26 | + tcg_gen_ext16u_i64(tmp, tcg_rn); |
25 | .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4, | 27 | + write_fp_dreg(s, rd, tmp); |
26 | - .access = PL0_RW, .type = ARM_CP_FPU, | 28 | + tcg_temp_free_i64(tmp); |
27 | + .access = PL0_RW, .type = ARM_CP_FPU | ARM_CP_SUPPRESS_TB_END, | 29 | + break; |
28 | .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write }, | 30 | + default: |
29 | { .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64, | 31 | + g_assert_not_reached(); |
30 | .opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0, | 32 | } |
33 | } else { | ||
34 | TCGv_i64 tcg_rd = cpu_reg(s, rd); | ||
35 | @@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) | ||
36 | /* 64 bits from top half */ | ||
37 | tcg_gen_ld_i64(tcg_rd, cpu_env, fp_reg_hi_offset(s, rn)); | ||
38 | break; | ||
39 | + case 3: | ||
40 | + /* 16 bit */ | ||
41 | + tcg_gen_ld16u_i64(tcg_rd, cpu_env, fp_reg_offset(s, rn, MO_16)); | ||
42 | + break; | ||
43 | + default: | ||
44 | + g_assert_not_reached(); | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | ||
49 | case 0xa: /* 64 bit */ | ||
50 | case 0xd: /* 64 bit to top half of quad */ | ||
51 | break; | ||
52 | + case 0x6: /* 16-bit float, 32-bit int */ | ||
53 | + case 0xe: /* 16-bit float, 64-bit int */ | ||
54 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
55 | + break; | ||
56 | + } | ||
57 | + /* fallthru */ | ||
58 | default: | ||
59 | /* all other sf/type/rmode combinations are invalid */ | ||
60 | unallocated_encoding(s); | ||
31 | -- | 61 | -- |
32 | 2.16.1 | 62 | 2.17.0 |
33 | 63 | ||
34 | 64 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Because they are ARM_CP_STATE_AA64, ARM_CP_64BIT is implied. | 3 | No sense in emitting code after the exception. |
4 | 4 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20180211205848.4568-2-richard.henderson@linaro.org | 6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> |
7 | Message-id: 20180512003217.9105-3-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@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 | 8 ++++---- | 11 | target/arm/translate-a64.c | 2 +- |
11 | 1 file changed, 4 insertions(+), 4 deletions(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 13 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 16 | --- a/target/arm/translate-a64.c |
16 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/translate-a64.c |
17 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 18 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) |
18 | static const ARMCPRegInfo zcr_el1_reginfo = { | 19 | default: |
19 | .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64, | 20 | /* all other sf/type/rmode combinations are invalid */ |
20 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0, | 21 | unallocated_encoding(s); |
21 | - .access = PL1_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT, | 22 | - break; |
22 | + .access = PL1_RW, .accessfn = zcr_access, | 23 | + return; |
23 | .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]), | 24 | } |
24 | .writefn = zcr_write, .raw_writefn = raw_write | 25 | |
25 | }; | 26 | if (!fp_access_check(s)) { |
26 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el1_reginfo = { | ||
27 | static const ARMCPRegInfo zcr_el2_reginfo = { | ||
28 | .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | ||
29 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | ||
30 | - .access = PL2_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT, | ||
31 | + .access = PL2_RW, .accessfn = zcr_access, | ||
32 | .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]), | ||
33 | .writefn = zcr_write, .raw_writefn = raw_write | ||
34 | }; | ||
35 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el2_reginfo = { | ||
36 | static const ARMCPRegInfo zcr_no_el2_reginfo = { | ||
37 | .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | ||
38 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | ||
39 | - .access = PL2_RW, .type = ARM_CP_64BIT, | ||
40 | + .access = PL2_RW, | ||
41 | .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore | ||
42 | }; | ||
43 | |||
44 | static const ARMCPRegInfo zcr_el3_reginfo = { | ||
45 | .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64, | ||
46 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0, | ||
47 | - .access = PL3_RW, .accessfn = zcr_access, .type = ARM_CP_64BIT, | ||
48 | + .access = PL3_RW, .accessfn = zcr_access, | ||
49 | .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]), | ||
50 | .writefn = zcr_write, .raw_writefn = raw_write | ||
51 | }; | ||
52 | -- | 27 | -- |
53 | 2.16.1 | 28 | 2.17.0 |
54 | 29 | ||
55 | 30 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Cc: qemu-stable@nongnu.org | ||
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Message-id: 20180211205848.4568-3-richard.henderson@linaro.org | 6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-id: 20180512003217.9105-4-richard.henderson@linaro.org |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 9 | --- |
8 | target/arm/cpu.h | 35 ++++++++++++++++++----------------- | 10 | target/arm/helper.h | 6 +++ |
9 | target/arm/helper.c | 6 ++++-- | 11 | target/arm/helper.c | 38 ++++++++++++++- |
10 | target/arm/translate-a64.c | 3 +++ | 12 | target/arm/translate-a64.c | 96 +++++++++++++++++++++++++++++++------- |
11 | 3 files changed, 25 insertions(+), 19 deletions(-) | 13 | 3 files changed, 122 insertions(+), 18 deletions(-) |
12 | 14 | ||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/helper.h |
16 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/helper.h |
17 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr) |
18 | } | 20 | DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr) |
19 | 21 | DEF_HELPER_3(vfp_touhh, i32, f16, i32, ptr) | |
20 | /* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a | 22 | DEF_HELPER_3(vfp_toshh, i32, f16, i32, ptr) |
21 | - * special-behaviour cp reg and bits [15..8] indicate what behaviour | 23 | +DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr) |
22 | + * special-behaviour cp reg and bits [11..8] indicate what behaviour | 24 | +DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr) |
23 | * it has. Otherwise it is a simple cp reg, where CONST indicates that | 25 | +DEF_HELPER_3(vfp_touqh, i64, f16, i32, ptr) |
24 | * TCG can assume the value to be constant (ie load at translate time) | 26 | +DEF_HELPER_3(vfp_tosqh, i64, f16, i32, ptr) |
25 | * and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END | 27 | DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr) |
26 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | 28 | DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr) |
27 | * need to be surrounded by gen_io_start()/gen_io_end(). In particular, | 29 | DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr) |
28 | * registers which implement clocks or timers require this. | 30 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr) |
29 | */ | 31 | DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr) |
30 | -#define ARM_CP_SPECIAL 1 | 32 | DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr) |
31 | -#define ARM_CP_CONST 2 | 33 | DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr) |
32 | -#define ARM_CP_64BIT 4 | 34 | +DEF_HELPER_3(vfp_sqtoh, f16, i64, i32, ptr) |
33 | -#define ARM_CP_SUPPRESS_TB_END 8 | 35 | +DEF_HELPER_3(vfp_uqtoh, f16, i64, i32, ptr) |
34 | -#define ARM_CP_OVERRIDE 16 | 36 | |
35 | -#define ARM_CP_ALIAS 32 | 37 | DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) |
36 | -#define ARM_CP_IO 64 | 38 | DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env) |
37 | -#define ARM_CP_NO_RAW 128 | ||
38 | -#define ARM_CP_NOP (ARM_CP_SPECIAL | (1 << 8)) | ||
39 | -#define ARM_CP_WFI (ARM_CP_SPECIAL | (2 << 8)) | ||
40 | -#define ARM_CP_NZCV (ARM_CP_SPECIAL | (3 << 8)) | ||
41 | -#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | (4 << 8)) | ||
42 | -#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | (5 << 8)) | ||
43 | -#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA | ||
44 | +#define ARM_CP_SPECIAL 0x0001 | ||
45 | +#define ARM_CP_CONST 0x0002 | ||
46 | +#define ARM_CP_64BIT 0x0004 | ||
47 | +#define ARM_CP_SUPPRESS_TB_END 0x0008 | ||
48 | +#define ARM_CP_OVERRIDE 0x0010 | ||
49 | +#define ARM_CP_ALIAS 0x0020 | ||
50 | +#define ARM_CP_IO 0x0040 | ||
51 | +#define ARM_CP_NO_RAW 0x0080 | ||
52 | +#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) | ||
53 | +#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) | ||
54 | +#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) | ||
55 | +#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) | ||
56 | +#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
57 | +#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA | ||
58 | +#define ARM_CP_FPU 0x1000 | ||
59 | /* Used only as a terminator for ARMCPRegInfo lists */ | ||
60 | -#define ARM_CP_SENTINEL 0xffff | ||
61 | +#define ARM_CP_SENTINEL 0xffff | ||
62 | /* Mask of only the flag bits in a type field */ | ||
63 | -#define ARM_CP_FLAG_MASK 0xff | ||
64 | +#define ARM_CP_FLAG_MASK 0x10ff | ||
65 | |||
66 | /* Valid values for ARMCPRegInfo state field, indicating which of | ||
67 | * the AArch32 and AArch64 execution states this register is visible in. | ||
68 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 39 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
69 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
70 | --- a/target/arm/helper.c | 41 | --- a/target/arm/helper.c |
71 | +++ b/target/arm/helper.c | 42 | +++ b/target/arm/helper.c |
72 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | 43 | @@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) |
73 | .writefn = aa64_daif_write, .resetfn = arm_cp_reset_ignore }, | 44 | #undef VFP_CONV_FIX_A64 |
74 | { .name = "FPCR", .state = ARM_CP_STATE_AA64, | 45 | |
75 | .opc0 = 3, .opc1 = 3, .opc2 = 0, .crn = 4, .crm = 4, | 46 | /* Conversion to/from f16 can overflow to infinity before/after scaling. |
76 | - .access = PL0_RW, .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write }, | 47 | - * Therefore we convert to f64 (which does not round), scale, |
77 | + .access = PL0_RW, .type = ARM_CP_FPU, | 48 | - * and then convert f64 to f16 (which may round). |
78 | + .readfn = aa64_fpcr_read, .writefn = aa64_fpcr_write }, | 49 | + * Therefore we convert to f64, scale, and then convert f64 to f16; or |
79 | { .name = "FPSR", .state = ARM_CP_STATE_AA64, | 50 | + * vice versa for conversion to integer. |
80 | .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4, | 51 | + * |
81 | - .access = PL0_RW, .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write }, | 52 | + * For 16- and 32-bit integers, the conversion to f64 never rounds. |
82 | + .access = PL0_RW, .type = ARM_CP_FPU, | 53 | + * For 64-bit integers, any integer that would cause rounding will also |
83 | + .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write }, | 54 | + * overflow to f16 infinity, so there is no double rounding problem. |
84 | { .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64, | 55 | */ |
85 | .opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0, | 56 | |
86 | .access = PL0_R, .type = ARM_CP_NO_RAW, | 57 | static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) |
58 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
59 | return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); | ||
60 | } | ||
61 | |||
62 | +float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
63 | +{ | ||
64 | + return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst); | ||
65 | +} | ||
66 | + | ||
67 | +float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | ||
68 | +{ | ||
69 | + return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst); | ||
70 | +} | ||
71 | + | ||
72 | static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) | ||
73 | { | ||
74 | if (unlikely(float16_is_any_nan(f))) { | ||
75 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) | ||
76 | return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); | ||
77 | } | ||
78 | |||
79 | +uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst) | ||
80 | +{ | ||
81 | + return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); | ||
82 | +} | ||
83 | + | ||
84 | +uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst) | ||
85 | +{ | ||
86 | + return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); | ||
87 | +} | ||
88 | + | ||
89 | +uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst) | ||
90 | +{ | ||
91 | + return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); | ||
92 | +} | ||
93 | + | ||
94 | +uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst) | ||
95 | +{ | ||
96 | + return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); | ||
97 | +} | ||
98 | + | ||
99 | /* Set the current fp rounding mode and return the old one. | ||
100 | * The argument is a softfloat float_round_ value. | ||
101 | */ | ||
87 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 102 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
88 | index XXXXXXX..XXXXXXX 100644 | 103 | index XXXXXXX..XXXXXXX 100644 |
89 | --- a/target/arm/translate-a64.c | 104 | --- a/target/arm/translate-a64.c |
90 | +++ b/target/arm/translate-a64.c | 105 | +++ b/target/arm/translate-a64.c |
91 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | 106 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, |
92 | default: | 107 | bool itof, int rmode, int scale, int sf, int type) |
93 | break; | 108 | { |
109 | bool is_signed = !(opcode & 1); | ||
110 | - bool is_double = type; | ||
111 | TCGv_ptr tcg_fpstatus; | ||
112 | - TCGv_i32 tcg_shift; | ||
113 | + TCGv_i32 tcg_shift, tcg_single; | ||
114 | + TCGv_i64 tcg_double; | ||
115 | |||
116 | - tcg_fpstatus = get_fpstatus_ptr(false); | ||
117 | + tcg_fpstatus = get_fpstatus_ptr(type == 3); | ||
118 | |||
119 | tcg_shift = tcg_const_i32(64 - scale); | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
122 | tcg_int = tcg_extend; | ||
123 | } | ||
124 | |||
125 | - if (is_double) { | ||
126 | - TCGv_i64 tcg_double = tcg_temp_new_i64(); | ||
127 | + switch (type) { | ||
128 | + case 1: /* float64 */ | ||
129 | + tcg_double = tcg_temp_new_i64(); | ||
130 | if (is_signed) { | ||
131 | gen_helper_vfp_sqtod(tcg_double, tcg_int, | ||
132 | tcg_shift, tcg_fpstatus); | ||
133 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
134 | } | ||
135 | write_fp_dreg(s, rd, tcg_double); | ||
136 | tcg_temp_free_i64(tcg_double); | ||
137 | - } else { | ||
138 | - TCGv_i32 tcg_single = tcg_temp_new_i32(); | ||
139 | + break; | ||
140 | + | ||
141 | + case 0: /* float32 */ | ||
142 | + tcg_single = tcg_temp_new_i32(); | ||
143 | if (is_signed) { | ||
144 | gen_helper_vfp_sqtos(tcg_single, tcg_int, | ||
145 | tcg_shift, tcg_fpstatus); | ||
146 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
147 | } | ||
148 | write_fp_sreg(s, rd, tcg_single); | ||
149 | tcg_temp_free_i32(tcg_single); | ||
150 | + break; | ||
151 | + | ||
152 | + case 3: /* float16 */ | ||
153 | + tcg_single = tcg_temp_new_i32(); | ||
154 | + if (is_signed) { | ||
155 | + gen_helper_vfp_sqtoh(tcg_single, tcg_int, | ||
156 | + tcg_shift, tcg_fpstatus); | ||
157 | + } else { | ||
158 | + gen_helper_vfp_uqtoh(tcg_single, tcg_int, | ||
159 | + tcg_shift, tcg_fpstatus); | ||
160 | + } | ||
161 | + write_fp_sreg(s, rd, tcg_single); | ||
162 | + tcg_temp_free_i32(tcg_single); | ||
163 | + break; | ||
164 | + | ||
165 | + default: | ||
166 | + g_assert_not_reached(); | ||
167 | } | ||
168 | } else { | ||
169 | TCGv_i64 tcg_int = cpu_reg(s, rd); | ||
170 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
171 | |||
172 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); | ||
173 | |||
174 | - if (is_double) { | ||
175 | - TCGv_i64 tcg_double = read_fp_dreg(s, rn); | ||
176 | + switch (type) { | ||
177 | + case 1: /* float64 */ | ||
178 | + tcg_double = read_fp_dreg(s, rn); | ||
179 | if (is_signed) { | ||
180 | if (!sf) { | ||
181 | gen_helper_vfp_tosld(tcg_int, tcg_double, | ||
182 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
183 | tcg_shift, tcg_fpstatus); | ||
184 | } | ||
185 | } | ||
186 | + if (!sf) { | ||
187 | + tcg_gen_ext32u_i64(tcg_int, tcg_int); | ||
188 | + } | ||
189 | tcg_temp_free_i64(tcg_double); | ||
190 | - } else { | ||
191 | - TCGv_i32 tcg_single = read_fp_sreg(s, rn); | ||
192 | + break; | ||
193 | + | ||
194 | + case 0: /* float32 */ | ||
195 | + tcg_single = read_fp_sreg(s, rn); | ||
196 | if (sf) { | ||
197 | if (is_signed) { | ||
198 | gen_helper_vfp_tosqs(tcg_int, tcg_single, | ||
199 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
200 | tcg_temp_free_i32(tcg_dest); | ||
201 | } | ||
202 | tcg_temp_free_i32(tcg_single); | ||
203 | + break; | ||
204 | + | ||
205 | + case 3: /* float16 */ | ||
206 | + tcg_single = read_fp_sreg(s, rn); | ||
207 | + if (sf) { | ||
208 | + if (is_signed) { | ||
209 | + gen_helper_vfp_tosqh(tcg_int, tcg_single, | ||
210 | + tcg_shift, tcg_fpstatus); | ||
211 | + } else { | ||
212 | + gen_helper_vfp_touqh(tcg_int, tcg_single, | ||
213 | + tcg_shift, tcg_fpstatus); | ||
214 | + } | ||
215 | + } else { | ||
216 | + TCGv_i32 tcg_dest = tcg_temp_new_i32(); | ||
217 | + if (is_signed) { | ||
218 | + gen_helper_vfp_toslh(tcg_dest, tcg_single, | ||
219 | + tcg_shift, tcg_fpstatus); | ||
220 | + } else { | ||
221 | + gen_helper_vfp_toulh(tcg_dest, tcg_single, | ||
222 | + tcg_shift, tcg_fpstatus); | ||
223 | + } | ||
224 | + tcg_gen_extu_i32_i64(tcg_int, tcg_dest); | ||
225 | + tcg_temp_free_i32(tcg_dest); | ||
226 | + } | ||
227 | + tcg_temp_free_i32(tcg_single); | ||
228 | + break; | ||
229 | + | ||
230 | + default: | ||
231 | + g_assert_not_reached(); | ||
232 | } | ||
233 | |||
234 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); | ||
235 | tcg_temp_free_i32(tcg_rmode); | ||
236 | - | ||
237 | - if (!sf) { | ||
238 | - tcg_gen_ext32u_i64(tcg_int, tcg_int); | ||
239 | - } | ||
94 | } | 240 | } |
95 | + if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) { | 241 | |
96 | + return; | 242 | tcg_temp_free_ptr(tcg_fpstatus); |
97 | + } | 243 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) |
98 | 244 | /* actual FP conversions */ | |
99 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | 245 | bool itof = extract32(opcode, 1, 1); |
100 | gen_io_start(); | 246 | |
247 | - if (type > 1 || (rmode != 0 && opcode > 1)) { | ||
248 | + if (rmode != 0 && opcode > 1) { | ||
249 | + unallocated_encoding(s); | ||
250 | + return; | ||
251 | + } | ||
252 | + switch (type) { | ||
253 | + case 0: /* float32 */ | ||
254 | + case 1: /* float64 */ | ||
255 | + break; | ||
256 | + case 3: /* float16 */ | ||
257 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
258 | + break; | ||
259 | + } | ||
260 | + /* fallthru */ | ||
261 | + default: | ||
262 | unallocated_encoding(s); | ||
263 | return; | ||
264 | } | ||
101 | -- | 265 | -- |
102 | 2.16.1 | 266 | 2.17.0 |
103 | 267 | ||
104 | 268 | 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 also makes sure that we get the correct ordering of | 3 | Cc: qemu-stable@nongnu.org |
4 | SVE vs FP exceptions. | 4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180211205848.4568-5-richard.henderson@linaro.org | 6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-id: 20180512003217.9105-5-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 9 | --- |
11 | target/arm/cpu.h | 3 ++- | 10 | target/arm/translate-a64.c | 17 +++++++++++++++-- |
12 | target/arm/internals.h | 6 ++++++ | 11 | 1 file changed, 15 insertions(+), 2 deletions(-) |
13 | target/arm/helper.c | 22 ++++------------------ | ||
14 | target/arm/translate-a64.c | 16 ++++++++++++++++ | ||
15 | 4 files changed, 28 insertions(+), 19 deletions(-) | ||
16 | 12 | ||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | ||
22 | #define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) | ||
23 | #define ARM_LAST_SPECIAL ARM_CP_DC_ZVA | ||
24 | #define ARM_CP_FPU 0x1000 | ||
25 | +#define ARM_CP_SVE 0x2000 | ||
26 | /* Used only as a terminator for ARMCPRegInfo lists */ | ||
27 | #define ARM_CP_SENTINEL 0xffff | ||
28 | /* Mask of only the flag bits in a type field */ | ||
29 | -#define ARM_CP_FLAG_MASK 0x10ff | ||
30 | +#define ARM_CP_FLAG_MASK 0x30ff | ||
31 | |||
32 | /* Valid values for ARMCPRegInfo state field, indicating which of | ||
33 | * the AArch32 and AArch64 execution states this register is visible in. | ||
34 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/internals.h | ||
37 | +++ b/target/arm/internals.h | ||
38 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | ||
39 | EC_AA64_HVC = 0x16, | ||
40 | EC_AA64_SMC = 0x17, | ||
41 | EC_SYSTEMREGISTERTRAP = 0x18, | ||
42 | + EC_SVEACCESSTRAP = 0x19, | ||
43 | EC_INSNABORT = 0x20, | ||
44 | EC_INSNABORT_SAME_EL = 0x21, | ||
45 | EC_PCALIGNMENT = 0x22, | ||
46 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit) | ||
47 | | (cv << 24) | (cond << 20); | ||
48 | } | ||
49 | |||
50 | +static inline uint32_t syn_sve_access_trap(void) | ||
51 | +{ | ||
52 | + return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT; | ||
53 | +} | ||
54 | + | ||
55 | static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) | ||
56 | { | ||
57 | return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT) | ||
58 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/helper.c | ||
61 | +++ b/target/arm/helper.c | ||
62 | @@ -XXX,XX +XXX,XX @@ static int sve_exception_el(CPUARMState *env) | ||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | -static CPAccessResult zcr_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
67 | - bool isread) | ||
68 | -{ | ||
69 | - switch (sve_exception_el(env)) { | ||
70 | - case 3: | ||
71 | - return CP_ACCESS_TRAP_EL3; | ||
72 | - case 2: | ||
73 | - return CP_ACCESS_TRAP_EL2; | ||
74 | - case 1: | ||
75 | - return CP_ACCESS_TRAP; | ||
76 | - } | ||
77 | - return CP_ACCESS_OK; | ||
78 | -} | ||
79 | - | ||
80 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
81 | uint64_t value) | ||
82 | { | ||
83 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
84 | static const ARMCPRegInfo zcr_el1_reginfo = { | ||
85 | .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64, | ||
86 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0, | ||
87 | - .access = PL1_RW, .accessfn = zcr_access, | ||
88 | + .access = PL1_RW, .type = ARM_CP_SVE | ARM_CP_FPU, | ||
89 | .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]), | ||
90 | .writefn = zcr_write, .raw_writefn = raw_write | ||
91 | }; | ||
92 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el1_reginfo = { | ||
93 | static const ARMCPRegInfo zcr_el2_reginfo = { | ||
94 | .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | ||
95 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | ||
96 | - .access = PL2_RW, .accessfn = zcr_access, | ||
97 | + .access = PL2_RW, .type = ARM_CP_SVE | ARM_CP_FPU, | ||
98 | .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]), | ||
99 | .writefn = zcr_write, .raw_writefn = raw_write | ||
100 | }; | ||
101 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_el2_reginfo = { | ||
102 | static const ARMCPRegInfo zcr_no_el2_reginfo = { | ||
103 | .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | ||
104 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | ||
105 | - .access = PL2_RW, | ||
106 | + .access = PL2_RW, .type = ARM_CP_SVE | ARM_CP_FPU, | ||
107 | .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore | ||
108 | }; | ||
109 | |||
110 | static const ARMCPRegInfo zcr_el3_reginfo = { | ||
111 | .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64, | ||
112 | .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0, | ||
113 | - .access = PL3_RW, .accessfn = zcr_access, | ||
114 | + .access = PL3_RW, .type = ARM_CP_SVE | ARM_CP_FPU, | ||
115 | .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]), | ||
116 | .writefn = zcr_write, .raw_writefn = raw_write | ||
117 | }; | ||
118 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
119 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
120 | --- a/target/arm/translate-a64.c | 15 | --- a/target/arm/translate-a64.c |
121 | +++ b/target/arm/translate-a64.c | 16 | +++ b/target/arm/translate-a64.c |
122 | @@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s) | 17 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_fixed_conv(DisasContext *s, uint32_t insn) |
123 | return false; | 18 | bool sf = extract32(insn, 31, 1); |
124 | } | 19 | bool itof; |
125 | 20 | ||
126 | +/* Check that SVE access is enabled. If it is, return true. | 21 | - if (sbit || (type > 1) |
127 | + * If not, emit code to generate an appropriate exception and return false. | 22 | - || (!sf && scale < 32)) { |
128 | + */ | 23 | + if (sbit || (!sf && scale < 32)) { |
129 | +static inline bool sve_access_check(DisasContext *s) | 24 | + unallocated_encoding(s); |
130 | +{ | ||
131 | + if (s->sve_excp_el) { | ||
132 | + gen_exception_insn(s, 4, EXCP_UDEF, syn_sve_access_trap(), | ||
133 | + s->sve_excp_el); | ||
134 | + return false; | ||
135 | + } | ||
136 | + return true; | ||
137 | +} | ||
138 | + | ||
139 | /* | ||
140 | * This utility function is for doing register extension with an | ||
141 | * optional shift. You will likely want to pass a temporary for the | ||
142 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
143 | default: | ||
144 | break; | ||
145 | } | ||
146 | + if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) { | ||
147 | + return; | 25 | + return; |
148 | + } | 26 | + } |
149 | if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) { | 27 | + |
28 | + switch (type) { | ||
29 | + case 0: /* float32 */ | ||
30 | + case 1: /* float64 */ | ||
31 | + break; | ||
32 | + case 3: /* float16 */ | ||
33 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
34 | + break; | ||
35 | + } | ||
36 | + /* fallthru */ | ||
37 | + default: | ||
38 | unallocated_encoding(s); | ||
150 | return; | 39 | return; |
151 | } | 40 | } |
152 | -- | 41 | -- |
153 | 2.16.1 | 42 | 2.17.0 |
154 | 43 | ||
155 | 44 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When storing to an AdvSIMD FP register, all of the high | 3 | Cc: qemu-stable@nongnu.org |
4 | bits of the SVE register are zeroed. Therefore, call it | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | more often with is_q as a parameter. | ||
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20180211205848.4568-6-richard.henderson@linaro.org | 6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-id: 20180512003217.9105-6-richard.henderson@linaro.org |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 9 | --- |
12 | target/arm/translate-a64.c | 162 +++++++++++++++++---------------------------- | 10 | target/arm/translate-a64.c | 30 ++++++++++++++---------------- |
13 | 1 file changed, 62 insertions(+), 100 deletions(-) | 11 | 1 file changed, 14 insertions(+), 16 deletions(-) |
14 | 12 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 15 | --- a/target/arm/translate-a64.c |
18 | +++ b/target/arm/translate-a64.c | 16 | +++ b/target/arm/translate-a64.c |
19 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 read_fp_sreg(DisasContext *s, int reg) | 17 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 read_fp_sreg(DisasContext *s, int reg) |
20 | return v; | 18 | return v; |
21 | } | 19 | } |
22 | 20 | ||
23 | +/* Clear the bits above an N-bit vector, for N = (is_q ? 128 : 64). | 21 | +static TCGv_i32 read_fp_hreg(DisasContext *s, int reg) |
24 | + * If SVE is not enabled, then there are only 128 bits in the vector. | ||
25 | + */ | ||
26 | +static void clear_vec_high(DisasContext *s, bool is_q, int rd) | ||
27 | +{ | 22 | +{ |
28 | + unsigned ofs = fp_reg_offset(s, rd, MO_64); | 23 | + TCGv_i32 v = tcg_temp_new_i32(); |
29 | + unsigned vsz = vec_full_reg_size(s); | ||
30 | + | 24 | + |
31 | + if (!is_q) { | 25 | + tcg_gen_ld16u_i32(v, cpu_env, fp_reg_offset(s, reg, MO_16)); |
32 | + TCGv_i64 tcg_zero = tcg_const_i64(0); | 26 | + return v; |
33 | + tcg_gen_st_i64(tcg_zero, cpu_env, ofs + 8); | ||
34 | + tcg_temp_free_i64(tcg_zero); | ||
35 | + } | ||
36 | + if (vsz > 16) { | ||
37 | + tcg_gen_gvec_dup8i(ofs + 16, vsz - 16, vsz - 16, 0); | ||
38 | + } | ||
39 | +} | 27 | +} |
40 | + | 28 | + |
41 | static void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v) | 29 | /* Clear the bits above an N-bit vector, for N = (is_q ? 128 : 64). |
30 | * If SVE is not enabled, then there are only 128 bits in the vector. | ||
31 | */ | ||
32 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | ||
33 | static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) | ||
42 | { | 34 | { |
43 | - TCGv_i64 tcg_zero = tcg_const_i64(0); | 35 | TCGv_ptr fpst = NULL; |
44 | + unsigned ofs = fp_reg_offset(s, reg, MO_64); | 36 | - TCGv_i32 tcg_op = tcg_temp_new_i32(); |
45 | 37 | + TCGv_i32 tcg_op = read_fp_hreg(s, rn); | |
46 | - tcg_gen_st_i64(v, cpu_env, fp_reg_offset(s, reg, MO_64)); | 38 | TCGv_i32 tcg_res = tcg_temp_new_i32(); |
47 | - tcg_gen_st_i64(tcg_zero, cpu_env, fp_reg_hi_offset(s, reg)); | 39 | |
48 | - tcg_temp_free_i64(tcg_zero); | 40 | - read_vec_element_i32(s, tcg_op, rn, 0, MO_16); |
49 | + tcg_gen_st_i64(v, cpu_env, ofs); | 41 | - |
50 | + clear_vec_high(s, false, reg); | 42 | switch (opcode) { |
51 | } | 43 | case 0x0: /* FMOV */ |
52 | 44 | tcg_gen_mov_i32(tcg_res, tcg_op); | |
53 | static void write_fp_sreg(DisasContext *s, int reg, TCGv_i32 v) | 45 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_diff(DisasContext *s, uint32_t insn) |
54 | @@ -XXX,XX +XXX,XX @@ static void do_fp_ld(DisasContext *s, int destidx, TCGv_i64 tcg_addr, int size) | 46 | tcg_temp_free_i64(tcg_op2); |
55 | 47 | tcg_temp_free_i64(tcg_res); | |
56 | tcg_temp_free_i64(tmplo); | 48 | } else { |
57 | tcg_temp_free_i64(tmphi); | 49 | - TCGv_i32 tcg_op1 = tcg_temp_new_i32(); |
58 | + | 50 | - TCGv_i32 tcg_op2 = tcg_temp_new_i32(); |
59 | + clear_vec_high(s, true, destidx); | 51 | + TCGv_i32 tcg_op1 = read_fp_hreg(s, rn); |
60 | } | 52 | + TCGv_i32 tcg_op2 = read_fp_hreg(s, rm); |
61 | 53 | TCGv_i64 tcg_res = tcg_temp_new_i64(); | |
62 | /* | 54 | |
63 | @@ -XXX,XX +XXX,XX @@ static void write_vec_element_i32(DisasContext *s, TCGv_i32 tcg_src, | 55 | - read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); |
56 | - read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); | ||
57 | - | ||
58 | gen_helper_neon_mull_s16(tcg_res, tcg_op1, tcg_op2); | ||
59 | gen_helper_neon_addl_saturate_s32(tcg_res, cpu_env, tcg_res, tcg_res); | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s, | ||
62 | |||
63 | fpst = get_fpstatus_ptr(true); | ||
64 | |||
65 | - tcg_op1 = tcg_temp_new_i32(); | ||
66 | - tcg_op2 = tcg_temp_new_i32(); | ||
67 | + tcg_op1 = read_fp_hreg(s, rn); | ||
68 | + tcg_op2 = read_fp_hreg(s, rm); | ||
69 | tcg_res = tcg_temp_new_i32(); | ||
70 | |||
71 | - read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); | ||
72 | - read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); | ||
73 | - | ||
74 | switch (fpopcode) { | ||
75 | case 0x03: /* FMULX */ | ||
76 | gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
77 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) | ||
64 | } | 78 | } |
65 | } | 79 | |
66 | 80 | if (is_scalar) { | |
67 | -/* Clear the high 64 bits of a 128 bit vector (in general non-quad | 81 | - TCGv_i32 tcg_op = tcg_temp_new_i32(); |
68 | - * vector ops all need to do this). | 82 | + TCGv_i32 tcg_op = read_fp_hreg(s, rn); |
69 | - */ | 83 | TCGv_i32 tcg_res = tcg_temp_new_i32(); |
70 | -static void clear_vec_high(DisasContext *s, int rd) | 84 | |
71 | -{ | 85 | - read_vec_element_i32(s, tcg_op, rn, 0, MO_16); |
72 | - TCGv_i64 tcg_zero = tcg_const_i64(0); | ||
73 | - | 86 | - |
74 | - write_vec_element(s, tcg_zero, rd, 1, MO_64); | 87 | switch (fpop) { |
75 | - tcg_temp_free_i64(tcg_zero); | 88 | case 0x1a: /* FCVTNS */ |
76 | -} | 89 | case 0x1b: /* FCVTMS */ |
77 | - | ||
78 | /* Store from vector register to memory */ | ||
79 | static void do_vec_st(DisasContext *s, int srcidx, int element, | ||
80 | TCGv_i64 tcg_addr, int size) | ||
81 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
82 | /* For non-quad operations, setting a slice of the low | ||
83 | * 64 bits of the register clears the high 64 bits (in | ||
84 | * the ARM ARM pseudocode this is implicit in the fact | ||
85 | - * that 'rval' is a 64 bit wide variable). We optimize | ||
86 | - * by noticing that we only need to do this the first | ||
87 | - * time we touch a register. | ||
88 | + * that 'rval' is a 64 bit wide variable). | ||
89 | + * For quad operations, we might still need to zero the | ||
90 | + * high bits of SVE. We optimize by noticing that we only | ||
91 | + * need to do this the first time we touch a register. | ||
92 | */ | ||
93 | - if (!is_q && e == 0 && (r == 0 || xs == selem - 1)) { | ||
94 | - clear_vec_high(s, tt); | ||
95 | + if (e == 0 && (r == 0 || xs == selem - 1)) { | ||
96 | + clear_vec_high(s, is_q, tt); | ||
97 | } | ||
98 | } | ||
99 | tcg_gen_addi_i64(tcg_addr, tcg_addr, ebytes); | ||
100 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
101 | write_vec_element(s, tcg_tmp, rt, 0, MO_64); | ||
102 | if (is_q) { | ||
103 | write_vec_element(s, tcg_tmp, rt, 1, MO_64); | ||
104 | - } else { | ||
105 | - clear_vec_high(s, rt); | ||
106 | } | ||
107 | tcg_temp_free_i64(tcg_tmp); | ||
108 | + clear_vec_high(s, is_q, rt); | ||
109 | } else { | ||
110 | /* Load/store one element per register */ | ||
111 | if (is_load) { | ||
112 | @@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_sqshrn(DisasContext *s, bool is_scalar, bool is_q, | ||
113 | } | ||
114 | |||
115 | if (!is_q) { | ||
116 | - clear_vec_high(s, rd); | ||
117 | write_vec_element(s, tcg_final, rd, 0, MO_64); | ||
118 | } else { | ||
119 | write_vec_element(s, tcg_final, rd, 1, MO_64); | ||
120 | @@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_sqshrn(DisasContext *s, bool is_scalar, bool is_q, | ||
121 | tcg_temp_free_i64(tcg_rd); | ||
122 | tcg_temp_free_i32(tcg_rd_narrowed); | ||
123 | tcg_temp_free_i64(tcg_final); | ||
124 | - return; | ||
125 | + | ||
126 | + clear_vec_high(s, is_q, rd); | ||
127 | } | ||
128 | |||
129 | /* SQSHLU, UQSHL, SQSHL: saturating left shifts */ | ||
130 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_qshl(DisasContext *s, bool scalar, bool is_q, | ||
131 | tcg_temp_free_i64(tcg_op); | ||
132 | } | ||
133 | tcg_temp_free_i64(tcg_shift); | ||
134 | - | ||
135 | - if (!is_q) { | ||
136 | - clear_vec_high(s, rd); | ||
137 | - } | ||
138 | + clear_vec_high(s, is_q, rd); | ||
139 | } else { | ||
140 | TCGv_i32 tcg_shift = tcg_const_i32(shift); | ||
141 | static NeonGenTwoOpEnvFn * const fns[2][2][3] = { | ||
142 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_qshl(DisasContext *s, bool scalar, bool is_q, | ||
143 | } | ||
144 | tcg_temp_free_i32(tcg_shift); | ||
145 | |||
146 | - if (!is_q && !scalar) { | ||
147 | - clear_vec_high(s, rd); | ||
148 | + if (!scalar) { | ||
149 | + clear_vec_high(s, is_q, rd); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_intfp_conv(DisasContext *s, int rd, int rn, | ||
154 | } | ||
155 | } | ||
156 | |||
157 | - if (!is_double && elements == 2) { | ||
158 | - clear_vec_high(s, rd); | ||
159 | - } | ||
160 | - | ||
161 | tcg_temp_free_i64(tcg_int); | ||
162 | tcg_temp_free_ptr(tcg_fpst); | ||
163 | tcg_temp_free_i32(tcg_shift); | ||
164 | + | ||
165 | + clear_vec_high(s, elements << size == 16, rd); | ||
166 | } | ||
167 | |||
168 | /* UCVTF/SCVTF - Integer to FP conversion */ | ||
169 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, | ||
170 | write_vec_element(s, tcg_op, rd, pass, MO_64); | ||
171 | tcg_temp_free_i64(tcg_op); | ||
172 | } | ||
173 | - if (!is_q) { | ||
174 | - clear_vec_high(s, rd); | ||
175 | - } | ||
176 | + clear_vec_high(s, is_q, rd); | ||
177 | } else { | ||
178 | int maxpass = is_scalar ? 1 : is_q ? 4 : 2; | ||
179 | for (pass = 0; pass < maxpass; pass++) { | ||
180 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar, | ||
181 | } | ||
182 | tcg_temp_free_i32(tcg_op); | ||
183 | } | ||
184 | - if (!is_q && !is_scalar) { | ||
185 | - clear_vec_high(s, rd); | ||
186 | + if (!is_scalar) { | ||
187 | + clear_vec_high(s, is_q, rd); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | @@ -XXX,XX +XXX,XX @@ static void handle_3same_float(DisasContext *s, int size, int elements, | ||
192 | |||
193 | tcg_temp_free_ptr(fpst); | ||
194 | |||
195 | - if ((elements << size) < 4) { | ||
196 | - /* scalar, or non-quad vector op */ | ||
197 | - clear_vec_high(s, rd); | ||
198 | - } | ||
199 | + clear_vec_high(s, elements * (size ? 8 : 4) > 8, rd); | ||
200 | } | ||
201 | |||
202 | /* AdvSIMD scalar three same | ||
203 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, | ||
204 | } | ||
205 | write_vec_element(s, tcg_res, rd, pass, MO_64); | ||
206 | } | ||
207 | - if (is_scalar) { | ||
208 | - clear_vec_high(s, rd); | ||
209 | - } | ||
210 | - | ||
211 | tcg_temp_free_i64(tcg_res); | ||
212 | tcg_temp_free_i64(tcg_zero); | ||
213 | tcg_temp_free_i64(tcg_op); | ||
214 | + | ||
215 | + clear_vec_high(s, !is_scalar, rd); | ||
216 | } else { | ||
217 | TCGv_i32 tcg_op = tcg_temp_new_i32(); | ||
218 | TCGv_i32 tcg_zero = tcg_const_i32(0); | ||
219 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_fcmp_zero(DisasContext *s, int opcode, | ||
220 | tcg_temp_free_i32(tcg_res); | ||
221 | tcg_temp_free_i32(tcg_zero); | ||
222 | tcg_temp_free_i32(tcg_op); | ||
223 | - if (!is_q && !is_scalar) { | ||
224 | - clear_vec_high(s, rd); | ||
225 | + if (!is_scalar) { | ||
226 | + clear_vec_high(s, is_q, rd); | ||
227 | } | ||
228 | } | ||
229 | |||
230 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode, | ||
231 | } | ||
232 | write_vec_element(s, tcg_res, rd, pass, MO_64); | ||
233 | } | ||
234 | - if (is_scalar) { | ||
235 | - clear_vec_high(s, rd); | ||
236 | - } | ||
237 | - | ||
238 | tcg_temp_free_i64(tcg_res); | ||
239 | tcg_temp_free_i64(tcg_op); | ||
240 | + clear_vec_high(s, !is_scalar, rd); | ||
241 | } else { | ||
242 | TCGv_i32 tcg_op = tcg_temp_new_i32(); | ||
243 | TCGv_i32 tcg_res = tcg_temp_new_i32(); | ||
244 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_reciprocal(DisasContext *s, int opcode, | ||
245 | } | ||
246 | tcg_temp_free_i32(tcg_res); | ||
247 | tcg_temp_free_i32(tcg_op); | ||
248 | - if (!is_q && !is_scalar) { | ||
249 | - clear_vec_high(s, rd); | ||
250 | + if (!is_scalar) { | ||
251 | + clear_vec_high(s, is_q, rd); | ||
252 | } | ||
253 | } | ||
254 | tcg_temp_free_ptr(fpst); | ||
255 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_narrow(DisasContext *s, bool scalar, | ||
256 | write_vec_element_i32(s, tcg_res[pass], rd, destelt + pass, MO_32); | ||
257 | tcg_temp_free_i32(tcg_res[pass]); | ||
258 | } | ||
259 | - if (!is_q) { | ||
260 | - clear_vec_high(s, rd); | ||
261 | - } | ||
262 | + clear_vec_high(s, is_q, rd); | ||
263 | } | ||
264 | |||
265 | /* Remaining saturating accumulating ops */ | ||
266 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_satacc(DisasContext *s, bool is_scalar, bool is_u, | ||
267 | } | ||
268 | write_vec_element(s, tcg_rd, rd, pass, MO_64); | ||
269 | } | ||
270 | - if (is_scalar) { | ||
271 | - clear_vec_high(s, rd); | ||
272 | - } | ||
273 | - | ||
274 | tcg_temp_free_i64(tcg_rd); | ||
275 | tcg_temp_free_i64(tcg_rn); | ||
276 | + clear_vec_high(s, !is_scalar, rd); | ||
277 | } else { | ||
278 | TCGv_i32 tcg_rn = tcg_temp_new_i32(); | ||
279 | TCGv_i32 tcg_rd = tcg_temp_new_i32(); | ||
280 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_satacc(DisasContext *s, bool is_scalar, bool is_u, | ||
281 | } | ||
282 | write_vec_element_i32(s, tcg_rd, rd, pass, MO_32); | ||
283 | } | ||
284 | - | ||
285 | - if (!is_q) { | ||
286 | - clear_vec_high(s, rd); | ||
287 | - } | ||
288 | - | ||
289 | tcg_temp_free_i32(tcg_rd); | ||
290 | tcg_temp_free_i32(tcg_rn); | ||
291 | + clear_vec_high(s, is_q, rd); | ||
292 | } | ||
293 | } | ||
294 | |||
295 | @@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shri(DisasContext *s, bool is_q, bool is_u, | ||
296 | tcg_temp_free_i64(tcg_round); | ||
297 | |||
298 | done: | ||
299 | - if (!is_q) { | ||
300 | - clear_vec_high(s, rd); | ||
301 | - } | ||
302 | + clear_vec_high(s, is_q, rd); | ||
303 | } | ||
304 | |||
305 | static void gen_shl8_ins_i64(TCGv_i64 d, TCGv_i64 a, int64_t shift) | ||
306 | @@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shrn(DisasContext *s, bool is_q, | ||
307 | } | ||
308 | |||
309 | if (!is_q) { | ||
310 | - clear_vec_high(s, rd); | ||
311 | write_vec_element(s, tcg_final, rd, 0, MO_64); | ||
312 | } else { | ||
313 | write_vec_element(s, tcg_final, rd, 1, MO_64); | ||
314 | } | ||
315 | - | ||
316 | if (round) { | ||
317 | tcg_temp_free_i64(tcg_round); | ||
318 | } | ||
319 | tcg_temp_free_i64(tcg_rn); | ||
320 | tcg_temp_free_i64(tcg_rd); | ||
321 | tcg_temp_free_i64(tcg_final); | ||
322 | - return; | ||
323 | + | ||
324 | + clear_vec_high(s, is_q, rd); | ||
325 | } | ||
326 | |||
327 | |||
328 | @@ -XXX,XX +XXX,XX @@ static void handle_3rd_narrowing(DisasContext *s, int is_q, int is_u, int size, | ||
329 | write_vec_element_i32(s, tcg_res[pass], rd, pass + part, MO_32); | ||
330 | tcg_temp_free_i32(tcg_res[pass]); | ||
331 | } | ||
332 | - if (!is_q) { | ||
333 | - clear_vec_high(s, rd); | ||
334 | - } | ||
335 | + clear_vec_high(s, is_q, rd); | ||
336 | } | ||
337 | |||
338 | static void handle_pmull_64(DisasContext *s, int is_q, int rd, int rn, int rm) | ||
339 | @@ -XXX,XX +XXX,XX @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode, | ||
340 | write_vec_element_i32(s, tcg_res[pass], rd, pass, MO_32); | ||
341 | tcg_temp_free_i32(tcg_res[pass]); | ||
342 | } | ||
343 | - if (!is_q) { | ||
344 | - clear_vec_high(s, rd); | ||
345 | - } | ||
346 | + clear_vec_high(s, is_q, rd); | ||
347 | } | ||
348 | |||
349 | if (fpst) { | ||
350 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) | ||
351 | tcg_temp_free_i32(tcg_op2); | ||
352 | } | ||
353 | } | ||
354 | - | ||
355 | - if (!is_q) { | ||
356 | - clear_vec_high(s, rd); | ||
357 | - } | ||
358 | + clear_vec_high(s, is_q, rd); | ||
359 | } | ||
360 | |||
361 | /* AdvSIMD three same | ||
362 | @@ -XXX,XX +XXX,XX @@ static void handle_rev(DisasContext *s, int opcode, bool u, | ||
363 | write_vec_element(s, tcg_tmp, rd, i, grp_size); | ||
364 | tcg_temp_free_i64(tcg_tmp); | ||
365 | } | ||
366 | - if (!is_q) { | ||
367 | - clear_vec_high(s, rd); | ||
368 | - } | ||
369 | + clear_vec_high(s, is_q, rd); | ||
370 | } else { | ||
371 | int revmask = (1 << grp_size) - 1; | ||
372 | int esize = 8 << size; | ||
373 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | ||
374 | tcg_temp_free_i32(tcg_op); | ||
375 | } | ||
376 | } | ||
377 | - if (!is_q) { | ||
378 | - clear_vec_high(s, rd); | ||
379 | - } | ||
380 | + clear_vec_high(s, is_q, rd); | ||
381 | |||
382 | if (need_rmode) { | ||
383 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env); | ||
384 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
385 | tcg_temp_free_i64(tcg_res); | ||
386 | } | ||
387 | |||
388 | - if (is_scalar) { | ||
389 | - clear_vec_high(s, rd); | ||
390 | - } | ||
391 | - | ||
392 | tcg_temp_free_i64(tcg_idx); | ||
393 | + clear_vec_high(s, !is_scalar, rd); | ||
394 | } else if (!is_long) { | ||
395 | /* 32 bit floating point, or 16 or 32 bit integer. | ||
396 | * For the 16 bit scalar case we use the usual Neon helpers and | ||
397 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
398 | } | ||
399 | |||
400 | tcg_temp_free_i32(tcg_idx); | ||
401 | - | ||
402 | - if (!is_q) { | ||
403 | - clear_vec_high(s, rd); | ||
404 | - } | ||
405 | + clear_vec_high(s, is_q, rd); | ||
406 | } else { | ||
407 | /* long ops: 16x16->32 or 32x32->64 */ | ||
408 | TCGv_i64 tcg_res[2]; | ||
409 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
410 | } | ||
411 | tcg_temp_free_i64(tcg_idx); | ||
412 | |||
413 | - if (is_scalar) { | ||
414 | - clear_vec_high(s, rd); | ||
415 | - } | ||
416 | + clear_vec_high(s, !is_scalar, rd); | ||
417 | } else { | ||
418 | TCGv_i32 tcg_idx = tcg_temp_new_i32(); | ||
419 | |||
420 | -- | 90 | -- |
421 | 2.16.1 | 91 | 2.17.0 |
422 | 92 | ||
423 | 93 | diff view generated by jsdifflib |
1 | From: Pekka Enberg <penberg@iki.fi> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds a "raspi3" machine type, which can now be selected as | 3 | We missed all of the scalar fp16 binary operations. |
4 | the machine to run on by users via the "-M" command line option to QEMU. | ||
5 | 4 | ||
6 | The machine type does *not* ignore memory transaction failures so we | 5 | Cc: qemu-stable@nongnu.org |
7 | likely need to add some dummy devices later when people run something | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | more complicated than what I'm using for testing. | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | 8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | |
10 | Signed-off-by: Pekka Enberg <penberg@iki.fi> | 9 | Message-id: 20180512003217.9105-7-richard.henderson@linaro.org |
11 | [PMM: added #ifdef TARGET_AARCH64 so we don't provide the 64-bit | ||
12 | board in the 32-bit only arm-softmmu build.] | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 11 | --- |
17 | hw/arm/raspi.c | 23 +++++++++++++++++++++++ | 12 | target/arm/translate-a64.c | 65 ++++++++++++++++++++++++++++++++++++++ |
18 | 1 file changed, 23 insertions(+) | 13 | 1 file changed, 65 insertions(+) |
19 | 14 | ||
20 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/raspi.c | 17 | --- a/target/arm/translate-a64.c |
23 | +++ b/hw/arm/raspi.c | 18 | +++ b/target/arm/translate-a64.c |
24 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) | 19 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_double(DisasContext *s, int opcode, |
25 | mc->ignore_memory_transaction_failures = true; | 20 | tcg_temp_free_i64(tcg_res); |
26 | }; | 21 | } |
27 | DEFINE_MACHINE("raspi2", raspi2_machine_init) | 22 | |
23 | +/* Floating-point data-processing (2 source) - half precision */ | ||
24 | +static void handle_fp_2src_half(DisasContext *s, int opcode, | ||
25 | + int rd, int rn, int rm) | ||
26 | +{ | ||
27 | + TCGv_i32 tcg_op1; | ||
28 | + TCGv_i32 tcg_op2; | ||
29 | + TCGv_i32 tcg_res; | ||
30 | + TCGv_ptr fpst; | ||
28 | + | 31 | + |
29 | +#ifdef TARGET_AARCH64 | 32 | + tcg_res = tcg_temp_new_i32(); |
30 | +static void raspi3_init(MachineState *machine) | 33 | + fpst = get_fpstatus_ptr(true); |
31 | +{ | 34 | + tcg_op1 = read_fp_hreg(s, rn); |
32 | + raspi_init(machine, 3); | 35 | + tcg_op2 = read_fp_hreg(s, rm); |
36 | + | ||
37 | + switch (opcode) { | ||
38 | + case 0x0: /* FMUL */ | ||
39 | + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
40 | + break; | ||
41 | + case 0x1: /* FDIV */ | ||
42 | + gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
43 | + break; | ||
44 | + case 0x2: /* FADD */ | ||
45 | + gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
46 | + break; | ||
47 | + case 0x3: /* FSUB */ | ||
48 | + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
49 | + break; | ||
50 | + case 0x4: /* FMAX */ | ||
51 | + gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
52 | + break; | ||
53 | + case 0x5: /* FMIN */ | ||
54 | + gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
55 | + break; | ||
56 | + case 0x6: /* FMAXNM */ | ||
57 | + gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
58 | + break; | ||
59 | + case 0x7: /* FMINNM */ | ||
60 | + gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
61 | + break; | ||
62 | + case 0x8: /* FNMUL */ | ||
63 | + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
64 | + tcg_gen_xori_i32(tcg_res, tcg_res, 0x8000); | ||
65 | + break; | ||
66 | + default: | ||
67 | + g_assert_not_reached(); | ||
68 | + } | ||
69 | + | ||
70 | + write_fp_sreg(s, rd, tcg_res); | ||
71 | + | ||
72 | + tcg_temp_free_ptr(fpst); | ||
73 | + tcg_temp_free_i32(tcg_op1); | ||
74 | + tcg_temp_free_i32(tcg_op2); | ||
75 | + tcg_temp_free_i32(tcg_res); | ||
33 | +} | 76 | +} |
34 | + | 77 | + |
35 | +static void raspi3_machine_init(MachineClass *mc) | 78 | /* Floating point data-processing (2 source) |
36 | +{ | 79 | * 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0 |
37 | + mc->desc = "Raspberry Pi 3"; | 80 | * +---+---+---+-----------+------+---+------+--------+-----+------+------+ |
38 | + mc->init = raspi3_init; | 81 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_2src(DisasContext *s, uint32_t insn) |
39 | + mc->block_default_type = IF_SD; | 82 | } |
40 | + mc->no_parallel = 1; | 83 | handle_fp_2src_double(s, opcode, rd, rn, rm); |
41 | + mc->no_floppy = 1; | 84 | break; |
42 | + mc->no_cdrom = 1; | 85 | + case 3: |
43 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); | 86 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { |
44 | + mc->max_cpus = BCM2836_NCPUS; | 87 | + unallocated_encoding(s); |
45 | + mc->min_cpus = BCM2836_NCPUS; | 88 | + return; |
46 | + mc->default_cpus = BCM2836_NCPUS; | 89 | + } |
47 | + mc->default_ram_size = 1024 * 1024 * 1024; | 90 | + if (!fp_access_check(s)) { |
48 | +} | 91 | + return; |
49 | +DEFINE_MACHINE("raspi3", raspi3_machine_init) | 92 | + } |
50 | +#endif | 93 | + handle_fp_2src_half(s, opcode, rd, rn, rm); |
94 | + break; | ||
95 | default: | ||
96 | unallocated_encoding(s); | ||
97 | } | ||
51 | -- | 98 | -- |
52 | 2.16.1 | 99 | 2.17.0 |
53 | 100 | ||
54 | 101 | diff view generated by jsdifflib |
1 | From: Pekka Enberg <penberg@iki.fi> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds Raspberry Pi 3 support to hw/arm/raspi.c. The | 3 | We missed all of the scalar fp16 fma operations. |
4 | differences to Pi 2 are: | ||
5 | 4 | ||
6 | - Firmware address | 5 | Cc: qemu-stable@nongnu.org |
7 | - Board ID | 6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | - Board revision | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | 8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | |
10 | The CPU is different too, but that's going to be configured as part of | 9 | Message-id: 20180512003217.9105-8-richard.henderson@linaro.org |
11 | the machine default CPU when we introduce a new machine type. | ||
12 | |||
13 | The patch was written from scratch by me but the logic is similar to | ||
14 | Zoltán Baldaszti's previous work, which I used as a reference (with | ||
15 | permission from the author): | ||
16 | |||
17 | https://github.com/bztsrc/qemu-raspi3 | ||
18 | |||
19 | Signed-off-by: Pekka Enberg <penberg@iki.fi> | ||
20 | [PMM: fixed trailing whitespace on one line] | ||
21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | --- | 11 | --- |
24 | hw/arm/raspi.c | 31 +++++++++++++++++++++---------- | 12 | target/arm/translate-a64.c | 48 ++++++++++++++++++++++++++++++++++++++ |
25 | 1 file changed, 21 insertions(+), 10 deletions(-) | 13 | 1 file changed, 48 insertions(+) |
26 | 14 | ||
27 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
28 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/hw/arm/raspi.c | 17 | --- a/target/arm/translate-a64.c |
30 | +++ b/hw/arm/raspi.c | 18 | +++ b/target/arm/translate-a64.c |
31 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1, |
32 | * Rasperry Pi 2 emulation Copyright (c) 2015, Microsoft | 20 | tcg_temp_free_i64(tcg_res); |
33 | * Written by Andrew Baumann | ||
34 | * | ||
35 | + * Raspberry Pi 3 emulation Copyright (c) 2018 Zoltán Baldaszti | ||
36 | + * Upstream code cleanup (c) 2018 Pekka Enberg | ||
37 | + * | ||
38 | * This code is licensed under the GNU GPLv2 and later. | ||
39 | */ | ||
40 | |||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | #define SMPBOOT_ADDR 0x300 /* this should leave enough space for ATAGS */ | ||
43 | #define MVBAR_ADDR 0x400 /* secure vectors */ | ||
44 | #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */ | ||
45 | -#define FIRMWARE_ADDR 0x8000 /* Pi loads kernel.img here by default */ | ||
46 | +#define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */ | ||
47 | +#define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ | ||
48 | |||
49 | /* Table of Linux board IDs for different Pi versions */ | ||
50 | -static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43}; | ||
51 | +static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; | ||
52 | |||
53 | typedef struct RasPiState { | ||
54 | BCM2836State soc; | ||
55 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
56 | binfo.secure_board_setup = true; | ||
57 | binfo.secure_boot = true; | ||
58 | |||
59 | - /* Pi2 requires SMP setup */ | ||
60 | - if (version == 2) { | ||
61 | + /* Pi2 and Pi3 requires SMP setup */ | ||
62 | + if (version >= 2) { | ||
63 | binfo.smp_loader_start = SMPBOOT_ADDR; | ||
64 | binfo.write_secondary_boot = write_smpboot; | ||
65 | binfo.secondary_cpu_reset_hook = reset_secondary; | ||
66 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
67 | * the normal Linux boot process | ||
68 | */ | ||
69 | if (machine->firmware) { | ||
70 | + hwaddr firmware_addr = version == 3 ? FIRMWARE_ADDR_3 : FIRMWARE_ADDR_2; | ||
71 | /* load the firmware image (typically kernel.img) */ | ||
72 | - r = load_image_targphys(machine->firmware, FIRMWARE_ADDR, | ||
73 | - ram_size - FIRMWARE_ADDR); | ||
74 | + r = load_image_targphys(machine->firmware, firmware_addr, | ||
75 | + ram_size - firmware_addr); | ||
76 | if (r < 0) { | ||
77 | error_report("Failed to load firmware from %s", machine->firmware); | ||
78 | exit(1); | ||
79 | } | ||
80 | |||
81 | - binfo.entry = FIRMWARE_ADDR; | ||
82 | + binfo.entry = firmware_addr; | ||
83 | binfo.firmware_loaded = true; | ||
84 | } else { | ||
85 | binfo.kernel_filename = machine->kernel_filename; | ||
86 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
87 | arm_load_kernel(ARM_CPU(first_cpu), &binfo); | ||
88 | } | 21 | } |
89 | 22 | ||
90 | -static void raspi2_init(MachineState *machine) | 23 | +/* Floating-point data-processing (3 source) - half precision */ |
91 | +static void raspi_init(MachineState *machine, int version) | 24 | +static void handle_fp_3src_half(DisasContext *s, bool o0, bool o1, |
92 | { | 25 | + int rd, int rn, int rm, int ra) |
93 | RasPiState *s = g_new0(RasPiState, 1); | 26 | +{ |
94 | uint32_t vcram_size; | 27 | + TCGv_i32 tcg_op1, tcg_op2, tcg_op3; |
95 | @@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine) | 28 | + TCGv_i32 tcg_res = tcg_temp_new_i32(); |
96 | &error_abort); | 29 | + TCGv_ptr fpst = get_fpstatus_ptr(true); |
97 | object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus", | 30 | + |
98 | &error_abort); | 31 | + tcg_op1 = read_fp_hreg(s, rn); |
99 | - object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev", | 32 | + tcg_op2 = read_fp_hreg(s, rm); |
100 | + int board_rev = version == 3 ? 0xa02082 : 0xa21041; | 33 | + tcg_op3 = read_fp_hreg(s, ra); |
101 | + object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev", | 34 | + |
102 | &error_abort); | 35 | + /* These are fused multiply-add, and must be done as one |
103 | object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abort); | 36 | + * floating point operation with no rounding between the |
104 | 37 | + * multiplication and addition steps. | |
105 | @@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine) | 38 | + * NB that doing the negations here as separate steps is |
106 | 39 | + * correct : an input NaN should come out with its sign bit | |
107 | vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size", | 40 | + * flipped if it is a negated-input. |
108 | &error_abort); | 41 | + */ |
109 | - setup_boot(machine, 2, machine->ram_size - vcram_size); | 42 | + if (o1 == true) { |
110 | + setup_boot(machine, version, machine->ram_size - vcram_size); | 43 | + tcg_gen_xori_i32(tcg_op3, tcg_op3, 0x8000); |
44 | + } | ||
45 | + | ||
46 | + if (o0 != o1) { | ||
47 | + tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000); | ||
48 | + } | ||
49 | + | ||
50 | + gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_op3, fpst); | ||
51 | + | ||
52 | + write_fp_sreg(s, rd, tcg_res); | ||
53 | + | ||
54 | + tcg_temp_free_ptr(fpst); | ||
55 | + tcg_temp_free_i32(tcg_op1); | ||
56 | + tcg_temp_free_i32(tcg_op2); | ||
57 | + tcg_temp_free_i32(tcg_op3); | ||
58 | + tcg_temp_free_i32(tcg_res); | ||
111 | +} | 59 | +} |
112 | + | 60 | + |
113 | +static void raspi2_init(MachineState *machine) | 61 | /* Floating point data-processing (3 source) |
114 | +{ | 62 | * 31 30 29 28 24 23 22 21 20 16 15 14 10 9 5 4 0 |
115 | + raspi_init(machine, 2); | 63 | * +---+---+---+-----------+------+----+------+----+------+------+------+ |
116 | } | 64 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn) |
117 | 65 | } | |
118 | static void raspi2_machine_init(MachineClass *mc) | 66 | handle_fp_3src_double(s, o0, o1, rd, rn, rm, ra); |
67 | break; | ||
68 | + case 3: | ||
69 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
70 | + unallocated_encoding(s); | ||
71 | + return; | ||
72 | + } | ||
73 | + if (!fp_access_check(s)) { | ||
74 | + return; | ||
75 | + } | ||
76 | + handle_fp_3src_half(s, o0, o1, rd, rn, rm, ra); | ||
77 | + break; | ||
78 | default: | ||
79 | unallocated_encoding(s); | ||
80 | } | ||
119 | -- | 81 | -- |
120 | 2.16.1 | 82 | 2.17.0 |
121 | 83 | ||
122 | 84 | diff view generated by jsdifflib |
1 | M profile cores have a similar setup for cache ID registers | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | to A profile: | 2 | |
3 | * Cache Level ID Register (CLIDR) is a fixed value | 3 | These where missed out from the rest of the half-precision work. |
4 | * Cache Type Register (CTR) is a fixed value | 4 | |
5 | * Cache Size ID Registers (CCSIDR) are a bank of registers; | 5 | Cc: qemu-stable@nongnu.org |
6 | which one you see is selected by the Cache Size Selection | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Register (CSSELR) | 7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
8 | 8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | |
9 | The only difference is that they're in the NVIC memory mapped | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | register space rather than being coprocessor registers. | 10 | Message-id: 20180512003217.9105-9-richard.henderson@linaro.org |
11 | Implement the M profile view of them. | 11 | [rth: Diagnose lack of FP16 before fp_access_check] |
12 | 12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | |
13 | Since neither Cortex-M3 nor Cortex-M4 implement caches, | ||
14 | we don't need to update their init functions and can leave | ||
15 | the ctr/clidr/ccsidr[] fields in their ARMCPU structs at zero. | ||
16 | Newer cores (like the Cortex-M33) will want to be able to | ||
17 | set these ID registers to non-zero values, though. | ||
18 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20180209165810.6668-6-peter.maydell@linaro.org | ||
22 | --- | 14 | --- |
23 | target/arm/cpu.h | 26 ++++++++++++++++++++++++++ | 15 | target/arm/helper-a64.h | 2 + |
24 | hw/intc/armv7m_nvic.c | 16 ++++++++++++++++ | 16 | target/arm/helper-a64.c | 10 +++++ |
25 | target/arm/machine.c | 36 ++++++++++++++++++++++++++++++++++++ | 17 | target/arm/translate-a64.c | 88 ++++++++++++++++++++++++++++++-------- |
26 | 3 files changed, 78 insertions(+) | 18 | 3 files changed, 83 insertions(+), 17 deletions(-) |
27 | 19 | ||
28 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 20 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h |
29 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/cpu.h | 22 | --- a/target/arm/helper-a64.h |
31 | +++ b/target/arm/cpu.h | 23 | +++ b/target/arm/helper-a64.h |
32 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 24 | @@ -XXX,XX +XXX,XX @@ |
33 | uint32_t faultmask[M_REG_NUM_BANKS]; | 25 | DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64) |
34 | uint32_t aircr; /* only holds r/w state if security extn implemented */ | 26 | DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64) |
35 | uint32_t secure; /* Is CPU in Secure state? (not guest visible) */ | 27 | DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64) |
36 | + uint32_t csselr[M_REG_NUM_BANKS]; | 28 | +DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr) |
37 | } v7m; | 29 | +DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr) |
38 | 30 | DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr) | |
39 | /* Information associated with an exception about to be taken: | 31 | DEF_HELPER_3(vfp_cmpes_a64, i64, f32, f32, ptr) |
40 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_MPU_CTRL, ENABLE, 0, 1) | 32 | DEF_HELPER_3(vfp_cmpd_a64, i64, f64, f64, ptr) |
41 | FIELD(V7M_MPU_CTRL, HFNMIENA, 1, 1) | 33 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c |
42 | FIELD(V7M_MPU_CTRL, PRIVDEFENA, 2, 1) | 34 | index XXXXXXX..XXXXXXX 100644 |
43 | 35 | --- a/target/arm/helper-a64.c | |
44 | +/* v7M CLIDR bits */ | 36 | +++ b/target/arm/helper-a64.c |
45 | +FIELD(V7M_CLIDR, CTYPE_ALL, 0, 21) | 37 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res) |
46 | +FIELD(V7M_CLIDR, LOUIS, 21, 3) | 38 | return flags; |
47 | +FIELD(V7M_CLIDR, LOC, 24, 3) | ||
48 | +FIELD(V7M_CLIDR, LOUU, 27, 3) | ||
49 | +FIELD(V7M_CLIDR, ICB, 30, 2) | ||
50 | + | ||
51 | +FIELD(V7M_CSSELR, IND, 0, 1) | ||
52 | +FIELD(V7M_CSSELR, LEVEL, 1, 3) | ||
53 | +/* We use the combination of InD and Level to index into cpu->ccsidr[]; | ||
54 | + * define a mask for this and check that it doesn't permit running off | ||
55 | + * the end of the array. | ||
56 | + */ | ||
57 | +FIELD(V7M_CSSELR, INDEX, 0, 4) | ||
58 | + | ||
59 | +QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK); | ||
60 | + | ||
61 | /* If adding a feature bit which corresponds to a Linux ELF | ||
62 | * HWCAP bit, remember to update the feature-bit-to-hwcap | ||
63 | * mapping in linux-user/elfload.c:get_elf_hwcap(). | ||
64 | @@ -XXX,XX +XXX,XX @@ static inline int arm_debug_target_el(CPUARMState *env) | ||
65 | } | ||
66 | } | 39 | } |
67 | 40 | ||
68 | +static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu) | 41 | +uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status) |
69 | +{ | 42 | +{ |
70 | + /* If all the CLIDR.Ctypem bits are 0 there are no caches, and | 43 | + return float_rel_to_flags(float16_compare_quiet(x, y, fp_status)); |
71 | + * CSSELR is RAZ/WI. | ||
72 | + */ | ||
73 | + return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0; | ||
74 | +} | 44 | +} |
75 | + | 45 | + |
76 | static inline bool aa64_generate_debug_exceptions(CPUARMState *env) | 46 | +uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status) |
47 | +{ | ||
48 | + return float_rel_to_flags(float16_compare(x, y, fp_status)); | ||
49 | +} | ||
50 | + | ||
51 | uint64_t HELPER(vfp_cmps_a64)(float32 x, float32 y, void *fp_status) | ||
77 | { | 52 | { |
78 | if (arm_is_secure(env)) { | 53 | return float_rel_to_flags(float32_compare_quiet(x, y, fp_status)); |
79 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 54 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
80 | index XXXXXXX..XXXXXXX 100644 | 55 | index XXXXXXX..XXXXXXX 100644 |
81 | --- a/hw/intc/armv7m_nvic.c | 56 | --- a/target/arm/translate-a64.c |
82 | +++ b/hw/intc/armv7m_nvic.c | 57 | +++ b/target/arm/translate-a64.c |
83 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 58 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn) |
84 | return cpu->id_isar4; | 59 | } |
85 | case 0xd74: /* ISAR5. */ | 60 | } |
86 | return cpu->id_isar5; | 61 | |
87 | + case 0xd78: /* CLIDR */ | 62 | -static void handle_fp_compare(DisasContext *s, bool is_double, |
88 | + return cpu->clidr; | 63 | +static void handle_fp_compare(DisasContext *s, int size, |
89 | + case 0xd7c: /* CTR */ | 64 | unsigned int rn, unsigned int rm, |
90 | + return cpu->ctr; | 65 | bool cmp_with_zero, bool signal_all_nans) |
91 | + case 0xd80: /* CSSIDR */ | 66 | { |
92 | + { | 67 | TCGv_i64 tcg_flags = tcg_temp_new_i64(); |
93 | + int idx = cpu->env.v7m.csselr[attrs.secure] & R_V7M_CSSELR_INDEX_MASK; | 68 | - TCGv_ptr fpst = get_fpstatus_ptr(false); |
94 | + return cpu->ccsidr[idx]; | 69 | + TCGv_ptr fpst = get_fpstatus_ptr(size == MO_16); |
70 | |||
71 | - if (is_double) { | ||
72 | + if (size == MO_64) { | ||
73 | TCGv_i64 tcg_vn, tcg_vm; | ||
74 | |||
75 | tcg_vn = read_fp_dreg(s, rn); | ||
76 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double, | ||
77 | tcg_temp_free_i64(tcg_vn); | ||
78 | tcg_temp_free_i64(tcg_vm); | ||
79 | } else { | ||
80 | - TCGv_i32 tcg_vn, tcg_vm; | ||
81 | + TCGv_i32 tcg_vn = tcg_temp_new_i32(); | ||
82 | + TCGv_i32 tcg_vm = tcg_temp_new_i32(); | ||
83 | |||
84 | - tcg_vn = read_fp_sreg(s, rn); | ||
85 | + read_vec_element_i32(s, tcg_vn, rn, 0, size); | ||
86 | if (cmp_with_zero) { | ||
87 | - tcg_vm = tcg_const_i32(0); | ||
88 | + tcg_gen_movi_i32(tcg_vm, 0); | ||
89 | } else { | ||
90 | - tcg_vm = read_fp_sreg(s, rm); | ||
91 | + read_vec_element_i32(s, tcg_vm, rm, 0, size); | ||
92 | } | ||
93 | - if (signal_all_nans) { | ||
94 | - gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
95 | - } else { | ||
96 | - gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
97 | + | ||
98 | + switch (size) { | ||
99 | + case MO_32: | ||
100 | + if (signal_all_nans) { | ||
101 | + gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
102 | + } else { | ||
103 | + gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
104 | + } | ||
105 | + break; | ||
106 | + case MO_16: | ||
107 | + if (signal_all_nans) { | ||
108 | + gen_helper_vfp_cmpeh_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
109 | + } else { | ||
110 | + gen_helper_vfp_cmph_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | ||
111 | + } | ||
112 | + break; | ||
113 | + default: | ||
114 | + g_assert_not_reached(); | ||
115 | } | ||
116 | + | ||
117 | tcg_temp_free_i32(tcg_vn); | ||
118 | tcg_temp_free_i32(tcg_vm); | ||
119 | } | ||
120 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double, | ||
121 | static void disas_fp_compare(DisasContext *s, uint32_t insn) | ||
122 | { | ||
123 | unsigned int mos, type, rm, op, rn, opc, op2r; | ||
124 | + int size; | ||
125 | |||
126 | mos = extract32(insn, 29, 3); | ||
127 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ | ||
128 | + type = extract32(insn, 22, 2); | ||
129 | rm = extract32(insn, 16, 5); | ||
130 | op = extract32(insn, 14, 2); | ||
131 | rn = extract32(insn, 5, 5); | ||
132 | opc = extract32(insn, 3, 2); | ||
133 | op2r = extract32(insn, 0, 3); | ||
134 | |||
135 | - if (mos || op || op2r || type > 1) { | ||
136 | + if (mos || op || op2r) { | ||
137 | + unallocated_encoding(s); | ||
138 | + return; | ||
95 | + } | 139 | + } |
96 | + case 0xd84: /* CSSELR */ | 140 | + |
97 | + return cpu->env.v7m.csselr[attrs.secure]; | 141 | + switch (type) { |
98 | /* TODO: Implement debug registers. */ | 142 | + case 0: |
99 | case 0xd90: /* MPU_TYPE */ | 143 | + size = MO_32; |
100 | /* Unified MPU; if the MPU is not present this value is zero */ | 144 | + break; |
101 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | 145 | + case 1: |
102 | qemu_log_mask(LOG_UNIMP, | 146 | + size = MO_64; |
103 | "NVIC: Aux fault status registers unimplemented\n"); | 147 | + break; |
104 | break; | 148 | + case 3: |
105 | + case 0xd84: /* CSSELR */ | 149 | + size = MO_16; |
106 | + if (!arm_v7m_csselr_razwi(cpu)) { | 150 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { |
107 | + cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK; | 151 | + break; |
108 | + } | 152 | + } |
109 | + break; | 153 | + /* fallthru */ |
110 | case 0xd90: /* MPU_TYPE */ | 154 | + default: |
111 | return; /* RO */ | 155 | unallocated_encoding(s); |
112 | case 0xd94: /* MPU_CTRL */ | 156 | return; |
113 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 157 | } |
114 | index XXXXXXX..XXXXXXX 100644 | 158 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_compare(DisasContext *s, uint32_t insn) |
115 | --- a/target/arm/machine.c | 159 | return; |
116 | +++ b/target/arm/machine.c | 160 | } |
117 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_faultmask_primask = { | 161 | |
118 | } | 162 | - handle_fp_compare(s, type, rn, rm, opc & 1, opc & 2); |
119 | }; | 163 | + handle_fp_compare(s, size, rn, rm, opc & 1, opc & 2); |
120 | 164 | } | |
121 | +/* CSSELR is in a subsection because we didn't implement it previously. | 165 | |
122 | + * Migration from an old implementation will leave it at zero, which | 166 | /* Floating point conditional compare |
123 | + * is OK since the only CPUs in the old implementation make the | 167 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) |
124 | + * register RAZ/WI. | 168 | unsigned int mos, type, rm, cond, rn, op, nzcv; |
125 | + * Since there was no version of QEMU which implemented the CSSELR for | 169 | TCGv_i64 tcg_flags; |
126 | + * just non-secure, we transfer both banks here rather than putting | 170 | TCGLabel *label_continue = NULL; |
127 | + * the secure banked version in the m-security subsection. | 171 | + int size; |
128 | + */ | 172 | |
129 | +static bool csselr_vmstate_validate(void *opaque, int version_id) | 173 | mos = extract32(insn, 29, 3); |
130 | +{ | 174 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ |
131 | + ARMCPU *cpu = opaque; | 175 | + type = extract32(insn, 22, 2); |
132 | + | 176 | rm = extract32(insn, 16, 5); |
133 | + return cpu->env.v7m.csselr[M_REG_NS] <= R_V7M_CSSELR_INDEX_MASK | 177 | cond = extract32(insn, 12, 4); |
134 | + && cpu->env.v7m.csselr[M_REG_S] <= R_V7M_CSSELR_INDEX_MASK; | 178 | rn = extract32(insn, 5, 5); |
135 | +} | 179 | op = extract32(insn, 4, 1); |
136 | + | 180 | nzcv = extract32(insn, 0, 4); |
137 | +static bool m_csselr_needed(void *opaque) | 181 | |
138 | +{ | 182 | - if (mos || type > 1) { |
139 | + ARMCPU *cpu = opaque; | 183 | + if (mos) { |
140 | + | 184 | + unallocated_encoding(s); |
141 | + return !arm_v7m_csselr_razwi(cpu); | 185 | + return; |
142 | +} | ||
143 | + | ||
144 | +static const VMStateDescription vmstate_m_csselr = { | ||
145 | + .name = "cpu/m/csselr", | ||
146 | + .version_id = 1, | ||
147 | + .minimum_version_id = 1, | ||
148 | + .needed = m_csselr_needed, | ||
149 | + .fields = (VMStateField[]) { | ||
150 | + VMSTATE_UINT32_ARRAY(env.v7m.csselr, ARMCPU, M_REG_NUM_BANKS), | ||
151 | + VMSTATE_VALIDATE("CSSELR is valid", csselr_vmstate_validate), | ||
152 | + VMSTATE_END_OF_LIST() | ||
153 | + } | 186 | + } |
154 | +}; | 187 | + |
155 | + | 188 | + switch (type) { |
156 | static const VMStateDescription vmstate_m = { | 189 | + case 0: |
157 | .name = "cpu/m", | 190 | + size = MO_32; |
158 | .version_id = 4, | 191 | + break; |
159 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | 192 | + case 1: |
160 | }, | 193 | + size = MO_64; |
161 | .subsections = (const VMStateDescription*[]) { | 194 | + break; |
162 | &vmstate_m_faultmask_primask, | 195 | + case 3: |
163 | + &vmstate_m_csselr, | 196 | + size = MO_16; |
164 | NULL | 197 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { |
165 | } | 198 | + break; |
166 | }; | 199 | + } |
200 | + /* fallthru */ | ||
201 | + default: | ||
202 | unallocated_encoding(s); | ||
203 | return; | ||
204 | } | ||
205 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) | ||
206 | gen_set_label(label_match); | ||
207 | } | ||
208 | |||
209 | - handle_fp_compare(s, type, rn, rm, false, op); | ||
210 | + handle_fp_compare(s, size, rn, rm, false, op); | ||
211 | |||
212 | if (cond < 0x0e) { | ||
213 | gen_set_label(label_continue); | ||
167 | -- | 214 | -- |
168 | 2.16.1 | 215 | 2.17.0 |
169 | 216 | ||
170 | 217 | diff view generated by jsdifflib |
1 | From: Pekka Enberg <penberg@iki.fi> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This patch adds a "cpu-type" property to BCM2836 SoC in preparation for | 3 | These were missed out from the rest of the half-precision work. |
4 | reusing the code for the Raspberry Pi 3, which has a different processor | ||
5 | model. | ||
6 | 4 | ||
7 | Signed-off-by: Pekka Enberg <penberg@iki.fi> | 5 | Cc: qemu-stable@nongnu.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20180512003217.9105-10-richard.henderson@linaro.org | ||
11 | [rth: Fix erroneous check vs type] | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | include/hw/arm/bcm2836.h | 1 + | 15 | target/arm/translate-a64.c | 31 +++++++++++++++++++++++++------ |
12 | hw/arm/bcm2836.c | 17 +++++++++-------- | 16 | 1 file changed, 25 insertions(+), 6 deletions(-) |
13 | hw/arm/raspi.c | 3 +++ | ||
14 | 3 files changed, 13 insertions(+), 8 deletions(-) | ||
15 | 17 | ||
16 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 18 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/bcm2836.h | 20 | --- a/target/arm/translate-a64.c |
19 | +++ b/include/hw/arm/bcm2836.h | 21 | +++ b/target/arm/translate-a64.c |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State { | 22 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) |
21 | DeviceState parent_obj; | 23 | unsigned int mos, type, rm, cond, rn, rd; |
22 | /*< public >*/ | 24 | TCGv_i64 t_true, t_false, t_zero; |
23 | 25 | DisasCompare64 c; | |
24 | + char *cpu_type; | 26 | + TCGMemOp sz; |
25 | uint32_t enabled_cpus; | 27 | |
26 | 28 | mos = extract32(insn, 29, 3); | |
27 | ARMCPU cpus[BCM2836_NCPUS]; | 29 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ |
28 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 30 | + type = extract32(insn, 22, 2); |
29 | index XXXXXXX..XXXXXXX 100644 | 31 | rm = extract32(insn, 16, 5); |
30 | --- a/hw/arm/bcm2836.c | 32 | cond = extract32(insn, 12, 4); |
31 | +++ b/hw/arm/bcm2836.c | 33 | rn = extract32(insn, 5, 5); |
32 | @@ -XXX,XX +XXX,XX @@ | 34 | rd = extract32(insn, 0, 5); |
33 | static void bcm2836_init(Object *obj) | 35 | |
34 | { | 36 | - if (mos || type > 1) { |
35 | BCM2836State *s = BCM2836(obj); | 37 | + if (mos) { |
36 | - int n; | 38 | + unallocated_encoding(s); |
37 | - | 39 | + return; |
38 | - for (n = 0; n < BCM2836_NCPUS; n++) { | ||
39 | - object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | ||
40 | - "cortex-a15-" TYPE_ARM_CPU); | ||
41 | - object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
42 | - &error_abort); | ||
43 | - } | ||
44 | |||
45 | object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); | ||
46 | object_property_add_child(obj, "control", OBJECT(&s->control), NULL); | ||
47 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
48 | |||
49 | /* common peripherals from bcm2835 */ | ||
50 | |||
51 | + obj = OBJECT(dev); | ||
52 | + for (n = 0; n < BCM2836_NCPUS; n++) { | ||
53 | + object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | ||
54 | + s->cpu_type); | ||
55 | + object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
56 | + &error_abort); | ||
57 | + } | 40 | + } |
58 | + | 41 | + |
59 | obj = object_property_get_link(OBJECT(dev), "ram", &err); | 42 | + switch (type) { |
60 | if (obj == NULL) { | 43 | + case 0: |
61 | error_setg(errp, "%s: required ram link not found: %s", | 44 | + sz = MO_32; |
62 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | 45 | + break; |
63 | } | 46 | + case 1: |
64 | 47 | + sz = MO_64; | |
65 | static Property bcm2836_props[] = { | 48 | + break; |
66 | + DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type), | 49 | + case 3: |
67 | DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS), | 50 | + sz = MO_16; |
68 | DEFINE_PROP_END_OF_LIST() | 51 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { |
69 | }; | 52 | + break; |
70 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 53 | + } |
71 | index XXXXXXX..XXXXXXX 100644 | 54 | + /* fallthru */ |
72 | --- a/hw/arm/raspi.c | 55 | + default: |
73 | +++ b/hw/arm/raspi.c | 56 | unallocated_encoding(s); |
74 | @@ -XXX,XX +XXX,XX @@ static void raspi2_init(MachineState *machine) | 57 | return; |
75 | /* Setup the SOC */ | 58 | } |
76 | object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), | 59 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) |
77 | &error_abort); | 60 | return; |
78 | + object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type", | 61 | } |
79 | + &error_abort); | 62 | |
80 | object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus", | 63 | - /* Zero extend sreg inputs to 64 bits now. */ |
81 | &error_abort); | 64 | + /* Zero extend sreg & hreg inputs to 64 bits now. */ |
82 | object_property_set_int(OBJECT(&s->soc), 0xa21041, "board-rev", | 65 | t_true = tcg_temp_new_i64(); |
83 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) | 66 | t_false = tcg_temp_new_i64(); |
84 | mc->no_parallel = 1; | 67 | - read_vec_element(s, t_true, rn, 0, type ? MO_64 : MO_32); |
85 | mc->no_floppy = 1; | 68 | - read_vec_element(s, t_false, rm, 0, type ? MO_64 : MO_32); |
86 | mc->no_cdrom = 1; | 69 | + read_vec_element(s, t_true, rn, 0, sz); |
87 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); | 70 | + read_vec_element(s, t_false, rm, 0, sz); |
88 | mc->max_cpus = BCM2836_NCPUS; | 71 | |
89 | mc->min_cpus = BCM2836_NCPUS; | 72 | a64_test_cc(&c, cond); |
90 | mc->default_cpus = BCM2836_NCPUS; | 73 | t_zero = tcg_const_i64(0); |
74 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | ||
75 | tcg_temp_free_i64(t_false); | ||
76 | a64_free_cc(&c); | ||
77 | |||
78 | - /* Note that sregs write back zeros to the high bits, | ||
79 | + /* Note that sregs & hregs write back zeros to the high bits, | ||
80 | and we've already done the zero-extension. */ | ||
81 | write_fp_dreg(s, rd, t_true); | ||
82 | tcg_temp_free_i64(t_true); | ||
91 | -- | 83 | -- |
92 | 2.16.1 | 84 | 2.17.0 |
93 | 85 | ||
94 | 86 | diff view generated by jsdifflib |
1 | In commit commit 3b2e934463121 we added support for the AIRCR | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | register holding state, but forgot to add it to the vmstate | ||
3 | structs. Since it only holds r/w state if the security extension | ||
4 | is implemented, we can just add it to vmstate_m_security. | ||
5 | 2 | ||
3 | All the hard work is already done by vfp_expand_imm, we just need to | ||
4 | make sure we pick up the correct size. | ||
5 | |||
6 | Cc: qemu-stable@nongnu.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20180512003217.9105-11-richard.henderson@linaro.org | ||
12 | [rth: Merge unallocated_encoding check with TCGMemOp conversion.] | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180209165810.6668-10-peter.maydell@linaro.org | ||
9 | --- | 15 | --- |
10 | target/arm/machine.c | 4 ++++ | 16 | target/arm/translate-a64.c | 20 +++++++++++++++++--- |
11 | 1 file changed, 4 insertions(+) | 17 | 1 file changed, 17 insertions(+), 3 deletions(-) |
12 | 18 | ||
13 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 19 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/machine.c | 21 | --- a/target/arm/translate-a64.c |
16 | +++ b/target/arm/machine.c | 22 | +++ b/target/arm/translate-a64.c |
17 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_security = { | 23 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) |
18 | VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate), | 24 | { |
19 | VMSTATE_UINT32(env.sau.ctrl, ARMCPU), | 25 | int rd = extract32(insn, 0, 5); |
20 | VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU), | 26 | int imm8 = extract32(insn, 13, 8); |
21 | + /* AIRCR is not secure-only, but our implementation is R/O if the | 27 | - int is_double = extract32(insn, 22, 2); |
22 | + * security extension is unimplemented, so we migrate it here. | 28 | + int type = extract32(insn, 22, 2); |
23 | + */ | 29 | uint64_t imm; |
24 | + VMSTATE_UINT32(env.v7m.aircr, ARMCPU), | 30 | TCGv_i64 tcg_res; |
25 | VMSTATE_END_OF_LIST() | 31 | + TCGMemOp sz; |
32 | |||
33 | - if (is_double > 1) { | ||
34 | + switch (type) { | ||
35 | + case 0: | ||
36 | + sz = MO_32; | ||
37 | + break; | ||
38 | + case 1: | ||
39 | + sz = MO_64; | ||
40 | + break; | ||
41 | + case 3: | ||
42 | + sz = MO_16; | ||
43 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
44 | + break; | ||
45 | + } | ||
46 | + /* fallthru */ | ||
47 | + default: | ||
48 | unallocated_encoding(s); | ||
49 | return; | ||
26 | } | 50 | } |
27 | }; | 51 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) |
52 | return; | ||
53 | } | ||
54 | |||
55 | - imm = vfp_expand_imm(MO_32 + is_double, imm8); | ||
56 | + imm = vfp_expand_imm(sz, imm8); | ||
57 | |||
58 | tcg_res = tcg_const_i64(imm); | ||
59 | write_fp_dreg(s, rd, tcg_res); | ||
28 | -- | 60 | -- |
29 | 2.16.1 | 61 | 2.17.0 |
30 | 62 | ||
31 | 63 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | (qemu) info mtree | 3 | We are meant to explicitly pass fpst, not cpu_env. |
4 | address-space: cpu-memory-0 | ||
5 | 0000000000000000-ffffffffffffffff (prio 0, i/o): system | ||
6 | 0000000000000000-0000000007ffffff (prio 0, rom): aspeed.boot_rom | ||
7 | 000000001e600000-000000001e7fffff (prio -1, i/o): aspeed_soc.io | ||
8 | - 000000001e784000-000000001e78401f (prio 0, i/o): serial | ||
9 | 000000001e620000-000000001e6200ff (prio 0, i/o): aspeed.smc.ast2500-fmc | ||
10 | 000000001e630000-000000001e6300ff (prio 0, i/o): aspeed.smc.ast2500-spi1 | ||
11 | [...] | ||
12 | 000000001e720000-000000001e728fff (prio 0, ram): aspeed.sram | ||
13 | 000000001e782000-000000001e782fff (prio 0, i/o): aspeed.timer | ||
14 | + 000000001e784000-000000001e78401f (prio 0, i/o): serial | ||
15 | 000000001e785000-000000001e78501f (prio 0, i/o): aspeed.wdt | ||
16 | 000000001e785020-000000001e78503f (prio 0, i/o): aspeed.wdt | ||
17 | 4 | ||
18 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Cc: qemu-stable@nongnu.org |
19 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
20 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
21 | Message-id: 20180209085755.30414-2-f4bug@amsat.org | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Message-id: 20180512003217.9105-12-richard.henderson@linaro.org | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | --- | 12 | --- |
24 | hw/arm/aspeed_soc.c | 3 ++- | 13 | target/arm/translate-a64.c | 3 ++- |
25 | 1 file changed, 2 insertions(+), 1 deletion(-) | 14 | 1 file changed, 2 insertions(+), 1 deletion(-) |
26 | 15 | ||
27 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
28 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/hw/arm/aspeed_soc.c | 18 | --- a/target/arm/translate-a64.c |
30 | +++ b/hw/arm/aspeed_soc.c | 19 | +++ b/target/arm/translate-a64.c |
31 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 20 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) |
32 | /* UART - attach an 8250 to the IO space as our UART5 */ | 21 | tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); |
33 | if (serial_hds[0]) { | 22 | break; |
34 | qemu_irq uart5 = qdev_get_gpio_in(DEVICE(&s->vic), uart_irqs[4]); | 23 | case 0x3: /* FSQRT */ |
35 | - serial_mm_init(&s->iomem, ASPEED_SOC_UART_5_BASE, 2, | 24 | - gen_helper_sqrt_f16(tcg_res, tcg_op, cpu_env); |
36 | + serial_mm_init(get_system_memory(), | 25 | + fpst = get_fpstatus_ptr(true); |
37 | + ASPEED_SOC_IOMEM_BASE + ASPEED_SOC_UART_5_BASE, 2, | 26 | + gen_helper_sqrt_f16(tcg_res, tcg_op, fpst); |
38 | uart5, 38400, serial_hds[0], DEVICE_LITTLE_ENDIAN); | 27 | break; |
39 | } | 28 | case 0x8: /* FRINTN */ |
40 | 29 | case 0x9: /* FRINTP */ | |
41 | -- | 30 | -- |
42 | 2.16.1 | 31 | 2.17.0 |
43 | 32 | ||
44 | 33 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | (qemu) info mtree | 3 | Per the Physical Layer Simplified Spec. "4.3.10.4 Switch Function Status": |
4 | address-space: cpu-memory-0 | 4 | |
5 | 0000000000000000-ffffffffffffffff (prio 0, i/o): system | 5 | The block length is predefined to 512 bits |
6 | 0000000000000000-0000000007ffffff (prio 0, rom): aspeed.boot_rom | 6 | |
7 | - 000000001e600000-000000001e7fffff (prio -1, i/o): aspeed_soc.io | 7 | and "4.10.2 SD Status": |
8 | + 000000001e600000-000000001e7fffff (prio -1000, i/o): aspeed_soc.io | 8 | |
9 | 000000001e620000-000000001e6200ff (prio 0, i/o): aspeed.smc.ast2500-fmc | 9 | The SD Status contains status bits that are related to the SD Memory Card |
10 | 000000001e630000-000000001e6300ff (prio 0, i/o): aspeed.smc.ast2500-spi1 | 10 | proprietary features and may be used for future application-specific usage. |
11 | 000000001e631000-000000001e6310ff (prio 0, i/o): aspeed.smc.ast2500-spi2 | 11 | The size of the SD Status is one data block of 512 bit. The content of this |
12 | register is transmitted to the Host over the DAT bus along with a 16-bit CRC. | ||
13 | |||
14 | Thus the 16-bit CRC goes at offset 64. | ||
12 | 15 | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 16 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
14 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 17 | Message-id: 20180509060104.4458-3-f4bug@amsat.org |
15 | Reviewed-by: Andrew Jeffery <andrew@aj.id.au> | 18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Message-id: 20180209085755.30414-3-f4bug@amsat.org | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 20 | --- |
19 | include/hw/arm/aspeed_soc.h | 1 - | 21 | hw/sd/sd.c | 2 +- |
20 | hw/arm/aspeed_soc.c | 32 +++----------------------------- | 22 | 1 file changed, 1 insertion(+), 1 deletion(-) |
21 | 2 files changed, 3 insertions(+), 30 deletions(-) | ||
22 | 23 | ||
23 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 24 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c |
24 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/arm/aspeed_soc.h | 26 | --- a/hw/sd/sd.c |
26 | +++ b/include/hw/arm/aspeed_soc.h | 27 | +++ b/hw/sd/sd.c |
27 | @@ -XXX,XX +XXX,XX @@ typedef struct AspeedSoCState { | 28 | @@ -XXX,XX +XXX,XX @@ static void sd_function_switch(SDState *sd, uint32_t arg) |
28 | 29 | sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4); | |
29 | /*< public >*/ | 30 | } |
30 | ARMCPU cpu; | 31 | memset(&sd->data[17], 0, 47); |
31 | - MemoryRegion iomem; | 32 | - stw_be_p(sd->data + 65, sd_crc16(sd->data, 64)); |
32 | MemoryRegion sram; | 33 | + stw_be_p(sd->data + 64, sd_crc16(sd->data, 64)); |
33 | AspeedVICState vic; | 34 | } |
34 | AspeedTimerCtrlState timerctrl; | 35 | |
35 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 36 | static inline bool sd_wp_addr(SDState *sd, uint64_t addr) |
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/arm/aspeed_soc.c | ||
38 | +++ b/hw/arm/aspeed_soc.c | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | #include "qemu-common.h" | ||
41 | #include "cpu.h" | ||
42 | #include "exec/address-spaces.h" | ||
43 | +#include "hw/misc/unimp.h" | ||
44 | #include "hw/arm/aspeed_soc.h" | ||
45 | #include "hw/char/serial.h" | ||
46 | #include "qemu/log.h" | ||
47 | @@ -XXX,XX +XXX,XX @@ static const AspeedSoCInfo aspeed_socs[] = { | ||
48 | }, | ||
49 | }; | ||
50 | |||
51 | -/* | ||
52 | - * IO handlers: simply catch any reads/writes to IO addresses that aren't | ||
53 | - * handled by a device mapping. | ||
54 | - */ | ||
55 | - | ||
56 | -static uint64_t aspeed_soc_io_read(void *p, hwaddr offset, unsigned size) | ||
57 | -{ | ||
58 | - qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n", | ||
59 | - __func__, offset, size); | ||
60 | - return 0; | ||
61 | -} | ||
62 | - | ||
63 | -static void aspeed_soc_io_write(void *opaque, hwaddr offset, uint64_t value, | ||
64 | - unsigned size) | ||
65 | -{ | ||
66 | - qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " <- 0x%" PRIx64 " [%u]\n", | ||
67 | - __func__, offset, value, size); | ||
68 | -} | ||
69 | - | ||
70 | -static const MemoryRegionOps aspeed_soc_io_ops = { | ||
71 | - .read = aspeed_soc_io_read, | ||
72 | - .write = aspeed_soc_io_write, | ||
73 | - .endianness = DEVICE_LITTLE_ENDIAN, | ||
74 | -}; | ||
75 | - | ||
76 | static void aspeed_soc_init(Object *obj) | ||
77 | { | ||
78 | AspeedSoCState *s = ASPEED_SOC(obj); | ||
79 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | ||
80 | Error *err = NULL, *local_err = NULL; | ||
81 | |||
82 | /* IO space */ | ||
83 | - memory_region_init_io(&s->iomem, NULL, &aspeed_soc_io_ops, NULL, | ||
84 | - "aspeed_soc.io", ASPEED_SOC_IOMEM_SIZE); | ||
85 | - memory_region_add_subregion_overlap(get_system_memory(), | ||
86 | - ASPEED_SOC_IOMEM_BASE, &s->iomem, -1); | ||
87 | + create_unimplemented_device("aspeed_soc.io", | ||
88 | + ASPEED_SOC_IOMEM_BASE, ASPEED_SOC_IOMEM_SIZE); | ||
89 | |||
90 | /* CPU */ | ||
91 | object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); | ||
92 | -- | 37 | -- |
93 | 2.16.1 | 38 | 2.17.0 |
94 | 39 | ||
95 | 40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The PENDNMISET/CLR bits in the ICSR should be RAZ/WI from | ||
2 | NonSecure state if the AIRCR.BFHFNMINS bit is zero. We had | ||
3 | misimplemented this as making the bits RAZ/WI from both | ||
4 | Secure and NonSecure states. Fix this bug by checking | ||
5 | attrs.secure so that Secure code can pend and unpend NMIs. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180209165810.6668-3-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/intc/armv7m_nvic.c | 6 +++--- | ||
12 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
13 | |||
14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/intc/armv7m_nvic.c | ||
17 | +++ b/hw/intc/armv7m_nvic.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
19 | } | ||
20 | } | ||
21 | /* NMIPENDSET */ | ||
22 | - if ((cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) && | ||
23 | - s->vectors[ARMV7M_EXCP_NMI].pending) { | ||
24 | + if ((attrs.secure || (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) | ||
25 | + && s->vectors[ARMV7M_EXCP_NMI].pending) { | ||
26 | val |= (1 << 31); | ||
27 | } | ||
28 | /* ISRPREEMPT: RES0 when halting debug not implemented */ | ||
29 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
30 | break; | ||
31 | } | ||
32 | case 0xd04: /* Interrupt Control State (ICSR) */ | ||
33 | - if (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) { | ||
34 | + if (attrs.secure || cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) { | ||
35 | if (value & (1 << 31)) { | ||
36 | armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI, false); | ||
37 | } else if (value & (1 << 30) && | ||
38 | -- | ||
39 | 2.16.1 | ||
40 | |||
41 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | For M profile cores, cache maintenance operations are done by | ||
2 | writing to special registers in the system register space. | ||
3 | For QEMU, cache operations are always NOPs, since we don't | ||
4 | implement the cache. Implementing these explicitly avoids | ||
5 | a spurious LOG_GUEST_ERROR when the guest uses them. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20180209165810.6668-4-peter.maydell@linaro.org | ||
10 | --- | ||
11 | hw/intc/armv7m_nvic.c | 12 ++++++++++++ | ||
12 | 1 file changed, 12 insertions(+) | ||
13 | |||
14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/intc/armv7m_nvic.c | ||
17 | +++ b/hw/intc/armv7m_nvic.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
19 | } | ||
20 | break; | ||
21 | } | ||
22 | + case 0xf50: /* ICIALLU */ | ||
23 | + case 0xf58: /* ICIMVAU */ | ||
24 | + case 0xf5c: /* DCIMVAC */ | ||
25 | + case 0xf60: /* DCISW */ | ||
26 | + case 0xf64: /* DCCMVAU */ | ||
27 | + case 0xf68: /* DCCMVAC */ | ||
28 | + case 0xf6c: /* DCCSW */ | ||
29 | + case 0xf70: /* DCCIMVAC */ | ||
30 | + case 0xf74: /* DCCISW */ | ||
31 | + case 0xf78: /* BPIALL */ | ||
32 | + /* Cache and branch predictor maintenance: for QEMU these always NOP */ | ||
33 | + break; | ||
34 | default: | ||
35 | bad_offset: | ||
36 | qemu_log_mask(LOG_GUEST_ERROR, | ||
37 | -- | ||
38 | 2.16.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The Coprocessor Power Control Register (CPPWR) is new in v8M. | ||
2 | It allows software to control whether coprocessors are allowed | ||
3 | to power down and lose their state. QEMU doesn't have any | ||
4 | notion of power control, so we choose the IMPDEF option of | ||
5 | making the whole register RAZ/WI (indicating that no coprocessors | ||
6 | can ever power down and lose state). | ||
7 | 1 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20180209165810.6668-5-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/intc/armv7m_nvic.c | 14 ++++++++++++++ | ||
13 | 1 file changed, 14 insertions(+) | ||
14 | |||
15 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/intc/armv7m_nvic.c | ||
18 | +++ b/hw/intc/armv7m_nvic.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
20 | switch (offset) { | ||
21 | case 4: /* Interrupt Control Type. */ | ||
22 | return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1; | ||
23 | + case 0xc: /* CPPWR */ | ||
24 | + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { | ||
25 | + goto bad_offset; | ||
26 | + } | ||
27 | + /* We make the IMPDEF choice that nothing can ever go into a | ||
28 | + * non-retentive power state, which allows us to RAZ/WI this. | ||
29 | + */ | ||
30 | + return 0; | ||
31 | case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */ | ||
32 | { | ||
33 | int startvec = 8 * (offset - 0x380) + NVIC_FIRST_IRQ; | ||
34 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
35 | ARMCPU *cpu = s->cpu; | ||
36 | |||
37 | switch (offset) { | ||
38 | + case 0xc: /* CPPWR */ | ||
39 | + if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { | ||
40 | + goto bad_offset; | ||
41 | + } | ||
42 | + /* Make the IMPDEF choice to RAZ/WI this. */ | ||
43 | + break; | ||
44 | case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */ | ||
45 | { | ||
46 | int startvec = 8 * (offset - 0x380) + NVIC_FIRST_IRQ; | ||
47 | -- | ||
48 | 2.16.1 | ||
49 | |||
50 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | We were previously making the system control register (SCR) | ||
2 | just RAZ/WI. Although we don't implement the functionality | ||
3 | this register controls, we should at least provide the state, | ||
4 | including the banked state for v8M. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20180209165810.6668-7-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/cpu.h | 7 +++++++ | ||
11 | hw/intc/armv7m_nvic.c | 12 ++++++++---- | ||
12 | target/arm/machine.c | 12 ++++++++++++ | ||
13 | 3 files changed, 27 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | ||
20 | uint32_t aircr; /* only holds r/w state if security extn implemented */ | ||
21 | uint32_t secure; /* Is CPU in Secure state? (not guest visible) */ | ||
22 | uint32_t csselr[M_REG_NUM_BANKS]; | ||
23 | + uint32_t scr[M_REG_NUM_BANKS]; | ||
24 | } v7m; | ||
25 | |||
26 | /* Information associated with an exception about to be taken: | ||
27 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_CCR, STKALIGN, 9, 1) | ||
28 | FIELD(V7M_CCR, DC, 16, 1) | ||
29 | FIELD(V7M_CCR, IC, 17, 1) | ||
30 | |||
31 | +/* V7M SCR bits */ | ||
32 | +FIELD(V7M_SCR, SLEEPONEXIT, 1, 1) | ||
33 | +FIELD(V7M_SCR, SLEEPDEEP, 2, 1) | ||
34 | +FIELD(V7M_SCR, SLEEPDEEPS, 3, 1) | ||
35 | +FIELD(V7M_SCR, SEVONPEND, 4, 1) | ||
36 | + | ||
37 | /* V7M AIRCR bits */ | ||
38 | FIELD(V7M_AIRCR, VECTRESET, 0, 1) | ||
39 | FIELD(V7M_AIRCR, VECTCLRACTIVE, 1, 1) | ||
40 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/intc/armv7m_nvic.c | ||
43 | +++ b/hw/intc/armv7m_nvic.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
45 | } | ||
46 | return val; | ||
47 | case 0xd10: /* System Control. */ | ||
48 | - /* TODO: Implement SLEEPONEXIT. */ | ||
49 | - return 0; | ||
50 | + return cpu->env.v7m.scr[attrs.secure]; | ||
51 | case 0xd14: /* Configuration Control. */ | ||
52 | /* The BFHFNMIGN bit is the only non-banked bit; we | ||
53 | * keep it in the non-secure copy of the register. | ||
54 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
55 | } | ||
56 | break; | ||
57 | case 0xd10: /* System Control. */ | ||
58 | - /* TODO: Implement control registers. */ | ||
59 | - qemu_log_mask(LOG_UNIMP, "NVIC: SCR unimplemented\n"); | ||
60 | + /* We don't implement deep-sleep so these bits are RAZ/WI. | ||
61 | + * The other bits in the register are banked. | ||
62 | + * QEMU's implementation ignores SEVONPEND and SLEEPONEXIT, which | ||
63 | + * is architecturally permitted. | ||
64 | + */ | ||
65 | + value &= ~(R_V7M_SCR_SLEEPDEEP_MASK | R_V7M_SCR_SLEEPDEEPS_MASK); | ||
66 | + cpu->env.v7m.scr[attrs.secure] = value; | ||
67 | break; | ||
68 | case 0xd14: /* Configuration Control. */ | ||
69 | /* Enforce RAZ/WI on reserved and must-RAZ/WI bits */ | ||
70 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/target/arm/machine.c | ||
73 | +++ b/target/arm/machine.c | ||
74 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_csselr = { | ||
75 | } | ||
76 | }; | ||
77 | |||
78 | +static const VMStateDescription vmstate_m_scr = { | ||
79 | + .name = "cpu/m/scr", | ||
80 | + .version_id = 1, | ||
81 | + .minimum_version_id = 1, | ||
82 | + .fields = (VMStateField[]) { | ||
83 | + VMSTATE_UINT32(env.v7m.scr[M_REG_NS], ARMCPU), | ||
84 | + VMSTATE_END_OF_LIST() | ||
85 | + } | ||
86 | +}; | ||
87 | + | ||
88 | static const VMStateDescription vmstate_m = { | ||
89 | .name = "cpu/m", | ||
90 | .version_id = 4, | ||
91 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | ||
92 | .subsections = (const VMStateDescription*[]) { | ||
93 | &vmstate_m_faultmask_primask, | ||
94 | &vmstate_m_csselr, | ||
95 | + &vmstate_m_scr, | ||
96 | NULL | ||
97 | } | ||
98 | }; | ||
99 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_security = { | ||
100 | VMSTATE_UINT32(env.sau.rnr, ARMCPU), | ||
101 | VMSTATE_VALIDATE("SAU_RNR is valid", sau_rnr_vmstate_validate), | ||
102 | VMSTATE_UINT32(env.sau.ctrl, ARMCPU), | ||
103 | + VMSTATE_UINT32(env.v7m.scr[M_REG_S], ARMCPU), | ||
104 | VMSTATE_END_OF_LIST() | ||
105 | } | ||
106 | }; | ||
107 | -- | ||
108 | 2.16.1 | ||
109 | |||
110 | diff view generated by jsdifflib |
1 | In commit 50f11062d4c896 we added support for MSR/MRS access | 1 | Usually the logging of the CPU state produced by -d cpu is sufficient |
---|---|---|---|
2 | to the NS banked special registers, but we forgot to implement | 2 | to diagnose problems, but sometimes you want to see the state of |
3 | the support for writing to CONTROL_NS. Correct the omission. | 3 | the floating point registers as well. We don't want to enable that |
4 | by default as it adds a lot of extra data to the log; instead, | ||
5 | allow it to be optionally enabled via -d fpu. | ||
4 | 6 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20180209165810.6668-8-peter.maydell@linaro.org | 9 | Message-id: 20180510130024.31678-1-peter.maydell@linaro.org |
8 | --- | 10 | --- |
9 | target/arm/helper.c | 10 ++++++++++ | 11 | include/qemu/log.h | 1 + |
10 | 1 file changed, 10 insertions(+) | 12 | accel/tcg/cpu-exec.c | 9 ++++++--- |
13 | util/log.c | 2 ++ | ||
14 | 3 files changed, 9 insertions(+), 3 deletions(-) | ||
11 | 15 | ||
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 16 | diff --git a/include/qemu/log.h b/include/qemu/log.h |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.c | 18 | --- a/include/qemu/log.h |
15 | +++ b/target/arm/helper.c | 19 | +++ b/include/qemu/log.h |
16 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 20 | @@ -XXX,XX +XXX,XX @@ static inline bool qemu_log_separate(void) |
17 | } | 21 | #define CPU_LOG_PAGE (1 << 14) |
18 | env->v7m.faultmask[M_REG_NS] = val & 1; | 22 | /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ |
19 | return; | 23 | #define CPU_LOG_TB_OP_IND (1 << 16) |
20 | + case 0x94: /* CONTROL_NS */ | 24 | +#define CPU_LOG_TB_FPU (1 << 17) |
21 | + if (!env->v7m.secure) { | 25 | |
22 | + return; | 26 | /* Lock output for a series of related logs. Since this is not needed |
23 | + } | 27 | * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we |
24 | + write_v7m_control_spsel_for_secstate(env, | 28 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c |
25 | + val & R_V7M_CONTROL_SPSEL_MASK, | 29 | index XXXXXXX..XXXXXXX 100644 |
26 | + M_REG_NS); | 30 | --- a/accel/tcg/cpu-exec.c |
27 | + env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK; | 31 | +++ b/accel/tcg/cpu-exec.c |
28 | + env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK; | 32 | @@ -XXX,XX +XXX,XX @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) |
29 | + return; | 33 | if (qemu_loglevel_mask(CPU_LOG_TB_CPU) |
30 | case 0x98: /* SP_NS */ | 34 | && qemu_log_in_addr_range(itb->pc)) { |
31 | { | 35 | qemu_log_lock(); |
32 | /* This gives the non-secure SP selected based on whether we're | 36 | + int flags = 0; |
37 | + if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) { | ||
38 | + flags |= CPU_DUMP_FPU; | ||
39 | + } | ||
40 | #if defined(TARGET_I386) | ||
41 | - log_cpu_state(cpu, CPU_DUMP_CCOP); | ||
42 | -#else | ||
43 | - log_cpu_state(cpu, 0); | ||
44 | + flags |= CPU_DUMP_CCOP; | ||
45 | #endif | ||
46 | + log_cpu_state(cpu, flags); | ||
47 | qemu_log_unlock(); | ||
48 | } | ||
49 | #endif /* DEBUG_DISAS */ | ||
50 | diff --git a/util/log.c b/util/log.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/util/log.c | ||
53 | +++ b/util/log.c | ||
54 | @@ -XXX,XX +XXX,XX @@ const QEMULogItem qemu_log_items[] = { | ||
55 | "show trace before each executed TB (lots of logs)" }, | ||
56 | { CPU_LOG_TB_CPU, "cpu", | ||
57 | "show CPU registers before entering a TB (lots of logs)" }, | ||
58 | + { CPU_LOG_TB_FPU, "fpu", | ||
59 | + "include FPU registers in the 'cpu' logging" }, | ||
60 | { CPU_LOG_MMU, "mmu", | ||
61 | "log MMU-related activities" }, | ||
62 | { CPU_LOG_PCALL, "pcall", | ||
33 | -- | 63 | -- |
34 | 2.16.1 | 64 | 2.17.0 |
35 | 65 | ||
36 | 66 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In many of the NVIC registers relating to interrupts, we | ||
2 | have to convert from a byte offset within a register set | ||
3 | into the number of the first interrupt which is affected. | ||
4 | We were getting this wrong for: | ||
5 | * reads of NVIC_ISPR<n>, NVIC_ISER<n>, NVIC_ICPR<n>, NVIC_ICER<n>, | ||
6 | NVIC_IABR<n> -- in all these cases we were missing the "* 8" | ||
7 | needed to convert from the byte offset to the interrupt number | ||
8 | (since all these registers use one bit per interrupt) | ||
9 | * writes of NVIC_IPR<n> had the opposite problem of a spurious | ||
10 | "* 8" (since these registers use one byte per interrupt) | ||
11 | 1 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20180209165810.6668-9-peter.maydell@linaro.org | ||
15 | --- | ||
16 | hw/intc/armv7m_nvic.c | 8 ++++---- | ||
17 | 1 file changed, 4 insertions(+), 4 deletions(-) | ||
18 | |||
19 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/intc/armv7m_nvic.c | ||
22 | +++ b/hw/intc/armv7m_nvic.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, | ||
24 | /* fall through */ | ||
25 | case 0x180 ... 0x1bf: /* NVIC Clear enable */ | ||
26 | val = 0; | ||
27 | - startvec = offset - 0x180 + NVIC_FIRST_IRQ; /* vector # */ | ||
28 | + startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ; /* vector # */ | ||
29 | |||
30 | for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) { | ||
31 | if (s->vectors[startvec + i].enabled && | ||
32 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, | ||
33 | /* fall through */ | ||
34 | case 0x280 ... 0x2bf: /* NVIC Clear pend */ | ||
35 | val = 0; | ||
36 | - startvec = offset - 0x280 + NVIC_FIRST_IRQ; /* vector # */ | ||
37 | + startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ; /* vector # */ | ||
38 | for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) { | ||
39 | if (s->vectors[startvec + i].pending && | ||
40 | (attrs.secure || s->itns[startvec + i])) { | ||
41 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr, | ||
42 | break; | ||
43 | case 0x300 ... 0x33f: /* NVIC Active */ | ||
44 | val = 0; | ||
45 | - startvec = offset - 0x300 + NVIC_FIRST_IRQ; /* vector # */ | ||
46 | + startvec = 8 * (offset - 0x300) + NVIC_FIRST_IRQ; /* vector # */ | ||
47 | |||
48 | for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) { | ||
49 | if (s->vectors[startvec + i].active && | ||
50 | @@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr, | ||
51 | case 0x300 ... 0x33f: /* NVIC Active */ | ||
52 | return MEMTX_OK; /* R/O */ | ||
53 | case 0x400 ... 0x5ef: /* NVIC Priority */ | ||
54 | - startvec = 8 * (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */ | ||
55 | + startvec = (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */ | ||
56 | |||
57 | for (i = 0; i < size && startvec + i < s->num_irq; i++) { | ||
58 | if (attrs.secure || s->itns[startvec + i]) { | ||
59 | -- | ||
60 | 2.16.1 | ||
61 | |||
62 | diff view generated by jsdifflib |