From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Nicholas Piggin <npiggin@gmail.com>,
Michael Ellerman <mpe@ellerman.id.au>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH 3/4] powerpc/kuap: Refactor static branch for disabling kuap
Date: Thu, 22 Jun 2023 06:08:49 +0000 [thread overview]
Message-ID: <59568be8-1164-042e-d843-ef5d45c1591c@csgroup.eu> (raw)
In-Reply-To: <CT5GCZLAL3QC.URC3KKG0M0WR@wheely>
Le 06/06/2023 à 11:16, Nicholas Piggin a écrit :
> On Mon Jun 5, 2023 at 9:04 PM AEST, Christophe Leroy wrote:
>> All but book3s/64 use a static branch key for disabling kuap.
>> book3s/64 uses a memory feature.
>>
>> Refactor all targets except book3s/64.
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>> ---
>> arch/powerpc/include/asm/book3s/32/kup.h | 7 -------
>> arch/powerpc/include/asm/book3s/64/kup.h | 1 +
>> arch/powerpc/include/asm/kup.h | 15 +++++++++++++++
>> arch/powerpc/include/asm/nohash/32/kup-8xx.h | 7 -------
>> arch/powerpc/include/asm/nohash/kup-booke.h | 7 -------
>> arch/powerpc/mm/book3s32/kuap.c | 3 ---
>> arch/powerpc/mm/init-common.c | 3 +++
>> arch/powerpc/mm/nohash/kup.c | 3 ---
>> 8 files changed, 19 insertions(+), 27 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/book3s/32/kup.h b/arch/powerpc/include/asm/book3s/32/kup.h
>> index 466a19cfb4df..8da9997a67ba 100644
>> --- a/arch/powerpc/include/asm/book3s/32/kup.h
>> +++ b/arch/powerpc/include/asm/book3s/32/kup.h
>> @@ -11,8 +11,6 @@
>>
>> #include <linux/jump_label.h>
>>
>> -extern struct static_key_false disable_kuap_key;
>> -
>> static __always_inline bool kuep_is_disabled(void)
>> {
>> return !IS_ENABLED(CONFIG_PPC_KUEP);
>> @@ -25,11 +23,6 @@ static __always_inline bool kuep_is_disabled(void)
>> #define KUAP_NONE (~0UL)
>> #define KUAP_ALL (~1UL)
>>
>> -static __always_inline bool kuap_is_disabled(void)
>> -{
>> - return static_branch_unlikely(&disable_kuap_key);
>> -}
>> -
>> static inline void kuap_lock_one(unsigned long addr)
>> {
>> mtsr(mfsr(addr) | SR_KS, addr);
>> diff --git a/arch/powerpc/include/asm/book3s/64/kup.h b/arch/powerpc/include/asm/book3s/64/kup.h
>> index 1b0215ff3710..f8b8e93c488c 100644
>> --- a/arch/powerpc/include/asm/book3s/64/kup.h
>> +++ b/arch/powerpc/include/asm/book3s/64/kup.h
>> @@ -233,6 +233,7 @@ static __always_inline bool kuap_is_disabled(void)
>> {
>> return !mmu_has_feature(MMU_FTR_BOOK3S_KUAP);
>> }
>> +#define kuap_is_disabled kuap_is_disabled
>
> Is there any point to doing this pattern since the code is in places
> that have ifdef PPC6 S etc?
I'm not sure what you have in mind.
There is a default kuap_is_disabled() in arch/powerpc/include/asm/kup.h
For 64s we want the version from
arch/powerpc/include/asm/book3s/64/kup.h instead of the default one.
And kuap_is_disabled() is used in some common code in
arch/powerpc/include/asm/kup.h, not only in the code encloded by #ifndef 64s
>
>> diff --git a/arch/powerpc/mm/init-common.c b/arch/powerpc/mm/init-common.c
>> index 119ef491f797..74e140b1efef 100644
>> --- a/arch/powerpc/mm/init-common.c
>> +++ b/arch/powerpc/mm/init-common.c
>> @@ -32,6 +32,9 @@ EXPORT_SYMBOL_GPL(kernstart_virt_addr);
>> bool disable_kuep = !IS_ENABLED(CONFIG_PPC_KUEP);
>> bool disable_kuap = !IS_ENABLED(CONFIG_PPC_KUAP);
>>
>> +struct static_key_false disable_kuap_key;
>> +EXPORT_SYMBOL(disable_kuap_key);
>> +
>
> That's going to define it on 64s?
Is that a problem at all ?
By the way I was thinking about also using that key on 64s, will look at
it as a second step.
Thanks for the review
Christophe
>
> Nice refactoring though.
>
> Thanks,
> Nick
next prev parent reply other threads:[~2023-06-22 6:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 11:04 [PATCH 1/4] powerpc/kuap: Avoid unnecessary reads of MD_AP Christophe Leroy
2023-06-05 11:04 ` [PATCH 2/4] powerpc/kuap: Avoid useless jump_label on empty function Christophe Leroy
2023-06-06 9:12 ` Nicholas Piggin
2023-06-05 11:04 ` [PATCH 3/4] powerpc/kuap: Refactor static branch for disabling kuap Christophe Leroy
2023-06-06 9:16 ` Nicholas Piggin
2023-06-22 6:08 ` Christophe Leroy [this message]
2023-06-05 11:04 ` [PATCH 4/4] powerpc/kuap: Make disabling KUAP at boottime optional Christophe Leroy
2023-06-06 9:27 ` Nicholas Piggin
2023-06-22 6:20 ` Christophe Leroy
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=59568be8-1164-042e-d843-ef5d45c1591c@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=npiggin@gmail.com \
/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®