From: Richard Henderson <richard.henderson@linaro.org>
To: Gautam Bhat <mindentropy@gmail.com>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: Point where target instructions are read
Date: Mon, 1 Apr 2024 10:31:15 -1000 [thread overview]
Message-ID: <dd957513-1272-40cf-bda5-4d3f717f3c71@linaro.org> (raw)
In-Reply-To: <CAM2a4uwktAA=Uk9_GRnxusvHhfrZg+EUWjfxy95YgxGsQQntjA@mail.gmail.com>
On 4/1/24 09:50, Gautam Bhat wrote:
> Hi,
>
> Some background: I am trying to write a CPU emulator for MSP430 with
> Qemu. I am loading the MSP430 program as follows using the generic
> device loader:
>
> /qemu-system-msp430 -machine msp430-launchpad -device
> loader,file=simple_test -d in_asm,out_asm
>
> I have implemented somewhat the TranslatorOps callbacks and my sample
> output with some prints is as follows:
>
> ===msp430_tr_disas_log:204===
>
> OUT: [size=51]
> -- guest addr 0x00000000000007fa + tb prologue
> 0x7fff6403fe00: 8b 5d f0 movl -0x10(%rbp), %ebx
> 0x7fff6403fe03: 85 db testl %ebx, %ebx
> 0x7fff6403fe05: 0f 8c 1c 00 00 00 jl 0x7fff6403fe27
> 0x7fff6403fe0b: c6 45 f4 01 movb $1, -0xc(%rbp)
> 0x7fff6403fe0f: e9 00 00 00 00 jmp 0x7fff6403fe14
> 0x7fff6403fe14: c7 45 00 fc 07 00 00 movl $0x7fc, (%rbp)
> 0x7fff6403fe1b: 48 8d 05 1e ff ff ff leaq -0xe2(%rip), %rax
> 0x7fff6403fe22: e9 f1 01 fc ff jmp 0x7fff64000018
> 0x7fff6403fe27: 48 8d 05 15 ff ff ff leaq -0xeb(%rip), %rax
> 0x7fff6403fe2e: e9 e5 01 fc ff jmp 0x7fff64000018
>
> ===gen_intermediate_code:251===
> ===msp430_tr_init_disas_context:84===
> ===msp430_tr_tb_start:99===
> ===msp430_tr_insn_start:107===
> ===msp430_tr_translate_insn:122===
> CTX Dump State
> ==============
> pc_first 2044
> pc_next 2044
> is_jmp 0
> max_insns 1
> num_insns 1
> TB flags: 1
> TB cflags: 4278190081
> TB CS base: 0
> TB PC: 2044
> ==============
> Opcode: 0
> is_jmp: 1
> DISAS_TOO_MANY ===msp430_tr_tb_stop:170===
>
> I was trying to find out where exactly in the Qemu code does it read
> the target instructions from the file loaded (I could trace it to
> load_elf(...) loading the FW file)
Yes, the contents of the file are loaded within load_elf().
> and call my TranslatorOps
> callbacks. I get the above output continuously in a loop. Also when
> the device generic loader is used, should I set the program counter to
> a specific value?
The boot process must cooperate somehow.
When using loader, you must link the image such that it loads at the pc reset address
defined by the architecture manual.
r~
next prev parent reply other threads:[~2024-04-01 20:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 19:50 Point where target instructions are read Gautam Bhat
2024-04-01 20:31 ` Richard Henderson [this message]
2024-04-03 18:15 ` Gautam Bhat
2024-04-03 22:35 ` BALATON Zoltan
2024-04-03 22:40 ` Richard Henderson
2024-04-04 8:53 ` Peter Maydell
2024-04-08 19:25 ` Gautam Bhat
2024-04-09 8:53 ` Peter Maydell
2024-04-10 21:15 ` Gautam Bhat
2024-04-13 20:51 ` Gautam Bhat
2024-05-18 6:59 ` Gautam Bhat
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=dd957513-1272-40cf-bda5-4d3f717f3c71@linaro.org \
--to=richard.henderson@linaro.org \
--cc=mindentropy@gmail.com \
--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).