From patchwork Tue Aug 6 07:00:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11078281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 090A41395 for ; Tue, 6 Aug 2019 07:02:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB65F288FC for ; Tue, 6 Aug 2019 07:02:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDB962892B; Tue, 6 Aug 2019 07:02:22 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3628288FC for ; Tue, 6 Aug 2019 07:02:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hutS4-0002kl-Ef; Tue, 06 Aug 2019 07:00:08 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hutS3-0002kg-KN for xen-devel@lists.xenproject.org; Tue, 06 Aug 2019 07:00:07 +0000 X-Inumbo-ID: d0546c04-b817-11e9-8224-0336220bd45e Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d0546c04-b817-11e9-8224-0336220bd45e; Tue, 06 Aug 2019 07:00:03 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8FA7AAD7F; Tue, 6 Aug 2019 07:00:02 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 09:00:00 +0200 Message-Id: <20190806070000.13718-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 Subject: [Xen-devel] [PATCH] xen/x86: lock cacheline for add_sized() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP add_sized() should use an atomic update of the memory word, as it is used by spin_unlock(). With ticket locks unlocking needs to be atomic in order to avoid very rare races when someone tries to get the lock while the lock holder is just releasing it. Signed-off-by: Juergen Gross --- xen/include/asm-x86/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/asm-x86/atomic.h b/xen/include/asm-x86/atomic.h index 682bcf91b1..0ef6a60e69 100644 --- a/xen/include/asm-x86/atomic.h +++ b/xen/include/asm-x86/atomic.h @@ -21,7 +21,7 @@ static inline void name(volatile type *addr, type val) \ #define build_add_sized(name, size, type, reg) \ static inline void name(volatile type *addr, type val) \ { \ - asm volatile("add" size " %1,%0" \ + asm volatile("lock; add" size " %1,%0" \ : "=m" (*addr) \ : reg (val)); \ }