From: Alexandre Ghiti <alex@ghiti.fr> To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Jisheng Zhang <jszhang@kernel.org>, Christoph Hellwig <hch@infradead.org>, Zong Li <zong.li@sifive.com>, Anup Patel <anup@brainfault.org>, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti <alex@ghiti.fr> Subject: [PATCH v7 0/2] Map the kernel with correct permissions the first time Date: Tue, 22 Jun 2021 10:21:32 +0200 [thread overview] Message-ID: <20210622082134.2404162-1-alex@ghiti.fr> (raw) The kernel permissions are fixed after the kernel page table is created: avoid that by mapping the kernel 'correctly' the first time. Patch 1 introduces a new helper to set kernel mapping permissions while avoiding all the casts when using set_memory_* API. Patch 2 is the bulk of this work and deals with mapping the kernel with the right permissions. Changes in v7: * Split long lines and reintroduce parameters names of set_kernel_memory callback, as suggested by Christoph * Make set_kernel_memory __always_inline as suggested by Christoph * Change 64b spelling into 64-bit, as suggested by Christoph Changes in v6: * load_sz was placed in init section but is now used in kernel address conversions macros, so remove this attribute. Changes in v5: * Remove non-relevant commits to this patchset that raised issues * Make load_sz non-static as it is used in kernel address conversions macros * Rebased on top for-next Changes in v4: * Add patch 1 as noted by Jisheng * Changes patch 2 title as suggested by Anup * Add Reviewed-by from Anup Changes in v3: * Add a patch that factorizes kernel address conversions * Add a helper called set_kernel_memory in its own patch, as suggested by Christoph * Prefer IS_ENABLED over #ifdef, as suggested by Christoph * Split overly long lines, as suggested by Christoph * Simplify kernel mapping by mapping ALL text as readonly and taking advantage of already present code that enables write for init text before free_initmem_default. Changes in v2: * Rebased on top of for-next (and "riscv: mm: fix build errors caused by mk_pmd()") * Get rid of protect_kernel_linear_mapping_text_rodata as suggested by Jisheng * Improve code in general compared to previous RFC Alexandre Ghiti (2): riscv: Introduce set_kernel_memory helper riscv: Map the kernel with correct permissions the first time arch/riscv/include/asm/page.h | 13 +++- arch/riscv/include/asm/sections.h | 17 +++++ arch/riscv/include/asm/set_memory.h | 16 ++-- arch/riscv/kernel/setup.c | 12 +-- arch/riscv/mm/init.c | 112 ++++++++++++---------------- arch/riscv/mm/pageattr.c | 11 +++ 6 files changed, 100 insertions(+), 81 deletions(-) -- 2.30.2
WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Ghiti <alex@ghiti.fr> To: Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Jisheng Zhang <jszhang@kernel.org>, Christoph Hellwig <hch@infradead.org>, Zong Li <zong.li@sifive.com>, Anup Patel <anup@brainfault.org>, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti <alex@ghiti.fr> Subject: [PATCH v7 0/2] Map the kernel with correct permissions the first time Date: Tue, 22 Jun 2021 10:21:32 +0200 [thread overview] Message-ID: <20210622082134.2404162-1-alex@ghiti.fr> (raw) The kernel permissions are fixed after the kernel page table is created: avoid that by mapping the kernel 'correctly' the first time. Patch 1 introduces a new helper to set kernel mapping permissions while avoiding all the casts when using set_memory_* API. Patch 2 is the bulk of this work and deals with mapping the kernel with the right permissions. Changes in v7: * Split long lines and reintroduce parameters names of set_kernel_memory callback, as suggested by Christoph * Make set_kernel_memory __always_inline as suggested by Christoph * Change 64b spelling into 64-bit, as suggested by Christoph Changes in v6: * load_sz was placed in init section but is now used in kernel address conversions macros, so remove this attribute. Changes in v5: * Remove non-relevant commits to this patchset that raised issues * Make load_sz non-static as it is used in kernel address conversions macros * Rebased on top for-next Changes in v4: * Add patch 1 as noted by Jisheng * Changes patch 2 title as suggested by Anup * Add Reviewed-by from Anup Changes in v3: * Add a patch that factorizes kernel address conversions * Add a helper called set_kernel_memory in its own patch, as suggested by Christoph * Prefer IS_ENABLED over #ifdef, as suggested by Christoph * Split overly long lines, as suggested by Christoph * Simplify kernel mapping by mapping ALL text as readonly and taking advantage of already present code that enables write for init text before free_initmem_default. Changes in v2: * Rebased on top of for-next (and "riscv: mm: fix build errors caused by mk_pmd()") * Get rid of protect_kernel_linear_mapping_text_rodata as suggested by Jisheng * Improve code in general compared to previous RFC Alexandre Ghiti (2): riscv: Introduce set_kernel_memory helper riscv: Map the kernel with correct permissions the first time arch/riscv/include/asm/page.h | 13 +++- arch/riscv/include/asm/sections.h | 17 +++++ arch/riscv/include/asm/set_memory.h | 16 ++-- arch/riscv/kernel/setup.c | 12 +-- arch/riscv/mm/init.c | 112 ++++++++++++---------------- arch/riscv/mm/pageattr.c | 11 +++ 6 files changed, 100 insertions(+), 81 deletions(-) -- 2.30.2 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2021-06-22 8:21 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-22 8:21 Alexandre Ghiti [this message] 2021-06-22 8:21 ` [PATCH v7 0/2] Map the kernel with correct permissions the first time Alexandre Ghiti 2021-06-22 8:21 ` [PATCH v7 1/2] riscv: Introduce set_kernel_memory helper Alexandre Ghiti 2021-06-22 8:21 ` Alexandre Ghiti 2021-06-22 14:53 ` Jisheng Zhang 2021-06-22 14:53 ` Jisheng Zhang 2021-06-23 7:11 ` Christoph Hellwig 2021-06-23 7:11 ` Christoph Hellwig 2021-06-22 8:21 ` [PATCH v7 2/2] riscv: Map the kernel with correct permissions the first time Alexandre Ghiti 2021-06-22 8:21 ` Alexandre Ghiti
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=20210622082134.2404162-1-alex@ghiti.fr \ --to=alex@ghiti.fr \ --cc=anup@brainfault.org \ --cc=aou@eecs.berkeley.edu \ --cc=hch@infradead.org \ --cc=jszhang@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-riscv@lists.infradead.org \ --cc=palmer@dabbelt.com \ --cc=paul.walmsley@sifive.com \ --cc=zong.li@sifive.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: linkBe 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.