Skip to contentSkip to conversation

x86/hvm: Fix HVM guest regression introduced by c58ba78c84

PATCH In review Andrew Cooper 4 participants 8 messages Feb 4, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hvm: Fix HVM guest regression introduced by c58ba78c84

The xen event channel for the ioreq server must be targeted at the appropriate vcpu, so the correct one can be unpaused when IO is completed.

---

The cosmetic tweaks were not completely cosmetic.

---
 xen/arch/x86/hvm/hvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +1 -1
index b03ee4e..4b7792d 100644
@@ -638,7 +638,7 @@ static int hvm_ioreq_server_add_vcpu(struct hvm_ioreq_server *s,
     {
         struct domain *d = s->domain;
 
-        rc = alloc_unbound_xen_event_channel(v->domain, 0, s->domid, NULL);
+        rc = alloc_unbound_xen_event_channel(v->domain, v->vcpu_id, s->domid, NULL);
         if ( rc < 0 )
             goto fail3;
 
Signature · 1 line
1.7.10.4
#1 lore raw

xen/arch/x86/hvm/hvm.c static int hvm_ioreq_server_add_vcpu(struct hvm_ioreq_server *s, · line 641

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 04.02.15 at 13:35, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +1 -1
@@ -638,7 +638,7 @@ static int hvm_ioreq_server_add_vcpu(struct hvm_ioreq_server *s,
     {
         struct domain *d = s->domain;
 
-        rc = alloc_unbound_xen_event_channel(v->domain, 0, s->domid, NULL);
+        rc = alloc_unbound_xen_event_channel(v->domain, v->vcpu_id, s->domid, NULL);

But this sits in a conditional checking v->vcpu_id == 0. I.e. I don't see what difference this makes.

Jan

#2 lore raw
Quoted 17 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Jan Beulich
Sent: 04 February 2015 12:46
To: Andrew Cooper
Cc: Xen-devel
Subject: Re: [Xen-devel] [PATCH] x86/hvm: Fix HVM guest regression introduced by c58ba78c84

xen/arch/x86/hvm/hvm.c static int hvm_ioreq_server_add_vcpu(struct

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 04.02.15 at 13:35, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +0 -0
@@ -638,7 +638,7 @@ static int hvm_ioreq_server_add_vcpu(struct

hvm_ioreq_server *s,

Quoted 3 lines
xen/arch/x86/hvm/hvm.c +0 -0
     {
         struct domain *d = s->domain;
 
Quoted 7 lines

xen/arch/x86/hvm/hvm.c static int hvm_ioreq_server_add_vcpu(struct · line 641

Quoted 1 line
xen/arch/x86/hvm/hvm.c +0 -1
-        rc = alloc_unbound_xen_event_channel(v->domain, 0, s->domid,

NULL);

xen/arch/x86/hvm/hvm.c static int hvm_ioreq_server_add_vcpu(struct · line 642

Quoted 2 lines
xen/arch/x86/hvm/hvm.c +1 -0
+        rc = alloc_unbound_xen_event_channel(v->domain, v->vcpu_id, s-
 domid, NULL);

But this sits in a conditional checking v->vcpu_id == 0. I.e. I don't see what difference this makes.

True, but without the context it did appear to be wrong. Perhaps best to go with vcpu_id for clarity?

Paul

Quoted 8 lines

Jan

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

#3 lore raw
In reply to Jan Beulich
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 04.02.15 at 13:35, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +0 -0
@@ -638,7 +638,7 @@ static int hvm_ioreq_server_add_vcpu(struct hvm_ioreq_server *s,
     {
         struct domain *d = s->domain;
 
Quoted 7 lines

xen/arch/x86/hvm/hvm.c static int hvm_ioreq_server_add_vcpu(struct hvm_ioreq_server *s, · line 641

Quoted 2 lines
xen/arch/x86/hvm/hvm.c +1 -1
-        rc = alloc_unbound_xen_event_channel(v->domain, 0, s->domid, NULL);
+        rc = alloc_unbound_xen_event_channel(v->domain, v->vcpu_id, s->domid, NULL);

But this sits in a conditional checking v->vcpu_id == 0. I.e. I don't see what difference this makes.

Jan

Hmm so it does.

Something between d0b2caa..c58ba78 has broken HVM guests to point at which HVMloader doesn't reliably function.

Back to debugging...

~Andrew

#4 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 04.02.15 at 13:56, <[email protected]> wrote:

Something between d0b2caa..c58ba78 has broken HVM guests to point at which HVMloader doesn't reliably function.

And no crash (with register state dumped) or any other hint as to what's going wrong?

Jan

#5 lore raw
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 04.02.15 at 13:56, <[email protected]> wrote:

Something between d0b2caa..c58ba78 has broken HVM guests to point at which HVMloader doesn't reliably function.

And no crash (with register state dumped) or any other hint as to what's going wrong?

PV guests are all fine, and mixed PV/HVM tests have the PV side complete successfully.

~Andrew

#6 lore raw
Quoted 10 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 04.02.15 at 13:56, <[email protected]> wrote:

Something between d0b2caa..c58ba78 has broken HVM guests to point at which HVMloader doesn't reliably function.

And no crash (with register state dumped) or any other hint as to what's going wrong?

PV guests are all fine, and mixed PV/HVM tests have the PV side complete successfully.

With the info provided, it looks a lot like I have found:

(copied here, dropped duplication):

-------- Forwarded Message --------
Subject: Re: [Qemu-devel] [PATCH v5 2/2] Xen: Use the ioreq-server API when available
Date: Wed, 28 Jan 2015 19:57:42 -0500
From: Don Slutz <[email protected]>
To: Don Slutz <[email protected]>, Paul Durrant <[email protected]>, [email protected], Stefano Stabellini <[email protected]>
CC: Peter Maydell <[email protected]>, Olaf Hering <[email protected]>, Alexey Kardashevskiy <[email protected]>, Stefan Weil <[email protected]>, Michael Tokarev <[email protected]>, Alexander Graf <[email protected]>, Gerd Hoffmann <[email protected]>, Stefan Hajnoczi <[email protected]>, Paolo Bonzini <[email protected]>

Quoted 18 lines · Don Slutz
Quoted 11 lines · Don Slutz
Quoted 9 lines · Paul Durrant

The ioreq-server API added to Xen 4.5 offers better security than the existing Xen/QEMU interface because the shared pages that are used to pass emulation request/results back and forth are removed from the guest's memory space before any requests are serviced. This prevents the guest from mapping these pages (they are in a well known location) and attempting to attack QEMU by synthesizing its own request structures. Hence, this patch modifies configure to detect whether the API is available, and adds the necessary code to use the API if it is.

Quoted 3 lines

This patch (which is now on xenbits qemu staging) is causing me issues.

I have found the key.

Quoted 9 lines

The following will reproduce my issue:

1) xl create -p <config>
2) read one of HVM_PARAM_IOREQ_PFN, HVM_PARAM_BUFIOREQ_PFN, or HVM_PARAM_BUFIOREQ_EVTCHN
3) xl unpause new guest

The guest will hang in hvmloader.

...

Using QEMU upstream master (or xenbits qemu staging), you do not have a default ioreq server. And so hvm_select_ioreq_server() returns NULL for hvmloader's iorequest to:

CPU4 0 (+ 0) HANDLE_PIO [ port = 0x0cfe size = 2 dir = 1 ]

(I added this xentrace to figure out what is happening, and I have a lot of data about it, if any one wants it.)

To get a guest hang instead of calling hvm_complete_assist_req() for some of hvmloader's pci_read() calls, you can do the following:

1) xl create -p <config>
2) read one of HVM_PARAM_IOREQ_PFN, HVM_PARAM_BUFIOREQ_PFN, or HVM_PARAM_BUFIOREQ_EVTCHN
3) xl unpause new guest

The guest will hang in hvmloader.

The read of HVM_PARAM_IOREQ_PFN will cause a default ioreq server to be created and directed to the QEMU upsteam that is not a default ioreq server. This read also creates the extra event channels that I see.

I see that hvmop_create_ioreq_server() prevents you from creating an is_default ioreq_server, so QEMU is not able to do.

Not sure where we go from here.

-Don Slutz

Using the debug key e, you can see extra unbound event channels.

I had proposed the 1 line fix:

xen/arch/x86/hvm/hvm.c +0 -0
index bad410e..7ac4b45 100644
@@ -993,7 +993,7 @@ static int hvm_create_ioreq_server(struct domain *d,

domid_t domid,

     spin_lock(&d->arch.hvm_domain.ioreq_server.lock);

     rc = -EEXIST;

- if ( is_default && d->arch.hvm_domain.default_ioreq_server != NULL )
+ if ( is_default && !list_empty(&d->arch.hvm_domain.ioreq_server.list) )
goto fail2;

rc = hvm_ioreq_server_init(s, d, domid, is_default, handle_bufioreq,

But no idea if this is right or way off base.

-Don Slutz

Quoted 7 lines

~Andrew

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

Reviewed-by on v1 1/1
#7 lore raw
In reply to Andrew Cooper
Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Andrew Cooper
Sent: 04 February 2015 12:35
To: Xen-devel
Cc: Andrew Cooper; Jan Beulich
Subject: [Xen-devel] [PATCH] x86/hvm: Fix HVM guest regression introduced by c58ba78c84

The xen event channel for the ioreq server must be targeted at the appropriate
vcpu, so the correct one can be unpaused when IO is completed.

Quoted 6 lines

---

The cosmetic tweaks were not completely cosmetic.

No, they weren't were they.

Quoted 28 lines
---
 xen/arch/x86/hvm/hvm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/hvm.c +1 -1
index b03ee4e..4b7792d 100644
@@ -638,7 +638,7 @@ static int hvm_ioreq_server_add_vcpu(struct
 hvm_ioreq_server *s,
     {
         struct domain *d = s->domain;
 
-        rc = alloc_unbound_xen_event_channel(v->domain, 0, s->domid,
 NULL);
+        rc = alloc_unbound_xen_event_channel(v->domain, v->vcpu_id, s-
 >domid, NULL);
         if ( rc < 0 )
             goto fail3;

--
1.7.10.4

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