From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Maxime Bizon <mbizon@freebox.fr>,
Russell Currey <ruscur@russell.cc>
Subject: Re: [PATCH v2 1/2] powerpc/set_memory: Avoid spinlock recursion in change_page_attr()
Date: Thu, 23 Dec 2021 15:14:20 +0000 [thread overview]
Message-ID: <e07eefc3-6f84-2e95-05f2-8c56eb6a0c1f@csgroup.eu> (raw)
In-Reply-To: <871r2334ld.fsf@mpe.ellerman.id.au>
Le 23/12/2021 à 13:09, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>> Commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines")
>> included a spin_lock() to change_page_attr() in order to
>> safely perform the three step operations. But then
>> commit 9f7853d7609d ("powerpc/mm: Fix set_memory_*() against
>> concurrent accesses") modify it to use pte_update() and do
>> the operation atomically.
>
> It's not really atomic, it's just safe against concurrent access.
>
> We still do a read / modify / write of the pte value.
>
> Which isn't safe against concurrent calls to change_page_attr() for the
> same address.
>
> But maybe that's OK? AFAICS other architectures (eg. arm64) have no
> protection against concurrent callers. I think the assumption is higher
> level code is ensuring there's only a single caller at a time.
>
> On the other hand x86 and s390 do have locking (cpa_lock / cpa_mutex).
> But it seems that's mostly to protect against splitting of page tables,
> which we aren't doing.
>
> We'd be a bit safer if we used pte_update() "properly", like I did in:
>
> https://lore.kernel.org/linuxppc-dev/20210817132552.3375738-1-mpe@ellerman.id.au/
>
>
Probably not so simple as that patch, but I get the idea.
See b6cb20fdc273 ("powerpc/book3e: Fix set_memory_x() and set_memory_nx()")
I think we then need to define platform specific helpers to do it,
similar to ptep_set_wrprotect() and avoid an #ifdefery in change_page_attr()
Christophe
prev parent reply other threads:[~2021-12-23 15:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 17:47 Christophe Leroy
2021-12-16 17:47 ` [PATCH v2 2/2] powerpc: Add set_memory_{p/np}() and remove set_memory_attr() Christophe Leroy
2021-12-17 9:25 ` [PATCH v2 1/2] powerpc/set_memory: Avoid spinlock recursion in change_page_attr() Maxime Bizon
2021-12-23 12:09 ` Michael Ellerman
2021-12-23 15:14 ` Christophe Leroy [this message]
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=e07eefc3-6f84-2e95-05f2-8c56eb6a0c1f@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mbizon@freebox.fr \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=ruscur@russell.cc \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®