From mboxrd@z Thu Jan 1 00:00:00 1970 From: bugzilla-daemon@freedesktop.org Subject: [Bug 100077] libdrm atomic_add_unless() may reverse return value meaning Date: Mon, 06 Mar 2017 08:41:32 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2113708430==" Return-path: Received: from culpepper.freedesktop.org (culpepper.freedesktop.org [IPv6:2610:10:20:722:a800:ff:fe98:4b55]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EE496E3CE for ; Mon, 6 Mar 2017 08:41:32 +0000 (UTC) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============2113708430== Content-Type: multipart/alternative; boundary="14887896920.e6Afb.25850"; charset="UTF-8" --14887896920.e6Afb.25850 Date: Mon, 6 Mar 2017 08:41:32 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.freedesktop.org/ Auto-Submitted: auto-generated https://bugs.freedesktop.org/show_bug.cgi?id=3D100077 Bug ID: 100077 Summary: libdrm atomic_add_unless() may reverse return value meaning Product: DRI Version: unspecified Hardware: x86-64 (AMD64) OS: BSD (Others) Status: NEW Severity: normal Priority: medium Component: libdrm Assignee: dri-devel@lists.freedesktop.org Reporter: davshao@gmail.com atomic_add_unless() in libdrm xf86atomic.h may reverse the meaning of its return value. Linux kernel documentation seems to indicate something like: "Returns non-zero if @v was not @u, and zero otherwise." A simple inverting the meaning of libdrm's return value allowed glxgears to properly function for a hacked version of pkgsrc on DragonFly 4.7-DEVELOPMENT on an Intel IvyBridge integrated graphics machine. glxgears was already properly functioning on the same machine for NetBSD current, NetBSD using its own atomic operations declared in its sys/atomic.h header. A one line (character) fix is of the form: --- xf86atomic.h.orig 2015-09-22 04:34:51.000000000 +0000 +++ xf86atomic.h @@ -111,7 +111,7 @@ static inline int atomic_add_unless(atom c =3D atomic_read(v); while (c !=3D unless && (old =3D atomic_cmpxchg(v, c, c + add)) != =3D c) c =3D old; - return c =3D=3D unless; + return c !=3D unless; } --=20 You are receiving this mail because: You are the assignee for the bug.= --14887896920.e6Afb.25850 Date: Mon, 6 Mar 2017 08:41:32 +0000 MIME-Version: 1.0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.freedesktop.org/ Auto-Submitted: auto-generated
Bug ID 100077
Summary libdrm atomic_add_unless() may reverse return value meaning
Product DRI
Version unspecified
Hardware x86-64 (AMD64)
OS BSD (Others)
Status NEW
Severity normal
Priority medium
Component libdrm
Assignee dri-devel@lists.freedesktop.org
Reporter davshao@gmail.com

atomic_add_unless() in libdrm xf86atomic.h may reverse the mea=
ning
of its return value.

Linux kernel documentation seems to indicate something like:
"Returns non-zero if @v was not @u, and zero otherwise."

A simple inverting the meaning of libdrm's return value
allowed glxgears to properly function for a hacked version
of pkgsrc on DragonFly 4.7-DEVELOPMENT on an Intel IvyBridge
integrated graphics machine.  glxgears was already properly
functioning on the same machine for NetBSD current, NetBSD
using its own atomic operations declared in its sys/atomic.h
header.

A one line (character) fix is of the form:

--- xf86atomic.h.orig   2015-09-22 04:34:51.000000000 +0000
+++ xf86atomic.h
@@ -111,7 +111,7 @@ static inline int atomic_add_unless(atom
        c =3D atomic_read(v);
        while (c !=3D unless && (old =3D atomic_cmpxchg(v, c, c + a=
dd)) !=3D c)
                c =3D old;
-       return c =3D=3D unless;
+       return c !=3D unless;
 }


You are receiving this mail because:
  • You are the assignee for the bug.
= --14887896920.e6Afb.25850-- --===============2113708430== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============2113708430==--