public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Prepare bhyve for GPU-Passthrough
@ 2021-06-24  6:05 Corvin Köhne
  2021-06-24  6:05 ` [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support Corvin Köhne
  2021-06-24  6:05 ` [PATCH v2 2/2] OvmfPkg/Bhyve: use static PCI32Base address Corvin Köhne
  0 siblings, 2 replies; 10+ messages in thread
From: Corvin Köhne @ 2021-06-24  6:05 UTC (permalink / raw)
  To: devel
  Cc: p.bruenn, lersek, ardb+tianocore, jordan.l.justen, rebecca,
	grehan, Corvin Köhne

Hi,

these patches could be merged to improve GPU-Passthrough support.

If I get an agreement with Peter about BusEnumeration, I'll create a new patch series


Best Regards
Corvin


Corvin Köhne (2):
  OvmfPkg/Bhyve: add USB support
  OvmfPkg/Bhyve: use static PCI32Base address

 OvmfPkg/Bhyve/BhyveX64.dsc           | 15 +++++++++++++--
 OvmfPkg/Bhyve/BhyveX64.fdf           | 10 ++++++++++
 OvmfPkg/Bhyve/PlatformPei/Platform.c |  4 +++-
 3 files changed, 26 insertions(+), 3 deletions(-)

-- 
2.11.0

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support
  2021-06-24  6:05 [PATCH v2 0/2] Prepare bhyve for GPU-Passthrough Corvin Köhne
@ 2021-06-24  6:05 ` Corvin Köhne
  2021-06-29  3:14   ` Peter Grehan
  2021-06-24  6:05 ` [PATCH v2 2/2] OvmfPkg/Bhyve: use static PCI32Base address Corvin Köhne
  1 sibling, 1 reply; 10+ messages in thread
From: Corvin Köhne @ 2021-06-24  6:05 UTC (permalink / raw)
  To: devel
  Cc: p.bruenn, lersek, ardb+tianocore, jordan.l.justen, rebecca,
	grehan, Corvin Köhne

An USB driver is required to use a keyboard or mouse while installing
an OS or while in a bootloader menu like grub when using GPU + USB
Passthrough.
---
 OvmfPkg/Bhyve/BhyveX64.dsc | 11 +++++++++++
 OvmfPkg/Bhyve/BhyveX64.fdf | 10 ++++++++++
 2 files changed, 21 insertions(+)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index d8792812ab..22a6f11069 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -163,6 +163,7 @@
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
   UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
+  UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
   SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
@@ -777,6 +778,16 @@
 !endif
   OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
+  #
+  # Usb Support
+  #
+  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+  MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
 !ifdef $(CSM_ENABLE)
   IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf {
     <LibraryClasses>
diff --git a/OvmfPkg/Bhyve/BhyveX64.fdf b/OvmfPkg/Bhyve/BhyveX64.fdf
index 3eff36dac1..f081b82137 100644
--- a/OvmfPkg/Bhyve/BhyveX64.fdf
+++ b/OvmfPkg/Bhyve/BhyveX64.fdf
@@ -291,6 +291,16 @@ INF MdeModulePkg/Logo/LogoDxe.inf
 !include NetworkPkg/Network.fdf.inc
   INF  OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
+#
+# Usb Support
+#
+INF  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
+INF  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
+INF  MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
+INF  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
+INF  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
+INF  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
+
 !ifdef $(CSM_ENABLE)
 INF  IntelFrameworkModulePkg/Csm/BiosThunk/VideoDxe/VideoDxe.inf
 !endif
-- 
2.11.0

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/2] OvmfPkg/Bhyve: use static PCI32Base address
  2021-06-24  6:05 [PATCH v2 0/2] Prepare bhyve for GPU-Passthrough Corvin Köhne
  2021-06-24  6:05 ` [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support Corvin Köhne
@ 2021-06-24  6:05 ` Corvin Köhne
  1 sibling, 0 replies; 10+ messages in thread
From: Corvin Köhne @ 2021-06-24  6:05 UTC (permalink / raw)
  To: devel
  Cc: p.bruenn, lersek, ardb+tianocore, jordan.l.justen, rebecca,
	grehan, Corvin Köhne

It's neccessary to allocate a Graphics Stolen Memory area to enable
GPU-Passthrough for integrated Intel GPUs. Therefore, use a new
memory layout with a static Pci32Baseaddress.

Old layout:
	[...        , lowmemlimit] RAM
	[lowmemlimit, 0xE000 0000] PCI Space
New layout:
	[...        , lowmemlimit] RAM
	[lowmemlimit, gsmbase    ] Memory hole (may be absent)
	[gsmbase    , 0xC000 0000] GSM (may be absent)
	[0xC000 0000, 0xE000 0000] PCI Space
---
 OvmfPkg/Bhyve/BhyveX64.dsc           | 4 ++--
 OvmfPkg/Bhyve/PlatformPei/Platform.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index 22a6f11069..b678029b40 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -537,8 +537,8 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId|0
   gUefiOvmfPkgTokenSpaceGuid.PcdPciIoBase|0x0
   gUefiOvmfPkgTokenSpaceGuid.PcdPciIoSize|0x0
-  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0x0
-  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x0
+  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Base|0xC0000000
+  gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio32Size|0x20000000
   gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Base|0x0
   gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size|0x800000000
 
diff --git a/OvmfPkg/Bhyve/PlatformPei/Platform.c b/OvmfPkg/Bhyve/PlatformPei/Platform.c
index 3a414ffcb7..f38e74ccfc 100644
--- a/OvmfPkg/Bhyve/PlatformPei/Platform.c
+++ b/OvmfPkg/Bhyve/PlatformPei/Platform.c
@@ -191,7 +191,9 @@ MemMapInitialization (
       ASSERT (PciExBarBase <= MAX_UINT32 - SIZE_256MB);
       PciBase = (UINT32)(PciExBarBase + SIZE_256MB);
     } else {
-      PciBase = (TopOfLowRam < BASE_2GB) ? BASE_2GB : TopOfLowRam;
+      PciBase = PcdGet64(PcdPciMmio32Base);
+      if (PciBase == 0)
+        PciBase = (TopOfLowRam < BASE_2GB) ? BASE_2GB : TopOfLowRam;
     }
 
     //
-- 
2.11.0

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support
  2021-06-24  6:05 ` [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support Corvin Köhne
@ 2021-06-29  3:14   ` Peter Grehan
  2021-07-01  9:51     ` Corvin Köhne
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Grehan @ 2021-06-29  3:14 UTC (permalink / raw)
  To: Corvin Köhne, devel
  Cc: p.bruenn, lersek, ardb+tianocore, jordan.l.justen, rebecca

Hi Corvin,

> +  #
> +  # Usb Support
> +  #
> +  MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
> +  MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
> +  MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
> +  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
> +  MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
> +  MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf

  bhyve doesn't (and will likely never) support Uhci/Ehci controllers so 
those lines can be removed.

later,

Peter.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support
  2021-06-29  3:14   ` Peter Grehan
@ 2021-07-01  9:51     ` Corvin Köhne
  2021-07-01 10:32       ` [edk2-devel] " Peter Grehan
  0 siblings, 1 reply; 10+ messages in thread
From: Corvin Köhne @ 2021-07-01  9:51 UTC (permalink / raw)
  To: Peter Grehan, devel@edk2.groups.io
  Cc: Patrick Brünn, lersek@redhat.com, ardb+tianocore@kernel.org,
	jordan.l.justen@intel.com, rebecca@bsdio.com

Hi Peter,

>  bhyve doesn't (and will likely never) support Uhci/Ehci controllers so those lines can be removed.

Is it possible to pass such a controller by PCI-Passthrough to a VM?
If it's possible, I would keep these lines.


Best regards
Corvin

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support
  2021-07-01  9:51     ` Corvin Köhne
@ 2021-07-01 10:32       ` Peter Grehan
  2021-07-01 14:12         ` Michael Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Grehan @ 2021-07-01 10:32 UTC (permalink / raw)
  To: devel, c.koehne
  Cc: Patrick Brünn, lersek@redhat.com, ardb+tianocore@kernel.org,
	jordan.l.justen@intel.com, rebecca@bsdio.com

Hi Corvin,

>>   bhyve doesn't (and will likely never) support Uhci/Ehci controllers so those lines can be removed.
> 
> Is it possible to pass such a controller by PCI-Passthrough to a VM?
> If it's possible, I would keep these lines.

  Uhci/Ehci only support legacy interrupts and that isn't supported by 
bhyve PCI passthru.

later,

Peter.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support
  2021-07-01 10:32       ` [edk2-devel] " Peter Grehan
@ 2021-07-01 14:12         ` Michael Brown
  2021-07-01 23:31           ` Peter Grehan
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Brown @ 2021-07-01 14:12 UTC (permalink / raw)
  To: devel, grehan, c.koehne
  Cc: Patrick Brünn, lersek@redhat.com, ardb+tianocore@kernel.org,
	jordan.l.justen@intel.com, rebecca@bsdio.com

On 01/07/2021 11:32, Peter Grehan wrote:
>>>   bhyve doesn't (and will likely never) support Uhci/Ehci controllers 
>>> so those lines can be removed.
>>
>> Is it possible to pass such a controller by PCI-Passthrough to a VM?
>> If it's possible, I would keep these lines.
> 
>   Uhci/Ehci only support legacy interrupts and that isn't supported by 
> bhyve PCI passthru.

Is that a detail of the current implementation, or a fundamental 
limitation in the bhyve architecture?

Thanks,

Michael

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support
  2021-07-01 14:12         ` Michael Brown
@ 2021-07-01 23:31           ` Peter Grehan
  2021-07-02 12:21             ` Michael Brown
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Grehan @ 2021-07-01 23:31 UTC (permalink / raw)
  To: Michael Brown, devel, c.koehne
  Cc: Patrick Brünn, lersek@redhat.com, ardb+tianocore@kernel.org,
	jordan.l.justen@intel.com, rebecca@bsdio.com

Hi Michael,

>>>>   bhyve doesn't (and will likely never) support Uhci/Ehci 
>>>> controllers so those lines can be removed.
>>>
>>> Is it possible to pass such a controller by PCI-Passthrough to a VM?
>>> If it's possible, I would keep these lines.
>>
>>   Uhci/Ehci only support legacy interrupts and that isn't supported by 
>> bhyve PCI passthru.
> 
> Is that a detail of the current implementation, or a fundamental 
> limitation in the bhyve architecture?

  Only two choices ? :) Maybe half way between those points.

later,

Peter.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support
  2021-07-01 23:31           ` Peter Grehan
@ 2021-07-02 12:21             ` Michael Brown
  2021-07-02 13:55               ` Peter Grehan
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Brown @ 2021-07-02 12:21 UTC (permalink / raw)
  To: Peter Grehan, devel, c.koehne
  Cc: Patrick Brünn, lersek@redhat.com, ardb+tianocore@kernel.org,
	jordan.l.justen@intel.com, rebecca@bsdio.com

On 02/07/2021 00:31, Peter Grehan wrote:
>>>>>   bhyve doesn't (and will likely never) support Uhci/Ehci 
>>>>> controllers so those lines can be removed.
>>>>
>>>> Is it possible to pass such a controller by PCI-Passthrough to a VM?
>>>> If it's possible, I would keep these lines.
>>>
>>>   Uhci/Ehci only support legacy interrupts and that isn't supported 
>>> by bhyve PCI passthru.
>>
>> Is that a detail of the current implementation, or a fundamental 
>> limitation in the bhyve architecture?
> 
>   Only two choices ? :) Maybe half way between those points.

When there is no fundamental limitation, i.e. when a future version of 
the hypervisor may be able to support the feature with no changes to the 
firmware, then it would be good practice to leave the drivers enabled. 
Doing so avoids creating an unnecessarily tight coupling between the 
hypervisor and firmware versions.

More importantly: does it even matter that the hypervisor doesn't 
support passthrough of PCI legacy interrupts?  UEFI operates on a 
polling basis, with the only active interrupt being some kind of 
periodic timer.  Where do you see any requirement for legacy interrupts 
in the UHCI/EHCI drivers?

Thanks,

Michael

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [edk2-devel] [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support
  2021-07-02 12:21             ` Michael Brown
@ 2021-07-02 13:55               ` Peter Grehan
  0 siblings, 0 replies; 10+ messages in thread
From: Peter Grehan @ 2021-07-02 13:55 UTC (permalink / raw)
  To: Michael Brown, devel, c.koehne
  Cc: Patrick Brünn, lersek@redhat.com, ardb+tianocore@kernel.org,
	jordan.l.justen@intel.com, rebecca@bsdio.com

>>> Is that a detail of the current implementation, or a fundamental 
>>> limitation in the bhyve architecture?
>>
>>   Only two choices ? :) Maybe half way between those points.
> 
> When there is no fundamental limitation,

  It's not so much a fundamental technical limitation as in a large 
amount of work in FreeBSD for almost zero return - maybe a fundamental 
resource limitation.

> i.e. when a future version of 
> the hypervisor may be able to support the feature with no changes to the 
> firmware, then it would be good practice to leave the drivers enabled. 
> Doing so avoids creating an unnecessarily tight coupling between the 
> hypervisor and firmware versions.
  Well versed in those issues :)

> More importantly: does it even matter that the hypervisor doesn't 
> support passthrough of PCI legacy interrupts?  UEFI operates on a 
> polling basis, with the only active interrupt being some kind of 
> periodic timer.  Where do you see any requirement for legacy interrupts 
> in the UHCI/EHCI drivers?

  It creates a case where the o/s booted by EFI isn't able to use those 
controllers as expected.

  Anyways, this is more a discussion for the freebsd-virtualization 
mailing list if you'd like to chat about it more.

later,

Peter.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-07-02 13:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-24  6:05 [PATCH v2 0/2] Prepare bhyve for GPU-Passthrough Corvin Köhne
2021-06-24  6:05 ` [PATCH v2 1/2] OvmfPkg/Bhyve: add USB support Corvin Köhne
2021-06-29  3:14   ` Peter Grehan
2021-07-01  9:51     ` Corvin Köhne
2021-07-01 10:32       ` [edk2-devel] " Peter Grehan
2021-07-01 14:12         ` Michael Brown
2021-07-01 23:31           ` Peter Grehan
2021-07-02 12:21             ` Michael Brown
2021-07-02 13:55               ` Peter Grehan
2021-06-24  6:05 ` [PATCH v2 2/2] OvmfPkg/Bhyve: use static PCI32Base address Corvin Köhne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox