Received: from eggs.gnu.org ([2001:4830:134:3::10]:37320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjqFi-0002up-5R for qemu-devel@nongnu.org; Tue, 04 Jun 2013 08:22:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjqFd-0005OM-DJ for qemu-devel@nongnu.org; Tue, 04 Jun 2013 08:22:14 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:47751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjqFd-0005O9-8G for qemu-devel@nongnu.org; Tue, 04 Jun 2013 08:22:09 -0400 Received: by mail-pd0-f170.google.com with SMTP id x10so157572pdj.29 for ; Tue, 04 Jun 2013 05:22:08 -0700 (PDT) From: Alexey Kardashevskiy Date: Tue, 4 Jun 2013 22:21:04 +1000 Message-Id: <1370348465-31652-13-git-send-email-aik@ozlabs.ru> In-Reply-To: <1370348465-31652-1-git-send-email-aik@ozlabs.ru> References: <1370348465-31652-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH 12/13] target-ppc: Add helper for KVM_PPC_RTAS_DEFINE_TOKEN List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aik@ozlabs.ru, Alexander Graf , qemu-ppc@nongnu.org, Paul Mackerras , David Gibson From: David Gibson 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 --- target-ppc/kvm.c | 14 ++++++++++++++ target-ppc/kvm_ppc.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index c89dd58..33ddf63 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -1787,6 +1787,20 @@ static int kvm_ppc_register_host_cpu_type(void) return 0; } +int kvmppc_define_rtas_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); +} bool kvm_arch_stop_on_emulation_error(CPUState *cpu) { diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index 771cfbe..21939a8 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -38,6 +38,7 @@ uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift); #endif /* !CONFIG_USER_ONLY */ int kvmppc_fixup_cpu(PowerPCCPU *cpu); bool kvmppc_has_cap_epr(void); +int kvmppc_define_rtas_token(uint32_t token, const char *function); #else @@ -159,6 +160,12 @@ static inline bool kvmppc_has_cap_epr(void) { return false; } + +static inline int kvmppc_define_rtas_token(uint32_t token, + const char *function) +{ + return -1; +} #endif #ifndef CONFIG_KVM -- 1.7.10.4