Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2531068ybb; Sun, 5 Apr 2020 09:48:36 -0700 (PDT) X-Google-Smtp-Source: APiQypIDXXyF51v/yfirWULZ5Ev39eAtlWbyzO9wSVru5bDnvh17yng1AjF/iQjmYCraIxuWKx2U X-Received: by 2002:a05:6808:43:: with SMTP id v3mr10368736oic.59.1586105316772; Sun, 05 Apr 2020 09:48:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586105316; cv=none; d=google.com; s=arc-20160816; b=c8H5ETpSHUxkQTkMgNWqvGgbZUU03s6gSr6vyPHNqDAhKxl78rD+zMdt8Uwv5X/Tg1 rCFgdrd1+RneFqBtJDBfvFsT18UyM0TtOFXTFuLX8cA7wngK1AzIytt5WXoEy005zbZ6 zloD6TkQWdZf104/7mo4fgL8xKfu/cCDpA8pTnsY0F1sk0727ru4kQEo4ONDXvEd7OxO 6TIbnGAqaA56OluA3rmFVc55xcQGkrjKUU33KDgjiUbQcOhywMgyDRTWT2KOj39au8W0 HmQYvWNoNC1gLwFwwERUHlS/McYiEYYUhvHr5H/Bns7/4SxQQhF+vM1x3mhLHbx9CbtN YkeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:message-id :in-reply-to:subject:cc:to:from:date; bh=Zcefnqw61gC94evdmMletO2MoRntimk7+dDmdu5nnWs=; b=mHMTPYrQRlMqsr8geWCP1L6wsB5pMAkzCYDT4xDhDvIF4Og0VoVxeI+C1XGBh5mTvw CQSjpTol3S11L7v75lLzFr14uhR6X3ZjiqBUK3CBSYY1/yMF8XsdX6kRqRLwVeTubaj0 /VeXmFiYpEZMDZMn8f4D8xzCH/BYqDaDdLlNzJYD4PDhV6AI2VXYePfIs+sT2h4IgHT9 5ygpKOvMEfrQMwgnFgcYZtphJcCizU2Q7oczpdyDc8FqVDKUrSvMHYUJIR8HdcNGU49n E2cYUmwvcSC9aN3W2SAy5YZiQdje1RHcvLLVXESWCI3Lu71TJym9OYA2sCLz1qZRPWUx iCfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1si6667588otq.87.2020.04.05.09.48.24; Sun, 05 Apr 2020 09:48:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727674AbgDEQrc (ORCPT + 99 others); Sun, 5 Apr 2020 12:47:32 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:47490 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbgDEQrc (ORCPT ); Sun, 5 Apr 2020 12:47:32 -0400 Received: (from localhost user: 'macro', uid#1010) by eddie.linux-mips.org with ESMTP id S23992819AbgDEQr3TATqt (ORCPT + 1 other); Sun, 5 Apr 2020 18:47:29 +0200 Date: Sun, 5 Apr 2020 17:47:29 +0100 (BST) From: "Maciej W. Rozycki" To: Jiaxun Yang cc: linux-mips@vger.kernel.org, Fangrui Song , Nathan Chancellor , Thomas Bogendoerfer , linux-kernel@vger.kernel.org Subject: Re: [PATCH] MIPS: malta: Set load address for 32bit kernel correctly In-Reply-To: <20200405082451.694910-1-jiaxun.yang@flygoat.com> Message-ID: References: <20200405082451.694910-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 5 Apr 2020, Jiaxun Yang wrote: > LLD failed to link vmlinux with 64bit load address for 32bit ELF > while bfd will strip 64bit address into 32bit silently. > To fix LLD build, we should supply a 32bit load address for 32bit > kernel. [...] > diff --git a/arch/mips/mti-malta/Platform b/arch/mips/mti-malta/Platform > index 2cc72c9b38e3..f9b49cba1764 100644 > --- a/arch/mips/mti-malta/Platform > +++ b/arch/mips/mti-malta/Platform > @@ -6,6 +6,10 @@ cflags-$(CONFIG_MIPS_MALTA) += -I$(srctree)/arch/mips/include/asm/mach-malta > ifdef CONFIG_KVM_GUEST > load-$(CONFIG_MIPS_MALTA) += 0x0000000040100000 > else > +ifdef CONFIG_64BIT > load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000 > +else > + load-$(CONFIG_MIPS_MALTA) += 0x80100000 Given the description above I think it should be done uniformly and automatically across all platforms by trimming the address supplied with $(load-y) to low 8 digits in a single place, that is at the place where the variable is consumed. This will reduce clutter across Makefile fragments, avoid inconsistencies and extra work to handle individual platforms as the problem is triggered over and over again, and limit the risk of mistakes. Some error checking might be doable for verifying that the 64-bit address truncated is a sign-extended 32-bit value, but that perhaps would be an overkill as certainly any 64-bit system that sets the load address to be outside the sign-extended 32-bit address range does not support a !64BIT configuration anyway. Maciej