hmm_range_fault() will succeed for any kind of device private memory, even if it doesn't belong to the calling entity. While nouveau has some crude checks for that, they are broken because they assume nouveau is the only user of device private memory. Fix this by passing in an expected pgmap owner in the hmm_range_fault structure. If a device_private page is found and doesn't match the owner then it is treated as an non-present and non-faultable page. This prevents a bug in amdgpu, where it doesn't know how to handle device_private pages, but hmm_range_fault would return them anyhow.
Showing the changes to include/linux (1 of 3 files). Show all
Unified · Split
| @@ -132,6 +132,7 @@ enum hmm_pfn_value_e { · 131 unmodified lines | ||
| 132 | 132 | * @pfn_flags_mask: allows to mask pfn flags so that only default_flags matter |
| 133 | 133 | * @pfn_shifts: pfn shift value (should be <= PAGE_SHIFT) |
| 134 | 134 | * @valid: pfns array did not change since it has been fill by an HMM function |
| 135 | + * @dev_private_owner: owner of device private pages | |
| 135 | 136 | */ |
| 136 | 137 | struct hmm_range { |
| 137 | 138 | struct mmu_interval_notifier *notifier; |
| @@ -144,6 +145,7 @@ struct hmm_range { · 6 unmodified lines | ||
| 144 | 145 | uint64_t default_flags; |
| 145 | 146 | uint64_t pfn_flags_mask; |
| 146 | 147 | uint8_t pfn_shift; |
| 148 | + void *dev_private_owner; | |
| 147 | 149 | }; |
| 148 | 150 | |
| 149 | 151 | /* |