From feaa64c41f56b1b3111c31f652999799b28b9e12 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 26 Sep 2013 16:18:35 +1000 Subject: target-ppc: Add helper for KVM_PPC_RTAS_DEFINE_TOKEN Recent PowerKVM allows the kernel to intercept some RTAS calls from the guest directly. This is used to implement the more efficient in-kernel XICS for example. qemu is still responsible for assigning the RTAS token numbers however, and needs to tell the kernel which RTAS function name is assigned to a given token value. This patch adds a convenience wrapper for the KVM_PPC_RTAS_DEFINE_TOKEN ioctl() which is used for this purpose. Signed-off-by: David Gibson Signed-off-by: Alexey Kardashevskiy Acked-by: David Gibson Signed-off-by: Alexander Graf --- target-ppc/kvm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'target-ppc/kvm.c') diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 8a196c6cc1..0b5d391403 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -1789,6 +1789,20 @@ static int kvm_ppc_register_host_cpu_type(void) return 0; } +int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function) +{ + struct kvm_rtas_token_args args = { + .token = token, + }; + + if (!kvm_check_extension(kvm_state, KVM_CAP_PPC_RTAS)) { + return -ENOENT; + } + + strncpy(args.name, function, sizeof(args.name)); + + return kvm_vm_ioctl(kvm_state, KVM_PPC_RTAS_DEFINE_TOKEN, &args); +} int kvmppc_get_htab_fd(bool write) { -- cgit v1.2.3