1 | A few patches for the rc today... | 1 | target-arm queue, mostly SME preliminaries. |
---|---|---|---|
2 | 2 | ||
3 | The following changes since commit 109918d24a3bb9ed3d05beb34ea4ac6be443c138: | 3 | In the unlikely event we don't land the rest of SME before freeze |
4 | for 7.1 we can revert the docs/property changes included here. | ||
4 | 5 | ||
5 | Merge remote-tracking branch 'remotes/nvme/tags/nvme-fixes-for-6.0-pull-request' into staging (2021-04-05 22:15:38 +0100) | 6 | -- PMM |
7 | |||
8 | The following changes since commit 097ccbbbaf2681df1e65542e5b7d2b2d0c66e2bc: | ||
9 | |||
10 | Merge tag 'qemu-sparc-20220626' of https://github.com/mcayland/qemu into staging (2022-06-27 05:21:05 +0530) | ||
6 | 11 | ||
7 | are available in the Git repository at: | 12 | are available in the Git repository at: |
8 | 13 | ||
9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210406 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220627 |
10 | 15 | ||
11 | for you to fetch changes up to 49bc76550c37f4a2b92a05cb3e6989a739d56ac9: | 16 | for you to fetch changes up to 59e1b8a22ea9f947d038ccac784de1020f266e14: |
12 | 17 | ||
13 | Remove myself as i.mx31 maintainer (2021-04-06 11:49:15 +0100) | 18 | target/arm: Check V7VE as well as LPAE in arm_pamax (2022-06-27 11:18:17 +0100) |
14 | 19 | ||
15 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
16 | target-arm queue: | 21 | target-arm queue: |
17 | * ppc/e500 and arm/virt: only add valid dynamic sysbus devices to the | 22 | * sphinx: change default language to 'en' |
18 | platform bus | 23 | * Diagnose attempts to emulate EL3 in hvf as well as kvm |
19 | * update i.mx31 maintainer list | 24 | * More SME groundwork patches |
20 | * Revert "target/arm: Make number of counters in PMCR follow the CPU" | 25 | * virt: Fix calculation of physical address space size |
26 | for v7VE CPUs (eg cortex-a15) | ||
21 | 27 | ||
22 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
23 | Chubb, Peter (Data61, Eveleigh) (1): | 29 | Alexander Graf (2): |
24 | Remove myself as i.mx31 maintainer | 30 | accel: Introduce current_accel_name() |
31 | target/arm: Catch invalid kvm state also for hvf | ||
25 | 32 | ||
26 | Peter Maydell (5): | 33 | Martin Liška (1): |
27 | include/hw/boards.h: Document machine_class_allow_dynamic_sysbus_dev() | 34 | sphinx: change default language to 'en' |
28 | machine: Provide a function to check the dynamic sysbus allowlist | ||
29 | hw/arm/virt: Only try to add valid dynamic sysbus devices to platform bus | ||
30 | hw/ppc/e500plat: Only try to add valid dynamic sysbus devices to platform bus | ||
31 | Revert "target/arm: Make number of counters in PMCR follow the CPU" | ||
32 | 35 | ||
33 | include/hw/boards.h | 39 +++++++++++++++++++++++++++++++++++++++ | 36 | Richard Henderson (22): |
34 | target/arm/cpu.h | 1 - | 37 | target/arm: Implement TPIDR2_EL0 |
35 | hw/arm/virt.c | 8 ++++++-- | 38 | target/arm: Add SMEEXC_EL to TB flags |
36 | hw/core/machine.c | 21 ++++++++++++++++----- | 39 | target/arm: Add syn_smetrap |
37 | hw/ppc/e500plat.c | 8 ++++++-- | 40 | target/arm: Add ARM_CP_SME |
38 | target/arm/cpu64.c | 3 --- | 41 | target/arm: Add SVCR |
39 | target/arm/cpu_tcg.c | 5 ----- | 42 | target/arm: Add SMCR_ELx |
40 | target/arm/helper.c | 29 ++++++++++++----------------- | 43 | target/arm: Add SMIDR_EL1, SMPRI_EL1, SMPRIMAP_EL2 |
41 | target/arm/kvm64.c | 2 -- | 44 | target/arm: Add PSTATE.{SM,ZA} to TB flags |
42 | MAINTAINERS | 1 - | 45 | target/arm: Add the SME ZA storage to CPUARMState |
43 | 10 files changed, 79 insertions(+), 38 deletions(-) | 46 | target/arm: Implement SMSTART, SMSTOP |
47 | target/arm: Move error for sve%d property to arm_cpu_sve_finalize | ||
48 | target/arm: Create ARMVQMap | ||
49 | target/arm: Generalize cpu_arm_{get,set}_vq | ||
50 | target/arm: Generalize cpu_arm_{get, set}_default_vec_len | ||
51 | target/arm: Move arm_cpu_*_finalize to internals.h | ||
52 | target/arm: Unexport aarch64_add_*_properties | ||
53 | target/arm: Add cpu properties for SME | ||
54 | target/arm: Introduce sve_vqm1_for_el_sm | ||
55 | target/arm: Add SVL to TB flags | ||
56 | target/arm: Move pred_{full, gvec}_reg_{offset, size} to translate-a64.h | ||
57 | target/arm: Extend arm_pamax to more than aarch64 | ||
58 | target/arm: Check V7VE as well as LPAE in arm_pamax | ||
44 | 59 | ||
60 | docs/conf.py | 2 +- | ||
61 | docs/system/arm/cpu-features.rst | 56 ++++++++++ | ||
62 | include/qemu/accel.h | 1 + | ||
63 | target/arm/cpregs.h | 5 + | ||
64 | target/arm/cpu.h | 103 ++++++++++++++----- | ||
65 | target/arm/helper-sme.h | 21 ++++ | ||
66 | target/arm/helper.h | 1 + | ||
67 | target/arm/internals.h | 4 + | ||
68 | target/arm/syndrome.h | 14 +++ | ||
69 | target/arm/translate-a64.h | 38 +++++++ | ||
70 | target/arm/translate.h | 6 ++ | ||
71 | accel/accel-common.c | 8 ++ | ||
72 | hw/arm/virt.c | 10 +- | ||
73 | softmmu/vl.c | 3 +- | ||
74 | target/arm/cpu.c | 32 ++++-- | ||
75 | target/arm/cpu64.c | 205 ++++++++++++++++++++++++++++--------- | ||
76 | target/arm/helper.c | 213 +++++++++++++++++++++++++++++++++++++-- | ||
77 | target/arm/kvm64.c | 2 +- | ||
78 | target/arm/machine.c | 34 +++++++ | ||
79 | target/arm/ptw.c | 26 +++-- | ||
80 | target/arm/sme_helper.c | 61 +++++++++++ | ||
81 | target/arm/translate-a64.c | 46 +++++++++ | ||
82 | target/arm/translate-sve.c | 36 ------- | ||
83 | target/arm/meson.build | 1 + | ||
84 | 24 files changed, 782 insertions(+), 146 deletions(-) | ||
85 | create mode 100644 target/arm/helper-sme.h | ||
86 | create mode 100644 target/arm/sme_helper.c | ||
87 | diff view generated by jsdifflib |
1 | From: "Chubb, Peter (Data61, Eveleigh)" <Peter.Chubb@data61.csiro.au> | 1 | From: Martin Liška <mliska@suse.cz> |
---|---|---|---|
2 | 2 | ||
3 | Remove Peter Chubb as i/MX31 maintainer. | 3 | Fixes the following Sphinx warning (treated as error) starting |
4 | with 5.0 release: | ||
4 | 5 | ||
5 | I'm leaving my current job and will no longer have access to the | 6 | Warning, treated as error: |
6 | hardware to test or maintain this port. | 7 | Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English). |
7 | 8 | ||
8 | Signed-off-by: Peter Chubb <peter.chubb@data61.csiro.au> | 9 | Signed-off-by: Martin Liska <mliska@suse.cz> |
10 | Message-id: e91e51ee-48ac-437e-6467-98b56ee40042@suse.cz | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 13 | --- |
12 | MAINTAINERS | 1 - | 14 | docs/conf.py | 2 +- |
13 | 1 file changed, 1 deletion(-) | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 16 | ||
15 | diff --git a/MAINTAINERS b/MAINTAINERS | 17 | diff --git a/docs/conf.py b/docs/conf.py |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/MAINTAINERS | 19 | --- a/docs/conf.py |
18 | +++ b/MAINTAINERS | 20 | +++ b/docs/conf.py |
19 | @@ -XXX,XX +XXX,XX @@ F: include/hw/misc/imx25_ccm.h | 21 | @@ -XXX,XX +XXX,XX @@ |
20 | F: include/hw/watchdog/wdt_imx2.h | 22 | # |
21 | 23 | # This is also used if you do content translation via gettext catalogs. | |
22 | i.MX31 (kzm) | 24 | # Usually you set "language" from the command line for these cases. |
23 | -M: Peter Chubb <peter.chubb@nicta.com.au> | 25 | -language = None |
24 | M: Peter Maydell <peter.maydell@linaro.org> | 26 | +language = 'en' |
25 | L: qemu-arm@nongnu.org | 27 | |
26 | S: Odd Fixes | 28 | # List of patterns, relative to source directory, that match files and |
29 | # directories to ignore when looking for source files. | ||
27 | -- | 30 | -- |
28 | 2.20.1 | 31 | 2.25.1 |
29 | 32 | ||
30 | 33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
1 | 2 | ||
3 | We need to fetch the name of the current accelerator in flexible error | ||
4 | messages more going forward. Let's create a helper that gives it to us | ||
5 | without casting in the target code. | ||
6 | |||
7 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220620192242.70573-1-agraf@csgraf.de | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/qemu/accel.h | 1 + | ||
13 | accel/accel-common.c | 8 ++++++++ | ||
14 | softmmu/vl.c | 3 +-- | ||
15 | 3 files changed, 10 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/include/qemu/accel.h b/include/qemu/accel.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/qemu/accel.h | ||
20 | +++ b/include/qemu/accel.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct AccelClass { | ||
22 | |||
23 | AccelClass *accel_find(const char *opt_name); | ||
24 | AccelState *current_accel(void); | ||
25 | +const char *current_accel_name(void); | ||
26 | |||
27 | void accel_init_interfaces(AccelClass *ac); | ||
28 | |||
29 | diff --git a/accel/accel-common.c b/accel/accel-common.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/accel/accel-common.c | ||
32 | +++ b/accel/accel-common.c | ||
33 | @@ -XXX,XX +XXX,XX @@ AccelClass *accel_find(const char *opt_name) | ||
34 | return ac; | ||
35 | } | ||
36 | |||
37 | +/* Return the name of the current accelerator */ | ||
38 | +const char *current_accel_name(void) | ||
39 | +{ | ||
40 | + AccelClass *ac = ACCEL_GET_CLASS(current_accel()); | ||
41 | + | ||
42 | + return ac->name; | ||
43 | +} | ||
44 | + | ||
45 | static void accel_init_cpu_int_aux(ObjectClass *klass, void *opaque) | ||
46 | { | ||
47 | CPUClass *cc = CPU_CLASS(klass); | ||
48 | diff --git a/softmmu/vl.c b/softmmu/vl.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/softmmu/vl.c | ||
51 | +++ b/softmmu/vl.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void configure_accelerators(const char *progname) | ||
53 | } | ||
54 | |||
55 | if (init_failed && !qtest_chrdev) { | ||
56 | - AccelClass *ac = ACCEL_GET_CLASS(current_accel()); | ||
57 | - error_report("falling back to %s", ac->name); | ||
58 | + error_report("falling back to %s", current_accel_name()); | ||
59 | } | ||
60 | |||
61 | if (icount_enabled() && !tcg_enabled()) { | ||
62 | -- | ||
63 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
1 | 2 | ||
3 | Some features such as running in EL3 or running M profile code are | ||
4 | incompatible with virtualization as QEMU implements it today. To prevent | ||
5 | users from picking invalid configurations on other virt solutions like | ||
6 | Hvf, let's run the same checks there too. | ||
7 | |||
8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1073 | ||
9 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220620192242.70573-2-agraf@csgraf.de | ||
12 | [PMM: Allow qtest accelerator too; tweak comment] | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/cpu.c | 16 ++++++++++++---- | ||
16 | 1 file changed, 12 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu.c | ||
21 | +++ b/target/arm/cpu.c | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #include "hw/boards.h" | ||
24 | #endif | ||
25 | #include "sysemu/tcg.h" | ||
26 | +#include "sysemu/qtest.h" | ||
27 | #include "sysemu/hw_accel.h" | ||
28 | #include "kvm_arm.h" | ||
29 | #include "disas/capstone.h" | ||
30 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
31 | } | ||
32 | } | ||
33 | |||
34 | - if (kvm_enabled()) { | ||
35 | + if (!tcg_enabled() && !qtest_enabled()) { | ||
36 | /* | ||
37 | + * We assume that no accelerator except TCG (and the "not really an | ||
38 | + * accelerator" qtest) can handle these features, because Arm hardware | ||
39 | + * virtualization can't virtualize them. | ||
40 | + * | ||
41 | * Catch all the cases which might cause us to create more than one | ||
42 | * address space for the CPU (otherwise we will assert() later in | ||
43 | * cpu_address_space_init()). | ||
44 | */ | ||
45 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
46 | error_setg(errp, | ||
47 | - "Cannot enable KVM when using an M-profile guest CPU"); | ||
48 | + "Cannot enable %s when using an M-profile guest CPU", | ||
49 | + current_accel_name()); | ||
50 | return; | ||
51 | } | ||
52 | if (cpu->has_el3) { | ||
53 | error_setg(errp, | ||
54 | - "Cannot enable KVM when guest CPU has EL3 enabled"); | ||
55 | + "Cannot enable %s when guest CPU has EL3 enabled", | ||
56 | + current_accel_name()); | ||
57 | return; | ||
58 | } | ||
59 | if (cpu->tag_memory) { | ||
60 | error_setg(errp, | ||
61 | - "Cannot enable KVM when guest CPUs has MTE enabled"); | ||
62 | + "Cannot enable %s when guest CPUs has MTE enabled", | ||
63 | + current_accel_name()); | ||
64 | return; | ||
65 | } | ||
66 | } | ||
67 | -- | ||
68 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This register is part of SME, but isn't closely related to the | ||
4 | rest of the extension. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-2-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 1 + | ||
12 | target/arm/helper.c | 32 ++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 33 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
20 | }; | ||
21 | uint64_t tpidr_el[4]; | ||
22 | }; | ||
23 | + uint64_t tpidr2_el0; | ||
24 | /* The secure banks of these registers don't map anywhere */ | ||
25 | uint64_t tpidrurw_s; | ||
26 | uint64_t tpidrprw_s; | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/helper.c | ||
30 | +++ b/target/arm/helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_reginfo[] = { | ||
32 | .writefn = zcr_write, .raw_writefn = raw_write }, | ||
33 | }; | ||
34 | |||
35 | +#ifdef TARGET_AARCH64 | ||
36 | +static CPAccessResult access_tpidr2(CPUARMState *env, const ARMCPRegInfo *ri, | ||
37 | + bool isread) | ||
38 | +{ | ||
39 | + int el = arm_current_el(env); | ||
40 | + | ||
41 | + if (el == 0) { | ||
42 | + uint64_t sctlr = arm_sctlr(env, el); | ||
43 | + if (!(sctlr & SCTLR_EnTP2)) { | ||
44 | + return CP_ACCESS_TRAP; | ||
45 | + } | ||
46 | + } | ||
47 | + /* TODO: FEAT_FGT */ | ||
48 | + if (el < 3 | ||
49 | + && arm_feature(env, ARM_FEATURE_EL3) | ||
50 | + && !(env->cp15.scr_el3 & SCR_ENTP2)) { | ||
51 | + return CP_ACCESS_TRAP_EL3; | ||
52 | + } | ||
53 | + return CP_ACCESS_OK; | ||
54 | +} | ||
55 | + | ||
56 | +static const ARMCPRegInfo sme_reginfo[] = { | ||
57 | + { .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64, | ||
58 | + .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5, | ||
59 | + .access = PL0_RW, .accessfn = access_tpidr2, | ||
60 | + .fieldoffset = offsetof(CPUARMState, cp15.tpidr2_el0) }, | ||
61 | +}; | ||
62 | +#endif /* TARGET_AARCH64 */ | ||
63 | + | ||
64 | void hw_watchpoint_update(ARMCPU *cpu, int n) | ||
65 | { | ||
66 | CPUARMState *env = &cpu->env; | ||
67 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
68 | } | ||
69 | |||
70 | #ifdef TARGET_AARCH64 | ||
71 | + if (cpu_isar_feature(aa64_sme, cpu)) { | ||
72 | + define_arm_cp_regs(cpu, sme_reginfo); | ||
73 | + } | ||
74 | if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
75 | define_arm_cp_regs(cpu, pauth_reginfo); | ||
76 | } | ||
77 | -- | ||
78 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This is CheckSMEAccess, which is the basis for a set of | ||
4 | related tests for various SME cpregs and instructions. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-3-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 2 ++ | ||
12 | target/arm/translate.h | 1 + | ||
13 | target/arm/helper.c | 52 ++++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-a64.c | 1 + | ||
15 | 4 files changed, 56 insertions(+) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env); | ||
22 | |||
23 | int fp_exception_el(CPUARMState *env, int cur_el); | ||
24 | int sve_exception_el(CPUARMState *env, int cur_el); | ||
25 | +int sme_exception_el(CPUARMState *env, int cur_el); | ||
26 | |||
27 | /** | ||
28 | * sve_vqm1_for_el: | ||
29 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, ATA, 15, 1) | ||
30 | FIELD(TBFLAG_A64, TCMA, 16, 2) | ||
31 | FIELD(TBFLAG_A64, MTE_ACTIVE, 18, 1) | ||
32 | FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
33 | +FIELD(TBFLAG_A64, SMEEXC_EL, 20, 2) | ||
34 | |||
35 | /* | ||
36 | * Helpers for using the above. | ||
37 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/translate.h | ||
40 | +++ b/target/arm/translate.h | ||
41 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
42 | bool ns; /* Use non-secure CPREG bank on access */ | ||
43 | int fp_excp_el; /* FP exception EL or 0 if enabled */ | ||
44 | int sve_excp_el; /* SVE exception EL or 0 if enabled */ | ||
45 | + int sme_excp_el; /* SME exception EL or 0 if enabled */ | ||
46 | int vl; /* current vector length in bytes */ | ||
47 | bool vfp_enabled; /* FP enabled via FPSCR.EN */ | ||
48 | int vec_len; | ||
49 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/helper.c | ||
52 | +++ b/target/arm/helper.c | ||
53 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | +/* | ||
58 | + * Return the exception level to which exceptions should be taken for SME. | ||
59 | + * C.f. the ARM pseudocode function CheckSMEAccess. | ||
60 | + */ | ||
61 | +int sme_exception_el(CPUARMState *env, int el) | ||
62 | +{ | ||
63 | +#ifndef CONFIG_USER_ONLY | ||
64 | + if (el <= 1 && !el_is_in_host(env, el)) { | ||
65 | + switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, SMEN)) { | ||
66 | + case 1: | ||
67 | + if (el != 0) { | ||
68 | + break; | ||
69 | + } | ||
70 | + /* fall through */ | ||
71 | + case 0: | ||
72 | + case 2: | ||
73 | + return 1; | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + if (el <= 2 && arm_is_el2_enabled(env)) { | ||
78 | + /* CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */ | ||
79 | + if (env->cp15.hcr_el2 & HCR_E2H) { | ||
80 | + switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, SMEN)) { | ||
81 | + case 1: | ||
82 | + if (el != 0 || !(env->cp15.hcr_el2 & HCR_TGE)) { | ||
83 | + break; | ||
84 | + } | ||
85 | + /* fall through */ | ||
86 | + case 0: | ||
87 | + case 2: | ||
88 | + return 2; | ||
89 | + } | ||
90 | + } else { | ||
91 | + if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TSM)) { | ||
92 | + return 2; | ||
93 | + } | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + /* CPTR_EL3. Since ESM is negative we must check for EL3. */ | ||
98 | + if (arm_feature(env, ARM_FEATURE_EL3) | ||
99 | + && !FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, ESM)) { | ||
100 | + return 3; | ||
101 | + } | ||
102 | +#endif | ||
103 | + return 0; | ||
104 | +} | ||
105 | + | ||
106 | /* | ||
107 | * Given that SVE is enabled, return the vector length for EL. | ||
108 | */ | ||
109 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
110 | } | ||
111 | DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | ||
112 | } | ||
113 | + if (cpu_isar_feature(aa64_sme, env_archcpu(env))) { | ||
114 | + DP_TBFLAG_A64(flags, SMEEXC_EL, sme_exception_el(env, el)); | ||
115 | + } | ||
116 | |||
117 | sctlr = regime_sctlr(env, stage1); | ||
118 | |||
119 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/translate-a64.c | ||
122 | +++ b/target/arm/translate-a64.c | ||
123 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
124 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | ||
125 | dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); | ||
126 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | ||
127 | + dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL); | ||
128 | dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16; | ||
129 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | ||
130 | dc->bt = EX_TBFLAG_A64(tb_flags, BT); | ||
131 | -- | ||
132 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This will be used for raising various traps for SME. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220620175235.60881-4-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/syndrome.h | 14 ++++++++++++++ | ||
11 | 1 file changed, 14 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/syndrome.h | ||
16 | +++ b/target/arm/syndrome.h | ||
17 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | ||
18 | EC_AA64_SMC = 0x17, | ||
19 | EC_SYSTEMREGISTERTRAP = 0x18, | ||
20 | EC_SVEACCESSTRAP = 0x19, | ||
21 | + EC_SMETRAP = 0x1d, | ||
22 | EC_INSNABORT = 0x20, | ||
23 | EC_INSNABORT_SAME_EL = 0x21, | ||
24 | EC_PCALIGNMENT = 0x22, | ||
25 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | ||
26 | EC_AA64_BKPT = 0x3c, | ||
27 | }; | ||
28 | |||
29 | +typedef enum { | ||
30 | + SME_ET_AccessTrap, | ||
31 | + SME_ET_Streaming, | ||
32 | + SME_ET_NotStreaming, | ||
33 | + SME_ET_InactiveZA, | ||
34 | +} SMEExceptionType; | ||
35 | + | ||
36 | #define ARM_EL_EC_SHIFT 26 | ||
37 | #define ARM_EL_IL_SHIFT 25 | ||
38 | #define ARM_EL_ISV_SHIFT 24 | ||
39 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_sve_access_trap(void) | ||
40 | return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT; | ||
41 | } | ||
42 | |||
43 | +static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit) | ||
44 | +{ | ||
45 | + return (EC_SMETRAP << ARM_EL_EC_SHIFT) | ||
46 | + | (is_16bit ? 0 : ARM_EL_IL) | etype; | ||
47 | +} | ||
48 | + | ||
49 | static inline uint32_t syn_pactrap(void) | ||
50 | { | ||
51 | return EC_PACTRAP << ARM_EL_EC_SHIFT; | ||
52 | -- | ||
53 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This will be used for controlling access to SME cpregs. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220620175235.60881-5-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/cpregs.h | 5 +++++ | ||
11 | target/arm/translate-a64.c | 18 ++++++++++++++++++ | ||
12 | 2 files changed, 23 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpregs.h | ||
17 | +++ b/target/arm/cpregs.h | ||
18 | @@ -XXX,XX +XXX,XX @@ enum { | ||
19 | ARM_CP_EL3_NO_EL2_UNDEF = 1 << 16, | ||
20 | ARM_CP_EL3_NO_EL2_KEEP = 1 << 17, | ||
21 | ARM_CP_EL3_NO_EL2_C_NZ = 1 << 18, | ||
22 | + /* | ||
23 | + * Flag: Access check for this sysreg is constrained by the | ||
24 | + * ARM pseudocode function CheckSMEAccess(). | ||
25 | + */ | ||
26 | + ARM_CP_SME = 1 << 19, | ||
27 | }; | ||
28 | |||
29 | /* | ||
30 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate-a64.c | ||
33 | +++ b/target/arm/translate-a64.c | ||
34 | @@ -XXX,XX +XXX,XX @@ bool sve_access_check(DisasContext *s) | ||
35 | return fp_access_check(s); | ||
36 | } | ||
37 | |||
38 | +/* | ||
39 | + * Check that SME access is enabled, raise an exception if not. | ||
40 | + * Note that this function corresponds to CheckSMEAccess and is | ||
41 | + * only used directly for cpregs. | ||
42 | + */ | ||
43 | +static bool sme_access_check(DisasContext *s) | ||
44 | +{ | ||
45 | + if (s->sme_excp_el) { | ||
46 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
47 | + syn_smetrap(SME_ET_AccessTrap, false), | ||
48 | + s->sme_excp_el); | ||
49 | + return false; | ||
50 | + } | ||
51 | + return true; | ||
52 | +} | ||
53 | + | ||
54 | /* | ||
55 | * This utility function is for doing register extension with an | ||
56 | * optional shift. You will likely want to pass a temporary for the | ||
57 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
58 | return; | ||
59 | } else if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) { | ||
60 | return; | ||
61 | + } else if ((ri->type & ARM_CP_SME) && !sme_access_check(s)) { | ||
62 | + return; | ||
63 | } | ||
64 | |||
65 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | ||
66 | -- | ||
67 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | This cpreg is used to access two new bits of PSTATE | ||
4 | that are not visible via any other mechanism. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-6-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 6 ++++++ | ||
12 | target/arm/helper.c | 13 +++++++++++++ | ||
13 | 2 files changed, 19 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
20 | * nRW (also known as M[4]) is kept, inverted, in env->aarch64 | ||
21 | * DAIF (exception masks) are kept in env->daif | ||
22 | * BTYPE is kept in env->btype | ||
23 | + * SM and ZA are kept in env->svcr | ||
24 | * all other bits are stored in their correct places in env->pstate | ||
25 | */ | ||
26 | uint32_t pstate; | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
28 | uint32_t condexec_bits; /* IT bits. cpsr[15:10,26:25]. */ | ||
29 | uint32_t btype; /* BTI branch type. spsr[11:10]. */ | ||
30 | uint64_t daif; /* exception masks, in the bits they are in PSTATE */ | ||
31 | + uint64_t svcr; /* PSTATE.{SM,ZA} in the bits they are in SVCR */ | ||
32 | |||
33 | uint64_t elr_el[4]; /* AArch64 exception link regs */ | ||
34 | uint64_t sp_el[4]; /* AArch64 banked stack pointers */ | ||
35 | @@ -XXX,XX +XXX,XX @@ FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
36 | #define PSTATE_MODE_EL1t 4 | ||
37 | #define PSTATE_MODE_EL0t 0 | ||
38 | |||
39 | +/* PSTATE bits that are accessed via SVCR and not stored in SPSR_ELx. */ | ||
40 | +FIELD(SVCR, SM, 0, 1) | ||
41 | +FIELD(SVCR, ZA, 1, 1) | ||
42 | + | ||
43 | /* Write a new value to v7m.exception, thus transitioning into or out | ||
44 | * of Handler mode; this may result in a change of active stack pointer. | ||
45 | */ | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/helper.c | ||
49 | +++ b/target/arm/helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpidr2(CPUARMState *env, const ARMCPRegInfo *ri, | ||
51 | return CP_ACCESS_OK; | ||
52 | } | ||
53 | |||
54 | +static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
55 | + uint64_t value) | ||
56 | +{ | ||
57 | + value &= R_SVCR_SM_MASK | R_SVCR_ZA_MASK; | ||
58 | + /* TODO: Side effects. */ | ||
59 | + env->svcr = value; | ||
60 | +} | ||
61 | + | ||
62 | static const ARMCPRegInfo sme_reginfo[] = { | ||
63 | { .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64, | ||
64 | .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5, | ||
65 | .access = PL0_RW, .accessfn = access_tpidr2, | ||
66 | .fieldoffset = offsetof(CPUARMState, cp15.tpidr2_el0) }, | ||
67 | + { .name = "SVCR", .state = ARM_CP_STATE_AA64, | ||
68 | + .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 2, | ||
69 | + .access = PL0_RW, .type = ARM_CP_SME, | ||
70 | + .fieldoffset = offsetof(CPUARMState, svcr), | ||
71 | + .writefn = svcr_write, .raw_writefn = raw_write }, | ||
72 | }; | ||
73 | #endif /* TARGET_AARCH64 */ | ||
74 | |||
75 | -- | ||
76 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | These cpregs control the streaming vector length and whether the | ||
4 | full a64 instruction set is allowed while in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-7-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 8 ++++++-- | ||
12 | target/arm/helper.c | 41 +++++++++++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 47 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
20 | float_status standard_fp_status; | ||
21 | float_status standard_fp_status_f16; | ||
22 | |||
23 | - /* ZCR_EL[1-3] */ | ||
24 | - uint64_t zcr_el[4]; | ||
25 | + uint64_t zcr_el[4]; /* ZCR_EL[1-3] */ | ||
26 | + uint64_t smcr_el[4]; /* SMCR_EL[1-3] */ | ||
27 | } vfp; | ||
28 | uint64_t exclusive_addr; | ||
29 | uint64_t exclusive_val; | ||
30 | @@ -XXX,XX +XXX,XX @@ FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
31 | FIELD(SVCR, SM, 0, 1) | ||
32 | FIELD(SVCR, ZA, 1, 1) | ||
33 | |||
34 | +/* Fields for SMCR_ELx. */ | ||
35 | +FIELD(SMCR, LEN, 0, 4) | ||
36 | +FIELD(SMCR, FA64, 31, 1) | ||
37 | + | ||
38 | /* Write a new value to v7m.exception, thus transitioning into or out | ||
39 | * of Handler mode; this may result in a change of active stack pointer. | ||
40 | */ | ||
41 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/helper.c | ||
44 | +++ b/target/arm/helper.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
46 | */ | ||
47 | { K(3, 0, 1, 2, 0), K(3, 4, 1, 2, 0), K(3, 5, 1, 2, 0), | ||
48 | "ZCR_EL1", "ZCR_EL2", "ZCR_EL12", isar_feature_aa64_sve }, | ||
49 | + { K(3, 0, 1, 2, 6), K(3, 4, 1, 2, 6), K(3, 5, 1, 2, 6), | ||
50 | + "SMCR_EL1", "SMCR_EL2", "SMCR_EL12", isar_feature_aa64_sme }, | ||
51 | |||
52 | { K(3, 0, 5, 6, 0), K(3, 4, 5, 6, 0), K(3, 5, 5, 6, 0), | ||
53 | "TFSR_EL1", "TFSR_EL2", "TFSR_EL12", isar_feature_aa64_mte }, | ||
54 | @@ -XXX,XX +XXX,XX @@ static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
55 | env->svcr = value; | ||
56 | } | ||
57 | |||
58 | +static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
59 | + uint64_t value) | ||
60 | +{ | ||
61 | + int cur_el = arm_current_el(env); | ||
62 | + int old_len = sve_vqm1_for_el(env, cur_el); | ||
63 | + int new_len; | ||
64 | + | ||
65 | + QEMU_BUILD_BUG_ON(ARM_MAX_VQ > R_SMCR_LEN_MASK + 1); | ||
66 | + value &= R_SMCR_LEN_MASK | R_SMCR_FA64_MASK; | ||
67 | + raw_write(env, ri, value); | ||
68 | + | ||
69 | + /* | ||
70 | + * Note that it is CONSTRAINED UNPREDICTABLE what happens to ZA storage | ||
71 | + * when SVL is widened (old values kept, or zeros). Choose to keep the | ||
72 | + * current values for simplicity. But for QEMU internals, we must still | ||
73 | + * apply the narrower SVL to the Zregs and Pregs -- see the comment | ||
74 | + * above aarch64_sve_narrow_vq. | ||
75 | + */ | ||
76 | + new_len = sve_vqm1_for_el(env, cur_el); | ||
77 | + if (new_len < old_len) { | ||
78 | + aarch64_sve_narrow_vq(env, new_len + 1); | ||
79 | + } | ||
80 | +} | ||
81 | + | ||
82 | static const ARMCPRegInfo sme_reginfo[] = { | ||
83 | { .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64, | ||
84 | .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5, | ||
85 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo sme_reginfo[] = { | ||
86 | .access = PL0_RW, .type = ARM_CP_SME, | ||
87 | .fieldoffset = offsetof(CPUARMState, svcr), | ||
88 | .writefn = svcr_write, .raw_writefn = raw_write }, | ||
89 | + { .name = "SMCR_EL1", .state = ARM_CP_STATE_AA64, | ||
90 | + .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 6, | ||
91 | + .access = PL1_RW, .type = ARM_CP_SME, | ||
92 | + .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[1]), | ||
93 | + .writefn = smcr_write, .raw_writefn = raw_write }, | ||
94 | + { .name = "SMCR_EL2", .state = ARM_CP_STATE_AA64, | ||
95 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 6, | ||
96 | + .access = PL2_RW, .type = ARM_CP_SME, | ||
97 | + .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[2]), | ||
98 | + .writefn = smcr_write, .raw_writefn = raw_write }, | ||
99 | + { .name = "SMCR_EL3", .state = ARM_CP_STATE_AA64, | ||
100 | + .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 6, | ||
101 | + .access = PL3_RW, .type = ARM_CP_SME, | ||
102 | + .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[3]), | ||
103 | + .writefn = smcr_write, .raw_writefn = raw_write }, | ||
104 | }; | ||
105 | #endif /* TARGET_AARCH64 */ | ||
106 | |||
107 | -- | ||
108 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Implement the streaming mode identification register, and the | ||
4 | two streaming priority registers. For QEMU, they are all RES0. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-8-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.c | 33 +++++++++++++++++++++++++++++++++ | ||
12 | 1 file changed, 33 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper.c | ||
17 | +++ b/target/arm/helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpidr2(CPUARMState *env, const ARMCPRegInfo *ri, | ||
19 | return CP_ACCESS_OK; | ||
20 | } | ||
21 | |||
22 | +static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri, | ||
23 | + bool isread) | ||
24 | +{ | ||
25 | + /* TODO: FEAT_FGT for SMPRI_EL1 but not SMPRIMAP_EL2 */ | ||
26 | + if (arm_current_el(env) < 3 | ||
27 | + && arm_feature(env, ARM_FEATURE_EL3) | ||
28 | + && !FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, ESM)) { | ||
29 | + return CP_ACCESS_TRAP_EL3; | ||
30 | + } | ||
31 | + return CP_ACCESS_OK; | ||
32 | +} | ||
33 | + | ||
34 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
35 | uint64_t value) | ||
36 | { | ||
37 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo sme_reginfo[] = { | ||
38 | .access = PL3_RW, .type = ARM_CP_SME, | ||
39 | .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[3]), | ||
40 | .writefn = smcr_write, .raw_writefn = raw_write }, | ||
41 | + { .name = "SMIDR_EL1", .state = ARM_CP_STATE_AA64, | ||
42 | + .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 6, | ||
43 | + .access = PL1_R, .accessfn = access_aa64_tid1, | ||
44 | + /* | ||
45 | + * IMPLEMENTOR = 0 (software) | ||
46 | + * REVISION = 0 (implementation defined) | ||
47 | + * SMPS = 0 (no streaming execution priority in QEMU) | ||
48 | + * AFFINITY = 0 (streaming sve mode not shared with other PEs) | ||
49 | + */ | ||
50 | + .type = ARM_CP_CONST, .resetvalue = 0, }, | ||
51 | + /* | ||
52 | + * Because SMIDR_EL1.SMPS is 0, SMPRI_EL1 and SMPRIMAP_EL2 are RES 0. | ||
53 | + */ | ||
54 | + { .name = "SMPRI_EL1", .state = ARM_CP_STATE_AA64, | ||
55 | + .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 4, | ||
56 | + .access = PL1_RW, .accessfn = access_esm, | ||
57 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
58 | + { .name = "SMPRIMAP_EL2", .state = ARM_CP_STATE_AA64, | ||
59 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 5, | ||
60 | + .access = PL2_RW, .accessfn = access_esm, | ||
61 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
62 | }; | ||
63 | #endif /* TARGET_AARCH64 */ | ||
64 | |||
65 | -- | ||
66 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | These are required to determine if various insns | ||
4 | are allowed to issue. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-9-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 2 ++ | ||
12 | target/arm/translate.h | 4 ++++ | ||
13 | target/arm/helper.c | 4 ++++ | ||
14 | target/arm/translate-a64.c | 2 ++ | ||
15 | 4 files changed, 12 insertions(+) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, TCMA, 16, 2) | ||
22 | FIELD(TBFLAG_A64, MTE_ACTIVE, 18, 1) | ||
23 | FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
24 | FIELD(TBFLAG_A64, SMEEXC_EL, 20, 2) | ||
25 | +FIELD(TBFLAG_A64, PSTATE_SM, 22, 1) | ||
26 | +FIELD(TBFLAG_A64, PSTATE_ZA, 23, 1) | ||
27 | |||
28 | /* | ||
29 | * Helpers for using the above. | ||
30 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate.h | ||
33 | +++ b/target/arm/translate.h | ||
34 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
35 | bool align_mem; | ||
36 | /* True if PSTATE.IL is set */ | ||
37 | bool pstate_il; | ||
38 | + /* True if PSTATE.SM is set. */ | ||
39 | + bool pstate_sm; | ||
40 | + /* True if PSTATE.ZA is set. */ | ||
41 | + bool pstate_za; | ||
42 | /* True if MVE insns are definitely not predicated by VPR or LTPSIZE */ | ||
43 | bool mve_no_pred; | ||
44 | /* | ||
45 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/helper.c | ||
48 | +++ b/target/arm/helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
50 | } | ||
51 | if (cpu_isar_feature(aa64_sme, env_archcpu(env))) { | ||
52 | DP_TBFLAG_A64(flags, SMEEXC_EL, sme_exception_el(env, el)); | ||
53 | + if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
54 | + DP_TBFLAG_A64(flags, PSTATE_SM, 1); | ||
55 | + } | ||
56 | + DP_TBFLAG_A64(flags, PSTATE_ZA, FIELD_EX64(env->svcr, SVCR, ZA)); | ||
57 | } | ||
58 | |||
59 | sctlr = regime_sctlr(env, stage1); | ||
60 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/translate-a64.c | ||
63 | +++ b/target/arm/translate-a64.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
65 | dc->ata = EX_TBFLAG_A64(tb_flags, ATA); | ||
66 | dc->mte_active[0] = EX_TBFLAG_A64(tb_flags, MTE_ACTIVE); | ||
67 | dc->mte_active[1] = EX_TBFLAG_A64(tb_flags, MTE0_ACTIVE); | ||
68 | + dc->pstate_sm = EX_TBFLAG_A64(tb_flags, PSTATE_SM); | ||
69 | + dc->pstate_za = EX_TBFLAG_A64(tb_flags, PSTATE_ZA); | ||
70 | dc->vec_len = 0; | ||
71 | dc->vec_stride = 0; | ||
72 | dc->cp_regs = arm_cpu->cp_regs; | ||
73 | -- | ||
74 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Place this late in the resettable section of the structure, | ||
4 | to keep the most common element offsets from being > 64k. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-10-richard.henderson@linaro.org | ||
9 | [PMM: expanded comment on zarray[] format] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 22 ++++++++++++++++++++++ | ||
13 | target/arm/machine.c | 34 ++++++++++++++++++++++++++++++++++ | ||
14 | 2 files changed, 56 insertions(+) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
21 | } keys; | ||
22 | |||
23 | uint64_t scxtnum_el[4]; | ||
24 | + | ||
25 | + /* | ||
26 | + * SME ZA storage -- 256 x 256 byte array, with bytes in host word order, | ||
27 | + * as we do with vfp.zregs[]. This corresponds to the architectural ZA | ||
28 | + * array, where ZA[N] is in the least-significant bytes of env->zarray[N]. | ||
29 | + * When SVL is less than the architectural maximum, the accessible | ||
30 | + * storage is restricted, such that if the SVL is X bytes the guest can | ||
31 | + * see only the bottom X elements of zarray[], and only the least | ||
32 | + * significant X bytes of each element of the array. (In other words, | ||
33 | + * the observable part is always square.) | ||
34 | + * | ||
35 | + * The ZA storage can also be considered as a set of square tiles of | ||
36 | + * elements of different sizes. The mapping from tiles to the ZA array | ||
37 | + * is architecturally defined, such that for tiles of elements of esz | ||
38 | + * bytes, the Nth row (or "horizontal slice") of tile T is in | ||
39 | + * ZA[T + N * esz]. Note that this means that each tile is not contiguous | ||
40 | + * in the ZA storage, because its rows are striped through the ZA array. | ||
41 | + * | ||
42 | + * Because this is so large, keep this toward the end of the reset area, | ||
43 | + * to keep the offsets into the rest of the structure smaller. | ||
44 | + */ | ||
45 | + ARMVectorReg zarray[ARM_MAX_VQ * 16]; | ||
46 | #endif | ||
47 | |||
48 | #if defined(CONFIG_USER_ONLY) | ||
49 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/machine.c | ||
52 | +++ b/target/arm/machine.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_sve = { | ||
54 | VMSTATE_END_OF_LIST() | ||
55 | } | ||
56 | }; | ||
57 | + | ||
58 | +static const VMStateDescription vmstate_vreg = { | ||
59 | + .name = "vreg", | ||
60 | + .version_id = 1, | ||
61 | + .minimum_version_id = 1, | ||
62 | + .fields = (VMStateField[]) { | ||
63 | + VMSTATE_UINT64_ARRAY(d, ARMVectorReg, ARM_MAX_VQ * 2), | ||
64 | + VMSTATE_END_OF_LIST() | ||
65 | + } | ||
66 | +}; | ||
67 | + | ||
68 | +static bool za_needed(void *opaque) | ||
69 | +{ | ||
70 | + ARMCPU *cpu = opaque; | ||
71 | + | ||
72 | + /* | ||
73 | + * When ZA storage is disabled, its contents are discarded. | ||
74 | + * It will be zeroed when ZA storage is re-enabled. | ||
75 | + */ | ||
76 | + return FIELD_EX64(cpu->env.svcr, SVCR, ZA); | ||
77 | +} | ||
78 | + | ||
79 | +static const VMStateDescription vmstate_za = { | ||
80 | + .name = "cpu/sme", | ||
81 | + .version_id = 1, | ||
82 | + .minimum_version_id = 1, | ||
83 | + .needed = za_needed, | ||
84 | + .fields = (VMStateField[]) { | ||
85 | + VMSTATE_STRUCT_ARRAY(env.zarray, ARMCPU, ARM_MAX_VQ * 16, 0, | ||
86 | + vmstate_vreg, ARMVectorReg), | ||
87 | + VMSTATE_END_OF_LIST() | ||
88 | + } | ||
89 | +}; | ||
90 | #endif /* AARCH64 */ | ||
91 | |||
92 | static bool serror_needed(void *opaque) | ||
93 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = { | ||
94 | &vmstate_m_security, | ||
95 | #ifdef TARGET_AARCH64 | ||
96 | &vmstate_sve, | ||
97 | + &vmstate_za, | ||
98 | #endif | ||
99 | &vmstate_serror, | ||
100 | &vmstate_irq_line_state, | ||
101 | -- | ||
102 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | These two instructions are aliases of MSR (immediate). | ||
4 | Use the two helpers to properly implement svcr_write. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-11-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 1 + | ||
12 | target/arm/helper-sme.h | 21 +++++++++++++ | ||
13 | target/arm/helper.h | 1 + | ||
14 | target/arm/helper.c | 6 ++-- | ||
15 | target/arm/sme_helper.c | 61 ++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-a64.c | 24 +++++++++++++++ | ||
17 | target/arm/meson.build | 1 + | ||
18 | 7 files changed, 112 insertions(+), 3 deletions(-) | ||
19 | create mode 100644 target/arm/helper-sme.h | ||
20 | create mode 100644 target/arm/sme_helper.c | ||
21 | |||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/cpu.h | ||
25 | +++ b/target/arm/cpu.h | ||
26 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, | ||
27 | int new_el, bool el0_a64); | ||
28 | void aarch64_add_sve_properties(Object *obj); | ||
29 | void aarch64_add_pauth_properties(Object *obj); | ||
30 | +void arm_reset_sve_state(CPUARMState *env); | ||
31 | |||
32 | /* | ||
33 | * SVE registers are encoded in KVM's memory in an endianness-invariant format. | ||
34 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h | ||
35 | new file mode 100644 | ||
36 | index XXXXXXX..XXXXXXX | ||
37 | --- /dev/null | ||
38 | +++ b/target/arm/helper-sme.h | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | +/* | ||
41 | + * AArch64 SME specific helper definitions | ||
42 | + * | ||
43 | + * Copyright (c) 2022 Linaro, Ltd | ||
44 | + * | ||
45 | + * This library is free software; you can redistribute it and/or | ||
46 | + * modify it under the terms of the GNU Lesser General Public | ||
47 | + * License as published by the Free Software Foundation; either | ||
48 | + * version 2.1 of the License, or (at your option) any later version. | ||
49 | + * | ||
50 | + * This library is distributed in the hope that it will be useful, | ||
51 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
52 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
53 | + * Lesser General Public License for more details. | ||
54 | + * | ||
55 | + * You should have received a copy of the GNU Lesser General Public | ||
56 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
57 | + */ | ||
58 | + | ||
59 | +DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32) | ||
60 | +DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32) | ||
61 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/helper.h | ||
64 | +++ b/target/arm/helper.h | ||
65 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_6(gvec_bfmlal_idx, TCG_CALL_NO_RWG, | ||
66 | #ifdef TARGET_AARCH64 | ||
67 | #include "helper-a64.h" | ||
68 | #include "helper-sve.h" | ||
69 | +#include "helper-sme.h" | ||
70 | #endif | ||
71 | |||
72 | #include "helper-mve.h" | ||
73 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/helper.c | ||
76 | +++ b/target/arm/helper.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri, | ||
78 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
79 | uint64_t value) | ||
80 | { | ||
81 | - value &= R_SVCR_SM_MASK | R_SVCR_ZA_MASK; | ||
82 | - /* TODO: Side effects. */ | ||
83 | - env->svcr = value; | ||
84 | + helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM)); | ||
85 | + helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA)); | ||
86 | + arm_rebuild_hflags(env); | ||
87 | } | ||
88 | |||
89 | static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
90 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
91 | new file mode 100644 | ||
92 | index XXXXXXX..XXXXXXX | ||
93 | --- /dev/null | ||
94 | +++ b/target/arm/sme_helper.c | ||
95 | @@ -XXX,XX +XXX,XX @@ | ||
96 | +/* | ||
97 | + * ARM SME Operations | ||
98 | + * | ||
99 | + * Copyright (c) 2022 Linaro, Ltd. | ||
100 | + * | ||
101 | + * This library is free software; you can redistribute it and/or | ||
102 | + * modify it under the terms of the GNU Lesser General Public | ||
103 | + * License as published by the Free Software Foundation; either | ||
104 | + * version 2.1 of the License, or (at your option) any later version. | ||
105 | + * | ||
106 | + * This library is distributed in the hope that it will be useful, | ||
107 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
108 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
109 | + * Lesser General Public License for more details. | ||
110 | + * | ||
111 | + * You should have received a copy of the GNU Lesser General Public | ||
112 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
113 | + */ | ||
114 | + | ||
115 | +#include "qemu/osdep.h" | ||
116 | +#include "cpu.h" | ||
117 | +#include "internals.h" | ||
118 | +#include "exec/helper-proto.h" | ||
119 | + | ||
120 | +/* ResetSVEState */ | ||
121 | +void arm_reset_sve_state(CPUARMState *env) | ||
122 | +{ | ||
123 | + memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs)); | ||
124 | + /* Recall that FFR is stored as pregs[16]. */ | ||
125 | + memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs)); | ||
126 | + vfp_set_fpcr(env, 0x0800009f); | ||
127 | +} | ||
128 | + | ||
129 | +void helper_set_pstate_sm(CPUARMState *env, uint32_t i) | ||
130 | +{ | ||
131 | + if (i == FIELD_EX64(env->svcr, SVCR, SM)) { | ||
132 | + return; | ||
133 | + } | ||
134 | + env->svcr ^= R_SVCR_SM_MASK; | ||
135 | + arm_reset_sve_state(env); | ||
136 | +} | ||
137 | + | ||
138 | +void helper_set_pstate_za(CPUARMState *env, uint32_t i) | ||
139 | +{ | ||
140 | + if (i == FIELD_EX64(env->svcr, SVCR, ZA)) { | ||
141 | + return; | ||
142 | + } | ||
143 | + env->svcr ^= R_SVCR_ZA_MASK; | ||
144 | + | ||
145 | + /* | ||
146 | + * ResetSMEState. | ||
147 | + * | ||
148 | + * SetPSTATE_ZA zeros on enable and disable. We can zero this only | ||
149 | + * on enable: while disabled, the storage is inaccessible and the | ||
150 | + * value does not matter. We're not saving the storage in vmstate | ||
151 | + * when disabled either. | ||
152 | + */ | ||
153 | + if (i) { | ||
154 | + memset(env->zarray, 0, sizeof(env->zarray)); | ||
155 | + } | ||
156 | +} | ||
157 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/target/arm/translate-a64.c | ||
160 | +++ b/target/arm/translate-a64.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
162 | } | ||
163 | break; | ||
164 | |||
165 | + case 0x1b: /* SVCR* */ | ||
166 | + if (!dc_isar_feature(aa64_sme, s) || crm < 2 || crm > 7) { | ||
167 | + goto do_unallocated; | ||
168 | + } | ||
169 | + if (sme_access_check(s)) { | ||
170 | + bool i = crm & 1; | ||
171 | + bool changed = false; | ||
172 | + | ||
173 | + if ((crm & 2) && i != s->pstate_sm) { | ||
174 | + gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); | ||
175 | + changed = true; | ||
176 | + } | ||
177 | + if ((crm & 4) && i != s->pstate_za) { | ||
178 | + gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); | ||
179 | + changed = true; | ||
180 | + } | ||
181 | + if (changed) { | ||
182 | + gen_rebuild_hflags(s); | ||
183 | + } else { | ||
184 | + s->base.is_jmp = DISAS_NEXT; | ||
185 | + } | ||
186 | + } | ||
187 | + break; | ||
188 | + | ||
189 | default: | ||
190 | do_unallocated: | ||
191 | unallocated_encoding(s); | ||
192 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/target/arm/meson.build | ||
195 | +++ b/target/arm/meson.build | ||
196 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( | ||
197 | 'mte_helper.c', | ||
198 | 'pauth_helper.c', | ||
199 | 'sve_helper.c', | ||
200 | + 'sme_helper.c', | ||
201 | 'translate-a64.c', | ||
202 | 'translate-sve.c', | ||
203 | )) | ||
204 | -- | ||
205 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Keep all of the error messages together. This does mean that | ||
4 | when setting many sve length properties we'll only generate | ||
5 | one error, but we only really need one. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220620175235.60881-12-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu64.c | 15 +++++++-------- | ||
13 | 1 file changed, 7 insertions(+), 8 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu64.c | ||
18 | +++ b/target/arm/cpu64.c | ||
19 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
20 | "using only sve<N> properties.\n"); | ||
21 | } else { | ||
22 | error_setg(errp, "cannot enable sve%d", vq * 128); | ||
23 | - error_append_hint(errp, "This CPU does not support " | ||
24 | - "the vector length %d-bits.\n", vq * 128); | ||
25 | + if (vq_supported) { | ||
26 | + error_append_hint(errp, "This CPU does not support " | ||
27 | + "the vector length %d-bits.\n", vq * 128); | ||
28 | + } else { | ||
29 | + error_append_hint(errp, "SVE not supported by KVM " | ||
30 | + "on this host\n"); | ||
31 | + } | ||
32 | } | ||
33 | return; | ||
34 | } else { | ||
35 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
36 | return; | ||
37 | } | ||
38 | |||
39 | - if (value && kvm_enabled() && !kvm_arm_sve_supported()) { | ||
40 | - error_setg(errp, "cannot enable %s", name); | ||
41 | - error_append_hint(errp, "SVE not supported by KVM on this host\n"); | ||
42 | - return; | ||
43 | - } | ||
44 | - | ||
45 | cpu->sve_vq_map = deposit32(cpu->sve_vq_map, vq - 1, 1, value); | ||
46 | cpu->sve_vq_init |= 1 << (vq - 1); | ||
47 | } | ||
48 | -- | ||
49 | 2.25.1 | diff view generated by jsdifflib |
1 | This reverts commit f7fb73b8cdd3f77e26f9fcff8cf24ff1b58d200f. | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This change turned out to be a bit half-baked, and doesn't | 3 | Pull the three sve_vq_* values into a structure. |
4 | work with KVM, which fails with the error: | 4 | This will be reused for SME. |
5 | "qemu-system-aarch64: Failed to retrieve host CPU features" | ||
6 | 5 | ||
7 | because KVM does not allow accessing of the PMCR_EL0 value in | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | the scratch "query CPU ID registers" VM unless we have first | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | set the KVM_ARM_VCPU_PMU_V3 feature on the VM. | 8 | Message-id: 20220620175235.60881-13-richard.henderson@linaro.org |
10 | |||
11 | Revert the change for 6.0. | ||
12 | |||
13 | Reported-by: Zenghui Yu <yuzenghui@huawei.com> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Tested-by: Zenghui Yu <yuzenghui@huawei.com> | ||
16 | Message-id: 20210331154822.23332-1-peter.maydell@linaro.org | ||
17 | --- | 10 | --- |
18 | target/arm/cpu.h | 1 - | 11 | target/arm/cpu.h | 29 ++++++++++++++--------------- |
19 | target/arm/cpu64.c | 3 --- | 12 | target/arm/cpu64.c | 22 +++++++++++----------- |
20 | target/arm/cpu_tcg.c | 5 ----- | 13 | target/arm/helper.c | 2 +- |
21 | target/arm/helper.c | 29 ++++++++++++----------------- | 14 | target/arm/kvm64.c | 2 +- |
22 | target/arm/kvm64.c | 2 -- | 15 | 4 files changed, 27 insertions(+), 28 deletions(-) |
23 | 5 files changed, 12 insertions(+), 28 deletions(-) | ||
24 | 16 | ||
25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
26 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/cpu.h | 19 | --- a/target/arm/cpu.h |
28 | +++ b/target/arm/cpu.h | 20 | +++ b/target/arm/cpu.h |
29 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 21 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMPSCIState { |
30 | uint64_t id_aa64mmfr2; | 22 | |
31 | uint64_t id_aa64dfr0; | 23 | typedef struct ARMISARegisters ARMISARegisters; |
32 | uint64_t id_aa64dfr1; | 24 | |
33 | - uint64_t reset_pmcr_el0; | 25 | +/* |
34 | } isar; | 26 | + * In map, each set bit is a supported vector length of (bit-number + 1) * 16 |
35 | uint64_t midr; | 27 | + * bytes, i.e. each bit number + 1 is the vector length in quadwords. |
36 | uint32_t revidr; | 28 | + * |
29 | + * While processing properties during initialization, corresponding init bits | ||
30 | + * are set for bits in sve_vq_map that have been set by properties. | ||
31 | + * | ||
32 | + * Bits set in supported represent valid vector lengths for the CPU type. | ||
33 | + */ | ||
34 | +typedef struct { | ||
35 | + uint32_t map, init, supported; | ||
36 | +} ARMVQMap; | ||
37 | + | ||
38 | /** | ||
39 | * ARMCPU: | ||
40 | * @env: #CPUARMState | ||
41 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
42 | uint32_t sve_default_vq; | ||
43 | #endif | ||
44 | |||
45 | - /* | ||
46 | - * In sve_vq_map each set bit is a supported vector length of | ||
47 | - * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector | ||
48 | - * length in quadwords. | ||
49 | - * | ||
50 | - * While processing properties during initialization, corresponding | ||
51 | - * sve_vq_init bits are set for bits in sve_vq_map that have been | ||
52 | - * set by properties. | ||
53 | - * | ||
54 | - * Bits set in sve_vq_supported represent valid vector lengths for | ||
55 | - * the CPU type. | ||
56 | - */ | ||
57 | - uint32_t sve_vq_map; | ||
58 | - uint32_t sve_vq_init; | ||
59 | - uint32_t sve_vq_supported; | ||
60 | + ARMVQMap sve_vq; | ||
61 | |||
62 | /* Generic timer counter frequency, in Hz */ | ||
63 | uint64_t gt_cntfrq_hz; | ||
37 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 64 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
38 | index XXXXXXX..XXXXXXX 100644 | 65 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/cpu64.c | 66 | --- a/target/arm/cpu64.c |
40 | +++ b/target/arm/cpu64.c | 67 | +++ b/target/arm/cpu64.c |
41 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj) | 68 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) |
42 | cpu->gic_num_lrs = 4; | 69 | * any of the above. Finally, if SVE is not disabled, then at least one |
43 | cpu->gic_vpribits = 5; | 70 | * vector length must be enabled. |
44 | cpu->gic_vprebits = 5; | 71 | */ |
45 | - cpu->isar.reset_pmcr_el0 = 0x41013000; | 72 | - uint32_t vq_map = cpu->sve_vq_map; |
46 | define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | 73 | - uint32_t vq_init = cpu->sve_vq_init; |
74 | + uint32_t vq_map = cpu->sve_vq.map; | ||
75 | + uint32_t vq_init = cpu->sve_vq.init; | ||
76 | uint32_t vq_supported; | ||
77 | uint32_t vq_mask = 0; | ||
78 | uint32_t tmp, vq, max_vq = 0; | ||
79 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
80 | */ | ||
81 | if (kvm_enabled()) { | ||
82 | if (kvm_arm_sve_supported()) { | ||
83 | - cpu->sve_vq_supported = kvm_arm_sve_get_vls(CPU(cpu)); | ||
84 | - vq_supported = cpu->sve_vq_supported; | ||
85 | + cpu->sve_vq.supported = kvm_arm_sve_get_vls(CPU(cpu)); | ||
86 | + vq_supported = cpu->sve_vq.supported; | ||
87 | } else { | ||
88 | assert(!cpu_isar_feature(aa64_sve, cpu)); | ||
89 | vq_supported = 0; | ||
90 | } | ||
91 | } else { | ||
92 | - vq_supported = cpu->sve_vq_supported; | ||
93 | + vq_supported = cpu->sve_vq.supported; | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
98 | |||
99 | /* From now on sve_max_vq is the actual maximum supported length. */ | ||
100 | cpu->sve_max_vq = max_vq; | ||
101 | - cpu->sve_vq_map = vq_map; | ||
102 | + cpu->sve_vq.map = vq_map; | ||
47 | } | 103 | } |
48 | 104 | ||
49 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | 105 | static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name, |
50 | cpu->gic_num_lrs = 4; | 106 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, |
51 | cpu->gic_vpribits = 5; | 107 | if (!cpu_isar_feature(aa64_sve, cpu)) { |
52 | cpu->gic_vprebits = 5; | 108 | value = false; |
53 | - cpu->isar.reset_pmcr_el0 = 0x41033000; | 109 | } else { |
54 | define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | 110 | - value = extract32(cpu->sve_vq_map, vq - 1, 1); |
111 | + value = extract32(cpu->sve_vq.map, vq - 1, 1); | ||
112 | } | ||
113 | visit_type_bool(v, name, &value, errp); | ||
55 | } | 114 | } |
56 | 115 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | |
57 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj) | 116 | return; |
58 | cpu->gic_num_lrs = 4; | 117 | } |
59 | cpu->gic_vpribits = 5; | 118 | |
60 | cpu->gic_vprebits = 5; | 119 | - cpu->sve_vq_map = deposit32(cpu->sve_vq_map, vq - 1, 1, value); |
61 | - cpu->isar.reset_pmcr_el0 = 0x41023000; | 120 | - cpu->sve_vq_init |= 1 << (vq - 1); |
62 | define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); | 121 | + cpu->sve_vq.map = deposit32(cpu->sve_vq.map, vq - 1, 1, value); |
122 | + cpu->sve_vq.init |= 1 << (vq - 1); | ||
63 | } | 123 | } |
64 | 124 | ||
65 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 125 | static bool cpu_arm_get_sve(Object *obj, Error **errp) |
66 | index XXXXXXX..XXXXXXX 100644 | 126 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) |
67 | --- a/target/arm/cpu_tcg.c | 127 | cpu->dcz_blocksize = 7; /* 512 bytes */ |
68 | +++ b/target/arm/cpu_tcg.c | 128 | #endif |
69 | @@ -XXX,XX +XXX,XX @@ static void cortex_a8_initfn(Object *obj) | 129 | |
70 | cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */ | 130 | - cpu->sve_vq_supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); |
71 | cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */ | 131 | + cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); |
72 | cpu->reset_auxcr = 2; | 132 | |
73 | - cpu->isar.reset_pmcr_el0 = 0x41002000; | 133 | aarch64_add_pauth_properties(obj); |
74 | define_arm_cp_regs(cpu, cortexa8_cp_reginfo); | 134 | aarch64_add_sve_properties(obj); |
75 | } | 135 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) |
76 | 136 | ||
77 | @@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj) | 137 | /* The A64FX supports only 128, 256 and 512 bit vector lengths */ |
78 | cpu->clidr = (1 << 27) | (1 << 24) | 3; | 138 | aarch64_add_sve_properties(obj); |
79 | cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */ | 139 | - cpu->sve_vq_supported = (1 << 0) /* 128bit */ |
80 | cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */ | 140 | + cpu->sve_vq.supported = (1 << 0) /* 128bit */ |
81 | - cpu->isar.reset_pmcr_el0 = 0x41093000; | 141 | | (1 << 1) /* 256bit */ |
82 | define_arm_cp_regs(cpu, cortexa9_cp_reginfo); | 142 | | (1 << 3); /* 512bit */ |
83 | } | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | ||
86 | cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ | ||
87 | cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ | ||
88 | cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ | ||
89 | - cpu->isar.reset_pmcr_el0 = 0x41072000; | ||
90 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */ | ||
91 | } | ||
92 | |||
93 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
94 | cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ | ||
95 | cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ | ||
96 | cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ | ||
97 | - cpu->isar.reset_pmcr_el0 = 0x410F3000; | ||
98 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); | ||
99 | } | ||
100 | |||
101 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | ||
102 | cpu->isar.id_isar6 = 0x0; | ||
103 | cpu->mp_is_up = true; | ||
104 | cpu->pmsav7_dregion = 16; | ||
105 | - cpu->isar.reset_pmcr_el0 = 0x41151800; | ||
106 | define_arm_cp_regs(cpu, cortexr5_cp_reginfo); | ||
107 | } | ||
108 | 143 | ||
109 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 144 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
110 | index XXXXXXX..XXXXXXX 100644 | 145 | index XXXXXXX..XXXXXXX 100644 |
111 | --- a/target/arm/helper.c | 146 | --- a/target/arm/helper.c |
112 | +++ b/target/arm/helper.c | 147 | +++ b/target/arm/helper.c |
113 | @@ -XXX,XX +XXX,XX @@ | 148 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_vqm1_for_el(CPUARMState *env, int el) |
114 | #endif | 149 | len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); |
115 | 150 | } | |
116 | #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ | 151 | |
117 | +#define PMCR_NUM_COUNTERS 4 /* QEMU IMPDEF choice */ | 152 | - len = 31 - clz32(cpu->sve_vq_map & MAKE_64BIT_MASK(0, len + 1)); |
118 | 153 | + len = 31 - clz32(cpu->sve_vq.map & MAKE_64BIT_MASK(0, len + 1)); | |
119 | #ifndef CONFIG_USER_ONLY | 154 | return len; |
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
122 | |||
123 | static inline uint32_t pmu_num_counters(CPUARMState *env) | ||
124 | { | ||
125 | - ARMCPU *cpu = env_archcpu(env); | ||
126 | - | ||
127 | - return (cpu->isar.reset_pmcr_el0 & PMCRN_MASK) >> PMCRN_SHIFT; | ||
128 | + return (env->cp15.c9_pmcr & PMCRN_MASK) >> PMCRN_SHIFT; | ||
129 | } | 155 | } |
130 | 156 | ||
131 | /* Bits allowed to be set/cleared for PMCNTEN* and PMINTEN* */ | ||
132 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
133 | .resetvalue = 0, | ||
134 | .writefn = gt_hyp_ctl_write, .raw_writefn = raw_write }, | ||
135 | #endif | ||
136 | + /* The only field of MDCR_EL2 that has a defined architectural reset value | ||
137 | + * is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N. | ||
138 | + */ | ||
139 | + { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
140 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1, | ||
141 | + .access = PL2_RW, .resetvalue = PMCR_NUM_COUNTERS, | ||
142 | + .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2), }, | ||
143 | { .name = "HPFAR", .state = ARM_CP_STATE_AA32, | ||
144 | .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4, | ||
145 | .access = PL2_RW, .accessfn = access_el3_aa32ns, | ||
146 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
147 | * field as main ID register, and we implement four counters in | ||
148 | * addition to the cycle count register. | ||
149 | */ | ||
150 | - unsigned int i, pmcrn = pmu_num_counters(&cpu->env); | ||
151 | + unsigned int i, pmcrn = PMCR_NUM_COUNTERS; | ||
152 | ARMCPRegInfo pmcr = { | ||
153 | .name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0, | ||
154 | .access = PL0_RW, | ||
155 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) | ||
156 | .access = PL0_RW, .accessfn = pmreg_access, | ||
157 | .type = ARM_CP_IO, | ||
158 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr), | ||
159 | - .resetvalue = cpu->isar.reset_pmcr_el0, | ||
160 | + .resetvalue = (cpu->midr & 0xff000000) | (pmcrn << PMCRN_SHIFT) | | ||
161 | + PMCRLC, | ||
162 | .writefn = pmcr_write, .raw_writefn = raw_write, | ||
163 | }; | ||
164 | - | ||
165 | define_one_arm_cp_reg(cpu, &pmcr); | ||
166 | define_one_arm_cp_reg(cpu, &pmcr64); | ||
167 | for (i = 0; i < pmcrn; i++) { | ||
168 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
169 | .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, | ||
170 | REGINFO_SENTINEL | ||
171 | }; | ||
172 | - /* | ||
173 | - * The only field of MDCR_EL2 that has a defined architectural reset | ||
174 | - * value is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N. | ||
175 | - */ | ||
176 | - ARMCPRegInfo mdcr_el2 = { | ||
177 | - .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH, | ||
178 | - .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1, | ||
179 | - .access = PL2_RW, .resetvalue = pmu_num_counters(env), | ||
180 | - .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2), | ||
181 | - }; | ||
182 | - define_one_arm_cp_reg(cpu, &mdcr_el2); | ||
183 | define_arm_cp_regs(cpu, vpidr_regs); | ||
184 | define_arm_cp_regs(cpu, el2_cp_reginfo); | ||
185 | if (arm_feature(env, ARM_FEATURE_V8)) { | ||
186 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 157 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c |
187 | index XXXXXXX..XXXXXXX 100644 | 158 | index XXXXXXX..XXXXXXX 100644 |
188 | --- a/target/arm/kvm64.c | 159 | --- a/target/arm/kvm64.c |
189 | +++ b/target/arm/kvm64.c | 160 | +++ b/target/arm/kvm64.c |
190 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) | 161 | @@ -XXX,XX +XXX,XX @@ uint32_t kvm_arm_sve_get_vls(CPUState *cs) |
191 | ARM64_SYS_REG(3, 0, 0, 7, 1)); | 162 | static int kvm_arm_sve_set_vls(CPUState *cs) |
192 | err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, | 163 | { |
193 | ARM64_SYS_REG(3, 0, 0, 7, 2)); | 164 | ARMCPU *cpu = ARM_CPU(cs); |
194 | - err |= read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0, | 165 | - uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq_map }; |
195 | - ARM64_SYS_REG(3, 3, 9, 12, 0)); | 166 | + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map }; |
196 | 167 | struct kvm_one_reg reg = { | |
197 | /* | 168 | .id = KVM_REG_ARM64_SVE_VLS, |
198 | * Note that if AArch32 support is not present in the host, | 169 | .addr = (uint64_t)&vls[0], |
199 | -- | 170 | -- |
200 | 2.20.1 | 171 | 2.25.1 |
201 | |||
202 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Rename from cpu_arm_{get,set}_sve_vq, and take the | ||
4 | ARMVQMap as the opaque parameter. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-14-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu64.c | 29 +++++++++++++++-------------- | ||
12 | 1 file changed, 15 insertions(+), 14 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpu64.c | ||
17 | +++ b/target/arm/cpu64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
19 | } | ||
20 | |||
21 | /* | ||
22 | - * Note that cpu_arm_get/set_sve_vq cannot use the simpler | ||
23 | - * object_property_add_bool interface because they make use | ||
24 | - * of the contents of "name" to determine which bit on which | ||
25 | - * to operate. | ||
26 | + * Note that cpu_arm_{get,set}_vq cannot use the simpler | ||
27 | + * object_property_add_bool interface because they make use of the | ||
28 | + * contents of "name" to determine which bit on which to operate. | ||
29 | */ | ||
30 | -static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
31 | - void *opaque, Error **errp) | ||
32 | +static void cpu_arm_get_vq(Object *obj, Visitor *v, const char *name, | ||
33 | + void *opaque, Error **errp) | ||
34 | { | ||
35 | ARMCPU *cpu = ARM_CPU(obj); | ||
36 | + ARMVQMap *vq_map = opaque; | ||
37 | uint32_t vq = atoi(&name[3]) / 128; | ||
38 | bool value; | ||
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
41 | if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
42 | value = false; | ||
43 | } else { | ||
44 | - value = extract32(cpu->sve_vq.map, vq - 1, 1); | ||
45 | + value = extract32(vq_map->map, vq - 1, 1); | ||
46 | } | ||
47 | visit_type_bool(v, name, &value, errp); | ||
48 | } | ||
49 | |||
50 | -static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
51 | - void *opaque, Error **errp) | ||
52 | +static void cpu_arm_set_vq(Object *obj, Visitor *v, const char *name, | ||
53 | + void *opaque, Error **errp) | ||
54 | { | ||
55 | - ARMCPU *cpu = ARM_CPU(obj); | ||
56 | + ARMVQMap *vq_map = opaque; | ||
57 | uint32_t vq = atoi(&name[3]) / 128; | ||
58 | bool value; | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | - cpu->sve_vq.map = deposit32(cpu->sve_vq.map, vq - 1, 1, value); | ||
65 | - cpu->sve_vq.init |= 1 << (vq - 1); | ||
66 | + vq_map->map = deposit32(vq_map->map, vq - 1, 1, value); | ||
67 | + vq_map->init |= 1 << (vq - 1); | ||
68 | } | ||
69 | |||
70 | static bool cpu_arm_get_sve(Object *obj, Error **errp) | ||
71 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, | ||
72 | |||
73 | void aarch64_add_sve_properties(Object *obj) | ||
74 | { | ||
75 | + ARMCPU *cpu = ARM_CPU(obj); | ||
76 | uint32_t vq; | ||
77 | |||
78 | object_property_add_bool(obj, "sve", cpu_arm_get_sve, cpu_arm_set_sve); | ||
79 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) | ||
80 | for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
81 | char name[8]; | ||
82 | sprintf(name, "sve%d", vq * 128); | ||
83 | - object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
84 | - cpu_arm_set_sve_vq, NULL, NULL); | ||
85 | + object_property_add(obj, name, "bool", cpu_arm_get_vq, | ||
86 | + cpu_arm_set_vq, NULL, &cpu->sve_vq); | ||
87 | } | ||
88 | |||
89 | #ifdef CONFIG_USER_ONLY | ||
90 | -- | ||
91 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Rename from cpu_arm_{get,set}_sve_default_vec_len, | ||
4 | and take the pointer to default_vq from opaque. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-15-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu64.c | 27 ++++++++++++++------------- | ||
12 | 1 file changed, 14 insertions(+), 13 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpu64.c | ||
17 | +++ b/target/arm/cpu64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) | ||
19 | |||
20 | #ifdef CONFIG_USER_ONLY | ||
21 | /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
22 | -static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
23 | - const char *name, void *opaque, | ||
24 | - Error **errp) | ||
25 | +static void cpu_arm_set_default_vec_len(Object *obj, Visitor *v, | ||
26 | + const char *name, void *opaque, | ||
27 | + Error **errp) | ||
28 | { | ||
29 | - ARMCPU *cpu = ARM_CPU(obj); | ||
30 | + uint32_t *ptr_default_vq = opaque; | ||
31 | int32_t default_len, default_vq, remainder; | ||
32 | |||
33 | if (!visit_type_int32(v, name, &default_len, errp)) { | ||
34 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
35 | |||
36 | /* Undocumented, but the kernel allows -1 to indicate "maximum". */ | ||
37 | if (default_len == -1) { | ||
38 | - cpu->sve_default_vq = ARM_MAX_VQ; | ||
39 | + *ptr_default_vq = ARM_MAX_VQ; | ||
40 | return; | ||
41 | } | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
44 | return; | ||
45 | } | ||
46 | |||
47 | - cpu->sve_default_vq = default_vq; | ||
48 | + *ptr_default_vq = default_vq; | ||
49 | } | ||
50 | |||
51 | -static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, | ||
52 | - const char *name, void *opaque, | ||
53 | - Error **errp) | ||
54 | +static void cpu_arm_get_default_vec_len(Object *obj, Visitor *v, | ||
55 | + const char *name, void *opaque, | ||
56 | + Error **errp) | ||
57 | { | ||
58 | - ARMCPU *cpu = ARM_CPU(obj); | ||
59 | - int32_t value = cpu->sve_default_vq * 16; | ||
60 | + uint32_t *ptr_default_vq = opaque; | ||
61 | + int32_t value = *ptr_default_vq * 16; | ||
62 | |||
63 | visit_type_int32(v, name, &value, errp); | ||
64 | } | ||
65 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) | ||
66 | #ifdef CONFIG_USER_ONLY | ||
67 | /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
68 | object_property_add(obj, "sve-default-vector-length", "int32", | ||
69 | - cpu_arm_get_sve_default_vec_len, | ||
70 | - cpu_arm_set_sve_default_vec_len, NULL, NULL); | ||
71 | + cpu_arm_get_default_vec_len, | ||
72 | + cpu_arm_set_default_vec_len, NULL, | ||
73 | + &cpu->sve_default_vq); | ||
74 | #endif | ||
75 | } | ||
76 | |||
77 | -- | ||
78 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Drop the aa32-only inline fallbacks, | ||
4 | and just use a couple of ifdefs. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-16-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 6 ------ | ||
12 | target/arm/internals.h | 3 +++ | ||
13 | target/arm/cpu.c | 2 ++ | ||
14 | 3 files changed, 5 insertions(+), 6 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
21 | |||
22 | #ifdef TARGET_AARCH64 | ||
23 | # define ARM_MAX_VQ 16 | ||
24 | -void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | ||
25 | -void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); | ||
26 | -void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); | ||
27 | #else | ||
28 | # define ARM_MAX_VQ 1 | ||
29 | -static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { } | ||
30 | -static inline void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { } | ||
31 | -static inline void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) { } | ||
32 | #endif | ||
33 | |||
34 | typedef struct ARMVectorReg { | ||
35 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/internals.h | ||
38 | +++ b/target/arm/internals.h | ||
39 | @@ -XXX,XX +XXX,XX @@ int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg); | ||
40 | int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg); | ||
41 | int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
42 | int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
43 | +void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | ||
44 | +void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); | ||
45 | +void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); | ||
46 | #endif | ||
47 | |||
48 | #ifdef CONFIG_USER_ONLY | ||
49 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/cpu.c | ||
52 | +++ b/target/arm/cpu.c | ||
53 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | ||
54 | { | ||
55 | Error *local_err = NULL; | ||
56 | |||
57 | +#ifdef TARGET_AARCH64 | ||
58 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
59 | arm_cpu_sve_finalize(cpu, &local_err); | ||
60 | if (local_err != NULL) { | ||
61 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | ||
62 | return; | ||
63 | } | ||
64 | } | ||
65 | +#endif | ||
66 | |||
67 | if (kvm_enabled()) { | ||
68 | kvm_arm_steal_time_finalize(cpu, &local_err); | ||
69 | -- | ||
70 | 2.25.1 | diff view generated by jsdifflib |
1 | The e500plat machine device plug callback currently calls | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | platform_bus_link_device() for any sysbus device. This is overly | ||
3 | broad, because platform_bus_link_device() will unconditionally grab | ||
4 | the IRQs and MMIOs of the device it is passed, whether it was | ||
5 | intended for the platform bus or not. Restrict hotpluggability of | ||
6 | sysbus devices to only those devices on the dynamic sysbus allowlist. | ||
7 | 2 | ||
8 | We were mostly getting away with this because the board creates the | 3 | These functions are not used outside cpu64.c, |
9 | platform bus as the last device it creates, and so the hotplug | 4 | so make them static. |
10 | callback did not do anything for all the sysbus devices created by | ||
11 | the board itself. However if the user plugged in a device which | ||
12 | itself uses a sysbus device internally we would have mishandled this | ||
13 | and probably asserted. An example of this is: | ||
14 | qemu-system-ppc64 -M ppce500 -device macio-oldworld | ||
15 | 5 | ||
16 | This isn't a sensible command because the macio-oldworld device | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
17 | is really specific to the 'g3beige' machine, but we now fail | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
18 | with a reasonable error message rather than asserting: | 8 | Message-id: 20220620175235.60881-17-richard.henderson@linaro.org |
19 | qemu-system-ppc64: Device heathrow is not supported by this machine yet. | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | ||
11 | target/arm/cpu.h | 3 --- | ||
12 | target/arm/cpu64.c | 4 ++-- | ||
13 | 2 files changed, 2 insertions(+), 5 deletions(-) | ||
20 | 14 | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | ||
24 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
25 | Acked-by: David Gibson <david@gibson.dropbear.id.au> | ||
26 | Message-id: 20210325153310.9131-5-peter.maydell@linaro.org | ||
27 | --- | ||
28 | hw/ppc/e500plat.c | 8 ++++++-- | ||
29 | 1 file changed, 6 insertions(+), 2 deletions(-) | ||
30 | |||
31 | diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/hw/ppc/e500plat.c | 17 | --- a/target/arm/cpu.h |
34 | +++ b/hw/ppc/e500plat.c | 18 | +++ b/target/arm/cpu.h |
35 | @@ -XXX,XX +XXX,XX @@ static void e500plat_machine_device_plug_cb(HotplugHandler *hotplug_dev, | 19 | @@ -XXX,XX +XXX,XX @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); |
36 | PPCE500MachineState *pms = PPCE500_MACHINE(hotplug_dev); | 20 | void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); |
37 | 21 | void aarch64_sve_change_el(CPUARMState *env, int old_el, | |
38 | if (pms->pbus_dev) { | 22 | int new_el, bool el0_a64); |
39 | - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { | 23 | -void aarch64_add_sve_properties(Object *obj); |
40 | + MachineClass *mc = MACHINE_GET_CLASS(pms); | 24 | -void aarch64_add_pauth_properties(Object *obj); |
41 | + | 25 | void arm_reset_sve_state(CPUARMState *env); |
42 | + if (device_is_dynamic_sysbus(mc, dev)) { | 26 | |
43 | platform_bus_link_device(pms->pbus_dev, SYS_BUS_DEVICE(dev)); | 27 | /* |
44 | } | 28 | @@ -XXX,XX +XXX,XX @@ static inline void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) { } |
45 | } | 29 | static inline void aarch64_sve_change_el(CPUARMState *env, int o, |
46 | @@ -XXX,XX +XXX,XX @@ static | 30 | int n, bool a) |
47 | HotplugHandler *e500plat_machine_get_hotpug_handler(MachineState *machine, | 31 | { } |
48 | DeviceState *dev) | 32 | -static inline void aarch64_add_sve_properties(Object *obj) { } |
33 | #endif | ||
34 | |||
35 | void aarch64_sync_32_to_64(CPUARMState *env); | ||
36 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/cpu64.c | ||
39 | +++ b/target/arm/cpu64.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_default_vec_len(Object *obj, Visitor *v, | ||
41 | } | ||
42 | #endif | ||
43 | |||
44 | -void aarch64_add_sve_properties(Object *obj) | ||
45 | +static void aarch64_add_sve_properties(Object *obj) | ||
49 | { | 46 | { |
50 | - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { | 47 | ARMCPU *cpu = ARM_CPU(obj); |
51 | + MachineClass *mc = MACHINE_GET_CLASS(machine); | 48 | uint32_t vq; |
52 | + | 49 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pauth_property = |
53 | + if (device_is_dynamic_sysbus(mc, dev)) { | 50 | static Property arm_cpu_pauth_impdef_property = |
54 | return HOTPLUG_HANDLER(machine); | 51 | DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); |
55 | } | 52 | |
53 | -void aarch64_add_pauth_properties(Object *obj) | ||
54 | +static void aarch64_add_pauth_properties(Object *obj) | ||
55 | { | ||
56 | ARMCPU *cpu = ARM_CPU(obj); | ||
56 | 57 | ||
57 | -- | 58 | -- |
58 | 2.20.1 | 59 | 2.25.1 |
59 | |||
60 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | Mirror the properties for SVE. The main difference is | ||
4 | that any arbitrary set of powers of 2 may be supported, | ||
5 | and not the stricter constraints that apply to SVE. | ||
6 | |||
7 | Include a property to control FEAT_SME_FA64, as failing | ||
8 | to restrict the runtime to the proper subset of insns | ||
9 | could be a major point for bugs. | ||
10 | |||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20220620175235.60881-18-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | docs/system/arm/cpu-features.rst | 56 +++++++++++++++ | ||
17 | target/arm/cpu.h | 2 + | ||
18 | target/arm/internals.h | 1 + | ||
19 | target/arm/cpu.c | 14 +++- | ||
20 | target/arm/cpu64.c | 114 +++++++++++++++++++++++++++++-- | ||
21 | 5 files changed, 180 insertions(+), 7 deletions(-) | ||
22 | |||
23 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/docs/system/arm/cpu-features.rst | ||
26 | +++ b/docs/system/arm/cpu-features.rst | ||
27 | @@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector | ||
28 | lengths is to explicitly enable each desired length. Therefore only | ||
29 | example's (1), (4), and (6) exhibit recommended uses of the properties. | ||
30 | |||
31 | +SME CPU Property Examples | ||
32 | +------------------------- | ||
33 | + | ||
34 | + 1) Disable SME:: | ||
35 | + | ||
36 | + $ qemu-system-aarch64 -M virt -cpu max,sme=off | ||
37 | + | ||
38 | + 2) Implicitly enable all vector lengths for the ``max`` CPU type:: | ||
39 | + | ||
40 | + $ qemu-system-aarch64 -M virt -cpu max | ||
41 | + | ||
42 | + 3) Only enable the 256-bit vector length:: | ||
43 | + | ||
44 | + $ qemu-system-aarch64 -M virt -cpu max,sme256=on | ||
45 | + | ||
46 | + 3) Enable the 256-bit and 1024-bit vector lengths:: | ||
47 | + | ||
48 | + $ qemu-system-aarch64 -M virt -cpu max,sme256=on,sme1024=on | ||
49 | + | ||
50 | + 4) Disable the 512-bit vector length. This results in all the other | ||
51 | + lengths supported by ``max`` defaulting to enabled | ||
52 | + (128, 256, 1024 and 2048):: | ||
53 | + | ||
54 | + $ qemu-system-aarch64 -M virt -cpu max,sve512=off | ||
55 | + | ||
56 | SVE User-mode Default Vector Length Property | ||
57 | -------------------------------------------- | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ length supported by QEMU is 256. | ||
60 | |||
61 | If this property is set to ``-1`` then the default vector length | ||
62 | is set to the maximum possible length. | ||
63 | + | ||
64 | +SME CPU Properties | ||
65 | +================== | ||
66 | + | ||
67 | +The SME CPU properties are much like the SVE properties: ``sme`` is | ||
68 | +used to enable or disable the entire SME feature, and ``sme<N>`` is | ||
69 | +used to enable or disable specific vector lengths. Finally, | ||
70 | +``sme_fa64`` is used to enable or disable ``FEAT_SME_FA64``, which | ||
71 | +allows execution of the "full a64" instruction set while Streaming | ||
72 | +SVE mode is enabled. | ||
73 | + | ||
74 | +SME is not supported by KVM at this time. | ||
75 | + | ||
76 | +At least one vector length must be enabled when ``sme`` is enabled, | ||
77 | +and all vector lengths must be powers of 2. The maximum vector | ||
78 | +length supported by qemu is 2048 bits. Otherwise, there are no | ||
79 | +additional constraints on the set of vector lengths supported by SME. | ||
80 | + | ||
81 | +SME User-mode Default Vector Length Property | ||
82 | +-------------------------------------------- | ||
83 | + | ||
84 | +For qemu-aarch64, the cpu propery ``sme-default-vector-length=N`` is | ||
85 | +defined to mirror the Linux kernel parameter file | ||
86 | +``/proc/sys/abi/sme_default_vector_length``. The default length, ``N``, | ||
87 | +is in units of bytes and must be between 16 and 8192. | ||
88 | +If not specified, the default vector length is 32. | ||
89 | + | ||
90 | +As with ``sve-default-vector-length``, if the default length is larger | ||
91 | +than the maximum vector length enabled, the actual vector length will | ||
92 | +be reduced. If this property is set to ``-1`` then the default vector | ||
93 | +length is set to the maximum possible length. | ||
94 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
95 | index XXXXXXX..XXXXXXX 100644 | ||
96 | --- a/target/arm/cpu.h | ||
97 | +++ b/target/arm/cpu.h | ||
98 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
99 | #ifdef CONFIG_USER_ONLY | ||
100 | /* Used to set the default vector length at process start. */ | ||
101 | uint32_t sve_default_vq; | ||
102 | + uint32_t sme_default_vq; | ||
103 | #endif | ||
104 | |||
105 | ARMVQMap sve_vq; | ||
106 | + ARMVQMap sme_vq; | ||
107 | |||
108 | /* Generic timer counter frequency, in Hz */ | ||
109 | uint64_t gt_cntfrq_hz; | ||
110 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/target/arm/internals.h | ||
113 | +++ b/target/arm/internals.h | ||
114 | @@ -XXX,XX +XXX,XX @@ int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg); | ||
115 | int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
116 | int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
117 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | ||
118 | +void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp); | ||
119 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); | ||
120 | void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); | ||
121 | #endif | ||
122 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/target/arm/cpu.c | ||
125 | +++ b/target/arm/cpu.c | ||
126 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | ||
127 | #ifdef CONFIG_USER_ONLY | ||
128 | # ifdef TARGET_AARCH64 | ||
129 | /* | ||
130 | - * The linux kernel defaults to 512-bit vectors, when sve is supported. | ||
131 | - * See documentation for /proc/sys/abi/sve_default_vector_length, and | ||
132 | - * our corresponding sve-default-vector-length cpu property. | ||
133 | + * The linux kernel defaults to 512-bit for SVE, and 256-bit for SME. | ||
134 | + * These values were chosen to fit within the default signal frame. | ||
135 | + * See documentation for /proc/sys/abi/{sve,sme}_default_vector_length, | ||
136 | + * and our corresponding cpu property. | ||
137 | */ | ||
138 | cpu->sve_default_vq = 4; | ||
139 | + cpu->sme_default_vq = 2; | ||
140 | # endif | ||
141 | #else | ||
142 | /* Our inbound IRQ and FIQ lines */ | ||
143 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | ||
144 | return; | ||
145 | } | ||
146 | |||
147 | + arm_cpu_sme_finalize(cpu, &local_err); | ||
148 | + if (local_err != NULL) { | ||
149 | + error_propagate(errp, local_err); | ||
150 | + return; | ||
151 | + } | ||
152 | + | ||
153 | arm_cpu_pauth_finalize(cpu, &local_err); | ||
154 | if (local_err != NULL) { | ||
155 | error_propagate(errp, local_err); | ||
156 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
157 | index XXXXXXX..XXXXXXX 100644 | ||
158 | --- a/target/arm/cpu64.c | ||
159 | +++ b/target/arm/cpu64.c | ||
160 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_vq(Object *obj, Visitor *v, const char *name, | ||
161 | ARMCPU *cpu = ARM_CPU(obj); | ||
162 | ARMVQMap *vq_map = opaque; | ||
163 | uint32_t vq = atoi(&name[3]) / 128; | ||
164 | + bool sve = vq_map == &cpu->sve_vq; | ||
165 | bool value; | ||
166 | |||
167 | - /* All vector lengths are disabled when SVE is off. */ | ||
168 | - if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
169 | + /* All vector lengths are disabled when feature is off. */ | ||
170 | + if (sve | ||
171 | + ? !cpu_isar_feature(aa64_sve, cpu) | ||
172 | + : !cpu_isar_feature(aa64_sme, cpu)) { | ||
173 | value = false; | ||
174 | } else { | ||
175 | value = extract32(vq_map->map, vq - 1, 1); | ||
176 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) | ||
177 | cpu->isar.id_aa64pfr0 = t; | ||
178 | } | ||
179 | |||
180 | +void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp) | ||
181 | +{ | ||
182 | + uint32_t vq_map = cpu->sme_vq.map; | ||
183 | + uint32_t vq_init = cpu->sme_vq.init; | ||
184 | + uint32_t vq_supported = cpu->sme_vq.supported; | ||
185 | + uint32_t vq; | ||
186 | + | ||
187 | + if (vq_map == 0) { | ||
188 | + if (!cpu_isar_feature(aa64_sme, cpu)) { | ||
189 | + cpu->isar.id_aa64smfr0 = 0; | ||
190 | + return; | ||
191 | + } | ||
192 | + | ||
193 | + /* TODO: KVM will require limitations via SMCR_EL2. */ | ||
194 | + vq_map = vq_supported & ~vq_init; | ||
195 | + | ||
196 | + if (vq_map == 0) { | ||
197 | + vq = ctz32(vq_supported) + 1; | ||
198 | + error_setg(errp, "cannot disable sme%d", vq * 128); | ||
199 | + error_append_hint(errp, "All SME vector lengths are disabled.\n"); | ||
200 | + error_append_hint(errp, "With SME enabled, at least one " | ||
201 | + "vector length must be enabled.\n"); | ||
202 | + return; | ||
203 | + } | ||
204 | + } else { | ||
205 | + if (!cpu_isar_feature(aa64_sme, cpu)) { | ||
206 | + vq = 32 - clz32(vq_map); | ||
207 | + error_setg(errp, "cannot enable sme%d", vq * 128); | ||
208 | + error_append_hint(errp, "SME must be enabled to enable " | ||
209 | + "vector lengths.\n"); | ||
210 | + error_append_hint(errp, "Add sme=on to the CPU property list.\n"); | ||
211 | + return; | ||
212 | + } | ||
213 | + /* TODO: KVM will require limitations via SMCR_EL2. */ | ||
214 | + } | ||
215 | + | ||
216 | + cpu->sme_vq.map = vq_map; | ||
217 | +} | ||
218 | + | ||
219 | +static bool cpu_arm_get_sme(Object *obj, Error **errp) | ||
220 | +{ | ||
221 | + ARMCPU *cpu = ARM_CPU(obj); | ||
222 | + return cpu_isar_feature(aa64_sme, cpu); | ||
223 | +} | ||
224 | + | ||
225 | +static void cpu_arm_set_sme(Object *obj, bool value, Error **errp) | ||
226 | +{ | ||
227 | + ARMCPU *cpu = ARM_CPU(obj); | ||
228 | + uint64_t t; | ||
229 | + | ||
230 | + t = cpu->isar.id_aa64pfr1; | ||
231 | + t = FIELD_DP64(t, ID_AA64PFR1, SME, value); | ||
232 | + cpu->isar.id_aa64pfr1 = t; | ||
233 | +} | ||
234 | + | ||
235 | +static bool cpu_arm_get_sme_fa64(Object *obj, Error **errp) | ||
236 | +{ | ||
237 | + ARMCPU *cpu = ARM_CPU(obj); | ||
238 | + return cpu_isar_feature(aa64_sme, cpu) && | ||
239 | + cpu_isar_feature(aa64_sme_fa64, cpu); | ||
240 | +} | ||
241 | + | ||
242 | +static void cpu_arm_set_sme_fa64(Object *obj, bool value, Error **errp) | ||
243 | +{ | ||
244 | + ARMCPU *cpu = ARM_CPU(obj); | ||
245 | + uint64_t t; | ||
246 | + | ||
247 | + t = cpu->isar.id_aa64smfr0; | ||
248 | + t = FIELD_DP64(t, ID_AA64SMFR0, FA64, value); | ||
249 | + cpu->isar.id_aa64smfr0 = t; | ||
250 | +} | ||
251 | + | ||
252 | #ifdef CONFIG_USER_ONLY | ||
253 | -/* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
254 | +/* Mirror linux /proc/sys/abi/{sve,sme}_default_vector_length. */ | ||
255 | static void cpu_arm_set_default_vec_len(Object *obj, Visitor *v, | ||
256 | const char *name, void *opaque, | ||
257 | Error **errp) | ||
258 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_default_vec_len(Object *obj, Visitor *v, | ||
259 | * and is the maximum architectural width of ZCR_ELx.LEN. | ||
260 | */ | ||
261 | if (remainder || default_vq < 1 || default_vq > 512) { | ||
262 | - error_setg(errp, "cannot set sve-default-vector-length"); | ||
263 | + ARMCPU *cpu = ARM_CPU(obj); | ||
264 | + const char *which = | ||
265 | + (ptr_default_vq == &cpu->sve_default_vq ? "sve" : "sme"); | ||
266 | + | ||
267 | + error_setg(errp, "cannot set %s-default-vector-length", which); | ||
268 | if (remainder) { | ||
269 | error_append_hint(errp, "Vector length not a multiple of 16\n"); | ||
270 | } else if (default_vq < 1) { | ||
271 | @@ -XXX,XX +XXX,XX @@ static void aarch64_add_sve_properties(Object *obj) | ||
272 | #endif | ||
273 | } | ||
274 | |||
275 | +static void aarch64_add_sme_properties(Object *obj) | ||
276 | +{ | ||
277 | + ARMCPU *cpu = ARM_CPU(obj); | ||
278 | + uint32_t vq; | ||
279 | + | ||
280 | + object_property_add_bool(obj, "sme", cpu_arm_get_sme, cpu_arm_set_sme); | ||
281 | + object_property_add_bool(obj, "sme_fa64", cpu_arm_get_sme_fa64, | ||
282 | + cpu_arm_set_sme_fa64); | ||
283 | + | ||
284 | + for (vq = 1; vq <= ARM_MAX_VQ; vq <<= 1) { | ||
285 | + char name[8]; | ||
286 | + sprintf(name, "sme%d", vq * 128); | ||
287 | + object_property_add(obj, name, "bool", cpu_arm_get_vq, | ||
288 | + cpu_arm_set_vq, NULL, &cpu->sme_vq); | ||
289 | + } | ||
290 | + | ||
291 | +#ifdef CONFIG_USER_ONLY | ||
292 | + /* Mirror linux /proc/sys/abi/sme_default_vector_length. */ | ||
293 | + object_property_add(obj, "sme-default-vector-length", "int32", | ||
294 | + cpu_arm_get_default_vec_len, | ||
295 | + cpu_arm_set_default_vec_len, NULL, | ||
296 | + &cpu->sme_default_vq); | ||
297 | +#endif | ||
298 | +} | ||
299 | + | ||
300 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) | ||
301 | { | ||
302 | int arch_val = 0, impdef_val = 0; | ||
303 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
304 | #endif | ||
305 | |||
306 | cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
307 | + cpu->sme_vq.supported = SVE_VQ_POW2_MAP; | ||
308 | |||
309 | aarch64_add_pauth_properties(obj); | ||
310 | aarch64_add_sve_properties(obj); | ||
311 | + aarch64_add_sme_properties(obj); | ||
312 | object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | ||
313 | cpu_max_set_sve_max_vq, NULL, NULL); | ||
314 | qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property); | ||
315 | -- | ||
316 | 2.25.1 | diff view generated by jsdifflib |
1 | Provide a new function dynamic_sysbus_dev_allowed() which checks the | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | per-machine list of permitted dynamic sysbus devices and returns a | ||
3 | boolean result indicating whether the device is allowed. We can use | ||
4 | this in the implementation of validate_sysbus_device(), but we will | ||
5 | also need it so that machine hotplug callbacks can validate devices | ||
6 | rather than assuming that any sysbus device might be hotpluggable | ||
7 | into the platform bus. | ||
8 | 2 | ||
3 | When Streaming SVE mode is enabled, the size is taken from | ||
4 | SMCR_ELx instead of ZCR_ELx. The format is shared, but the | ||
5 | set of vector lengths is not. Further, Streaming SVE does | ||
6 | not require any particular length to be supported. | ||
7 | |||
8 | Adjust sve_vqm1_for_el to pass the current value of PSTATE.SM | ||
9 | to the new function. | ||
10 | |||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20220620175235.60881-19-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | ||
12 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Message-id: 20210325153310.9131-3-peter.maydell@linaro.org | ||
14 | --- | 15 | --- |
15 | include/hw/boards.h | 24 ++++++++++++++++++++++++ | 16 | target/arm/cpu.h | 9 +++++++-- |
16 | hw/core/machine.c | 21 ++++++++++++++++----- | 17 | target/arm/helper.c | 32 +++++++++++++++++++++++++------- |
17 | 2 files changed, 40 insertions(+), 5 deletions(-) | 18 | 2 files changed, 32 insertions(+), 9 deletions(-) |
18 | 19 | ||
19 | diff --git a/include/hw/boards.h b/include/hw/boards.h | 20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
20 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/include/hw/boards.h | 22 | --- a/target/arm/cpu.h |
22 | +++ b/include/hw/boards.h | 23 | +++ b/target/arm/cpu.h |
23 | @@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine, | 24 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int cur_el); |
25 | int sme_exception_el(CPUARMState *env, int cur_el); | ||
26 | |||
27 | /** | ||
28 | - * sve_vqm1_for_el: | ||
29 | + * sve_vqm1_for_el_sm: | ||
30 | * @env: CPUARMState | ||
31 | * @el: exception level | ||
32 | + * @sm: streaming mode | ||
33 | * | ||
34 | - * Compute the current SVE vector length for @el, in units of | ||
35 | + * Compute the current vector length for @el & @sm, in units of | ||
36 | * Quadwords Minus 1 -- the same scale used for ZCR_ELx.LEN. | ||
37 | + * If @sm, compute for SVL, otherwise NVL. | ||
24 | */ | 38 | */ |
25 | void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); | 39 | +uint32_t sve_vqm1_for_el_sm(CPUARMState *env, int el, bool sm); |
26 | |||
27 | +/** | ||
28 | + * device_is_dynamic_sysbus: test whether device is a dynamic sysbus device | ||
29 | + * @mc: Machine class | ||
30 | + * @dev: device to check | ||
31 | + * | ||
32 | + * Returns: true if @dev is a sysbus device on the machine's list | ||
33 | + * of dynamically pluggable sysbus devices; otherwise false. | ||
34 | + * | ||
35 | + * This function checks whether @dev is a valid dynamic sysbus device, | ||
36 | + * by first confirming that it is a sysbus device and then checking it | ||
37 | + * against the list of permitted dynamic sysbus devices which has been | ||
38 | + * set up by the machine using machine_class_allow_dynamic_sysbus_dev(). | ||
39 | + * | ||
40 | + * It is valid to call this with something that is not a subclass of | ||
41 | + * TYPE_SYS_BUS_DEVICE; the function will return false in this case. | ||
42 | + * This allows hotplug callback functions to be written as: | ||
43 | + * if (device_is_dynamic_sysbus(mc, dev)) { | ||
44 | + * handle dynamic sysbus case; | ||
45 | + * } else if (some other kind of hotplug) { | ||
46 | + * handle that; | ||
47 | + * } | ||
48 | + */ | ||
49 | +bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev); | ||
50 | + | 40 | + |
41 | +/* Likewise, but using @sm = PSTATE.SM. */ | ||
42 | uint32_t sve_vqm1_for_el(CPUARMState *env, int el); | ||
43 | |||
44 | static inline bool is_a64(CPUARMState *env) | ||
45 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/helper.c | ||
48 | +++ b/target/arm/helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ int sme_exception_el(CPUARMState *env, int el) | ||
51 | /* | 50 | /* |
52 | * Checks that backend isn't used, preps it for exclusive usage and | 51 | * Given that SVE is enabled, return the vector length for EL. |
53 | * returns migratable MemoryRegion provided by backend. | 52 | */ |
54 | diff --git a/hw/core/machine.c b/hw/core/machine.c | 53 | -uint32_t sve_vqm1_for_el(CPUARMState *env, int el) |
55 | index XXXXXXX..XXXXXXX 100644 | 54 | +uint32_t sve_vqm1_for_el_sm(CPUARMState *env, int el, bool sm) |
56 | --- a/hw/core/machine.c | ||
57 | +++ b/hw/core/machine.c | ||
58 | @@ -XXX,XX +XXX,XX @@ void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type) | ||
59 | QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type)); | ||
60 | } | ||
61 | |||
62 | -static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) | ||
63 | +bool device_is_dynamic_sysbus(MachineClass *mc, DeviceState *dev) | ||
64 | { | 55 | { |
65 | - MachineState *machine = opaque; | 56 | ARMCPU *cpu = env_archcpu(env); |
66 | - MachineClass *mc = MACHINE_GET_CLASS(machine); | 57 | - uint32_t len = cpu->sve_max_vq - 1; |
67 | bool allowed = false; | 58 | + uint64_t *cr = env->vfp.zcr_el; |
68 | strList *wl; | 59 | + uint32_t map = cpu->sve_vq.map; |
69 | + Object *obj = OBJECT(dev); | 60 | + uint32_t len = ARM_MAX_VQ - 1; |
70 | + | 61 | + |
71 | + if (!object_dynamic_cast(obj, TYPE_SYS_BUS_DEVICE)) { | 62 | + if (sm) { |
72 | + return false; | 63 | + cr = env->vfp.smcr_el; |
64 | + map = cpu->sme_vq.map; | ||
73 | + } | 65 | + } |
74 | 66 | ||
75 | for (wl = mc->allowed_dynamic_sysbus_devices; | 67 | if (el <= 1 && !el_is_in_host(env, el)) { |
76 | !allowed && wl; | 68 | - len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[1]); |
77 | wl = wl->next) { | 69 | + len = MIN(len, 0xf & (uint32_t)cr[1]); |
78 | - allowed |= !!object_dynamic_cast(OBJECT(sbdev), wl->value); | ||
79 | + allowed |= !!object_dynamic_cast(obj, wl->value); | ||
80 | } | 70 | } |
81 | 71 | if (el <= 2 && arm_feature(env, ARM_FEATURE_EL2)) { | |
82 | - if (!allowed) { | 72 | - len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[2]); |
83 | + return allowed; | 73 | + len = MIN(len, 0xf & (uint32_t)cr[2]); |
74 | } | ||
75 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
76 | - len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | ||
77 | + len = MIN(len, 0xf & (uint32_t)cr[3]); | ||
78 | } | ||
79 | |||
80 | - len = 31 - clz32(cpu->sve_vq.map & MAKE_64BIT_MASK(0, len + 1)); | ||
81 | - return len; | ||
82 | + map &= MAKE_64BIT_MASK(0, len + 1); | ||
83 | + if (map != 0) { | ||
84 | + return 31 - clz32(map); | ||
85 | + } | ||
86 | + | ||
87 | + /* Bit 0 is always set for Normal SVE -- not so for Streaming SVE. */ | ||
88 | + assert(sm); | ||
89 | + return ctz32(cpu->sme_vq.map); | ||
84 | +} | 90 | +} |
85 | + | 91 | + |
86 | +static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque) | 92 | +uint32_t sve_vqm1_for_el(CPUARMState *env, int el) |
87 | +{ | 93 | +{ |
88 | + MachineState *machine = opaque; | 94 | + return sve_vqm1_for_el_sm(env, el, FIELD_EX64(env->svcr, SVCR, SM)); |
89 | + MachineClass *mc = MACHINE_GET_CLASS(machine); | 95 | } |
90 | + | 96 | |
91 | + if (!device_is_dynamic_sysbus(mc, DEVICE(sbdev))) { | 97 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
92 | error_report("Option '-device %s' cannot be handled by this machine", | ||
93 | object_class_get_name(object_get_class(OBJECT(sbdev)))); | ||
94 | exit(1); | ||
95 | -- | 98 | -- |
96 | 2.20.1 | 99 | 2.25.1 |
97 | |||
98 | diff view generated by jsdifflib |
1 | The function machine_class_allow_dynamic_sysbus_dev() is currently | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | undocumented; add a doc comment. | ||
3 | 2 | ||
3 | We need SVL separate from VL for RDSVL et al, as well as | ||
4 | ZA storage loads and stores, which do not require PSTATE.SM. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-20-richard.henderson@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | ||
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Message-id: 20210325153310.9131-2-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | include/hw/boards.h | 15 +++++++++++++++ | 11 | target/arm/cpu.h | 12 ++++++++++++ |
11 | 1 file changed, 15 insertions(+) | 12 | target/arm/translate.h | 1 + |
13 | target/arm/helper.c | 8 +++++++- | ||
14 | target/arm/translate-a64.c | 1 + | ||
15 | 4 files changed, 21 insertions(+), 1 deletion(-) | ||
12 | 16 | ||
13 | diff --git a/include/hw/boards.h b/include/hw/boards.h | 17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/boards.h | 19 | --- a/target/arm/cpu.h |
16 | +++ b/include/hw/boards.h | 20 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine, | 21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) |
18 | const CpuInstanceProperties *props, | 22 | FIELD(TBFLAG_A64, SMEEXC_EL, 20, 2) |
19 | Error **errp); | 23 | FIELD(TBFLAG_A64, PSTATE_SM, 22, 1) |
24 | FIELD(TBFLAG_A64, PSTATE_ZA, 23, 1) | ||
25 | +FIELD(TBFLAG_A64, SVL, 24, 4) | ||
26 | |||
27 | /* | ||
28 | * Helpers for using the above. | ||
29 | @@ -XXX,XX +XXX,XX @@ static inline int sve_vq(CPUARMState *env) | ||
30 | return EX_TBFLAG_A64(env->hflags, VL) + 1; | ||
31 | } | ||
20 | 32 | ||
21 | +/** | 33 | +/** |
22 | + * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices | 34 | + * sme_vq |
23 | + * @mc: Machine class | 35 | + * @env: the cpu context |
24 | + * @type: type to allow (should be a subtype of TYPE_SYS_BUS_DEVICE) | ||
25 | + * | 36 | + * |
26 | + * Add the QOM type @type to the list of devices of which are subtypes | 37 | + * Return the SVL cached within env->hflags, in units of quadwords. |
27 | + * of TYPE_SYS_BUS_DEVICE but which are still permitted to be dynamically | ||
28 | + * created (eg by the user on the command line with -device). | ||
29 | + * By default if the user tries to create any devices on the command line | ||
30 | + * that are subtypes of TYPE_SYS_BUS_DEVICE they will get an error message; | ||
31 | + * for the special cases which are permitted for this machine model, the | ||
32 | + * machine model class init code must call this function to add them | ||
33 | + * to the list of specifically permitted devices. | ||
34 | + */ | 38 | + */ |
35 | void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); | 39 | +static inline int sme_vq(CPUARMState *env) |
40 | +{ | ||
41 | + return EX_TBFLAG_A64(env->hflags, SVL) + 1; | ||
42 | +} | ||
36 | + | 43 | + |
37 | /* | 44 | static inline bool bswap_code(bool sctlr_b) |
38 | * Checks that backend isn't used, preps it for exclusive usage and | 45 | { |
39 | * returns migratable MemoryRegion provided by backend. | 46 | #ifdef CONFIG_USER_ONLY |
47 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/translate.h | ||
50 | +++ b/target/arm/translate.h | ||
51 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
52 | int sve_excp_el; /* SVE exception EL or 0 if enabled */ | ||
53 | int sme_excp_el; /* SME exception EL or 0 if enabled */ | ||
54 | int vl; /* current vector length in bytes */ | ||
55 | + int svl; /* current streaming vector length in bytes */ | ||
56 | bool vfp_enabled; /* FP enabled via FPSCR.EN */ | ||
57 | int vec_len; | ||
58 | int vec_stride; | ||
59 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/helper.c | ||
62 | +++ b/target/arm/helper.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
64 | DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | ||
65 | } | ||
66 | if (cpu_isar_feature(aa64_sme, env_archcpu(env))) { | ||
67 | - DP_TBFLAG_A64(flags, SMEEXC_EL, sme_exception_el(env, el)); | ||
68 | + int sme_el = sme_exception_el(env, el); | ||
69 | + | ||
70 | + DP_TBFLAG_A64(flags, SMEEXC_EL, sme_el); | ||
71 | + if (sme_el == 0) { | ||
72 | + /* Similarly, do not compute SVL if SME is disabled. */ | ||
73 | + DP_TBFLAG_A64(flags, SVL, sve_vqm1_for_el_sm(env, el, true)); | ||
74 | + } | ||
75 | if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
76 | DP_TBFLAG_A64(flags, PSTATE_SM, 1); | ||
77 | } | ||
78 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/target/arm/translate-a64.c | ||
81 | +++ b/target/arm/translate-a64.c | ||
82 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
83 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | ||
84 | dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL); | ||
85 | dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16; | ||
86 | + dc->svl = (EX_TBFLAG_A64(tb_flags, SVL) + 1) * 16; | ||
87 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | ||
88 | dc->bt = EX_TBFLAG_A64(tb_flags, BT); | ||
89 | dc->btype = EX_TBFLAG_A64(tb_flags, BTYPE); | ||
40 | -- | 90 | -- |
41 | 2.20.1 | 91 | 2.25.1 |
42 | |||
43 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | We will need these functions in translate-sme.c. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220620175235.60881-21-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate-a64.h | 38 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-sve.c | 36 ------------------------------------ | ||
12 | 2 files changed, 38 insertions(+), 36 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate-a64.h | ||
17 | +++ b/target/arm/translate-a64.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s) | ||
19 | return s->vl; | ||
20 | } | ||
21 | |||
22 | +/* | ||
23 | + * Return the offset info CPUARMState of the predicate vector register Pn. | ||
24 | + * Note for this purpose, FFR is P16. | ||
25 | + */ | ||
26 | +static inline int pred_full_reg_offset(DisasContext *s, int regno) | ||
27 | +{ | ||
28 | + return offsetof(CPUARMState, vfp.pregs[regno]); | ||
29 | +} | ||
30 | + | ||
31 | +/* Return the byte size of the whole predicate register, VL / 64. */ | ||
32 | +static inline int pred_full_reg_size(DisasContext *s) | ||
33 | +{ | ||
34 | + return s->vl >> 3; | ||
35 | +} | ||
36 | + | ||
37 | +/* | ||
38 | + * Round up the size of a register to a size allowed by | ||
39 | + * the tcg vector infrastructure. Any operation which uses this | ||
40 | + * size may assume that the bits above pred_full_reg_size are zero, | ||
41 | + * and must leave them the same way. | ||
42 | + * | ||
43 | + * Note that this is not needed for the vector registers as they | ||
44 | + * are always properly sized for tcg vectors. | ||
45 | + */ | ||
46 | +static inline int size_for_gvec(int size) | ||
47 | +{ | ||
48 | + if (size <= 8) { | ||
49 | + return 8; | ||
50 | + } else { | ||
51 | + return QEMU_ALIGN_UP(size, 16); | ||
52 | + } | ||
53 | +} | ||
54 | + | ||
55 | +static inline int pred_gvec_reg_size(DisasContext *s) | ||
56 | +{ | ||
57 | + return size_for_gvec(pred_full_reg_size(s)); | ||
58 | +} | ||
59 | + | ||
60 | bool disas_sve(DisasContext *, uint32_t); | ||
61 | |||
62 | void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
63 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/translate-sve.c | ||
66 | +++ b/target/arm/translate-sve.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline int msz_dtype(DisasContext *s, int msz) | ||
68 | * Implement all of the translator functions referenced by the decoder. | ||
69 | */ | ||
70 | |||
71 | -/* Return the offset info CPUARMState of the predicate vector register Pn. | ||
72 | - * Note for this purpose, FFR is P16. | ||
73 | - */ | ||
74 | -static inline int pred_full_reg_offset(DisasContext *s, int regno) | ||
75 | -{ | ||
76 | - return offsetof(CPUARMState, vfp.pregs[regno]); | ||
77 | -} | ||
78 | - | ||
79 | -/* Return the byte size of the whole predicate register, VL / 64. */ | ||
80 | -static inline int pred_full_reg_size(DisasContext *s) | ||
81 | -{ | ||
82 | - return s->vl >> 3; | ||
83 | -} | ||
84 | - | ||
85 | -/* Round up the size of a register to a size allowed by | ||
86 | - * the tcg vector infrastructure. Any operation which uses this | ||
87 | - * size may assume that the bits above pred_full_reg_size are zero, | ||
88 | - * and must leave them the same way. | ||
89 | - * | ||
90 | - * Note that this is not needed for the vector registers as they | ||
91 | - * are always properly sized for tcg vectors. | ||
92 | - */ | ||
93 | -static int size_for_gvec(int size) | ||
94 | -{ | ||
95 | - if (size <= 8) { | ||
96 | - return 8; | ||
97 | - } else { | ||
98 | - return QEMU_ALIGN_UP(size, 16); | ||
99 | - } | ||
100 | -} | ||
101 | - | ||
102 | -static int pred_gvec_reg_size(DisasContext *s) | ||
103 | -{ | ||
104 | - return size_for_gvec(pred_full_reg_size(s)); | ||
105 | -} | ||
106 | - | ||
107 | /* Invoke an out-of-line helper on 2 Zregs. */ | ||
108 | static bool gen_gvec_ool_zz(DisasContext *s, gen_helper_gvec_2 *fn, | ||
109 | int rd, int rn, int data) | ||
110 | -- | ||
111 | 2.25.1 | diff view generated by jsdifflib |
1 | The virt machine device plug callback currently calls | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | platform_bus_link_device() for any sysbus device. This is overly | ||
3 | broad, because platform_bus_link_device() will unconditionally grab | ||
4 | the IRQs and MMIOs of the device it is passed, whether it was | ||
5 | intended for the platform bus or not. Restrict hotpluggability of | ||
6 | sysbus devices to only those devices on the dynamic sysbus | ||
7 | allowlist. | ||
8 | 2 | ||
9 | We were mostly getting away with this because the board creates the | 3 | Move the code from hw/arm/virt.c that is supposed |
10 | platform bus as the last device it creates, and so the hotplug | 4 | to handle v7 into the one function. |
11 | callback did not do anything for all the sysbus devices created by | ||
12 | the board itself. However if the user plugged in a device which | ||
13 | itself uses a sysbus device internally we would have mishandled this | ||
14 | and probably asserted. | ||
15 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reported-by: He Zhe <zhe.he@windriver.com> | ||
8 | Message-id: 20220619001541.131672-2-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | ||
19 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
20 | Message-id: 20210325153310.9131-4-peter.maydell@linaro.org | ||
21 | --- | 11 | --- |
22 | hw/arm/virt.c | 8 ++++++-- | 12 | hw/arm/virt.c | 10 +--------- |
23 | 1 file changed, 6 insertions(+), 2 deletions(-) | 13 | target/arm/ptw.c | 24 ++++++++++++++++-------- |
14 | 2 files changed, 17 insertions(+), 17 deletions(-) | ||
24 | 15 | ||
25 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 16 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
26 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/arm/virt.c | 18 | --- a/hw/arm/virt.c |
28 | +++ b/hw/arm/virt.c | 19 | +++ b/hw/arm/virt.c |
29 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, | 20 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
30 | VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); | 21 | cpuobj = object_new(possible_cpus->cpus[0].type); |
31 | 22 | armcpu = ARM_CPU(cpuobj); | |
32 | if (vms->platform_bus_dev) { | 23 | |
33 | - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { | 24 | - if (object_property_get_bool(cpuobj, "aarch64", NULL)) { |
34 | + MachineClass *mc = MACHINE_GET_CLASS(vms); | 25 | - pa_bits = arm_pamax(armcpu); |
35 | + | 26 | - } else if (arm_feature(&armcpu->env, ARM_FEATURE_LPAE)) { |
36 | + if (device_is_dynamic_sysbus(mc, dev)) { | 27 | - /* v7 with LPAE */ |
37 | platform_bus_link_device(PLATFORM_BUS_DEVICE(vms->platform_bus_dev), | 28 | - pa_bits = 40; |
38 | SYS_BUS_DEVICE(dev)); | 29 | - } else { |
39 | } | 30 | - /* Anything else */ |
40 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, | 31 | - pa_bits = 32; |
41 | static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | 32 | - } |
42 | DeviceState *dev) | 33 | + pa_bits = arm_pamax(armcpu); |
34 | |||
35 | object_unref(cpuobj); | ||
36 | |||
37 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/ptw.c | ||
40 | +++ b/target/arm/ptw.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static const uint8_t pamax_map[] = { | ||
42 | /* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ | ||
43 | unsigned int arm_pamax(ARMCPU *cpu) | ||
43 | { | 44 | { |
44 | - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || | 45 | - unsigned int parange = |
45 | + MachineClass *mc = MACHINE_GET_CLASS(machine); | 46 | - FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); |
46 | + | 47 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { |
47 | + if (device_is_dynamic_sysbus(mc, dev) || | 48 | + unsigned int parange = |
48 | (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { | 49 | + FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); |
49 | return HOTPLUG_HANDLER(machine); | 50 | |
50 | } | 51 | - /* |
52 | - * id_aa64mmfr0 is a read-only register so values outside of the | ||
53 | - * supported mappings can be considered an implementation error. | ||
54 | - */ | ||
55 | - assert(parange < ARRAY_SIZE(pamax_map)); | ||
56 | - return pamax_map[parange]; | ||
57 | + /* | ||
58 | + * id_aa64mmfr0 is a read-only register so values outside of the | ||
59 | + * supported mappings can be considered an implementation error. | ||
60 | + */ | ||
61 | + assert(parange < ARRAY_SIZE(pamax_map)); | ||
62 | + return pamax_map[parange]; | ||
63 | + } | ||
64 | + if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) { | ||
65 | + /* v7 with LPAE */ | ||
66 | + return 40; | ||
67 | + } | ||
68 | + /* Anything else */ | ||
69 | + return 32; | ||
70 | } | ||
71 | |||
72 | /* | ||
51 | -- | 73 | -- |
52 | 2.20.1 | 74 | 2.25.1 |
53 | |||
54 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
1 | 2 | ||
3 | In machvirt_init we create a cpu but do not fully initialize it. | ||
4 | Thus the propagation of V7VE to LPAE has not been done, and we | ||
5 | compute the wrong value for some v7 cpus, e.g. cortex-a15. | ||
6 | |||
7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1078 | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reported-by: He Zhe <zhe.he@windriver.com> | ||
10 | Message-id: 20220619001541.131672-3-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/ptw.c | 8 +++++++- | ||
15 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/ptw.c | ||
20 | +++ b/target/arm/ptw.c | ||
21 | @@ -XXX,XX +XXX,XX @@ unsigned int arm_pamax(ARMCPU *cpu) | ||
22 | assert(parange < ARRAY_SIZE(pamax_map)); | ||
23 | return pamax_map[parange]; | ||
24 | } | ||
25 | - if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) { | ||
26 | + | ||
27 | + /* | ||
28 | + * In machvirt_init, we call arm_pamax on a cpu that is not fully | ||
29 | + * initialized, so we can't rely on the propagation done in realize. | ||
30 | + */ | ||
31 | + if (arm_feature(&cpu->env, ARM_FEATURE_LPAE) || | ||
32 | + arm_feature(&cpu->env, ARM_FEATURE_V7VE)) { | ||
33 | /* v7 with LPAE */ | ||
34 | return 40; | ||
35 | } | ||
36 | -- | ||
37 | 2.25.1 | diff view generated by jsdifflib |