Re: libgo patch committed: Add S/390 support to internal/cpu package

2019-02-20 Thread Ian Lance Taylor
On Sat, Feb 16, 2019 at 1:28 PM Jakub Jelinek  wrote:
>
> On Sat, Feb 16, 2019 at 08:42:11AM +0100, Jakub Jelinek wrote:
> > On Fri, Feb 15, 2019 at 08:59:29PM +0100, Matthias Klose wrote:
> > > On 15.02.19 15:52, Ian Lance Taylor wrote:
> > > > This patch by Robin Dapp adds S/390 support to the internal/cpu
> > > > package.  This partially addresses PR 89123.  I bootstrapped it on
> > > > x86_64-pc-linux-gnu, which means little.  Committed to mainline.
> > >
> > > fails in the -m31 multilib variant with
> >
> > Indeed.  Given that there is just
> > libgo/go/internal/cpu/cpu_s390x.go
> > libgo/go/internal/cpu/cpu_s390x_test.go
> > (note, no s390), I think the easiest fix is:
>
> Bootstrapped/regtested on s390x-linux successfully now.

Thanks, committed to mainline.

Ian


Re: libgo patch committed: Add S/390 support to internal/cpu package

2019-02-16 Thread Jakub Jelinek
On Sat, Feb 16, 2019 at 08:42:11AM +0100, Jakub Jelinek wrote:
> On Fri, Feb 15, 2019 at 08:59:29PM +0100, Matthias Klose wrote:
> > On 15.02.19 15:52, Ian Lance Taylor wrote:
> > > This patch by Robin Dapp adds S/390 support to the internal/cpu
> > > package.  This partially addresses PR 89123.  I bootstrapped it on
> > > x86_64-pc-linux-gnu, which means little.  Committed to mainline.
> > 
> > fails in the -m31 multilib variant with
> 
> Indeed.  Given that there is just
> libgo/go/internal/cpu/cpu_s390x.go
> libgo/go/internal/cpu/cpu_s390x_test.go
> (note, no s390), I think the easiest fix is:

Bootstrapped/regtested on s390x-linux successfully now.

> --- libgo/go/internal/cpu/cpu_gccgo.c.jj  2019-02-16 07:57:27.882179972 
> +0100
> +++ libgo/go/internal/cpu/cpu_gccgo.c 2019-02-16 08:36:37.241900882 +0100
> @@ -71,7 +71,7 @@ struct xgetbv_ret xgetbv(void) {
>  
>  #endif /* defined(__i386__) || defined(__x86_64__)  */
>  
> -#ifdef __s390__
> +#ifdef __s390x__
>  
>  struct facilityList {
>   uint64_t bits[4];
> @@ -184,4 +184,4 @@ struct queryResult klmdQuery() {
>  return ret;
>  }
>  
> -#endif /* defined(__s390__)  */
> +#endif /* defined(__s390x__)  */
> 
> If cpu_s390.go is ever added, this can be changed again and there can be say
> #ifdef __s390x__
> #define LHI "lghi"
> #else
> #define LHI "lhi"
> #endif
> and replace "lghi ... in the inline asm with LHI "...

Jakub


Re: libgo patch committed: Add S/390 support to internal/cpu package

2019-02-15 Thread Jakub Jelinek
On Fri, Feb 15, 2019 at 08:59:29PM +0100, Matthias Klose wrote:
> On 15.02.19 15:52, Ian Lance Taylor wrote:
> > This patch by Robin Dapp adds S/390 support to the internal/cpu
> > package.  This partially addresses PR 89123.  I bootstrapped it on
> > x86_64-pc-linux-gnu, which means little.  Committed to mainline.
> 
> fails in the -m31 multilib variant with

Indeed.  Given that there is just
libgo/go/internal/cpu/cpu_s390x.go
libgo/go/internal/cpu/cpu_s390x_test.go
(note, no s390), I think the easiest fix is:

--- libgo/go/internal/cpu/cpu_gccgo.c.jj2019-02-16 07:57:27.882179972 
+0100
+++ libgo/go/internal/cpu/cpu_gccgo.c   2019-02-16 08:36:37.241900882 +0100
@@ -71,7 +71,7 @@ struct xgetbv_ret xgetbv(void) {
 
 #endif /* defined(__i386__) || defined(__x86_64__)  */
 
-#ifdef __s390__
+#ifdef __s390x__
 
 struct facilityList {
uint64_t bits[4];
@@ -184,4 +184,4 @@ struct queryResult klmdQuery() {
 return ret;
 }
 
-#endif /* defined(__s390__)  */
+#endif /* defined(__s390x__)  */

If cpu_s390.go is ever added, this can be changed again and there can be say
#ifdef __s390x__
#define LHI "lghi"
#else
#define LHI "lhi"
#endif
and replace "lghi ... in the inline asm with LHI "...

Jakub


Re: libgo patch committed: Add S/390 support to internal/cpu package

2019-02-15 Thread Matthias Klose
On 15.02.19 15:52, Ian Lance Taylor wrote:
> This patch by Robin Dapp adds S/390 support to the internal/cpu
> package.  This partially addresses PR 89123.  I bootstrapped it on
> x86_64-pc-linux-gnu, which means little.  Committed to mainline.

fails in the -m31 multilib variant with

libtool: compile:  /<>/build/./gcc/xgcc
-B/<>/build/./gcc/ -B/usr/s390x-linux-gnu/bin/
-B/usr/s390x-linux-gnu/lib/ -isystem /usr/s390x-linux-gnu/include -isystem
/usr/s390x-linux-gnu/sys-include -isys
tem /<>/build/sys-include -m31 -DHAVE_CONFIG_H -I.
-I../../../../src/libgo -I ../../../../src/libgo/
runtime -I../../../../src/libgo/../libffi/include -I../libffi/include -pthread
-L../libatomic/.libs -fexceptions
-fnon-call-exceptions -fno-stack-protector -fsplit-stack -Wall -Wextra
-Wwrite-strings -Wcast-qual -D_GNU_SOURCE
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I ../../../../src/libgo/../libgcc -I
../../../../src/libgo/../libback
trace -I ../../../gcc/include -g -O2 -m31 -c
../../../../src/libgo/go/internal/cpu/cpu_gccgo.c  -fPIC -DPIC -o in
ternal/cpu/.libs/cpu_gccgo.o

../../../../src/libgo/go/internal/cpu/cpu_gccgo.c: Assembler messages:
../../../../src/libgo/go/internal/cpu/cpu_gccgo.c:91: Error: Unrecognized
opcode: `lghi'
../../../../src/libgo/go/internal/cpu/cpu_gccgo.c:105: Error: Unrecognized
opcode: `lghi'
../../../../src/libgo/go/internal/cpu/cpu_gccgo.c:119: Error: Unrecognized
opcode: `lghi'
../../../../src/libgo/go/internal/cpu/cpu_gccgo.c:134: Error: Unrecognized
opcode: `lghi'
../../../../src/libgo/go/internal/cpu/cpu_gccgo.c:149: Error: Unrecognized
opcode: `lghi'
../../../../src/libgo/go/internal/cpu/cpu_gccgo.c:164: Error: Unrecognized
opcode: `lghi'
../../../../src/libgo/go/internal/cpu/cpu_gccgo.c:179: Error: Unrecognized
opcode: `lghi'
make[10]: *** [Makefile:2899: internal/cpu/cpu_gccgo.lo] Error 1

make[10]: *** Waiting for unfinished jobs
make[10]: Leaving directory '/<>/build/s390x-linux-gnu/32/libgo'
make[9]: *** [Makefile:2242: all-recursive] Error 1
make[9]: Leaving directory '/<>/build/s390x-linux-gnu/32/libgo'
make[8]: *** [Makefile:1167: all] Error 2
make[8]: Leaving directory '/<>/build/s390x-linux-gnu/32/libgo'
make[7]: *** [Makefile:3062: multi-do] Error 1

using binutils 2.32


libgo patch committed: Add S/390 support to internal/cpu package

2019-02-15 Thread Ian Lance Taylor
This patch by Robin Dapp adds S/390 support to the internal/cpu
package.  This partially addresses PR 89123.  I bootstrapped it on
x86_64-pc-linux-gnu, which means little.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===
--- gcc/go/gofrontend/MERGE (revision 268940)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-6877c95a5f44c3ab4f492d2000ce07771341d7b7
+0563f2d018cdb2cd685c254bac5ceb38396d0a27
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/internal/cpu/cpu_gccgo.c
===
--- libgo/go/internal/cpu/cpu_gccgo.c   (revision 268369)
+++ libgo/go/internal/cpu/cpu_gccgo.c   (working copy)
@@ -70,3 +70,118 @@ struct xgetbv_ret xgetbv(void) {
 #pragma GCC pop_options
 
 #endif /* defined(__i386__) || defined(__x86_64__)  */
+
+#ifdef __s390__
+
+struct facilityList {
+   uint64_t bits[4];
+};
+
+struct queryResult {
+   uint64_t bits[2];
+};
+
+struct facilityList stfle(void)
+  __asm__(GOSYM_PREFIX "internal..z2fcpu.stfle")
+  __attribute__((no_split_stack));
+
+struct facilityList stfle(void) {
+struct facilityList ret;
+__asm__ ("la%%r1, %[ret]\t\n"
+"lghi  %%r0, 3\t\n" // last doubleword index to store
+"xc0(32,%%r1), 0(%%r1)\t\n" // clear 4 doublewords (32 bytes)
+".long 0xb2b01000\t\n"  // store facility list extended (STFLE)
+:[ret] "=Q" (ret) : : "r0", "r1", "cc");
+return ret;
+}
+
+struct queryResult kmQuery(void)
+  __asm__(GOSYM_PREFIX "internal..z2fcpu.kmQuery")
+  __attribute__((no_split_stack));
+
+struct queryResult kmQuery() {
+struct queryResult ret;
+
+__asm__ ("lghi   %%r0, 0\t\n" // set function code to 0 (KM-Query)
+"la %%r1, %[ret]\t\n"
+".long  0xb92e0024\t\n" // cipher message (KM)
+:[ret] "=Q" (ret) : : "r0", "r1", "cc");
+return ret;
+}
+
+struct queryResult kmcQuery(void)
+  __asm__(GOSYM_PREFIX "internal..z2fcpu.kmcQuery")
+  __attribute__((no_split_stack));
+
+struct queryResult kmcQuery() {
+struct queryResult ret;
+
+__asm__ ("lghi   %%r0, 0\t\n" // set function code to 0 (KMC-Query)
+"la %%r1, %[ret]\t\n"
+".long  0xb92f0024\t\n"  // cipher message with chaining (KMC)
+:[ret] "=Q" (ret) : : "r0", "r1", "cc");
+
+return ret;
+}
+
+struct queryResult kmctrQuery(void)
+  __asm__(GOSYM_PREFIX "internal..z2fcpu.kmctrQuery")
+  __attribute__((no_split_stack));
+
+struct queryResult kmctrQuery() {
+struct queryResult ret;
+
+__asm__ ("lghi   %%r0, 0\t\n" // set function code to 0 (KMCTR-Query)
+"la %%r1, %[ret]\t\n"
+".long  0xb92d4024\t\n" // cipher message with counter (KMCTR)
+:[ret] "=Q" (ret) : : "r0", "r1", "cc");
+
+return ret;
+}
+
+struct queryResult kmaQuery(void)
+  __asm__(GOSYM_PREFIX "internal..z2fcpu.kmaQuery")
+  __attribute__((no_split_stack));
+
+struct queryResult kmaQuery() {
+struct queryResult ret;
+
+__asm__ ("lghi   %%r0, 0\t\n" // set function code to 0 (KMA-Query)
+"la %%r1, %[ret]\t\n"
+".long  0xb9296024\t\n" // cipher message with authentication (KMA)
+:[ret] "=Q" (ret) : : "r0", "r1", "cc");
+
+return ret;
+}
+
+struct queryResult kimdQuery(void)
+  __asm__(GOSYM_PREFIX "internal..z2fcpu.kimdQuery")
+  __attribute__((no_split_stack));
+
+struct queryResult kimdQuery() {
+struct queryResult ret;
+
+__asm__ ("lghi   %%r0, 0\t\n"  // set function code to 0 (KIMD-Query)
+"la %%r1, %[ret]\t\n"
+".long  0xb93e0024\t\n"  // compute intermediate message digest 
(KIMD)
+:[ret] "=Q" (ret) : : "r0", "r1", "cc");
+
+return ret;
+}
+
+struct queryResult klmdQuery(void)
+  __asm__(GOSYM_PREFIX "internal..z2fcpu.klmdQuery")
+  __attribute__((no_split_stack));
+
+struct queryResult klmdQuery() {
+struct queryResult ret;
+
+__asm__ ("lghi   %%r0, 0\t\n"  // set function code to 0 (KLMD-Query)
+"la %%r1, %[ret]\t\n"
+".long  0xb93f0024\t\n"  // compute last message digest (KLMD)
+:[ret] "=Q" (ret) : : "r0", "r1", "cc");
+
+return ret;
+}
+
+#endif /* defined(__s390__)  */
Index: libgo/go/internal/cpu/cpu_s390x.go
===
--- libgo/go/internal/cpu/cpu_s390x.go  (revision 268369)
+++ libgo/go/internal/cpu/cpu_s390x.go  (working copy)
@@ -98,13 +98,13 @@ func (s *facilityList) Has(fs ...facilit
 
 // The following feature detection functions are defined in cpu_s390x.s.
 // They are likely to be expensive to call so the results should be cached.
-func stfle() facilityList { panic("not implemented for gccgo") }
-func kmQuery() queryResult{ panic("not implemented for gccgo") }
-func kmcQuery()