@@ -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
@@ -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, ®);
+}
This adds QEMU wrappers for KVM_SET_ONE_REG/KVM_GET_ONE_REG ioctls. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- Changes: v2: * added Doc Comments * removed error_print --- include/sysemu/kvm.h | 4 ++++ kvm-all.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)