[U-Boot] [PATCH v2 07/29] riscv: add Kconfig entries for the code model

Bin Meng bmeng.cn at gmail.com
Tue Nov 13 07:34:39 UTC 2018


Hi Lukas,

On Wed, Oct 31, 2018 at 11:01 PM Auer, Lukas
<lukas.auer at aisec.fraunhofer.de> wrote:
>
> Hi Bin,
>
> On Wed, 2018-10-31 at 10:13 +0800, Bin Meng wrote:
> > Hi Lukas,
> >
> > On Tue, Oct 30, 2018 at 8:57 PM Lukas Auer
> > <lukas.auer at aisec.fraunhofer.de> wrote:
> > >
> > > RISC-V has two code models, medium low (medlow) and medium any
> > > (medany).
> > > Medlow limits addressable memory to a single 2 GiB range between
> > > the
> > > absolute addresses -2 GiB and +2 GiB. Medany limits addressable
> > > memory
> > > to any single 2 GiB address range.
> > > By default, medlow is selected on 32-bit systems and medany on 64-
> > > bit
> > > systems. This matches the configuration in Linux.
> > >
> > > The -mcmodel compiler flag is selected according to the Kconfig
> > > configuration.
> > >
> > > Signed-off-by: Lukas Auer <lukas.auer at aisec.fraunhofer.de>
> > > ---
> > >
> > > Changes in v2:
> > > - Change ISA string construction, as suggested by Bin Meng
> > >
> > >  arch/riscv/Kconfig  | 19 +++++++++++++++++++
> > >  arch/riscv/Makefile |  9 ++++++++-
> > >  2 files changed, 27 insertions(+), 1 deletion(-)
> > >
> >
> > I had a further look at this, and I suspect we should stick to medlow
> > for U-Boot, even for 64-bit. As U-Boot will be only running within
> > the
> > low 4GB memory space even for 64-bit. Adding medany seems
> > unnecessary.
> >
> > Regards,
> > Bin
>
> You are right, however I think it's actually because U-Boot is compiled
> as a position independent binary. U-Boot can be relocated above what's
> addressable with 32-bit if the memory is large enough. This should
> cause issues with medlow.
> I suspects that's the reason, but I am not entirely sure. What do you
> think?

Sorry I missed this email. I just found in your v3 this patch was
dropped. I think this is still needed to explicitly pass the code
model to the compiler. I believe we only need change to:

+choice
+       prompt "Code Model"
+       default CMODEL_MEDLOW

I can include the modified patch in my upcoming series.

Regards,
Bin


More information about the U-Boot mailing list