Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ASL compiler support (ACPI) #199

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

shchuko
Copy link
Contributor

@shchuko shchuko commented Oct 5, 2020

Closes #198

There's no pre-installed iasl compiler under macOS (unlike freebsd). This series of changes adds iasl compiler support. I've found that ACPICA tools can be built under macOS, so its iasl compiler can be given to xhyve to build ACPI Tables. Backward compatibility is saved.

Changes overview:

  • ACPI building method can be chosen at runtime (callbacks used):
    • without -a <iasl/compiler/path> option xhyve uses an old method with copying precompiled ACPI to guest mem
    • with -a <iasl/compiler/path> option xhyve uses given asl compiler to build tables
  • applied updates to catch up with the newest stable ACPICA 2020052
  • MADT table correction applied (VM_MAXCPU > 21 now supported) freebsd/freebsd-src@5822161

ASL compiler will be used to build ACPI tables at runtime
We'll switch between precompiled AMLs (used now) and runtime-compiling
ACPI when starting xhyve. 'acpi.c' and 'acpitbl.c' have same acpi
tables offsets definitions. To prevent problems in future and partly
save compatibility with bhyve sources, rename definitios in 'acpitbl.c'
Since this moment we're assuming that ACPI tables build method will be
chosen at runtime.

If ASL compiler path specified - building ACPI tables using it, if not
- building them from existing AMLs
Wrapping functions with callbacks let us choose at runtime how the
tables should be built: using precompiled AMLs or using ASL compiler.

ASL-compiling method is gonna be updated, it doesn't work properly now
The bhyve acpi MADT table was given a static space of 256 (0x100) bytes,
this is enough space to allow VM_MAXCPU to be 21, this patch changes
that so VM_MAXCPU can be of arbitrary value and not overflow the space
by actually calculating the space needed for the table.

Based on freebsd/freebsd-src@5822161
@shchuko shchuko mentioned this pull request Feb 2, 2021
adaugherity added a commit to adaugherity/xhyve that referenced this pull request Jan 25, 2022
@adaugherity
Copy link
Contributor

So, I decided to try this out, and got in way deeper than intended, and have some findings.
Disclaimer: speaking as a fellow user -- I am not an xhyve developer.

This seems like a good addition, although I'm unclear when it would be needed and how to fully make use of it. Does this let you add new ACPI tables or modify the built-in ones without recompiling? If so, please add an explanation to the man page.

Speaking of which, the man page should be updated to list this option. I'll point out that -a is already used for something different in bhyve, so might it be wise to pick a different option? Personally, I would leave a compiled in default path (e.g. /usr/local/bin/iasl); it could be easily overridden by building with -DBHYVE_ASL_COMPILER=...). Then the path could be optional, i.e. xhyve [ -a [ /path/to/iasl ] ].

Some minor issues:

  • The code as it presently is does not build with make -- missing function prototypes and undefined symbols when linking, but those errors are easily fixed, as I've done in my repo.

  • When running a VM with this option, the tables as seen by the VM are the same as without it, but I guess that is to be expected? I do receive a warning from iasl:

/tmp/bhyve.FIp4RNN     19:     Device (PC00)
Warning  3073 -           Multiple types ^  (Device object requires either a _HID or _ADR, but not both)

I have no idea what this means, but it appears to be a problem with the DSDT table supplied by xhyve.

  • Style nit: your dsdt_fixup() definition has the opening brace on the same line, but it appears this project uses brace on a new line for functions.

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.

Use ASL compiler to build ACPI Tables
2 participants