2001-03-08 20:01:18

by Manfred Spraul

[permalink] [raw]
Subject: flush_page_to_ram() question in kernel/ptrace.c

>From linux/kernel/ptrace.c, access_one_page():

> flush_cache_page(vma, addr);
>
> if (write) {
> maddr = kmap(page);
> memcpy(maddr + (addr & ~PAGE_MASK), buf, len);
> flush_page_to_ram(page);
> flush_icache_page(vma, page);
> kunmap(page);
> } else {
> maddr = kmap(page);
> memcpy(buf, maddr + (addr & ~PAGE_MASK), len);
> flush_page_to_ram(page);
^^^^^^^^^^^^^^^^^^^^^^
> kunmap(page);
> }

Is this flush required?

The memcpy read from the mapping, it didn't write.

--
Manfred


2001-03-08 21:09:49

by David Miller

[permalink] [raw]
Subject: Re: flush_page_to_ram() question in kernel/ptrace.c


Manfred Spraul writes:
> > memcpy(buf, maddr + (addr & ~PAGE_MASK), len);
> > flush_page_to_ram(page);
> ^^^^^^^^^^^^^^^^^^^^^^
> Is this flush required?
>
> The memcpy read from the mapping, it didn't write.

You have to kick it out of the cache so that future reads on the
kernel side don't get stale data with caching setups that allow
illegal aliases to form.

Later,
David S. Miller
[email protected]