From: Rusty Russell <rusty.russell@linaro.org>
To: Rusty Russell <rusty.russell@linaro.org>,
Avi Kivity <avi@redhat.com>,
Christoffer Dall <c.dall@virtualopensystems.com>,
Alexander Graf <agraf@suse.de>,
Peter Maydell <peter.maydell@linaro.org>
Cc: kvmarm@lists.cs.columbia.edu, kvm-devel <kvm@vger.kernel.org>
Subject: [RFC 3/5] KVM: Add KVM_VCPU_GET_REG_LIST.
Date: Wed, 29 Aug 2012 09:17:14 +0930 [thread overview]
Message-ID: <87vcg28tq5.fsf@rustcorp.com.au> (raw)
In-Reply-To: <877gsia8rm.fsf@rustcorp.com.au>
This is a generic interface to find out what you can use
KVM_GET_ONE_REG/KVM_SET_ONE_REG on. Arhs need to define
KVM_HAVE_REG_LIST and then kvm_arch_num_regs() and
kvm_arch_copy_reg_indices() functions.
It's inspired by KVM_GET_MSR_INDEX_LIST, except it's a per-vcpu ioctl,
and uses 64-bit indices.
Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 209b432..b607f60 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -906,7 +906,7 @@ struct kvm_s390_ucas_mapping {
#define KVM_KVMCLOCK_CTRL _IO(KVMIO, 0xad)
#define KVM_ARM_VCPU_INIT _IOW(KVMIO, 0xae, struct kvm_vcpu_init)
#define KVM_VCPU_GET_MSR_INDEX_LIST _IOWR(KVMIO, 0xaf, struct kvm_msr_list)
+#define KVM_VCPU_GET_REG_LIST _IOWR(KVMIO, 0xb0, struct kvm_reg_list)
#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
#define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
@@ -958,4 +958,9 @@ struct kvm_assigned_msix_entry {
__u16 padding[3];
};
+/* For KVM_VCPU_GET_REG_LIST. */
+struct kvm_reg_list {
+ __u64 n; /* number of regs */
+ __u64 reg[0];
+};
#endif /* __LINUX_KVM_H */
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index f3d43c3..daa3838 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -572,7 +572,10 @@ int kvm_arch_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);
#define KVM_REG_LEN(index) \
(1U << (((index) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))
#endif
-
+#ifdef KVM_HAVE_REG_LIST
+unsigned long kvm_arch_num_regs(struct kvm_vcpu *vcpu);
+int kvm_arch_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
+#endif
void kvm_free_physmem(struct kvm *kvm);
void *kvm_kvzalloc(unsigned long size);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ad67cf4..b220c74 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1949,6 +1949,23 @@ out_free2:
break;
}
#endif
+#ifdef KVM_HAVE_REG_LIST
+ case KVM_VCPU_GET_REG_LIST: {
+ struct kvm_reg_list __user *user_list = argp;
+ struct kvm_reg_list reg_list;
+ unsigned n;
+
+ if (copy_from_user(®_list, user_list, sizeof reg_list))
+ return -EFAULT;
+ n = reg_list.n;
+ reg_list.n = kvm_arch_num_regs(vcpu);
+ if (copy_to_user(user_list, ®_list, sizeof reg_list))
+ return -EFAULT;
+ if (n < reg_list.n)
+ return -E2BIG;
+ return kvm_arch_copy_reg_indices(vcpu, user_list->reg);
+ }
+#endif
default:
r = kvm_arch_vcpu_ioctl(filp, ioctl, arg);
next prev parent reply other threads:[~2012-08-28 23:49 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-28 23:37 [RFC 0/5] Making KVM_GET_ONE_REG/KVM_SET_ONE_REG generic Rusty Russell
2012-08-28 23:45 ` [RFC 1/5] KVM: Move KVM_SET_ONE_REG/KVM_GET_ONE_REG to generic code Rusty Russell
2012-09-01 9:11 ` Avi Kivity
2012-09-01 10:18 ` Peter Maydell
2012-09-01 10:44 ` Avi Kivity
2012-08-28 23:46 ` [RFC 2/5] KVM: ARM: use KVM_SET_ONE_REG/KVM_GET_ONE_REG Rusty Russell
2012-08-29 15:10 ` Christoffer Dall
2012-08-28 23:47 ` Rusty Russell [this message]
2012-08-29 15:13 ` [RFC 3/5] KVM: Add KVM_VCPU_GET_REG_LIST Christoffer Dall
2012-08-28 23:47 ` [RFC 4/5] KVM: ARM: Use KVM_VCPU_GET_REG_LIST Rusty Russell
2012-08-29 15:14 ` Christoffer Dall
2012-08-28 23:48 ` [RFC 5/5] KVM: ARM: Access all registers via KVM_GET_ONE_REG/KVM_SET_ONE_REG Rusty Russell
2012-08-29 15:29 ` Christoffer Dall
2012-09-01 9:14 ` Avi Kivity
2012-08-29 15:36 ` Peter Maydell
2012-08-29 18:21 ` Rusty Russell
2012-09-01 9:16 ` Avi Kivity
2012-09-01 10:25 ` Peter Maydell
2012-09-01 19:40 ` Christoffer Dall
2012-09-04 13:09 ` Peter Maydell
2012-09-04 14:29 ` Christoffer Dall
2012-09-05 6:37 ` Rusty Russell
2012-08-29 18:16 ` Rusty Russell
2012-08-29 16:30 ` [RFC 0/5] Making KVM_GET_ONE_REG/KVM_SET_ONE_REG generic Peter Maydell
2012-08-29 18:39 ` Rusty Russell
2012-09-01 9:21 ` Avi Kivity
2012-09-01 12:35 ` Rusty Russell
2012-09-03 9:20 ` Avi Kivity
2012-09-03 12:33 ` Rusty Russell
2012-09-03 12:49 ` Peter Maydell
2012-09-04 11:48 ` Avi Kivity
2012-09-04 13:59 ` Alexander Graf
2012-09-06 14:44 ` Avi Kivity
2012-09-05 6:43 ` Rusty Russell
2012-09-01 12:28 ` Rusty Russell
2012-09-01 12:37 ` Rusty Russell
2012-09-04 13:31 ` Peter Maydell
2012-09-05 3:15 ` Alexander Graf
2012-09-05 6:48 ` Rusty Russell
2012-09-05 8:52 ` Peter Maydell
2012-09-06 1:44 ` Rusty Russell
2012-09-06 7:37 ` Peter Maydell
2012-09-06 14:48 ` Avi Kivity
2012-09-06 15:08 ` Alexander Graf
2012-09-06 15:16 ` Avi Kivity
2012-09-06 15:23 ` Peter Maydell
2012-09-06 15:35 ` Avi Kivity
2012-09-06 23:00 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vcg28tq5.fsf@rustcorp.com.au \
--to=rusty.russell@linaro.org \
--cc=agraf@suse.de \
--cc=avi@redhat.com \
--cc=c.dall@virtualopensystems.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=peter.maydell@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).