Page MenuHomeFreeBSD

linuxkpi: honor the prot argument in vmap
Needs ReviewPublic

Authored by ashafer on Fri, Sep 4, 11:24 PM.
Tags
None
Referenced Files
F170657364: D59436.diff
Sat, Sep 5, 8:42 PM
F170614637: D59436.id185902.diff
Sat, Sep 5, 3:52 PM
F170571944: D59436.id.diff
Sat, Sep 5, 11:23 AM
F170537755: D59436.id185902.diff
Sat, Sep 5, 7:32 AM
F170518738: D59436.id.diff
Sat, Sep 5, 5:15 AM

Details

Reviewers
None
Group Reviewers
linuxkpi
Summary

This adds missing support to the vmap function to respect what the user
requested via the prot argument. This matches what we do for
linuxkpi_vmap_pfn. We create a memattr from the passed in prot and apply
it to all mapped pages. This also updates vunmap to clear any
non-default memattrs that are set before we return the page to the
vm_page allocator.

We hit this in the wild with drm-kmod, specifically when the i915 driver
tries to initialize firmware. The firmware is supposed to be mapped as
write combined but doesn't due to us not honoring prot, which goes on to
fail due to the memory not being visible to the GPU properly.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76556
Build 73439: arc lint + arc unit

Event Timeline

I found that this was needed for the GT1 hardware unit to come up with GuC firmware enabled on meteorlake

I found that this was needed for the GT1 hardware unit to come up with GuC firmware enabled on meteorlake

Can you tell us in which version and possibly where the code (argument) comes from?
I am trying to understand how this is supposed to work but cannot find many PAGE_* definitions (well PAGE_KERNEL[_IO]) in LinuxKPI.

sys/compat/linuxkpi/common/src/linux_page.c
426

We should probably fix the prot argument type as well into something resembling "unsigned long" or uint64_t, like pgprot_t.
I am not sure if it matters for LinuxKPI given vm_memattr_t is a char, but for "correctness".
Probably a separate commit?