From patchwork Sat Sep 30 21:24:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 9979587 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 769D56034B for ; Sat, 30 Sep 2017 21:24:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5919D28D18 for ; Sat, 30 Sep 2017 21:24:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C2A028D20; Sat, 30 Sep 2017 21:24:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D17E28D18 for ; Sat, 30 Sep 2017 21:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751202AbdI3VYZ (ORCPT ); Sat, 30 Sep 2017 17:24:25 -0400 Received: from belmont79srvr.owm.bell.net ([184.150.200.79]:50474 "EHLO mtlfep01.bell.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751141AbdI3VYZ (ORCPT ); Sat, 30 Sep 2017 17:24:25 -0400 Received: from bell.net mtlfep01 184.150.200.30 by mtlfep01.bell.net with ESMTP id <20170930212423.GESB11966.mtlfep01.bell.net@mtlspm01.bell.net> for ; Sat, 30 Sep 2017 17:24:23 -0400 Received: from [192.168.2.25] (really [70.54.50.145]) by mtlspm01.bell.net with ESMTP id <20170930212423.JKPU5856.mtlspm01.bell.net@[192.168.2.25]>; Sat, 30 Sep 2017 17:24:23 -0400 From: John David Anglin Mime-Version: 1.0 (Apple Message framework v1085) Date: Sat, 30 Sep 2017 17:24:23 -0400 Subject: [PATCH] parisc: Fix double-word compare and exchange on 32-bit kernels Cc: Helge Deller , "James E.J. Bottomley" To: linux-parisc List Message-Id: <44C4D87F-A487-4537-AE07-B938416DA437@bell.net> X-Mailer: Apple Mail (2.1085) X-Cloudmark-Analysis: v=2.2 cv=Pe0Qvmpd c=1 sm=0 tr=0 a=1hRIHJrxedDHIGFr3TbrYQ==:17 a=2JCJgTwv5E4A:10 a=FBHGMhGWAAAA:8 a=HTQvRuqGDTvnixegNgwA:9 a=CjuIK1q_8ugA:10 a=syUfrjFSKIRkY4oNQK0A:9 a=Ld372NDzu18A:10 a=CTwWI_8SlGQyalyz8_QA:9 a=ATlVsGG5QSsA:10 a=9gvnlMMaQFpL9xblJ6ne:22 Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As discussed on the debian-hppa list, double-wordcompare and exchange operations fail on 32-bit kernels. Looking at the code, I realized that the ",ma" completer does the wrong thing in the "ldw,ma 4(%r26), %r29" instruction. This increments %r26 and causes the following store to write to the wrong location. Signed-off-by: John David Anglin --- John David Anglin dave.anglin@bell.net diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S index 23de307c3052..41e60a9c7db2 100644 --- a/arch/parisc/kernel/syscall.S +++ b/arch/parisc/kernel/syscall.S @@ -742,7 +742,7 @@ lws_compare_and_swap_2: 10: ldd 0(%r25), %r25 11: ldd 0(%r24), %r24 #else - /* Load new value into r22/r23 - high/low */ + /* Load old value into r22/r23 - high/low */ 10: ldw 0(%r25), %r22 11: ldw 4(%r25), %r23 /* Load new value into fr4 for atomic store later */ @@ -834,11 +834,11 @@ cas2_action: copy %r0, %r28 #else /* Compare first word */ -19: ldw,ma 0(%r26), %r29 +19: ldw 0(%r26), %r29 sub,= %r29, %r22, %r0 b,n cas2_end /* Compare second word */ -20: ldw,ma 4(%r26), %r29 +20: ldw 4(%r26), %r29 sub,= %r29, %r23, %r0 b,n cas2_end /* Perform the store */