linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: fix vmlinuz build when only 32bit math shell is available
@ 2010-01-18 23:17 Alexander Clouter
  2010-01-19  9:35 ` Wu Zhangjin
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Clouter @ 2010-01-18 23:17 UTC (permalink / raw)
  To: linux-mips

Counter to the documentation for the dash shell, it seems that on my
x86_64 filth under Debian only does 32bit math.  As I have configured
my lapdog to use 'dash' for non-interactive tasks I run into problems
when compiling a compressed kernel.

I play with the AR7 platform, so VMLINUX_LOAD_ADDRESS is
0xffffffff94100000, and for a (for example) 4MiB kernel
VMLINUZ_LOAD_ADDRESS is made out to be:
----
alex@berk:~$ bash -c 'printf "%x\n" $((0xffffffff94100000 + 0x400000))'
ffffffff94500000
alex@berk:~$ dash -c 'printf "%x\n" $((0xffffffff94100000 + 0x400000))'
80000000003fffff
----

The former is obviously correct whilst the later breaks things royally.

This patch fixes vmlinuz kernel builds on systems where only a 32bit
math enabled shell is a available.  It does this by bringing 'bc' back
in as a build dependency (Wu Zhangjin had orginally used 'bc' but I had
suggested he 'fixes' the original dependency *sigh*) but things now seem
to work as expected.

Signed-off-by: Alexander Clouter <alex@digriz.org.uk>
---
 arch/mips/boot/compressed/Makefile |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
index 671d344..65d1adf 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -14,8 +14,10 @@
 
 # compressed kernel load addr: VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE
 VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | cut -d' ' -f1)
-VMLINUX_SIZE := $(shell [ -n "$(VMLINUX_SIZE)" ] && echo $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))
-VMLINUZ_LOAD_ADDRESS := 0x$(shell [ -n "$(VMLINUX_SIZE)" ] && printf %x $$(($(VMLINUX_LOAD_ADDRESS) + $(VMLINUX_SIZE))))
+VMLINUX_SIZE := $(shell printf %X $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))
+VMLINUZ_LOAD_ADDRESS := $(shell A=$(VMLINUX_LOAD_ADDRESS); A=$${A\#0xffffffff}; echo $${A\#0x} | tr a-f A-F)
+VMLINUZ_LOAD_ADDRESS := $(shell echo "obase=16; ibase=16; $(VMLINUZ_LOAD_ADDRESS) + $(VMLINUX_SIZE)" | bc)
+VMLINUZ_LOAD_ADDRESS := $(shell A=$(VMLINUX_LOAD_ADDRESS); [ "$${A\#0xffffffff}" = "$${A}" ] && echo 0x$(VMLINUZ_LOAD_ADDRESS) || echo 0xffffffff$(VMLINUZ_LOAD_ADDRESS))
 
 # set the default size of the mallocing area for decompressing
 BOOT_HEAP_SIZE := 0x400000
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: fix vmlinuz build when only 32bit math shell is available
  2010-01-18 23:17 [PATCH] MIPS: fix vmlinuz build when only 32bit math shell is available Alexander Clouter
@ 2010-01-19  9:35 ` Wu Zhangjin
  0 siblings, 0 replies; 2+ messages in thread
From: Wu Zhangjin @ 2010-01-19  9:35 UTC (permalink / raw)
  To: Alexander Clouter; +Cc: linux-mips, Ralf Baechle

On Mon, 2010-01-18 at 23:17 +0000, Alexander Clouter wrote:
> Counter to the documentation for the dash shell, it seems that on my
> x86_64 filth under Debian only does 32bit math.  As I have configured
> my lapdog to use 'dash' for non-interactive tasks I run into problems
> when compiling a compressed kernel.
> 
> I play with the AR7 platform, so VMLINUX_LOAD_ADDRESS is
> 0xffffffff94100000, and for a (for example) 4MiB kernel
> VMLINUZ_LOAD_ADDRESS is made out to be:
> ----
> alex@berk:~$ bash -c 'printf "%x\n" $((0xffffffff94100000 + 0x400000))'
> ffffffff94500000
> alex@berk:~$ dash -c 'printf "%x\n" $((0xffffffff94100000 + 0x400000))'
> 80000000003fffff
> ----
> 
> The former is obviously correct whilst the later breaks things royally.
> 

Just reproduced the above problem on the YeeLoong netbook(loongson-2F
processor), but no problem on my thinkpad SL400 laptop(Intel(R)
Core(TM)2 Duo CPU). so, dash not always support 64bit math, and perhaps
some other shells not support 64bit math either.

> This patch fixes vmlinuz kernel builds on systems where only a 32bit
> math enabled shell is a available.  It does this by bringing 'bc' back
> in as a build dependency (Wu Zhangjin had orginally used 'bc' but I had
> suggested he 'fixes' the original dependency *sigh*) but things now seem
> to work as expected.
> 
> Signed-off-by: Alexander Clouter <alex@digriz.org.uk>
> ---
>  arch/mips/boot/compressed/Makefile |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
> index 671d344..65d1adf 100644
> --- a/arch/mips/boot/compressed/Makefile
> +++ b/arch/mips/boot/compressed/Makefile
> @@ -14,8 +14,10 @@
>  
>  # compressed kernel load addr: VMLINUZ_LOAD_ADDRESS > VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE
>  VMLINUX_SIZE := $(shell wc -c $(objtree)/$(KBUILD_IMAGE) 2>/dev/null | cut -d' ' -f1)
> -VMLINUX_SIZE := $(shell [ -n "$(VMLINUX_SIZE)" ] && echo $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))
> -VMLINUZ_LOAD_ADDRESS := 0x$(shell [ -n "$(VMLINUX_SIZE)" ] && printf %x $$(($(VMLINUX_LOAD_ADDRESS) + $(VMLINUX_SIZE))))
> +VMLINUX_SIZE := $(shell printf %X $$(($(VMLINUX_SIZE) + (65536 - $(VMLINUX_SIZE) % 65536))))

No, we can not remove this '-n "$(VMLINUX_SIZE)"', otherwise, we will
get the following error when "make clean" or "make distclean":

(standard_in) 1: parse error

> +VMLINUZ_LOAD_ADDRESS := $(shell A=$(VMLINUX_LOAD_ADDRESS); A=$${A\#0xffffffff}; echo $${A\#0x} | tr a-f A-F)
> +VMLINUZ_LOAD_ADDRESS := $(shell echo "obase=16; ibase=16; $(VMLINUZ_LOAD_ADDRESS) + $(VMLINUX_SIZE)" | bc)

The following command(without the prefix 0xffffffff) works well on
yeeloong netbook, what about your machine?

$ dash -c 'printf "%x\n" $((0x94100000 + 0x400000))'
94500000

so, bc is not necessary.

> +VMLINUZ_LOAD_ADDRESS := $(shell A=$(VMLINUX_LOAD_ADDRESS); [ "$${A\#0xffffffff}" = "$${A}" ] && echo 0x$(VMLINUZ_LOAD_ADDRESS) || echo 0xffffffff$(VMLINUZ_LOAD_ADDRESS))

And seems some of the other situations are not covered here:

$ cat arch/mips/Makefile | grep "^load\-" | grep -v 0xffffffff
load-$(CONFIG_MIPS_SIM)		+= 0x80100000
load-$(CONFIG_BASLER_EXCITE)    += 0x80100000
load-$(CONFIG_SGI_IP27)		+= 0xc00000004001c000
load-$(CONFIG_SGI_IP27)		+= 0xa80000000001c000
load-$(CONFIG_SGI_IP28)		+= 0xa800000020004000

so, a general method should be:

1. Get the sum of "the low 32bit of VMLINUX_LOAD_ADDRESS + VMLINUX_SIZE"
with printf "%08x" (08 herein is used to prefix it with 0...)

2. append "the high 32bit of VMLINUX_LOAD_ADDRESS" as the prefix if it
exists.

Will resend a revision of this patch with the above method later.

Thanks & Regards,
	Wu Zhangjin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-19  9:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-18 23:17 [PATCH] MIPS: fix vmlinuz build when only 32bit math shell is available Alexander Clouter
2010-01-19  9:35 ` Wu Zhangjin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).