All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Sven Schnelle <svens@stackframe.org>
Cc: linux-parisc@vger.kernel.org
Subject: Re: [PATCH 1/4] parisc: disable preemption during local tlb flush
Date: Sat, 9 Oct 2021 14:30:21 +0200	[thread overview]
Message-ID: <5c0536ef-87fa-a153-7e36-20010512cbaf@gmx.de> (raw)
In-Reply-To: <87tuhrjj2z.fsf@x1.stackframe.org>

On 10/8/21 23:35, Sven Schnelle wrote:
> Sven Schnelle <svens@stackframe.org> writes:
>
>> flush_cache_mm() fetches %sr3 via mtsp(3). If it matches mm->context,
>> it flushes caches and the TLB. However, the TLB is cpu-local, so if the
>> code gets preempted shortly after the mtsp(), and later resumed on another
>> CPU, the wrong TLB is flushed.
>>
>> Signed-off-by: Sven Schnelle <svens@stackframe.org>
>> ---
>>  arch/parisc/kernel/cache.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
>> index 39e02227e231..90656c49bc07 100644
>> --- a/arch/parisc/kernel/cache.c
>> +++ b/arch/parisc/kernel/cache.c
>> @@ -558,6 +558,7 @@ void flush_cache_mm(struct mm_struct *mm)
>>  		return;
>>  	}
>>
>> +	preempt_disable();
>>  	if (mm->context == mfsp(3)) {
>>  		for (vma = mm->mmap; vma; vma = vma->vm_next) {
>>  			flush_user_dcache_range_asm(vma->vm_start, vma->vm_end);
>> @@ -565,8 +566,10 @@ void flush_cache_mm(struct mm_struct *mm)
>>  				flush_user_icache_range_asm(vma->vm_start, vma->vm_end);
>>  			flush_tlb_range(vma, vma->vm_start, vma->vm_end);
>>  		}
>> +		preempt_enable();
>>  		return;
>>  	}
>> +	preempt_enable();
>>
>>  	pgd = mm->pgd;
>>  	for (vma = mm->mmap; vma; vma = vma->vm_next) {
>
> I noticed that flush_cache_range() has the same problem. Helge, let me
> know whether i should send a v2 with an additional patch, or a single
> follow up patch. Both functions also look very similar, so i think
> best would be to combine the code of these two functions.

I'm fine with either option.

Thanks for your patches!
Helge

  reply	other threads:[~2021-10-09 12:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08 20:48 [PATCH 0/4] parisc: fixes for CONFIG_PREEMPT Sven Schnelle
2021-10-08 20:48 ` [PATCH 1/4] parisc: disable preemption during local tlb flush Sven Schnelle
2021-10-08 21:35   ` Sven Schnelle
2021-10-09 12:30     ` Helge Deller [this message]
2021-10-08 20:48 ` [PATCH 2/4] parisc: fix preempt_count() check in entry.S Sven Schnelle
2021-10-08 20:48 ` [PATCH 3/4] parisc: disable preemption in send_IPI_allbutself() Sven Schnelle
2021-10-08 20:48 ` [PATCH 4/4] parisc: fix warning in flush_tlb_all Sven Schnelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c0536ef-87fa-a153-7e36-20010512cbaf@gmx.de \
    --to=deller@gmx.de \
    --cc=linux-parisc@vger.kernel.org \
    --cc=svens@stackframe.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.