From: Mike Rapoport <rppt@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>,
Song Liu <song@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
"Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>,
Stephen Rothwell <sfr@canb.auug.org.au>,
Christian Brauner <brauner@kernel.org>,
Pankaj Raghav <p.raghav@samsung.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Next Mailing List <linux-next@vger.kernel.org>,
djwong@kernel.org, ritesh.list@gmail.com,
linuxppc-dev@lists.ozlabs.org
Subject: Re: linux-next: boot warning after merge of the vfs-brauner tree
Date: Tue, 27 Aug 2024 18:38:57 +0300 [thread overview]
Message-ID: <Zs3zEcLh5cMykkho@kernel.org> (raw)
In-Reply-To: <ZszrJkFOpiy5rCma@bombadil.infradead.org>
On Mon, Aug 26, 2024 at 01:52:54PM -0700, Luis Chamberlain wrote:
> On Mon, Aug 26, 2024 at 07:43:20PM +0200, Christophe Leroy wrote:
> >
> >
> > Le 26/08/2024 à 17:48, Pankaj Raghav (Samsung) a écrit :
> > > On Mon, Aug 26, 2024 at 05:59:31PM +1000, Stephen Rothwell wrote:
> > > > Hi all,
> > > >
> > > > After merging the vfs-brauner tree, today's linux-next boot test (powerpc
> > > > pseries_le_defconfig) produced this warning:
> > >
> > > iomap dio calls set_memory_ro() on the page that is used for sub block
> > > zeroing.
> > >
> > > But looking at powerpc code, they don't support set_memory_ro() for
> > > memory region that belongs to the kernel(LINEAR_MAP_REGION_ID).
> > >
> > > /*
> > > * On hash, the linear mapping is not in the Linux page table so
> > > * apply_to_existing_page_range() will have no effect. If in the future
> > > * the set_memory_* functions are used on the linear map this will need
> > > * to be updated.
> > > */
> > > if (!radix_enabled()) {
> > > int region = get_region_id(addr);
> > >
> > > if (WARN_ON_ONCE(region != VMALLOC_REGION_ID && region != IO_REGION_ID))
> > > return -EINVAL;
> > > }
> > >
> > > We call set_memory_ro() on the zero page as a extra security measure.
> > > I don't know much about powerpc, but looking at the comment, is it just
> > > adding the following to support it in powerpc:
> > >
> > > diff --git a/arch/powerpc/mm/pageattr.c b/arch/powerpc/mm/pageattr.c
> > > index ac22bf28086fa..e6e0b40ba6db4 100644
> > > --- a/arch/powerpc/mm/pageattr.c
> > > +++ b/arch/powerpc/mm/pageattr.c
> > > @@ -94,7 +94,9 @@ int change_memory_attr(unsigned long addr, int numpages, long action)
> > > if (!radix_enabled()) {
> > > int region = get_region_id(addr);
> > > - if (WARN_ON_ONCE(region != VMALLOC_REGION_ID && region != IO_REGION_ID))
> > > + if (WARN_ON_ONCE(region != VMALLOC_REGION_ID &&
> > > + region != IO_REGION_ID &&
> > > + region != LINEAR_MAP_REGION_ID))
> > > return -EINVAL;
> > > }
> > > #endif
> >
> > By doing this you will just hide the fact that it didn't work.
> >
> > See commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines") for
> > details. The linear memory region is not mapped using page tables so
> > set_memory_ro() will have no effect on it.
> >
> > You can either use vmalloc'ed pages, or do a const static allocation at
> > buildtime so that it will be allocated in the kernel static rodata area.
> >
> > By the way, your code should check the value returned by set_memory_ro(),
> > there is some work in progress to make it mandatory, see
> > https://github.com/KSPP/linux/issues/7
>
> Our users expect contiguous memory [0] and so we use alloc_pages() here,
> so if we're architecture limitted by this I'd rather we just remove the
> set_memory_ro() only for PPC, I don't see why other have to skip this.
>
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index c02b266bba52..aba5cde89e14 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -775,14 +775,22 @@ EXPORT_SYMBOL_GPL(iomap_dio_rw);
>
> static int __init iomap_dio_init(void)
> {
> + int ret;
> +
> zero_page = alloc_pages(GFP_KERNEL | __GFP_ZERO,
> IOMAP_ZERO_PAGE_ORDER);
>
> if (!zero_page)
> return -ENOMEM;
>
> - set_memory_ro((unsigned long)page_address(zero_page),
> - 1U << IOMAP_ZERO_PAGE_ORDER);
> - return 0;
> + if (IS_ENABLED(CONFIG_PPC))
> + return 0;
> +
> + ret = set_memory_ro((unsigned long)page_address(zero_page),
> + 1U << IOMAP_ZERO_PAGE_ORDER);
> + if (ret)
> + free_pages((unsigned long) zero_page, IOMAP_ZERO_PAGE_ORDER);
arm64 will return -EINVAL here, their code for changing memory attributes
only works on vmalloc:
* Let's restrict ourselves to mappings created by vmalloc (or vmap).
* Those are guaranteed to consist entirely of page mappings, and
* splitting is never needed.
> +
> + return ret;
> }
> fs_initcall(iomap_dio_init);
>
> Thoughts?
>
> [0] https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/commit/?h=vfs.blocksize&id=d940b3b7b76b409b0550fdf2de6dc2183f01526f
>
> Luis
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2024-08-27 15:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 7:59 linux-next: boot warning after merge of the vfs-brauner tree Stephen Rothwell
2024-08-26 15:48 ` Pankaj Raghav (Samsung)
2024-08-26 17:43 ` Christophe Leroy
2024-08-26 20:52 ` Luis Chamberlain
2024-08-26 21:10 ` Darrick J. Wong
2024-08-26 21:41 ` Luis Chamberlain
2024-08-27 5:26 ` Ritesh Harjani
2024-08-27 15:38 ` Mike Rapoport [this message]
2024-08-27 6:28 ` 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=Zs3zEcLh5cMykkho@kernel.org \
--to=rppt@kernel.org \
--cc=arnd@arndb.de \
--cc=brauner@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=djwong@kernel.org \
--cc=kernel@pankajraghav.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mcgrof@kernel.org \
--cc=p.raghav@samsung.com \
--cc=ritesh.list@gmail.com \
--cc=sfr@canb.auug.org.au \
--cc=song@kernel.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.