aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/s390/kvm/gaccess.h21
-rw-r--r--arch/s390/kvm/intercept.c4
-rw-r--r--arch/s390/kvm/interrupt.c36
-rw-r--r--arch/s390/kvm/priv.c22
4 files changed, 42 insertions, 41 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;
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 64744003a66e..c6ba4dfd7f1e 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -44,7 +44,7 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)
44 44
45 do { 45 do {
46 rc = get_guest(vcpu, vcpu->arch.sie_block->gcr[reg], 46 rc = get_guest(vcpu, vcpu->arch.sie_block->gcr[reg],
47 (u64 *) useraddr); 47 (u64 __user *) useraddr);
48 if (rc) { 48 if (rc) {
49 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 49 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
50 break; 50 break;
@@ -78,7 +78,7 @@ static int handle_lctl(struct kvm_vcpu *vcpu)
78 78
79 reg = reg1; 79 reg = reg1;
80 do { 80 do {
81 rc = get_guest(vcpu, val, (u32 *) useraddr); 81 rc = get_guest(vcpu, val, (u32 __user *) useraddr);
82 if (rc) { 82 if (rc) {
83 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 83 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
84 break; 84 break;
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index d78824b18e9d..5c948177529e 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -188,9 +188,9 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
188 vcpu->stat.deliver_emergency_signal++; 188 vcpu->stat.deliver_emergency_signal++;
189 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, 189 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
190 inti->emerg.code, 0); 190 inti->emerg.code, 0);
191 rc = put_guest(vcpu, 0x1201, (u16 *)__LC_EXT_INT_CODE); 191 rc = put_guest(vcpu, 0x1201, (u16 __user *)__LC_EXT_INT_CODE);
192 rc |= put_guest(vcpu, inti->emerg.code, 192 rc |= put_guest(vcpu, inti->emerg.code,
193 (u16 *)__LC_EXT_CPU_ADDR); 193 (u16 __user *)__LC_EXT_CPU_ADDR);
194 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW, 194 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW,
195 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 195 &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
196 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw, 196 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
@@ -201,9 +201,9 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
201 vcpu->stat.deliver_external_call++; 201 vcpu->stat.deliver_external_call++;
202 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, 202 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
203 inti->extcall.code, 0); 203 inti->extcall.code, 0);
204 rc = put_guest(vcpu, 0x1202, (u16 *)__LC_EXT_INT_CODE); 204 rc = put_guest(vcpu, 0x1202, (u16 __user *)__LC_EXT_INT_CODE);
205 rc |= put_guest(vcpu, inti->extcall.code, 205 rc |= put_guest(vcpu, inti->extcall.code,
206 (u16 *)__LC_EXT_CPU_ADDR); 206 (u16 __user *)__LC_EXT_CPU_ADDR);
207 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW, 207 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW,
208 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 208 &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
209 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw, 209 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
@@ -215,13 +215,13 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
215 vcpu->stat.deliver_service_signal++; 215 vcpu->stat.deliver_service_signal++;
216 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, 216 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
217 inti->ext.ext_params, 0); 217 inti->ext.ext_params, 0);
218 rc = put_guest(vcpu, 0x2401, (u16 *)__LC_EXT_INT_CODE); 218 rc = put_guest(vcpu, 0x2401, (u16 __user *)__LC_EXT_INT_CODE);
219 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW, 219 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW,
220 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 220 &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
221 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw, 221 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
222 __LC_EXT_NEW_PSW, sizeof(psw_t)); 222 __LC_EXT_NEW_PSW, sizeof(psw_t));
223 rc |= put_guest(vcpu, inti->ext.ext_params, 223 rc |= put_guest(vcpu, inti->ext.ext_params,
224 (u32 *)__LC_EXT_PARAMS); 224 (u32 __user *)__LC_EXT_PARAMS);
225 break; 225 break;
226 case KVM_S390_INT_VIRTIO: 226 case KVM_S390_INT_VIRTIO:
227 VCPU_EVENT(vcpu, 4, "interrupt: virtio parm:%x,parm64:%llx", 227 VCPU_EVENT(vcpu, 4, "interrupt: virtio parm:%x,parm64:%llx",
@@ -230,16 +230,16 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
230 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, 230 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
231 inti->ext.ext_params, 231 inti->ext.ext_params,
232 inti->ext.ext_params2); 232 inti->ext.ext_params2);
233 rc = put_guest(vcpu, 0x2603, (u16 *)__LC_EXT_INT_CODE); 233 rc = put_guest(vcpu, 0x2603, (u16 __user *)__LC_EXT_INT_CODE);
234 rc |= put_guest(vcpu, 0x0d00, (u16 *)__LC_EXT_CPU_ADDR); 234 rc |= put_guest(vcpu, 0x0d00, (u16 __user *)__LC_EXT_CPU_ADDR);
235 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW, 235 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW,
236 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 236 &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
237 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw, 237 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
238 __LC_EXT_NEW_PSW, sizeof(psw_t)); 238 __LC_EXT_NEW_PSW, sizeof(psw_t));
239 rc |= put_guest(vcpu, inti->ext.ext_params, 239 rc |= put_guest(vcpu, inti->ext.ext_params,
240 (u32 *)__LC_EXT_PARAMS); 240 (u32 __user *)__LC_EXT_PARAMS);
241 rc |= put_guest(vcpu, inti->ext.ext_params2, 241 rc |= put_guest(vcpu, inti->ext.ext_params2,
242 (u64 *)__LC_EXT_PARAMS2); 242 (u64 __user *)__LC_EXT_PARAMS2);
243 break; 243 break;
244 case KVM_S390_SIGP_STOP: 244 case KVM_S390_SIGP_STOP:
245 VCPU_EVENT(vcpu, 4, "%s", "interrupt: cpu stop"); 245 VCPU_EVENT(vcpu, 4, "%s", "interrupt: cpu stop");
@@ -278,9 +278,9 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
278 vcpu->stat.deliver_program_int++; 278 vcpu->stat.deliver_program_int++;
279 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, 279 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
280 inti->pgm.code, 0); 280 inti->pgm.code, 0);
281 rc = put_guest(vcpu, inti->pgm.code, (u16 *)__LC_PGM_INT_CODE); 281 rc = put_guest(vcpu, inti->pgm.code, (u16 __user *)__LC_PGM_INT_CODE);
282 rc |= put_guest(vcpu, table[vcpu->arch.sie_block->ipa >> 14], 282 rc |= put_guest(vcpu, table[vcpu->arch.sie_block->ipa >> 14],
283 (u16 *)__LC_PGM_ILC); 283 (u16 __user *)__LC_PGM_ILC);
284 rc |= copy_to_guest(vcpu, __LC_PGM_OLD_PSW, 284 rc |= copy_to_guest(vcpu, __LC_PGM_OLD_PSW,
285 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 285 &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
286 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw, 286 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
@@ -295,7 +295,7 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
295 inti->mchk.mcic); 295 inti->mchk.mcic);
296 rc = kvm_s390_vcpu_store_status(vcpu, 296 rc = kvm_s390_vcpu_store_status(vcpu,
297 KVM_S390_STORE_STATUS_PREFIXED); 297 KVM_S390_STORE_STATUS_PREFIXED);
298 rc |= put_guest(vcpu, inti->mchk.mcic, (u64 *) __LC_MCCK_CODE); 298 rc |= put_guest(vcpu, inti->mchk.mcic, (u64 __user *) __LC_MCCK_CODE);
299 rc |= copy_to_guest(vcpu, __LC_MCK_OLD_PSW, 299 rc |= copy_to_guest(vcpu, __LC_MCK_OLD_PSW,
300 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 300 &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
301 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw, 301 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
@@ -313,13 +313,13 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
313 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, 313 trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type,
314 param0, param1); 314 param0, param1);
315 rc = put_guest(vcpu, inti->io.subchannel_id, 315 rc = put_guest(vcpu, inti->io.subchannel_id,
316 (u16 *) __LC_SUBCHANNEL_ID); 316 (u16 __user *) __LC_SUBCHANNEL_ID);
317 rc |= put_guest(vcpu, inti->io.subchannel_nr, 317 rc |= put_guest(vcpu, inti->io.subchannel_nr,
318 (u16 *) __LC_SUBCHANNEL_NR); 318 (u16 __user *) __LC_SUBCHANNEL_NR);
319 rc |= put_guest(vcpu, inti->io.io_int_parm, 319 rc |= put_guest(vcpu, inti->io.io_int_parm,
320 (u32 *) __LC_IO_INT_PARM); 320 (u32 __user *) __LC_IO_INT_PARM);
321 rc |= put_guest(vcpu, inti->io.io_int_word, 321 rc |= put_guest(vcpu, inti->io.io_int_word,
322 (u32 *) __LC_IO_INT_WORD); 322 (u32 __user *) __LC_IO_INT_WORD);
323 rc |= copy_to_guest(vcpu, __LC_IO_OLD_PSW, 323 rc |= copy_to_guest(vcpu, __LC_IO_OLD_PSW,
324 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 324 &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
325 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw, 325 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
@@ -344,7 +344,7 @@ static int __try_deliver_ckc_interrupt(struct kvm_vcpu *vcpu)
344 return 0; 344 return 0;
345 if (!(vcpu->arch.sie_block->gcr[0] & 0x800ul)) 345 if (!(vcpu->arch.sie_block->gcr[0] & 0x800ul))
346 return 0; 346 return 0;
347 rc = put_guest(vcpu, 0x1004, (u16 *)__LC_EXT_INT_CODE); 347 rc = put_guest(vcpu, 0x1004, (u16 __user *)__LC_EXT_INT_CODE);
348 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW, 348 rc |= copy_to_guest(vcpu, __LC_EXT_OLD_PSW,
349 &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); 349 &vcpu->arch.sie_block->gpsw, sizeof(psw_t));
350 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw, 350 rc |= copy_from_guest(vcpu, &vcpu->arch.sie_block->gpsw,
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index d64382c1ed61..7db2ad076f31 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -42,7 +42,7 @@ static int handle_set_prefix(struct kvm_vcpu *vcpu)
42 } 42 }
43 43
44 /* get the value */ 44 /* get the value */
45 if (get_guest(vcpu, address, (u32 *) operand2)) { 45 if (get_guest(vcpu, address, (u32 __user *) operand2)) {
46 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 46 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
47 goto out; 47 goto out;
48 } 48 }
@@ -83,7 +83,7 @@ static int handle_store_prefix(struct kvm_vcpu *vcpu)
83 address = address & 0x7fffe000u; 83 address = address & 0x7fffe000u;
84 84
85 /* get the value */ 85 /* get the value */
86 if (put_guest(vcpu, address, (u32 *)operand2)) { 86 if (put_guest(vcpu, address, (u32 __user *)operand2)) {
87 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 87 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
88 goto out; 88 goto out;
89 } 89 }
@@ -108,7 +108,7 @@ static int handle_store_cpu_address(struct kvm_vcpu *vcpu)
108 goto out; 108 goto out;
109 } 109 }
110 110
111 rc = put_guest(vcpu, vcpu->vcpu_id, (u16 *)useraddr); 111 rc = put_guest(vcpu, vcpu->vcpu_id, (u16 __user *)useraddr);
112 if (rc) { 112 if (rc) {
113 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 113 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
114 goto out; 114 goto out;
@@ -149,18 +149,18 @@ static int handle_tpi(struct kvm_vcpu *vcpu)
149 * Store the two-word I/O interruption code into the 149 * Store the two-word I/O interruption code into the
150 * provided area. 150 * provided area.
151 */ 151 */
152 put_guest(vcpu, inti->io.subchannel_id, (u16 *) addr); 152 put_guest(vcpu, inti->io.subchannel_id, (u16 __user *) addr);
153 put_guest(vcpu, inti->io.subchannel_nr, (u16 *) (addr + 2)); 153 put_guest(vcpu, inti->io.subchannel_nr, (u16 __user *) (addr + 2));
154 put_guest(vcpu, inti->io.io_int_parm, (u32 *) (addr + 4)); 154 put_guest(vcpu, inti->io.io_int_parm, (u32 __user *) (addr + 4));
155 } else { 155 } else {
156 /* 156 /*
157 * Store the three-word I/O interruption code into 157 * Store the three-word I/O interruption code into
158 * the appropriate lowcore area. 158 * the appropriate lowcore area.
159 */ 159 */
160 put_guest(vcpu, inti->io.subchannel_id, (u16 *) __LC_SUBCHANNEL_ID); 160 put_guest(vcpu, inti->io.subchannel_id, (u16 __user *) __LC_SUBCHANNEL_ID);
161 put_guest(vcpu, inti->io.subchannel_nr, (u16 *) __LC_SUBCHANNEL_NR); 161 put_guest(vcpu, inti->io.subchannel_nr, (u16 __user *) __LC_SUBCHANNEL_NR);
162 put_guest(vcpu, inti->io.io_int_parm, (u32 *) __LC_IO_INT_PARM); 162 put_guest(vcpu, inti->io.io_int_parm, (u32 __user *) __LC_IO_INT_PARM);
163 put_guest(vcpu, inti->io.io_int_word, (u32 *) __LC_IO_INT_WORD); 163 put_guest(vcpu, inti->io.io_int_word, (u32 __user *) __LC_IO_INT_WORD);
164 } 164 }
165 kfree(inti); 165 kfree(inti);
166no_interrupt: 166no_interrupt:
@@ -353,7 +353,7 @@ static int handle_stidp(struct kvm_vcpu *vcpu)
353 goto out; 353 goto out;
354 } 354 }
355 355
356 rc = put_guest(vcpu, vcpu->arch.stidp_data, (u64 *)operand2); 356 rc = put_guest(vcpu, vcpu->arch.stidp_data, (u64 __user *)operand2);
357 if (rc) { 357 if (rc) {
358 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 358 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
359 goto out; 359 goto out;