From: "Leif Lindholm" <quic_llindhol@quicinc.com>
To: <devel@edk2.groups.io>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Sami Mujawar <sami.mujawar@arm.com>
Subject: [edk2-devel] [PATCH 2/2] ArmVirtPkg: handle virtual EL2 timer in DT
Date: Tue, 19 Sep 2023 12:20:15 +0100 [thread overview]
Message-ID: <20230919112015.229479-3-quic_llindhol@quicinc.com> (raw)
In-Reply-To: <20230919112015.229479-1-quic_llindhol@quicinc.com>
FEAT_VHE, introduced in ARMv8.1, adds a virtual EL2 timer.
However, this library verifies that exactly 3 or 4 12-byte timer
interrupts are provided in input DT, ASSERTing when the new timer
is added.
Change the assert to >= 36.
Extend the current logic, also initializing PcdArmArchTimerHypVirtIntrNum
if 5 interrupts are provided.
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
---
ArmVirtPkg/ArmVirtQemu.dsc | 1 +
ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf | 1 +
ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c | 13 +++++++++----
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 1e0225951aef..30e3cfc8b9cc 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -253,6 +253,7 @@ [PcdsDynamicDefault.common]
gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0
gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0
gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum|0x0
+ gArmTokenSpaceGuid.PcdArmArchTimerHypVirtIntrNum|0x0
#
# ARM General Interrupt Controller
diff --git a/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf b/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
index 9e6f6f63a5a2..f8fc013700ad 100644
--- a/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
+++ b/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf
@@ -40,6 +40,7 @@ [Pcd]
gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
+ gArmTokenSpaceGuid.PcdArmArchTimerHypVirtIntrNum
[Depex]
gFdtClientProtocolGuid
diff --git a/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c b/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c
index 38dd6c533329..3b8491525eb3 100644
--- a/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c
+++ b/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c
@@ -34,7 +34,8 @@ ArmVirtTimerFdtClientLibConstructor (
FDT_CLIENT_PROTOCOL *FdtClient;
CONST INTERRUPT_PROPERTY *InterruptProp;
UINT32 PropSize;
- INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum;
+ INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum,
+ HypVirtIntrNum;
RETURN_STATUS PcdStatus;
Status = gBS->LocateProtocol (
@@ -66,10 +67,10 @@ ArmVirtTimerFdtClientLibConstructor (
}
//
- // - interrupts : Interrupt list for secure, non-secure, virtual and
- // hypervisor timers, in that order.
+ // - interrupts : Interrupt list for secure, non-secure, virtual,
+ // hypervisor and hypervisor virtual timers, in that order.
//
- ASSERT (PropSize == 36 || PropSize == 48);
+ ASSERT (PropSize >= 36);
SecIntrNum = SwapBytes32 (InterruptProp[0].Number)
+ (InterruptProp[0].Type ? 16 : 0);
@@ -79,6 +80,8 @@ ArmVirtTimerFdtClientLibConstructor (
+ (InterruptProp[2].Type ? 16 : 0);
HypIntrNum = PropSize < 48 ? 0 : SwapBytes32 (InterruptProp[3].Number)
+ (InterruptProp[3].Type ? 16 : 0);
+ HypVirtIntrNum = PropSize < 60 ? 0 : SwapBytes32 (InterruptProp[4].Number)
+ + (InterruptProp[4].Type ? 16 : 0);
DEBUG ((
DEBUG_INFO,
@@ -97,6 +100,8 @@ ArmVirtTimerFdtClientLibConstructor (
ASSERT_RETURN_ERROR (PcdStatus);
PcdStatus = PcdSet32S (PcdArmArchTimerHypIntrNum, HypIntrNum);
ASSERT_RETURN_ERROR (PcdStatus);
+ PcdStatus = PcdSet32S (PcdArmArchTimerHypVirtIntrNum, HypVirtIntrNum);
+ ASSERT_RETURN_ERROR (PcdStatus);
return EFI_SUCCESS;
}
--
2.30.2
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108825): https://edk2.groups.io/g/devel/message/108825
Mute This Topic: https://groups.io/mt/101453750/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-09-19 11:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-19 11:20 [edk2-devel] [PATCH 0/2] ArmPkg/ArmVirtPkg: handle FEAT_VHE NS-EL2 virtual timer Leif Lindholm
2023-09-19 11:20 ` [edk2-devel] [PATCH 1/2] ArmPkg: add EL2 virtual timer interrupt Pcd Leif Lindholm
2023-09-19 11:20 ` Leif Lindholm [this message]
2023-09-19 13:18 ` [edk2-devel] [PATCH 0/2] ArmPkg/ArmVirtPkg: handle FEAT_VHE NS-EL2 virtual timer Peter Maydell
2023-09-19 15:19 ` Leif Lindholm
2023-09-19 15:31 ` Peter Maydell
2023-09-19 20:43 ` Leif Lindholm
2023-09-19 14:13 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230919112015.229479-3-quic_llindhol@quicinc.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox