From: "Yang, Sheng" <sheng.yang@intel.com>
To: kvm@vger.kernel.org
Subject: [PATCH 1/4] KVM: Report hardware virtualization features
Date: Thu, 19 Jun 2008 18:42:56 +0800 [thread overview]
Message-ID: <200806191842.56275.sheng.yang@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2463 bytes --]
From f02d2ccf01e8671d2da517f14a908d1df1cc42ad Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Thu, 19 Jun 2008 18:41:26 +0800
Subject: [PATCH] KVM: Report hardware virtualization features
The hardware virtualization technology evolves very fast. But currently it's
hard to tell if your CPU support certain kind of HW technology without dig
into the source code.
The patch introduced a virtual file called "kvm_hw_feature_report" under
/sys/devices/system/kvm/kvm0 to show the mainly important current hardware
virtualization feature, then it's pretty easy to tell if your CPU support
some advanced virtualization technology now.
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
include/linux/kvm_host.h | 3 +++
virt/kvm/kvm_main.c | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index d220b49..654dba6 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -278,6 +278,9 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
+int kvm_register_hw_feature_report(int (*show)(char *page));
+void kvm_unregister_hw_feature_report(void);
+
static inline void kvm_guest_enter(void)
{
account_system_vtime(current);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4f38f5c..8eb74e5 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1518,6 +1518,32 @@ static struct sys_device kvm_sysdev = {
.cls = &kvm_sysdev_class,
};
+static int (*kvm_hw_fea_show_func)(char *);
+
+static ssize_t kvm_hw_feature_show(struct sys_device *dev, char *page)
+{
+ if (!kvm_hw_fea_show_func)
+ return 0;
+ return kvm_hw_fea_show_func(page);
+}
+
+static SYSDEV_ATTR(kvm_hw_feature_report, 0444, kvm_hw_feature_show, 0)
+
+int kvm_register_hw_feature_report(int (*show)(char *page))
+{
+ if (kvm_hw_fea_show_func)
+ sysdev_remove_file(&kvm_sysdev, &attr_kvm_hw_feature_report);
+ kvm_hw_fea_show_func = show;
+ return sysdev_create_file(&kvm_sysdev, &attr_kvm_hw_feature_report);
+}
+EXPORT_SYMBOL_GPL(kvm_register_hw_feature_report);
+
+void kvm_unregister_hw_feature_report(void)
+{
+ kvm_hw_fea_show_func = NULL;
+}
+EXPORT_SYMBOL_GPL(kvm_unregister_hw_feature_report);
+
struct page *bad_page;
pfn_t bad_pfn;
--
1.5.5
[-- Attachment #2: 0001-KVM-Report-hardware-virtualization-features.patch --]
[-- Type: text/x-diff, Size: 2466 bytes --]
From f02d2ccf01e8671d2da517f14a908d1df1cc42ad Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Thu, 19 Jun 2008 18:41:26 +0800
Subject: [PATCH] KVM: Report hardware virtualization features
The hardware virtualization technology evolves very fast. But currently it's
hard to tell if your CPU support certain kind of HW technology without dig into
the source code.
The patch introduced a virtual file called "kvm_hw_feature_report" under
/sys/devices/system/kvm/kvm0 to show the mainly important current hardware
virtualization feature, then it's pretty easy to tell if your CPU support
some advanced virtualization technology now.
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
include/linux/kvm_host.h | 3 +++
virt/kvm/kvm_main.c | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index d220b49..654dba6 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -278,6 +278,9 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
+int kvm_register_hw_feature_report(int (*show)(char *page));
+void kvm_unregister_hw_feature_report(void);
+
static inline void kvm_guest_enter(void)
{
account_system_vtime(current);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 4f38f5c..8eb74e5 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1518,6 +1518,32 @@ static struct sys_device kvm_sysdev = {
.cls = &kvm_sysdev_class,
};
+static int (*kvm_hw_fea_show_func)(char *);
+
+static ssize_t kvm_hw_feature_show(struct sys_device *dev, char *page)
+{
+ if (!kvm_hw_fea_show_func)
+ return 0;
+ return kvm_hw_fea_show_func(page);
+}
+
+static SYSDEV_ATTR(kvm_hw_feature_report, 0444, kvm_hw_feature_show, 0)
+
+int kvm_register_hw_feature_report(int (*show)(char *page))
+{
+ if (kvm_hw_fea_show_func)
+ sysdev_remove_file(&kvm_sysdev, &attr_kvm_hw_feature_report);
+ kvm_hw_fea_show_func = show;
+ return sysdev_create_file(&kvm_sysdev, &attr_kvm_hw_feature_report);
+}
+EXPORT_SYMBOL_GPL(kvm_register_hw_feature_report);
+
+void kvm_unregister_hw_feature_report(void)
+{
+ kvm_hw_fea_show_func = NULL;
+}
+EXPORT_SYMBOL_GPL(kvm_unregister_hw_feature_report);
+
struct page *bad_page;
pfn_t bad_pfn;
--
1.5.5
next reply other threads:[~2008-06-19 10:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-19 10:42 Yang, Sheng [this message]
2008-06-22 6:49 ` [PATCH 1/4] KVM: Report hardware virtualization features Avi Kivity
2008-06-22 12:18 ` Dor Laor
2008-06-22 12:21 ` Avi Kivity
2008-06-23 1:46 ` Yang, Sheng
2008-06-23 2:40 ` Avi Kivity
2008-06-23 3:01 ` Yang, Sheng
2008-06-23 9:47 ` Yang, Sheng
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=200806191842.56275.sheng.yang@intel.com \
--to=sheng.yang@intel.com \
--cc=kvm@vger.kernel.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