From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VM9HN-0006ky-Dj for qemu-devel@nongnu.org; Wed, 18 Sep 2013 00:22:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VM9HF-0003uQ-5V for qemu-devel@nongnu.org; Wed, 18 Sep 2013 00:22:17 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:56590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VM9HE-0003oR-I5 for qemu-devel@nongnu.org; Wed, 18 Sep 2013 00:22:09 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Sep 2013 14:22:02 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 0BDA62BB0053 for ; Wed, 18 Sep 2013 14:22:01 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8I4LnTh56754414 for ; Wed, 18 Sep 2013 14:21:50 +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 r8I4M09H030842 for ; Wed, 18 Sep 2013 14:22:00 +1000 From: Alexey Kardashevskiy Date: Wed, 18 Sep 2013 14:21:58 +1000 Message-Id: <1379478118-20448-1-git-send-email-aik@ozlabs.ru> Subject: [Qemu-devel] [PATCH] kvm: add set_one_reg/get_one_reg List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , Paolo Bonzini , Alexander Graf This adds QEMU wrappers for KVM_SET_ONE_REG/KVM_GET_ONE_REG ioctls. Signed-off-by: Alexey Kardashevskiy --- include/sysemu/kvm.h | 4 ++++ kvm-all.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 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..c24ab76 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,33 @@ int kvm_on_sigbus(int code, void *addr) { return kvm_arch_on_sigbus(code, addr); } + +int kvm_set_one_reg(CPUState *cs, uint64_t id, void *addr) +{ + struct kvm_one_reg reg = { + .id = id, + .addr = (uintptr_t)addr, + }; + int ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + + if (ret) { + error_report("Unable to set reg#0x%"PRIx64" to KVM: %m\n", id); + } + + return ret; +} + +int kvm_get_one_reg(CPUState *cs, uint64_t id, void *addr) +{ + struct kvm_one_reg reg = { + .id = id, + .addr = (uintptr_t)addr, + }; + int ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + + if (ret) { + error_report("Unable to get reg#0x%"PRIx64" from KVM: %m\n", id); + } + + return ret; +} -- 1.8.4.rc4