@samitouri / QOSamiQemu / commits / 92f6097af3

target/arm: Move -cpu max stuff out of cpu32.c

Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260827041557.775080-2-richard.henderson@linaro.org Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Richard Henderson committed Aug 26, 2026 at 21:15 UTC 92f6097af3648b036eaeabbbb81a263bbda1075a
3 files changed +118 -111
target/arm/tcg/cpu-max-v8.c new
+117
@@ -0,0 +1,117 @@
1 +/* SPDX-License-Identifier: GPL-2.0-or-later */
2 +
3 +#include "qemu/osdep.h"
4 +#include "cpu.h"
5 +#include "internals.h"
6 +
7 +
8 +/* Share AArch32 -cpu max features with AArch64. */
9 +void aa32_max_features(ARMCPU *cpu)
10 +{
11 + uint32_t t;
12 + ARMISARegisters *isar = &cpu->isar;
13 +
14 + /* Add additional features supported by QEMU */
15 + t = GET_IDREG(isar, ID_ISAR5);
16 + t = FIELD_DP32(t, ID_ISAR5, AES, 2); /* FEAT_PMULL */
17 + t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); /* FEAT_SHA1 */
18 + t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); /* FEAT_SHA256 */
19 + t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
20 + t = FIELD_DP32(t, ID_ISAR5, RDM, 1); /* FEAT_RDM */
21 + t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); /* FEAT_FCMA */
22 + SET_IDREG(isar, ID_ISAR5, t);
23 +
24 + t = GET_IDREG(isar, ID_ISAR6);
25 + t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); /* FEAT_JSCVT */
26 + t = FIELD_DP32(t, ID_ISAR6, DP, 1); /* Feat_DotProd */
27 + t = FIELD_DP32(t, ID_ISAR6, FHM, 1); /* FEAT_FHM */
28 + t = FIELD_DP32(t, ID_ISAR6, SB, 1); /* FEAT_SB */
29 + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); /* FEAT_SPECRES */
30 + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); /* FEAT_AA32BF16 */
31 + t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); /* FEAT_AA32I8MM */
32 + SET_IDREG(isar, ID_ISAR6, t);
33 +
34 + t = cpu->isar.mvfr1;
35 + t = FIELD_DP32(t, MVFR1, FPHP, 3); /* FEAT_FP16 */
36 + t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* FEAT_FP16 */
37 + cpu->isar.mvfr1 = t;
38 +
39 + t = cpu->isar.mvfr2;
40 + t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
41 + t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
42 + cpu->isar.mvfr2 = t;
43 +
44 + FIELD_DP32_IDREG(isar, ID_MMFR3, PAN, 2); /* FEAT_PAN2 */
45 +
46 + t = GET_IDREG(isar, ID_MMFR4);
47 + t = FIELD_DP32(t, ID_MMFR4, HPDS, 2); /* FEAT_HPDS2 */
48 + t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
49 + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */
50 + t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */
51 + t = FIELD_DP32(t, ID_MMFR4, EVT, 2); /* FEAT_EVT2 */
52 + SET_IDREG(isar, ID_MMFR4, t);
53 +
54 + FIELD_DP32_IDREG(isar, ID_MMFR5, ETS, 2); /* FEAT_ETS2 */
55 +
56 + t = GET_IDREG(isar, ID_PFR0);
57 + t = FIELD_DP32(t, ID_PFR0, CSV2, 2); /* FEAT_CSV2 */
58 + t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */
59 + t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */
60 + SET_IDREG(isar, ID_PFR0, t);
61 +
62 + t = GET_IDREG(isar, ID_PFR2);
63 + t = FIELD_DP32(t, ID_PFR2, CSV3, 1); /* FEAT_CSV3 */
64 + t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */
65 + SET_IDREG(isar, ID_PFR2, t);
66 +
67 + t = GET_IDREG(isar, ID_DFR0);
68 + t = FIELD_DP32(t, ID_DFR0, COPDBG, 10); /* FEAT_Debugv8p8 */
69 + t = FIELD_DP32(t, ID_DFR0, COPSDBG, 10); /* FEAT_Debugv8p8 */
70 + t = FIELD_DP32(t, ID_DFR0, PERFMON, 6); /* FEAT_PMUv3p5 */
71 + SET_IDREG(isar, ID_DFR0, t);
72 +
73 + /* Debug ID registers. */
74 +
75 + /* Bit[15] is RES1, Bit[13] and Bits[11:0] are RES0. */
76 + t = 0x00008000;
77 + t = FIELD_DP32(t, DBGDIDR, SE_IMP, 1);
78 + t = FIELD_DP32(t, DBGDIDR, NSUHD_IMP, 1);
79 + t = FIELD_DP32(t, DBGDIDR, VERSION, 10); /* FEAT_Debugv8p8 */
80 + t = FIELD_DP32(t, DBGDIDR, CTX_CMPS, 1);
81 + t = FIELD_DP32(t, DBGDIDR, BRPS, 5);
82 + t = FIELD_DP32(t, DBGDIDR, WRPS, 3);
83 + cpu->isar.dbgdidr = t;
84 +
85 + t = 0;
86 + t = FIELD_DP32(t, DBGDEVID, PCSAMPLE, 3);
87 + t = FIELD_DP32(t, DBGDEVID, WPADDRMASK, 1);
88 + t = FIELD_DP32(t, DBGDEVID, BPADDRMASK, 15);
89 + t = FIELD_DP32(t, DBGDEVID, VECTORCATCH, 0);
90 + t = FIELD_DP32(t, DBGDEVID, VIRTEXTNS, 1);
91 + t = FIELD_DP32(t, DBGDEVID, DOUBLELOCK, 1);
92 + t = FIELD_DP32(t, DBGDEVID, AUXREGS, 0);
93 + t = FIELD_DP32(t, DBGDEVID, CIDMASK, 0);
94 + cpu->isar.dbgdevid = t;
95 +
96 + /* Bits[31:4] are RES0. */
97 + t = 0;
98 + t = FIELD_DP32(t, DBGDEVID1, PCSROFFSET, 2);
99 + cpu->isar.dbgdevid1 = t;
100 +
101 + FIELD_DP32_IDREG(isar, ID_DFR1, HPMN0, 1); /* FEAT_HPMN0 */
102 +}
103 +
104 +void aarch32_max_tcg_init(ARMCPU *cpu)
105 +{
106 + aarch64_aa32_a57_init(cpu, false);
107 + aa32_max_features(cpu);
108 +#ifdef CONFIG_USER_ONLY
109 + /*
110 + * Break with true ARMv8 and add back old-style VFP short-vector
111 + * support. Only do this for user-mode, where -cpu max is the default,
112 + * so that older v6 and v7 programs are more likely to work without
113 + * adjustment.
114 + */
115 + cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
116 +#endif
117 +}
target/arm/tcg/cpu32.c
-111
@@ -758,114 +758,3 @@ static void arm_tcg_cpu_register_types(void)
758 type_init(arm_tcg_cpu_register_types)
759
760 #endif /* !CONFIG_USER_ONLY || !TARGET_AARCH64 */
761 -
762 -/* Share AArch32 -cpu max features with AArch64. */
763 -void aa32_max_features(ARMCPU *cpu)
764 -{
765 - uint32_t t;
766 - ARMISARegisters *isar = &cpu->isar;
767 -
768 - /* Add additional features supported by QEMU */
769 - t = GET_IDREG(isar, ID_ISAR5);
770 - t = FIELD_DP32(t, ID_ISAR5, AES, 2); /* FEAT_PMULL */
771 - t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); /* FEAT_SHA1 */
772 - t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); /* FEAT_SHA256 */
773 - t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
774 - t = FIELD_DP32(t, ID_ISAR5, RDM, 1); /* FEAT_RDM */
775 - t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); /* FEAT_FCMA */
776 - SET_IDREG(isar, ID_ISAR5, t);
777 -
778 - t = GET_IDREG(isar, ID_ISAR6);
779 - t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); /* FEAT_JSCVT */
780 - t = FIELD_DP32(t, ID_ISAR6, DP, 1); /* Feat_DotProd */
781 - t = FIELD_DP32(t, ID_ISAR6, FHM, 1); /* FEAT_FHM */
782 - t = FIELD_DP32(t, ID_ISAR6, SB, 1); /* FEAT_SB */
783 - t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); /* FEAT_SPECRES */
784 - t = FIELD_DP32(t, ID_ISAR6, BF16, 1); /* FEAT_AA32BF16 */
785 - t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); /* FEAT_AA32I8MM */
786 - SET_IDREG(isar, ID_ISAR6, t);
787 -
788 - t = cpu->isar.mvfr1;
789 - t = FIELD_DP32(t, MVFR1, FPHP, 3); /* FEAT_FP16 */
790 - t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* FEAT_FP16 */
791 - cpu->isar.mvfr1 = t;
792 -
793 - t = cpu->isar.mvfr2;
794 - t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
795 - t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
796 - cpu->isar.mvfr2 = t;
797 -
798 - FIELD_DP32_IDREG(isar, ID_MMFR3, PAN, 2); /* FEAT_PAN2 */
799 -
800 - t = GET_IDREG(isar, ID_MMFR4);
801 - t = FIELD_DP32(t, ID_MMFR4, HPDS, 2); /* FEAT_HPDS2 */
802 - t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
803 - t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */
804 - t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */
805 - t = FIELD_DP32(t, ID_MMFR4, EVT, 2); /* FEAT_EVT2 */
806 - SET_IDREG(isar, ID_MMFR4, t);
807 -
808 - FIELD_DP32_IDREG(isar, ID_MMFR5, ETS, 2); /* FEAT_ETS2 */
809 -
810 - t = GET_IDREG(isar, ID_PFR0);
811 - t = FIELD_DP32(t, ID_PFR0, CSV2, 2); /* FEAT_CSV2 */
812 - t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */
813 - t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */
814 - SET_IDREG(isar, ID_PFR0, t);
815 -
816 - t = GET_IDREG(isar, ID_PFR2);
817 - t = FIELD_DP32(t, ID_PFR2, CSV3, 1); /* FEAT_CSV3 */
818 - t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */
819 - SET_IDREG(isar, ID_PFR2, t);
820 -
821 - t = GET_IDREG(isar, ID_DFR0);
822 - t = FIELD_DP32(t, ID_DFR0, COPDBG, 10); /* FEAT_Debugv8p8 */
823 - t = FIELD_DP32(t, ID_DFR0, COPSDBG, 10); /* FEAT_Debugv8p8 */
824 - t = FIELD_DP32(t, ID_DFR0, PERFMON, 6); /* FEAT_PMUv3p5 */
825 - SET_IDREG(isar, ID_DFR0, t);
826 -
827 - /* Debug ID registers. */
828 -
829 - /* Bit[15] is RES1, Bit[13] and Bits[11:0] are RES0. */
830 - t = 0x00008000;
831 - t = FIELD_DP32(t, DBGDIDR, SE_IMP, 1);
832 - t = FIELD_DP32(t, DBGDIDR, NSUHD_IMP, 1);
833 - t = FIELD_DP32(t, DBGDIDR, VERSION, 10); /* FEAT_Debugv8p8 */
834 - t = FIELD_DP32(t, DBGDIDR, CTX_CMPS, 1);
835 - t = FIELD_DP32(t, DBGDIDR, BRPS, 5);
836 - t = FIELD_DP32(t, DBGDIDR, WRPS, 3);
837 - cpu->isar.dbgdidr = t;
838 -
839 - t = 0;
840 - t = FIELD_DP32(t, DBGDEVID, PCSAMPLE, 3);
841 - t = FIELD_DP32(t, DBGDEVID, WPADDRMASK, 1);
842 - t = FIELD_DP32(t, DBGDEVID, BPADDRMASK, 15);
843 - t = FIELD_DP32(t, DBGDEVID, VECTORCATCH, 0);
844 - t = FIELD_DP32(t, DBGDEVID, VIRTEXTNS, 1);
845 - t = FIELD_DP32(t, DBGDEVID, DOUBLELOCK, 1);
846 - t = FIELD_DP32(t, DBGDEVID, AUXREGS, 0);
847 - t = FIELD_DP32(t, DBGDEVID, CIDMASK, 0);
848 - cpu->isar.dbgdevid = t;
849 -
850 - /* Bits[31:4] are RES0. */
851 - t = 0;
852 - t = FIELD_DP32(t, DBGDEVID1, PCSROFFSET, 2);
853 - cpu->isar.dbgdevid1 = t;
854 -
855 - FIELD_DP32_IDREG(isar, ID_DFR1, HPMN0, 1); /* FEAT_HPMN0 */
856 -}
857 -
858 -void aarch32_max_tcg_init(ARMCPU *cpu)
859 -{
860 - aarch64_aa32_a57_init(cpu, false);
861 - aa32_max_features(cpu);
862 -#ifdef CONFIG_USER_ONLY
863 - /*
864 - * Break with true ARMv8 and add back old-style VFP short-vector
865 - * support. Only do this for user-mode, where -cpu max is the default,
866 - * so that older v6 and v7 programs are more likely to work without
867 - * adjustment.
868 - */
869 - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
870 -#endif
871 -}
target/arm/tcg/meson.build
+1
@@ -65,6 +65,7 @@ arm_common_user_system_ss.add(
65 translate32_d,
66 vfp_d,
67 files(
68 + 'cpu-max-v8.c',
69 'debug.c',
70 'gengvec.c',
71 'hflags.c',