Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools/virtio: use {READ,WRITE}_ONCE() in uaccess.h

As a step towards killing off ACCESS_ONCE, use {READ,WRITE}_ONCE() for the
virtio tools uaccess primitives, pulling these in from <linux/compiler.h>.

With this done, we can kill off the now-unused ACCESS_ONCE() definition.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: linux-kernel@vger.kernel.org
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>

authored by

Mark Rutland and committed by
Michael S. Tsirkin
ea9156fb 9d1b972f

+5 -4
+5 -4
tools/virtio/linux/uaccess.h
··· 1 1 #ifndef UACCESS_H 2 2 #define UACCESS_H 3 - extern void *__user_addr_min, *__user_addr_max; 4 3 5 - #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) 4 + #include <linux/compiler.h> 5 + 6 + extern void *__user_addr_min, *__user_addr_max; 6 7 7 8 static inline void __chk_user_ptr(const volatile void *p, size_t size) 8 9 { ··· 14 13 ({ \ 15 14 typeof(ptr) __pu_ptr = (ptr); \ 16 15 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \ 17 - ACCESS_ONCE(*(__pu_ptr)) = x; \ 16 + WRITE_ONCE(*(__pu_ptr), x); \ 18 17 0; \ 19 18 }) 20 19 ··· 22 21 ({ \ 23 22 typeof(ptr) __pu_ptr = (ptr); \ 24 23 __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \ 25 - x = ACCESS_ONCE(*(__pu_ptr)); \ 24 + x = READ_ONCE(*(__pu_ptr)); \ 26 25 0; \ 27 26 }) 28 27