From mboxrd@z Thu Jan 1 00:00:00 1970 From: zhangyanfei Subject: [PATCH 3/4] ksysfs: export VMCSINFO via sysfs Date: Wed, 11 Apr 2012 09:57:34 +0800 Message-ID: <4F84E50E.2090008@cn.fujitsu.com> References: <4F84E0DF.8040206@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: dzickus-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, luto-3s7WtUTddSA@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, joerg.roedel-5C7GfCeVMHo@public.gmane.org, gregkh-l3A5Bk7waGM@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org, ludwig.nussel-l3A5Bk7waGM@public.gmane.org, ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org To: avi-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org Return-path: In-Reply-To: <4F84E0DF.8040206-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kexec-bounces-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Errors-To: kexec-bounces+glkk-kexec=m.gmane.org-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: kvm.vger.kernel.org This patch creates sysfs file to export where VMCSINFO is allocated, as below: $ cat /sys/kernel/vmcsinfo 1cb88a0 2000 number on the left-hand side is the physical address of VMCSINFO, while the one on the right-hand side is the max size of VMCSINFO. Signed-off-by: zhangyanfei --- kernel/ksysfs.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c index 4e316e1..becbb68 100644 --- a/kernel/ksysfs.c +++ b/kernel/ksysfs.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #define KERNEL_ATTR_RO(_name) \ static struct kobj_attribute _name##_attr = __ATTR_RO(_name) @@ -133,6 +135,20 @@ KERNEL_ATTR_RO(vmcoreinfo); #endif /* CONFIG_KEXEC */ +#ifdef CONFIG_X86 +static ssize_t vmcsinfo_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + if (cpu_has_vmx()) + return sprintf(buf, "%lx %x\n", + paddr_vmcsinfo_note(), + (unsigned int)vmcsinfo_max_size); + return 0; +} +KERNEL_ATTR_RO(vmcsinfo); + +#endif /* CONFIG_X86 */ + /* whether file capabilities are enabled */ static ssize_t fscaps_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -182,6 +198,9 @@ static struct attribute * kernel_attrs[] = { &kexec_crash_size_attr.attr, &vmcoreinfo_attr.attr, #endif +#ifdef CONFIG_X86 + &vmcsinfo_attr.attr, +#endif NULL }; -- 1.7.1