Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6158C433DF for ; Mon, 17 Aug 2020 09:24:50 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 762CE2072D for ; Mon, 17 Aug 2020 09:24:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Z1yPhGUf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 762CE2072D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k7bNI-0001yP-TA; Mon, 17 Aug 2020 09:24:16 +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.92) (envelope-from ) id 1k7bNI-0001yK-Gr for xen-devel@lists.xenproject.org; Mon, 17 Aug 2020 09:24:16 +0000 X-Inumbo-ID: 924179c9-6945-4af0-b64f-60e596047527 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 924179c9-6945-4af0-b64f-60e596047527; Mon, 17 Aug 2020 09:24:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1597656255; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=a8EuNS+FyCsS3+jc99KD8Hn21BTahhBDwTlDVxAMES8=; b=Z1yPhGUfDzUkxnt6TwBbJOYIE1onmNzJf1q0dpWRs6Q8krY2CKzVz45Z 5lDkcNzK7hFWgCFWWeQdApxH/ghJvl0fHW/pkVkdtjZk7nbUysopweiX+ XECwhZfAQVycMz9yriRZv67jH/r4K4WuPnX+DT5jmWpWM+9jIhRSVoLlc I=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: Qw8AWra/g9ywudCpLzYMLT6P+r7qE0J9ZmmoloqiKwJjCPZN2qJHcGCzjMndFxtbqAHLuPmDaG Ag8bdzpsrS+E7+jeLECDagTHL3IJyfvv0H7SN4n+n+xjOiSLCq5ALaT6NT3ZO01ESINo75S/lw 1f0swjgAw6aWlmPE5ZgVSlByhJXCGIBTWXWHFV9p1HsOFKPFFcRGB29VduH/JKdewoWResHTlH YiTli02L++hilzsa1jRm4PVO4FXULU/dVybQcNSh1juxGVnEvbunBZt5zdoGfrEDyNQ02JNqNg 9Lc= X-SBRS: 2.7 X-MesageID: 24640582 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.76,322,1592884800"; d="scan'208";a="24640582" Date: Mon, 17 Aug 2020 11:24:06 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Julien Grall CC: , Julien Grall , Stefano Stabellini , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , Wei Liu , Oleksandr Tyshchenko Subject: Re: [PATCH] xen: Introduce cmpxchg64() and guest_cmpxchg64() Message-ID: <20200817092406.GO975@Air-de-Roger> References: <20200815172143.1327-1-julien@xen.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20200815172143.1327-1-julien@xen.org> X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Sat, Aug 15, 2020 at 06:21:43PM +0100, Julien Grall wrote: > From: Julien Grall > > The IOREQ code is using cmpxchg() with 64-bit value. At the moment, this > is x86 code, but there is plan to make it common. > > To cater 32-bit arch, introduce two new helpers to deal with 64-bit > cmpxchg. > > The Arm 32-bit implementation of cmpxchg64() is based on the __cmpxchg64 > in Linux v5.8 (arch/arm/include/asm/cmpxchg.h). > > Signed-off-by: Julien Grall > Cc: Oleksandr Tyshchenko > --- > diff --git a/xen/include/asm-x86/guest_atomics.h b/xen/include/asm-x86/guest_atomics.h > index 029417c8ffc1..f4de9d3631ff 100644 > --- a/xen/include/asm-x86/guest_atomics.h > +++ b/xen/include/asm-x86/guest_atomics.h > @@ -20,6 +20,8 @@ > ((void)(d), test_and_change_bit(nr, p)) > > #define guest_cmpxchg(d, ptr, o, n) ((void)(d), cmpxchg(ptr, o, n)) > +#define guest_cmpxchg64(d, ptr, o, n) ((void)(d), cmpxchg64(ptr, o, n)) > + > > #endif /* _X86_GUEST_ATOMICS_H */ > /* > diff --git a/xen/include/asm-x86/x86_64/system.h b/xen/include/asm-x86/x86_64/system.h > index f471859c19cc..c1b16105e9f2 100644 > --- a/xen/include/asm-x86/x86_64/system.h > +++ b/xen/include/asm-x86/x86_64/system.h > @@ -5,6 +5,8 @@ > ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \ > (unsigned long)(n),sizeof(*(ptr)))) > > +#define cmpxchg64(ptr, o, n) cmpxchg(ptr, o, n) Why do you need to introduce an explicitly sized version of cmpxchg for 64bit values? There's no cmpxchg{8,16,32}, so I would expect cmpxchg64 to just be handled by cmpxchg detecting the size of the parameter passed to the function. I think it's worth adding to the commit message why such differentiated helper is needed. Thanks, Roger.