xref: /linux/rust/helpers/mm.c (revision 00c010e130e58301db2ea0cec1eadc931e1cb8cf)
15bb9ed6cSAlice Ryhl // SPDX-License-Identifier: GPL-2.0
25bb9ed6cSAlice Ryhl 
35bb9ed6cSAlice Ryhl #include <linux/mm.h>
45bb9ed6cSAlice Ryhl #include <linux/sched/mm.h>
55bb9ed6cSAlice Ryhl 
rust_helper_mmgrab(struct mm_struct * mm)65bb9ed6cSAlice Ryhl void rust_helper_mmgrab(struct mm_struct *mm)
75bb9ed6cSAlice Ryhl {
85bb9ed6cSAlice Ryhl 	mmgrab(mm);
95bb9ed6cSAlice Ryhl }
105bb9ed6cSAlice Ryhl 
rust_helper_mmdrop(struct mm_struct * mm)115bb9ed6cSAlice Ryhl void rust_helper_mmdrop(struct mm_struct *mm)
125bb9ed6cSAlice Ryhl {
135bb9ed6cSAlice Ryhl 	mmdrop(mm);
145bb9ed6cSAlice Ryhl }
155bb9ed6cSAlice Ryhl 
rust_helper_mmget(struct mm_struct * mm)165bb9ed6cSAlice Ryhl void rust_helper_mmget(struct mm_struct *mm)
175bb9ed6cSAlice Ryhl {
185bb9ed6cSAlice Ryhl 	mmget(mm);
195bb9ed6cSAlice Ryhl }
205bb9ed6cSAlice Ryhl 
rust_helper_mmget_not_zero(struct mm_struct * mm)215bb9ed6cSAlice Ryhl bool rust_helper_mmget_not_zero(struct mm_struct *mm)
225bb9ed6cSAlice Ryhl {
235bb9ed6cSAlice Ryhl 	return mmget_not_zero(mm);
245bb9ed6cSAlice Ryhl }
255bb9ed6cSAlice Ryhl 
rust_helper_mmap_read_lock(struct mm_struct * mm)265bb9ed6cSAlice Ryhl void rust_helper_mmap_read_lock(struct mm_struct *mm)
275bb9ed6cSAlice Ryhl {
285bb9ed6cSAlice Ryhl 	mmap_read_lock(mm);
295bb9ed6cSAlice Ryhl }
305bb9ed6cSAlice Ryhl 
rust_helper_mmap_read_trylock(struct mm_struct * mm)315bb9ed6cSAlice Ryhl bool rust_helper_mmap_read_trylock(struct mm_struct *mm)
325bb9ed6cSAlice Ryhl {
335bb9ed6cSAlice Ryhl 	return mmap_read_trylock(mm);
345bb9ed6cSAlice Ryhl }
355bb9ed6cSAlice Ryhl 
rust_helper_mmap_read_unlock(struct mm_struct * mm)365bb9ed6cSAlice Ryhl void rust_helper_mmap_read_unlock(struct mm_struct *mm)
375bb9ed6cSAlice Ryhl {
385bb9ed6cSAlice Ryhl 	mmap_read_unlock(mm);
395bb9ed6cSAlice Ryhl }
40040f404bSAlice Ryhl 
rust_helper_vma_lookup(struct mm_struct * mm,unsigned long addr)41040f404bSAlice Ryhl struct vm_area_struct *rust_helper_vma_lookup(struct mm_struct *mm,
42040f404bSAlice Ryhl 					      unsigned long addr)
43040f404bSAlice Ryhl {
44040f404bSAlice Ryhl 	return vma_lookup(mm, addr);
45040f404bSAlice Ryhl }
46*3105f8f3SAlice Ryhl 
rust_helper_vma_end_read(struct vm_area_struct * vma)47*3105f8f3SAlice Ryhl void rust_helper_vma_end_read(struct vm_area_struct *vma)
48*3105f8f3SAlice Ryhl {
49*3105f8f3SAlice Ryhl 	vma_end_read(vma);
50*3105f8f3SAlice Ryhl }
51