From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, aurelien@aurel32.net
Subject: [Qemu-devel] [PULL 4/4] tcg/ppc: Allow a 32-bit offset to the constant pool
Date: Fri, 12 Jan 2018 13:06:13 -0800 [thread overview]
Message-ID: <20180112210613.14124-5-richard.henderson@linaro.org> (raw)
In-Reply-To: <20180112210613.14124-1-richard.henderson@linaro.org>
We recently relaxed the limit of the number of opcodes that can
appear in a TranslationBlock. In certain cases this has resulted
in relocation overflow.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/ppc/tcg-target.inc.c | 67 ++++++++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 28 deletions(-)
diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
index 74f9b4aa34..86f7de5f7e 100644
--- a/tcg/ppc/tcg-target.inc.c
+++ b/tcg/ppc/tcg-target.inc.c
@@ -222,33 +222,6 @@ static inline void tcg_out_bc_noaddr(TCGContext *s, int insn)
tcg_out32(s, insn | retrans);
}
-static void patch_reloc(tcg_insn_unit *code_ptr, int type,
- intptr_t value, intptr_t addend)
-{
- tcg_insn_unit *target;
- tcg_insn_unit old;
-
- value += addend;
- target = (tcg_insn_unit *)value;
-
- switch (type) {
- case R_PPC_REL14:
- reloc_pc14(code_ptr, target);
- break;
- case R_PPC_REL24:
- reloc_pc24(code_ptr, target);
- break;
- case R_PPC_ADDR16:
- assert(value == (int16_t)value);
- old = *code_ptr;
- old = deposit32(old, 0, 16, value);
- *code_ptr = old;
- break;
- default:
- tcg_abort();
- }
-}
-
/* parse target specific constraints */
static const char *target_parse_constraint(TCGArgConstraint *ct,
const char *ct_str, TCGType type)
@@ -552,6 +525,43 @@ static const uint32_t tcg_to_isel[] = {
[TCG_COND_GTU] = ISEL | BC_(7, CR_GT),
};
+static void patch_reloc(tcg_insn_unit *code_ptr, int type,
+ intptr_t value, intptr_t addend)
+{
+ tcg_insn_unit *target;
+ tcg_insn_unit old;
+
+ value += addend;
+ target = (tcg_insn_unit *)value;
+
+ switch (type) {
+ case R_PPC_REL14:
+ reloc_pc14(code_ptr, target);
+ break;
+ case R_PPC_REL24:
+ reloc_pc24(code_ptr, target);
+ break;
+ case R_PPC_ADDR16:
+ /* We are abusing this relocation type. This points to a pair
+ of insns, addis + load. If the displacement is small, we
+ can nop out the addis. */
+ if (value == (int16_t)value) {
+ code_ptr[0] = NOP;
+ old = deposit32(code_ptr[1], 0, 16, value);
+ code_ptr[1] = deposit32(old, 16, 5, TCG_REG_TB);
+ } else {
+ int16_t lo = value;
+ int hi = value - lo;
+ assert(hi + lo == value);
+ code_ptr[0] = deposit32(code_ptr[0], 0, 16, hi >> 16);
+ code_ptr[1] = deposit32(code_ptr[1], 0, 16, lo);
+ }
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt,
TCGReg base, tcg_target_long offset);
@@ -690,7 +700,8 @@ static void tcg_out_movi_int(TCGContext *s, TCGType type, TCGReg ret,
if (!in_prologue && USE_REG_TB) {
new_pool_label(s, arg, R_PPC_ADDR16, s->code_ptr,
-(intptr_t)s->code_gen_ptr);
- tcg_out32(s, LD | TAI(ret, TCG_REG_TB, 0));
+ tcg_out32(s, ADDIS | TAI(ret, TCG_REG_TB, 0));
+ tcg_out32(s, LD | TAI(ret, ret, 0));
return;
}
--
2.14.3
next prev parent reply other threads:[~2018-01-12 21:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 21:06 [Qemu-devel] [PULL 0/4] TCG queued patches Richard Henderson
2018-01-12 21:06 ` [Qemu-devel] [PULL 1/4] tcg/arm: Fix double-word comparisons Richard Henderson
2018-01-12 21:06 ` [Qemu-devel] [PULL 2/4] tcg/arm: Support tlb offsets larger than 64k Richard Henderson
2018-01-12 21:06 ` [Qemu-devel] [PULL 3/4] tcg/ppc: " Richard Henderson
2018-01-12 21:06 ` Richard Henderson [this message]
2018-01-12 21:42 ` [Qemu-devel] [PULL 0/4] TCG queued patches Aurelien Jarno
2018-01-15 10:08 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180112210613.14124-5-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=aurelien@aurel32.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).