From patchwork Thu Oct 13 17:25:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Reshetova, Elena" X-Patchwork-Id: 9375523 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 B0FDF60487 for ; Thu, 13 Oct 2016 17:26:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3EC22A17D for ; Thu, 13 Oct 2016 17:26:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97D7A2A180; Thu, 13 Oct 2016 17:26:14 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id C632F2A17D for ; Thu, 13 Oct 2016 17:26:13 +0000 (UTC) Received: (qmail 14278 invoked by uid 550); 13 Oct 2016 17:26:11 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: kernel-hardening@lists.openwall.com Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 14240 invoked from network); 13 Oct 2016 17:26:08 -0000 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,340,1473145200"; d="scan'208";a="19746451" From: "Reshetova, Elena" To: Colin Vidal , "kernel-hardening@lists.openwall.com" , AKASHI Takahiro Thread-Topic: atomic64_wrap_t generic implementation Thread-Index: AQHSJMDDiJ7BGF+9aUqjJTP9GBPl9aCmoH8Q Date: Thu, 13 Oct 2016 17:25:53 +0000 Message-ID: <2236FBA76BA1254E88B949DDB74E612B41BDE37B@IRSMSX102.ger.corp.intel.com> References: <1476301332.19131.24.camel@cvidal.org> In-Reply-To: <1476301332.19131.24.camel@cvidal.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] MIME-Version: 1.0 Subject: [kernel-hardening] RE: atomic64_wrap_t generic implementation X-Virus-Scanned: ClamAV using ClamSMTP Hi Colin,  #define atomic64_dec_and_test(v)       (atomic64_dec_return((v)) == 0)  #define atomic64_inc_not_zero(v)       atomic64_add_unless((v), 1LL, 0LL)   +#define atomic64_read_wrap(v) atomic64_read(v) #define +atomic64_set_wrap(v, i) atomic64_set((v), (i)) #define +atomic64_add_wrap(a, v) atomic64_add((a), (v)) #define +atomic64_add_return_wrap(a, v) atomic64_add_return((a), (v)) #define +atomic64_sub_wrap(a, v) atomic64_sub((a), (v)) #define +atomic64_inc_wrap(v) atomic64_inc(v) #define +atomic64_inc_return_wrap(v) atomic64_inc_return(v) #define +atomic64_dec_wrap(v) atomic64_dec(v) #define atomic64_cmpxchg_wrap(v, +o, n) atomic64_cmpxchg((v), (o), (n)) #define atomic64_xchg_wrap(v, n) +atomic64_xchg((v), (n)) >Isen't there a type error ? For instance: >atomic64_wrap_t atom_wrap; >atomic64_read_wrap(atom_wrap) will be expanded into atomic64_read(atom_wrap), which would lead to a type error (atomic64_t expected). I have been double checking this now and I think for x86, all the changes in asm-generic/atomic64.h are not needed. X86 overrides them with arch. specific implementations in include/asm/atomic64_64.h and include/asm/atomic64_32.h Takahiro, you have been looking into arm. Are the above ones used in any way in arm or can we simply get rid of the whole bundle of changes? Best Regards, Elena. diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h index dad68bf..4987419 100644 --- a/include/asm-generic/atomic64.h +++ b/include/asm-generic/atomic64.h @@ -16,6 +16,8 @@ typedef struct {         long long counter;  } atomic64_t;   +typedef atomic64_t atomic64_wrap_t; +  #define ATOMIC64_INIT(i)       { (i) }    extern long long atomic64_read(const atomic64_t *v); @@ -62,4 +64,15 @@ extern int    atomic64_add_unless(atomic64_t *v, long long a, long long u);