[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/10] target/riscv: avoid integer overflow in next_
From: |
Emilio G. Cota |
Subject: |
[Qemu-devel] [PATCH 01/10] target/riscv: avoid integer overflow in next_page PC check |
Date: |
Tue, 10 Apr 2018 12:19:37 -0400 |
If the PC is in the last page of the address space, next_page_start
overflows to 0. Fix it.
Reported-by: Richard Henderson <address@hidden>
Suggested-by: Richard Henderson <address@hidden>
Cc: Michael Clark <address@hidden>
Cc: Palmer Dabbelt <address@hidden>
Cc: Sagar Karandikar <address@hidden>
Cc: Bastian Koppelmann <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
---
target/riscv/translate.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index 808eab7..d2d2e5e 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -1849,11 +1849,11 @@ void gen_intermediate_code(CPUState *cs,
TranslationBlock *tb)
CPURISCVState *env = cs->env_ptr;
DisasContext ctx;
target_ulong pc_start;
- target_ulong next_page_start;
+ target_ulong page_start;
int num_insns;
int max_insns;
pc_start = tb->pc;
- next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE;
+ page_start = pc_start & TARGET_PAGE_MASK;
ctx.pc = pc_start;
/* once we have GDB, the rest of the translate.c implementation should be
@@ -1903,7 +1903,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock
*tb)
if (cs->singlestep_enabled) {
break;
}
- if (ctx.pc >= next_page_start) {
+ if (ctx.pc - page_start >= TARGET_PAGE_SIZE) {
break;
}
if (tcg_op_buf_full()) {
--
2.7.4
- [Qemu-devel] [PATCH 00/10] Avoid integer overflow in next_page_start, Emilio G. Cota, 2018/04/10
- [Qemu-devel] [PATCH 04/10] target/xtensa: avoid integer overflow in next_page PC check, Emilio G. Cota, 2018/04/10
- [Qemu-devel] [PATCH 05/10] target/unicore32: avoid integer overflow in next_page PC check, Emilio G. Cota, 2018/04/10
- [Qemu-devel] [PATCH 01/10] target/riscv: avoid integer overflow in next_page PC check,
Emilio G. Cota <=
- [Qemu-devel] [PATCH 03/10] target/lm32: avoid integer overflow in next_page PC check, Emilio G. Cota, 2018/04/10
- [Qemu-devel] [PATCH 07/10] target/microblaze: avoid integer overflow in next_page PC check, Emilio G. Cota, 2018/04/10
- [Qemu-devel] [PATCH 06/10] target/tilegx: avoid integer overflow in next_page PC check, Emilio G. Cota, 2018/04/10
- [Qemu-devel] [PATCH 08/10] target/arm: avoid integer overflow in next_page PC check, Emilio G. Cota, 2018/04/10
- [Qemu-devel] [PATCH 09/10] target/s390x: avoid integer overflow in next_page PC check, Emilio G. Cota, 2018/04/10