History

mm/hmm: check the device private page owner in hmm_range_fault()

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.

Christoph Hellwig committed 6 years ago

Commit 08ddddd1 parent 17ffdc43 files · +11 −13Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/hmm.h+2−0
@@ -132,6 +132,7 @@ enum hmm_pfn_value_e { · 131 unmodified lines
132 * @pfn_flags_mask: allows to mask pfn flags so that only default_flags matter132 * @pfn_flags_mask: allows to mask pfn flags so that only default_flags matter
133 * @pfn_shifts: pfn shift value (should be <= PAGE_SHIFT)133 * @pfn_shifts: pfn shift value (should be <= PAGE_SHIFT)
134 * @valid: pfns array did not change since it has been fill by an HMM function134 * @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 */
136struct hmm_range {137struct hmm_range {
137 struct mmu_interval_notifier *notifier;138 struct mmu_interval_notifier *notifier;
@@ -144,6 +145,7 @@ struct hmm_range { · 6 unmodified lines
144 uint64_t default_flags;145 uint64_t default_flags;
145 uint64_t pfn_flags_mask;146 uint64_t pfn_flags_mask;
146 uint8_t pfn_shift;147 uint8_t pfn_shift;
148 void *dev_private_owner;
147};149};
148 150
149/*151/*