Skip to contentSkip to conversation

ioreq-server: handle IOREQ_TYPE_PCI_CONFIG in assist function

PATCH In review Wei Liu 5 participants 7 messages Jan 27, 2015 – Jan 29, 2015

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 ioreq-server: handle IOREQ_TYPE_PCI_CONFIG in assist function

QEMU stubdom will read PCI config space when enumerating PCI devices. Xen should return ~0 when there is no suitable ioreq server to dispatch the request.

Without this patch, QEMU stubdom will fail to start because hvmloader fails following assertion:

118 ASSERT((devfn != PCI_ISA_DEVFN) ||
119 ((vendor_id == 0x8086) && (device_id == 0x7000)));

because vendor_id and device_id are 0.

This fixes a regression for QEMU stubdom. It should be backported to 4.5 as well.

Cc Jan Beulich <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Andrew Cooper <[email protected]>
---
 xen/arch/x86/hvm/hvm.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/hvm/hvm.c +1 -0
index c7984d1..c826ac5 100644
@@ -2577,6 +2577,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)
     {
     case IOREQ_TYPE_COPY:
     case IOREQ_TYPE_PIO:
+    case IOREQ_TYPE_PCI_CONFIG:
         if ( p->dir == IOREQ_READ )
         {
             if ( !p->data_is_ptr )
Signature · 1 line
1.9.1
#1 lore raw
Quoted 12 lines · Wei Liu

QEMU stubdom will read PCI config space when enumerating PCI devices. Xen should return ~0 when there is no suitable ioreq server to dispatch the request.

Without this patch, QEMU stubdom will fail to start because hvmloader fails following assertion:

118 ASSERT((devfn != PCI_ISA_DEVFN) ||
119 ((vendor_id == 0x8086) && (device_id == 0x7000)));

because vendor_id and device_id are 0.

Quoted 7 lines

This fixes a regression for QEMU stubdom. It should be backported to 4.5 as well.

Cc Jan Beulich <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Andrew Cooper <[email protected]>

The patch is clearly a good bugfix, but I am not sure the commit message is accurate.

A Qemu stubdom is a PV guest, not an HVM one, so will not be triggering this path in Xen. It is HVMLoader which scans the PCI bus.

I presume, given the description, that in the case that a Qemu stubdom is used (as opposed to a dom0 qemu), it is not registered as the default ioreq server, causing Xen to complete the config cycles (and incorrectly return 0 instead of ~0)?

~Andrew

Quoted 16 lines
---
 xen/arch/x86/hvm/hvm.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/hvm/hvm.c +1 -0
index c7984d1..c826ac5 100644
@@ -2577,6 +2577,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)
     {
     case IOREQ_TYPE_COPY:
     case IOREQ_TYPE_PIO:
+    case IOREQ_TYPE_PCI_CONFIG:
         if ( p->dir == IOREQ_READ )
         {
             if ( !p->data_is_ptr )
#4 lore raw
In reply to Wei Liu
Quoted 20 lines

-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 27 January 2015 19:06
To: [email protected]
Cc: Wei Liu; Jan Beulich; Paul Durrant; Andrew Cooper
Subject: [PATCH] ioreq-server: handle IOREQ_TYPE_PCI_CONFIG in assist function

QEMU stubdom will read PCI config space when enumerating PCI devices. Xen should return ~0 when there is no suitable ioreq server to dispatch the request.

Without this patch, QEMU stubdom will fail to start because hvmloader fails following assertion:

118 ASSERT((devfn != PCI_ISA_DEVFN) ||
119 ((vendor_id == 0x8086) && (device_id == 0x7000)));

because vendor_id and device_id are 0.

Quoted 7 lines

This fixes a regression for QEMU stubdom. It should be backported to 4.5 as well.

Cc Jan Beulich <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Andrew Cooper <[email protected]>

No, you should not need this. If you look at the code closely you'll see that hvm_complete_assist_req() is only called if hvm_select_ioreq_server() returns NULL, and the switch from IOREQ_TYPE_PIO to IOREQ_TYPE_PCI_CONFIG is only made if a non-default ioreq server matches the current cf8. Hence we could actually ASSERT(p->type !- IOREQ_TYPE_PCI_CONFIG) at the top of hvm_complete_assist_req().

Paul

Quoted 18 lines
---
 xen/arch/x86/hvm/hvm.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/hvm/hvm.c +1 -1
index c7984d1..c826ac5 100644
@@ -2577,6 +2577,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)
     {
     case IOREQ_TYPE_COPY:
     case IOREQ_TYPE_PIO:
+    case IOREQ_TYPE_PCI_CONFIG:
         if ( p->dir == IOREQ_READ )
         {
             if ( !p->data_is_ptr )
--

1.9.1

#2 lore raw
In reply to Andrew Cooper
Quoted 17 lines
Quoted 1 line
Quoted 1 line · On 27.01.15 at 20:34, <[email protected]> wrote:
Quoted 15 lines · Wei Liu

QEMU stubdom will read PCI config space when enumerating PCI devices. Xen should return ~0 when there is no suitable ioreq server to dispatch the request.

Without this patch, QEMU stubdom will fail to start because hvmloader fails following assertion:

118 ASSERT((devfn != PCI_ISA_DEVFN) ||
119 ((vendor_id == 0x8086) && (device_id == 0x7000)));

because vendor_id and device_id are 0.

This fixes a regression for QEMU stubdom. It should be backported to 4.5 as well.

Quoted 7 lines
Quoted 4 lines
Cc Jan Beulich <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Andrew Cooper <[email protected]>

The patch is clearly a good bugfix, but I am not sure the commit message is accurate.

Nor am I convinced that this is the only place to fix. hvmloader assuming to get back ~0 is contrary to various other code also taking 0 in vendor or device IDs as a sign to skip the device.

(Looking at the surrounding code I'm also puzzled by all the pci_write?()-s in that bus scanning loop: Most if not all of them should be done by the BIOS, not hvmloader. But of course that's the case for the BAR setup further down too.)

Jan

#3 lore raw

...

Quoted 5 lines

(Looking at the surrounding code I'm also puzzled by all the pci_write?()-s in that bus scanning loop: Most if not all of them should be done by the BIOS, not hvmloader. But of course that's the case for the BAR setup further down too.)

I do not know the history, but seabios (which would normally do this) has the statements (in qemu_platform_setup()):

    if (runningOnXen()) {

...
return
}

    // Initialize pci


    pci_setup();

Which expects that hvmloader has done the pci_setup().

-Don Slutz

Quoted 8 lines

Jan

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

#5 lore raw
In reply to Paul Durrant
Quoted 23 lines · Paul Durrant
Quoted 23 lines

-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 27 January 2015 19:06
To: [email protected]
Cc: Wei Liu; Jan Beulich; Paul Durrant; Andrew Cooper
Subject: [PATCH] ioreq-server: handle IOREQ_TYPE_PCI_CONFIG in assist function

QEMU stubdom will read PCI config space when enumerating PCI devices. Xen should return ~0 when there is no suitable ioreq server to dispatch the request.

Without this patch, QEMU stubdom will fail to start because hvmloader fails following assertion:

118 ASSERT((devfn != PCI_ISA_DEVFN) ||
119 ((vendor_id == 0x8086) && (device_id == 0x7000)));

because vendor_id and device_id are 0.

This fixes a regression for QEMU stubdom. It should be backported to 4.5 as well.

Quoted 7 lines
Quoted 4 lines
Cc Jan Beulich <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Andrew Cooper <[email protected]>

No, you should not need this. If you look at the code closely you'll see that hvm_complete_assist_req() is only called if hvm_select_ioreq_server()

returns NULL,

Quoted 1 line

and the switch from IOREQ_TYPE_PIO to IOREQ_TYPE_PCI_CONFIG is only

made if a

Quoted 4 lines

non-default ioreq server matches the current cf8. Hence we could actually ASSERT(p->type !- IOREQ_TYPE_PCI_CONFIG) at the top of hvm_complete_assist_req().

I will agree that the ASSERT looks good to me with s/!-/!=/.

I have no idea how Wei Liu makes it to this code via QEMU stubdom (last I knew QEMU stubdom needs QEMU traditional not QEMU upstream. And the only way to get IOREQ_TYPE_PCI_CONFIG is with QEMU upstream).

I have found out how hvmloader ends up using hvm_complete_assist_req() when not expected. Not sure how this is related to Wei Liu's issue.

-Don Slutz

Quoted 27 lines

Paul

Quoted 17 lines
---
 xen/arch/x86/hvm/hvm.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/hvm/hvm.c +1 -1
index c7984d1..c826ac5 100644
@@ -2577,6 +2577,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)
     {
     case IOREQ_TYPE_COPY:
     case IOREQ_TYPE_PIO:
+    case IOREQ_TYPE_PCI_CONFIG:
         if ( p->dir == IOREQ_READ )
         {
             if ( !p->data_is_ptr )
--
Quoted 1 line

1.9.1

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

author
#6 lore raw
Quoted 42 lines · Don Slutz
Quoted 23 lines · Paul Durrant
Quoted 23 lines

-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 27 January 2015 19:06
To: [email protected]
Cc: Wei Liu; Jan Beulich; Paul Durrant; Andrew Cooper
Subject: [PATCH] ioreq-server: handle IOREQ_TYPE_PCI_CONFIG in assist function

QEMU stubdom will read PCI config space when enumerating PCI devices. Xen should return ~0 when there is no suitable ioreq server to dispatch the request.

Without this patch, QEMU stubdom will fail to start because hvmloader fails following assertion:

118 ASSERT((devfn != PCI_ISA_DEVFN) ||
119 ((vendor_id == 0x8086) && (device_id == 0x7000)));

because vendor_id and device_id are 0.

This fixes a regression for QEMU stubdom. It should be backported to 4.5 as well.

Quoted 7 lines
Quoted 4 lines
Cc Jan Beulich <[email protected]>
Cc Paul Durrant <[email protected]>
Cc Andrew Cooper <[email protected]>

No, you should not need this. If you look at the code closely you'll see that hvm_complete_assist_req() is only called if hvm_select_ioreq_server()

returns NULL,

Quoted 1 line

and the switch from IOREQ_TYPE_PIO to IOREQ_TYPE_PCI_CONFIG is only

made if a

Quoted 4 lines

non-default ioreq server matches the current cf8. Hence we could actually ASSERT(p->type !- IOREQ_TYPE_PCI_CONFIG) at the top of hvm_complete_assist_req().

I will agree that the ASSERT looks good to me with s/!-/!=/.

Quoted 8 lines

I have no idea how Wei Liu makes it to this code via QEMU stubdom (last I knew QEMU stubdom needs QEMU traditional not QEMU upstream. And the only way to get IOREQ_TYPE_PCI_CONFIG is with QEMU upstream).

I have found out how hvmloader ends up using hvm_complete_assist_req() when not expected. Not sure how this is related to Wei Liu's issue.

This patch is now useless because the problem I discovered is a race between stubdom and guest. It will take some time to fix.

Wei.

Quoted 31 lines

-Don Slutz

Quoted 27 lines

Paul

Quoted 17 lines
---
 xen/arch/x86/hvm/hvm.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/hvm/hvm.c +1 -1
index c7984d1..c826ac5 100644
@@ -2577,6 +2577,7 @@ static bool_t hvm_complete_assist_req(ioreq_t *p)
     {
     case IOREQ_TYPE_COPY:
     case IOREQ_TYPE_PIO:
+    case IOREQ_TYPE_PCI_CONFIG:
         if ( p->dir == IOREQ_READ )
         {
             if ( !p->data_is_ptr )
--
Quoted 1 line

1.9.1

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