aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kvm/gaccess.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/kvm/gaccess.h')
-rw-r--r--arch/s390/kvm/gaccess.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/arch/s390/kvm/gaccess.h b/arch/s390/kvm/gaccess.h
index 8608d7e6a334..302e0e52b009 100644
--- a/arch/s390/kvm/gaccess.h
+++ b/arch/s390/kvm/gaccess.h
@@ -18,8 +18,9 @@
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include "kvm-s390.h" 19#include "kvm-s390.h"
20 20
21static inline void *__gptr_to_uptr(struct kvm_vcpu *vcpu, void *gptr, 21static inline void __user *__gptr_to_uptr(struct kvm_vcpu *vcpu,
22 int prefixing) 22 void __user *gptr,
23 int prefixing)
23{ 24{
24 unsigned long prefix = vcpu->arch.sie_block->prefix; 25 unsigned long prefix = vcpu->arch.sie_block->prefix;
25 unsigned long gaddr = (unsigned long) gptr; 26 unsigned long gaddr = (unsigned long) gptr;
@@ -34,14 +35,14 @@ static inline void *__gptr_to_uptr(struct kvm_vcpu *vcpu, void *gptr,
34 uaddr = gmap_fault(gaddr, vcpu->arch.gmap); 35 uaddr = gmap_fault(gaddr, vcpu->arch.gmap);
35 if (IS_ERR_VALUE(uaddr)) 36 if (IS_ERR_VALUE(uaddr))
36 uaddr = -EFAULT; 37 uaddr = -EFAULT;
37 return (void *)uaddr; 38 return (void __user *)uaddr;
38} 39}
39 40
40#define get_guest(vcpu, x, gptr) \ 41#define get_guest(vcpu, x, gptr) \
41({ \ 42({ \
42 __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\ 43 __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\
43 int __mask = sizeof(__typeof__(*(gptr))) - 1; \ 44 int __mask = sizeof(__typeof__(*(gptr))) - 1; \
44 int __ret = PTR_RET(__uptr); \ 45 int __ret = PTR_RET((void __force *)__uptr); \
45 \ 46 \
46 if (!__ret) { \ 47 if (!__ret) { \
47 BUG_ON((unsigned long)__uptr & __mask); \ 48 BUG_ON((unsigned long)__uptr & __mask); \
@@ -54,7 +55,7 @@ static inline void *__gptr_to_uptr(struct kvm_vcpu *vcpu, void *gptr,
54({ \ 55({ \
55 __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\ 56 __typeof__(gptr) __uptr = __gptr_to_uptr(vcpu, gptr, 1);\
56 int __mask = sizeof(__typeof__(*(gptr))) - 1; \ 57 int __mask = sizeof(__typeof__(*(gptr))) - 1; \
57 int __ret = PTR_RET(__uptr); \ 58 int __ret = PTR_RET((void __force *)__uptr); \
58 \ 59 \
59 if (!__ret) { \ 60 if (!__ret) { \
60 BUG_ON((unsigned long)__uptr & __mask); \ 61 BUG_ON((unsigned long)__uptr & __mask); \
@@ -68,19 +69,19 @@ static inline int __copy_guest(struct kvm_vcpu *vcpu, unsigned long to,
68 int to_guest, int prefixing) 69 int to_guest, int prefixing)
69{ 70{
70 unsigned long _len, rc; 71 unsigned long _len, rc;
71 void *uptr; 72 void __user *uptr;
72 73
73 while (len) { 74 while (len) {
74 uptr = to_guest ? (void *)to : (void *)from; 75 uptr = to_guest ? (void __user *)to : (void __user *)from;
75 uptr = __gptr_to_uptr(vcpu, uptr, prefixing); 76 uptr = __gptr_to_uptr(vcpu, uptr, prefixing);
76 if (IS_ERR(uptr)) 77 if (IS_ERR((void __force *)uptr))
77 return -EFAULT; 78 return -EFAULT;
78 _len = PAGE_SIZE - ((unsigned long)uptr & (PAGE_SIZE - 1)); 79 _len = PAGE_SIZE - ((unsigned long)uptr & (PAGE_SIZE - 1));
79 _len = min(_len, len); 80 _len = min(_len, len);
80 if (to_guest) 81 if (to_guest)
81 rc = copy_to_user(uptr, (void *)from, _len); 82 rc = copy_to_user((void __user *) uptr, (void *)from, _len);
82 else 83 else
83 rc = copy_from_user((void *)to, uptr, _len); 84 rc = copy_from_user((void *)to, (void __user *)uptr, _len);
84 if (rc) 85 if (rc)
85 return -EFAULT; 86 return -EFAULT;
86 len -= _len; 87 len -= _len;