1 | First arm pullreq of 4.2... | 1 | target-arm queue: the big stuff here is the final part of |
---|---|---|---|
2 | rth's patches for Cortex-A76 and Neoverse-N1 support; | ||
3 | also present are Gavin's NUMA series and a few other things. | ||
2 | 4 | ||
3 | thanks | 5 | thanks |
4 | -- PMM | 6 | -- PMM |
5 | 7 | ||
6 | The following changes since commit 27608c7c66bd923eb5e5faab80e795408cbe2b51: | 8 | The following changes since commit 554623226f800acf48a2ed568900c1c968ec9a8b: |
7 | 9 | ||
8 | Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20190814a' into staging (2019-08-16 12:00:18 +0100) | 10 | Merge tag 'qemu-sparc-20220508' of https://github.com/mcayland/qemu into staging (2022-05-08 17:03:26 -0500) |
9 | 11 | ||
10 | are available in the Git repository at: | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190816 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220509 |
13 | 15 | ||
14 | for you to fetch changes up to 664b7e3b97d6376f3329986c465b3782458b0f8b: | 16 | for you to fetch changes up to ae9141d4a3265553503bf07d3574b40f84615a34: |
15 | 17 | ||
16 | target/arm: Use tcg_gen_extrh_i64_i32 to extract the high word (2019-08-16 14:02:53 +0100) | 18 | hw/acpi/aml-build: Use existing CPU topology to build PPTT table (2022-05-09 11:47:55 +0100) |
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | target-arm queue: | 21 | target-arm queue: |
20 | * target/arm: generate a custom MIDR for -cpu max | 22 | * MAINTAINERS/.mailmap: update email for Leif Lindholm |
21 | * hw/misc/zynq_slcr: refactor to use standard register definition | 23 | * hw/arm: add version information to sbsa-ref machine DT |
22 | * Set ENET_BD_BDU in I.MX FEC controller | 24 | * Enable new features for -cpu max: |
23 | * target/arm: Fix routing of singlestep exceptions | 25 | FEAT_Debugv8p2, FEAT_Debugv8p4, FEAT_RAS (minimal version only), |
24 | * refactor a32/t32 decoder handling of PC | 26 | FEAT_IESB, FEAT_CSV2, FEAT_CSV2_2, FEAT_CSV3, FEAT_DGH |
25 | * minor optimisations/cleanups of some a32/t32 codegen | 27 | * Emulate Cortex-A76 |
26 | * target/arm/cpu64: Ensure kvm really supports aarch64=off | 28 | * Emulate Neoverse-N1 |
27 | * target/arm/cpu: Ensure we can use the pmu with kvm | 29 | * Fix the virt board default NUMA topology |
28 | * target/arm: Minor cleanups preparatory to KVM SVE support | ||
29 | 30 | ||
30 | ---------------------------------------------------------------- | 31 | ---------------------------------------------------------------- |
31 | Aaron Hill (1): | 32 | Gavin Shan (6): |
32 | Set ENET_BD_BDU in I.MX FEC controller | 33 | qapi/machine.json: Add cluster-id |
34 | qtest/numa-test: Specify CPU topology in aarch64_numa_cpu() | ||
35 | hw/arm/virt: Consider SMP configuration in CPU topology | ||
36 | qtest/numa-test: Correct CPU and NUMA association in aarch64_numa_cpu() | ||
37 | hw/arm/virt: Fix CPU's default NUMA node ID | ||
38 | hw/acpi/aml-build: Use existing CPU topology to build PPTT table | ||
33 | 39 | ||
34 | Alex Bennée (1): | 40 | Leif Lindholm (2): |
35 | target/arm: generate a custom MIDR for -cpu max | 41 | MAINTAINERS/.mailmap: update email for Leif Lindholm |
42 | hw/arm: add versioning to sbsa-ref machine DT | ||
36 | 43 | ||
37 | Andrew Jones (6): | 44 | Richard Henderson (24): |
38 | target/arm/cpu64: Ensure kvm really supports aarch64=off | 45 | target/arm: Handle cpreg registration for missing EL |
39 | target/arm/cpu: Ensure we can use the pmu with kvm | 46 | target/arm: Drop EL3 no EL2 fallbacks |
40 | target/arm/helper: zcr: Add build bug next to value range assumption | 47 | target/arm: Merge zcr reginfo |
41 | target/arm/cpu: Use div-round-up to determine predicate register array size | 48 | target/arm: Adjust definition of CONTEXTIDR_EL2 |
42 | target/arm/kvm64: Fix error returns | 49 | target/arm: Move cortex impdef sysregs to cpu_tcg.c |
43 | target/arm/kvm64: Move the get/put of fpsimd registers out | 50 | target/arm: Update qemu-system-arm -cpu max to cortex-a57 |
51 | target/arm: Set ID_DFR0.PerfMon for qemu-system-arm -cpu max | ||
52 | target/arm: Split out aa32_max_features | ||
53 | target/arm: Annotate arm_max_initfn with FEAT identifiers | ||
54 | target/arm: Use field names for manipulating EL2 and EL3 modes | ||
55 | target/arm: Enable FEAT_Debugv8p2 for -cpu max | ||
56 | target/arm: Enable FEAT_Debugv8p4 for -cpu max | ||
57 | target/arm: Add minimal RAS registers | ||
58 | target/arm: Enable SCR and HCR bits for RAS | ||
59 | target/arm: Implement virtual SError exceptions | ||
60 | target/arm: Implement ESB instruction | ||
61 | target/arm: Enable FEAT_RAS for -cpu max | ||
62 | target/arm: Enable FEAT_IESB for -cpu max | ||
63 | target/arm: Enable FEAT_CSV2 for -cpu max | ||
64 | target/arm: Enable FEAT_CSV2_2 for -cpu max | ||
65 | target/arm: Enable FEAT_CSV3 for -cpu max | ||
66 | target/arm: Enable FEAT_DGH for -cpu max | ||
67 | target/arm: Define cortex-a76 | ||
68 | target/arm: Define neoverse-n1 | ||
44 | 69 | ||
45 | Damien Hedde (1): | 70 | docs/system/arm/emulation.rst | 10 + |
46 | hw/misc/zynq_slcr: use standard register definition | 71 | docs/system/arm/virt.rst | 2 + |
47 | 72 | qapi/machine.json | 6 +- | |
48 | Peter Maydell (2): | 73 | target/arm/cpregs.h | 11 + |
49 | target/arm: Factor out 'generate singlestep exception' function | 74 | target/arm/cpu.h | 23 ++ |
50 | target/arm: Fix routing of singlestep exceptions | 75 | target/arm/helper.h | 1 + |
51 | 76 | target/arm/internals.h | 16 ++ | |
52 | Richard Henderson (18): | 77 | target/arm/syndrome.h | 5 + |
53 | target/arm: Pass in pc to thumb_insn_is_16bit | 78 | target/arm/a32.decode | 16 +- |
54 | target/arm: Introduce pc_curr | 79 | target/arm/t32.decode | 18 +- |
55 | target/arm: Introduce read_pc | 80 | hw/acpi/aml-build.c | 111 ++++---- |
56 | target/arm: Introduce add_reg_for_lit | 81 | hw/arm/sbsa-ref.c | 16 ++ |
57 | target/arm: Remove redundant s->pc & ~1 | 82 | hw/arm/virt.c | 21 +- |
58 | target/arm: Replace s->pc with s->base.pc_next | 83 | hw/core/machine-hmp-cmds.c | 4 + |
59 | target/arm: Replace offset with pc in gen_exception_insn | 84 | hw/core/machine.c | 16 ++ |
60 | target/arm: Replace offset with pc in gen_exception_internal_insn | 85 | target/arm/cpu.c | 66 ++++- |
61 | target/arm: Remove offset argument to gen_exception_bkpt_insn | 86 | target/arm/cpu64.c | 353 ++++++++++++++----------- |
62 | target/arm: Use unallocated_encoding for aarch32 | 87 | target/arm/cpu_tcg.c | 227 +++++++++++----- |
63 | target/arm: Remove helper_double_saturate | 88 | target/arm/helper.c | 600 +++++++++++++++++++++++++----------------- |
64 | target/arm: Use tcg_gen_extract_i32 for shifter_out_im | 89 | target/arm/op_helper.c | 43 +++ |
65 | target/arm: Use tcg_gen_deposit_i32 for PKHBT, PKHTB | 90 | target/arm/translate-a64.c | 18 ++ |
66 | target/arm: Remove redundant shift tests | 91 | target/arm/translate.c | 23 ++ |
67 | target/arm: Use ror32 instead of open-coding the operation | 92 | tests/qtest/numa-test.c | 19 +- |
68 | target/arm: Use tcg_gen_rotri_i32 for gen_swap_half | 93 | .mailmap | 3 +- |
69 | target/arm: Simplify SMMLA, SMMLAR, SMMLS, SMMLSR | 94 | MAINTAINERS | 2 +- |
70 | target/arm: Use tcg_gen_extrh_i64_i32 to extract the high word | 95 | 25 files changed, 1068 insertions(+), 562 deletions(-) |
71 | |||
72 | target/arm/cpu.h | 13 +- | ||
73 | target/arm/helper.h | 1 - | ||
74 | target/arm/kvm_arm.h | 28 ++ | ||
75 | target/arm/translate-a64.h | 4 +- | ||
76 | target/arm/translate.h | 39 ++- | ||
77 | hw/misc/zynq_slcr.c | 450 ++++++++++++++++---------------- | ||
78 | hw/net/imx_fec.c | 4 + | ||
79 | target/arm/cpu.c | 30 ++- | ||
80 | target/arm/cpu64.c | 31 ++- | ||
81 | target/arm/helper.c | 7 + | ||
82 | target/arm/kvm.c | 7 + | ||
83 | target/arm/kvm64.c | 161 +++++++----- | ||
84 | target/arm/op_helper.c | 15 -- | ||
85 | target/arm/translate-a64.c | 130 ++++------ | ||
86 | target/arm/translate-vfp.inc.c | 45 +--- | ||
87 | target/arm/translate.c | 572 +++++++++++++++++------------------------ | ||
88 | 16 files changed, 771 insertions(+), 766 deletions(-) | ||
89 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | All of the inputs to these instructions are 32-bits. Rather than | 3 | NUVIA was acquired by Qualcomm in March 2021, but kept functioning on |
4 | extend each input to 64-bits and then extract the high 32-bits of | 4 | separate infrastructure for a transitional period. We've now switched |
5 | the output, use tcg_gen_muls2_i32 and other 32-bit generator functions. | 5 | over to contributing as Qualcomm Innovation Center (quicinc), so update |
6 | my email address to reflect this. | ||
6 | 7 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> |
8 | Message-id: 20190808202616.13782-7-richard.henderson@linaro.org | 9 | Message-id: 20220505113740.75565-1-quic_llindhol@quicinc.com |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Cc: Leif Lindholm <leif@nuviainc.com> |
11 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | [Fixed commit message typo] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 15 | --- |
12 | target/arm/translate.c | 72 +++++++++++++++--------------------------- | 16 | .mailmap | 3 ++- |
13 | 1 file changed, 26 insertions(+), 46 deletions(-) | 17 | MAINTAINERS | 2 +- |
18 | 2 files changed, 3 insertions(+), 2 deletions(-) | ||
14 | 19 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 20 | diff --git a/.mailmap b/.mailmap |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 22 | --- a/.mailmap |
18 | +++ b/target/arm/translate.c | 23 | +++ b/.mailmap |
19 | @@ -XXX,XX +XXX,XX @@ static void gen_revsh(TCGv_i32 var) | 24 | @@ -XXX,XX +XXX,XX @@ Greg Kurz <groug@kaod.org> <gkurz@linux.vnet.ibm.com> |
20 | tcg_gen_ext16s_i32(var, var); | 25 | Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com> |
21 | } | 26 | Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn> |
22 | 27 | James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com> | |
23 | -/* Return (b << 32) + a. Mark inputs as dead */ | 28 | -Leif Lindholm <leif@nuviainc.com> <leif.lindholm@linaro.org> |
24 | -static TCGv_i64 gen_addq_msw(TCGv_i64 a, TCGv_i32 b) | 29 | +Leif Lindholm <quic_llindhol@quicinc.com> <leif.lindholm@linaro.org> |
25 | -{ | 30 | +Leif Lindholm <quic_llindhol@quicinc.com> <leif@nuviainc.com> |
26 | - TCGv_i64 tmp64 = tcg_temp_new_i64(); | 31 | Radoslaw Biernacki <rad@semihalf.com> <radoslaw.biernacki@linaro.org> |
27 | - | 32 | Paul Burton <paulburton@kernel.org> <paul.burton@mips.com> |
28 | - tcg_gen_extu_i32_i64(tmp64, b); | 33 | Paul Burton <paulburton@kernel.org> <paul.burton@imgtec.com> |
29 | - tcg_temp_free_i32(b); | 34 | diff --git a/MAINTAINERS b/MAINTAINERS |
30 | - tcg_gen_shli_i64(tmp64, tmp64, 32); | 35 | index XXXXXXX..XXXXXXX 100644 |
31 | - tcg_gen_add_i64(a, tmp64, a); | 36 | --- a/MAINTAINERS |
32 | - | 37 | +++ b/MAINTAINERS |
33 | - tcg_temp_free_i64(tmp64); | 38 | @@ -XXX,XX +XXX,XX @@ F: include/hw/ssi/imx_spi.h |
34 | - return a; | 39 | SBSA-REF |
35 | -} | 40 | M: Radoslaw Biernacki <rad@semihalf.com> |
36 | - | 41 | M: Peter Maydell <peter.maydell@linaro.org> |
37 | -/* Return (b << 32) - a. Mark inputs as dead. */ | 42 | -R: Leif Lindholm <leif@nuviainc.com> |
38 | -static TCGv_i64 gen_subq_msw(TCGv_i64 a, TCGv_i32 b) | 43 | +R: Leif Lindholm <quic_llindhol@quicinc.com> |
39 | -{ | 44 | L: qemu-arm@nongnu.org |
40 | - TCGv_i64 tmp64 = tcg_temp_new_i64(); | 45 | S: Maintained |
41 | - | 46 | F: hw/arm/sbsa-ref.c |
42 | - tcg_gen_extu_i32_i64(tmp64, b); | ||
43 | - tcg_temp_free_i32(b); | ||
44 | - tcg_gen_shli_i64(tmp64, tmp64, 32); | ||
45 | - tcg_gen_sub_i64(a, tmp64, a); | ||
46 | - | ||
47 | - tcg_temp_free_i64(tmp64); | ||
48 | - return a; | ||
49 | -} | ||
50 | - | ||
51 | /* 32x32->64 multiply. Marks inputs as dead. */ | ||
52 | static TCGv_i64 gen_mulu_i64_i32(TCGv_i32 a, TCGv_i32 b) | ||
53 | { | ||
54 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
55 | (SMMUL, SMMLA, SMMLS) */ | ||
56 | tmp = load_reg(s, rm); | ||
57 | tmp2 = load_reg(s, rs); | ||
58 | - tmp64 = gen_muls_i64_i32(tmp, tmp2); | ||
59 | + tcg_gen_muls2_i32(tmp2, tmp, tmp, tmp2); | ||
60 | |||
61 | if (rd != 15) { | ||
62 | - tmp = load_reg(s, rd); | ||
63 | + tmp3 = load_reg(s, rd); | ||
64 | if (insn & (1 << 6)) { | ||
65 | - tmp64 = gen_subq_msw(tmp64, tmp); | ||
66 | + tcg_gen_sub_i32(tmp, tmp, tmp3); | ||
67 | } else { | ||
68 | - tmp64 = gen_addq_msw(tmp64, tmp); | ||
69 | + tcg_gen_add_i32(tmp, tmp, tmp3); | ||
70 | } | ||
71 | + tcg_temp_free_i32(tmp3); | ||
72 | } | ||
73 | if (insn & (1 << 5)) { | ||
74 | - tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); | ||
75 | + /* | ||
76 | + * Adding 0x80000000 to the 64-bit quantity | ||
77 | + * means that we have carry in to the high | ||
78 | + * word when the low word has the high bit set. | ||
79 | + */ | ||
80 | + tcg_gen_shri_i32(tmp2, tmp2, 31); | ||
81 | + tcg_gen_add_i32(tmp, tmp, tmp2); | ||
82 | } | ||
83 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | ||
84 | - tmp = tcg_temp_new_i32(); | ||
85 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
86 | - tcg_temp_free_i64(tmp64); | ||
87 | + tcg_temp_free_i32(tmp2); | ||
88 | store_reg(s, rn, tmp); | ||
89 | break; | ||
90 | case 0: | ||
91 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
92 | } | ||
93 | break; | ||
94 | case 5: case 6: /* 32 * 32 -> 32msb (SMMUL, SMMLA, SMMLS) */ | ||
95 | - tmp64 = gen_muls_i64_i32(tmp, tmp2); | ||
96 | + tcg_gen_muls2_i32(tmp2, tmp, tmp, tmp2); | ||
97 | if (rs != 15) { | ||
98 | - tmp = load_reg(s, rs); | ||
99 | + tmp3 = load_reg(s, rs); | ||
100 | if (insn & (1 << 20)) { | ||
101 | - tmp64 = gen_addq_msw(tmp64, tmp); | ||
102 | + tcg_gen_add_i32(tmp, tmp, tmp3); | ||
103 | } else { | ||
104 | - tmp64 = gen_subq_msw(tmp64, tmp); | ||
105 | + tcg_gen_sub_i32(tmp, tmp, tmp3); | ||
106 | } | ||
107 | + tcg_temp_free_i32(tmp3); | ||
108 | } | ||
109 | if (insn & (1 << 4)) { | ||
110 | - tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); | ||
111 | + /* | ||
112 | + * Adding 0x80000000 to the 64-bit quantity | ||
113 | + * means that we have carry in to the high | ||
114 | + * word when the low word has the high bit set. | ||
115 | + */ | ||
116 | + tcg_gen_shri_i32(tmp2, tmp2, 31); | ||
117 | + tcg_gen_add_i32(tmp, tmp, tmp2); | ||
118 | } | ||
119 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | ||
120 | - tmp = tcg_temp_new_i32(); | ||
121 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | ||
122 | - tcg_temp_free_i64(tmp64); | ||
123 | + tcg_temp_free_i32(tmp2); | ||
124 | break; | ||
125 | case 7: /* Unsigned sum of absolute differences. */ | ||
126 | gen_helper_usad8(tmp, tmp, tmp2); | ||
127 | -- | 47 | -- |
128 | 2.20.1 | 48 | 2.25.1 |
129 | 49 | ||
130 | 50 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We must update s->base.pc_next when we return from the translate_insn | 3 | More gracefully handle cpregs when EL2 and/or EL3 are missing. |
4 | hook to the main translator loop. By incrementing s->base.pc_next | 4 | If the reg is entirely inaccessible, do not register it at all. |
5 | immediately after reading the insn word, "pc_next" contains the address | 5 | If the reg is for EL2, and EL3 is present but EL2 is not, |
6 | of the next instruction throughout translation. | 6 | either discard, squash to res0, const, or keep unchanged. |
7 | 7 | ||
8 | All remaining uses of s->pc are referencing the address of the next insn, | 8 | Per rule RJFFP, mark the 4 aarch32 hypervisor access registers |
9 | so this is now a simple global replacement. Remove the "s->pc" field. | 9 | with ARM_CP_EL3_NO_EL2_KEEP, and mark all of the EL2 address |
10 | 10 | translation and tlb invalidation "regs" ARM_CP_EL3_NO_EL2_UNDEF. | |
11 | Mark the 2 virtualization processor id regs ARM_CP_EL3_NO_EL2_C_NZ. | ||
12 | |||
13 | This will simplify cpreg registration for conditional arm features. | ||
14 | |||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Message-id: 20220506180242.216785-2-richard.henderson@linaro.org |
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Message-id: 20190807045335.1361-7-richard.henderson@linaro.org | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 19 | --- |
17 | target/arm/translate.h | 1 - | 20 | target/arm/cpregs.h | 11 +++ |
18 | target/arm/translate-a64.c | 51 +++++++++--------- | 21 | target/arm/helper.c | 178 ++++++++++++++++++++++++++++++-------------- |
19 | target/arm/translate.c | 103 ++++++++++++++++++------------------- | 22 | 2 files changed, 133 insertions(+), 56 deletions(-) |
20 | 3 files changed, 72 insertions(+), 83 deletions(-) | 23 | |
21 | 24 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | |
22 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate.h | 26 | --- a/target/arm/cpregs.h |
25 | +++ b/target/arm/translate.h | 27 | +++ b/target/arm/cpregs.h |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 28 | @@ -XXX,XX +XXX,XX @@ enum { |
27 | DisasContextBase base; | 29 | ARM_CP_SVE = 1 << 14, |
28 | const ARMISARegisters *isar; | 30 | /* Flag: Do not expose in gdb sysreg xml. */ |
29 | 31 | ARM_CP_NO_GDB = 1 << 15, | |
30 | - target_ulong pc; | 32 | + /* |
31 | /* The address of the current instruction being translated. */ | 33 | + * Flags: If EL3 but not EL2... |
32 | target_ulong pc_curr; | 34 | + * - UNDEF: discard the cpreg, |
33 | target_ulong page_start; | 35 | + * - KEEP: retain the cpreg as is, |
34 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 36 | + * - C_NZ: set const on the cpreg, but retain resetvalue, |
37 | + * - else: set const on the cpreg, zero resetvalue, aka RES0. | ||
38 | + * See rule RJFFP in section D1.1.3 of DDI0487H.a. | ||
39 | + */ | ||
40 | + ARM_CP_EL3_NO_EL2_UNDEF = 1 << 16, | ||
41 | + ARM_CP_EL3_NO_EL2_KEEP = 1 << 17, | ||
42 | + ARM_CP_EL3_NO_EL2_C_NZ = 1 << 18, | ||
43 | }; | ||
44 | |||
45 | /* | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/translate-a64.c | 48 | --- a/target/arm/helper.c |
37 | +++ b/target/arm/translate-a64.c | 49 | +++ b/target/arm/helper.c |
38 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | 50 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
39 | 51 | .access = PL1_RW, .readfn = spsel_read, .writefn = spsel_write }, | |
40 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 52 | { .name = "FPEXC32_EL2", .state = ARM_CP_STATE_AA64, |
53 | .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 3, .opc2 = 0, | ||
54 | - .access = PL2_RW, .type = ARM_CP_ALIAS | ARM_CP_FPU, | ||
55 | + .access = PL2_RW, | ||
56 | + .type = ARM_CP_ALIAS | ARM_CP_FPU | ARM_CP_EL3_NO_EL2_KEEP, | ||
57 | .fieldoffset = offsetof(CPUARMState, vfp.xregs[ARM_VFP_FPEXC]) }, | ||
58 | { .name = "DACR32_EL2", .state = ARM_CP_STATE_AA64, | ||
59 | .opc0 = 3, .opc1 = 4, .crn = 3, .crm = 0, .opc2 = 0, | ||
60 | - .access = PL2_RW, .resetvalue = 0, | ||
61 | + .access = PL2_RW, .resetvalue = 0, .type = ARM_CP_EL3_NO_EL2_KEEP, | ||
62 | .writefn = dacr_write, .raw_writefn = raw_write, | ||
63 | .fieldoffset = offsetof(CPUARMState, cp15.dacr32_el2) }, | ||
64 | { .name = "IFSR32_EL2", .state = ARM_CP_STATE_AA64, | ||
65 | .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 0, .opc2 = 1, | ||
66 | - .access = PL2_RW, .resetvalue = 0, | ||
67 | + .access = PL2_RW, .resetvalue = 0, .type = ARM_CP_EL3_NO_EL2_KEEP, | ||
68 | .fieldoffset = offsetof(CPUARMState, cp15.ifsr32_el2) }, | ||
69 | { .name = "SPSR_IRQ", .state = ARM_CP_STATE_AA64, | ||
70 | .type = ARM_CP_ALIAS, | ||
71 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
72 | .writefn = tlbimva_hyp_is_write }, | ||
73 | { .name = "TLBI_ALLE2", .state = ARM_CP_STATE_AA64, | ||
74 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 0, | ||
75 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
76 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
77 | .writefn = tlbi_aa64_alle2_write }, | ||
78 | { .name = "TLBI_VAE2", .state = ARM_CP_STATE_AA64, | ||
79 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 1, | ||
80 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
81 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
82 | .writefn = tlbi_aa64_vae2_write }, | ||
83 | { .name = "TLBI_VALE2", .state = ARM_CP_STATE_AA64, | ||
84 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 5, | ||
85 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
86 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
87 | .writefn = tlbi_aa64_vae2_write }, | ||
88 | { .name = "TLBI_ALLE2IS", .state = ARM_CP_STATE_AA64, | ||
89 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 0, | ||
90 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
91 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
92 | .writefn = tlbi_aa64_alle2is_write }, | ||
93 | { .name = "TLBI_VAE2IS", .state = ARM_CP_STATE_AA64, | ||
94 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 1, | ||
95 | - .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
96 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
97 | .writefn = tlbi_aa64_vae2is_write }, | ||
98 | { .name = "TLBI_VALE2IS", .state = ARM_CP_STATE_AA64, | ||
99 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 5, | ||
100 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
101 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
102 | .writefn = tlbi_aa64_vae2is_write }, | ||
103 | #ifndef CONFIG_USER_ONLY | ||
104 | /* Unlike the other EL2-related AT operations, these must | ||
105 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
106 | { .name = "AT_S1E2R", .state = ARM_CP_STATE_AA64, | ||
107 | .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 0, | ||
108 | .access = PL2_W, .accessfn = at_s1e2_access, | ||
109 | - .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, .writefn = ats_write64 }, | ||
110 | + .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF, | ||
111 | + .writefn = ats_write64 }, | ||
112 | { .name = "AT_S1E2W", .state = ARM_CP_STATE_AA64, | ||
113 | .opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 1, | ||
114 | .access = PL2_W, .accessfn = at_s1e2_access, | ||
115 | - .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, .writefn = ats_write64 }, | ||
116 | + .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF, | ||
117 | + .writefn = ats_write64 }, | ||
118 | /* The AArch32 ATS1H* operations are CONSTRAINED UNPREDICTABLE | ||
119 | * if EL2 is not implemented; we choose to UNDEF. Behaviour at EL3 | ||
120 | * with SCR.NS == 0 outside Monitor mode is UNPREDICTABLE; we choose | ||
121 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
122 | { .name = "DBGVCR32_EL2", .state = ARM_CP_STATE_AA64, | ||
123 | .opc0 = 2, .opc1 = 4, .crn = 0, .crm = 7, .opc2 = 0, | ||
124 | .access = PL2_RW, .accessfn = access_tda, | ||
125 | - .type = ARM_CP_NOP }, | ||
126 | + .type = ARM_CP_NOP | ARM_CP_EL3_NO_EL2_KEEP }, | ||
127 | /* Dummy MDCCINT_EL1, since we don't implement the Debug Communications | ||
128 | * Channel but Linux may try to access this register. The 32-bit | ||
129 | * alias is DBGDCCINT. | ||
130 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
131 | .access = PL2_W, .type = ARM_CP_NOP }, | ||
132 | { .name = "TLBI_RVAE2IS", .state = ARM_CP_STATE_AA64, | ||
133 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 2, .opc2 = 1, | ||
134 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
135 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
136 | .writefn = tlbi_aa64_rvae2is_write }, | ||
137 | { .name = "TLBI_RVALE2IS", .state = ARM_CP_STATE_AA64, | ||
138 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 2, .opc2 = 5, | ||
139 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
140 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
141 | .writefn = tlbi_aa64_rvae2is_write }, | ||
142 | { .name = "TLBI_RIPAS2E1", .state = ARM_CP_STATE_AA64, | ||
143 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 2, | ||
144 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
145 | .access = PL2_W, .type = ARM_CP_NOP }, | ||
146 | { .name = "TLBI_RVAE2OS", .state = ARM_CP_STATE_AA64, | ||
147 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 5, .opc2 = 1, | ||
148 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
149 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
150 | .writefn = tlbi_aa64_rvae2is_write }, | ||
151 | { .name = "TLBI_RVALE2OS", .state = ARM_CP_STATE_AA64, | ||
152 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 5, .opc2 = 5, | ||
153 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
154 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
155 | .writefn = tlbi_aa64_rvae2is_write }, | ||
156 | { .name = "TLBI_RVAE2", .state = ARM_CP_STATE_AA64, | ||
157 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 6, .opc2 = 1, | ||
158 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
159 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
160 | .writefn = tlbi_aa64_rvae2_write }, | ||
161 | { .name = "TLBI_RVALE2", .state = ARM_CP_STATE_AA64, | ||
162 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 6, .opc2 = 5, | ||
163 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
164 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
165 | .writefn = tlbi_aa64_rvae2_write }, | ||
166 | { .name = "TLBI_RVAE3IS", .state = ARM_CP_STATE_AA64, | ||
167 | .opc0 = 1, .opc1 = 6, .crn = 8, .crm = 2, .opc2 = 1, | ||
168 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { | ||
169 | .writefn = tlbi_aa64_vae1is_write }, | ||
170 | { .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64, | ||
171 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0, | ||
172 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
173 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
174 | .writefn = tlbi_aa64_alle2is_write }, | ||
175 | { .name = "TLBI_VAE2OS", .state = ARM_CP_STATE_AA64, | ||
176 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 1, | ||
177 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
178 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
179 | .writefn = tlbi_aa64_vae2is_write }, | ||
180 | { .name = "TLBI_ALLE1OS", .state = ARM_CP_STATE_AA64, | ||
181 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 4, | ||
182 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = { | ||
183 | .writefn = tlbi_aa64_alle1is_write }, | ||
184 | { .name = "TLBI_VALE2OS", .state = ARM_CP_STATE_AA64, | ||
185 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 5, | ||
186 | - .access = PL2_W, .type = ARM_CP_NO_RAW, | ||
187 | + .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF, | ||
188 | .writefn = tlbi_aa64_vae2is_write }, | ||
189 | { .name = "TLBI_VMALLS12E1OS", .state = ARM_CP_STATE_AA64, | ||
190 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 6, | ||
191 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
192 | { .name = "VPIDR", .state = ARM_CP_STATE_AA32, | ||
193 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
194 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
195 | - .resetvalue = cpu->midr, .type = ARM_CP_ALIAS, | ||
196 | + .resetvalue = cpu->midr, | ||
197 | + .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, | ||
198 | .fieldoffset = offsetoflow32(CPUARMState, cp15.vpidr_el2) }, | ||
199 | { .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64, | ||
200 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
201 | .access = PL2_RW, .resetvalue = cpu->midr, | ||
202 | + .type = ARM_CP_EL3_NO_EL2_C_NZ, | ||
203 | .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, | ||
204 | { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, | ||
205 | .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
206 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
207 | - .resetvalue = vmpidr_def, .type = ARM_CP_ALIAS, | ||
208 | + .resetvalue = vmpidr_def, | ||
209 | + .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, | ||
210 | .fieldoffset = offsetoflow32(CPUARMState, cp15.vmpidr_el2) }, | ||
211 | { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64, | ||
212 | .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
213 | - .access = PL2_RW, | ||
214 | - .resetvalue = vmpidr_def, | ||
215 | + .access = PL2_RW, .resetvalue = vmpidr_def, | ||
216 | + .type = ARM_CP_EL3_NO_EL2_C_NZ, | ||
217 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
218 | }; | ||
219 | define_arm_cp_regs(cpu, vpidr_regs); | ||
220 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, | ||
221 | int crm, int opc1, int opc2, | ||
222 | const char *name) | ||
41 | { | 223 | { |
42 | - gen_a64_set_pc_im(s->pc - offset); | 224 | + CPUARMState *env = &cpu->env; |
43 | + gen_a64_set_pc_im(s->base.pc_next - offset); | 225 | uint32_t key; |
44 | gen_exception_internal(excp); | 226 | ARMCPRegInfo *r2; |
45 | s->base.is_jmp = DISAS_NORETURN; | 227 | bool is64 = r->type & ARM_CP_64BIT; |
46 | } | 228 | bool ns = secstate & ARM_CP_SECSTATE_NS; |
47 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 229 | int cp = r->cp; |
48 | static void gen_exception_insn(DisasContext *s, int offset, int excp, | 230 | - bool isbanked; |
49 | uint32_t syndrome, uint32_t target_el) | 231 | size_t name_len; |
50 | { | 232 | + bool make_const; |
51 | - gen_a64_set_pc_im(s->pc - offset); | 233 | |
52 | + gen_a64_set_pc_im(s->base.pc_next - offset); | 234 | switch (state) { |
53 | gen_exception(excp, syndrome, target_el); | 235 | case ARM_CP_STATE_AA32: |
54 | s->base.is_jmp = DISAS_NORETURN; | 236 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
55 | } | ||
56 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, | ||
57 | { | ||
58 | TCGv_i32 tcg_syn; | ||
59 | |||
60 | - gen_a64_set_pc_im(s->pc - offset); | ||
61 | + gen_a64_set_pc_im(s->base.pc_next - offset); | ||
62 | tcg_syn = tcg_const_i32(syndrome); | ||
63 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
64 | tcg_temp_free_i32(tcg_syn); | ||
65 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) | ||
66 | |||
67 | if (insn & (1U << 31)) { | ||
68 | /* BL Branch with link */ | ||
69 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
70 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | ||
71 | } | ||
72 | |||
73 | /* B Branch / BL Branch with link */ | ||
74 | @@ -XXX,XX +XXX,XX @@ static void disas_comp_b_imm(DisasContext *s, uint32_t insn) | ||
75 | tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | ||
76 | tcg_cmp, 0, label_match); | ||
77 | |||
78 | - gen_goto_tb(s, 0, s->pc); | ||
79 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
80 | gen_set_label(label_match); | ||
81 | gen_goto_tb(s, 1, addr); | ||
82 | } | ||
83 | @@ -XXX,XX +XXX,XX @@ static void disas_test_b_imm(DisasContext *s, uint32_t insn) | ||
84 | tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | ||
85 | tcg_cmp, 0, label_match); | ||
86 | tcg_temp_free_i64(tcg_cmp); | ||
87 | - gen_goto_tb(s, 0, s->pc); | ||
88 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
89 | gen_set_label(label_match); | ||
90 | gen_goto_tb(s, 1, addr); | ||
91 | } | ||
92 | @@ -XXX,XX +XXX,XX @@ static void disas_cond_b_imm(DisasContext *s, uint32_t insn) | ||
93 | /* genuinely conditional branches */ | ||
94 | TCGLabel *label_match = gen_new_label(); | ||
95 | arm_gen_test_cc(cond, label_match); | ||
96 | - gen_goto_tb(s, 0, s->pc); | ||
97 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
98 | gen_set_label(label_match); | ||
99 | gen_goto_tb(s, 1, addr); | ||
100 | } else { | ||
101 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | ||
102 | * any pending interrupts immediately. | ||
103 | */ | ||
104 | reset_btype(s); | ||
105 | - gen_goto_tb(s, 0, s->pc); | ||
106 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
107 | return; | ||
108 | |||
109 | case 7: /* SB */ | ||
110 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | ||
111 | * MB and end the TB instead. | ||
112 | */ | ||
113 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
114 | - gen_goto_tb(s, 0, s->pc); | ||
115 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
116 | return; | ||
117 | |||
118 | default: | ||
119 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
120 | gen_a64_set_pc(s, dst); | ||
121 | /* BLR also needs to load return address */ | ||
122 | if (opc == 1) { | ||
123 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
124 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | ||
125 | } | ||
126 | break; | ||
127 | |||
128 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
129 | gen_a64_set_pc(s, dst); | ||
130 | /* BLRAA also needs to load return address */ | ||
131 | if (opc == 9) { | ||
132 | - tcg_gen_movi_i64(cpu_reg(s, 30), s->pc); | ||
133 | + tcg_gen_movi_i64(cpu_reg(s, 30), s->base.pc_next); | ||
134 | } | ||
135 | break; | ||
136 | |||
137 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
138 | { | ||
139 | uint32_t insn; | ||
140 | |||
141 | - s->pc_curr = s->pc; | ||
142 | - insn = arm_ldl_code(env, s->pc, s->sctlr_b); | ||
143 | + s->pc_curr = s->base.pc_next; | ||
144 | + insn = arm_ldl_code(env, s->base.pc_next, s->sctlr_b); | ||
145 | s->insn = insn; | ||
146 | - s->pc += 4; | ||
147 | + s->base.pc_next += 4; | ||
148 | |||
149 | s->fp_access_checked = false; | ||
150 | |||
151 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
152 | int bound, core_mmu_idx; | ||
153 | |||
154 | dc->isar = &arm_cpu->isar; | ||
155 | - dc->pc = dc->base.pc_first; | ||
156 | dc->condjmp = 0; | ||
157 | |||
158 | dc->aarch64 = 1; | ||
159 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | ||
160 | { | ||
161 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
162 | |||
163 | - tcg_gen_insn_start(dc->pc, 0, 0); | ||
164 | + tcg_gen_insn_start(dc->base.pc_next, 0, 0); | ||
165 | dc->insn_start = tcg_last_op(); | ||
166 | } | ||
167 | |||
168 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
169 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
170 | |||
171 | if (bp->flags & BP_CPU) { | ||
172 | - gen_a64_set_pc_im(dc->pc); | ||
173 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
174 | gen_helper_check_breakpoints(cpu_env); | ||
175 | /* End the TB early; it likely won't be executed */ | ||
176 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
177 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
178 | to for it to be properly cleared -- thus we | ||
179 | increment the PC here so that the logic setting | ||
180 | tb->size below does the right thing. */ | ||
181 | - dc->pc += 4; | ||
182 | + dc->base.pc_next += 4; | ||
183 | dc->base.is_jmp = DISAS_NORETURN; | ||
184 | } | ||
185 | |||
186 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
187 | disas_a64_insn(env, dc); | ||
188 | } | ||
189 | |||
190 | - dc->base.pc_next = dc->pc; | ||
191 | translator_loop_temp_check(&dc->base); | ||
192 | } | ||
193 | |||
194 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
195 | */ | ||
196 | switch (dc->base.is_jmp) { | ||
197 | default: | ||
198 | - gen_a64_set_pc_im(dc->pc); | ||
199 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
200 | /* fall through */ | ||
201 | case DISAS_EXIT: | ||
202 | case DISAS_JUMP: | ||
203 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
204 | switch (dc->base.is_jmp) { | ||
205 | case DISAS_NEXT: | ||
206 | case DISAS_TOO_MANY: | ||
207 | - gen_goto_tb(dc, 1, dc->pc); | ||
208 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
209 | break; | ||
210 | default: | ||
211 | case DISAS_UPDATE: | ||
212 | - gen_a64_set_pc_im(dc->pc); | ||
213 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
214 | /* fall through */ | ||
215 | case DISAS_EXIT: | ||
216 | tcg_gen_exit_tb(NULL, 0); | ||
217 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
218 | case DISAS_SWI: | ||
219 | break; | ||
220 | case DISAS_WFE: | ||
221 | - gen_a64_set_pc_im(dc->pc); | ||
222 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
223 | gen_helper_wfe(cpu_env); | ||
224 | break; | ||
225 | case DISAS_YIELD: | ||
226 | - gen_a64_set_pc_im(dc->pc); | ||
227 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
228 | gen_helper_yield(cpu_env); | ||
229 | break; | ||
230 | case DISAS_WFI: | ||
231 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
232 | */ | ||
233 | TCGv_i32 tmp = tcg_const_i32(4); | ||
234 | |||
235 | - gen_a64_set_pc_im(dc->pc); | ||
236 | + gen_a64_set_pc_im(dc->base.pc_next); | ||
237 | gen_helper_wfi(cpu_env, tmp); | ||
238 | tcg_temp_free_i32(tmp); | ||
239 | /* The helper doesn't necessarily throw an exception, but we | ||
240 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
241 | } | ||
242 | } | 237 | } |
243 | } | 238 | } |
244 | - | 239 | |
245 | - /* Functions above can change dc->pc, so re-align db->pc_next */ | 240 | + /* |
246 | - dc->base.pc_next = dc->pc; | 241 | + * Eliminate registers that are not present because the EL is missing. |
247 | } | 242 | + * Doing this here makes it easier to put all registers for a given |
248 | 243 | + * feature into the same ARMCPRegInfo array and define them all at once. | |
249 | static void aarch64_tr_disas_log(const DisasContextBase *dcbase, | 244 | + */ |
250 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 245 | + make_const = false; |
251 | index XXXXXXX..XXXXXXX 100644 | 246 | + if (arm_feature(env, ARM_FEATURE_EL3)) { |
252 | --- a/target/arm/translate.c | 247 | + /* |
253 | +++ b/target/arm/translate.c | 248 | + * An EL2 register without EL2 but with EL3 is (usually) RES0. |
254 | @@ -XXX,XX +XXX,XX @@ static inline void gen_blxns(DisasContext *s, int rm) | 249 | + * See rule RJFFP in section D1.1.3 of DDI0487H.a. |
255 | * We do however need to set the PC, because the blxns helper reads it. | 250 | + */ |
256 | * The blxns helper may throw an exception. | 251 | + int min_el = ctz32(r->access) / 2; |
257 | */ | 252 | + if (min_el == 2 && !arm_feature(env, ARM_FEATURE_EL2)) { |
258 | - gen_set_pc_im(s, s->pc); | 253 | + if (r->type & ARM_CP_EL3_NO_EL2_UNDEF) { |
259 | + gen_set_pc_im(s, s->base.pc_next); | 254 | + return; |
260 | gen_helper_v7m_blxns(cpu_env, var); | 255 | + } |
261 | tcg_temp_free_i32(var); | 256 | + make_const = !(r->type & ARM_CP_EL3_NO_EL2_KEEP); |
262 | s->base.is_jmp = DISAS_EXIT; | 257 | + } |
263 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hvc(DisasContext *s, int imm16) | 258 | + } else { |
264 | * for single stepping.) | 259 | + CPAccessRights max_el = (arm_feature(env, ARM_FEATURE_EL2) |
265 | */ | 260 | + ? PL2_RW : PL1_RW); |
266 | s->svc_imm = imm16; | 261 | + if ((r->access & max_el) == 0) { |
267 | - gen_set_pc_im(s, s->pc); | 262 | + return; |
268 | + gen_set_pc_im(s, s->base.pc_next); | 263 | + } |
269 | s->base.is_jmp = DISAS_HVC; | 264 | + } |
270 | } | 265 | + |
271 | 266 | /* Combine cpreg and name into one allocation. */ | |
272 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | 267 | name_len = strlen(name) + 1; |
273 | tmp = tcg_const_i32(syn_aa32_smc()); | 268 | r2 = g_malloc(sizeof(*r2) + name_len); |
274 | gen_helper_pre_smc(cpu_env, tmp); | 269 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
275 | tcg_temp_free_i32(tmp); | 270 | r2->opaque = opaque; |
276 | - gen_set_pc_im(s, s->pc); | 271 | } |
277 | + gen_set_pc_im(s, s->base.pc_next); | 272 | |
278 | s->base.is_jmp = DISAS_SMC; | 273 | - isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; |
279 | } | 274 | - if (isbanked) { |
280 | 275 | + if (make_const) { | |
281 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 276 | + /* This should not have been a very special register to begin. */ |
282 | { | 277 | + int old_special = r2->type & ARM_CP_SPECIAL_MASK; |
283 | gen_set_condexec(s); | 278 | + assert(old_special == 0 || old_special == ARM_CP_NOP); |
284 | - gen_set_pc_im(s, s->pc - offset); | 279 | /* |
285 | + gen_set_pc_im(s, s->base.pc_next - offset); | 280 | - * Register is banked (using both entries in array). |
286 | gen_exception_internal(excp); | 281 | - * Overwriting fieldoffset as the array is only used to define |
287 | s->base.is_jmp = DISAS_NORETURN; | 282 | - * banked registers but later only fieldoffset is used. |
288 | } | 283 | + * Set the special function to CONST, retaining the other flags. |
289 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, int offset, int excp, | 284 | + * This is important for e.g. ARM_CP_SVE so that we still |
290 | int syn, uint32_t target_el) | 285 | + * take the SVE trap if CPTR_EL3.EZ == 0. |
291 | { | ||
292 | gen_set_condexec(s); | ||
293 | - gen_set_pc_im(s, s->pc - offset); | ||
294 | + gen_set_pc_im(s, s->base.pc_next - offset); | ||
295 | gen_exception(excp, syn, target_el); | ||
296 | s->base.is_jmp = DISAS_NORETURN; | ||
297 | } | ||
298 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | ||
299 | TCGv_i32 tcg_syn; | ||
300 | |||
301 | gen_set_condexec(s); | ||
302 | - gen_set_pc_im(s, s->pc - offset); | ||
303 | + gen_set_pc_im(s, s->base.pc_next - offset); | ||
304 | tcg_syn = tcg_const_i32(syn); | ||
305 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
306 | tcg_temp_free_i32(tcg_syn); | ||
307 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | ||
308 | /* Force a TB lookup after an instruction that changes the CPU state. */ | ||
309 | static inline void gen_lookup_tb(DisasContext *s) | ||
310 | { | ||
311 | - tcg_gen_movi_i32(cpu_R[15], s->pc); | ||
312 | + tcg_gen_movi_i32(cpu_R[15], s->base.pc_next); | ||
313 | s->base.is_jmp = DISAS_EXIT; | ||
314 | } | ||
315 | |||
316 | @@ -XXX,XX +XXX,XX @@ static inline bool use_goto_tb(DisasContext *s, target_ulong dest) | ||
317 | { | ||
318 | #ifndef CONFIG_USER_ONLY | ||
319 | return (s->base.tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) || | ||
320 | - ((s->pc - 1) & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK); | ||
321 | + ((s->base.pc_next - 1) & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK); | ||
322 | #else | ||
323 | return true; | ||
324 | #endif | ||
325 | @@ -XXX,XX +XXX,XX @@ static void gen_nop_hint(DisasContext *s, int val) | ||
326 | */ | 286 | */ |
327 | case 1: /* yield */ | 287 | - r2->fieldoffset = r->bank_fieldoffsets[ns]; |
328 | if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | 288 | - } |
329 | - gen_set_pc_im(s, s->pc); | 289 | + r2->type = (r2->type & ~ARM_CP_SPECIAL_MASK) | ARM_CP_CONST; |
330 | + gen_set_pc_im(s, s->base.pc_next); | 290 | + /* |
331 | s->base.is_jmp = DISAS_YIELD; | 291 | + * Usually, these registers become RES0, but there are a few |
332 | } | 292 | + * special cases like VPIDR_EL2 which have a constant non-zero |
333 | break; | 293 | + * value with writes ignored. |
334 | case 3: /* wfi */ | 294 | + */ |
335 | - gen_set_pc_im(s, s->pc); | 295 | + if (!(r->type & ARM_CP_EL3_NO_EL2_C_NZ)) { |
336 | + gen_set_pc_im(s, s->base.pc_next); | 296 | + r2->resetvalue = 0; |
337 | s->base.is_jmp = DISAS_WFI; | 297 | + } |
338 | break; | 298 | + /* |
339 | case 2: /* wfe */ | 299 | + * ARM_CP_CONST has precedence, so removing the callbacks and |
340 | if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | 300 | + * offsets are not strictly necessary, but it is potentially |
341 | - gen_set_pc_im(s, s->pc); | 301 | + * less confusing to debug later. |
342 | + gen_set_pc_im(s, s->base.pc_next); | 302 | + */ |
343 | s->base.is_jmp = DISAS_WFE; | 303 | + r2->readfn = NULL; |
344 | } | 304 | + r2->writefn = NULL; |
345 | break; | 305 | + r2->raw_readfn = NULL; |
346 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | 306 | + r2->raw_writefn = NULL; |
347 | if (isread) { | 307 | + r2->resetfn = NULL; |
348 | return 1; | 308 | + r2->fieldoffset = 0; |
309 | + r2->bank_fieldoffsets[0] = 0; | ||
310 | + r2->bank_fieldoffsets[1] = 0; | ||
311 | + } else { | ||
312 | + bool isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1]; | ||
313 | |||
314 | - if (state == ARM_CP_STATE_AA32) { | ||
315 | if (isbanked) { | ||
316 | /* | ||
317 | - * If the register is banked then we don't need to migrate or | ||
318 | - * reset the 32-bit instance in certain cases: | ||
319 | - * | ||
320 | - * 1) If the register has both 32-bit and 64-bit instances then we | ||
321 | - * can count on the 64-bit instance taking care of the | ||
322 | - * non-secure bank. | ||
323 | - * 2) If ARMv8 is enabled then we can count on a 64-bit version | ||
324 | - * taking care of the secure bank. This requires that separate | ||
325 | - * 32 and 64-bit definitions are provided. | ||
326 | + * Register is banked (using both entries in array). | ||
327 | + * Overwriting fieldoffset as the array is only used to define | ||
328 | + * banked registers but later only fieldoffset is used. | ||
329 | */ | ||
330 | - if ((r->state == ARM_CP_STATE_BOTH && ns) || | ||
331 | - (arm_feature(&cpu->env, ARM_FEATURE_V8) && !ns)) { | ||
332 | + r2->fieldoffset = r->bank_fieldoffsets[ns]; | ||
333 | + } | ||
334 | + if (state == ARM_CP_STATE_AA32) { | ||
335 | + if (isbanked) { | ||
336 | + /* | ||
337 | + * If the register is banked then we don't need to migrate or | ||
338 | + * reset the 32-bit instance in certain cases: | ||
339 | + * | ||
340 | + * 1) If the register has both 32-bit and 64-bit instances | ||
341 | + * then we can count on the 64-bit instance taking care | ||
342 | + * of the non-secure bank. | ||
343 | + * 2) If ARMv8 is enabled then we can count on a 64-bit | ||
344 | + * version taking care of the secure bank. This requires | ||
345 | + * that separate 32 and 64-bit definitions are provided. | ||
346 | + */ | ||
347 | + if ((r->state == ARM_CP_STATE_BOTH && ns) || | ||
348 | + (arm_feature(env, ARM_FEATURE_V8) && !ns)) { | ||
349 | + r2->type |= ARM_CP_ALIAS; | ||
350 | + } | ||
351 | + } else if ((secstate != r->secure) && !ns) { | ||
352 | + /* | ||
353 | + * The register is not banked so we only want to allow | ||
354 | + * migration of the non-secure instance. | ||
355 | + */ | ||
356 | r2->type |= ARM_CP_ALIAS; | ||
349 | } | 357 | } |
350 | - gen_set_pc_im(s, s->pc); | 358 | - } else if ((secstate != r->secure) && !ns) { |
351 | + gen_set_pc_im(s, s->base.pc_next); | 359 | - /* |
352 | s->base.is_jmp = DISAS_WFI; | 360 | - * The register is not banked so we only want to allow migration |
353 | return 0; | 361 | - * of the non-secure instance. |
354 | default: | 362 | - */ |
355 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 363 | - r2->type |= ARM_CP_ALIAS; |
356 | * self-modifying code correctly and also to take | 364 | - } |
357 | * any pending interrupts immediately. | 365 | |
358 | */ | 366 | - if (HOST_BIG_ENDIAN && |
359 | - gen_goto_tb(s, 0, s->pc); | 367 | - r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { |
360 | + gen_goto_tb(s, 0, s->base.pc_next); | 368 | - r2->fieldoffset += sizeof(uint32_t); |
361 | return; | 369 | + if (HOST_BIG_ENDIAN && |
362 | case 7: /* sb */ | 370 | + r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) { |
363 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | 371 | + r2->fieldoffset += sizeof(uint32_t); |
364 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 372 | + } |
365 | * for TCG; MB and end the TB instead. | ||
366 | */ | ||
367 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
368 | - gen_goto_tb(s, 0, s->pc); | ||
369 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
370 | return; | ||
371 | default: | ||
372 | goto illegal_op; | ||
373 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
374 | int32_t offset; | ||
375 | |||
376 | tmp = tcg_temp_new_i32(); | ||
377 | - tcg_gen_movi_i32(tmp, s->pc); | ||
378 | + tcg_gen_movi_i32(tmp, s->base.pc_next); | ||
379 | store_reg(s, 14, tmp); | ||
380 | /* Sign-extend the 24-bit offset */ | ||
381 | offset = (((int32_t)insn) << 8) >> 8; | ||
382 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
383 | /* branch link/exchange thumb (blx) */ | ||
384 | tmp = load_reg(s, rm); | ||
385 | tmp2 = tcg_temp_new_i32(); | ||
386 | - tcg_gen_movi_i32(tmp2, s->pc); | ||
387 | + tcg_gen_movi_i32(tmp2, s->base.pc_next); | ||
388 | store_reg(s, 14, tmp2); | ||
389 | gen_bx(s, tmp); | ||
390 | break; | ||
391 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
392 | /* branch (and link) */ | ||
393 | if (insn & (1 << 24)) { | ||
394 | tmp = tcg_temp_new_i32(); | ||
395 | - tcg_gen_movi_i32(tmp, s->pc); | ||
396 | + tcg_gen_movi_i32(tmp, s->base.pc_next); | ||
397 | store_reg(s, 14, tmp); | ||
398 | } | ||
399 | offset = sextract32(insn << 2, 0, 26); | ||
400 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
401 | break; | ||
402 | case 0xf: | ||
403 | /* swi */ | ||
404 | - gen_set_pc_im(s, s->pc); | ||
405 | + gen_set_pc_im(s, s->base.pc_next); | ||
406 | s->svc_imm = extract32(insn, 0, 24); | ||
407 | s->base.is_jmp = DISAS_SWI; | ||
408 | break; | ||
409 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
410 | |||
411 | if (insn & (1 << 14)) { | ||
412 | /* Branch and link. */ | ||
413 | - tcg_gen_movi_i32(cpu_R[14], s->pc | 1); | ||
414 | + tcg_gen_movi_i32(cpu_R[14], s->base.pc_next | 1); | ||
415 | } | ||
416 | |||
417 | offset += read_pc(s); | ||
418 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
419 | * and also to take any pending interrupts | ||
420 | * immediately. | ||
421 | */ | ||
422 | - gen_goto_tb(s, 0, s->pc); | ||
423 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
424 | break; | ||
425 | case 7: /* sb */ | ||
426 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | ||
427 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
428 | * for TCG; MB and end the TB instead. | ||
429 | */ | ||
430 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
431 | - gen_goto_tb(s, 0, s->pc); | ||
432 | + gen_goto_tb(s, 0, s->base.pc_next); | ||
433 | break; | ||
434 | default: | ||
435 | goto illegal_op; | ||
436 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
437 | /* BLX/BX */ | ||
438 | tmp = load_reg(s, rm); | ||
439 | if (link) { | ||
440 | - val = (uint32_t)s->pc | 1; | ||
441 | + val = (uint32_t)s->base.pc_next | 1; | ||
442 | tmp2 = tcg_temp_new_i32(); | ||
443 | tcg_gen_movi_i32(tmp2, val); | ||
444 | store_reg(s, 14, tmp2); | ||
445 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
446 | |||
447 | if (cond == 0xf) { | ||
448 | /* swi */ | ||
449 | - gen_set_pc_im(s, s->pc); | ||
450 | + gen_set_pc_im(s, s->base.pc_next); | ||
451 | s->svc_imm = extract32(insn, 0, 8); | ||
452 | s->base.is_jmp = DISAS_SWI; | ||
453 | break; | ||
454 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
455 | tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); | ||
456 | |||
457 | tmp2 = tcg_temp_new_i32(); | ||
458 | - tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
459 | + tcg_gen_movi_i32(tmp2, s->base.pc_next | 1); | ||
460 | store_reg(s, 14, tmp2); | ||
461 | gen_bx(s, tmp); | ||
462 | break; | ||
463 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
464 | tcg_gen_addi_i32(tmp, tmp, offset); | ||
465 | |||
466 | tmp2 = tcg_temp_new_i32(); | ||
467 | - tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
468 | + tcg_gen_movi_i32(tmp2, s->base.pc_next | 1); | ||
469 | store_reg(s, 14, tmp2); | ||
470 | gen_bx(s, tmp); | ||
471 | } else { | ||
472 | @@ -XXX,XX +XXX,XX @@ undef: | ||
473 | |||
474 | static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | ||
475 | { | ||
476 | - /* Return true if the insn at dc->pc might cross a page boundary. | ||
477 | + /* Return true if the insn at dc->base.pc_next might cross a page boundary. | ||
478 | * (False positives are OK, false negatives are not.) | ||
479 | * We know this is a Thumb insn, and our caller ensures we are | ||
480 | - * only called if dc->pc is less than 4 bytes from the page | ||
481 | + * only called if dc->base.pc_next is less than 4 bytes from the page | ||
482 | * boundary, so we cross the page if the first 16 bits indicate | ||
483 | * that this is a 32 bit insn. | ||
484 | */ | ||
485 | - uint16_t insn = arm_lduw_code(env, s->pc, s->sctlr_b); | ||
486 | + uint16_t insn = arm_lduw_code(env, s->base.pc_next, s->sctlr_b); | ||
487 | |||
488 | - return !thumb_insn_is_16bit(s, s->pc, insn); | ||
489 | + return !thumb_insn_is_16bit(s, s->base.pc_next, insn); | ||
490 | } | ||
491 | |||
492 | static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
493 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | ||
494 | uint32_t condexec, core_mmu_idx; | ||
495 | |||
496 | dc->isar = &cpu->isar; | ||
497 | - dc->pc = dc->base.pc_first; | ||
498 | dc->condjmp = 0; | ||
499 | |||
500 | dc->aarch64 = 0; | ||
501 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | ||
502 | { | ||
503 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
504 | |||
505 | - tcg_gen_insn_start(dc->pc, | ||
506 | + tcg_gen_insn_start(dc->base.pc_next, | ||
507 | (dc->condexec_cond << 4) | (dc->condexec_mask >> 1), | ||
508 | 0); | ||
509 | dc->insn_start = tcg_last_op(); | ||
510 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
511 | |||
512 | if (bp->flags & BP_CPU) { | ||
513 | gen_set_condexec(dc); | ||
514 | - gen_set_pc_im(dc, dc->pc); | ||
515 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
516 | gen_helper_check_breakpoints(cpu_env); | ||
517 | /* End the TB early; it's likely not going to be executed */ | ||
518 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
519 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | ||
520 | tb->size below does the right thing. */ | ||
521 | /* TODO: Advance PC by correct instruction length to | ||
522 | * avoid disassembler error messages */ | ||
523 | - dc->pc += 2; | ||
524 | + dc->base.pc_next += 2; | ||
525 | dc->base.is_jmp = DISAS_NORETURN; | ||
526 | } | ||
527 | |||
528 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) | ||
529 | { | ||
530 | #ifdef CONFIG_USER_ONLY | ||
531 | /* Intercept jump to the magic kernel page. */ | ||
532 | - if (dc->pc >= 0xffff0000) { | ||
533 | + if (dc->base.pc_next >= 0xffff0000) { | ||
534 | /* We always get here via a jump, so know we are not in a | ||
535 | conditional execution block. */ | ||
536 | gen_exception_internal(EXCP_KERNEL_TRAP); | ||
537 | @@ -XXX,XX +XXX,XX @@ static void arm_post_translate_insn(DisasContext *dc) | ||
538 | gen_set_label(dc->condlabel); | ||
539 | dc->condjmp = 0; | ||
540 | } | ||
541 | - dc->base.pc_next = dc->pc; | ||
542 | translator_loop_temp_check(&dc->base); | ||
543 | } | ||
544 | |||
545 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
546 | return; | ||
547 | } | ||
548 | |||
549 | - dc->pc_curr = dc->pc; | ||
550 | - insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); | ||
551 | + dc->pc_curr = dc->base.pc_next; | ||
552 | + insn = arm_ldl_code(env, dc->base.pc_next, dc->sctlr_b); | ||
553 | dc->insn = insn; | ||
554 | - dc->pc += 4; | ||
555 | + dc->base.pc_next += 4; | ||
556 | disas_arm_insn(dc, insn); | ||
557 | |||
558 | arm_post_translate_insn(dc); | ||
559 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
560 | return; | ||
561 | } | ||
562 | |||
563 | - dc->pc_curr = dc->pc; | ||
564 | - insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
565 | - is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | ||
566 | - dc->pc += 2; | ||
567 | + dc->pc_curr = dc->base.pc_next; | ||
568 | + insn = arm_lduw_code(env, dc->base.pc_next, dc->sctlr_b); | ||
569 | + is_16bit = thumb_insn_is_16bit(dc, dc->base.pc_next, insn); | ||
570 | + dc->base.pc_next += 2; | ||
571 | if (!is_16bit) { | ||
572 | - uint32_t insn2 = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
573 | + uint32_t insn2 = arm_lduw_code(env, dc->base.pc_next, dc->sctlr_b); | ||
574 | |||
575 | insn = insn << 16 | insn2; | ||
576 | - dc->pc += 2; | ||
577 | + dc->base.pc_next += 2; | ||
578 | } | ||
579 | dc->insn = insn; | ||
580 | |||
581 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
582 | * but isn't very efficient). | ||
583 | */ | ||
584 | if (dc->base.is_jmp == DISAS_NEXT | ||
585 | - && (dc->pc - dc->page_start >= TARGET_PAGE_SIZE | ||
586 | - || (dc->pc - dc->page_start >= TARGET_PAGE_SIZE - 3 | ||
587 | + && (dc->base.pc_next - dc->page_start >= TARGET_PAGE_SIZE | ||
588 | + || (dc->base.pc_next - dc->page_start >= TARGET_PAGE_SIZE - 3 | ||
589 | && insn_crosses_page(env, dc)))) { | ||
590 | dc->base.is_jmp = DISAS_TOO_MANY; | ||
591 | } | ||
592 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
593 | case DISAS_NEXT: | ||
594 | case DISAS_TOO_MANY: | ||
595 | case DISAS_UPDATE: | ||
596 | - gen_set_pc_im(dc, dc->pc); | ||
597 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
598 | /* fall through */ | ||
599 | default: | ||
600 | /* FIXME: Single stepping a WFI insn will not halt the CPU. */ | ||
601 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
602 | switch(dc->base.is_jmp) { | ||
603 | case DISAS_NEXT: | ||
604 | case DISAS_TOO_MANY: | ||
605 | - gen_goto_tb(dc, 1, dc->pc); | ||
606 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
607 | break; | ||
608 | case DISAS_JUMP: | ||
609 | gen_goto_ptr(); | ||
610 | break; | ||
611 | case DISAS_UPDATE: | ||
612 | - gen_set_pc_im(dc, dc->pc); | ||
613 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
614 | /* fall through */ | ||
615 | default: | ||
616 | /* indicate that the hash table must be used to find the next TB */ | ||
617 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) | ||
618 | gen_set_label(dc->condlabel); | ||
619 | gen_set_condexec(dc); | ||
620 | if (unlikely(is_singlestepping(dc))) { | ||
621 | - gen_set_pc_im(dc, dc->pc); | ||
622 | + gen_set_pc_im(dc, dc->base.pc_next); | ||
623 | gen_singlestep_exception(dc); | ||
624 | } else { | ||
625 | - gen_goto_tb(dc, 1, dc->pc); | ||
626 | + gen_goto_tb(dc, 1, dc->base.pc_next); | ||
627 | } | 373 | } |
628 | } | 374 | } |
629 | - | 375 | |
630 | - /* Functions above can change dc->pc, so re-align db->pc_next */ | 376 | @@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, |
631 | - dc->base.pc_next = dc->pc; | 377 | * multiple times. Special registers (ie NOP/WFI) are |
632 | } | 378 | * never migratable and not even raw-accessible. |
633 | 379 | */ | |
634 | static void arm_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu) | 380 | - if (r->type & ARM_CP_SPECIAL_MASK) { |
381 | + if (r2->type & ARM_CP_SPECIAL_MASK) { | ||
382 | r2->type |= ARM_CP_NO_RAW; | ||
383 | } | ||
384 | if (((r->crm == CP_ANY) && crm != 0) || | ||
635 | -- | 385 | -- |
636 | 2.20.1 | 386 | 2.25.1 |
637 | |||
638 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Rotate is the more compact and obvious way to swap 16-bit | 3 | Drop el3_no_el2_cp_reginfo, el3_no_el2_v8_cp_reginfo, and the local |
4 | elements of a 32-bit word. | 4 | vpidr_regs definition, and rely on the squashing to ARM_CP_CONST |
5 | 5 | while registering for v8. | |
6 | |||
7 | This is a behavior change for v7 cpus with Security Extensions and | ||
8 | without Virtualization Extensions, in that the virtualization cpregs | ||
9 | are now correctly not present. This would be a migration compatibility | ||
10 | break, except that we have an existing bug in which migration of 32-bit | ||
11 | cpus with Security Extensions enabled does not work. | ||
12 | |||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190808202616.13782-6-richard.henderson@linaro.org | 15 | Message-id: 20220506180242.216785-3-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 17 | --- |
11 | target/arm/translate.c | 6 +----- | 18 | target/arm/helper.c | 158 ++++---------------------------------------- |
12 | 1 file changed, 1 insertion(+), 5 deletions(-) | 19 | 1 file changed, 13 insertions(+), 145 deletions(-) |
13 | 20 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 21 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 23 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/translate.c | 24 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static TCGv_i64 gen_muls_i64_i32(TCGv_i32 a, TCGv_i32 b) | 25 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { |
19 | /* Swap low and high halfwords. */ | 26 | .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, |
20 | static void gen_swap_half(TCGv_i32 var) | 27 | }; |
28 | |||
29 | -/* Used to describe the behaviour of EL2 regs when EL2 does not exist. */ | ||
30 | -static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = { | ||
31 | - { .name = "VBAR_EL2", .state = ARM_CP_STATE_BOTH, | ||
32 | - .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0, | ||
33 | - .access = PL2_RW, | ||
34 | - .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, | ||
35 | - { .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
36 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
37 | - .access = PL2_RW, | ||
38 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
39 | - { .name = "HACR_EL2", .state = ARM_CP_STATE_BOTH, | ||
40 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 7, | ||
41 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
42 | - { .name = "ESR_EL2", .state = ARM_CP_STATE_BOTH, | ||
43 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 0, | ||
44 | - .access = PL2_RW, | ||
45 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
46 | - { .name = "CPTR_EL2", .state = ARM_CP_STATE_BOTH, | ||
47 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2, | ||
48 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
49 | - { .name = "MAIR_EL2", .state = ARM_CP_STATE_BOTH, | ||
50 | - .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 0, | ||
51 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
52 | - .resetvalue = 0 }, | ||
53 | - { .name = "HMAIR1", .state = ARM_CP_STATE_AA32, | ||
54 | - .cp = 15, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 1, | ||
55 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
56 | - { .name = "AMAIR_EL2", .state = ARM_CP_STATE_BOTH, | ||
57 | - .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 3, .opc2 = 0, | ||
58 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
59 | - .resetvalue = 0 }, | ||
60 | - { .name = "HAMAIR1", .state = ARM_CP_STATE_AA32, | ||
61 | - .cp = 15, .opc1 = 4, .crn = 10, .crm = 3, .opc2 = 1, | ||
62 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
63 | - .resetvalue = 0 }, | ||
64 | - { .name = "AFSR0_EL2", .state = ARM_CP_STATE_BOTH, | ||
65 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 1, .opc2 = 0, | ||
66 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
67 | - .resetvalue = 0 }, | ||
68 | - { .name = "AFSR1_EL2", .state = ARM_CP_STATE_BOTH, | ||
69 | - .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 1, .opc2 = 1, | ||
70 | - .access = PL2_RW, .type = ARM_CP_CONST, | ||
71 | - .resetvalue = 0 }, | ||
72 | - { .name = "TCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
73 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 2, | ||
74 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
75 | - { .name = "VTCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
76 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 2, | ||
77 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
78 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | - { .name = "VTTBR", .state = ARM_CP_STATE_AA32, | ||
80 | - .cp = 15, .opc1 = 6, .crm = 2, | ||
81 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
82 | - .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
83 | - { .name = "VTTBR_EL2", .state = ARM_CP_STATE_AA64, | ||
84 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 0, | ||
85 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
86 | - { .name = "SCTLR_EL2", .state = ARM_CP_STATE_BOTH, | ||
87 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 0, | ||
88 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
89 | - { .name = "TPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
90 | - .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 2, | ||
91 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
92 | - { .name = "TTBR0_EL2", .state = ARM_CP_STATE_AA64, | ||
93 | - .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0, | ||
94 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
95 | - { .name = "HTTBR", .cp = 15, .opc1 = 4, .crm = 2, | ||
96 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, | ||
97 | - .resetvalue = 0 }, | ||
98 | - { .name = "CNTHCTL_EL2", .state = ARM_CP_STATE_BOTH, | ||
99 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 1, .opc2 = 0, | ||
100 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
101 | - { .name = "CNTVOFF_EL2", .state = ARM_CP_STATE_AA64, | ||
102 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 3, | ||
103 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
104 | - { .name = "CNTVOFF", .cp = 15, .opc1 = 4, .crm = 14, | ||
105 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, | ||
106 | - .resetvalue = 0 }, | ||
107 | - { .name = "CNTHP_CVAL_EL2", .state = ARM_CP_STATE_AA64, | ||
108 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 2, | ||
109 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
110 | - { .name = "CNTHP_CVAL", .cp = 15, .opc1 = 6, .crm = 14, | ||
111 | - .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST, | ||
112 | - .resetvalue = 0 }, | ||
113 | - { .name = "CNTHP_TVAL_EL2", .state = ARM_CP_STATE_BOTH, | ||
114 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 0, | ||
115 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
116 | - { .name = "CNTHP_CTL_EL2", .state = ARM_CP_STATE_BOTH, | ||
117 | - .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 1, | ||
118 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
119 | - { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
120 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1, | ||
121 | - .access = PL2_RW, .accessfn = access_tda, | ||
122 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
123 | - { .name = "HPFAR_EL2", .state = ARM_CP_STATE_BOTH, | ||
124 | - .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4, | ||
125 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
126 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
127 | - { .name = "HSTR_EL2", .state = ARM_CP_STATE_BOTH, | ||
128 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3, | ||
129 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
130 | - { .name = "FAR_EL2", .state = ARM_CP_STATE_BOTH, | ||
131 | - .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 0, | ||
132 | - .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
133 | - { .name = "HIFAR", .state = ARM_CP_STATE_AA32, | ||
134 | - .type = ARM_CP_CONST, | ||
135 | - .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2, | ||
136 | - .access = PL2_RW, .resetvalue = 0 }, | ||
137 | -}; | ||
138 | - | ||
139 | -/* Ditto, but for registers which exist in ARMv8 but not v7 */ | ||
140 | -static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | ||
141 | - { .name = "HCR2", .state = ARM_CP_STATE_AA32, | ||
142 | - .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
143 | - .access = PL2_RW, | ||
144 | - .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
145 | -}; | ||
146 | - | ||
147 | static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
21 | { | 148 | { |
22 | - TCGv_i32 tmp = tcg_temp_new_i32(); | 149 | ARMCPU *cpu = env_archcpu(env); |
23 | - tcg_gen_shri_i32(tmp, var, 16); | 150 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
24 | - tcg_gen_shli_i32(var, var, 16); | 151 | define_arm_cp_regs(cpu, v8_idregs); |
25 | - tcg_gen_or_i32(var, var, tmp); | 152 | define_arm_cp_regs(cpu, v8_cp_reginfo); |
26 | - tcg_temp_free_i32(tmp); | 153 | } |
27 | + tcg_gen_rotri_i32(var, var, 16); | 154 | - if (arm_feature(env, ARM_FEATURE_EL2)) { |
28 | } | 155 | + |
29 | 156 | + /* | |
30 | /* Dual 16-bit add. Result placed in t0 and t1 is marked as dead. | 157 | + * Register the base EL2 cpregs. |
158 | + * Pre v8, these registers are implemented only as part of the | ||
159 | + * Virtualization Extensions (EL2 present). Beginning with v8, | ||
160 | + * if EL2 is missing but EL3 is enabled, mostly these become | ||
161 | + * RES0 from EL3, with some specific exceptions. | ||
162 | + */ | ||
163 | + if (arm_feature(env, ARM_FEATURE_EL2) | ||
164 | + || (arm_feature(env, ARM_FEATURE_EL3) | ||
165 | + && arm_feature(env, ARM_FEATURE_V8))) { | ||
166 | uint64_t vmpidr_def = mpidr_read_val(env); | ||
167 | ARMCPRegInfo vpidr_regs[] = { | ||
168 | { .name = "VPIDR", .state = ARM_CP_STATE_AA32, | ||
169 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
170 | }; | ||
171 | define_one_arm_cp_reg(cpu, &rvbar); | ||
172 | } | ||
173 | - } else { | ||
174 | - /* If EL2 is missing but higher ELs are enabled, we need to | ||
175 | - * register the no_el2 reginfos. | ||
176 | - */ | ||
177 | - if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
178 | - /* When EL3 exists but not EL2, VPIDR and VMPIDR take the value | ||
179 | - * of MIDR_EL1 and MPIDR_EL1. | ||
180 | - */ | ||
181 | - ARMCPRegInfo vpidr_regs[] = { | ||
182 | - { .name = "VPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
183 | - .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, | ||
184 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
185 | - .type = ARM_CP_CONST, .resetvalue = cpu->midr, | ||
186 | - .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, | ||
187 | - { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_BOTH, | ||
188 | - .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, | ||
189 | - .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
190 | - .type = ARM_CP_NO_RAW, | ||
191 | - .writefn = arm_cp_write_ignore, .readfn = mpidr_read }, | ||
192 | - }; | ||
193 | - define_arm_cp_regs(cpu, vpidr_regs); | ||
194 | - define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo); | ||
195 | - if (arm_feature(env, ARM_FEATURE_V8)) { | ||
196 | - define_arm_cp_regs(cpu, el3_no_el2_v8_cp_reginfo); | ||
197 | - } | ||
198 | - } | ||
199 | } | ||
200 | + | ||
201 | + /* Register the base EL3 cpregs. */ | ||
202 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
203 | define_arm_cp_regs(cpu, el3_cp_reginfo); | ||
204 | ARMCPRegInfo el3_regs[] = { | ||
31 | -- | 205 | -- |
32 | 2.20.1 | 206 | 2.25.1 |
33 | |||
34 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Promote this function from aarch64 to fully general use. | 3 | Drop zcr_no_el2_reginfo and merge the 3 registers into one array, |
4 | Use it to unify the code sequences for generating illegal | 4 | now that ZCR_EL2 can be squashed to RES0 and ZCR_EL3 dropped |
5 | opcode exceptions. | 5 | while registering. |
6 | 6 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Message-id: 20220506180242.216785-4-richard.henderson@linaro.org |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190807045335.1361-11-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | target/arm/translate-a64.h | 2 -- | 12 | target/arm/helper.c | 55 ++++++++++++++------------------------------- |
14 | target/arm/translate.h | 2 ++ | 13 | 1 file changed, 17 insertions(+), 38 deletions(-) |
15 | target/arm/translate-a64.c | 7 ------- | ||
16 | target/arm/translate-vfp.inc.c | 3 +-- | ||
17 | target/arm/translate.c | 22 ++++++++++++---------- | ||
18 | 5 files changed, 15 insertions(+), 21 deletions(-) | ||
19 | 14 | ||
20 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/translate-a64.h | 17 | --- a/target/arm/helper.c |
23 | +++ b/target/arm/translate-a64.h | 18 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
25 | #ifndef TARGET_ARM_TRANSLATE_A64_H | ||
26 | #define TARGET_ARM_TRANSLATE_A64_H | ||
27 | |||
28 | -void unallocated_encoding(DisasContext *s); | ||
29 | - | ||
30 | #define unsupported_encoding(s, insn) \ | ||
31 | do { \ | ||
32 | qemu_log_mask(LOG_UNIMP, \ | ||
33 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/translate.h | ||
36 | +++ b/target/arm/translate.h | ||
37 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasCompare { | ||
38 | bool value_global; | ||
39 | } DisasCompare; | ||
40 | |||
41 | +void unallocated_encoding(DisasContext *s); | ||
42 | + | ||
43 | /* Share the TCG temporaries common between 32 and 64 bit modes. */ | ||
44 | extern TCGv_i32 cpu_NF, cpu_ZF, cpu_CF, cpu_VF; | ||
45 | extern TCGv_i64 cpu_exclusive_addr; | ||
46 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/translate-a64.c | ||
49 | +++ b/target/arm/translate-a64.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) | ||
51 | } | 20 | } |
52 | } | 21 | } |
53 | 22 | ||
54 | -void unallocated_encoding(DisasContext *s) | 23 | -static const ARMCPRegInfo zcr_el1_reginfo = { |
55 | -{ | 24 | - .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64, |
56 | - /* Unallocated and reserved encodings are uncategorized */ | 25 | - .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0, |
57 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | 26 | - .access = PL1_RW, .type = ARM_CP_SVE, |
58 | - default_exception_el(s)); | 27 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]), |
59 | -} | 28 | - .writefn = zcr_write, .raw_writefn = raw_write |
29 | -}; | ||
60 | - | 30 | - |
61 | static void init_tmp_a64_array(DisasContext *s) | 31 | -static const ARMCPRegInfo zcr_el2_reginfo = { |
62 | { | 32 | - .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, |
63 | #ifdef CONFIG_DEBUG_TCG | 33 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, |
64 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | 34 | - .access = PL2_RW, .type = ARM_CP_SVE, |
65 | index XXXXXXX..XXXXXXX 100644 | 35 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]), |
66 | --- a/target/arm/translate-vfp.inc.c | 36 | - .writefn = zcr_write, .raw_writefn = raw_write |
67 | +++ b/target/arm/translate-vfp.inc.c | 37 | -}; |
68 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | 38 | - |
69 | 39 | -static const ARMCPRegInfo zcr_no_el2_reginfo = { | |
70 | if (!s->vfp_enabled && !ignore_vfp_enabled) { | 40 | - .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, |
71 | assert(!arm_dc_feature(s, ARM_FEATURE_M)); | 41 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, |
72 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | 42 | - .access = PL2_RW, .type = ARM_CP_SVE, |
73 | - default_exception_el(s)); | 43 | - .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore |
74 | + unallocated_encoding(s); | 44 | -}; |
75 | return false; | 45 | - |
46 | -static const ARMCPRegInfo zcr_el3_reginfo = { | ||
47 | - .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64, | ||
48 | - .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0, | ||
49 | - .access = PL3_RW, .type = ARM_CP_SVE, | ||
50 | - .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]), | ||
51 | - .writefn = zcr_write, .raw_writefn = raw_write | ||
52 | +static const ARMCPRegInfo zcr_reginfo[] = { | ||
53 | + { .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64, | ||
54 | + .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0, | ||
55 | + .access = PL1_RW, .type = ARM_CP_SVE, | ||
56 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]), | ||
57 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
58 | + { .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64, | ||
59 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0, | ||
60 | + .access = PL2_RW, .type = ARM_CP_SVE, | ||
61 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]), | ||
62 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
63 | + { .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64, | ||
64 | + .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0, | ||
65 | + .access = PL3_RW, .type = ARM_CP_SVE, | ||
66 | + .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]), | ||
67 | + .writefn = zcr_write, .raw_writefn = raw_write }, | ||
68 | }; | ||
69 | |||
70 | void hw_watchpoint_update(ARMCPU *cpu, int n) | ||
71 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
76 | } | 72 | } |
77 | 73 | ||
78 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 74 | if (cpu_isar_feature(aa64_sve, cpu)) { |
79 | index XXXXXXX..XXXXXXX 100644 | 75 | - define_one_arm_cp_reg(cpu, &zcr_el1_reginfo); |
80 | --- a/target/arm/translate.c | 76 | - if (arm_feature(env, ARM_FEATURE_EL2)) { |
81 | +++ b/target/arm/translate.c | 77 | - define_one_arm_cp_reg(cpu, &zcr_el2_reginfo); |
82 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) | 78 | - } else { |
83 | s->base.is_jmp = DISAS_NORETURN; | 79 | - define_one_arm_cp_reg(cpu, &zcr_no_el2_reginfo); |
84 | } | 80 | - } |
85 | 81 | - if (arm_feature(env, ARM_FEATURE_EL3)) { | |
86 | +void unallocated_encoding(DisasContext *s) | 82 | - define_one_arm_cp_reg(cpu, &zcr_el3_reginfo); |
87 | +{ | 83 | - } |
88 | + /* Unallocated and reserved encodings are uncategorized */ | 84 | + define_arm_cp_regs(cpu, zcr_reginfo); |
89 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
90 | + default_exception_el(s)); | ||
91 | +} | ||
92 | + | ||
93 | /* Force a TB lookup after an instruction that changes the CPU state. */ | ||
94 | static inline void gen_lookup_tb(DisasContext *s) | ||
95 | { | ||
96 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | ||
97 | return; | ||
98 | } | 85 | } |
99 | 86 | ||
100 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | 87 | #ifdef TARGET_AARCH64 |
101 | - default_exception_el(s)); | ||
102 | + unallocated_encoding(s); | ||
103 | } | ||
104 | |||
105 | static inline void gen_add_data_offset(DisasContext *s, unsigned int insn, | ||
106 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
107 | } | ||
108 | |||
109 | if (undef) { | ||
110 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
111 | - default_exception_el(s)); | ||
112 | + unallocated_encoding(s); | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
117 | break; | ||
118 | default: | ||
119 | illegal_op: | ||
120 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
121 | - default_exception_el(s)); | ||
122 | + unallocated_encoding(s); | ||
123 | break; | ||
124 | } | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | return; | ||
129 | illegal_op: | ||
130 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
131 | - default_exception_el(s)); | ||
132 | + unallocated_encoding(s); | ||
133 | } | ||
134 | |||
135 | static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
136 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
137 | return; | ||
138 | illegal_op: | ||
139 | undef: | ||
140 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
141 | - default_exception_el(s)); | ||
142 | + unallocated_encoding(s); | ||
143 | } | ||
144 | |||
145 | static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | ||
146 | -- | 88 | -- |
147 | 2.20.1 | 89 | 2.25.1 |
148 | |||
149 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The current implementation of ZCR_ELx matches the architecture, only | 3 | This register is present for either VHE or Debugv8p2. |
4 | implementing the lower four bits, with the rest RAZ/WI. This puts | ||
5 | a strict limit on ARM_MAX_VQ of 16. Make sure we don't let ARM_MAX_VQ | ||
6 | grow without a corresponding update here. | ||
7 | 4 | ||
8 | Suggested-by: Dave Martin <Dave.Martin@arm.com> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Message-id: 20220506180242.216785-5-richard.henderson@linaro.org |
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 9 | --- |
14 | target/arm/helper.c | 1 + | 10 | target/arm/helper.c | 15 +++++++++++---- |
15 | 1 file changed, 1 insertion(+) | 11 | 1 file changed, 11 insertions(+), 4 deletions(-) |
16 | 12 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 15 | --- a/target/arm/helper.c |
20 | +++ b/target/arm/helper.c | 16 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 17 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = { |
22 | int new_len; | 18 | .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
23 | 19 | }; | |
24 | /* Bits other than [3:0] are RAZ/WI. */ | 20 | |
25 | + QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16); | 21 | +static const ARMCPRegInfo contextidr_el2 = { |
26 | raw_write(env, ri, value & 0xf); | 22 | + .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64, |
27 | 23 | + .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, | |
28 | /* | 24 | + .access = PL2_RW, |
25 | + .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) | ||
26 | +}; | ||
27 | + | ||
28 | static const ARMCPRegInfo vhe_reginfo[] = { | ||
29 | - { .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64, | ||
30 | - .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1, | ||
31 | - .access = PL2_RW, | ||
32 | - .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) }, | ||
33 | { .name = "TTBR1_EL2", .state = ARM_CP_STATE_AA64, | ||
34 | .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 1, | ||
35 | .access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write, | ||
36 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
37 | define_one_arm_cp_reg(cpu, &ssbs_reginfo); | ||
38 | } | ||
39 | |||
40 | + if (cpu_isar_feature(aa64_vh, cpu) || | ||
41 | + cpu_isar_feature(aa64_debugv8p2, cpu)) { | ||
42 | + define_one_arm_cp_reg(cpu, &contextidr_el2); | ||
43 | + } | ||
44 | if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) { | ||
45 | define_arm_cp_regs(cpu, vhe_reginfo); | ||
46 | } | ||
29 | -- | 47 | -- |
30 | 2.20.1 | 48 | 2.25.1 |
31 | |||
32 | diff view generated by jsdifflib |
1 | Factor out code to 'generate a singlestep exception', which is | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | currently repeated in four places. | 2 | |
3 | 3 | Previously we were defining some of these in user-only mode, | |
4 | To do this we need to also pull the identical copies of the | 4 | but none of them are accessible from user-only, therefore |
5 | gen-exception() function out of translate-a64.c and translate.c | 5 | define them only in system mode. |
6 | into translate.h. | 6 | |
7 | 7 | This will shortly be used from cpu_tcg.c also. | |
8 | (There is a bug in the code: we're taking the exception to the wrong | 8 | |
9 | target EL. This will be simpler to fix if there's only one place to | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | do it.) | 10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | 11 | Message-id: 20220506180242.216785-6-richard.henderson@linaro.org | |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
15 | Message-id: 20190805130952.4415-2-peter.maydell@linaro.org | ||
16 | --- | 13 | --- |
17 | target/arm/translate.h | 23 +++++++++++++++++++++++ | 14 | target/arm/internals.h | 6 ++++ |
18 | target/arm/translate-a64.c | 19 ++----------------- | 15 | target/arm/cpu64.c | 64 +++--------------------------------------- |
19 | target/arm/translate.c | 20 ++------------------ | 16 | target/arm/cpu_tcg.c | 59 ++++++++++++++++++++++++++++++++++++++ |
20 | 3 files changed, 27 insertions(+), 35 deletions(-) | 17 | 3 files changed, 69 insertions(+), 60 deletions(-) |
21 | 18 | ||
22 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 19 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
23 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/translate.h | 21 | --- a/target/arm/internals.h |
25 | +++ b/target/arm/translate.h | 22 | +++ b/target/arm/internals.h |
23 | @@ -XXX,XX +XXX,XX @@ int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
24 | int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
25 | #endif | ||
26 | |||
27 | +#ifdef CONFIG_USER_ONLY | ||
28 | +static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } | ||
29 | +#else | ||
30 | +void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); | ||
31 | +#endif | ||
32 | + | ||
33 | #endif | ||
34 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/cpu64.c | ||
37 | +++ b/target/arm/cpu64.c | ||
26 | @@ -XXX,XX +XXX,XX @@ | 38 | @@ -XXX,XX +XXX,XX @@ |
27 | #define TARGET_ARM_TRANSLATE_H | 39 | #include "hvf_arm.h" |
28 | 40 | #include "qapi/visitor.h" | |
29 | #include "exec/translator.h" | 41 | #include "hw/qdev-properties.h" |
42 | -#include "cpregs.h" | ||
30 | +#include "internals.h" | 43 | +#include "internals.h" |
31 | 44 | ||
32 | 45 | ||
33 | /* internal defines */ | 46 | -#ifndef CONFIG_USER_ONLY |
34 | @@ -XXX,XX +XXX,XX @@ static inline void gen_ss_advance(DisasContext *s) | 47 | -static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
35 | } | 48 | -{ |
49 | - ARMCPU *cpu = env_archcpu(env); | ||
50 | - | ||
51 | - /* Number of cores is in [25:24]; otherwise we RAZ */ | ||
52 | - return (cpu->core_count - 1) << 24; | ||
53 | -} | ||
54 | -#endif | ||
55 | - | ||
56 | -static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | ||
57 | -#ifndef CONFIG_USER_ONLY | ||
58 | - { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
59 | - .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2, | ||
60 | - .access = PL1_RW, .readfn = a57_a53_l2ctlr_read, | ||
61 | - .writefn = arm_cp_write_ignore }, | ||
62 | - { .name = "L2CTLR", | ||
63 | - .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2, | ||
64 | - .access = PL1_RW, .readfn = a57_a53_l2ctlr_read, | ||
65 | - .writefn = arm_cp_write_ignore }, | ||
66 | -#endif | ||
67 | - { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
68 | - .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3, | ||
69 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
70 | - { .name = "L2ECTLR", | ||
71 | - .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3, | ||
72 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
73 | - { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH, | ||
74 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0, | ||
75 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
76 | - { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
77 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0, | ||
78 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | - { .name = "CPUACTLR", | ||
80 | - .cp = 15, .opc1 = 0, .crm = 15, | ||
81 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
82 | - { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
83 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1, | ||
84 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
85 | - { .name = "CPUECTLR", | ||
86 | - .cp = 15, .opc1 = 1, .crm = 15, | ||
87 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
88 | - { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
89 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2, | ||
90 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
91 | - { .name = "CPUMERRSR", | ||
92 | - .cp = 15, .opc1 = 2, .crm = 15, | ||
93 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
94 | - { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
95 | - .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3, | ||
96 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
97 | - { .name = "L2MERRSR", | ||
98 | - .cp = 15, .opc1 = 3, .crm = 15, | ||
99 | - .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
100 | -}; | ||
101 | - | ||
102 | static void aarch64_a57_initfn(Object *obj) | ||
103 | { | ||
104 | ARMCPU *cpu = ARM_CPU(obj); | ||
105 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | ||
106 | cpu->gic_num_lrs = 4; | ||
107 | cpu->gic_vpribits = 5; | ||
108 | cpu->gic_vprebits = 5; | ||
109 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
110 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
36 | } | 111 | } |
37 | 112 | ||
38 | +static inline void gen_exception(int excp, uint32_t syndrome, | 113 | static void aarch64_a53_initfn(Object *obj) |
39 | + uint32_t target_el) | 114 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) |
115 | cpu->gic_num_lrs = 4; | ||
116 | cpu->gic_vpribits = 5; | ||
117 | cpu->gic_vprebits = 5; | ||
118 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
119 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
120 | } | ||
121 | |||
122 | static void aarch64_a72_initfn(Object *obj) | ||
123 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | ||
124 | cpu->gic_num_lrs = 4; | ||
125 | cpu->gic_vpribits = 5; | ||
126 | cpu->gic_vprebits = 5; | ||
127 | - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | ||
128 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
129 | } | ||
130 | |||
131 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
132 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
133 | index XXXXXXX..XXXXXXX 100644 | ||
134 | --- a/target/arm/cpu_tcg.c | ||
135 | +++ b/target/arm/cpu_tcg.c | ||
136 | @@ -XXX,XX +XXX,XX @@ | ||
137 | #endif | ||
138 | #include "cpregs.h" | ||
139 | |||
140 | +#ifndef CONFIG_USER_ONLY | ||
141 | +static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
40 | +{ | 142 | +{ |
41 | + TCGv_i32 tcg_excp = tcg_const_i32(excp); | 143 | + ARMCPU *cpu = env_archcpu(env); |
42 | + TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | 144 | + |
43 | + TCGv_i32 tcg_el = tcg_const_i32(target_el); | 145 | + /* Number of cores is in [25:24]; otherwise we RAZ */ |
44 | + | 146 | + return (cpu->core_count - 1) << 24; |
45 | + gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
46 | + tcg_syn, tcg_el); | ||
47 | + | ||
48 | + tcg_temp_free_i32(tcg_el); | ||
49 | + tcg_temp_free_i32(tcg_syn); | ||
50 | + tcg_temp_free_i32(tcg_excp); | ||
51 | +} | 147 | +} |
52 | + | 148 | + |
53 | +/* Generate an architectural singlestep exception */ | 149 | +static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { |
54 | +static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) | 150 | + { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64, |
151 | + .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2, | ||
152 | + .access = PL1_RW, .readfn = l2ctlr_read, | ||
153 | + .writefn = arm_cp_write_ignore }, | ||
154 | + { .name = "L2CTLR", | ||
155 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2, | ||
156 | + .access = PL1_RW, .readfn = l2ctlr_read, | ||
157 | + .writefn = arm_cp_write_ignore }, | ||
158 | + { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
159 | + .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3, | ||
160 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
161 | + { .name = "L2ECTLR", | ||
162 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3, | ||
163 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
164 | + { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH, | ||
165 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0, | ||
166 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
167 | + { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
168 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0, | ||
169 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
170 | + { .name = "CPUACTLR", | ||
171 | + .cp = 15, .opc1 = 0, .crm = 15, | ||
172 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
173 | + { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
174 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1, | ||
175 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
176 | + { .name = "CPUECTLR", | ||
177 | + .cp = 15, .opc1 = 1, .crm = 15, | ||
178 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
179 | + { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
180 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2, | ||
181 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
182 | + { .name = "CPUMERRSR", | ||
183 | + .cp = 15, .opc1 = 2, .crm = 15, | ||
184 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
185 | + { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64, | ||
186 | + .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3, | ||
187 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
188 | + { .name = "L2MERRSR", | ||
189 | + .cp = 15, .opc1 = 3, .crm = 15, | ||
190 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
191 | +}; | ||
192 | + | ||
193 | +void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) | ||
55 | +{ | 194 | +{ |
56 | + gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, isv, ex), | 195 | + define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); |
57 | + default_exception_el(s)); | ||
58 | +} | 196 | +} |
59 | + | 197 | +#endif /* !CONFIG_USER_ONLY */ |
60 | /* | 198 | + |
61 | * Given a VFP floating point constant encoded into an 8 bit immediate in an | 199 | /* CPU models. These are not needed for the AArch64 linux-user build. */ |
62 | * instruction, expand it to the actual constant value of the specified | 200 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) |
63 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 201 | |
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/translate-a64.c | ||
66 | +++ b/target/arm/translate-a64.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | ||
68 | tcg_temp_free_i32(tcg_excp); | ||
69 | } | ||
70 | |||
71 | -static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) | ||
72 | -{ | ||
73 | - TCGv_i32 tcg_excp = tcg_const_i32(excp); | ||
74 | - TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | ||
75 | - TCGv_i32 tcg_el = tcg_const_i32(target_el); | ||
76 | - | ||
77 | - gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
78 | - tcg_syn, tcg_el); | ||
79 | - tcg_temp_free_i32(tcg_el); | ||
80 | - tcg_temp_free_i32(tcg_syn); | ||
81 | - tcg_temp_free_i32(tcg_excp); | ||
82 | -} | ||
83 | - | ||
84 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
85 | { | ||
86 | gen_a64_set_pc_im(s->pc - offset); | ||
87 | @@ -XXX,XX +XXX,XX @@ static void gen_step_complete_exception(DisasContext *s) | ||
88 | * of the exception, and our syndrome information is always correct. | ||
89 | */ | ||
90 | gen_ss_advance(s); | ||
91 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex), | ||
92 | - default_exception_el(s)); | ||
93 | + gen_swstep_exception(s, 1, s->is_ldex); | ||
94 | s->base.is_jmp = DISAS_NORETURN; | ||
95 | } | ||
96 | |||
97 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
98 | * bits should be zero. | ||
99 | */ | ||
100 | assert(dc->base.num_insns == 1); | ||
101 | - gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), | ||
102 | - default_exception_el(dc)); | ||
103 | + gen_swstep_exception(dc, 0, 0); | ||
104 | dc->base.is_jmp = DISAS_NORETURN; | ||
105 | } else { | ||
106 | disas_a64_insn(env, dc); | ||
107 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/target/arm/translate.c | ||
110 | +++ b/target/arm/translate.c | ||
111 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | ||
112 | tcg_temp_free_i32(tcg_excp); | ||
113 | } | ||
114 | |||
115 | -static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) | ||
116 | -{ | ||
117 | - TCGv_i32 tcg_excp = tcg_const_i32(excp); | ||
118 | - TCGv_i32 tcg_syn = tcg_const_i32(syndrome); | ||
119 | - TCGv_i32 tcg_el = tcg_const_i32(target_el); | ||
120 | - | ||
121 | - gen_helper_exception_with_syndrome(cpu_env, tcg_excp, | ||
122 | - tcg_syn, tcg_el); | ||
123 | - | ||
124 | - tcg_temp_free_i32(tcg_el); | ||
125 | - tcg_temp_free_i32(tcg_syn); | ||
126 | - tcg_temp_free_i32(tcg_excp); | ||
127 | -} | ||
128 | - | ||
129 | static void gen_step_complete_exception(DisasContext *s) | ||
130 | { | ||
131 | /* We just completed step of an insn. Move from Active-not-pending | ||
132 | @@ -XXX,XX +XXX,XX @@ static void gen_step_complete_exception(DisasContext *s) | ||
133 | * of the exception, and our syndrome information is always correct. | ||
134 | */ | ||
135 | gen_ss_advance(s); | ||
136 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex), | ||
137 | - default_exception_el(s)); | ||
138 | + gen_swstep_exception(s, 1, s->is_ldex); | ||
139 | s->base.is_jmp = DISAS_NORETURN; | ||
140 | } | ||
141 | |||
142 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) | ||
143 | * bits should be zero. | ||
144 | */ | ||
145 | assert(dc->base.num_insns == 1); | ||
146 | - gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), | ||
147 | - default_exception_el(dc)); | ||
148 | + gen_swstep_exception(dc, 0, 0); | ||
149 | dc->base.is_jmp = DISAS_NORETURN; | ||
150 | return true; | ||
151 | } | ||
152 | -- | 202 | -- |
153 | 2.20.1 | 203 | 2.25.1 |
154 | |||
155 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The offset is variable depending on the instruction set, whereas | 3 | Instead of starting with cortex-a15 and adding v8 features to |
4 | we have stored values for the current pc and the next pc. Passing | 4 | a v7 cpu, begin with a v8 cpu stripped of its aarch64 features. |
5 | in the actual value is clearer in intent. | 5 | This fixes the long-standing to-do where we only enabled v8 |
6 | features for user-only. | ||
6 | 7 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Message-id: 20220506180242.216785-7-richard.henderson@linaro.org |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190807045335.1361-8-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | target/arm/translate-a64.c | 25 ++++++++++++++----------- | 13 | target/arm/cpu_tcg.c | 151 ++++++++++++++++++++++++++----------------- |
14 | target/arm/translate-vfp.inc.c | 6 +++--- | 14 | 1 file changed, 92 insertions(+), 59 deletions(-) |
15 | target/arm/translate.c | 31 ++++++++++++++++--------------- | ||
16 | 3 files changed, 33 insertions(+), 29 deletions(-) | ||
17 | 15 | ||
18 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 16 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/translate-a64.c | 18 | --- a/target/arm/cpu_tcg.c |
21 | +++ b/target/arm/translate-a64.c | 19 | +++ b/target/arm/cpu_tcg.c |
22 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 20 | @@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data) |
23 | s->base.is_jmp = DISAS_NORETURN; | 21 | static void arm_max_initfn(Object *obj) |
22 | { | ||
23 | ARMCPU *cpu = ARM_CPU(obj); | ||
24 | + uint32_t t; | ||
25 | |||
26 | - cortex_a15_initfn(obj); | ||
27 | + /* aarch64_a57_initfn, advertising none of the aarch64 features */ | ||
28 | + cpu->dtb_compatible = "arm,cortex-a57"; | ||
29 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
30 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
31 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
32 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
33 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
34 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
35 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
36 | + cpu->midr = 0x411fd070; | ||
37 | + cpu->revidr = 0x00000000; | ||
38 | + cpu->reset_fpsid = 0x41034070; | ||
39 | + cpu->isar.mvfr0 = 0x10110222; | ||
40 | + cpu->isar.mvfr1 = 0x12111111; | ||
41 | + cpu->isar.mvfr2 = 0x00000043; | ||
42 | + cpu->ctr = 0x8444c004; | ||
43 | + cpu->reset_sctlr = 0x00c50838; | ||
44 | + cpu->isar.id_pfr0 = 0x00000131; | ||
45 | + cpu->isar.id_pfr1 = 0x00011011; | ||
46 | + cpu->isar.id_dfr0 = 0x03010066; | ||
47 | + cpu->id_afr0 = 0x00000000; | ||
48 | + cpu->isar.id_mmfr0 = 0x10101105; | ||
49 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
50 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
51 | + cpu->isar.id_mmfr3 = 0x02102211; | ||
52 | + cpu->isar.id_isar0 = 0x02101110; | ||
53 | + cpu->isar.id_isar1 = 0x13112111; | ||
54 | + cpu->isar.id_isar2 = 0x21232042; | ||
55 | + cpu->isar.id_isar3 = 0x01112131; | ||
56 | + cpu->isar.id_isar4 = 0x00011142; | ||
57 | + cpu->isar.id_isar5 = 0x00011121; | ||
58 | + cpu->isar.id_isar6 = 0; | ||
59 | + cpu->isar.dbgdidr = 0x3516d000; | ||
60 | + cpu->clidr = 0x0a200023; | ||
61 | + cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ | ||
62 | + cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ | ||
63 | + cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ | ||
64 | + define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
65 | |||
66 | - /* old-style VFP short-vector support */ | ||
67 | - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
68 | + /* Add additional features supported by QEMU */ | ||
69 | + t = cpu->isar.id_isar5; | ||
70 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
71 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
72 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
73 | + t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
74 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
75 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
76 | + cpu->isar.id_isar5 = t; | ||
77 | + | ||
78 | + t = cpu->isar.id_isar6; | ||
79 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
80 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
81 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
82 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
83 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
84 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
85 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
86 | + cpu->isar.id_isar6 = t; | ||
87 | + | ||
88 | + t = cpu->isar.mvfr1; | ||
89 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
90 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
91 | + cpu->isar.mvfr1 = t; | ||
92 | + | ||
93 | + t = cpu->isar.mvfr2; | ||
94 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
95 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
96 | + cpu->isar.mvfr2 = t; | ||
97 | + | ||
98 | + t = cpu->isar.id_mmfr3; | ||
99 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
100 | + cpu->isar.id_mmfr3 = t; | ||
101 | + | ||
102 | + t = cpu->isar.id_mmfr4; | ||
103 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
104 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
105 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
106 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
107 | + cpu->isar.id_mmfr4 = t; | ||
108 | + | ||
109 | + t = cpu->isar.id_pfr0; | ||
110 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
111 | + cpu->isar.id_pfr0 = t; | ||
112 | + | ||
113 | + t = cpu->isar.id_pfr2; | ||
114 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
115 | + cpu->isar.id_pfr2 = t; | ||
116 | |||
117 | #ifdef CONFIG_USER_ONLY | ||
118 | /* | ||
119 | - * We don't set these in system emulation mode for the moment, | ||
120 | - * since we don't correctly set (all of) the ID registers to | ||
121 | - * advertise them. | ||
122 | + * Break with true ARMv8 and add back old-style VFP short-vector support. | ||
123 | + * Only do this for user-mode, where -cpu max is the default, so that | ||
124 | + * older v6 and v7 programs are more likely to work without adjustment. | ||
125 | */ | ||
126 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
127 | - { | ||
128 | - uint32_t t; | ||
129 | - | ||
130 | - t = cpu->isar.id_isar5; | ||
131 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
132 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
133 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
134 | - t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
135 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
136 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
137 | - cpu->isar.id_isar5 = t; | ||
138 | - | ||
139 | - t = cpu->isar.id_isar6; | ||
140 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
141 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
142 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
143 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
144 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
145 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
146 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
147 | - cpu->isar.id_isar6 = t; | ||
148 | - | ||
149 | - t = cpu->isar.mvfr1; | ||
150 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
151 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
152 | - cpu->isar.mvfr1 = t; | ||
153 | - | ||
154 | - t = cpu->isar.mvfr2; | ||
155 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
156 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
157 | - cpu->isar.mvfr2 = t; | ||
158 | - | ||
159 | - t = cpu->isar.id_mmfr3; | ||
160 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
161 | - cpu->isar.id_mmfr3 = t; | ||
162 | - | ||
163 | - t = cpu->isar.id_mmfr4; | ||
164 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
165 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
166 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
167 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
168 | - cpu->isar.id_mmfr4 = t; | ||
169 | - | ||
170 | - t = cpu->isar.id_pfr0; | ||
171 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
172 | - cpu->isar.id_pfr0 = t; | ||
173 | - | ||
174 | - t = cpu->isar.id_pfr2; | ||
175 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
176 | - cpu->isar.id_pfr2 = t; | ||
177 | - } | ||
178 | -#endif /* CONFIG_USER_ONLY */ | ||
179 | + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); | ||
180 | +#endif | ||
24 | } | 181 | } |
25 | 182 | #endif /* !TARGET_AARCH64 */ | |
26 | -static void gen_exception_insn(DisasContext *s, int offset, int excp, | ||
27 | +static void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | ||
28 | uint32_t syndrome, uint32_t target_el) | ||
29 | { | ||
30 | - gen_a64_set_pc_im(s->base.pc_next - offset); | ||
31 | + gen_a64_set_pc_im(pc); | ||
32 | gen_exception(excp, syndrome, target_el); | ||
33 | s->base.is_jmp = DISAS_NORETURN; | ||
34 | } | ||
35 | @@ -XXX,XX +XXX,XX @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) | ||
36 | void unallocated_encoding(DisasContext *s) | ||
37 | { | ||
38 | /* Unallocated and reserved encodings are uncategorized */ | ||
39 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
40 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
41 | default_exception_el(s)); | ||
42 | } | ||
43 | |||
44 | @@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s) | ||
45 | return true; | ||
46 | } | ||
47 | |||
48 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_fp_access_trap(1, 0xe, false), | ||
49 | - s->fp_excp_el); | ||
50 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
51 | + syn_fp_access_trap(1, 0xe, false), s->fp_excp_el); | ||
52 | return false; | ||
53 | } | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s) | ||
56 | bool sve_access_check(DisasContext *s) | ||
57 | { | ||
58 | if (s->sve_excp_el) { | ||
59 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_sve_access_trap(), | ||
60 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_sve_access_trap(), | ||
61 | s->sve_excp_el); | ||
62 | return false; | ||
63 | } | ||
64 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
65 | switch (op2_ll) { | ||
66 | case 1: /* SVC */ | ||
67 | gen_ss_advance(s); | ||
68 | - gen_exception_insn(s, 0, EXCP_SWI, syn_aa64_svc(imm16), | ||
69 | - default_exception_el(s)); | ||
70 | + gen_exception_insn(s, s->base.pc_next, EXCP_SWI, | ||
71 | + syn_aa64_svc(imm16), default_exception_el(s)); | ||
72 | break; | ||
73 | case 2: /* HVC */ | ||
74 | if (s->current_el == 0) { | ||
75 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
76 | gen_a64_set_pc_im(s->pc_curr); | ||
77 | gen_helper_pre_hvc(cpu_env); | ||
78 | gen_ss_advance(s); | ||
79 | - gen_exception_insn(s, 0, EXCP_HVC, syn_aa64_hvc(imm16), 2); | ||
80 | + gen_exception_insn(s, s->base.pc_next, EXCP_HVC, | ||
81 | + syn_aa64_hvc(imm16), 2); | ||
82 | break; | ||
83 | case 3: /* SMC */ | ||
84 | if (s->current_el == 0) { | ||
85 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
86 | gen_helper_pre_smc(cpu_env, tmp); | ||
87 | tcg_temp_free_i32(tmp); | ||
88 | gen_ss_advance(s); | ||
89 | - gen_exception_insn(s, 0, EXCP_SMC, syn_aa64_smc(imm16), 3); | ||
90 | + gen_exception_insn(s, s->base.pc_next, EXCP_SMC, | ||
91 | + syn_aa64_smc(imm16), 3); | ||
92 | break; | ||
93 | default: | ||
94 | unallocated_encoding(s); | ||
95 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
96 | if (s->btype != 0 | ||
97 | && s->guarded_page | ||
98 | && !btype_destination_ok(insn, s->bt, s->btype)) { | ||
99 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_btitrap(s->btype), | ||
100 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
101 | + syn_btitrap(s->btype), | ||
102 | default_exception_el(s)); | ||
103 | return; | ||
104 | } | ||
105 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/translate-vfp.inc.c | ||
108 | +++ b/target/arm/translate-vfp.inc.c | ||
109 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | ||
110 | { | ||
111 | if (s->fp_excp_el) { | ||
112 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
113 | - gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
114 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized(), | ||
115 | s->fp_excp_el); | ||
116 | } else { | ||
117 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
118 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
119 | syn_fp_access_trap(1, 0xe, false), | ||
120 | s->fp_excp_el); | ||
121 | } | ||
122 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) | ||
123 | |||
124 | if (!s->vfp_enabled && !ignore_vfp_enabled) { | ||
125 | assert(!arm_dc_feature(s, ARM_FEATURE_M)); | ||
126 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
127 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
128 | default_exception_el(s)); | ||
129 | return false; | ||
130 | } | ||
131 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
132 | index XXXXXXX..XXXXXXX 100644 | ||
133 | --- a/target/arm/translate.c | ||
134 | +++ b/target/arm/translate.c | ||
135 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
136 | s->base.is_jmp = DISAS_NORETURN; | ||
137 | } | ||
138 | |||
139 | -static void gen_exception_insn(DisasContext *s, int offset, int excp, | ||
140 | +static void gen_exception_insn(DisasContext *s, uint32_t pc, int excp, | ||
141 | int syn, uint32_t target_el) | ||
142 | { | ||
143 | gen_set_condexec(s); | ||
144 | - gen_set_pc_im(s, s->base.pc_next - offset); | ||
145 | + gen_set_pc_im(s, pc); | ||
146 | gen_exception(excp, syn, target_el); | ||
147 | s->base.is_jmp = DISAS_NORETURN; | ||
148 | } | ||
149 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | - gen_exception_insn(s, s->thumb ? 2 : 4, EXCP_UDEF, syn_uncategorized(), | ||
154 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
155 | default_exception_el(s)); | ||
156 | } | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn, | ||
159 | |||
160 | undef: | ||
161 | /* If we get here then some access check did not pass */ | ||
162 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), exc_target); | ||
163 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
164 | + syn_uncategorized(), exc_target); | ||
165 | return false; | ||
166 | } | ||
167 | |||
168 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn) | ||
169 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
170 | */ | ||
171 | if (s->fp_excp_el) { | ||
172 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
173 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
174 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
175 | return 0; | ||
176 | } | ||
177 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | ||
178 | * for attempts to execute invalid vfp/neon encodings with FP disabled. | ||
179 | */ | ||
180 | if (s->fp_excp_el) { | ||
181 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
182 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
183 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
184 | return 0; | ||
185 | } | ||
186 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn) | ||
187 | } | ||
188 | |||
189 | if (s->fp_excp_el) { | ||
190 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
191 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
192 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
193 | return 0; | ||
194 | } | ||
195 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn) | ||
196 | off_rm = vfp_reg_offset(0, rm); | ||
197 | } | ||
198 | if (s->fp_excp_el) { | ||
199 | - gen_exception_insn(s, 4, EXCP_UDEF, | ||
200 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, | ||
201 | syn_simd_access_trap(1, 0xe, false), s->fp_excp_el); | ||
202 | return 0; | ||
203 | } | ||
204 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
205 | * For the UNPREDICTABLE cases we choose to UNDEF. | ||
206 | */ | ||
207 | if (s->current_el == 1 && !s->ns && mode == ARM_CPU_MODE_MON) { | ||
208 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), 3); | ||
209 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), 3); | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
214 | } | ||
215 | |||
216 | if (undef) { | ||
217 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
218 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
219 | default_exception_el(s)); | ||
220 | return; | ||
221 | } | ||
222 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
223 | * UsageFault exception. | ||
224 | */ | ||
225 | if (arm_dc_feature(s, ARM_FEATURE_M)) { | ||
226 | - gen_exception_insn(s, 4, EXCP_INVSTATE, syn_uncategorized(), | ||
227 | + gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(), | ||
228 | default_exception_el(s)); | ||
229 | return; | ||
230 | } | ||
231 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | ||
232 | break; | ||
233 | default: | ||
234 | illegal_op: | ||
235 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
236 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
237 | default_exception_el(s)); | ||
238 | break; | ||
239 | } | ||
240 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
241 | } | ||
242 | |||
243 | /* All other insns: NOCP */ | ||
244 | - gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(), | ||
245 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized(), | ||
246 | default_exception_el(s)); | ||
247 | break; | ||
248 | } | ||
249 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
250 | } | ||
251 | return; | ||
252 | illegal_op: | ||
253 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
254 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
255 | default_exception_el(s)); | ||
256 | } | ||
257 | |||
258 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
259 | return; | ||
260 | illegal_op: | ||
261 | undef: | ||
262 | - gen_exception_insn(s, 2, EXCP_UDEF, syn_uncategorized(), | ||
263 | + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
264 | default_exception_el(s)); | ||
265 | } | ||
266 | 183 | ||
267 | -- | 184 | -- |
268 | 2.20.1 | 185 | 2.25.1 |
269 | |||
270 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The helper function is more documentary, and also already | 3 | We set this for qemu-system-aarch64, but failed to do so |
4 | handles the case of rotate by zero. | 4 | for the strictly 32-bit emulation. |
5 | 5 | ||
6 | Fixes: 3bec78447a9 ("target/arm: Provide ARMv8.4-PMU in '-cpu max'") | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190808202616.13782-5-richard.henderson@linaro.org | 9 | Message-id: 20220506180242.216785-8-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/translate.c | 7 ++----- | 12 | target/arm/cpu_tcg.c | 4 ++++ |
12 | 1 file changed, 2 insertions(+), 5 deletions(-) | 13 | 1 file changed, 4 insertions(+) |
13 | 14 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 17 | --- a/target/arm/cpu_tcg.c |
17 | +++ b/target/arm/translate.c | 18 | +++ b/target/arm/cpu_tcg.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 19 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) |
19 | /* CPSR = immediate */ | 20 | t = FIELD_DP32(t, ID_PFR2, SSBS, 1); |
20 | val = insn & 0xff; | 21 | cpu->isar.id_pfr2 = t; |
21 | shift = ((insn >> 8) & 0xf) * 2; | 22 | |
22 | - if (shift) | 23 | + t = cpu->isar.id_dfr0; |
23 | - val = (val >> shift) | (val << (32 - shift)); | 24 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ |
24 | + val = ror32(val, shift); | 25 | + cpu->isar.id_dfr0 = t; |
25 | i = ((insn & (1 << 22)) != 0); | 26 | + |
26 | if (gen_set_psr_im(s, msr_mask(s, (insn >> 16) & 0xf, i), | 27 | #ifdef CONFIG_USER_ONLY |
27 | i, val)) { | 28 | /* |
28 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 29 | * Break with true ARMv8 and add back old-style VFP short-vector support. |
29 | /* immediate operand */ | ||
30 | val = insn & 0xff; | ||
31 | shift = ((insn >> 8) & 0xf) * 2; | ||
32 | - if (shift) { | ||
33 | - val = (val >> shift) | (val << (32 - shift)); | ||
34 | - } | ||
35 | + val = ror32(val, shift); | ||
36 | tmp2 = tcg_temp_new_i32(); | ||
37 | tcg_gen_movi_i32(tmp2, val); | ||
38 | if (logic_cc && shift) { | ||
39 | -- | 30 | -- |
40 | 2.20.1 | 31 | 2.25.1 |
41 | |||
42 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We currently have 3 different ways of computing the architectural | 3 | Share the code to set AArch32 max features so that we no |
4 | value of "PC" as seen in the ARM ARM. | 4 | longer have code drift between qemu{-system,}-{arm,aarch64}. |
5 | 5 | ||
6 | The value of s->pc has been incremented past the current insn, | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | but that is all. Thus for a32, PC = s->pc + 4; for t32, PC = s->pc; | ||
8 | for t16, PC = s->pc + 2. These differing computations make it | ||
9 | impossible at present to unify the various code paths. | ||
10 | |||
11 | With the newly introduced s->pc_curr, we can compute the correct | ||
12 | value for all cases, using the formula given in the ARM ARM. | ||
13 | |||
14 | This changes the behaviour for load_reg() and load_reg_var() | ||
15 | when called with reg==15 from a 32-bit Thumb instruction: | ||
16 | previously they would have returned the incorrect value | ||
17 | of pc_curr + 6, and now they will return the architecturally | ||
18 | correct value of PC, which is pc_curr + 4. This will not | ||
19 | affect well-behaved guest software, because all of the places | ||
20 | we call these functions from T32 code are instructions where | ||
21 | using r15 is UNPREDICTABLE. Using the architectural PC value | ||
22 | here is more consistent with the T16 and A32 behaviour. | ||
23 | |||
24 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20220506180242.216785-9-richard.henderson@linaro.org |
26 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
27 | Message-id: 20190807045335.1361-4-richard.henderson@linaro.org | ||
28 | [PMM: added commit message note about UNPREDICTABLE T32 cases] | ||
29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
30 | --- | 10 | --- |
31 | target/arm/translate.c | 59 ++++++++++++++++-------------------------- | 11 | target/arm/internals.h | 2 + |
32 | 1 file changed, 23 insertions(+), 36 deletions(-) | 12 | target/arm/cpu64.c | 50 +----------------- |
13 | target/arm/cpu_tcg.c | 114 ++++++++++++++++++++++------------------- | ||
14 | 3 files changed, 65 insertions(+), 101 deletions(-) | ||
33 | 15 | ||
34 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
35 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/translate.c | 18 | --- a/target/arm/internals.h |
37 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/internals.h |
38 | @@ -XXX,XX +XXX,XX @@ static inline void store_cpu_offset(TCGv_i32 var, int offset) | 20 | @@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } |
39 | #define store_cpu_field(var, name) \ | 21 | void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); |
40 | store_cpu_offset(var, offsetof(CPUARMState, name)) | 22 | #endif |
41 | 23 | ||
42 | +/* The architectural value of PC. */ | 24 | +void aa32_max_features(ARMCPU *cpu); |
43 | +static uint32_t read_pc(DisasContext *s) | 25 | + |
26 | #endif | ||
27 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/cpu64.c | ||
30 | +++ b/target/arm/cpu64.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
32 | { | ||
33 | ARMCPU *cpu = ARM_CPU(obj); | ||
34 | uint64_t t; | ||
35 | - uint32_t u; | ||
36 | |||
37 | if (kvm_enabled() || hvf_enabled()) { | ||
38 | /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ | ||
39 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
40 | t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); | ||
41 | cpu->isar.id_aa64zfr0 = t; | ||
42 | |||
43 | - /* Replicate the same data to the 32-bit id registers. */ | ||
44 | - u = cpu->isar.id_isar5; | ||
45 | - u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */ | ||
46 | - u = FIELD_DP32(u, ID_ISAR5, SHA1, 1); | ||
47 | - u = FIELD_DP32(u, ID_ISAR5, SHA2, 1); | ||
48 | - u = FIELD_DP32(u, ID_ISAR5, CRC32, 1); | ||
49 | - u = FIELD_DP32(u, ID_ISAR5, RDM, 1); | ||
50 | - u = FIELD_DP32(u, ID_ISAR5, VCMA, 1); | ||
51 | - cpu->isar.id_isar5 = u; | ||
52 | - | ||
53 | - u = cpu->isar.id_isar6; | ||
54 | - u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1); | ||
55 | - u = FIELD_DP32(u, ID_ISAR6, DP, 1); | ||
56 | - u = FIELD_DP32(u, ID_ISAR6, FHM, 1); | ||
57 | - u = FIELD_DP32(u, ID_ISAR6, SB, 1); | ||
58 | - u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); | ||
59 | - u = FIELD_DP32(u, ID_ISAR6, BF16, 1); | ||
60 | - u = FIELD_DP32(u, ID_ISAR6, I8MM, 1); | ||
61 | - cpu->isar.id_isar6 = u; | ||
62 | - | ||
63 | - u = cpu->isar.id_pfr0; | ||
64 | - u = FIELD_DP32(u, ID_PFR0, DIT, 1); | ||
65 | - cpu->isar.id_pfr0 = u; | ||
66 | - | ||
67 | - u = cpu->isar.id_pfr2; | ||
68 | - u = FIELD_DP32(u, ID_PFR2, SSBS, 1); | ||
69 | - cpu->isar.id_pfr2 = u; | ||
70 | - | ||
71 | - u = cpu->isar.id_mmfr3; | ||
72 | - u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
73 | - cpu->isar.id_mmfr3 = u; | ||
74 | - | ||
75 | - u = cpu->isar.id_mmfr4; | ||
76 | - u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
77 | - u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
78 | - u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
79 | - u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
80 | - cpu->isar.id_mmfr4 = u; | ||
81 | - | ||
82 | t = cpu->isar.id_aa64dfr0; | ||
83 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
84 | cpu->isar.id_aa64dfr0 = t; | ||
85 | |||
86 | - u = cpu->isar.id_dfr0; | ||
87 | - u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
88 | - cpu->isar.id_dfr0 = u; | ||
89 | - | ||
90 | - u = cpu->isar.mvfr1; | ||
91 | - u = FIELD_DP32(u, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
92 | - u = FIELD_DP32(u, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
93 | - cpu->isar.mvfr1 = u; | ||
94 | + /* Replicate the same data to the 32-bit id registers. */ | ||
95 | + aa32_max_features(cpu); | ||
96 | |||
97 | #ifdef CONFIG_USER_ONLY | ||
98 | /* | ||
99 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/arm/cpu_tcg.c | ||
102 | +++ b/target/arm/cpu_tcg.c | ||
103 | @@ -XXX,XX +XXX,XX @@ | ||
104 | #endif | ||
105 | #include "cpregs.h" | ||
106 | |||
107 | + | ||
108 | +/* Share AArch32 -cpu max features with AArch64. */ | ||
109 | +void aa32_max_features(ARMCPU *cpu) | ||
44 | +{ | 110 | +{ |
45 | + return s->pc_curr + (s->thumb ? 4 : 8); | 111 | + uint32_t t; |
112 | + | ||
113 | + /* Add additional features supported by QEMU */ | ||
114 | + t = cpu->isar.id_isar5; | ||
115 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
116 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
117 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
118 | + t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
119 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
120 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
121 | + cpu->isar.id_isar5 = t; | ||
122 | + | ||
123 | + t = cpu->isar.id_isar6; | ||
124 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
125 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
126 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
127 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
128 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
129 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
130 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
131 | + cpu->isar.id_isar6 = t; | ||
132 | + | ||
133 | + t = cpu->isar.mvfr1; | ||
134 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
135 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
136 | + cpu->isar.mvfr1 = t; | ||
137 | + | ||
138 | + t = cpu->isar.mvfr2; | ||
139 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
140 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
141 | + cpu->isar.mvfr2 = t; | ||
142 | + | ||
143 | + t = cpu->isar.id_mmfr3; | ||
144 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
145 | + cpu->isar.id_mmfr3 = t; | ||
146 | + | ||
147 | + t = cpu->isar.id_mmfr4; | ||
148 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
149 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
150 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
151 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
152 | + cpu->isar.id_mmfr4 = t; | ||
153 | + | ||
154 | + t = cpu->isar.id_pfr0; | ||
155 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
156 | + cpu->isar.id_pfr0 = t; | ||
157 | + | ||
158 | + t = cpu->isar.id_pfr2; | ||
159 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
160 | + cpu->isar.id_pfr2 = t; | ||
161 | + | ||
162 | + t = cpu->isar.id_dfr0; | ||
163 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
164 | + cpu->isar.id_dfr0 = t; | ||
46 | +} | 165 | +} |
47 | + | 166 | + |
48 | /* Set a variable to the value of a CPU register. */ | 167 | #ifndef CONFIG_USER_ONLY |
49 | static void load_reg_var(DisasContext *s, TCGv_i32 var, int reg) | 168 | static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
50 | { | 169 | { |
51 | if (reg == 15) { | 170 | @@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data) |
52 | - uint32_t addr; | 171 | static void arm_max_initfn(Object *obj) |
53 | - /* normally, since we updated PC, we need only to add one insn */ | 172 | { |
54 | - if (s->thumb) | 173 | ARMCPU *cpu = ARM_CPU(obj); |
55 | - addr = (long)s->pc + 2; | 174 | - uint32_t t; |
56 | - else | 175 | |
57 | - addr = (long)s->pc + 4; | 176 | /* aarch64_a57_initfn, advertising none of the aarch64 features */ |
58 | - tcg_gen_movi_i32(var, addr); | 177 | cpu->dtb_compatible = "arm,cortex-a57"; |
59 | + tcg_gen_movi_i32(var, read_pc(s)); | 178 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) |
60 | } else { | 179 | cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ |
61 | tcg_gen_mov_i32(var, cpu_R[reg]); | 180 | define_cortex_a72_a57_a53_cp_reginfo(cpu); |
62 | } | 181 | |
63 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 182 | - /* Add additional features supported by QEMU */ |
64 | /* branch link and change to thumb (blx <offset>) */ | 183 | - t = cpu->isar.id_isar5; |
65 | int32_t offset; | 184 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); |
66 | 185 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | |
67 | - val = (uint32_t)s->pc; | 186 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); |
68 | tmp = tcg_temp_new_i32(); | 187 | - t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); |
69 | - tcg_gen_movi_i32(tmp, val); | 188 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); |
70 | + tcg_gen_movi_i32(tmp, s->pc); | 189 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); |
71 | store_reg(s, 14, tmp); | 190 | - cpu->isar.id_isar5 = t; |
72 | /* Sign-extend the 24-bit offset */ | 191 | - |
73 | offset = (((int32_t)insn) << 8) >> 8; | 192 | - t = cpu->isar.id_isar6; |
74 | + val = read_pc(s); | 193 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); |
75 | /* offset * 4 + bit24 * 2 + (thumb bit) */ | 194 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); |
76 | val += (offset << 2) | ((insn >> 23) & 2) | 1; | 195 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); |
77 | - /* pipeline offset */ | 196 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); |
78 | - val += 4; | 197 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); |
79 | /* protected by ARCH(5); above, near the start of uncond block */ | 198 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); |
80 | gen_bx_im(s, val); | 199 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); |
81 | return; | 200 | - cpu->isar.id_isar6 = t; |
82 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 201 | - |
83 | } else { | 202 | - t = cpu->isar.mvfr1; |
84 | /* store */ | 203 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ |
85 | if (i == 15) { | 204 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ |
86 | - /* special case: r15 = PC + 8 */ | 205 | - cpu->isar.mvfr1 = t; |
87 | - val = (long)s->pc + 4; | 206 | - |
88 | tmp = tcg_temp_new_i32(); | 207 | - t = cpu->isar.mvfr2; |
89 | - tcg_gen_movi_i32(tmp, val); | 208 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ |
90 | + tcg_gen_movi_i32(tmp, read_pc(s)); | 209 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ |
91 | } else if (user) { | 210 | - cpu->isar.mvfr2 = t; |
92 | tmp = tcg_temp_new_i32(); | 211 | - |
93 | tmp2 = tcg_const_i32(i); | 212 | - t = cpu->isar.id_mmfr3; |
94 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 213 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ |
95 | int32_t offset; | 214 | - cpu->isar.id_mmfr3 = t; |
96 | 215 | - | |
97 | /* branch (and link) */ | 216 | - t = cpu->isar.id_mmfr4; |
98 | - val = (int32_t)s->pc; | 217 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ |
99 | if (insn & (1 << 24)) { | 218 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ |
100 | tmp = tcg_temp_new_i32(); | 219 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ |
101 | - tcg_gen_movi_i32(tmp, val); | 220 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ |
102 | + tcg_gen_movi_i32(tmp, s->pc); | 221 | - cpu->isar.id_mmfr4 = t; |
103 | store_reg(s, 14, tmp); | 222 | - |
104 | } | 223 | - t = cpu->isar.id_pfr0; |
105 | offset = sextract32(insn << 2, 0, 26); | 224 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); |
106 | - val += offset + 4; | 225 | - cpu->isar.id_pfr0 = t; |
107 | - gen_jmp(s, val); | 226 | - |
108 | + gen_jmp(s, read_pc(s) + offset); | 227 | - t = cpu->isar.id_pfr2; |
109 | } | 228 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); |
110 | break; | 229 | - cpu->isar.id_pfr2 = t; |
111 | case 0xc: | 230 | - |
112 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 231 | - t = cpu->isar.id_dfr0; |
113 | tcg_temp_free_i32(addr); | 232 | - t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ |
114 | } else if ((insn & (7 << 5)) == 0) { | 233 | - cpu->isar.id_dfr0 = t; |
115 | /* Table Branch. */ | 234 | + aa32_max_features(cpu); |
116 | - if (rn == 15) { | 235 | |
117 | - addr = tcg_temp_new_i32(); | 236 | #ifdef CONFIG_USER_ONLY |
118 | - tcg_gen_movi_i32(addr, s->pc); | 237 | /* |
119 | - } else { | ||
120 | - addr = load_reg(s, rn); | ||
121 | - } | ||
122 | + addr = load_reg(s, rn); | ||
123 | tmp = load_reg(s, rm); | ||
124 | tcg_gen_add_i32(addr, addr, tmp); | ||
125 | if (insn & (1 << 4)) { | ||
126 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | tcg_temp_free_i32(addr); | ||
129 | tcg_gen_shli_i32(tmp, tmp, 1); | ||
130 | - tcg_gen_addi_i32(tmp, tmp, s->pc); | ||
131 | + tcg_gen_addi_i32(tmp, tmp, read_pc(s)); | ||
132 | store_reg(s, 15, tmp); | ||
133 | } else { | ||
134 | bool is_lasr = false; | ||
135 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
136 | tcg_gen_movi_i32(cpu_R[14], s->pc | 1); | ||
137 | } | ||
138 | |||
139 | - offset += s->pc; | ||
140 | + offset += read_pc(s); | ||
141 | if (insn & (1 << 12)) { | ||
142 | /* b/bl */ | ||
143 | gen_jmp(s, offset); | ||
144 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
145 | offset |= (insn & (1 << 11)) << 8; | ||
146 | |||
147 | /* jump to the offset */ | ||
148 | - gen_jmp(s, s->pc + offset); | ||
149 | + gen_jmp(s, read_pc(s) + offset); | ||
150 | } | ||
151 | } else { | ||
152 | /* | ||
153 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
154 | if (insn & (1 << 11)) { | ||
155 | rd = (insn >> 8) & 7; | ||
156 | /* load pc-relative. Bit 1 of PC is ignored. */ | ||
157 | - val = s->pc + 2 + ((insn & 0xff) * 4); | ||
158 | + val = read_pc(s) + ((insn & 0xff) * 4); | ||
159 | val &= ~(uint32_t)2; | ||
160 | addr = tcg_temp_new_i32(); | ||
161 | tcg_gen_movi_i32(addr, val); | ||
162 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
163 | } else { | ||
164 | /* PC. bit 1 is ignored. */ | ||
165 | tmp = tcg_temp_new_i32(); | ||
166 | - tcg_gen_movi_i32(tmp, (s->pc + 2) & ~(uint32_t)2); | ||
167 | + tcg_gen_movi_i32(tmp, read_pc(s) & ~(uint32_t)2); | ||
168 | } | ||
169 | val = (insn & 0xff) * 4; | ||
170 | tcg_gen_addi_i32(tmp, tmp, val); | ||
171 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
172 | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, s->condlabel); | ||
173 | tcg_temp_free_i32(tmp); | ||
174 | offset = ((insn & 0xf8) >> 2) | (insn & 0x200) >> 3; | ||
175 | - val = (uint32_t)s->pc + 2; | ||
176 | - val += offset; | ||
177 | - gen_jmp(s, val); | ||
178 | + gen_jmp(s, read_pc(s) + offset); | ||
179 | break; | ||
180 | |||
181 | case 15: /* IT, nop-hint. */ | ||
182 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
183 | arm_skip_unless(s, cond); | ||
184 | |||
185 | /* jump to the offset */ | ||
186 | - val = (uint32_t)s->pc + 2; | ||
187 | + val = read_pc(s); | ||
188 | offset = ((int32_t)insn << 24) >> 24; | ||
189 | val += offset << 1; | ||
190 | gen_jmp(s, val); | ||
191 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
192 | break; | ||
193 | } | ||
194 | /* unconditional branch */ | ||
195 | - val = (uint32_t)s->pc; | ||
196 | + val = read_pc(s); | ||
197 | offset = ((int32_t)insn << 21) >> 21; | ||
198 | - val += (offset << 1) + 2; | ||
199 | + val += offset << 1; | ||
200 | gen_jmp(s, val); | ||
201 | break; | ||
202 | |||
203 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
204 | /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix */ | ||
205 | uint32_t uoffset = ((int32_t)insn << 21) >> 9; | ||
206 | |||
207 | - tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + uoffset); | ||
208 | + tcg_gen_movi_i32(cpu_R[14], read_pc(s) + uoffset); | ||
209 | } | ||
210 | break; | ||
211 | } | ||
212 | -- | 238 | -- |
213 | 2.20.1 | 239 | 2.25.1 |
214 | |||
215 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Separate shift + extract low will result in one extra insn | 3 | Update the legacy feature names to the current names. |
4 | for hosts like RISC-V, MIPS, and Sparc. | 4 | Provide feature names for id changes that were not marked. |
5 | Sort the field updates into increasing bitfield order. | ||
5 | 6 | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190808202616.13782-8-richard.henderson@linaro.org | 9 | Message-id: 20220506180242.216785-10-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/translate.c | 18 ++++++------------ | 12 | target/arm/cpu64.c | 100 +++++++++++++++++++++---------------------- |
12 | 1 file changed, 6 insertions(+), 12 deletions(-) | 13 | target/arm/cpu_tcg.c | 48 ++++++++++----------- |
14 | 2 files changed, 74 insertions(+), 74 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 18 | --- a/target/arm/cpu64.c |
17 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/cpu64.c |
18 | @@ -XXX,XX +XXX,XX @@ static int disas_iwmmxt_insn(DisasContext *s, uint32_t insn) | 20 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
19 | if (insn & ARM_CP_RW_BIT) { /* TMRRC */ | 21 | cpu->midr = t; |
20 | iwmmxt_load_reg(cpu_V0, wrd); | 22 | |
21 | tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0); | 23 | t = cpu->isar.id_aa64isar0; |
22 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | 24 | - t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ |
23 | - tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0); | 25 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); |
24 | + tcg_gen_extrh_i64_i32(cpu_R[rdhi], cpu_V0); | 26 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* SHA512 */ |
25 | } else { /* TMCRR */ | 27 | + t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ |
26 | tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]); | 28 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ |
27 | iwmmxt_store_reg(cpu_V0, wrd); | 29 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ |
28 | @@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn) | 30 | t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1); |
29 | if (insn & ARM_CP_RW_BIT) { /* MRA */ | 31 | - t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); |
30 | iwmmxt_load_reg(cpu_V0, acc); | 32 | - t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); |
31 | tcg_gen_extrl_i64_i32(cpu_R[rdlo], cpu_V0); | 33 | - t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); |
32 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | 34 | - t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); |
33 | - tcg_gen_extrl_i64_i32(cpu_R[rdhi], cpu_V0); | 35 | - t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); |
34 | + tcg_gen_extrh_i64_i32(cpu_R[rdhi], cpu_V0); | 36 | - t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); |
35 | tcg_gen_andi_i32(cpu_R[rdhi], cpu_R[rdhi], (1 << (40 - 32)) - 1); | 37 | - t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); |
36 | } else { /* MAR */ | 38 | - t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* v8.5-CondM */ |
37 | tcg_gen_concat_i32_i64(cpu_V0, cpu_R[rdlo], cpu_R[rdhi]); | 39 | - t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */ |
38 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 40 | - t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); |
39 | gen_helper_neon_narrow_high_u16(tmp, cpu_V0); | 41 | + t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */ |
40 | break; | 42 | + t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */ |
41 | case 2: | 43 | + t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */ |
42 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | 44 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); /* FEAT_SM3 */ |
43 | - tcg_gen_extrl_i64_i32(tmp, cpu_V0); | 45 | + t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); /* FEAT_SM4 */ |
44 | + tcg_gen_extrh_i64_i32(tmp, cpu_V0); | 46 | + t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); /* FEAT_DotProd */ |
45 | break; | 47 | + t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); /* FEAT_FHM */ |
46 | default: abort(); | 48 | + t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* FEAT_FlagM2 */ |
47 | } | 49 | + t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */ |
48 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) | 50 | + t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); /* FEAT_RNG */ |
49 | break; | 51 | cpu->isar.id_aa64isar0 = t; |
50 | case 2: | 52 | |
51 | tcg_gen_addi_i64(cpu_V0, cpu_V0, 1u << 31); | 53 | t = cpu->isar.id_aa64isar1; |
52 | - tcg_gen_shri_i64(cpu_V0, cpu_V0, 32); | 54 | - t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); |
53 | - tcg_gen_extrl_i64_i32(tmp, cpu_V0); | 55 | - t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); |
54 | + tcg_gen_extrh_i64_i32(tmp, cpu_V0); | 56 | - t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); |
55 | break; | 57 | - t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); |
56 | default: abort(); | 58 | - t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); |
57 | } | 59 | - t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); |
58 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | 60 | - t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); |
59 | tmp = tcg_temp_new_i32(); | 61 | - t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* ARMv8.4-RCPC */ |
60 | tcg_gen_extrl_i64_i32(tmp, tmp64); | 62 | - t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); |
61 | store_reg(s, rt, tmp); | 63 | + t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */ |
62 | - tcg_gen_shri_i64(tmp64, tmp64, 32); | 64 | + t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */ |
63 | tmp = tcg_temp_new_i32(); | 65 | + t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); /* FEAT_FCMA */ |
64 | - tcg_gen_extrl_i64_i32(tmp, tmp64); | 66 | + t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* FEAT_LRCPC2 */ |
65 | + tcg_gen_extrh_i64_i32(tmp, tmp64); | 67 | + t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); /* FEAT_FRINTTS */ |
66 | tcg_temp_free_i64(tmp64); | 68 | + t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */ |
67 | store_reg(s, rt2, tmp); | 69 | + t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */ |
68 | } else { | 70 | + t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */ |
69 | @@ -XXX,XX +XXX,XX @@ static void gen_storeq_reg(DisasContext *s, int rlow, int rhigh, TCGv_i64 val) | 71 | + t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */ |
70 | tcg_gen_extrl_i64_i32(tmp, val); | 72 | cpu->isar.id_aa64isar1 = t; |
71 | store_reg(s, rlow, tmp); | 73 | |
72 | tmp = tcg_temp_new_i32(); | 74 | t = cpu->isar.id_aa64pfr0; |
73 | - tcg_gen_shri_i64(val, val, 32); | 75 | + t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ |
74 | - tcg_gen_extrl_i64_i32(tmp, val); | 76 | + t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ |
75 | + tcg_gen_extrh_i64_i32(tmp, val); | 77 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); |
76 | store_reg(s, rhigh, tmp); | 78 | - t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); |
79 | - t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); | ||
80 | - t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); | ||
81 | - t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); | ||
82 | + t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | ||
83 | + t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | ||
84 | cpu->isar.id_aa64pfr0 = t; | ||
85 | |||
86 | t = cpu->isar.id_aa64pfr1; | ||
87 | - t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); | ||
88 | - t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); | ||
89 | + t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); /* FEAT_BTI */ | ||
90 | + t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); /* FEAT_SSBS2 */ | ||
91 | /* | ||
92 | * Begin with full support for MTE. This will be downgraded to MTE=0 | ||
93 | * during realize if the board provides no tag memory, much like | ||
94 | * we do for EL2 with the virtualization=on property. | ||
95 | */ | ||
96 | - t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); | ||
97 | + t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ | ||
98 | cpu->isar.id_aa64pfr1 = t; | ||
99 | |||
100 | t = cpu->isar.id_aa64mmfr0; | ||
101 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
102 | cpu->isar.id_aa64mmfr0 = t; | ||
103 | |||
104 | t = cpu->isar.id_aa64mmfr1; | ||
105 | - t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */ | ||
106 | - t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); | ||
107 | - t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); | ||
108 | - t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */ | ||
109 | - t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */ | ||
110 | - t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */ | ||
111 | + t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ | ||
112 | + t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ | ||
113 | + t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */ | ||
114 | + t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */ | ||
115 | + t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* FEAT_PAN2 */ | ||
116 | + t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ | ||
117 | cpu->isar.id_aa64mmfr1 = t; | ||
118 | |||
119 | t = cpu->isar.id_aa64mmfr2; | ||
120 | - t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); | ||
121 | - t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */ | ||
122 | - t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */ | ||
123 | - t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ | ||
124 | - t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
125 | - t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ | ||
126 | + t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */ | ||
127 | + t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */ | ||
128 | + t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ | ||
129 | + t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */ | ||
130 | + t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | ||
131 | + t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ | ||
132 | cpu->isar.id_aa64mmfr2 = t; | ||
133 | |||
134 | t = cpu->isar.id_aa64zfr0; | ||
135 | t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1); | ||
136 | - t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* PMULL */ | ||
137 | - t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); | ||
138 | - t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); | ||
139 | - t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); | ||
140 | - t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); | ||
141 | - t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); | ||
142 | - t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); | ||
143 | - t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); | ||
144 | + t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* FEAT_SVE_PMULL128 */ | ||
145 | + t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); /* FEAT_SVE_BitPerm */ | ||
146 | + t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); /* FEAT_BF16 */ | ||
147 | + t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); /* FEAT_SVE_SHA3 */ | ||
148 | + t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); /* FEAT_SVE_SM4 */ | ||
149 | + t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); /* FEAT_I8MM */ | ||
150 | + t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); /* FEAT_F32MM */ | ||
151 | + t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); /* FEAT_F64MM */ | ||
152 | cpu->isar.id_aa64zfr0 = t; | ||
153 | |||
154 | t = cpu->isar.id_aa64dfr0; | ||
155 | - t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */ | ||
156 | + t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ | ||
157 | cpu->isar.id_aa64dfr0 = t; | ||
158 | |||
159 | /* Replicate the same data to the 32-bit id registers. */ | ||
160 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
161 | index XXXXXXX..XXXXXXX 100644 | ||
162 | --- a/target/arm/cpu_tcg.c | ||
163 | +++ b/target/arm/cpu_tcg.c | ||
164 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
165 | |||
166 | /* Add additional features supported by QEMU */ | ||
167 | t = cpu->isar.id_isar5; | ||
168 | - t = FIELD_DP32(t, ID_ISAR5, AES, 2); | ||
169 | - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); | ||
170 | - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); | ||
171 | + t = FIELD_DP32(t, ID_ISAR5, AES, 2); /* FEAT_PMULL */ | ||
172 | + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); /* FEAT_SHA1 */ | ||
173 | + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); /* FEAT_SHA256 */ | ||
174 | t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); | ||
175 | - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); | ||
176 | - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); | ||
177 | + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); /* FEAT_RDM */ | ||
178 | + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); /* FEAT_FCMA */ | ||
179 | cpu->isar.id_isar5 = t; | ||
180 | |||
181 | t = cpu->isar.id_isar6; | ||
182 | - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
183 | - t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
184 | - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
185 | - t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
186 | - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
187 | - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
188 | - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
189 | + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); /* FEAT_JSCVT */ | ||
190 | + t = FIELD_DP32(t, ID_ISAR6, DP, 1); /* Feat_DotProd */ | ||
191 | + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); /* FEAT_FHM */ | ||
192 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); /* FEAT_SB */ | ||
193 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); /* FEAT_SPECRES */ | ||
194 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); /* FEAT_AA32BF16 */ | ||
195 | + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); /* FEAT_AA32I8MM */ | ||
196 | cpu->isar.id_isar6 = t; | ||
197 | |||
198 | t = cpu->isar.mvfr1; | ||
199 | - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */ | ||
200 | - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */ | ||
201 | + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* FEAT_FP16 */ | ||
202 | + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* FEAT_FP16 */ | ||
203 | cpu->isar.mvfr1 = t; | ||
204 | |||
205 | t = cpu->isar.mvfr2; | ||
206 | - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
207 | - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
208 | + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ | ||
209 | + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ | ||
210 | cpu->isar.mvfr2 = t; | ||
211 | |||
212 | t = cpu->isar.id_mmfr3; | ||
213 | - t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */ | ||
214 | + t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* FEAT_PAN2 */ | ||
215 | cpu->isar.id_mmfr3 = t; | ||
216 | |||
217 | t = cpu->isar.id_mmfr4; | ||
218 | - t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
219 | - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
220 | - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
221 | - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */ | ||
222 | + t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ | ||
223 | + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
224 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ | ||
225 | + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX*/ | ||
226 | cpu->isar.id_mmfr4 = t; | ||
227 | |||
228 | t = cpu->isar.id_pfr0; | ||
229 | - t = FIELD_DP32(t, ID_PFR0, DIT, 1); | ||
230 | + t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ | ||
231 | cpu->isar.id_pfr0 = t; | ||
232 | |||
233 | t = cpu->isar.id_pfr2; | ||
234 | - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); | ||
235 | + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */ | ||
236 | cpu->isar.id_pfr2 = t; | ||
237 | |||
238 | t = cpu->isar.id_dfr0; | ||
239 | - t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */ | ||
240 | + t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ | ||
241 | cpu->isar.id_dfr0 = t; | ||
77 | } | 242 | } |
78 | 243 | ||
79 | -- | 244 | -- |
80 | 2.20.1 | 245 | 2.25.1 |
81 | |||
82 | 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 function is used in two different contexts, and it will be | 3 | Use FIELD_DP{32,64} to manipulate id_pfr1 and id_aa64pfr0 |
4 | clearer if the function is given the address to which it applies. | 4 | during arm_cpu_realizefn. |
5 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20220506180242.216785-11-richard.henderson@linaro.org |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-2-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/translate.c | 14 +++++++------- | 11 | target/arm/cpu.c | 22 +++++++++++++--------- |
13 | 1 file changed, 7 insertions(+), 7 deletions(-) | 12 | 1 file changed, 13 insertions(+), 9 deletions(-) |
14 | 13 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 16 | --- a/target/arm/cpu.c |
18 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/cpu.c |
19 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
19 | */ | ||
20 | unset_feature(env, ARM_FEATURE_EL3); | ||
21 | |||
22 | - /* Disable the security extension feature bits in the processor feature | ||
23 | - * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12]. | ||
24 | + /* | ||
25 | + * Disable the security extension feature bits in the processor | ||
26 | + * feature registers as well. | ||
27 | */ | ||
28 | - cpu->isar.id_pfr1 &= ~0xf0; | ||
29 | - cpu->isar.id_aa64pfr0 &= ~0xf000; | ||
30 | + cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0); | ||
31 | + cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, | ||
32 | + ID_AA64PFR0, EL3, 0); | ||
20 | } | 33 | } |
21 | } | 34 | |
22 | 35 | if (!cpu->has_el2) { | |
23 | -static bool thumb_insn_is_16bit(DisasContext *s, uint32_t insn) | 36 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
24 | +static bool thumb_insn_is_16bit(DisasContext *s, uint32_t pc, uint32_t insn) | ||
25 | { | ||
26 | - /* Return true if this is a 16 bit instruction. We must be precise | ||
27 | - * about this (matching the decode). We assume that s->pc still | ||
28 | - * points to the first 16 bits of the insn. | ||
29 | + /* | ||
30 | + * Return true if this is a 16 bit instruction. We must be precise | ||
31 | + * about this (matching the decode). | ||
32 | */ | ||
33 | if ((insn >> 11) < 0x1d) { | ||
34 | /* Definitely a 16-bit instruction */ | ||
35 | @@ -XXX,XX +XXX,XX @@ static bool thumb_insn_is_16bit(DisasContext *s, uint32_t insn) | ||
36 | return false; | ||
37 | } | 37 | } |
38 | 38 | ||
39 | - if ((insn >> 11) == 0x1e && s->pc - s->page_start < TARGET_PAGE_SIZE - 3) { | 39 | if (!arm_feature(env, ARM_FEATURE_EL2)) { |
40 | + if ((insn >> 11) == 0x1e && pc - s->page_start < TARGET_PAGE_SIZE - 3) { | 40 | - /* Disable the hypervisor feature bits in the processor feature |
41 | /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix, and the suffix | 41 | - * registers if we don't have EL2. These are id_pfr1[15:12] and |
42 | * is not on the next page; we merge this into a 32-bit | 42 | - * id_aa64pfr0_el1[11:8]. |
43 | * insn. | 43 | + /* |
44 | @@ -XXX,XX +XXX,XX @@ static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | 44 | + * Disable the hypervisor feature bits in the processor feature |
45 | */ | 45 | + * registers if we don't have EL2. |
46 | uint16_t insn = arm_lduw_code(env, s->pc, s->sctlr_b); | 46 | */ |
47 | 47 | - cpu->isar.id_aa64pfr0 &= ~0xf00; | |
48 | - return !thumb_insn_is_16bit(s, insn); | 48 | - cpu->isar.id_pfr1 &= ~0xf000; |
49 | + return !thumb_insn_is_16bit(s, s->pc, insn); | 49 | + cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, |
50 | } | 50 | + ID_AA64PFR0, EL2, 0); |
51 | 51 | + cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, | |
52 | static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 52 | + ID_PFR1, VIRTUALIZATION, 0); |
53 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
54 | } | 53 | } |
55 | 54 | ||
56 | insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | 55 | #ifndef CONFIG_USER_ONLY |
57 | - is_16bit = thumb_insn_is_16bit(dc, insn); | ||
58 | + is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | ||
59 | dc->pc += 2; | ||
60 | if (!is_16bit) { | ||
61 | uint32_t insn2 = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
62 | -- | 56 | -- |
63 | 2.20.1 | 57 | 2.25.1 |
64 | |||
65 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The immediate shift generator functions already test for, | 3 | The only portion of FEAT_Debugv8p2 that is relevant to QEMU |
4 | and eliminate, the case of a shift by zero. | 4 | is CONTEXTIDR_EL2, which is also conditionally implemented |
5 | with FEAT_VHE. The rest of the debug extension concerns the | ||
6 | External debug interface, which is outside the scope of QEMU. | ||
5 | 7 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190808202616.13782-4-richard.henderson@linaro.org | 10 | Message-id: 20220506180242.216785-12-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | target/arm/translate.c | 19 +++++++------------ | 13 | docs/system/arm/emulation.rst | 1 + |
12 | 1 file changed, 7 insertions(+), 12 deletions(-) | 14 | target/arm/cpu.c | 1 + |
15 | target/arm/cpu64.c | 1 + | ||
16 | target/arm/cpu_tcg.c | 2 ++ | ||
17 | 4 files changed, 5 insertions(+) | ||
13 | 18 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 21 | --- a/docs/system/arm/emulation.rst |
17 | +++ b/target/arm/translate.c | 22 | +++ b/docs/system/arm/emulation.rst |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
19 | shift = (insn >> 10) & 3; | 24 | - FEAT_BTI (Branch Target Identification) |
20 | /* ??? In many cases it's not necessary to do a | 25 | - FEAT_DIT (Data Independent Timing instructions) |
21 | rotate, a shift is sufficient. */ | 26 | - FEAT_DPB (DC CVAP instruction) |
22 | - if (shift != 0) | 27 | +- FEAT_Debugv8p2 (Debug changes for v8.2) |
23 | - tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 28 | - FEAT_DotProd (Advanced SIMD dot product instructions) |
24 | + tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 29 | - FEAT_FCMA (Floating-point complex number instructions) |
25 | op1 = (insn >> 20) & 7; | 30 | - FEAT_FHM (Floating-point half-precision multiplication instructions) |
26 | switch (op1) { | 31 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
27 | case 0: gen_sxtb16(tmp); break; | 32 | index XXXXXXX..XXXXXXX 100644 |
28 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 33 | --- a/target/arm/cpu.c |
29 | shift = (insn >> 4) & 3; | 34 | +++ b/target/arm/cpu.c |
30 | /* ??? In many cases it's not necessary to do a | 35 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) |
31 | rotate, a shift is sufficient. */ | 36 | * feature registers as well. |
32 | - if (shift != 0) | 37 | */ |
33 | - tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 38 | cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0); |
34 | + tcg_gen_rotri_i32(tmp, tmp, shift * 8); | 39 | + cpu->isar.id_dfr0 = FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPSDBG, 0); |
35 | op = (insn >> 20) & 7; | 40 | cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0, |
36 | switch (op) { | 41 | ID_AA64PFR0, EL3, 0); |
37 | case 0: gen_sxth(tmp); break; | 42 | } |
38 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 43 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
39 | case 7: | 44 | index XXXXXXX..XXXXXXX 100644 |
40 | goto illegal_op; | 45 | --- a/target/arm/cpu64.c |
41 | default: /* Saturate. */ | 46 | +++ b/target/arm/cpu64.c |
42 | - if (shift) { | 47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
43 | - if (op & 1) | 48 | cpu->isar.id_aa64zfr0 = t; |
44 | - tcg_gen_sari_i32(tmp, tmp, shift); | 49 | |
45 | - else | 50 | t = cpu->isar.id_aa64dfr0; |
46 | - tcg_gen_shli_i32(tmp, tmp, shift); | 51 | + t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 8); /* FEAT_Debugv8p2 */ |
47 | + if (op & 1) { | 52 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ |
48 | + tcg_gen_sari_i32(tmp, tmp, shift); | 53 | cpu->isar.id_aa64dfr0 = t; |
49 | + } else { | 54 | |
50 | + tcg_gen_shli_i32(tmp, tmp, shift); | 55 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
51 | } | 56 | index XXXXXXX..XXXXXXX 100644 |
52 | tmp2 = tcg_const_i32(imm); | 57 | --- a/target/arm/cpu_tcg.c |
53 | if (op & 4) { | 58 | +++ b/target/arm/cpu_tcg.c |
54 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 59 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
55 | goto illegal_op; | 60 | cpu->isar.id_pfr2 = t; |
56 | } | 61 | |
57 | tmp = load_reg(s, rm); | 62 | t = cpu->isar.id_dfr0; |
58 | - if (shift) { | 63 | + t = FIELD_DP32(t, ID_DFR0, COPDBG, 8); /* FEAT_Debugv8p2 */ |
59 | - tcg_gen_shli_i32(tmp, tmp, shift); | 64 | + t = FIELD_DP32(t, ID_DFR0, COPSDBG, 8); /* FEAT_Debugv8p2 */ |
60 | - } | 65 | t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ |
61 | + tcg_gen_shli_i32(tmp, tmp, shift); | 66 | cpu->isar.id_dfr0 = t; |
62 | tcg_gen_add_i32(addr, addr, tmp); | 67 | } |
63 | tcg_temp_free_i32(tmp); | ||
64 | break; | ||
65 | -- | 68 | -- |
66 | 2.20.1 | 69 | 2.25.1 |
67 | |||
68 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use deposit as the composit operation to merge the | 3 | This extension concerns changes to the External Debug interface, |
4 | bits from the two inputs. | 4 | with Secure and Non-secure access to the debug registers, and all |
5 | of it is outside the scope of QEMU. Indicating support for this | ||
6 | is mandatory with FEAT_SEL2, which we do implement. | ||
5 | 7 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20190808202616.13782-3-richard.henderson@linaro.org | 10 | Message-id: 20220506180242.216785-13-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | target/arm/translate.c | 26 ++++++++++---------------- | 13 | docs/system/arm/emulation.rst | 1 + |
12 | 1 file changed, 10 insertions(+), 16 deletions(-) | 14 | target/arm/cpu64.c | 2 +- |
15 | target/arm/cpu_tcg.c | 4 ++-- | ||
16 | 3 files changed, 4 insertions(+), 3 deletions(-) | ||
13 | 17 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 18 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 20 | --- a/docs/system/arm/emulation.rst |
17 | +++ b/target/arm/translate.c | 21 | +++ b/docs/system/arm/emulation.rst |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 22 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
19 | shift = (insn >> 7) & 0x1f; | 23 | - FEAT_DIT (Data Independent Timing instructions) |
20 | if (insn & (1 << 6)) { | 24 | - FEAT_DPB (DC CVAP instruction) |
21 | /* pkhtb */ | 25 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
22 | - if (shift == 0) | 26 | +- FEAT_Debugv8p4 (Debug changes for v8.4) |
23 | + if (shift == 0) { | 27 | - FEAT_DotProd (Advanced SIMD dot product instructions) |
24 | shift = 31; | 28 | - FEAT_FCMA (Floating-point complex number instructions) |
25 | + } | 29 | - FEAT_FHM (Floating-point half-precision multiplication instructions) |
26 | tcg_gen_sari_i32(tmp2, tmp2, shift); | 30 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
27 | - tcg_gen_andi_i32(tmp, tmp, 0xffff0000); | 31 | index XXXXXXX..XXXXXXX 100644 |
28 | - tcg_gen_ext16u_i32(tmp2, tmp2); | 32 | --- a/target/arm/cpu64.c |
29 | + tcg_gen_deposit_i32(tmp, tmp, tmp2, 0, 16); | 33 | +++ b/target/arm/cpu64.c |
30 | } else { | 34 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
31 | /* pkhbt */ | 35 | cpu->isar.id_aa64zfr0 = t; |
32 | - if (shift) | 36 | |
33 | - tcg_gen_shli_i32(tmp2, tmp2, shift); | 37 | t = cpu->isar.id_aa64dfr0; |
34 | - tcg_gen_ext16u_i32(tmp, tmp); | 38 | - t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 8); /* FEAT_Debugv8p2 */ |
35 | - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); | 39 | + t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */ |
36 | + tcg_gen_shli_i32(tmp2, tmp2, shift); | 40 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */ |
37 | + tcg_gen_deposit_i32(tmp, tmp2, tmp, 0, 16); | 41 | cpu->isar.id_aa64dfr0 = t; |
38 | } | 42 | |
39 | - tcg_gen_or_i32(tmp, tmp, tmp2); | 43 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
40 | tcg_temp_free_i32(tmp2); | 44 | index XXXXXXX..XXXXXXX 100644 |
41 | store_reg(s, rd, tmp); | 45 | --- a/target/arm/cpu_tcg.c |
42 | } else if ((insn & 0x00200020) == 0x00200000) { | 46 | +++ b/target/arm/cpu_tcg.c |
43 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 47 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
44 | shift = ((insn >> 10) & 0x1c) | ((insn >> 6) & 0x3); | 48 | cpu->isar.id_pfr2 = t; |
45 | if (insn & (1 << 5)) { | 49 | |
46 | /* pkhtb */ | 50 | t = cpu->isar.id_dfr0; |
47 | - if (shift == 0) | 51 | - t = FIELD_DP32(t, ID_DFR0, COPDBG, 8); /* FEAT_Debugv8p2 */ |
48 | + if (shift == 0) { | 52 | - t = FIELD_DP32(t, ID_DFR0, COPSDBG, 8); /* FEAT_Debugv8p2 */ |
49 | shift = 31; | 53 | + t = FIELD_DP32(t, ID_DFR0, COPDBG, 9); /* FEAT_Debugv8p4 */ |
50 | + } | 54 | + t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */ |
51 | tcg_gen_sari_i32(tmp2, tmp2, shift); | 55 | t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */ |
52 | - tcg_gen_andi_i32(tmp, tmp, 0xffff0000); | 56 | cpu->isar.id_dfr0 = t; |
53 | - tcg_gen_ext16u_i32(tmp2, tmp2); | 57 | } |
54 | + tcg_gen_deposit_i32(tmp, tmp, tmp2, 0, 16); | ||
55 | } else { | ||
56 | /* pkhbt */ | ||
57 | - if (shift) | ||
58 | - tcg_gen_shli_i32(tmp2, tmp2, shift); | ||
59 | - tcg_gen_ext16u_i32(tmp, tmp); | ||
60 | - tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); | ||
61 | + tcg_gen_shli_i32(tmp2, tmp2, shift); | ||
62 | + tcg_gen_deposit_i32(tmp, tmp2, tmp, 0, 16); | ||
63 | } | ||
64 | - tcg_gen_or_i32(tmp, tmp, tmp2); | ||
65 | tcg_temp_free_i32(tmp2); | ||
66 | store_reg(s, rd, tmp); | ||
67 | } else { | ||
68 | -- | 58 | -- |
69 | 2.20.1 | 59 | 2.25.1 |
70 | |||
71 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Unless we're guaranteed to always increase ARM_MAX_VQ by a multiple of | 3 | Add only the system registers required to implement zero error |
4 | four, then we should use DIV_ROUND_UP to ensure we get an appropriate | 4 | records. This means that all values for ERRSELR are out of range, |
5 | array size. | 5 | which means that it and all of the indexed error record registers |
6 | need not be implemented. | ||
6 | 7 | ||
7 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 8 | Add the EL2 registers required for injecting virtual SError. |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20220506180242.216785-14-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 | target/arm/cpu.h | 2 +- | 15 | target/arm/cpu.h | 5 +++ |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | target/arm/helper.c | 84 +++++++++++++++++++++++++++++++++++++++++++++ |
17 | 2 files changed, 89 insertions(+) | ||
13 | 18 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 19 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
15 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 21 | --- a/target/arm/cpu.h |
17 | +++ b/target/arm/cpu.h | 22 | +++ b/target/arm/cpu.h |
18 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMVectorReg { | 23 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
19 | #ifdef TARGET_AARCH64 | 24 | uint64_t tfsr_el[4]; /* tfsre0_el1 is index 0. */ |
20 | /* In AArch32 mode, predicate registers do not exist at all. */ | 25 | uint64_t gcr_el1; |
21 | typedef struct ARMPredicateReg { | 26 | uint64_t rgsr_el1; |
22 | - uint64_t p[2 * ARM_MAX_VQ / 8] QEMU_ALIGNED(16); | 27 | + |
23 | + uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); | 28 | + /* Minimal RAS registers */ |
24 | } ARMPredicateReg; | 29 | + uint64_t disr_el1; |
25 | 30 | + uint64_t vdisr_el2; | |
26 | /* In AArch32 mode, PAC keys do not exist at all. */ | 31 | + uint64_t vsesr_el2; |
32 | } cp15; | ||
33 | |||
34 | struct { | ||
35 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/helper.c | ||
38 | +++ b/target/arm/helper.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { | ||
40 | .access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 }, | ||
41 | }; | ||
42 | |||
43 | +/* | ||
44 | + * Check for traps to RAS registers, which are controlled | ||
45 | + * by HCR_EL2.TERR and SCR_EL3.TERR. | ||
46 | + */ | ||
47 | +static CPAccessResult access_terr(CPUARMState *env, const ARMCPRegInfo *ri, | ||
48 | + bool isread) | ||
49 | +{ | ||
50 | + int el = arm_current_el(env); | ||
51 | + | ||
52 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_TERR)) { | ||
53 | + return CP_ACCESS_TRAP_EL2; | ||
54 | + } | ||
55 | + if (el < 3 && (env->cp15.scr_el3 & SCR_TERR)) { | ||
56 | + return CP_ACCESS_TRAP_EL3; | ||
57 | + } | ||
58 | + return CP_ACCESS_OK; | ||
59 | +} | ||
60 | + | ||
61 | +static uint64_t disr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
62 | +{ | ||
63 | + int el = arm_current_el(env); | ||
64 | + | ||
65 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) { | ||
66 | + return env->cp15.vdisr_el2; | ||
67 | + } | ||
68 | + if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) { | ||
69 | + return 0; /* RAZ/WI */ | ||
70 | + } | ||
71 | + return env->cp15.disr_el1; | ||
72 | +} | ||
73 | + | ||
74 | +static void disr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t val) | ||
75 | +{ | ||
76 | + int el = arm_current_el(env); | ||
77 | + | ||
78 | + if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) { | ||
79 | + env->cp15.vdisr_el2 = val; | ||
80 | + return; | ||
81 | + } | ||
82 | + if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) { | ||
83 | + return; /* RAZ/WI */ | ||
84 | + } | ||
85 | + env->cp15.disr_el1 = val; | ||
86 | +} | ||
87 | + | ||
88 | +/* | ||
89 | + * Minimal RAS implementation with no Error Records. | ||
90 | + * Which means that all of the Error Record registers: | ||
91 | + * ERXADDR_EL1 | ||
92 | + * ERXCTLR_EL1 | ||
93 | + * ERXFR_EL1 | ||
94 | + * ERXMISC0_EL1 | ||
95 | + * ERXMISC1_EL1 | ||
96 | + * ERXMISC2_EL1 | ||
97 | + * ERXMISC3_EL1 | ||
98 | + * ERXPFGCDN_EL1 (RASv1p1) | ||
99 | + * ERXPFGCTL_EL1 (RASv1p1) | ||
100 | + * ERXPFGF_EL1 (RASv1p1) | ||
101 | + * ERXSTATUS_EL1 | ||
102 | + * and | ||
103 | + * ERRSELR_EL1 | ||
104 | + * may generate UNDEFINED, which is the effect we get by not | ||
105 | + * listing them at all. | ||
106 | + */ | ||
107 | +static const ARMCPRegInfo minimal_ras_reginfo[] = { | ||
108 | + { .name = "DISR_EL1", .state = ARM_CP_STATE_BOTH, | ||
109 | + .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 1, .opc2 = 1, | ||
110 | + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.disr_el1), | ||
111 | + .readfn = disr_read, .writefn = disr_write, .raw_writefn = raw_write }, | ||
112 | + { .name = "ERRIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
113 | + .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 3, .opc2 = 0, | ||
114 | + .access = PL1_R, .accessfn = access_terr, | ||
115 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
116 | + { .name = "VDISR_EL2", .state = ARM_CP_STATE_BOTH, | ||
117 | + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 1, .opc2 = 1, | ||
118 | + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vdisr_el2) }, | ||
119 | + { .name = "VSESR_EL2", .state = ARM_CP_STATE_BOTH, | ||
120 | + .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 3, | ||
121 | + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vsesr_el2) }, | ||
122 | +}; | ||
123 | + | ||
124 | /* Return the exception level to which exceptions should be taken | ||
125 | * via SVEAccessTrap. If an exception should be routed through | ||
126 | * AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should | ||
127 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
128 | if (cpu_isar_feature(aa64_ssbs, cpu)) { | ||
129 | define_one_arm_cp_reg(cpu, &ssbs_reginfo); | ||
130 | } | ||
131 | + if (cpu_isar_feature(any_ras, cpu)) { | ||
132 | + define_arm_cp_regs(cpu, minimal_ras_reginfo); | ||
133 | + } | ||
134 | |||
135 | if (cpu_isar_feature(aa64_vh, cpu) || | ||
136 | cpu_isar_feature(aa64_debugv8p2, cpu)) { | ||
27 | -- | 137 | -- |
28 | 2.20.1 | 138 | 2.25.1 |
29 | |||
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 | The offset is variable depending on the instruction set. | 3 | Enable writes to the TERR and TEA bits when RAS is enabled. |
4 | Passing in the actual value is clearer in intent. | 4 | These bits are otherwise RES0. |
5 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20220506180242.216785-15-richard.henderson@linaro.org |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-9-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/translate-a64.c | 8 ++++---- | 11 | target/arm/helper.c | 9 +++++++++ |
13 | target/arm/translate.c | 8 ++++---- | 12 | 1 file changed, 9 insertions(+) |
14 | 2 files changed, 8 insertions(+), 8 deletions(-) | ||
15 | 13 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 16 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/translate-a64.c | 17 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal(int excp) | 18 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
21 | tcg_temp_free_i32(tcg_excp); | ||
22 | } | ||
23 | |||
24 | -static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
25 | +static void gen_exception_internal_insn(DisasContext *s, uint64_t pc, int excp) | ||
26 | { | ||
27 | - gen_a64_set_pc_im(s->base.pc_next - offset); | ||
28 | + gen_a64_set_pc_im(pc); | ||
29 | gen_exception_internal(excp); | ||
30 | s->base.is_jmp = DISAS_NORETURN; | ||
31 | } | ||
32 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
33 | break; | ||
34 | } | ||
35 | #endif | ||
36 | - gen_exception_internal_insn(s, 0, EXCP_SEMIHOST); | ||
37 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | ||
38 | } else { | ||
39 | unsupported_encoding(s, insn); | ||
40 | } | 19 | } |
41 | @@ -XXX,XX +XXX,XX @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | 20 | valid_mask &= ~SCR_NET; |
42 | /* End the TB early; it likely won't be executed */ | 21 | |
43 | dc->base.is_jmp = DISAS_TOO_MANY; | 22 | + if (cpu_isar_feature(aa64_ras, cpu)) { |
23 | + valid_mask |= SCR_TERR; | ||
24 | + } | ||
25 | if (cpu_isar_feature(aa64_lor, cpu)) { | ||
26 | valid_mask |= SCR_TLOR; | ||
27 | } | ||
28 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
29 | } | ||
44 | } else { | 30 | } else { |
45 | - gen_exception_internal_insn(dc, 0, EXCP_DEBUG); | 31 | valid_mask &= ~(SCR_RW | SCR_ST); |
46 | + gen_exception_internal_insn(dc, dc->base.pc_next, EXCP_DEBUG); | 32 | + if (cpu_isar_feature(aa32_ras, cpu)) { |
47 | /* The address covered by the breakpoint must be | 33 | + valid_mask |= SCR_TERR; |
48 | included in [tb->pc, tb->pc + tb->size) in order | 34 | + } |
49 | to for it to be properly cleared -- thus we | ||
50 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/translate.c | ||
53 | +++ b/target/arm/translate.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | ||
55 | s->base.is_jmp = DISAS_SMC; | ||
56 | } | ||
57 | |||
58 | -static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | ||
59 | +static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp) | ||
60 | { | ||
61 | gen_set_condexec(s); | ||
62 | - gen_set_pc_im(s, s->base.pc_next - offset); | ||
63 | + gen_set_pc_im(s, pc); | ||
64 | gen_exception_internal(excp); | ||
65 | s->base.is_jmp = DISAS_NORETURN; | ||
66 | } | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | ||
68 | s->current_el != 0 && | ||
69 | #endif | ||
70 | (imm == (s->thumb ? 0x3c : 0xf000))) { | ||
71 | - gen_exception_internal_insn(s, 0, EXCP_SEMIHOST); | ||
72 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | ||
73 | return; | ||
74 | } | 35 | } |
75 | 36 | ||
76 | @@ -XXX,XX +XXX,XX @@ static bool arm_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, | 37 | if (!arm_feature(env, ARM_FEATURE_EL2)) { |
77 | /* End the TB early; it's likely not going to be executed */ | 38 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) |
78 | dc->base.is_jmp = DISAS_TOO_MANY; | 39 | if (cpu_isar_feature(aa64_vh, cpu)) { |
79 | } else { | 40 | valid_mask |= HCR_E2H; |
80 | - gen_exception_internal_insn(dc, 0, EXCP_DEBUG); | 41 | } |
81 | + gen_exception_internal_insn(dc, dc->base.pc_next, EXCP_DEBUG); | 42 | + if (cpu_isar_feature(aa64_ras, cpu)) { |
82 | /* The address covered by the breakpoint must be | 43 | + valid_mask |= HCR_TERR | HCR_TEA; |
83 | included in [tb->pc, tb->pc + tb->size) in order | 44 | + } |
84 | to for it to be properly cleared -- thus we | 45 | if (cpu_isar_feature(aa64_lor, cpu)) { |
46 | valid_mask |= HCR_TLOR; | ||
47 | } | ||
85 | -- | 48 | -- |
86 | 2.20.1 | 49 | 2.25.1 |
87 | |||
88 | diff view generated by jsdifflib |
1 | When generating an architectural single-step exception we were | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | routing it to the "default exception level", which is to say | ||
3 | the same exception level we execute at except that EL0 exceptions | ||
4 | go to EL1. This is incorrect because the debug exception level | ||
5 | can be configured by the guest for situations such as single | ||
6 | stepping of EL0 and EL1 code by EL2. | ||
7 | 2 | ||
8 | We have to track the target debug exception level in the TB | 3 | Virtual SError exceptions are raised by setting HCR_EL2.VSE, |
9 | flags, because it is dependent on CPU state like HCR_EL2.TGE | 4 | and are routed to EL1 just like other virtual exceptions. |
10 | and MDCR_EL2.TDE. (That we were previously calling the | ||
11 | arm_debug_target_el() function to determine dc->ss_same_el | ||
12 | is itself a bug, though one that would only have manifested | ||
13 | as incorrect syndrome information.) Since we are out of TB | ||
14 | flag bits unless we want to expand into the cs_base field, | ||
15 | we share some bits with the M-profile only HANDLER and | ||
16 | STACKCHECK bits, since only A-profile has this singlestep. | ||
17 | 5 | ||
18 | Fixes: https://bugs.launchpad.net/qemu/+bug/1838913 | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220506180242.216785-16-richard.henderson@linaro.org | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
21 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
22 | Message-id: 20190805130952.4415-3-peter.maydell@linaro.org | ||
23 | --- | 10 | --- |
24 | target/arm/cpu.h | 5 +++++ | 11 | target/arm/cpu.h | 2 ++ |
25 | target/arm/translate.h | 15 +++++++++++---- | 12 | target/arm/internals.h | 8 ++++++++ |
26 | target/arm/helper.c | 6 ++++++ | 13 | target/arm/syndrome.h | 5 +++++ |
27 | target/arm/translate-a64.c | 2 +- | 14 | target/arm/cpu.c | 38 +++++++++++++++++++++++++++++++++++++- |
28 | target/arm/translate.c | 4 +++- | 15 | target/arm/helper.c | 40 +++++++++++++++++++++++++++++++++++++++- |
29 | 5 files changed, 26 insertions(+), 6 deletions(-) | 16 | 5 files changed, 91 insertions(+), 2 deletions(-) |
30 | 17 | ||
31 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 18 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
32 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/arm/cpu.h | 20 | --- a/target/arm/cpu.h |
34 | +++ b/target/arm/cpu.h | 21 | +++ b/target/arm/cpu.h |
35 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, PSTATE_SS, 26, 1) | 22 | @@ -XXX,XX +XXX,XX @@ |
36 | /* Target EL if we take a floating-point-disabled exception */ | 23 | #define EXCP_LSERR 21 /* v8M LSERR SecureFault */ |
37 | FIELD(TBFLAG_ANY, FPEXC_EL, 24, 2) | 24 | #define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */ |
38 | FIELD(TBFLAG_ANY, BE_DATA, 23, 1) | 25 | #define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */ |
39 | +/* | 26 | +#define EXCP_VSERR 24 |
40 | + * For A-profile only, target EL for debug exceptions. | 27 | /* NB: add new EXCP_ defines to the array in arm_log_exception() too */ |
41 | + * Note that this overlaps with the M-profile-only HANDLER and STACKCHECK bits. | 28 | |
29 | #define ARMV7M_EXCP_RESET 1 | ||
30 | @@ -XXX,XX +XXX,XX @@ enum { | ||
31 | #define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1 | ||
32 | #define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2 | ||
33 | #define CPU_INTERRUPT_VFIQ CPU_INTERRUPT_TGT_EXT_3 | ||
34 | +#define CPU_INTERRUPT_VSERR CPU_INTERRUPT_TGT_INT_0 | ||
35 | |||
36 | /* The usual mapping for an AArch64 system register to its AArch32 | ||
37 | * counterpart is for the 32 bit world to have access to the lower | ||
38 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/internals.h | ||
41 | +++ b/target/arm/internals.h | ||
42 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu); | ||
43 | */ | ||
44 | void arm_cpu_update_vfiq(ARMCPU *cpu); | ||
45 | |||
46 | +/** | ||
47 | + * arm_cpu_update_vserr: Update CPU_INTERRUPT_VSERR bit | ||
48 | + * | ||
49 | + * Update the CPU_INTERRUPT_VSERR bit in cs->interrupt_request, | ||
50 | + * following a change to the HCR_EL2.VSE bit. | ||
42 | + */ | 51 | + */ |
43 | +FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 21, 2) | 52 | +void arm_cpu_update_vserr(ARMCPU *cpu); |
44 | 53 | + | |
45 | /* Bit usage when in AArch32 state: */ | 54 | /** |
46 | FIELD(TBFLAG_A32, THUMB, 0, 1) | 55 | * arm_mmu_idx_el: |
47 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 56 | * @env: The cpu environment |
48 | index XXXXXXX..XXXXXXX 100644 | 57 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h |
49 | --- a/target/arm/translate.h | 58 | index XXXXXXX..XXXXXXX 100644 |
50 | +++ b/target/arm/translate.h | 59 | --- a/target/arm/syndrome.h |
51 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 60 | +++ b/target/arm/syndrome.h |
52 | uint32_t svc_imm; | 61 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_pcalignment(void) |
53 | int aarch64; | 62 | return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL; |
54 | int current_el; | 63 | } |
55 | + /* Debug target exception level for single-step exceptions */ | 64 | |
56 | + int debug_target_el; | 65 | +static inline uint32_t syn_serror(uint32_t extra) |
57 | GHashTable *cp_regs; | 66 | +{ |
58 | uint64_t features; /* CPU features bits */ | 67 | + return (EC_SERROR << ARM_EL_EC_SHIFT) | ARM_EL_IL | extra; |
59 | /* Because unallocated encodings generate different exception syndrome | 68 | +} |
60 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 69 | + |
61 | * ie A64 LDX*, LDAX*, A32/T32 LDREX*, LDAEX*. | 70 | #endif /* TARGET_ARM_SYNDROME_H */ |
62 | */ | 71 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
63 | bool is_ldex; | 72 | index XXXXXXX..XXXXXXX 100644 |
64 | - /* True if a single-step exception will be taken to the current EL */ | 73 | --- a/target/arm/cpu.c |
65 | - bool ss_same_el; | 74 | +++ b/target/arm/cpu.c |
66 | /* True if v8.3-PAuth is active. */ | 75 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs) |
67 | bool pauth_active; | 76 | return (cpu->power_state != PSCI_OFF) |
68 | /* True with v8.5-BTI and SCTLR_ELx.BT* set. */ | 77 | && cs->interrupt_request & |
69 | @@ -XXX,XX +XXX,XX @@ static inline void gen_exception(int excp, uint32_t syndrome, | 78 | (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD |
70 | /* Generate an architectural singlestep exception */ | 79 | - | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ |
71 | static inline void gen_swstep_exception(DisasContext *s, int isv, int ex) | 80 | + | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR |
81 | | CPU_INTERRUPT_EXITTB); | ||
82 | } | ||
83 | |||
84 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
85 | return false; | ||
86 | } | ||
87 | return !(env->daif & PSTATE_I); | ||
88 | + case EXCP_VSERR: | ||
89 | + if (!(hcr_el2 & HCR_AMO) || (hcr_el2 & HCR_TGE)) { | ||
90 | + /* VIRQs are only taken when hypervized. */ | ||
91 | + return false; | ||
92 | + } | ||
93 | + return !(env->daif & PSTATE_A); | ||
94 | default: | ||
95 | g_assert_not_reached(); | ||
96 | } | ||
97 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
98 | goto found; | ||
99 | } | ||
100 | } | ||
101 | + if (interrupt_request & CPU_INTERRUPT_VSERR) { | ||
102 | + excp_idx = EXCP_VSERR; | ||
103 | + target_el = 1; | ||
104 | + if (arm_excp_unmasked(cs, excp_idx, target_el, | ||
105 | + cur_el, secure, hcr_el2)) { | ||
106 | + /* Taking a virtual abort clears HCR_EL2.VSE */ | ||
107 | + env->cp15.hcr_el2 &= ~HCR_VSE; | ||
108 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); | ||
109 | + goto found; | ||
110 | + } | ||
111 | + } | ||
112 | return false; | ||
113 | |||
114 | found: | ||
115 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu) | ||
116 | } | ||
117 | } | ||
118 | |||
119 | +void arm_cpu_update_vserr(ARMCPU *cpu) | ||
120 | +{ | ||
121 | + /* | ||
122 | + * Update the interrupt level for VSERR, which is the HCR_EL2.VSE bit. | ||
123 | + */ | ||
124 | + CPUARMState *env = &cpu->env; | ||
125 | + CPUState *cs = CPU(cpu); | ||
126 | + | ||
127 | + bool new_state = env->cp15.hcr_el2 & HCR_VSE; | ||
128 | + | ||
129 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VSERR) != 0)) { | ||
130 | + if (new_state) { | ||
131 | + cpu_interrupt(cs, CPU_INTERRUPT_VSERR); | ||
132 | + } else { | ||
133 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR); | ||
134 | + } | ||
135 | + } | ||
136 | +} | ||
137 | + | ||
138 | #ifndef CONFIG_USER_ONLY | ||
139 | static void arm_cpu_set_irq(void *opaque, int irq, int level) | ||
72 | { | 140 | { |
73 | - gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, isv, ex), | ||
74 | - default_exception_el(s)); | ||
75 | + bool same_el = (s->debug_target_el == s->current_el); | ||
76 | + | ||
77 | + /* | ||
78 | + * If singlestep is targeting a lower EL than the current one, | ||
79 | + * then s->ss_active must be false and we can never get here. | ||
80 | + */ | ||
81 | + assert(s->debug_target_el >= s->current_el); | ||
82 | + | ||
83 | + gen_exception(EXCP_UDEF, syn_swstep(same_el, isv, ex), s->debug_target_el); | ||
84 | } | ||
85 | |||
86 | /* | ||
87 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 141 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
88 | index XXXXXXX..XXXXXXX 100644 | 142 | index XXXXXXX..XXXXXXX 100644 |
89 | --- a/target/arm/helper.c | 143 | --- a/target/arm/helper.c |
90 | +++ b/target/arm/helper.c | 144 | +++ b/target/arm/helper.c |
91 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 145 | @@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
92 | } | 146 | } |
93 | } | 147 | } |
94 | 148 | ||
95 | + if (!arm_feature(env, ARM_FEATURE_M)) { | 149 | - /* External aborts are not possible in QEMU so A bit is always clear */ |
96 | + int target_el = arm_debug_target_el(env); | 150 | + if (hcr_el2 & HCR_AMO) { |
97 | + | 151 | + if (cs->interrupt_request & CPU_INTERRUPT_VSERR) { |
98 | + flags = FIELD_DP32(flags, TBFLAG_ANY, DEBUG_TARGET_EL, target_el); | 152 | + ret |= CPSR_A; |
153 | + } | ||
99 | + } | 154 | + } |
100 | + | 155 | + |
101 | *pflags = flags; | 156 | return ret; |
102 | *cs_base = 0; | 157 | } |
103 | } | 158 | |
104 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 159 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) |
105 | index XXXXXXX..XXXXXXX 100644 | 160 | g_assert(qemu_mutex_iothread_locked()); |
106 | --- a/target/arm/translate-a64.c | 161 | arm_cpu_update_virq(cpu); |
107 | +++ b/target/arm/translate-a64.c | 162 | arm_cpu_update_vfiq(cpu); |
108 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 163 | + arm_cpu_update_vserr(cpu); |
109 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | 164 | } |
110 | dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | 165 | |
111 | dc->is_ldex = false; | 166 | static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) |
112 | - dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el); | 167 | @@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs) |
113 | + dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | 168 | [EXCP_LSERR] = "v8M LSERR UsageFault", |
114 | 169 | [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault", | |
115 | /* Bound the number of insns to execute to those left on the page. */ | 170 | [EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault", |
116 | bound = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4; | 171 | + [EXCP_VSERR] = "Virtual SERR", |
117 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 172 | }; |
118 | index XXXXXXX..XXXXXXX 100644 | 173 | |
119 | --- a/target/arm/translate.c | 174 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { |
120 | +++ b/target/arm/translate.c | 175 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) |
121 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) | 176 | mask = CPSR_A | CPSR_I | CPSR_F; |
122 | dc->ss_active = FIELD_EX32(tb_flags, TBFLAG_ANY, SS_ACTIVE); | 177 | offset = 4; |
123 | dc->pstate_ss = FIELD_EX32(tb_flags, TBFLAG_ANY, PSTATE_SS); | 178 | break; |
124 | dc->is_ldex = false; | 179 | + case EXCP_VSERR: |
125 | - dc->ss_same_el = false; /* Can't be true since EL_d must be AArch64 */ | 180 | + { |
126 | + if (!arm_feature(env, ARM_FEATURE_M)) { | 181 | + /* |
127 | + dc->debug_target_el = FIELD_EX32(tb_flags, TBFLAG_ANY, DEBUG_TARGET_EL); | 182 | + * Note that this is reported as a data abort, but the DFAR |
128 | + } | 183 | + * has an UNKNOWN value. Construct the SError syndrome from |
129 | 184 | + * AET and ExT fields. | |
130 | dc->page_start = dc->base.pc_first & TARGET_PAGE_MASK; | 185 | + */ |
131 | 186 | + ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal, }; | |
187 | + | ||
188 | + if (extended_addresses_enabled(env)) { | ||
189 | + env->exception.fsr = arm_fi_to_lfsc(&fi); | ||
190 | + } else { | ||
191 | + env->exception.fsr = arm_fi_to_sfsc(&fi); | ||
192 | + } | ||
193 | + env->exception.fsr |= env->cp15.vsesr_el2 & 0xd000; | ||
194 | + A32_BANKED_CURRENT_REG_SET(env, dfsr, env->exception.fsr); | ||
195 | + qemu_log_mask(CPU_LOG_INT, "...with IFSR 0x%x\n", | ||
196 | + env->exception.fsr); | ||
197 | + | ||
198 | + new_mode = ARM_CPU_MODE_ABT; | ||
199 | + addr = 0x10; | ||
200 | + mask = CPSR_A | CPSR_I; | ||
201 | + offset = 8; | ||
202 | + } | ||
203 | + break; | ||
204 | case EXCP_SMC: | ||
205 | new_mode = ARM_CPU_MODE_MON; | ||
206 | addr = 0x08; | ||
207 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | ||
208 | case EXCP_VFIQ: | ||
209 | addr += 0x100; | ||
210 | break; | ||
211 | + case EXCP_VSERR: | ||
212 | + addr += 0x180; | ||
213 | + /* Construct the SError syndrome from IDS and ISS fields. */ | ||
214 | + env->exception.syndrome = syn_serror(env->cp15.vsesr_el2 & 0x1ffffff); | ||
215 | + env->cp15.esr_el[new_el] = env->exception.syndrome; | ||
216 | + break; | ||
217 | default: | ||
218 | cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); | ||
219 | } | ||
132 | -- | 220 | -- |
133 | 2.20.1 | 221 | 2.25.1 |
134 | |||
135 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Replace x = double_saturate(y) with x = add_saturate(y, y). | 3 | Check for and defer any pending virtual SError. |
4 | There is no need for a separate more specialized helper. | ||
5 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-id: 20220506180242.216785-17-richard.henderson@linaro.org |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-12-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/helper.h | 1 - | 10 | target/arm/helper.h | 1 + |
13 | target/arm/op_helper.c | 15 --------------- | 11 | target/arm/a32.decode | 16 ++++++++------ |
14 | target/arm/translate.c | 4 ++-- | 12 | target/arm/t32.decode | 18 ++++++++-------- |
15 | 3 files changed, 2 insertions(+), 18 deletions(-) | 13 | target/arm/op_helper.c | 43 ++++++++++++++++++++++++++++++++++++++ |
14 | target/arm/translate-a64.c | 17 +++++++++++++++ | ||
15 | target/arm/translate.c | 23 ++++++++++++++++++++ | ||
16 | 6 files changed, 103 insertions(+), 15 deletions(-) | ||
16 | 17 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 18 | diff --git a/target/arm/helper.h b/target/arm/helper.h |
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 20 | --- a/target/arm/helper.h |
20 | +++ b/target/arm/helper.h | 21 | +++ b/target/arm/helper.h |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(add_saturate, i32, env, i32, i32) | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_1(wfe, void, env) |
22 | DEF_HELPER_3(sub_saturate, i32, env, i32, i32) | 23 | DEF_HELPER_1(yield, void, env) |
23 | DEF_HELPER_3(add_usaturate, i32, env, i32, i32) | 24 | DEF_HELPER_1(pre_hvc, void, env) |
24 | DEF_HELPER_3(sub_usaturate, i32, env, i32, i32) | 25 | DEF_HELPER_2(pre_smc, void, env, i32) |
25 | -DEF_HELPER_2(double_saturate, i32, env, s32) | 26 | +DEF_HELPER_1(vesb, void, env) |
26 | DEF_HELPER_FLAGS_2(sdiv, TCG_CALL_NO_RWG_SE, s32, s32, s32) | 27 | |
27 | DEF_HELPER_FLAGS_2(udiv, TCG_CALL_NO_RWG_SE, i32, i32, i32) | 28 | DEF_HELPER_3(cpsr_write, void, env, i32, i32) |
28 | DEF_HELPER_FLAGS_1(rbit, TCG_CALL_NO_RWG_SE, i32, i32) | 29 | DEF_HELPER_2(cpsr_write_eret, void, env, i32) |
30 | diff --git a/target/arm/a32.decode b/target/arm/a32.decode | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/a32.decode | ||
33 | +++ b/target/arm/a32.decode | ||
34 | @@ -XXX,XX +XXX,XX @@ SMULTT .... 0001 0110 .... 0000 .... 1110 .... @rd0mn | ||
35 | |||
36 | { | ||
37 | { | ||
38 | - YIELD ---- 0011 0010 0000 1111 ---- 0000 0001 | ||
39 | - WFE ---- 0011 0010 0000 1111 ---- 0000 0010 | ||
40 | - WFI ---- 0011 0010 0000 1111 ---- 0000 0011 | ||
41 | + [ | ||
42 | + YIELD ---- 0011 0010 0000 1111 ---- 0000 0001 | ||
43 | + WFE ---- 0011 0010 0000 1111 ---- 0000 0010 | ||
44 | + WFI ---- 0011 0010 0000 1111 ---- 0000 0011 | ||
45 | |||
46 | - # TODO: Implement SEV, SEVL; may help SMP performance. | ||
47 | - # SEV ---- 0011 0010 0000 1111 ---- 0000 0100 | ||
48 | - # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101 | ||
49 | + # TODO: Implement SEV, SEVL; may help SMP performance. | ||
50 | + # SEV ---- 0011 0010 0000 1111 ---- 0000 0100 | ||
51 | + # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101 | ||
52 | + | ||
53 | + ESB ---- 0011 0010 0000 1111 ---- 0001 0000 | ||
54 | + ] | ||
55 | |||
56 | # The canonical nop ends in 00000000, but the whole of the | ||
57 | # rest of the space executes as nop if otherwise unsupported. | ||
58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/t32.decode | ||
61 | +++ b/target/arm/t32.decode | ||
62 | @@ -XXX,XX +XXX,XX @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 .... @rdm | ||
63 | [ | ||
64 | # Hints, and CPS | ||
65 | { | ||
66 | - YIELD 1111 0011 1010 1111 1000 0000 0000 0001 | ||
67 | - WFE 1111 0011 1010 1111 1000 0000 0000 0010 | ||
68 | - WFI 1111 0011 1010 1111 1000 0000 0000 0011 | ||
69 | + [ | ||
70 | + YIELD 1111 0011 1010 1111 1000 0000 0000 0001 | ||
71 | + WFE 1111 0011 1010 1111 1000 0000 0000 0010 | ||
72 | + WFI 1111 0011 1010 1111 1000 0000 0000 0011 | ||
73 | |||
74 | - # TODO: Implement SEV, SEVL; may help SMP performance. | ||
75 | - # SEV 1111 0011 1010 1111 1000 0000 0000 0100 | ||
76 | - # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 | ||
77 | + # TODO: Implement SEV, SEVL; may help SMP performance. | ||
78 | + # SEV 1111 0011 1010 1111 1000 0000 0000 0100 | ||
79 | + # SEVL 1111 0011 1010 1111 1000 0000 0000 0101 | ||
80 | |||
81 | - # For M-profile minimal-RAS ESB can be a NOP, which is the | ||
82 | - # default behaviour since it is in the hint space. | ||
83 | - # ESB 1111 0011 1010 1111 1000 0000 0001 0000 | ||
84 | + ESB 1111 0011 1010 1111 1000 0000 0001 0000 | ||
85 | + ] | ||
86 | |||
87 | # The canonical nop ends in 0000 0000, but the whole rest | ||
88 | # of the space is "reserved hint, behaves as nop". | ||
29 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | 89 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
30 | index XXXXXXX..XXXXXXX 100644 | 90 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/op_helper.c | 91 | --- a/target/arm/op_helper.c |
32 | +++ b/target/arm/op_helper.c | 92 | +++ b/target/arm/op_helper.c |
33 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sub_saturate)(CPUARMState *env, uint32_t a, uint32_t b) | 93 | @@ -XXX,XX +XXX,XX @@ void HELPER(probe_access)(CPUARMState *env, target_ulong ptr, |
34 | return res; | 94 | access_type, mmu_idx, ra); |
95 | } | ||
35 | } | 96 | } |
36 | 97 | + | |
37 | -uint32_t HELPER(double_saturate)(CPUARMState *env, int32_t val) | 98 | +/* |
38 | -{ | 99 | + * This function corresponds to AArch64.vESBOperation(). |
39 | - uint32_t res; | 100 | + * Note that the AArch32 version is not functionally different. |
40 | - if (val >= 0x40000000) { | 101 | + */ |
41 | - res = ~SIGNBIT; | 102 | +void HELPER(vesb)(CPUARMState *env) |
42 | - env->QF = 1; | 103 | +{ |
43 | - } else if (val <= (int32_t)0xc0000000) { | 104 | + /* |
44 | - res = SIGNBIT; | 105 | + * The EL2Enabled() check is done inside arm_hcr_el2_eff, |
45 | - env->QF = 1; | 106 | + * and will return HCR_EL2.VSE == 0, so nothing happens. |
46 | - } else { | 107 | + */ |
47 | - res = val << 1; | 108 | + uint64_t hcr = arm_hcr_el2_eff(env); |
48 | - } | 109 | + bool enabled = !(hcr & HCR_TGE) && (hcr & HCR_AMO); |
49 | - return res; | 110 | + bool pending = enabled && (hcr & HCR_VSE); |
50 | -} | 111 | + bool masked = (env->daif & PSTATE_A); |
51 | - | 112 | + |
52 | uint32_t HELPER(add_usaturate)(CPUARMState *env, uint32_t a, uint32_t b) | 113 | + /* If VSE pending and masked, defer the exception. */ |
53 | { | 114 | + if (pending && masked) { |
54 | uint32_t res = a + b; | 115 | + uint32_t syndrome; |
116 | + | ||
117 | + if (arm_el_is_aa64(env, 1)) { | ||
118 | + /* Copy across IDS and ISS from VSESR. */ | ||
119 | + syndrome = env->cp15.vsesr_el2 & 0x1ffffff; | ||
120 | + } else { | ||
121 | + ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal }; | ||
122 | + | ||
123 | + if (extended_addresses_enabled(env)) { | ||
124 | + syndrome = arm_fi_to_lfsc(&fi); | ||
125 | + } else { | ||
126 | + syndrome = arm_fi_to_sfsc(&fi); | ||
127 | + } | ||
128 | + /* Copy across AET and ExT from VSESR. */ | ||
129 | + syndrome |= env->cp15.vsesr_el2 & 0xd000; | ||
130 | + } | ||
131 | + | ||
132 | + /* Set VDISR_EL2.A along with the syndrome. */ | ||
133 | + env->cp15.vdisr_el2 = syndrome | (1u << 31); | ||
134 | + | ||
135 | + /* Clear pending virtual SError */ | ||
136 | + env->cp15.hcr_el2 &= ~HCR_VSE; | ||
137 | + cpu_reset_interrupt(env_cpu(env), CPU_INTERRUPT_VSERR); | ||
138 | + } | ||
139 | +} | ||
140 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
141 | index XXXXXXX..XXXXXXX 100644 | ||
142 | --- a/target/arm/translate-a64.c | ||
143 | +++ b/target/arm/translate-a64.c | ||
144 | @@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn, | ||
145 | gen_helper_autib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
146 | } | ||
147 | break; | ||
148 | + case 0b10000: /* ESB */ | ||
149 | + /* Without RAS, we must implement this as NOP. */ | ||
150 | + if (dc_isar_feature(aa64_ras, s)) { | ||
151 | + /* | ||
152 | + * QEMU does not have a source of physical SErrors, | ||
153 | + * so we are only concerned with virtual SErrors. | ||
154 | + * The pseudocode in the ARM for this case is | ||
155 | + * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then | ||
156 | + * AArch64.vESBOperation(); | ||
157 | + * Most of the condition can be evaluated at translation time. | ||
158 | + * Test for EL2 present, and defer test for SEL2 to runtime. | ||
159 | + */ | ||
160 | + if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) { | ||
161 | + gen_helper_vesb(cpu_env); | ||
162 | + } | ||
163 | + } | ||
164 | + break; | ||
165 | case 0b11000: /* PACIAZ */ | ||
166 | if (s->pauth_active) { | ||
167 | gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], | ||
55 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 168 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
56 | index XXXXXXX..XXXXXXX 100644 | 169 | index XXXXXXX..XXXXXXX 100644 |
57 | --- a/target/arm/translate.c | 170 | --- a/target/arm/translate.c |
58 | +++ b/target/arm/translate.c | 171 | +++ b/target/arm/translate.c |
59 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 172 | @@ -XXX,XX +XXX,XX @@ static bool trans_WFI(DisasContext *s, arg_WFI *a) |
60 | tmp = load_reg(s, rm); | 173 | return true; |
61 | tmp2 = load_reg(s, rn); | 174 | } |
62 | if (op1 & 2) | 175 | |
63 | - gen_helper_double_saturate(tmp2, cpu_env, tmp2); | 176 | +static bool trans_ESB(DisasContext *s, arg_ESB *a) |
64 | + gen_helper_add_saturate(tmp2, cpu_env, tmp2, tmp2); | 177 | +{ |
65 | if (op1 & 1) | 178 | + /* |
66 | gen_helper_sub_saturate(tmp, cpu_env, tmp, tmp2); | 179 | + * For M-profile, minimal-RAS ESB can be a NOP. |
67 | else | 180 | + * Without RAS, we must implement this as NOP. |
68 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 181 | + */ |
69 | tmp = load_reg(s, rn); | 182 | + if (!arm_dc_feature(s, ARM_FEATURE_M) && dc_isar_feature(aa32_ras, s)) { |
70 | tmp2 = load_reg(s, rm); | 183 | + /* |
71 | if (op & 1) | 184 | + * QEMU does not have a source of physical SErrors, |
72 | - gen_helper_double_saturate(tmp, cpu_env, tmp); | 185 | + * so we are only concerned with virtual SErrors. |
73 | + gen_helper_add_saturate(tmp, cpu_env, tmp, tmp); | 186 | + * The pseudocode in the ARM for this case is |
74 | if (op & 2) | 187 | + * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then |
75 | gen_helper_sub_saturate(tmp, cpu_env, tmp2, tmp); | 188 | + * AArch32.vESBOperation(); |
76 | else | 189 | + * Most of the condition can be evaluated at translation time. |
190 | + * Test for EL2 present, and defer test for SEL2 to runtime. | ||
191 | + */ | ||
192 | + if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) { | ||
193 | + gen_helper_vesb(cpu_env); | ||
194 | + } | ||
195 | + } | ||
196 | + return true; | ||
197 | +} | ||
198 | + | ||
199 | static bool trans_NOP(DisasContext *s, arg_NOP *a) | ||
200 | { | ||
201 | return true; | ||
77 | -- | 202 | -- |
78 | 2.20.1 | 203 | 2.25.1 |
79 | |||
80 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Extract is a compact combination of shift + and. | 3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20190808202616.13782-2-richard.henderson@linaro.org | 5 | Message-id: 20220506180242.216785-18-richard.henderson@linaro.org |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 7 | --- |
10 | target/arm/translate.c | 9 +-------- | 8 | docs/system/arm/emulation.rst | 1 + |
11 | 1 file changed, 1 insertion(+), 8 deletions(-) | 9 | target/arm/cpu64.c | 1 + |
10 | target/arm/cpu_tcg.c | 1 + | ||
11 | 3 files changed, 3 insertions(+) | ||
12 | 12 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 15 | --- a/docs/system/arm/emulation.rst |
16 | +++ b/target/arm/translate.c | 16 | +++ b/docs/system/arm/emulation.rst |
17 | @@ -XXX,XX +XXX,XX @@ static void gen_sar(TCGv_i32 dest, TCGv_i32 t0, TCGv_i32 t1) | 17 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
18 | 18 | - FEAT_PMULL (PMULL, PMULL2 instructions) | |
19 | static void shifter_out_im(TCGv_i32 var, int shift) | 19 | - FEAT_PMUv3p1 (PMU Extensions v3.1) |
20 | { | 20 | - FEAT_PMUv3p4 (PMU Extensions v3.4) |
21 | - if (shift == 0) { | 21 | +- FEAT_RAS (Reliability, availability, and serviceability) |
22 | - tcg_gen_andi_i32(cpu_CF, var, 1); | 22 | - FEAT_RDM (Advanced SIMD rounding double multiply accumulate instructions) |
23 | - } else { | 23 | - FEAT_RNG (Random number generator) |
24 | - tcg_gen_shri_i32(cpu_CF, var, shift); | 24 | - FEAT_SB (Speculation Barrier) |
25 | - if (shift != 31) { | 25 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
26 | - tcg_gen_andi_i32(cpu_CF, cpu_CF, 1); | 26 | index XXXXXXX..XXXXXXX 100644 |
27 | - } | 27 | --- a/target/arm/cpu64.c |
28 | - } | 28 | +++ b/target/arm/cpu64.c |
29 | + tcg_gen_extract_i32(cpu_CF, var, shift, 1); | 29 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
30 | } | 30 | t = cpu->isar.id_aa64pfr0; |
31 | 31 | t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ | |
32 | /* Shift by immediate. Includes special handling for shift == 0. */ | 32 | t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ |
33 | + t = FIELD_DP64(t, ID_AA64PFR0, RAS, 1); /* FEAT_RAS */ | ||
34 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
35 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | ||
36 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | ||
37 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/cpu_tcg.c | ||
40 | +++ b/target/arm/cpu_tcg.c | ||
41 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
42 | |||
43 | t = cpu->isar.id_pfr0; | ||
44 | t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ | ||
45 | + t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */ | ||
46 | cpu->isar.id_pfr0 = t; | ||
47 | |||
48 | t = cpu->isar.id_pfr2; | ||
33 | -- | 49 | -- |
34 | 2.20.1 | 50 | 2.25.1 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The thumb bit has already been removed from s->pc, and is always even. | 3 | This feature is AArch64 only, and applies to physical SErrors, |
4 | which QEMU does not implement, thus the feature is a nop. | ||
4 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20220506180242.216785-19-richard.henderson@linaro.org |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20190807045335.1361-6-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/translate.c | 10 +++++----- | 11 | docs/system/arm/emulation.rst | 1 + |
12 | 1 file changed, 5 insertions(+), 5 deletions(-) | 12 | target/arm/cpu64.c | 1 + |
13 | 2 files changed, 2 insertions(+) | ||
13 | 14 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 17 | --- a/docs/system/arm/emulation.rst |
17 | +++ b/target/arm/translate.c | 18 | +++ b/docs/system/arm/emulation.rst |
18 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | 19 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
19 | /* Force a TB lookup after an instruction that changes the CPU state. */ | 20 | - FEAT_FlagM2 (Enhancements to flag manipulation instructions) |
20 | static inline void gen_lookup_tb(DisasContext *s) | 21 | - FEAT_HPDS (Hierarchical permission disables) |
21 | { | 22 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) |
22 | - tcg_gen_movi_i32(cpu_R[15], s->pc & ~1); | 23 | +- FEAT_IESB (Implicit error synchronization event) |
23 | + tcg_gen_movi_i32(cpu_R[15], s->pc); | 24 | - FEAT_JSCVT (JavaScript conversion instructions) |
24 | s->base.is_jmp = DISAS_EXIT; | 25 | - FEAT_LOR (Limited ordering regions) |
25 | } | 26 | - FEAT_LPA (Large Physical Address space) |
26 | 27 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | |
27 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 28 | index XXXXXXX..XXXXXXX 100644 |
28 | * self-modifying code correctly and also to take | 29 | --- a/target/arm/cpu64.c |
29 | * any pending interrupts immediately. | 30 | +++ b/target/arm/cpu64.c |
30 | */ | 31 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
31 | - gen_goto_tb(s, 0, s->pc & ~1); | 32 | t = cpu->isar.id_aa64mmfr2; |
32 | + gen_goto_tb(s, 0, s->pc); | 33 | t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */ |
33 | return; | 34 | t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */ |
34 | case 7: /* sb */ | 35 | + t = FIELD_DP64(t, ID_AA64MMFR2, IESB, 1); /* FEAT_IESB */ |
35 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | 36 | t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */ |
36 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 37 | t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */ |
37 | * for TCG; MB and end the TB instead. | 38 | t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ |
38 | */ | ||
39 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
40 | - gen_goto_tb(s, 0, s->pc & ~1); | ||
41 | + gen_goto_tb(s, 0, s->pc); | ||
42 | return; | ||
43 | default: | ||
44 | goto illegal_op; | ||
45 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
46 | * and also to take any pending interrupts | ||
47 | * immediately. | ||
48 | */ | ||
49 | - gen_goto_tb(s, 0, s->pc & ~1); | ||
50 | + gen_goto_tb(s, 0, s->pc); | ||
51 | break; | ||
52 | case 7: /* sb */ | ||
53 | if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | ||
54 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
55 | * for TCG; MB and end the TB instead. | ||
56 | */ | ||
57 | tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
58 | - gen_goto_tb(s, 0, s->pc & ~1); | ||
59 | + gen_goto_tb(s, 0, s->pc); | ||
60 | break; | ||
61 | default: | ||
62 | goto illegal_op; | ||
63 | -- | 39 | -- |
64 | 2.20.1 | 40 | 2.25.1 |
65 | |||
66 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | While most features are now detected by probing the ID_* registers | 3 | This extension concerns branch speculation, which TCG does |
4 | kernels can (and do) use MIDR_EL1 for working out of they have to | 4 | not implement. Thus we can trivially enable this feature. |
5 | apply errata. This can trip up warnings in the kernel as it tries to | ||
6 | work out if it should apply workarounds to features that don't | ||
7 | actually exist in the reported CPU type. | ||
8 | 5 | ||
9 | Avoid this problem by synthesising our own MIDR value. | ||
10 | |||
11 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20190726113950.7499-1-alex.bennee@linaro.org | 8 | Message-id: 20220506180242.216785-20-richard.henderson@linaro.org |
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 10 | --- |
17 | target/arm/cpu.h | 6 ++++++ | 11 | docs/system/arm/emulation.rst | 1 + |
18 | target/arm/cpu64.c | 19 +++++++++++++++++++ | 12 | target/arm/cpu64.c | 1 + |
19 | 2 files changed, 25 insertions(+) | 13 | target/arm/cpu_tcg.c | 1 + |
14 | 3 files changed, 3 insertions(+) | ||
20 | 15 | ||
21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
22 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.h | 18 | --- a/docs/system/arm/emulation.rst |
24 | +++ b/target/arm/cpu.h | 19 | +++ b/docs/system/arm/emulation.rst |
25 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_FPCCR, ASPEN, 31, 1) | 20 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
26 | /* | 21 | - FEAT_BBM at level 2 (Translation table break-before-make levels) |
27 | * System register ID fields. | 22 | - FEAT_BF16 (AArch64 BFloat16 instructions) |
28 | */ | 23 | - FEAT_BTI (Branch Target Identification) |
29 | +FIELD(MIDR_EL1, REVISION, 0, 4) | 24 | +- FEAT_CSV2 (Cache speculation variant 2) |
30 | +FIELD(MIDR_EL1, PARTNUM, 4, 12) | 25 | - FEAT_DIT (Data Independent Timing instructions) |
31 | +FIELD(MIDR_EL1, ARCHITECTURE, 16, 4) | 26 | - FEAT_DPB (DC CVAP instruction) |
32 | +FIELD(MIDR_EL1, VARIANT, 20, 4) | 27 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
33 | +FIELD(MIDR_EL1, IMPLEMENTER, 24, 8) | ||
34 | + | ||
35 | FIELD(ID_ISAR0, SWAP, 0, 4) | ||
36 | FIELD(ID_ISAR0, BITCOUNT, 4, 4) | ||
37 | FIELD(ID_ISAR0, BITFIELD, 8, 4) | ||
38 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 28 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
39 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/target/arm/cpu64.c | 30 | --- a/target/arm/cpu64.c |
41 | +++ b/target/arm/cpu64.c | 31 | +++ b/target/arm/cpu64.c |
42 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 32 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
43 | uint32_t u; | 33 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); |
44 | aarch64_a57_initfn(obj); | 34 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ |
45 | 35 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | |
46 | + /* | 36 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1); /* FEAT_CSV2 */ |
47 | + * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real | 37 | cpu->isar.id_aa64pfr0 = t; |
48 | + * one and try to apply errata workarounds or use impdef features we | 38 | |
49 | + * don't provide. | 39 | t = cpu->isar.id_aa64pfr1; |
50 | + * An IMPLEMENTER field of 0 means "reserved for software use"; | 40 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
51 | + * ARCHITECTURE must be 0xf indicating "v7 or later, check ID registers | 41 | index XXXXXXX..XXXXXXX 100644 |
52 | + * to see which features are present"; | 42 | --- a/target/arm/cpu_tcg.c |
53 | + * the VARIANT, PARTNUM and REVISION fields are all implementation | 43 | +++ b/target/arm/cpu_tcg.c |
54 | + * defined and we choose to define PARTNUM just in case guest | 44 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
55 | + * code needs to distinguish this QEMU CPU from other software | 45 | cpu->isar.id_mmfr4 = t; |
56 | + * implementations, though this shouldn't be needed. | 46 | |
57 | + */ | 47 | t = cpu->isar.id_pfr0; |
58 | + t = FIELD_DP64(0, MIDR_EL1, IMPLEMENTER, 0); | 48 | + t = FIELD_DP32(t, ID_PFR0, CSV2, 2); /* FEAT_CVS2 */ |
59 | + t = FIELD_DP64(t, MIDR_EL1, ARCHITECTURE, 0xf); | 49 | t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ |
60 | + t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q'); | 50 | t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */ |
61 | + t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0); | 51 | cpu->isar.id_pfr0 = t; |
62 | + t = FIELD_DP64(t, MIDR_EL1, REVISION, 0); | ||
63 | + cpu->midr = t; | ||
64 | + | ||
65 | t = cpu->isar.id_aa64isar0; | ||
66 | t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */ | ||
67 | t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); | ||
68 | -- | 52 | -- |
69 | 2.20.1 | 53 | 2.25.1 |
70 | |||
71 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We first convert the pmu property from a static property to one with | 3 | There is no branch prediction in TCG, therefore there is no |
4 | its own accessors. Then we use the set accessor to check if the PMU is | 4 | need to actually include the context number into the predictor. |
5 | supported when using KVM. Indeed a 32-bit KVM host does not support | 5 | Therefore all we need to do is add the state for SCXTNUM_ELx. |
6 | the PMU, so this check will catch an attempt to use it at property-set | ||
7 | time. | ||
8 | 6 | ||
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20220506180242.216785-21-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | target/arm/kvm_arm.h | 14 ++++++++++++++ | 12 | docs/system/arm/emulation.rst | 3 ++ |
14 | target/arm/cpu.c | 30 +++++++++++++++++++++++++----- | 13 | target/arm/cpu.h | 16 +++++++++ |
15 | target/arm/kvm.c | 7 +++++++ | 14 | target/arm/cpu.c | 5 +++ |
16 | 3 files changed, 46 insertions(+), 5 deletions(-) | 15 | target/arm/cpu64.c | 3 +- |
16 | target/arm/helper.c | 61 ++++++++++++++++++++++++++++++++++- | ||
17 | 5 files changed, 86 insertions(+), 2 deletions(-) | ||
17 | 18 | ||
18 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 19 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
19 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/kvm_arm.h | 21 | --- a/docs/system/arm/emulation.rst |
21 | +++ b/target/arm/kvm_arm.h | 22 | +++ b/docs/system/arm/emulation.rst |
22 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); | 23 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
23 | */ | 24 | - FEAT_BF16 (AArch64 BFloat16 instructions) |
24 | bool kvm_arm_aarch32_supported(CPUState *cs); | 25 | - FEAT_BTI (Branch Target Identification) |
25 | 26 | - FEAT_CSV2 (Cache speculation variant 2) | |
26 | +/** | 27 | +- FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) |
27 | + * bool kvm_arm_pmu_supported: | 28 | +- FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
28 | + * @cs: CPUState | 29 | +- FEAT_CSV2_2 (Cache speculation variant 2, version 2) |
29 | + * | 30 | - FEAT_DIT (Data Independent Timing instructions) |
30 | + * Returns: true if the KVM VCPU can enable its PMU | 31 | - FEAT_DPB (DC CVAP instruction) |
31 | + * and false otherwise. | 32 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
32 | + */ | 33 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
33 | +bool kvm_arm_pmu_supported(CPUState *cs); | 34 | index XXXXXXX..XXXXXXX 100644 |
34 | + | 35 | --- a/target/arm/cpu.h |
35 | /** | 36 | +++ b/target/arm/cpu.h |
36 | * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the | 37 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
37 | * IPA address space supported by KVM | 38 | ARMPACKey apdb; |
38 | @@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_aarch32_supported(CPUState *cs) | 39 | ARMPACKey apga; |
39 | return false; | 40 | } keys; |
41 | + | ||
42 | + uint64_t scxtnum_el[4]; | ||
43 | #endif | ||
44 | |||
45 | #if defined(CONFIG_USER_ONLY) | ||
46 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
47 | #define SCTLR_WXN (1U << 19) | ||
48 | #define SCTLR_ST (1U << 20) /* up to ??, RAZ in v6 */ | ||
49 | #define SCTLR_UWXN (1U << 20) /* v7 onward, AArch32 only */ | ||
50 | +#define SCTLR_TSCXT (1U << 20) /* FEAT_CSV2_1p2, AArch64 only */ | ||
51 | #define SCTLR_FI (1U << 21) /* up to v7, v8 RES0 */ | ||
52 | #define SCTLR_IESB (1U << 21) /* v8.2-IESB, AArch64 only */ | ||
53 | #define SCTLR_U (1U << 22) /* up to v6, RAO in v7 */ | ||
54 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dit(const ARMISARegisters *id) | ||
55 | return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0; | ||
40 | } | 56 | } |
41 | 57 | ||
42 | +static inline bool kvm_arm_pmu_supported(CPUState *cs) | 58 | +static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id) |
43 | +{ | 59 | +{ |
60 | + int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2); | ||
61 | + if (key >= 2) { | ||
62 | + return true; /* FEAT_CSV2_2 */ | ||
63 | + } | ||
64 | + if (key == 1) { | ||
65 | + key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC); | ||
66 | + return key >= 2; /* FEAT_CSV2_1p2 */ | ||
67 | + } | ||
44 | + return false; | 68 | + return false; |
45 | +} | 69 | +} |
46 | + | 70 | + |
47 | static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | 71 | static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id) |
48 | { | 72 | { |
49 | return -ENOENT; | 73 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0; |
50 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 74 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
51 | index XXXXXXX..XXXXXXX 100644 | 75 | index XXXXXXX..XXXXXXX 100644 |
52 | --- a/target/arm/cpu.c | 76 | --- a/target/arm/cpu.c |
53 | +++ b/target/arm/cpu.c | 77 | +++ b/target/arm/cpu.c |
54 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_has_el3_property = | 78 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) |
55 | static Property arm_cpu_cfgend_property = | 79 | */ |
56 | DEFINE_PROP_BOOL("cfgend", ARMCPU, cfgend, false); | 80 | env->cp15.gcr_el1 = 0x1ffff; |
57 | 81 | } | |
58 | -/* use property name "pmu" to match other archs and virt tools */ | 82 | + /* |
59 | -static Property arm_cpu_has_pmu_property = | 83 | + * Disable access to SCXTNUM_EL0 from CSV2_1p2. |
60 | - DEFINE_PROP_BOOL("pmu", ARMCPU, has_pmu, true); | 84 | + * This is not yet exposed from the Linux kernel in any way. |
61 | - | 85 | + */ |
62 | static Property arm_cpu_has_vfp_property = | 86 | + env->cp15.sctlr_el[1] |= SCTLR_TSCXT; |
63 | DEFINE_PROP_BOOL("vfp", ARMCPU, has_vfp, true); | 87 | #else |
64 | 88 | /* Reset into the highest available EL */ | |
65 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pmsav7_dregion_property = | 89 | if (arm_feature(env, ARM_FEATURE_EL3)) { |
66 | pmsav7_dregion, | 90 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
67 | qdev_prop_uint32, uint32_t); | 91 | index XXXXXXX..XXXXXXX 100644 |
68 | 92 | --- a/target/arm/cpu64.c | |
69 | +static bool arm_get_pmu(Object *obj, Error **errp) | 93 | +++ b/target/arm/cpu64.c |
94 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
95 | t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1); | ||
96 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ | ||
97 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ | ||
98 | - t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1); /* FEAT_CSV2 */ | ||
99 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ | ||
100 | cpu->isar.id_aa64pfr0 = t; | ||
101 | |||
102 | t = cpu->isar.id_aa64pfr1; | ||
103 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
104 | * we do for EL2 with the virtualization=on property. | ||
105 | */ | ||
106 | t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */ | ||
107 | + t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ | ||
108 | cpu->isar.id_aa64pfr1 = t; | ||
109 | |||
110 | t = cpu->isar.id_aa64mmfr0; | ||
111 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/target/arm/helper.c | ||
114 | +++ b/target/arm/helper.c | ||
115 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
116 | if (cpu_isar_feature(aa64_mte, cpu)) { | ||
117 | valid_mask |= SCR_ATA; | ||
118 | } | ||
119 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { | ||
120 | + valid_mask |= SCR_ENSCXT; | ||
121 | + } | ||
122 | } else { | ||
123 | valid_mask &= ~(SCR_RW | SCR_ST); | ||
124 | if (cpu_isar_feature(aa32_ras, cpu)) { | ||
125 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
126 | if (cpu_isar_feature(aa64_mte, cpu)) { | ||
127 | valid_mask |= HCR_ATA | HCR_DCT | HCR_TID5; | ||
128 | } | ||
129 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { | ||
130 | + valid_mask |= HCR_ENSCXT; | ||
131 | + } | ||
132 | } | ||
133 | |||
134 | /* Clear RES0 bits. */ | ||
135 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
136 | { K(3, 0, 5, 6, 0), K(3, 4, 5, 6, 0), K(3, 5, 5, 6, 0), | ||
137 | "TFSR_EL1", "TFSR_EL2", "TFSR_EL12", isar_feature_aa64_mte }, | ||
138 | |||
139 | + { K(3, 0, 13, 0, 7), K(3, 4, 13, 0, 7), K(3, 5, 13, 0, 7), | ||
140 | + "SCXTNUM_EL1", "SCXTNUM_EL2", "SCXTNUM_EL12", | ||
141 | + isar_feature_aa64_scxtnum }, | ||
142 | + | ||
143 | /* TODO: ARMv8.2-SPE -- PMSCR_EL2 */ | ||
144 | /* TODO: ARMv8.4-Trace -- TRFCR_EL2 */ | ||
145 | }; | ||
146 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { | ||
147 | }, | ||
148 | }; | ||
149 | |||
150 | -#endif | ||
151 | +static CPAccessResult access_scxtnum(CPUARMState *env, const ARMCPRegInfo *ri, | ||
152 | + bool isread) | ||
70 | +{ | 153 | +{ |
71 | + ARMCPU *cpu = ARM_CPU(obj); | 154 | + uint64_t hcr = arm_hcr_el2_eff(env); |
72 | + | 155 | + int el = arm_current_el(env); |
73 | + return cpu->has_pmu; | 156 | + |
157 | + if (el == 0 && !((hcr & HCR_E2H) && (hcr & HCR_TGE))) { | ||
158 | + if (env->cp15.sctlr_el[1] & SCTLR_TSCXT) { | ||
159 | + if (hcr & HCR_TGE) { | ||
160 | + return CP_ACCESS_TRAP_EL2; | ||
161 | + } | ||
162 | + return CP_ACCESS_TRAP; | ||
163 | + } | ||
164 | + } else if (el < 2 && (env->cp15.sctlr_el[2] & SCTLR_TSCXT)) { | ||
165 | + return CP_ACCESS_TRAP_EL2; | ||
166 | + } | ||
167 | + if (el < 2 && arm_is_el2_enabled(env) && !(hcr & HCR_ENSCXT)) { | ||
168 | + return CP_ACCESS_TRAP_EL2; | ||
169 | + } | ||
170 | + if (el < 3 | ||
171 | + && arm_feature(env, ARM_FEATURE_EL3) | ||
172 | + && !(env->cp15.scr_el3 & SCR_ENSCXT)) { | ||
173 | + return CP_ACCESS_TRAP_EL3; | ||
174 | + } | ||
175 | + return CP_ACCESS_OK; | ||
74 | +} | 176 | +} |
75 | + | 177 | + |
76 | +static void arm_set_pmu(Object *obj, bool value, Error **errp) | 178 | +static const ARMCPRegInfo scxtnum_reginfo[] = { |
77 | +{ | 179 | + { .name = "SCXTNUM_EL0", .state = ARM_CP_STATE_AA64, |
78 | + ARMCPU *cpu = ARM_CPU(obj); | 180 | + .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 7, |
79 | + | 181 | + .access = PL0_RW, .accessfn = access_scxtnum, |
80 | + if (value) { | 182 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[0]) }, |
81 | + if (kvm_enabled() && !kvm_arm_pmu_supported(CPU(cpu))) { | 183 | + { .name = "SCXTNUM_EL1", .state = ARM_CP_STATE_AA64, |
82 | + error_setg(errp, "'pmu' feature not supported by KVM on this host"); | 184 | + .opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 7, |
83 | + return; | 185 | + .access = PL1_RW, .accessfn = access_scxtnum, |
84 | + } | 186 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[1]) }, |
85 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | 187 | + { .name = "SCXTNUM_EL2", .state = ARM_CP_STATE_AA64, |
86 | + } else { | 188 | + .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 7, |
87 | + unset_feature(&cpu->env, ARM_FEATURE_PMU); | 189 | + .access = PL2_RW, .accessfn = access_scxtnum, |
88 | + } | 190 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[2]) }, |
89 | + cpu->has_pmu = value; | 191 | + { .name = "SCXTNUM_EL3", .state = ARM_CP_STATE_AA64, |
90 | +} | 192 | + .opc0 = 3, .opc1 = 6, .crn = 13, .crm = 0, .opc2 = 7, |
91 | + | 193 | + .access = PL3_RW, |
92 | static void arm_get_init_svtor(Object *obj, Visitor *v, const char *name, | 194 | + .fieldoffset = offsetof(CPUARMState, scxtnum_el[3]) }, |
93 | void *opaque, Error **errp) | 195 | +}; |
94 | { | 196 | +#endif /* TARGET_AARCH64 */ |
95 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | 197 | |
198 | static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, | ||
199 | bool isread) | ||
200 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
201 | define_arm_cp_regs(cpu, mte_tco_ro_reginfo); | ||
202 | define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo); | ||
96 | } | 203 | } |
97 | 204 | + | |
98 | if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { | 205 | + if (cpu_isar_feature(aa64_scxtnum, cpu)) { |
99 | - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_pmu_property, | 206 | + define_arm_cp_regs(cpu, scxtnum_reginfo); |
100 | + cpu->has_pmu = true; | 207 | + } |
101 | + object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu, | 208 | #endif |
102 | &error_abort); | 209 | |
103 | } | 210 | if (cpu_isar_feature(any_predinv, cpu)) { |
104 | |||
105 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
106 | index XXXXXXX..XXXXXXX 100644 | ||
107 | --- a/target/arm/kvm.c | ||
108 | +++ b/target/arm/kvm.c | ||
109 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | ||
110 | env->features = arm_host_cpu_features.features; | ||
111 | } | ||
112 | |||
113 | +bool kvm_arm_pmu_supported(CPUState *cpu) | ||
114 | +{ | ||
115 | + KVMState *s = KVM_STATE(current_machine->accelerator); | ||
116 | + | ||
117 | + return kvm_check_extension(s, KVM_CAP_ARM_PMU_V3); | ||
118 | +} | ||
119 | + | ||
120 | int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
121 | { | ||
122 | KVMState *s = KVM_STATE(ms->accelerator); | ||
123 | -- | 211 | -- |
124 | 2.20.1 | 212 | 2.25.1 |
125 | |||
126 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Unlike the other more generic gen_exception{,_internal}_insn | 3 | This extension concerns cache speculation, which TCG does |
4 | interfaces, breakpoints always refer to the current instruction. | 4 | not implement. Thus we can trivially enable this feature. |
5 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20220506180242.216785-22-richard.henderson@linaro.org |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190807045335.1361-10-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/translate-a64.c | 7 +++---- | 11 | docs/system/arm/emulation.rst | 1 + |
13 | target/arm/translate.c | 8 ++++---- | 12 | target/arm/cpu64.c | 1 + |
14 | 2 files changed, 7 insertions(+), 8 deletions(-) | 13 | target/arm/cpu_tcg.c | 1 + |
14 | 3 files changed, 3 insertions(+) | ||
15 | 15 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 16 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 18 | --- a/docs/system/arm/emulation.rst |
19 | +++ b/target/arm/translate-a64.c | 19 | +++ b/docs/system/arm/emulation.rst |
20 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | 20 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
21 | s->base.is_jmp = DISAS_NORETURN; | 21 | - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1) |
22 | } | 22 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
23 | 23 | - FEAT_CSV2_2 (Cache speculation variant 2, version 2) | |
24 | -static void gen_exception_bkpt_insn(DisasContext *s, int offset, | 24 | +- FEAT_CSV3 (Cache speculation variant 3) |
25 | - uint32_t syndrome) | 25 | - FEAT_DIT (Data Independent Timing instructions) |
26 | +static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syndrome) | 26 | - FEAT_DPB (DC CVAP instruction) |
27 | { | 27 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
28 | TCGv_i32 tcg_syn; | 28 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
29 | |||
30 | - gen_a64_set_pc_im(s->base.pc_next - offset); | ||
31 | + gen_a64_set_pc_im(s->pc_curr); | ||
32 | tcg_syn = tcg_const_i32(syndrome); | ||
33 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | ||
34 | tcg_temp_free_i32(tcg_syn); | ||
35 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
36 | break; | ||
37 | } | ||
38 | /* BRK */ | ||
39 | - gen_exception_bkpt_insn(s, 4, syn_aa64_bkpt(imm16)); | ||
40 | + gen_exception_bkpt_insn(s, syn_aa64_bkpt(imm16)); | ||
41 | break; | ||
42 | case 2: | ||
43 | if (op2_ll != 0) { | ||
44 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/target/arm/translate.c | 30 | --- a/target/arm/cpu64.c |
47 | +++ b/target/arm/translate.c | 31 | +++ b/target/arm/cpu64.c |
48 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_insn(DisasContext *s, uint32_t pc, int excp, | 32 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
49 | s->base.is_jmp = DISAS_NORETURN; | 33 | t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */ |
50 | } | 34 | t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ |
51 | 35 | t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ | |
52 | -static void gen_exception_bkpt_insn(DisasContext *s, int offset, uint32_t syn) | 36 | + t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */ |
53 | +static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) | 37 | cpu->isar.id_aa64pfr0 = t; |
54 | { | 38 | |
55 | TCGv_i32 tcg_syn; | 39 | t = cpu->isar.id_aa64pfr1; |
56 | 40 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | |
57 | gen_set_condexec(s); | 41 | index XXXXXXX..XXXXXXX 100644 |
58 | - gen_set_pc_im(s, s->base.pc_next - offset); | 42 | --- a/target/arm/cpu_tcg.c |
59 | + gen_set_pc_im(s, s->pc_curr); | 43 | +++ b/target/arm/cpu_tcg.c |
60 | tcg_syn = tcg_const_i32(syn); | 44 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
61 | gen_helper_exception_bkpt_insn(cpu_env, tcg_syn); | 45 | cpu->isar.id_pfr0 = t; |
62 | tcg_temp_free_i32(tcg_syn); | 46 | |
63 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 47 | t = cpu->isar.id_pfr2; |
64 | case 1: | 48 | + t = FIELD_DP32(t, ID_PFR2, CSV3, 1); /* FEAT_CSV3 */ |
65 | /* bkpt */ | 49 | t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */ |
66 | ARCH(5); | 50 | cpu->isar.id_pfr2 = t; |
67 | - gen_exception_bkpt_insn(s, 4, syn_aa32_bkpt(imm16, false)); | ||
68 | + gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm16, false)); | ||
69 | break; | ||
70 | case 2: | ||
71 | /* Hypervisor call (v7) */ | ||
72 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
73 | { | ||
74 | int imm8 = extract32(insn, 0, 8); | ||
75 | ARCH(5); | ||
76 | - gen_exception_bkpt_insn(s, 2, syn_aa32_bkpt(imm8, true)); | ||
77 | + gen_exception_bkpt_insn(s, syn_aa32_bkpt(imm8, true)); | ||
78 | break; | ||
79 | } | ||
80 | 51 | ||
81 | -- | 52 | -- |
82 | 2.20.1 | 53 | 2.25.1 |
83 | |||
84 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add a new field to retain the address of the instruction currently | 3 | This extension concerns not merging memory access, which TCG does |
4 | being translated. The 32-bit uses are all within subroutines used | 4 | not implement. Thus we can trivially enable this feature. |
5 | by a32 and t32. This will become less obvious when t16 support is | 5 | Add a comment to handle_hint for the DGH instruction, but no code. |
6 | merged with a32+t32, and having a clear definition will help. | ||
7 | 6 | ||
8 | Convert aarch64 as well for consistency. Note that there is one | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | instance of a pre-assert fprintf that used the wrong value for the | ||
10 | address of the current instruction. | ||
11 | |||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Message-id: 20220506180242.216785-23-richard.henderson@linaro.org |
14 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Message-id: 20190807045335.1361-3-richard.henderson@linaro.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 11 | --- |
18 | target/arm/translate-a64.h | 2 +- | 12 | docs/system/arm/emulation.rst | 1 + |
19 | target/arm/translate.h | 2 ++ | 13 | target/arm/cpu64.c | 1 + |
20 | target/arm/translate-a64.c | 21 +++++++++++---------- | 14 | target/arm/translate-a64.c | 1 + |
21 | target/arm/translate.c | 14 ++++++++------ | 15 | 3 files changed, 3 insertions(+) |
22 | 4 files changed, 22 insertions(+), 17 deletions(-) | ||
23 | 16 | ||
24 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | 17 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
25 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/translate-a64.h | 19 | --- a/docs/system/arm/emulation.rst |
27 | +++ b/target/arm/translate-a64.h | 20 | +++ b/docs/system/arm/emulation.rst |
28 | @@ -XXX,XX +XXX,XX @@ void unallocated_encoding(DisasContext *s); | 21 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
29 | qemu_log_mask(LOG_UNIMP, \ | 22 | - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2) |
30 | "%s:%d: unsupported instruction encoding 0x%08x " \ | 23 | - FEAT_CSV2_2 (Cache speculation variant 2, version 2) |
31 | "at pc=%016" PRIx64 "\n", \ | 24 | - FEAT_CSV3 (Cache speculation variant 3) |
32 | - __FILE__, __LINE__, insn, s->pc - 4); \ | 25 | +- FEAT_DGH (Data gathering hint) |
33 | + __FILE__, __LINE__, insn, s->pc_curr); \ | 26 | - FEAT_DIT (Data Independent Timing instructions) |
34 | unallocated_encoding(s); \ | 27 | - FEAT_DPB (DC CVAP instruction) |
35 | } while (0) | 28 | - FEAT_Debugv8p2 (Debug changes for v8.2) |
36 | 29 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | |
37 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/translate.h | 31 | --- a/target/arm/cpu64.c |
40 | +++ b/target/arm/translate.h | 32 | +++ b/target/arm/cpu64.c |
41 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 33 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
42 | const ARMISARegisters *isar; | 34 | t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */ |
43 | 35 | t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */ | |
44 | target_ulong pc; | 36 | t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */ |
45 | + /* The address of the current instruction being translated. */ | 37 | + t = FIELD_DP64(t, ID_AA64ISAR1, DGH, 1); /* FEAT_DGH */ |
46 | + target_ulong pc_curr; | 38 | t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */ |
47 | target_ulong page_start; | 39 | cpu->isar.id_aa64isar1 = t; |
48 | uint32_t insn; | 40 | |
49 | /* Nonzero if this instruction has been conditionally skipped. */ | ||
50 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 41 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
51 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
52 | --- a/target/arm/translate-a64.c | 43 | --- a/target/arm/translate-a64.c |
53 | +++ b/target/arm/translate-a64.c | 44 | +++ b/target/arm/translate-a64.c |
54 | @@ -XXX,XX +XXX,XX @@ static inline AArch64DecodeFn *lookup_disas_fn(const AArch64DecodeTable *table, | 45 | @@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn, |
55 | */ | 46 | break; |
56 | static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) | 47 | case 0b00100: /* SEV */ |
57 | { | 48 | case 0b00101: /* SEVL */ |
58 | - uint64_t addr = s->pc + sextract32(insn, 0, 26) * 4 - 4; | 49 | + case 0b00110: /* DGH */ |
59 | + uint64_t addr = s->pc_curr + sextract32(insn, 0, 26) * 4; | 50 | /* we treat all as NOP at least for now */ |
60 | 51 | break; | |
61 | if (insn & (1U << 31)) { | 52 | case 0b00111: /* XPACLRI */ |
62 | /* BL Branch with link */ | ||
63 | @@ -XXX,XX +XXX,XX @@ static void disas_comp_b_imm(DisasContext *s, uint32_t insn) | ||
64 | sf = extract32(insn, 31, 1); | ||
65 | op = extract32(insn, 24, 1); /* 0: CBZ; 1: CBNZ */ | ||
66 | rt = extract32(insn, 0, 5); | ||
67 | - addr = s->pc + sextract32(insn, 5, 19) * 4 - 4; | ||
68 | + addr = s->pc_curr + sextract32(insn, 5, 19) * 4; | ||
69 | |||
70 | tcg_cmp = read_cpu_reg(s, rt, sf); | ||
71 | label_match = gen_new_label(); | ||
72 | @@ -XXX,XX +XXX,XX @@ static void disas_test_b_imm(DisasContext *s, uint32_t insn) | ||
73 | |||
74 | bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); | ||
75 | op = extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ | ||
76 | - addr = s->pc + sextract32(insn, 5, 14) * 4 - 4; | ||
77 | + addr = s->pc_curr + sextract32(insn, 5, 14) * 4; | ||
78 | rt = extract32(insn, 0, 5); | ||
79 | |||
80 | tcg_cmp = tcg_temp_new_i64(); | ||
81 | @@ -XXX,XX +XXX,XX @@ static void disas_cond_b_imm(DisasContext *s, uint32_t insn) | ||
82 | unallocated_encoding(s); | ||
83 | return; | ||
84 | } | ||
85 | - addr = s->pc + sextract32(insn, 5, 19) * 4 - 4; | ||
86 | + addr = s->pc_curr + sextract32(insn, 5, 19) * 4; | ||
87 | cond = extract32(insn, 0, 4); | ||
88 | |||
89 | reset_btype(s); | ||
90 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
91 | TCGv_i32 tcg_syn, tcg_isread; | ||
92 | uint32_t syndrome; | ||
93 | |||
94 | - gen_a64_set_pc_im(s->pc - 4); | ||
95 | + gen_a64_set_pc_im(s->pc_curr); | ||
96 | tmpptr = tcg_const_ptr(ri); | ||
97 | syndrome = syn_aa64_sysregtrap(op0, op1, op2, crn, crm, rt, isread); | ||
98 | tcg_syn = tcg_const_i32(syndrome); | ||
99 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
100 | /* The pre HVC helper handles cases when HVC gets trapped | ||
101 | * as an undefined insn by runtime configuration. | ||
102 | */ | ||
103 | - gen_a64_set_pc_im(s->pc - 4); | ||
104 | + gen_a64_set_pc_im(s->pc_curr); | ||
105 | gen_helper_pre_hvc(cpu_env); | ||
106 | gen_ss_advance(s); | ||
107 | gen_exception_insn(s, 0, EXCP_HVC, syn_aa64_hvc(imm16), 2); | ||
108 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
109 | unallocated_encoding(s); | ||
110 | break; | ||
111 | } | ||
112 | - gen_a64_set_pc_im(s->pc - 4); | ||
113 | + gen_a64_set_pc_im(s->pc_curr); | ||
114 | tmp = tcg_const_i32(syn_aa64_smc(imm16)); | ||
115 | gen_helper_pre_smc(cpu_env, tmp); | ||
116 | tcg_temp_free_i32(tmp); | ||
117 | @@ -XXX,XX +XXX,XX @@ static void disas_ld_lit(DisasContext *s, uint32_t insn) | ||
118 | |||
119 | tcg_rt = cpu_reg(s, rt); | ||
120 | |||
121 | - clean_addr = tcg_const_i64((s->pc - 4) + imm); | ||
122 | + clean_addr = tcg_const_i64(s->pc_curr + imm); | ||
123 | if (is_vector) { | ||
124 | do_fp_ld(s, rt, clean_addr, size); | ||
125 | } else { | ||
126 | @@ -XXX,XX +XXX,XX @@ static void disas_pc_rel_adr(DisasContext *s, uint32_t insn) | ||
127 | offset = sextract64(insn, 5, 19); | ||
128 | offset = offset << 2 | extract32(insn, 29, 2); | ||
129 | rd = extract32(insn, 0, 5); | ||
130 | - base = s->pc - 4; | ||
131 | + base = s->pc_curr; | ||
132 | |||
133 | if (page) { | ||
134 | /* ADRP (page based) */ | ||
135 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_fp16(DisasContext *s, uint32_t insn) | ||
136 | break; | ||
137 | default: | ||
138 | fprintf(stderr, "%s: insn %#04x, fpop %#2x @ %#" PRIx64 "\n", | ||
139 | - __func__, insn, fpopcode, s->pc); | ||
140 | + __func__, insn, fpopcode, s->pc_curr); | ||
141 | g_assert_not_reached(); | ||
142 | } | ||
143 | |||
144 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s) | ||
145 | { | ||
146 | uint32_t insn; | ||
147 | |||
148 | + s->pc_curr = s->pc; | ||
149 | insn = arm_ldl_code(env, s->pc, s->sctlr_b); | ||
150 | s->insn = insn; | ||
151 | s->pc += 4; | ||
152 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
153 | index XXXXXXX..XXXXXXX 100644 | ||
154 | --- a/target/arm/translate.c | ||
155 | +++ b/target/arm/translate.c | ||
156 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hvc(DisasContext *s, int imm16) | ||
157 | * as an undefined insn by runtime configuration (ie before | ||
158 | * the insn really executes). | ||
159 | */ | ||
160 | - gen_set_pc_im(s, s->pc - 4); | ||
161 | + gen_set_pc_im(s, s->pc_curr); | ||
162 | gen_helper_pre_hvc(cpu_env); | ||
163 | /* Otherwise we will treat this as a real exception which | ||
164 | * happens after execution of the insn. (The distinction matters | ||
165 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | ||
166 | */ | ||
167 | TCGv_i32 tmp; | ||
168 | |||
169 | - gen_set_pc_im(s, s->pc - 4); | ||
170 | + gen_set_pc_im(s, s->pc_curr); | ||
171 | tmp = tcg_const_i32(syn_aa32_smc()); | ||
172 | gen_helper_pre_smc(cpu_env, tmp); | ||
173 | tcg_temp_free_i32(tmp); | ||
174 | @@ -XXX,XX +XXX,XX @@ static void gen_msr_banked(DisasContext *s, int r, int sysm, int rn) | ||
175 | |||
176 | /* Sync state because msr_banked() can raise exceptions */ | ||
177 | gen_set_condexec(s); | ||
178 | - gen_set_pc_im(s, s->pc - 4); | ||
179 | + gen_set_pc_im(s, s->pc_curr); | ||
180 | tcg_reg = load_reg(s, rn); | ||
181 | tcg_tgtmode = tcg_const_i32(tgtmode); | ||
182 | tcg_regno = tcg_const_i32(regno); | ||
183 | @@ -XXX,XX +XXX,XX @@ static void gen_mrs_banked(DisasContext *s, int r, int sysm, int rn) | ||
184 | |||
185 | /* Sync state because mrs_banked() can raise exceptions */ | ||
186 | gen_set_condexec(s); | ||
187 | - gen_set_pc_im(s, s->pc - 4); | ||
188 | + gen_set_pc_im(s, s->pc_curr); | ||
189 | tcg_reg = tcg_temp_new_i32(); | ||
190 | tcg_tgtmode = tcg_const_i32(tgtmode); | ||
191 | tcg_regno = tcg_const_i32(regno); | ||
192 | @@ -XXX,XX +XXX,XX @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn) | ||
193 | } | ||
194 | |||
195 | gen_set_condexec(s); | ||
196 | - gen_set_pc_im(s, s->pc - 4); | ||
197 | + gen_set_pc_im(s, s->pc_curr); | ||
198 | tmpptr = tcg_const_ptr(ri); | ||
199 | tcg_syn = tcg_const_i32(syndrome); | ||
200 | tcg_isread = tcg_const_i32(isread); | ||
201 | @@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s, | ||
202 | tmp = tcg_const_i32(mode); | ||
203 | /* get_r13_banked() will raise an exception if called from System mode */ | ||
204 | gen_set_condexec(s); | ||
205 | - gen_set_pc_im(s, s->pc - 4); | ||
206 | + gen_set_pc_im(s, s->pc_curr); | ||
207 | gen_helper_get_r13_banked(addr, cpu_env, tmp); | ||
208 | tcg_temp_free_i32(tmp); | ||
209 | switch (amode) { | ||
210 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
211 | return; | ||
212 | } | ||
213 | |||
214 | + dc->pc_curr = dc->pc; | ||
215 | insn = arm_ldl_code(env, dc->pc, dc->sctlr_b); | ||
216 | dc->insn = insn; | ||
217 | dc->pc += 4; | ||
218 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
219 | return; | ||
220 | } | ||
221 | |||
222 | + dc->pc_curr = dc->pc; | ||
223 | insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
224 | is_16bit = thumb_insn_is_16bit(dc, dc->pc, insn); | ||
225 | dc->pc += 2; | ||
226 | -- | 53 | -- |
227 | 2.20.1 | 54 | 2.25.1 |
228 | |||
229 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | If -cpu <cpu>,aarch64=off is used then KVM must also be used, and it | 3 | Enable the a76 for virt and sbsa board use. |
4 | and the host must support running the vcpu in 32-bit mode. Also, if | ||
5 | -cpu <cpu>,aarch64=on is used, then it doesn't matter if kvm is | ||
6 | enabled or not. | ||
7 | 4 | ||
8 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20220506180242.216785-24-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/kvm_arm.h | 14 ++++++++++++++ | 10 | docs/system/arm/virt.rst | 1 + |
13 | target/arm/cpu64.c | 12 ++++++------ | 11 | hw/arm/sbsa-ref.c | 1 + |
14 | target/arm/kvm64.c | 9 +++++++++ | 12 | hw/arm/virt.c | 1 + |
15 | 3 files changed, 29 insertions(+), 6 deletions(-) | 13 | target/arm/cpu64.c | 66 ++++++++++++++++++++++++++++++++++++++++ |
14 | 4 files changed, 69 insertions(+) | ||
16 | 15 | ||
17 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 16 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/kvm_arm.h | 18 | --- a/docs/system/arm/virt.rst |
20 | +++ b/target/arm/kvm_arm.h | 19 | +++ b/docs/system/arm/virt.rst |
21 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); | 20 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: |
22 | */ | 21 | - ``cortex-a53`` (64-bit) |
23 | void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); | 22 | - ``cortex-a57`` (64-bit) |
24 | 23 | - ``cortex-a72`` (64-bit) | |
25 | +/** | 24 | +- ``cortex-a76`` (64-bit) |
26 | + * kvm_arm_aarch32_supported: | 25 | - ``a64fx`` (64-bit) |
27 | + * @cs: CPUState | 26 | - ``host`` (with KVM only) |
28 | + * | 27 | - ``max`` (same as ``host`` for KVM; best possible emulation with TCG) |
29 | + * Returns: true if the KVM VCPU can enable AArch32 mode | 28 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
30 | + * and false otherwise. | 29 | index XXXXXXX..XXXXXXX 100644 |
31 | + */ | 30 | --- a/hw/arm/sbsa-ref.c |
32 | +bool kvm_arm_aarch32_supported(CPUState *cs); | 31 | +++ b/hw/arm/sbsa-ref.c |
33 | + | 32 | @@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = { |
34 | /** | 33 | static const char * const valid_cpus[] = { |
35 | * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the | 34 | ARM_CPU_TYPE_NAME("cortex-a57"), |
36 | * IPA address space supported by KVM | 35 | ARM_CPU_TYPE_NAME("cortex-a72"), |
37 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | 36 | + ARM_CPU_TYPE_NAME("cortex-a76"), |
38 | cpu->host_cpu_probe_failed = true; | 37 | ARM_CPU_TYPE_NAME("max"), |
39 | } | 38 | }; |
40 | 39 | ||
41 | +static inline bool kvm_arm_aarch32_supported(CPUState *cs) | 40 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
42 | +{ | 41 | index XXXXXXX..XXXXXXX 100644 |
43 | + return false; | 42 | --- a/hw/arm/virt.c |
44 | +} | 43 | +++ b/hw/arm/virt.c |
45 | + | 44 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { |
46 | static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | 45 | ARM_CPU_TYPE_NAME("cortex-a53"), |
47 | { | 46 | ARM_CPU_TYPE_NAME("cortex-a57"), |
48 | return -ENOENT; | 47 | ARM_CPU_TYPE_NAME("cortex-a72"), |
48 | + ARM_CPU_TYPE_NAME("cortex-a76"), | ||
49 | ARM_CPU_TYPE_NAME("a64fx"), | ||
50 | ARM_CPU_TYPE_NAME("host"), | ||
51 | ARM_CPU_TYPE_NAME("max"), | ||
49 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 52 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
50 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/target/arm/cpu64.c | 54 | --- a/target/arm/cpu64.c |
52 | +++ b/target/arm/cpu64.c | 55 | +++ b/target/arm/cpu64.c |
53 | @@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp) | 56 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) |
54 | * restriction allows us to avoid fixing up functionality that assumes a | 57 | define_cortex_a72_a57_a53_cp_reginfo(cpu); |
55 | * uniform execution state like do_interrupt. | ||
56 | */ | ||
57 | - if (!kvm_enabled()) { | ||
58 | - error_setg(errp, "'aarch64' feature cannot be disabled " | ||
59 | - "unless KVM is enabled"); | ||
60 | - return; | ||
61 | - } | ||
62 | - | ||
63 | if (value == false) { | ||
64 | + if (!kvm_enabled() || !kvm_arm_aarch32_supported(CPU(cpu))) { | ||
65 | + error_setg(errp, "'aarch64' feature cannot be disabled " | ||
66 | + "unless KVM is enabled and 32-bit EL1 " | ||
67 | + "is supported"); | ||
68 | + return; | ||
69 | + } | ||
70 | unset_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
71 | } else { | ||
72 | set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
73 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/kvm64.c | ||
76 | +++ b/target/arm/kvm64.c | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | #include "exec/gdbstub.h" | ||
79 | #include "sysemu/sysemu.h" | ||
80 | #include "sysemu/kvm.h" | ||
81 | +#include "sysemu/kvm_int.h" | ||
82 | #include "kvm_arm.h" | ||
83 | +#include "hw/boards.h" | ||
84 | #include "internals.h" | ||
85 | |||
86 | static bool have_guest_debug; | ||
87 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | ||
88 | return true; | ||
89 | } | 58 | } |
90 | 59 | ||
91 | +bool kvm_arm_aarch32_supported(CPUState *cpu) | 60 | +static void aarch64_a76_initfn(Object *obj) |
92 | +{ | 61 | +{ |
93 | + KVMState *s = KVM_STATE(current_machine->accelerator); | 62 | + ARMCPU *cpu = ARM_CPU(obj); |
94 | + | 63 | + |
95 | + return kvm_check_extension(s, KVM_CAP_ARM_EL1_32BIT); | 64 | + cpu->dtb_compatible = "arm,cortex-a76"; |
65 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
66 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
67 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
68 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
69 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
70 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
71 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
73 | + | ||
74 | + /* Ordered by B2.4 AArch64 registers by functional group */ | ||
75 | + cpu->clidr = 0x82000023; | ||
76 | + cpu->ctr = 0x8444C004; | ||
77 | + cpu->dcz_blocksize = 4; | ||
78 | + cpu->isar.id_aa64dfr0 = 0x0000000010305408ull; | ||
79 | + cpu->isar.id_aa64isar0 = 0x0000100010211120ull; | ||
80 | + cpu->isar.id_aa64isar1 = 0x0000000000100001ull; | ||
81 | + cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull; | ||
82 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
83 | + cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; | ||
84 | + cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ | ||
85 | + cpu->isar.id_aa64pfr1 = 0x0000000000000010ull; | ||
86 | + cpu->id_afr0 = 0x00000000; | ||
87 | + cpu->isar.id_dfr0 = 0x04010088; | ||
88 | + cpu->isar.id_isar0 = 0x02101110; | ||
89 | + cpu->isar.id_isar1 = 0x13112111; | ||
90 | + cpu->isar.id_isar2 = 0x21232042; | ||
91 | + cpu->isar.id_isar3 = 0x01112131; | ||
92 | + cpu->isar.id_isar4 = 0x00010142; | ||
93 | + cpu->isar.id_isar5 = 0x01011121; | ||
94 | + cpu->isar.id_isar6 = 0x00000010; | ||
95 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
96 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
97 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
98 | + cpu->isar.id_mmfr3 = 0x02122211; | ||
99 | + cpu->isar.id_mmfr4 = 0x00021110; | ||
100 | + cpu->isar.id_pfr0 = 0x10010131; | ||
101 | + cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ | ||
102 | + cpu->isar.id_pfr2 = 0x00000011; | ||
103 | + cpu->midr = 0x414fd0b1; /* r4p1 */ | ||
104 | + cpu->revidr = 0; | ||
105 | + | ||
106 | + /* From B2.18 CCSIDR_EL1 */ | ||
107 | + cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ | ||
108 | + cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ | ||
109 | + cpu->ccsidr[2] = 0x707fe03a; /* 512KB L2 cache */ | ||
110 | + | ||
111 | + /* From B2.93 SCTLR_EL3 */ | ||
112 | + cpu->reset_sctlr = 0x30c50838; | ||
113 | + | ||
114 | + /* From B4.23 ICH_VTR_EL2 */ | ||
115 | + cpu->gic_num_lrs = 4; | ||
116 | + cpu->gic_vpribits = 5; | ||
117 | + cpu->gic_vprebits = 5; | ||
118 | + | ||
119 | + /* From B5.1 AdvSIMD AArch64 register summary */ | ||
120 | + cpu->isar.mvfr0 = 0x10110222; | ||
121 | + cpu->isar.mvfr1 = 0x13211111; | ||
122 | + cpu->isar.mvfr2 = 0x00000043; | ||
96 | +} | 123 | +} |
97 | + | 124 | + |
98 | #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 | 125 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) |
99 | 126 | { | |
100 | int kvm_arch_init_vcpu(CPUState *cs) | 127 | /* |
128 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { | ||
129 | { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, | ||
130 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, | ||
131 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | ||
132 | + { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, | ||
133 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, | ||
134 | { .name = "max", .initfn = aarch64_max_initfn }, | ||
135 | #if defined(CONFIG_KVM) || defined(CONFIG_HVF) | ||
101 | -- | 136 | -- |
102 | 2.20.1 | 137 | 2.25.1 |
103 | |||
104 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Provide a common routine for the places that require ALIGN(PC, 4) | 3 | Enable the n1 for virt and sbsa board use. |
4 | as the base address as opposed to plain PC. The two are always | ||
5 | the same for A32, but the difference is meaningful for thumb mode. | ||
6 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Message-id: 20220506180242.216785-25-richard.henderson@linaro.org |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20190807045335.1361-5-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 9 | --- |
13 | target/arm/translate-vfp.inc.c | 38 ++------ | 10 | docs/system/arm/virt.rst | 1 + |
14 | target/arm/translate.c | 166 +++++++++++++++------------------ | 11 | hw/arm/sbsa-ref.c | 1 + |
15 | 2 files changed, 82 insertions(+), 122 deletions(-) | 12 | hw/arm/virt.c | 1 + |
13 | target/arm/cpu64.c | 66 ++++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 69 insertions(+) | ||
16 | 15 | ||
17 | diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c | 16 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate-vfp.inc.c | 18 | --- a/docs/system/arm/virt.rst |
20 | +++ b/target/arm/translate-vfp.inc.c | 19 | +++ b/docs/system/arm/virt.rst |
21 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | 20 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: |
22 | offset = -offset; | 21 | - ``cortex-a76`` (64-bit) |
23 | } | 22 | - ``a64fx`` (64-bit) |
24 | 23 | - ``host`` (with KVM only) | |
25 | - if (s->thumb && a->rn == 15) { | 24 | +- ``neoverse-n1`` (64-bit) |
26 | - /* This is actually UNPREDICTABLE */ | 25 | - ``max`` (same as ``host`` for KVM; best possible emulation with TCG) |
27 | - addr = tcg_temp_new_i32(); | 26 | |
28 | - tcg_gen_movi_i32(addr, s->pc & ~2); | 27 | Note that the default is ``cortex-a15``, so for an AArch64 guest you must |
29 | - } else { | 28 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
30 | - addr = load_reg(s, a->rn); | ||
31 | - } | ||
32 | - tcg_gen_addi_i32(addr, addr, offset); | ||
33 | + /* For thumb, use of PC is UNPREDICTABLE. */ | ||
34 | + addr = add_reg_for_lit(s, a->rn, offset); | ||
35 | tmp = tcg_temp_new_i32(); | ||
36 | if (a->l) { | ||
37 | gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
39 | offset = -offset; | ||
40 | } | ||
41 | |||
42 | - if (s->thumb && a->rn == 15) { | ||
43 | - /* This is actually UNPREDICTABLE */ | ||
44 | - addr = tcg_temp_new_i32(); | ||
45 | - tcg_gen_movi_i32(addr, s->pc & ~2); | ||
46 | - } else { | ||
47 | - addr = load_reg(s, a->rn); | ||
48 | - } | ||
49 | - tcg_gen_addi_i32(addr, addr, offset); | ||
50 | + /* For thumb, use of PC is UNPREDICTABLE. */ | ||
51 | + addr = add_reg_for_lit(s, a->rn, offset); | ||
52 | tmp = tcg_temp_new_i64(); | ||
53 | if (a->l) { | ||
54 | gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | - if (s->thumb && a->rn == 15) { | ||
60 | - /* This is actually UNPREDICTABLE */ | ||
61 | - addr = tcg_temp_new_i32(); | ||
62 | - tcg_gen_movi_i32(addr, s->pc & ~2); | ||
63 | - } else { | ||
64 | - addr = load_reg(s, a->rn); | ||
65 | - } | ||
66 | + /* For thumb, use of PC is UNPREDICTABLE. */ | ||
67 | + addr = add_reg_for_lit(s, a->rn, 0); | ||
68 | if (a->p) { | ||
69 | /* pre-decrement */ | ||
70 | tcg_gen_addi_i32(addr, addr, -(a->imm << 2)); | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
72 | return true; | ||
73 | } | ||
74 | |||
75 | - if (s->thumb && a->rn == 15) { | ||
76 | - /* This is actually UNPREDICTABLE */ | ||
77 | - addr = tcg_temp_new_i32(); | ||
78 | - tcg_gen_movi_i32(addr, s->pc & ~2); | ||
79 | - } else { | ||
80 | - addr = load_reg(s, a->rn); | ||
81 | - } | ||
82 | + /* For thumb, use of PC is UNPREDICTABLE. */ | ||
83 | + addr = add_reg_for_lit(s, a->rn, 0); | ||
84 | if (a->p) { | ||
85 | /* pre-decrement */ | ||
86 | tcg_gen_addi_i32(addr, addr, -(a->imm << 2)); | ||
87 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
88 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
89 | --- a/target/arm/translate.c | 30 | --- a/hw/arm/sbsa-ref.c |
90 | +++ b/target/arm/translate.c | 31 | +++ b/hw/arm/sbsa-ref.c |
91 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_reg(DisasContext *s, int reg) | 32 | @@ -XXX,XX +XXX,XX @@ static const char * const valid_cpus[] = { |
92 | return tmp; | 33 | ARM_CPU_TYPE_NAME("cortex-a57"), |
34 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
35 | ARM_CPU_TYPE_NAME("cortex-a76"), | ||
36 | + ARM_CPU_TYPE_NAME("neoverse-n1"), | ||
37 | ARM_CPU_TYPE_NAME("max"), | ||
38 | }; | ||
39 | |||
40 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/hw/arm/virt.c | ||
43 | +++ b/hw/arm/virt.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { | ||
45 | ARM_CPU_TYPE_NAME("cortex-a72"), | ||
46 | ARM_CPU_TYPE_NAME("cortex-a76"), | ||
47 | ARM_CPU_TYPE_NAME("a64fx"), | ||
48 | + ARM_CPU_TYPE_NAME("neoverse-n1"), | ||
49 | ARM_CPU_TYPE_NAME("host"), | ||
50 | ARM_CPU_TYPE_NAME("max"), | ||
51 | }; | ||
52 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/cpu64.c | ||
55 | +++ b/target/arm/cpu64.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a76_initfn(Object *obj) | ||
57 | cpu->isar.mvfr2 = 0x00000043; | ||
93 | } | 58 | } |
94 | 59 | ||
95 | +/* | 60 | +static void aarch64_neoverse_n1_initfn(Object *obj) |
96 | + * Create a new temp, REG + OFS, except PC is ALIGN(PC, 4). | ||
97 | + * This is used for load/store for which use of PC implies (literal), | ||
98 | + * or ADD that implies ADR. | ||
99 | + */ | ||
100 | +static TCGv_i32 add_reg_for_lit(DisasContext *s, int reg, int ofs) | ||
101 | +{ | 61 | +{ |
102 | + TCGv_i32 tmp = tcg_temp_new_i32(); | 62 | + ARMCPU *cpu = ARM_CPU(obj); |
103 | + | 63 | + |
104 | + if (reg == 15) { | 64 | + cpu->dtb_compatible = "arm,neoverse-n1"; |
105 | + tcg_gen_movi_i32(tmp, (read_pc(s) & ~3) + ofs); | 65 | + set_feature(&cpu->env, ARM_FEATURE_V8); |
106 | + } else { | 66 | + set_feature(&cpu->env, ARM_FEATURE_NEON); |
107 | + tcg_gen_addi_i32(tmp, cpu_R[reg], ofs); | 67 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); |
108 | + } | 68 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); |
109 | + return tmp; | 69 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); |
70 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
71 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
73 | + | ||
74 | + /* Ordered by B2.4 AArch64 registers by functional group */ | ||
75 | + cpu->clidr = 0x82000023; | ||
76 | + cpu->ctr = 0x8444c004; | ||
77 | + cpu->dcz_blocksize = 4; | ||
78 | + cpu->isar.id_aa64dfr0 = 0x0000000110305408ull; | ||
79 | + cpu->isar.id_aa64isar0 = 0x0000100010211120ull; | ||
80 | + cpu->isar.id_aa64isar1 = 0x0000000000100001ull; | ||
81 | + cpu->isar.id_aa64mmfr0 = 0x0000000000101125ull; | ||
82 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
83 | + cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; | ||
84 | + cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ | ||
85 | + cpu->isar.id_aa64pfr1 = 0x0000000000000020ull; | ||
86 | + cpu->id_afr0 = 0x00000000; | ||
87 | + cpu->isar.id_dfr0 = 0x04010088; | ||
88 | + cpu->isar.id_isar0 = 0x02101110; | ||
89 | + cpu->isar.id_isar1 = 0x13112111; | ||
90 | + cpu->isar.id_isar2 = 0x21232042; | ||
91 | + cpu->isar.id_isar3 = 0x01112131; | ||
92 | + cpu->isar.id_isar4 = 0x00010142; | ||
93 | + cpu->isar.id_isar5 = 0x01011121; | ||
94 | + cpu->isar.id_isar6 = 0x00000010; | ||
95 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
96 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
97 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
98 | + cpu->isar.id_mmfr3 = 0x02122211; | ||
99 | + cpu->isar.id_mmfr4 = 0x00021110; | ||
100 | + cpu->isar.id_pfr0 = 0x10010131; | ||
101 | + cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ | ||
102 | + cpu->isar.id_pfr2 = 0x00000011; | ||
103 | + cpu->midr = 0x414fd0c1; /* r4p1 */ | ||
104 | + cpu->revidr = 0; | ||
105 | + | ||
106 | + /* From B2.23 CCSIDR_EL1 */ | ||
107 | + cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ | ||
108 | + cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ | ||
109 | + cpu->ccsidr[2] = 0x70ffe03a; /* 1MB L2 cache */ | ||
110 | + | ||
111 | + /* From B2.98 SCTLR_EL3 */ | ||
112 | + cpu->reset_sctlr = 0x30c50838; | ||
113 | + | ||
114 | + /* From B4.23 ICH_VTR_EL2 */ | ||
115 | + cpu->gic_num_lrs = 4; | ||
116 | + cpu->gic_vpribits = 5; | ||
117 | + cpu->gic_vprebits = 5; | ||
118 | + | ||
119 | + /* From B5.1 AdvSIMD AArch64 register summary */ | ||
120 | + cpu->isar.mvfr0 = 0x10110222; | ||
121 | + cpu->isar.mvfr1 = 0x13211111; | ||
122 | + cpu->isar.mvfr2 = 0x00000043; | ||
110 | +} | 123 | +} |
111 | + | 124 | + |
112 | /* Set a CPU register. The source must be a temporary and will be | 125 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) |
113 | marked as dead. */ | 126 | { |
114 | static void store_reg(DisasContext *s, int reg, TCGv_i32 var) | 127 | /* |
115 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 128 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { |
116 | */ | 129 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, |
117 | bool wback = extract32(insn, 21, 1); | 130 | { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, |
118 | 131 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, | |
119 | - if (rn == 15) { | 132 | + { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn }, |
120 | - if (insn & (1 << 21)) { | 133 | { .name = "max", .initfn = aarch64_max_initfn }, |
121 | - /* UNPREDICTABLE */ | 134 | #if defined(CONFIG_KVM) || defined(CONFIG_HVF) |
122 | - goto illegal_op; | 135 | { .name = "host", .initfn = aarch64_host_initfn }, |
123 | - } | ||
124 | - addr = tcg_temp_new_i32(); | ||
125 | - tcg_gen_movi_i32(addr, s->pc & ~3); | ||
126 | - } else { | ||
127 | - addr = load_reg(s, rn); | ||
128 | + if (rn == 15 && (insn & (1 << 21))) { | ||
129 | + /* UNPREDICTABLE */ | ||
130 | + goto illegal_op; | ||
131 | } | ||
132 | + | ||
133 | + addr = add_reg_for_lit(s, rn, 0); | ||
134 | offset = (insn & 0xff) * 4; | ||
135 | if ((insn & (1 << 23)) == 0) { | ||
136 | offset = -offset; | ||
137 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
138 | store_reg(s, rd, tmp); | ||
139 | } else { | ||
140 | /* Add/sub 12-bit immediate. */ | ||
141 | - if (rn == 15) { | ||
142 | - offset = s->pc & ~(uint32_t)3; | ||
143 | - if (insn & (1 << 23)) | ||
144 | - offset -= imm; | ||
145 | - else | ||
146 | - offset += imm; | ||
147 | - tmp = tcg_temp_new_i32(); | ||
148 | - tcg_gen_movi_i32(tmp, offset); | ||
149 | - store_reg(s, rd, tmp); | ||
150 | + if (insn & (1 << 23)) { | ||
151 | + imm = -imm; | ||
152 | + } | ||
153 | + tmp = add_reg_for_lit(s, rn, imm); | ||
154 | + if (rn == 13 && rd == 13) { | ||
155 | + /* ADD SP, SP, imm or SUB SP, SP, imm */ | ||
156 | + store_sp_checked(s, tmp); | ||
157 | } else { | ||
158 | - tmp = load_reg(s, rn); | ||
159 | - if (insn & (1 << 23)) | ||
160 | - tcg_gen_subi_i32(tmp, tmp, imm); | ||
161 | - else | ||
162 | - tcg_gen_addi_i32(tmp, tmp, imm); | ||
163 | - if (rn == 13 && rd == 13) { | ||
164 | - /* ADD SP, SP, imm or SUB SP, SP, imm */ | ||
165 | - store_sp_checked(s, tmp); | ||
166 | - } else { | ||
167 | - store_reg(s, rd, tmp); | ||
168 | - } | ||
169 | + store_reg(s, rd, tmp); | ||
170 | } | ||
171 | } | ||
172 | } | ||
173 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
174 | } | ||
175 | } | ||
176 | memidx = get_mem_index(s); | ||
177 | - if (rn == 15) { | ||
178 | - addr = tcg_temp_new_i32(); | ||
179 | - /* PC relative. */ | ||
180 | - /* s->pc has already been incremented by 4. */ | ||
181 | - imm = s->pc & 0xfffffffc; | ||
182 | - if (insn & (1 << 23)) | ||
183 | - imm += insn & 0xfff; | ||
184 | - else | ||
185 | - imm -= insn & 0xfff; | ||
186 | - tcg_gen_movi_i32(addr, imm); | ||
187 | + imm = insn & 0xfff; | ||
188 | + if (insn & (1 << 23)) { | ||
189 | + /* PC relative or Positive offset. */ | ||
190 | + addr = add_reg_for_lit(s, rn, imm); | ||
191 | + } else if (rn == 15) { | ||
192 | + /* PC relative with negative offset. */ | ||
193 | + addr = add_reg_for_lit(s, rn, -imm); | ||
194 | } else { | ||
195 | addr = load_reg(s, rn); | ||
196 | - if (insn & (1 << 23)) { | ||
197 | - /* Positive offset. */ | ||
198 | - imm = insn & 0xfff; | ||
199 | - tcg_gen_addi_i32(addr, addr, imm); | ||
200 | - } else { | ||
201 | - imm = insn & 0xff; | ||
202 | - switch ((insn >> 8) & 0xf) { | ||
203 | - case 0x0: /* Shifted Register. */ | ||
204 | - shift = (insn >> 4) & 0xf; | ||
205 | - if (shift > 3) { | ||
206 | - tcg_temp_free_i32(addr); | ||
207 | - goto illegal_op; | ||
208 | - } | ||
209 | - tmp = load_reg(s, rm); | ||
210 | - if (shift) | ||
211 | - tcg_gen_shli_i32(tmp, tmp, shift); | ||
212 | - tcg_gen_add_i32(addr, addr, tmp); | ||
213 | - tcg_temp_free_i32(tmp); | ||
214 | - break; | ||
215 | - case 0xc: /* Negative offset. */ | ||
216 | - tcg_gen_addi_i32(addr, addr, -imm); | ||
217 | - break; | ||
218 | - case 0xe: /* User privilege. */ | ||
219 | - tcg_gen_addi_i32(addr, addr, imm); | ||
220 | - memidx = get_a32_user_mem_index(s); | ||
221 | - break; | ||
222 | - case 0x9: /* Post-decrement. */ | ||
223 | - imm = -imm; | ||
224 | - /* Fall through. */ | ||
225 | - case 0xb: /* Post-increment. */ | ||
226 | - postinc = 1; | ||
227 | - writeback = 1; | ||
228 | - break; | ||
229 | - case 0xd: /* Pre-decrement. */ | ||
230 | - imm = -imm; | ||
231 | - /* Fall through. */ | ||
232 | - case 0xf: /* Pre-increment. */ | ||
233 | - writeback = 1; | ||
234 | - break; | ||
235 | - default: | ||
236 | + imm = insn & 0xff; | ||
237 | + switch ((insn >> 8) & 0xf) { | ||
238 | + case 0x0: /* Shifted Register. */ | ||
239 | + shift = (insn >> 4) & 0xf; | ||
240 | + if (shift > 3) { | ||
241 | tcg_temp_free_i32(addr); | ||
242 | goto illegal_op; | ||
243 | } | ||
244 | + tmp = load_reg(s, rm); | ||
245 | + if (shift) { | ||
246 | + tcg_gen_shli_i32(tmp, tmp, shift); | ||
247 | + } | ||
248 | + tcg_gen_add_i32(addr, addr, tmp); | ||
249 | + tcg_temp_free_i32(tmp); | ||
250 | + break; | ||
251 | + case 0xc: /* Negative offset. */ | ||
252 | + tcg_gen_addi_i32(addr, addr, -imm); | ||
253 | + break; | ||
254 | + case 0xe: /* User privilege. */ | ||
255 | + tcg_gen_addi_i32(addr, addr, imm); | ||
256 | + memidx = get_a32_user_mem_index(s); | ||
257 | + break; | ||
258 | + case 0x9: /* Post-decrement. */ | ||
259 | + imm = -imm; | ||
260 | + /* Fall through. */ | ||
261 | + case 0xb: /* Post-increment. */ | ||
262 | + postinc = 1; | ||
263 | + writeback = 1; | ||
264 | + break; | ||
265 | + case 0xd: /* Pre-decrement. */ | ||
266 | + imm = -imm; | ||
267 | + /* Fall through. */ | ||
268 | + case 0xf: /* Pre-increment. */ | ||
269 | + writeback = 1; | ||
270 | + break; | ||
271 | + default: | ||
272 | + tcg_temp_free_i32(addr); | ||
273 | + goto illegal_op; | ||
274 | } | ||
275 | } | ||
276 | |||
277 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
278 | if (insn & (1 << 11)) { | ||
279 | rd = (insn >> 8) & 7; | ||
280 | /* load pc-relative. Bit 1 of PC is ignored. */ | ||
281 | - val = read_pc(s) + ((insn & 0xff) * 4); | ||
282 | - val &= ~(uint32_t)2; | ||
283 | - addr = tcg_temp_new_i32(); | ||
284 | - tcg_gen_movi_i32(addr, val); | ||
285 | + addr = add_reg_for_lit(s, 15, (insn & 0xff) * 4); | ||
286 | tmp = tcg_temp_new_i32(); | ||
287 | gen_aa32_ld32u_iss(s, tmp, addr, get_mem_index(s), | ||
288 | rd | ISSIs16Bit); | ||
289 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
290 | * - Add PC/SP (immediate) | ||
291 | */ | ||
292 | rd = (insn >> 8) & 7; | ||
293 | - if (insn & (1 << 11)) { | ||
294 | - /* SP */ | ||
295 | - tmp = load_reg(s, 13); | ||
296 | - } else { | ||
297 | - /* PC. bit 1 is ignored. */ | ||
298 | - tmp = tcg_temp_new_i32(); | ||
299 | - tcg_gen_movi_i32(tmp, read_pc(s) & ~(uint32_t)2); | ||
300 | - } | ||
301 | val = (insn & 0xff) * 4; | ||
302 | - tcg_gen_addi_i32(tmp, tmp, val); | ||
303 | + tmp = add_reg_for_lit(s, insn & (1 << 11) ? 13 : 15, val); | ||
304 | store_reg(s, rd, tmp); | ||
305 | break; | ||
306 | |||
307 | -- | 136 | -- |
308 | 2.20.1 | 137 | 2.25.1 |
309 | |||
310 | diff view generated by jsdifflib |
1 | From: Aaron Hill <aa1ronham@gmail.com> | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | This commit properly sets the ENET_BD_BDU flag once the emulated FEC controller | 3 | The sbsa-ref machine is continuously evolving. Some of the changes we |
4 | has finished processing the last descriptor. This is done for both transmit | 4 | want to make in the near future, to align with real components (e.g. |
5 | and receive descriptors. | 5 | the GIC-700), will break compatibility for existing firmware. |
6 | 6 | ||
7 | This allows the QNX 7.0.0 BSP for the Sabrelite board (which can be | 7 | Introduce two new properties to the DT generated on machine generation: |
8 | found at http://blackberry.qnx.com/en/developers/bsp) to properly | 8 | - machine-version-major |
9 | control the FEC. Without this patch, the BSP ethernet driver will never | 9 | To be incremented when a platform change makes the machine |
10 | re-use FEC descriptors, as the unset ENET_BD_BDU flag will cause | 10 | incompatible with existing firmware. |
11 | it to believe that the descriptors are still in use by the NIC. | 11 | - machine-version-minor |
12 | To be incremented when functionality is added to the machine | ||
13 | without causing incompatibility with existing firmware. | ||
14 | to be reset to 0 when machine-version-major is incremented. | ||
12 | 15 | ||
13 | Note that Linux does not appear to use this field at all, and is | 16 | This versioning scheme is *neither*: |
14 | unaffected by this patch. | 17 | - A QEMU versioned machine type; a given version of QEMU will emulate |
18 | a given version of the platform. | ||
19 | - A reflection of level of SBSA (now SystemReady SR) support provided. | ||
15 | 20 | ||
16 | Without this patch, QNX will think that the NIC is still processing its | 21 | The version will increment on guest-visible functional changes only, |
17 | transaction descriptors, and won't send any more data over the network. | 22 | akin to a revision ID register found on a physical platform. |
18 | 23 | ||
19 | For reference: | 24 | These properties are both introduced with the value 0. |
25 | (Hence, a machine where the DT is lacking these nodes is equivalent | ||
26 | to version 0.0.) | ||
20 | 27 | ||
21 | On page 1192 of the I.MX 6DQ reference manual revision (Rev. 5, 06/2018), | 28 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> |
22 | which can be found at https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/i.mx-applications-processors/i.mx-6-processors/i.mx-6quad-processors-high-performance-3d-graphics-hd-video-arm-cortex-a9-core:i.MX6Q?&tab=Documentation_Tab&linkline=Application-Note | 29 | Message-id: 20220505113947.75714-1-quic_llindhol@quicinc.com |
23 | 30 | Cc: Peter Maydell <peter.maydell@linaro.org> | |
24 | the 'BDU' field is described as follows for the 'Enhanced transmit | 31 | Cc: Radoslaw Biernacki <rad@semihalf.com> |
25 | buffer descriptor': | 32 | Cc: Cédric Le Goater <clg@kaod.org> |
26 | |||
27 | 'Last buffer descriptor update done. Indicates that the last BD data has been updated by | ||
28 | uDMA. This field is written by the user (=0) and uDMA (=1).' | ||
29 | |||
30 | The same description is used for the receive buffer descriptor. | ||
31 | |||
32 | Signed-off-by: Aaron Hill <aa1ronham@gmail.com> | ||
33 | Message-id: 20190805142417.10433-1-aaron.hill@alertinnovation.com | ||
34 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 33 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 34 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
36 | --- | 35 | --- |
37 | hw/net/imx_fec.c | 4 ++++ | 36 | hw/arm/sbsa-ref.c | 14 ++++++++++++++ |
38 | 1 file changed, 4 insertions(+) | 37 | 1 file changed, 14 insertions(+) |
39 | 38 | ||
40 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | 39 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
41 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/hw/net/imx_fec.c | 41 | --- a/hw/arm/sbsa-ref.c |
43 | +++ b/hw/net/imx_fec.c | 42 | +++ b/hw/arm/sbsa-ref.c |
44 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) | 43 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) |
45 | if (bd.option & ENET_BD_TX_INT) { | 44 | qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); |
46 | s->regs[ENET_EIR] |= int_txf; | 45 | qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); |
47 | } | 46 | |
48 | + /* Indicate that we've updated the last buffer descriptor. */ | 47 | + /* |
49 | + bd.last_buffer = ENET_BD_BDU; | 48 | + * This versioning scheme is for informing platform fw only. It is neither: |
50 | } | 49 | + * - A QEMU versioned machine type; a given version of QEMU will emulate |
51 | if (bd.option & ENET_BD_TX_INT) { | 50 | + * a given version of the platform. |
52 | s->regs[ENET_EIR] |= int_txb; | 51 | + * - A reflection of level of SBSA (now SystemReady SR) support provided. |
53 | @@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, | 52 | + * |
54 | /* Last buffer in frame. */ | 53 | + * machine-version-major: updated when changes breaking fw compatibility |
55 | bd.flags |= flags | ENET_BD_L; | 54 | + * are introduced. |
56 | FEC_PRINTF("rx frame flags %04x\n", bd.flags); | 55 | + * machine-version-minor: updated when features are added that don't break |
57 | + /* Indicate that we've updated the last buffer descriptor. */ | 56 | + * fw compatibility. |
58 | + bd.last_buffer = ENET_BD_BDU; | 57 | + */ |
59 | if (bd.option & ENET_BD_RX_INT) { | 58 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0); |
60 | s->regs[ENET_EIR] |= ENET_INT_RXF; | 59 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 0); |
61 | } | 60 | + |
61 | if (ms->numa_state->have_numa_distance) { | ||
62 | int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); | ||
63 | uint32_t *matrix = g_malloc0(size); | ||
62 | -- | 64 | -- |
63 | 2.20.1 | 65 | 2.25.1 |
64 | 66 | ||
65 | 67 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Gavin Shan <gshan@redhat.com> | ||
1 | 2 | ||
3 | This adds cluster-id in CPU instance properties, which will be used | ||
4 | by arm/virt machine. Besides, the cluster-id is also verified or | ||
5 | dumped in various spots: | ||
6 | |||
7 | * hw/core/machine.c::machine_set_cpu_numa_node() to associate | ||
8 | CPU with its NUMA node. | ||
9 | |||
10 | * hw/core/machine.c::machine_numa_finish_cpu_init() to record | ||
11 | CPU slots with no NUMA mapping set. | ||
12 | |||
13 | * hw/core/machine-hmp-cmds.c::hmp_hotpluggable_cpus() to dump | ||
14 | cluster-id. | ||
15 | |||
16 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
17 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
18 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
19 | Message-id: 20220503140304.855514-2-gshan@redhat.com | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
21 | --- | ||
22 | qapi/machine.json | 6 ++++-- | ||
23 | hw/core/machine-hmp-cmds.c | 4 ++++ | ||
24 | hw/core/machine.c | 16 ++++++++++++++++ | ||
25 | 3 files changed, 24 insertions(+), 2 deletions(-) | ||
26 | |||
27 | diff --git a/qapi/machine.json b/qapi/machine.json | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/qapi/machine.json | ||
30 | +++ b/qapi/machine.json | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | # @node-id: NUMA node ID the CPU belongs to | ||
33 | # @socket-id: socket number within node/board the CPU belongs to | ||
34 | # @die-id: die number within socket the CPU belongs to (since 4.1) | ||
35 | -# @core-id: core number within die the CPU belongs to | ||
36 | +# @cluster-id: cluster number within die the CPU belongs to (since 7.1) | ||
37 | +# @core-id: core number within cluster the CPU belongs to | ||
38 | # @thread-id: thread number within core the CPU belongs to | ||
39 | # | ||
40 | -# Note: currently there are 5 properties that could be present | ||
41 | +# Note: currently there are 6 properties that could be present | ||
42 | # but management should be prepared to pass through other | ||
43 | # properties with device_add command to allow for future | ||
44 | # interface extension. This also requires the filed names to be kept in | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | 'data': { '*node-id': 'int', | ||
47 | '*socket-id': 'int', | ||
48 | '*die-id': 'int', | ||
49 | + '*cluster-id': 'int', | ||
50 | '*core-id': 'int', | ||
51 | '*thread-id': 'int' | ||
52 | } | ||
53 | diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/core/machine-hmp-cmds.c | ||
56 | +++ b/hw/core/machine-hmp-cmds.c | ||
57 | @@ -XXX,XX +XXX,XX @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict) | ||
58 | if (c->has_die_id) { | ||
59 | monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id); | ||
60 | } | ||
61 | + if (c->has_cluster_id) { | ||
62 | + monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n", | ||
63 | + c->cluster_id); | ||
64 | + } | ||
65 | if (c->has_core_id) { | ||
66 | monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id); | ||
67 | } | ||
68 | diff --git a/hw/core/machine.c b/hw/core/machine.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/core/machine.c | ||
71 | +++ b/hw/core/machine.c | ||
72 | @@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine, | ||
73 | return; | ||
74 | } | ||
75 | |||
76 | + if (props->has_cluster_id && !slot->props.has_cluster_id) { | ||
77 | + error_setg(errp, "cluster-id is not supported"); | ||
78 | + return; | ||
79 | + } | ||
80 | + | ||
81 | if (props->has_socket_id && !slot->props.has_socket_id) { | ||
82 | error_setg(errp, "socket-id is not supported"); | ||
83 | return; | ||
84 | @@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine, | ||
85 | continue; | ||
86 | } | ||
87 | |||
88 | + if (props->has_cluster_id && | ||
89 | + props->cluster_id != slot->props.cluster_id) { | ||
90 | + continue; | ||
91 | + } | ||
92 | + | ||
93 | if (props->has_die_id && props->die_id != slot->props.die_id) { | ||
94 | continue; | ||
95 | } | ||
96 | @@ -XXX,XX +XXX,XX @@ static char *cpu_slot_to_string(const CPUArchId *cpu) | ||
97 | } | ||
98 | g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id); | ||
99 | } | ||
100 | + if (cpu->props.has_cluster_id) { | ||
101 | + if (s->len) { | ||
102 | + g_string_append_printf(s, ", "); | ||
103 | + } | ||
104 | + g_string_append_printf(s, "cluster-id: %"PRId64, cpu->props.cluster_id); | ||
105 | + } | ||
106 | if (cpu->props.has_core_id) { | ||
107 | if (s->len) { | ||
108 | g_string_append_printf(s, ", "); | ||
109 | -- | ||
110 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | A couple return -EINVAL's forgot their '-'s. | 3 | The CPU topology isn't enabled on arm/virt machine yet, but we're |
4 | going to do it in next patch. After the CPU topology is enabled by | ||
5 | next patch, "thread-id=1" becomes invalid because the CPU core is | ||
6 | preferred on arm/virt machine. It means these two CPUs have 0/1 | ||
7 | as their core IDs, but their thread IDs are all 0. It will trigger | ||
8 | test failure as the following message indicates: | ||
4 | 9 | ||
5 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 10 | [14/21 qemu:qtest+qtest-aarch64 / qtest-aarch64/numa-test ERROR |
6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 11 | 1.48s killed by signal 6 SIGABRT |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 12 | >>> G_TEST_DBUS_DAEMON=/home/gavin/sandbox/qemu.main/tests/dbus-vmstate-daemon.sh \ |
13 | QTEST_QEMU_STORAGE_DAEMON_BINARY=./storage-daemon/qemu-storage-daemon \ | ||
14 | QTEST_QEMU_BINARY=./qemu-system-aarch64 \ | ||
15 | QTEST_QEMU_IMG=./qemu-img MALLOC_PERTURB_=83 \ | ||
16 | /home/gavin/sandbox/qemu.main/build/tests/qtest/numa-test --tap -k | ||
17 | ―――――――――――――――――――――――――――――――――――――――――――――― | ||
18 | stderr: | ||
19 | qemu-system-aarch64: -numa cpu,node-id=0,thread-id=1: no match found | ||
20 | |||
21 | This fixes the issue by providing comprehensive SMP configurations | ||
22 | in aarch64_numa_cpu(). The SMP configurations aren't used before | ||
23 | the CPU topology is enabled in next patch. | ||
24 | |||
25 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
26 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
27 | Message-id: 20220503140304.855514-3-gshan@redhat.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 29 | --- |
10 | target/arm/kvm64.c | 4 ++-- | 30 | tests/qtest/numa-test.c | 3 ++- |
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | 31 | 1 file changed, 2 insertions(+), 1 deletion(-) |
12 | 32 | ||
13 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 33 | diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c |
14 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/kvm64.c | 35 | --- a/tests/qtest/numa-test.c |
16 | +++ b/target/arm/kvm64.c | 36 | +++ b/tests/qtest/numa-test.c |
17 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | 37 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) |
18 | write_cpustate_to_list(cpu, true); | 38 | QTestState *qts; |
19 | 39 | g_autofree char *cli = NULL; | |
20 | if (!write_list_to_kvmstate(cpu, level)) { | 40 | |
21 | - return EINVAL; | 41 | - cli = make_cli(data, "-machine smp.cpus=2 " |
22 | + return -EINVAL; | 42 | + cli = make_cli(data, "-machine " |
23 | } | 43 | + "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 " |
24 | 44 | "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 " | |
25 | kvm_arm_sync_mpstate_to_kvm(cpu); | 45 | "-numa cpu,node-id=1,thread-id=0 " |
26 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | 46 | "-numa cpu,node-id=0,thread-id=1"); |
27 | } | ||
28 | |||
29 | if (!write_kvmstate_to_list(cpu)) { | ||
30 | - return EINVAL; | ||
31 | + return -EINVAL; | ||
32 | } | ||
33 | /* Note that it's OK to have registers which aren't in CPUState, | ||
34 | * so we can ignore a failure return here. | ||
35 | -- | 47 | -- |
36 | 2.20.1 | 48 | 2.25.1 |
37 | 49 | ||
38 | 50 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Gavin Shan <gshan@redhat.com> | ||
1 | 2 | ||
3 | Currently, the SMP configuration isn't considered when the CPU | ||
4 | topology is populated. In this case, it's impossible to provide | ||
5 | the default CPU-to-NUMA mapping or association based on the socket | ||
6 | ID of the given CPU. | ||
7 | |||
8 | This takes account of SMP configuration when the CPU topology | ||
9 | is populated. The die ID for the given CPU isn't assigned since | ||
10 | it's not supported on arm/virt machine. Besides, the used SMP | ||
11 | configuration in qtest/numa-test/aarch64_numa_cpu() is corrcted | ||
12 | to avoid testing failure | ||
13 | |||
14 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
15 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
16 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
17 | Message-id: 20220503140304.855514-4-gshan@redhat.com | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | hw/arm/virt.c | 15 ++++++++++++++- | ||
21 | 1 file changed, 14 insertions(+), 1 deletion(-) | ||
22 | |||
23 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/hw/arm/virt.c | ||
26 | +++ b/hw/arm/virt.c | ||
27 | @@ -XXX,XX +XXX,XX @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) | ||
28 | int n; | ||
29 | unsigned int max_cpus = ms->smp.max_cpus; | ||
30 | VirtMachineState *vms = VIRT_MACHINE(ms); | ||
31 | + MachineClass *mc = MACHINE_GET_CLASS(vms); | ||
32 | |||
33 | if (ms->possible_cpus) { | ||
34 | assert(ms->possible_cpus->len == max_cpus); | ||
35 | @@ -XXX,XX +XXX,XX @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) | ||
36 | ms->possible_cpus->cpus[n].type = ms->cpu_type; | ||
37 | ms->possible_cpus->cpus[n].arch_id = | ||
38 | virt_cpu_mp_affinity(vms, n); | ||
39 | + | ||
40 | + assert(!mc->smp_props.dies_supported); | ||
41 | + ms->possible_cpus->cpus[n].props.has_socket_id = true; | ||
42 | + ms->possible_cpus->cpus[n].props.socket_id = | ||
43 | + n / (ms->smp.clusters * ms->smp.cores * ms->smp.threads); | ||
44 | + ms->possible_cpus->cpus[n].props.has_cluster_id = true; | ||
45 | + ms->possible_cpus->cpus[n].props.cluster_id = | ||
46 | + (n / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters; | ||
47 | + ms->possible_cpus->cpus[n].props.has_core_id = true; | ||
48 | + ms->possible_cpus->cpus[n].props.core_id = | ||
49 | + (n / ms->smp.threads) % ms->smp.cores; | ||
50 | ms->possible_cpus->cpus[n].props.has_thread_id = true; | ||
51 | - ms->possible_cpus->cpus[n].props.thread_id = n; | ||
52 | + ms->possible_cpus->cpus[n].props.thread_id = | ||
53 | + n % ms->smp.threads; | ||
54 | } | ||
55 | return ms->possible_cpus; | ||
56 | } | ||
57 | -- | ||
58 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Gavin Shan <gshan@redhat.com> | ||
1 | 2 | ||
3 | In aarch64_numa_cpu(), the CPU and NUMA association is something | ||
4 | like below. Two threads in the same core/cluster/socket are | ||
5 | associated with two individual NUMA nodes, which is unreal as | ||
6 | Igor Mammedov mentioned. We don't expect the association to break | ||
7 | NUMA-to-socket boundary, which matches with the real world. | ||
8 | |||
9 | NUMA-node socket cluster core thread | ||
10 | ------------------------------------------ | ||
11 | 0 0 0 0 0 | ||
12 | 1 0 0 0 1 | ||
13 | |||
14 | This corrects the topology for CPUs and their association with | ||
15 | NUMA nodes. After this patch is applied, the CPU and NUMA | ||
16 | association becomes something like below, which looks real. | ||
17 | Besides, socket/cluster/core/thread IDs are all checked when | ||
18 | the NUMA node IDs are verified. It helps to check if the CPU | ||
19 | topology is properly populated or not. | ||
20 | |||
21 | NUMA-node socket cluster core thread | ||
22 | ------------------------------------------ | ||
23 | 0 1 0 0 0 | ||
24 | 1 0 0 0 0 | ||
25 | |||
26 | Suggested-by: Igor Mammedov <imammedo@redhat.com> | ||
27 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
28 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
29 | Message-id: 20220503140304.855514-5-gshan@redhat.com | ||
30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
31 | --- | ||
32 | tests/qtest/numa-test.c | 18 ++++++++++++------ | ||
33 | 1 file changed, 12 insertions(+), 6 deletions(-) | ||
34 | |||
35 | diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/tests/qtest/numa-test.c | ||
38 | +++ b/tests/qtest/numa-test.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) | ||
40 | g_autofree char *cli = NULL; | ||
41 | |||
42 | cli = make_cli(data, "-machine " | ||
43 | - "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 " | ||
44 | + "smp.cpus=2,smp.sockets=2,smp.clusters=1,smp.cores=1,smp.threads=1 " | ||
45 | "-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 " | ||
46 | - "-numa cpu,node-id=1,thread-id=0 " | ||
47 | - "-numa cpu,node-id=0,thread-id=1"); | ||
48 | + "-numa cpu,node-id=0,socket-id=1,cluster-id=0,core-id=0,thread-id=0 " | ||
49 | + "-numa cpu,node-id=1,socket-id=0,cluster-id=0,core-id=0,thread-id=0"); | ||
50 | qts = qtest_init(cli); | ||
51 | cpus = get_cpus(qts, &resp); | ||
52 | g_assert(cpus); | ||
53 | |||
54 | while ((e = qlist_pop(cpus))) { | ||
55 | QDict *cpu, *props; | ||
56 | - int64_t thread, node; | ||
57 | + int64_t socket, cluster, core, thread, node; | ||
58 | |||
59 | cpu = qobject_to(QDict, e); | ||
60 | g_assert(qdict_haskey(cpu, "props")); | ||
61 | @@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data) | ||
62 | |||
63 | g_assert(qdict_haskey(props, "node-id")); | ||
64 | node = qdict_get_int(props, "node-id"); | ||
65 | + g_assert(qdict_haskey(props, "socket-id")); | ||
66 | + socket = qdict_get_int(props, "socket-id"); | ||
67 | + g_assert(qdict_haskey(props, "cluster-id")); | ||
68 | + cluster = qdict_get_int(props, "cluster-id"); | ||
69 | + g_assert(qdict_haskey(props, "core-id")); | ||
70 | + core = qdict_get_int(props, "core-id"); | ||
71 | g_assert(qdict_haskey(props, "thread-id")); | ||
72 | thread = qdict_get_int(props, "thread-id"); | ||
73 | |||
74 | - if (thread == 0) { | ||
75 | + if (socket == 0 && cluster == 0 && core == 0 && thread == 0) { | ||
76 | g_assert_cmpint(node, ==, 1); | ||
77 | - } else if (thread == 1) { | ||
78 | + } else if (socket == 1 && cluster == 0 && core == 0 && thread == 0) { | ||
79 | g_assert_cmpint(node, ==, 0); | ||
80 | } else { | ||
81 | g_assert(false); | ||
82 | -- | ||
83 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Damien Hedde <damien.hedde@greensocs.com> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Replace the zynq_slcr registers enum and macros using the | 3 | When CPU-to-NUMA association isn't explicitly provided by users, |
4 | hw/registerfields.h macros. | 4 | the default one is given by mc->get_default_cpu_node_id(). However, |
5 | the CPU topology isn't fully considered in the default association | ||
6 | and this causes CPU topology broken warnings on booting Linux guest. | ||
5 | 7 | ||
6 | Signed-off-by: Damien Hedde <damien.hedde@greensocs.com> | 8 | For example, the following warning messages are observed when the |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Linux guest is booted with the following command lines. |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 10 | |
9 | Message-id: 20190729145654.14644-30-damien.hedde@greensocs.com | 11 | /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ |
12 | -accel kvm -machine virt,gic-version=host \ | ||
13 | -cpu host \ | ||
14 | -smp 6,sockets=2,cores=3,threads=1 \ | ||
15 | -m 1024M,slots=16,maxmem=64G \ | ||
16 | -object memory-backend-ram,id=mem0,size=128M \ | ||
17 | -object memory-backend-ram,id=mem1,size=128M \ | ||
18 | -object memory-backend-ram,id=mem2,size=128M \ | ||
19 | -object memory-backend-ram,id=mem3,size=128M \ | ||
20 | -object memory-backend-ram,id=mem4,size=128M \ | ||
21 | -object memory-backend-ram,id=mem4,size=384M \ | ||
22 | -numa node,nodeid=0,memdev=mem0 \ | ||
23 | -numa node,nodeid=1,memdev=mem1 \ | ||
24 | -numa node,nodeid=2,memdev=mem2 \ | ||
25 | -numa node,nodeid=3,memdev=mem3 \ | ||
26 | -numa node,nodeid=4,memdev=mem4 \ | ||
27 | -numa node,nodeid=5,memdev=mem5 | ||
28 | : | ||
29 | alternatives: patching kernel code | ||
30 | BUG: arch topology borken | ||
31 | the CLS domain not a subset of the MC domain | ||
32 | <the above error log repeats> | ||
33 | BUG: arch topology borken | ||
34 | the DIE domain not a subset of the NODE domain | ||
35 | |||
36 | With current implementation of mc->get_default_cpu_node_id(), | ||
37 | CPU#0 to CPU#5 are associated with NODE#0 to NODE#5 separately. | ||
38 | That's incorrect because CPU#0/1/2 should be associated with same | ||
39 | NUMA node because they're seated in same socket. | ||
40 | |||
41 | This fixes the issue by considering the socket ID when the default | ||
42 | CPU-to-NUMA association is provided in virt_possible_cpu_arch_ids(). | ||
43 | With this applied, no more CPU topology broken warnings are seen | ||
44 | from the Linux guest. The 6 CPUs are associated with NODE#0/1, but | ||
45 | there are no CPUs associated with NODE#2/3/4/5. | ||
46 | |||
47 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
48 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
49 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> | ||
50 | Message-id: 20220503140304.855514-6-gshan@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 51 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 52 | --- |
12 | hw/misc/zynq_slcr.c | 450 ++++++++++++++++++++++---------------------- | 53 | hw/arm/virt.c | 4 +++- |
13 | 1 file changed, 225 insertions(+), 225 deletions(-) | 54 | 1 file changed, 3 insertions(+), 1 deletion(-) |
14 | 55 | ||
15 | diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c | 56 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
16 | index XXXXXXX..XXXXXXX 100644 | 57 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/misc/zynq_slcr.c | 58 | --- a/hw/arm/virt.c |
18 | +++ b/hw/misc/zynq_slcr.c | 59 | +++ b/hw/arm/virt.c |
19 | @@ -XXX,XX +XXX,XX @@ | 60 | @@ -XXX,XX +XXX,XX @@ virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) |
20 | #include "sysemu/sysemu.h" | 61 | |
21 | #include "qemu/log.h" | 62 | static int64_t virt_get_default_cpu_node_id(const MachineState *ms, int idx) |
22 | #include "qemu/module.h" | 63 | { |
23 | +#include "hw/registerfields.h" | 64 | - return idx % ms->numa_state->num_nodes; |
24 | 65 | + int64_t socket_id = ms->possible_cpus->cpus[idx].props.socket_id; | |
25 | #ifndef ZYNQ_SLCR_ERR_DEBUG | 66 | + |
26 | #define ZYNQ_SLCR_ERR_DEBUG 0 | 67 | + return socket_id % ms->numa_state->num_nodes; |
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | #define XILINX_LOCK_KEY 0x767b | ||
29 | #define XILINX_UNLOCK_KEY 0xdf0d | ||
30 | |||
31 | -#define R_PSS_RST_CTRL_SOFT_RST 0x1 | ||
32 | +REG32(SCL, 0x000) | ||
33 | +REG32(LOCK, 0x004) | ||
34 | +REG32(UNLOCK, 0x008) | ||
35 | +REG32(LOCKSTA, 0x00c) | ||
36 | |||
37 | -enum { | ||
38 | - SCL = 0x000 / 4, | ||
39 | - LOCK, | ||
40 | - UNLOCK, | ||
41 | - LOCKSTA, | ||
42 | +REG32(ARM_PLL_CTRL, 0x100) | ||
43 | +REG32(DDR_PLL_CTRL, 0x104) | ||
44 | +REG32(IO_PLL_CTRL, 0x108) | ||
45 | +REG32(PLL_STATUS, 0x10c) | ||
46 | +REG32(ARM_PLL_CFG, 0x110) | ||
47 | +REG32(DDR_PLL_CFG, 0x114) | ||
48 | +REG32(IO_PLL_CFG, 0x118) | ||
49 | |||
50 | - ARM_PLL_CTRL = 0x100 / 4, | ||
51 | - DDR_PLL_CTRL, | ||
52 | - IO_PLL_CTRL, | ||
53 | - PLL_STATUS, | ||
54 | - ARM_PLL_CFG, | ||
55 | - DDR_PLL_CFG, | ||
56 | - IO_PLL_CFG, | ||
57 | - | ||
58 | - ARM_CLK_CTRL = 0x120 / 4, | ||
59 | - DDR_CLK_CTRL, | ||
60 | - DCI_CLK_CTRL, | ||
61 | - APER_CLK_CTRL, | ||
62 | - USB0_CLK_CTRL, | ||
63 | - USB1_CLK_CTRL, | ||
64 | - GEM0_RCLK_CTRL, | ||
65 | - GEM1_RCLK_CTRL, | ||
66 | - GEM0_CLK_CTRL, | ||
67 | - GEM1_CLK_CTRL, | ||
68 | - SMC_CLK_CTRL, | ||
69 | - LQSPI_CLK_CTRL, | ||
70 | - SDIO_CLK_CTRL, | ||
71 | - UART_CLK_CTRL, | ||
72 | - SPI_CLK_CTRL, | ||
73 | - CAN_CLK_CTRL, | ||
74 | - CAN_MIOCLK_CTRL, | ||
75 | - DBG_CLK_CTRL, | ||
76 | - PCAP_CLK_CTRL, | ||
77 | - TOPSW_CLK_CTRL, | ||
78 | +REG32(ARM_CLK_CTRL, 0x120) | ||
79 | +REG32(DDR_CLK_CTRL, 0x124) | ||
80 | +REG32(DCI_CLK_CTRL, 0x128) | ||
81 | +REG32(APER_CLK_CTRL, 0x12c) | ||
82 | +REG32(USB0_CLK_CTRL, 0x130) | ||
83 | +REG32(USB1_CLK_CTRL, 0x134) | ||
84 | +REG32(GEM0_RCLK_CTRL, 0x138) | ||
85 | +REG32(GEM1_RCLK_CTRL, 0x13c) | ||
86 | +REG32(GEM0_CLK_CTRL, 0x140) | ||
87 | +REG32(GEM1_CLK_CTRL, 0x144) | ||
88 | +REG32(SMC_CLK_CTRL, 0x148) | ||
89 | +REG32(LQSPI_CLK_CTRL, 0x14c) | ||
90 | +REG32(SDIO_CLK_CTRL, 0x150) | ||
91 | +REG32(UART_CLK_CTRL, 0x154) | ||
92 | +REG32(SPI_CLK_CTRL, 0x158) | ||
93 | +REG32(CAN_CLK_CTRL, 0x15c) | ||
94 | +REG32(CAN_MIOCLK_CTRL, 0x160) | ||
95 | +REG32(DBG_CLK_CTRL, 0x164) | ||
96 | +REG32(PCAP_CLK_CTRL, 0x168) | ||
97 | +REG32(TOPSW_CLK_CTRL, 0x16c) | ||
98 | |||
99 | #define FPGA_CTRL_REGS(n, start) \ | ||
100 | - FPGA ## n ## _CLK_CTRL = (start) / 4, \ | ||
101 | - FPGA ## n ## _THR_CTRL, \ | ||
102 | - FPGA ## n ## _THR_CNT, \ | ||
103 | - FPGA ## n ## _THR_STA, | ||
104 | - FPGA_CTRL_REGS(0, 0x170) | ||
105 | - FPGA_CTRL_REGS(1, 0x180) | ||
106 | - FPGA_CTRL_REGS(2, 0x190) | ||
107 | - FPGA_CTRL_REGS(3, 0x1a0) | ||
108 | + REG32(FPGA ## n ## _CLK_CTRL, (start)) \ | ||
109 | + REG32(FPGA ## n ## _THR_CTRL, (start) + 0x4)\ | ||
110 | + REG32(FPGA ## n ## _THR_CNT, (start) + 0x8)\ | ||
111 | + REG32(FPGA ## n ## _THR_STA, (start) + 0xc) | ||
112 | +FPGA_CTRL_REGS(0, 0x170) | ||
113 | +FPGA_CTRL_REGS(1, 0x180) | ||
114 | +FPGA_CTRL_REGS(2, 0x190) | ||
115 | +FPGA_CTRL_REGS(3, 0x1a0) | ||
116 | |||
117 | - BANDGAP_TRIP = 0x1b8 / 4, | ||
118 | - PLL_PREDIVISOR = 0x1c0 / 4, | ||
119 | - CLK_621_TRUE, | ||
120 | +REG32(BANDGAP_TRIP, 0x1b8) | ||
121 | +REG32(PLL_PREDIVISOR, 0x1c0) | ||
122 | +REG32(CLK_621_TRUE, 0x1c4) | ||
123 | |||
124 | - PSS_RST_CTRL = 0x200 / 4, | ||
125 | - DDR_RST_CTRL, | ||
126 | - TOPSW_RESET_CTRL, | ||
127 | - DMAC_RST_CTRL, | ||
128 | - USB_RST_CTRL, | ||
129 | - GEM_RST_CTRL, | ||
130 | - SDIO_RST_CTRL, | ||
131 | - SPI_RST_CTRL, | ||
132 | - CAN_RST_CTRL, | ||
133 | - I2C_RST_CTRL, | ||
134 | - UART_RST_CTRL, | ||
135 | - GPIO_RST_CTRL, | ||
136 | - LQSPI_RST_CTRL, | ||
137 | - SMC_RST_CTRL, | ||
138 | - OCM_RST_CTRL, | ||
139 | - FPGA_RST_CTRL = 0x240 / 4, | ||
140 | - A9_CPU_RST_CTRL, | ||
141 | +REG32(PSS_RST_CTRL, 0x200) | ||
142 | + FIELD(PSS_RST_CTRL, SOFT_RST, 0, 1) | ||
143 | +REG32(DDR_RST_CTRL, 0x204) | ||
144 | +REG32(TOPSW_RESET_CTRL, 0x208) | ||
145 | +REG32(DMAC_RST_CTRL, 0x20c) | ||
146 | +REG32(USB_RST_CTRL, 0x210) | ||
147 | +REG32(GEM_RST_CTRL, 0x214) | ||
148 | +REG32(SDIO_RST_CTRL, 0x218) | ||
149 | +REG32(SPI_RST_CTRL, 0x21c) | ||
150 | +REG32(CAN_RST_CTRL, 0x220) | ||
151 | +REG32(I2C_RST_CTRL, 0x224) | ||
152 | +REG32(UART_RST_CTRL, 0x228) | ||
153 | +REG32(GPIO_RST_CTRL, 0x22c) | ||
154 | +REG32(LQSPI_RST_CTRL, 0x230) | ||
155 | +REG32(SMC_RST_CTRL, 0x234) | ||
156 | +REG32(OCM_RST_CTRL, 0x238) | ||
157 | +REG32(FPGA_RST_CTRL, 0x240) | ||
158 | +REG32(A9_CPU_RST_CTRL, 0x244) | ||
159 | |||
160 | - RS_AWDT_CTRL = 0x24c / 4, | ||
161 | - RST_REASON, | ||
162 | +REG32(RS_AWDT_CTRL, 0x24c) | ||
163 | +REG32(RST_REASON, 0x250) | ||
164 | |||
165 | - REBOOT_STATUS = 0x258 / 4, | ||
166 | - BOOT_MODE, | ||
167 | +REG32(REBOOT_STATUS, 0x258) | ||
168 | +REG32(BOOT_MODE, 0x25c) | ||
169 | |||
170 | - APU_CTRL = 0x300 / 4, | ||
171 | - WDT_CLK_SEL, | ||
172 | +REG32(APU_CTRL, 0x300) | ||
173 | +REG32(WDT_CLK_SEL, 0x304) | ||
174 | |||
175 | - TZ_DMA_NS = 0x440 / 4, | ||
176 | - TZ_DMA_IRQ_NS, | ||
177 | - TZ_DMA_PERIPH_NS, | ||
178 | +REG32(TZ_DMA_NS, 0x440) | ||
179 | +REG32(TZ_DMA_IRQ_NS, 0x444) | ||
180 | +REG32(TZ_DMA_PERIPH_NS, 0x448) | ||
181 | |||
182 | - PSS_IDCODE = 0x530 / 4, | ||
183 | +REG32(PSS_IDCODE, 0x530) | ||
184 | |||
185 | - DDR_URGENT = 0x600 / 4, | ||
186 | - DDR_CAL_START = 0x60c / 4, | ||
187 | - DDR_REF_START = 0x614 / 4, | ||
188 | - DDR_CMD_STA, | ||
189 | - DDR_URGENT_SEL, | ||
190 | - DDR_DFI_STATUS, | ||
191 | +REG32(DDR_URGENT, 0x600) | ||
192 | +REG32(DDR_CAL_START, 0x60c) | ||
193 | +REG32(DDR_REF_START, 0x614) | ||
194 | +REG32(DDR_CMD_STA, 0x618) | ||
195 | +REG32(DDR_URGENT_SEL, 0x61c) | ||
196 | +REG32(DDR_DFI_STATUS, 0x620) | ||
197 | |||
198 | - MIO = 0x700 / 4, | ||
199 | +REG32(MIO, 0x700) | ||
200 | #define MIO_LENGTH 54 | ||
201 | |||
202 | - MIO_LOOPBACK = 0x804 / 4, | ||
203 | - MIO_MST_TRI0, | ||
204 | - MIO_MST_TRI1, | ||
205 | +REG32(MIO_LOOPBACK, 0x804) | ||
206 | +REG32(MIO_MST_TRI0, 0x808) | ||
207 | +REG32(MIO_MST_TRI1, 0x80c) | ||
208 | |||
209 | - SD0_WP_CD_SEL = 0x830 / 4, | ||
210 | - SD1_WP_CD_SEL, | ||
211 | +REG32(SD0_WP_CD_SEL, 0x830) | ||
212 | +REG32(SD1_WP_CD_SEL, 0x834) | ||
213 | |||
214 | - LVL_SHFTR_EN = 0x900 / 4, | ||
215 | - OCM_CFG = 0x910 / 4, | ||
216 | +REG32(LVL_SHFTR_EN, 0x900) | ||
217 | +REG32(OCM_CFG, 0x910) | ||
218 | |||
219 | - CPU_RAM = 0xa00 / 4, | ||
220 | +REG32(CPU_RAM, 0xa00) | ||
221 | |||
222 | - IOU = 0xa30 / 4, | ||
223 | +REG32(IOU, 0xa30) | ||
224 | |||
225 | - DMAC_RAM = 0xa50 / 4, | ||
226 | +REG32(DMAC_RAM, 0xa50) | ||
227 | |||
228 | - AFI0 = 0xa60 / 4, | ||
229 | - AFI1 = AFI0 + 3, | ||
230 | - AFI2 = AFI1 + 3, | ||
231 | - AFI3 = AFI2 + 3, | ||
232 | +REG32(AFI0, 0xa60) | ||
233 | +REG32(AFI1, 0xa6c) | ||
234 | +REG32(AFI2, 0xa78) | ||
235 | +REG32(AFI3, 0xa84) | ||
236 | #define AFI_LENGTH 3 | ||
237 | |||
238 | - OCM = 0xa90 / 4, | ||
239 | +REG32(OCM, 0xa90) | ||
240 | |||
241 | - DEVCI_RAM = 0xaa0 / 4, | ||
242 | +REG32(DEVCI_RAM, 0xaa0) | ||
243 | |||
244 | - CSG_RAM = 0xab0 / 4, | ||
245 | +REG32(CSG_RAM, 0xab0) | ||
246 | |||
247 | - GPIOB_CTRL = 0xb00 / 4, | ||
248 | - GPIOB_CFG_CMOS18, | ||
249 | - GPIOB_CFG_CMOS25, | ||
250 | - GPIOB_CFG_CMOS33, | ||
251 | - GPIOB_CFG_HSTL = 0xb14 / 4, | ||
252 | - GPIOB_DRVR_BIAS_CTRL, | ||
253 | +REG32(GPIOB_CTRL, 0xb00) | ||
254 | +REG32(GPIOB_CFG_CMOS18, 0xb04) | ||
255 | +REG32(GPIOB_CFG_CMOS25, 0xb08) | ||
256 | +REG32(GPIOB_CFG_CMOS33, 0xb0c) | ||
257 | +REG32(GPIOB_CFG_HSTL, 0xb14) | ||
258 | +REG32(GPIOB_DRVR_BIAS_CTRL, 0xb18) | ||
259 | |||
260 | - DDRIOB = 0xb40 / 4, | ||
261 | +REG32(DDRIOB, 0xb40) | ||
262 | #define DDRIOB_LENGTH 14 | ||
263 | -}; | ||
264 | |||
265 | #define ZYNQ_SLCR_MMIO_SIZE 0x1000 | ||
266 | #define ZYNQ_SLCR_NUM_REGS (ZYNQ_SLCR_MMIO_SIZE / 4) | ||
267 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset(DeviceState *d) | ||
268 | |||
269 | DB_PRINT("RESET\n"); | ||
270 | |||
271 | - s->regs[LOCKSTA] = 1; | ||
272 | + s->regs[R_LOCKSTA] = 1; | ||
273 | /* 0x100 - 0x11C */ | ||
274 | - s->regs[ARM_PLL_CTRL] = 0x0001A008; | ||
275 | - s->regs[DDR_PLL_CTRL] = 0x0001A008; | ||
276 | - s->regs[IO_PLL_CTRL] = 0x0001A008; | ||
277 | - s->regs[PLL_STATUS] = 0x0000003F; | ||
278 | - s->regs[ARM_PLL_CFG] = 0x00014000; | ||
279 | - s->regs[DDR_PLL_CFG] = 0x00014000; | ||
280 | - s->regs[IO_PLL_CFG] = 0x00014000; | ||
281 | + s->regs[R_ARM_PLL_CTRL] = 0x0001A008; | ||
282 | + s->regs[R_DDR_PLL_CTRL] = 0x0001A008; | ||
283 | + s->regs[R_IO_PLL_CTRL] = 0x0001A008; | ||
284 | + s->regs[R_PLL_STATUS] = 0x0000003F; | ||
285 | + s->regs[R_ARM_PLL_CFG] = 0x00014000; | ||
286 | + s->regs[R_DDR_PLL_CFG] = 0x00014000; | ||
287 | + s->regs[R_IO_PLL_CFG] = 0x00014000; | ||
288 | |||
289 | /* 0x120 - 0x16C */ | ||
290 | - s->regs[ARM_CLK_CTRL] = 0x1F000400; | ||
291 | - s->regs[DDR_CLK_CTRL] = 0x18400003; | ||
292 | - s->regs[DCI_CLK_CTRL] = 0x01E03201; | ||
293 | - s->regs[APER_CLK_CTRL] = 0x01FFCCCD; | ||
294 | - s->regs[USB0_CLK_CTRL] = s->regs[USB1_CLK_CTRL] = 0x00101941; | ||
295 | - s->regs[GEM0_RCLK_CTRL] = s->regs[GEM1_RCLK_CTRL] = 0x00000001; | ||
296 | - s->regs[GEM0_CLK_CTRL] = s->regs[GEM1_CLK_CTRL] = 0x00003C01; | ||
297 | - s->regs[SMC_CLK_CTRL] = 0x00003C01; | ||
298 | - s->regs[LQSPI_CLK_CTRL] = 0x00002821; | ||
299 | - s->regs[SDIO_CLK_CTRL] = 0x00001E03; | ||
300 | - s->regs[UART_CLK_CTRL] = 0x00003F03; | ||
301 | - s->regs[SPI_CLK_CTRL] = 0x00003F03; | ||
302 | - s->regs[CAN_CLK_CTRL] = 0x00501903; | ||
303 | - s->regs[DBG_CLK_CTRL] = 0x00000F03; | ||
304 | - s->regs[PCAP_CLK_CTRL] = 0x00000F01; | ||
305 | + s->regs[R_ARM_CLK_CTRL] = 0x1F000400; | ||
306 | + s->regs[R_DDR_CLK_CTRL] = 0x18400003; | ||
307 | + s->regs[R_DCI_CLK_CTRL] = 0x01E03201; | ||
308 | + s->regs[R_APER_CLK_CTRL] = 0x01FFCCCD; | ||
309 | + s->regs[R_USB0_CLK_CTRL] = s->regs[R_USB1_CLK_CTRL] = 0x00101941; | ||
310 | + s->regs[R_GEM0_RCLK_CTRL] = s->regs[R_GEM1_RCLK_CTRL] = 0x00000001; | ||
311 | + s->regs[R_GEM0_CLK_CTRL] = s->regs[R_GEM1_CLK_CTRL] = 0x00003C01; | ||
312 | + s->regs[R_SMC_CLK_CTRL] = 0x00003C01; | ||
313 | + s->regs[R_LQSPI_CLK_CTRL] = 0x00002821; | ||
314 | + s->regs[R_SDIO_CLK_CTRL] = 0x00001E03; | ||
315 | + s->regs[R_UART_CLK_CTRL] = 0x00003F03; | ||
316 | + s->regs[R_SPI_CLK_CTRL] = 0x00003F03; | ||
317 | + s->regs[R_CAN_CLK_CTRL] = 0x00501903; | ||
318 | + s->regs[R_DBG_CLK_CTRL] = 0x00000F03; | ||
319 | + s->regs[R_PCAP_CLK_CTRL] = 0x00000F01; | ||
320 | |||
321 | /* 0x170 - 0x1AC */ | ||
322 | - s->regs[FPGA0_CLK_CTRL] = s->regs[FPGA1_CLK_CTRL] = s->regs[FPGA2_CLK_CTRL] | ||
323 | - = s->regs[FPGA3_CLK_CTRL] = 0x00101800; | ||
324 | - s->regs[FPGA0_THR_STA] = s->regs[FPGA1_THR_STA] = s->regs[FPGA2_THR_STA] | ||
325 | - = s->regs[FPGA3_THR_STA] = 0x00010000; | ||
326 | + s->regs[R_FPGA0_CLK_CTRL] = s->regs[R_FPGA1_CLK_CTRL] | ||
327 | + = s->regs[R_FPGA2_CLK_CTRL] | ||
328 | + = s->regs[R_FPGA3_CLK_CTRL] = 0x00101800; | ||
329 | + s->regs[R_FPGA0_THR_STA] = s->regs[R_FPGA1_THR_STA] | ||
330 | + = s->regs[R_FPGA2_THR_STA] | ||
331 | + = s->regs[R_FPGA3_THR_STA] = 0x00010000; | ||
332 | |||
333 | /* 0x1B0 - 0x1D8 */ | ||
334 | - s->regs[BANDGAP_TRIP] = 0x0000001F; | ||
335 | - s->regs[PLL_PREDIVISOR] = 0x00000001; | ||
336 | - s->regs[CLK_621_TRUE] = 0x00000001; | ||
337 | + s->regs[R_BANDGAP_TRIP] = 0x0000001F; | ||
338 | + s->regs[R_PLL_PREDIVISOR] = 0x00000001; | ||
339 | + s->regs[R_CLK_621_TRUE] = 0x00000001; | ||
340 | |||
341 | /* 0x200 - 0x25C */ | ||
342 | - s->regs[FPGA_RST_CTRL] = 0x01F33F0F; | ||
343 | - s->regs[RST_REASON] = 0x00000040; | ||
344 | + s->regs[R_FPGA_RST_CTRL] = 0x01F33F0F; | ||
345 | + s->regs[R_RST_REASON] = 0x00000040; | ||
346 | |||
347 | - s->regs[BOOT_MODE] = 0x00000001; | ||
348 | + s->regs[R_BOOT_MODE] = 0x00000001; | ||
349 | |||
350 | /* 0x700 - 0x7D4 */ | ||
351 | for (i = 0; i < 54; i++) { | ||
352 | - s->regs[MIO + i] = 0x00001601; | ||
353 | + s->regs[R_MIO + i] = 0x00001601; | ||
354 | } | ||
355 | for (i = 2; i <= 8; i++) { | ||
356 | - s->regs[MIO + i] = 0x00000601; | ||
357 | + s->regs[R_MIO + i] = 0x00000601; | ||
358 | } | ||
359 | |||
360 | - s->regs[MIO_MST_TRI0] = s->regs[MIO_MST_TRI1] = 0xFFFFFFFF; | ||
361 | + s->regs[R_MIO_MST_TRI0] = s->regs[R_MIO_MST_TRI1] = 0xFFFFFFFF; | ||
362 | |||
363 | - s->regs[CPU_RAM + 0] = s->regs[CPU_RAM + 1] = s->regs[CPU_RAM + 3] | ||
364 | - = s->regs[CPU_RAM + 4] = s->regs[CPU_RAM + 7] | ||
365 | - = 0x00010101; | ||
366 | - s->regs[CPU_RAM + 2] = s->regs[CPU_RAM + 5] = 0x01010101; | ||
367 | - s->regs[CPU_RAM + 6] = 0x00000001; | ||
368 | + s->regs[R_CPU_RAM + 0] = s->regs[R_CPU_RAM + 1] = s->regs[R_CPU_RAM + 3] | ||
369 | + = s->regs[R_CPU_RAM + 4] = s->regs[R_CPU_RAM + 7] | ||
370 | + = 0x00010101; | ||
371 | + s->regs[R_CPU_RAM + 2] = s->regs[R_CPU_RAM + 5] = 0x01010101; | ||
372 | + s->regs[R_CPU_RAM + 6] = 0x00000001; | ||
373 | |||
374 | - s->regs[IOU + 0] = s->regs[IOU + 1] = s->regs[IOU + 2] = s->regs[IOU + 3] | ||
375 | - = 0x09090909; | ||
376 | - s->regs[IOU + 4] = s->regs[IOU + 5] = 0x00090909; | ||
377 | - s->regs[IOU + 6] = 0x00000909; | ||
378 | + s->regs[R_IOU + 0] = s->regs[R_IOU + 1] = s->regs[R_IOU + 2] | ||
379 | + = s->regs[R_IOU + 3] = 0x09090909; | ||
380 | + s->regs[R_IOU + 4] = s->regs[R_IOU + 5] = 0x00090909; | ||
381 | + s->regs[R_IOU + 6] = 0x00000909; | ||
382 | |||
383 | - s->regs[DMAC_RAM] = 0x00000009; | ||
384 | + s->regs[R_DMAC_RAM] = 0x00000009; | ||
385 | |||
386 | - s->regs[AFI0 + 0] = s->regs[AFI0 + 1] = 0x09090909; | ||
387 | - s->regs[AFI1 + 0] = s->regs[AFI1 + 1] = 0x09090909; | ||
388 | - s->regs[AFI2 + 0] = s->regs[AFI2 + 1] = 0x09090909; | ||
389 | - s->regs[AFI3 + 0] = s->regs[AFI3 + 1] = 0x09090909; | ||
390 | - s->regs[AFI0 + 2] = s->regs[AFI1 + 2] = s->regs[AFI2 + 2] | ||
391 | - = s->regs[AFI3 + 2] = 0x00000909; | ||
392 | + s->regs[R_AFI0 + 0] = s->regs[R_AFI0 + 1] = 0x09090909; | ||
393 | + s->regs[R_AFI1 + 0] = s->regs[R_AFI1 + 1] = 0x09090909; | ||
394 | + s->regs[R_AFI2 + 0] = s->regs[R_AFI2 + 1] = 0x09090909; | ||
395 | + s->regs[R_AFI3 + 0] = s->regs[R_AFI3 + 1] = 0x09090909; | ||
396 | + s->regs[R_AFI0 + 2] = s->regs[R_AFI1 + 2] = s->regs[R_AFI2 + 2] | ||
397 | + = s->regs[R_AFI3 + 2] = 0x00000909; | ||
398 | |||
399 | - s->regs[OCM + 0] = 0x01010101; | ||
400 | - s->regs[OCM + 1] = s->regs[OCM + 2] = 0x09090909; | ||
401 | + s->regs[R_OCM + 0] = 0x01010101; | ||
402 | + s->regs[R_OCM + 1] = s->regs[R_OCM + 2] = 0x09090909; | ||
403 | |||
404 | - s->regs[DEVCI_RAM] = 0x00000909; | ||
405 | - s->regs[CSG_RAM] = 0x00000001; | ||
406 | + s->regs[R_DEVCI_RAM] = 0x00000909; | ||
407 | + s->regs[R_CSG_RAM] = 0x00000001; | ||
408 | |||
409 | - s->regs[DDRIOB + 0] = s->regs[DDRIOB + 1] = s->regs[DDRIOB + 2] | ||
410 | - = s->regs[DDRIOB + 3] = 0x00000e00; | ||
411 | - s->regs[DDRIOB + 4] = s->regs[DDRIOB + 5] = s->regs[DDRIOB + 6] | ||
412 | - = 0x00000e00; | ||
413 | - s->regs[DDRIOB + 12] = 0x00000021; | ||
414 | + s->regs[R_DDRIOB + 0] = s->regs[R_DDRIOB + 1] = s->regs[R_DDRIOB + 2] | ||
415 | + = s->regs[R_DDRIOB + 3] = 0x00000e00; | ||
416 | + s->regs[R_DDRIOB + 4] = s->regs[R_DDRIOB + 5] = s->regs[R_DDRIOB + 6] | ||
417 | + = 0x00000e00; | ||
418 | + s->regs[R_DDRIOB + 12] = 0x00000021; | ||
419 | } | 68 | } |
420 | 69 | ||
421 | 70 | static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) | |
422 | static bool zynq_slcr_check_offset(hwaddr offset, bool rnw) | ||
423 | { | ||
424 | switch (offset) { | ||
425 | - case LOCK: | ||
426 | - case UNLOCK: | ||
427 | - case DDR_CAL_START: | ||
428 | - case DDR_REF_START: | ||
429 | + case R_LOCK: | ||
430 | + case R_UNLOCK: | ||
431 | + case R_DDR_CAL_START: | ||
432 | + case R_DDR_REF_START: | ||
433 | return !rnw; /* Write only */ | ||
434 | - case LOCKSTA: | ||
435 | - case FPGA0_THR_STA: | ||
436 | - case FPGA1_THR_STA: | ||
437 | - case FPGA2_THR_STA: | ||
438 | - case FPGA3_THR_STA: | ||
439 | - case BOOT_MODE: | ||
440 | - case PSS_IDCODE: | ||
441 | - case DDR_CMD_STA: | ||
442 | - case DDR_DFI_STATUS: | ||
443 | - case PLL_STATUS: | ||
444 | + case R_LOCKSTA: | ||
445 | + case R_FPGA0_THR_STA: | ||
446 | + case R_FPGA1_THR_STA: | ||
447 | + case R_FPGA2_THR_STA: | ||
448 | + case R_FPGA3_THR_STA: | ||
449 | + case R_BOOT_MODE: | ||
450 | + case R_PSS_IDCODE: | ||
451 | + case R_DDR_CMD_STA: | ||
452 | + case R_DDR_DFI_STATUS: | ||
453 | + case R_PLL_STATUS: | ||
454 | return rnw;/* read only */ | ||
455 | - case SCL: | ||
456 | - case ARM_PLL_CTRL ... IO_PLL_CTRL: | ||
457 | - case ARM_PLL_CFG ... IO_PLL_CFG: | ||
458 | - case ARM_CLK_CTRL ... TOPSW_CLK_CTRL: | ||
459 | - case FPGA0_CLK_CTRL ... FPGA0_THR_CNT: | ||
460 | - case FPGA1_CLK_CTRL ... FPGA1_THR_CNT: | ||
461 | - case FPGA2_CLK_CTRL ... FPGA2_THR_CNT: | ||
462 | - case FPGA3_CLK_CTRL ... FPGA3_THR_CNT: | ||
463 | - case BANDGAP_TRIP: | ||
464 | - case PLL_PREDIVISOR: | ||
465 | - case CLK_621_TRUE: | ||
466 | - case PSS_RST_CTRL ... A9_CPU_RST_CTRL: | ||
467 | - case RS_AWDT_CTRL: | ||
468 | - case RST_REASON: | ||
469 | - case REBOOT_STATUS: | ||
470 | - case APU_CTRL: | ||
471 | - case WDT_CLK_SEL: | ||
472 | - case TZ_DMA_NS ... TZ_DMA_PERIPH_NS: | ||
473 | - case DDR_URGENT: | ||
474 | - case DDR_URGENT_SEL: | ||
475 | - case MIO ... MIO + MIO_LENGTH - 1: | ||
476 | - case MIO_LOOPBACK ... MIO_MST_TRI1: | ||
477 | - case SD0_WP_CD_SEL: | ||
478 | - case SD1_WP_CD_SEL: | ||
479 | - case LVL_SHFTR_EN: | ||
480 | - case OCM_CFG: | ||
481 | - case CPU_RAM: | ||
482 | - case IOU: | ||
483 | - case DMAC_RAM: | ||
484 | - case AFI0 ... AFI3 + AFI_LENGTH - 1: | ||
485 | - case OCM: | ||
486 | - case DEVCI_RAM: | ||
487 | - case CSG_RAM: | ||
488 | - case GPIOB_CTRL ... GPIOB_CFG_CMOS33: | ||
489 | - case GPIOB_CFG_HSTL: | ||
490 | - case GPIOB_DRVR_BIAS_CTRL: | ||
491 | - case DDRIOB ... DDRIOB + DDRIOB_LENGTH - 1: | ||
492 | + case R_SCL: | ||
493 | + case R_ARM_PLL_CTRL ... R_IO_PLL_CTRL: | ||
494 | + case R_ARM_PLL_CFG ... R_IO_PLL_CFG: | ||
495 | + case R_ARM_CLK_CTRL ... R_TOPSW_CLK_CTRL: | ||
496 | + case R_FPGA0_CLK_CTRL ... R_FPGA0_THR_CNT: | ||
497 | + case R_FPGA1_CLK_CTRL ... R_FPGA1_THR_CNT: | ||
498 | + case R_FPGA2_CLK_CTRL ... R_FPGA2_THR_CNT: | ||
499 | + case R_FPGA3_CLK_CTRL ... R_FPGA3_THR_CNT: | ||
500 | + case R_BANDGAP_TRIP: | ||
501 | + case R_PLL_PREDIVISOR: | ||
502 | + case R_CLK_621_TRUE: | ||
503 | + case R_PSS_RST_CTRL ... R_A9_CPU_RST_CTRL: | ||
504 | + case R_RS_AWDT_CTRL: | ||
505 | + case R_RST_REASON: | ||
506 | + case R_REBOOT_STATUS: | ||
507 | + case R_APU_CTRL: | ||
508 | + case R_WDT_CLK_SEL: | ||
509 | + case R_TZ_DMA_NS ... R_TZ_DMA_PERIPH_NS: | ||
510 | + case R_DDR_URGENT: | ||
511 | + case R_DDR_URGENT_SEL: | ||
512 | + case R_MIO ... R_MIO + MIO_LENGTH - 1: | ||
513 | + case R_MIO_LOOPBACK ... R_MIO_MST_TRI1: | ||
514 | + case R_SD0_WP_CD_SEL: | ||
515 | + case R_SD1_WP_CD_SEL: | ||
516 | + case R_LVL_SHFTR_EN: | ||
517 | + case R_OCM_CFG: | ||
518 | + case R_CPU_RAM: | ||
519 | + case R_IOU: | ||
520 | + case R_DMAC_RAM: | ||
521 | + case R_AFI0 ... R_AFI3 + AFI_LENGTH - 1: | ||
522 | + case R_OCM: | ||
523 | + case R_DEVCI_RAM: | ||
524 | + case R_CSG_RAM: | ||
525 | + case R_GPIOB_CTRL ... R_GPIOB_CFG_CMOS33: | ||
526 | + case R_GPIOB_CFG_HSTL: | ||
527 | + case R_GPIOB_DRVR_BIAS_CTRL: | ||
528 | + case R_DDRIOB ... R_DDRIOB + DDRIOB_LENGTH - 1: | ||
529 | return true; | ||
530 | default: | ||
531 | return false; | ||
532 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
533 | } | ||
534 | |||
535 | switch (offset) { | ||
536 | - case SCL: | ||
537 | - s->regs[SCL] = val & 0x1; | ||
538 | + case R_SCL: | ||
539 | + s->regs[R_SCL] = val & 0x1; | ||
540 | return; | ||
541 | - case LOCK: | ||
542 | + case R_LOCK: | ||
543 | if ((val & 0xFFFF) == XILINX_LOCK_KEY) { | ||
544 | DB_PRINT("XILINX LOCK 0xF8000000 + 0x%x <= 0x%x\n", (int)offset, | ||
545 | (unsigned)val & 0xFFFF); | ||
546 | - s->regs[LOCKSTA] = 1; | ||
547 | + s->regs[R_LOCKSTA] = 1; | ||
548 | } else { | ||
549 | DB_PRINT("WRONG XILINX LOCK KEY 0xF8000000 + 0x%x <= 0x%x\n", | ||
550 | (int)offset, (unsigned)val & 0xFFFF); | ||
551 | } | ||
552 | return; | ||
553 | - case UNLOCK: | ||
554 | + case R_UNLOCK: | ||
555 | if ((val & 0xFFFF) == XILINX_UNLOCK_KEY) { | ||
556 | DB_PRINT("XILINX UNLOCK 0xF8000000 + 0x%x <= 0x%x\n", (int)offset, | ||
557 | (unsigned)val & 0xFFFF); | ||
558 | - s->regs[LOCKSTA] = 0; | ||
559 | + s->regs[R_LOCKSTA] = 0; | ||
560 | } else { | ||
561 | DB_PRINT("WRONG XILINX UNLOCK KEY 0xF8000000 + 0x%x <= 0x%x\n", | ||
562 | (int)offset, (unsigned)val & 0xFFFF); | ||
563 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
564 | return; | ||
565 | } | ||
566 | |||
567 | - if (s->regs[LOCKSTA]) { | ||
568 | + if (s->regs[R_LOCKSTA]) { | ||
569 | qemu_log_mask(LOG_GUEST_ERROR, | ||
570 | "SCLR registers are locked. Unlock them first\n"); | ||
571 | return; | ||
572 | @@ -XXX,XX +XXX,XX @@ static void zynq_slcr_write(void *opaque, hwaddr offset, | ||
573 | s->regs[offset] = val; | ||
574 | |||
575 | switch (offset) { | ||
576 | - case PSS_RST_CTRL: | ||
577 | - if (val & R_PSS_RST_CTRL_SOFT_RST) { | ||
578 | + case R_PSS_RST_CTRL: | ||
579 | + if (FIELD_EX32(val, PSS_RST_CTRL, SOFT_RST)) { | ||
580 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
581 | } | ||
582 | break; | ||
583 | -- | 71 | -- |
584 | 2.20.1 | 72 | 2.25.1 |
585 | |||
586 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Gavin Shan <gshan@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Move the getting/putting of the fpsimd registers out of | 3 | When the PPTT table is built, the CPU topology is re-calculated, but |
4 | kvm_arch_get/put_registers() into their own helper functions | 4 | it's unecessary because the CPU topology has been populated in |
5 | to prepare for alternatively getting/putting SVE registers. | 5 | virt_possible_cpu_arch_ids() on arm/virt machine. |
6 | 6 | ||
7 | No functional change. | 7 | This reworks build_pptt() to avoid by reusing the existing IDs in |
8 | ms->possible_cpus. Currently, the only user of build_pptt() is | ||
9 | arm/virt machine. | ||
8 | 10 | ||
9 | Signed-off-by: Andrew Jones <drjones@redhat.com> | 11 | Signed-off-by: Gavin Shan <gshan@redhat.com> |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 12 | Tested-by: Yanan Wang <wangyanan55@huawei.com> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Yanan Wang <wangyanan55@huawei.com> |
14 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Acked-by: Michael S. Tsirkin <mst@redhat.com> | ||
16 | Message-id: 20220503140304.855514-7-gshan@redhat.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 18 | --- |
14 | target/arm/kvm64.c | 148 +++++++++++++++++++++++++++------------------ | 19 | hw/acpi/aml-build.c | 111 +++++++++++++++++++------------------------- |
15 | 1 file changed, 88 insertions(+), 60 deletions(-) | 20 | 1 file changed, 48 insertions(+), 63 deletions(-) |
16 | 21 | ||
17 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 22 | diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c |
18 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/kvm64.c | 24 | --- a/hw/acpi/aml-build.c |
20 | +++ b/target/arm/kvm64.c | 25 | +++ b/hw/acpi/aml-build.c |
21 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_cpreg_level(uint64_t regidx) | 26 | @@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms, |
22 | #define AARCH64_SIMD_CTRL_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U32 | \ | 27 | const char *oem_id, const char *oem_table_id) |
23 | KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) | ||
24 | |||
25 | +static int kvm_arch_put_fpsimd(CPUState *cs) | ||
26 | +{ | ||
27 | + ARMCPU *cpu = ARM_CPU(cs); | ||
28 | + CPUARMState *env = &cpu->env; | ||
29 | + struct kvm_one_reg reg; | ||
30 | + uint32_t fpr; | ||
31 | + int i, ret; | ||
32 | + | ||
33 | + for (i = 0; i < 32; i++) { | ||
34 | + uint64_t *q = aa64_vfp_qreg(env, i); | ||
35 | +#ifdef HOST_WORDS_BIGENDIAN | ||
36 | + uint64_t fp_val[2] = { q[1], q[0] }; | ||
37 | + reg.addr = (uintptr_t)fp_val; | ||
38 | +#else | ||
39 | + reg.addr = (uintptr_t)q; | ||
40 | +#endif | ||
41 | + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
42 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
43 | + if (ret) { | ||
44 | + return ret; | ||
45 | + } | ||
46 | + } | ||
47 | + | ||
48 | + reg.addr = (uintptr_t)(&fpr); | ||
49 | + fpr = vfp_get_fpsr(env); | ||
50 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
51 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
52 | + if (ret) { | ||
53 | + return ret; | ||
54 | + } | ||
55 | + | ||
56 | + reg.addr = (uintptr_t)(&fpr); | ||
57 | + fpr = vfp_get_fpcr(env); | ||
58 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
59 | + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
60 | + if (ret) { | ||
61 | + return ret; | ||
62 | + } | ||
63 | + | ||
64 | + return 0; | ||
65 | +} | ||
66 | + | ||
67 | int kvm_arch_put_registers(CPUState *cs, int level) | ||
68 | { | 28 | { |
69 | struct kvm_one_reg reg; | 29 | MachineClass *mc = MACHINE_GET_CLASS(ms); |
70 | - uint32_t fpr; | 30 | - GQueue *list = g_queue_new(); |
71 | uint64_t val; | 31 | - guint pptt_start = table_data->len; |
72 | - int i; | 32 | - guint parent_offset; |
73 | - int ret; | 33 | - guint length, i; |
74 | + int i, ret; | 34 | - int uid = 0; |
75 | unsigned int el; | 35 | - int socket; |
76 | 36 | + CPUArchIdList *cpus = ms->possible_cpus; | |
77 | ARMCPU *cpu = ARM_CPU(cs); | 37 | + int64_t socket_id = -1, cluster_id = -1, core_id = -1; |
78 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | 38 | + uint32_t socket_offset = 0, cluster_offset = 0, core_offset = 0; |
39 | + uint32_t pptt_start = table_data->len; | ||
40 | + int n; | ||
41 | AcpiTable table = { .sig = "PPTT", .rev = 2, | ||
42 | .oem_id = oem_id, .oem_table_id = oem_table_id }; | ||
43 | |||
44 | acpi_table_begin(&table, table_data); | ||
45 | |||
46 | - for (socket = 0; socket < ms->smp.sockets; socket++) { | ||
47 | - g_queue_push_tail(list, | ||
48 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
49 | - build_processor_hierarchy_node( | ||
50 | - table_data, | ||
51 | - /* | ||
52 | - * Physical package - represents the boundary | ||
53 | - * of a physical package | ||
54 | - */ | ||
55 | - (1 << 0), | ||
56 | - 0, socket, NULL, 0); | ||
57 | - } | ||
58 | - | ||
59 | - if (mc->smp_props.clusters_supported) { | ||
60 | - length = g_queue_get_length(list); | ||
61 | - for (i = 0; i < length; i++) { | ||
62 | - int cluster; | ||
63 | - | ||
64 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | ||
65 | - for (cluster = 0; cluster < ms->smp.clusters; cluster++) { | ||
66 | - g_queue_push_tail(list, | ||
67 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
68 | - build_processor_hierarchy_node( | ||
69 | - table_data, | ||
70 | - (0 << 0), /* not a physical package */ | ||
71 | - parent_offset, cluster, NULL, 0); | ||
72 | - } | ||
73 | + /* | ||
74 | + * This works with the assumption that cpus[n].props.*_id has been | ||
75 | + * sorted from top to down levels in mc->possible_cpu_arch_ids(). | ||
76 | + * Otherwise, the unexpected and duplicated containers will be | ||
77 | + * created. | ||
78 | + */ | ||
79 | + for (n = 0; n < cpus->len; n++) { | ||
80 | + if (cpus->cpus[n].props.socket_id != socket_id) { | ||
81 | + assert(cpus->cpus[n].props.socket_id > socket_id); | ||
82 | + socket_id = cpus->cpus[n].props.socket_id; | ||
83 | + cluster_id = -1; | ||
84 | + core_id = -1; | ||
85 | + socket_offset = table_data->len - pptt_start; | ||
86 | + build_processor_hierarchy_node(table_data, | ||
87 | + (1 << 0), /* Physical package */ | ||
88 | + 0, socket_id, NULL, 0); | ||
89 | } | ||
90 | - } | ||
91 | |||
92 | - length = g_queue_get_length(list); | ||
93 | - for (i = 0; i < length; i++) { | ||
94 | - int core; | ||
95 | - | ||
96 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | ||
97 | - for (core = 0; core < ms->smp.cores; core++) { | ||
98 | - if (ms->smp.threads > 1) { | ||
99 | - g_queue_push_tail(list, | ||
100 | - GUINT_TO_POINTER(table_data->len - pptt_start)); | ||
101 | - build_processor_hierarchy_node( | ||
102 | - table_data, | ||
103 | - (0 << 0), /* not a physical package */ | ||
104 | - parent_offset, core, NULL, 0); | ||
105 | - } else { | ||
106 | - build_processor_hierarchy_node( | ||
107 | - table_data, | ||
108 | - (1 << 1) | /* ACPI Processor ID valid */ | ||
109 | - (1 << 3), /* Node is a Leaf */ | ||
110 | - parent_offset, uid++, NULL, 0); | ||
111 | + if (mc->smp_props.clusters_supported) { | ||
112 | + if (cpus->cpus[n].props.cluster_id != cluster_id) { | ||
113 | + assert(cpus->cpus[n].props.cluster_id > cluster_id); | ||
114 | + cluster_id = cpus->cpus[n].props.cluster_id; | ||
115 | + core_id = -1; | ||
116 | + cluster_offset = table_data->len - pptt_start; | ||
117 | + build_processor_hierarchy_node(table_data, | ||
118 | + (0 << 0), /* Not a physical package */ | ||
119 | + socket_offset, cluster_id, NULL, 0); | ||
120 | } | ||
121 | + } else { | ||
122 | + cluster_offset = socket_offset; | ||
123 | } | ||
124 | - } | ||
125 | |||
126 | - length = g_queue_get_length(list); | ||
127 | - for (i = 0; i < length; i++) { | ||
128 | - int thread; | ||
129 | + if (ms->smp.threads == 1) { | ||
130 | + build_processor_hierarchy_node(table_data, | ||
131 | + (1 << 1) | /* ACPI Processor ID valid */ | ||
132 | + (1 << 3), /* Node is a Leaf */ | ||
133 | + cluster_offset, n, NULL, 0); | ||
134 | + } else { | ||
135 | + if (cpus->cpus[n].props.core_id != core_id) { | ||
136 | + assert(cpus->cpus[n].props.core_id > core_id); | ||
137 | + core_id = cpus->cpus[n].props.core_id; | ||
138 | + core_offset = table_data->len - pptt_start; | ||
139 | + build_processor_hierarchy_node(table_data, | ||
140 | + (0 << 0), /* Not a physical package */ | ||
141 | + cluster_offset, core_id, NULL, 0); | ||
142 | + } | ||
143 | |||
144 | - parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list)); | ||
145 | - for (thread = 0; thread < ms->smp.threads; thread++) { | ||
146 | - build_processor_hierarchy_node( | ||
147 | - table_data, | ||
148 | + build_processor_hierarchy_node(table_data, | ||
149 | (1 << 1) | /* ACPI Processor ID valid */ | ||
150 | (1 << 2) | /* Processor is a Thread */ | ||
151 | (1 << 3), /* Node is a Leaf */ | ||
152 | - parent_offset, uid++, NULL, 0); | ||
153 | + core_offset, n, NULL, 0); | ||
79 | } | 154 | } |
80 | } | 155 | } |
81 | 156 | ||
82 | - /* Advanced SIMD and FP registers. */ | 157 | - g_queue_free(list); |
83 | - for (i = 0; i < 32; i++) { | 158 | acpi_table_end(linker, &table); |
84 | - uint64_t *q = aa64_vfp_qreg(env, i); | ||
85 | -#ifdef HOST_WORDS_BIGENDIAN | ||
86 | - uint64_t fp_val[2] = { q[1], q[0] }; | ||
87 | - reg.addr = (uintptr_t)fp_val; | ||
88 | -#else | ||
89 | - reg.addr = (uintptr_t)q; | ||
90 | -#endif | ||
91 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
92 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
93 | - if (ret) { | ||
94 | - return ret; | ||
95 | - } | ||
96 | - } | ||
97 | - | ||
98 | - reg.addr = (uintptr_t)(&fpr); | ||
99 | - fpr = vfp_get_fpsr(env); | ||
100 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
101 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
102 | - if (ret) { | ||
103 | - return ret; | ||
104 | - } | ||
105 | - | ||
106 | - fpr = vfp_get_fpcr(env); | ||
107 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
108 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
109 | + ret = kvm_arch_put_fpsimd(cs); | ||
110 | if (ret) { | ||
111 | return ret; | ||
112 | } | ||
113 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
114 | return ret; | ||
115 | } | 159 | } |
116 | 160 | ||
117 | +static int kvm_arch_get_fpsimd(CPUState *cs) | ||
118 | +{ | ||
119 | + ARMCPU *cpu = ARM_CPU(cs); | ||
120 | + CPUARMState *env = &cpu->env; | ||
121 | + struct kvm_one_reg reg; | ||
122 | + uint32_t fpr; | ||
123 | + int i, ret; | ||
124 | + | ||
125 | + for (i = 0; i < 32; i++) { | ||
126 | + uint64_t *q = aa64_vfp_qreg(env, i); | ||
127 | + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
128 | + reg.addr = (uintptr_t)q; | ||
129 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
130 | + if (ret) { | ||
131 | + return ret; | ||
132 | + } else { | ||
133 | +#ifdef HOST_WORDS_BIGENDIAN | ||
134 | + uint64_t t; | ||
135 | + t = q[0], q[0] = q[1], q[1] = t; | ||
136 | +#endif | ||
137 | + } | ||
138 | + } | ||
139 | + | ||
140 | + reg.addr = (uintptr_t)(&fpr); | ||
141 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
142 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
143 | + if (ret) { | ||
144 | + return ret; | ||
145 | + } | ||
146 | + vfp_set_fpsr(env, fpr); | ||
147 | + | ||
148 | + reg.addr = (uintptr_t)(&fpr); | ||
149 | + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
150 | + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
151 | + if (ret) { | ||
152 | + return ret; | ||
153 | + } | ||
154 | + vfp_set_fpcr(env, fpr); | ||
155 | + | ||
156 | + return 0; | ||
157 | +} | ||
158 | + | ||
159 | int kvm_arch_get_registers(CPUState *cs) | ||
160 | { | ||
161 | struct kvm_one_reg reg; | ||
162 | uint64_t val; | ||
163 | - uint32_t fpr; | ||
164 | unsigned int el; | ||
165 | - int i; | ||
166 | - int ret; | ||
167 | + int i, ret; | ||
168 | |||
169 | ARMCPU *cpu = ARM_CPU(cs); | ||
170 | CPUARMState *env = &cpu->env; | ||
171 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
172 | env->spsr = env->banked_spsr[i]; | ||
173 | } | ||
174 | |||
175 | - /* Advanced SIMD and FP registers */ | ||
176 | - for (i = 0; i < 32; i++) { | ||
177 | - uint64_t *q = aa64_vfp_qreg(env, i); | ||
178 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
179 | - reg.addr = (uintptr_t)q; | ||
180 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
181 | - if (ret) { | ||
182 | - return ret; | ||
183 | - } else { | ||
184 | -#ifdef HOST_WORDS_BIGENDIAN | ||
185 | - uint64_t t; | ||
186 | - t = q[0], q[0] = q[1], q[1] = t; | ||
187 | -#endif | ||
188 | - } | ||
189 | - } | ||
190 | - | ||
191 | - reg.addr = (uintptr_t)(&fpr); | ||
192 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
193 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
194 | + ret = kvm_arch_get_fpsimd(cs); | ||
195 | if (ret) { | ||
196 | return ret; | ||
197 | } | ||
198 | - vfp_set_fpsr(env, fpr); | ||
199 | - | ||
200 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
201 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
202 | - if (ret) { | ||
203 | - return ret; | ||
204 | - } | ||
205 | - vfp_set_fpcr(env, fpr); | ||
206 | |||
207 | ret = kvm_get_vcpu_events(cpu); | ||
208 | if (ret) { | ||
209 | -- | 161 | -- |
210 | 2.20.1 | 162 | 2.25.1 |
211 | |||
212 | diff view generated by jsdifflib |