On 01/16/2017 09:47 PM, David Miller wrote:
From: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Date: Wed, 11 Jan 2017 10:13:54 -0800
For memory shared by two different processes, do they have to agree on
what the tags are, or can they differ?
Whoever allocates the memory (does the mmap()+mprotect() or whatever),
decides on the tag. They set it, and this determines which virtual
address is valid to access that mapping.
It's like kmalloc() returns pointers with some weird bits set in the
upper bits of the address. Behind the scenes kmalloc() sets the
TAG bits appropriately.
It doesn't, in that sense, matter where in the non-tagged virtual
address space the memory is mapped. All that matters is that, for
a given page, the TAG bits in the virtual address used for loads
and stores to that mapping are set properly.
I think the fundamental thing being missed is that the TAG bits in the
virtual address are not interpreted by the TLB. They are chopped off
before virtual address translation occurs.
The TAG bits of the virtual address serve only to indicate what ADI
value the load or store thinks is valid to use for access to that
piece of memory.
Or something like that... :-)
Hi David,
Your explanation is spot on. MMU looks at the tag bits only to determine
if the process has permission to access the memory address. Tag bits are
not part of VA->PA translation. The tags are stored in physical memory
though and MMU compares the tag stored at physical address obtained from
TLB translation to the tag embedded in VA. What that means is if two
processes map the same physical page in their address space, they both
must embed the same tag in the VA they present to MMU irrespective of
where in each process' address space the page is mapped in. If one
process changes the tag, stored in physical memory, the other process
must also embed the new tag in its VA when accessing this shared mapped
page. This is something to consider because a tag can be set and changed
entirely from userspace with no kernel involvement as long as the
process has write access to memory.
--
Khalid
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html