Skip to contentSkip to conversation

Xen 4.4-rc3 regression with PVH compared to Xen 4.4-rc2.

PATCH In review Konrad Rzeszutek Wilk 6 participants 23 messages Feb 3, 2014 – Feb 13, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Xen 4.4-rc3 regression with PVH compared to Xen 4.4-rc2.

I am hereby requesting an Xen 4.4 exemption for this bug-fix.

The PVH feature is considered experimental, but it would be good to have it working out of the box without crashing the hypervisor.

Sadly that is not the case as 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" casues an NULL pointer dereference when starting a guest with 'pvh=1' in the guest config.

There are two ways of fixing this:
a). Add an '!xen_pvh_domain()' or '!xen_pvh_vcpu(current)' in the path, or b). Check for ioreq() being NULL. This is actually done in other places
in the hypervisor - so I choose to piggyback on that.

Thank you!

 xen/arch/x86/hvm/vmx/vvmx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Konrad Rzeszutek Wilk (1):
pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

#1 lore raw

PATCH 1/1 pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

The commit 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" assumes that the HVM paths are only taken by HVM guests. With the PVH enabled that is no longer the case - which means that we do not have to have the IO-backend device (QEMU) enabled.

As such, that patch can crash the hypervisor:

Xen call trace:

    [<ffff82d0801ddd9a>] nvmx_switch_guest+0x4d/0x903
    [<ffff82d0801de95b>] vmx_asm_vmexit_handler+0x4b/0xc0

Pagetable walk from 000000000000001e:
L4[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 7:
FATAL PAGE FAULT
[error_code=0000]
Faulting linear address: 000000000000001e
****************************************

as we do not have an io based backend.

---
 xen/arch/x86/hvm/vmx/vvmx.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
index d2ba435..2f516c9 100644
@@ -1400,7 +1400,7 @@ void nvmx_switch_guest(void)
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( get_ioreq(v) && get_ioreq(v)->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Signature · 1 line
1.7.7.6
#2 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1403

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1400,7 +1400,7 @@ void nvmx_switch_guest(void)
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( get_ioreq(v) && get_ioreq(v)->state != STATE_IOREQ_NONE )

As Mukesh pointed out, calling get_ioreq() twice is inefficient.

But to me it's not clear whether a PVH vCPU getting here is wrong in the first place, i.e. I would think the above condition should be || rather than && (after all, even if nested HVM one day became supported for PVH, there not being an ioreq would still seem to be a clear indication of no further work to be done here).

Of course, if done that way, the corresponding comment would benefit from being extended accordingly.

Jan

#3 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 12 lines · Jan Beulich

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1403

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1400,7 +1400,7 @@ void nvmx_switch_guest(void)
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( get_ioreq(v) && get_ioreq(v)->state != STATE_IOREQ_NONE )

As Mukesh pointed out, calling get_ioreq() twice is inefficient.

Quoted 3 lines

But to me it's not clear whether a PVH vCPU getting here is wrong in the first place, i.e. I would think the above condition should be || rather than && (after all, even if nested HVM one day became

I presume you mean like this:

	if ( !get_ioreq(v) || get_ioreq(v)->state != STATE_IOREQ_NONE )
		return;

If the Intel maintainers are OK with that I can do it that (and only do one get_ioreq(v) call) and expand the comment.

Or just take the simple route and squash Mukesh's patch in mine and revist this later - as I would prefer to make the minimal amount of changes to any code in during rc3.

Quoted 9 lines

supported for PVH, there not being an ioreq would still seem to be a clear indication of no further work to be done here).

Of course, if done that way, the corresponding comment would benefit from being extended accordingly.

Jan

#4 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 23 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 12 lines · Jan Beulich

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1403

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1400,7 +1400,7 @@ void nvmx_switch_guest(void)
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( get_ioreq(v) && get_ioreq(v)->state != STATE_IOREQ_NONE )

As Mukesh pointed out, calling get_ioreq() twice is inefficient.

Quoted 3 lines

But to me it's not clear whether a PVH vCPU getting here is wrong in the first place, i.e. I would think the above condition should be || rather than && (after all, even if nested HVM one day became

I presume you mean like this:

	if ( !get_ioreq(v) || get_ioreq(v)->state != STATE_IOREQ_NONE )
		return;
Quoted 6 lines

If the Intel maintainers are OK with that I can do it that (and only do one get_ioreq(v) call) and expand the comment.

Or just take the simple route and squash Mukesh's patch in mine and revist this later - as I would prefer to make the minimal amount of changes to any code in during rc3.

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Jan

#5 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 12 lines · Jan Beulich

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1403

Quoted 9 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1400,7 +1400,7 @@ void nvmx_switch_guest(void)
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( get_ioreq(v) && get_ioreq(v)->state != STATE_IOREQ_NONE )

As Mukesh pointed out, calling get_ioreq() twice is inefficient.

Quoted 3 lines

But to me it's not clear whether a PVH vCPU getting here is wrong in the first place, i.e. I would think the above condition should be || rather than && (after all, even if nested HVM one day became

I presume you mean like this:

	if ( !get_ioreq(v) || get_ioreq(v)->state != STATE_IOREQ_NONE )
		return;

If the Intel maintainers are OK with that I can do it that (and only do one get_ioreq(v) call) and expand the comment.

Quoted 6 lines
Quoted 3 lines

Or just take the simple route and squash Mukesh's patch in mine and revist this later - as I would prefer to make the minimal amount of changes to any code in during rc3.

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Quoted 1 line

From 6864786da87c4d67998a8ef46a3d289ac85074a9 Mon Sep 17 00:00:00 2001

From: Mukesh Rathor <[email protected]>
Date: Mon, 3 Feb 2014 11:45:52 -0500
Subject: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST
use io-backend device.

The commit 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" assumes that the HVM paths are only taken by HVM guests. With the PVH enabled that is no longer the case - which means that we do not have to have the IO-backend device (QEMU) enabled.

As such, that patch can crash the hypervisor:

Xen call trace:

    [<ffff82d0801ddd9a>] nvmx_switch_guest+0x4d/0x903
    [<ffff82d0801de95b>] vmx_asm_vmexit_handler+0x4b/0xc0

Pagetable walk from 000000000000001e:
L4[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 7:
FATAL PAGE FAULT
[error_code=0000]
Faulting linear address: 000000000000001e
****************************************

as we do not have an io based backend.

---
 xen/arch/x86/hvm/vmx/vvmx.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +2 -2
index d2ba435..143b7a2 100644
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Signature · 1 line
1.7.7.6
#6 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 6 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1403

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

Jan

#7 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 29 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1403

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )
Quoted 2 lines

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

Quoted 1 line

From 47a5554201f0bc1778e5bcbde8c39088707f727f Mon Sep 17 00:00:00 2001

From: Mukesh Rathor <[email protected]>
Date: Mon, 3 Feb 2014 11:45:52 -0500
Subject: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST
use io-backend device.

The commit 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" assumes that the HVM paths are only taken by HVM guests. With the PVH enabled that is no longer the case - which means that we do not have to have the IO-backend device (QEMU) enabled.

As such, that patch can crash the hypervisor:

Xen call trace:

    [<ffff82d0801ddd9a>] nvmx_switch_guest+0x4d/0x903
    [<ffff82d0801de95b>] vmx_asm_vmexit_handler+0x4b/0xc0

Pagetable walk from 000000000000001e:
L4[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 7:
FATAL PAGE FAULT
[error_code=0000]
Faulting linear address: 000000000000001e
****************************************

as we do not have an io based backend.

---
 xen/arch/x86/hvm/vmx/vvmx.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +2 -1
index d2ba435..563b02f 100644
@@ -1394,13 +1394,14 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( ioreq && ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Signature · 1 line
1.7.7.6
Quoted 1 line

From d76fc0d2f59ac65bd692adfa5f215da9ecf85d6a Mon Sep 17 00:00:00 2001

From: Mukesh Rathor <[email protected]>
Date: Mon, 3 Feb 2014 11:45:52 -0500
Subject: [PATCH] pvh: Fix regression due to assumption that HVM paths MUST
use io-backend device.

The commit 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" assumes that the HVM paths are only taken by HVM guests. With the PVH enabled that is no longer the case - which means that we do not have to have the IO-backend device (QEMU) enabled.

As such, that patch can crash the hypervisor:

Xen call trace:

    [<ffff82d0801ddd9a>] nvmx_switch_guest+0x4d/0x903
    [<ffff82d0801de95b>] vmx_asm_vmexit_handler+0x4b/0xc0

Pagetable walk from 000000000000001e:
L4[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 7:
FATAL PAGE FAULT
[error_code=0000]
Faulting linear address: 000000000000001e
****************************************

as we do not have an io based backend. In the case that the PVH guest does run an HVM guest inside it - we need to do further work to suport this - and for now the check will bail us out.

We also fix spelling mistakes and the sentence structure.

---
 xen/arch/x86/hvm/vmx/vvmx.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +7 -3
index d2ba435..71522cf 100644
@@ -1394,13 +1394,17 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
-     * a pending IO emualtion may still no finished. In this case,
+     * A pending IO emulation may still be not finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
-     * emulation will handled in a wrong VCPU context.
+     * emulation will be handled in a wrong VCPU context. If there are
+     * no IO backends - PVH guest by itself or a PVH guest with an HVM guest
+     * running inside - we don't want to continue as this setup is not
+     * implemented nor supported as of right now.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( !ioreq || ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Signature · 1 line
1.7.7.6
Quoted 4 lines

Jan

From 47a5554201f0bc1778e5bcbde8c39088707f727f Mon Sep 17 00:00:00 2001

From: Mukesh Rathor <[email protected]>
Date: Mon, 3 Feb 2014 11:45:52 -0500
Subject: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST
use io-backend device.

The commit 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" assumes that the HVM paths are only taken by HVM guests. With the PVH enabled that is no longer the case - which means that we do not have to have the IO-backend device (QEMU) enabled.

As such, that patch can crash the hypervisor:

Xen call trace:

    [<ffff82d0801ddd9a>] nvmx_switch_guest+0x4d/0x903
    [<ffff82d0801de95b>] vmx_asm_vmexit_handler+0x4b/0xc0

Pagetable walk from 000000000000001e:
L4[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 7:
FATAL PAGE FAULT
[error_code=0000]
Faulting linear address: 000000000000001e
****************************************

as we do not have an io based backend.

---
 xen/arch/x86/hvm/vmx/vvmx.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +2 -1
index d2ba435..563b02f 100644
@@ -1394,13 +1394,14 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( ioreq && ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Signature · 1 line
1.7.7.6
Quoted 1 line

From d76fc0d2f59ac65bd692adfa5f215da9ecf85d6a Mon Sep 17 00:00:00 2001

From: Mukesh Rathor <[email protected]>
Date: Mon, 3 Feb 2014 11:45:52 -0500
Subject: [PATCH] pvh: Fix regression due to assumption that HVM paths MUST
use io-backend device.

The commit 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" assumes that the HVM paths are only taken by HVM guests. With the PVH enabled that is no longer the case - which means that we do not have to have the IO-backend device (QEMU) enabled.

As such, that patch can crash the hypervisor:

Xen call trace:

    [<ffff82d0801ddd9a>] nvmx_switch_guest+0x4d/0x903
    [<ffff82d0801de95b>] vmx_asm_vmexit_handler+0x4b/0xc0

Pagetable walk from 000000000000001e:
L4[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 7:
FATAL PAGE FAULT
[error_code=0000]
Faulting linear address: 000000000000001e
****************************************

as we do not have an io based backend. In the case that the PVH guest does run an HVM guest inside it - we need to do further work to suport this - and for now the check will bail us out.

We also fix spelling mistakes and the sentence structure.

---
 xen/arch/x86/hvm/vmx/vvmx.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +7 -3
index d2ba435..71522cf 100644
@@ -1394,13 +1394,17 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
-     * a pending IO emualtion may still no finished. In this case,
+     * A pending IO emulation may still be not finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
-     * emulation will handled in a wrong VCPU context.
+     * emulation will be handled in a wrong VCPU context. If there are
+     * no IO backends - PVH guest by itself or a PVH guest with an HVM guest
+     * running inside - we don't want to continue as this setup is not
+     * implemented nor supported as of right now.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( !ioreq || ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Signature · 1 line
1.7.7.6

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 26 lines · Konrad Rzeszutek Wilk
Quoted 25 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
      struct vcpu *v = current;
      struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
      struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
      /*
       * a pending IO emualtion may still no finished. In this case,
       * no virtual vmswith is allowed. Or else, the following IO
       * emulation will handled in a wrong VCPU context.
       */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )
Quoted 7 lines
Quoted 2 lines

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

But they do different things -- one does "ioreq && ioreq->state..." and the other does "!ioreq || ioreq->state...". The first one is incorrect, AFAICT.

-George

#9 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 11 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 5 lines · Konrad Rzeszutek Wilk

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

But they do different things -- one does "ioreq && ioreq->state..." and the other does "!ioreq || ioreq->state...". The first one is incorrect, AFAICT.

Not outright incorrect perhaps, but sub-optimal. That was the subject of the discussion so far, and we're mainly waiting for the two copied VMX guys to confirm that the second patch is correct.

Jan

#10 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

In reply to George Dunlap
Quoted 29 lines · George Dunlap
Quoted 28 lines · Konrad Rzeszutek Wilk
Quoted 27 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void)

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

Quoted 7 lines
Quoted 5 lines

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

But they do different things -- one does "ioreq && ioreq->state..."

Correct.

Quoted 2 lines

and the other does "!ioreq || ioreq->state...". The first one is incorrect, AFAICT.

Both of them fix the hypervisor blowing up with any PVH guest.

Quoted 4 lines

-George

#11 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Konrad Rzeszutek Wilk wrote on 2014-02-05:

Quoted 29 lines · George Dunlap
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.02.14 at 16:32, Konrad Rzeszutek Wilk

Quoted 24 lines · <[email protected]> wrote:
Quoted 24 lines
Quoted 24 lines
Quoted 4 lines · Jan Beulich
Quoted 2 lines

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

Sorry for the late response. I just back from Chinese new year holiday.

Quoted 7 lines
Quoted 1 line

But they do different things -- one does "ioreq && ioreq->state..."

Correct.

Quoted 2 lines

and the other does "!ioreq || ioreq->state...". The first one is incorrect, AFAICT.

Both of them fix the hypervisor blowing up with any PVH guest.

Both of fixings are right to me.
The only concern is that what we want to do here:
"ioreq && ioreq->state..." will only allow the VCPU that supporting IO request emulation mechanism to continue nested check which current means HVM VCPU. And "!ioreq || ioreq->state..." will check the VCPU that doesn't support the IO request emulation mechanism only which current means PVH VCPU.

The purpose of my original patch only wants to allow the HVM VCPU that doesn't has pending IO request to continue nested check. Not use it to distinguish whether it is HVM or PVH. So here I prefer to only allow HVM VCPU goes to here as Jan mentioned before that non-HVM domain should never call nested related function at all unless it also supports nested.

Best regards,
Yang

#12 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 47 lines · Yang Z

Konrad Rzeszutek Wilk wrote on 2014-02-05:

Quoted 29 lines · George Dunlap
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.02.14 at 16:32, Konrad Rzeszutek Wilk

Quoted 24 lines · <[email protected]> wrote:
Quoted 24 lines
Quoted 24 lines
Quoted 4 lines · Jan Beulich
Quoted 2 lines

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

Sorry for the late response. I just back from Chinese new year holiday.

Quoted 6 lines
Quoted 1 line

But they do different things -- one does "ioreq && ioreq->state..."

Correct.

Quoted 2 lines

and the other does "!ioreq || ioreq->state...". The first one is incorrect, AFAICT.

Quoted 8 lines
Quoted 1 line

Both of them fix the hypervisor blowing up with any PVH guest.

Both of fixings are right to me.
The only concern is that what we want to do here:
"ioreq && ioreq->state..." will only allow the VCPU that supporting IO request emulation mechanism to continue nested check which current means HVM VCPU. And "!ioreq || ioreq->state..." will check the VCPU that doesn't support the IO request emulation mechanism only which current means PVH VCPU.

The purpose of my original patch only wants to allow the HVM VCPU that doesn't has pending IO request to continue nested check. Not use it to distinguish whether it is HVM or PVH. So here I prefer to only allow HVM VCPU goes to here as Jan mentioned before that non-HVM domain should never call nested related function at all unless it also supports nested.

So it sounds like the #2 patch is preferable by you.

Can I stick Acked-by on it?

Quoted 1 line

From d76fc0d2f59ac65bd692adfa5f215da9ecf85d6a Mon Sep 17 00:00:00 2001

From: Mukesh Rathor <[email protected]>
Date: Mon, 3 Feb 2014 11:45:52 -0500
Subject: [PATCH] pvh: Fix regression due to assumption that HVM paths MUST
use io-backend device.

The commit 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" assumes that the HVM paths are only taken by HVM guests. With the PVH enabled that is no longer the case - which means that we do not have to have the IO-backend device (QEMU) enabled.

As such, that patch can crash the hypervisor:

Xen call trace:

    [<ffff82d0801ddd9a>] nvmx_switch_guest+0x4d/0x903
    [<ffff82d0801de95b>] vmx_asm_vmexit_handler+0x4b/0xc0

Pagetable walk from 000000000000001e:
L4[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 7:
FATAL PAGE FAULT
[error_code=0000]
Faulting linear address: 000000000000001e
****************************************

as we do not have an io based backend. In the case that the PVH guest does run an HVM guest inside it - we need to do further work to suport this - and for now the check will bail us out.

We also fix spelling mistakes and the sentence structure.

---
 xen/arch/x86/hvm/vmx/vvmx.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +7 -3
index d2ba435..71522cf 100644
@@ -1394,13 +1394,17 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
-     * a pending IO emualtion may still no finished. In this case,
+     * A pending IO emulation may still be not finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
-     * emulation will handled in a wrong VCPU context.
+     * emulation will be handled in a wrong VCPU context. If there are
+     * no IO backends - PVH guest by itself or a PVH guest with an HVM guest
+     * running inside - we don't want to continue as this setup is not
+     * implemented nor supported as of right now.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( !ioreq || ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Signature · 1 line
1.7.7.6
Quoted 4 lines

Best regards,
Yang

Acked-by
#13 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 89 lines · Konrad Rzeszutek Wilk
Quoted 43 lines · Yang Z

Konrad Rzeszutek Wilk wrote on 2014-02-05:

Quoted 29 lines · George Dunlap
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.02.14 at 16:32, Konrad Rzeszutek Wilk

Quoted 24 lines · <[email protected]> wrote:
Quoted 24 lines
Quoted 24 lines
Quoted 4 lines · Jan Beulich
Quoted 2 lines

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
      struct vcpu *v = current;
      struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
      struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
      /*
       * a pending IO emualtion may still no finished. In this case,
       * no virtual vmswith is allowed. Or else, the following IO
       * emulation will handled in a wrong VCPU context.
       */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

Sorry for the late response. I just back from Chinese new year holiday.

Quoted 4 lines
Quoted 1 line

But they do different things -- one does "ioreq && ioreq->state..."

Correct.

Quoted 2 lines

and the other does "!ioreq || ioreq->state...". The first one is incorrect, AFAICT.

Quoted 7 lines
Quoted 1 line

Both of them fix the hypervisor blowing up with any PVH guest.

Both of fixings are right to me.
The only concern is that what we want to do here:
"ioreq && ioreq->state..." will only allow the VCPU that supporting IO request emulation mechanism to continue nested check which current means HVM VCPU. And "!ioreq || ioreq->state..." will check the VCPU that doesn't support the IO request emulation mechanism only which current means PVH VCPU.

The purpose of my original patch only wants to allow the HVM VCPU that doesn't has pending IO request to continue nested check. Not use it to distinguish whether it is HVM or PVH. So here I prefer to only allow HVM VCPU goes to here as Jan mentioned before that non-HVM domain should never call nested related function at all unless it also supports nested.

So it sounds like the #2 patch is preferable by you.

Can I stick Acked-by on it?

From d76fc0d2f59ac65bd692adfa5f215da9ecf85d6a Mon Sep 17 00:00:00 2001
From: Mukesh Rathor <[email protected]>
Date: Mon, 3 Feb 2014 11:45:52 -0500
Subject: [PATCH] pvh: Fix regression due to assumption that HVM paths MUST
use io-backend device.

The commit 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" assumes that the HVM paths are only taken by HVM guests. With the PVH enabled that is no longer the case - which means that we do not have to have the IO-backend device (QEMU) enabled.

As such, that patch can crash the hypervisor:

Xen call trace:

     [<ffff82d0801ddd9a>] nvmx_switch_guest+0x4d/0x903
     [<ffff82d0801de95b>] vmx_asm_vmexit_handler+0x4b/0xc0

Pagetable walk from 000000000000001e:

   L4[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 7:
FATAL PAGE FAULT
[error_code=0000]
Faulting linear address: 000000000000001e
****************************************

as we do not have an io based backend. In the case that the PVH guest does run an HVM guest inside it - we need to do further work to suport this - and for now the check will bail us out.

Quoted 7 lines

We also fix spelling mistakes and the sentence structure.

I forget if I release acked this yet, but just in case:

Quoted 29 lines
---
  xen/arch/x86/hvm/vmx/vvmx.c |   10 +++++++---
  1 files changed, 7 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +7 -3
index d2ba435..71522cf 100644
@@ -1394,13 +1394,17 @@ void nvmx_switch_guest(void)
      struct vcpu *v = current;
      struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
      struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
      /*
-     * a pending IO emualtion may still no finished. In this case,
+     * A pending IO emulation may still be not finished. In this case,
       * no virtual vmswith is allowed. Or else, the following IO
-     * emulation will handled in a wrong VCPU context.
+     * emulation will be handled in a wrong VCPU context. If there are
+     * no IO backends - PVH guest by itself or a PVH guest with an HVM guest
+     * running inside - we don't want to continue as this setup is not
+     * implemented nor supported as of right now.
       */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( !ioreq || ioreq->state != STATE_IOREQ_NONE )
          return;
      /*
       * a softirq may interrupt us between a virtual vmentry is
#14 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

In reply to Konrad Rzeszutek Wilk

Konrad Rzeszutek Wilk wrote on 2014-02-07:

Quoted 61 lines · Yang Z
Quoted 45 lines

Konrad Rzeszutek Wilk wrote on 2014-02-05:

Quoted 31 lines · George Dunlap
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.02.14 at 16:32, Konrad Rzeszutek Wilk

Quoted 26 lines · <[email protected]> wrote:
Quoted 26 lines
Quoted 26 lines
Quoted 4 lines · Jan Beulich
Quoted 2 lines

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void)

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

Sorry for the late response. I just back from Chinese new year holiday.

Quoted 3 lines
Quoted 1 line

But they do different things -- one does "ioreq && ioreq->state..."

Correct.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

and the other does "!ioreq || ioreq->state...". The first one is incorrect, AFAICT.

Both of them fix the hypervisor blowing up with any PVH guest.

Both of fixings are right to me.
The only concern is that what we want to do here:
"ioreq && ioreq->state..." will only allow the VCPU that supporting IO

request emulation mechanism to continue nested check which current means HVM VCPU.

Quoted 5 lines

And "!ioreq || ioreq->state..." will check the VCPU that doesn't support the IO request emulation mechanism only which current means PVH VCPU.

The purpose of my original patch only wants to allow the HVM VCPU that

Quoted 9 lines

doesn't has pending IO request to continue nested check. Not use it to distinguish whether it is HVM or PVH. So here I prefer to only allow HVM VCPU goes to here as Jan mentioned before that non-HVM domain should never call nested related function at all unless it also supports nested.

So it sounds like the #2 patch is preferable by you.

Can I stick Acked-by on it?

Sure.

Best regards,
Yang

#15 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 67 lines · Yang Z

Konrad Rzeszutek Wilk wrote on 2014-02-07:

Quoted 66 lines · Yang Z
Quoted 45 lines

Konrad Rzeszutek Wilk wrote on 2014-02-05:

Quoted 31 lines · George Dunlap
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On 04.02.14 at 16:32, Konrad Rzeszutek Wilk

Quoted 26 lines · <[email protected]> wrote:
Quoted 26 lines
Quoted 26 lines
Quoted 4 lines · Jan Beulich
Quoted 2 lines

Wasn't it that Mukesh's patch simply was yours with the two get_ioreq()s folded by using a local variable?

Yes. As so

Thanks. Except that ...

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void) · line 1397

Quoted 8 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
@@ -1394,13 +1394,13 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
-
+    ioreq_t *p = get_ioreq(v);

... you don't want to drop the blank line, and naming the new variable "ioreq" would seem preferable.

xen/arch/x86/hvm/vmx/vvmx.c void nvmx_switch_guest(void)

Quoted 7 lines
xen/arch/x86/hvm/vmx/vvmx.c +1 -1
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( p && p->state != STATE_IOREQ_NONE )

And, as said before, I'd think "!p ||" instead of "p &&" would be the right thing here. Yang, Jun?

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

I have two patches - one the simpler one that is pretty straightfoward and the one you suggested. Either one fixes PVH guests. I also did bootup tests with HVM guests to make sure they worked.

Attached and inline.

Sorry for the late response. I just back from Chinese new year holiday.

Quoted 3 lines
Quoted 1 line

But they do different things -- one does "ioreq && ioreq->state..."

Correct.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

and the other does "!ioreq || ioreq->state...". The first one is incorrect, AFAICT.

Both of them fix the hypervisor blowing up with any PVH guest.

Both of fixings are right to me.
The only concern is that what we want to do here:
"ioreq && ioreq->state..." will only allow the VCPU that supporting IO

request emulation mechanism to continue nested check which current means HVM VCPU.

Quoted 5 lines

And "!ioreq || ioreq->state..." will check the VCPU that doesn't support the IO request emulation mechanism only which current means PVH VCPU.

The purpose of my original patch only wants to allow the HVM VCPU that

doesn't has pending IO request to continue nested check. Not use it to distinguish whether it is HVM or PVH. So here I prefer to only allow HVM VCPU goes to here as Jan mentioned before that non-HVM domain should never call nested related function at all unless it also supports nested.

Quoted 6 lines
Quoted 4 lines

So it sounds like the #2 patch is preferable by you.

Can I stick Acked-by on it?

Sure.

Konrad / Jan: Ping?

If this fix looks reasonable it would be nice to get this in before RC4.

-George

#16 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 4 lines
Quoted 1 line
Quoted 1 line · George Dunlap

Konrad / Jan: Ping?

If this fix looks reasonable it would be nice to get this in before RC4.

It would have long been committed if the VMX maintainers finally gave their okay. Even privately pinging them didn't seem to help...

Jan

#17 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · George Dunlap

Konrad / Jan: Ping?

If this fix looks reasonable it would be nice to get this in before RC4.

It would have long been committed if the VMX maintainers finally gave their okay. Even privately pinging them didn't seem to help...

Oh, right, I forgot that Yang isn't a maintainer.

Well it looks like we have two options:
* Commit it without a maintainer's ack
* Revert the patch that caused the regression to PVH.

(Or maybe Yang can chase the maintainers internally.)

-George

#18 lore raw

Re: [PATCH] pvh: Fix regression caused by assumption that HVM paths MUST use io-backend device.

Quoted 5 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 3 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · George Dunlap

Konrad / Jan: Ping?

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

If this fix looks reasonable it would be nice to get this in before RC4.

It would have long been committed if the VMX maintainers finally gave their okay. Even privately pinging them didn't seem to help...

Oh, right, I forgot that Yang isn't a maintainer.

Well it looks like we have two options:
* Commit it without a maintainer's ack

Just committed it on the basis that I too can ack this. I would just have preferred for the more specific maintainers to have given their input/okay...

Jan

Quoted 5 lines

* Revert the patch that caused the regression to PVH.

(Or maybe Yang can chase the maintainers internally.)

-George

#19 lore raw
In reply to Konrad Rzeszutek Wilk
Quoted 10 lines · On Mon, 3 Feb 2014 12:03:20 -0500 Konrad Rzeszutek Wilk <[email protected]>…

I am hereby requesting an Xen 4.4 exemption for this bug-fix.

The PVH feature is considered experimental, but it would be good to have it working out of the box without crashing the hypervisor.

Sadly that is not the case as 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" casues an NULL pointer dereference when starting a guest with 'pvh=1' in the guest config.

Quoted 5 lines

There are two ways of fixing this:
a). Add an '!xen_pvh_domain()' or '!xen_pvh_vcpu(current)' in the path, or b). Check for ioreq() being NULL. This is actually done in other places in the hypervisor - so I choose to piggyback on that.

I was about to send this patch on friday:

xen/arch/x86/hvm/vmx/vvmx.c +2 -1
index d2ba435..563b02f 100644
@@ -1394,13 +1394,14 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( ioreq && ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is

when I realized even after the above fix it is still crashing for me... debugging right now. JFYI.

thanks
Mukesh

#20 lore raw
Quoted 44 lines · Mukesh Rathor
Quoted 10 lines · On Mon, 3 Feb 2014 12:03:20 -0500 Konrad Rzeszutek Wilk <[email protected]>…

I am hereby requesting an Xen 4.4 exemption for this bug-fix.

The PVH feature is considered experimental, but it would be good to have it working out of the box without crashing the hypervisor.

Sadly that is not the case as 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" casues an NULL pointer dereference when starting a guest with 'pvh=1' in the guest config.

Quoted 5 lines

There are two ways of fixing this:
a). Add an '!xen_pvh_domain()' or '!xen_pvh_vcpu(current)' in the path, or b). Check for ioreq() being NULL. This is actually done in other places in the hypervisor - so I choose to piggyback on that.

I was about to send this patch on friday:

xen/arch/x86/hvm/vmx/vvmx.c +2 -1
index d2ba435..563b02f 100644
@@ -1394,13 +1394,14 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( ioreq && ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Quoted 2 lines

when I realized even after the above fix it is still crashing for me... debugging right now. JFYI.

Are you doing it on a 'virgin' 4.4-rc3 or with your extra patches?

Also adding Roger so that he does not have to debug this crash.

Quoted 4 lines

thanks
Mukesh

#21 lore raw
Quoted 47 lines · On Mon, 3 Feb 2014 14:53:58 -0500 Konrad Rzeszutek Wilk…
Quoted 46 lines · Mukesh Rathor
Quoted 11 lines · On Mon, 3 Feb 2014 12:03:20 -0500 Konrad Rzeszutek Wilk <[email protected]>…

I am hereby requesting an Xen 4.4 exemption for this bug-fix.

The PVH feature is considered experimental, but it would be good to have it working out of the box without crashing the hypervisor.

Sadly that is not the case as 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" casues an NULL pointer dereference when starting a guest with 'pvh=1' in the guest config.

Quoted 6 lines

There are two ways of fixing this:
a). Add an '!xen_pvh_domain()' or '!xen_pvh_vcpu(current)' in the path, or b). Check for ioreq() being NULL. This is actually done in other places in the hypervisor - so I choose to piggyback on that.

I was about to send this patch on friday:

(quoted diff) +0 -0

b/xen/arch/x86/hvm/vmx/vvmx.c index d2ba435..563b02f 100644

xen/arch/x86/hvm/vmx/vvmx.c +2 -1
@@ -1394,13 +1394,14 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( ioreq && ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Quoted 4 lines
Quoted 2 lines

when I realized even after the above fix it is still crashing for me... debugging right now. JFYI.

Are you doing it on a 'virgin' 4.4-rc3 or with your extra patches?

Actually, it's with my extra dom0 patches.

Mukesh

#22 lore raw
In reply to Mukesh Rathor
Quoted 44 lines · On Mon, 3 Feb 2014 11:26:05 -0800 Mukesh Rathor <[email protected]>…
Quoted 10 lines · On Mon, 3 Feb 2014 12:03:20 -0500 Konrad Rzeszutek Wilk <[email protected]>…

I am hereby requesting an Xen 4.4 exemption for this bug-fix.

The PVH feature is considered experimental, but it would be good to have it working out of the box without crashing the hypervisor.

Sadly that is not the case as 09bb434748af9bfe3f7fca4b6eef721a7d5042a4 "Nested VMX: prohibit virtual vmentry/vmexit during IO emulation" casues an NULL pointer dereference when starting a guest with 'pvh=1' in the guest config.

Quoted 5 lines

There are two ways of fixing this:
a). Add an '!xen_pvh_domain()' or '!xen_pvh_vcpu(current)' in the path, or b). Check for ioreq() being NULL. This is actually done in other places in the hypervisor - so I choose to piggyback on that.

I was about to send this patch on friday:

xen/arch/x86/hvm/vmx/vvmx.c +2 -1
index d2ba435..563b02f 100644
@@ -1394,13 +1394,14 @@ void nvmx_switch_guest(void)
     struct vcpu *v = current;
     struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v);
     struct cpu_user_regs *regs = guest_cpu_user_regs();
+    ioreq_t *ioreq = get_ioreq(v);
 
     /*
      * a pending IO emualtion may still no finished. In this case,
      * no virtual vmswith is allowed. Or else, the following IO
      * emulation will handled in a wrong VCPU context.
      */
-    if ( get_ioreq(v)->state != STATE_IOREQ_NONE )
+    if ( ioreq && ioreq->state != STATE_IOREQ_NONE )
         return;
     /*
      * a softirq may interrupt us between a virtual vmentry is
Quoted 2 lines

when I realized even after the above fix it is still crashing for me... debugging right now. JFYI.

Ok, the crash in nvmx_switch_guest() even after the above fix is a different issue for which I am making a patch. So, this patch should be applied, however, rather than calling get_ioreq() twice as in Konrad's patch, I recommend my code above which calls it once. It's inlined now, and prob would be optimized, but the function could change in many ways in future.

thanks
mukesh