From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752262AbcKYClB (ORCPT ); Thu, 24 Nov 2016 21:41:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60244 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751303AbcKYCkz (ORCPT ); Thu, 24 Nov 2016 21:40:55 -0500 Subject: Re: [PATCH 3/3] tools/virtio: use {READ,WRITE}_ONCE() in uaccess.h To: Mark Rutland , linux-kernel@vger.kernel.org References: <1479983114-17190-1-git-send-email-mark.rutland@arm.com> <1479983114-17190-4-git-send-email-mark.rutland@arm.com> Cc: dave@stgolabs.net, dbueso@suse.de, dvyukov@google.com, kvm@vger.kernel.org, mst@redhat.com, netdev@vger.kernel.org, paulmck@linux.vnet.ibm.com, virtualization@lists.linux-foundation.org From: Jason Wang Message-ID: Date: Fri, 25 Nov 2016 10:40:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1479983114-17190-4-git-send-email-mark.rutland@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 25 Nov 2016 02:40:54 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016年11月24日 18:25, Mark Rutland wrote: > As a step towards killing off ACCESS_ONCE, use {READ,WRITE}_ONCE() for the > virtio tools uaccess primitives, pulling these in from . > > With this done, we can kill off the now-unused ACCESS_ONCE() definition. > > Signed-off-by: Mark Rutland > Cc: Jason Wang > Cc: Michael S. Tsirkin > Cc: linux-kernel@vger.kernel.org > Cc: virtualization@lists.linux-foundation.org > --- > tools/virtio/linux/uaccess.h | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/tools/virtio/linux/uaccess.h b/tools/virtio/linux/uaccess.h > index 0a578fe..fa05d01 100644 > --- a/tools/virtio/linux/uaccess.h > +++ b/tools/virtio/linux/uaccess.h > @@ -1,8 +1,9 @@ > #ifndef UACCESS_H > #define UACCESS_H > -extern void *__user_addr_min, *__user_addr_max; > > -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) > +#include > + > +extern void *__user_addr_min, *__user_addr_max; > > static inline void __chk_user_ptr(const volatile void *p, size_t size) > { > @@ -13,7 +14,7 @@ static inline void __chk_user_ptr(const volatile void *p, size_t size) > ({ \ > typeof(ptr) __pu_ptr = (ptr); \ > __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \ > - ACCESS_ONCE(*(__pu_ptr)) = x; \ > + WRITE_ONCE(*(__pu_ptr), x); \ > 0; \ > }) > > @@ -21,7 +22,7 @@ static inline void __chk_user_ptr(const volatile void *p, size_t size) > ({ \ > typeof(ptr) __pu_ptr = (ptr); \ > __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \ > - x = ACCESS_ONCE(*(__pu_ptr)); \ > + x = READ_ONCE(*(__pu_ptr)); \ > 0; \ > }) > Reviewed-by: Jason Wang