1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * ucall support. A ucall is a "hypercall to userspace".
4  *
5  * Copyright (C) 2019 Red Hat, Inc.
6  */
7 #include "kvm_util.h"
8 
ucall_arch_get_ucall(struct kvm_vcpu * vcpu)9 void *ucall_arch_get_ucall(struct kvm_vcpu *vcpu)
10 {
11 	struct kvm_run *run = vcpu->run;
12 
13 	if (run->exit_reason == KVM_EXIT_S390_SIEIC &&
14 	    run->s390_sieic.icptcode == 4 &&
15 	    (run->s390_sieic.ipa >> 8) == 0x83 &&    /* 0x83 means DIAGNOSE */
16 	    (run->s390_sieic.ipb >> 16) == 0x501) {
17 		int reg = run->s390_sieic.ipa & 0xf;
18 
19 		return (void *)run->s.regs.gprs[reg];
20 	}
21 	return NULL;
22 }
23