Skip to content

feat: add hypercall to query ECAM base - #377

Merged
Solicey merged 1 commit into
syswonder:devfrom
yydawx:ecam-dynamic-prob
Aug 10, 2026
Merged

Solicey merged 1 commit into
syswonder:devfrom
yydawx:ecam-dynamic-prob

Conversation

@yydawx

@yydawx yydawx commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

ECAM base can differ across x86_64 devices. hvisor already parses ACPI MCFG, but hvisor-tool needs a way to obtain the correct base before constructing the zone configuration.

Changes

  • src/hypercall/mod.rs: add HvGetEcamBase = 9 hypercall and dispatch it.
  • src/arch/x86_64/hypercall.rs: implement hv_get_ecam_base() to write the ACPI MCFG ECAM base into the caller-provided address.
  • aarch64/riscv64/loongarch64 hypercall files: add a no-op handler returning 0 so the shared hypercall dispatch compiles.

hvisor-tool

hvisor-tool queries this hypercall before starting a zone and overrides pci_config[0].ecam_base. See syswonder/hvisor-tool#115.

Verification

  • hvisor x86_64 build passes.
  • Tested with zone JSON ecam_base=0x12345000; hvisor receives 0xe0000000 after hvisor-tool correction, Asterinas starts and the shell responds to echo ci-ok.

@github-actions github-actions Bot added x86_64 feature New feature or request labels Aug 9, 2026
@Solicey

Solicey commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

We'd better not called apply_dynamic_ecam inside hv_zone_start, because it is a x86-specific function. (We are avoiding things like #[cfg(target_arch = "x86_64")] in shared functions). It might be a good idea to call this function in hvisor-tool. You can add a new hyper-code such as HvGetEcamBase, and a hypercall function which gives hvisor-tool the correct ecam base. Then, hvisor-tool can correct this address and pass it to hvisor.

@yydawx
yydawx force-pushed the ecam-dynamic-prob branch from 71fc6e6 to 6aa5338 Compare August 10, 2026 02:04
@yydawx yydawx changed the title feat(x86_64): probe ECAM base from ACPI MCFG for non-root zones feat(x86_64): add hypercall to query ECAM base Aug 10, 2026
@yydawx

yydawx commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I updated the implementation to follow your suggestion:

  • Removed apply_dynamic_ecam from the shared hv_zone_start path.
  • Added an HvGetEcamBase hypercall that lets hvisor-tool query the ACPI MCFG ECAM base.
  • hvisor-tool now queries this hypercall before starting a zone and overrides pci_config[0].ecam_base.

Related hvisor-tool PR: syswonder/hvisor-tool#115.

Verification: with zone JSON ecam_base=0x12345000, hvisor receives 0xe0000000 after the hvisor-tool correction, and Asterinas boots to the shell.

@yydawx yydawx changed the title feat(x86_64): add hypercall to query ECAM base feat: add hypercall to query ECAM base Aug 10, 2026
@Solicey
Solicey merged commit d780faa into syswonder:dev Aug 10, 2026
25 checks passed
agicy pushed a commit that referenced this pull request Aug 24, 2026
feat: add hypercall to query ECAM base
agicy pushed a commit that referenced this pull request Aug 24, 2026
feat: add hypercall to query ECAM base
@yydawx
yydawx deleted the ecam-dynamic-prob branch September 28, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants