From patchwork Thu Sep 19 02:08:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 275859 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 91F982C00F7 for ; Thu, 19 Sep 2013 12:09:43 +1000 (EST) Received: from localhost ([::1]:49328 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMTgZ-0001Hm-3u for incoming@patchwork.ozlabs.org; Wed, 18 Sep 2013 22:09:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMTgB-0001GX-Sb for qemu-devel@nongnu.org; Wed, 18 Sep 2013 22:09:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMTg3-0005Es-FL for qemu-devel@nongnu.org; Wed, 18 Sep 2013 22:09:15 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:47485) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMTg2-0005Ed-Sf for qemu-devel@nongnu.org; Wed, 18 Sep 2013 22:09:07 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Sep 2013 12:08:46 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Sep 2013 12:08:44 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 154A73578050 for ; Thu, 19 Sep 2013 12:08:44 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8J1qBC042729520 for ; Thu, 19 Sep 2013 11:52:11 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r8J28g3W006898 for ; Thu, 19 Sep 2013 12:08:42 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.190.163.12]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r8J28gCW006895; Thu, 19 Sep 2013 12:08:42 +1000 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.190.164.82]) by ozlabs.au.ibm.com (Postfix) with ESMTP id 3256BA01A5; Thu, 19 Sep 2013 12:08:42 +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 D947F16AB60; Thu, 19 Sep 2013 12:08:41 +1000 (EST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 19 Sep 2013 12:08:40 +1000 Message-Id: <1379556520-4563-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.8.4.rc4 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13091902-7014-0000-0000-000003A37F70 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.148 Cc: Alexey Kardashevskiy , Peter Maydell , Paolo Bonzini Subject: [Qemu-devel] [PATCH v2] kvm: add set_one_reg/get_one_reg helpers 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 This adds QEMU wrappers for KVM_SET_ONE_REG/KVM_GET_ONE_REG ioctls. Signed-off-by: Alexey Kardashevskiy --- Changes: v2: * added Doc Comments * removed error_print --- include/sysemu/kvm.h | 4 ++++ kvm-all.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index c7bc07b..b2d61e9 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -319,4 +319,8 @@ int kvm_irqchip_remove_irqfd_notifier(KVMState *s, EventNotifier *n, int virq); void kvm_pc_gsi_handler(void *opaque, int n, int level); void kvm_pc_setup_irq_routing(bool pci_enabled); void kvm_init_irq_routing(KVMState *s); + +int kvm_set_one_reg(CPUState *cs, uint64_t id, void *addr); +int kvm_get_one_reg(CPUState *cs, uint64_t id, void *addr); + #endif diff --git a/kvm-all.c b/kvm-all.c index ded7fc8..da02c96 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -34,6 +34,7 @@ #include "exec/address-spaces.h" #include "qemu/event_notifier.h" #include "trace.h" +#include "qemu/error-report.h" /* This check must be after config-host.h is included */ #ifdef CONFIG_EVENTFD @@ -2049,3 +2050,35 @@ int kvm_on_sigbus(int code, void *addr) { return kvm_arch_on_sigbus(code, addr); } + +/** + * kvm_set_one_reg - set a register value in KVM via KVM_SET_ONE_REG ioctl + * @id: The register ID + * @addr: The pointer to a value + * + * Returns 0 if succeded and negative value if failed. + */ +int kvm_set_one_reg(CPUState *cs, uint64_t id, void *addr) +{ + struct kvm_one_reg reg = { + .id = id, + .addr = (uintptr_t)addr, + }; + return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); +} + +/** + * kvm_get_one_reg - get a register value from KVM via KVM_GET_ONE_REG ioctl + * @id: The register ID + * @addr: The pointer to a value + * + * Returns 0 if succeded and negative value if failed. + */ +int kvm_get_one_reg(CPUState *cs, uint64_t id, void *addr) +{ + struct kvm_one_reg reg = { + .id = id, + .addr = (uintptr_t)addr, + }; + return kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); +}