1 | Couple of minor patches to sneak in before rc0. The PSCI return | 1 | This bug seemed worth fixing for 8.0 since we need an rc4 anyway: |
---|---|---|---|
2 | values fix is the most important one. | 2 | we were using uninitialized data for the guarded bit when |
3 | combining stage 1 and stage 2 attrs. | ||
3 | 4 | ||
5 | thanks | ||
4 | -- PMM | 6 | -- PMM |
5 | 7 | ||
6 | The following changes since commit 94b5d57d2f5a3c849cecd65e424bb6f50b998df9: | 8 | The following changes since commit 08dede07030973c1053868bc64de7e10bfa02ad6: |
7 | 9 | ||
8 | Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.9-20170314' into staging (2017-03-14 10:13:19 +0000) | 10 | Merge tag 'pull-ppc-20230409' of https://github.com/legoater/qemu into staging (2023-04-10 11:47:52 +0100) |
9 | 11 | ||
10 | are available in the git repository at: | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170314 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230410 |
13 | 15 | ||
14 | for you to fetch changes up to d5affb0d8677e1a8a8fe03fa25005b669e7cdc02: | 16 | for you to fetch changes up to 8539dc00552e8ea60420856fc1262c8299bc6308: |
15 | 17 | ||
16 | target/arm/arm-powerctl: Fix psci info return values (2017-03-14 11:28:54 +0000) | 18 | target/arm: Copy guarded bit in combine_cacheattrs (2023-04-10 14:31:40 +0100) |
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | target-arm queue: | 21 | target-arm: Fix bug where we weren't initializing |
20 | * arm-powerctl: Fix psci info return values | 22 | guarded bit state when combining S1/S2 attrs |
21 | * implement armv8 PMUSERENR (user-mode enable bits) | ||
22 | 23 | ||
23 | ---------------------------------------------------------------- | 24 | ---------------------------------------------------------------- |
24 | Andrew Baumann (1): | 25 | Richard Henderson (2): |
25 | target/arm: implement armv8 PMUSERENR (user-mode enable bits) | 26 | target/arm: PTE bit GP only applies to stage1 |
27 | target/arm: Copy guarded bit in combine_cacheattrs | ||
26 | 28 | ||
27 | Andrew Jones (1): | 29 | target/arm/ptw.c | 11 ++++++----- |
28 | target/arm/arm-powerctl: Fix psci info return values | 30 | 1 file changed, 6 insertions(+), 5 deletions(-) |
29 | |||
30 | target/arm/cpu.h | 4 +-- | ||
31 | target/arm/helper.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++------ | ||
32 | 2 files changed, 73 insertions(+), 10 deletions(-) | ||
33 | diff view generated by jsdifflib |
1 | From: Andrew Jones <drjones@redhat.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The power state spec section 5.1.5 AFFINITY_INFO defines the | 3 | Only perform the extract of GP during the stage1 walk. |
4 | affinity info return values as | ||
5 | 4 | ||
6 | 0 ON | 5 | Reported-by: Peter Maydell <peter.maydell@linaro.org> |
7 | 1 OFF | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | 2 ON_PENDING | ||
9 | |||
10 | I grepped QEMU for power_state to ensure that no assumptions | ||
11 | of OFF=0 were being made. | ||
12 | |||
13 | Signed-off-by: Andrew Jones <drjones@redhat.com> | ||
14 | Message-id: 20170303123232.4967-1-drjones@redhat.com | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20230407185149.3253946-2-richard.henderson@linaro.org | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 10 | --- |
18 | target/arm/cpu.h | 4 ++-- | 11 | target/arm/ptw.c | 10 +++++----- |
19 | 1 file changed, 2 insertions(+), 2 deletions(-) | 12 | 1 file changed, 5 insertions(+), 5 deletions(-) |
20 | 13 | ||
21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
22 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.h | 16 | --- a/target/arm/ptw.c |
24 | +++ b/target/arm/cpu.h | 17 | +++ b/target/arm/ptw.c |
25 | @@ -XXX,XX +XXX,XX @@ typedef void ARMELChangeHook(ARMCPU *cpu, void *opaque); | 18 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, |
26 | /* These values map onto the return values for | 19 | result->f.attrs.secure = false; |
27 | * QEMU_PSCI_0_2_FN_AFFINITY_INFO */ | 20 | } |
28 | typedef enum ARMPSCIState { | 21 | |
29 | - PSCI_OFF = 0, | 22 | - /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ |
30 | - PSCI_ON = 1, | 23 | - if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { |
31 | + PSCI_ON = 0, | 24 | - result->f.guarded = extract64(attrs, 50, 1); /* GP */ |
32 | + PSCI_OFF = 1, | 25 | - } |
33 | PSCI_ON_PENDING = 2 | 26 | - |
34 | } ARMPSCIState; | 27 | if (regime_is_stage2(mmu_idx)) { |
35 | 28 | result->cacheattrs.is_s2_format = true; | |
29 | result->cacheattrs.attrs = extract32(attrs, 2, 4); | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, | ||
31 | assert(attrindx <= 7); | ||
32 | result->cacheattrs.is_s2_format = false; | ||
33 | result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8); | ||
34 | + | ||
35 | + /* When in aarch64 mode, and BTI is enabled, remember GP in the TLB. */ | ||
36 | + if (aarch64 && cpu_isar_feature(aa64_bti, cpu)) { | ||
37 | + result->f.guarded = extract64(attrs, 50, 1); /* GP */ | ||
38 | + } | ||
39 | } | ||
40 | |||
41 | /* | ||
36 | -- | 42 | -- |
37 | 2.7.4 | 43 | 2.34.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Andrew Baumann <Andrew.Baumann@microsoft.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In armv8, this register implements more than a single bit, with | 3 | The guarded bit comes from the stage1 walk. |
4 | fine-grained enables for read access to event counters, cycles | ||
5 | counters, and write access to the software increment. This change | ||
6 | implements those checks using custom access functions for the relevant | ||
7 | registers. | ||
8 | 4 | ||
9 | Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | 5 | Fixes: Coverity CID 1507929 |
10 | Message-id: 20170228215801.10472-2-Andrew.Baumann@microsoft.com | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | [PMM: move a couple of access functions to be only compiled | 8 | Message-id: 20230407185149.3253946-3-richard.henderson@linaro.org |
13 | ifndef CONFIG_USER_ONLY to avoid compiler warnings] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 10 | --- |
16 | target/arm/helper.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++------ | 11 | target/arm/ptw.c | 1 + |
17 | 1 file changed, 71 insertions(+), 8 deletions(-) | 12 | 1 file changed, 1 insertion(+) |
18 | 13 | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
20 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 16 | --- a/target/arm/ptw.c |
22 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/ptw.c |
23 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri, | 18 | @@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(uint64_t hcr, |
24 | */ | 19 | |
25 | int el = arm_current_el(env); | 20 | assert(!s1.is_s2_format); |
26 | 21 | ret.is_s2_format = false; | |
27 | - if (el == 0 && !env->cp15.c9_pmuserenr) { | 22 | + ret.guarded = s1.guarded; |
28 | + if (el == 0 && !(env->cp15.c9_pmuserenr & 1)) { | 23 | |
29 | return CP_ACCESS_TRAP; | 24 | if (s1.attrs == 0xf0) { |
30 | } | 25 | tagged = true; |
31 | if (el < 2 && (env->cp15.mdcr_el2 & MDCR_TPM) | ||
32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri, | ||
33 | return CP_ACCESS_OK; | ||
34 | } | ||
35 | |||
36 | +static CPAccessResult pmreg_access_xevcntr(CPUARMState *env, | ||
37 | + const ARMCPRegInfo *ri, | ||
38 | + bool isread) | ||
39 | +{ | ||
40 | + /* ER: event counter read trap control */ | ||
41 | + if (arm_feature(env, ARM_FEATURE_V8) | ||
42 | + && arm_current_el(env) == 0 | ||
43 | + && (env->cp15.c9_pmuserenr & (1 << 3)) != 0 | ||
44 | + && isread) { | ||
45 | + return CP_ACCESS_OK; | ||
46 | + } | ||
47 | + | ||
48 | + return pmreg_access(env, ri, isread); | ||
49 | +} | ||
50 | + | ||
51 | +static CPAccessResult pmreg_access_swinc(CPUARMState *env, | ||
52 | + const ARMCPRegInfo *ri, | ||
53 | + bool isread) | ||
54 | +{ | ||
55 | + /* SW: software increment write trap control */ | ||
56 | + if (arm_feature(env, ARM_FEATURE_V8) | ||
57 | + && arm_current_el(env) == 0 | ||
58 | + && (env->cp15.c9_pmuserenr & (1 << 1)) != 0 | ||
59 | + && !isread) { | ||
60 | + return CP_ACCESS_OK; | ||
61 | + } | ||
62 | + | ||
63 | + return pmreg_access(env, ri, isread); | ||
64 | +} | ||
65 | + | ||
66 | #ifndef CONFIG_USER_ONLY | ||
67 | |||
68 | +static CPAccessResult pmreg_access_selr(CPUARMState *env, | ||
69 | + const ARMCPRegInfo *ri, | ||
70 | + bool isread) | ||
71 | +{ | ||
72 | + /* ER: event counter read trap control */ | ||
73 | + if (arm_feature(env, ARM_FEATURE_V8) | ||
74 | + && arm_current_el(env) == 0 | ||
75 | + && (env->cp15.c9_pmuserenr & (1 << 3)) != 0) { | ||
76 | + return CP_ACCESS_OK; | ||
77 | + } | ||
78 | + | ||
79 | + return pmreg_access(env, ri, isread); | ||
80 | +} | ||
81 | + | ||
82 | +static CPAccessResult pmreg_access_ccntr(CPUARMState *env, | ||
83 | + const ARMCPRegInfo *ri, | ||
84 | + bool isread) | ||
85 | +{ | ||
86 | + /* CR: cycle counter read trap control */ | ||
87 | + if (arm_feature(env, ARM_FEATURE_V8) | ||
88 | + && arm_current_el(env) == 0 | ||
89 | + && (env->cp15.c9_pmuserenr & (1 << 2)) != 0 | ||
90 | + && isread) { | ||
91 | + return CP_ACCESS_OK; | ||
92 | + } | ||
93 | + | ||
94 | + return pmreg_access(env, ri, isread); | ||
95 | +} | ||
96 | + | ||
97 | static inline bool arm_ccnt_enabled(CPUARMState *env) | ||
98 | { | ||
99 | /* This does not support checking PMCCFILTR_EL0 register */ | ||
100 | @@ -XXX,XX +XXX,XX @@ static uint64_t pmxevtyper_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
101 | static void pmuserenr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
102 | uint64_t value) | ||
103 | { | ||
104 | - env->cp15.c9_pmuserenr = value & 1; | ||
105 | + if (arm_feature(env, ARM_FEATURE_V8)) { | ||
106 | + env->cp15.c9_pmuserenr = value & 0xf; | ||
107 | + } else { | ||
108 | + env->cp15.c9_pmuserenr = value & 1; | ||
109 | + } | ||
110 | } | ||
111 | |||
112 | static void pmintenset_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
113 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
114 | .raw_writefn = raw_write }, | ||
115 | /* Unimplemented so WI. */ | ||
116 | { .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4, | ||
117 | - .access = PL0_W, .accessfn = pmreg_access, .type = ARM_CP_NOP }, | ||
118 | + .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NOP }, | ||
119 | #ifndef CONFIG_USER_ONLY | ||
120 | { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, | ||
121 | .access = PL0_RW, .type = ARM_CP_ALIAS, | ||
122 | .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr), | ||
123 | - .accessfn = pmreg_access, .writefn = pmselr_write, | ||
124 | + .accessfn = pmreg_access_selr, .writefn = pmselr_write, | ||
125 | .raw_writefn = raw_write}, | ||
126 | { .name = "PMSELR_EL0", .state = ARM_CP_STATE_AA64, | ||
127 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 5, | ||
128 | - .access = PL0_RW, .accessfn = pmreg_access, | ||
129 | + .access = PL0_RW, .accessfn = pmreg_access_selr, | ||
130 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmselr), | ||
131 | .writefn = pmselr_write, .raw_writefn = raw_write, }, | ||
132 | { .name = "PMCCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 0, | ||
133 | .access = PL0_RW, .resetvalue = 0, .type = ARM_CP_IO, | ||
134 | .readfn = pmccntr_read, .writefn = pmccntr_write32, | ||
135 | - .accessfn = pmreg_access }, | ||
136 | + .accessfn = pmreg_access_ccntr }, | ||
137 | { .name = "PMCCNTR_EL0", .state = ARM_CP_STATE_AA64, | ||
138 | .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 0, | ||
139 | - .access = PL0_RW, .accessfn = pmreg_access, | ||
140 | + .access = PL0_RW, .accessfn = pmreg_access_ccntr, | ||
141 | .type = ARM_CP_IO, | ||
142 | .readfn = pmccntr_read, .writefn = pmccntr_write, }, | ||
143 | #endif | ||
144 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
145 | /* Unimplemented, RAZ/WI. */ | ||
146 | { .name = "PMXEVCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 2, | ||
147 | .access = PL0_RW, .type = ARM_CP_CONST, .resetvalue = 0, | ||
148 | - .accessfn = pmreg_access }, | ||
149 | + .accessfn = pmreg_access_xevcntr }, | ||
150 | { .name = "PMUSERENR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 0, | ||
151 | .access = PL0_R | PL1_RW, .accessfn = access_tpm, | ||
152 | .fieldoffset = offsetof(CPUARMState, cp15.c9_pmuserenr), | ||
153 | -- | 26 | -- |
154 | 2.7.4 | 27 | 2.34.1 |
155 | |||
156 | diff view generated by jsdifflib |