qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Question on save_globals() in TCG
@ 2010-07-23 11:59 Jun Koi
  2010-07-23 17:53 ` Aurelien Jarno
  0 siblings, 1 reply; 7+ messages in thread
From: Jun Koi @ 2010-07-23 11:59 UTC (permalink / raw)
  To: qemu-devel

Hi,

I am looking at the save_globals() of TCG code, and it seems this
function saves regular registers like EAX, ..., EDI back to CPU state.

But I am not sure if it also saves value of other registers, like
EFlags, Segments, CR*, DR*, ... (?)
>From what I saw, it doesnt seem to do so. Is it correct?

Thanks,
J

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Question on save_globals() in TCG
  2010-07-23 11:59 [Qemu-devel] Question on save_globals() in TCG Jun Koi
@ 2010-07-23 17:53 ` Aurelien Jarno
  2010-07-24  0:35   ` Jun Koi
  0 siblings, 1 reply; 7+ messages in thread
From: Aurelien Jarno @ 2010-07-23 17:53 UTC (permalink / raw)
  To: Jun Koi; +Cc: qemu-devel

On Fri, Jul 23, 2010 at 08:59:54PM +0900, Jun Koi wrote:
> Hi,
> 
> I am looking at the save_globals() of TCG code, and it seems this
> function saves regular registers like EAX, ..., EDI back to CPU state.
> 
> But I am not sure if it also saves value of other registers, like
> EFlags, Segments, CR*, DR*, ... (?)
> From what I saw, it doesnt seem to do so. Is it correct?
> 

save_globals() is run before calling a function that can trigger a CPU
exception, to make sure that in that case all TCG variables are synced
with the CPU state.

Given the CPU state only uses "normal" registers, there is no need to
save the other registers.

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Question on save_globals() in TCG
  2010-07-23 17:53 ` Aurelien Jarno
@ 2010-07-24  0:35   ` Jun Koi
  2010-07-24  2:49     ` Aurelien Jarno
  0 siblings, 1 reply; 7+ messages in thread
From: Jun Koi @ 2010-07-24  0:35 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: qemu-devel

On Sat, Jul 24, 2010 at 2:53 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> On Fri, Jul 23, 2010 at 08:59:54PM +0900, Jun Koi wrote:
>> Hi,
>>
>> I am looking at the save_globals() of TCG code, and it seems this
>> function saves regular registers like EAX, ..., EDI back to CPU state.
>>
>> But I am not sure if it also saves value of other registers, like
>> EFlags, Segments, CR*, DR*, ... (?)
>> From what I saw, it doesnt seem to do so. Is it correct?
>>
>
> save_globals() is run before calling a function that can trigger a CPU
> exception, to make sure that in that case all TCG variables are synced
> with the CPU state.

Is it correct? I always assume that save_globals() is also called at
end of each block.

>
> Given the CPU state only uses "normal" registers, there is no need to
> save the other registers.

Why do you say that CPU state includes only normal registers, given
that, like on x86, CPUState has also segs[], cr[] and dr[]?

Another question: if save_globals() only saves regular registers,
where Qemu saves other registers  like segs[], cr[]? Or do they always
sync, all the time?

Finally, how about Eflags? I remember that Eflags is "lazy sync", but
does it sync at end of each block?

Thanks,
Jun

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Question on save_globals() in TCG
  2010-07-24  0:35   ` Jun Koi
@ 2010-07-24  2:49     ` Aurelien Jarno
  2010-07-24 16:58       ` Jun Koi
  0 siblings, 1 reply; 7+ messages in thread
From: Aurelien Jarno @ 2010-07-24  2:49 UTC (permalink / raw)
  To: Jun Koi; +Cc: qemu-devel

On Sat, Jul 24, 2010 at 09:35:44AM +0900, Jun Koi wrote:
> On Sat, Jul 24, 2010 at 2:53 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> > On Fri, Jul 23, 2010 at 08:59:54PM +0900, Jun Koi wrote:
> >> Hi,
> >>
> >> I am looking at the save_globals() of TCG code, and it seems this
> >> function saves regular registers like EAX, ..., EDI back to CPU state.
> >>
> >> But I am not sure if it also saves value of other registers, like
> >> EFlags, Segments, CR*, DR*, ... (?)
> >> From what I saw, it doesnt seem to do so. Is it correct?
> >>
> >
> > save_globals() is run before calling a function that can trigger a CPU
> > exception, to make sure that in that case all TCG variables are synced
> > with the CPU state.
> 
> Is it correct? I always assume that save_globals() is also called at
> end of each block.

Correct also here.

> >
> > Given the CPU state only uses "normal" registers, there is no need to
> > save the other registers.
> 
> Why do you say that CPU state includes only normal registers, given
> that, like on x86, CPUState has also segs[], cr[] and dr[]?
>
>
>
> Another question: if save_globals() only saves regular registers,
> where Qemu saves other registers  like segs[], cr[]? Or do they always
> sync, all the time?

It's actually the same question. You are mixing host and target
registers. save_globals() only saves "normal" host registers. Host 
registers can then contain whatever registers from the target, and
more precisely the one declared as globals.


> Finally, how about Eflags? I remember that Eflags is "lazy sync", but
> does it sync at end of each block?
> 

It's the same. Eflags are actually stored in a lazy way in cc_*
globals. They are therefore synced with save_globals().


-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Question on save_globals() in TCG
  2010-07-24  2:49     ` Aurelien Jarno
@ 2010-07-24 16:58       ` Jun Koi
  2010-07-24 22:57         ` Aurelien Jarno
  0 siblings, 1 reply; 7+ messages in thread
From: Jun Koi @ 2010-07-24 16:58 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: qemu-devel

On Sat, Jul 24, 2010 at 11:49 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> On Sat, Jul 24, 2010 at 09:35:44AM +0900, Jun Koi wrote:
>> On Sat, Jul 24, 2010 at 2:53 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
>> > On Fri, Jul 23, 2010 at 08:59:54PM +0900, Jun Koi wrote:
>> >> Hi,
>> >>
>> >> I am looking at the save_globals() of TCG code, and it seems this
>> >> function saves regular registers like EAX, ..., EDI back to CPU state.
>> >>
>> >> But I am not sure if it also saves value of other registers, like
>> >> EFlags, Segments, CR*, DR*, ... (?)
>> >> From what I saw, it doesnt seem to do so. Is it correct?
>> >>
>> >
>> > save_globals() is run before calling a function that can trigger a CPU
>> > exception, to make sure that in that case all TCG variables are synced
>> > with the CPU state.
>>
>> Is it correct? I always assume that save_globals() is also called at
>> end of each block.
>
> Correct also here.
>
>> >
>> > Given the CPU state only uses "normal" registers, there is no need to
>> > save the other registers.
>>
>> Why do you say that CPU state includes only normal registers, given
>> that, like on x86, CPUState has also segs[], cr[] and dr[]?
>>
>>
>>
>> Another question: if save_globals() only saves regular registers,
>> where Qemu saves other registers  like segs[], cr[]? Or do they always
>> sync, all the time?
>
> It's actually the same question. You are mixing host and target
> registers. save_globals() only saves "normal" host registers. Host
> registers can then contain whatever registers from the target, and
> more precisely the one declared as globals.
>
>
>> Finally, how about Eflags? I remember that Eflags is "lazy sync", but
>> does it sync at end of each block?
>>
>
> It's the same. Eflags are actually stored in a lazy way in cc_*
> globals. They are therefore synced with save_globals().

This is very helpful, thanks!

Another question: as far as I can see in the code, most context is
always synced, all the time. One exception is Eflags, which is only
synced at the end of block.
Is there other lazy synced context, besides EFLAGS?

Thanks,
Jun

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Question on save_globals() in TCG
  2010-07-24 16:58       ` Jun Koi
@ 2010-07-24 22:57         ` Aurelien Jarno
  2010-07-25  0:00           ` Jun Koi
  0 siblings, 1 reply; 7+ messages in thread
From: Aurelien Jarno @ 2010-07-24 22:57 UTC (permalink / raw)
  To: Jun Koi; +Cc: qemu-devel

On Sun, Jul 25, 2010 at 01:58:51AM +0900, Jun Koi wrote:
> On Sat, Jul 24, 2010 at 11:49 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> > On Sat, Jul 24, 2010 at 09:35:44AM +0900, Jun Koi wrote:
> >> On Sat, Jul 24, 2010 at 2:53 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> >> > On Fri, Jul 23, 2010 at 08:59:54PM +0900, Jun Koi wrote:
> >> >> Hi,
> >> >>
> >> >> I am looking at the save_globals() of TCG code, and it seems this
> >> >> function saves regular registers like EAX, ..., EDI back to CPU state.
> >> >>
> >> >> But I am not sure if it also saves value of other registers, like
> >> >> EFlags, Segments, CR*, DR*, ... (?)
> >> >> From what I saw, it doesnt seem to do so. Is it correct?
> >> >>
> >> >
> >> > save_globals() is run before calling a function that can trigger a CPU
> >> > exception, to make sure that in that case all TCG variables are synced
> >> > with the CPU state.
> >>
> >> Is it correct? I always assume that save_globals() is also called at
> >> end of each block.
> >
> > Correct also here.
> >
> >> >
> >> > Given the CPU state only uses "normal" registers, there is no need to
> >> > save the other registers.
> >>
> >> Why do you say that CPU state includes only normal registers, given
> >> that, like on x86, CPUState has also segs[], cr[] and dr[]?
> >>
> >>
> >>
> >> Another question: if save_globals() only saves regular registers,
> >> where Qemu saves other registers  like segs[], cr[]? Or do they always
> >> sync, all the time?
> >
> > It's actually the same question. You are mixing host and target
> > registers. save_globals() only saves "normal" host registers. Host
> > registers can then contain whatever registers from the target, and
> > more precisely the one declared as globals.
> >
> >
> >> Finally, how about Eflags? I remember that Eflags is "lazy sync", but
> >> does it sync at end of each block?
> >>
> >
> > It's the same. Eflags are actually stored in a lazy way in cc_*
> > globals. They are therefore synced with save_globals().
> 
> This is very helpful, thanks!
> 
> Another question: as far as I can see in the code, most context is
> always synced, all the time. One exception is Eflags, which is only
> synced at the end of block.
> Is there other lazy synced context, besides EFLAGS?

It depends on the target, some of ones are also syncing the program
counter lazily.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Question on save_globals() in TCG
  2010-07-24 22:57         ` Aurelien Jarno
@ 2010-07-25  0:00           ` Jun Koi
  0 siblings, 0 replies; 7+ messages in thread
From: Jun Koi @ 2010-07-25  0:00 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: qemu-devel

On Sun, Jul 25, 2010 at 7:57 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> On Sun, Jul 25, 2010 at 01:58:51AM +0900, Jun Koi wrote:
>> On Sat, Jul 24, 2010 at 11:49 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
>> > On Sat, Jul 24, 2010 at 09:35:44AM +0900, Jun Koi wrote:
>> >> On Sat, Jul 24, 2010 at 2:53 AM, Aurelien Jarno <aurelien@aurel32.net> wrote:
>> >> > On Fri, Jul 23, 2010 at 08:59:54PM +0900, Jun Koi wrote:
>> >> >> Hi,
>> >> >>
>> >> >> I am looking at the save_globals() of TCG code, and it seems this
>> >> >> function saves regular registers like EAX, ..., EDI back to CPU state.
>> >> >>
>> >> >> But I am not sure if it also saves value of other registers, like
>> >> >> EFlags, Segments, CR*, DR*, ... (?)
>> >> >> From what I saw, it doesnt seem to do so. Is it correct?
>> >> >>
>> >> >
>> >> > save_globals() is run before calling a function that can trigger a CPU
>> >> > exception, to make sure that in that case all TCG variables are synced
>> >> > with the CPU state.
>> >>
>> >> Is it correct? I always assume that save_globals() is also called at
>> >> end of each block.
>> >
>> > Correct also here.
>> >
>> >> >
>> >> > Given the CPU state only uses "normal" registers, there is no need to
>> >> > save the other registers.
>> >>
>> >> Why do you say that CPU state includes only normal registers, given
>> >> that, like on x86, CPUState has also segs[], cr[] and dr[]?
>> >>
>> >>
>> >>
>> >> Another question: if save_globals() only saves regular registers,
>> >> where Qemu saves other registers  like segs[], cr[]? Or do they always
>> >> sync, all the time?
>> >
>> > It's actually the same question. You are mixing host and target
>> > registers. save_globals() only saves "normal" host registers. Host
>> > registers can then contain whatever registers from the target, and
>> > more precisely the one declared as globals.
>> >
>> >
>> >> Finally, how about Eflags? I remember that Eflags is "lazy sync", but
>> >> does it sync at end of each block?
>> >>
>> >
>> > It's the same. Eflags are actually stored in a lazy way in cc_*
>> > globals. They are therefore synced with save_globals().
>>
>> This is very helpful, thanks!
>>
>> Another question: as far as I can see in the code, most context is
>> always synced, all the time. One exception is Eflags, which is only
>> synced at the end of block.
>> Is there other lazy synced context, besides EFLAGS?
>
> It depends on the target, some of ones are also syncing the program
> counter lazily.
>

ok, now i see that on x86, only EFLAGS is lazy sync.

many thanks,
J

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-07-25  0:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-23 11:59 [Qemu-devel] Question on save_globals() in TCG Jun Koi
2010-07-23 17:53 ` Aurelien Jarno
2010-07-24  0:35   ` Jun Koi
2010-07-24  2:49     ` Aurelien Jarno
2010-07-24 16:58       ` Jun Koi
2010-07-24 22:57         ` Aurelien Jarno
2010-07-25  0:00           ` Jun Koi

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).