From patchwork Tue Aug 6 08:27:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 264919 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 040092C007E for ; Tue, 6 Aug 2013 18:46:18 +1000 (EST) Received: from localhost ([::1]:40926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6cf3-0002du-4l for incoming@patchwork.ozlabs.org; Tue, 06 Aug 2013 04:30:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6ccr-0008CV-He for qemu-devel@nongnu.org; Tue, 06 Aug 2013 04:28:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6cci-0003gw-LR for qemu-devel@nongnu.org; Tue, 06 Aug 2013 04:28:17 -0400 Received: from mail-pb0-f51.google.com ([209.85.160.51]:42810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6cci-0003fo-Fw for qemu-devel@nongnu.org; Tue, 06 Aug 2013 04:28:08 -0400 Received: by mail-pb0-f51.google.com with SMTP id jt11so109579pbb.10 for ; Tue, 06 Aug 2013 01:28:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j/o+sSVclE+EzKoFGel7jpgiNbvbSGLu5jnOba3AEHI=; b=LWjz+CvzQbGaiXiUMOBcrLfkJG8YLDBmEBJnhJtvlCxgVzmT1mBXmFt5/suLFQr000 EX+PeZVpLRztrOyHuMwiyrloD/dHnzDT76dcfu0WyFfko1SMYT3x4zvjiZp2TaUno/AV iV/Ac3w+Iq9LCLO+908wL7cukWgU+G4hHroQTrjAfAvKhEQJsBOhCD+iWFLCNu47TZpa NzXS8qUap2zuD8Q5S75nbP2jBrv+sXx5liBQ/cn/mSdEbHAskRnelTf3jqzed6lRFlrc 78xiDfypLfeGmeRfUOMxdZDmDOEq2rqLpS5vDhDPvTIQEv7qbrCylovAUg/7HpVSxC2M TujQ== X-Gm-Message-State: ALoCoQkURe6kRMA/Pzl5siOoPASkdsD3Z9KJDUHXNhrT+D3fJwrj5eahb5M+dibZkCEyXQucq+SI X-Received: by 10.66.2.130 with SMTP id 2mr2008056pau.13.1375777687746; Tue, 06 Aug 2013 01:28:07 -0700 (PDT) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPSA id qv4sm574174pbc.16.2013.08.06.01.28.03 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 06 Aug 2013 01:28:06 -0700 (PDT) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Tue, 6 Aug 2013 18:27:48 +1000 Message-Id: <1375777673-20274-2-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1375777673-20274-1-git-send-email-aik@ozlabs.ru> References: <1375777673-20274-1-git-send-email-aik@ozlabs.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.160.51 Cc: Anthony Liguori , aik@ozlabs.ru, Alexander Graf , qemu-ppc@nongnu.org, Paul Mackerras , =?UTF-8?q?Andreas=20F=C3=A4rber?= , David Gibson Subject: [Qemu-devel] [PATCH 1/6] 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 --- 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 30a870e..8afa7eb 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_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..12564ef 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); 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_token(uint32_t token, + const char *function) +{ + return -1; +} + static inline int kvmppc_get_htab_fd(bool write) { return -1;