Skip to contentSkip to conversation

x86/PCI: fix guest_io_read() when pci_cfg_ok() denies access

PATCH In review Jan Beulich 2 participants 2 messages Jun 21, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/PCI: fix guest_io_read() when pci_cfg_ok() denies access

For a multi-byte aligned read, this so far resulted in 0x00ff to be put in the guest's register rather than 0xffff or 0xffffffff, which in turn could confuse bus scanning functions (which, when reading vendor and/or device IDs, expect to get back all zeroes or all ones).

As the value gets masked to the read width when merging back into the full result, setting the initial value to all ones should not harm any or the other cases.

xen/arch/x86/traps.c +1 -1
@@ -1717,7 +1717,7 @@ static uint32_t guest_io_read(
     while ( bytes != 0 )
     {
         unsigned int size = 1;
-        uint32_t sub_data = 0xff;
+        uint32_t sub_data = ~0;
 
         if ( (port == 0x42) || (port == 0x43) || (port == 0x61) )
         {

x86/PCI: fix guest_io_read() when pci_cfg_ok() denies access

For a multi-byte aligned read, this so far resulted in 0x00ff to be put in the guest's register rather than 0xffff or 0xffffffff, which in turn could confuse bus scanning functions (which, when reading vendor and/or device IDs, expect to get back all zeroes or all ones).

As the value gets masked to the read width when merging back into the full result, setting the initial value to all ones should not harm any or the other cases.

xen/arch/x86/traps.c +1 -1
@@ -1717,7 +1717,7 @@ static uint32_t guest_io_read(
     while ( bytes != 0 )
     {
         unsigned int size = 1;
-        uint32_t sub_data = 0xff;
+        uint32_t sub_data = ~0;
 
         if ( (port == 0x42) || (port == 0x43) || (port == 0x61) )
         {

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

Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Jan Beulich

For a multi-byte aligned read, this so far resulted in 0x00ff to be put in the guest's register rather than 0xffff or 0xffffffff, which in turn could confuse bus scanning functions (which, when reading vendor and/or device IDs, expect to get back all zeroes or all ones).

As the value gets masked to the read width when merging back into the full result, setting the initial value to all ones should not harm any or the other cases.

Quoted 18 lines
xen/arch/x86/traps.c +1 -1
@@ -1717,7 +1717,7 @@ static uint32_t guest_io_read(
     while ( bytes != 0 )
     {
         unsigned int size = 1;
-        uint32_t sub_data = 0xff;
+        uint32_t sub_data = ~0;
 
         if ( (port == 0x42) || (port == 0x43) || (port == 0x61) )
         {

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