diff mbox series

[v2,24/31] OvmfPkg/XenPlatformPei: Ignore missing PCI Host Bridge on Xen PVH

Message ID 20190409110844.14746-25-anthony.perard@citrix.com (mailing list archive)
State New, archived
Headers show
Series Specific platform to run OVMF in Xen PVH and HVM guests | expand

Commit Message

Anthony PERARD April 9, 2019, 11:08 a.m. UTC
When the device ID of the host bridge is unknown, check if we are
running as a PVH guest as there is no PCI bus in that case.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v2:
    - Use new XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID macro

 OvmfPkg/Include/OvmfPlatforms.h   | 6 ++++++
 OvmfPkg/XenPlatformPei/Platform.c | 7 +++++++
 2 files changed, 13 insertions(+)

Comments

Laszlo Ersek April 15, 2019, 1:29 p.m. UTC | #1
On 04/09/19 13:08, Anthony PERARD wrote:
> When the device ID of the host bridge is unknown, check if we are
> running as a PVH guest as there is no PCI bus in that case.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
> 
> Notes:
>     v2:
>     - Use new XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID macro
> 
>  OvmfPkg/Include/OvmfPlatforms.h   | 6 ++++++
>  OvmfPkg/XenPlatformPei/Platform.c | 7 +++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/OvmfPkg/Include/OvmfPlatforms.h b/OvmfPkg/Include/OvmfPlatforms.h
> index cc67f40a88..1ce71e18ec 100644
> --- a/OvmfPkg/Include/OvmfPlatforms.h
> +++ b/OvmfPkg/Include/OvmfPlatforms.h
> @@ -43,4 +43,10 @@
>  //
>  #define ACPI_TIMER_OFFSET 0x8
>  
> +//
> +// When running OVMF on a Xen PVH guest there is no PCI,
> +// so -1 is return for the Host Bridge Device ID.
> +//
> +#define XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID 0xFFFF
> +
>  #endif

We split the i440fx and Q35 host bridge device IDs to separate files,
under "OvmfPkg/Include/IndustryStandard/", in commit cb2e300766ae
("OvmfPkg: split Include/OvmfPlatforms.h", 2015-05-13).

(1) I'd prefer if we could introduce the above macro similarly -- and
include that header only in XenPlatformPei (plus wherever else it is
necessary).

Thanks!
Laszlo


> diff --git a/OvmfPkg/XenPlatformPei/Platform.c b/OvmfPkg/XenPlatformPei/Platform.c
> index 5e6d553ad5..d91cd98bf4 100644
> --- a/OvmfPkg/XenPlatformPei/Platform.c
> +++ b/OvmfPkg/XenPlatformPei/Platform.c
> @@ -278,6 +278,13 @@ MiscInitialization (
>        AcpiEnBit  = ICH9_ACPI_CNTL_ACPI_EN;
>        break;
>      default:
> +      if (XenPvhDetected ()) {
> +        //
> +        // There is no PCI bus in this case
> +        //
> +        PcdSet16S (PcdOvmfHostBridgePciDevId, XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID);
> +        return;
> +      }
>        DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
>          __FUNCTION__, mHostBridgeDevId));
>        ASSERT (FALSE);
>
Laszlo Ersek April 15, 2019, 1:33 p.m. UTC | #2
On 04/15/19 15:29, Laszlo Ersek wrote:
> On 04/09/19 13:08, Anthony PERARD wrote:
>> When the device ID of the host bridge is unknown, check if we are
>> running as a PVH guest as there is no PCI bus in that case.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
>> ---
>>
>> Notes:
>>     v2:
>>     - Use new XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID macro
>>
>>  OvmfPkg/Include/OvmfPlatforms.h   | 6 ++++++
>>  OvmfPkg/XenPlatformPei/Platform.c | 7 +++++++
>>  2 files changed, 13 insertions(+)
>>
>> diff --git a/OvmfPkg/Include/OvmfPlatforms.h b/OvmfPkg/Include/OvmfPlatforms.h
>> index cc67f40a88..1ce71e18ec 100644
>> --- a/OvmfPkg/Include/OvmfPlatforms.h
>> +++ b/OvmfPkg/Include/OvmfPlatforms.h
>> @@ -43,4 +43,10 @@
>>  //
>>  #define ACPI_TIMER_OFFSET 0x8
>>  
>> +//
>> +// When running OVMF on a Xen PVH guest there is no PCI,
>> +// so -1 is return for the Host Bridge Device ID.
>> +//
>> +#define XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID 0xFFFF
>> +
>>  #endif
> 
> We split the i440fx and Q35 host bridge device IDs to separate files,
> under "OvmfPkg/Include/IndustryStandard/", in commit cb2e300766ae
> ("OvmfPkg: split Include/OvmfPlatforms.h", 2015-05-13).
> 
> (1) I'd prefer if we could introduce the above macro similarly -- and
> include that header only in XenPlatformPei (plus wherever else it is
> necessary).

sorry, for a second I missed:

#include <IndustryStandard/Q35MchIch9.h>
#include <IndustryStandard/I440FxPiix4.h>

in "OvmfPlatforms.h". So it's fine to #include the new Xen-specific
header in "OvmfPlatforms.h", centrally.

Thanks
Laszlo


> 
> Thanks!
> Laszlo
> 
> 
>> diff --git a/OvmfPkg/XenPlatformPei/Platform.c b/OvmfPkg/XenPlatformPei/Platform.c
>> index 5e6d553ad5..d91cd98bf4 100644
>> --- a/OvmfPkg/XenPlatformPei/Platform.c
>> +++ b/OvmfPkg/XenPlatformPei/Platform.c
>> @@ -278,6 +278,13 @@ MiscInitialization (
>>        AcpiEnBit  = ICH9_ACPI_CNTL_ACPI_EN;
>>        break;
>>      default:
>> +      if (XenPvhDetected ()) {
>> +        //
>> +        // There is no PCI bus in this case
>> +        //
>> +        PcdSet16S (PcdOvmfHostBridgePciDevId, XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID);
>> +        return;
>> +      }
>>        DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
>>          __FUNCTION__, mHostBridgeDevId));
>>        ASSERT (FALSE);
>>
>
Andrew Cooper April 15, 2019, 1:37 p.m. UTC | #3
On 09/04/2019 12:08, Anthony PERARD wrote:
> diff --git a/OvmfPkg/Include/OvmfPlatforms.h b/OvmfPkg/Include/OvmfPlatforms.h
> index cc67f40a88..1ce71e18ec 100644
> --- a/OvmfPkg/Include/OvmfPlatforms.h
> +++ b/OvmfPkg/Include/OvmfPlatforms.h
> @@ -43,4 +43,10 @@
>  //
>  #define ACPI_TIMER_OFFSET 0x8
>  
> +//
> +// When running OVMF on a Xen PVH guest there is no PCI,
> +// so -1 is return for the Host Bridge Device ID.
> +//
> +#define XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID 0xFFFF

This isn't anything Xen specific - it is a property of how PCI config
cycles work.

> +
>  #endif
> diff --git a/OvmfPkg/XenPlatformPei/Platform.c b/OvmfPkg/XenPlatformPei/Platform.c
> index 5e6d553ad5..d91cd98bf4 100644
> --- a/OvmfPkg/XenPlatformPei/Platform.c
> +++ b/OvmfPkg/XenPlatformPei/Platform.c
> @@ -278,6 +278,13 @@ MiscInitialization (
>        AcpiEnBit  = ICH9_ACPI_CNTL_ACPI_EN;
>        break;
>      default:
> +      if (XenPvhDetected ()) {
> +        //
> +        // There is no PCI bus in this case
> +        //
> +        PcdSet16S (PcdOvmfHostBridgePciDevId, XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID);

This is not correct.

There may be no PCI bus, and OVMF needs to cope with this case, but
there may also be one (especially once we get around to making PCI
Passthrough work with PVH guests).  That case needs to work too.

~Andrew
diff mbox series

Patch

diff --git a/OvmfPkg/Include/OvmfPlatforms.h b/OvmfPkg/Include/OvmfPlatforms.h
index cc67f40a88..1ce71e18ec 100644
--- a/OvmfPkg/Include/OvmfPlatforms.h
+++ b/OvmfPkg/Include/OvmfPlatforms.h
@@ -43,4 +43,10 @@ 
 //
 #define ACPI_TIMER_OFFSET 0x8
 
+//
+// When running OVMF on a Xen PVH guest there is no PCI,
+// so -1 is return for the Host Bridge Device ID.
+//
+#define XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID 0xFFFF
+
 #endif
diff --git a/OvmfPkg/XenPlatformPei/Platform.c b/OvmfPkg/XenPlatformPei/Platform.c
index 5e6d553ad5..d91cd98bf4 100644
--- a/OvmfPkg/XenPlatformPei/Platform.c
+++ b/OvmfPkg/XenPlatformPei/Platform.c
@@ -278,6 +278,13 @@  MiscInitialization (
       AcpiEnBit  = ICH9_ACPI_CNTL_ACPI_EN;
       break;
     default:
+      if (XenPvhDetected ()) {
+        //
+        // There is no PCI bus in this case
+        //
+        PcdSet16S (PcdOvmfHostBridgePciDevId, XEN_PVH_PCI_HOST_BRIDGE_DEVICE_ID);
+        return;
+      }
       DEBUG ((EFI_D_ERROR, "%a: Unknown Host Bridge Device ID: 0x%04x\n",
         __FUNCTION__, mHostBridgeDevId));
       ASSERT (FALSE);