linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [Question] flush_dcache_page() need to flush icache?
@ 2013-04-30  8:16 Ming Lei
  2013-04-30  9:05 ` Catalin Marinas
  0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2013-04-30  8:16 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

Looks flush_dcache_page() need to deal with both dcache alias and I/D
cache coherency, but set_pte_at() has already run __sync_icache_dcache()
to make I/D cache coherency in the path of executable page fault.

So could the flushing icache be removed in flush_dcache_page()?

If it is yes for the above question, could the flushing dcache in case of
vipt nonaliasing be removed in flush_dcache_page() too?

Maybe they are stupid questions, sorry in advance.

Thanks,
-- 
Ming Lei

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

* [Question] flush_dcache_page() need to flush icache?
  2013-04-30  8:16 [Question] flush_dcache_page() need to flush icache? Ming Lei
@ 2013-04-30  9:05 ` Catalin Marinas
  2013-04-30 10:02   ` Ming Lei
  0 siblings, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2013-04-30  9:05 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 30, 2013 at 09:16:16AM +0100, Ming Lei wrote:
> Looks flush_dcache_page() need to deal with both dcache alias and I/D
> cache coherency, but set_pte_at() has already run __sync_icache_dcache()
> to make I/D cache coherency in the path of executable page fault.
> 
> So could the flushing icache be removed in flush_dcache_page()?

That's the case for (mapping && mapping_mapped(mapping)) where the
kernel modifies a page cache page which is already mapped in user space
and we won't get a subsequent set_pte_at() call.

-- 
Catalin

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

* [Question] flush_dcache_page() need to flush icache?
  2013-04-30  9:05 ` Catalin Marinas
@ 2013-04-30 10:02   ` Ming Lei
  2013-04-30 15:26     ` Catalin Marinas
  0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2013-04-30 10:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 30, 2013 at 5:05 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Tue, Apr 30, 2013 at 09:16:16AM +0100, Ming Lei wrote:
>> Looks flush_dcache_page() need to deal with both dcache alias and I/D
>> cache coherency, but set_pte_at() has already run __sync_icache_dcache()
>> to make I/D cache coherency in the path of executable page fault.
>>
>> So could the flushing icache be removed in flush_dcache_page()?
>
> That's the case for (mapping && mapping_mapped(mapping)) where the
> kernel modifies a page cache page which is already mapped in user space
> and we won't get a subsequent set_pte_at() call.

OK, I got it, so looks it is only needed in self-modifying-code case, but I am
wondering why it is always done for all cases of (mapping &&
mapping_mapped(mapping))......

Thanks,
-- 
Ming Lei

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

* [Question] flush_dcache_page() need to flush icache?
  2013-04-30 10:02   ` Ming Lei
@ 2013-04-30 15:26     ` Catalin Marinas
  2013-05-01  8:11       ` Ming Lei
  0 siblings, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2013-04-30 15:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 30, 2013 at 11:02:36AM +0100, Ming Lei wrote:
> On Tue, Apr 30, 2013 at 5:05 PM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> > On Tue, Apr 30, 2013 at 09:16:16AM +0100, Ming Lei wrote:
> >> Looks flush_dcache_page() need to deal with both dcache alias and I/D
> >> cache coherency, but set_pte_at() has already run __sync_icache_dcache()
> >> to make I/D cache coherency in the path of executable page fault.
> >>
> >> So could the flushing icache be removed in flush_dcache_page()?
> >
> > That's the case for (mapping && mapping_mapped(mapping)) where the
> > kernel modifies a page cache page which is already mapped in user space
> > and we won't get a subsequent set_pte_at() call.
> 
> OK, I got it, so looks it is only needed in self-modifying-code case,
> but I am wondering why it is always done for all cases of (mapping &&
> mapping_mapped(mapping))......

It's not self-modifying code, this would be code running in user space
which modifies some other code and it would invoke the ARM-specific
syscall for flushing.

Here it is about kernel modifying a page which is already mapped in user
space, hence the check for mapping && mapping_mapped.

-- 
Catalin

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

* [Question] flush_dcache_page() need to flush icache?
  2013-04-30 15:26     ` Catalin Marinas
@ 2013-05-01  8:11       ` Ming Lei
  2013-05-01  8:22         ` Catalin Marinas
  0 siblings, 1 reply; 7+ messages in thread
From: Ming Lei @ 2013-05-01  8:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 30, 2013 at 11:26 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
>
> It's not self-modifying code, this would be code running in user space
> which modifies some other code and it would invoke the ARM-specific
> syscall for flushing.
>
> Here it is about kernel modifying a page which is already mapped in user
> space, hence the check for mapping && mapping_mapped.

I understand that flushing icache is only needed when the page is mapped
as executable in virtual address, right?  If yes, the flush_dcache_page might
be inside read/write on one mapped page(executable in virtual space), then
still looks like self-modifying code case?

Thanks,
-- 
Ming Lei

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

* [Question] flush_dcache_page() need to flush icache?
  2013-05-01  8:11       ` Ming Lei
@ 2013-05-01  8:22         ` Catalin Marinas
  2013-05-01  8:53           ` Ming Lei
  0 siblings, 1 reply; 7+ messages in thread
From: Catalin Marinas @ 2013-05-01  8:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, May 01, 2013 at 09:11:47AM +0100, Ming Lei wrote:
> On Tue, Apr 30, 2013 at 11:26 PM, Catalin Marinas
> <catalin.marinas@arm.com> wrote:
> >
> > It's not self-modifying code, this would be code running in user space
> > which modifies some other code and it would invoke the ARM-specific
> > syscall for flushing.
> >
> > Here it is about kernel modifying a page which is already mapped in user
> > space, hence the check for mapping && mapping_mapped.
> 
> I understand that flushing icache is only needed when the page is mapped
> as executable in virtual address, right?  If yes, the flush_dcache_page might
> be inside read/write on one mapped page(executable in virtual space), then
> still looks like self-modifying code case?

It depends on the definition of 'self'. If by that you mean the user
application, it hasn't modified itself and it can't trigger
flush_dcache_page().

-- 
Catalin

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

* [Question] flush_dcache_page() need to flush icache?
  2013-05-01  8:22         ` Catalin Marinas
@ 2013-05-01  8:53           ` Ming Lei
  0 siblings, 0 replies; 7+ messages in thread
From: Ming Lei @ 2013-05-01  8:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, May 1, 2013 at 4:22 PM, Catalin Marinas <catalin.marinas@arm.com> wrote:
>
> It depends on the definition of 'self'. If by that you mean the user
> application, it hasn't modified itself and it can't trigger
> flush_dcache_page().

Yes, you are right, and it is the case in which one user application
modifies code of another application. I mean if it is possible to flush
icache only under this situation, which should be very rare.


Thanks,
-- 
Ming Lei

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

end of thread, other threads:[~2013-05-01  8:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-30  8:16 [Question] flush_dcache_page() need to flush icache? Ming Lei
2013-04-30  9:05 ` Catalin Marinas
2013-04-30 10:02   ` Ming Lei
2013-04-30 15:26     ` Catalin Marinas
2013-05-01  8:11       ` Ming Lei
2013-05-01  8:22         ` Catalin Marinas
2013-05-01  8:53           ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).