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

1bdc94
From 1ef4307f6e1299d337bc925ea7bbea41c2f99706 Mon Sep 17 00:00:00 2001
1bdc94
From: Laurent Vivier <lvivier@redhat.com>
1bdc94
Date: Fri, 4 May 2018 09:38:55 +0200
1bdc94
Subject: [PATCH 06/13] tcg: workaround branch instruction overflow in
1bdc94
 tcg_out_qemu_ld/st
1bdc94
1bdc94
RH-Author: Laurent Vivier <lvivier@redhat.com>
1bdc94
Message-id: <20180504093855.30922-1-lvivier@redhat.com>
1bdc94
Patchwork-id: 80025
1bdc94
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH] tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st
1bdc94
Bugzilla: 1574577
1bdc94
RH-Acked-by: Serhii Popovych <spopovyc@redhat.com>
1bdc94
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
1bdc94
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
1bdc94
ppc64 uses a BC instruction to call the tcg_out_qemu_ld/st
1bdc94
slow path. BC instruction uses a relative address encoded
1bdc94
on 14 bits.
1bdc94
1bdc94
The slow path functions are added at the end of the generated
1bdc94
instructions buffer, in the reverse order of the callers.
1bdc94
So more we have slow path functions more the distance between
1bdc94
the caller (BC) and the function increases.
1bdc94
1bdc94
This patch changes the behavior to generate the functions in
1bdc94
the same order of the callers.
1bdc94
1bdc94
Cc: qemu-stable@nongnu.org
1bdc94
Fixes: 15fa08f845 ("tcg: Dynamically allocate TCGOps")
1bdc94
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
1bdc94
Message-Id: <20180429235840.16659-1-lvivier@redhat.com>
1bdc94
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
1bdc94
(cherry picked from commit 6001f7729e12dd1d810291e4cbf83cee8e07441d)
1bdc94
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 tcg/tcg-ldst.inc.c | 8 ++++----
1bdc94
 tcg/tcg.c          | 2 +-
1bdc94
 tcg/tcg.h          | 2 +-
1bdc94
 3 files changed, 6 insertions(+), 6 deletions(-)
1bdc94
1bdc94
diff --git a/tcg/tcg-ldst.inc.c b/tcg/tcg-ldst.inc.c
1bdc94
index 0e14cf4..47f41b9 100644
1bdc94
--- a/tcg/tcg-ldst.inc.c
1bdc94
+++ b/tcg/tcg-ldst.inc.c
1bdc94
@@ -30,7 +30,7 @@ typedef struct TCGLabelQemuLdst {
1bdc94
     TCGReg datahi_reg;      /* reg index for high word to be loaded or stored */
1bdc94
     tcg_insn_unit *raddr;   /* gen code addr of the next IR of qemu_ld/st IR */
1bdc94
     tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */
1bdc94
-    struct TCGLabelQemuLdst *next;
1bdc94
+    QSIMPLEQ_ENTRY(TCGLabelQemuLdst) next;
1bdc94
 } TCGLabelQemuLdst;
1bdc94
 
1bdc94
 
1bdc94
@@ -46,7 +46,7 @@ static bool tcg_out_ldst_finalize(TCGContext *s)
1bdc94
     TCGLabelQemuLdst *lb;
1bdc94
 
1bdc94
     /* qemu_ld/st slow paths */
1bdc94
-    for (lb = s->ldst_labels; lb != NULL; lb = lb->next) {
1bdc94
+    QSIMPLEQ_FOREACH(lb, &s->ldst_labels, next) {
1bdc94
         if (lb->is_ld) {
1bdc94
             tcg_out_qemu_ld_slow_path(s, lb);
1bdc94
         } else {
1bdc94
@@ -72,7 +72,7 @@ static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s)
1bdc94
 {
1bdc94
     TCGLabelQemuLdst *l = tcg_malloc(sizeof(*l));
1bdc94
 
1bdc94
-    l->next = s->ldst_labels;
1bdc94
-    s->ldst_labels = l;
1bdc94
+    QSIMPLEQ_INSERT_TAIL(&s->ldst_labels, l, next);
1bdc94
+
1bdc94
     return l;
1bdc94
 }
1bdc94
diff --git a/tcg/tcg.c b/tcg/tcg.c
1bdc94
index bb24526..b84850b 100644
1bdc94
--- a/tcg/tcg.c
1bdc94
+++ b/tcg/tcg.c
1bdc94
@@ -3324,7 +3324,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
1bdc94
     s->code_ptr = tb->tc.ptr;
1bdc94
 
1bdc94
 #ifdef TCG_TARGET_NEED_LDST_LABELS
1bdc94
-    s->ldst_labels = NULL;
1bdc94
+    QSIMPLEQ_INIT(&s->ldst_labels);
1bdc94
 #endif
1bdc94
 #ifdef TCG_TARGET_NEED_POOL_LABELS
1bdc94
     s->pool_labels = NULL;
1bdc94
diff --git a/tcg/tcg.h b/tcg/tcg.h
1bdc94
index 30896ca..a3076c5 100644
1bdc94
--- a/tcg/tcg.h
1bdc94
+++ b/tcg/tcg.h
1bdc94
@@ -699,7 +699,7 @@ struct TCGContext {
1bdc94
 
1bdc94
     /* These structures are private to tcg-target.inc.c.  */
1bdc94
 #ifdef TCG_TARGET_NEED_LDST_LABELS
1bdc94
-    struct TCGLabelQemuLdst *ldst_labels;
1bdc94
+    QSIMPLEQ_HEAD(ldst_labels, TCGLabelQemuLdst) ldst_labels;
1bdc94
 #endif
1bdc94
 #ifdef TCG_TARGET_NEED_POOL_LABELS
1bdc94
     struct TCGLabelPoolData *pool_labels;
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94