Your message dated Sun, 22 Apr 2018 22:05:49 +0000
with message-id <[email protected]>
and subject line Bug#892088: fixed in golang-1.10 1.10.1-3
has caused the Debian Bug report #892088,
regarding golang-1.10: FTBFS on mips when built on Octeon III buildds
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
892088: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892088
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Source: golang-1.10
Version: 1.10-1
Severity: serious
Tags: upstream patch
Forwarded: https://go-review.googlesource.com/c/go/+/97735
X-Debbugs-CC: [email protected]

[CC the list for the HW issue]

Hi,

golang-1.10 (and 1.9) FTBFS on mips big-endian with various floating
point test errors, but only when built on the Octeon III buildds.

After tearing my head out investigating this, I have concluded that
there is a hardware bug in the Octeon IIIs. The bug occurs when:
- You run a big floating point double operation (like div.d).
- Wait a few instructions (a store here seems to be important).
- Read the *odd* register which the above float operation stored into.
This ends up reading the value from before the double operation instead
of the result of the operation. I've attached a small C program which
reproduces this. It should happen 99% of the time (it will only fail if
you are unlucky and get an interrupt at the wrong time).

I think this does not affect the wider Debian archive because:
- MFHC1 (move from high float) seems to be unaffected (probably...)
- If mips32r2 and fpxx are enabled, GCC only reads the high part of a
float register using MFHC1 (in the few cases it needs to do this - like
integer <-> float conversion).

However, golang is affected because it uses FP32 and on big endian, all
double loads are split into word loads with the odd register loaded
first. I have attached a patch which fixes this which I have also
submitted upstream.

Thanks,
James
#include <stdint.h>
#include <stdio.h>

static void div_octeon_bug(double a, double b, uint32_t* buf)
{
	asm(
		"mtc1 %[fake_clobber], $f5\n"
		"div.d $f4, %[a], %[b]\n"
		"nop\n"
		"nop\n"
		"nop\n"
		"nop\n"
		"swc1 $f0, 0(%[buf])\n"
		"swc1 $f0, 0(%[buf])\n"
		"swc1 $f5, 0(%[buf])\n"
		"swc1 $f4, 4(%[buf])\n"
		"swc1 $f5, 8(%[buf])\n"
		"swc1 $f4, 12(%[buf])\n"
		:
		: [buf]"r"(buf), [fake_clobber]"r"(0xdeadbeef), [a]"f"(a), [b]"f"(b)
		: "memory", "f4", "$f5");
}

int main(void)
{
	uint32_t buf[4];
	div_octeon_bug(1.0, 21.63538985889851, buf);
	printf("%08x %08x\n", buf[0], buf[1]);
	printf("%08x %08x\n", buf[2], buf[3]);
	return 0;
}
From 5ab26b4e5996a3557a1d6f1af7f1e54104448a79 Mon Sep 17 00:00:00 2001
From: James Cowgill <[email protected]>
Date: Wed, 28 Feb 2018 16:10:14 +0000
Subject: [PATCH] cmd/internal/obj/mips: load/store even float registers first

There is a bug in Octeon III processors where storing an odd floating
point register after it has recently been written to by a double
floating point operation will store the old value from before the double
operation (there are some extra details - the operation and store
must be a certain number of cycles apart). However, this bug does not
occur if the even register is stored first. Currently the bug only
happens on big endian because go always loads the even register first on
little endian.

Workaround the bug by always loading / storing the even floating point
register first. Since this is just an instruction reordering, it should
have no performance penalty. This follows other compilers like GCC which
will always store the even register first (although you do have to set
the ISA level to MIPS I to prevent it from using SDC1).

Change-Id: I5e73daa4d724ca1df7bf5228aab19f53f26a4976
---
 src/cmd/internal/obj/mips/obj0.go | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/cmd/internal/obj/mips/obj0.go b/src/cmd/internal/obj/mips/obj0.go
index 2b9f18c942..c3bab5c48e 100644
--- a/src/cmd/internal/obj/mips/obj0.go
+++ b/src/cmd/internal/obj/mips/obj0.go
@@ -558,20 +558,22 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym, newprog obj.ProgAlloc) {
 			p.Link = q
 			p1 = q.Link
 
-			var regOff int16
+			var addrOff int64
 			if c.ctxt.Arch.ByteOrder == binary.BigEndian {
-				regOff = 1 // load odd register first
+				addrOff = 4 // swap load/save order
 			}
 			if p.From.Type == obj.TYPE_MEM {
 				reg := REG_F0 + (p.To.Reg-REG_F0)&^1
-				p.To.Reg = reg + regOff
-				q.To.Reg = reg + 1 - regOff
-				q.From.Offset += 4
+				p.To.Reg = reg
+				q.To.Reg = reg + 1
+				p.From.Offset += addrOff
+				q.From.Offset += 4 - addrOff
 			} else if p.To.Type == obj.TYPE_MEM {
 				reg := REG_F0 + (p.From.Reg-REG_F0)&^1
-				p.From.Reg = reg + regOff
-				q.From.Reg = reg + 1 - regOff
-				q.To.Offset += 4
+				p.From.Reg = reg
+				q.From.Reg = reg + 1
+				p.To.Offset += addrOff
+				q.To.Offset += 4 - addrOff
 			}
 		}
 	}
-- 
2.16.2

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
Source: golang-1.10
Source-Version: 1.10.1-3

We believe that the bug you reported is fixed in the latest version of
golang-1.10, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Martín Ferrari <[email protected]> (supplier of updated golang-1.10 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Sun, 22 Apr 2018 21:21:05 +0000
Source: golang-1.10
Binary: golang-1.10-go golang-1.10-src golang-1.10-doc golang-1.10
Architecture: source
Version: 1.10.1-3
Distribution: unstable
Urgency: high
Maintainer: Go Compiler Team <[email protected]>
Changed-By: Martín Ferrari <[email protected]>
Description:
 golang-1.10 - Go programming language compiler - metapackage
 golang-1.10-doc - Go programming language - documentation
 golang-1.10-go - Go programming language compiler, linker, compiled stdlib
 golang-1.10-src - Go programming language - source files
Closes: 892088 894992
Changes:
 golang-1.10 (1.10.1-3) unstable; urgency=high
 .
   * Team upload.
 .
   [ Michael Hudson-Doyle ]
   * Install the 'misc' and 'api' directories as part of the golang-1.10-src
     package as some tools (vgo, go tool trace) expect them to be there.
     (Closes: 894992¸ LP: #1743598)
 .
   [ Martín Ferrari ]
   * Backport fix for FP bug in mips/Octeon III. Closes: #892088. Raising
     severity.
Checksums-Sha1:
 739c32213cfa8e2d9b23abc1d2388924175e1e33 2551 golang-1.10_1.10.1-3.dsc
 ff780d5d21f9545237b4264c76c3a850890090c0 27520 
golang-1.10_1.10.1-3.debian.tar.xz
 768524f859ffa521622232021cc432dac849f107 6407 
golang-1.10_1.10.1-3_amd64.buildinfo
Checksums-Sha256:
 9b789111b24cb131992dca4f3a0d1285ac6a3abc9fd6cd9f80f740dc7c5c3297 2551 
golang-1.10_1.10.1-3.dsc
 80a52daa7ad0a3006c65412e97cd2a9ef93279691e890c42bba26248e979b56e 27520 
golang-1.10_1.10.1-3.debian.tar.xz
 b2dacdb9f77379488d6ab63d6f7f0863351b122be099d668cd054ef62eae2aa3 6407 
golang-1.10_1.10.1-3_amd64.buildinfo
Files:
 6ff81325fc4be3b927c9fb119a75f336 2551 devel optional golang-1.10_1.10.1-3.dsc
 a3935adf8cc8dcb57e710b43eff38967 27520 devel optional 
golang-1.10_1.10.1-3.debian.tar.xz
 61f7967a4259b2fda31c1edd9982c0c1 6407 devel optional 
golang-1.10_1.10.1-3_amd64.buildinfo

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEETe94h3mvRsa9AoOeXdjgv5Gj09oFAlrdASYACgkQXdjgv5Gj
09rkZhAAkKAWpFzQIOugVh0F+6d2F4Jllftp8XjSAmFA5d4zqqfDR65BxjujVcMQ
7flz5k+I5u6ZmZTBzZOoB3S0f/LpSUgh4Z8oJ8mw5Hcc1+RCfzaIDp8LRAvxzJ+0
MiFqGJnK2lA4q5c2oltdcSonQkfYOBKd8GCy83RYQ2mtun9q5YkAUu/W3oYzmemh
DF+BC8Ys4gfm8drWRCMdFazQVTAz/0Axhh1tyrqkJfYvVp/6qi9q5tZqZsfwGLbz
N508wGk0Ic1SGM9H1kOGiRthyMBkLFzNdOysr2Xvh/fPaeC7Fe4xZbNyiBLh9i1Q
Pr99ZszuSCQnWD2cGXZ9B1vGXDm4rycv8mjgDuyqbR0DO6UwlgFBkyGqv6qppZRa
xcFT4rJ30aZryuLai48hsQoIk2QOx/cw8jbjbxkb1ZlnPa0CH1g5kBBkC2EW3b+p
Jyuffvh2j5BQuMl0KHRmC4JEbGLEEs576YFYcRaNnfTiD5WTKMquNNP8zLqt0khT
Py1szpBOFzBQClvQEAXjpu6KfE+Um9XxMKYhZD7SLzX14q5xoOXdQh7RLjE6Gkly
nrWyqpn5B3XjXgRhXytwVgjLcOIZqlxqRaf7kvqaHz+bsQF01kdMYO1NUPJsvVAe
o4vmseGO96A3A+ard8jnHqmmA1SWWsQquDSkCMrAFFB+Bm6qqIo=
=Om2T
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to