From patchwork Thu Sep 26 06:18:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 278097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 650AF2C032E for ; Thu, 26 Sep 2013 16:20:07 +1000 (EST) Received: from localhost ([::1]:56342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VP4vl-0001jG-6o for incoming@patchwork.ozlabs.org; Thu, 26 Sep 2013 02:20:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VP4v1-0001Wb-NN for qemu-devel@nongnu.org; Thu, 26 Sep 2013 02:19:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VP4uo-00084Z-8w for qemu-devel@nongnu.org; Thu, 26 Sep 2013 02:19:19 -0400 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:53080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VP4un-00083e-I1 for qemu-devel@nongnu.org; Thu, 26 Sep 2013 02:19:06 -0400 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Sep 2013 16:19:03 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 26 Sep 2013 16:19:01 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 9867B357805C; Thu, 26 Sep 2013 16:19:00 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8Q6Ii1K59048146; Thu, 26 Sep 2013 16:18:49 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8Q6IsVj005541; Thu, 26 Sep 2013 16:18:55 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.190.163.12]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r8Q6IseF005534; Thu, 26 Sep 2013 16:18:54 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.190.164.82]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 832FCA010D; Thu, 26 Sep 2013 16:18:54 +1000 (EST) Received: from ka1.ozlabs.ibm.com (ka1.ozlabs.ibm.com [10.61.145.11]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id EB56C16ABBA; Thu, 26 Sep 2013 16:18:53 +1000 (EST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 26 Sep 2013 16:18:35 +1000 Message-Id: <1380176328-21320-2-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.8.4.rc4 In-Reply-To: <1380176328-21320-1-git-send-email-aik@ozlabs.ru> References: <1380176328-21320-1-git-send-email-aik@ozlabs.ru> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13092606-1396-0000-0000-0000039C9CF0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.147 Cc: aik@ozlabs.ru, qemu-ppc@nongnu.org, Alexander Graf , Anthony Liguori , David Gibson Subject: [Qemu-devel] [PATCH v5 01/14] target-ppc: Add helper for KVM_PPC_RTAS_DEFINE_TOKEN X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Acked-by: David Gibson --- Changes: v4: * kvmppc_define_rtas_token renamed to kvmppc_define_rtas_kernel_token --- 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 8a196c6..0b5d391 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) { diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index 4ae7bf2..5f78e4b 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_kernel_token(uint32_t token, const char *function); int kvmppc_get_htab_fd(bool write); int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns); int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index, @@ -164,6 +165,12 @@ static inline bool kvmppc_has_cap_epr(void) return false; } +static inline int kvmppc_define_rtas_kernel_token(uint32_t token, + const char *function) +{ + return -1; +} + static inline int kvmppc_get_htab_fd(bool write) { return -1;