kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid
@ 2012-06-15 11:34 Sasha Levin
  2012-06-15 11:34 ` [PATCH 2/2] kvm tools: support 9p flush command Sasha Levin
  2012-06-15 11:38 ` [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid Cyrill Gorcunov
  0 siblings, 2 replies; 7+ messages in thread
From: Sasha Levin @ 2012-06-15 11:34 UTC (permalink / raw)
  To: penberg, mingo, gorcunov, asias.hejun; +Cc: kvm, Sasha Levin

We need to set the HYPERVISOR flag to let the kernel know we're running
under a hypervisor.

This makes the kernel enable all sorts of para-virtualization options
such as kvm-clock.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/x86/cpuid.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/tools/kvm/x86/cpuid.c b/tools/kvm/x86/cpuid.c
index 75f3b4d..6a20dd0 100644
--- a/tools/kvm/x86/cpuid.c
+++ b/tools/kvm/x86/cpuid.c
@@ -21,6 +21,10 @@ static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
 		struct kvm_cpuid_entry2 *entry = &kvm_cpuid->entries[i];
 
 		switch (entry->function) {
+		case 1:
+			if (entry->index == 0)
+				entry->ecx |= (1<<31);
+			break;
 		case 6:
 			/* Clear presence of IA32_ENERGY_PERF_BIAS */
 			entry->ecx = entry->ecx & ~(1 << 3);
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] kvm tools: support 9p flush command
  2012-06-15 11:34 [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid Sasha Levin
@ 2012-06-15 11:34 ` Sasha Levin
  2012-06-20  7:23   ` Pekka Enberg
  2012-06-15 11:38 ` [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid Cyrill Gorcunov
  1 sibling, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2012-06-15 11:34 UTC (permalink / raw)
  To: penberg, mingo, gorcunov, asias.hejun; +Cc: kvm, Sasha Levin

While we process 9p requests serially, so there's no point for implementing
flush, we still need to answer it to prevent guest kernel from hanging waiting
for it.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/virtio/9p.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c
index b4341b9..830fc50 100644
--- a/tools/kvm/virtio/9p.c
+++ b/tools/kvm/virtio/9p.c
@@ -1071,6 +1071,19 @@ err_out:
 	return;
 }
 
+static void virtio_p9_flush(struct p9_dev *p9dev,
+				struct p9_pdu *pdu, u32 *outlen)
+{
+	u16 tag, oldtag;
+
+	virtio_p9_pdu_readf(pdu, "ww", &tag, &oldtag);
+	virtio_p9_pdu_writef(pdu, "w", tag);
+	*outlen = pdu->write_offset;
+	virtio_p9_set_reply_header(pdu, *outlen);
+
+	return;
+}
+
 static void virtio_p9_eopnotsupp(struct p9_dev *p9dev,
 				 struct p9_pdu *pdu, u32 *outlen)
 {
@@ -1105,7 +1118,7 @@ static p9_handler *virtio_9p_dotl_handler [] = {
 	[P9_TCLUNK]       = virtio_p9_clunk,
 	[P9_TFSYNC]       = virtio_p9_fsync,
 	[P9_TREAD]        = virtio_p9_read,
-	[P9_TFLUSH]       = virtio_p9_eopnotsupp,
+	[P9_TFLUSH]       = virtio_p9_flush,
 	[P9_TLINK]        = virtio_p9_link,
 	[P9_TSYMLINK]     = virtio_p9_symlink,
 	[P9_TLCREATE]     = virtio_p9_create,
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid
  2012-06-15 11:34 [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid Sasha Levin
  2012-06-15 11:34 ` [PATCH 2/2] kvm tools: support 9p flush command Sasha Levin
@ 2012-06-15 11:38 ` Cyrill Gorcunov
  2012-06-20  7:23   ` Pekka Enberg
  1 sibling, 1 reply; 7+ messages in thread
From: Cyrill Gorcunov @ 2012-06-15 11:38 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, mingo, asias.hejun, kvm

On Fri, Jun 15, 2012 at 01:34:16PM +0200, Sasha Levin wrote:
> We need to set the HYPERVISOR flag to let the kernel know we're running
> under a hypervisor.
> 
> This makes the kernel enable all sorts of para-virtualization options
> such as kvm-clock.
> 
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>

OK, looks good, but please Sasha, add a comment into the code
itself about the bitflag enabled (or maybe Pekka would add at
merge time).

	Cyrill

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid
  2012-06-15 11:38 ` [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid Cyrill Gorcunov
@ 2012-06-20  7:23   ` Pekka Enberg
  2012-06-20  7:37     ` Cyrill Gorcunov
  0 siblings, 1 reply; 7+ messages in thread
From: Pekka Enberg @ 2012-06-20  7:23 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: Sasha Levin, mingo, asias.hejun, kvm

On Fri, 15 Jun 2012, Cyrill Gorcunov wrote:

> On Fri, Jun 15, 2012 at 01:34:16PM +0200, Sasha Levin wrote:
> > We need to set the HYPERVISOR flag to let the kernel know we're running
> > under a hypervisor.
> > 
> > This makes the kernel enable all sorts of para-virtualization options
> > such as kvm-clock.
> > 
> > Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> 
> OK, looks good, but please Sasha, add a comment into the code
> itself about the bitflag enabled (or maybe Pekka would add at
> merge time).

Sasha?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] kvm tools: support 9p flush command
  2012-06-15 11:34 ` [PATCH 2/2] kvm tools: support 9p flush command Sasha Levin
@ 2012-06-20  7:23   ` Pekka Enberg
  0 siblings, 0 replies; 7+ messages in thread
From: Pekka Enberg @ 2012-06-20  7:23 UTC (permalink / raw)
  To: Sasha Levin; +Cc: mingo, gorcunov, asias.hejun, kvm

On Fri, 15 Jun 2012, Sasha Levin wrote:

> While we process 9p requests serially, so there's no point for implementing
> flush, we still need to answer it to prevent guest kernel from hanging waiting
> for it.
> 
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid
  2012-06-20  7:23   ` Pekka Enberg
@ 2012-06-20  7:37     ` Cyrill Gorcunov
  2012-06-20  7:59       ` Pekka Enberg
  0 siblings, 1 reply; 7+ messages in thread
From: Cyrill Gorcunov @ 2012-06-20  7:37 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Sasha Levin, mingo, asias.hejun, kvm

On Wed, Jun 20, 2012 at 10:23:06AM +0300, Pekka Enberg wrote:
> On Fri, 15 Jun 2012, Cyrill Gorcunov wrote:
> 
> > On Fri, Jun 15, 2012 at 01:34:16PM +0200, Sasha Levin wrote:
> > > We need to set the HYPERVISOR flag to let the kernel know we're running
> > > under a hypervisor.
> > > 
> > > This makes the kernel enable all sorts of para-virtualization options
> > > such as kvm-clock.
> > > 
> > > Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> > 
> > OK, looks good, but please Sasha, add a comment into the code
> > itself about the bitflag enabled (or maybe Pekka would add at
> > merge time).
> 
> Sasha?

I think it should be something like below

	Cyrill
---
From: Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH] kvm tools: set the HYPERVISOR flag in cpuid

We need to set the HYPERVISOR flag to let the kernel know we're running
under a hypervisor.

This makes the kernel enable all sorts of para-virtualization options
such as kvm-clock.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
[gorcunov@: Add comments on bits]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 tools/kvm/x86/cpuid.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: linux-2.6.git/tools/kvm/x86/cpuid.c
===================================================================
--- linux-2.6.git.orig/tools/kvm/x86/cpuid.c
+++ linux-2.6.git/tools/kvm/x86/cpuid.c
@@ -21,8 +21,13 @@ static void filter_cpuid(struct kvm_cpui
 		struct kvm_cpuid_entry2 *entry = &kvm_cpuid->entries[i];
 
 		switch (entry->function) {
+		case 1:
+			/* Set X86_FEATURE_HYPERVISOR */
+			if (entry->index == 0)
+				entry->ecx |= (1 << 31);
+			break;
 		case 6:
-			/* Clear presence of IA32_ENERGY_PERF_BIAS */
+			/* Clear X86_FEATURE_EPB */
 			entry->ecx = entry->ecx & ~(1 << 3);
 			break;
 		case CPUID_FUNC_PERFMON:

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid
  2012-06-20  7:37     ` Cyrill Gorcunov
@ 2012-06-20  7:59       ` Pekka Enberg
  0 siblings, 0 replies; 7+ messages in thread
From: Pekka Enberg @ 2012-06-20  7:59 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: Sasha Levin, mingo, asias.hejun, kvm

On Wed, Jun 20, 2012 at 10:37 AM, Cyrill Gorcunov <gorcunov@openvz.org> wrote:
> From: Sasha Levin <levinsasha928@gmail.com>
> Subject: [PATCH] kvm tools: set the HYPERVISOR flag in cpuid
>
> We need to set the HYPERVISOR flag to let the kernel know we're running
> under a hypervisor.
>
> This makes the kernel enable all sorts of para-virtualization options
> such as kvm-clock.
>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> [gorcunov@: Add comments on bits]
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>  tools/kvm/x86/cpuid.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.git/tools/kvm/x86/cpuid.c
> ===================================================================
> --- linux-2.6.git.orig/tools/kvm/x86/cpuid.c
> +++ linux-2.6.git/tools/kvm/x86/cpuid.c
> @@ -21,8 +21,13 @@ static void filter_cpuid(struct kvm_cpui
>                struct kvm_cpuid_entry2 *entry = &kvm_cpuid->entries[i];
>
>                switch (entry->function) {
> +               case 1:
> +                       /* Set X86_FEATURE_HYPERVISOR */
> +                       if (entry->index == 0)
> +                               entry->ecx |= (1 << 31);
> +                       break;
>                case 6:
> -                       /* Clear presence of IA32_ENERGY_PERF_BIAS */
> +                       /* Clear X86_FEATURE_EPB */
>                        entry->ecx = entry->ecx & ~(1 << 3);
>                        break;
>                case CPUID_FUNC_PERFMON:

I applied the patch. Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-06-20  7:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-15 11:34 [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid Sasha Levin
2012-06-15 11:34 ` [PATCH 2/2] kvm tools: support 9p flush command Sasha Levin
2012-06-20  7:23   ` Pekka Enberg
2012-06-15 11:38 ` [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid Cyrill Gorcunov
2012-06-20  7:23   ` Pekka Enberg
2012-06-20  7:37     ` Cyrill Gorcunov
2012-06-20  7:59       ` Pekka Enberg

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).