Skip to content

Add APMT ACPI table support for guest uncore PMU#48

Open
Arvean-microsoft wants to merge 1 commit intomicrosoft:mainfrom
Arvean-microsoft:arveanlabib/apmt-support
Open

Add APMT ACPI table support for guest uncore PMU#48
Arvean-microsoft wants to merge 1 commit intomicrosoft:mainfrom
Arvean-microsoft:arveanlabib/apmt-support

Conversation

@Arvean-microsoft
Copy link
Copy Markdown

Add receive and install support for the ARM Performance Monitoring Table (APMT) in the guest UEFI firmware. This enables guest VMs to discover uncore PMU MMIO ranges when the host provides an APMT via the UEFI config blob.

Changes:

  • Add UefiConfigApmt (0x28) enum value and UEFI_CONFIG_APMT struct
  • Add ARM_ACPI_APMT_TABLE_SIGNATURE definition
  • Add PcdApmtPtr/PcdApmtSize PCDs (tokens 0x6073/0x6074)
  • Parse and validate APMT in PEI phase (Config.c)
  • Install APMT in DXE phase via AcpiInstallApmtTable()
  • Wire PCDs through both AARCH64 and X64 DSC/INF files

The APMT is optional: it is not added to requiredStructures, and the DXE installer gracefully skips when the table is absent. The parsing and installation follow the same pattern as IORT/PPTT/HMAT.

@Arvean-microsoft
Copy link
Copy Markdown
Author

@Arvean-microsoft please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@Arvean-microsoft
Copy link
Copy Markdown
Author

@Arvean-microsoft please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement
@microsoft-github-policy-service agree company="Microsoft"

@Arvean-microsoft Arvean-microsoft force-pushed the arveanlabib/apmt-support branch from d0990b1 to 0e0d24c Compare March 13, 2026 21:51
Add receive and install support for the ARM Performance Monitoring Table
(APMT) in the guest UEFI firmware. This enables guest VMs to discover
uncore PMU MMIO ranges when the host provides an APMT via the UEFI
config blob.

Changes:
- Add UefiConfigApmt (0x28) enum value and UEFI_CONFIG_APMT struct
- Add ARM_ACPI_APMT_TABLE_SIGNATURE definition
- Add PcdApmtPtr/PcdApmtSize PCDs (tokens 0x6073/0x6074)
- Parse and validate APMT in PEI phase (Config.c)
- Install APMT in DXE phase via AcpiInstallApmtTable()
- Wire PCDs through both AARCH64 and X64 DSC/INF files

The APMT is optional: it is not added to requiredStructures, and the
DXE installer gracefully skips when the table is absent. The parsing
and installation follow the same pattern as IORT/PPTT/HMAT.
Copy link
Copy Markdown
Collaborator

@mebersol mebersol left a comment

Choose a reason for hiding this comment

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

[Copilot] Overall this is a clean change that follows the established IORT/PPTT/HMAT pattern well. One thing to fix: the case UefiConfigApmt: block in Config.c needs braces { } around the body to match the adjacent cases and properly scope variable declarations. The other two comments are minor questions.

Comment on lines +1639 to +1653
case UefiConfigApmt:
UEFI_CONFIG_APMT *apmtStructure = (UEFI_CONFIG_APMT*) header;
EFI_ACPI_DESCRIPTION_HEADER *apmtHdr = (EFI_ACPI_DESCRIPTION_HEADER*) apmtStructure->Apmt;

if (apmtStructure->Header.Length < (sizeof(UEFI_CONFIG_HEADER) + sizeof(EFI_ACPI_DESCRIPTION_HEADER)) ||
apmtHdr->Signature != ARM_ACPI_APMT_TABLE_SIGNATURE ||
apmtHdr->Length > (apmtStructure->Header.Length - sizeof(UEFI_CONFIG_HEADER)))
{
DEBUG((DEBUG_ERROR, "*** Malformed APMT\n"));
FAIL_FAST_UNEXPECTED_HOST_BEHAVIOR();
}

PEI_FAIL_FAST_IF_FAILED(PcdSet64S(PcdApmtPtr, (UINT64)apmtStructure->Apmt));
PEI_FAIL_FAST_IF_FAILED(PcdSet32S(PcdApmtSize, apmtHdr->Length));
break;
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] The adjacent UefiConfigIort case (and others that declare local variables) wraps the body in { }:

case UefiConfigIort:
{
    UEFI_CONFIG_IORT *iortStructure = ...;
    ...
    break;
}

This case declares apmtStructure and apmtHdr without a compound statement. Please add braces for consistency and to properly scope the variable declarations.

Comment thread MsvmPkg/MsvmPkg.dec
gMsvmPkgTokenSpaceGuid.PcdIortSize|0x0|UINT32|0x6071

# UEFI_CONFIG_APMT
gMsvmPkgTokenSpaceGuid.PcdApmtPtr|0x0|UINT64|0x6073
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] Nit: IORT uses tokens 0x6070/0x6071. APMT jumps to 0x6073/0x6074, skipping 0x6072. Is this intentional (reserved for something else) or a typo? If intentional, a comment noting the reservation would help future readers.

Comment thread MsvmPkg/MsvmPkgX64.dsc
Comment on lines +560 to +562
gMsvmPkgTokenSpaceGuid.PcdApmtPtr|0x0
gMsvmPkgTokenSpaceGuid.PcdApmtSize|0x0

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] APMT is ARM-specific (ARM Performance Monitoring Table). Adding it to the X64 DSC is harmless since the host will never provide one and the installer gracefully skips when absent — but is this intentional for symmetry, or should the PCDs only be wired in the AARCH64 DSC?

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