[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 86/88] target-xtensa: fix translation for opcodes cr
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 86/88] target-xtensa: fix translation for opcodes crossing page boundary |
Date: |
Thu, 8 Jan 2015 11:34:30 -0600 |
From: Max Filippov <address@hidden>
If TB ends with an opcode that crosses page boundary and the following
page is not executable then EPC1 for the code fetch exception wrongly
points at the beginning of the TB. Always treat instruction that crosses
page boundary as a separate TB.
Cc: address@hidden
Signed-off-by: Max Filippov <address@hidden>
(cherry picked from commit 01673a3401614b4199c9946ad47b97bedfc7a7c2)
Signed-off-by: Michael Roth <address@hidden>
---
target-xtensa/translate.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
index 2f22cce..ff7eb23 100644
--- a/target-xtensa/translate.c
+++ b/target-xtensa/translate.c
@@ -884,6 +884,11 @@ static TCGv_i32 gen_mac16_m(TCGv_i32 v, bool hi, bool
is_unsigned)
return m;
}
+static inline unsigned xtensa_op0_insn_len(unsigned op0)
+{
+ return op0 >= 8 ? 2 : 3;
+}
+
static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
{
#define HAS_OPTION_BITS(opt) do { \
@@ -986,6 +991,7 @@ static void disas_xtensa_insn(CPUXtensaState *env,
DisasContext *dc)
uint8_t b0 = cpu_ldub_code(env, dc->pc);
uint8_t b1 = cpu_ldub_code(env, dc->pc + 1);
uint8_t b2 = 0;
+ unsigned len = xtensa_op0_insn_len(OP0);
static const uint32_t B4CONST[] = {
0xffffffff, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
@@ -995,13 +1001,19 @@ static void disas_xtensa_insn(CPUXtensaState *env,
DisasContext *dc)
32768, 65536, 2, 3, 4, 5, 6, 7, 8, 10, 12, 16, 32, 64, 128, 256
};
- if (OP0 >= 8) {
- dc->next_pc = dc->pc + 2;
+ switch (len) {
+ case 2:
HAS_OPTION(XTENSA_OPTION_CODE_DENSITY);
- } else {
- dc->next_pc = dc->pc + 3;
+ break;
+
+ case 3:
b2 = cpu_ldub_code(env, dc->pc + 2);
+ break;
+
+ default:
+ RESERVED();
}
+ dc->next_pc = dc->pc + len;
switch (OP0) {
case 0: /*QRST*/
@@ -2946,6 +2958,12 @@ invalid_opcode:
#undef HAS_OPTION
}
+static inline unsigned xtensa_insn_len(CPUXtensaState *env, DisasContext *dc)
+{
+ uint8_t b0 = cpu_ldub_code(env, dc->pc);
+ return xtensa_op0_insn_len(OP0);
+}
+
static void check_breakpoint(CPUXtensaState *env, DisasContext *dc)
{
CPUState *cs = CPU(xtensa_env_get_cpu(env));
@@ -3078,6 +3096,7 @@ void gen_intermediate_code_internal(XtensaCPU *cpu,
} while (dc.is_jmp == DISAS_NEXT &&
insn_count < max_insns &&
dc.pc < next_page_start &&
+ dc.pc + xtensa_insn_len(env, &dc) <= next_page_start &&
tcg_ctx.gen_opc_ptr < gen_opc_end);
reset_litbase(&dc);
--
1.9.1
- [Qemu-devel] [PATCH 77/88] qcow2: Respect bdrv_truncate() error, (continued)
- [Qemu-devel] [PATCH 77/88] qcow2: Respect bdrv_truncate() error, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 80/88] qcow2: Fix header extension size check, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 76/88] qcow2: Flushing the caches in qcow2_close may fail, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 84/88] linuxboot: fix loading old kernels, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 83/88] linuxboot: compute initrd loading address, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 82/88] block: Don't probe for unknown backing file format, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 85/88] audio: Don't free hw resources until after hw backend is stopped, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 78/88] block/raw-posix: Fix ret in raw_open_common(), Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 75/88] qcow2: Prevent numerical overflow, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 81/88] qcow2.py: Add required padding for header extensions, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 86/88] target-xtensa: fix translation for opcodes crossing page boundary,
Michael Roth <=
- [Qemu-devel] [PATCH 88/88] pc: acpi: mark all possible CPUs as enabled in SRAT, Michael Roth, 2015/01/08
- [Qemu-devel] [PATCH 87/88] target-xtensa: test cross-page opcode, Michael Roth, 2015/01/08
- Re: [Qemu-devel] Patch Round-up for stable 2.1.3, freeze on 2015-01-14, Marcel Apfelbaum, 2015/01/09
- Re: [Qemu-devel] Patch Round-up for stable 2.1.3, freeze on 2015-01-14, Paolo Bonzini, 2015/01/09
- Re: [Qemu-devel] Patch Round-up for stable 2.1.3, freeze on 2015-01-14, William Dauchy, 2015/01/13
- Re: [Qemu-devel] Patch Round-up for stable 2.1.3, freeze on 2015-01-14, Marcel Apfelbaum, 2015/01/13
- Re: [Qemu-devel] Patch Round-up for stable 2.1.3, freeze on 2015-01-14, Michael Roth, 2015/01/13
- Re: [Qemu-devel] Patch Round-up for stable 2.1.3, freeze on 2015-01-14, Paolo Bonzini, 2015/01/13
- Re: [Qemu-devel] Patch Round-up for stable 2.1.3, freeze on 2015-01-14, Michael Roth, 2015/01/13
- Re: [Qemu-devel] Patch Round-up for stable 2.1.3, freeze on 2015-01-14, Michael Roth, 2015/01/13