summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-05-04 12:14:45 +0100
committerSteve Sakoman <steve@sakoman.com>2023-05-10 04:16:51 -1000
commiteb319d974c6d9583d7962cf0bd18be2a3ed885fc (patch)
tree3249d31cbc17de2e1a31719e9bbd940c98757f6b
parentb8e4efae7f5f20a92c5e9b8eeccc4e537b4d401d (diff)
downloadpoky-eb319d974c6d9583d7962cf0bd18be2a3ed885fc.tar.gz
qemu: Add fix for powerpc instruction fallback issue
See the patch for more details, fixes a regression in qemu causing illegal instructions in libm on powerpc, triggered by a libinput upgrade. https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=f1c56cdff09f650ad721fae026eb6a3651631f3d was the glibc code generating the instruction and triggering the issue. (From OE-Core rev: 6a19b4a5f6eb7138ec6e79acf5c85c5d38f22d8f) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-devtools/qemu/qemu.inc1
-rw-r--r--meta/recipes-devtools/qemu/qemu/ppc.patch70
2 files changed, 71 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc
index e2453dd8bc..29bc34d743 100644
--- a/meta/recipes-devtools/qemu/qemu.inc
+++ b/meta/recipes-devtools/qemu/qemu.inc
@@ -35,6 +35,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
35 file://0001-tracetool-use-relative-paths-for-line-preprocessor-d.patch \ 35 file://0001-tracetool-use-relative-paths-for-line-preprocessor-d.patch \
36 file://qemu-guest-agent.init \ 36 file://qemu-guest-agent.init \
37 file://qemu-guest-agent.udev \ 37 file://qemu-guest-agent.udev \
38 file://ppc.patch \
38 " 39 "
39UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar" 40UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
40 41
diff --git a/meta/recipes-devtools/qemu/qemu/ppc.patch b/meta/recipes-devtools/qemu/qemu/ppc.patch
new file mode 100644
index 0000000000..395cdb814f
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/ppc.patch
@@ -0,0 +1,70 @@
1target/ppc: Fix fallback to MFSS for MFFSCRN, MFFSCRNI, MFFSCE and MFFSL
2
3The following commits changed the code such that these instructions became invalid
4on pre 3.0 ISAs:
5
6 bf8adfd88b547680aa857c46098f3a1e94373160 - target/ppc: Move mffscrn[i] to decodetree
7 394c2e2fda70da722f20fb60412d6c0ca4bfaa03 - target/ppc: Move mffsce to decodetree
8 3e5bce70efe6bd1f684efbb21fd2a316cbf0657e - target/ppc: Move mffsl to decodetree
9
10The hardware will handle them as a MFFS instruction as the code did previously.
11Restore that behaviour. This means applications that were segfaulting under qemu
12when encountering these instructions now operate correctly. The instruction
13is used in glibc libm functions for example.
14
15Upstream-Status: Submitted [https://lore.kernel.org/qemu-devel/20230504110150.3044402-1-richard.purdie@linuxfoundation.org/]
16
17Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
18
19Index: qemu-8.0.0/target/ppc/translate/fp-impl.c.inc
20===================================================================
21--- qemu-8.0.0.orig/target/ppc/translate/fp-impl.c.inc
22+++ qemu-8.0.0/target/ppc/translate/fp-impl.c.inc
23@@ -584,7 +584,10 @@ static bool trans_MFFSCE(DisasContext *c
24 {
25 TCGv_i64 fpscr;
26
27- REQUIRE_INSNS_FLAGS2(ctx, ISA300);
28+ if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) {
29+ return trans_MFFS(ctx, a);
30+ }
31+
32 REQUIRE_FPU(ctx);
33
34 gen_reset_fpstatus();
35@@ -597,7 +600,10 @@ static bool trans_MFFSCRN(DisasContext *
36 {
37 TCGv_i64 t1, fpscr;
38
39- REQUIRE_INSNS_FLAGS2(ctx, ISA300);
40+ if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) {
41+ return trans_MFFS(ctx, a);
42+ }
43+
44 REQUIRE_FPU(ctx);
45
46 t1 = tcg_temp_new_i64();
47@@ -631,7 +637,10 @@ static bool trans_MFFSCRNI(DisasContext
48 {
49 TCGv_i64 t1, fpscr;
50
51- REQUIRE_INSNS_FLAGS2(ctx, ISA300);
52+ if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) {
53+ return trans_MFFS(ctx, a);
54+ }
55+
56 REQUIRE_FPU(ctx);
57
58 t1 = tcg_temp_new_i64();
59@@ -661,7 +670,10 @@ static bool trans_MFFSCDRNI(DisasContext
60 {
61 TCGv_i64 fpscr;
62
63- REQUIRE_INSNS_FLAGS2(ctx, ISA300);
64+ if (unlikely(!(ctx->insns_flags2 & PPC2_ISA300))) {
65+ return trans_MFFS(ctx, a);
66+ }
67+
68 REQUIRE_FPU(ctx);
69
70 gen_reset_fpstatus();