Skip to content

Commit

Permalink
tools/virtio: use {READ,WRITE}_ONCE() in uaccess.h
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Jason Wang <[email protected]>
  • Loading branch information
Mark Rutland authored and mstsirkin committed Dec 15, 2016
1 parent 9d1b972 commit ea9156f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/virtio/linux/uaccess.h
Original file line number Diff line number Diff line change
@@ -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 <linux/compiler.h>

extern void *__user_addr_min, *__user_addr_max;

static inline void __chk_user_ptr(const volatile void *p, size_t size)
{
Expand All @@ -13,15 +14,15 @@ 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; \
})

#define get_user(x, ptr) \
({ \
typeof(ptr) __pu_ptr = (ptr); \
__chk_user_ptr(__pu_ptr, sizeof(*__pu_ptr)); \
x = ACCESS_ONCE(*(__pu_ptr)); \
x = READ_ONCE(*(__pu_ptr)); \
0; \
})

Expand Down

0 comments on commit ea9156f

Please sign in to comment.