From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7C2AC54E94 for ; Thu, 26 Jan 2023 16:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674750832; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bMosRqKvrZ+PUCh/1C+XMtSmpFfltBvkGAZQ+lK5mlc=; b=ScYYX+UiJkMV94Y3OZg2GOk4ktghNOhg7slvW0ooJQC2VO5+UY/7evhoIEuulRxTVr+1UM Hz2cSFeD4p0iLmlYFFTfkfidP2bYEnRhPNkcv7FC4rMHmx7rkTz/D7jVnkV/Wbmlh00VEv qwOM8x1yTK3DG1W2+C7FJmEjXGl4qfM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-7pDL-VK3O-idmFWJdBxjtA-1; Thu, 26 Jan 2023 11:33:51 -0500 X-MC-Unique: 7pDL-VK3O-idmFWJdBxjtA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 04D3A1991C44; Thu, 26 Jan 2023 16:33:50 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA8A8492C14; Thu, 26 Jan 2023 16:33:49 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CFDD6194658D; Thu, 26 Jan 2023 16:33:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C1CFC194658C for ; Thu, 26 Jan 2023 11:15:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 6CE592026D76; Thu, 26 Jan 2023 11:15:54 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 651122026D4B for ; Thu, 26 Jan 2023 11:15:54 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 46D67857F82 for ; Thu, 26 Jan 2023 11:15:54 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by relay.mimecast.com with ESMTP id us-mta-222-aRhJMwwCOVCkaUjigmRqAA-1; Thu, 26 Jan 2023 06:15:50 -0500 X-MC-Unique: aRhJMwwCOVCkaUjigmRqAA-1 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 33988C14; Thu, 26 Jan 2023 03:16:31 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.10.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 402733F71E; Thu, 26 Jan 2023 03:15:40 -0800 (PST) Date: Thu, 26 Jan 2023 11:15:37 +0000 From: Mark Rutland To: Jules Maselbas Subject: Re: [RFC PATCH v2 11/31] kvx: Add atomic/locking headers Message-ID: References: <20230120141002.2442-1-ysionneau@kalray.eu> <20230120141002.2442-12-ysionneau@kalray.eu> <20230126095720.GF5952@tellis.lin.mbt.kalray.eu> MIME-Version: 1.0 In-Reply-To: <20230126095720.GF5952@tellis.lin.mbt.kalray.eu> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mailman-Approved-At: Thu, 26 Jan 2023 16:33:45 +0000 X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason A. Donenfeld" , Marc =?utf-8?B?UG91bGhpw6hz?= , linux-doc@vger.kernel.org, Peter Zijlstra , Catalin Marinas , Atish Patra , Jiaxun Yang , Julien Hascoet , Clement Leger , linux-mm@kvack.org, devicetree@vger.kernel.org, Louis Morhet , Krzysztof Kozlowski , linux-riscv@lists.infradead.org, Will Deacon , Guangbin Huang , Alex Michon , Thomas Costis , Jonathan Corbet , Jonathan Borne , Marc Zyngier , Huacai Chen , bpf@vger.kernel.org, Samuel Jones , Ingo Molnar , linux-arch@vger.kernel.org, Jean-Christophe Pince , Waiman Long , Bharat Bhushan , Qi Liu , Alexey Dobriyan , Luc Michel , John Garry , Ashley Lesdalons , Albert Ou , Kees Cook , Arnd Bergmann , Yann Sionneau , Boqun Feng , Guillaume Thouvenin , Julian Vetter , Nick Piggin , Shaokun Zhang , Rob Herring , Bibo Mao , Paul Walmsley , WANG Xuerui , Thomas Gleixner , Marius Gligor , Janosch Frank , Julien Villette , linux-audit@redhat.com, Christian Brauner , Benjamin Mugnier , Vincent Chardon , Guillaume Missonnier , Oleg Nesterov , Eric Paris , linux-kernel@vger.kernel.org, Mark Brown , Palmer Dabbelt , Eric Biederman , "Aneesh Kumar K.V" , Andrew Morton Errors-To: linux-audit-bounces@redhat.com Sender: "Linux-audit" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi Jules, On Thu, Jan 26, 2023 at 10:57:20AM +0100, Jules Maselbas wrote: > Hi Mark, > > On Fri, Jan 20, 2023 at 03:18:48PM +0000, Mark Rutland wrote: > > On Fri, Jan 20, 2023 at 03:09:42PM +0100, Yann Sionneau wrote: > > > +#define ATOMIC64_RETURN_OP(op, c_op) \ > > > +static inline long arch_atomic64_##op##_return(long i, atomic64_t *v) \ > > > +{ \ > > > + long new, old, ret; \ > > > + \ > > > + do { \ > > > + old = v->counter; \ > > > > This should be arch_atomic64_read(v), in order to avoid the potential for the > > compiler to replay the access and introduce ABA races and other such problems. > Thanks for the suggestion, this will be into v3. > > > For details, see: > > > > https://lore.kernel.org/lkml/Y70SWXHDmOc3RhMd@osiris/ > > https://lore.kernel.org/lkml/Y71LoCIl+IFdy9D8@FVFF77S0Q05N/ > > > > I see that the generic 32-bit atomic code suffers from that issue, and we > > should fix it. > I took a look at the generic 32-bit atomic, but I am unsure if this > needs to be done for both the SMP and non-SMP implementations. But I > can send a first patch and we can discuss from there. Sounds good to me; thanks! [...] > > > +static inline int arch_atomic_add_return(int i, atomic_t *v) > > > +{ > > > + int new, old, ret; > > > + > > > + do { > > > + old = v->counter; > > > > Likewise, arch_atomic64_read(v) here. > ack, this will bt arch_atomic_read(v) here since this is not atomic64_t > here. Ah, yes, my bad! Thanks, Mark. -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit