HomeFreeBSD

x86/xen: use UNUSABLE e820 regions for external mappings

Description

x86/xen: use UNUSABLE e820 regions for external mappings

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
Differential revision: https://reviews.freebsd.org/D46123

Details

Provenance
roygerAuthored on Feb 15 2024, 10:42 AM
Differential Revision
D46123: x86/xen: use UNUSABLE e820 regions for external mappings
Parents
rGbaa006f34227: xen: introduce a per-arch scratch mapping ranges
Branches
Unknown
Tags
Unknown