All of lore.kernel.org
 help / color / mirror / Atom feed
* misunderstanding of the virtual memory
       [not found] <518BB132.5050802@gmail.com>
@ 2013-05-09 14:33 ` Ben Teissier
  2013-05-09 16:57   ` Seth Jennings
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Teissier @ 2013-05-09 14:33 UTC (permalink / raw)
  To: linux-mm


Hi,

I'm Benjamin and I'm studying the kernel. I write you this email
because I've a trouble with the mmu and the virtual memory. I try to
understand how a program (user land) can write something into the stack
(push ebp, for example), indeed, the program works with virtual address
(between 0x00000 and 0x8... if my memory is good) but at the hardware
side the address is not the same (that's why mmu was created, if I'm right).

My problem is the following : how the data is wrote on the physical
memory. When I try a strace (kernel 2.6.32 on a simple program) I have
no hint on the transfer of data. Moreover, according to the wikipedia
web page on syscall (
https://en.wikipedia.org/wiki/System_call#The_library_as_an_intermediary
), a call is not managed by the kernel. So, how the transfer between
virtual memory and physical memory is possible ?

I hope my email is understandable, I tried to put words on my troubles.

Thanks a lot for your help and have a nice day.

Benjamin.


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: misunderstanding of the virtual memory
  2013-05-09 14:33 ` misunderstanding of the virtual memory Ben Teissier
@ 2013-05-09 16:57   ` Seth Jennings
  2013-05-10 15:57     ` Benjamin Teissier
  0 siblings, 1 reply; 3+ messages in thread
From: Seth Jennings @ 2013-05-09 16:57 UTC (permalink / raw)
  To: Ben Teissier; +Cc: linux-mm

On Thu, May 09, 2013 at 10:33:21AM -0400, Ben Teissier wrote:
> 
> Hi,
> 
> I'm Benjamin and I'm studying the kernel. I write you this email
> because I've a trouble with the mmu and the virtual memory. I try to
> understand how a program (user land) can write something into the stack
> (push ebp, for example), indeed, the program works with virtual address
> (between 0x00000 and 0x8... if my memory is good) but at the hardware
> side the address is not the same (that's why mmu was created, if I'm right).

Yes, this is the purpose of pages tables; to map virtual addresses to real
memory addresses (more precisely virtual memory _pages_ to real memory pages).

> 
> My problem is the following : how the data is wrote on the physical
> memory. When I try a strace (kernel 2.6.32 on a simple program) I have
> no hint on the transfer of data. Moreover, according to the wikipedia
> web page on syscall (
> https://en.wikipedia.org/wiki/System_call#The_library_as_an_intermediary
> ), a call is not managed by the kernel. So, how the transfer between
> virtual memory and physical memory is possible ?

That is because writing to a memory location in userspace isn't an operation
that requires a syscall or any kind of kernel intervention at all.  It is an
assembly store instruction executed directly on the CPU by the program.  The
only time the kernel is involved in a store operation is if the virtual address
translation doesn't exist in the TLB (or is write-protected, etc..), in which
case the hardware generates a fault so the kernel take the required action to
populate the TLB with the translation.

Hope this answers your question.

Seth

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: misunderstanding of the virtual memory
  2013-05-09 16:57   ` Seth Jennings
@ 2013-05-10 15:57     ` Benjamin Teissier
  0 siblings, 0 replies; 3+ messages in thread
From: Benjamin Teissier @ 2013-05-10 15:57 UTC (permalink / raw)
  To: Seth Jennings; +Cc: linux-mm

2013/5/9, Seth Jennings <sjenning@linux.vnet.ibm.com>:
> On Thu, May 09, 2013 at 10:33:21AM -0400, Ben Teissier wrote:
>>
>> Hi,
>>
>> I'm Benjamin and I'm studying the kernel. I write you this email
>> because I've a trouble with the mmu and the virtual memory. I try to
>> understand how a program (user land) can write something into the stack
>> (push ebp, for example), indeed, the program works with virtual address
>> (between 0x00000 and 0x8... if my memory is good) but at the hardware
>> side the address is not the same (that's why mmu was created, if I'm
>> right).
>
> Yes, this is the purpose of pages tables; to map virtual addresses to real
> memory addresses (more precisely virtual memory _pages_ to real memory
> pages).
>
>>
>> My problem is the following : how the data is wrote on the physical
>> memory. When I try a strace (kernel 2.6.32 on a simple program) I have
>> no hint on the transfer of data. Moreover, according to the wikipedia
>> web page on syscall (
>> https://en.wikipedia.org/wiki/System_call#The_library_as_an_intermediary
>> ), a call is not managed by the kernel. So, how the transfer between
>> virtual memory and physical memory is possible ?
>
> That is because writing to a memory location in userspace isn't an
> operation
> that requires a syscall or any kind of kernel intervention at all.  It is
> an
> assembly store instruction executed directly on the CPU by the program.
> The
> only time the kernel is involved in a store operation is if the virtual
> address
> translation doesn't exist in the TLB (or is write-protected, etc..), in
> which
> case the hardware generates a fault so the kernel take the required action
> to
> populate the TLB with the translation.
>
> Hope this answers your question.
>
> Seth
>
>

Hi,

Your answer is perfect, thanks a lot for your help !

Benjamin.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2013-05-10 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <518BB132.5050802@gmail.com>
2013-05-09 14:33 ` misunderstanding of the virtual memory Ben Teissier
2013-05-09 16:57   ` Seth Jennings
2013-05-10 15:57     ` Benjamin Teissier

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.