1
Small target-arm queue for 2.9: just the patches
1
Only thing for Arm for rc1 is RTH's fix for the KVM SVE probe code.
2
which fix bugs in our MRS/MSR decoding for M profile,
3
including a fix for a regression introduced in commit
4
58117c9bb429cd.
5
2
6
thanks
7
-- PMM
3
-- PMM
8
4
9
The following changes since commit 00e7c07b06d004cf54b19724f82afde8a7a37f37:
5
The following changes since commit 4e06b3fc1b5e1ec03f22190eabe56891dc9c2236:
10
6
11
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20170320' into staging (2017-03-20 10:51:30 +0000)
7
Merge tag 'pull-hex-20220731' of https://github.com/quic/qemu into staging (2022-07-31 21:38:54 -0700)
12
8
13
are available in the git repository at:
9
are available in the Git repository at:
14
10
15
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170320
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220801
16
12
17
for you to fetch changes up to b28b3377d7e9ba35611d454d5a63ef50cab1f8c5:
13
for you to fetch changes up to 5265d24c981dfdda8d29b44f7e84a514da75eedc:
18
14
19
arm: Fix APSR writes via M profile MSR (2017-03-20 12:41:44 +0000)
15
target/arm: Move sve probe inside kvm >= 4.15 branch (2022-08-01 16:21:18 +0100)
20
16
21
----------------------------------------------------------------
17
----------------------------------------------------------------
22
target-arm queue:
18
target-arm queue:
23
* fix MSR/MRS decoding for M profile CPUs
19
* Fix KVM SVE ID register probe code
24
20
25
----------------------------------------------------------------
21
----------------------------------------------------------------
26
Peter Maydell (4):
22
Richard Henderson (3):
27
arm: HVC and SMC encodings don't exist for M profile
23
target/arm: Use kvm_arm_sve_supported in kvm_arm_get_host_cpu_features
28
arm: Don't decode MRS(banked) or MSR(banked) for M profile
24
target/arm: Set KVM_ARM_VCPU_SVE while probing the host
29
arm: Enforce should-be-1 bits in MRS decoding
25
target/arm: Move sve probe inside kvm >= 4.15 branch
30
arm: Fix APSR writes via M profile MSR
31
26
32
target/arm/helper.c | 26 ++++++++++++++++++++++----
27
target/arm/kvm64.c | 45 ++++++++++++++++++++++-----------------------
33
target/arm/translate.c | 26 +++++++++++++++++++++++---
28
1 file changed, 22 insertions(+), 23 deletions(-)
34
2 files changed, 45 insertions(+), 7 deletions(-)
35
diff view generated by jsdifflib
Deleted patch
1
M profile doesn't have the HVC or SMC encodings, so make them always
2
UNDEF rather than generating calls to helper functions that assume
3
A/R profile.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Message-id: 1487616072-9226-2-git-send-email-peter.maydell@linaro.org
8
---
9
target/arm/translate.c | 3 +++
10
1 file changed, 3 insertions(+)
11
12
diff --git a/target/arm/translate.c b/target/arm/translate.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/translate.c
15
+++ b/target/arm/translate.c
16
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
17
goto illegal_op;
18
19
if (insn & (1 << 26)) {
20
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
21
+ goto illegal_op;
22
+ }
23
if (!(insn & (1 << 20))) {
24
/* Hypervisor call (v7) */
25
int imm16 = extract32(insn, 16, 4) << 12
26
--
27
2.7.4
28
29
diff view generated by jsdifflib
1
Our implementation of writes to the APSR for M-profile via the MSR
1
From: Richard Henderson <richard.henderson@linaro.org>
2
instruction was badly broken.
3
2
4
First and worst, we had the sense wrong on the test of bit 2 of the
3
Indication for support for SVE will not depend on whether we
5
SYSm field -- this is supposed to request an APSR write if bit 2 is 0
4
perform the query on the main kvm_state or the temp vcpu.
6
but we were doing it if bit 2 was 1. This bug was introduced in
7
commit 58117c9bb429cd, so hasn't been in a QEMU release.
8
5
9
Secondly, the choice of exactly which parts of APSR should be written
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
is defined by bits in the 'mask' field. We were not passing these
7
Message-id: 20220726045828.53697-2-richard.henderson@linaro.org
11
through from instruction decode, making it impossible to check them
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
in the helper.
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/kvm64.c | 2 +-
12
1 file changed, 1 insertion(+), 1 deletion(-)
13
13
14
Pass the mask bits through from the instruction decode to the helper
14
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
15
function and process them appropriately; fix the wrong sense of the
16
SYSm bit 2 check.
17
18
Invalid mask values and invalid combinations of mask and register
19
number are UNPREDICTABLE; we choose to treat them as if the mask
20
values were valid.
21
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Message-id: 1487616072-9226-5-git-send-email-peter.maydell@linaro.org
24
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
25
---
26
target/arm/helper.c | 26 ++++++++++++++++++++++----
27
target/arm/translate.c | 3 ++-
28
2 files changed, 24 insertions(+), 5 deletions(-)
29
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
31
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/helper.c
16
--- a/target/arm/kvm64.c
33
+++ b/target/arm/helper.c
17
+++ b/target/arm/kvm64.c
34
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
18
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
19
}
35
}
20
}
36
}
21
37
22
- sve_supported = ioctl(fdarray[0], KVM_CHECK_EXTENSION, KVM_CAP_ARM_SVE) > 0;
38
-void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val)
23
+ sve_supported = kvm_arm_sve_supported();
39
-{
24
40
+void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
25
/* Add feature bits that can't appear until after VCPU init. */
41
+{
26
if (sve_supported) {
42
+ /* We're passed bits [11..0] of the instruction; extract
43
+ * SYSm and the mask bits.
44
+ * Invalid combinations of SYSm and mask are UNPREDICTABLE;
45
+ * we choose to treat them as if the mask bits were valid.
46
+ * NB that the pseudocode 'mask' variable is bits [11..10],
47
+ * whereas ours is [11..8].
48
+ */
49
+ uint32_t mask = extract32(maskreg, 8, 4);
50
+ uint32_t reg = extract32(maskreg, 0, 8);
51
+
52
if (arm_current_el(env) == 0 && reg > 7) {
53
/* only xPSR sub-fields may be written by unprivileged */
54
return;
55
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val)
56
switch (reg) {
57
case 0 ... 7: /* xPSR sub-fields */
58
/* only APSR is actually writable */
59
- if (reg & 4) {
60
- xpsr_write(env, val, 0xf8000000); /* APSR */
61
+ if (!(reg & 4)) {
62
+ uint32_t apsrmask = 0;
63
+
64
+ if (mask & 8) {
65
+ apsrmask |= 0xf8000000; /* APSR NZCVQ */
66
+ }
67
+ if ((mask & 4) && arm_feature(env, ARM_FEATURE_THUMB_DSP)) {
68
+ apsrmask |= 0x000f0000; /* APSR GE[3:0] */
69
+ }
70
+ xpsr_write(env, val, apsrmask);
71
}
72
break;
73
case 8: /* MSP */
74
diff --git a/target/arm/translate.c b/target/arm/translate.c
75
index XXXXXXX..XXXXXXX 100644
76
--- a/target/arm/translate.c
77
+++ b/target/arm/translate.c
78
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
79
case 0: /* msr cpsr. */
80
if (arm_dc_feature(s, ARM_FEATURE_M)) {
81
tmp = load_reg(s, rn);
82
- addr = tcg_const_i32(insn & 0xff);
83
+ /* the constant is the mask and SYSm fields */
84
+ addr = tcg_const_i32(insn & 0xfff);
85
gen_helper_v7m_msr(cpu_env, addr, tmp);
86
tcg_temp_free_i32(addr);
87
tcg_temp_free_i32(tmp);
88
--
27
--
89
2.7.4
28
2.25.1
90
91
diff view generated by jsdifflib
1
The MRS instruction requires that bits [19..16] are all 1s, and for
1
From: Richard Henderson <richard.henderson@linaro.org>
2
A/R profile also that bits [7..0] are all 0s. At this point in the
3
decode tree we have checked all of the rest of the instruction but
4
were allowing these to be any value. If these bits are not set then
5
the result is architecturally UNPREDICTABLE, but choosing to UNDEF is
6
more helpful to the user and avoids unexpected odd behaviour if the
7
encodings are used for some purpose in future architecture versions.
8
2
3
Because we weren't setting this flag, our probe of ID_AA64ZFR0
4
was always returning zero. This also obviates the adjustment
5
of ID_AA64PFR0, which had sanitized the SVE field.
6
7
The effects of the bug are not visible, because the only thing that
8
ID_AA64ZFR0 is used for within qemu at present is tcg translation.
9
The other tests for SVE within KVM are via ID_AA64PFR0.SVE.
10
11
Reported-by: Zenghui Yu <yuzenghui@huawei.com>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20220726045828.53697-3-richard.henderson@linaro.org
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Message-id: 1487616072-9226-4-git-send-email-peter.maydell@linaro.org
12
---
16
---
13
target/arm/translate.c | 14 ++++++++++++++
17
target/arm/kvm64.c | 27 +++++++++++++--------------
14
1 file changed, 14 insertions(+)
18
1 file changed, 13 insertions(+), 14 deletions(-)
15
19
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
20
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
17
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
22
--- a/target/arm/kvm64.c
19
+++ b/target/arm/translate.c
23
+++ b/target/arm/kvm64.c
20
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
24
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
21
break;
25
bool sve_supported;
22
}
26
bool pmu_supported = false;
23
27
uint64_t features = 0;
24
+ if (extract32(insn, 16, 4) != 0xf) {
28
- uint64_t t;
25
+ goto illegal_op;
29
int err;
26
+ }
30
27
+ if (!arm_dc_feature(s, ARM_FEATURE_M) &&
31
/* Old kernels may not know about the PREFERRED_TARGET ioctl: however
28
+ extract32(insn, 0, 8) != 0) {
32
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
29
+ goto illegal_op;
33
struct kvm_vcpu_init init = { .target = -1, };
30
+ }
34
35
/*
36
- * Ask for Pointer Authentication if supported. We can't play the
37
- * SVE trick of synthesising the ID reg as KVM won't tell us
38
- * whether we have the architected or IMPDEF version of PAuth, so
39
- * we have to use the actual ID regs.
40
+ * Ask for SVE if supported, so that we can query ID_AA64ZFR0,
41
+ * which is otherwise RAZ.
42
+ */
43
+ sve_supported = kvm_arm_sve_supported();
44
+ if (sve_supported) {
45
+ init.features[0] |= 1 << KVM_ARM_VCPU_SVE;
46
+ }
31
+
47
+
32
/* mrs cpsr */
48
+ /*
33
tmp = tcg_temp_new_i32();
49
+ * Ask for Pointer Authentication if supported, so that we get
34
if (arm_dc_feature(s, ARM_FEATURE_M)) {
50
+ * the unsanitized field values for AA64ISAR1_EL1.
35
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
51
*/
36
if (IS_USER(s) || arm_dc_feature(s, ARM_FEATURE_M)) {
52
if (kvm_arm_pauth_supported()) {
37
goto illegal_op;
53
init.features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
38
}
54
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
39
+
55
}
40
+ if (extract32(insn, 16, 4) != 0xf ||
56
}
41
+ extract32(insn, 0, 8) != 0) {
57
42
+ goto illegal_op;
58
- sve_supported = kvm_arm_sve_supported();
43
+ }
59
-
44
+
60
- /* Add feature bits that can't appear until after VCPU init. */
45
tmp = load_cpu_field(spsr);
61
if (sve_supported) {
46
store_reg(s, rd, tmp);
62
- t = ahcf->isar.id_aa64pfr0;
47
break;
63
- t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
64
- ahcf->isar.id_aa64pfr0 = t;
65
-
66
/*
67
* There is a range of kernels between kernel commit 73433762fcae
68
* and f81cb2c3ad41 which have a bug where the kernel doesn't expose
69
* SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM has enabled
70
- * SVE support, so we only read it here, rather than together with all
71
- * the other ID registers earlier.
72
+ * SVE support, which resulted in an error rather than RAZ.
73
+ * So only read the register if we set KVM_ARM_VCPU_SVE above.
74
*/
75
err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0,
76
ARM64_SYS_REG(3, 0, 0, 4, 4));
48
--
77
--
49
2.7.4
78
2.25.1
50
51
diff view generated by jsdifflib
1
M profile doesn't have the MSR(banked) and MRS(banked) instructions
1
From: Richard Henderson <richard.henderson@linaro.org>
2
and uses the encodings for different kinds of M-profile MRS/MSR.
3
Guard the relevant bits of the decode logic to make sure we don't
4
accidentally fall into them by accident on M-profile.
5
2
6
(The bit being checked for this (bit 5) is part of the SYSm field on
3
The test for the IF block indicates no ID registers are exposed, much
7
M-profile, but since no currently allocated system registers have
4
less host support for SVE. Move the SVE probe into the ELSE block.
8
encodings with bit 5 of SYSm set, this hasn't been a problem in
9
practice.)
10
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220726045828.53697-4-richard.henderson@linaro.org
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Message-id: 1487616072-9226-3-git-send-email-peter.maydell@linaro.org
14
---
10
---
15
target/arm/translate.c | 6 ++++--
11
target/arm/kvm64.c | 22 +++++++++++-----------
16
1 file changed, 4 insertions(+), 2 deletions(-)
12
1 file changed, 11 insertions(+), 11 deletions(-)
17
13
18
diff --git a/target/arm/translate.c b/target/arm/translate.c
14
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
19
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate.c
16
--- a/target/arm/kvm64.c
21
+++ b/target/arm/translate.c
17
+++ b/target/arm/kvm64.c
22
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
18
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
23
gen_exception_return(s, tmp);
19
err |= read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0,
24
break;
20
ARM64_SYS_REG(3, 3, 9, 12, 0));
25
case 6: /* MRS */
21
}
26
- if (extract32(insn, 5, 1)) {
22
- }
27
+ if (extract32(insn, 5, 1) &&
23
28
+ !arm_dc_feature(s, ARM_FEATURE_M)) {
24
- if (sve_supported) {
29
/* MRS (banked) */
25
- /*
30
int sysm = extract32(insn, 16, 4) |
26
- * There is a range of kernels between kernel commit 73433762fcae
31
(extract32(insn, 4, 1) << 4);
27
- * and f81cb2c3ad41 which have a bug where the kernel doesn't expose
32
@@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw
28
- * SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM has enabled
33
store_reg(s, rd, tmp);
29
- * SVE support, which resulted in an error rather than RAZ.
34
break;
30
- * So only read the register if we set KVM_ARM_VCPU_SVE above.
35
case 7: /* MRS */
31
- */
36
- if (extract32(insn, 5, 1)) {
32
- err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0,
37
+ if (extract32(insn, 5, 1) &&
33
- ARM64_SYS_REG(3, 0, 0, 4, 4));
38
+ !arm_dc_feature(s, ARM_FEATURE_M)) {
34
+ if (sve_supported) {
39
/* MRS (banked) */
35
+ /*
40
int sysm = extract32(insn, 16, 4) |
36
+ * There is a range of kernels between kernel commit 73433762fcae
41
(extract32(insn, 4, 1) << 4);
37
+ * and f81cb2c3ad41 which have a bug where the kernel doesn't
38
+ * expose SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM has
39
+ * enabled SVE support, which resulted in an error rather than RAZ.
40
+ * So only read the register if we set KVM_ARM_VCPU_SVE above.
41
+ */
42
+ err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0,
43
+ ARM64_SYS_REG(3, 0, 0, 4, 4));
44
+ }
45
}
46
47
kvm_arm_destroy_scratch_host_vcpu(fdarray);
42
--
48
--
43
2.7.4
49
2.25.1
44
45
diff view generated by jsdifflib