[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190328075526.GC14864@rapoport-lnx>
Date: Thu, 28 Mar 2019 09:55:26 +0200
From: Mike Rapoport <rppt@...ux.ibm.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: Anup Patel <anup@...infault.org>,
Palmer Dabbelt <palmer@...ive.com>,
Anup Patel <Anup.Patel@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Atish Patra <Atish.Patra@....com>,
Albert Ou <aou@...s.berkeley.edu>,
Paul Walmsley <paul.walmsley@...ive.com>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>
Subject: Re: [PATCH v3 4/4] RISC-V: Allow booting kernel from any 4KB aligned
address
On Wed, Mar 27, 2019 at 12:54:41AM -0700, Christoph Hellwig wrote:
> On Mon, Mar 25, 2019 at 09:46:59PM +0530, Anup Patel wrote:
> > > Why do you even care about kernel mappings for non-existant ram.
> >
> > We care because there will always be some buggy kernel driver/code going
> > out-of-bound and accessing non-existent RAM. If we by default map all
> > possible kernel virtual address then behaviour of buggy accesses will be
> > unpredictable.
> >
> > Further, I think we should also make .text and .rodata sections of kernel
> > as read-only. This will protect kernel code and rodata.
>
> All of that is useful at the final_setup_vm() time - but none of it
> matters during early setup_vm where life is complicated.
>
> Mike suggested on the previous iteration that you only do smaller
> mappings when setting up the final mapping to avoid the ops churn,
> and I fully agree with him.
>
> So I would suggest we avoid complicated the fiddly early boot changes
> that just add complxity, and you instead redirect your efforts to
> say implemented proper ro and non-executable sections using 4k mappings
> in the final VM setup only. That should actuall lead to less code
> and complexity, and provide more benefits.
It might be worth keeping trampoline_pg_dir if we are to split setup_vm().
Then setup_vm() will only initialize the trampoline_pg_dir and
final_setup_vm() will setup the swapper_pg_dir and switch to it.
Otherwise final_setup_vm() would need to update live mappings which might
be fragile.
--
Sincerely yours,
Mike.
Powered by blists - more mailing lists