* [Qemu-devel] When the tlb_fill will be called from generated code?
@ 2011-09-27 4:15 陳韋任
2011-09-27 7:06 ` Jan Kiszka
0 siblings, 1 reply; 10+ messages in thread
From: 陳韋任 @ 2011-09-27 4:15 UTC (permalink / raw)
To: qemu-devel
Hi, all
The comment above tlb_fill says:
/* try to fill the TLB and return an exception if error. If retaddr is
NULL, it means that the function was called in C code (i.e. not
from generated code or from helper.c) */
I see tlb_fill only be called from softmmu_template.h (i.e., C code). I
am wondering when/where the tlb_fill is called from generated code (code
cache) or from helper.c.
Thanks!
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-27 4:15 [Qemu-devel] When the tlb_fill will be called from generated code? 陳韋任
@ 2011-09-27 7:06 ` Jan Kiszka
2011-09-27 11:02 ` 陳韋任
0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2011-09-27 7:06 UTC (permalink / raw)
To: 陳韋任; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
On 2011-09-27 06:15, 陳韋任 wrote:
> Hi, all
>
> The comment above tlb_fill says:
>
> /* try to fill the TLB and return an exception if error. If retaddr is
> NULL, it means that the function was called in C code (i.e. not
> from generated code or from helper.c) */
>
> I see tlb_fill only be called from softmmu_template.h (i.e., C code). I
> am wondering when/where the tlb_fill is called from generated code (code
> cache) or from helper.c.
>
You can find the answer yourself: Load qemu into gdb, set a breakpoint
on that function and let it run. If you want to catch only the retaddr
== NULL case, make the breakpoint conditional.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-27 7:06 ` Jan Kiszka
@ 2011-09-27 11:02 ` 陳韋任
2011-09-27 11:29 ` Max Filippov
2011-09-27 17:10 ` Blue Swirl
0 siblings, 2 replies; 10+ messages in thread
From: 陳韋任 @ 2011-09-27 11:02 UTC (permalink / raw)
To: Jan Kiszka; +Cc: qemu-devel, 陳韋任
Hi, Jan
> You can find the answer yourself: Load qemu into gdb, set a breakpoint
> on that function and let it run. If you want to catch only the retaddr
> == NULL case, make the breakpoint conditional.
Thanks for your tip. I see when retaddr != NULL, then the calling
sequence of tlb_fill might be something like (take i386 guest for
example):
- __stl_mmu/__ldl_mmu -> tlb_fill
- helper_ljmp_protected -> load_segment -> ldl_kernel -> __ldl_mmu
I am not sure when/where __stl_mmu/__ldl_mmu are used. I do set
breakpoint on __stl_mmu/__ldl_mmu, but the backtrace can only show
something like,
#0 __stl_mmu (addr=196608, val=0, mmu_idx=0) at /tmp/chenwj/temp/qemu-0.13.0/softmmu_template.h:228
#1 0x00000000400028e1 in ?? ()
#2 0x00000000000000b4 in ?? ()
#3 0xecc68ff412fa4137 in ?? ()
#4 0x0000000000000000 in ?? ()
When retaddr == NULL, then the calling sequence of tlb_fill is,
tb_find_slow -> get_page_addr_code -> ldub_code -> __ldb_cmmu
I can only guest the b in __ldb_cmmu means load byte, but I can't
figure out what's the difference between _cmmu and _mmu. Could you
give me some hint? Thanks!
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-27 11:02 ` 陳韋任
@ 2011-09-27 11:29 ` Max Filippov
2011-09-28 3:51 ` 陳韋任
2011-09-27 17:10 ` Blue Swirl
1 sibling, 1 reply; 10+ messages in thread
From: Max Filippov @ 2011-09-27 11:29 UTC (permalink / raw)
To: 陳韋任; +Cc: Jan Kiszka, qemu-devel
> I am not sure when/where __stl_mmu/__ldl_mmu are used. I do set
They are called from the places in TBs where
tcg_gen_qemu_{ld,st}{8,16,32,64}{u,s} were injected.
> breakpoint on __stl_mmu/__ldl_mmu, but the backtrace can only show
> something like,
>
> #0 __stl_mmu (addr=196608, val=0, mmu_idx=0) at /tmp/chenwj/temp/qemu-0.13.0/softmmu_template.h:228
> #1 0x00000000400028e1 in ?? ()
> #2 0x00000000000000b4 in ?? ()
> #3 0xecc68ff412fa4137 in ?? ()
> #4 0x0000000000000000 in ?? ()
>
> When retaddr == NULL, then the calling sequence of tlb_fill is,
>
> tb_find_slow -> get_page_addr_code -> ldub_code -> __ldb_cmmu
>
> I can only guest the b in __ldb_cmmu means load byte, but I can't
> figure out what's the difference between _cmmu and _mmu. Could you
> give me some hint? Thanks!
_cmmu is used to access code, _mmu is for data.
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-27 11:02 ` 陳韋任
2011-09-27 11:29 ` Max Filippov
@ 2011-09-27 17:10 ` Blue Swirl
2011-09-28 2:32 ` 陳韋任
1 sibling, 1 reply; 10+ messages in thread
From: Blue Swirl @ 2011-09-27 17:10 UTC (permalink / raw)
To: 陳韋任; +Cc: Jan Kiszka, qemu-devel
On Tue, Sep 27, 2011 at 11:02 AM, 陳韋任 <chenwj@iis.sinica.edu.tw> wrote:
> Hi, Jan
>
>> You can find the answer yourself: Load qemu into gdb, set a breakpoint
>> on that function and let it run. If you want to catch only the retaddr
>> == NULL case, make the breakpoint conditional.
>
> Thanks for your tip. I see when retaddr != NULL, then the calling
> sequence of tlb_fill might be something like (take i386 guest for
> example):
>
> - __stl_mmu/__ldl_mmu -> tlb_fill
>
> - helper_ljmp_protected -> load_segment -> ldl_kernel -> __ldl_mmu
>
> I am not sure when/where __stl_mmu/__ldl_mmu are used. I do set
> breakpoint on __stl_mmu/__ldl_mmu, but the backtrace can only show
> something like,
>
> #0 __stl_mmu (addr=196608, val=0, mmu_idx=0) at /tmp/chenwj/temp/qemu-0.13.0/softmmu_template.h:228
> #1 0x00000000400028e1 in ?? ()
> #2 0x00000000000000b4 in ?? ()
> #3 0xecc68ff412fa4137 in ?? ()
> #4 0x0000000000000000 in ?? ()
>
> When retaddr == NULL, then the calling sequence of tlb_fill is,
>
> tb_find_slow -> get_page_addr_code -> ldub_code -> __ldb_cmmu
>
> I can only guest the b in __ldb_cmmu means load byte, but I can't
> figure out what's the difference between _cmmu and _mmu. Could you
> give me some hint? Thanks!
End of exec.c instantiates the code load functions (ld*_code), there
GETPC is defined as NULL. Otherwise GETPC works as usual, so it will
not return NULL.
The memory access templates are a bit confusing. Op helpers use
softmmu_exec.h to instantiate {ld,st}*_{kernel,user,etc} functions.
TCG needs __{ld,st}* helpers for qemu_{ld,st}* TLB miss case, these
are generated by softmmu_template.h. I'll soon apply a patch which
adds comments to the files.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-27 17:10 ` Blue Swirl
@ 2011-09-28 2:32 ` 陳韋任
0 siblings, 0 replies; 10+ messages in thread
From: 陳韋任 @ 2011-09-28 2:32 UTC (permalink / raw)
To: Blue Swirl; +Cc: Jan Kiszka, qemu-devel, 陳韋任
> End of exec.c instantiates the code load functions (ld*_code), there
> GETPC is defined as NULL. Otherwise GETPC works as usual, so it will
> not return NULL.
>
> The memory access templates are a bit confusing. Op helpers use
> softmmu_exec.h to instantiate {ld,st}*_{kernel,user,etc} functions.
> TCG needs __{ld,st}* helpers for qemu_{ld,st}* TLB miss case, these
> are generated by softmmu_template.h. I'll soon apply a patch which
> adds comments to the files.
Thanks. I am very appreciate it. :-)
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-27 11:29 ` Max Filippov
@ 2011-09-28 3:51 ` 陳韋任
2011-09-28 6:36 ` Max Filippov
2011-09-29 3:40 ` Mulyadi Santosa
0 siblings, 2 replies; 10+ messages in thread
From: 陳韋任 @ 2011-09-28 3:51 UTC (permalink / raw)
To: Max Filippov; +Cc: Jan Kiszka, qemu-devel, 陳韋任
> > I am not sure when/where __stl_mmu/__ldl_mmu are used. I do set
>
> They are called from the places in TBs where
> tcg_gen_qemu_{ld,st}{8,16,32,64}{u,s} were injected.
So you mean __stl_mmu/__ldl_mmu are called from the code cache.
> > breakpoint on __stl_mmu/__ldl_mmu, but the backtrace can only show
> > something like,
> >
> > #0 鍮_stl_mmu (addr=196608, val=0, mmu_idx=0) at /tmp/chenwj/temp/qemu-0.13.0/softmmu_template.h:228
> > #1 ?0x00000000400028e1 in ?? ()
> > #2 ?0x00000000000000b4 in ?? ()
> > #3 ?0xecc68ff412fa4137 in ?? ()
> > #4 ?0x0000000000000000 in ?? ()
Does those ?? mean since we are in the code cache, so GDB cannot
show their backtarce?
> > When retaddr == NULL, then the calling sequence of tlb_fill is,
> >
> > 慯b_find_slow -> get_page_addr_code -> ldub_code -> __ldb_cmmu
> >
> > I can only guest the b in __ldb_cmmu means load byte, but I can't
> > figure out what's the difference between _cmmu and _mmu. Could you
> > give me some hint? Thanks!
>
> _cmmu is used to access code, _mmu is for data.
I see. Thanks, and I find building QEMU with --extra-cflags="-save-temps"
is really help. Those *.i files make things much clear.
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-28 3:51 ` 陳韋任
@ 2011-09-28 6:36 ` Max Filippov
2011-09-29 3:40 ` Mulyadi Santosa
1 sibling, 0 replies; 10+ messages in thread
From: Max Filippov @ 2011-09-28 6:36 UTC (permalink / raw)
To: 陳韋任; +Cc: Jan Kiszka, qemu-devel
> > They are called from the places in TBs where
> > tcg_gen_qemu_{ld,st}{8,16,32,64}{u,s} were injected.
>
> So you mean __stl_mmu/__ldl_mmu are called from the code cache.
>
> > > breakpoint on __stl_mmu/__ldl_mmu, but the backtrace can only show
> > > something like,
> > >
> > > #0 鍮_stl_mmu (addr=196608, val=0, mmu_idx=0) at /tmp/chenwj/temp/qemu-0.13.0/softmmu_template.h:228
> > > #1 ?0x00000000400028e1 in ?? ()
> > > #2 ?0x00000000000000b4 in ?? ()
> > > #3 ?0xecc68ff412fa4137 in ?? ()
> > > #4 ?0x0000000000000000 in ?? ()
>
> Does those ?? mean since we are in the code cache, so GDB cannot
> show their backtarce?
Yes, at least for the frame #1. Addresses in frames #2-#4 don't look right, probably because #1 does not have a stack frame.
Thanks.
-- Max
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-28 3:51 ` 陳韋任
2011-09-28 6:36 ` Max Filippov
@ 2011-09-29 3:40 ` Mulyadi Santosa
2011-09-29 3:45 ` 陳韋任
1 sibling, 1 reply; 10+ messages in thread
From: Mulyadi Santosa @ 2011-09-29 3:40 UTC (permalink / raw)
To: 陳韋任; +Cc: qemu-devel
Hi :)
2011/9/28 陳韋任 <chenwj@iis.sinica.edu.tw>:
> I see. Thanks, and I find building QEMU with --extra-cflags="-save-temps"
> is really help. Those *.i files make things much clear.
glad that my -save-temps suggestion helps other ;)
--
regards,
Mulyadi Santosa
Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] When the tlb_fill will be called from generated code?
2011-09-29 3:40 ` Mulyadi Santosa
@ 2011-09-29 3:45 ` 陳韋任
0 siblings, 0 replies; 10+ messages in thread
From: 陳韋任 @ 2011-09-29 3:45 UTC (permalink / raw)
To: Mulyadi Santosa; +Cc: qemu-devel, 陳韋任
> glad that my -save-temps suggestion helps other ;)
Indeed. Thanks again, Mulyadi.
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-09-29 3:45 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 4:15 [Qemu-devel] When the tlb_fill will be called from generated code? 陳韋任
2011-09-27 7:06 ` Jan Kiszka
2011-09-27 11:02 ` 陳韋任
2011-09-27 11:29 ` Max Filippov
2011-09-28 3:51 ` 陳韋任
2011-09-28 6:36 ` Max Filippov
2011-09-29 3:40 ` Mulyadi Santosa
2011-09-29 3:45 ` 陳韋任
2011-09-27 17:10 ` Blue Swirl
2011-09-28 2:32 ` 陳韋任
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.