提交 ea9156fb 编写于 作者: M Mark Rutland 提交者: Michael S. Tsirkin

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: NMark 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: NMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: NCornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: NJason Wang <jasowang@redhat.com>
上级 9d1b972f
#ifndef UACCESS_H #ifndef UACCESS_H
#define UACCESS_H #define UACCESS_H
extern void *__user_addr_min, *__user_addr_max;
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) #include <linux/compiler.h>
extern void *__user_addr_min, *__user_addr_max;
static inline void __chk_user_ptr(const volatile void *p, size_t size) 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) ...@@ -13,7 +14,7 @@ static inline void __chk_user_ptr(const volatile void *p, size_t size)
({ \ ({ \
typeof(ptr) __pu_ptr = (ptr); \ typeof(ptr) __pu_ptr = (ptr); \
__chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \ __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
ACCESS_ONCE(*(__pu_ptr)) = x; \ WRITE_ONCE(*(__pu_ptr), x); \
0; \ 0; \
}) })
...@@ -21,7 +22,7 @@ static inline void __chk_user_ptr(const volatile void *p, size_t size) ...@@ -21,7 +22,7 @@ static inline void __chk_user_ptr(const volatile void *p, size_t size)
({ \ ({ \
typeof(ptr) __pu_ptr = (ptr); \ typeof(ptr) __pu_ptr = (ptr); \
__chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \ __chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
x = ACCESS_ONCE(*(__pu_ptr)); \ x = READ_ONCE(*(__pu_ptr)); \
0; \ 0; \
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册