On 22-11-07 14:07, Wang Yu wrote:
Usually I find the following codes in Linux source that I can not
understand clearly, it often happens when some error occured
char *kaddr = kmap_atomic(page, KM_USER0);
memset(kaddr, 0, PAGE_CACHE_SIZE);
flush_dcache_page(page);
kunmap_atomic(kaddr, KM_USER0);
what is the usage of memset function?
memset(addr, value, count) fills the memory from address "addr" to "addr +
count -1" with the byte "value". In this case, it zeros a page.
As to why; it's generally a security thing. When one application (GPG, say)
is done with a page and frees it, you want be sure that none will be able to
predict a pattern where they'll be able to get that just freed page assigned
to them now and read whatever interesting things were there.
and in i386 flush_dcache_page(page) does nothing, why?
As the comment says:
/* Caches aren't brain-dead on the intel. */
so the question can be answered by looking at architectures where they're
not empty. Those supposedly have a dcache that's braindead enough to need
manual flushing.
Rene.
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ