From: "Andreas Färber" <afaerber@suse.de>
To: Xin Tong <xerox.time.tech@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] cpu_regs in target-i386
Date: Sun, 27 Nov 2011 17:10:34 +0100 [thread overview]
Message-ID: <4ED260FA.6020701@suse.de> (raw)
In-Reply-To: <CALKntY0DhKoUQGk-oFLVQHD2D=hq8mWpeUFNWpyyiokB3pSfoA@mail.gmail.com>
Am 27.11.2011 16:23, schrieb Xin Tong:
> This is a bit confusing then
>
> in target-i386/translate.c
>
> void optimize_flags_init(void)
> {
> ...
> cpu_regs[15] = tcg_global_mem_new_i64(TCG_AREG0,
> offsetof(CPUState, regs[15]), "r15");
> printf("offsetof(CPUState, regs[15]) is %ld\n", offsetof(CPUState, regs[15]));
>
> ...
> }
>
> output is cpu_regs[15] is 20, offsetof(CPUState, regs[15]) is 120,
> should not cpu_regs[15] == 120 ?
Please don't top-post, your reply is out of context then. See below.
> On Sun, Nov 27, 2011 at 9:53 AM, Andreas Färber <afaerber@suse.de> wrote:
>> Am 27.11.2011 15:36, schrieb Xin Tong:
>>> If i understand correctly here, those are just array of offsets for
>>> the emulated registers such that the tcg can easily get access to the
>>> address of the emulated registers. This is, however, different from
>>> the env (CPUx86State) variable which will always have a host register
>>> pointing to it ( host register is made to point to env in the tb enter
>>> prologue).
>>
>> Yes:
>>
>> host register pointed to by cpu_env contains address of env
>> +
>> offset stored in cpu_* variable
Note that "variable" refers to TCG variable (TCGv), not C variable, cf.
tcg/README. If you do printf("%d", cpu_xyz), you will only see the
internal ID of that variable that points to data stored elsewhere. In
this case the ID happens to be constant because these are set up once
during target initialization.
>> =
>> address of corresponding struct member in env
When playing with TCG, configure with --enable-debug-tcg, then the
definitions are changed so that the compiler can make you aware of such
mixups.
Andreas
>>> On Sun, Nov 27, 2011 at 9:12 AM, Andreas Färber <afaerber@suse.de> wrote:
>>>> Am 27.11.2011 14:46, schrieb Xin Tong:
>>>>> When the x86 vcpu is initialized, a CPUX86State is qemu_mallocz'ed.
>>>>> env is used to point to it and modifications to the CPUX86State can
>>>>> thereby be done via the register that contains the env. I do not get
>>>>> what the cpu_regs[CPU_NB_REGS] are for, do not we already have a set
>>>>> of emulated x86 registers when we allocate the CPUX86State ?
>>>>
>>>> I assume in i386, too, it will be a TCGv array and will be initialized
>>>> to point to individual memory offsets inside CPU*State.
>>>> So they're for convenience and readability.
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
prev parent reply other threads:[~2011-11-27 16:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-27 13:46 [Qemu-devel] cpu_regs in target-i386 Xin Tong
2011-11-27 14:12 ` Andreas Färber
2011-11-27 14:36 ` Xin Tong
2011-11-27 14:53 ` Andreas Färber
2011-11-27 15:23 ` Xin Tong
2011-11-27 15:43 ` Peter Maydell
2011-11-27 16:17 ` Xin Tong
2011-11-27 20:59 ` Peter Maydell
2011-11-27 23:07 ` Xin Tong
2011-11-27 23:33 ` Peter Maydell
2011-11-28 0:32 ` Xin Tong
2011-11-28 1:00 ` Xin Tong
2011-11-27 16:10 ` Andreas Färber [this message]
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=4ED260FA.6020701@suse.de \
--to=afaerber@suse.de \
--cc=qemu-devel@nongnu.org \
--cc=xerox.time.tech@gmail.com \
/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).