summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/lib/powerpc/ucall.c
blob: 3481a7a0b850c1498b01b1f70ac0ec2aacf78ffc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SPDX-License-Identifier: GPL-2.0
/*
 * ucall support. A ucall is a "hypercall to host userspace".
 */
#include "kvm_util.h"
#include "ucall_common.h"
#include "hcall.h"

void *ucall_arch_get_ucall(struct kvm_vcpu *vcpu)
{
	struct kvm_run *run = vcpu->run;

	if (run->exit_reason == UCALL_EXIT_REASON &&
	    run->papr_hcall.nr == H_UCALL) {
		struct kvm_regs regs;

		vcpu_regs_get(vcpu, &regs);
		if (regs.gpr[4] == UCALL_R4_UCALL)
			return (void *)regs.gpr[5];
	}
	return NULL;
}