RE: Address spaces on a i386 - Getting Confused

Paul Sargent (Paul.Sargent@3dlabs.com)
Tue, 30 Mar 1999 12:29:31 +0100


Hi David,

Let's just say I'm learning about the linux kernel with a device I
understand.

OK, so user process address space lies below 0xC0000000 and there is a
different mapping per process. Kernel mappings are above 0xC0000000 and are
constant. So when a syscall is run, we're still in the user process context,
therefore the userspace mappings still exist for that process. (How am I
doing?) This means that the copy-from-user() and copy-to-user() can just be
simple copies.

But I'm still confused by the virt-to-phys macro. I would have thought if I
want to find the physical address of a user space buffer I would have to go
through the page table to fins out where is physical page is, not just mask
off some bits.

Cheers

Paul

> -----Original Message-----
> From: David Miller [SMTP:davem@twiddle.net]
> Sent: Tuesday, March 30, 1999 11:47 AM
> To: Paul.Sargent@3dlabs.com
> Cc: linux-kernel@vger.rutgers.edu
> Subject: Re: Address spaces on a i386 - Getting Confused
>
> From: Paul Sargent <Paul.Sargent@3dlabs.com>
> Date: Tue, 30 Mar 1999 11:35:39 +0100
>
> Now by my reckoning this would give a 1:1 virtual to physical memory
> mapping, so why bother with virtual addresses.
>
> Because user space is at 0x0 --> 0xc0000000
>
> All of the kernel and the current user process mapped by the tlb on
> the x86 cpu using the page tables setup by the memory management layer
> of ther kernel (mostly, arch/i386/mm/init.c, mm/*.c,
> include/asm-i386/{pgtable,page}.h)
>
> The kernel mappings are present for each user address space, but the
> mappings below 0xc0000000 are unique for each user.
>
> So when the copy is done from user space to kernel space for your
> read() example, the TLB maps the user's virtual address to the
> physical page the kernel gave to it and the copy data comes from
> there, likewise for the kernel destination addresses even though it's
> just a straight 1:1 mapping.
>
> Trying to write some kernel video card drivers are we? :-)
>
> Later,
> David S. Miller
> davem@redhat.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/