From patchwork Wed May 22 13:22:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 164828 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp861056ili; Wed, 22 May 2019 06:25:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgbZtHCT0Xxt3qbmgEwKXqzqsFJ9OYirMJwcINGhRuXl2AtZZfcO6KptmJV1uU3oMRkvUL X-Received: by 2002:a63:6848:: with SMTP id d69mr91704937pgc.0.1558531510530; Wed, 22 May 2019 06:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558531510; cv=none; d=google.com; s=arc-20160816; b=Yvfgvy2Pm6aiJxYOfsDB6JQ0Wgi188WvMVdSVyX8lV5rjg4Ub4jFk6rAU8y6V5waCy VHVfPBJHZxJxGfsBU03m3HJ5x+wK0fKokcSn+Tm0cFUKlmIq8iFdDAY5IAgvHC5lEWOQ k3hJdlNqgZvotTDjXoUabOALDbqULqcuAgY5JrYmunpf1WuTpKg6YaSu1oPzUYMu/z/d WVa3sXgLDSAlJ7lkq1+z/Msk8TYdRpuruGIdCIgv/4gjFLhT2ohZEvyZlRP56tErOusC Gn0De/mL5bbP16zt2hOL1/YYaroJxkiE0DnaYeyw7UTHZDNBAOn3WN8OctUf5cuA2veq oYXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Y3a3DtL5vxb30QvjeCe0BFxibn7kZxuICtdDZY9FYmY=; b=U5No/1W3dESCg2mYgsYY6iUssGtQBRPqU6r1yhT6L6GfwSzBmF2FBPy9kxOUrIrrpm kIqHzCa82yw3XPLXRGUSMijOep0X/O4peqbkomINNZ5kmIp13WVur3VSErBoZqgZ9YaT Ob8rdsqXTThSt1eWEO5Vz6gLh9+cA9OiMyYdzyrdFHfC3C+8vvvJ3KhGpZOYFh/0qQkJ T7GM3y+mqbpNXhrrRqdcB2IOZWpumc52URK1c92SRS6XmarWaFvRNZkGUVQx64lSXk27 ygMjenvP7wtDm46vHzMeQrFpRv9s2RQliB+kYFyGAx/mDv7cp2XLi3vPgy8mXDiy+XMm fBmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f191si24087456pgc.570.2019.05.22.06.25.05; Wed, 22 May 2019 06:25:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729673AbfEVNZE (ORCPT + 30 others); Wed, 22 May 2019 09:25:04 -0400 Received: from foss.arm.com ([217.140.101.70]:51026 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729324AbfEVNZD (ORCPT ); Wed, 22 May 2019 09:25:03 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EC72715AB; Wed, 22 May 2019 06:25:02 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A32BB3F575; Wed, 22 May 2019 06:24:58 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org, peterz@infradead.org, will.deacon@arm.com Cc: aou@eecs.berkeley.edu, arnd@arndb.de, bp@alien8.de, catalin.marinas@arm.com, davem@davemloft.net, fenghua.yu@intel.com, heiko.carstens@de.ibm.com, herbert@gondor.apana.org.au, ink@jurassic.park.msu.ru, jhogan@kernel.org, linux@armlinux.org.uk, mark.rutland@arm.com, mattst88@gmail.com, mingo@kernel.org, mpe@ellerman.id.au, palmer@sifive.com, paul.burton@mips.com, paulus@samba.org, ralf@linux-mips.org, rth@twiddle.net, stable@vger.kernel.org, tglx@linutronix.de, tony.luck@intel.com, vgupta@synopsys.com Subject: [PATCH 11/18] locking/atomic: riscv: fix atomic64_sub_if_positive() offset argument Date: Wed, 22 May 2019 14:22:43 +0100 Message-Id: <20190522132250.26499-12-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190522132250.26499-1-mark.rutland@arm.com> References: <20190522132250.26499-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Presently the riscv implementation of atomic64_sub_if_positive() takes a 32-bit offset value rather than a 64-bit offset value as it should do. Thus, if called with a 64-bit offset, the value will be unexpectedly truncated to 32 bits. Fix this by taking the offset as a long rather than an int. Signed-off-by: Mark Rutland Cc: Albert Ou Cc: Palmer Dabbelt Cc: Peter Zijlstra Cc: Will Deacon Cc: stable@vger.kernel.org --- arch/riscv/include/asm/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/arch/riscv/include/asm/atomic.h b/arch/riscv/include/asm/atomic.h index 93826771b616..c9e18289d65c 100644 --- a/arch/riscv/include/asm/atomic.h +++ b/arch/riscv/include/asm/atomic.h @@ -336,7 +336,7 @@ static __always_inline int atomic_sub_if_positive(atomic_t *v, int offset) #define atomic_dec_if_positive(v) atomic_sub_if_positive(v, 1) #ifndef CONFIG_GENERIC_ATOMIC64 -static __always_inline long atomic64_sub_if_positive(atomic64_t *v, int offset) +static __always_inline long atomic64_sub_if_positive(atomic64_t *v, long offset) { long prev, rc;