Page MenuHomeFreeBSD

x86/xen: use UNUSABLE e820 regions for external mappings
ClosedPublic

Authored by royger on Jul 25 2024, 10:48 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 9, 3:12 AM
Unknown Object (File)
Nov 16 2024, 12:03 PM
Unknown Object (File)
Nov 14 2024, 2:41 AM
Unknown Object (File)
Nov 3 2024, 12:10 PM
Unknown Object (File)
Oct 9 2024, 10:01 AM
Unknown Object (File)
Oct 9 2024, 10:01 AM
Unknown Object (File)
Oct 9 2024, 10:01 AM
Unknown Object (File)
Oct 9 2024, 9:29 AM
Subscribers

Details

Summary

Using holes in the memory map to create external mappings (for example grants
or foreign maps) can be dangerous, as the guest might not have enough knowledge
of whether such holes are maybe MMIO of some devices.

Workaround this by using UNUSABLE e820 ranges as scratch space for external
mappings. The e820 memory map provided to dom0 is based on the native one, but
since PVH dom0 uses second stage translation, the UNUSABLE ranges on the host
memory map doesn't affect it, and we can also guarantee no device MMIO uses
those.

Additionally, any RAM in the e820 not available to dom0 because dom0
memory has been limited on the command line, or because those are in use by
Xen, are converted to UNUSABLE in the dom0 memory map.

Note that domU don't usually have UNUSABLE ranges in their memory maps, and
hence the logic introduced here won't help in avoiding conflicts with MMIO
regions. However the usage of external mappings on domUs is in general
limited, and the logic introduced here simply won't be helpful to them, but
won't regress the current state.

Sponsored by: Cloud Software Group
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Seems fine, though as this is x86-land so I'm not doing testing. I do strongly prefer this being a separate commit from D46122 as it now is.

sys/x86/xen/hvm.c
573

When I initially noticed this delta I was worried. Since is in sys/x86/xen/hvm.c this is fine though.

Thanks for taking a look. I will push this together with the generic part.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 30 2024, 7:57 AM
This revision was automatically updated to reflect the committed changes.