[edk2-devel] [PATCH 10/17] OvmfPkg/Microvm: use XenTimerDxe (lapic timer)

Gerd Hoffmann posted 17 patches 4 years, 5 months ago
There is a newer version of this series
[edk2-devel] [PATCH 10/17] OvmfPkg/Microvm: use XenTimerDxe (lapic timer)
Posted by Gerd Hoffmann 4 years, 5 months ago
Microvm has no acpi timer, so go use XenTimerDxe
which uses the local apic instead.

FIXME: timer frequency is wrong.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 OvmfPkg/Microvm/MicrovmX64.dsc | 3 +--
 OvmfPkg/Microvm/MicrovmX64.fdf | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index de68446e7f48..8d17bb4f0520 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -648,10 +648,9 @@ [Components]
 
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
-  OvmfPkg/8259InterruptControllerDxe/8259.inf
+  OvmfPkg/XenTimerDxe/XenTimerDxe.inf
   UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
   UefiCpuPkg/CpuDxe/CpuDxe.inf
-  OvmfPkg/8254TimerDxe/8254Timer.inf
   OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
   OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
   MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf {
diff --git a/OvmfPkg/Microvm/MicrovmX64.fdf b/OvmfPkg/Microvm/MicrovmX64.fdf
index d57d958fde86..b4d56bd2d0e7 100644
--- a/OvmfPkg/Microvm/MicrovmX64.fdf
+++ b/OvmfPkg/Microvm/MicrovmX64.fdf
@@ -215,10 +215,9 @@ [FV.DXEFV]
 INF  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
 INF  MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 INF  MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
-INF  OvmfPkg/8259InterruptControllerDxe/8259.inf
+INF  OvmfPkg/XenTimerDxe/XenTimerDxe.inf
 INF  UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
 INF  UefiCpuPkg/CpuDxe/CpuDxe.inf
-INF  OvmfPkg/8254TimerDxe/8254Timer.inf
 INF  OvmfPkg/IncompatiblePciDeviceSupportDxe/IncompatiblePciDeviceSupport.inf
 INF  OvmfPkg/PciHotPlugInitDxe/PciHotPlugInit.inf
 INF  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#79995): https://edk2.groups.io/g/devel/message/79995
Mute This Topic: https://groups.io/mt/85272566/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 10/17] OvmfPkg/Microvm: use XenTimerDxe (lapic timer)
Posted by Philippe Mathieu-Daudé 4 years, 5 months ago
On 8/31/21 11:57 AM, Gerd Hoffmann wrote:
> Microvm has no acpi timer, so go use XenTimerDxe
> which uses the local apic instead.
> 
> FIXME: timer frequency is wrong.

Xen seems to expect a 10MHz timer. Maybe use as constant
to make a generic LocalAPICTimer driver used by both Xen
and microVM (with different clock rates)?

> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  OvmfPkg/Microvm/MicrovmX64.dsc | 3 +--
>  OvmfPkg/Microvm/MicrovmX64.fdf | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80014): https://edk2.groups.io/g/devel/message/80014
Mute This Topic: https://groups.io/mt/85272566/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 10/17] OvmfPkg/Microvm: use XenTimerDxe (lapic timer)
Posted by Gerd Hoffmann 4 years, 5 months ago
On Tue, Aug 31, 2021 at 06:25:49PM +0200, Philippe Mathieu-Daudé wrote:
> On 8/31/21 11:57 AM, Gerd Hoffmann wrote:
> > Microvm has no acpi timer, so go use XenTimerDxe
> > which uses the local apic instead.
> > 
> > FIXME: timer frequency is wrong.
> 
> Xen seems to expect a 10MHz timer. Maybe use as constant
> to make a generic LocalAPICTimer driver used by both Xen
> and microVM (with different clock rates)?

It's configurable already (PcdFSBClock).

I can tweak that in my .dsc file, which improves the situation a bit for
me.  Of course the problem is the lapic timer frequency is not constant,
and xen uses the xen clock to calibrate the timer
(see CalibrateLapicTimer in XenPlatformPei/Xen.c).

Maybe I can use kvmclock to figure the frequency.  Maybe it makes sense
to just go all in and write a kvmclock-based timer driver then.

Is it possible to have multiple drivers implementing the
EfiTimerArchProtocol in one firmware binary, then just use the one which
successfully initializes first?  If so, can I define the initialization
order?  i.e. can I add a kvmclock driver, try initialize it first, when
it works use it, otherwise (because tcg) fallback to some other driver?

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80058): https://edk2.groups.io/g/devel/message/80058
Mute This Topic: https://groups.io/mt/85272566/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH 10/17] OvmfPkg/Microvm: use XenTimerDxe (lapic timer)
Posted by Ard Biesheuvel 4 years, 5 months ago
On Wed, 1 Sept 2021 at 09:20, Gerd Hoffmann <kraxel@redhat.com> wrote:
>
...
> Is it possible to have multiple drivers implementing the
> EfiTimerArchProtocol in one firmware binary, then just use the one which
> successfully initializes first?  If so, can I define the initialization
> order?  i.e. can I add a kvmclock driver, try initialize it first, when
> it works use it, otherwise (because tcg) fallback to some other driver?
>

I don't think that should be a problem, as long as the
EfiTimerArchProtocol becomes available early enough to satisfy all
dependencies on it. But avoid exposing more than one instance: I don't
think you are guaranteed to get the right one (i.e., the one that got
registered first)


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#80061): https://edk2.groups.io/g/devel/message/80061
Mute This Topic: https://groups.io/mt/85272566/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-