All of lore.kernel.org
 help / color / mirror / Atom feed
* where can I find the 'address translation' code in Xen?
@ 2018-04-29 10:11 Minjun Hong
  2018-04-30  6:44 ` Petr Tesarik
  2018-04-30 13:13 ` Andrew Cooper
  0 siblings, 2 replies; 7+ messages in thread
From: Minjun Hong @ 2018-04-29 10:11 UTC (permalink / raw)
  To: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 750 bytes --]

Hi.
I'm looking for a point where address translation (guest virtual address to
machine address) occurs in Xen.
Of course, I mean when TLB miss has occured.
I'm using a PV guest and I've found 'guest_walk_tables()' function in
"xen/arch/x86/mm/guest_walk.c".
However, in the comment of the function, it says "Walk the guest
pagetables, after the manner of a hardware walker".
I'm confused because I'm not sure if the function is called after the
'hardware page table walker'.

My question is,

1. Is it sure that the function will be called even though the HW already
translates the address and populates the TLB entry?

2. I'm just asking, is there any code in Xen that is related to the
behavior of the 'hardware walker'?

Thanks for your reading.

[-- Attachment #1.2: Type: text/html, Size: 1031 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: where can I find the 'address translation' code in Xen?
  2018-04-29 10:11 where can I find the 'address translation' code in Xen? Minjun Hong
@ 2018-04-30  6:44 ` Petr Tesarik
  2018-04-30  8:17   ` Minjun Hong
  2018-04-30 13:13 ` Andrew Cooper
  1 sibling, 1 reply; 7+ messages in thread
From: Petr Tesarik @ 2018-04-30  6:44 UTC (permalink / raw)
  To: xen-devel

Hi Minjun,

On Sun, 29 Apr 2018 19:11:30 +0900
Minjun Hong <nickeysgo@gmail.com> wrote:

>[...]
> My question is,
> 
> 1. Is it sure that the function will be called even though the HW already
> translates the address and populates the TLB entry?

I think you miss the point. The hardware page tables for PV domains
already contain machine addresses. In other words, virtual addresses
get translated directly to machine addresses by the hardware page table
walker.

> 2. I'm just asking, is there any code in Xen that is related to the
> behavior of the 'hardware walker'?

Not sure what you mean. Maybe this question is no longer pertinent
given the explanation above?

HTH,
Petr T

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: where can I find the 'address translation' code in Xen?
  2018-04-30  6:44 ` Petr Tesarik
@ 2018-04-30  8:17   ` Minjun Hong
  2018-04-30  9:29     ` Petr Tesarik
  0 siblings, 1 reply; 7+ messages in thread
From: Minjun Hong @ 2018-04-30  8:17 UTC (permalink / raw)
  To: Petr Tesarik; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1450 bytes --]

On Mon, Apr 30, 2018 at 3:44 PM, Petr Tesarik <ptesarik@suse.cz> wrote:

> Hi Minjun,
>
> On Sun, 29 Apr 2018 19:11:30 +0900
> Minjun Hong <nickeysgo@gmail.com> wrote:
>
> >[...]
> > My question is,
> >
> > 1. Is it sure that the function will be called even though the HW already
> > translates the address and populates the TLB entry?
>
> I think you miss the point. The hardware page tables for PV domains
> already contain machine addresses. In other words, virtual addresses
> get translated directly to machine addresses by the hardware page table
> walker.
>
> > 2. I'm just asking, is there any code in Xen that is related to the
> > behavior of the 'hardware walker'?
>
> Not sure what you mean. Maybe this question is no longer pertinent
> given the explanation above?
>
> HTH,
> Petr T
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel



Thanks for your kind answer, Petr.

In your answer on my first question, I was wondering why the function (
guest_walk_tables()) should be called even after the address translation
and TLB filling has been completed by the hardware page table walker.
As you mentioned, original goal (address translation) is achieved by the
hardware. If so, is its role like bottom half of interrupt?

I want to know this function is always called after the translation by the
hardware page walker.

[-- Attachment #1.2: Type: text/html, Size: 2774 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: where can I find the 'address translation' code in Xen?
  2018-04-30  8:17   ` Minjun Hong
@ 2018-04-30  9:29     ` Petr Tesarik
  0 siblings, 0 replies; 7+ messages in thread
From: Petr Tesarik @ 2018-04-30  9:29 UTC (permalink / raw)
  To: Minjun Hong; +Cc: xen-devel

Hi Minjun,

On Mon, 30 Apr 2018 17:17:36 +0900
Minjun Hong <nickeysgo@gmail.com> wrote:

> On Mon, Apr 30, 2018 at 3:44 PM, Petr Tesarik <ptesarik@suse.cz> wrote:
> 
> > Hi Minjun,
> >
> > On Sun, 29 Apr 2018 19:11:30 +0900
> > Minjun Hong <nickeysgo@gmail.com> wrote:
> >  
> > >[...]
> > > My question is,
> > >
> > > 1. Is it sure that the function will be called even though the HW already
> > > translates the address and populates the TLB entry?  
> >
> > I think you miss the point. The hardware page tables for PV domains
> > already contain machine addresses. In other words, virtual addresses
> > get translated directly to machine addresses by the hardware page table
> > walker.
> >  
> > > 2. I'm just asking, is there any code in Xen that is related to the
> > > behavior of the 'hardware walker'?  
> >
> > Not sure what you mean. Maybe this question is no longer pertinent
> > given the explanation above?
> >
> > HTH,
> > Petr T
> >
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xenproject.org
> > https://lists.xenproject.org/mailman/listinfo/xen-devel  
> 
> 
> 
> Thanks for your kind answer, Petr.
> 
> In your answer on my first question, I was wondering why the function (
> guest_walk_tables()) should be called even after the address translation
> and TLB filling has been completed by the hardware page table walker.
> As you mentioned, original goal (address translation) is achieved by the
> hardware. If so, is its role like bottom half of interrupt?

Ah, now I'm starting to get your point. So, you're interested in
what happens after guest page tables are updated.

> I want to know this function is always called after the translation
> by the hardware page walker.

It seems to me that there are quite a few ways to avoid a full page
table walk, but I'm not an expert on this topic, sorry.

Petr T


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: where can I find the 'address translation' code in Xen?
  2018-04-29 10:11 where can I find the 'address translation' code in Xen? Minjun Hong
  2018-04-30  6:44 ` Petr Tesarik
@ 2018-04-30 13:13 ` Andrew Cooper
  2018-05-01 12:54   ` Minjun Hong
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Cooper @ 2018-04-30 13:13 UTC (permalink / raw)
  To: Minjun Hong, xen-devel

On 29/04/18 11:11, Minjun Hong wrote:
> Hi.
> I'm looking for a point where address translation (guest virtual
> address to machine address) occurs in Xen.
> Of course, I mean when TLB miss has occured.

This question makes me wonder whether you are more familiar with PowerPC
than x86.  In x86, the TLB is automatically maintained by hardware, and
new entries will be populated as necessary.  All pagetable related
errors result in a pagefault exception, which Xen handles.

> I'm using a PV guest and I've found 'guest_walk_tables()' function in
> "xen/arch/x86/mm/guest_walk.c".
> However, in the comment of the function, it says "Walk the guest
> pagetables, after the manner of a hardware walker".
> I'm confused because I'm not sure if the function is called after the
> 'hardware page table walker'.

"after the manner" is an uncommon phrase in English, which AFAICT
derives from Latin originally.  It means "in the style of", "in the same
way as", etc.

guest_walk_tables() is a function which tries to match the behaviour of
the hardware pagewalker.  However, it is only used for cases where we
can't use regular hardware support, such as emulation of instructions.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: where can I find the 'address translation' code in Xen?
  2018-04-30 13:13 ` Andrew Cooper
@ 2018-05-01 12:54   ` Minjun Hong
  2018-05-02  8:36     ` George Dunlap
  0 siblings, 1 reply; 7+ messages in thread
From: Minjun Hong @ 2018-05-01 12:54 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1792 bytes --]

On Mon, Apr 30, 2018 at 10:13 PM, Andrew Cooper <andrew.cooper3@citrix.com>
wrote:

> On 29/04/18 11:11, Minjun Hong wrote:
> > Hi.
> > I'm looking for a point where address translation (guest virtual
> > address to machine address) occurs in Xen.
> > Of course, I mean when TLB miss has occured.
>
> This question makes me wonder whether you are more familiar with PowerPC
> than x86.  In x86, the TLB is automatically maintained by hardware, and
> new entries will be populated as necessary.  All pagetable related
> errors result in a pagefault exception, which Xen handles.
>
> > I'm using a PV guest and I've found 'guest_walk_tables()' function in
> > "xen/arch/x86/mm/guest_walk.c".
> > However, in the comment of the function, it says "Walk the guest
> > pagetables, after the manner of a hardware walker".
> > I'm confused because I'm not sure if the function is called after the
> > 'hardware page table walker'.
>
> "after the manner" is an uncommon phrase in English, which AFAICT
> derives from Latin originally.  It means "in the style of", "in the same
> way as", etc.
>
> guest_walk_tables() is a function which tries to match the behaviour of
> the hardware pagewalker.  However, it is only used for cases where we
> can't use regular hardware support, such as emulation of instructions.
>
> ~Andrew
>

Thank you, Andrew.
Your answer is very helpful for me.

It appears that there is no code to be executed when address translations
of the guest occurs in Xen.
Frankly, I was expecting there may be an address translation when accessing
guest memory, and I wanted to find the code used in Xen at that time.
Is there any code I can use for this purpose in Xen? No matter how I look,
I could not find it in Xen with my background knowledge right now. So that
I need your help.

[-- Attachment #1.2: Type: text/html, Size: 3911 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: where can I find the 'address translation' code in Xen?
  2018-05-01 12:54   ` Minjun Hong
@ 2018-05-02  8:36     ` George Dunlap
  0 siblings, 0 replies; 7+ messages in thread
From: George Dunlap @ 2018-05-02  8:36 UTC (permalink / raw)
  To: Minjun Hong; +Cc: Andrew Cooper, Xen-devel

On Tue, May 1, 2018 at 1:54 PM, Minjun Hong <nickeysgo@gmail.com> wrote:
> On Mon, Apr 30, 2018 at 10:13 PM, Andrew Cooper <andrew.cooper3@citrix.com>
> wrote:
>>
>> On 29/04/18 11:11, Minjun Hong wrote:
>> > Hi.
>> > I'm looking for a point where address translation (guest virtual
>> > address to machine address) occurs in Xen.
>> > Of course, I mean when TLB miss has occured.
>>
>> This question makes me wonder whether you are more familiar with PowerPC
>> than x86.  In x86, the TLB is automatically maintained by hardware, and
>> new entries will be populated as necessary.  All pagetable related
>> errors result in a pagefault exception, which Xen handles.
>>
>> > I'm using a PV guest and I've found 'guest_walk_tables()' function in
>> > "xen/arch/x86/mm/guest_walk.c".
>> > However, in the comment of the function, it says "Walk the guest
>> > pagetables, after the manner of a hardware walker".
>> > I'm confused because I'm not sure if the function is called after the
>> > 'hardware page table walker'.
>>
>> "after the manner" is an uncommon phrase in English, which AFAICT
>> derives from Latin originally.  It means "in the style of", "in the same
>> way as", etc.
>>
>> guest_walk_tables() is a function which tries to match the behaviour of
>> the hardware pagewalker.  However, it is only used for cases where we
>> can't use regular hardware support, such as emulation of instructions.
>>
>> ~Andrew
>
>
> Thank you, Andrew.
> Your answer is very helpful for me.
>
> It appears that there is no code to be executed when address translations of
> the guest occurs in Xen.
> Frankly, I was expecting there may be an address translation when accessing
> guest memory, and I wanted to find the code used in Xen at that time.
> Is there any code I can use for this purpose in Xen? No matter how I look, I
> could not find it in Xen with my background knowledge right now. So that I
> need your help.

Maybe if you described what it was you were trying to accomplish, we
could help point you in the right direction.

If you actually need to intercept every virtual -> physical
translation, I'm afraid full emulation (such as QEMU) is going to be
your only option.

If you only need to intercept them the first time they're used, then
you might be able to use some combination of VMI and/or shadow mode to
intercept only the virtual -> physical translations you need.

 -George

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2018-05-02  8:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-29 10:11 where can I find the 'address translation' code in Xen? Minjun Hong
2018-04-30  6:44 ` Petr Tesarik
2018-04-30  8:17   ` Minjun Hong
2018-04-30  9:29     ` Petr Tesarik
2018-04-30 13:13 ` Andrew Cooper
2018-05-01 12:54   ` Minjun Hong
2018-05-02  8:36     ` George Dunlap

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.