Skip to content

MsvmPkg/AARCH64: Switch to ARM architectural timers#86

Merged
jstarks merged 1 commit into
microsoft:mainfrom
jstarks:arm_arch
Jun 30, 2026
Merged

MsvmPkg/AARCH64: Switch to ARM architectural timers#86
jstarks merged 1 commit into
microsoft:mainfrom
jstarks:arm_arch

Conversation

@jstarks

@jstarks jstarks commented Jun 16, 2026

Copy link
Copy Markdown
Member

Replace Hyper-V synthetic timer components with ARM architectural equivalents on AARCH64:

  • TimerLib: HvTimerLib -> ArmArchTimerLib (uses CNTVCT_EL0/CNTFRQ_EL0)
  • Timer DXE: SynicTimerDxe -> ArmPkg/Drivers/TimerDxe (generic timer + GIC)
  • ArmGenericTimerCounterLib: promoted from DxeMain-only to global

This eliminates an unnecessary Hyper-V dependency. This is a prereq for using mu_msvm without Hyper-V enlightenments.

We still use the synthetic timer infrastructure on x64, since we still support machines without invariant TSC, and Hyper-V has no other efficient invariant time source except hypervisor reference time.

@mebersol

Copy link
Copy Markdown
Collaborator

How do you feel about alphabetization?

gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|29
gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|19
gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|20
gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum|21

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Copilot] PcdArmArchTimerHypIntrNum|21 is non-zero, so ArmPkg/Drivers/TimerDxe will call RegisterInterruptSource() for the EL2/hyp timer PPI and ASSERT_EFI_ERROR() on failure (see TimerInitialize() in ArmPkg/Drivers/TimerDxe/TimerDxe.c). The driver's own comment notes "The hypervisor timer interrupt may be omitted by implementations that execute under virtualization."

For a non-nested guest, UEFI runs at EL1, so the hyp timer register (CNTHP_EL2) isn't accessible and Hyper-V wouldn't deliver PPI 21 to firmware — suggesting this should be 0.

But this matters specifically for the ARM64 nested case: when mu_msvm runs as the L1 hypervisor's firmware, the guest does have EL2, and the EL2 timer PPI may actually be delivered. So the correct value is environment-dependent.

Two questions:

  1. In the non-nested (EL1-only) configuration, does Hyper-V actually deliver PPI 21? If not, hardcoding 21 risks a boot-time ASSERT — should it be 0?
  2. If the intent is to support both nested and non-nested with one DSC, is 21 guaranteed safe in both? It'd be worth a comment here documenting the EL1-vs-EL2 assumption so the value isn't silently wrong when the nested-ness changes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaykrell FYI

@jstarks

jstarks commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

How do you feel about alphabetization?

I knew you'd say that, which is one reason this is a draft.

@jaykrell

Copy link
Copy Markdown
Member

I like alphabetization. :)

since we still support machines without invariant TSC

Really? I mean, isn't this going back like 15+ years?

Replace Hyper-V synthetic timer components with ARM architectural
equivalents on AARCH64:

- TimerLib: HvTimerLib -> ArmArchTimerLib (uses CNTVCT_EL0/CNTFRQ_EL0)
- Timer DXE: SynicTimerDxe -> ArmPkg/Drivers/TimerDxe (generic timer + GIC)
- ArmGenericTimerCounterLib: promoted from DxeMain-only to global

This eliminates an unnecessary Hyper-V dependency. This is a prereq
for using mu_msvm without Hyper-V enlightenments.

We still use the synthetic timer infrastructure on x64, since we still
support machines without invariant TSC, and Hyper-V has no other
efficient invariant time source except hypervisor reference time.
@jstarks jstarks marked this pull request as ready for review June 19, 2026 00:44
@jstarks

jstarks commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

since we still support machines without invariant TSC

Really? I mean, isn't this going back like 15+ years?

Yeah, I hear you. I think we could at least conditionally use architectural timers on x64. I just don't have a pressing need to take that on.

@chris-oo chris-oo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat, no objections here.

@jstarks jstarks merged commit 62407fa into microsoft:main Jun 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants