[PATCH 11/17] MIPS: Makefile: sign-extend TEXT_BASE value on CONFIG_64BIT
Ahmad Fatoum
a.fatoum at pengutronix.de
Thu Jun 8 23:40:07 PDT 2023
On 06.06.23 11:23, Denis Orlov wrote:
> On Tue, 6 Jun 2023 at 12:04, Ahmad Fatoum <a.fatoum at pengutronix.de> wrote:
>>
>> On 05.06.23 22:10, Denis Orlov wrote:
>>> The code that uses TEXT_BASE will fail on reading truncated 32-bit
>>> address if running with 64BIT enabled. As we only support running from
>>> compatibility segments (i.e. no 'proper' 64-bit base addresses), simply
>>> make sure the value is sign-extended when passing it as a define.
>>
>> Below is not really a sign extension. e.g. 0x0000_0000 would be turned
>> into 0xffff_ffff_0000_0000. Is that ok?
>
> Yeah, we can only handle KSEG0/KSEG1 segments, i.e. text base should be
> somewhere in 0x8000_0000/0xa000_0000. So for those, this might be
> considered a sign extension, I guess.
Hmm, ok.
Acked-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
>
> Regards,
> Denis
>
>>
>>>
>>> Signed-off-by: Denis Orlov <denorl2009 at gmail.com>
>>> ---
>>> arch/mips/Makefile | 8 +++++++-
>>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/arch/mips/Makefile b/arch/mips/Makefile
>>> index bad6e574c4..65a00379ab 100644
>>> --- a/arch/mips/Makefile
>>> +++ b/arch/mips/Makefile
>>> @@ -57,7 +57,13 @@ cflags-$(CONFIG_CPU_MIPS64_R1) += $(call cc-option,-march=mips64,-mips64 -U_MIPS
>>> cflags-$(CONFIG_CPU_MIPS64_R2) += $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) -Wa,-mips64r2 -Wa,--trap
>>> cflags-$(CONFIG_CPU_GS232) += $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) -Wa,-mips32r2 -Wa,--trap
>>>
>>> -KBUILD_CPPFLAGS += -DTEXT_BASE=$(CONFIG_TEXT_BASE)
>>> +ifdef CONFIG_64BIT
>>> +MIPS_TEXT_BASE = $(subst 0x,0xffffffff,$(CONFIG_TEXT_BASE))
>>> +else
>>> +MIPS_TEXT_BASE = $(CONFIG_TEXT_BASE)
>>> +endif
>>> +
>>> +KBUILD_CPPFLAGS += -DTEXT_BASE=$(MIPS_TEXT_BASE)
>>>
>>> ifndef CONFIG_MODULES
>>> # Add cleanup flags
>>
>> --
>> Pengutronix e.K. | |
>> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
>> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
>> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list