Skip to content

OvmfPkg/OvmfXen: Switch timer library to support x2APIC mode#12322

Open
d3athjest3r wants to merge 1 commit intotianocore:masterfrom
d3athjest3r:new_timer_lib
Open

OvmfPkg/OvmfXen: Switch timer library to support x2APIC mode#12322
d3athjest3r wants to merge 1 commit intotianocore:masterfrom
d3athjest3r:new_timer_lib

Conversation

@d3athjest3r
Copy link
Copy Markdown

@d3athjest3r d3athjest3r commented Mar 23, 2026

Description

The SecPeiDxeTimerLibCpu library from the MdePkg accesses the Local APIC timer exclusively via MMIO and explicitly asserts that x2APIC mode is not enabled. This causes failures when vCPUs are pre-enabled in x2APIC mode, which might be necessary for domains with more than 128 vCPUs. So, this commit switches the TimerLib to SecPeiDxeTimerLibUefiCpu from the UefiCpuPkg, which delegates APIC mode handling to the LocalApicLib. OvmfXen already uses BaseXApicX2ApicLib as its LocalApicLib, which transparently supports both xAPIC (MMIO) and x2APIC (MSR) modes.

new PR based on: #12148

@tperard : I have addressed your comment, and fixed the commit message.

How This Was Tested

Tested with a PVH VM, with the following parameters:

type='pvh'
kernel='/usr/share/edk2/OVMF-debug.fd'

memory = 3072
vcpus = 4
sdl = 0
vnc = 0
serial='pty'
name = "ovmf"
disk = [
## This line works in OVMF, but Linux will not look at CDROM over PV interface
  '/mnt/debian-live-12.4.0-amd64-standard.iso,,hdc,cdrom',
## This works for both Linux and OVMF, and archlinux ISO can boot.
  '/mnt/debian-live-12.4.0-amd64-standard.iso,,hdd,r',
]
on_reboot = 'destroy'

and xl create -c foo.pvh. I see OVMF booting properly. Although I don't see my Linux booting afterwards. I think there is an issue with disk command? It then jumps into the EDKII menu and BIOS settings. It doesn't fail with an error with the timer driver or so. So, I think we should be good for PVH as well.

Integration Instructions

n/a

The SecPeiDxeTimerLibCpu library from the MdePkg accesses the Local APIC
timer exclusively via MMIO and explicitly asserts that x2APIC mode is
not enabled. This causes failures when vCPUs are pre-enabled in x2APIC
mode, which might be necessary for domains with more than 128 vCPUs.
So, this commit switches the TimerLib to SecPeiDxeTimerLibUefiCpu from
the UefiCpuPkg, which delegates APIC mode handling to the LocalApicLib.
OvmfXen already uses BaseXApicX2ApicLib as its LocalApicLib, which
transparently supports both xAPIC (MMIO) and x2APIC (MSR) modes.

Signed-off-by: Julian Vetter <julian.vetter@vates.tech>
@tianocore-pr-automation
Copy link
Copy Markdown

Pull Request Formatting Issues

⚠️ Remove the following template lines from your PR description:
<_Include a description of the change and why this change was made._>
<_For each item, place an "x" in between [and]if true. Example:[x] (you can also check items in GitHub UI)_>
<_Create the PR as a Draft PR if it is only created to run CI checks._>
<_Delete lines in \<\> tags before creating the PR._>
<_Describe the test(s) that were run to verify the changes._>
<_Describe how these changes should be integrated. Use N/A if nothing is required._>

Address these issues and the validation will automatically re-run when you update your pull request.

@ardbiesheuvel
Copy link
Copy Markdown
Member

Please close this PR and use #12148 to upload new versions of your changes.

@d3athjest3r
Copy link
Copy Markdown
Author

Please close this PR and use #12148 to upload new versions of your changes.

Sorry, I can't. I have deleted the old repo, so it automatically closed the pull request. I had to re-fork the repo and open a new PR.

@ardbiesheuvel ardbiesheuvel added the push Auto push patch series in PR if all checks pass label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

push Auto push patch series in PR if all checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants