thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/0022-tcg-workaround-branch-instruction-overflow-in-tcg_ou.patch

26ba25
From 3319e2fd5b151695f30f8574bbd9250f86a96e16 Mon Sep 17 00:00:00 2001
26ba25
From: Laurent Vivier <lvivier@redhat.com>
26ba25
Date: Thu, 3 May 2018 14:59:08 +0100
26ba25
Subject: tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st
26ba25
26ba25
RH-Author: Laurent Vivier <lvivier@redhat.com>
26ba25
Message-id: <20180503145908.8110-1-lvivier@redhat.com>
26ba25
Patchwork-id: 80019
26ba25
O-Subject: [qemu-kvm RHEL8/virt212 PATCH] tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st
26ba25
Bugzilla: 1571145
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
RH-Acked-by: Serhii Popovych <spopovyc@redhat.com>
26ba25
RH-Acked-by: David Gibson <dgibson@redhat.com>
26ba25
26ba25
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1571145
26ba25
BRANCH:rhel8/master-2.12.0
26ba25
UPSTREAM: https://github.com/qemu/qemu/commit/6001f7729e12dd1d810291e4cbf83cee8e07441d
26ba25
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=15973114
26ba25
26ba25
ppc64 uses a BC instruction to call the tcg_out_qemu_ld/st
26ba25
slow path. BC instruction uses a relative address encoded
26ba25
on 14 bits.
26ba25
26ba25
The slow path functions are added at the end of the generated
26ba25
instructions buffer, in the reverse order of the callers.
26ba25
So more we have slow path functions more the distance between
26ba25
the caller (BC) and the function increases.
26ba25
26ba25
This patch changes the behavior to generate the functions in
26ba25
the same order of the callers.
26ba25
26ba25
Cc: qemu-stable@nongnu.org
26ba25
Fixes: 15fa08f845 ("tcg: Dynamically allocate TCGOps")
26ba25
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
26ba25
Message-Id: <20180429235840.16659-1-lvivier@redhat.com>
26ba25
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
26ba25
(cherry picked from commit 6001f7729e12dd1d810291e4cbf83cee8e07441d)
26ba25
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 tcg/tcg-ldst.inc.c | 8 ++++----
26ba25
 tcg/tcg.c          | 2 +-
26ba25
 tcg/tcg.h          | 2 +-
26ba25
 3 files changed, 6 insertions(+), 6 deletions(-)
26ba25
26ba25
diff --git a/tcg/tcg-ldst.inc.c b/tcg/tcg-ldst.inc.c
26ba25
index 0e14cf4..47f41b9 100644
26ba25
--- a/tcg/tcg-ldst.inc.c
26ba25
+++ b/tcg/tcg-ldst.inc.c
26ba25
@@ -30,7 +30,7 @@ typedef struct TCGLabelQemuLdst {
26ba25
     TCGReg datahi_reg;      /* reg index for high word to be loaded or stored */
26ba25
     tcg_insn_unit *raddr;   /* gen code addr of the next IR of qemu_ld/st IR */
26ba25
     tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */
26ba25
-    struct TCGLabelQemuLdst *next;
26ba25
+    QSIMPLEQ_ENTRY(TCGLabelQemuLdst) next;
26ba25
 } TCGLabelQemuLdst;
26ba25
 
26ba25
 
26ba25
@@ -46,7 +46,7 @@ static bool tcg_out_ldst_finalize(TCGContext *s)
26ba25
     TCGLabelQemuLdst *lb;
26ba25
 
26ba25
     /* qemu_ld/st slow paths */
26ba25
-    for (lb = s->ldst_labels; lb != NULL; lb = lb->next) {
26ba25
+    QSIMPLEQ_FOREACH(lb, &s->ldst_labels, next) {
26ba25
         if (lb->is_ld) {
26ba25
             tcg_out_qemu_ld_slow_path(s, lb);
26ba25
         } else {
26ba25
@@ -72,7 +72,7 @@ static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s)
26ba25
 {
26ba25
     TCGLabelQemuLdst *l = tcg_malloc(sizeof(*l));
26ba25
 
26ba25
-    l->next = s->ldst_labels;
26ba25
-    s->ldst_labels = l;
26ba25
+    QSIMPLEQ_INSERT_TAIL(&s->ldst_labels, l, next);
26ba25
+
26ba25
     return l;
26ba25
 }
26ba25
diff --git a/tcg/tcg.c b/tcg/tcg.c
26ba25
index bb24526..b84850b 100644
26ba25
--- a/tcg/tcg.c
26ba25
+++ b/tcg/tcg.c
26ba25
@@ -3324,7 +3324,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
26ba25
     s->code_ptr = tb->tc.ptr;
26ba25
 
26ba25
 #ifdef TCG_TARGET_NEED_LDST_LABELS
26ba25
-    s->ldst_labels = NULL;
26ba25
+    QSIMPLEQ_INIT(&s->ldst_labels);
26ba25
 #endif
26ba25
 #ifdef TCG_TARGET_NEED_POOL_LABELS
26ba25
     s->pool_labels = NULL;
26ba25
diff --git a/tcg/tcg.h b/tcg/tcg.h
26ba25
index 30896ca..a3076c5 100644
26ba25
--- a/tcg/tcg.h
26ba25
+++ b/tcg/tcg.h
26ba25
@@ -699,7 +699,7 @@ struct TCGContext {
26ba25
 
26ba25
     /* These structures are private to tcg-target.inc.c.  */
26ba25
 #ifdef TCG_TARGET_NEED_LDST_LABELS
26ba25
-    struct TCGLabelQemuLdst *ldst_labels;
26ba25
+    QSIMPLEQ_HEAD(ldst_labels, TCGLabelQemuLdst) ldst_labels;
26ba25
 #endif
26ba25
 #ifdef TCG_TARGET_NEED_POOL_LABELS
26ba25
     struct TCGLabelPoolData *pool_labels;
26ba25
-- 
26ba25
1.8.3.1
26ba25