All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] silo: Add 64-bit support
@ 2016-11-24 17:33 John Paul Adrian Glaubitz
  2016-11-24 17:33 ` John Paul Adrian Glaubitz
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-24 17:33 UTC (permalink / raw)
  To: sparclinux

Hi Dave!

As promised in another mail earlier today, here is the current patch
changes that we are currently using on top of silo HEAD to build
it as a 64-bit package in Debian unstable (sparc64).

The silo package has been shipped in Debian with 64-bit support for
a while now without any major issues for most people. So far, I
only know of two cases where people had issues but this seems to
affect Serengeti and Amazon machines only and not a result of this
particular patch.

Thanks,

Adrian

> [1] http://marc.info/?l=linux-sparc&m\x147363964605901&w=2


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

* [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
@ 2016-11-24 17:33 ` John Paul Adrian Glaubitz
  2016-11-24 17:43 ` alexmcwhirter
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-24 17:33 UTC (permalink / raw)
  To: sparclinux

This patch adds the necessary changes to compile silo
on sparc64. It adds the required stack bias for stack
operations and makes sure that all variables are properly
aligned and have the proper size, both on 32- and 64-bit
targets. These changes have been verified to work and
have been used in Debian to ship silo as a 64-bit package.

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
---
 Rules.make          |  6 +++---
 common/console.c    |  6 +++---
 common/divdi3.S     | 11 ++++++++++-
 common/jmp.S        | 10 ++++++++--
 common/prom.c       |  4 ++--
 common/tree.c       |  8 ++++----
 common/udivdi3.S    | 10 +++++++++-
 first-isofs/crt0.S  |  8 +++++++-
 first-isofs/isofs.c |  6 +++---
 second/crt0.S       | 21 +++++++++++++++++++--
 second/disk.c       |  8 ++++----
 second/file.c       |  2 +-
 second/muldi3.S     | 10 +++++++++-
 silo/silo.c         | 12 ++++++------
 14 files changed, 88 insertions(+), 34 deletions(-)

diff --git a/Rules.make b/Rules.make
index 0f176db..4b023a7 100644
--- a/Rules.make
+++ b/Rules.make
@@ -2,10 +2,10 @@ VERSION=1.4.14
 IMGVERSION=0.99
 SHELL=/bin/bash
 RM=rm -f
-# We want to force 32-bit builds
-CC=gcc -m32
+# We want to force 64-bit builds
+CC=gcc
 HOSTCC=gcc
-LD=ld -m elf32_sparc
+LD=ld -m elf64_sparc
 AS=as
 STRIP=strip
 NM=nm
diff --git a/common/console.c b/common/console.c
index 44d7efb..270caca 100644
--- a/common/console.c
+++ b/common/console.c
@@ -27,7 +27,7 @@ prom_nbgetchar(void)
 			i = inc;
 		break;
 	case PROM_P1275:
-		if (p1275_cmd ("read", 3, prom_stdin, &inc, 1) = 1)
+		if (p1275_cmd ("read", 3, (unsigned int) prom_stdin, &inc, 1) = 1)
 			i = inc;
 		break;
 	}
@@ -55,7 +55,7 @@ prom_nbputchar(char c)
 		break;
 	case PROM_P1275:
 		outc = c;
-		if (p1275_cmd ("write", 3, prom_stdout, &outc, 1) = 1)
+		if (p1275_cmd ("write", 3, (unsigned int) prom_stdout, &outc, 1) = 1)
 			i = 0;
 		break;
 	}
@@ -93,7 +93,7 @@ prom_puts (char *s, int len)
 		(*(romvec->pv_v2devops).v2_dev_write)(prom_stdout, s, len);
 		break;
 	case PROM_P1275:
-		p1275_cmd ("write", 3, prom_stdout, s, len);
+		p1275_cmd ("write", 3, (unsigned int) prom_stdout, s, len);
 		break;
 	}
 }
diff --git a/common/divdi3.S b/common/divdi3.S
index 681b368..128df53 100644
--- a/common/divdi3.S
+++ b/common/divdi3.S
@@ -17,9 +17,18 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+#define STACK_BIAS 2047
+#endif
+
 	.data
 	.align 8
 	.globl	__clz_tab
+	.register %g2,#scratch
+	.register %g3,#scratch
+
 __clz_tab:
 	.byte	0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
 	.byte	6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
@@ -36,7 +45,7 @@ __clz_tab:
 	.align 4
 	.globl __divdi3
 __divdi3:
-	save %sp,-104,%sp
+	save %sp,-STACK_BIAS-104,%sp
 	cmp %i0,0
 	bge .LL40
 	mov 0,%l4
diff --git a/common/jmp.S b/common/jmp.S
index 3bc8c94..a446d78 100644
--- a/common/jmp.S
+++ b/common/jmp.S
@@ -18,7 +18,13 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
-#define _SV save %sp, -0x40, %sp
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
+
+#define _SV save %sp, -STACK_BIAS-0x40, %sp
 #define _RV restore
 #define FLUSH_ALL_WINDOWS \
 	_SV; _SV; _SV; _SV; _SV; _SV; _SV; \
@@ -46,7 +52,7 @@ __longjmp:
 	FLUSH_ALL_WINDOWS
 	ld [%o0], %o7		/* Return PC.  */
 	ld [%o0 + 4], %fp	/* Saved SP.  */
-	sub %fp, 64, %sp	/* Allocate a register save area.  */
+	sub %fp, 64+STACK_BIAS, %sp	/* Allocate a register save area.  */
 	tst %o1
 	be,a 1f
 	mov 1, %o1
diff --git a/common/prom.c b/common/prom.c
index 939bbb9..7585e10 100644
--- a/common/prom.c
+++ b/common/prom.c
@@ -196,7 +196,7 @@ int prom_map(int mode, unsigned long long size,
 			    P1275_ARG_64B(3) | P1275_ARG_64B(4) |
 			    P1275_ARG_64B(6) | 7,
 			    "map",
-			    prom_get_mmu_ihandle(),
+			    (unsigned int) prom_get_mmu_ihandle(),
 			    mode,
 			    size,
 			    vaddr,
@@ -211,7 +211,7 @@ void prom_unmap(unsigned long long size, unsigned long long vaddr)
 	p1275_cmd("call-method",
 		  P1275_ARG_64B(2) | P1275_ARG_64B(3) | 4,
 		  "unmap",
-		  prom_get_mmu_ihandle(),
+		  (unsigned int) prom_get_mmu_ihandle(),
 		  size,
 		  vaddr);
 }
diff --git a/common/tree.c b/common/tree.c
index 56da8b8..65a7743 100644
--- a/common/tree.c
+++ b/common/tree.c
@@ -22,7 +22,7 @@ int prom_getchild(int node)
 	if (prom_vers != PROM_P1275)
 		cnode = prom_nodeops->no_child(node);
 	else
-		cnode = p1275_cmd ("child", 1, node);
+		cnode = p1275_cmd ("child", 1, (unsigned int) node);
 		
 	if (cnode = 0 || cnode = -1)
 		return 0;
@@ -43,7 +43,7 @@ int prom_getsibling(int node)
 	if (prom_vers != PROM_P1275)
 		sibnode = prom_nodeops->no_nextnode(node);
 	else
-		sibnode = p1275_cmd ("peer", 1, node);
+		sibnode = p1275_cmd ("peer", 1, (unsigned int) node);
 		
 	if (sibnode = 0 || sibnode = -1)
 		return 0;
@@ -64,7 +64,7 @@ int prom_getproplen(int node, char *prop)
 		if (prom_vers != PROM_P1275)
 			ret = prom_nodeops->no_proplen(node, prop);
 		else
-			ret = p1275_cmd ("getproplen", 2, node, prop);
+			ret = p1275_cmd ("getproplen", 2, (unsigned int) node, prop);
 	}
 	return ret;
 }
@@ -85,7 +85,7 @@ int prom_getproperty(int node, char *prop, char *buffer, int bufsize)
 		if (prom_vers != PROM_P1275)
 			ret = prom_nodeops->no_getprop(node, prop, buffer);
 		else
-			ret = p1275_cmd ("getprop", 4, node, prop, buffer, bufsize);
+			ret = p1275_cmd ("getprop", 4, (unsigned int) node, prop, buffer, bufsize);
 	}
 	return ret;
 }
diff --git a/common/udivdi3.S b/common/udivdi3.S
index b430f1f..25ba6ef 100644
--- a/common/udivdi3.S
+++ b/common/udivdi3.S
@@ -17,11 +17,19 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
 	.text
 	.align 4
 	.globl __udivdi3
+	.register %g2,#scratch
+	.register %g3,#scratch
+
 __udivdi3:
-	save %sp,-104,%sp
+	save %sp,STACK_BIAS-104,%sp
 	mov %i3,%o3
 	cmp %i2,0
 	bne .LL40
diff --git a/first-isofs/crt0.S b/first-isofs/crt0.S
index 2db1281..88fcab5 100644
--- a/first-isofs/crt0.S
+++ b/first-isofs/crt0.S
@@ -21,6 +21,12 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
+
 #define COPY	jmpl	%o7 + (copy - _start), %l7
 
 	.text
@@ -76,7 +82,7 @@ jumphere:
 	! Set up a stack
 setup_stack:
 	set	0x400000, %l1
-	save	%l1, -64, %sp
+	save	%l1, -STACK_BIAS-64, %sp
 
 	! Call cd_main() to start the whole thingie up
 
diff --git a/first-isofs/isofs.c b/first-isofs/isofs.c
index d7a603b..47d1c48 100644
--- a/first-isofs/isofs.c
+++ b/first-isofs/isofs.c
@@ -114,7 +114,7 @@ static void cd_fini(void)
 		break;
 
 	case PROM_P1275:
-		p1275_cmd("close", 1, fd);
+		p1275_cmd("close", 1, (unsigned)fd);
 		break;
 	};
 }
@@ -141,7 +141,7 @@ static int cd_read_block(unsigned long long offset, int size, void *data)
 
 		if (seekp != offset) {
 			if (prom_vers = PROM_P1275) {
-				if (p1275_cmd("seek", P1275_ARG_64B(2) | 3, fd, 0, offset) = -1)
+				if (p1275_cmd("seek", P1275_ARG_64B(2) | 3, (unsigned)fd, 0, offset) = -1)
 					return -1;
 			} else {
 				if ((*romvec->pv_v2devops.v2_dev_seek)
@@ -152,7 +152,7 @@ static int cd_read_block(unsigned long long offset, int size, void *data)
 		}
 
 		if (prom_vers = PROM_P1275)
-			ret = p1275_cmd ("read", 3, fd, data, size);
+			ret = p1275_cmd ("read", 3, (unsigned)fd, data, size);
 		else
 			ret = (*romvec->pv_v2devops.v2_dev_read) (fd, data, size);
 
diff --git a/second/crt0.S b/second/crt0.S
index f1ba1c8..399d174 100644
--- a/second/crt0.S
+++ b/second/crt0.S
@@ -21,6 +21,12 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
+
 #define COPY	jmpl	%o7 + (copy - _start), %l7
 
 	.text
@@ -82,7 +88,11 @@ boot_parts:
 	sub	%l0, 16, %l0
 	sethi	%hi(gzminpi), %l1
 	add	%l1, %i3, %l1
+#if __WORDSIZE = 32
 	st	%l0, [%l1 + %lo(gzminpi)]
+#else
+	stx	%l0, [%l1 + %lo(gzminpi)]
+#endif
 
 	/* Jump to relocated code */
 	sethi	%hi(_end), %l0
@@ -121,12 +131,15 @@ jumphere:
 
 	! Set up a stack
 setup_stack:
-	save	%i0,-120,%sp
-
+	save	%i0,-STACK_BIAS-120,%sp
 	tst	%i4
 	be	0f
 	 sethi	%hi(gzminpi+0x100000), %l0
+#if __WORDSIZE = 32
 	ld	[%l0 + %lo(gzminpi)], %l1
+#else
+	ldx	[%l0 + %lo(gzminpi)], %l1
+#endif
 	sethi	%hi(LARGE_RELOC), %l2
 1:	lduh	[%l1], %l3
 	add	%l1, 2, %l1
@@ -147,7 +160,11 @@ setup_stack:
 	add	%l3, 16, %l3
 	ba	3b
 	 stb	%l3, [%l2]
+#if __WORDSIZE = 32
 4:	st	%l1, [%l0 + %lo(gzminpi)]
+#else
+4:	stx	%l1, [%l0 + %lo(gzminpi)]
+#endif
 
 	! Call my_main() to start the whole thingie up
 
diff --git a/second/disk.c b/second/disk.c
index 40234b3..989ab61 100644
--- a/second/disk.c
+++ b/second/disk.c
@@ -79,7 +79,7 @@ int silo_disk_open(char *device)
 
         	fd = p1275_cmd ("open", 1, device);
         	if ((unsigned)(fd + 1) > 1) {
-		    node = p1275_cmd ("instance-to-package", 1, fd);
+		    node = p1275_cmd ("instance-to-package", 1, (unsigned)fd);
                     /*
                      * Don't use our argument due to devalias.
                      * Alas, flash has no device_type property.
@@ -301,7 +301,7 @@ int silo_disk_read(char *buff, int size, unsigned long long offset)
 	    }
 	    if (seekp != offset) {
 	    	if (prom_vers = PROM_P1275) {
-		        if ((rc = p1275_cmd ("seek", P1275_ARG_64B(2) | 3, fd, 0, offset)) = -1)
+		        if ((rc = p1275_cmd ("seek", P1275_ARG_64B(2) | 3, (unsigned) fd, 0, offset)) = -1)
 			    return -1;
 	    	} else {
 		        if ((*romvec->pv_v2devops.v2_dev_seek) (fd, (unsigned)(offset >> 32), (unsigned)offset) = -1)
@@ -311,7 +311,7 @@ int silo_disk_read(char *buff, int size, unsigned long long offset)
 	    }
 	}
 	if (prom_vers = PROM_P1275) {
-		rc = p1275_cmd ("read", 3, fd, buff, size);
+		rc = p1275_cmd ("read", 3, (unsigned) fd, buff, size);
 	} else {
 		int i;
 		for (i = 0; i < 2; i++) {
@@ -355,7 +355,7 @@ void silo_disk_close(void)
 	case PROM_V3:
 	    (*romvec->pv_v2devops.v2_dev_close) (fd); break;
 	case PROM_P1275:
-	    p1275_cmd ("close", 1, fd); break;
+	    p1275_cmd ("close", 1, (unsigned) fd); break;
 	}
     }
     *currentdevice = 0;
diff --git a/second/file.c b/second/file.c
index c7c1ed2..379af2f 100644
--- a/second/file.c
+++ b/second/file.c
@@ -193,7 +193,7 @@ int dump_block (blk_t * blocknr, int blockcnt)
                 }
                 last_blockcnt = -1;
             }
-            if ((char *)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
+            if ((unsigned int)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
                 silo_fatal("Image too large to fit in destination");
                 return BLOCK_ABORT;
             }
diff --git a/second/muldi3.S b/second/muldi3.S
index 7f17872..7180630 100644
--- a/second/muldi3.S
+++ b/second/muldi3.S
@@ -17,11 +17,19 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
+
 	.text
 	.align 4
 	.globl __muldi3
+	.register %g2,#scratch
+	.register %g3,#scratch
 __muldi3:
-	save  %sp, -104, %sp
+	save  %sp, -STACK_BIAS-104, %sp
 	wr  %g0, %i1, %y
 	sra  %i3, 0x1f, %g2
 	and  %i1, %g2, %g2
diff --git a/silo/silo.c b/silo/silo.c
index 9728af2..20b7a0c 100644
--- a/silo/silo.c
+++ b/silo/silo.c
@@ -107,14 +107,14 @@ static int allow_confchk_fail = 0;
 
 /* This is just so that we don't have to fight with incompatible ufs_fs.h headers */
 #define SILO_UFS_MAGIC 0x00011954
-struct silo_ufs_super_block {
+struct __attribute__((packed)) silo_ufs_super_block {
 	unsigned char xxx1[36];
 	unsigned int fs_fsize;
 	unsigned char xxx2[1332];
 	unsigned int fs_magic;
 };
                                 
-struct sun_disklabel {
+struct __attribute__((packed)) sun_disklabel {
     unsigned char info[128];	/* Informative text string */
     unsigned char spare[292];	/* Boot information etc. */
     unsigned short rspeed;	/* Disk rotational speed */
@@ -127,9 +127,9 @@ struct sun_disklabel {
     unsigned short ntrks;	/* Tracks per cylinder */
     unsigned short nsect;	/* Sectors per track */
     unsigned char spare3[4];	/* Even more magic... */
-    struct sun_partition {
-	unsigned long start_cylinder;
-	unsigned long num_sectors;
+    struct __attribute__((packed)) sun_partition {
+	unsigned int start_cylinder;
+	unsigned int num_sectors;
     } partitions[8];
     unsigned short magic;	/* Magic number */
     unsigned short csum;	/* Label xor'd checksum */
@@ -205,7 +205,7 @@ int check_fs (int fd)
 {
     struct silo_ufs_super_block ufs;
     struct ext2_super_block sb;	/* Super Block Info */
-    struct romfs_super_block {
+    struct __attribute__((packed)) romfs_super_block {
 	__u32 word0;
 	__u32 word1;
 	__u32 size;
-- 
2.10.2


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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
  2016-11-24 17:33 ` John Paul Adrian Glaubitz
@ 2016-11-24 17:43 ` alexmcwhirter
  2016-11-24 18:05 ` John Paul Adrian Glaubitz
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: alexmcwhirter @ 2016-11-24 17:43 UTC (permalink / raw)
  To: sparclinux

On 2016-11-24 12:33, John Paul Adrian Glaubitz wrote:
> Hi Dave!
> 
> As promised in another mail earlier today, here is the current patch
> changes that we are currently using on top of silo HEAD to build
> it as a 64-bit package in Debian unstable (sparc64).
> 
> The silo package has been shipped in Debian with 64-bit support for
> a while now without any major issues for most people. So far, I
> only know of two cases where people had issues but this seems to
> affect Serengeti and Amazon machines only and not a result of this
> particular patch.
> 
> Thanks,
> 
> Adrian
> 
>> [1] http://marc.info/?l=linux-sparc&m\x147363964605901&w=2

Just as a side note, i can personally verify that both Debian SILO and 
current SILO are broken on Serengeti / Amazon in the same way. 64 Bit 
patches make no absolutely difference here.

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
  2016-11-24 17:33 ` John Paul Adrian Glaubitz
  2016-11-24 17:43 ` alexmcwhirter
@ 2016-11-24 18:05 ` John Paul Adrian Glaubitz
  2016-11-24 21:23 ` Aaro Koskinen
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-24 18:05 UTC (permalink / raw)
  To: sparclinux


On Nov 24, 2016, at 6:43 PM, alexmcwhirter@triadic.us wrote:
> 
>> On 2016-11-24 12:33, John Paul Adrian Glaubitz wrote:
>> Hi Dave!
>> As promised in another mail earlier today, here is the current patch
>> changes that we are currently using on top of silo HEAD to build
>> it as a 64-bit package in Debian unstable (sparc64).
>> The silo package has been shipped in Debian with 64-bit support for
>> a while now without any major issues for most people. So far, I
>> only know of two cases where people had issues but this seems to
>> affect Serengeti and Amazon machines only and not a result of this
>> particular patch.
>> Thanks,
>> Adrian
>>> [1] http://marc.info/?l=linux-sparc&m\x147363964605901&w=2
> 
> Just as a side note, i can personally verify that both Debian SILO and current SILO are broken on Serengeti / Amazon in the same way. 64 Bit patches make no absolutely difference here.

Thank you very much for confirming this! I was actually hoping for this exact statement!

Thanks,
Adrian

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (2 preceding siblings ...)
  2016-11-24 18:05 ` John Paul Adrian Glaubitz
@ 2016-11-24 21:23 ` Aaro Koskinen
  2016-11-24 21:51 ` John Paul Adrian Glaubitz
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Aaro Koskinen @ 2016-11-24 21:23 UTC (permalink / raw)
  To: sparclinux

Hi,

On Thu, Nov 24, 2016 at 06:33:30PM +0100, John Paul Adrian Glaubitz wrote:
> -# We want to force 32-bit builds
> -CC=gcc -m32
> +# We want to force 64-bit builds
> +CC=gcc
>  HOSTCC=gcc
> -LD=ld -m elf32_sparc
> +LD=ld -m elf64_sparc

This breaks the native build on my Sun Ultra 5 with 32-bit userspace and GCC
defaulting to ultrasparc:

$ make
[...]
make[1]: Entering directory '/home/aaro/silo/first'
gcc -Os -Wall -I. -I../include -fomit-frame-pointer -fno-strict-aliasing -DSMALL_RELOC=0x280000 -DLARGE_RELOC=0x380000 -fno-stack-protector -c first.S -o first.o
ld -m elf64_sparc -N -Ttext 0x4000 -o first first.o
ld: sparc architecture of input file `first.o' is incompatible with sparc:v9 output
Makefile:39: recipe for target 'first' failed
make[1]: *** [first] Error 1
make[1]: Leaving directory '/home/aaro/silo/first'
Makefile:15: recipe for target 'all' failed
make: *** [all] Error 1

Also you broke the tilo build...

A.

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (3 preceding siblings ...)
  2016-11-24 21:23 ` Aaro Koskinen
@ 2016-11-24 21:51 ` John Paul Adrian Glaubitz
  2016-11-24 22:05 ` Aaro Koskinen
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-24 21:51 UTC (permalink / raw)
  To: sparclinux

On 11/24/2016 10:23 PM, Aaro Koskinen wrote:
> This breaks the native build on my Sun Ultra 5 with 32-bit userspace and GCC
> defaulting to ultrasparc:

Well, you can just change this part back to "elf32_sparc" and it will work. Might
even be possible to omit the "-m" option altogether to it will default to -m native.

> Also you broke the tilo build...

Not here. Just tried it again and it builds fine. Can you be more specific?

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (4 preceding siblings ...)
  2016-11-24 21:51 ` John Paul Adrian Glaubitz
@ 2016-11-24 22:05 ` Aaro Koskinen
  2016-11-24 22:26 ` John Paul Adrian Glaubitz
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Aaro Koskinen @ 2016-11-24 22:05 UTC (permalink / raw)
  To: sparclinux

Hi,

On Thu, Nov 24, 2016 at 10:51:14PM +0100, John Paul Adrian Glaubitz wrote:
> On 11/24/2016 10:23 PM, Aaro Koskinen wrote:
> > This breaks the native build on my Sun Ultra 5 with 32-bit userspace and GCC
> > defaulting to ultrasparc:
> 
> Well, you can just change this part back to "elf32_sparc" and it will work. Might
> even be possible to omit the "-m" option altogether to it will default to -m native.

I think that's your job to try. If you want to "add 64-bit support"
(instead of forcing it to everybody), do the required changes so that
it's still works for everybody without extra fiddling.

> > Also you broke the tilo build...
> 
> Not here. Just tried it again and it builds fine. Can you be more specific?

The same issue as with silo.

A.

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (5 preceding siblings ...)
  2016-11-24 22:05 ` Aaro Koskinen
@ 2016-11-24 22:26 ` John Paul Adrian Glaubitz
  2016-11-24 22:32 ` James Clarke
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-24 22:26 UTC (permalink / raw)
  To: sparclinux

On 11/24/2016 11:05 PM, Aaro Koskinen wrote:
> I think that's your job to try. If you want to "add 64-bit support"
> (instead of forcing it to everybody), do the required changes so that
> it's still works for everybody without extra fiddling.

Don't be so rude, I'm not forcing anything onto anyone.

>>> Also you broke the tilo build...
>>
>> Not here. Just tried it again and it builds fine. Can you be more specific?
> 
> The same issue as with silo.

Don't you think your statements are a bit misleading then? I didn't break anything,
I changed the default target to 64-bit which is somewhat reasonable in the year
2016, isn't it.

Or are you going to tell me now that your 333 MHz, 128 MiB RAM Sun Ultra 5 is
your everyday production machine?

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (6 preceding siblings ...)
  2016-11-24 22:26 ` John Paul Adrian Glaubitz
@ 2016-11-24 22:32 ` James Clarke
  2016-11-24 22:35 ` John Paul Adrian Glaubitz
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: James Clarke @ 2016-11-24 22:32 UTC (permalink / raw)
  To: sparclinux

> On 24 Nov 2016, at 22:26, John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> wrote:
> 
> On 11/24/2016 11:05 PM, Aaro Koskinen wrote:
>> I think that's your job to try. If you want to "add 64-bit support"
>> (instead of forcing it to everybody), do the required changes so that
>> it's still works for everybody without extra fiddling.
> 
> Don't be so rude, I'm not forcing anything onto anyone.
> 
>>>> Also you broke the tilo build...
>>> 
>>> Not here. Just tried it again and it builds fine. Can you be more specific?
>> 
>> The same issue as with silo.
> 
> Don't you think your statements are a bit misleading then? I didn't break anything,
> I changed the default target to 64-bit which is somewhat reasonable in the year
> 2016, isn't it.
> 
> Or are you going to tell me now that your 333 MHz, 128 MiB RAM Sun Ultra 5 is
> your everyday production machine?

Part of the problem is not forcing 64-bit, but that the Makefile is inconsistent.
The default CC is gcc without any flags, but ld is given -m elf64_sparc. If you
are running with sparc32 as your default target, gcc will generate 32-bit files
but ld expects 64-bit. If you really want to force 64-bit, you should also pass
appropriate -m64/-64 flags to gcc/as. However, I think the sensible, least
controversial solution is to just drop the -m elf64_sparc and let everything
be the default. It was only changed to force 32-bit in c836dbda because 64-bit
support wasn’t present.

Regards,
James


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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (7 preceding siblings ...)
  2016-11-24 22:32 ` James Clarke
@ 2016-11-24 22:35 ` John Paul Adrian Glaubitz
  2016-11-24 22:51 ` Aaro Koskinen
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-24 22:35 UTC (permalink / raw)
  To: sparclinux

On 11/24/2016 11:32 PM, James Clarke wrote:
> Part of the problem is not forcing 64-bit, but that the Makefile is inconsistent.
> The default CC is gcc without any flags, but ld is given -m elf64_sparc. If you
> are running with sparc32 as your default target, gcc will generate 32-bit files
> but ld expects 64-bit. If you really want to force 64-bit, you should also pass
> appropriate -m64/-64 flags to gcc/as. However, I think the sensible, least
> controversial solution is to just drop the -m elf64_sparc and let everything
> be the default. It was only changed to force 32-bit in c836dbda because 64-bit
> support wasn’t present.

Thank you! This is actually very constructive criticism which actually helps
improving the patch.  I'll look into improving the Makefile.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (8 preceding siblings ...)
  2016-11-24 22:35 ` John Paul Adrian Glaubitz
@ 2016-11-24 22:51 ` Aaro Koskinen
  2016-11-24 22:53 ` John Paul Adrian Glaubitz
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Aaro Koskinen @ 2016-11-24 22:51 UTC (permalink / raw)
  To: sparclinux

Hi,

On Thu, Nov 24, 2016 at 11:26:20PM +0100, John Paul Adrian Glaubitz wrote:
> On 11/24/2016 11:05 PM, Aaro Koskinen wrote:
> > The same issue as with silo.
> 
> Don't you think your statements are a bit misleading then? I didn't break anything,
> I changed the default target to 64-bit which is somewhat reasonable in the year
> 2016, isn't it.

You could write the Makefile so that build works even with 32-bit
userspace. I don't think it's unreasonable or rude to demand.

> Or are you going to tell me now that your 333 MHz, 128 MiB RAM Sun
> Ultra 5 is your everyday production machine?

Yes, I'm using Ultra 5 on daily basis. The CPU is 360 MHz and with 512
MiB RAM.

A.

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (9 preceding siblings ...)
  2016-11-24 22:51 ` Aaro Koskinen
@ 2016-11-24 22:53 ` John Paul Adrian Glaubitz
  2016-11-24 22:59 ` John Paul Adrian Glaubitz
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-24 22:53 UTC (permalink / raw)
  To: sparclinux

On 11/24/2016 11:51 PM, Aaro Koskinen wrote:
> You could write the Makefile so that build works even with 32-bit
> userspace. I don't think it's unreasonable or rude to demand.

It isn't. But it's always possible to say that in polite way. I'm
trying to help improving things, not forcing anything to anyone.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (10 preceding siblings ...)
  2016-11-24 22:53 ` John Paul Adrian Glaubitz
@ 2016-11-24 22:59 ` John Paul Adrian Glaubitz
  2016-11-25 16:43 ` David Miller
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-24 22:59 UTC (permalink / raw)
  To: sparclinux

This patch adds the necessary changes to compile silo
on sparc64. It adds the required stack bias for stack
operations and makes sure that all variables are properly
aligned and have the proper size, both on 32- and 64-bit
targets. These changes have been verified to work and
have been used in Debian to ship silo as a 64-bit package.

Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
---
 Rules.make          |  5 ++---
 common/console.c    |  6 +++---
 common/divdi3.S     | 11 ++++++++++-
 common/jmp.S        | 10 ++++++++--
 common/prom.c       |  4 ++--
 common/tree.c       |  8 ++++----
 common/udivdi3.S    | 10 +++++++++-
 first-isofs/crt0.S  |  8 +++++++-
 first-isofs/isofs.c |  6 +++---
 second/crt0.S       | 21 +++++++++++++++++++--
 second/disk.c       |  8 ++++----
 second/file.c       |  2 +-
 second/muldi3.S     | 10 +++++++++-
 silo/silo.c         | 12 ++++++------
 14 files changed, 87 insertions(+), 34 deletions(-)

diff --git a/Rules.make b/Rules.make
index 0f176db..e46af48 100644
--- a/Rules.make
+++ b/Rules.make
@@ -2,10 +2,9 @@ VERSION=1.4.14
 IMGVERSION=0.99
 SHELL=/bin/bash
 RM=rm -f
-# We want to force 32-bit builds
-CC=gcc -m32
+CC=gcc
 HOSTCC=gcc
-LD=ld -m elf32_sparc
+LD=ld
 AS=as
 STRIP=strip
 NM=nm
diff --git a/common/console.c b/common/console.c
index 44d7efb..270caca 100644
--- a/common/console.c
+++ b/common/console.c
@@ -27,7 +27,7 @@ prom_nbgetchar(void)
 			i = inc;
 		break;
 	case PROM_P1275:
-		if (p1275_cmd ("read", 3, prom_stdin, &inc, 1) = 1)
+		if (p1275_cmd ("read", 3, (unsigned int) prom_stdin, &inc, 1) = 1)
 			i = inc;
 		break;
 	}
@@ -55,7 +55,7 @@ prom_nbputchar(char c)
 		break;
 	case PROM_P1275:
 		outc = c;
-		if (p1275_cmd ("write", 3, prom_stdout, &outc, 1) = 1)
+		if (p1275_cmd ("write", 3, (unsigned int) prom_stdout, &outc, 1) = 1)
 			i = 0;
 		break;
 	}
@@ -93,7 +93,7 @@ prom_puts (char *s, int len)
 		(*(romvec->pv_v2devops).v2_dev_write)(prom_stdout, s, len);
 		break;
 	case PROM_P1275:
-		p1275_cmd ("write", 3, prom_stdout, s, len);
+		p1275_cmd ("write", 3, (unsigned int) prom_stdout, s, len);
 		break;
 	}
 }
diff --git a/common/divdi3.S b/common/divdi3.S
index 681b368..128df53 100644
--- a/common/divdi3.S
+++ b/common/divdi3.S
@@ -17,9 +17,18 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+#define STACK_BIAS 2047
+#endif
+
 	.data
 	.align 8
 	.globl	__clz_tab
+	.register %g2,#scratch
+	.register %g3,#scratch
+
 __clz_tab:
 	.byte	0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
 	.byte	6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
@@ -36,7 +45,7 @@ __clz_tab:
 	.align 4
 	.globl __divdi3
 __divdi3:
-	save %sp,-104,%sp
+	save %sp,-STACK_BIAS-104,%sp
 	cmp %i0,0
 	bge .LL40
 	mov 0,%l4
diff --git a/common/jmp.S b/common/jmp.S
index 3bc8c94..a446d78 100644
--- a/common/jmp.S
+++ b/common/jmp.S
@@ -18,7 +18,13 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
-#define _SV save %sp, -0x40, %sp
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
+
+#define _SV save %sp, -STACK_BIAS-0x40, %sp
 #define _RV restore
 #define FLUSH_ALL_WINDOWS \
 	_SV; _SV; _SV; _SV; _SV; _SV; _SV; \
@@ -46,7 +52,7 @@ __longjmp:
 	FLUSH_ALL_WINDOWS
 	ld [%o0], %o7		/* Return PC.  */
 	ld [%o0 + 4], %fp	/* Saved SP.  */
-	sub %fp, 64, %sp	/* Allocate a register save area.  */
+	sub %fp, 64+STACK_BIAS, %sp	/* Allocate a register save area.  */
 	tst %o1
 	be,a 1f
 	mov 1, %o1
diff --git a/common/prom.c b/common/prom.c
index 939bbb9..7585e10 100644
--- a/common/prom.c
+++ b/common/prom.c
@@ -196,7 +196,7 @@ int prom_map(int mode, unsigned long long size,
 			    P1275_ARG_64B(3) | P1275_ARG_64B(4) |
 			    P1275_ARG_64B(6) | 7,
 			    "map",
-			    prom_get_mmu_ihandle(),
+			    (unsigned int) prom_get_mmu_ihandle(),
 			    mode,
 			    size,
 			    vaddr,
@@ -211,7 +211,7 @@ void prom_unmap(unsigned long long size, unsigned long long vaddr)
 	p1275_cmd("call-method",
 		  P1275_ARG_64B(2) | P1275_ARG_64B(3) | 4,
 		  "unmap",
-		  prom_get_mmu_ihandle(),
+		  (unsigned int) prom_get_mmu_ihandle(),
 		  size,
 		  vaddr);
 }
diff --git a/common/tree.c b/common/tree.c
index 56da8b8..65a7743 100644
--- a/common/tree.c
+++ b/common/tree.c
@@ -22,7 +22,7 @@ int prom_getchild(int node)
 	if (prom_vers != PROM_P1275)
 		cnode = prom_nodeops->no_child(node);
 	else
-		cnode = p1275_cmd ("child", 1, node);
+		cnode = p1275_cmd ("child", 1, (unsigned int) node);
 		
 	if (cnode = 0 || cnode = -1)
 		return 0;
@@ -43,7 +43,7 @@ int prom_getsibling(int node)
 	if (prom_vers != PROM_P1275)
 		sibnode = prom_nodeops->no_nextnode(node);
 	else
-		sibnode = p1275_cmd ("peer", 1, node);
+		sibnode = p1275_cmd ("peer", 1, (unsigned int) node);
 		
 	if (sibnode = 0 || sibnode = -1)
 		return 0;
@@ -64,7 +64,7 @@ int prom_getproplen(int node, char *prop)
 		if (prom_vers != PROM_P1275)
 			ret = prom_nodeops->no_proplen(node, prop);
 		else
-			ret = p1275_cmd ("getproplen", 2, node, prop);
+			ret = p1275_cmd ("getproplen", 2, (unsigned int) node, prop);
 	}
 	return ret;
 }
@@ -85,7 +85,7 @@ int prom_getproperty(int node, char *prop, char *buffer, int bufsize)
 		if (prom_vers != PROM_P1275)
 			ret = prom_nodeops->no_getprop(node, prop, buffer);
 		else
-			ret = p1275_cmd ("getprop", 4, node, prop, buffer, bufsize);
+			ret = p1275_cmd ("getprop", 4, (unsigned int) node, prop, buffer, bufsize);
 	}
 	return ret;
 }
diff --git a/common/udivdi3.S b/common/udivdi3.S
index b430f1f..25ba6ef 100644
--- a/common/udivdi3.S
+++ b/common/udivdi3.S
@@ -17,11 +17,19 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
 	.text
 	.align 4
 	.globl __udivdi3
+	.register %g2,#scratch
+	.register %g3,#scratch
+
 __udivdi3:
-	save %sp,-104,%sp
+	save %sp,STACK_BIAS-104,%sp
 	mov %i3,%o3
 	cmp %i2,0
 	bne .LL40
diff --git a/first-isofs/crt0.S b/first-isofs/crt0.S
index 2db1281..88fcab5 100644
--- a/first-isofs/crt0.S
+++ b/first-isofs/crt0.S
@@ -21,6 +21,12 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
+
 #define COPY	jmpl	%o7 + (copy - _start), %l7
 
 	.text
@@ -76,7 +82,7 @@ jumphere:
 	! Set up a stack
 setup_stack:
 	set	0x400000, %l1
-	save	%l1, -64, %sp
+	save	%l1, -STACK_BIAS-64, %sp
 
 	! Call cd_main() to start the whole thingie up
 
diff --git a/first-isofs/isofs.c b/first-isofs/isofs.c
index d7a603b..47d1c48 100644
--- a/first-isofs/isofs.c
+++ b/first-isofs/isofs.c
@@ -114,7 +114,7 @@ static void cd_fini(void)
 		break;
 
 	case PROM_P1275:
-		p1275_cmd("close", 1, fd);
+		p1275_cmd("close", 1, (unsigned)fd);
 		break;
 	};
 }
@@ -141,7 +141,7 @@ static int cd_read_block(unsigned long long offset, int size, void *data)
 
 		if (seekp != offset) {
 			if (prom_vers = PROM_P1275) {
-				if (p1275_cmd("seek", P1275_ARG_64B(2) | 3, fd, 0, offset) = -1)
+				if (p1275_cmd("seek", P1275_ARG_64B(2) | 3, (unsigned)fd, 0, offset) = -1)
 					return -1;
 			} else {
 				if ((*romvec->pv_v2devops.v2_dev_seek)
@@ -152,7 +152,7 @@ static int cd_read_block(unsigned long long offset, int size, void *data)
 		}
 
 		if (prom_vers = PROM_P1275)
-			ret = p1275_cmd ("read", 3, fd, data, size);
+			ret = p1275_cmd ("read", 3, (unsigned)fd, data, size);
 		else
 			ret = (*romvec->pv_v2devops.v2_dev_read) (fd, data, size);
 
diff --git a/second/crt0.S b/second/crt0.S
index f1ba1c8..399d174 100644
--- a/second/crt0.S
+++ b/second/crt0.S
@@ -21,6 +21,12 @@
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
+
 #define COPY	jmpl	%o7 + (copy - _start), %l7
 
 	.text
@@ -82,7 +88,11 @@ boot_parts:
 	sub	%l0, 16, %l0
 	sethi	%hi(gzminpi), %l1
 	add	%l1, %i3, %l1
+#if __WORDSIZE = 32
 	st	%l0, [%l1 + %lo(gzminpi)]
+#else
+	stx	%l0, [%l1 + %lo(gzminpi)]
+#endif
 
 	/* Jump to relocated code */
 	sethi	%hi(_end), %l0
@@ -121,12 +131,15 @@ jumphere:
 
 	! Set up a stack
 setup_stack:
-	save	%i0,-120,%sp
-
+	save	%i0,-STACK_BIAS-120,%sp
 	tst	%i4
 	be	0f
 	 sethi	%hi(gzminpi+0x100000), %l0
+#if __WORDSIZE = 32
 	ld	[%l0 + %lo(gzminpi)], %l1
+#else
+	ldx	[%l0 + %lo(gzminpi)], %l1
+#endif
 	sethi	%hi(LARGE_RELOC), %l2
 1:	lduh	[%l1], %l3
 	add	%l1, 2, %l1
@@ -147,7 +160,11 @@ setup_stack:
 	add	%l3, 16, %l3
 	ba	3b
 	 stb	%l3, [%l2]
+#if __WORDSIZE = 32
 4:	st	%l1, [%l0 + %lo(gzminpi)]
+#else
+4:	stx	%l1, [%l0 + %lo(gzminpi)]
+#endif
 
 	! Call my_main() to start the whole thingie up
 
diff --git a/second/disk.c b/second/disk.c
index 40234b3..989ab61 100644
--- a/second/disk.c
+++ b/second/disk.c
@@ -79,7 +79,7 @@ int silo_disk_open(char *device)
 
         	fd = p1275_cmd ("open", 1, device);
         	if ((unsigned)(fd + 1) > 1) {
-		    node = p1275_cmd ("instance-to-package", 1, fd);
+		    node = p1275_cmd ("instance-to-package", 1, (unsigned)fd);
                     /*
                      * Don't use our argument due to devalias.
                      * Alas, flash has no device_type property.
@@ -301,7 +301,7 @@ int silo_disk_read(char *buff, int size, unsigned long long offset)
 	    }
 	    if (seekp != offset) {
 	    	if (prom_vers = PROM_P1275) {
-		        if ((rc = p1275_cmd ("seek", P1275_ARG_64B(2) | 3, fd, 0, offset)) = -1)
+		        if ((rc = p1275_cmd ("seek", P1275_ARG_64B(2) | 3, (unsigned) fd, 0, offset)) = -1)
 			    return -1;
 	    	} else {
 		        if ((*romvec->pv_v2devops.v2_dev_seek) (fd, (unsigned)(offset >> 32), (unsigned)offset) = -1)
@@ -311,7 +311,7 @@ int silo_disk_read(char *buff, int size, unsigned long long offset)
 	    }
 	}
 	if (prom_vers = PROM_P1275) {
-		rc = p1275_cmd ("read", 3, fd, buff, size);
+		rc = p1275_cmd ("read", 3, (unsigned) fd, buff, size);
 	} else {
 		int i;
 		for (i = 0; i < 2; i++) {
@@ -355,7 +355,7 @@ void silo_disk_close(void)
 	case PROM_V3:
 	    (*romvec->pv_v2devops.v2_dev_close) (fd); break;
 	case PROM_P1275:
-	    p1275_cmd ("close", 1, fd); break;
+	    p1275_cmd ("close", 1, (unsigned) fd); break;
 	}
     }
     *currentdevice = 0;
diff --git a/second/file.c b/second/file.c
index c7c1ed2..379af2f 100644
--- a/second/file.c
+++ b/second/file.c
@@ -193,7 +193,7 @@ int dump_block (blk_t * blocknr, int blockcnt)
                 }
                 last_blockcnt = -1;
             }
-            if ((char *)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
+            if ((unsigned int)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
                 silo_fatal("Image too large to fit in destination");
                 return BLOCK_ABORT;
             }
diff --git a/second/muldi3.S b/second/muldi3.S
index 7f17872..7180630 100644
--- a/second/muldi3.S
+++ b/second/muldi3.S
@@ -17,11 +17,19 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#if __WORDSIZE = 32
+# define STACK_BIAS 0
+#else
+# define STACK_BIAS 2047
+#endif
+
 	.text
 	.align 4
 	.globl __muldi3
+	.register %g2,#scratch
+	.register %g3,#scratch
 __muldi3:
-	save  %sp, -104, %sp
+	save  %sp, -STACK_BIAS-104, %sp
 	wr  %g0, %i1, %y
 	sra  %i3, 0x1f, %g2
 	and  %i1, %g2, %g2
diff --git a/silo/silo.c b/silo/silo.c
index 9728af2..20b7a0c 100644
--- a/silo/silo.c
+++ b/silo/silo.c
@@ -107,14 +107,14 @@ static int allow_confchk_fail = 0;
 
 /* This is just so that we don't have to fight with incompatible ufs_fs.h headers */
 #define SILO_UFS_MAGIC 0x00011954
-struct silo_ufs_super_block {
+struct __attribute__((packed)) silo_ufs_super_block {
 	unsigned char xxx1[36];
 	unsigned int fs_fsize;
 	unsigned char xxx2[1332];
 	unsigned int fs_magic;
 };
                                 
-struct sun_disklabel {
+struct __attribute__((packed)) sun_disklabel {
     unsigned char info[128];	/* Informative text string */
     unsigned char spare[292];	/* Boot information etc. */
     unsigned short rspeed;	/* Disk rotational speed */
@@ -127,9 +127,9 @@ struct sun_disklabel {
     unsigned short ntrks;	/* Tracks per cylinder */
     unsigned short nsect;	/* Sectors per track */
     unsigned char spare3[4];	/* Even more magic... */
-    struct sun_partition {
-	unsigned long start_cylinder;
-	unsigned long num_sectors;
+    struct __attribute__((packed)) sun_partition {
+	unsigned int start_cylinder;
+	unsigned int num_sectors;
     } partitions[8];
     unsigned short magic;	/* Magic number */
     unsigned short csum;	/* Label xor'd checksum */
@@ -205,7 +205,7 @@ int check_fs (int fd)
 {
     struct silo_ufs_super_block ufs;
     struct ext2_super_block sb;	/* Super Block Info */
-    struct romfs_super_block {
+    struct __attribute__((packed)) romfs_super_block {
 	__u32 word0;
 	__u32 word1;
 	__u32 size;
-- 
2.10.2


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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (11 preceding siblings ...)
  2016-11-24 22:59 ` John Paul Adrian Glaubitz
@ 2016-11-25 16:43 ` David Miller
  2016-11-25 16:44 ` David Miller
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: David Miller @ 2016-11-25 16:43 UTC (permalink / raw)
  To: sparclinux

From: Aaro Koskinen <aaro.koskinen@iki.fi>
Date: Fri, 25 Nov 2016 00:05:15 +0200

> Hi,
> 
> On Thu, Nov 24, 2016 at 10:51:14PM +0100, John Paul Adrian Glaubitz wrote:
>> On 11/24/2016 10:23 PM, Aaro Koskinen wrote:
>> > This breaks the native build on my Sun Ultra 5 with 32-bit userspace and GCC
>> > defaulting to ultrasparc:
>> 
>> Well, you can just change this part back to "elf32_sparc" and it will work. Might
>> even be possible to omit the "-m" option altogether to it will default to -m native.
> 
> I think that's your job to try. If you want to "add 64-bit support"
> (instead of forcing it to everybody), do the required changes so that
> it's still works for everybody without extra fiddling.

+1

This is exactly the kind of trouble the original patch submissions
were causing, and which were not resolved by the person submitting
the patches.

SILO must continue to build and work properly on systems which have a
predominantly 32-bit compilation environment and a gcc which defaults
to 32-bit.

I will not apply any patch which breaks this, because I too am going
to stick with a 32-bit userland on my sparc64 machines for as long as
I feasibly can.

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (12 preceding siblings ...)
  2016-11-25 16:43 ` David Miller
@ 2016-11-25 16:44 ` David Miller
  2016-11-25 16:55 ` John Paul Adrian Glaubitz
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: David Miller @ 2016-11-25 16:44 UTC (permalink / raw)
  To: sparclinux

From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Thu, 24 Nov 2016 23:26:20 +0100

> On 11/24/2016 11:05 PM, Aaro Koskinen wrote:
>> I think that's your job to try. If you want to "add 64-bit support"
>> (instead of forcing it to everybody), do the required changes so that
>> it's still works for everybody without extra fiddling.
> 
> Don't be so rude, I'm not forcing anything onto anyone.
> 
>>>> Also you broke the tilo build...
>>>
>>> Not here. Just tried it again and it builds fine. Can you be more specific?
>> 
>> The same issue as with silo.
> 
> Don't you think your statements are a bit misleading then? I didn't break anything,
> I changed the default target to 64-bit which is somewhat reasonable in the year
> 2016, isn't it.

Not really.

Many people, including myself, are still using predominantly 32-bit
userspace on sparc64 machines.  It is significantly faster, and for
me speed is really important.

So submitting a patch which breaks a common build environment is
really not acceptable.

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (13 preceding siblings ...)
  2016-11-25 16:44 ` David Miller
@ 2016-11-25 16:55 ` John Paul Adrian Glaubitz
  2016-11-25 21:22 ` Sam Ravnborg
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-25 16:55 UTC (permalink / raw)
  To: sparclinux

On 11/25/2016 05:44 PM, David Miller wrote:
> Many people, including myself, are still using predominantly 32-bit
> userspace on sparc64 machines.  It is significantly faster, and for
> me speed is really important.

I have already fixed this issue in a second version posted yesterday.

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (14 preceding siblings ...)
  2016-11-25 16:55 ` John Paul Adrian Glaubitz
@ 2016-11-25 21:22 ` Sam Ravnborg
  2016-11-26 12:21 ` John Paul Adrian Glaubitz
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Sam Ravnborg @ 2016-11-25 21:22 UTC (permalink / raw)
  To: sparclinux

Hi John.

On Thu, Nov 24, 2016 at 11:59:32PM +0100, John Paul Adrian Glaubitz wrote:
> This patch adds the necessary changes to compile silo
> on sparc64. It adds the required stack bias for stack
> operations and makes sure that all variables are properly
> aligned and have the proper size, both on 32- and 64-bit
> targets. These changes have been verified to work and
> have been used in Debian to ship silo as a 64-bit package.
> 
> Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> ---
>  Rules.make          |  5 ++---
>  common/console.c    |  6 +++---
>  common/divdi3.S     | 11 ++++++++++-
>  common/jmp.S        | 10 ++++++++--
>  common/prom.c       |  4 ++--
>  common/tree.c       |  8 ++++----
>  common/udivdi3.S    | 10 +++++++++-
>  first-isofs/crt0.S  |  8 +++++++-
>  first-isofs/isofs.c |  6 +++---
>  second/crt0.S       | 21 +++++++++++++++++++--
>  second/disk.c       |  8 ++++----
>  second/file.c       |  2 +-
>  second/muldi3.S     | 10 +++++++++-
>  silo/silo.c         | 12 ++++++------
>  14 files changed, 87 insertions(+), 34 deletions(-)
> 
> diff --git a/Rules.make b/Rules.make
> index 0f176db..e46af48 100644
> --- a/Rules.make
> +++ b/Rules.make
> @@ -2,10 +2,9 @@ VERSION=1.4.14
>  IMGVERSION=0.99
>  SHELL=/bin/bash
>  RM=rm -f
> -# We want to force 32-bit builds
> -CC=gcc -m32
> +CC=gcc
>  HOSTCC=gcc
> -LD=ld -m elf32_sparc
> +LD=ld
>  AS=as
>  STRIP=strip
>  NM=nm
> diff --git a/common/console.c b/common/console.c
> index 44d7efb..270caca 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -27,7 +27,7 @@ prom_nbgetchar(void)
>  			i = inc;
>  		break;
>  	case PROM_P1275:
> -		if (p1275_cmd ("read", 3, prom_stdin, &inc, 1) = 1)
> +		if (p1275_cmd ("read", 3, (unsigned int) prom_stdin, &inc, 1) = 1)
This is unrelated to the changelog.

The prototype:
int p1275_cmd (char *service, unsigned fmt, ...)

The above fixes a warning, where the right fix would be to let p1275_cmd()
take a signed paramter.

Likewise for all other cases that cast when calling p1275_cmd().

> +#define _SV save %sp, -STACK_BIAS-0x40, %sp

Spaces arounf "-" please.


>  #define _RV restore
>  #define FLUSH_ALL_WINDOWS \
>  	_SV; _SV; _SV; _SV; _SV; _SV; _SV; \
> @@ -46,7 +52,7 @@ __longjmp:
>  	FLUSH_ALL_WINDOWS
>  	ld [%o0], %o7		/* Return PC.  */
>  	ld [%o0 + 4], %fp	/* Saved SP.  */
> -	sub %fp, 64, %sp	/* Allocate a register save area.  */
> +	sub %fp, 64+STACK_BIAS, %sp	/* Allocate a register save area.  */
Spaces around "+"

>  	tst %o1
>  	be,a 1f
>  	mov 1, %o1
> diff --git a/common/prom.c b/common/prom.c
> index 939bbb9..7585e10 100644
> --- a/common/prom.c
> +++ b/common/prom.c
> @@ -196,7 +196,7 @@ int prom_map(int mode, unsigned long long size,
>  			    P1275_ARG_64B(3) | P1275_ARG_64B(4) |
>  			    P1275_ARG_64B(6) | 7,
>  			    "map",
> -			    prom_get_mmu_ihandle(),
> +			    (unsigned int) prom_get_mmu_ihandle(),
>  			    mode,
>  			    size,
>  			    vaddr,
> @@ -211,7 +211,7 @@ void prom_unmap(unsigned long long size, unsigned long long vaddr)
>  	p1275_cmd("call-method",
>  		  P1275_ARG_64B(2) | P1275_ARG_64B(3) | 4,
>  		  "unmap",
> -		  prom_get_mmu_ihandle(),
> +		  (unsigned int) prom_get_mmu_ihandle(),
>  		  size,
>  		  vaddr);
>  }

In both cases where the static prom_get_mmu_ihandle() is used
the return value has a cast int => unsigned int
If the unsigned variable is required then fix the function.


> diff --git a/common/tree.c b/common/tree.c
> index 56da8b8..65a7743 100644
> --- a/common/tree.c
> +++ b/common/tree.c
> @@ -22,7 +22,7 @@ int prom_getchild(int node)
>  	if (prom_vers != PROM_P1275)
>  		cnode = prom_nodeops->no_child(node);
>  	else
> -		cnode = p1275_cmd ("child", 1, node);
> +		cnode = p1275_cmd ("child", 1, (unsigned int) node);
Cannot see why this is required?

>  		
>  	if (cnode = 0 || cnode = -1)
>  		return 0;
> @@ -43,7 +43,7 @@ int prom_getsibling(int node)
>  	if (prom_vers != PROM_P1275)
>  		sibnode = prom_nodeops->no_nextnode(node);
>  	else
> -		sibnode = p1275_cmd ("peer", 1, node);
> +		sibnode = p1275_cmd ("peer", 1, (unsigned int) node);
Cannot see why this is required?

>  		
>  	if (sibnode = 0 || sibnode = -1)
>  		return 0;
> @@ -64,7 +64,7 @@ int prom_getproplen(int node, char *prop)
>  		if (prom_vers != PROM_P1275)
>  			ret = prom_nodeops->no_proplen(node, prop);
>  		else
> -			ret = p1275_cmd ("getproplen", 2, node, prop);
> +			ret = p1275_cmd ("getproplen", 2, (unsigned int) node, prop)
Likewise...


>  	}
>  	return ret;
>  }
> @@ -85,7 +85,7 @@ int prom_getproperty(int node, char *prop, char *buffer, int bufsize)
>  		if (prom_vers != PROM_P1275)
>  			ret = prom_nodeops->no_getprop(node, prop, buffer);
>  		else
> -			ret = p1275_cmd ("getprop", 4, node, prop, buffer, bufsize);
> +			ret = p1275_cmd ("getprop", 4, (unsigned int) node, prop, buffer, bufsize);
Likewise..
Same ges for reaming uses of cast to unisged int in p1275_cmd() calls.
Maybe I have missed something obvious?

> --- a/second/disk.c
> +++ b/second/disk.c
> @@ -79,7 +79,7 @@ int silo_disk_open(char *device)
>  
>          	fd = p1275_cmd ("open", 1, device);
>          	if ((unsigned)(fd + 1) > 1) {
> -		    node = p1275_cmd ("instance-to-package", 1, fd);
> +		    node = p1275_cmd ("instance-to-package", 1, (unsigned)fd);
New pattern. Now a cast to (unsigned) not (unsigend int) as before.
Goes for the rest of the file.

> diff --git a/second/file.c b/second/file.c
> index c7c1ed2..379af2f 100644
> --- a/second/file.c
> +++ b/second/file.c
> @@ -193,7 +193,7 @@ int dump_block (blk_t * blocknr, int blockcnt)
>                  }
>                  last_blockcnt = -1;
>              }
> -            if ((char *)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
> +            if ((unsigned int)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {

That if () needs a rewrite to somethign readable - which is not
the fault of this patch.

> +++ b/second/muldi3.S
> @@ -17,11 +17,19 @@ along with GNU CC; see the file COPYING.  If not, write to
>  the Free Software Foundation, 59 Temple Place - Suite 330,
>  Boston, MA 02111-1307, USA.  */
>  
> +#if __WORDSIZE = 32
> +# define STACK_BIAS 0
> +#else
> +# define STACK_BIAS 2047
> +#endif

The above have been repeated a few times now.
Stuff it in a header so we have on place to define this.


> diff --git a/silo/silo.c b/silo/silo.c
> index 9728af2..20b7a0c 100644
> --- a/silo/silo.c
> +++ b/silo/silo.c
> @@ -107,14 +107,14 @@ static int allow_confchk_fail = 0;
>  
>  /* This is just so that we don't have to fight with incompatible ufs_fs.h headers */
>  #define SILO_UFS_MAGIC 0x00011954
> -struct silo_ufs_super_block {
> +struct __attribute__((packed)) silo_ufs_super_block {
>  	unsigned char xxx1[36];
>  	unsigned int fs_fsize;
>  	unsigned char xxx2[1332];
>  	unsigned int fs_magic;
>  };
>                                  
> -struct sun_disklabel {
> +struct __attribute__((packed)) sun_disklabel {
>      unsigned char info[128];	/* Informative text string */
>      unsigned char spare[292];	/* Boot information etc. */
>      unsigned short rspeed;	/* Disk rotational speed */
> @@ -127,9 +127,9 @@ struct sun_disklabel {
>      unsigned short ntrks;	/* Tracks per cylinder */
>      unsigned short nsect;	/* Sectors per track */
>      unsigned char spare3[4];	/* Even more magic... */
> -    struct sun_partition {
> -	unsigned long start_cylinder;
> -	unsigned long num_sectors;
> +    struct __attribute__((packed)) sun_partition {
> +	unsigned int start_cylinder;
> +	unsigned int num_sectors;
>      } partitions[8];
>      unsigned short magic;	/* Magic number */
>      unsigned short csum;	/* Label xor'd checksum */

The kernel variant uses __be16/__be32 - we should maybe do the same here.
And the kernel do not need any packer attribute?!?

> @@ -205,7 +205,7 @@ int check_fs (int fd)
>  {
>      struct silo_ufs_super_block ufs;
>      struct ext2_super_block sb;	/* Super Block Info */
> -    struct romfs_super_block {
> +    struct __attribute__((packed)) romfs_super_block {
>  	__u32 word0;
>  	__u32 word1;
>  	__u32 size;
See how the kernel define this wwithout packed attribute. Maybe better?

	Sam

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (15 preceding siblings ...)
  2016-11-25 21:22 ` Sam Ravnborg
@ 2016-11-26 12:21 ` John Paul Adrian Glaubitz
  2016-11-26 17:27 ` Jose E. Marchesi
  2016-11-30 15:55 ` Jose E. Marchesi
  18 siblings, 0 replies; 20+ messages in thread
From: John Paul Adrian Glaubitz @ 2016-11-26 12:21 UTC (permalink / raw)
  To: sparclinux

Hi Sam!

On 11/25/2016 10:22 PM, Sam Ravnborg wrote:
> (...)

Thank you very much for all the input! This helps a lot!
I will have a look at your comments and improve the patch.

Cheers,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (16 preceding siblings ...)
  2016-11-26 12:21 ` John Paul Adrian Glaubitz
@ 2016-11-26 17:27 ` Jose E. Marchesi
  2016-11-30 15:55 ` Jose E. Marchesi
  18 siblings, 0 replies; 20+ messages in thread
From: Jose E. Marchesi @ 2016-11-26 17:27 UTC (permalink / raw)
  To: sparclinux


Some comments regarding the stack frames...
    
    Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    ---
     Rules.make          |  5 ++---
     common/console.c    |  6 +++---
     common/divdi3.S     | 11 ++++++++++-
     common/jmp.S        | 10 ++++++++--
     common/prom.c       |  4 ++--
     common/tree.c       |  8 ++++----
     common/udivdi3.S    | 10 +++++++++-
     first-isofs/crt0.S  |  8 +++++++-
     first-isofs/isofs.c |  6 +++---
     second/crt0.S       | 21 +++++++++++++++++++--
     second/disk.c       |  8 ++++----
     second/file.c       |  2 +-
     second/muldi3.S     | 10 +++++++++-
     silo/silo.c         | 12 ++++++------
     14 files changed, 87 insertions(+), 34 deletions(-)
    
    diff --git a/Rules.make b/Rules.make
    index 0f176db..e46af48 100644
    --- a/Rules.make
    +++ b/Rules.make
    @@ -2,10 +2,9 @@ VERSION=1.4.14
     IMGVERSION=0.99
     SHELL=/bin/bash
     RM=rm -f
    -# We want to force 32-bit builds
    -CC=gcc -m32
    +CC=gcc
     HOSTCC=gcc
    -LD=ld -m elf32_sparc
    +LD=ld
     AS=as
     STRIP=strip
     NM=nm
    diff --git a/common/console.c b/common/console.c
    index 44d7efb..270caca 100644
    --- a/common/console.c
    +++ b/common/console.c
    @@ -27,7 +27,7 @@ prom_nbgetchar(void)
     			i = inc;
     		break;
     	case PROM_P1275:
    -		if (p1275_cmd ("read", 3, prom_stdin, &inc, 1) = 1)
    +		if (p1275_cmd ("read", 3, (unsigned int) prom_stdin, &inc, 1) = 1)
     			i = inc;
     		break;
     	}
    @@ -55,7 +55,7 @@ prom_nbputchar(char c)
     		break;
     	case PROM_P1275:
     		outc = c;
    -		if (p1275_cmd ("write", 3, prom_stdout, &outc, 1) = 1)
    +		if (p1275_cmd ("write", 3, (unsigned int) prom_stdout, &outc, 1) = 1)
     			i = 0;
     		break;
     	}
    @@ -93,7 +93,7 @@ prom_puts (char *s, int len)
     		(*(romvec->pv_v2devops).v2_dev_write)(prom_stdout, s, len);
     		break;
     	case PROM_P1275:
    -		p1275_cmd ("write", 3, prom_stdout, s, len);
    +		p1275_cmd ("write", 3, (unsigned int) prom_stdout, s, len);
     		break;
     	}
     }
    diff --git a/common/divdi3.S b/common/divdi3.S
    index 681b368..128df53 100644
    --- a/common/divdi3.S
    +++ b/common/divdi3.S
    @@ -17,9 +17,18 @@ along with GNU CC; see the file COPYING.  If not, write to
     the Free Software Foundation, 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.  */
     
    +#if __WORDSIZE = 32
    +# define STACK_BIAS 0
    +#else
    +#define STACK_BIAS 2047
    +#endif
    +
     	.data
     	.align 8
     	.globl	__clz_tab
    +	.register %g2,#scratch
    +	.register %g3,#scratch
    +
     __clz_tab:
     	.byte	0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
     	.byte	6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
    @@ -36,7 +45,7 @@ __clz_tab:
     	.align 4
     	.globl __divdi3
     __divdi3:
    -	save %sp,-104,%sp
    +	save %sp,-STACK_BIAS-104,%sp


Subtracting the stack bias in that save instruction is wrong.  I would
suggest using something like this instead:

#if __WORDSIZE = 32
  save %sp,-104,%sp
#else
  save %sp,-192,%sp
#endif

        cmp %i0,0
     	bge .LL40
     	mov 0,%l4
    diff --git a/common/jmp.S b/common/jmp.S
    index 3bc8c94..a446d78 100644
    --- a/common/jmp.S
    +++ b/common/jmp.S
    @@ -18,7 +18,13 @@
        Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
        USA.  */
     
    -#define _SV save %sp, -0x40, %sp
    +#if __WORDSIZE = 32
    +# define STACK_BIAS 0
    +#else
    +# define STACK_BIAS 2047
    +#endif
    +
    +#define _SV save %sp, -STACK_BIAS-0x40, %sp

Same problem than above.  Here I would suggest something like this:

#if __WORDSIZE = 32
# define FRAMESIZE 0x40
#else
# define FRAMESIZE 0x80
#endif

#define _SV save %sp, -FRAMESIZE, %sp

     #define _RV restore
     #define FLUSH_ALL_WINDOWS \
     	_SV; _SV; _SV; _SV; _SV; _SV; _SV; \
    @@ -46,7 +52,7 @@ __longjmp:
     	FLUSH_ALL_WINDOWS
     	ld [%o0], %o7		/* Return PC.  */
     	ld [%o0 + 4], %fp	/* Saved SP.  */
    -	sub %fp, 64, %sp	/* Allocate a register save area.  */
    +	sub %fp, 64+STACK_BIAS, %sp	/* Allocate a register save area.  */

And then use FRAMESIZE here:
sub %fp, FRAMESIZE, %sp

        tst %o1
     	be,a 1f
     	mov 1, %o1
    diff --git a/common/prom.c b/common/prom.c
    index 939bbb9..7585e10 100644
    --- a/common/prom.c
    +++ b/common/prom.c
    @@ -196,7 +196,7 @@ int prom_map(int mode, unsigned long long size,
     			    P1275_ARG_64B(3) | P1275_ARG_64B(4) |
     			    P1275_ARG_64B(6) | 7,
     			    "map",
    -			    prom_get_mmu_ihandle(),
    +			    (unsigned int) prom_get_mmu_ihandle(),
     			    mode,
     			    size,
     			    vaddr,
    @@ -211,7 +211,7 @@ void prom_unmap(unsigned long long size, unsigned long long vaddr)
     	p1275_cmd("call-method",
     		  P1275_ARG_64B(2) | P1275_ARG_64B(3) | 4,
     		  "unmap",
    -		  prom_get_mmu_ihandle(),
    +		  (unsigned int) prom_get_mmu_ihandle(),
     		  size,
     		  vaddr);
     }
    diff --git a/common/tree.c b/common/tree.c
    index 56da8b8..65a7743 100644
    --- a/common/tree.c
    +++ b/common/tree.c
    @@ -22,7 +22,7 @@ int prom_getchild(int node)
     	if (prom_vers != PROM_P1275)
     		cnode = prom_nodeops->no_child(node);
     	else
    -		cnode = p1275_cmd ("child", 1, node);
    +		cnode = p1275_cmd ("child", 1, (unsigned int) node);
     		
     	if (cnode = 0 || cnode = -1)
     		return 0;
    @@ -43,7 +43,7 @@ int prom_getsibling(int node)
     	if (prom_vers != PROM_P1275)
     		sibnode = prom_nodeops->no_nextnode(node);
     	else
    -		sibnode = p1275_cmd ("peer", 1, node);
    +		sibnode = p1275_cmd ("peer", 1, (unsigned int) node);
     		
     	if (sibnode = 0 || sibnode = -1)
     		return 0;
    @@ -64,7 +64,7 @@ int prom_getproplen(int node, char *prop)
     		if (prom_vers != PROM_P1275)
     			ret = prom_nodeops->no_proplen(node, prop);
     		else
    -			ret = p1275_cmd ("getproplen", 2, node, prop);
    +			ret = p1275_cmd ("getproplen", 2, (unsigned int) node, prop);
     	}
     	return ret;
     }
    @@ -85,7 +85,7 @@ int prom_getproperty(int node, char *prop, char *buffer, int bufsize)
     		if (prom_vers != PROM_P1275)
     			ret = prom_nodeops->no_getprop(node, prop, buffer);
     		else
    -			ret = p1275_cmd ("getprop", 4, node, prop, buffer, bufsize);
    +			ret = p1275_cmd ("getprop", 4, (unsigned int) node, prop, buffer, bufsize);
     	}
     	return ret;
     }
    diff --git a/common/udivdi3.S b/common/udivdi3.S
    index b430f1f..25ba6ef 100644
    --- a/common/udivdi3.S
    +++ b/common/udivdi3.S
    @@ -17,11 +17,19 @@ along with GNU CC; see the file COPYING.  If not, write to
     the Free Software Foundation, 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.  */
     
    +#if __WORDSIZE = 32
    +# define STACK_BIAS 0
    +#else
    +# define STACK_BIAS 2047
    +#endif
     	.text
     	.align 4
     	.globl __udivdi3
    +	.register %g2,#scratch
    +	.register %g3,#scratch
    +
     __udivdi3:
    -	save %sp,-104,%sp
    +	save %sp,STACK_BIAS-104,%sp

Same problem here.  Again I would suggest:

#if __WORDSIZE = 32
  save %sp,-104,%sp
#else
  save %sp,-192,%sp
#endif

        mov %i3,%o3
     	cmp %i2,0
     	bne .LL40
    diff --git a/first-isofs/crt0.S b/first-isofs/crt0.S
    index 2db1281..88fcab5 100644
    --- a/first-isofs/crt0.S
    +++ b/first-isofs/crt0.S
    @@ -21,6 +21,12 @@
        Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
        USA.  */
     
    +#if __WORDSIZE = 32
    +# define STACK_BIAS 0
    +#else
    +# define STACK_BIAS 2047
    +#endif
    +
     #define COPY	jmpl	%o7 + (copy - _start), %l7
     
     	.text
    @@ -76,7 +82,7 @@ jumphere:
     	! Set up a stack
     setup_stack:
     	set	0x400000, %l1
    -	save	%l1, -64, %sp
    +	save	%l1, -STACK_BIAS-64, %sp

Here the STACK_BIAS in the save instruction seems correct, but we need
a different frame size for 64 bits.  Something like this:

#if __WORDSIZE = 32
save    %l1, -64, %sp
#else
save    %l1, -2047-128, %sp
#endif

     	! Call cd_main() to start the whole thingie up
     
    diff --git a/first-isofs/isofs.c b/first-isofs/isofs.c
    index d7a603b..47d1c48 100644
    --- a/first-isofs/isofs.c
    +++ b/first-isofs/isofs.c
    @@ -114,7 +114,7 @@ static void cd_fini(void)
     		break;
     
     	case PROM_P1275:
    -		p1275_cmd("close", 1, fd);
    +		p1275_cmd("close", 1, (unsigned)fd);
     		break;
     	};
     }
    @@ -141,7 +141,7 @@ static int cd_read_block(unsigned long long offset, int size, void *data)
     
     		if (seekp != offset) {
     			if (prom_vers = PROM_P1275) {
    -				if (p1275_cmd("seek", P1275_ARG_64B(2) | 3, fd, 0, offset) = -1)
    +				if (p1275_cmd("seek", P1275_ARG_64B(2) | 3, (unsigned)fd, 0, offset) = -1)
     					return -1;
     			} else {
     				if ((*romvec->pv_v2devops.v2_dev_seek)
    @@ -152,7 +152,7 @@ static int cd_read_block(unsigned long long offset, int size, void *data)
     		}
     
     		if (prom_vers = PROM_P1275)
    -			ret = p1275_cmd ("read", 3, fd, data, size);
    +			ret = p1275_cmd ("read", 3, (unsigned)fd, data, size);
     		else
     			ret = (*romvec->pv_v2devops.v2_dev_read) (fd, data, size);
     
    diff --git a/second/crt0.S b/second/crt0.S
    index f1ba1c8..399d174 100644
    --- a/second/crt0.S
    +++ b/second/crt0.S
    @@ -21,6 +21,12 @@
        Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
        USA.  */
     
    +#if __WORDSIZE = 32
    +# define STACK_BIAS 0
    +#else
    +# define STACK_BIAS 2047
    +#endif
    +
     #define COPY	jmpl	%o7 + (copy - _start), %l7
     
     	.text
    @@ -82,7 +88,11 @@ boot_parts:
     	sub	%l0, 16, %l0
     	sethi	%hi(gzminpi), %l1
     	add	%l1, %i3, %l1
    +#if __WORDSIZE = 32
     	st	%l0, [%l1 + %lo(gzminpi)]
    +#else
    +	stx	%l0, [%l1 + %lo(gzminpi)]
    +#endif
     
     	/* Jump to relocated code */
     	sethi	%hi(_end), %l0
    @@ -121,12 +131,15 @@ jumphere:
     
     	! Set up a stack
     setup_stack:
    -	save	%i0,-120,%sp
    -
    +	save	%i0,-STACK_BIAS-120,%sp

Here I think that the stack bias is correct, but again we need to adjust
the frame size to 64-bits.  Something like:

#if __WORDSIZE = 32
save    %i0,-120,%sp
#else
save    %i0,-2047-192,%sp
#endif
         

        tst	%i4
     	be	0f
     	 sethi	%hi(gzminpi+0x100000), %l0
    +#if __WORDSIZE = 32
     	ld	[%l0 + %lo(gzminpi)], %l1
    +#else
    +	ldx	[%l0 + %lo(gzminpi)], %l1
    +#endif
     	sethi	%hi(LARGE_RELOC), %l2
     1:	lduh	[%l1], %l3
     	add	%l1, 2, %l1
    @@ -147,7 +160,11 @@ setup_stack:
     	add	%l3, 16, %l3
     	ba	3b
     	 stb	%l3, [%l2]
    +#if __WORDSIZE = 32
     4:	st	%l1, [%l0 + %lo(gzminpi)]
    +#else
    +4:	stx	%l1, [%l0 + %lo(gzminpi)]
    +#endif
     
     	! Call my_main() to start the whole thingie up
     
    diff --git a/second/disk.c b/second/disk.c
    index 40234b3..989ab61 100644
    --- a/second/disk.c
    +++ b/second/disk.c
    @@ -79,7 +79,7 @@ int silo_disk_open(char *device)
     
             	fd = p1275_cmd ("open", 1, device);
             	if ((unsigned)(fd + 1) > 1) {
    -		    node = p1275_cmd ("instance-to-package", 1, fd);
    +		    node = p1275_cmd ("instance-to-package", 1, (unsigned)fd);
                         /*
                          * Don't use our argument due to devalias.
                          * Alas, flash has no device_type property.
    @@ -301,7 +301,7 @@ int silo_disk_read(char *buff, int size, unsigned long long offset)
     	    }
     	    if (seekp != offset) {
     	    	if (prom_vers = PROM_P1275) {
    -		        if ((rc = p1275_cmd ("seek", P1275_ARG_64B(2) | 3, fd, 0, offset)) = -1)
    +		        if ((rc = p1275_cmd ("seek", P1275_ARG_64B(2) | 3, (unsigned) fd, 0, offset)) = -1)
     			    return -1;
     	    	} else {
     		        if ((*romvec->pv_v2devops.v2_dev_seek) (fd, (unsigned)(offset >> 32), (unsigned)offset) = -1)
    @@ -311,7 +311,7 @@ int silo_disk_read(char *buff, int size, unsigned long long offset)
     	    }
     	}
     	if (prom_vers = PROM_P1275) {
    -		rc = p1275_cmd ("read", 3, fd, buff, size);
    +		rc = p1275_cmd ("read", 3, (unsigned) fd, buff, size);
     	} else {
     		int i;
     		for (i = 0; i < 2; i++) {
    @@ -355,7 +355,7 @@ void silo_disk_close(void)
     	case PROM_V3:
     	    (*romvec->pv_v2devops.v2_dev_close) (fd); break;
     	case PROM_P1275:
    -	    p1275_cmd ("close", 1, fd); break;
    +	    p1275_cmd ("close", 1, (unsigned) fd); break;
     	}
         }
         *currentdevice = 0;
    diff --git a/second/file.c b/second/file.c
    index c7c1ed2..379af2f 100644
    --- a/second/file.c
    +++ b/second/file.c
    @@ -193,7 +193,7 @@ int dump_block (blk_t * blocknr, int blockcnt)
                     }
                     last_blockcnt = -1;
                 }
    -            if ((char *)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
    +            if ((unsigned int)filebuffer + (block_cnt + ((*blocknr) ? (blockcnt - last_blockcnt - 1) : 0)) * bs > filelimit) {
                     silo_fatal("Image too large to fit in destination");
                     return BLOCK_ABORT;
                 }
    diff --git a/second/muldi3.S b/second/muldi3.S
    index 7f17872..7180630 100644
    --- a/second/muldi3.S
    +++ b/second/muldi3.S
    @@ -17,11 +17,19 @@ along with GNU CC; see the file COPYING.  If not, write to
     the Free Software Foundation, 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.  */
     
    +#if __WORDSIZE = 32
    +# define STACK_BIAS 0
    +#else
    +# define STACK_BIAS 2047
    +#endif
    +
     	.text
     	.align 4
     	.globl __muldi3
    +	.register %g2,#scratch
    +	.register %g3,#scratch
     __muldi3:
    -	save  %sp, -104, %sp
    +	save  %sp, -STACK_BIAS-104, %sp

Same problem with the stack bias.

#if __WORDSIZE = 32
  save %sp,-104,%sp
#else
  save %sp,-192,%sp
#endif

        wr  %g0, %i1, %y
     	sra  %i3, 0x1f, %g2
     	and  %i1, %g2, %g2
    diff --git a/silo/silo.c b/silo/silo.c
    index 9728af2..20b7a0c 100644
    --- a/silo/silo.c
    +++ b/silo/silo.c
    @@ -107,14 +107,14 @@ static int allow_confchk_fail = 0;
     
     /* This is just so that we don't have to fight with incompatible ufs_fs.h headers */
     #define SILO_UFS_MAGIC 0x00011954
    -struct silo_ufs_super_block {
    +struct __attribute__((packed)) silo_ufs_super_block {
     	unsigned char xxx1[36];
     	unsigned int fs_fsize;
     	unsigned char xxx2[1332];
     	unsigned int fs_magic;
     };
                                     
    -struct sun_disklabel {
    +struct __attribute__((packed)) sun_disklabel {
         unsigned char info[128];	/* Informative text string */
         unsigned char spare[292];	/* Boot information etc. */
         unsigned short rspeed;	/* Disk rotational speed */
    @@ -127,9 +127,9 @@ struct sun_disklabel {
         unsigned short ntrks;	/* Tracks per cylinder */
         unsigned short nsect;	/* Sectors per track */
         unsigned char spare3[4];	/* Even more magic... */
    -    struct sun_partition {
    -	unsigned long start_cylinder;
    -	unsigned long num_sectors;
    +    struct __attribute__((packed)) sun_partition {
    +	unsigned int start_cylinder;
    +	unsigned int num_sectors;
         } partitions[8];
         unsigned short magic;	/* Magic number */
         unsigned short csum;	/* Label xor'd checksum */
    @@ -205,7 +205,7 @@ int check_fs (int fd)
     {
         struct silo_ufs_super_block ufs;
         struct ext2_super_block sb;	/* Super Block Info */
    -    struct romfs_super_block {
    +    struct __attribute__((packed)) romfs_super_block {
     	__u32 word0;
     	__u32 word1;
     	__u32 size;

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

* Re: [PATCH] silo: Add 64-bit support
  2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
                   ` (17 preceding siblings ...)
  2016-11-26 17:27 ` Jose E. Marchesi
@ 2016-11-30 15:55 ` Jose E. Marchesi
  18 siblings, 0 replies; 20+ messages in thread
From: Jose E. Marchesi @ 2016-11-30 15:55 UTC (permalink / raw)
  To: sparclinux


Two more caveats in common/jmp.S..

    diff --git a/common/jmp.S b/common/jmp.S
    index 3bc8c94..a446d78 100644
    --- a/common/jmp.S
    +++ b/common/jmp.S
    @@ -18,7 +18,13 @@
        Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
        USA.  */
     
    -#define _SV save %sp, -0x40, %sp
    +#if __WORDSIZE = 32
    +# define STACK_BIAS 0
    +#else
    +# define STACK_BIAS 2047
    +#endif
    +
    +#define _SV save %sp, -STACK_BIAS-0x40, %sp
     #define _RV restore
     #define FLUSH_ALL_WINDOWS \
     	_SV; _SV; _SV; _SV; _SV; _SV; _SV; \
    @@ -46,7 +52,7 @@ __longjmp:
     	FLUSH_ALL_WINDOWS
        ld [%o0], %o7		/* Return PC.  */
     	ld [%o0 + 4], %fp	/* Saved SP.  */

#if __WORDSIZE = 32
        ld [%o0], %o7		/* Return PC.  */
     	ld [%o0 + 4], %fp	/* Saved SP.  */
#else
        ldx [%o0], %o7		/* Return PC.  */
     	ldx [%o0 + 8], %fp	/* Saved SP.  */
#endif

and also in the corresponding stores in setjmp:

#if __WORDSIZE = 32        
	st %o7, [%o0]
	st %sp, [%o0 + 4]
#else
        stx %o7, [%o0]
        stx %sp, [%o0 + 8]
#endif

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

end of thread, other threads:[~2016-11-30 15:55 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-24 17:33 [PATCH] silo: Add 64-bit support John Paul Adrian Glaubitz
2016-11-24 17:33 ` John Paul Adrian Glaubitz
2016-11-24 17:43 ` alexmcwhirter
2016-11-24 18:05 ` John Paul Adrian Glaubitz
2016-11-24 21:23 ` Aaro Koskinen
2016-11-24 21:51 ` John Paul Adrian Glaubitz
2016-11-24 22:05 ` Aaro Koskinen
2016-11-24 22:26 ` John Paul Adrian Glaubitz
2016-11-24 22:32 ` James Clarke
2016-11-24 22:35 ` John Paul Adrian Glaubitz
2016-11-24 22:51 ` Aaro Koskinen
2016-11-24 22:53 ` John Paul Adrian Glaubitz
2016-11-24 22:59 ` John Paul Adrian Glaubitz
2016-11-25 16:43 ` David Miller
2016-11-25 16:44 ` David Miller
2016-11-25 16:55 ` John Paul Adrian Glaubitz
2016-11-25 21:22 ` Sam Ravnborg
2016-11-26 12:21 ` John Paul Adrian Glaubitz
2016-11-26 17:27 ` Jose E. Marchesi
2016-11-30 15:55 ` Jose E. Marchesi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.