From 10b16da16a0a8f8c40e998cf6ded457e0f7691e2 Mon Sep 17 00:00:00 2001 From: Min Xu Date: Thu, 18 Mar 2021 22:05:58 +0800 Subject: [PATCH] OvmfPkg: Disable 8254/8259 timer in Td guest TODO: Add more description --- OvmfPkg/8254TimerDxe/8254Timer.inf | 1 + OvmfPkg/8254TimerDxe/Timer.c | 5 +++++ OvmfPkg/8259InterruptControllerDxe/8259.c | 4 ++++ OvmfPkg/8259InterruptControllerDxe/8259.inf | 1 + 4 files changed, 11 insertions(+) diff --git a/OvmfPkg/8254TimerDxe/8254Timer.inf b/OvmfPkg/8254TimerDxe/8254Timer.inf index 8a07c8247ebe9..007e3f405c0ab 100644 --- a/OvmfPkg/8254TimerDxe/8254Timer.inf +++ b/OvmfPkg/8254TimerDxe/8254Timer.inf @@ -26,6 +26,7 @@ DebugLib UefiDriverEntryPoint IoLib + TdxProbeLib [Sources] Timer.h diff --git a/OvmfPkg/8254TimerDxe/Timer.c b/OvmfPkg/8254TimerDxe/Timer.c index fd1691beb3c75..701cc65a303e0 100644 --- a/OvmfPkg/8254TimerDxe/Timer.c +++ b/OvmfPkg/8254TimerDxe/Timer.c @@ -7,6 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "Timer.h" +#include // // The handle onto which the Timer Architectural Protocol will be installed @@ -340,6 +341,10 @@ TimerDriverInitialize ( EFI_STATUS Status; UINT32 TimerVector; + if(ProbeTdGuest()) { + return EFI_UNSUPPORTED; + } + // // Initialize the pointer to our notify function. // diff --git a/OvmfPkg/8259InterruptControllerDxe/8259.c b/OvmfPkg/8259InterruptControllerDxe/8259.c index 1c2ac1039d403..94b7cb83c90e8 100644 --- a/OvmfPkg/8259InterruptControllerDxe/8259.c +++ b/OvmfPkg/8259InterruptControllerDxe/8259.c @@ -8,6 +8,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "8259.h" +#include // // Global for the Legacy 8259 Protocol that is produced by this driver // @@ -586,6 +587,9 @@ Install8259 ( EFI_STATUS Status; EFI_8259_IRQ Irq; + if(ProbeTdGuest()) { + return EFI_UNSUPPORTED; + } // // Initialze mask values from PCDs // diff --git a/OvmfPkg/8259InterruptControllerDxe/8259.inf b/OvmfPkg/8259InterruptControllerDxe/8259.inf index 7320ff2490a7d..09a4b41996af4 100644 --- a/OvmfPkg/8259InterruptControllerDxe/8259.inf +++ b/OvmfPkg/8259InterruptControllerDxe/8259.inf @@ -29,6 +29,7 @@ UefiDriverEntryPoint IoLib PcdLib + TdxProbeLib [Protocols] gEfiLegacy8259ProtocolGuid ## PRODUCES