* [PATCH] parisc: Fix non-access data TLB cache flush faults
@ 2022-03-09 18:57 John David Anglin
2022-03-10 20:57 ` Sven Schnelle
0 siblings, 1 reply; 3+ messages in thread
From: John David Anglin @ 2022-03-09 18:57 UTC (permalink / raw)
To: linux-parisc; +Cc: Helge Deller, Deller, James Bottomley
[-- Attachment #1: Type: text/plain, Size: 2212 bytes --]
When a page is not present, we get non-access data TLB faults from
the fdc and fic instructions in flush_user_dcache_range_asm and
flush_user_icache_range_asm. When these occur, the cache line is
not invalidated and potentially we get memory corruption. The
problem was hidden by the nullification of the flush instructions.
These faults also affect performance. With pa8800/pa8900 processors,
there will be 32 faults per 4 KB page since the cache line is 128
bytes. The will be more faults with earlier processors.
The problem is fixed by using flush_cache_pages(). It does the flush
using a tmp alias mapping.
The flush_cache_pages() call in flush_cache_range() flushed too
large a range.
Signed-off-by: John David Anglin <dave.anglin@bell.net>
---
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index 94150b91c96f..e439b53b0f62 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -558,15 +558,6 @@ static void flush_cache_pages(struct vm_area_struct *vma, struct mm_struct *mm,
}
}
-static void flush_user_cache_tlb(struct vm_area_struct *vma,
- unsigned long start, unsigned long end)
-{
- flush_user_dcache_range_asm(start, end);
- if (vma->vm_flags & VM_EXEC)
- flush_user_icache_range_asm(start, end);
- flush_tlb_range(vma, start, end);
-}
-
void flush_cache_mm(struct mm_struct *mm)
{
struct vm_area_struct *vma;
@@ -582,13 +573,6 @@ void flush_cache_mm(struct mm_struct *mm)
}
preempt_disable();
- if (mm->context == mfsp(3)) {
- for (vma = mm->mmap; vma; vma = vma->vm_next)
- flush_user_cache_tlb(vma, vma->vm_start, vma->vm_end);
- preempt_enable();
- return;
- }
-
for (vma = mm->mmap; vma; vma = vma->vm_next)
flush_cache_pages(vma, mm, vma->vm_start, vma->vm_end);
preempt_enable();
@@ -606,13 +590,7 @@ void flush_cache_range(struct vm_area_struct *vma,
}
preempt_disable();
- if (vma->vm_mm->context == mfsp(3)) {
- flush_user_cache_tlb(vma, start, end);
- preempt_enable();
- return;
- }
-
- flush_cache_pages(vma, vma->vm_mm, vma->vm_start, vma->vm_end);
+ flush_cache_pages(vma, vma->vm_mm, start, end);
preempt_enable();
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] parisc: Fix non-access data TLB cache flush faults
2022-03-09 18:57 [PATCH] parisc: Fix non-access data TLB cache flush faults John David Anglin
@ 2022-03-10 20:57 ` Sven Schnelle
2022-03-10 22:52 ` John David Anglin
0 siblings, 1 reply; 3+ messages in thread
From: Sven Schnelle @ 2022-03-10 20:57 UTC (permalink / raw)
To: John David Anglin; +Cc: linux-parisc, Helge Deller, Deller, James Bottomley
Hi Dave,
John David Anglin <dave.anglin@bell.net> writes:
> When a page is not present, we get non-access data TLB faults from
> the fdc and fic instructions in flush_user_dcache_range_asm and
> flush_user_icache_range_asm. When these occur, the cache line is
> not invalidated and potentially we get memory corruption. The
> problem was hidden by the nullification of the flush instructions.
>
> These faults also affect performance. With pa8800/pa8900 processors,
> there will be 32 faults per 4 KB page since the cache line is 128
> bytes. The will be more faults with earlier processors.
>
> The problem is fixed by using flush_cache_pages(). It does the flush
> using a tmp alias mapping.
>
> The flush_cache_pages() call in flush_cache_range() flushed too
> large a range.
>
> Signed-off-by: John David Anglin <dave.anglin@bell.net>
> ---
>
> diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
> index 94150b91c96f..e439b53b0f62 100644
> --- a/arch/parisc/kernel/cache.c
> +++ b/arch/parisc/kernel/cache.c
> @@ -558,15 +558,6 @@ static void flush_cache_pages(struct vm_area_struct *vma, struct mm_struct *mm,
> }
> }
>
> -static void flush_user_cache_tlb(struct vm_area_struct *vma,
> - unsigned long start, unsigned long end)
> -{
> - flush_user_dcache_range_asm(start, end);
> - if (vma->vm_flags & VM_EXEC)
> - flush_user_icache_range_asm(start, end);
> - flush_tlb_range(vma, start, end);
> -}
> -
> void flush_cache_mm(struct mm_struct *mm)
> {
> struct vm_area_struct *vma;
> @@ -582,13 +573,6 @@ void flush_cache_mm(struct mm_struct *mm)
> }
>
> preempt_disable();
> - if (mm->context == mfsp(3)) {
> - for (vma = mm->mmap; vma; vma = vma->vm_next)
> - flush_user_cache_tlb(vma, vma->vm_start, vma->vm_end);
> - preempt_enable();
> - return;
> - }
> -
> for (vma = mm->mmap; vma; vma = vma->vm_next)
> flush_cache_pages(vma, mm, vma->vm_start, vma->vm_end);
> preempt_enable();
> @@ -606,13 +590,7 @@ void flush_cache_range(struct vm_area_struct *vma,
> }
>
> preempt_disable();
> - if (vma->vm_mm->context == mfsp(3)) {
> - flush_user_cache_tlb(vma, start, end);
> - preempt_enable();
> - return;
> - }
> -
> - flush_cache_pages(vma, vma->vm_mm, vma->vm_start, vma->vm_end);
> + flush_cache_pages(vma, vma->vm_mm, start, end);
> preempt_enable();
> }
>
I think the preempt_enable()/disable() calls are no longer
required. I've added them to fix a bug when the kernel is preempted
after the mm->context / mfsp(3) compare but as that is now removed
this shouldn't be required anymore.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] parisc: Fix non-access data TLB cache flush faults
2022-03-10 20:57 ` Sven Schnelle
@ 2022-03-10 22:52 ` John David Anglin
0 siblings, 0 replies; 3+ messages in thread
From: John David Anglin @ 2022-03-10 22:52 UTC (permalink / raw)
To: Sven Schnelle; +Cc: linux-parisc, Helge Deller, Deller, James Bottomley
On 2022-03-10 3:57 p.m., Sven Schnelle wrote:
> I think the preempt_enable()/disable() calls are no longer
> required. I've added them to fix a bug when the kernel is preempted
> after the mm->context / mfsp(3) compare but as that is now removed
> this shouldn't be required anymore.
Good thought. I'll test.
Dave
--
John David Anglin dave.anglin@bell.net
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-10 22:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-09 18:57 [PATCH] parisc: Fix non-access data TLB cache flush faults John David Anglin
2022-03-10 20:57 ` Sven Schnelle
2022-03-10 22:52 ` John David Anglin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox