Lines Matching refs:mop
2854 static int mem_op_validate_common(struct kvm_s390_mem_op *mop, u64 supported_flags) in mem_op_validate_common() argument
2856 if (mop->flags & ~supported_flags || !mop->size) in mem_op_validate_common()
2858 if (mop->size > MEM_OP_MAX_SIZE) in mem_op_validate_common()
2860 if (mop->flags & KVM_S390_MEMOP_F_SKEY_PROTECTION) { in mem_op_validate_common()
2861 if (mop->key > 0xf) in mem_op_validate_common()
2864 mop->key = 0; in mem_op_validate_common()
2869 static int kvm_s390_vm_mem_op_abs(struct kvm *kvm, struct kvm_s390_mem_op *mop) in kvm_s390_vm_mem_op_abs() argument
2871 void __user *uaddr = (void __user *)mop->buf; in kvm_s390_vm_mem_op_abs()
2876 r = mem_op_validate_common(mop, KVM_S390_MEMOP_F_SKEY_PROTECTION | in kvm_s390_vm_mem_op_abs()
2881 if (!(mop->flags & KVM_S390_MEMOP_F_CHECK_ONLY)) { in kvm_s390_vm_mem_op_abs()
2882 tmpbuf = vmalloc(mop->size); in kvm_s390_vm_mem_op_abs()
2889 if (!kvm_is_gpa_in_memslot(kvm, mop->gaddr)) { in kvm_s390_vm_mem_op_abs()
2894 acc_mode = mop->op == KVM_S390_MEMOP_ABSOLUTE_READ ? GACC_FETCH : GACC_STORE; in kvm_s390_vm_mem_op_abs()
2895 if (mop->flags & KVM_S390_MEMOP_F_CHECK_ONLY) { in kvm_s390_vm_mem_op_abs()
2896 r = check_gpa_range(kvm, mop->gaddr, mop->size, acc_mode, mop->key); in kvm_s390_vm_mem_op_abs()
2900 r = access_guest_abs_with_key(kvm, mop->gaddr, tmpbuf, in kvm_s390_vm_mem_op_abs()
2901 mop->size, GACC_FETCH, mop->key); in kvm_s390_vm_mem_op_abs()
2904 if (copy_to_user(uaddr, tmpbuf, mop->size)) in kvm_s390_vm_mem_op_abs()
2907 if (copy_from_user(tmpbuf, uaddr, mop->size)) { in kvm_s390_vm_mem_op_abs()
2911 r = access_guest_abs_with_key(kvm, mop->gaddr, tmpbuf, in kvm_s390_vm_mem_op_abs()
2912 mop->size, GACC_STORE, mop->key); in kvm_s390_vm_mem_op_abs()
2922 static int kvm_s390_vm_mem_op_cmpxchg(struct kvm *kvm, struct kvm_s390_mem_op *mop) in kvm_s390_vm_mem_op_cmpxchg() argument
2924 void __user *uaddr = (void __user *)mop->buf; in kvm_s390_vm_mem_op_cmpxchg()
2925 void __user *old_addr = (void __user *)mop->old_addr; in kvm_s390_vm_mem_op_cmpxchg()
2930 unsigned int off_in_quad = sizeof(new) - mop->size; in kvm_s390_vm_mem_op_cmpxchg()
2934 r = mem_op_validate_common(mop, KVM_S390_MEMOP_F_SKEY_PROTECTION); in kvm_s390_vm_mem_op_cmpxchg()
2942 if (mop->size > sizeof(new)) in kvm_s390_vm_mem_op_cmpxchg()
2944 if (copy_from_user(&new.raw[off_in_quad], uaddr, mop->size)) in kvm_s390_vm_mem_op_cmpxchg()
2946 if (copy_from_user(&old.raw[off_in_quad], old_addr, mop->size)) in kvm_s390_vm_mem_op_cmpxchg()
2951 if (!kvm_is_gpa_in_memslot(kvm, mop->gaddr)) { in kvm_s390_vm_mem_op_cmpxchg()
2956 r = cmpxchg_guest_abs_with_key(kvm, mop->gaddr, mop->size, &old.quad, in kvm_s390_vm_mem_op_cmpxchg()
2957 new.quad, mop->key, &success); in kvm_s390_vm_mem_op_cmpxchg()
2958 if (!success && copy_to_user(old_addr, &old.raw[off_in_quad], mop->size)) in kvm_s390_vm_mem_op_cmpxchg()
2966 static int kvm_s390_vm_mem_op(struct kvm *kvm, struct kvm_s390_mem_op *mop) in kvm_s390_vm_mem_op() argument
2980 switch (mop->op) { in kvm_s390_vm_mem_op()
2983 return kvm_s390_vm_mem_op_abs(kvm, mop); in kvm_s390_vm_mem_op()
2985 return kvm_s390_vm_mem_op_cmpxchg(kvm, mop); in kvm_s390_vm_mem_op()
5333 struct kvm_s390_mem_op *mop) in kvm_s390_vcpu_sida_op() argument
5335 void __user *uaddr = (void __user *)mop->buf; in kvm_s390_vcpu_sida_op()
5339 if (mop->flags || !mop->size) in kvm_s390_vcpu_sida_op()
5341 if (mop->size + mop->sida_offset < mop->size) in kvm_s390_vcpu_sida_op()
5343 if (mop->size + mop->sida_offset > sida_size(vcpu->arch.sie_block)) in kvm_s390_vcpu_sida_op()
5348 sida_addr = (char *)sida_addr(vcpu->arch.sie_block) + mop->sida_offset; in kvm_s390_vcpu_sida_op()
5350 switch (mop->op) { in kvm_s390_vcpu_sida_op()
5352 if (copy_to_user(uaddr, sida_addr, mop->size)) in kvm_s390_vcpu_sida_op()
5357 if (copy_from_user(sida_addr, uaddr, mop->size)) in kvm_s390_vcpu_sida_op()
5365 struct kvm_s390_mem_op *mop) in kvm_s390_vcpu_mem_op() argument
5367 void __user *uaddr = (void __user *)mop->buf; in kvm_s390_vcpu_mem_op()
5372 r = mem_op_validate_common(mop, KVM_S390_MEMOP_F_INJECT_EXCEPTION | in kvm_s390_vcpu_mem_op()
5377 if (mop->ar >= NUM_ACRS) in kvm_s390_vcpu_mem_op()
5381 if (!(mop->flags & KVM_S390_MEMOP_F_CHECK_ONLY)) { in kvm_s390_vcpu_mem_op()
5382 tmpbuf = vmalloc(mop->size); in kvm_s390_vcpu_mem_op()
5387 acc_mode = mop->op == KVM_S390_MEMOP_LOGICAL_READ ? GACC_FETCH : GACC_STORE; in kvm_s390_vcpu_mem_op()
5388 if (mop->flags & KVM_S390_MEMOP_F_CHECK_ONLY) { in kvm_s390_vcpu_mem_op()
5389 r = check_gva_range(vcpu, mop->gaddr, mop->ar, mop->size, in kvm_s390_vcpu_mem_op()
5390 acc_mode, mop->key); in kvm_s390_vcpu_mem_op()
5394 r = read_guest_with_key(vcpu, mop->gaddr, mop->ar, tmpbuf, in kvm_s390_vcpu_mem_op()
5395 mop->size, mop->key); in kvm_s390_vcpu_mem_op()
5398 if (copy_to_user(uaddr, tmpbuf, mop->size)) { in kvm_s390_vcpu_mem_op()
5403 if (copy_from_user(tmpbuf, uaddr, mop->size)) { in kvm_s390_vcpu_mem_op()
5407 r = write_guest_with_key(vcpu, mop->gaddr, mop->ar, tmpbuf, in kvm_s390_vcpu_mem_op()
5408 mop->size, mop->key); in kvm_s390_vcpu_mem_op()
5412 if (r > 0 && (mop->flags & KVM_S390_MEMOP_F_INJECT_EXCEPTION) != 0) in kvm_s390_vcpu_mem_op()
5421 struct kvm_s390_mem_op *mop) in kvm_s390_vcpu_memsida_op() argument
5427 switch (mop->op) { in kvm_s390_vcpu_memsida_op()
5430 r = kvm_s390_vcpu_mem_op(vcpu, mop); in kvm_s390_vcpu_memsida_op()
5435 r = kvm_s390_vcpu_sida_op(vcpu, mop); in kvm_s390_vcpu_memsida_op()