From: Michael Ellerman <mpe@ellerman.id.au>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
Nicholas Piggin <npiggin@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH 2/2] powerpc: Don't ignore errors from set_memory_{n}p() in __kernel_map_pages()
Date: Thu, 22 Feb 2024 09:59:35 +1100 [thread overview]
Message-ID: <875xyhbezs.fsf@mail.lhotse> (raw)
In-Reply-To: <eefeb056-bc71-46ad-90b3-b07c392f5903@csgroup.eu>
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 21/02/2024 à 13:09, Michael Ellerman a écrit :
>> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>>> set_memory_p() and set_memory_np() can fail.
>>>
>>> As mentioned in linux/mm.h:
>>>
>>> /*
>>> * To support DEBUG_PAGEALLOC architecture must ensure that
>>> * __kernel_map_pages() never fails
>>> */
>>>
>>> So panic in case set_memory_p() or set_memory_np() fail
>>> in __kernel_map_pages().
>>>
>>> Link: https://github.com/KSPP/linux/issues/7
>>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>>> ---
>>> arch/powerpc/include/asm/book3s/64/hash.h | 2 +-
>>> arch/powerpc/mm/book3s64/hash_utils.c | 3 ++-
>>> arch/powerpc/mm/pageattr.c | 10 +++++++---
>>> 3 files changed, 10 insertions(+), 5 deletions(-)
>>>
>> ...
>>> diff --git a/arch/powerpc/mm/pageattr.c b/arch/powerpc/mm/pageattr.c
>>> index 16b8d20d6ca8..62b678585878 100644
>>> --- a/arch/powerpc/mm/pageattr.c
>>> +++ b/arch/powerpc/mm/pageattr.c
>>> @@ -106,17 +106,21 @@ int change_memory_attr(unsigned long addr, int numpages, long action)
>>> #ifdef CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC
>>> void __kernel_map_pages(struct page *page, int numpages, int enable)
>>> {
>>> + int err;
>>> unsigned long addr = (unsigned long)page_address(page);
>>>
>>> if (PageHighMem(page))
>>> return;
>>>
>>> if (IS_ENABLED(CONFIG_PPC_BOOK3S_64) && !radix_enabled())
>>> - hash__kernel_map_pages(page, numpages, enable);
>>> + err = hash__kernel_map_pages(page, numpages, enable);
>>> else if (enable)
>>> - set_memory_p(addr, numpages);
>>> + err = set_memory_p(addr, numpages);
>>> else
>>> - set_memory_np(addr, numpages);
>>> + err = set_memory_np(addr, numpages);
>>> +
>>> + if (err)
>>> + panic("%s: set_memory_%sp() failed\n", enable ? "" : "n");
>>
>> This doesn't compile, it's missing __func__ I guess.
>
> Damn, I was too quick when I took into account checkpatch's feedback,
> sorry for that.
>
>>
>> Seems like we could keep it simpler though, it should hopefully never
>> happen anyway, eg:
>>
>> panic("%s: changing memory protections failed\n", __func__);
>
> Sure, let's do that. Do you want a v2 or you do the change directly ?
No need for a v2, I'll just fix it up when applying.
cheers
next prev parent reply other threads:[~2024-02-21 22:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 10:17 [PATCH 1/2] powerpc: Refactor __kernel_map_pages() Christophe Leroy
2024-02-16 10:17 ` [PATCH 2/2] powerpc: Don't ignore errors from set_memory_{n}p() in __kernel_map_pages() Christophe Leroy
2024-02-21 12:09 ` Michael Ellerman
2024-02-21 12:55 ` Christophe Leroy
2024-02-21 22:59 ` Michael Ellerman [this message]
2024-02-22 5:32 ` [PATCH 1/2] powerpc: Refactor __kernel_map_pages() Michael Ellerman
2024-02-22 7:59 ` Christophe Leroy
2024-02-23 6:28 ` Michael Ellerman
2024-03-13 13:19 ` Michael Ellerman
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=875xyhbezs.fsf@mail.lhotse \
--to=mpe@ellerman.id.au \
--cc=christophe.leroy@csgroup.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--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