Re: [PATCH] x86/kaslr: P2PDMA is one of a class of ZONE_DEVICE-KASLR collisions

Dave Hansen
2025-12-01T17:39:34Z

The subject probably wants to be something along the lines of:

x86/kaslr: Recognize all ZONE_DEVICE users as physaddr consumers

On 11/7/25 18:32, Dan Williams wrote:
> Commit 7ffb791423c7 ("x86/kaslr: Reduce KASLR entropy on most x86 systems")
> is too narrow. ZONE_DEVICE, in general, lets any physical address be added
> to the direct-map. I.e. not only ACPI hotplug ranges, CXL Memory Windows,
> or EFI Specific Purpose Memory, but also any PCI MMIO range for the
> CONFIG_DEVICE_PRIVATE and CONFIG_PCI_P2PDMA cases.

This should probably also mention the fact that:

config PCI_P2PDMA
depends on ZONE_DEVICE

It would also be nice to point out how the "too narrow" check had an
impact on real ZONE_DEVICE but !PCI_P2PDMA users. This isn't just a
theoretical problem, right?

> A potential path to recover entropy would be to walk ACPI and determine the
> limits for hotplug and PCI MMIO before kernel_randomize_memory(). On
> smaller systems that could yield some KASLR address bits. This needs
> additional investigation to determine if some limited ACPI table scanning
> can happen this early without an open coded solution like
> arch/x86/boot/compressed/acpi.c needs to deploy.

Yeah, a more flexible runtime solution would be highly preferred over
the existing solution built around config options. But this is really
orthogonal to the bug fix here.

With the changelog fixes above:

Acked-by: Dave Hansen <dave.hansen@linux.intel.com>

Oh, and does this need to be cc:stable@?