From 51d54503e8049512bdbe55d4f87caf97cd99ca23 Mon Sep 17 00:00:00 2001 From: Tianrui Zhao Date: Mon, 27 Mar 2023 19:23:13 +0800 Subject: [PATCH 1/2] hw/loongarch/virt: Fix virt_to_phys_addr function The virt addr should mask TARGET_PHYS_ADDR_SPACE_BITS to get the phys addr, and this is used by loading kernel elf. Signed-off-by: Tianrui Zhao Acked-by: Richard Henderson Message-Id: <20230327112313.3042829-1-zhaotianrui@loongson.cn> Signed-off-by: Song Gao --- hw/loongarch/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index b702c3f51e..f4bf14c1c8 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -399,7 +399,7 @@ static struct _loaderparams { static uint64_t cpu_loongarch_virt_to_phys(void *opaque, uint64_t addr) { - return addr & 0x1fffffffll; + return addr & MAKE_64BIT_MASK(0, TARGET_PHYS_ADDR_SPACE_BITS); } static int64_t load_kernel_info(void) From ec28dd6c6fc1366504003c25828953cac49e2da7 Mon Sep 17 00:00:00 2001 From: tanhongze Date: Thu, 30 Mar 2023 20:46:00 +0800 Subject: [PATCH 2/2] target/loongarch: Enables plugins to get instruction codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: tanhongze Reviewed-by: Richard Henderson Acked-by: Alex Bennée Message-Id: <20230330124600.1523026-1-tanhongze@loongson.cn> Signed-off-by: Song Gao --- target/loongarch/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/loongarch/translate.c b/target/loongarch/translate.c index f443b5822f..21d86077f4 100644 --- a/target/loongarch/translate.c +++ b/target/loongarch/translate.c @@ -177,7 +177,7 @@ static void loongarch_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) CPULoongArchState *env = cs->env_ptr; DisasContext *ctx = container_of(dcbase, DisasContext, base); - ctx->opcode = cpu_ldl_code(env, ctx->base.pc_next); + ctx->opcode = translator_ldl(env, &ctx->base, ctx->base.pc_next); if (!decode(ctx, ctx->opcode)) { qemu_log_mask(LOG_UNIMP, "Error: unknown opcode. "