lkml.org 
[lkml]   [2023]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] mmu_notifiers: Notify on pte permission upgrades
From


On 2023/5/22 15:45, Alistair Popple wrote:
>
> Qi Zheng <qi.zheng@linux.dev> writes:
>
>> Hi Alistair,
>>
>> On 2023/5/22 14:37, Alistair Popple wrote:
>
> [...]
>
>>> + if (changed) {
>>> + struct mmu_notifier_range range;
>>> +
>>> + mmu_notifier_range_init(&range, MMU_NOTIFY_PROTECTION_UPGRADE,
>>> + 0, vmf->vma, vmf->vma->vm_mm,
>>> + vmf->address & PAGE_MASK,
>>> + (vmf->address & PAGE_MASK) + PAGE_SIZE);
>>> + mmu_notifier_invalidate_range_start(&range);
>>> + mmu_notifier_invalidate_range_end(&range);
>>> + }
>>
>> There are four similar patterns, can we introduce a helper function to
>> deduplicate them?
>
> For sure. How about something like this?
>
> void mmu_notifier_range_start_end(enum mmu_notifier_event event,
> struct vm_area_struct *vma,
> struct mm_struct *mm,
> unsigned long start,
> unsigned long end)

LGTM. :)

>
> As an aside I didn't just use mmu_notifier_invalidate_range() as that
> doesn't allow an event type to be set for interval notifiers which may
> want to filter this.
>
>>> +
>>> return 0;
>>> }
>>>
>

--
Thanks,
Qi

\
 
 \ /
  Last update: 2023-05-22 10:30    [W:0.055 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site